blade-code 0.10.155 → 0.10.157
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blade.js +2 -2
- package/dist/{chunk-kg0mjdr8.js → chunk-04vy4a4a.js} +1 -1
- package/dist/{chunk-ad392pqj.js → chunk-1qp826p9.js} +1 -1
- package/dist/{chunk-8wdnzcxy.js → chunk-2nnrrfte.js} +1 -1
- package/dist/{chunk-phq6ejfh.js → chunk-3jqvgxnc.js} +1 -1
- package/dist/{chunk-bs99tz6h.js → chunk-46a6mzfg.js} +1 -1
- package/dist/chunk-4d6d5xtp.js +1 -0
- package/dist/{chunk-14s52tht.js → chunk-5h9q6jjv.js} +1 -1
- package/dist/{chunk-2sphbc7z.js → chunk-75n6cr3x.js} +1 -1
- package/dist/{chunk-8rpshvhq.js → chunk-7aysjqen.js} +1 -1
- package/dist/{chunk-x83b8ttr.js → chunk-7mqmyhfe.js} +1 -1
- package/dist/{chunk-h0ka760f.js → chunk-7r26xgk4.js} +1 -1
- package/dist/{chunk-5vdg6z0a.js → chunk-8bm5bpa2.js} +1 -1
- package/dist/{chunk-k678bgw3.js → chunk-8brsyfkz.js} +2 -2
- package/dist/{chunk-42gkes5k.js → chunk-96c1kd2j.js} +1 -1
- package/dist/{chunk-zvzdbv7a.js → chunk-9cfh48md.js} +1 -1
- package/dist/{chunk-ffmrt66h.js → chunk-9rx1axgj.js} +1 -1
- package/dist/{chunk-zz14c6h3.js → chunk-9svd1x6q.js} +1 -1
- package/dist/chunk-bfd4yt7c.js +1 -0
- package/dist/{chunk-yj3t8dd0.js → chunk-d6x9aqqp.js} +1 -1
- package/dist/{chunk-j470cdhj.js → chunk-eass9t33.js} +1 -1
- package/dist/{chunk-mqcmd414.js → chunk-ha8w887r.js} +1 -1
- package/dist/{chunk-27x9485f.js → chunk-j5fwzfaj.js} +1 -1
- package/dist/{chunk-b93y9nd6.js → chunk-m268099y.js} +1 -1
- package/dist/{chunk-3cyed1mn.js → chunk-nk1kfpz5.js} +3 -3
- package/dist/{chunk-4d0esqac.js → chunk-nmymd2hf.js} +1 -1
- package/dist/{chunk-mp1kckbw.js → chunk-p1d4ep58.js} +1 -1
- package/dist/{chunk-9fw3kwk5.js → chunk-pdfdj5rp.js} +1 -1
- package/dist/{chunk-nvyxejt7.js → chunk-ra0y5drh.js} +1 -1
- package/dist/{chunk-jcx2j7e0.js → chunk-rdvadyyt.js} +1 -1
- package/dist/{chunk-hv1bda16.js → chunk-s9ws4xsz.js} +1 -1
- package/dist/{chunk-559adewt.js → chunk-sr61gfha.js} +1 -1
- package/dist/{chunk-273kk0cn.js → chunk-tbg7yrwp.js} +1 -1
- package/dist/{chunk-pxc61k03.js → chunk-tfsmykk5.js} +1 -1
- package/dist/{chunk-qank9aj0.js → chunk-v25d7gze.js} +1 -1
- package/dist/{chunk-f06aknxh.js → chunk-w5awn40e.js} +1 -1
- package/dist/{chunk-xsd1pj8s.js → chunk-wax2788t.js} +1 -1
- package/dist/{chunk-gjbtr074.js → chunk-xqzmm1bf.js} +1 -1
- package/dist/{chunk-ja6d4r04.js → chunk-zqn8q1b6.js} +1 -1
- package/dist/web/assets/{ChatView-DhjLZ2OR.js → ChatView-D9Rgy4Xd.js} +17 -17
- package/dist/web/assets/{CodeBlockHighlighter-CYGqk6nC.js → CodeBlockHighlighter-D2xmVZ64.js} +1 -1
- package/dist/web/assets/{FilePreview-Cti4_C5N.js → FilePreview-DNvYgNjf.js} +1 -1
- package/dist/web/assets/{KanbanBoard-Ct16zVW3.js → KanbanBoard-DHsb2qNL.js} +1 -1
- package/dist/web/assets/{MarkdownRenderer-RfULWJEE.js → MarkdownRenderer-DaQIOCqh.js} +3 -3
- package/dist/web/assets/{ScrollArea-DzblNpCd.js → ScrollArea-CMTG2oYB.js} +1 -1
- package/dist/web/assets/{SessionHistorySurface-D3-0PA12.js → SessionHistorySurface-B5W8o5Ac.js} +1 -1
- package/dist/web/assets/SettingsModal-CoIGqfB8.js +20 -0
- package/dist/web/assets/{Sidebar-DgTGp3BO.js → Sidebar-Bp-rTtWG.js} +1 -1
- package/dist/web/assets/{TaskSwitcher-BVau39Em.js → TaskSwitcher-BHlCaj6w.js} +1 -1
- package/dist/web/assets/{TerminalPanel-N2fFhXPj.js → TerminalPanel-1SkToIB-.js} +1 -1
- package/dist/web/assets/{archive-DYlK7NlT.js → archive-VQ-zwIBp.js} +1 -1
- package/dist/web/assets/{arrow-left-DaRjPuTX.js → arrow-left-CNl5Vg6X.js} +1 -1
- package/dist/web/assets/{calendar-clock-UTpg6J58.js → calendar-clock-B_VagIW-.js} +1 -1
- package/dist/web/assets/{chevron-right-DW6hcYoH.js → chevron-right-rbUP1NBz.js} +1 -1
- package/dist/web/assets/{chevrons-up-down-D0BwYbw9.js → chevrons-up-down-DSWrXgFD.js} +1 -1
- package/dist/web/assets/{clock-3-DTmdPhfW.js → clock-3-B7G3JFdh.js} +1 -1
- package/dist/web/assets/{copy-3oxA5Cc-.js → copy-BSAC3Lqd.js} +1 -1
- package/dist/web/assets/{download-D1w7sCBV.js → download-Da_UuSK6.js} +1 -1
- package/dist/web/assets/{external-link-BHWE2Q9K.js → external-link-RaJbv6zJ.js} +1 -1
- package/dist/web/assets/{folder-y0Ib4FZ2.js → folder-BDc_dntN.js} +1 -1
- package/dist/web/assets/{index-D4bsP__r.js → index-Cqil5mhT.js} +4 -4
- package/dist/web/assets/{pause-dr9-0ZX_.js → pause-DcqIkSCj.js} +1 -1
- package/dist/web/assets/{pencil-BtXBcDA8.js → pencil-CuEcqcGd.js} +1 -1
- package/dist/web/assets/{play-CGxptupd.js → play-D-6oneXl.js} +1 -1
- package/dist/web/assets/{plus-DUJ7l4H3.js → plus-BszxRz9B.js} +1 -1
- package/dist/web/assets/{session-events-CGQa6VXb.js → session-events-Dwyp0AVI.js} +16 -14
- package/dist/web/assets/{settings-DFt3q7ma.js → settings-C2nXcRY-.js} +1 -1
- package/dist/web/assets/{team-C6IcokCI.js → team-CWZp-rb4.js} +1 -1
- package/dist/web/assets/{teamService-T8g5BXdN.js → teamService-Dyi2wFpb.js} +1 -1
- package/dist/web/assets/{terminal-DLip4ER9.js → terminal-ZQmTPaBq.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/dist/chunk-2yqar0hx.js +0 -1
- package/dist/chunk-42mh48fg.js +0 -1
- package/dist/web/assets/SettingsModal-j0PEfToT.js +0 -20
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownRenderer-
|
|
2
|
-
import{r as h,j as e}from"./vendor-react-DofNRwfy.js";import{c as X,u as B,a as f,s as ze,b as mt,d as de,H as $e,P as ht,G as qe,L as _,S as Ge,T as ne,C as ge,D as We,e as Je,f as xt,g as Ye,h as Xe,i as Ze,j as D,k as pt,l as ae,B as ft,m as Ce,n as me,R as fe,F as bt,_ as et,o as vt,p as tt,q as gt,r as st,t as kt,X as at,v as yt,A as Ae,w as jt,x as wt,W as Nt,y as St,z as Ct}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownRenderer-DaQIOCqh.js","assets/index-Cqil5mhT.js","assets/vendor-react-DofNRwfy.js","assets/vendor-radix-D6QrtXqd.js","assets/session-events-Dwyp0AVI.js","assets/index-RGoMvYl5.css","assets/copy-BSAC3Lqd.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as h,j as e}from"./vendor-react-DofNRwfy.js";import{c as X,u as B,a as f,s as ze,b as mt,d as de,H as $e,P as ht,G as qe,L as _,S as Ge,T as ne,C as ge,D as We,e as Je,f as xt,g as Ye,h as Xe,i as Ze,j as D,k as pt,l as ae,B as ft,m as Ce,n as me,R as fe,F as bt,_ as et,o as vt,p as tt,q as gt,r as st,t as kt,X as at,v as yt,A as Ae,w as jt,x as wt,W as Nt,y as St,z as Ct}from"./index-Cqil5mhT.js";import{_ as Re,M as ie,Z as K,a2 as Tt,A as Et,a3 as Mt,a4 as At,Q as Rt,X as Ft,Y as Dt}from"./session-events-Dwyp0AVI.js";import{A as It,E as $t}from"./external-link-RaJbv6zJ.js";import{S as _t}from"./ScrollArea-CMTG2oYB.js";import{C as rt}from"./copy-BSAC3Lqd.js";import{C as oe}from"./chevron-right-rbUP1NBz.js";import{A as Fe,a as Bt,C as Pt}from"./chevrons-up-down-DSWrXgFD.js";import{f as Lt,g as Ut,h as Ot,i as nt}from"./vendor-radix-D6QrtXqd.js";import{P as Kt}from"./pause-DcqIkSCj.js";import{P as Vt}from"./play-D-6oneXl.js";import{P as it}from"./pencil-CuEcqcGd.js";import{C as Ht}from"./clock-3-B7G3JFdh.js";import{t as U,A as _e}from"./team-CWZp-rb4.js";import{teamService as Be}from"./teamService-Dyi2wFpb.js";/**
|
|
3
3
|
* @license lucide-react v0.300.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
6
6
|
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/const
|
|
7
|
+
*/const Qt=X("Files",[["path",{d:"M15.5 2H8.6c-.4 0-.8.2-1.1.5-.3.3-.5.7-.5 1.1v12.8c0 .4.2.8.5 1.1.3.3.7.5 1.1.5h9.8c.4 0 .8-.2 1.1-.5.3-.3.5-.7.5-1.1V6.5L15.5 2z",key:"cennsq"}],["path",{d:"M3 7.6v12.8c0 .4.2.8.5 1.1.3.3.7.5 1.1.5h9.8",key:"ms809a"}],["path",{d:"M15 2v5h5",key:"qq6kwv"}]]);/**
|
|
8
8
|
* @license lucide-react v0.300.0 - ISC
|
|
9
9
|
*
|
|
10
10
|
* This source code is licensed under the ISC license.
|
|
11
11
|
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
-
*/const
|
|
12
|
+
*/const zt=X("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);/**
|
|
13
13
|
* @license lucide-react v0.300.0 - ISC
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the ISC license.
|
|
16
16
|
* See the LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/const
|
|
17
|
+
*/const qt=X("HelpCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
|
|
18
18
|
* @license lucide-react v0.300.0 - ISC
|
|
19
19
|
*
|
|
20
20
|
* This source code is licensed under the ISC license.
|
|
21
21
|
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
-
*/const
|
|
22
|
+
*/const Gt=X("ListOrdered",[["line",{x1:"10",x2:"21",y1:"6",y2:"6",key:"76qw6h"}],["line",{x1:"10",x2:"21",y1:"12",y2:"12",key:"16nom4"}],["line",{x1:"10",x2:"21",y1:"18",y2:"18",key:"u3jurt"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);/**
|
|
23
23
|
* @license lucide-react v0.300.0 - ISC
|
|
24
24
|
*
|
|
25
25
|
* This source code is licensed under the ISC license.
|
|
26
26
|
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
-
*/const
|
|
27
|
+
*/const Wt=X("LockKeyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]);/**
|
|
28
28
|
* @license lucide-react v0.300.0 - ISC
|
|
29
29
|
*
|
|
30
30
|
* This source code is licensed under the ISC license.
|
|
31
31
|
* See the LICENSE file in the root directory of this source tree.
|
|
32
|
-
*/const
|
|
32
|
+
*/const Jt=X("MessageCircleQuestion",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
|
|
33
33
|
* @license lucide-react v0.300.0 - ISC
|
|
34
34
|
*
|
|
35
35
|
* This source code is licensed under the ISC license.
|
|
36
36
|
* See the LICENSE file in the root directory of this source tree.
|
|
37
|
-
*/const
|
|
37
|
+
*/const Yt=X("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/**
|
|
38
38
|
* @license lucide-react v0.300.0 - ISC
|
|
39
39
|
*
|
|
40
40
|
* This source code is licensed under the ISC license.
|
|
41
41
|
* See the LICENSE file in the root directory of this source tree.
|
|
42
|
-
*/const
|
|
42
|
+
*/const Xt=X("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);/**
|
|
43
43
|
* @license lucide-react v0.300.0 - ISC
|
|
44
44
|
*
|
|
45
45
|
* This source code is licensed under the ISC license.
|
|
46
46
|
* See the LICENSE file in the root directory of this source tree.
|
|
47
|
-
*/const Xt=X("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);function Pe(t){return t.split("/").filter(Boolean).at(-1)||t}function Zt(){const t=B(),a=f(j=>j.sessions),s=f(j=>j.currentSessionRef),r=f(j=>j.historySurfaceSelection),o=f(j=>j.taskDeliveryActions),i=f(j=>j.deliverTask),l=Re(j=>j.openFilePreview),[u,x]=h.useState(!1),c=a.find(j=>ze({sessionId:j.sessionId,projectPath:j.projectPath},s));if(ie(r)||!(c!=null&&c.taskIsolation))return null;const v=c.taskDiffStat,b=c.taskIsolation==="worktree",d=mt(c),y=o[de(d)],p=c.taskDelivery,N=(p==null?void 0:p.status)==="conflicted",m=!!(v&&(v.changedFiles>0||v.commits>0)),S=!["queued","running"].includes(c.taskStatus),k=(p==null?void 0:p.status)==="applied"||(p==null?void 0:p.status)==="discarded",w=b&&m&&S&&!k,n=v?v.additions+v.deletions:0,E=n>0&&v?v.additions/n*100:0,F=j=>{K(f.getState())||i(d,j).catch(()=>{})},R=()=>{K(f.getState())||l({tab:"diff"})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex min-h-10 flex-wrap items-center gap-x-3 gap-y-1.5 border-b border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))]/60 px-3 py-1.5 font-mono text-[10.5px] text-[hsl(var(--deck-ink-muted))] backdrop-blur-sm sm:px-5",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[e.jsx($e,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate text-[hsl(var(--deck-ink))]",children:Pe(c.taskSourceProjectPath||c.projectPath)})]}),e.jsx("span",{className:"text-[hsl(var(--deck-ink-faint))]/60",children:"/"}),e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[b?e.jsx(ht,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-accent))]"}):e.jsx($e,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:b?"text-[hsl(var(--deck-accent))]":void 0,children:t(b?"artifact.env.isolated":"artifact.env.local")})]}),c.taskWorktreeBranch&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[hsl(var(--deck-ink-faint))]/60",children:"/"}),e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 truncate",title:c.taskWorktreeBranch,children:[e.jsx(qe,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate",children:c.taskWorktreeBranch})]})]})]}),v&&e.jsxs("div",{className:"ml-auto flex max-w-full items-center gap-2",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(Ht,{className:"h-3 w-3 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"tabular-nums",children:v.changedFiles})]}),n>0&&e.jsxs("span",{className:"relative hidden h-1.5 w-14 overflow-hidden rounded-sm border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] sm:inline-flex","aria-hidden":"true",children:[e.jsx("span",{className:"h-full bg-[hsl(var(--deck-accent))]",style:{width:`${E}%`}}),e.jsx("span",{className:"h-full bg-red-500/80",style:{width:`${100-E}%`}})]}),e.jsxs("span",{className:"tabular-nums text-[hsl(var(--deck-accent))]",children:["+",v.additions]}),e.jsxs("span",{className:"tabular-nums text-red-600 dark:text-red-400",children:["-",v.deletions]}),v.commits>0&&e.jsx("span",{className:"hidden tabular-nums text-[hsl(var(--deck-ink-faint))] sm:inline",children:t("artifact.commits",{count:v.commits})}),m&&(p==null?void 0:p.status)!=="discarded"&&e.jsx("button",{type:"button",onClick:R,className:"inline-flex items-center gap-1 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-2 py-1 text-[hsl(var(--deck-ink))] transition hover:border-[hsl(var(--deck-accent)/0.55)] hover:text-[hsl(var(--deck-accent))]",children:t("artifact.review")}),w&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",disabled:!!y,onClick:()=>F("apply"),className:"inline-flex items-center gap-1 rounded-md bg-[hsl(var(--deck-accent))] px-2 py-1 font-semibold text-white transition hover:brightness-95 disabled:cursor-wait disabled:opacity-65",children:[y==="apply"?e.jsx(_,{className:"h-3 w-3 animate-spin"}):e.jsx(Ge,{className:"h-3 w-3"}),t(y==="apply"?"artifact.applying":N?"artifact.retryApply":"artifact.apply")]}),e.jsx("button",{type:"button",disabled:!!y,onClick:()=>x(!0),className:"inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-[hsl(var(--deck-ink-faint))] transition hover:bg-red-500/10 hover:text-red-600 disabled:cursor-wait disabled:opacity-50 dark:hover:text-red-400","aria-label":t("artifact.discard"),title:t("artifact.discard"),children:y==="discard"?e.jsx(_,{className:"h-3 w-3 animate-spin"}):e.jsx(ne,{className:"h-3 w-3"})})]}),(p==null?void 0:p.status)==="applied"&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-emerald-500/10 px-2 py-1 font-semibold text-emerald-700 dark:text-emerald-300",children:[e.jsx(ge,{className:"h-3 w-3"}),t("artifact.applied")]}),(p==null?void 0:p.status)==="discarded"&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-[hsl(var(--deck-surface-2))] px-2 py-1 text-[hsl(var(--deck-ink-faint))]",children:[e.jsx(ne,{className:"h-3 w-3"}),t("artifact.discarded")]})]}),(p==null?void 0:p.status)==="conflicted"&&e.jsxs("div",{className:"flex w-full items-start gap-1.5 border-t border-amber-500/20 pt-1.5 text-amber-700 dark:text-amber-300",role:"alert",children:[e.jsx(Dt,{className:"mt-0.5 h-3 w-3 shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1 space-y-0.5",children:[e.jsx("span",{className:"block",children:p.message||t("artifact.conflict")}),e.jsx("span",{className:"block text-[hsl(var(--deck-ink-faint))]",children:t("artifact.conflictHint")})]})]})]}),e.jsx(We,{open:u,onOpenChange:x,children:e.jsxs(Je,{className:"w-[calc(100%_-_2rem)] max-w-md border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] text-[hsl(var(--deck-ink))]",children:[e.jsxs(xt,{children:[e.jsx(Ye,{children:t("artifact.discardDialog.title")}),e.jsx(Xe,{className:"text-[hsl(var(--deck-ink-muted))]",children:t("artifact.discardDialog.description",{project:Pe(c.taskSourceProjectPath||c.projectPath),count:(v==null?void 0:v.changedFiles)??0})})]}),e.jsx("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 px-3 py-2 text-xs leading-relaxed text-red-700 dark:text-red-300",children:t("artifact.discardDialog.warning")}),e.jsxs(Ze,{className:"gap-2 sm:space-x-0",children:[e.jsx("button",{type:"button",onClick:()=>x(!1),className:"rounded-md border border-[hsl(var(--deck-border))] px-3 py-2 text-sm hover:bg-[hsl(var(--deck-surface-2))]",children:t("artifact.discardDialog.cancel")}),e.jsxs("button",{type:"button",onClick:()=>{x(!1),F("discard")},className:"inline-flex items-center justify-center gap-1.5 rounded-md bg-red-600 px-3 py-2 text-sm font-semibold text-white hover:bg-red-700",children:[e.jsx(ne,{className:"h-3.5 w-3.5"}),t("artifact.discardDialog.confirm")]})]})]})})]})}const es=new Set(["completed","stale","failed","aborted","interrupted"]),ts={completed:"chat.review.status.completed",stale:"chat.review.status.stale",failed:"chat.review.status.failed",aborted:"chat.review.status.aborted",interrupted:"chat.review.status.interrupted"},ss={completed:"bg-emerald-500/10 text-emerald-700 dark:text-emerald-300 border-emerald-500/20",stale:"bg-amber-500/10 text-amber-700 dark:text-amber-300 border-amber-500/20",failed:"bg-red-500/10 text-red-700 dark:text-red-300 border-red-500/20",aborted:"bg-zinc-500/10 text-zinc-700 dark:text-zinc-300 border-zinc-500/20",interrupted:"bg-amber-500/10 text-amber-700 dark:text-amber-300 border-amber-500/20"};function be(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function as(t){const a=be(t),s=be(a==null?void 0:a.codeLocation),r=a==null?void 0:a.priority,o=a==null?void 0:a.confidenceScore,i=s==null?void 0:s.lineStart,l=s==null?void 0:s.lineEnd;if(!(typeof(a==null?void 0:a.title)!="string"||typeof a.body!="string"||r!==0&&r!==1&&r!==2&&r!==3||typeof o!="number"||!Number.isFinite(o)||typeof(s==null?void 0:s.path)!="string"||!Number.isInteger(i)||!Number.isInteger(l)))return{title:a.title,body:a.body,priority:r,confidenceScore:o,codeLocation:{path:s.path,lineStart:i,lineEnd:l}}}function rs(t){const a=be(t),s=be(a==null?void 0:a.target);if((a==null?void 0:a.phase)!=="completed"||typeof a.status!="string"||!es.has(a.status)||typeof(s==null?void 0:s.label)!="string"||s.kind!=="uncommitted"&&s.kind!=="base"&&s.kind!=="commit"||typeof a.overallExplanation!="string"||!Array.isArray(a.findings))return;const r=a.findings.map(as);if(!r.some(o=>o===void 0))return{status:a.status,target:{kind:s.kind,label:s.label,...typeof s.reference=="string"?{reference:s.reference}:{}},overallExplanation:a.overallExplanation,findings:r,...typeof a.error=="string"?{error:a.error}:{}}}function ns(t){const{path:a,lineStart:s,lineEnd:r}=t.codeLocation;return s===r?`${a}:L${s}`:`${a}:L${s}-${r}`}function is({report:t}){const a=B(),s=t.target.kind==="uncommitted"?a("chat.review.target.uncommitted"):t.target.kind==="base"?a("chat.review.target.base",{ref:t.target.reference??t.target.label}):a("chat.review.target.commit",{ref:t.target.reference??t.target.label});return e.jsxs("section",{"data-code-review-report":!0,className:"overflow-hidden rounded-xl border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface-2))]/60 px-4 py-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-[hsl(var(--deck-ink))]",children:a("chat.review.title")}),e.jsxs("p",{className:"mt-0.5 font-mono text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:[a("chat.review.target"),": ",s]})]}),e.jsxs("span",{className:D("rounded-full border px-2.5 py-1 font-mono text-[10.5px] font-medium",ss[t.status]),children:[a("chat.review.status"),": ",a(ts[t.status])]})]}),e.jsxs("div",{className:"space-y-4 px-4 py-3.5",children:[e.jsx("p",{className:"whitespace-pre-wrap text-[13px] leading-6 text-[hsl(var(--deck-ink-muted))]",children:t.overallExplanation}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("h4",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:a("chat.review.findings")}),e.jsx("span",{className:"font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:t.findings.length})]}),t.findings.length===0?e.jsx("div",{className:"rounded-lg bg-[hsl(var(--deck-surface-2))] px-3 py-2.5 text-[12px] text-[hsl(var(--deck-ink-muted))]",children:a("chat.review.noFindings")}):e.jsx("ol",{className:"space-y-2",children:t.findings.map((r,o)=>e.jsxs("li",{className:"rounded-lg border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))] px-3 py-2.5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsx("h5",{className:"text-[12.5px] font-medium leading-5 text-[hsl(var(--deck-ink))]",children:r.title}),e.jsx("span",{className:"shrink-0 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:a("chat.review.confidence",{value:r.confidenceScore.toFixed(2)})})]}),e.jsx("code",{className:"mt-1 block text-[10.5px] text-[hsl(var(--deck-accent))]",children:ns(r)}),e.jsx("p",{className:"mt-1.5 whitespace-pre-wrap text-[12px] leading-5 text-[hsl(var(--deck-ink-muted))]",children:r.body})]},`${r.codeLocation.path}:${r.codeLocation.lineStart}:${o}`))})]}),t.error&&e.jsxs("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 px-3 py-2 text-[11px] text-red-700 dark:text-red-300",children:[e.jsxs("span",{className:"font-medium",children:[a("chat.review.error"),":"]})," ",t.error]})]})]})}function os({elicitation:t,messageId:a}){const s=B(),r=f(k=>k.currentSessionRef),o=f(k=>k.setElicitation),[i,l]=h.useState(()=>ls(t.details.fields??[])),[u,x]=h.useState(()=>ds(t.details.fields??[])),[c,v]=h.useState(!1),[b,d]=h.useState(),y=t.details.fields??[],p=h.useMemo(()=>y.every(k=>{var n;if(!k.required)return!0;if(ke(k))return!!((n=u[k.name])!=null&&n.trim()||k.defaultValue!==void 0);const w=i[k.name]??k.defaultValue;return Array.isArray(w)?w.length>0:w!==void 0}),[y,u,i]);if(t.status!=="pending")return e.jsx("div",{className:"rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:s(t.status==="cancelled"?"interaction.elicitation.cancelled":"interaction.elicitation.responded")});const N=async(k,w)=>{if(!K(f.getState())&&!(!r||c)){v(!0),d(void 0);try{await ae.respondToElicitation(r,t.toolCallId,{action:k,...w?{content:w}:{}}),o(a,{...t,status:"responded"})}catch(n){d(n instanceof Error?n.message:s("interaction.elicitation.failed"))}finally{v(!1)}}},m=async()=>{try{await N("accept",us(y,i,u))}catch(k){d(k instanceof Error?k.message:String(k))}},S=()=>{if(K(f.getState()))return;const k=t.details.url;if(!k){d("MCP URL is unavailable");return}if(!window.open(k,"_blank","noopener,noreferrer")){d("The browser blocked the external window");return}N("accept")};return e.jsxs("div",{"data-pending-interaction":"elicitation",tabIndex:-1,role:"alert",className:"space-y-4 rounded-lg border border-amber-300/70 bg-amber-50/70 p-4 outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-800/70 dark:bg-amber-950/25",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(pt,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("div",{className:"font-mono text-[12px] font-semibold text-[hsl(var(--deck-ink))]",children:[s("interaction.elicitation.title")," · ",t.details.serverName]}),e.jsx("div",{className:"font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:t.details.message}),e.jsx("div",{className:"font-mono text-[11px] text-amber-700 dark:text-amber-300",children:s("interaction.elicitation.warning")})]})]}),t.details.mode==="url"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] p-3 font-mono text-[11px]",children:[e.jsx("div",{className:"text-[hsl(var(--deck-ink-muted))]",children:t.details.domain}),e.jsx("div",{className:"mt-1 break-all text-[hsl(var(--deck-ink))]",children:t.details.url})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(re,{onClick:S,disabled:c,primary:!0,label:s("interaction.elicitation.open"),icon:e.jsx(It,{className:"h-3.5 w-3.5"})}),e.jsx(re,{onClick:()=>void N("decline"),disabled:c,label:s("interaction.elicitation.decline")}),e.jsx(re,{onClick:()=>void N("cancel"),disabled:c,label:s("interaction.elicitation.cancel")})]})]}):e.jsxs("div",{className:"space-y-4",children:[y.map(k=>e.jsx(cs,{field:k,value:i[k.name],rawValue:u[k.name]??"",onValueChange:w=>l(n=>({...n,[k.name]:w})),onRawChange:w=>x(n=>({...n,[k.name]:w}))},k.name)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(re,{onClick:()=>void m(),disabled:c||!p,primary:!0,label:s("interaction.elicitation.submit"),icon:c?e.jsx(_,{className:"h-3.5 w-3.5 animate-spin"}):null}),e.jsx(re,{onClick:()=>void N("decline"),disabled:c,label:s("interaction.elicitation.decline")}),e.jsx(re,{onClick:()=>void N("cancel"),disabled:c,label:s("interaction.elicitation.cancel")})]})]}),b&&e.jsx("div",{className:"rounded-md border border-red-300/70 bg-red-50 px-2.5 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:b})]})}function cs({field:t,value:a,rawValue:s,onValueChange:r,onRawChange:o}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{htmlFor:`mcp-elicitation-${t.name}`,className:"block font-mono text-[12px] font-medium text-[hsl(var(--deck-ink))]",children:[t.title,t.required?" *":""]}),t.description&&e.jsx("div",{className:"font-mono text-[11px] text-[hsl(var(--deck-ink-faint))]",children:t.description}),t.type==="select"||t.type==="multi-select"||t.type==="boolean"?e.jsx("div",{id:`mcp-elicitation-${t.name}`,className:"flex flex-wrap gap-2",children:ms(t).map(i=>{const l=Array.isArray(a)?a.includes(i.value):a===i.typedValue;return e.jsx("button",{type:"button","aria-pressed":l,onClick:()=>{if(t.type==="multi-select"){const u=Array.isArray(a)?a:[];r(u.includes(i.value)?u.filter(x=>x!==i.value):[...u,i.value])}else r(i.typedValue)},className:D("rounded-md border px-3 py-2 font-mono text-[12px] transition-colors",l?"border-emerald-500 bg-emerald-50 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-200":"border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] text-[hsl(var(--deck-ink-muted))] hover:text-[hsl(var(--deck-ink))]"),children:i.label},i.value)})}):e.jsx("input",{id:`mcp-elicitation-${t.name}`,type:hs(t),value:s,onChange:i=>o(i.target.value),min:t.minimum,max:t.maximum,minLength:t.minLength,maxLength:t.maxLength,required:t.required,placeholder:t.defaultValue===void 0?t.required?"Required":"Optional":String(t.defaultValue),className:"w-full rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2 font-mono text-[12px] text-[hsl(var(--deck-ink))] outline-none transition-colors focus:border-amber-500 focus:ring-1 focus:ring-amber-500"})]})}function re({onClick:t,disabled:a,primary:s=!1,label:r,icon:o}){return e.jsxs("button",{type:"button",onClick:t,disabled:a,className:D("inline-flex min-h-8 items-center gap-1.5 rounded-md px-3 py-1.5 font-mono text-[12px] transition-colors disabled:cursor-wait disabled:opacity-50",s?"bg-amber-600 text-white hover:bg-amber-700":"border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] text-[hsl(var(--deck-ink-muted))] hover:text-[hsl(var(--deck-ink))]"),children:[o,r]})}function ls(t){return Object.fromEntries(t.filter(a=>!ke(a)&&a.defaultValue!==void 0).map(a=>[a.name,Array.isArray(a.defaultValue)?[...a.defaultValue]:a.defaultValue]))}function ds(t){return Object.fromEntries(t.filter(a=>ke(a)&&a.defaultValue!==void 0).map(a=>[a.name,String(a.defaultValue)]))}function us(t,a,s){var o;const r={};for(const i of t){if(ke(i)){const u=((o=s[i.name])==null?void 0:o.trim())??"";if(!u){if(i.defaultValue!==void 0)r[i.name]=i.defaultValue;else if(i.required)throw new Error(`${i.title} is required`);continue}if(i.type==="number"||i.type==="integer"){const x=Number(u);if(!Number.isFinite(x))throw new Error(`${i.title} must be a finite number`);if(i.type==="integer"&&!Number.isSafeInteger(x))throw new Error(`${i.title} must be a safe integer`);r[i.name]=x}else r[i.name]=u;continue}const l=a[i.name]??i.defaultValue;if(l===void 0){if(i.required)throw new Error(`${i.title} is required`);continue}if(Array.isArray(l)){if(i.minItems!==void 0&&l.length<i.minItems)throw new Error(`${i.title} requires at least ${i.minItems} choices`);if(i.maxItems!==void 0&&l.length>i.maxItems)throw new Error(`${i.title} allows at most ${i.maxItems} choices`)}r[i.name]=l}return r}function ms(t){return t.type==="boolean"?[{value:"true",label:"Yes",typedValue:!0},{value:"false",label:"No",typedValue:!1}]:(t.options??[]).map(a=>({...a,typedValue:a.value}))}function ke(t){return t.type==="string"||t.type==="number"||t.type==="integer"}function hs(t){return t.type==="number"||t.type==="integer"?"number":t.format==="email"?"email":t.format==="uri"?"url":t.format==="date"?"date":t.format==="date-time"?"datetime-local":"text"}function xs(t){if(!t||typeof t!="object"||Array.isArray(t))return;const a=t;if(!(!a.output||typeof a.output!="object"||Array.isArray(a.output)))return{output:a.output,...typeof a.schemaDigest=="string"?{schemaDigest:a.schemaDigest}:{}}}function ps({report:t}){const a=B(),[s,r]=h.useState(!1),o=JSON.stringify(t.output,null,2),i=async()=>{try{await navigator.clipboard.writeText(o),r(!0),window.setTimeout(()=>r(!1),1400)}catch{}};return e.jsxs("section",{"data-structured-output":!0,className:"overflow-hidden rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsxs("header",{className:"flex min-h-9 items-center justify-between gap-3 border-b border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(ft,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-accent))]"}),e.jsx("span",{className:"font-mono text-[11px] font-semibold text-[hsl(var(--deck-ink))]",children:a("chat.structuredOutput.title")}),t.schemaDigest&&e.jsxs("span",{title:t.schemaDigest,className:"truncate font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:["sha256:",t.schemaDigest.slice(0,10)]})]}),e.jsx("button",{type:"button",onClick:i,"aria-label":a("chat.structuredOutput.copy"),title:a("chat.structuredOutput.copy"),className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-[hsl(var(--deck-ink-faint))] hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:s?e.jsx(ge,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(rt,{className:"h-3.5 w-3.5"})})]}),e.jsx("pre",{className:"max-h-[440px] overflow-auto whitespace-pre p-3 font-mono text-[11px] leading-5 text-[hsl(var(--deck-ink))]",children:o})]})}const fs=h.lazy(()=>et(()=>import("./MarkdownRenderer-RfULWJEE.js").then(t=>t.M),__vite__mapDeps([0,1,2,3,4,5,6])).then(t=>({default:t.MarkdownRenderer})));function Le({text:t,label:a}){const[s,r]=h.useState(!1);if(!t.trim())return null;const o=async()=>{try{await navigator.clipboard.writeText(t),r(!0),window.setTimeout(()=>r(!1),1400)}catch{}};return e.jsx("button",{type:"button","aria-label":a,title:a,onClick:o,className:"flex h-6 w-6 items-center justify-center rounded-md text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:s?e.jsx(ge,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(rt,{className:"h-3.5 w-3.5"})})}function bs(){return e.jsx("div",{className:"flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] shadow-[0_1px_0_hsl(var(--deck-hairline))]",children:e.jsx(Ce,{size:20,pulse:!1})})}function vs(){return e.jsx("div",{className:"flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-full border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas-veil))]",children:e.jsx("span",{className:"font-mono text-[11px] font-medium text-[hsl(var(--deck-ink))]",children:"U"})})}function Ue(t){let a=t;return a=a.replace(/<system-reminder>[\s\S]*?<\/system-reminder>/g,""),a=a.replace(/<file path="[^"]*">[\s\S]*?<\/file>/g,""),a=a.replace(/<attached_files>[\s\S]*?<\/attached_files>/g,""),a=a.trim(),a}function gs(t){if(typeof t=="string")return{text:Ue(t),images:[]};const a=t.filter(r=>r.type==="text").map(r=>r.text).join(`
|
|
47
|
+
*/const Zt=X("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);function Pe(t){return t.split("/").filter(Boolean).at(-1)||t}function es(){const t=B(),a=f(j=>j.sessions),s=f(j=>j.currentSessionRef),r=f(j=>j.historySurfaceSelection),o=f(j=>j.taskDeliveryActions),i=f(j=>j.deliverTask),l=Re(j=>j.openFilePreview),[u,x]=h.useState(!1),c=a.find(j=>ze({sessionId:j.sessionId,projectPath:j.projectPath},s));if(ie(r)||!(c!=null&&c.taskIsolation))return null;const v=c.taskDiffStat,b=c.taskIsolation==="worktree",d=mt(c),y=o[de(d)],p=c.taskDelivery,N=(p==null?void 0:p.status)==="conflicted",m=!!(v&&(v.changedFiles>0||v.commits>0)),S=!["queued","running"].includes(c.taskStatus),k=(p==null?void 0:p.status)==="applied"||(p==null?void 0:p.status)==="discarded",w=b&&m&&S&&!k,n=v?v.additions+v.deletions:0,E=n>0&&v?v.additions/n*100:0,F=j=>{K(f.getState())||i(d,j).catch(()=>{})},R=()=>{K(f.getState())||l({tab:"diff"})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex min-h-10 flex-wrap items-center gap-x-3 gap-y-1.5 border-b border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))]/60 px-3 py-1.5 font-mono text-[10.5px] text-[hsl(var(--deck-ink-muted))] backdrop-blur-sm sm:px-5",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[e.jsx($e,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate text-[hsl(var(--deck-ink))]",children:Pe(c.taskSourceProjectPath||c.projectPath)})]}),e.jsx("span",{className:"text-[hsl(var(--deck-ink-faint))]/60",children:"/"}),e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[b?e.jsx(ht,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-accent))]"}):e.jsx($e,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:b?"text-[hsl(var(--deck-accent))]":void 0,children:t(b?"artifact.env.isolated":"artifact.env.local")})]}),c.taskWorktreeBranch&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[hsl(var(--deck-ink-faint))]/60",children:"/"}),e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 truncate",title:c.taskWorktreeBranch,children:[e.jsx(qe,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate",children:c.taskWorktreeBranch})]})]})]}),v&&e.jsxs("div",{className:"ml-auto flex max-w-full items-center gap-2",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(Qt,{className:"h-3 w-3 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"tabular-nums",children:v.changedFiles})]}),n>0&&e.jsxs("span",{className:"relative hidden h-1.5 w-14 overflow-hidden rounded-sm border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] sm:inline-flex","aria-hidden":"true",children:[e.jsx("span",{className:"h-full bg-[hsl(var(--deck-accent))]",style:{width:`${E}%`}}),e.jsx("span",{className:"h-full bg-red-500/80",style:{width:`${100-E}%`}})]}),e.jsxs("span",{className:"tabular-nums text-[hsl(var(--deck-accent))]",children:["+",v.additions]}),e.jsxs("span",{className:"tabular-nums text-red-600 dark:text-red-400",children:["-",v.deletions]}),v.commits>0&&e.jsx("span",{className:"hidden tabular-nums text-[hsl(var(--deck-ink-faint))] sm:inline",children:t("artifact.commits",{count:v.commits})}),m&&(p==null?void 0:p.status)!=="discarded"&&e.jsx("button",{type:"button",onClick:R,className:"inline-flex items-center gap-1 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-2 py-1 text-[hsl(var(--deck-ink))] transition hover:border-[hsl(var(--deck-accent)/0.55)] hover:text-[hsl(var(--deck-accent))]",children:t("artifact.review")}),w&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",disabled:!!y,onClick:()=>F("apply"),className:"inline-flex items-center gap-1 rounded-md bg-[hsl(var(--deck-accent))] px-2 py-1 font-semibold text-white transition hover:brightness-95 disabled:cursor-wait disabled:opacity-65",children:[y==="apply"?e.jsx(_,{className:"h-3 w-3 animate-spin"}):e.jsx(Ge,{className:"h-3 w-3"}),t(y==="apply"?"artifact.applying":N?"artifact.retryApply":"artifact.apply")]}),e.jsx("button",{type:"button",disabled:!!y,onClick:()=>x(!0),className:"inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-[hsl(var(--deck-ink-faint))] transition hover:bg-red-500/10 hover:text-red-600 disabled:cursor-wait disabled:opacity-50 dark:hover:text-red-400","aria-label":t("artifact.discard"),title:t("artifact.discard"),children:y==="discard"?e.jsx(_,{className:"h-3 w-3 animate-spin"}):e.jsx(ne,{className:"h-3 w-3"})})]}),(p==null?void 0:p.status)==="applied"&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-emerald-500/10 px-2 py-1 font-semibold text-emerald-700 dark:text-emerald-300",children:[e.jsx(ge,{className:"h-3 w-3"}),t("artifact.applied")]}),(p==null?void 0:p.status)==="discarded"&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-[hsl(var(--deck-surface-2))] px-2 py-1 text-[hsl(var(--deck-ink-faint))]",children:[e.jsx(ne,{className:"h-3 w-3"}),t("artifact.discarded")]})]}),(p==null?void 0:p.status)==="conflicted"&&e.jsxs("div",{className:"flex w-full items-start gap-1.5 border-t border-amber-500/20 pt-1.5 text-amber-700 dark:text-amber-300",role:"alert",children:[e.jsx(It,{className:"mt-0.5 h-3 w-3 shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1 space-y-0.5",children:[e.jsx("span",{className:"block",children:p.message||t("artifact.conflict")}),e.jsx("span",{className:"block text-[hsl(var(--deck-ink-faint))]",children:t("artifact.conflictHint")})]})]})]}),e.jsx(We,{open:u,onOpenChange:x,children:e.jsxs(Je,{className:"w-[calc(100%_-_2rem)] max-w-md border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] text-[hsl(var(--deck-ink))]",children:[e.jsxs(xt,{children:[e.jsx(Ye,{children:t("artifact.discardDialog.title")}),e.jsx(Xe,{className:"text-[hsl(var(--deck-ink-muted))]",children:t("artifact.discardDialog.description",{project:Pe(c.taskSourceProjectPath||c.projectPath),count:(v==null?void 0:v.changedFiles)??0})})]}),e.jsx("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 px-3 py-2 text-xs leading-relaxed text-red-700 dark:text-red-300",children:t("artifact.discardDialog.warning")}),e.jsxs(Ze,{className:"gap-2 sm:space-x-0",children:[e.jsx("button",{type:"button",onClick:()=>x(!1),className:"rounded-md border border-[hsl(var(--deck-border))] px-3 py-2 text-sm hover:bg-[hsl(var(--deck-surface-2))]",children:t("artifact.discardDialog.cancel")}),e.jsxs("button",{type:"button",onClick:()=>{x(!1),F("discard")},className:"inline-flex items-center justify-center gap-1.5 rounded-md bg-red-600 px-3 py-2 text-sm font-semibold text-white hover:bg-red-700",children:[e.jsx(ne,{className:"h-3.5 w-3.5"}),t("artifact.discardDialog.confirm")]})]})]})})]})}const ts=new Set(["completed","stale","failed","aborted","interrupted"]),ss={completed:"chat.review.status.completed",stale:"chat.review.status.stale",failed:"chat.review.status.failed",aborted:"chat.review.status.aborted",interrupted:"chat.review.status.interrupted"},as={completed:"bg-emerald-500/10 text-emerald-700 dark:text-emerald-300 border-emerald-500/20",stale:"bg-amber-500/10 text-amber-700 dark:text-amber-300 border-amber-500/20",failed:"bg-red-500/10 text-red-700 dark:text-red-300 border-red-500/20",aborted:"bg-zinc-500/10 text-zinc-700 dark:text-zinc-300 border-zinc-500/20",interrupted:"bg-amber-500/10 text-amber-700 dark:text-amber-300 border-amber-500/20"};function be(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function rs(t){const a=be(t),s=be(a==null?void 0:a.codeLocation),r=a==null?void 0:a.priority,o=a==null?void 0:a.confidenceScore,i=s==null?void 0:s.lineStart,l=s==null?void 0:s.lineEnd;if(!(typeof(a==null?void 0:a.title)!="string"||typeof a.body!="string"||r!==0&&r!==1&&r!==2&&r!==3||typeof o!="number"||!Number.isFinite(o)||typeof(s==null?void 0:s.path)!="string"||!Number.isInteger(i)||!Number.isInteger(l)))return{title:a.title,body:a.body,priority:r,confidenceScore:o,codeLocation:{path:s.path,lineStart:i,lineEnd:l}}}function ns(t){const a=be(t),s=be(a==null?void 0:a.target);if((a==null?void 0:a.phase)!=="completed"||typeof a.status!="string"||!ts.has(a.status)||typeof(s==null?void 0:s.label)!="string"||s.kind!=="uncommitted"&&s.kind!=="base"&&s.kind!=="commit"||typeof a.overallExplanation!="string"||!Array.isArray(a.findings))return;const r=a.findings.map(rs);if(!r.some(o=>o===void 0))return{status:a.status,target:{kind:s.kind,label:s.label,...typeof s.reference=="string"?{reference:s.reference}:{}},overallExplanation:a.overallExplanation,findings:r,...typeof a.error=="string"?{error:a.error}:{}}}function is(t){const{path:a,lineStart:s,lineEnd:r}=t.codeLocation;return s===r?`${a}:L${s}`:`${a}:L${s}-${r}`}function os({report:t}){const a=B(),s=t.target.kind==="uncommitted"?a("chat.review.target.uncommitted"):t.target.kind==="base"?a("chat.review.target.base",{ref:t.target.reference??t.target.label}):a("chat.review.target.commit",{ref:t.target.reference??t.target.label});return e.jsxs("section",{"data-code-review-report":!0,className:"overflow-hidden rounded-xl border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface-2))]/60 px-4 py-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-[hsl(var(--deck-ink))]",children:a("chat.review.title")}),e.jsxs("p",{className:"mt-0.5 font-mono text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:[a("chat.review.target"),": ",s]})]}),e.jsxs("span",{className:D("rounded-full border px-2.5 py-1 font-mono text-[10.5px] font-medium",as[t.status]),children:[a("chat.review.status"),": ",a(ss[t.status])]})]}),e.jsxs("div",{className:"space-y-4 px-4 py-3.5",children:[e.jsx("p",{className:"whitespace-pre-wrap text-[13px] leading-6 text-[hsl(var(--deck-ink-muted))]",children:t.overallExplanation}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("h4",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:a("chat.review.findings")}),e.jsx("span",{className:"font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:t.findings.length})]}),t.findings.length===0?e.jsx("div",{className:"rounded-lg bg-[hsl(var(--deck-surface-2))] px-3 py-2.5 text-[12px] text-[hsl(var(--deck-ink-muted))]",children:a("chat.review.noFindings")}):e.jsx("ol",{className:"space-y-2",children:t.findings.map((r,o)=>e.jsxs("li",{className:"rounded-lg border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))] px-3 py-2.5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsx("h5",{className:"text-[12.5px] font-medium leading-5 text-[hsl(var(--deck-ink))]",children:r.title}),e.jsx("span",{className:"shrink-0 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:a("chat.review.confidence",{value:r.confidenceScore.toFixed(2)})})]}),e.jsx("code",{className:"mt-1 block text-[10.5px] text-[hsl(var(--deck-accent))]",children:is(r)}),e.jsx("p",{className:"mt-1.5 whitespace-pre-wrap text-[12px] leading-5 text-[hsl(var(--deck-ink-muted))]",children:r.body})]},`${r.codeLocation.path}:${r.codeLocation.lineStart}:${o}`))})]}),t.error&&e.jsxs("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 px-3 py-2 text-[11px] text-red-700 dark:text-red-300",children:[e.jsxs("span",{className:"font-medium",children:[a("chat.review.error"),":"]})," ",t.error]})]})]})}function cs({elicitation:t,messageId:a}){const s=B(),r=f(k=>k.currentSessionRef),o=f(k=>k.setElicitation),[i,l]=h.useState(()=>ds(t.details.fields??[])),[u,x]=h.useState(()=>us(t.details.fields??[])),[c,v]=h.useState(!1),[b,d]=h.useState(),y=t.details.fields??[],p=h.useMemo(()=>y.every(k=>{var n;if(!k.required)return!0;if(ke(k))return!!((n=u[k.name])!=null&&n.trim()||k.defaultValue!==void 0);const w=i[k.name]??k.defaultValue;return Array.isArray(w)?w.length>0:w!==void 0}),[y,u,i]);if(t.status!=="pending")return e.jsx("div",{className:"rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:s(t.status==="cancelled"?"interaction.elicitation.cancelled":"interaction.elicitation.responded")});const N=async(k,w)=>{if(!K(f.getState())&&!(!r||c)){v(!0),d(void 0);try{await ae.respondToElicitation(r,t.toolCallId,{action:k,...w?{content:w}:{}}),o(a,{...t,status:"responded"})}catch(n){d(n instanceof Error?n.message:s("interaction.elicitation.failed"))}finally{v(!1)}}},m=async()=>{try{await N("accept",ms(y,i,u))}catch(k){d(k instanceof Error?k.message:String(k))}},S=()=>{if(K(f.getState()))return;const k=t.details.url;if(!k){d("MCP URL is unavailable");return}if(!window.open(k,"_blank","noopener,noreferrer")){d("The browser blocked the external window");return}N("accept")};return e.jsxs("div",{"data-pending-interaction":"elicitation",tabIndex:-1,role:"alert",className:"space-y-4 rounded-lg border border-amber-300/70 bg-amber-50/70 p-4 outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-800/70 dark:bg-amber-950/25",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(pt,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("div",{className:"font-mono text-[12px] font-semibold text-[hsl(var(--deck-ink))]",children:[s("interaction.elicitation.title")," · ",t.details.serverName]}),e.jsx("div",{className:"font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:t.details.message}),e.jsx("div",{className:"font-mono text-[11px] text-amber-700 dark:text-amber-300",children:s("interaction.elicitation.warning")})]})]}),t.details.mode==="url"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] p-3 font-mono text-[11px]",children:[e.jsx("div",{className:"text-[hsl(var(--deck-ink-muted))]",children:t.details.domain}),e.jsx("div",{className:"mt-1 break-all text-[hsl(var(--deck-ink))]",children:t.details.url})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(re,{onClick:S,disabled:c,primary:!0,label:s("interaction.elicitation.open"),icon:e.jsx($t,{className:"h-3.5 w-3.5"})}),e.jsx(re,{onClick:()=>void N("decline"),disabled:c,label:s("interaction.elicitation.decline")}),e.jsx(re,{onClick:()=>void N("cancel"),disabled:c,label:s("interaction.elicitation.cancel")})]})]}):e.jsxs("div",{className:"space-y-4",children:[y.map(k=>e.jsx(ls,{field:k,value:i[k.name],rawValue:u[k.name]??"",onValueChange:w=>l(n=>({...n,[k.name]:w})),onRawChange:w=>x(n=>({...n,[k.name]:w}))},k.name)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(re,{onClick:()=>void m(),disabled:c||!p,primary:!0,label:s("interaction.elicitation.submit"),icon:c?e.jsx(_,{className:"h-3.5 w-3.5 animate-spin"}):null}),e.jsx(re,{onClick:()=>void N("decline"),disabled:c,label:s("interaction.elicitation.decline")}),e.jsx(re,{onClick:()=>void N("cancel"),disabled:c,label:s("interaction.elicitation.cancel")})]})]}),b&&e.jsx("div",{className:"rounded-md border border-red-300/70 bg-red-50 px-2.5 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:b})]})}function ls({field:t,value:a,rawValue:s,onValueChange:r,onRawChange:o}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{htmlFor:`mcp-elicitation-${t.name}`,className:"block font-mono text-[12px] font-medium text-[hsl(var(--deck-ink))]",children:[t.title,t.required?" *":""]}),t.description&&e.jsx("div",{className:"font-mono text-[11px] text-[hsl(var(--deck-ink-faint))]",children:t.description}),t.type==="select"||t.type==="multi-select"||t.type==="boolean"?e.jsx("div",{id:`mcp-elicitation-${t.name}`,className:"flex flex-wrap gap-2",children:hs(t).map(i=>{const l=Array.isArray(a)?a.includes(i.value):a===i.typedValue;return e.jsx("button",{type:"button","aria-pressed":l,onClick:()=>{if(t.type==="multi-select"){const u=Array.isArray(a)?a:[];r(u.includes(i.value)?u.filter(x=>x!==i.value):[...u,i.value])}else r(i.typedValue)},className:D("rounded-md border px-3 py-2 font-mono text-[12px] transition-colors",l?"border-emerald-500 bg-emerald-50 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-200":"border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] text-[hsl(var(--deck-ink-muted))] hover:text-[hsl(var(--deck-ink))]"),children:i.label},i.value)})}):e.jsx("input",{id:`mcp-elicitation-${t.name}`,type:xs(t),value:s,onChange:i=>o(i.target.value),min:t.minimum,max:t.maximum,minLength:t.minLength,maxLength:t.maxLength,required:t.required,placeholder:t.defaultValue===void 0?t.required?"Required":"Optional":String(t.defaultValue),className:"w-full rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2 font-mono text-[12px] text-[hsl(var(--deck-ink))] outline-none transition-colors focus:border-amber-500 focus:ring-1 focus:ring-amber-500"})]})}function re({onClick:t,disabled:a,primary:s=!1,label:r,icon:o}){return e.jsxs("button",{type:"button",onClick:t,disabled:a,className:D("inline-flex min-h-8 items-center gap-1.5 rounded-md px-3 py-1.5 font-mono text-[12px] transition-colors disabled:cursor-wait disabled:opacity-50",s?"bg-amber-600 text-white hover:bg-amber-700":"border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] text-[hsl(var(--deck-ink-muted))] hover:text-[hsl(var(--deck-ink))]"),children:[o,r]})}function ds(t){return Object.fromEntries(t.filter(a=>!ke(a)&&a.defaultValue!==void 0).map(a=>[a.name,Array.isArray(a.defaultValue)?[...a.defaultValue]:a.defaultValue]))}function us(t){return Object.fromEntries(t.filter(a=>ke(a)&&a.defaultValue!==void 0).map(a=>[a.name,String(a.defaultValue)]))}function ms(t,a,s){var o;const r={};for(const i of t){if(ke(i)){const u=((o=s[i.name])==null?void 0:o.trim())??"";if(!u){if(i.defaultValue!==void 0)r[i.name]=i.defaultValue;else if(i.required)throw new Error(`${i.title} is required`);continue}if(i.type==="number"||i.type==="integer"){const x=Number(u);if(!Number.isFinite(x))throw new Error(`${i.title} must be a finite number`);if(i.type==="integer"&&!Number.isSafeInteger(x))throw new Error(`${i.title} must be a safe integer`);r[i.name]=x}else r[i.name]=u;continue}const l=a[i.name]??i.defaultValue;if(l===void 0){if(i.required)throw new Error(`${i.title} is required`);continue}if(Array.isArray(l)){if(i.minItems!==void 0&&l.length<i.minItems)throw new Error(`${i.title} requires at least ${i.minItems} choices`);if(i.maxItems!==void 0&&l.length>i.maxItems)throw new Error(`${i.title} allows at most ${i.maxItems} choices`)}r[i.name]=l}return r}function hs(t){return t.type==="boolean"?[{value:"true",label:"Yes",typedValue:!0},{value:"false",label:"No",typedValue:!1}]:(t.options??[]).map(a=>({...a,typedValue:a.value}))}function ke(t){return t.type==="string"||t.type==="number"||t.type==="integer"}function xs(t){return t.type==="number"||t.type==="integer"?"number":t.format==="email"?"email":t.format==="uri"?"url":t.format==="date"?"date":t.format==="date-time"?"datetime-local":"text"}function ps(t){if(!t||typeof t!="object"||Array.isArray(t))return;const a=t;if(!(!a.output||typeof a.output!="object"||Array.isArray(a.output)))return{output:a.output,...typeof a.schemaDigest=="string"?{schemaDigest:a.schemaDigest}:{}}}function fs({report:t}){const a=B(),[s,r]=h.useState(!1),o=JSON.stringify(t.output,null,2),i=async()=>{try{await navigator.clipboard.writeText(o),r(!0),window.setTimeout(()=>r(!1),1400)}catch{}};return e.jsxs("section",{"data-structured-output":!0,className:"overflow-hidden rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsxs("header",{className:"flex min-h-9 items-center justify-between gap-3 border-b border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(ft,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-accent))]"}),e.jsx("span",{className:"font-mono text-[11px] font-semibold text-[hsl(var(--deck-ink))]",children:a("chat.structuredOutput.title")}),t.schemaDigest&&e.jsxs("span",{title:t.schemaDigest,className:"truncate font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:["sha256:",t.schemaDigest.slice(0,10)]})]}),e.jsx("button",{type:"button",onClick:i,"aria-label":a("chat.structuredOutput.copy"),title:a("chat.structuredOutput.copy"),className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-[hsl(var(--deck-ink-faint))] hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:s?e.jsx(ge,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(rt,{className:"h-3.5 w-3.5"})})]}),e.jsx("pre",{className:"max-h-[440px] overflow-auto whitespace-pre p-3 font-mono text-[11px] leading-5 text-[hsl(var(--deck-ink))]",children:o})]})}const bs=h.lazy(()=>et(()=>import("./MarkdownRenderer-DaQIOCqh.js").then(t=>t.M),__vite__mapDeps([0,1,2,3,4,5,6])).then(t=>({default:t.MarkdownRenderer})));function Le({text:t,label:a}){const[s,r]=h.useState(!1);if(!t.trim())return null;const o=async()=>{try{await navigator.clipboard.writeText(t),r(!0),window.setTimeout(()=>r(!1),1400)}catch{}};return e.jsx("button",{type:"button","aria-label":a,title:a,onClick:o,className:"flex h-6 w-6 items-center justify-center rounded-md text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:s?e.jsx(ge,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(rt,{className:"h-3.5 w-3.5"})})}function vs(){return e.jsx("div",{className:"flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] shadow-[0_1px_0_hsl(var(--deck-hairline))]",children:e.jsx(Ce,{size:20,pulse:!1})})}function gs(){return e.jsx("div",{className:"flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-full border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas-veil))]",children:e.jsx("span",{className:"font-mono text-[11px] font-medium text-[hsl(var(--deck-ink))]",children:"U"})})}function Ue(t){let a=t;return a=a.replace(/<system-reminder>[\s\S]*?<\/system-reminder>/g,""),a=a.replace(/<file path="[^"]*">[\s\S]*?<\/file>/g,""),a=a.replace(/<attached_files>[\s\S]*?<\/attached_files>/g,""),a=a.trim(),a}function ks(t){if(typeof t=="string")return{text:Ue(t),images:[]};const a=t.filter(r=>r.type==="text").map(r=>r.text).join(`
|
|
48
48
|
`),s=t.filter(r=>r.type==="image_url").map(r=>r.image_url.url);return{text:Ue(a),images:s}}function De(t){return typeof t=="string"?t:t.filter(a=>a.type==="text").map(a=>a.text).join(`
|
|
49
|
-
`)}function
|
|
49
|
+
`)}function ys(t){const a=t.agentContent;return a?Tt(a):De(t.content)}function Oe({content:t,syntaxHighlight:a=!0}){return e.jsx(h.Suspense,{fallback:e.jsx("pre",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono whitespace-pre-wrap",children:t}),children:e.jsx(bs,{content:t,syntaxHighlight:a})})}function Ie({status:t}){if(!t)return null;const a={running:"bg-[#FEF3C7] text-[#92400E] dark:bg-[#F59E0B]/20 dark:text-[#FBBF24]",success:"bg-[#DCFCE7] text-[#15803D] dark:bg-[#22C55E]/20 dark:text-[#22C55E]",error:"bg-[#FEE2E2] text-[#b91c1c] dark:bg-[#EF4444]/20 dark:text-[#fca5a5]",pending:"bg-[#E5E7EB] text-[#6B7280] dark:bg-[#27272a] dark:text-[#a1a1aa]",info:"bg-[#DBEAFE] text-[#1D4ED8] dark:bg-[#3B82F6]/20 dark:text-[#60A5FA]"},s={running:"Running",success:"Success",error:"Error",pending:"Pending",info:"Info"};return e.jsx("span",{className:D("text-[11px] px-2 py-0.5 rounded-full font-mono",a[t]),children:s[t]})}function js(t){if(!t)return"";if(typeof t=="string")try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}return JSON.stringify(t,null,2)}const Ke=500;function ot(t,a){if(t.length<=a)return t;let s=Math.max(0,a);return s>0&&/[\uD800-\uDBFF]/.test(t.charAt(s-1))&&(s-=1),t.slice(0,s)}function Ve(t,a){if(t.length<=a)return t;let s=Math.max(0,t.length-a);return/[\uDC00-\uDFFF]/.test(t.charAt(s))&&(s+=1),t.slice(s)}function je(t,a){if(t.length<=a)return t;if(a<=0)return"";const s=`
|
|
50
50
|
... (display clipped) ...
|
|
51
|
-
`,r=a-s.length;if(r<=0)return Ve(t,a);const o=Math.floor(r/3);return`${ot(t,o)}${s}${Ve(t,r-o)}`}function
|
|
51
|
+
`,r=a-s.length;if(r<=0)return Ve(t,a);const o=Math.floor(r/3);return`${ot(t,o)}${s}${Ve(t,r-o)}`}function ws(t){const a=t.split(`
|
|
52
52
|
`),s=a.at(-1),r=s!=null&&s.startsWith("Output truncated")?s:void 0,o=r?a.slice(0,-1).join(`
|
|
53
53
|
`):t,i=r?`
|
|
54
54
|
${r}`:"",l=Math.max(0,Ke-i.length),x=o.indexOf(`
|
|
@@ -56,8 +56,8 @@ stderr:
|
|
|
56
56
|
`);let c;if(x>=0&&o.includes(`
|
|
57
57
|
stdout:
|
|
58
58
|
`)){const v=o.slice(0,x),b=o.slice(x+1),d=Math.max(0,l-1),y=Math.floor(d/2);c=`${je(v,y)}
|
|
59
|
-
${je(b,d-y)}`}else c=je(o,l);return{body:ot(c,l),...r?{notice:r}:{},truncated:!!r||t.length>Ke}}function
|
|
60
|
-
`,e.jsx("span",{"data-tool-truncation-notice":!0,children:o.notice})]})]})]})]})]})}function ct({toolCalls:t}){return t.length===0?null:e.jsx("div",{className:"space-y-2",children:t.map(a=>e.jsx(ws,{tool:a},a.toolCallId))})}function Ns({toolCalls:t,toolCallIds:a}){const s=B(),[r,o]=h.useState(!1),i=h.useMemo(()=>new Map(t.map(b=>[b.toolCallId,b])),[t]),l=a.flatMap(b=>{const d=i.get(b);return d?[d]:[]});if(l.length===0)return null;const u=l.filter(b=>b.status==="running").length,x=l.filter(b=>b.status==="error").length,c=[...l].reverse().find(b=>b.status==="running"&&!!b.progressMessage),v=u>0?s(l.length===1?"chat.timeline.tools.runningOne":"chat.timeline.tools.running",{count:l.length}):x>0?s(l.length===1?"chat.timeline.tools.completedOneWithError":"chat.timeline.tools.completedWithErrors",{count:l.length,errors:x}):s(l.length===1?"chat.timeline.tools.completedOne":"chat.timeline.tools.completed",{count:l.length});return e.jsxs("div",{"data-agent-tool-group":!0,className:"py-0.5",children:[e.jsxs("button",{type:"button","aria-expanded":r,onClick:()=>o(b=>!b),className:"group flex min-h-7 w-full items-center gap-1.5 rounded-md px-1.5 text-left font-mono text-[11.5px] text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))]/65 hover:text-[hsl(var(--deck-ink-muted))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[r?e.jsx(me,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(oe,{className:"h-3.5 w-3.5 shrink-0"}),u>0&&e.jsx(_,{className:"h-3 w-3 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"}),e.jsx("span",{children:v}),(c==null?void 0:c.progressMessage)&&e.jsxs("span",{className:"min-w-0 truncate text-[10.5px] text-[hsl(var(--deck-ink-muted))]",children:[c.progressMessage,c.progress!==void 0&&c.progressTotal!==void 0&&` · ${Math.max(0,Math.min(100,Math.round(c.progress/c.progressTotal*100)))}%`]})]}),(c==null?void 0:c.progress)!==void 0&&c.progressTotal!==void 0&&e.jsx("div",{role:"progressbar","aria-label":`${c.toolName} progress`,"aria-valuemin":0,"aria-valuemax":c.progressTotal,"aria-valuenow":Math.min(c.progress,c.progressTotal),className:"mx-1.5 h-0.5 overflow-hidden rounded-full bg-[hsl(var(--deck-border))]",children:e.jsx("div",{className:"h-full rounded-full bg-amber-500 transition-[width] duration-150",style:{width:`${Math.max(0,Math.min(100,c.progress/c.progressTotal*100))}%`}})}),r&&e.jsx("div",{"data-agent-tool-group-details":!0,className:"mt-2 space-y-2 pl-1",children:e.jsx(ct,{toolCalls:l})})]})}function Ss({content:t}){const a=B(),[s,r]=h.useState(!1);return t?e.jsxs("div",{"data-agent-thinking":!0,className:"py-0.5",children:[e.jsxs("button",{type:"button","aria-expanded":s,onClick:()=>r(o=>!o),className:"flex min-h-7 w-full items-center gap-1.5 rounded-md px-1.5 text-left font-mono text-[11.5px] text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))]/65 hover:text-[hsl(var(--deck-ink-muted))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[s?e.jsx(me,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))]"}):e.jsx(oe,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{children:a("chat.timeline.thinking")})]}),s&&e.jsx("div",{className:"ml-1 mt-1 border-l border-[hsl(var(--deck-border))] py-1 pl-3",children:e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-[11px] leading-5 text-[hsl(var(--deck-ink-muted))]",children:t})})]}):null}function Cs({tasks:t}){if(t.length===0)return null;const a=t.filter(r=>r.status==="completed").length,s=a===t.length;return e.jsx("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:e.jsx("div",{className:"flex gap-2 items-center",children:e.jsx("span",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:s?"✓ All tasks done":`Tasks: ${a}/${t.length}`})})})}function Ts({toolCalls:t}){const a=Re(i=>i.openFilePreview),s=f(i=>ie(i.historySurfaceSelection)),r=h.useMemo(()=>{const i=new Map,l=["Write","SearchReplace","Edit","ApplyPatch"];for(const u of t){if(u.status!=="success")continue;const x=u.metadata;if(u.toolName==="ApplyPatch"&&Array.isArray(x==null?void 0:x.changes)){for(const v of x.changes)v&&typeof v=="object"&&"path"in v&&typeof v.path=="string"&&i.set(v.path,{path:v.path,toolName:u.toolName});continue}const c=x==null?void 0:x.file_path;c&&l.includes(u.toolName)&&i.set(c,{path:c,toolName:u.toolName})}return Array.from(i.values())},[t]);if(s||r.length===0)return null;const o=i=>{K(f.getState())||a({tab:"diff",targetPath:i})};return e.jsxs("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:[e.jsxs("div",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono mb-1.5",children:["Changed files (",r.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.map(({path:i})=>{const l=i.split("/").pop()||i;return e.jsxs("button",{onClick:()=>o(i),className:"flex items-center gap-1 px-2 py-1 text-[11px] font-mono bg-[#E5E7EB] dark:bg-[#27272a] text-[hsl(var(--deck-ink))] rounded hover:bg-[#D1D5DB] dark:hover:bg-[#3f3f46] transition-colors",title:i,children:[e.jsx(bt,{className:"w-3 h-3"}),l]},i)})})]})}function Es({subagent:t}){var Q,Z,J,te;const a=B(),[s,r]=h.useState(null),[o,i]=h.useState(!1),[l,u]=h.useState(null),[x,c]=h.useState(!1),[v,b]=h.useState(""),[d,y]=h.useState(!1),[p,N]=h.useState(null),[m,S]=h.useState(null),[k,w]=h.useState(null),n=f(A=>A.currentSessionRef),E=f(A=>A.isStreaming),F=f(A=>A.isTemporarySession),R=f(A=>ie(A.historySurfaceSelection));if(!t)return null;const j=t.status==="running",O=s!==null?s:j,G=t.toolCalls||l||[],C=t.output||t.thinking||G.length>0||t.sessionId,T=m&&m.status!=="running"?m:k,M=(T==null?void 0:T.id)??t.sessionId,P=((Q=T==null?void 0:T.restartRecovery)==null?void 0:Q.outcome)==="failed",L=!j&&!E&&!F&&!R&&!P&&(m==null?void 0:m.status)!=="running"&&!!(M&&n);h.useEffect(()=>{if(R||!O||j||!t.sessionId||!(n!=null&&n.projectPath)||l!==null||t.toolCalls&&t.toolCalls.length>0)return;let A=!0;return i(!0),ae.getMessages({sessionId:t.sessionId,projectPath:n.projectPath}).then(z=>{var H,$;if(!A)return;const q=At(z),V=new Map;for(const W of q)if(($=(H=W.agentContent)==null?void 0:H.toolCalls)!=null&&$.length)for(const Y of W.agentContent.toolCalls)V.has(Y.toolCallId)||V.set(Y.toolCallId,Y);u(Array.from(V.values()))}).finally(()=>{A&&i(!1)}),()=>{A=!1}},[O,R,j,t.sessionId,t.toolCalls,l,n==null?void 0:n.projectPath]),h.useEffect(()=>{if(R||!t.sessionId||!n)return;let A=!0;const z=t.rootAgentId??t.sessionId,q=t.resumeDepth??0;return ae.listSubagents(n).then(V=>{if(!A)return;w(V.find($=>$.id===t.sessionId)??null);const H=V.filter($=>$.id!==t.sessionId&&$.rootAgentId===z&&$.resumeDepth>q).sort(($,W)=>W.resumeDepth-$.resumeDepth||W.lastActiveAt-$.lastActiveAt)[0];H&&S(H)}).catch(()=>{}),()=>{A=!1}},[n==null?void 0:n.sessionId,n==null?void 0:n.projectPath,R,t.sessionId,t.rootAgentId,t.resumeDepth]),h.useEffect(()=>{if(R||!m||m.status!=="running"||!n)return;let A=!0;const z=async()=>{try{const H=(await ae.listSubagents(n)).find($=>$.id===m.id);A&&H&&S(H)}catch{}},q=window.setInterval(()=>{z()},1e3);return()=>{A=!1,window.clearInterval(q)}},[n,R,m==null?void 0:m.id,m==null?void 0:m.status]);const ee=async()=>{if(!K(f.getState())&&!(!n||!M||!v.trim()||d)){y(!0),N(null);try{const A=await ae.resumeSubagent(n,M,v.trim());S(A.session),b(""),c(!1),r(!0)}catch(A){N(A instanceof Error?A.message:a("chat.subagent.resumeFailed"))}finally{y(!1)}}};return e.jsxs("div",{"data-subagent-id":t.id,"data-subagent-session-id":t.sessionId,className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:[e.jsxs("button",{type:"button",onClick:()=>r(!O),className:"flex gap-2 justify-between items-center w-full transition-opacity cursor-pointer hover:opacity-80",children:[e.jsxs("div",{className:"flex gap-2 items-center",children:[j&&e.jsx(_,{className:"h-3 w-3 animate-spin text-[hsl(var(--deck-ink-muted))]"}),e.jsxs("span",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:[t.type,": ",t.description]}),e.jsx(Ie,{status:t.status==="completed"?"success":t.status==="failed"?"error":"running"}),t.type==="verification"&&t.verificationVerdict&&e.jsx("span",{"data-verification-verdict":t.verificationVerdict,className:D("rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide",t.verificationVerdict==="pass"?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":t.verificationVerdict==="fail"?"bg-red-500/10 text-red-600 dark:text-red-400":"bg-amber-500/10 text-amber-600 dark:text-amber-400"),children:t.verificationVerdict}),t.resumedFrom&&e.jsx("span",{className:"rounded bg-[#EDE9FE] px-1.5 py-0.5 text-[10px] font-mono text-[#6D28D9] dark:bg-[#2E1065] dark:text-[#C4B5FD]",title:a("chat.subagent.resumedFromTitle",{id:t.resumedFrom}),children:a("chat.subagent.resumedDepth",{depth:t.resumeDepth??1})})]}),C&&e.jsx(me,{className:D("h-3.5 w-3.5 text-[hsl(var(--deck-ink-muted))] transition-transform",O&&"rotate-180")})]}),!O&&!j&&t.output&&e.jsx("div",{"data-subagent-output-summary":!0,className:"mt-2 max-h-10 overflow-hidden whitespace-pre-wrap break-words font-mono text-[11px] text-[hsl(var(--deck-ink))]",children:t.output}),O&&e.jsxs("div",{className:"mt-2 space-y-2",children:[(t.output||t.thinking)&&e.jsxs(e.Fragment,{children:[t.output&&e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[160px] overflow-y-auto",children:t.output}),t.thinking&&e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[120px] overflow-y-auto",children:t.thinking})]}),o&&e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono",children:[e.jsx(_,{className:"w-3 h-3 animate-spin"}),a("chat.subagent.loadingLogs")]}),!o&&G.length>0&&e.jsx(ct,{toolCalls:G}),m&&e.jsxs("div",{className:"rounded-md border border-[#DDD6FE] bg-[#F5F3FF] p-2 text-[11px] font-mono text-[#5B21B6] dark:border-[#4C1D95] dark:bg-[#1E1B4B] dark:text-[#C4B5FD]",children:[e.jsx("div",{children:a("chat.subagent.resumedAs",{id:m.id,status:m.status,depth:m.resumeDepth??1})}),(((Z=m.result)==null?void 0:Z.message)||((J=m.result)==null?void 0:J.error))&&e.jsx("div",{className:"mt-1 whitespace-pre-wrap text-[hsl(var(--deck-ink))]",children:m.result.message||m.result.error})]}),P&&((te=T==null?void 0:T.result)==null?void 0:te.error)&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:T.result.error}),L&&e.jsxs("div",{className:"space-y-2",children:[x?e.jsxs("div",{className:"space-y-2 rounded-md border border-[#E5E7EB] bg-white p-2 dark:border-[#27272a] dark:bg-[#111113]",children:[e.jsx("textarea",{"aria-label":a("chat.subagent.followUpAria"),value:v,onChange:A=>b(A.target.value),placeholder:a("chat.subagent.followUpPlaceholder"),rows:3,className:"w-full resize-y rounded border border-[#D1D5DB] bg-white p-2 text-[11px] text-[#111827] outline-none focus:border-[#8B5CF6] dark:border-[#3f3f46] dark:bg-[#18181b] dark:text-[#f4f4f5]"}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:()=>{c(!1),N(null)},className:"rounded px-2 py-1 text-[11px] text-[#6B7280] hover:bg-[#F3F4F6] dark:hover:bg-[#27272a]",children:a("chat.subagent.cancel")}),e.jsxs("button",{type:"button",onClick:()=>void ee(),disabled:!v.trim()||d,className:"flex items-center gap-1 rounded bg-[#7C3AED] px-2 py-1 text-[11px] font-medium text-white disabled:opacity-50",children:[d&&e.jsx(_,{className:"w-3 h-3 animate-spin"}),a("chat.subagent.resumeAgent")]})]})]}):e.jsxs("button",{type:"button","aria-label":a("chat.subagent.resumeAria"),onClick:()=>c(!0),className:"flex items-center gap-1.5 rounded-md border border-[#D1D5DB] px-2 py-1 text-[11px] font-medium text-[#374151] transition-colors hover:bg-[#F3F4F6] dark:border-[#3f3f46] dark:text-[#d4d4d8] dark:hover:bg-[#27272a]",children:[e.jsx(fe,{className:"w-3 h-3"}),a("chat.subagent.resume")]}),p&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:p})]})]})]})}function Ms({confirmation:t,messageId:a}){const s=B(),[r,o]=h.useState(!1),[i,l]=h.useState(null),u=f(v=>v.currentSessionRef),x=f(v=>v.setConfirmation);if(!t)return null;const c=async(v,b)=>{if(!K(f.getState())&&!(!u||r)){o(!0),l(null);try{await ae.respondPermission(u,t.toolCallId,{approved:v,scope:b}),x(a,{...t,status:v?"approved":"denied"})}catch(d){l(d instanceof Error?d.message:s("interaction.permission.failed"))}finally{o(!1)}}};return t.status!=="pending"?null:e.jsxs("div",{"data-pending-interaction":"permission",tabIndex:-1,role:"alert",className:"space-y-3 rounded-lg border border-amber-300/70 bg-amber-50/70 p-4 outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-800/70 dark:bg-amber-950/25",children:[e.jsx("div",{className:"text-[13px] text-[hsl(var(--deck-ink))] font-mono",children:s("interaction.permission.title",{tool:t.toolName})}),e.jsx("div",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:t.description}),t.diff&&e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[200px] overflow-y-auto",children:t.diff}),i&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-300/70 bg-red-50 px-2.5 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:i}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void c(!0,"once"),disabled:r,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#22C55E] text-white rounded-md hover:bg-[#16A34A] disabled:cursor-wait disabled:opacity-50",children:r?e.jsx(_,{className:"h-3.5 w-3.5 animate-spin"}):s("interaction.permission.once")}),t.allowRemember!==!1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>void c(!0,"session"),disabled:r,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#3B82F6] text-white rounded-md hover:bg-[#2563EB] disabled:cursor-wait disabled:opacity-50",children:s("interaction.permission.session")}),e.jsx("button",{type:"button",onClick:()=>void c(!0,"project"),disabled:r,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#6366F1] text-white rounded-md hover:bg-[#4F46E5] disabled:cursor-wait disabled:opacity-50",children:s("interaction.permission.project")})]}),e.jsx("button",{type:"button",onClick:()=>void c(!1),disabled:r,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#EF4444] text-white rounded-md hover:bg-[#DC2626] disabled:cursor-wait disabled:opacity-50",children:s("interaction.permission.deny")})]})]})}function As({question:t,messageId:a}){const s=B(),[r,o]=h.useState({}),[i,l]=h.useState({}),[u,x]=h.useState(!1),[c,v]=h.useState(null),b=f(m=>m.currentSessionRef),d=f(m=>m.setQuestion),y=h.useMemo(()=>t?t.questions.reduce((m,S)=>{var E;const k=(E=i[S.header])==null?void 0:E.trim(),w=r[S.header];if(S.multiSelect){const F=Array.isArray(w)?[...w]:[];return k&&F.push(k),F.length>0&&(m[S.header]=F),m}const n=k||(typeof w=="string"?w:"");return n&&(m[S.header]=n),m},{}):{},[r,i,t]),p=(t==null?void 0:t.questions.every(m=>m.header in y))??!1;if(!t)return null;const N=async()=>{if(!K(f.getState())&&!(!b||u||!p)){x(!0),v(null);try{await ae.respondToQuestion(b,t.toolCallId,y),d(a,{...t,status:"answered",answers:y})}catch(m){v(m instanceof Error?m.message:s("interaction.question.failed"))}finally{x(!1)}}};return t.status!=="pending"?e.jsx("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:e.jsx("div",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:s("interaction.question.answered")})}):e.jsxs("div",{"data-pending-interaction":"question",tabIndex:-1,role:"alert",className:"space-y-4 rounded-lg border border-amber-300/70 bg-amber-50/70 p-4 outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-800/70 dark:bg-amber-950/25",children:[t.questions.map((m,S)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[13px] text-[hsl(var(--deck-ink))] font-mono",children:m.question}),e.jsxs("div",{className:"space-y-1",children:[m.options.map((k,w)=>e.jsxs("button",{type:"button",onClick:()=>{if(m.multiSelect){const n=r[m.header]||[],E=n.includes(k.label)?n.filter(F=>F!==k.label):[...n,k.label];o({...r,[m.header]:E})}else o({...r,[m.header]:k.label}),l({...i,[m.header]:""})},className:D("w-full text-left px-3 py-2 rounded-md border text-[12px] font-mono transition-colors","border-[hsl(var(--deck-border))]",(m.multiSelect?(r[m.header]||[]).includes(k.label):r[m.header]===k.label)?"bg-[#DCFCE7] text-[#166534] dark:bg-[#22C55E]/20 dark:text-[#E5E5E5]":"bg-[hsl(var(--deck-surface-2))] text-[hsl(var(--deck-ink-muted))]"),children:[e.jsx("div",{children:k.label}),e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-faint))] mt-1",children:k.description})]},w)),e.jsx("input",{"aria-label":`${m.header} other response`,value:i[m.header]??"",onChange:k=>l({...i,[m.header]:k.target.value}),placeholder:s("interaction.question.other"),className:"w-full rounded-md border border-[#E5E7EB] bg-white px-3 py-2 text-[12px] text-[#111827] outline-none focus:border-[#22C55E] dark:border-[#27272a] dark:bg-[#111113] dark:text-[#E5E5E5]"})]})]},S)),c&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-300/70 bg-red-50 px-2.5 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:c}),e.jsxs("button",{type:"button",onClick:()=>void N(),disabled:u||!p,className:"inline-flex min-h-8 items-center gap-1.5 px-3 py-1.5 text-[12px] font-mono bg-[#22C55E] text-white rounded-md hover:bg-[#16A34A] disabled:cursor-wait disabled:opacity-50",children:[u&&e.jsx(_,{className:"h-3.5 w-3.5 animate-spin"}),s("interaction.question.submit")]})]})}function Rs({message:t}){const a=t.agentContent,s=f(p=>p.isStreaming&&p.currentAssistantMessageId===t.id);if(!a){const p=De(t.content);return p?e.jsx(Oe,{content:p}):null}const{toolCalls:r,tasks:o,confirmation:i,question:l,elicitation:u}=a,x=Et(a),c=Mt(a);if(!(c.length>0||o.length>0||x.length>0||i||l||u)&&s)return e.jsxs("div",{className:"flex items-center gap-2 text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(_,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{className:"text-[12px] font-mono",children:"Thinking..."})]});const d=r.length>0&&r.every(p=>p.status==="success"||p.status==="error")&&!s,y=!s;return e.jsxs("div",{className:"space-y-3",children:[c.map(p=>p.type==="thinking"?e.jsx("div",{"data-agent-timeline-block":"thinking",children:e.jsx(Ss,{content:p.content})},p.id):p.type==="text"?e.jsx("div",{"data-agent-timeline-block":"text",children:e.jsx(Oe,{content:p.content,syntaxHighlight:y})},p.id):e.jsx("div",{"data-agent-timeline-block":"tool_group",children:e.jsx(Ns,{toolCalls:r,toolCallIds:p.toolCallIds})},p.id)),o.length>0&&e.jsx(Cs,{tasks:o}),x.map(p=>e.jsx(Es,{subagent:p},p.id)),i&&e.jsx(Ms,{confirmation:i,messageId:t.id}),l&&e.jsx(As,{question:l,messageId:t.id}),u&&e.jsx(os,{elicitation:u,messageId:t.id}),d&&e.jsx(Ts,{toolCalls:r})]})}function Fs({message:t,showAvatar:a=!0}){var u,x,c,v;const s=t.role==="user";if(t.role==="system"){const b=De(t.content);return e.jsx("div",{"data-chat-message-id":t.id,"data-chat-role":"system",className:"flex justify-center p-2 w-full",children:e.jsx("div",{className:"text-xs text-[hsl(var(--deck-ink-muted))] bg-[#F3F4F6] dark:bg-[#18181b] px-3 py-1 rounded-full font-mono",children:b})})}if(s){const b=(u=t.metadata)!=null&&u.userShellCommand&&typeof t.metadata.userShellCommand=="object"?t.metadata.userShellCommand:(x=t.metadata)!=null&&x.userShellExecution&&typeof t.metadata.userShellExecution=="object"?t.metadata.userShellExecution:void 0;if(b){const p=typeof b.command=="string"?b.command:"",N=b.status==="running"?"running":b.status==="completed"?"success":"error",m=typeof b.output=="string"?b.output:[typeof b.stdout=="string"?b.stdout:"",typeof b.stderr=="string"&&b.stderr?`stderr:
|
|
59
|
+
${je(b,d-y)}`}else c=je(o,l);return{body:ot(c,l),...r?{notice:r}:{},truncated:!!r||t.length>Ke}}function Ns({tool:t}){const[a,s]=h.useState(!1),r=js(t.arguments),o=t.output?ws(t.output):void 0;return e.jsxs("div",{"data-tool-name":t.toolName,"data-tool-status":t.status,"data-tool-truncated":o!=null&&o.truncated?"true":"false",className:"bg-white dark:bg-[#18181b] border border-[hsl(var(--deck-border))] rounded-lg overflow-hidden",children:[e.jsxs("button",{type:"button","aria-expanded":a,"data-tool-call-id":t.toolCallId,onClick:()=>s(i=>!i),className:"w-full flex items-center justify-between px-3 py-2 bg-[hsl(var(--deck-surface-2))] hover:bg-[hsl(var(--deck-surface))] transition-colors",children:[e.jsxs("div",{className:"flex gap-2 items-center min-w-0",children:[a?e.jsx(me,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))] shrink-0"}):e.jsx(oe,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))] shrink-0"}),e.jsx("span",{className:"text-[12px] text-[hsl(var(--deck-ink))] font-mono shrink-0",children:t.toolName}),t.summary&&e.jsx("span",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono truncate",children:t.summary})]}),e.jsx(Ie,{status:t.status})]}),t.status==="running"&&t.progressMessage&&e.jsxs("div",{className:"border-t border-[hsl(var(--deck-border))] px-3 py-2 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 font-mono text-[10px] text-[hsl(var(--deck-ink-muted))]",children:[e.jsx("span",{className:"truncate",children:t.progressMessage}),t.progressTotal!==void 0&&t.progress!==void 0&&e.jsxs("span",{className:"shrink-0",children:[Math.max(0,Math.min(100,Math.round(t.progress/t.progressTotal*100))),"%"]})]}),t.progressTotal!==void 0&&t.progress!==void 0&&e.jsx("div",{role:"progressbar","aria-label":`${t.toolName} progress`,"aria-valuemin":0,"aria-valuemax":t.progressTotal,"aria-valuenow":Math.min(t.progress,t.progressTotal),className:"h-1 overflow-hidden rounded-full bg-[hsl(var(--deck-border))]",children:e.jsx("div",{className:"h-full rounded-full bg-amber-500 transition-[width] duration-150",style:{width:`${Math.max(0,Math.min(100,t.progress/t.progressTotal*100))}%`}})})]}),a&&e.jsxs("div",{className:"px-3 py-2 space-y-2 border-t border-[hsl(var(--deck-border))]",children:[r&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono",children:"Arguments"}),e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[120px] overflow-y-auto",children:r})]}),o&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono",children:"Output"}),e.jsxs("pre",{"data-tool-output":!0,className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[120px] overflow-y-auto",children:[o.body,o.notice&&e.jsxs(e.Fragment,{children:[`
|
|
60
|
+
`,e.jsx("span",{"data-tool-truncation-notice":!0,children:o.notice})]})]})]})]})]})}function ct({toolCalls:t}){return t.length===0?null:e.jsx("div",{className:"space-y-2",children:t.map(a=>e.jsx(Ns,{tool:a},a.toolCallId))})}function Ss({toolCalls:t,toolCallIds:a}){const s=B(),[r,o]=h.useState(!1),i=h.useMemo(()=>new Map(t.map(b=>[b.toolCallId,b])),[t]),l=a.flatMap(b=>{const d=i.get(b);return d?[d]:[]});if(l.length===0)return null;const u=l.filter(b=>b.status==="running").length,x=l.filter(b=>b.status==="error").length,c=[...l].reverse().find(b=>b.status==="running"&&!!b.progressMessage),v=u>0?s(l.length===1?"chat.timeline.tools.runningOne":"chat.timeline.tools.running",{count:l.length}):x>0?s(l.length===1?"chat.timeline.tools.completedOneWithError":"chat.timeline.tools.completedWithErrors",{count:l.length,errors:x}):s(l.length===1?"chat.timeline.tools.completedOne":"chat.timeline.tools.completed",{count:l.length});return e.jsxs("div",{"data-agent-tool-group":!0,className:"py-0.5",children:[e.jsxs("button",{type:"button","aria-expanded":r,onClick:()=>o(b=>!b),className:"group flex min-h-7 w-full items-center gap-1.5 rounded-md px-1.5 text-left font-mono text-[11.5px] text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))]/65 hover:text-[hsl(var(--deck-ink-muted))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[r?e.jsx(me,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(oe,{className:"h-3.5 w-3.5 shrink-0"}),u>0&&e.jsx(_,{className:"h-3 w-3 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"}),e.jsx("span",{children:v}),(c==null?void 0:c.progressMessage)&&e.jsxs("span",{className:"min-w-0 truncate text-[10.5px] text-[hsl(var(--deck-ink-muted))]",children:[c.progressMessage,c.progress!==void 0&&c.progressTotal!==void 0&&` · ${Math.max(0,Math.min(100,Math.round(c.progress/c.progressTotal*100)))}%`]})]}),(c==null?void 0:c.progress)!==void 0&&c.progressTotal!==void 0&&e.jsx("div",{role:"progressbar","aria-label":`${c.toolName} progress`,"aria-valuemin":0,"aria-valuemax":c.progressTotal,"aria-valuenow":Math.min(c.progress,c.progressTotal),className:"mx-1.5 h-0.5 overflow-hidden rounded-full bg-[hsl(var(--deck-border))]",children:e.jsx("div",{className:"h-full rounded-full bg-amber-500 transition-[width] duration-150",style:{width:`${Math.max(0,Math.min(100,c.progress/c.progressTotal*100))}%`}})}),r&&e.jsx("div",{"data-agent-tool-group-details":!0,className:"pl-1 mt-2 space-y-2",children:e.jsx(ct,{toolCalls:l})})]})}function Cs({content:t}){const a=B(),[s,r]=h.useState(!1);return t?e.jsxs("div",{"data-agent-thinking":!0,className:"py-0.5",children:[e.jsxs("button",{type:"button","aria-expanded":s,onClick:()=>r(o=>!o),className:"flex min-h-7 w-full items-center gap-1.5 rounded-md px-1.5 text-left font-mono text-[11.5px] text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))]/65 hover:text-[hsl(var(--deck-ink-muted))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[s?e.jsx(me,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))]"}):e.jsx(oe,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{children:a("chat.timeline.thinking")})]}),s&&e.jsx("div",{className:"ml-1 mt-1 border-l border-[hsl(var(--deck-border))] py-1 pl-3",children:e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-[11px] leading-5 text-[hsl(var(--deck-ink-muted))]",children:t})})]}):null}function Ts({tasks:t}){if(t.length===0)return null;const a=t.filter(r=>r.status==="completed").length,s=a===t.length;return e.jsx("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:e.jsx("div",{className:"flex gap-2 items-center",children:e.jsx("span",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:s?"✓ All tasks done":`Tasks: ${a}/${t.length}`})})})}function Es({toolCalls:t}){const a=Re(i=>i.openFilePreview),s=f(i=>ie(i.historySurfaceSelection)),r=h.useMemo(()=>{const i=new Map,l=["Write","SearchReplace","Edit","ApplyPatch"];for(const u of t){if(u.status!=="success")continue;const x=u.metadata;if(u.toolName==="ApplyPatch"&&Array.isArray(x==null?void 0:x.changes)){for(const v of x.changes)v&&typeof v=="object"&&"path"in v&&typeof v.path=="string"&&i.set(v.path,{path:v.path,toolName:u.toolName});continue}const c=x==null?void 0:x.file_path;c&&l.includes(u.toolName)&&i.set(c,{path:c,toolName:u.toolName})}return Array.from(i.values())},[t]);if(s||r.length===0)return null;const o=i=>{K(f.getState())||a({tab:"diff",targetPath:i})};return e.jsxs("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:[e.jsxs("div",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono mb-1.5",children:["Changed files (",r.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.map(({path:i})=>{const l=i.split("/").pop()||i;return e.jsxs("button",{onClick:()=>o(i),className:"flex items-center gap-1 px-2 py-1 text-[11px] font-mono bg-[#E5E7EB] dark:bg-[#27272a] text-[hsl(var(--deck-ink))] rounded hover:bg-[#D1D5DB] dark:hover:bg-[#3f3f46] transition-colors",title:i,children:[e.jsx(bt,{className:"w-3 h-3"}),l]},i)})})]})}function Ms({subagent:t}){var Q,Z,J,te;const a=B(),[s,r]=h.useState(null),[o,i]=h.useState(!1),[l,u]=h.useState(null),[x,c]=h.useState(!1),[v,b]=h.useState(""),[d,y]=h.useState(!1),[p,N]=h.useState(null),[m,S]=h.useState(null),[k,w]=h.useState(null),n=f(A=>A.currentSessionRef),E=f(A=>A.isStreaming),F=f(A=>A.isTemporarySession),R=f(A=>ie(A.historySurfaceSelection));if(!t)return null;const j=t.status==="running",O=s!==null?s:j,G=t.toolCalls||l||[],C=t.output||t.thinking||G.length>0||t.sessionId,T=m&&m.status!=="running"?m:k,M=(T==null?void 0:T.id)??t.sessionId,P=((Q=T==null?void 0:T.restartRecovery)==null?void 0:Q.outcome)==="failed",L=!j&&!E&&!F&&!R&&!P&&(m==null?void 0:m.status)!=="running"&&!!(M&&n);h.useEffect(()=>{if(R||!O||j||!t.sessionId||!(n!=null&&n.projectPath)||l!==null||t.toolCalls&&t.toolCalls.length>0)return;let A=!0;return i(!0),ae.getMessages({sessionId:t.sessionId,projectPath:n.projectPath}).then(z=>{var H,$;if(!A)return;const q=Rt(z),V=new Map;for(const W of q)if(($=(H=W.agentContent)==null?void 0:H.toolCalls)!=null&&$.length)for(const Y of W.agentContent.toolCalls)V.has(Y.toolCallId)||V.set(Y.toolCallId,Y);u(Array.from(V.values()))}).finally(()=>{A&&i(!1)}),()=>{A=!1}},[O,R,j,t.sessionId,t.toolCalls,l,n==null?void 0:n.projectPath]),h.useEffect(()=>{if(R||!t.sessionId||!n)return;let A=!0;const z=t.rootAgentId??t.sessionId,q=t.resumeDepth??0;return ae.listSubagents(n).then(V=>{if(!A)return;w(V.find($=>$.id===t.sessionId)??null);const H=V.filter($=>$.id!==t.sessionId&&$.rootAgentId===z&&$.resumeDepth>q).sort(($,W)=>W.resumeDepth-$.resumeDepth||W.lastActiveAt-$.lastActiveAt)[0];H&&S(H)}).catch(()=>{}),()=>{A=!1}},[n==null?void 0:n.sessionId,n==null?void 0:n.projectPath,R,t.sessionId,t.rootAgentId,t.resumeDepth]),h.useEffect(()=>{if(R||!m||m.status!=="running"||!n)return;let A=!0;const z=async()=>{try{const H=(await ae.listSubagents(n)).find($=>$.id===m.id);A&&H&&S(H)}catch{}},q=window.setInterval(()=>{z()},1e3);return()=>{A=!1,window.clearInterval(q)}},[n,R,m==null?void 0:m.id,m==null?void 0:m.status]);const ee=async()=>{if(!K(f.getState())&&!(!n||!M||!v.trim()||d)){y(!0),N(null);try{const A=await ae.resumeSubagent(n,M,v.trim());S(A.session),b(""),c(!1),r(!0)}catch(A){N(A instanceof Error?A.message:a("chat.subagent.resumeFailed"))}finally{y(!1)}}};return e.jsxs("div",{"data-subagent-id":t.id,"data-subagent-session-id":t.sessionId,className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:[e.jsxs("button",{type:"button",onClick:()=>r(!O),className:"flex gap-2 justify-between items-center w-full transition-opacity cursor-pointer hover:opacity-80",children:[e.jsxs("div",{className:"flex gap-2 items-center",children:[j&&e.jsx(_,{className:"h-3 w-3 animate-spin text-[hsl(var(--deck-ink-muted))]"}),e.jsxs("span",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:[t.type,": ",t.description]}),e.jsx(Ie,{status:t.status==="completed"?"success":t.status==="failed"?"error":"running"}),t.type==="verification"&&t.verificationVerdict&&e.jsx("span",{"data-verification-verdict":t.verificationVerdict,className:D("rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide",t.verificationVerdict==="pass"?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":t.verificationVerdict==="fail"?"bg-red-500/10 text-red-600 dark:text-red-400":"bg-amber-500/10 text-amber-600 dark:text-amber-400"),children:t.verificationVerdict}),t.resumedFrom&&e.jsx("span",{className:"rounded bg-[#EDE9FE] px-1.5 py-0.5 text-[10px] font-mono text-[#6D28D9] dark:bg-[#2E1065] dark:text-[#C4B5FD]",title:a("chat.subagent.resumedFromTitle",{id:t.resumedFrom}),children:a("chat.subagent.resumedDepth",{depth:t.resumeDepth??1})})]}),C&&e.jsx(me,{className:D("h-3.5 w-3.5 text-[hsl(var(--deck-ink-muted))] transition-transform",O&&"rotate-180")})]}),!O&&!j&&t.output&&e.jsx("div",{"data-subagent-output-summary":!0,className:"mt-2 max-h-10 overflow-hidden whitespace-pre-wrap break-words font-mono text-[11px] text-[hsl(var(--deck-ink))]",children:t.output}),O&&e.jsxs("div",{className:"mt-2 space-y-2",children:[(t.output||t.thinking)&&e.jsxs(e.Fragment,{children:[t.output&&e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[160px] overflow-y-auto",children:t.output}),t.thinking&&e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink-muted))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[120px] overflow-y-auto",children:t.thinking})]}),o&&e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-[hsl(var(--deck-ink-muted))] font-mono",children:[e.jsx(_,{className:"w-3 h-3 animate-spin"}),a("chat.subagent.loadingLogs")]}),!o&&G.length>0&&e.jsx(ct,{toolCalls:G}),m&&e.jsxs("div",{className:"rounded-md border border-[#DDD6FE] bg-[#F5F3FF] p-2 text-[11px] font-mono text-[#5B21B6] dark:border-[#4C1D95] dark:bg-[#1E1B4B] dark:text-[#C4B5FD]",children:[e.jsx("div",{children:a("chat.subagent.resumedAs",{id:m.id,status:m.status,depth:m.resumeDepth??1})}),(((Z=m.result)==null?void 0:Z.message)||((J=m.result)==null?void 0:J.error))&&e.jsx("div",{className:"mt-1 whitespace-pre-wrap text-[hsl(var(--deck-ink))]",children:m.result.message||m.result.error})]}),P&&((te=T==null?void 0:T.result)==null?void 0:te.error)&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:T.result.error}),L&&e.jsxs("div",{className:"space-y-2",children:[x?e.jsxs("div",{className:"space-y-2 rounded-md border border-[#E5E7EB] bg-white p-2 dark:border-[#27272a] dark:bg-[#111113]",children:[e.jsx("textarea",{"aria-label":a("chat.subagent.followUpAria"),value:v,onChange:A=>b(A.target.value),placeholder:a("chat.subagent.followUpPlaceholder"),rows:3,className:"w-full resize-y rounded border border-[#D1D5DB] bg-white p-2 text-[11px] text-[#111827] outline-none focus:border-[#8B5CF6] dark:border-[#3f3f46] dark:bg-[#18181b] dark:text-[#f4f4f5]"}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{type:"button",onClick:()=>{c(!1),N(null)},className:"rounded px-2 py-1 text-[11px] text-[#6B7280] hover:bg-[#F3F4F6] dark:hover:bg-[#27272a]",children:a("chat.subagent.cancel")}),e.jsxs("button",{type:"button",onClick:()=>void ee(),disabled:!v.trim()||d,className:"flex items-center gap-1 rounded bg-[#7C3AED] px-2 py-1 text-[11px] font-medium text-white disabled:opacity-50",children:[d&&e.jsx(_,{className:"w-3 h-3 animate-spin"}),a("chat.subagent.resumeAgent")]})]})]}):e.jsxs("button",{type:"button","aria-label":a("chat.subagent.resumeAria"),onClick:()=>c(!0),className:"flex items-center gap-1.5 rounded-md border border-[#D1D5DB] px-2 py-1 text-[11px] font-medium text-[#374151] transition-colors hover:bg-[#F3F4F6] dark:border-[#3f3f46] dark:text-[#d4d4d8] dark:hover:bg-[#27272a]",children:[e.jsx(fe,{className:"w-3 h-3"}),a("chat.subagent.resume")]}),p&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:p})]})]})]})}function As({confirmation:t,messageId:a}){const s=B(),[r,o]=h.useState(!1),[i,l]=h.useState(null),u=f(v=>v.currentSessionRef),x=f(v=>v.setConfirmation);if(!t)return null;const c=async(v,b)=>{if(!K(f.getState())&&!(!u||r)){o(!0),l(null);try{await ae.respondPermission(u,t.toolCallId,{approved:v,scope:b}),x(a,{...t,status:v?"approved":"denied"})}catch(d){l(d instanceof Error?d.message:s("interaction.permission.failed"))}finally{o(!1)}}};return t.status!=="pending"?null:e.jsxs("div",{"data-pending-interaction":"permission",tabIndex:-1,role:"alert",className:"p-4 space-y-3 rounded-lg border outline-none border-amber-300/70 bg-amber-50/70 focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-800/70 dark:bg-amber-950/25",children:[e.jsx("div",{className:"text-[13px] text-[hsl(var(--deck-ink))] font-mono",children:s("interaction.permission.title",{tool:t.toolName})}),e.jsx("div",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:t.description}),t.diff&&e.jsx("pre",{className:"text-[11px] text-[hsl(var(--deck-ink))] bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-md p-2 overflow-x-auto whitespace-pre-wrap font-mono max-h-[200px] overflow-y-auto",children:t.diff}),i&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-300/70 bg-red-50 px-2.5 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:i}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void c(!0,"once"),disabled:r,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#22C55E] text-white rounded-md hover:bg-[#16A34A] disabled:cursor-wait disabled:opacity-50",children:r?e.jsx(_,{className:"h-3.5 w-3.5 animate-spin"}):s("interaction.permission.once")}),t.allowRemember!==!1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>void c(!0,"session"),disabled:r,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#3B82F6] text-white rounded-md hover:bg-[#2563EB] disabled:cursor-wait disabled:opacity-50",children:s("interaction.permission.session")}),e.jsx("button",{type:"button",onClick:()=>void c(!0,"project"),disabled:r,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#6366F1] text-white rounded-md hover:bg-[#4F46E5] disabled:cursor-wait disabled:opacity-50",children:s("interaction.permission.project")})]}),e.jsx("button",{type:"button",onClick:()=>void c(!1),disabled:r,className:"min-h-8 px-3 py-1.5 text-[12px] font-mono bg-[#EF4444] text-white rounded-md hover:bg-[#DC2626] disabled:cursor-wait disabled:opacity-50",children:s("interaction.permission.deny")})]})]})}function Rs({question:t,messageId:a}){const s=B(),[r,o]=h.useState({}),[i,l]=h.useState({}),[u,x]=h.useState(!1),[c,v]=h.useState(null),b=f(m=>m.currentSessionRef),d=f(m=>m.setQuestion),y=h.useMemo(()=>t?t.questions.reduce((m,S)=>{var E;const k=(E=i[S.header])==null?void 0:E.trim(),w=r[S.header];if(S.multiSelect){const F=Array.isArray(w)?[...w]:[];return k&&F.push(k),F.length>0&&(m[S.header]=F),m}const n=k||(typeof w=="string"?w:"");return n&&(m[S.header]=n),m},{}):{},[r,i,t]),p=(t==null?void 0:t.questions.every(m=>m.header in y))??!1;if(!t)return null;const N=async()=>{if(!K(f.getState())&&!(!b||u||!p)){x(!0),v(null);try{await ae.respondToQuestion(b,t.toolCallId,y),d(a,{...t,status:"answered",answers:y})}catch(m){v(m instanceof Error?m.message:s("interaction.question.failed"))}finally{x(!1)}}};return t.status!=="pending"?e.jsx("div",{className:"bg-[hsl(var(--deck-surface-2))] border border-[hsl(var(--deck-border))] rounded-lg px-3 py-2",children:e.jsx("div",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:s("interaction.question.answered")})}):e.jsxs("div",{"data-pending-interaction":"question",tabIndex:-1,role:"alert",className:"p-4 space-y-4 rounded-lg border outline-none border-amber-300/70 bg-amber-50/70 focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-800/70 dark:bg-amber-950/25",children:[t.questions.map((m,S)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[13px] text-[hsl(var(--deck-ink))] font-mono",children:m.question}),e.jsxs("div",{className:"space-y-1",children:[m.options.map((k,w)=>e.jsxs("button",{type:"button",onClick:()=>{if(m.multiSelect){const n=r[m.header]||[],E=n.includes(k.label)?n.filter(F=>F!==k.label):[...n,k.label];o({...r,[m.header]:E})}else o({...r,[m.header]:k.label}),l({...i,[m.header]:""})},className:D("w-full text-left px-3 py-2 rounded-md border text-[12px] font-mono transition-colors","border-[hsl(var(--deck-border))]",(m.multiSelect?(r[m.header]||[]).includes(k.label):r[m.header]===k.label)?"bg-[#DCFCE7] text-[#166534] dark:bg-[#22C55E]/20 dark:text-[#E5E5E5]":"bg-[hsl(var(--deck-surface-2))] text-[hsl(var(--deck-ink-muted))]"),children:[e.jsx("div",{children:k.label}),e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-faint))] mt-1",children:k.description})]},w)),e.jsx("input",{"aria-label":`${m.header} other response`,value:i[m.header]??"",onChange:k=>l({...i,[m.header]:k.target.value}),placeholder:s("interaction.question.other"),className:"w-full rounded-md border border-[#E5E7EB] bg-white px-3 py-2 text-[12px] text-[#111827] outline-none focus:border-[#22C55E] dark:border-[#27272a] dark:bg-[#111113] dark:text-[#E5E5E5]"})]})]},S)),c&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-300/70 bg-red-50 px-2.5 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:c}),e.jsxs("button",{type:"button",onClick:()=>void N(),disabled:u||!p,className:"inline-flex min-h-8 items-center gap-1.5 px-3 py-1.5 text-[12px] font-mono bg-[#22C55E] text-white rounded-md hover:bg-[#16A34A] disabled:cursor-wait disabled:opacity-50",children:[u&&e.jsx(_,{className:"h-3.5 w-3.5 animate-spin"}),s("interaction.question.submit")]})]})}function Fs({message:t}){const a=t.agentContent,s=f(p=>p.isStreaming&&p.currentAssistantMessageId===t.id);if(!a){const p=De(t.content);return p?e.jsx(Oe,{content:p}):null}const{toolCalls:r,tasks:o,confirmation:i,question:l,elicitation:u}=a,x=Et(a),c=Mt(At(a));if(!(c.length>0||o.length>0||x.length>0||i||l||u)&&s)return e.jsxs("div",{className:"flex items-center gap-2 text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(_,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{className:"text-[12px] font-mono",children:"Thinking..."})]});const d=r.length>0&&r.every(p=>p.status==="success"||p.status==="error")&&!s,y=!s;return e.jsxs("div",{className:"space-y-3",children:[c.map(p=>p.type==="thinking"?e.jsx("div",{"data-agent-timeline-block":"thinking",children:e.jsx(Cs,{content:p.content})},p.id):p.type==="text"?e.jsx("div",{"data-agent-timeline-block":"text",children:e.jsx(Oe,{content:p.content,syntaxHighlight:y})},p.id):e.jsx("div",{"data-agent-timeline-block":"tool_group",children:e.jsx(Ss,{toolCalls:r,toolCallIds:p.toolCallIds})},p.id)),o.length>0&&e.jsx(Ts,{tasks:o}),x.map(p=>e.jsx(Ms,{subagent:p},p.id)),i&&e.jsx(As,{confirmation:i,messageId:t.id}),l&&e.jsx(Rs,{question:l,messageId:t.id}),u&&e.jsx(cs,{elicitation:u,messageId:t.id}),d&&e.jsx(Es,{toolCalls:r})]})}function Ds({message:t,showAvatar:a=!0}){var u,x,c,v;const s=t.role==="user";if(t.role==="system"){const b=De(t.content);return e.jsx("div",{"data-chat-message-id":t.id,"data-chat-role":"system",className:"flex justify-center p-2 w-full",children:e.jsx("div",{className:"text-xs text-[hsl(var(--deck-ink-muted))] bg-[#F3F4F6] dark:bg-[#18181b] px-3 py-1 rounded-full font-mono",children:b})})}if(s){const b=(u=t.metadata)!=null&&u.userShellCommand&&typeof t.metadata.userShellCommand=="object"?t.metadata.userShellCommand:(x=t.metadata)!=null&&x.userShellExecution&&typeof t.metadata.userShellExecution=="object"?t.metadata.userShellExecution:void 0;if(b){const p=typeof b.command=="string"?b.command:"",N=b.status==="running"?"running":b.status==="completed"?"success":"error",m=typeof b.output=="string"?b.output:[typeof b.stdout=="string"?b.stdout:"",typeof b.stderr=="string"&&b.stderr?`stderr:
|
|
61
61
|
${b.stderr}`:""].filter(Boolean).join(`
|
|
62
|
-
`);return e.jsx("div",{"data-chat-message-id":t.id,"data-chat-role":"user","data-user-shell-command":!0,className:"flex w-full justify-end p-4",children:e.jsxs("div",{className:"w-full max-w-[85%] overflow-hidden rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2",children:[e.jsxs("div",{className:"min-w-0 truncate font-mono text-[12px] text-[hsl(var(--deck-ink))]",children:[e.jsx("span",{className:"mr-2 text-amber-600 dark:text-amber-400",children:"$"}),p]}),e.jsx(Ie,{status:N})]}),e.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap px-3 py-2 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))]",children:m||"(no output)"}),typeof b.exitCode=="number"&&e.jsxs("div",{className:"border-t border-[hsl(var(--deck-border))] px-3 py-1.5 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:["exit ",b.exitCode,typeof b.durationMs=="number"?` · ${(b.durationMs/1e3).toFixed(3)}s`:"",b.truncated===!0?" · truncated":""]})]})})}const{text:d,images:y}=gs(t.content);return e.jsxs("div",{"data-chat-message-id":t.id,"data-chat-role":"user",className:"group flex gap-2 justify-end p-4 w-full items-start",children:[e.jsx("div",{className:"mt-1 flex shrink-0 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",children:e.jsx(Le,{text:d,label:"Copy message"})}),e.jsxs("div",{className:"bg-[hsl(var(--deck-surface-2))] rounded-lg px-4 py-3 max-w-[85%]",children:[d&&e.jsx("p",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono leading-relaxed whitespace-pre-wrap",children:d}),y.length>0&&e.jsx("div",{className:D("grid gap-2",y.length===1?"grid-cols-1 mt-0":"grid-cols-2 mt-3"),children:y.map((p,N)=>e.jsx("img",{src:p,alt:`attachment-${N+1}`,className:"object-cover w-full max-h-64 rounded-md"},`${p}-${N}`))})]}),e.jsx(vs,{})]})}const o=ks(t),i=rs((c=t.metadata)==null?void 0:c.codeReview),l=xs((v=t.metadata)==null?void 0:v.structuredOutput);return e.jsxs("div",{"data-chat-message-id":t.id,"data-chat-role":"assistant",className:D("group flex gap-4 justify-start w-full",a?"p-4":"px-4 pt-0 pb-3"),children:[a?e.jsx(bs,{}):e.jsx("div",{className:"w-8 shrink-0"}),e.jsxs("div",{className:"overflow-hidden flex-1 min-w-0",children:[i?e.jsx(is,{report:i}):l?e.jsx(ps,{report:l}):e.jsx(Rs,{message:t}),!l&&o.trim()&&e.jsx("div",{className:"mt-1.5 flex opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",children:e.jsx(Le,{text:o,label:"Copy response"})})]})]})}const Ds=h.memo(Fs);function Is(t,a,s){return Math.max(0,t+(s-a))}function $s(t,a,s){return Math.min(a,Math.max(0,t)+Math.max(0,s))}function _s(t,a,s,r){const o=new Map(t.filter(l=>!!l.id).map(l=>[l.id,l])),i=new Set(s);for(const l of a){if(!l.id)continue;const u=o.get(l.id);u!==l&&(!u||!r||r(u)!==r(l))&&i.add(l.id)}return i}function He(t,a){return t?t.querySelector(`[data-chat-message-id="${CSS.escape(a)}"]`):null}function Bs({turns:t,viewportRef:a,containerRef:s,onRevealTurn:r}){const o=B(),[i,l]=h.useState(null),[u,x]=h.useState(!1),c=h.useRef(null),v=h.useCallback(()=>{var m;const d=a.current,y=s.current;if(!d||!y||t.length===0)return;const p=d.getBoundingClientRect().top;let N=((m=t[0])==null?void 0:m.id)??null;for(const S of t){const k=He(y,S.id);if(k)if(k.getBoundingClientRect().top-p<=24)N=S.id;else break}l(N)},[t,a,s]);h.useEffect(()=>{const d=a.current;if(!d)return;const y=()=>{c.current===null&&(c.current=window.requestAnimationFrame(()=>{c.current=null,v()}))};return v(),d.addEventListener("scroll",y,{passive:!0}),()=>{d.removeEventListener("scroll",y),c.current!==null&&(window.cancelAnimationFrame(c.current),c.current=null)}},[v,a]);const b=h.useCallback(d=>{const y=()=>{const N=He(s.current,d.id);N&&(N.scrollIntoView({behavior:"smooth",block:"start"}),l(d.id))};r(d.index)?y():window.requestAnimationFrame(()=>window.requestAnimationFrame(y))},[s,r]);return t.length<2?null:e.jsx("nav",{"aria-label":o("chat.turns.aria"),className:"absolute right-1 top-1/2 z-20 hidden -translate-y-1/2 sm:block",onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),onFocusCapture:()=>x(!0),onBlurCapture:d=>{d.currentTarget.contains(d.relatedTarget)||x(!1)},children:e.jsxs("div",{className:"relative flex items-center justify-end",children:[e.jsx("ul",{className:D("flex flex-col items-center gap-2 py-2 transition-opacity",u?"opacity-0":"opacity-100"),"aria-hidden":u,children:t.map(d=>e.jsx("li",{children:e.jsx("span",{className:D("block rounded-full transition-all",d.id===i?"h-2 w-2 bg-[hsl(var(--deck-accent))]":"h-1.5 w-1.5 bg-[hsl(var(--deck-ink-faint))]/40")})},d.id))}),e.jsx("div",{className:D("absolute right-0 max-h-[min(70vh,520px)] w-[280px] overflow-y-auto rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]/95 p-1 shadow-xl backdrop-blur transition-all",u?"pointer-events-auto translate-x-0 opacity-100":"pointer-events-none translate-x-2 opacity-0"),children:t.map((d,y)=>e.jsxs("button",{type:"button",onClick:()=>b(d),className:D("flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors",d.id===i?"bg-[hsl(var(--deck-hairline))]/70 text-[hsl(var(--deck-ink))]":"text-[hsl(var(--deck-ink-muted))] hover:bg-[hsl(var(--deck-hairline))]/50 hover:text-[hsl(var(--deck-ink))]"),children:[e.jsx("span",{className:D("mt-1 h-1.5 w-1.5 shrink-0 rounded-full",d.id===i?"bg-[hsl(var(--deck-accent))]":"bg-[hsl(var(--deck-ink-faint))]/40")}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block font-mono text-[9.5px] uppercase tracking-[0.12em] text-[hsl(var(--deck-ink-faint))]",children:o("chat.turns.label",{n:y+1})}),e.jsx("span",{className:"line-clamp-2 text-[12px] leading-4",children:d.preview})]})]},d.id))})]})})}const Qe=80;function Ps(t){return typeof t=="string"?t:Array.isArray(t)?t.filter(a=>a.type==="text").map(a=>a.text).join(" "):""}function Ls(t){const a=Ps(t).replace(/\s+/g," ").trim();return a?a.length>Qe?`${a.slice(0,Qe-1)}…`:a:""}function Us(t){const a=[];for(let s=0;s<t.length;s+=1){const r=t[s];if(r.role!=="user"||!r.id)continue;const o=Ls(r.content);o&&a.push({id:r.id,index:s,preview:o})}return a}const we=120,Ne=80,Os=96;function le(t){return(t==null?void 0:t.querySelector("[data-radix-scroll-area-viewport]"))??null}function Ks(t){return JSON.stringify([t.role,t.content,t.metadata,t.agentContent])}function Vs({messages:t,isLoading:a}){const s=B(),r=h.useRef(null),o=h.useRef(null),i=h.useRef(!0),l=h.useRef(!1),u=h.useRef(t),x=h.useRef(t),c=h.useRef(new Set),v=h.useRef(t.length),b=h.useRef(null),[d,y]=h.useState(we),[p,N]=h.useState(!1),[m,S]=h.useState(0),k=t.length>0;u.current=t,h.useEffect(()=>{const C=le(r.current);if(!C||l.current&&!i.current)return;const T=window.requestAnimationFrame(()=>{C.scrollTop=C.scrollHeight,l.current=!0,i.current=!0,c.current=new Set,S(0),N(!1)});return()=>window.cancelAnimationFrame(T)},[t]),h.useEffect(()=>{const C=le(r.current);if(!C)return;o.current=C;const T=()=>{if(!l.current)return;const P=C.scrollHeight-C.scrollTop-C.clientHeight<=Os,L=i.current;i.current=P,N(!P),P?(c.current=new Set,S(0)):L&&(x.current=u.current,c.current=new Set,S(0))};return T(),C.addEventListener("scroll",T,{passive:!0}),()=>C.removeEventListener("scroll",T)},[k,a]),h.useEffect(()=>{const C=x.current;if(x.current=t,i.current){c.current.size>0&&(c.current=new Set,S(0));return}const T=_s(C,t,c.current,Ks);c.current=T,S(T.size)},[t]),h.useEffect(()=>{const C=v.current;v.current=t.length,y(T=>T>=C&&t.length>C?t.length:Math.min(Math.max(T,we),t.length||we))},[t.length]);const w=Math.max(t.length-d,0),n=w,E=h.useMemo(()=>t.slice(n),[t,n]),F=h.useMemo(()=>Us(t),[t]);if(h.useLayoutEffect(()=>{var M;const C=b.current;if(!C)return;const T=le(r.current);if(b.current=null,!!T){if((M=C.element)!=null&&M.isConnected){const P=C.element.getBoundingClientRect().top-C.viewportTop;T.scrollTop+=P;return}T.scrollTop=Is(C.scrollTop,C.scrollHeight,T.scrollHeight)}},[d]),a)return e.jsx("div",{role:"status","aria-live":"polite","aria-busy":"true",className:"flex overflow-hidden flex-1 justify-center items-center px-5 py-8 min-h-0",children:e.jsxs("div",{className:"w-full max-w-[560px]",children:[e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 animate-pulse rounded-full bg-[hsl(var(--deck-accent-soft))] blur-xl"}),e.jsx(Ce,{size:42,className:"relative"})]}),e.jsxs("div",{className:"mt-4 inline-flex items-center gap-1.5 font-mono text-[10px] uppercase tracking-[0.16em] text-[hsl(var(--deck-accent))]",children:[e.jsx(vt,{className:"w-3 h-3"}),s("chat.list.loading.eyebrow")]}),e.jsx("h2",{className:"mt-2 text-[15px] font-medium text-[hsl(var(--deck-ink))]",children:s("chat.list.loading.title")}),e.jsx("p",{className:"mt-1 max-w-sm text-[11.5px] leading-5 text-[hsl(var(--deck-ink-faint))]",children:s("chat.list.loading.hint")})]}),e.jsx("div",{"aria-hidden":"true",className:"mt-7 space-y-4 rounded-xl border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface))]/45 px-4 py-5",children:[72,88,64].map((C,T)=>e.jsxs("div",{className:D("flex gap-3",T%2===1&&"flex-row-reverse"),children:[e.jsx("span",{className:"h-7 w-7 shrink-0 animate-pulse rounded-md bg-[hsl(var(--deck-surface-2))]"}),e.jsx("span",{className:"h-10 animate-pulse rounded-lg bg-[hsl(var(--deck-surface-2))]",style:{width:`${C}%`,animationDelay:`${T*120}ms`}})]},C))})]})});if(t.length===0&&!a)return e.jsx("div",{className:"flex flex-1 justify-center items-center",children:e.jsxs("div",{className:"flex flex-col gap-4 items-center text-center",children:[e.jsx(Ce,{size:44}),e.jsxs("div",{children:[e.jsx("div",{className:"deck-eyebrow text-[hsl(var(--deck-accent))]",children:s("chat.list.empty.eyebrow")}),e.jsx("div",{className:"mt-2 text-[15px] font-medium text-[hsl(var(--deck-ink))]",children:s("chat.list.empty.title")}),e.jsx("div",{className:"mt-1 max-w-xs text-[12px] text-[hsl(var(--deck-ink-muted))]",children:s("chat.list.empty.hint")})]})]})});const R=()=>{const C=le(r.current);C&&(C.scrollTop=C.scrollHeight,i.current=!0,l.current=!0,c.current=new Set,S(0),N(!1))},j=()=>{var T;const C=le(r.current);if(C){const M=((T=r.current)==null?void 0:T.querySelector("[data-chat-message-id]"))??null;b.current={element:M,viewportTop:(M==null?void 0:M.getBoundingClientRect().top)??0,scrollHeight:C.scrollHeight,scrollTop:C.scrollTop}}y(M=>$s(M,t.length,Ne))},O=C=>C>=n?!0:(y(t.length),!1),G=m===1?s("chat.list.unreadMessage"):s("chat.list.unreadMessages",{count:m});return e.jsxs("div",{ref:r,className:"relative flex-1 min-h-0",children:[e.jsx($t,{className:"h-full",children:e.jsxs("div",{className:"flex flex-col px-4 pb-4 w-full md:px-6",children:[w>0&&e.jsx("div",{className:"flex justify-center py-3",children:e.jsx("button",{type:"button",onClick:j,"aria-label":s("chat.list.showEarlierWithRemaining",{count:Math.min(w,Ne),remaining:w}),className:"rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-3 py-1.5 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:border-[hsl(var(--deck-border-strong))] hover:text-[hsl(var(--deck-ink))]",children:s("chat.list.showEarlier",{count:Math.min(w,Ne)})})}),E.map((C,T)=>{const M=n+T,P=M>0?t[M-1]:null,L=!P||P.role!==C.role||P.role==="user";return e.jsx(Ds,{message:C,showAvatar:L},C.id||`msg-${M}`)})]})}),e.jsx(Bs,{turns:F,viewportRef:o,containerRef:r,onRevealTurn:O}),p&&e.jsxs("button",{type:"button",onClick:R,"aria-live":"polite","aria-label":m>0?G:s("chat.list.jumpLatest"),className:"absolute bottom-4 left-1/2 z-10 inline-flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-[hsl(var(--deck-border-strong))] bg-[hsl(var(--deck-surface))]/95 px-3 py-1.5 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] shadow-lg backdrop-blur transition-colors hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[e.jsx(Fe,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}),m>0?G:s("chat.list.jumpLatest")]})]})}const lt=h.memo(Vs);function Hs({queue:t,mutation:a,onMutate:s,onRefresh:r}){const o=B(),[i,l]=h.useState(!1),u=h.useRef(null),x=h.useRef(null),c=h.useRef(null);h.useLayoutEffect(()=>{var p,N,m;if(a.pending||!u.current)return;const d=u.current;u.current=null,(m=Array.from(((p=x.current)==null?void 0:p.querySelectorAll("[data-follow-up-focus-id]"))??[]).find(S=>S.dataset.followUpFocusId===d)??((N=x.current)==null?void 0:N.querySelector("button")))==null||m.focus()},[a.pending,t==null?void 0:t.version]);const v=h.useCallback(async d=>{u.current=d.messageId,await s(d)},[s]),b=h.useCallback((d,y)=>{v({type:"move",messageId:d,toPosition:y})},[v]);return!t||t.pending===0&&!a.errorMessage?null:e.jsxs("section",{ref:x,"data-blade-follow-up-queue":!0,className:"mx-4 mb-2 overflow-hidden rounded-lg border border-amber-300/70 bg-amber-50/70 shadow-sm dark:border-amber-900/60 dark:bg-amber-950/25 md:mx-6","aria-label":o("chat.followUpQueue.title"),children:[e.jsxs("button",{type:"button","aria-label":o(i?"chat.followUpQueue.hide":"chat.followUpQueue.show"),"aria-expanded":i,onClick:()=>l(d=>!d),className:"flex min-h-10 w-full items-center gap-2 px-3 text-left font-mono text-[11px] text-amber-950 transition-colors hover:bg-amber-100/70 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-amber-500 dark:text-amber-100 dark:hover:bg-amber-900/35",children:[e.jsx(qt,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"font-semibold",children:o("chat.followUpQueue.count",{count:t.pending})}),t.locked>0&&e.jsx("span",{className:"text-amber-700/80 dark:text-amber-300/75",children:o("chat.followUpQueue.lockedCount",{count:t.locked})}),e.jsx(oe,{className:`ml-auto h-3.5 w-3.5 transition-transform ${i?"rotate-90":""}`,"aria-hidden":!0})]}),i&&e.jsxs("div",{className:"border-t border-amber-300/60 px-2 py-2 dark:border-amber-900/50",children:[a.errorMessage&&e.jsxs("div",{role:"alert",className:"mb-2 flex items-center gap-2 rounded-md border border-red-200 bg-red-50 px-2.5 py-2 text-[11px] text-red-700 dark:border-red-900/60 dark:bg-red-950/35 dark:text-red-300",children:[e.jsx("span",{className:"min-w-0 flex-1",children:a.errorCode==="revision_conflict"?o("chat.followUpQueue.stale"):a.errorMessage}),r&&e.jsx("button",{type:"button","aria-label":o("chat.followUpQueue.refresh"),onClick:()=>void r(),className:"rounded p-1 hover:bg-red-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-red-500 dark:hover:bg-red-900/60",children:e.jsx(tt,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx("ol",{className:"space-y-1.5",children:t.items.map((d,y)=>{const p=t.items[y-1],N=t.items[y+1],m=d.mutable&&(p==null?void 0:p.mutable)===!0,S=d.mutable&&(N==null?void 0:N.mutable)===!0,k=a.pending;return e.jsxs("li",{"data-follow-up-id":d.id,"data-follow-up-state":d.state,"data-follow-up-focus-id":d.id,tabIndex:-1,draggable:d.mutable&&!a.pending,onDragStart:()=>{c.current=d.mutable?d.id:null},onDragOver:w=>{const n=c.current,E=t.items.find(F=>F.id===n);E!=null&&E.mutable&&d.mutable&&w.preventDefault()},onDrop:w=>{w.preventDefault();const n=c.current;c.current=null;const E=t.items.find(j=>j.id===n);if(!(E!=null&&E.mutable)||!d.mutable||E.id===d.id)return;const F=Math.min(E.position,d.position),R=Math.max(E.position,d.position);t.items.slice(F,R+1).some(j=>!j.mutable)||b(E.id,d.position)},onDragEnd:()=>{c.current=null},className:"flex min-w-0 items-center gap-2 rounded-md border border-amber-200/70 bg-white/75 px-2.5 py-2 dark:border-amber-900/50 dark:bg-zinc-950/45",children:[e.jsx("span",{className:"w-5 shrink-0 text-center font-mono text-[10px] text-amber-700 dark:text-amber-400",children:y+1}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-xs text-[hsl(var(--deck-ink))]",children:d.kind==="internal"?o("chat.followUpQueue.internal"):d.preview||o("chat.followUpQueue.attachmentOnly")}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-2 font-mono text-[9px] uppercase tracking-[0.08em] text-[hsl(var(--deck-ink-faint))]",children:[e.jsx("span",{children:o(`chat.followUpQueue.delivery.${d.delivery}`)}),!d.mutable&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Gt,{className:"h-2.5 w-2.5","aria-hidden":!0}),o("chat.followUpQueue.locked")]}),d.attachmentCount>0&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(gt,{className:"h-2.5 w-2.5","aria-hidden":!0}),d.attachmentCount]})]})]}),k&&a.messageId===d.id?e.jsx(_,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-amber-600"}):e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[e.jsx("button",{type:"button","aria-label":o("chat.followUpQueue.moveUp",{id:d.id}),disabled:k||!m,onClick:()=>b(d.id,y-1),className:"rounded p-1 text-amber-800 transition-colors hover:bg-amber-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-amber-500 disabled:opacity-30 dark:text-amber-300 dark:hover:bg-amber-900/50",children:e.jsx(_t,{className:"h-3.5 w-3.5","aria-hidden":!0})}),e.jsx("button",{type:"button","aria-label":o("chat.followUpQueue.moveDown",{id:d.id}),disabled:k||!S,onClick:()=>b(d.id,y+1),className:"rounded p-1 text-amber-800 transition-colors hover:bg-amber-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-amber-500 disabled:opacity-30 dark:text-amber-300 dark:hover:bg-amber-900/50",children:e.jsx(Fe,{className:"h-3.5 w-3.5","aria-hidden":!0})}),e.jsx("button",{type:"button","aria-label":o("chat.followUpQueue.remove",{id:d.id}),disabled:k||!d.mutable,onClick:()=>void v({type:"remove",messageId:d.id}),className:"rounded p-1 text-red-600 transition-colors hover:bg-red-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-red-500 disabled:opacity-30 dark:text-red-400 dark:hover:bg-red-950/60",children:e.jsx(ne,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})]},d.id)})})]})]})}const Te=Pt,Ee=Lt,Me=Ut,ve=h.forwardRef(({className:t,sideOffset:a=4,...s},r)=>e.jsx(nt,{ref:r,sideOffset:a,className:D("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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 origin-[--radix-tooltip-content-transform-origin]",t),...s}));ve.displayName=nt.displayName;const Qs={active:{labelKey:"goal.status.active",dot:"bg-[hsl(var(--deck-accent))] shadow-[0_0_6px_hsl(var(--deck-accent-glow)/0.5)]",accent:"text-[hsl(var(--deck-accent))]"},verifying:{labelKey:"goal.status.active",dot:"animate-pulse bg-sky-400",accent:"text-sky-600 dark:text-sky-300"},paused:{labelKey:"goal.status.paused",dot:"bg-amber-400",accent:"text-amber-600 dark:text-amber-300"},blocked:{labelKey:"goal.status.blocked",dot:"bg-rose-500",accent:"text-rose-600 dark:text-rose-300"},usage_limited:{labelKey:"goal.status.usageLimited",dot:"bg-orange-500",accent:"text-orange-600 dark:text-orange-300"},budget_limited:{labelKey:"goal.status.budgetLimited",dot:"bg-orange-500",accent:"text-orange-600 dark:text-orange-300"},complete:{labelKey:"goal.status.complete",dot:"bg-emerald-500",accent:"text-emerald-600 dark:text-emerald-300"}};function xe(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)}function zs(t){if(t<60)return`${t}s`;const a=Math.floor(t/60),s=t%60;return s===0?`${a}m`:`${a}m ${s}s`}function qs(){var C,T,M,P,L,ee,Q,Z,J,te,A,z,q,V,H,$,W,Y,he,ce;const t=B(),{locale:a}=st(),s=f(I=>I.goal),r=f(I=>I.pauseGoal),o=f(I=>I.resumeGoal),i=f(I=>I.editGoal),l=f(I=>I.clearGoal),u=f(I=>ie(I.historySurfaceSelection)),[x,c]=h.useState(!1),[v,b]=h.useState(!1),[d,y]=h.useState(""),[p,N]=h.useState(null),[m,S]=h.useState(!1);if(h.useEffect(()=>{c(!1),b(!1),y((s==null?void 0:s.objective)??""),S(!1)},[s==null?void 0:s.goalId]),u||!s)return null;const k=Qs[s.status],w=["active","verifying","paused","blocked"].includes(s.status),n=s.status==="active"||s.status==="verifying",E=s.status==="paused"||s.status==="blocked",F=p!==null,R=async(I,g)=>{if(!K(f.getState())){N(I);try{await g()}finally{N(null)}}},j=()=>{y(s.objective),b(!0),c(!0)},O=async I=>{I.preventDefault();const g=d.trim();if(!g||g===s.objective){b(!1);return}await R("edit",()=>i(g)),b(!1)},G=async()=>{await R("delete",l),S(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(Te,{delayDuration:250,children:e.jsxs("section",{"aria-label":t("goal.aria.section"),className:"mx-3 mb-1 shrink-0","data-blade-goal-status":s.status,"data-blade-goal-recovery":(C=s.prematureStop)==null?void 0:C.consecutiveCount,"data-blade-goal-recovery-pattern":(T=s.prematureStop)==null?void 0:T.pattern,"data-blade-goal-verification-stall":(M=s.verificationStall)==null?void 0:M.consecutiveCount,"data-blade-goal-frontier-task-list":(P=s.executionFrontier)==null?void 0:P.taskListId,"data-blade-goal-frontier-total":(L=s.executionFrontier)==null?void 0:L.total,"data-blade-goal-frontier-completed":(ee=s.executionFrontier)==null?void 0:ee.completed,"data-blade-goal-frontier-in-progress":(Q=s.executionFrontier)==null?void 0:Q.inProgress,"data-blade-goal-frontier-pending":(Z=s.executionFrontier)==null?void 0:Z.pending,"data-blade-goal-frontier-blocked":(J=s.executionFrontier)==null?void 0:J.blocked,"data-blade-goal-frontier-next-task":(A=(te=s.executionFrontier)==null?void 0:te.nextTask)==null?void 0:A.id,"data-blade-goal-frontier-digest":(z=s.executionFrontier)==null?void 0:z.digestSha256.slice(0,16),"data-blade-goal-frontier-stall":(q=s.frontierStall)==null?void 0:q.category,"data-blade-goal-frontier-stall-count":(V=s.frontierStall)==null?void 0:V.consecutiveCount,"data-blade-goal-execution-host-failure":(H=s.executionHostFailure)==null?void 0:H.category,"data-blade-goal-execution-host-failure-count":($=s.executionHostFailure)==null?void 0:$.consecutiveCount,"data-blade-goal-root-turn":(W=s.turnLineage)==null?void 0:W.rootTurnId,"data-blade-goal-current-turn":(Y=s.turnLineage)==null?void 0:Y.currentTurnId,"data-blade-goal-parent-turn":(he=s.turnLineage)==null?void 0:he.parentTurnId,children:[e.jsxs("div",{className:D("flex h-9 items-center gap-2 rounded-lg border px-3 transition-colors","border-[hsl(var(--deck-border))]/60 bg-[hsl(var(--deck-surface))]/80 backdrop-blur-sm",x&&"rounded-b-none border-b-0"),children:[s.status==="complete"?e.jsx(kt,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500"}):e.jsx(Jt,{className:D("h-3.5 w-3.5 shrink-0",k.accent)}),e.jsx("span",{className:D("h-1.5 w-1.5 shrink-0 rounded-full",k.dot)}),e.jsx("span",{className:D("shrink-0 text-[10px] font-medium leading-none",k.accent),children:s.status==="verifying"?a==="zh"?"验证中":"Verifying":t(k.labelKey)}),e.jsx("span",{className:"h-3 w-px shrink-0 bg-[hsl(var(--deck-hairline))]"}),e.jsx("button",{type:"button","aria-label":t(x?"goal.action.collapse":"goal.action.expand"),className:"min-w-0 flex-1 truncate text-left text-[12px] leading-5 text-[hsl(var(--deck-ink))]/85 outline-none transition-colors hover:text-[hsl(var(--deck-ink))]",onClick:()=>c(I=>!I),"aria-expanded":x,title:s.objective,children:s.objective}),s.tokensUsed>0&&e.jsxs("span",{className:"hidden shrink-0 text-[10px] tabular-nums text-[hsl(var(--deck-ink-muted))] sm:inline",children:[xe(s.tokensUsed),s.tokenBudget!==void 0&&`/${xe(s.tokenBudget)}`]}),e.jsxs("div",{className:"flex shrink-0 items-center",children:[n&&e.jsx(pe,{label:t("goal.action.pause"),disabled:F,onClick:()=>void R("pause",r),children:p==="pause"?e.jsx(_,{className:"animate-spin"}):e.jsx(Ot,{})}),E&&e.jsx(pe,{label:t("goal.action.resume"),disabled:F,onClick:()=>void R("resume",o),children:p==="resume"?e.jsx(_,{className:"animate-spin"}):e.jsx(Kt,{})}),e.jsx(pe,{label:t(w?"goal.action.edit":"goal.action.expand"),disabled:!w&&!x,onClick:w?j:()=>c(I=>!I),children:w?e.jsx(it,{}):e.jsx(Bt,{})}),e.jsx(pe,{label:t("goal.action.delete"),disabled:F,destructive:!0,onClick:()=>S(!0),children:e.jsx(ne,{})})]})]}),x&&e.jsx("div",{className:"rounded-b-lg border border-t-0 border-[hsl(var(--deck-border))]/60 bg-[hsl(var(--deck-surface))]/80 px-4 py-3 backdrop-blur-sm",children:v?e.jsxs("form",{onSubmit:O,children:[e.jsx("textarea",{id:"goal-objective",value:d,onChange:I=>y(I.target.value),onKeyDown:I=>{I.key==="Escape"&&b(!1)},rows:3,autoFocus:!0,className:"w-full resize-none rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))] px-3 py-2 text-[12px] leading-5 text-[hsl(var(--deck-ink))] outline-none transition-shadow focus:border-[hsl(var(--deck-accent))] focus:ring-1 focus:ring-[hsl(var(--deck-accent-glow))]"}),e.jsxs("div",{className:"mt-2 flex items-center justify-end gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>b(!1),className:"inline-flex h-7 items-center gap-1 rounded-md px-2.5 text-[11px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:bg-[hsl(var(--deck-hairline))]/60",children:[e.jsx(at,{className:"h-3 w-3"}),t("goal.action.cancel")]}),e.jsxs("button",{type:"submit",disabled:!d.trim()||p==="edit",className:"inline-flex h-7 items-center gap-1 rounded-md bg-[hsl(var(--deck-accent))] px-2.5 text-[11px] font-medium text-white transition-colors hover:bg-[hsl(var(--deck-accent))]/90 disabled:cursor-not-allowed disabled:opacity-50",children:[p==="edit"?e.jsx(_,{className:"h-3 w-3 animate-spin"}):e.jsx(ge,{className:"h-3 w-3"}),t("goal.action.save")]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"whitespace-pre-wrap text-[12px] leading-5 text-[hsl(var(--deck-ink))]/90",children:s.objective}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[10px] text-[hsl(var(--deck-ink-muted))]",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Qt,{className:"h-3 w-3"}),xe(s.tokensUsed),s.tokenBudget!==void 0&&` / ${xe(s.tokenBudget)}`," ",t("goal.metrics.tokens")]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Yt,{className:"h-3 w-3"}),zs(s.timeUsedSeconds)]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(fe,{className:"h-3 w-3"}),s.continuationCount===1?t("goal.metrics.continuationOne",{n:s.continuationCount}):t("goal.metrics.continuationMany",{n:s.continuationCount})]})]}),s.turnLineage&&e.jsxs("div",{className:"mt-2 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 rounded-md border border-[hsl(var(--deck-border))]/50 bg-[hsl(var(--deck-canvas))]/45 px-2.5 py-2 font-mono text-[10px] text-[hsl(var(--deck-ink-muted))]",children:[e.jsx("span",{children:t("goal.lineage.origin")}),e.jsx("span",{className:"truncate",children:s.turnLineage.rootTurnId??"?"}),e.jsx("span",{children:t("goal.lineage.current")}),e.jsx("span",{className:"truncate",children:s.turnLineage.currentTurnId}),e.jsx("span",{children:t("goal.lineage.parent")}),e.jsx("span",{className:"truncate",children:s.turnLineage.parentTurnId??"?"})]}),s.prematureStop&&e.jsxs("div",{className:"mt-2 inline-flex items-center gap-1.5 font-mono text-[10px] text-amber-700 dark:text-amber-300",children:[e.jsx(fe,{className:"h-3 w-3"}),a==="zh"?"恢复提示":"Recovery nudge"," ",s.prematureStop.consecutiveCount," ·"," ",s.prematureStop.pattern.replaceAll("_"," ")]}),s.executionHostFailure&&e.jsxs("div",{className:"mt-2 rounded-md border border-amber-200/50 bg-amber-50/60 px-2.5 py-2 text-[11px] text-amber-900 dark:border-amber-400/15 dark:bg-amber-400/[0.05] dark:text-amber-100",children:[e.jsx("p",{className:"font-medium",children:t("goal.executionHostFailure.title")}),e.jsxs("p",{className:"mt-1 font-mono opacity-80",children:[t(`goal.executionHostFailure.category.${s.executionHostFailure.category}`)," ","· ",s.executionHostFailure.consecutiveCount,"/3"]})]}),s.completionVerification&&e.jsxs("div",{"data-goal-verification":s.completionVerification.status,className:"mt-2 rounded-md border border-sky-200/50 bg-sky-50/60 px-2.5 py-2 text-[11px] text-sky-900 dark:border-sky-400/15 dark:bg-sky-400/[0.05] dark:text-sky-100",children:[e.jsxs("p",{className:"font-mono font-medium",children:["#",s.completionVerification.attempt," ·"," ",s.completionVerification.status.toUpperCase()," ·"," ",((ce=s.completionVerification.verifierSessionId)==null?void 0:ce.slice(0,12))??"-",s.verificationStall?a==="zh"?` · 重复 ${s.verificationStall.consecutiveCount}/3`:` · repeat ${s.verificationStall.consecutiveCount}/3`:""]}),s.completionVerification.summary&&e.jsx("p",{className:"mt-1 line-clamp-3 whitespace-pre-wrap opacity-80",children:s.completionVerification.summary}),s.completionVerification.evidenceSha256&&e.jsxs("p",{className:"mt-1 font-mono text-[10px] opacity-60",children:["sha256:",s.completionVerification.evidenceSha256.slice(0,12)]})]}),s.statusReason&&e.jsx("div",{className:"mt-2 rounded-md border border-amber-200/50 bg-amber-50/60 px-2.5 py-1.5 text-[11px] text-amber-800 dark:border-amber-400/15 dark:bg-amber-400/[0.05] dark:text-amber-200",children:s.statusReason})]})})]})}),e.jsx(We,{open:m,onOpenChange:S,children:e.jsxs(Je,{className:"max-w-[400px] border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsx(Ye,{children:t("goal.dialog.title")}),e.jsx(Xe,{children:t("goal.dialog.description")}),e.jsxs(Ze,{className:"mt-2",children:[e.jsx("button",{type:"button",onClick:()=>S(!1),className:"inline-flex h-8 items-center justify-center rounded-md border border-[hsl(var(--deck-border))] px-3 text-[12px] text-[hsl(var(--deck-ink))] hover:bg-[hsl(var(--deck-hairline))]/60",children:t("goal.action.cancel")}),e.jsxs("button",{type:"button",disabled:p==="delete",onClick:()=>void G(),className:"inline-flex gap-1.5 justify-center items-center px-3 h-8 text-[12px] font-medium text-white bg-rose-600 rounded-md hover:bg-rose-500 disabled:opacity-50",children:[p==="delete"&&e.jsx(_,{className:"w-3.5 h-3.5 animate-spin"}),t("goal.action.delete")]})]})]})})]})}function pe({label:t,children:a,disabled:s,destructive:r,onClick:o}){return e.jsxs(Ee,{children:[e.jsx(Me,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":t,disabled:s,onClick:o,className:D("flex h-6 w-6 items-center justify-center rounded-md text-[hsl(var(--deck-ink-muted))] outline-none transition-colors focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent-glow))]/50 disabled:cursor-not-allowed disabled:opacity-35 [&_svg]:h-3.5 [&_svg]:w-3.5",r?"hover:bg-rose-500/10 hover:text-rose-500":"hover:bg-[hsl(var(--deck-hairline))]/60 hover:text-[hsl(var(--deck-ink))]"),children:a})}),e.jsx(ve,{side:"top",className:"text-[10px]",children:t})]})}function Gs(){const t=B(),a=f(c=>c.currentSessionRef),s=f(c=>c.sessions),r=f(c=>c.messages),o=f(c=>ie(c.historySurfaceSelection)),i=h.useMemo(()=>{var v,b,d,y,p;const c=a?(v=yt(s,a))==null?void 0:v.pendingInteraction:void 0;if(c)return c.type;for(let N=r.length-1;N>=0;N-=1){const m=(b=r[N])==null?void 0:b.agentContent;if(((d=m==null?void 0:m.confirmation)==null?void 0:d.status)==="pending")return"permission";if(((y=m==null?void 0:m.question)==null?void 0:y.status)==="pending")return"question";if(((p=m==null?void 0:m.elicitation)==null?void 0:p.status)==="pending")return"elicitation"}return null},[a,r,s]);if(o||!i)return null;const l=()=>{const c=document.querySelector(`[data-pending-interaction="${i}"]`);c==null||c.scrollIntoView({block:"center",behavior:"smooth"}),window.setTimeout(()=>c==null?void 0:c.focus(),250)},u=i==="question",x=i==="elicitation";return e.jsxs("div",{role:"alert",className:"mx-3 mb-2 flex flex-wrap items-center gap-2 rounded-lg border border-amber-300/80 bg-amber-50/95 px-3 py-2 font-mono text-amber-950 shadow-sm backdrop-blur dark:border-amber-800/80 dark:bg-amber-950/90 dark:text-amber-100 sm:mx-5",children:[e.jsx(Ae,{className:"h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"min-w-[180px] flex-1",children:[e.jsx("div",{className:"text-[11.5px] font-semibold",children:t(u?"interaction.bar.questionTitle":x?"interaction.bar.elicitationTitle":"interaction.bar.permissionTitle")}),e.jsx("div",{className:"mt-0.5 text-[10px] leading-4 text-amber-800 dark:text-amber-300",children:t(u?"interaction.bar.questionHint":x?"interaction.bar.elicitationHint":"interaction.bar.permissionHint")})]}),e.jsxs("button",{type:"button",onClick:l,className:"inline-flex min-h-8 shrink-0 items-center gap-1.5 rounded-md border border-amber-400/80 bg-white/80 px-2.5 text-[10.5px] font-medium transition-colors hover:bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-700 dark:bg-amber-950/70 dark:hover:bg-amber-900",children:[e.jsx(Fe,{className:"h-3 w-3"}),t("interaction.bar.review")]})]})}function ue(t){return Math.max(0,Math.ceil((t??0)/1e3))}function Ws(t,a=Date.now()){var r;const s=(r=t.snapshot)==null?void 0:r.nextActionAt;return s===void 0?void 0:ue(s-a)}function dt(t,a=Date.now()){const s=t==null?void 0:t.snapshot;if(!s)return null;const r=Ws(t,a)??0,o=s.retry,i=s.admission,l=s.stall,u=s.fallback,x={seconds:r,attempt:(o==null?void 0:o.attempt)??0,maxRetries:(o==null?void 0:o.maxRetries)??0,budgetSeconds:ue(o==null?void 0:o.recoveryRemainingMs),position:(i==null?void 0:i.queuePosition)??0,depth:i?Math.max(i.queueDepth,i.queuePosition):0,scope:(i==null?void 0:i.scope)??"",waitSeconds:ue(i==null?void 0:i.waitMs),stallSeconds:ue(l==null?void 0:l.durationMs),timeoutSeconds:ue(l==null?void 0:l.timeoutMs),from:(u==null?void 0:u.from.model)??"",to:(u==null?void 0:u.to.model)??"",candidate:(u==null?void 0:u.candidate)??0,candidateCount:(u==null?void 0:u.candidateCount)??0};switch(s.activity){case"admission_wait":return{titleKey:"chat.providerRecovery.admission",detailKey:"chat.providerRecovery.admissionDetail",compactKey:"chat.providerRecovery.admissionCompact",params:x};case"retry_wait":return{titleKey:s.reason==="rate_limit"?"chat.providerRecovery.rateLimit":"chat.providerRecovery.retryWait",detailKey:"chat.providerRecovery.retryDetail",compactKey:"chat.providerRecovery.retryCompact",params:x};case"retry_attempt":return{titleKey:"chat.providerRecovery.retryAttempt",detailKey:"chat.providerRecovery.retryDetail",compactKey:"chat.providerRecovery.retryCompact",params:x};case"circuit_open":return{titleKey:s.reason==="rate_limit"?"chat.providerRecovery.rateLimitCircuit":"chat.providerRecovery.circuit",detailKey:"chat.providerRecovery.circuitDetail",compactKey:s.reason==="rate_limit"?"chat.providerRecovery.rateLimitCircuitCompact":"chat.providerRecovery.circuitCompact",params:x};case"circuit_probe":return{titleKey:"chat.providerRecovery.probe",detailKey:"chat.providerRecovery.probeDetail",compactKey:"chat.providerRecovery.probeCompact",params:x};case"stream_stall":return{titleKey:l!=null&&l.outputStarted?"chat.providerRecovery.stallAfterOutput":"chat.providerRecovery.stall",detailKey:"chat.providerRecovery.stallDetail",compactKey:"chat.providerRecovery.stallCompact",params:x};case"fallback":return{titleKey:"chat.providerRecovery.fallback",detailKey:"chat.providerRecovery.fallbackDetail",compactKey:"chat.providerRecovery.fallbackCompact",params:x}}}function Js({recovery:t,stopping:a,onStop:s}){var x;const r=B(),[o,i]=h.useState(Date.now()),l=(x=t==null?void 0:t.snapshot)==null?void 0:x.nextActionAt;h.useEffect(()=>{if(l===void 0)return;i(Date.now());const c=window.setInterval(()=>i(Date.now()),1e3);return()=>window.clearInterval(c)},[l]);const u=dt(t,o);return u?e.jsxs("section",{role:"status","aria-live":"polite","data-provider-recovery-banner":!0,className:"mx-4 mb-2 flex min-h-12 items-center gap-3 rounded-lg border border-amber-300/70 bg-amber-50/80 px-3 py-2 text-amber-950 shadow-sm dark:border-amber-800/60 dark:bg-amber-950/35 dark:text-amber-100 md:mx-6",children:[e.jsx(_,{className:"h-4 w-4 shrink-0 animate-spin","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-semibold",children:r(u.titleKey,u.params)}),e.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] opacity-80",children:r(u.detailKey,u.params)})]}),e.jsxs("button",{type:"button","data-provider-recovery-stop":!0,onClick:s,disabled:a,className:"inline-flex min-h-8 shrink-0 items-center gap-1.5 rounded-md border border-amber-400/70 bg-white/70 px-2.5 text-xs font-medium transition-colors hover:bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 disabled:cursor-wait disabled:opacity-60 dark:border-amber-700 dark:bg-amber-950/50 dark:hover:bg-amber-900/50",children:[a?e.jsx(_,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(jt,{className:"h-3 w-3 fill-current","aria-hidden":!0}),r(a?"chat.input.action.stopping":"chat.providerRecovery.stop")]})]}):null}const Ys=h.lazy(()=>et(()=>import("./MarkdownRenderer-RfULWJEE.js").then(t=>t.M),__vite__mapDeps([0,1,2,3,4,5,6])).then(t=>({default:t.MarkdownRenderer})));function Xs(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(1)}s`}function Zs(){const t=B(),a=f(r=>r.sideConversation),s=f(r=>r.dismissSideConversation);return a?e.jsx("section",{"aria-label":t("chat.side.title"),"data-blade-side-conversation":!0,"data-status":a.status,className:"shrink-0 border-y border-[hsl(var(--deck-accent)/0.28)] bg-[hsl(var(--deck-accent-soft)/0.42)]",children:e.jsxs("div",{className:"px-4 py-3 md:px-6",children:[e.jsxs("header",{className:"flex min-h-7 items-start gap-2",children:[e.jsx(Wt,{"aria-hidden":!0,className:"mt-0.5 h-4 w-4 shrink-0 text-[hsl(var(--deck-accent))]"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-1",children:[e.jsx("h2",{className:"font-mono text-[11px] font-semibold uppercase text-[hsl(var(--deck-accent))]",children:t("chat.side.title")}),a.durationMs!==void 0&&e.jsxs("span",{className:"inline-flex items-center gap-1 font-mono text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:[e.jsx(Vt,{"aria-hidden":!0,className:"h-3 w-3"}),Xs(a.durationMs)]})]}),e.jsx("p",{className:"mt-0.5 break-words font-mono text-[11px] leading-4 text-[hsl(var(--deck-ink-muted))]",children:a.question})]}),e.jsx("button",{type:"button",onClick:s,"aria-label":t("chat.side.dismiss"),title:t("chat.side.dismiss"),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:e.jsx(at,{"aria-hidden":!0,className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{"aria-live":"polite","aria-busy":a.status==="loading",className:"mt-2 max-h-[min(36vh,320px)] overflow-y-auto border-l-2 border-[hsl(var(--deck-accent)/0.42)] pl-3 pr-1",children:[a.status==="loading"&&e.jsxs("div",{role:"status",className:"flex min-h-9 items-center gap-2 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(_,{"aria-hidden":!0,className:"h-3.5 w-3.5 animate-spin text-[hsl(var(--deck-accent))]"}),t("chat.side.loading")]}),a.status==="error"&&e.jsxs("div",{role:"alert",className:"flex min-h-9 items-start gap-2 font-mono text-[11px] leading-5 text-red-700 dark:text-red-300",children:[e.jsx(Ae,{"aria-hidden":!0,className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"break-words",children:a.error??t("chat.side.failed")})]}),a.status==="completed"&&a.response&&e.jsx(h.Suspense,{fallback:e.jsx("div",{className:"whitespace-pre-wrap break-words font-mono text-[12px] leading-5 text-[hsl(var(--deck-ink))]",children:a.response}),children:e.jsx(Ys,{content:a.response,className:"text-[12px] leading-5 [&_h1]:text-[14px] [&_h2]:text-[13px] [&_h3]:text-[12px]"})})]})]})}):null}function Se(t){return Number.isFinite(t)?Math.max(0,t):0}function ea(t){const a=Se(t.totalInputTokens),s=Se(t.cacheReadTokens),r=Se(t.cacheWriteTokens),o=Math.min(s,a),i=Math.min(r,Math.max(0,a-o)),l=Math.max(0,a-o-i),u=a>0&&(s>0||r>0);return{totalInputTokens:a,cacheReadTokens:o,cacheWriteTokens:i,uncachedInputTokens:l,...u?{hitRate:o/a}:{}}}function ta(t){return t===void 0||!Number.isFinite(t)?"—":`${Math.round(Math.max(0,Math.min(1,t))*100)}%`}const sa={running:"status.phase.running",compacting:"status.phase.compacting",recovering_context:"status.phase.recoveringContext",switching_model:"status.phase.switchingModel",waiting_permission:"status.phase.waitingPermission",error:"status.phase.error",idle:""},aa={model_changed:"status.cacheBreak.model",system_prompt_changed:"status.cacheBreak.system",tools_changed:"status.cacheBreak.tools",request_policy_changed:"status.cacheBreak.policy",ttl_expired:"status.cacheBreak.ttl",server_side:"status.cacheBreak.server"},se=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString(),ra=t=>{const a=Math.max(0,Math.ceil(t/1e3)),s=Math.floor(a/60),r=a%60;return s>0?`${s}m ${r}s`:`${r}s`};function ut(){const t=B(),a=f(n=>n.tokenUsage),s=f(n=>n.isStreaming),r=f(n=>n.agentPhase),o=f(n=>n.providerRecovery),i=f(n=>n.turnActivity),l=f(n=>n.pendingResume),u=f(n=>n.actionStationarity),x=f(n=>n.turnRecovery),c=sa[r]??"",v=dt(o),b=(l==null?void 0:l.delayMs)!==void 0?` · retry in ${ra(l.delayMs)}`:"",d=(x==null?void 0:x.state)==="requires_attention"?t("status.recovery.review"):"",y=(x==null?void 0:x.state)==="requires_attention"?t(x.reason==="interrupted_tool_call"?"status.recovery.interruptedTool":"status.recovery.successfulTool"):"",p=d||(u?`${t(u.phase==="halted"?"status.phase.actionStationarityStopped":"status.phase.actionStationarityRecovering")} · ${u.toolName} · ${u.runLength}/${u.haltThreshold}`:v?t(v.compactKey,v.params):l?`Recovery attempt ${l.attempt}/${l.maxAttempts}${b}`:c?t(c):""),N=a.maxContextTokens>0?Math.round(a.totalTokens/a.maxContextTokens*100):0,m=ea(a),S=ta(m.hitRate),k=Math.min(N,100),w=N>95?"danger":N>80?"warn":"safe";return e.jsxs("div",{"data-chat-status-bar":!0,className:"flex items-center gap-2 border-t border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))]/70 px-3 py-2 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] backdrop-blur-sm sm:gap-4 sm:px-5",children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[e.jsx("span",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:t("status.context")}),e.jsxs("span",{className:"flex gap-1 items-baseline tabular-nums",children:[e.jsx("span",{className:D("text-[12px] font-medium",w==="safe"&&"text-[hsl(var(--deck-ink))]",w==="warn"&&"text-amber-600 dark:text-amber-400",w==="danger"&&"text-red-600 dark:text-red-400"),children:se(a.totalTokens)}),e.jsxs("span",{className:"text-[hsl(var(--deck-ink-faint))]",children:["/ ",se(a.maxContextTokens)]})]}),a.isDefaultMaxTokens&&e.jsx(Te,{children:e.jsxs(Ee,{children:[e.jsx(Me,{asChild:!0,children:e.jsx(zt,{className:"h-3 w-3 cursor-help text-[hsl(var(--deck-ink-faint))]"})}),e.jsx(ve,{side:"top",className:"max-w-[220px]",children:e.jsx("p",{className:"text-xs",children:t("status.tokenLimitTooltip")})})]})}),e.jsxs("div",{className:"relative hidden h-2 w-32 overflow-hidden rounded-sm border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] sm:block","aria-hidden":"true",children:[e.jsx("div",{className:D("absolute inset-y-0 left-0 transition-[width] duration-300",w==="safe"&&"bg-[hsl(var(--deck-accent))]",w==="warn"&&"bg-amber-500",w==="danger"&&"bg-red-500"),style:{width:`${k}%`}}),e.jsx("div",{className:"flex absolute inset-0 pointer-events-none",children:[25,50,75].map(n=>e.jsx("span",{className:"absolute inset-y-0 w-px bg-[hsl(var(--deck-canvas-veil))]/60",style:{left:`${n}%`}},n))})]}),e.jsxs("span",{className:D("w-10 text-right tabular-nums text-[hsl(var(--deck-ink-faint))]",w==="warn"&&"text-amber-600 dark:text-amber-400",w==="danger"&&"text-red-600 dark:text-red-400"),children:[N,"%"]})]}),e.jsx(Te,{children:e.jsxs(Ee,{children:[e.jsx(Me,{asChild:!0,children:e.jsxs("div",{className:"flex shrink-0 cursor-help items-baseline gap-2 border-l border-[hsl(var(--deck-hairline))] pl-2 sm:pl-4","data-testid":"prompt-cache-hit-rate","aria-label":`${t("status.cache")} ${S}`,children:[e.jsx("span",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:t("status.cache")}),e.jsx("span",{className:D("tabular-nums",m.hitRate===void 0?"text-[hsl(var(--deck-ink-faint))]":"font-medium text-[hsl(var(--deck-accent))]"),children:S})]})}),e.jsx(ve,{side:"top",className:"max-w-[280px]",children:m.hitRate===void 0?e.jsx("p",{className:"text-xs",children:t("status.cacheUnavailable")}):e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("p",{children:t("status.cacheTooltip")}),e.jsx("p",{className:"font-mono tabular-nums",children:t("status.cacheDetails",{read:se(m.cacheReadTokens),write:se(m.cacheWriteTokens),uncached:se(m.uncachedInputTokens)})}),a.cacheBreak&&e.jsx("p",{className:"text-[hsl(var(--deck-accent))]",children:t("status.cacheBreak",{reason:t(aa[a.cacheBreak.reason]??"status.cacheBreak.server"),previous:se(a.cacheBreak.previousCacheReadTokens),current:se(a.cacheBreak.cacheReadTokens)})})]})})]})}),e.jsx("div",{className:"flex-1"}),(d||s&&p&&(!(i!=null&&i.snapshot)||u))&&e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:D("shrink-0",d?"h-2 w-2 rounded-sm bg-amber-500":"deck-pulse-dot")}),e.jsxs("span",{className:D("truncate",d?"text-amber-600 dark:text-amber-400":"text-[hsl(var(--deck-accent))]"),children:[p,y?e.jsxs("span",{className:"hidden sm:inline",children:[" · ",y]}):null]})]})]})}function na(){const{locale:t}=st(),a=wt(n=>n.agentTeamsEnabled),s=f(n=>n.teams),r=f(n=>n.currentSessionRef),o=f(n=>ie(n.historySurfaceSelection)),i=f(n=>n.loadTeams),[l,u]=h.useState({}),[x,c]=h.useState({}),[v,b]=h.useState({}),[d,y]=h.useState(null),[p,N]=h.useState(null),[m,S]=h.useState(null);if(h.useEffect(()=>{o||i(r??void 0)},[a,r,o,i]),o||!a||!r||s.length===0)return null;const k=async n=>{var F;if(K(f.getState()))return;const E=(F=v[n])==null?void 0:F.trim();if(!(!E||d)){y(n),S(null);try{await Be.sendMessage(r,n,x[n]??"*",E),b(R=>({...R,[n]:""})),await i(r)}catch(R){S(R instanceof Error?R.message:U(t,"actionFailed"))}finally{y(null)}}},w=async n=>{if(!K(f.getState())&&!p){N(n),S(null);try{await Be.delete(r,n),await i(r)}catch(E){S(E instanceof Error?E.message:U(t,"actionFailed"))}finally{N(null)}}};return e.jsxs("section",{"aria-label":U(t,"title"),"data-blade-team-panel":!0,className:"shrink-0 border-y border-emerald-300/50 bg-emerald-50/55 dark:border-emerald-800/55 dark:bg-emerald-950/20",children:[m&&e.jsx("div",{role:"alert",className:"border-b border-red-200 bg-red-50 px-4 py-2 font-mono text-[10px] text-red-700 dark:border-red-900 dark:bg-red-950/30 dark:text-red-300 md:px-6",children:m}),s.filter(n=>n.status!=="deleted").map(n=>{var R;const E=l[n.name]??n.status==="running",F=n.tasks.filter(j=>j.status==="completed").length;return e.jsxs("div",{className:"border-b border-emerald-200/40 last:border-0 dark:border-emerald-900/40",children:[e.jsxs("div",{className:"flex min-h-11 items-center gap-2 px-4 py-2 md:px-6",children:[e.jsx("button",{type:"button",onClick:()=>u(j=>({...j,[n.name]:!E})),"aria-label":E?U(t,"collapse"):U(t,"expand"),className:"flex h-7 w-7 items-center justify-center rounded-md text-emerald-700 hover:bg-emerald-100 dark:text-emerald-300 dark:hover:bg-emerald-900/50",children:E?e.jsx(me,{className:"h-4 w-4"}):e.jsx(oe,{className:"h-4 w-4"})}),e.jsx(Xt,{className:"h-4 w-4 shrink-0 text-emerald-700 dark:text-emerald-300"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[e.jsx("h2",{className:"truncate font-mono text-[11px] font-semibold uppercase text-emerald-800 dark:text-emerald-200",children:n.name}),e.jsxs("span",{className:"font-mono text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:[n.status," · ",n.members.length-1," ",U(t,"members")," · ",F,"/",n.tasks.length," ",U(t,"tasks")]})]}),n.description&&e.jsx("p",{className:"truncate font-mono text-[10px] text-[hsl(var(--deck-ink-muted))]",children:n.description})]}),e.jsx("button",{type:"button",onClick:()=>void w(n.name),disabled:p===n.name,"aria-label":U(t,"delete"),title:U(t,"delete"),className:"flex h-7 w-7 items-center justify-center rounded-md text-[hsl(var(--deck-ink-faint))] hover:bg-red-50 hover:text-red-600 disabled:opacity-40 dark:hover:bg-red-950/40",children:e.jsx(ne,{className:"h-3.5 w-3.5"})})]}),E&&e.jsxs("div",{className:"max-h-[min(40vh,360px)] overflow-y-auto border-t border-emerald-200/40 px-4 py-3 md:px-6 dark:border-emerald-900/40",children:[e.jsxs("div",{className:"grid gap-x-6 gap-y-2 lg:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"mb-1 font-mono text-[9.5px] font-semibold uppercase text-[hsl(var(--deck-ink-faint))]",children:U(t,"members")}),n.members.map(j=>e.jsxs("div",{className:"flex min-h-7 items-center gap-2 border-b border-[hsl(var(--deck-hairline)/0.55)] py-1 last:border-0",children:[e.jsx("span",{"aria-label":j.status,className:`h-1.5 w-1.5 shrink-0 rounded-full ${j.status==="running"?"bg-emerald-500":j.status==="completed"||j.status==="leader"?"bg-sky-500":j.status==="failed"?"bg-red-500":"bg-zinc-400"}`}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10.5px] text-[hsl(var(--deck-ink))]",children:j.name}),e.jsx("span",{className:"font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:j.subagentType}),j.worktreePath&&e.jsx(qe,{className:"h-3 w-3 text-[hsl(var(--deck-ink-faint))]","aria-label":U(t,"worktree")})]},j.id))]}),e.jsxs("div",{children:[e.jsx("h3",{className:"mb-1 font-mono text-[9.5px] font-semibold uppercase text-[hsl(var(--deck-ink-faint))]",children:U(t,"tasks")}),n.tasks.length===0?e.jsx("p",{className:"font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:U(t,"noTasks")}):n.tasks.map(j=>e.jsxs("div",{className:"flex min-h-7 items-center gap-2 border-b border-[hsl(var(--deck-hairline)/0.55)] py-1 last:border-0",children:[e.jsxs("span",{className:"w-5 shrink-0 font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:["#",j.id]}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10.5px] text-[hsl(var(--deck-ink))]",children:j.subject}),e.jsx("span",{className:"font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:j.status})]},j.id))]})]}),n.peerMessagingEnabled&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 border-t border-emerald-200/40 pt-3 dark:border-emerald-900/40",children:[e.jsxs("select",{"aria-label":U(t,"recipient"),value:x[n.name]??"*",onChange:j=>c(O=>({...O,[n.name]:j.target.value})),className:"h-8 max-w-32 rounded-md border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface))] px-2 font-mono text-[10px]",children:[e.jsx("option",{value:"*",children:U(t,"broadcast")}),n.members.filter(j=>j.status!=="leader").map(j=>e.jsx("option",{value:j.name,children:j.name},j.id))]}),e.jsx("input",{value:v[n.name]??"",onChange:j=>b(O=>({...O,[n.name]:j.target.value})),onKeyDown:j=>{j.key==="Enter"&&k(n.name)},placeholder:U(t,"messagePlaceholder"),className:"h-8 min-w-0 flex-1 rounded-md border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface))] px-2 font-mono text-[10.5px] outline-none focus:border-emerald-500"}),e.jsx("button",{type:"button",onClick:()=>void k(n.name),disabled:!((R=v[n.name])!=null&&R.trim())||d===n.name,"aria-label":U(t,"send"),title:U(t,"send"),className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-emerald-700 text-white hover:bg-emerald-800 disabled:opacity-40 dark:bg-emerald-600",children:e.jsx(Ge,{className:"h-3.5 w-3.5"})})]})]})]},n.name)})]})}const ia={starting:"chat.turnActivity.starting",thinking:"chat.turnActivity.thinking",responding:"chat.turnActivity.responding",executing_tools:"chat.turnActivity.executingTools",compacting:"chat.turnActivity.compacting",continuing:"chat.turnActivity.continuing"};function oa(t){const a=Math.max(0,Math.floor(t/1e3));if(a<60)return`${a}s`;const s=Math.floor(a/60),r=a%60;return s<60?`${s}m ${r}s`:`${Math.floor(s/60)}h ${s%60}m ${r}s`}function ca(t,a=Date.now()){const s=t==null?void 0:t.snapshot;if(!s)return null;const r=s.activeTools.length+s.activeToolOverflow,o=s.activeTools.slice(0,2).map(l=>l.progress!==void 0&&l.total!==void 0?`${l.name} ${l.progress}/${l.total}`:l.name),i=Math.max(0,s.activeTools.length-o.length+s.activeToolOverflow);return{phaseKey:ia[s.phase],phaseParams:{count:r},tools:o,hiddenTools:i,completedTools:s.toolCallsCompleted,startedTools:s.toolCallsStarted,turn:s.turn,maxTurns:s.maxTurns,elapsed:oa(a-s.startedAt)}}function la({activity:t,memory:a=null}){var x;const s=B(),[r,o]=h.useState(Date.now()),i=(x=t==null?void 0:t.snapshot)==null?void 0:x.startedAt;h.useEffect(()=>{if(i===void 0)return;o(Date.now());const c=window.setInterval(()=>o(Date.now()),1e3);return()=>window.clearInterval(c)},[i]);const l=ca(t,r);if(!l)return(a==null?void 0:a.outcome)!=="written"?null:e.jsxs("section",{role:"status","aria-live":"polite","data-memory-consolidation-notice":!0,className:"mx-4 mb-2 flex min-h-10 items-center gap-3 rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]/80 px-3 py-2 text-[hsl(var(--deck-ink))] shadow-sm md:mx-6",children:[e.jsx(_e,{className:"h-4 w-4 shrink-0 text-[hsl(var(--deck-accent))]","aria-hidden":!0}),e.jsx("span",{className:"text-xs font-semibold",children:s("chat.memoryConsolidation.saved",{count:a.entries})})]});const u=[(a==null?void 0:a.outcome)==="written"?s("chat.memoryConsolidation.saved",{count:a.entries}):void 0,...l.tools,l.hiddenTools>0?`+${l.hiddenTools}`:void 0,l.startedTools>0?s("chat.turnActivity.toolCount",{completed:l.completedTools,started:l.startedTools}):void 0,l.turn>0?l.maxTurns===null?s("chat.turnActivity.turn",{turn:l.turn}):s("chat.turnActivity.turnBounded",{turn:l.turn,maxTurns:l.maxTurns}):void 0].filter(c=>c!==void 0);return e.jsxs("section",{role:"status","aria-live":"polite","data-turn-activity-strip":!0,className:"mx-4 mb-2 flex min-h-10 items-center gap-3 rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]/80 px-3 py-2 text-[hsl(var(--deck-ink))] shadow-sm md:mx-6",children:[e.jsx(_e,{className:"h-4 w-4 shrink-0 text-[hsl(var(--deck-accent))] motion-safe:animate-pulse","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-semibold",children:s(l.phaseKey,l.phaseParams)}),u.length>0&&e.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-[hsl(var(--deck-ink-muted))]",children:u.join(" · ")})]}),e.jsx("span",{className:"shrink-0 font-mono text-[10px] tabular-nums text-[hsl(var(--deck-ink-muted))]",children:l.elapsed})]})}function da(t){const a=[...t].reverse().find(o=>o.role==="user");if(!a)return null;if(typeof a.content=="string")return{content:a.content,attachments:[]};const s=a.content.filter(o=>o.type==="text").map(o=>o.text).join(`
|
|
63
|
-
`),r=a.content.filter(o=>o.type==="image_url").map((o,i)=>{var u;const l=((u=o.image_url.url.match(/^data:([^;,]+)[;,]/))==null?void 0:u[1])??"application/octet-stream";return{id:`recovery-${a.id}-${i}`,name:`attachment-${i+1}`,mimeType:l,dataUrl:o.image_url.url}});return{content:s,attachments:r}}function
|
|
62
|
+
`);return e.jsx("div",{"data-chat-message-id":t.id,"data-chat-role":"user","data-user-shell-command":!0,className:"flex justify-end p-4 w-full",children:e.jsxs("div",{className:"w-full max-w-[85%] overflow-hidden rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2",children:[e.jsxs("div",{className:"min-w-0 truncate font-mono text-[12px] text-[hsl(var(--deck-ink))]",children:[e.jsx("span",{className:"mr-2 text-amber-600 dark:text-amber-400",children:"$"}),p]}),e.jsx(Ie,{status:N})]}),e.jsx("pre",{className:"max-h-64 overflow-auto whitespace-pre-wrap px-3 py-2 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))]",children:m||"(no output)"}),typeof b.exitCode=="number"&&e.jsxs("div",{className:"border-t border-[hsl(var(--deck-border))] px-3 py-1.5 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:["exit ",b.exitCode,typeof b.durationMs=="number"?` · ${(b.durationMs/1e3).toFixed(3)}s`:"",b.truncated===!0?" · truncated":""]})]})})}const{text:d,images:y}=ks(t.content);return e.jsxs("div",{"data-chat-message-id":t.id,"data-chat-role":"user",className:"flex gap-2 justify-end items-start p-4 w-full group",children:[e.jsx("div",{className:"flex mt-1 opacity-0 transition-opacity shrink-0 group-hover:opacity-100 group-focus-within:opacity-100",children:e.jsx(Le,{text:d,label:"Copy message"})}),e.jsxs("div",{className:"bg-[hsl(var(--deck-surface-2))] rounded-lg px-4 py-3 max-w-[85%]",children:[d&&e.jsx("p",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono leading-relaxed whitespace-pre-wrap",children:d}),y.length>0&&e.jsx("div",{className:D("grid gap-2",y.length===1?"grid-cols-1 mt-0":"grid-cols-2 mt-3"),children:y.map((p,N)=>e.jsx("img",{src:p,alt:`attachment-${N+1}`,className:"object-cover w-full max-h-64 rounded-md"},`${p}-${N}`))})]}),e.jsx(gs,{})]})}const o=ys(t),i=ns((c=t.metadata)==null?void 0:c.codeReview),l=ps((v=t.metadata)==null?void 0:v.structuredOutput);return e.jsxs("div",{"data-chat-message-id":t.id,"data-chat-role":"assistant",className:D("flex gap-4 justify-start w-full group",a?"p-4":"px-4 pt-0 pb-3"),children:[a?e.jsx(vs,{}):e.jsx("div",{className:"w-8 shrink-0"}),e.jsxs("div",{className:"overflow-hidden flex-1 min-w-0",children:[i?e.jsx(os,{report:i}):l?e.jsx(fs,{report:l}):e.jsx(Fs,{message:t}),!l&&o.trim()&&e.jsx("div",{className:"mt-1.5 flex opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",children:e.jsx(Le,{text:o,label:"Copy response"})})]})]})}const Is=h.memo(Ds);function $s(t,a,s){return Math.max(0,t+(s-a))}function _s(t,a,s){return Math.min(a,Math.max(0,t)+Math.max(0,s))}function Bs(t,a,s,r){const o=new Map(t.filter(l=>!!l.id).map(l=>[l.id,l])),i=new Set(s);for(const l of a){if(!l.id)continue;const u=o.get(l.id);u!==l&&(!u||!r||r(u)!==r(l))&&i.add(l.id)}return i}function He(t,a){return t?t.querySelector(`[data-chat-message-id="${CSS.escape(a)}"]`):null}function Ps({turns:t,viewportRef:a,containerRef:s,onRevealTurn:r}){const o=B(),[i,l]=h.useState(null),[u,x]=h.useState(!1),c=h.useRef(null),v=h.useCallback(()=>{var m;const d=a.current,y=s.current;if(!d||!y||t.length===0)return;const p=d.getBoundingClientRect().top;let N=((m=t[0])==null?void 0:m.id)??null;for(const S of t){const k=He(y,S.id);if(k)if(k.getBoundingClientRect().top-p<=24)N=S.id;else break}l(N)},[t,a,s]);h.useEffect(()=>{const d=a.current;if(!d)return;const y=()=>{c.current===null&&(c.current=window.requestAnimationFrame(()=>{c.current=null,v()}))};return v(),d.addEventListener("scroll",y,{passive:!0}),()=>{d.removeEventListener("scroll",y),c.current!==null&&(window.cancelAnimationFrame(c.current),c.current=null)}},[v,a]);const b=h.useCallback(d=>{const y=()=>{const N=He(s.current,d.id);N&&(N.scrollIntoView({behavior:"smooth",block:"start"}),l(d.id))};r(d.index)?y():window.requestAnimationFrame(()=>window.requestAnimationFrame(y))},[s,r]);return t.length<2?null:e.jsx("nav",{"aria-label":o("chat.turns.aria"),className:"absolute right-1 top-1/2 z-20 hidden -translate-y-1/2 sm:block",onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),onFocusCapture:()=>x(!0),onBlurCapture:d=>{d.currentTarget.contains(d.relatedTarget)||x(!1)},children:e.jsxs("div",{className:"relative flex items-center justify-end",children:[e.jsx("ul",{className:D("flex flex-col items-center gap-2 py-2 transition-opacity",u?"opacity-0":"opacity-100"),"aria-hidden":u,children:t.map(d=>e.jsx("li",{children:e.jsx("span",{className:D("block rounded-full transition-all",d.id===i?"h-2 w-2 bg-[hsl(var(--deck-accent))]":"h-1.5 w-1.5 bg-[hsl(var(--deck-ink-faint))]/40")})},d.id))}),e.jsx("div",{className:D("absolute right-0 max-h-[min(70vh,520px)] w-[280px] overflow-y-auto rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]/95 p-1 shadow-xl backdrop-blur transition-all",u?"pointer-events-auto translate-x-0 opacity-100":"pointer-events-none translate-x-2 opacity-0"),children:t.map((d,y)=>e.jsxs("button",{type:"button",onClick:()=>b(d),className:D("flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors",d.id===i?"bg-[hsl(var(--deck-hairline))]/70 text-[hsl(var(--deck-ink))]":"text-[hsl(var(--deck-ink-muted))] hover:bg-[hsl(var(--deck-hairline))]/50 hover:text-[hsl(var(--deck-ink))]"),children:[e.jsx("span",{className:D("mt-1 h-1.5 w-1.5 shrink-0 rounded-full",d.id===i?"bg-[hsl(var(--deck-accent))]":"bg-[hsl(var(--deck-ink-faint))]/40")}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block font-mono text-[9.5px] uppercase tracking-[0.12em] text-[hsl(var(--deck-ink-faint))]",children:o("chat.turns.label",{n:y+1})}),e.jsx("span",{className:"line-clamp-2 text-[12px] leading-4",children:d.preview})]})]},d.id))})]})})}const Qe=80;function Ls(t){return typeof t=="string"?t:Array.isArray(t)?t.filter(a=>a.type==="text").map(a=>a.text).join(" "):""}function Us(t){const a=Ls(t).replace(/\s+/g," ").trim();return a?a.length>Qe?`${a.slice(0,Qe-1)}…`:a:""}function Os(t){const a=[];for(let s=0;s<t.length;s+=1){const r=t[s];if(r.role!=="user"||!r.id)continue;const o=Us(r.content);o&&a.push({id:r.id,index:s,preview:o})}return a}const we=120,Ne=80,Ks=96;function le(t){return(t==null?void 0:t.querySelector("[data-radix-scroll-area-viewport]"))??null}function Vs(t){return JSON.stringify([t.role,t.content,t.metadata,t.agentContent])}function Hs({messages:t,isLoading:a}){const s=B(),r=h.useRef(null),o=h.useRef(null),i=h.useRef(!0),l=h.useRef(!1),u=h.useRef(t),x=h.useRef(t),c=h.useRef(new Set),v=h.useRef(t.length),b=h.useRef(null),[d,y]=h.useState(we),[p,N]=h.useState(!1),[m,S]=h.useState(0),k=t.length>0;u.current=t,h.useEffect(()=>{const C=le(r.current);if(!C||l.current&&!i.current)return;const T=window.requestAnimationFrame(()=>{C.scrollTop=C.scrollHeight,l.current=!0,i.current=!0,c.current=new Set,S(0),N(!1)});return()=>window.cancelAnimationFrame(T)},[t]),h.useEffect(()=>{const C=le(r.current);if(!C)return;o.current=C;const T=()=>{if(!l.current)return;const P=C.scrollHeight-C.scrollTop-C.clientHeight<=Ks,L=i.current;i.current=P,N(!P),P?(c.current=new Set,S(0)):L&&(x.current=u.current,c.current=new Set,S(0))};return T(),C.addEventListener("scroll",T,{passive:!0}),()=>C.removeEventListener("scroll",T)},[k,a]),h.useEffect(()=>{const C=x.current;if(x.current=t,i.current){c.current.size>0&&(c.current=new Set,S(0));return}const T=Bs(C,t,c.current,Vs);c.current=T,S(T.size)},[t]),h.useEffect(()=>{const C=v.current;v.current=t.length,y(T=>T>=C&&t.length>C?t.length:Math.min(Math.max(T,we),t.length||we))},[t.length]);const w=Math.max(t.length-d,0),n=w,E=h.useMemo(()=>t.slice(n),[t,n]),F=h.useMemo(()=>Os(t),[t]);if(h.useLayoutEffect(()=>{var M;const C=b.current;if(!C)return;const T=le(r.current);if(b.current=null,!!T){if((M=C.element)!=null&&M.isConnected){const P=C.element.getBoundingClientRect().top-C.viewportTop;T.scrollTop+=P;return}T.scrollTop=$s(C.scrollTop,C.scrollHeight,T.scrollHeight)}},[d]),a)return e.jsx("div",{role:"status","aria-live":"polite","aria-busy":"true",className:"flex overflow-hidden flex-1 justify-center items-center px-5 py-8 min-h-0",children:e.jsxs("div",{className:"w-full max-w-[560px]",children:[e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 animate-pulse rounded-full bg-[hsl(var(--deck-accent-soft))] blur-xl"}),e.jsx(Ce,{size:42,className:"relative"})]}),e.jsxs("div",{className:"mt-4 inline-flex items-center gap-1.5 font-mono text-[10px] uppercase tracking-[0.16em] text-[hsl(var(--deck-accent))]",children:[e.jsx(vt,{className:"w-3 h-3"}),s("chat.list.loading.eyebrow")]}),e.jsx("h2",{className:"mt-2 text-[15px] font-medium text-[hsl(var(--deck-ink))]",children:s("chat.list.loading.title")}),e.jsx("p",{className:"mt-1 max-w-sm text-[11.5px] leading-5 text-[hsl(var(--deck-ink-faint))]",children:s("chat.list.loading.hint")})]}),e.jsx("div",{"aria-hidden":"true",className:"mt-7 space-y-4 rounded-xl border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface))]/45 px-4 py-5",children:[72,88,64].map((C,T)=>e.jsxs("div",{className:D("flex gap-3",T%2===1&&"flex-row-reverse"),children:[e.jsx("span",{className:"h-7 w-7 shrink-0 animate-pulse rounded-md bg-[hsl(var(--deck-surface-2))]"}),e.jsx("span",{className:"h-10 animate-pulse rounded-lg bg-[hsl(var(--deck-surface-2))]",style:{width:`${C}%`,animationDelay:`${T*120}ms`}})]},C))})]})});if(t.length===0&&!a)return e.jsx("div",{className:"flex flex-1 justify-center items-center",children:e.jsxs("div",{className:"flex flex-col gap-4 items-center text-center",children:[e.jsx(Ce,{size:44}),e.jsxs("div",{children:[e.jsx("div",{className:"deck-eyebrow text-[hsl(var(--deck-accent))]",children:s("chat.list.empty.eyebrow")}),e.jsx("div",{className:"mt-2 text-[15px] font-medium text-[hsl(var(--deck-ink))]",children:s("chat.list.empty.title")}),e.jsx("div",{className:"mt-1 max-w-xs text-[12px] text-[hsl(var(--deck-ink-muted))]",children:s("chat.list.empty.hint")})]})]})});const R=()=>{const C=le(r.current);C&&(C.scrollTop=C.scrollHeight,i.current=!0,l.current=!0,c.current=new Set,S(0),N(!1))},j=()=>{var T;const C=le(r.current);if(C){const M=((T=r.current)==null?void 0:T.querySelector("[data-chat-message-id]"))??null;b.current={element:M,viewportTop:(M==null?void 0:M.getBoundingClientRect().top)??0,scrollHeight:C.scrollHeight,scrollTop:C.scrollTop}}y(M=>_s(M,t.length,Ne))},O=C=>C>=n?!0:(y(t.length),!1),G=m===1?s("chat.list.unreadMessage"):s("chat.list.unreadMessages",{count:m});return e.jsxs("div",{ref:r,className:"relative flex-1 min-h-0",children:[e.jsx(_t,{className:"h-full",children:e.jsxs("div",{className:"flex flex-col px-4 pb-4 w-full md:px-6",children:[w>0&&e.jsx("div",{className:"flex justify-center py-3",children:e.jsx("button",{type:"button",onClick:j,"aria-label":s("chat.list.showEarlierWithRemaining",{count:Math.min(w,Ne),remaining:w}),className:"rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-3 py-1.5 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:border-[hsl(var(--deck-border-strong))] hover:text-[hsl(var(--deck-ink))]",children:s("chat.list.showEarlier",{count:Math.min(w,Ne)})})}),E.map((C,T)=>{const M=n+T,P=M>0?t[M-1]:null,L=!P||P.role!==C.role||P.role==="user";return e.jsx(Is,{message:C,showAvatar:L},C.id||`msg-${M}`)})]})}),e.jsx(Ps,{turns:F,viewportRef:o,containerRef:r,onRevealTurn:O}),p&&e.jsxs("button",{type:"button",onClick:R,"aria-live":"polite","aria-label":m>0?G:s("chat.list.jumpLatest"),className:"absolute bottom-4 left-1/2 z-10 inline-flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-[hsl(var(--deck-border-strong))] bg-[hsl(var(--deck-surface))]/95 px-3 py-1.5 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] shadow-lg backdrop-blur transition-colors hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:[e.jsx(Fe,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}),m>0?G:s("chat.list.jumpLatest")]})]})}const lt=h.memo(Hs);function Qs({queue:t,mutation:a,onMutate:s,onRefresh:r}){const o=B(),[i,l]=h.useState(!1),u=h.useRef(null),x=h.useRef(null),c=h.useRef(null);h.useLayoutEffect(()=>{var p,N,m;if(a.pending||!u.current)return;const d=u.current;u.current=null,(m=Array.from(((p=x.current)==null?void 0:p.querySelectorAll("[data-follow-up-focus-id]"))??[]).find(S=>S.dataset.followUpFocusId===d)??((N=x.current)==null?void 0:N.querySelector("button")))==null||m.focus()},[a.pending,t==null?void 0:t.version]);const v=h.useCallback(async d=>{u.current=d.messageId,await s(d)},[s]),b=h.useCallback((d,y)=>{v({type:"move",messageId:d,toPosition:y})},[v]);return!t||t.pending===0&&!a.errorMessage?null:e.jsxs("section",{ref:x,"data-blade-follow-up-queue":!0,className:"mx-4 mb-2 overflow-hidden rounded-lg border border-amber-300/70 bg-amber-50/70 shadow-sm dark:border-amber-900/60 dark:bg-amber-950/25 md:mx-6","aria-label":o("chat.followUpQueue.title"),children:[e.jsxs("button",{type:"button","aria-label":o(i?"chat.followUpQueue.hide":"chat.followUpQueue.show"),"aria-expanded":i,onClick:()=>l(d=>!d),className:"flex min-h-10 w-full items-center gap-2 px-3 text-left font-mono text-[11px] text-amber-950 transition-colors hover:bg-amber-100/70 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-amber-500 dark:text-amber-100 dark:hover:bg-amber-900/35",children:[e.jsx(Gt,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"font-semibold",children:o("chat.followUpQueue.count",{count:t.pending})}),t.locked>0&&e.jsx("span",{className:"text-amber-700/80 dark:text-amber-300/75",children:o("chat.followUpQueue.lockedCount",{count:t.locked})}),e.jsx(oe,{className:`ml-auto h-3.5 w-3.5 transition-transform ${i?"rotate-90":""}`,"aria-hidden":!0})]}),i&&e.jsxs("div",{className:"border-t border-amber-300/60 px-2 py-2 dark:border-amber-900/50",children:[a.errorMessage&&e.jsxs("div",{role:"alert",className:"mb-2 flex items-center gap-2 rounded-md border border-red-200 bg-red-50 px-2.5 py-2 text-[11px] text-red-700 dark:border-red-900/60 dark:bg-red-950/35 dark:text-red-300",children:[e.jsx("span",{className:"min-w-0 flex-1",children:a.errorCode==="revision_conflict"?o("chat.followUpQueue.stale"):a.errorMessage}),r&&e.jsx("button",{type:"button","aria-label":o("chat.followUpQueue.refresh"),onClick:()=>void r(),className:"rounded p-1 hover:bg-red-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-red-500 dark:hover:bg-red-900/60",children:e.jsx(tt,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),e.jsx("ol",{className:"space-y-1.5",children:t.items.map((d,y)=>{const p=t.items[y-1],N=t.items[y+1],m=d.mutable&&(p==null?void 0:p.mutable)===!0,S=d.mutable&&(N==null?void 0:N.mutable)===!0,k=a.pending;return e.jsxs("li",{"data-follow-up-id":d.id,"data-follow-up-state":d.state,"data-follow-up-focus-id":d.id,tabIndex:-1,draggable:d.mutable&&!a.pending,onDragStart:()=>{c.current=d.mutable?d.id:null},onDragOver:w=>{const n=c.current,E=t.items.find(F=>F.id===n);E!=null&&E.mutable&&d.mutable&&w.preventDefault()},onDrop:w=>{w.preventDefault();const n=c.current;c.current=null;const E=t.items.find(j=>j.id===n);if(!(E!=null&&E.mutable)||!d.mutable||E.id===d.id)return;const F=Math.min(E.position,d.position),R=Math.max(E.position,d.position);t.items.slice(F,R+1).some(j=>!j.mutable)||b(E.id,d.position)},onDragEnd:()=>{c.current=null},className:"flex min-w-0 items-center gap-2 rounded-md border border-amber-200/70 bg-white/75 px-2.5 py-2 dark:border-amber-900/50 dark:bg-zinc-950/45",children:[e.jsx("span",{className:"w-5 shrink-0 text-center font-mono text-[10px] text-amber-700 dark:text-amber-400",children:y+1}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-xs text-[hsl(var(--deck-ink))]",children:d.kind==="internal"?o("chat.followUpQueue.internal"):d.preview||o("chat.followUpQueue.attachmentOnly")}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-2 font-mono text-[9px] uppercase tracking-[0.08em] text-[hsl(var(--deck-ink-faint))]",children:[e.jsx("span",{children:o(`chat.followUpQueue.delivery.${d.delivery}`)}),!d.mutable&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Wt,{className:"h-2.5 w-2.5","aria-hidden":!0}),o("chat.followUpQueue.locked")]}),d.attachmentCount>0&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(gt,{className:"h-2.5 w-2.5","aria-hidden":!0}),d.attachmentCount]})]})]}),k&&a.messageId===d.id?e.jsx(_,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-amber-600"}):e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[e.jsx("button",{type:"button","aria-label":o("chat.followUpQueue.moveUp",{id:d.id}),disabled:k||!m,onClick:()=>b(d.id,y-1),className:"rounded p-1 text-amber-800 transition-colors hover:bg-amber-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-amber-500 disabled:opacity-30 dark:text-amber-300 dark:hover:bg-amber-900/50",children:e.jsx(Bt,{className:"h-3.5 w-3.5","aria-hidden":!0})}),e.jsx("button",{type:"button","aria-label":o("chat.followUpQueue.moveDown",{id:d.id}),disabled:k||!S,onClick:()=>b(d.id,y+1),className:"rounded p-1 text-amber-800 transition-colors hover:bg-amber-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-amber-500 disabled:opacity-30 dark:text-amber-300 dark:hover:bg-amber-900/50",children:e.jsx(Fe,{className:"h-3.5 w-3.5","aria-hidden":!0})}),e.jsx("button",{type:"button","aria-label":o("chat.followUpQueue.remove",{id:d.id}),disabled:k||!d.mutable,onClick:()=>void v({type:"remove",messageId:d.id}),className:"rounded p-1 text-red-600 transition-colors hover:bg-red-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-red-500 disabled:opacity-30 dark:text-red-400 dark:hover:bg-red-950/60",children:e.jsx(ne,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})]},d.id)})})]})]})}const Te=Lt,Ee=Ut,Me=Ot,ve=h.forwardRef(({className:t,sideOffset:a=4,...s},r)=>e.jsx(nt,{ref:r,sideOffset:a,className:D("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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 origin-[--radix-tooltip-content-transform-origin]",t),...s}));ve.displayName=nt.displayName;const zs={active:{labelKey:"goal.status.active",dot:"bg-[hsl(var(--deck-accent))] shadow-[0_0_6px_hsl(var(--deck-accent-glow)/0.5)]",accent:"text-[hsl(var(--deck-accent))]"},verifying:{labelKey:"goal.status.active",dot:"animate-pulse bg-sky-400",accent:"text-sky-600 dark:text-sky-300"},paused:{labelKey:"goal.status.paused",dot:"bg-amber-400",accent:"text-amber-600 dark:text-amber-300"},blocked:{labelKey:"goal.status.blocked",dot:"bg-rose-500",accent:"text-rose-600 dark:text-rose-300"},usage_limited:{labelKey:"goal.status.usageLimited",dot:"bg-orange-500",accent:"text-orange-600 dark:text-orange-300"},budget_limited:{labelKey:"goal.status.budgetLimited",dot:"bg-orange-500",accent:"text-orange-600 dark:text-orange-300"},complete:{labelKey:"goal.status.complete",dot:"bg-emerald-500",accent:"text-emerald-600 dark:text-emerald-300"}};function xe(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)}function qs(t){if(t<60)return`${t}s`;const a=Math.floor(t/60),s=t%60;return s===0?`${a}m`:`${a}m ${s}s`}function Gs(){var C,T,M,P,L,ee,Q,Z,J,te,A,z,q,V,H,$,W,Y,he,ce;const t=B(),{locale:a}=st(),s=f(I=>I.goal),r=f(I=>I.pauseGoal),o=f(I=>I.resumeGoal),i=f(I=>I.editGoal),l=f(I=>I.clearGoal),u=f(I=>ie(I.historySurfaceSelection)),[x,c]=h.useState(!1),[v,b]=h.useState(!1),[d,y]=h.useState(""),[p,N]=h.useState(null),[m,S]=h.useState(!1);if(h.useEffect(()=>{c(!1),b(!1),y((s==null?void 0:s.objective)??""),S(!1)},[s==null?void 0:s.goalId]),u||!s)return null;const k=zs[s.status],w=["active","verifying","paused","blocked"].includes(s.status),n=s.status==="active"||s.status==="verifying",E=s.status==="paused"||s.status==="blocked",F=p!==null,R=async(I,g)=>{if(!K(f.getState())){N(I);try{await g()}finally{N(null)}}},j=()=>{y(s.objective),b(!0),c(!0)},O=async I=>{I.preventDefault();const g=d.trim();if(!g||g===s.objective){b(!1);return}await R("edit",()=>i(g)),b(!1)},G=async()=>{await R("delete",l),S(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(Te,{delayDuration:250,children:e.jsxs("section",{"aria-label":t("goal.aria.section"),className:"mx-3 mb-1 shrink-0","data-blade-goal-status":s.status,"data-blade-goal-recovery":(C=s.prematureStop)==null?void 0:C.consecutiveCount,"data-blade-goal-recovery-pattern":(T=s.prematureStop)==null?void 0:T.pattern,"data-blade-goal-verification-stall":(M=s.verificationStall)==null?void 0:M.consecutiveCount,"data-blade-goal-frontier-task-list":(P=s.executionFrontier)==null?void 0:P.taskListId,"data-blade-goal-frontier-total":(L=s.executionFrontier)==null?void 0:L.total,"data-blade-goal-frontier-completed":(ee=s.executionFrontier)==null?void 0:ee.completed,"data-blade-goal-frontier-in-progress":(Q=s.executionFrontier)==null?void 0:Q.inProgress,"data-blade-goal-frontier-pending":(Z=s.executionFrontier)==null?void 0:Z.pending,"data-blade-goal-frontier-blocked":(J=s.executionFrontier)==null?void 0:J.blocked,"data-blade-goal-frontier-next-task":(A=(te=s.executionFrontier)==null?void 0:te.nextTask)==null?void 0:A.id,"data-blade-goal-frontier-digest":(z=s.executionFrontier)==null?void 0:z.digestSha256.slice(0,16),"data-blade-goal-frontier-stall":(q=s.frontierStall)==null?void 0:q.category,"data-blade-goal-frontier-stall-count":(V=s.frontierStall)==null?void 0:V.consecutiveCount,"data-blade-goal-execution-host-failure":(H=s.executionHostFailure)==null?void 0:H.category,"data-blade-goal-execution-host-failure-count":($=s.executionHostFailure)==null?void 0:$.consecutiveCount,"data-blade-goal-root-turn":(W=s.turnLineage)==null?void 0:W.rootTurnId,"data-blade-goal-current-turn":(Y=s.turnLineage)==null?void 0:Y.currentTurnId,"data-blade-goal-parent-turn":(he=s.turnLineage)==null?void 0:he.parentTurnId,children:[e.jsxs("div",{className:D("flex h-9 items-center gap-2 rounded-lg border px-3 transition-colors","border-[hsl(var(--deck-border))]/60 bg-[hsl(var(--deck-surface))]/80 backdrop-blur-sm",x&&"rounded-b-none border-b-0"),children:[s.status==="complete"?e.jsx(kt,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500"}):e.jsx(Yt,{className:D("h-3.5 w-3.5 shrink-0",k.accent)}),e.jsx("span",{className:D("h-1.5 w-1.5 shrink-0 rounded-full",k.dot)}),e.jsx("span",{className:D("shrink-0 text-[10px] font-medium leading-none",k.accent),children:s.status==="verifying"?a==="zh"?"验证中":"Verifying":t(k.labelKey)}),e.jsx("span",{className:"h-3 w-px shrink-0 bg-[hsl(var(--deck-hairline))]"}),e.jsx("button",{type:"button","aria-label":t(x?"goal.action.collapse":"goal.action.expand"),className:"min-w-0 flex-1 truncate text-left text-[12px] leading-5 text-[hsl(var(--deck-ink))]/85 outline-none transition-colors hover:text-[hsl(var(--deck-ink))]",onClick:()=>c(I=>!I),"aria-expanded":x,title:s.objective,children:s.objective}),s.tokensUsed>0&&e.jsxs("span",{className:"hidden shrink-0 text-[10px] tabular-nums text-[hsl(var(--deck-ink-muted))] sm:inline",children:[xe(s.tokensUsed),s.tokenBudget!==void 0&&`/${xe(s.tokenBudget)}`]}),e.jsxs("div",{className:"flex shrink-0 items-center",children:[n&&e.jsx(pe,{label:t("goal.action.pause"),disabled:F,onClick:()=>void R("pause",r),children:p==="pause"?e.jsx(_,{className:"animate-spin"}):e.jsx(Kt,{})}),E&&e.jsx(pe,{label:t("goal.action.resume"),disabled:F,onClick:()=>void R("resume",o),children:p==="resume"?e.jsx(_,{className:"animate-spin"}):e.jsx(Vt,{})}),e.jsx(pe,{label:t(w?"goal.action.edit":"goal.action.expand"),disabled:!w&&!x,onClick:w?j:()=>c(I=>!I),children:w?e.jsx(it,{}):e.jsx(Pt,{})}),e.jsx(pe,{label:t("goal.action.delete"),disabled:F,destructive:!0,onClick:()=>S(!0),children:e.jsx(ne,{})})]})]}),x&&e.jsx("div",{className:"rounded-b-lg border border-t-0 border-[hsl(var(--deck-border))]/60 bg-[hsl(var(--deck-surface))]/80 px-4 py-3 backdrop-blur-sm",children:v?e.jsxs("form",{onSubmit:O,children:[e.jsx("textarea",{id:"goal-objective",value:d,onChange:I=>y(I.target.value),onKeyDown:I=>{I.key==="Escape"&&b(!1)},rows:3,autoFocus:!0,className:"w-full resize-none rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))] px-3 py-2 text-[12px] leading-5 text-[hsl(var(--deck-ink))] outline-none transition-shadow focus:border-[hsl(var(--deck-accent))] focus:ring-1 focus:ring-[hsl(var(--deck-accent-glow))]"}),e.jsxs("div",{className:"mt-2 flex items-center justify-end gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>b(!1),className:"inline-flex h-7 items-center gap-1 rounded-md px-2.5 text-[11px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:bg-[hsl(var(--deck-hairline))]/60",children:[e.jsx(at,{className:"h-3 w-3"}),t("goal.action.cancel")]}),e.jsxs("button",{type:"submit",disabled:!d.trim()||p==="edit",className:"inline-flex h-7 items-center gap-1 rounded-md bg-[hsl(var(--deck-accent))] px-2.5 text-[11px] font-medium text-white transition-colors hover:bg-[hsl(var(--deck-accent))]/90 disabled:cursor-not-allowed disabled:opacity-50",children:[p==="edit"?e.jsx(_,{className:"h-3 w-3 animate-spin"}):e.jsx(ge,{className:"h-3 w-3"}),t("goal.action.save")]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"whitespace-pre-wrap text-[12px] leading-5 text-[hsl(var(--deck-ink))]/90",children:s.objective}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[10px] text-[hsl(var(--deck-ink-muted))]",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(zt,{className:"h-3 w-3"}),xe(s.tokensUsed),s.tokenBudget!==void 0&&` / ${xe(s.tokenBudget)}`," ",t("goal.metrics.tokens")]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Xt,{className:"h-3 w-3"}),qs(s.timeUsedSeconds)]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(fe,{className:"h-3 w-3"}),s.continuationCount===1?t("goal.metrics.continuationOne",{n:s.continuationCount}):t("goal.metrics.continuationMany",{n:s.continuationCount})]})]}),s.turnLineage&&e.jsxs("div",{className:"mt-2 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 rounded-md border border-[hsl(var(--deck-border))]/50 bg-[hsl(var(--deck-canvas))]/45 px-2.5 py-2 font-mono text-[10px] text-[hsl(var(--deck-ink-muted))]",children:[e.jsx("span",{children:t("goal.lineage.origin")}),e.jsx("span",{className:"truncate",children:s.turnLineage.rootTurnId??"?"}),e.jsx("span",{children:t("goal.lineage.current")}),e.jsx("span",{className:"truncate",children:s.turnLineage.currentTurnId}),e.jsx("span",{children:t("goal.lineage.parent")}),e.jsx("span",{className:"truncate",children:s.turnLineage.parentTurnId??"?"})]}),s.prematureStop&&e.jsxs("div",{className:"mt-2 inline-flex items-center gap-1.5 font-mono text-[10px] text-amber-700 dark:text-amber-300",children:[e.jsx(fe,{className:"h-3 w-3"}),a==="zh"?"恢复提示":"Recovery nudge"," ",s.prematureStop.consecutiveCount," ·"," ",s.prematureStop.pattern.replaceAll("_"," ")]}),s.executionHostFailure&&e.jsxs("div",{className:"mt-2 rounded-md border border-amber-200/50 bg-amber-50/60 px-2.5 py-2 text-[11px] text-amber-900 dark:border-amber-400/15 dark:bg-amber-400/[0.05] dark:text-amber-100",children:[e.jsx("p",{className:"font-medium",children:t("goal.executionHostFailure.title")}),e.jsxs("p",{className:"mt-1 font-mono opacity-80",children:[t(`goal.executionHostFailure.category.${s.executionHostFailure.category}`)," ","· ",s.executionHostFailure.consecutiveCount,"/3"]})]}),s.completionVerification&&e.jsxs("div",{"data-goal-verification":s.completionVerification.status,className:"mt-2 rounded-md border border-sky-200/50 bg-sky-50/60 px-2.5 py-2 text-[11px] text-sky-900 dark:border-sky-400/15 dark:bg-sky-400/[0.05] dark:text-sky-100",children:[e.jsxs("p",{className:"font-mono font-medium",children:["#",s.completionVerification.attempt," ·"," ",s.completionVerification.status.toUpperCase()," ·"," ",((ce=s.completionVerification.verifierSessionId)==null?void 0:ce.slice(0,12))??"-",s.verificationStall?a==="zh"?` · 重复 ${s.verificationStall.consecutiveCount}/3`:` · repeat ${s.verificationStall.consecutiveCount}/3`:""]}),s.completionVerification.summary&&e.jsx("p",{className:"mt-1 line-clamp-3 whitespace-pre-wrap opacity-80",children:s.completionVerification.summary}),s.completionVerification.evidenceSha256&&e.jsxs("p",{className:"mt-1 font-mono text-[10px] opacity-60",children:["sha256:",s.completionVerification.evidenceSha256.slice(0,12)]})]}),s.statusReason&&e.jsx("div",{className:"mt-2 rounded-md border border-amber-200/50 bg-amber-50/60 px-2.5 py-1.5 text-[11px] text-amber-800 dark:border-amber-400/15 dark:bg-amber-400/[0.05] dark:text-amber-200",children:s.statusReason})]})})]})}),e.jsx(We,{open:m,onOpenChange:S,children:e.jsxs(Je,{className:"max-w-[400px] border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsx(Ye,{children:t("goal.dialog.title")}),e.jsx(Xe,{children:t("goal.dialog.description")}),e.jsxs(Ze,{className:"mt-2",children:[e.jsx("button",{type:"button",onClick:()=>S(!1),className:"inline-flex h-8 items-center justify-center rounded-md border border-[hsl(var(--deck-border))] px-3 text-[12px] text-[hsl(var(--deck-ink))] hover:bg-[hsl(var(--deck-hairline))]/60",children:t("goal.action.cancel")}),e.jsxs("button",{type:"button",disabled:p==="delete",onClick:()=>void G(),className:"inline-flex gap-1.5 justify-center items-center px-3 h-8 text-[12px] font-medium text-white bg-rose-600 rounded-md hover:bg-rose-500 disabled:opacity-50",children:[p==="delete"&&e.jsx(_,{className:"w-3.5 h-3.5 animate-spin"}),t("goal.action.delete")]})]})]})})]})}function pe({label:t,children:a,disabled:s,destructive:r,onClick:o}){return e.jsxs(Ee,{children:[e.jsx(Me,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":t,disabled:s,onClick:o,className:D("flex h-6 w-6 items-center justify-center rounded-md text-[hsl(var(--deck-ink-muted))] outline-none transition-colors focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent-glow))]/50 disabled:cursor-not-allowed disabled:opacity-35 [&_svg]:h-3.5 [&_svg]:w-3.5",r?"hover:bg-rose-500/10 hover:text-rose-500":"hover:bg-[hsl(var(--deck-hairline))]/60 hover:text-[hsl(var(--deck-ink))]"),children:a})}),e.jsx(ve,{side:"top",className:"text-[10px]",children:t})]})}function Ws(){const t=B(),a=f(c=>c.currentSessionRef),s=f(c=>c.sessions),r=f(c=>c.messages),o=f(c=>ie(c.historySurfaceSelection)),i=h.useMemo(()=>{var v,b,d,y,p;const c=a?(v=yt(s,a))==null?void 0:v.pendingInteraction:void 0;if(c)return c.type;for(let N=r.length-1;N>=0;N-=1){const m=(b=r[N])==null?void 0:b.agentContent;if(((d=m==null?void 0:m.confirmation)==null?void 0:d.status)==="pending")return"permission";if(((y=m==null?void 0:m.question)==null?void 0:y.status)==="pending")return"question";if(((p=m==null?void 0:m.elicitation)==null?void 0:p.status)==="pending")return"elicitation"}return null},[a,r,s]);if(o||!i)return null;const l=()=>{const c=document.querySelector(`[data-pending-interaction="${i}"]`);c==null||c.scrollIntoView({block:"center",behavior:"smooth"}),window.setTimeout(()=>c==null?void 0:c.focus(),250)},u=i==="question",x=i==="elicitation";return e.jsxs("div",{role:"alert",className:"mx-3 mb-2 flex flex-wrap items-center gap-2 rounded-lg border border-amber-300/80 bg-amber-50/95 px-3 py-2 font-mono text-amber-950 shadow-sm backdrop-blur dark:border-amber-800/80 dark:bg-amber-950/90 dark:text-amber-100 sm:mx-5",children:[e.jsx(Ae,{className:"h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"min-w-[180px] flex-1",children:[e.jsx("div",{className:"text-[11.5px] font-semibold",children:t(u?"interaction.bar.questionTitle":x?"interaction.bar.elicitationTitle":"interaction.bar.permissionTitle")}),e.jsx("div",{className:"mt-0.5 text-[10px] leading-4 text-amber-800 dark:text-amber-300",children:t(u?"interaction.bar.questionHint":x?"interaction.bar.elicitationHint":"interaction.bar.permissionHint")})]}),e.jsxs("button",{type:"button",onClick:l,className:"inline-flex min-h-8 shrink-0 items-center gap-1.5 rounded-md border border-amber-400/80 bg-white/80 px-2.5 text-[10.5px] font-medium transition-colors hover:bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-700 dark:bg-amber-950/70 dark:hover:bg-amber-900",children:[e.jsx(Fe,{className:"h-3 w-3"}),t("interaction.bar.review")]})]})}function ue(t){return Math.max(0,Math.ceil((t??0)/1e3))}function Js(t,a=Date.now()){var r;const s=(r=t.snapshot)==null?void 0:r.nextActionAt;return s===void 0?void 0:ue(s-a)}function dt(t,a=Date.now()){const s=t==null?void 0:t.snapshot;if(!s)return null;const r=Js(t,a)??0,o=s.retry,i=s.admission,l=s.stall,u=s.fallback,x={seconds:r,attempt:(o==null?void 0:o.attempt)??0,maxRetries:(o==null?void 0:o.maxRetries)??0,budgetSeconds:ue(o==null?void 0:o.recoveryRemainingMs),position:(i==null?void 0:i.queuePosition)??0,depth:i?Math.max(i.queueDepth,i.queuePosition):0,scope:(i==null?void 0:i.scope)??"",waitSeconds:ue(i==null?void 0:i.waitMs),stallSeconds:ue(l==null?void 0:l.durationMs),timeoutSeconds:ue(l==null?void 0:l.timeoutMs),from:(u==null?void 0:u.from.model)??"",to:(u==null?void 0:u.to.model)??"",candidate:(u==null?void 0:u.candidate)??0,candidateCount:(u==null?void 0:u.candidateCount)??0};switch(s.activity){case"admission_wait":return{titleKey:"chat.providerRecovery.admission",detailKey:"chat.providerRecovery.admissionDetail",compactKey:"chat.providerRecovery.admissionCompact",params:x};case"retry_wait":return{titleKey:s.reason==="rate_limit"?"chat.providerRecovery.rateLimit":"chat.providerRecovery.retryWait",detailKey:"chat.providerRecovery.retryDetail",compactKey:"chat.providerRecovery.retryCompact",params:x};case"retry_attempt":return{titleKey:"chat.providerRecovery.retryAttempt",detailKey:"chat.providerRecovery.retryDetail",compactKey:"chat.providerRecovery.retryCompact",params:x};case"circuit_open":return{titleKey:s.reason==="rate_limit"?"chat.providerRecovery.rateLimitCircuit":"chat.providerRecovery.circuit",detailKey:"chat.providerRecovery.circuitDetail",compactKey:s.reason==="rate_limit"?"chat.providerRecovery.rateLimitCircuitCompact":"chat.providerRecovery.circuitCompact",params:x};case"circuit_probe":return{titleKey:"chat.providerRecovery.probe",detailKey:"chat.providerRecovery.probeDetail",compactKey:"chat.providerRecovery.probeCompact",params:x};case"stream_stall":return{titleKey:l!=null&&l.outputStarted?"chat.providerRecovery.stallAfterOutput":"chat.providerRecovery.stall",detailKey:"chat.providerRecovery.stallDetail",compactKey:"chat.providerRecovery.stallCompact",params:x};case"fallback":return{titleKey:"chat.providerRecovery.fallback",detailKey:"chat.providerRecovery.fallbackDetail",compactKey:"chat.providerRecovery.fallbackCompact",params:x}}}function Ys({recovery:t,stopping:a,onStop:s}){var x;const r=B(),[o,i]=h.useState(Date.now()),l=(x=t==null?void 0:t.snapshot)==null?void 0:x.nextActionAt;h.useEffect(()=>{if(l===void 0)return;i(Date.now());const c=window.setInterval(()=>i(Date.now()),1e3);return()=>window.clearInterval(c)},[l]);const u=dt(t,o);return u?e.jsxs("section",{role:"status","aria-live":"polite","data-provider-recovery-banner":!0,className:"mx-4 mb-2 flex min-h-12 items-center gap-3 rounded-lg border border-amber-300/70 bg-amber-50/80 px-3 py-2 text-amber-950 shadow-sm dark:border-amber-800/60 dark:bg-amber-950/35 dark:text-amber-100 md:mx-6",children:[e.jsx(_,{className:"h-4 w-4 shrink-0 animate-spin","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-semibold",children:r(u.titleKey,u.params)}),e.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] opacity-80",children:r(u.detailKey,u.params)})]}),e.jsxs("button",{type:"button","data-provider-recovery-stop":!0,onClick:s,disabled:a,className:"inline-flex min-h-8 shrink-0 items-center gap-1.5 rounded-md border border-amber-400/70 bg-white/70 px-2.5 text-xs font-medium transition-colors hover:bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 disabled:cursor-wait disabled:opacity-60 dark:border-amber-700 dark:bg-amber-950/50 dark:hover:bg-amber-900/50",children:[a?e.jsx(_,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):e.jsx(jt,{className:"h-3 w-3 fill-current","aria-hidden":!0}),r(a?"chat.input.action.stopping":"chat.providerRecovery.stop")]})]}):null}const Xs=h.lazy(()=>et(()=>import("./MarkdownRenderer-DaQIOCqh.js").then(t=>t.M),__vite__mapDeps([0,1,2,3,4,5,6])).then(t=>({default:t.MarkdownRenderer})));function Zs(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(1)}s`}function ea(){const t=B(),a=f(r=>r.sideConversation),s=f(r=>r.dismissSideConversation);return a?e.jsx("section",{"aria-label":t("chat.side.title"),"data-blade-side-conversation":!0,"data-status":a.status,className:"shrink-0 border-y border-[hsl(var(--deck-accent)/0.28)] bg-[hsl(var(--deck-accent-soft)/0.42)]",children:e.jsxs("div",{className:"px-4 py-3 md:px-6",children:[e.jsxs("header",{className:"flex min-h-7 items-start gap-2",children:[e.jsx(Jt,{"aria-hidden":!0,className:"mt-0.5 h-4 w-4 shrink-0 text-[hsl(var(--deck-accent))]"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-1",children:[e.jsx("h2",{className:"font-mono text-[11px] font-semibold uppercase text-[hsl(var(--deck-accent))]",children:t("chat.side.title")}),a.durationMs!==void 0&&e.jsxs("span",{className:"inline-flex items-center gap-1 font-mono text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:[e.jsx(Ht,{"aria-hidden":!0,className:"h-3 w-3"}),Zs(a.durationMs)]})]}),e.jsx("p",{className:"mt-0.5 break-words font-mono text-[11px] leading-4 text-[hsl(var(--deck-ink-muted))]",children:a.question})]}),e.jsx("button",{type:"button",onClick:s,"aria-label":t("chat.side.dismiss"),title:t("chat.side.dismiss"),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-[hsl(var(--deck-ink-faint))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:e.jsx(at,{"aria-hidden":!0,className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{"aria-live":"polite","aria-busy":a.status==="loading",className:"mt-2 max-h-[min(36vh,320px)] overflow-y-auto border-l-2 border-[hsl(var(--deck-accent)/0.42)] pl-3 pr-1",children:[a.status==="loading"&&e.jsxs("div",{role:"status",className:"flex min-h-9 items-center gap-2 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(_,{"aria-hidden":!0,className:"h-3.5 w-3.5 animate-spin text-[hsl(var(--deck-accent))]"}),t("chat.side.loading")]}),a.status==="error"&&e.jsxs("div",{role:"alert",className:"flex min-h-9 items-start gap-2 font-mono text-[11px] leading-5 text-red-700 dark:text-red-300",children:[e.jsx(Ae,{"aria-hidden":!0,className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"break-words",children:a.error??t("chat.side.failed")})]}),a.status==="completed"&&a.response&&e.jsx(h.Suspense,{fallback:e.jsx("div",{className:"whitespace-pre-wrap break-words font-mono text-[12px] leading-5 text-[hsl(var(--deck-ink))]",children:a.response}),children:e.jsx(Xs,{content:a.response,className:"text-[12px] leading-5 [&_h1]:text-[14px] [&_h2]:text-[13px] [&_h3]:text-[12px]"})})]})]})}):null}function Se(t){return Number.isFinite(t)?Math.max(0,t):0}function ta(t){const a=Se(t.totalInputTokens),s=Se(t.cacheReadTokens),r=Se(t.cacheWriteTokens),o=Math.min(s,a),i=Math.min(r,Math.max(0,a-o)),l=Math.max(0,a-o-i),u=a>0&&(s>0||r>0);return{totalInputTokens:a,cacheReadTokens:o,cacheWriteTokens:i,uncachedInputTokens:l,...u?{hitRate:o/a}:{}}}function sa(t){return t===void 0||!Number.isFinite(t)?"—":`${Math.round(Math.max(0,Math.min(1,t))*100)}%`}const aa={running:"status.phase.running",compacting:"status.phase.compacting",recovering_context:"status.phase.recoveringContext",switching_model:"status.phase.switchingModel",waiting_permission:"status.phase.waitingPermission",error:"status.phase.error",idle:""},ra={model_changed:"status.cacheBreak.model",system_prompt_changed:"status.cacheBreak.system",tools_changed:"status.cacheBreak.tools",request_policy_changed:"status.cacheBreak.policy",ttl_expired:"status.cacheBreak.ttl",server_side:"status.cacheBreak.server"},se=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString(),na=t=>{const a=Math.max(0,Math.ceil(t/1e3)),s=Math.floor(a/60),r=a%60;return s>0?`${s}m ${r}s`:`${r}s`};function ut(){const t=B(),a=f(n=>n.tokenUsage),s=f(n=>n.isStreaming),r=f(n=>n.agentPhase),o=f(n=>n.providerRecovery),i=f(n=>n.turnActivity),l=f(n=>n.pendingResume),u=f(n=>n.actionStationarity),x=f(n=>n.turnRecovery),c=aa[r]??"",v=dt(o),b=(l==null?void 0:l.delayMs)!==void 0?` · retry in ${na(l.delayMs)}`:"",d=(x==null?void 0:x.state)==="requires_attention"?t("status.recovery.review"):"",y=(x==null?void 0:x.state)==="requires_attention"?t(x.reason==="interrupted_tool_call"?"status.recovery.interruptedTool":"status.recovery.successfulTool"):"",p=d||(u?`${t(u.phase==="halted"?"status.phase.actionStationarityStopped":"status.phase.actionStationarityRecovering")} · ${u.toolName} · ${u.runLength}/${u.haltThreshold}`:v?t(v.compactKey,v.params):l?`Recovery attempt ${l.attempt}/${l.maxAttempts}${b}`:c?t(c):""),N=a.maxContextTokens>0?Math.round(a.totalTokens/a.maxContextTokens*100):0,m=ta(a),S=sa(m.hitRate),k=Math.min(N,100),w=N>95?"danger":N>80?"warn":"safe";return e.jsxs("div",{"data-chat-status-bar":!0,className:"flex items-center gap-2 border-t border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))]/70 px-3 py-2 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] backdrop-blur-sm sm:gap-4 sm:px-5",children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[e.jsx("span",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:t("status.context")}),e.jsxs("span",{className:"flex gap-1 items-baseline tabular-nums",children:[e.jsx("span",{className:D("text-[12px] font-medium",w==="safe"&&"text-[hsl(var(--deck-ink))]",w==="warn"&&"text-amber-600 dark:text-amber-400",w==="danger"&&"text-red-600 dark:text-red-400"),children:se(a.totalTokens)}),e.jsxs("span",{className:"text-[hsl(var(--deck-ink-faint))]",children:["/ ",se(a.maxContextTokens)]})]}),a.isDefaultMaxTokens&&e.jsx(Te,{children:e.jsxs(Ee,{children:[e.jsx(Me,{asChild:!0,children:e.jsx(qt,{className:"h-3 w-3 cursor-help text-[hsl(var(--deck-ink-faint))]"})}),e.jsx(ve,{side:"top",className:"max-w-[220px]",children:e.jsx("p",{className:"text-xs",children:t("status.tokenLimitTooltip")})})]})}),e.jsxs("div",{className:"relative hidden h-2 w-32 overflow-hidden rounded-sm border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] sm:block","aria-hidden":"true",children:[e.jsx("div",{className:D("absolute inset-y-0 left-0 transition-[width] duration-300",w==="safe"&&"bg-[hsl(var(--deck-accent))]",w==="warn"&&"bg-amber-500",w==="danger"&&"bg-red-500"),style:{width:`${k}%`}}),e.jsx("div",{className:"flex absolute inset-0 pointer-events-none",children:[25,50,75].map(n=>e.jsx("span",{className:"absolute inset-y-0 w-px bg-[hsl(var(--deck-canvas-veil))]/60",style:{left:`${n}%`}},n))})]}),e.jsxs("span",{className:D("w-10 text-right tabular-nums text-[hsl(var(--deck-ink-faint))]",w==="warn"&&"text-amber-600 dark:text-amber-400",w==="danger"&&"text-red-600 dark:text-red-400"),children:[N,"%"]})]}),e.jsx(Te,{children:e.jsxs(Ee,{children:[e.jsx(Me,{asChild:!0,children:e.jsxs("div",{className:"flex shrink-0 cursor-help items-baseline gap-2 border-l border-[hsl(var(--deck-hairline))] pl-2 sm:pl-4","data-testid":"prompt-cache-hit-rate","aria-label":`${t("status.cache")} ${S}`,children:[e.jsx("span",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:t("status.cache")}),e.jsx("span",{className:D("tabular-nums",m.hitRate===void 0?"text-[hsl(var(--deck-ink-faint))]":"font-medium text-[hsl(var(--deck-accent))]"),children:S})]})}),e.jsx(ve,{side:"top",className:"max-w-[280px]",children:m.hitRate===void 0?e.jsx("p",{className:"text-xs",children:t("status.cacheUnavailable")}):e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("p",{children:t("status.cacheTooltip")}),e.jsx("p",{className:"font-mono tabular-nums",children:t("status.cacheDetails",{read:se(m.cacheReadTokens),write:se(m.cacheWriteTokens),uncached:se(m.uncachedInputTokens)})}),a.cacheBreak&&e.jsx("p",{className:"text-[hsl(var(--deck-accent))]",children:t("status.cacheBreak",{reason:t(ra[a.cacheBreak.reason]??"status.cacheBreak.server"),previous:se(a.cacheBreak.previousCacheReadTokens),current:se(a.cacheBreak.cacheReadTokens)})})]})})]})}),e.jsx("div",{className:"flex-1"}),(d||s&&p&&(!(i!=null&&i.snapshot)||u))&&e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:D("shrink-0",d?"h-2 w-2 rounded-sm bg-amber-500":"deck-pulse-dot")}),e.jsxs("span",{className:D("truncate",d?"text-amber-600 dark:text-amber-400":"text-[hsl(var(--deck-accent))]"),children:[p,y?e.jsxs("span",{className:"hidden sm:inline",children:[" · ",y]}):null]})]})]})}function ia(){const{locale:t}=st(),a=wt(n=>n.agentTeamsEnabled),s=f(n=>n.teams),r=f(n=>n.currentSessionRef),o=f(n=>ie(n.historySurfaceSelection)),i=f(n=>n.loadTeams),[l,u]=h.useState({}),[x,c]=h.useState({}),[v,b]=h.useState({}),[d,y]=h.useState(null),[p,N]=h.useState(null),[m,S]=h.useState(null);if(h.useEffect(()=>{o||i(r??void 0)},[a,r,o,i]),o||!a||!r||s.length===0)return null;const k=async n=>{var F;if(K(f.getState()))return;const E=(F=v[n])==null?void 0:F.trim();if(!(!E||d)){y(n),S(null);try{await Be.sendMessage(r,n,x[n]??"*",E),b(R=>({...R,[n]:""})),await i(r)}catch(R){S(R instanceof Error?R.message:U(t,"actionFailed"))}finally{y(null)}}},w=async n=>{if(!K(f.getState())&&!p){N(n),S(null);try{await Be.delete(r,n),await i(r)}catch(E){S(E instanceof Error?E.message:U(t,"actionFailed"))}finally{N(null)}}};return e.jsxs("section",{"aria-label":U(t,"title"),"data-blade-team-panel":!0,className:"shrink-0 border-y border-emerald-300/50 bg-emerald-50/55 dark:border-emerald-800/55 dark:bg-emerald-950/20",children:[m&&e.jsx("div",{role:"alert",className:"border-b border-red-200 bg-red-50 px-4 py-2 font-mono text-[10px] text-red-700 dark:border-red-900 dark:bg-red-950/30 dark:text-red-300 md:px-6",children:m}),s.filter(n=>n.status!=="deleted").map(n=>{var R;const E=l[n.name]??n.status==="running",F=n.tasks.filter(j=>j.status==="completed").length;return e.jsxs("div",{className:"border-b border-emerald-200/40 last:border-0 dark:border-emerald-900/40",children:[e.jsxs("div",{className:"flex min-h-11 items-center gap-2 px-4 py-2 md:px-6",children:[e.jsx("button",{type:"button",onClick:()=>u(j=>({...j,[n.name]:!E})),"aria-label":E?U(t,"collapse"):U(t,"expand"),className:"flex h-7 w-7 items-center justify-center rounded-md text-emerald-700 hover:bg-emerald-100 dark:text-emerald-300 dark:hover:bg-emerald-900/50",children:E?e.jsx(me,{className:"h-4 w-4"}):e.jsx(oe,{className:"h-4 w-4"})}),e.jsx(Zt,{className:"h-4 w-4 shrink-0 text-emerald-700 dark:text-emerald-300"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[e.jsx("h2",{className:"truncate font-mono text-[11px] font-semibold uppercase text-emerald-800 dark:text-emerald-200",children:n.name}),e.jsxs("span",{className:"font-mono text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:[n.status," · ",n.members.length-1," ",U(t,"members")," · ",F,"/",n.tasks.length," ",U(t,"tasks")]})]}),n.description&&e.jsx("p",{className:"truncate font-mono text-[10px] text-[hsl(var(--deck-ink-muted))]",children:n.description})]}),e.jsx("button",{type:"button",onClick:()=>void w(n.name),disabled:p===n.name,"aria-label":U(t,"delete"),title:U(t,"delete"),className:"flex h-7 w-7 items-center justify-center rounded-md text-[hsl(var(--deck-ink-faint))] hover:bg-red-50 hover:text-red-600 disabled:opacity-40 dark:hover:bg-red-950/40",children:e.jsx(ne,{className:"h-3.5 w-3.5"})})]}),E&&e.jsxs("div",{className:"max-h-[min(40vh,360px)] overflow-y-auto border-t border-emerald-200/40 px-4 py-3 md:px-6 dark:border-emerald-900/40",children:[e.jsxs("div",{className:"grid gap-x-6 gap-y-2 lg:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"mb-1 font-mono text-[9.5px] font-semibold uppercase text-[hsl(var(--deck-ink-faint))]",children:U(t,"members")}),n.members.map(j=>e.jsxs("div",{className:"flex min-h-7 items-center gap-2 border-b border-[hsl(var(--deck-hairline)/0.55)] py-1 last:border-0",children:[e.jsx("span",{"aria-label":j.status,className:`h-1.5 w-1.5 shrink-0 rounded-full ${j.status==="running"?"bg-emerald-500":j.status==="completed"||j.status==="leader"?"bg-sky-500":j.status==="failed"?"bg-red-500":"bg-zinc-400"}`}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10.5px] text-[hsl(var(--deck-ink))]",children:j.name}),e.jsx("span",{className:"font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:j.subagentType}),j.worktreePath&&e.jsx(qe,{className:"h-3 w-3 text-[hsl(var(--deck-ink-faint))]","aria-label":U(t,"worktree")})]},j.id))]}),e.jsxs("div",{children:[e.jsx("h3",{className:"mb-1 font-mono text-[9.5px] font-semibold uppercase text-[hsl(var(--deck-ink-faint))]",children:U(t,"tasks")}),n.tasks.length===0?e.jsx("p",{className:"font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:U(t,"noTasks")}):n.tasks.map(j=>e.jsxs("div",{className:"flex min-h-7 items-center gap-2 border-b border-[hsl(var(--deck-hairline)/0.55)] py-1 last:border-0",children:[e.jsxs("span",{className:"w-5 shrink-0 font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:["#",j.id]}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10.5px] text-[hsl(var(--deck-ink))]",children:j.subject}),e.jsx("span",{className:"font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:j.status})]},j.id))]})]}),n.peerMessagingEnabled&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 border-t border-emerald-200/40 pt-3 dark:border-emerald-900/40",children:[e.jsxs("select",{"aria-label":U(t,"recipient"),value:x[n.name]??"*",onChange:j=>c(O=>({...O,[n.name]:j.target.value})),className:"h-8 max-w-32 rounded-md border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface))] px-2 font-mono text-[10px]",children:[e.jsx("option",{value:"*",children:U(t,"broadcast")}),n.members.filter(j=>j.status!=="leader").map(j=>e.jsx("option",{value:j.name,children:j.name},j.id))]}),e.jsx("input",{value:v[n.name]??"",onChange:j=>b(O=>({...O,[n.name]:j.target.value})),onKeyDown:j=>{j.key==="Enter"&&k(n.name)},placeholder:U(t,"messagePlaceholder"),className:"h-8 min-w-0 flex-1 rounded-md border border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface))] px-2 font-mono text-[10.5px] outline-none focus:border-emerald-500"}),e.jsx("button",{type:"button",onClick:()=>void k(n.name),disabled:!((R=v[n.name])!=null&&R.trim())||d===n.name,"aria-label":U(t,"send"),title:U(t,"send"),className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-emerald-700 text-white hover:bg-emerald-800 disabled:opacity-40 dark:bg-emerald-600",children:e.jsx(Ge,{className:"h-3.5 w-3.5"})})]})]})]},n.name)})]})}const oa={starting:"chat.turnActivity.starting",thinking:"chat.turnActivity.thinking",responding:"chat.turnActivity.responding",executing_tools:"chat.turnActivity.executingTools",compacting:"chat.turnActivity.compacting",continuing:"chat.turnActivity.continuing"};function ca(t){const a=Math.max(0,Math.floor(t/1e3));if(a<60)return`${a}s`;const s=Math.floor(a/60),r=a%60;return s<60?`${s}m ${r}s`:`${Math.floor(s/60)}h ${s%60}m ${r}s`}function la(t,a=Date.now()){const s=t==null?void 0:t.snapshot;if(!s)return null;const r=s.activeTools.length+s.activeToolOverflow,o=s.activeTools.slice(0,2).map(l=>l.progress!==void 0&&l.total!==void 0?`${l.name} ${l.progress}/${l.total}`:l.name),i=Math.max(0,s.activeTools.length-o.length+s.activeToolOverflow);return{phaseKey:oa[s.phase],phaseParams:{count:r},tools:o,hiddenTools:i,completedTools:s.toolCallsCompleted,startedTools:s.toolCallsStarted,turn:s.turn,maxTurns:s.maxTurns,elapsed:ca(a-s.startedAt)}}function da({activity:t,memory:a=null}){var x;const s=B(),[r,o]=h.useState(Date.now()),i=(x=t==null?void 0:t.snapshot)==null?void 0:x.startedAt;h.useEffect(()=>{if(i===void 0)return;o(Date.now());const c=window.setInterval(()=>o(Date.now()),1e3);return()=>window.clearInterval(c)},[i]);const l=la(t,r);if(!l)return(a==null?void 0:a.outcome)!=="written"?null:e.jsxs("section",{role:"status","aria-live":"polite","data-memory-consolidation-notice":!0,className:"mx-4 mb-2 flex min-h-10 items-center gap-3 rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]/80 px-3 py-2 text-[hsl(var(--deck-ink))] shadow-sm md:mx-6",children:[e.jsx(_e,{className:"h-4 w-4 shrink-0 text-[hsl(var(--deck-accent))]","aria-hidden":!0}),e.jsx("span",{className:"text-xs font-semibold",children:s("chat.memoryConsolidation.saved",{count:a.entries})})]});const u=[(a==null?void 0:a.outcome)==="written"?s("chat.memoryConsolidation.saved",{count:a.entries}):void 0,...l.tools,l.hiddenTools>0?`+${l.hiddenTools}`:void 0,l.startedTools>0?s("chat.turnActivity.toolCount",{completed:l.completedTools,started:l.startedTools}):void 0,l.turn>0?l.maxTurns===null?s("chat.turnActivity.turn",{turn:l.turn}):s("chat.turnActivity.turnBounded",{turn:l.turn,maxTurns:l.maxTurns}):void 0].filter(c=>c!==void 0);return e.jsxs("section",{role:"status","aria-live":"polite","data-turn-activity-strip":!0,className:"mx-4 mb-2 flex min-h-10 items-center gap-3 rounded-lg border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]/80 px-3 py-2 text-[hsl(var(--deck-ink))] shadow-sm md:mx-6",children:[e.jsx(_e,{className:"h-4 w-4 shrink-0 text-[hsl(var(--deck-accent))] motion-safe:animate-pulse","aria-hidden":!0}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-semibold",children:s(l.phaseKey,l.phaseParams)}),u.length>0&&e.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-[hsl(var(--deck-ink-muted))]",children:u.join(" · ")})]}),e.jsx("span",{className:"shrink-0 font-mono text-[10px] tabular-nums text-[hsl(var(--deck-ink-muted))]",children:l.elapsed})]})}function ua(t){const a=[...t].reverse().find(o=>o.role==="user");if(!a)return null;if(typeof a.content=="string")return{content:a.content,attachments:[]};const s=a.content.filter(o=>o.type==="text").map(o=>o.text).join(`
|
|
63
|
+
`),r=a.content.filter(o=>o.type==="image_url").map((o,i)=>{var u;const l=((u=o.image_url.url.match(/^data:([^;,]+)[;,]/))==null?void 0:u[1])??"application/octet-stream";return{id:`recovery-${a.id}-${i}`,name:`attachment-${i+1}`,mimeType:l,dataUrl:o.image_url.url}});return{content:s,attachments:r}}function ma({messages:t,isLoading:a,isStreaming:s,isStopping:r,errorMessage:o}){const i=B(),[l,u]=h.useState(!1),x=i(o?"status.phase.error":r?"chat.input.action.stopping":s?"status.phase.running":"preview.files.status.ready");return e.jsxs("details",{"data-preview-status-disclosure":!0,open:l,onToggle:c=>u(c.currentTarget.open),className:"group hidden",children:[e.jsxs("summary",{className:"flex h-9 cursor-pointer list-none items-center gap-2 px-3 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[hsl(var(--deck-accent))]",children:[s&&e.jsx("span",{className:"deck-pulse-dot"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:x}),e.jsx(oe,{className:"h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-90"})]}),l&&e.jsxs("div",{"data-preview-activity-details":!0,className:"flex h-[min(44vh,420px)] min-h-0 flex-col border-t border-[hsl(var(--deck-hairline))]",children:[o&&e.jsx("div",{role:"alert",className:"border-b border-red-200/60 bg-red-50/80 px-3 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/50 dark:bg-red-950/30 dark:text-red-300",children:o}),e.jsx(lt,{messages:t,isLoading:a}),e.jsx(ut,{})]})]})}function Ea(){var I;const t=B(),a=f(g=>g.messages),s=f(g=>g.currentSessionRef),r=f(g=>g.isStreaming),o=f(g=>g.isStopping),i=f(g=>g.providerRecovery),l=f(g=>g.turnActivity),u=f(g=>g.memoryConsolidation),x=f(g=>g.actionStationarity),c=f(g=>g.sessionEventConnectionState),v=f(g=>g.pendingSteeringCount),b=f(g=>g.pendingInputDelivery),d=f(g=>g.recoveredSteeringCount),y=f(g=>g.followUpQueue),p=f(g=>g.followUpQueueMutation),N=f(g=>g.mutateFollowUpQueue),m=f(g=>g.refreshFollowUpQueue),S=f(g=>!!g.historySurfaceSelection),k=f(g=>g.isLoading),w=f(g=>g.error),n=f(g=>g.errorContext),E=f(g=>g.sessions),F=f(g=>g.sendMessage),R=f(g=>g.abortSession),j=f(g=>g.retryTask),O=f(g=>g.retryingTaskKeys),G=Re(g=>g.openSettings),C=f(g=>g.reconnectSessionEvents),T=f(g=>g.clearError),[M,P]=h.useState(null),L=s?E.find(g=>g.sessionId===s.sessionId&&g.projectPath===s.projectPath):void 0,ee=!!w&&((n==null?void 0:n.kind)==="navigation"||!(n!=null&&n.sessionRef)||ze(n.sessionRef,s)),Q=(n==null?void 0:n.failureCode)??((I=L==null?void 0:L.taskFailure)==null?void 0:I.code),Z=((n==null?void 0:n.kind)==="execution"||n!=null&&n.failureCode)&&Q?t(Ft(Q)):w==="queue_full"?t("chat.error.queueFull"):w==="turn_unavailable"||w==="turn_active"?t("chat.error.turnChanged"):w,J=c==="connecting"||c==="reconnecting",te=r&&c!=="connected",A=s?`session:${de(s)}`:"session:temporary",z=h.useMemo(()=>ua(a),[a]),q=s?de(s):"temporary-session",V=!!(s&&(L!=null&&L.taskRetryAvailable)&&(!Q||Dt(Q)))&&((n==null?void 0:n.kind)==="execution"||(n==null?void 0:n.kind)==="task_action"),H=(n==null?void 0:n.kind)==="execution"&&(Q==="authentication"||Q==="permission"||Q==="model_unavailable"),$=s?O.includes(de(s)):!1;h.useEffect(()=>{P(null)},[q]);const W=async g=>K(f.getState())?!1:F({content:g.content,modelId:g.modelId,reasoningEffort:g.reasoningEffort,serviceTier:g.serviceTier,responseVerbosity:g.responseVerbosity,communicationStyle:g.communicationStyle,...g.outputSchema?{outputSchema:g.outputSchema}:{},attachments:g.attachments.map(ye=>({type:"image",content:ye.dataUrl,mimeType:ye.mimeType,name:ye.name}))}),Y=()=>{if(!K(f.getState()))return R()},he=async()=>{if(!K(f.getState())){if(H){T(),G("models");return}if(V&&s){T(),await j(s).catch(()=>{});return}if((n==null?void 0:n.kind)==="execution"&&z){P({...z,revision:Date.now()}),T();return}T(),requestAnimationFrame(()=>Ct())}},ce=V?t($?"chat.error.action.retryingTask":"chat.error.action.retryTask"):H?t("chat.error.action.checkModels"):(n==null?void 0:n.kind)==="execution"&&z?t("chat.error.action.editResend"):(n==null?void 0:n.kind)==="submission"?t("chat.error.action.returnDraft"):null;return e.jsxs("div",{"data-chat-view":!0,className:"flex h-full flex-col bg-[hsl(var(--deck-canvas))]",children:[e.jsxs("div",{"data-chat-history":!0,className:"contents",children:[ee&&e.jsxs("div",{role:"alert","data-blade-session-error":!0,className:"flex min-h-11 flex-wrap items-center gap-2 border-b border-red-200/60 bg-red-50/80 px-4 py-2 font-mono text-[11px] text-red-700 dark:border-red-900/50 dark:bg-red-950/30 dark:text-red-300 sm:px-5",children:[e.jsx(Ae,{className:"h-3.5 w-3.5 shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1 break-words",children:[e.jsx("span",{className:"font-semibold",children:t((n==null?void 0:n.kind)==="submission"?"chat.error.title.submission":(n==null?void 0:n.kind)==="execution"?"chat.error.title.execution":(n==null?void 0:n.kind)==="navigation"?"chat.error.title.navigation":"chat.error.title.generic")})," ",Z]}),ce&&e.jsxs("button",{type:"button",onClick:()=>void he(),disabled:$,className:"inline-flex min-h-7 shrink-0 items-center gap-1.5 rounded-md border border-red-300/70 bg-white/65 px-2.5 font-medium transition-colors hover:bg-white focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-red-500 disabled:cursor-wait disabled:opacity-60 dark:border-red-800 dark:bg-red-950/45 dark:hover:bg-red-900/60",children:[V?$?e.jsx(_,{className:"h-3 w-3 animate-spin"}):e.jsx(fe,{className:"h-3 w-3"}):e.jsx(it,{className:"h-3 w-3"}),ce]}),e.jsx("button",{type:"button",onClick:T,"aria-label":t("chat.error.dismiss"),className:"p-1 text-red-500 rounded transition-colors hover:bg-red-100/60 hover:text-red-700 dark:hover:bg-red-950/60 dark:hover:text-red-100",children:"✕"})]}),(J||c==="offline")&&e.jsxs("div",{role:c==="offline"?"alert":"status","aria-live":"polite",className:"flex min-h-10 flex-wrap items-center gap-2 border-b border-amber-300/60 bg-amber-50/80 px-4 py-2 font-mono text-[11px] text-amber-900 dark:border-amber-800/60 dark:bg-amber-950/35 dark:text-amber-200 sm:px-5",children:[J?e.jsx(_,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(Nt,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1",children:t(J?"chat.connection.reconnecting":"chat.connection.offline")}),c==="offline"&&e.jsxs("button",{type:"button",onClick:()=>{K(f.getState())||C().catch(()=>{})},className:"inline-flex min-h-7 items-center gap-1.5 rounded-md border border-amber-400/70 bg-white/60 px-2.5 font-medium transition-colors hover:bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 dark:border-amber-700 dark:bg-amber-950/50 dark:hover:bg-amber-900/50",children:[e.jsx(tt,{className:"h-3 w-3"}),t("chat.connection.retry")]})]}),e.jsx(es,{}),e.jsx(lt,{messages:a,isLoading:k},s?de(s):"temporary-session"),e.jsx(ia,{}),e.jsx(ea,{})]}),e.jsxs("div",{"data-chat-composer-dock":!0,className:"contents",children:[e.jsx(ma,{messages:a,isLoading:k,isStreaming:r,isStopping:o,errorMessage:ee?Z:null},q),e.jsx(Ws,{}),e.jsx(Gs,{}),e.jsx(Qs,{queue:S?null:y,mutation:p,onMutate:N,onRefresh:m}),e.jsx(Ys,{recovery:S?null:i,stopping:o,onStop:Y}),e.jsx(da,{activity:S||i!=null&&i.snapshot||x||L!=null&&L.pendingInteraction?null:l,memory:S?null:u}),e.jsx(St,{draftKey:A,draft:M==null?void 0:M.content,draftAttachments:M==null?void 0:M.attachments,draftRevision:M==null?void 0:M.revision,onSend:W,onAbort:Y,disabled:k||te,isStreaming:r,isStopping:o,pendingSteeringCount:v,pendingInputDelivery:b,recoveredSteeringCount:d,workspacePath:s==null?void 0:s.projectPath},A),e.jsx("div",{"data-chat-primary-status":!0,className:"contents",children:e.jsx(ut,{})})]})]})}export{Ea as ChatView};
|