blade-code 0.10.93 → 0.10.95
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-0pnj92hk.js → chunk-09ya3a21.js} +1 -1
- package/dist/{chunk-3p7c1dsk.js → chunk-2f0wn3ne.js} +1 -1
- package/dist/{chunk-fkhtff66.js → chunk-2ge1zqts.js} +1 -1
- package/dist/{chunk-qern9m2c.js → chunk-2zzc7g29.js} +1 -1
- package/dist/{chunk-7jgj63tj.js → chunk-3aayczyy.js} +1 -1
- package/dist/{chunk-wgd4ject.js → chunk-4fmyjf1x.js} +1 -1
- package/dist/chunk-4hb71f98.js +1 -0
- package/dist/{chunk-7wf2acxx.js → chunk-4p69xraf.js} +1 -1
- package/dist/{chunk-gynpj5sv.js → chunk-4smdhn1h.js} +1 -1
- package/dist/{chunk-m4tpqesg.js → chunk-871g570t.js} +255 -255
- package/dist/{chunk-05fctawm.js → chunk-8pvsw4gw.js} +1 -1
- package/dist/{chunk-xh4pgtj2.js → chunk-bd4nqrtm.js} +1 -1
- package/dist/{chunk-mmd1hx8c.js → chunk-bxtqcgvs.js} +1 -1
- package/dist/{chunk-t7nj9vg8.js → chunk-cbafxem4.js} +1 -1
- package/dist/{chunk-96pnk11m.js → chunk-cnnht4m3.js} +1 -1
- package/dist/{chunk-7b718dgf.js → chunk-cvybf60x.js} +1 -1
- package/dist/{chunk-xby5w74x.js → chunk-e5ht9d18.js} +1 -1
- package/dist/{chunk-61efg3yh.js → chunk-eqbcxa12.js} +1 -1
- package/dist/{chunk-37csc3d2.js → chunk-es4evt6m.js} +1 -1
- package/dist/{chunk-9h756tk9.js → chunk-esstp9h0.js} +2 -2
- package/dist/{chunk-93rvs2hb.js → chunk-f66cptes.js} +1 -1
- package/dist/chunk-gnzcz6e1.js +1 -0
- package/dist/{chunk-5rtjx9xk.js → chunk-h2a3edj4.js} +1 -1
- package/dist/{chunk-scfwdpph.js → chunk-hajer580.js} +1 -1
- package/dist/{chunk-qr3w31ys.js → chunk-hfd00skc.js} +1 -1
- package/dist/{chunk-nht2hy5h.js → chunk-hqb6qxzj.js} +1 -1
- package/dist/{chunk-n23chvhe.js → chunk-hrpqz2jv.js} +1 -1
- package/dist/{chunk-tt3n8gnq.js → chunk-ktt7vmqz.js} +1 -1
- package/dist/{chunk-sbrj2czw.js → chunk-qp165b79.js} +1 -1
- package/dist/{chunk-v7rnx21e.js → chunk-rjw8pj7t.js} +1 -1
- package/dist/{chunk-fyms8zy1.js → chunk-rrav5aea.js} +1 -1
- package/dist/chunk-s2erwc49.js +8 -0
- package/dist/{chunk-b9bbyzk4.js → chunk-sckqp0t9.js} +1 -1
- package/dist/{chunk-hn1xztva.js → chunk-vt99w0vh.js} +1 -1
- package/dist/{chunk-ns5vb2p4.js → chunk-vxwqsmqg.js} +1 -1
- package/dist/{chunk-9kfk68qj.js → chunk-wwzc3ryj.js} +1 -1
- package/dist/{chunk-82n941y8.js → chunk-xm8w4jaa.js} +1 -1
- package/dist/web/assets/{ChatView-D-UBHYgT.js → ChatView-CpKiglLV.js} +7 -7
- package/dist/web/assets/{CodeBlockHighlighter-CjP3le5E.js → CodeBlockHighlighter-BzmHeWKU.js} +1 -1
- package/dist/web/assets/FilePreview-uShTCL2_.js +59 -0
- package/dist/web/assets/{KanbanBoard-CRu-0zva.js → KanbanBoard-CnZoKZFy.js} +2 -2
- package/dist/web/assets/{MarkdownRenderer-fbB4bMCw.js → MarkdownRenderer-CxcqGo57.js} +3 -3
- package/dist/web/assets/{SettingsModal-RAG8JMXx.js → SettingsModal-Bu5uH8ic.js} +2 -2
- package/dist/web/assets/{TaskSwitcher-DC-7RPBv.js → TaskSwitcher-BDwk7i6w.js} +6 -6
- package/dist/web/assets/{TerminalPanel-CCB3heKF.js → TerminalPanel-PiLhnW-8.js} +2 -2
- package/dist/web/assets/{arrow-left-Dwndq437.js → arrow-left-B7RwOx8T.js} +1 -1
- package/dist/web/assets/{calendar-clock-CNd8rd6n.js → calendar-clock-BeSXiMFw.js} +1 -1
- package/dist/web/assets/{chevrons-up-down-DGxAunkR.js → chevrons-up-down-DuC8PppK.js} +1 -1
- package/dist/web/assets/{clock-3-BEqhPeh5.js → clock-3-lYrt_Amt.js} +1 -1
- package/dist/web/assets/{external-link-ClLpF7at.js → external-link-BTHyQJWk.js} +1 -1
- package/dist/web/assets/{folder-B5LF32bS.js → folder-CX6zAF9w.js} +1 -1
- package/dist/web/assets/{index-DI8ZWdWH.js → index-B5mUEr6D.js} +3 -3
- package/dist/web/assets/{index-BgdiwWDg.js → index-FdbcPJSj.js} +56 -56
- package/dist/web/assets/index-zY4JU9fd.css +1 -0
- package/dist/web/assets/{pause-B39o8olb.js → pause-qlDcCjBJ.js} +1 -1
- package/dist/web/assets/{play-Bmh7JaqQ.js → play-BGPTTFWa.js} +1 -1
- package/dist/web/assets/session-events-Ci1823tS.js +22 -0
- package/dist/web/assets/{teamService-4Cn4uKC9.js → teamService-Bk8B4hZp.js} +1 -1
- package/dist/web/assets/{vendor-radix-DXRuAJHH.js → vendor-radix-Bc1_Q9tz.js} +1 -1
- package/dist/web/assets/{vendor-react-DG5dkZ_t.js → vendor-react-DofNRwfy.js} +1 -1
- package/dist/web/index.html +5 -5
- package/package.json +1 -1
- package/dist/chunk-fs8ra760.js +0 -8
- package/dist/chunk-jaegtaq3.js +0 -1
- package/dist/chunk-z2asrfm1.js +0 -1
- package/dist/web/assets/FilePreview-DRJTAYmL.js +0 -54
- package/dist/web/assets/index-C8M-7zAh.css +0 -1
- package/dist/web/assets/session-events-Bgir_Gl_.js +0 -22
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownRenderer-
|
|
2
|
-
import{r as f,j as e}from"./vendor-react-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownRenderer-CxcqGo57.js","assets/index-FdbcPJSj.js","assets/vendor-react-DofNRwfy.js","assets/vendor-radix-Bc1_Q9tz.js","assets/session-events-Ci1823tS.js","assets/index-zY4JU9fd.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as f,j as e}from"./vendor-react-DofNRwfy.js";import{c as z,u as D,a as y,s as Be,b as tt,d as Z,H as Ce,P as st,G as _e,L as $,S as Pe,T as ee,C as ue,D as Le,e as Ve,f as at,g as Oe,h as Ue,i as He,j as M,k as rt,l as G,B as nt,m as ve,n as te,o as se,R as le,F as it,_ as qe,p as ot,q as lt,r as ze,t as ct,v as Ke,X as Ge,w as dt,A as ye,x as ut,W as mt,y as ht,z as xt,E as pt}from"./index-FdbcPJSj.js";import{l as we,m as ft,g as bt,n as vt,f as gt,t as kt,k as jt}from"./session-events-Ci1823tS.js";import{A as yt,E as wt}from"./external-link-BTHyQJWk.js";import{A as We,C as Nt}from"./chevrons-up-down-DuC8PppK.js";import{j as St,k as Ct,l as Et,m as Qe}from"./vendor-radix-Bc1_Q9tz.js";import{P as Tt}from"./pause-qlDcCjBJ.js";import{P as Mt}from"./play-BGPTTFWa.js";import{C as At}from"./clock-3-lYrt_Amt.js";import{t as F}from"./team-QZ9byb3E.js";import{teamService as Ee}from"./teamService-Bk8B4hZp.js";/**
|
|
3
3
|
* @license lucide-react v0.300.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
@@ -39,9 +39,9 @@ import{r as f,j as e}from"./vendor-react-DG5dkZ_t.js";import{c as z,u as D,a as
|
|
|
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 _t=z("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 Te(t){return t.split("/").filter(Boolean).at(-1)||t}function Pt(){const t=D(),s=y(w=>w.sessions),a=y(w=>w.currentSessionRef),r=y(w=>w.taskDeliveryActions),i=y(w=>w.deliverTask),n=ye(w=>w.openFilePreview),[d,b]=f.useState(!1),u=s.find(w=>Be({sessionId:w.sessionId,projectPath:w.projectPath},a));if(!(u!=null&&u.taskIsolation))return null;const c=u.taskDiffStat,k=u.taskIsolation==="worktree",l=tt(u),p=r[Z(l)],x=u.taskDelivery,j=(x==null?void 0:x.status)==="conflicted",S=!!(c&&(c.changedFiles>0||c.commits>0)),h=!["queued","running"].includes(u.taskStatus),N=(x==null?void 0:x.status)==="applied"||(x==null?void 0:x.status)==="discarded",v=k&&S&&h&&!N,o=c?c.additions+c.deletions:0,m=o>0&&c?c.additions/o*100:0,E=w=>{i(l,w).catch(()=>{})};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(Ce,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate text-[hsl(var(--deck-ink))]",children:Te(u.taskSourceProjectPath||u.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:[k?e.jsx(st,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-accent))]"}):e.jsx(Ce,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:k?"text-[hsl(var(--deck-accent))]":void 0,children:t(k?"artifact.env.isolated":"artifact.env.local")})]}),u.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:u.taskWorktreeBranch,children:[e.jsx(_e,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate",children:u.taskWorktreeBranch})]})]})]}),c&&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(Rt,{className:"h-3 w-3 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"tabular-nums",children:c.changedFiles})]}),o>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:`${m}%`}}),e.jsx("span",{className:"h-full bg-red-500/80",style:{width:`${100-m}%`}})]}),e.jsxs("span",{className:"tabular-nums text-[hsl(var(--deck-accent))]",children:["+",c.additions]}),e.jsxs("span",{className:"tabular-nums text-red-600 dark:text-red-400",children:["-",c.deletions]}),c.commits>0&&e.jsx("span",{className:"hidden tabular-nums text-[hsl(var(--deck-ink-faint))] sm:inline",children:t("artifact.commits",{count:c.commits})}),S&&(x==null?void 0:x.status)!=="discarded"&&e.jsx("button",{type:"button",onClick:()=>n({tab:"diff"}),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")}),v&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",disabled:!!p,onClick:()=>E("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:[p==="apply"?e.jsx($,{className:"h-3 w-3 animate-spin"}):e.jsx(Pe,{className:"h-3 w-3"}),t(p==="apply"?"artifact.applying":j?"artifact.retryApply":"artifact.apply")]}),e.jsx("button",{type:"button",disabled:!!p,onClick:()=>b(!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:p==="discard"?e.jsx($,{className:"h-3 w-3 animate-spin"}):e.jsx(ee,{className:"h-3 w-3"})})]}),(x==null?void 0:x.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(ue,{className:"h-3 w-3"}),t("artifact.applied")]}),(x==null?void 0:x.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(ee,{className:"h-3 w-3"}),t("artifact.discarded")]})]}),(x==null?void 0:x.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(ft,{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:x.message||t("artifact.conflict")}),e.jsx("span",{className:"block text-[hsl(var(--deck-ink-faint))]",children:t("artifact.conflictHint")})]})]})]}),e.jsx(Le,{open:d,onOpenChange:b,children:e.jsxs(Ve,{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(at,{children:[e.jsx(Oe,{children:t("artifact.discardDialog.title")}),e.jsx(Ue,{className:"text-[hsl(var(--deck-ink-muted))]",children:t("artifact.discardDialog.description",{project:Te(u.taskSourceProjectPath||u.projectPath),count:(c==null?void 0:c.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(He,{className:"gap-2 sm:space-x-0",children:[e.jsx("button",{type:"button",onClick:()=>b(!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:()=>{b(!1),E("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(ee,{className:"h-3.5 w-3.5"}),t("artifact.discardDialog.confirm")]})]})]})})]})}const Lt=new Set(["completed","stale","failed","aborted","interrupted"]),Vt={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"},Ot={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 ce(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function Ut(t){const s=ce(t),a=ce(s==null?void 0:s.codeLocation),r=s==null?void 0:s.priority,i=s==null?void 0:s.confidenceScore,n=a==null?void 0:a.lineStart,d=a==null?void 0:a.lineEnd;if(!(typeof(s==null?void 0:s.title)!="string"||typeof s.body!="string"||r!==0&&r!==1&&r!==2&&r!==3||typeof i!="number"||!Number.isFinite(i)||typeof(a==null?void 0:a.path)!="string"||!Number.isInteger(n)||!Number.isInteger(d)))return{title:s.title,body:s.body,priority:r,confidenceScore:i,codeLocation:{path:a.path,lineStart:n,lineEnd:d}}}function Ht(t){const s=ce(t),a=ce(s==null?void 0:s.target);if((s==null?void 0:s.phase)!=="completed"||typeof s.status!="string"||!Lt.has(s.status)||typeof(a==null?void 0:a.label)!="string"||a.kind!=="uncommitted"&&a.kind!=="base"&&a.kind!=="commit"||typeof s.overallExplanation!="string"||!Array.isArray(s.findings))return;const r=s.findings.map(Ut);if(!r.some(i=>i===void 0))return{status:s.status,target:{kind:a.kind,label:a.label,...typeof a.reference=="string"?{reference:a.reference}:{}},overallExplanation:s.overallExplanation,findings:r,...typeof s.error=="string"?{error:s.error}:{}}}function qt(t){const{path:s,lineStart:a,lineEnd:r}=t.codeLocation;return a===r?`${s}:L${a}`:`${s}:L${a}-${r}`}function zt({report:t}){const s=D(),a=t.target.kind==="uncommitted"?s("chat.review.target.uncommitted"):t.target.kind==="base"?s("chat.review.target.base",{ref:t.target.reference??t.target.label}):s("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:s("chat.review.title")}),e.jsxs("p",{className:"mt-0.5 font-mono text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:[s("chat.review.target"),": ",a]})]}),e.jsxs("span",{className:M("rounded-full border px-2.5 py-1 font-mono text-[10.5px] font-medium",Ot[t.status]),children:[s("chat.review.status"),": ",s(Vt[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:s("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:s("chat.review.noFindings")}):e.jsx("ol",{className:"space-y-2",children:t.findings.map((r,i)=>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:s("chat.review.confidence",{value:r.confidenceScore.toFixed(2)})})]}),e.jsx("code",{className:"mt-1 block text-[10.5px] text-[hsl(var(--deck-accent))]",children:qt(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}:${i}`))})]}),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:[s("chat.review.error"),":"]})," ",t.error]})]})]})}function Kt({elicitation:t,messageId:s}){const a=D(),r=y(v=>v.currentSessionRef),i=y(v=>v.setElicitation),[n,d]=f.useState(()=>Wt(t.details.fields??[])),[b,u]=f.useState(()=>Qt(t.details.fields??[])),[c,k]=f.useState(!1),[l,p]=f.useState(),x=t.details.fields??[],j=f.useMemo(()=>x.every(v=>{var m;if(!v.required)return!0;if(me(v))return!!((m=b[v.name])!=null&&m.trim()||v.defaultValue!==void 0);const o=n[v.name]??v.defaultValue;return Array.isArray(o)?o.length>0:o!==void 0}),[x,b,n]);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:a(t.status==="cancelled"?"interaction.elicitation.cancelled":"interaction.elicitation.responded")});const S=async(v,o)=>{if(!(!r||c)){k(!0),p(void 0);try{await G.respondToElicitation(r,t.toolCallId,{action:v,...o?{content:o}:{}}),i(s,{...t,status:"responded"})}catch(m){p(m instanceof Error?m.message:a("interaction.elicitation.failed"))}finally{k(!1)}}},h=async()=>{try{await S("accept",Jt(x,n,b))}catch(v){p(v instanceof Error?v.message:String(v))}},N=()=>{const v=t.details.url;if(!v){p("MCP URL is unavailable");return}if(!window.open(v,"_blank","noopener,noreferrer")){p("The browser blocked the external window");return}S("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(rt,{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:[a("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:a("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(Q,{onClick:N,disabled:c,primary:!0,label:a("interaction.elicitation.open"),icon:e.jsx(bt,{className:"h-3.5 w-3.5"})}),e.jsx(Q,{onClick:()=>void S("decline"),disabled:c,label:a("interaction.elicitation.decline")}),e.jsx(Q,{onClick:()=>void S("cancel"),disabled:c,label:a("interaction.elicitation.cancel")})]})]}):e.jsxs("div",{className:"space-y-4",children:[x.map(v=>e.jsx(Gt,{field:v,value:n[v.name],rawValue:b[v.name]??"",onValueChange:o=>d(m=>({...m,[v.name]:o})),onRawChange:o=>u(m=>({...m,[v.name]:o}))},v.name)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Q,{onClick:()=>void h(),disabled:c||!j,primary:!0,label:a("interaction.elicitation.submit"),icon:c?e.jsx($,{className:"h-3.5 w-3.5 animate-spin"}):null}),e.jsx(Q,{onClick:()=>void S("decline"),disabled:c,label:a("interaction.elicitation.decline")}),e.jsx(Q,{onClick:()=>void S("cancel"),disabled:c,label:a("interaction.elicitation.cancel")})]})]}),l&&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:l})]})}function Gt({field:t,value:s,rawValue:a,onValueChange:r,onRawChange:i}){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:Yt(t).map(n=>{const d=Array.isArray(s)?s.includes(n.value):s===n.typedValue;return e.jsx("button",{type:"button","aria-pressed":d,onClick:()=>{if(t.type==="multi-select"){const b=Array.isArray(s)?s:[];r(b.includes(n.value)?b.filter(u=>u!==n.value):[...b,n.value])}else r(n.typedValue)},className:M("rounded-md border px-3 py-2 font-mono text-[12px] transition-colors",d?"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:n.label},n.value)})}):e.jsx("input",{id:`mcp-elicitation-${t.name}`,type:Xt(t),value:a,onChange:n=>i(n.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 Q({onClick:t,disabled:s,primary:a=!1,label:r,icon:i}){return e.jsxs("button",{type:"button",onClick:t,disabled:s,className:M("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",a?"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:[i,r]})}function Wt(t){return Object.fromEntries(t.filter(s=>!me(s)&&s.defaultValue!==void 0).map(s=>[s.name,Array.isArray(s.defaultValue)?[...s.defaultValue]:s.defaultValue]))}function Qt(t){return Object.fromEntries(t.filter(s=>me(s)&&s.defaultValue!==void 0).map(s=>[s.name,String(s.defaultValue)]))}function Jt(t,s,a){var i;const r={};for(const n of t){if(me(n)){const b=((i=a[n.name])==null?void 0:i.trim())??"";if(!b){if(n.defaultValue!==void 0)r[n.name]=n.defaultValue;else if(n.required)throw new Error(`${n.title} is required`);continue}if(n.type==="number"||n.type==="integer"){const u=Number(b);if(!Number.isFinite(u))throw new Error(`${n.title} must be a finite number`);if(n.type==="integer"&&!Number.isSafeInteger(u))throw new Error(`${n.title} must be a safe integer`);r[n.name]=u}else r[n.name]=b;continue}const d=s[n.name]??n.defaultValue;if(d===void 0){if(n.required)throw new Error(`${n.title} is required`);continue}if(Array.isArray(d)){if(n.minItems!==void 0&&d.length<n.minItems)throw new Error(`${n.title} requires at least ${n.minItems} choices`);if(n.maxItems!==void 0&&d.length>n.maxItems)throw new Error(`${n.title} allows at most ${n.maxItems} choices`)}r[n.name]=d}return r}function Yt(t){return t.type==="boolean"?[{value:"true",label:"Yes",typedValue:!0},{value:"false",label:"No",typedValue:!1}]:(t.options??[]).map(s=>({...s,typedValue:s.value}))}function me(t){return t.type==="string"||t.type==="number"||t.type==="integer"}function Xt(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 Zt(t){if(!t||typeof t!="object"||Array.isArray(t))return;const s=t;if(!(!s.output||typeof s.output!="object"||Array.isArray(s.output)))return{output:s.output,...typeof s.schemaDigest=="string"?{schemaDigest:s.schemaDigest}:{}}}function es({report:t}){const s=D(),[a,r]=f.useState(!1),i=JSON.stringify(t.output,null,2),n=async()=>{try{await navigator.clipboard.writeText(i),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(nt,{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:s("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:n,"aria-label":s("chat.structuredOutput.copy"),title:s("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:a?e.jsx(ue,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(Je,{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:i})]})}const ts=f.lazy(()=>qe(()=>import("./MarkdownRenderer-fbB4bMCw.js").then(t=>t.M),__vite__mapDeps([0,1,2,3,4,5])).then(t=>({default:t.MarkdownRenderer})));function Me({text:t,label:s}){const[a,r]=f.useState(!1);if(!t.trim())return null;const i=async()=>{try{await navigator.clipboard.writeText(t),r(!0),window.setTimeout(()=>r(!1),1400)}catch{}};return e.jsx("button",{type:"button","aria-label":s,title:s,onClick:i,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:a?e.jsx(ue,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(Je,{className:"h-3.5 w-3.5"})})}function ss(){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(ve,{size:20,pulse:!1})})}function as(){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 Ae(t){let s=t;return s=s.replace(/<system-reminder>[\s\S]*?<\/system-reminder>/g,""),s=s.replace(/<file path="[^"]*">[\s\S]*?<\/file>/g,""),s=s.replace(/<attached_files>[\s\S]*?<\/attached_files>/g,""),s=s.trim(),s}function rs(t){if(typeof t=="string")return{text:Ae(t),images:[]};const s=t.filter(r=>r.type==="text").map(r=>r.text).join(`
|
|
42
|
+
*/const _t=z("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 Te(t){return t.split("/").filter(Boolean).at(-1)||t}function Pt(){const t=D(),s=y(w=>w.sessions),a=y(w=>w.currentSessionRef),r=y(w=>w.taskDeliveryActions),i=y(w=>w.deliverTask),n=we(w=>w.openFilePreview),[d,b]=f.useState(!1),u=s.find(w=>Be({sessionId:w.sessionId,projectPath:w.projectPath},a));if(!(u!=null&&u.taskIsolation))return null;const c=u.taskDiffStat,k=u.taskIsolation==="worktree",l=tt(u),p=r[Z(l)],x=u.taskDelivery,j=(x==null?void 0:x.status)==="conflicted",S=!!(c&&(c.changedFiles>0||c.commits>0)),h=!["queued","running"].includes(u.taskStatus),N=(x==null?void 0:x.status)==="applied"||(x==null?void 0:x.status)==="discarded",v=k&&S&&h&&!N,o=c?c.additions+c.deletions:0,m=o>0&&c?c.additions/o*100:0,E=w=>{i(l,w).catch(()=>{})};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(Ce,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate text-[hsl(var(--deck-ink))]",children:Te(u.taskSourceProjectPath||u.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:[k?e.jsx(st,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-accent))]"}):e.jsx(Ce,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:k?"text-[hsl(var(--deck-accent))]":void 0,children:t(k?"artifact.env.isolated":"artifact.env.local")})]}),u.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:u.taskWorktreeBranch,children:[e.jsx(_e,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate",children:u.taskWorktreeBranch})]})]})]}),c&&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(Rt,{className:"h-3 w-3 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"tabular-nums",children:c.changedFiles})]}),o>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:`${m}%`}}),e.jsx("span",{className:"h-full bg-red-500/80",style:{width:`${100-m}%`}})]}),e.jsxs("span",{className:"tabular-nums text-[hsl(var(--deck-accent))]",children:["+",c.additions]}),e.jsxs("span",{className:"tabular-nums text-red-600 dark:text-red-400",children:["-",c.deletions]}),c.commits>0&&e.jsx("span",{className:"hidden tabular-nums text-[hsl(var(--deck-ink-faint))] sm:inline",children:t("artifact.commits",{count:c.commits})}),S&&(x==null?void 0:x.status)!=="discarded"&&e.jsx("button",{type:"button",onClick:()=>n({tab:"diff"}),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")}),v&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",disabled:!!p,onClick:()=>E("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:[p==="apply"?e.jsx($,{className:"h-3 w-3 animate-spin"}):e.jsx(Pe,{className:"h-3 w-3"}),t(p==="apply"?"artifact.applying":j?"artifact.retryApply":"artifact.apply")]}),e.jsx("button",{type:"button",disabled:!!p,onClick:()=>b(!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:p==="discard"?e.jsx($,{className:"h-3 w-3 animate-spin"}):e.jsx(ee,{className:"h-3 w-3"})})]}),(x==null?void 0:x.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(ue,{className:"h-3 w-3"}),t("artifact.applied")]}),(x==null?void 0:x.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(ee,{className:"h-3 w-3"}),t("artifact.discarded")]})]}),(x==null?void 0:x.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(yt,{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:x.message||t("artifact.conflict")}),e.jsx("span",{className:"block text-[hsl(var(--deck-ink-faint))]",children:t("artifact.conflictHint")})]})]})]}),e.jsx(Le,{open:d,onOpenChange:b,children:e.jsxs(Ve,{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(at,{children:[e.jsx(Oe,{children:t("artifact.discardDialog.title")}),e.jsx(Ue,{className:"text-[hsl(var(--deck-ink-muted))]",children:t("artifact.discardDialog.description",{project:Te(u.taskSourceProjectPath||u.projectPath),count:(c==null?void 0:c.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(He,{className:"gap-2 sm:space-x-0",children:[e.jsx("button",{type:"button",onClick:()=>b(!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:()=>{b(!1),E("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(ee,{className:"h-3.5 w-3.5"}),t("artifact.discardDialog.confirm")]})]})]})})]})}const Lt=new Set(["completed","stale","failed","aborted","interrupted"]),Vt={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"},Ot={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 ce(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function Ut(t){const s=ce(t),a=ce(s==null?void 0:s.codeLocation),r=s==null?void 0:s.priority,i=s==null?void 0:s.confidenceScore,n=a==null?void 0:a.lineStart,d=a==null?void 0:a.lineEnd;if(!(typeof(s==null?void 0:s.title)!="string"||typeof s.body!="string"||r!==0&&r!==1&&r!==2&&r!==3||typeof i!="number"||!Number.isFinite(i)||typeof(a==null?void 0:a.path)!="string"||!Number.isInteger(n)||!Number.isInteger(d)))return{title:s.title,body:s.body,priority:r,confidenceScore:i,codeLocation:{path:a.path,lineStart:n,lineEnd:d}}}function Ht(t){const s=ce(t),a=ce(s==null?void 0:s.target);if((s==null?void 0:s.phase)!=="completed"||typeof s.status!="string"||!Lt.has(s.status)||typeof(a==null?void 0:a.label)!="string"||a.kind!=="uncommitted"&&a.kind!=="base"&&a.kind!=="commit"||typeof s.overallExplanation!="string"||!Array.isArray(s.findings))return;const r=s.findings.map(Ut);if(!r.some(i=>i===void 0))return{status:s.status,target:{kind:a.kind,label:a.label,...typeof a.reference=="string"?{reference:a.reference}:{}},overallExplanation:s.overallExplanation,findings:r,...typeof s.error=="string"?{error:s.error}:{}}}function qt(t){const{path:s,lineStart:a,lineEnd:r}=t.codeLocation;return a===r?`${s}:L${a}`:`${s}:L${a}-${r}`}function zt({report:t}){const s=D(),a=t.target.kind==="uncommitted"?s("chat.review.target.uncommitted"):t.target.kind==="base"?s("chat.review.target.base",{ref:t.target.reference??t.target.label}):s("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:s("chat.review.title")}),e.jsxs("p",{className:"mt-0.5 font-mono text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:[s("chat.review.target"),": ",a]})]}),e.jsxs("span",{className:M("rounded-full border px-2.5 py-1 font-mono text-[10.5px] font-medium",Ot[t.status]),children:[s("chat.review.status"),": ",s(Vt[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:s("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:s("chat.review.noFindings")}):e.jsx("ol",{className:"space-y-2",children:t.findings.map((r,i)=>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:s("chat.review.confidence",{value:r.confidenceScore.toFixed(2)})})]}),e.jsx("code",{className:"mt-1 block text-[10.5px] text-[hsl(var(--deck-accent))]",children:qt(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}:${i}`))})]}),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:[s("chat.review.error"),":"]})," ",t.error]})]})]})}function Kt({elicitation:t,messageId:s}){const a=D(),r=y(v=>v.currentSessionRef),i=y(v=>v.setElicitation),[n,d]=f.useState(()=>Wt(t.details.fields??[])),[b,u]=f.useState(()=>Qt(t.details.fields??[])),[c,k]=f.useState(!1),[l,p]=f.useState(),x=t.details.fields??[],j=f.useMemo(()=>x.every(v=>{var m;if(!v.required)return!0;if(me(v))return!!((m=b[v.name])!=null&&m.trim()||v.defaultValue!==void 0);const o=n[v.name]??v.defaultValue;return Array.isArray(o)?o.length>0:o!==void 0}),[x,b,n]);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:a(t.status==="cancelled"?"interaction.elicitation.cancelled":"interaction.elicitation.responded")});const S=async(v,o)=>{if(!(!r||c)){k(!0),p(void 0);try{await G.respondToElicitation(r,t.toolCallId,{action:v,...o?{content:o}:{}}),i(s,{...t,status:"responded"})}catch(m){p(m instanceof Error?m.message:a("interaction.elicitation.failed"))}finally{k(!1)}}},h=async()=>{try{await S("accept",Jt(x,n,b))}catch(v){p(v instanceof Error?v.message:String(v))}},N=()=>{const v=t.details.url;if(!v){p("MCP URL is unavailable");return}if(!window.open(v,"_blank","noopener,noreferrer")){p("The browser blocked the external window");return}S("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(rt,{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:[a("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:a("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(Q,{onClick:N,disabled:c,primary:!0,label:a("interaction.elicitation.open"),icon:e.jsx(wt,{className:"h-3.5 w-3.5"})}),e.jsx(Q,{onClick:()=>void S("decline"),disabled:c,label:a("interaction.elicitation.decline")}),e.jsx(Q,{onClick:()=>void S("cancel"),disabled:c,label:a("interaction.elicitation.cancel")})]})]}):e.jsxs("div",{className:"space-y-4",children:[x.map(v=>e.jsx(Gt,{field:v,value:n[v.name],rawValue:b[v.name]??"",onValueChange:o=>d(m=>({...m,[v.name]:o})),onRawChange:o=>u(m=>({...m,[v.name]:o}))},v.name)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Q,{onClick:()=>void h(),disabled:c||!j,primary:!0,label:a("interaction.elicitation.submit"),icon:c?e.jsx($,{className:"h-3.5 w-3.5 animate-spin"}):null}),e.jsx(Q,{onClick:()=>void S("decline"),disabled:c,label:a("interaction.elicitation.decline")}),e.jsx(Q,{onClick:()=>void S("cancel"),disabled:c,label:a("interaction.elicitation.cancel")})]})]}),l&&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:l})]})}function Gt({field:t,value:s,rawValue:a,onValueChange:r,onRawChange:i}){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:Yt(t).map(n=>{const d=Array.isArray(s)?s.includes(n.value):s===n.typedValue;return e.jsx("button",{type:"button","aria-pressed":d,onClick:()=>{if(t.type==="multi-select"){const b=Array.isArray(s)?s:[];r(b.includes(n.value)?b.filter(u=>u!==n.value):[...b,n.value])}else r(n.typedValue)},className:M("rounded-md border px-3 py-2 font-mono text-[12px] transition-colors",d?"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:n.label},n.value)})}):e.jsx("input",{id:`mcp-elicitation-${t.name}`,type:Xt(t),value:a,onChange:n=>i(n.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 Q({onClick:t,disabled:s,primary:a=!1,label:r,icon:i}){return e.jsxs("button",{type:"button",onClick:t,disabled:s,className:M("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",a?"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:[i,r]})}function Wt(t){return Object.fromEntries(t.filter(s=>!me(s)&&s.defaultValue!==void 0).map(s=>[s.name,Array.isArray(s.defaultValue)?[...s.defaultValue]:s.defaultValue]))}function Qt(t){return Object.fromEntries(t.filter(s=>me(s)&&s.defaultValue!==void 0).map(s=>[s.name,String(s.defaultValue)]))}function Jt(t,s,a){var i;const r={};for(const n of t){if(me(n)){const b=((i=a[n.name])==null?void 0:i.trim())??"";if(!b){if(n.defaultValue!==void 0)r[n.name]=n.defaultValue;else if(n.required)throw new Error(`${n.title} is required`);continue}if(n.type==="number"||n.type==="integer"){const u=Number(b);if(!Number.isFinite(u))throw new Error(`${n.title} must be a finite number`);if(n.type==="integer"&&!Number.isSafeInteger(u))throw new Error(`${n.title} must be a safe integer`);r[n.name]=u}else r[n.name]=b;continue}const d=s[n.name]??n.defaultValue;if(d===void 0){if(n.required)throw new Error(`${n.title} is required`);continue}if(Array.isArray(d)){if(n.minItems!==void 0&&d.length<n.minItems)throw new Error(`${n.title} requires at least ${n.minItems} choices`);if(n.maxItems!==void 0&&d.length>n.maxItems)throw new Error(`${n.title} allows at most ${n.maxItems} choices`)}r[n.name]=d}return r}function Yt(t){return t.type==="boolean"?[{value:"true",label:"Yes",typedValue:!0},{value:"false",label:"No",typedValue:!1}]:(t.options??[]).map(s=>({...s,typedValue:s.value}))}function me(t){return t.type==="string"||t.type==="number"||t.type==="integer"}function Xt(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 Zt(t){if(!t||typeof t!="object"||Array.isArray(t))return;const s=t;if(!(!s.output||typeof s.output!="object"||Array.isArray(s.output)))return{output:s.output,...typeof s.schemaDigest=="string"?{schemaDigest:s.schemaDigest}:{}}}function es({report:t}){const s=D(),[a,r]=f.useState(!1),i=JSON.stringify(t.output,null,2),n=async()=>{try{await navigator.clipboard.writeText(i),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(nt,{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:s("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:n,"aria-label":s("chat.structuredOutput.copy"),title:s("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:a?e.jsx(ue,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(Je,{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:i})]})}const ts=f.lazy(()=>qe(()=>import("./MarkdownRenderer-CxcqGo57.js").then(t=>t.M),__vite__mapDeps([0,1,2,3,4,5])).then(t=>({default:t.MarkdownRenderer})));function Me({text:t,label:s}){const[a,r]=f.useState(!1);if(!t.trim())return null;const i=async()=>{try{await navigator.clipboard.writeText(t),r(!0),window.setTimeout(()=>r(!1),1400)}catch{}};return e.jsx("button",{type:"button","aria-label":s,title:s,onClick:i,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:a?e.jsx(ue,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(Je,{className:"h-3.5 w-3.5"})})}function ss(){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(ve,{size:20,pulse:!1})})}function as(){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 Ae(t){let s=t;return s=s.replace(/<system-reminder>[\s\S]*?<\/system-reminder>/g,""),s=s.replace(/<file path="[^"]*">[\s\S]*?<\/file>/g,""),s=s.replace(/<attached_files>[\s\S]*?<\/attached_files>/g,""),s=s.trim(),s}function rs(t){if(typeof t=="string")return{text:Ae(t),images:[]};const s=t.filter(r=>r.type==="text").map(r=>r.text).join(`
|
|
43
43
|
`),a=t.filter(r=>r.type==="image_url").map(r=>r.image_url.url);return{text:Ae(s),images:a}}function Ne(t){return typeof t=="string"?t:t.filter(s=>s.type==="text").map(s=>s.text).join(`
|
|
44
|
-
`)}function ns(t){const s=t.agentContent;return s?
|
|
44
|
+
`)}function ns(t){const s=t.agentContent;return s?ft(s):Ne(t.content)}function Re({content:t,syntaxHighlight:s=!0}){return e.jsx(f.Suspense,{fallback:e.jsx("pre",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono whitespace-pre-wrap",children:t}),children:e.jsx(ts,{content:t,syntaxHighlight:s})})}function Se({status:t}){if(!t)return null;const s={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]"},a={running:"Running",success:"Success",error:"Error",pending:"Pending",info:"Info"};return e.jsx("span",{className:M("text-[11px] px-2 py-0.5 rounded-full font-mono",s[t]),children:a[t]})}function is(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 Fe=500;function Ye(t,s){if(t.length<=s)return t;let a=Math.max(0,s);return a>0&&/[\uD800-\uDBFF]/.test(t.charAt(a-1))&&(a-=1),t.slice(0,a)}function $e(t,s){if(t.length<=s)return t;let a=Math.max(0,t.length-s);return/[\uDC00-\uDFFF]/.test(t.charAt(a))&&(a+=1),t.slice(a)}function xe(t,s){if(t.length<=s)return t;if(s<=0)return"";const a=`
|
|
45
45
|
... (display clipped) ...
|
|
46
46
|
`,r=s-a.length;if(r<=0)return $e(t,s);const i=Math.floor(r/3);return`${Ye(t,i)}${a}${$e(t,r-i)}`}function os(t){const s=t.split(`
|
|
47
47
|
`),a=s.at(-1),r=a!=null&&a.startsWith("Output truncated")?a:void 0,i=r?s.slice(0,-1).join(`
|
|
@@ -52,7 +52,7 @@ stderr:
|
|
|
52
52
|
stdout:
|
|
53
53
|
`)){const k=i.slice(0,u),l=i.slice(u+1),p=Math.max(0,d-1),x=Math.floor(p/2);c=`${xe(k,x)}
|
|
54
54
|
${xe(l,p-x)}`}else c=xe(i,d);return{body:Ye(c,d),...r?{notice:r}:{},truncated:!!r||t.length>Fe}}function ls({tool:t}){const[s,a]=f.useState(!1),r=is(t.arguments),i=t.output?os(t.output):void 0;return e.jsxs("div",{"data-tool-name":t.toolName,"data-tool-status":t.status,"data-tool-truncated":i!=null&&i.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":s,"data-tool-call-id":t.toolCallId,onClick:()=>a(n=>!n),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:[s?e.jsx(te,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))] shrink-0"}):e.jsx(se,{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(Se,{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))}%`}})})]}),s&&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})]}),i&&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:[i.body,i.notice&&e.jsxs(e.Fragment,{children:[`
|
|
55
|
-
`,e.jsx("span",{"data-tool-truncation-notice":!0,children:i.notice})]})]})]})]})]})}function Xe({toolCalls:t}){return t.length===0?null:e.jsx("div",{className:"space-y-2",children:t.map(s=>e.jsx(ls,{tool:s},s.toolCallId))})}function cs({toolCalls:t,toolCallIds:s}){const a=D(),[r,i]=f.useState(!1),n=f.useMemo(()=>new Map(t.map(l=>[l.toolCallId,l])),[t]),d=s.flatMap(l=>{const p=n.get(l);return p?[p]:[]});if(d.length===0)return null;const b=d.filter(l=>l.status==="running").length,u=d.filter(l=>l.status==="error").length,c=[...d].reverse().find(l=>l.status==="running"&&!!l.progressMessage),k=b>0?a(d.length===1?"chat.timeline.tools.runningOne":"chat.timeline.tools.running",{count:d.length}):u>0?a(d.length===1?"chat.timeline.tools.completedOneWithError":"chat.timeline.tools.completedWithErrors",{count:d.length,errors:u}):a(d.length===1?"chat.timeline.tools.completedOne":"chat.timeline.tools.completed",{count:d.length});return e.jsxs("div",{"data-agent-tool-group":!0,className:"py-0.5",children:[e.jsxs("button",{type:"button","aria-expanded":r,onClick:()=>i(l=>!l),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(te,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(se,{className:"h-3.5 w-3.5 shrink-0"}),b>0&&e.jsx($,{className:"h-3 w-3 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"}),e.jsx("span",{children:k}),(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(Xe,{toolCalls:d})})]})}function ds({content:t}){const s=D(),[a,r]=f.useState(!1);return t?e.jsxs("div",{"data-agent-thinking":!0,className:"py-0.5",children:[e.jsxs("button",{type:"button","aria-expanded":a,onClick:()=>r(i=>!i),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:[a?e.jsx(te,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))]"}):e.jsx(se,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{children:s("chat.timeline.thinking")})]}),a&&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 us({tasks:t}){if(t.length===0)return null;const s=t.filter(r=>r.status==="completed").length,a=s===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:a?"✓ All tasks done":`Tasks: ${s}/${t.length}`})})})}function ms({toolCalls:t}){const s=ye(r=>r.openFilePreview),a=f.useMemo(()=>{const r=new Map,i=["Write","SearchReplace","Edit","ApplyPatch"];for(const n of t){if(n.status!=="success")continue;const d=n.metadata;if(n.toolName==="ApplyPatch"&&Array.isArray(d==null?void 0:d.changes)){for(const u of d.changes)u&&typeof u=="object"&&"path"in u&&typeof u.path=="string"&&r.set(u.path,{path:u.path,toolName:n.toolName});continue}const b=d==null?void 0:d.file_path;b&&i.includes(n.toolName)&&r.set(b,{path:b,toolName:n.toolName})}return Array.from(r.values())},[t]);return a.length===0?null: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 (",a.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:a.map(({path:r})=>{const i=r.split("/").pop()||r;return e.jsxs("button",{onClick:()=>s({tab:"diff",targetPath:r}),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:r,children:[e.jsx(it,{className:"w-3 h-3"}),i]},r)})})]})}function hs({subagent:t}){var J,W,ae,re;const s=D(),[a,r]=f.useState(null),[i,n]=f.useState(!1),[d,b]=f.useState(null),[u,c]=f.useState(!1),[k,l]=f.useState(""),[p,x]=f.useState(!1),[j,S]=f.useState(null),[h,N]=f.useState(null),[v,o]=f.useState(null),m=y(A=>A.currentSessionRef),E=y(A=>A.isStreaming),w=y(A=>A.isTemporarySession);if(!t)return null;const C=t.status==="running",R=a!==null?a:C,O=t.toolCalls||d||[],U=t.output||t.thinking||O.length>0||t.sessionId,I=h&&h.status!=="running"?h:v,L=(I==null?void 0:I.id)??t.sessionId,V=((J=I==null?void 0:I.restartRecovery)==null?void 0:J.outcome)==="failed",T=!C&&!E&&!w&&!V&&(h==null?void 0:h.status)!=="running"&&!!(L&&m);f.useEffect(()=>{if(!R||C||!t.sessionId||!(m!=null&&m.projectPath)||d!==null||t.toolCalls&&t.toolCalls.length>0)return;let A=!0;return n(!0),G.getMessages({sessionId:t.sessionId,projectPath:m.projectPath}).then(H=>{var _,B;if(!A)return;const q=jt(H),g=new Map;for(const Y of q)if((B=(_=Y.agentContent)==null?void 0:_.toolCalls)!=null&&B.length)for(const he of Y.agentContent.toolCalls)g.has(he.toolCallId)||g.set(he.toolCallId,he);b(Array.from(g.values()))}).finally(()=>{A&&n(!1)}),()=>{A=!1}},[R,C,t.sessionId,t.toolCalls,d,m==null?void 0:m.projectPath]),f.useEffect(()=>{if(!t.sessionId||!m)return;let A=!0;const H=t.rootAgentId??t.sessionId,q=t.resumeDepth??0;return G.listSubagents(m).then(g=>{if(!A)return;o(g.find(B=>B.id===t.sessionId)??null);const _=g.filter(B=>B.id!==t.sessionId&&B.rootAgentId===H&&B.resumeDepth>q).sort((B,Y)=>Y.resumeDepth-B.resumeDepth||Y.lastActiveAt-B.lastActiveAt)[0];_&&N(_)}).catch(()=>{}),()=>{A=!1}},[m==null?void 0:m.sessionId,m==null?void 0:m.projectPath,t.sessionId,t.rootAgentId,t.resumeDepth]),f.useEffect(()=>{if(!h||h.status!=="running"||!m)return;let A=!0;const H=async()=>{try{const _=(await G.listSubagents(m)).find(B=>B.id===h.id);A&&_&&N(_)}catch{}},q=window.setInterval(()=>{H()},1e3);return()=>{A=!1,window.clearInterval(q)}},[m,h==null?void 0:h.id,h==null?void 0:h.status]);const P=async()=>{if(!(!m||!L||!k.trim()||p)){x(!0),S(null);try{const A=await G.resumeSubagent(m,L,k.trim());N(A.session),l(""),c(!1),r(!0)}catch(A){S(A instanceof Error?A.message:s("chat.subagent.resumeFailed"))}finally{x(!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(!R),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:[C&&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(Se,{status:t.status==="completed"?"success":t.status==="failed"?"error":"running"}),t.type==="verification"&&t.verificationVerdict&&e.jsx("span",{"data-verification-verdict":t.verificationVerdict,className:M("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:s("chat.subagent.resumedFromTitle",{id:t.resumedFrom}),children:s("chat.subagent.resumedDepth",{depth:t.resumeDepth??1})})]}),U&&e.jsx(te,{className:M("h-3.5 w-3.5 text-[hsl(var(--deck-ink-muted))] transition-transform",R&&"rotate-180")})]}),!R&&!C&&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}),R&&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})]}),i&&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"}),s("chat.subagent.loadingLogs")]}),!i&&O.length>0&&e.jsx(Xe,{toolCalls:O}),h&&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:s("chat.subagent.resumedAs",{id:h.id,status:h.status,depth:h.resumeDepth??1})}),(((W=h.result)==null?void 0:W.message)||((ae=h.result)==null?void 0:ae.error))&&e.jsx("div",{className:"mt-1 whitespace-pre-wrap text-[hsl(var(--deck-ink))]",children:h.result.message||h.result.error})]}),V&&((re=I==null?void 0:I.result)==null?void 0:re.error)&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:I.result.error}),T&&e.jsxs("div",{className:"space-y-2",children:[u?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":s("chat.subagent.followUpAria"),value:k,onChange:A=>l(A.target.value),placeholder:s("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),S(null)},className:"rounded px-2 py-1 text-[11px] text-[#6B7280] hover:bg-[#F3F4F6] dark:hover:bg-[#27272a]",children:s("chat.subagent.cancel")}),e.jsxs("button",{type:"button",onClick:()=>void P(),disabled:!k.trim()||p,className:"flex items-center gap-1 rounded bg-[#7C3AED] px-2 py-1 text-[11px] font-medium text-white disabled:opacity-50",children:[p&&e.jsx($,{className:"w-3 h-3 animate-spin"}),s("chat.subagent.resumeAgent")]})]})]}):e.jsxs("button",{type:"button","aria-label":s("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(le,{className:"w-3 h-3"}),s("chat.subagent.resume")]}),j&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:j})]})]})]})}function xs({confirmation:t,messageId:s}){const a=D(),[r,i]=f.useState(!1),[n,d]=f.useState(null),b=y(k=>k.currentSessionRef),u=y(k=>k.setConfirmation);if(!t)return null;const c=async(k,l)=>{if(!(!b||r)){i(!0),d(null);try{await G.respondPermission(b,t.toolCallId,{approved:k,scope:l}),u(s,{...t,status:k?"approved":"denied"})}catch(p){d(p instanceof Error?p.message:a("interaction.permission.failed"))}finally{i(!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:a("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}),n&&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:n}),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"}):a("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:a("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:a("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:a("interaction.permission.deny")})]})]})}function ps({question:t,messageId:s}){const a=D(),[r,i]=f.useState({}),[n,d]=f.useState({}),[b,u]=f.useState(!1),[c,k]=f.useState(null),l=y(h=>h.currentSessionRef),p=y(h=>h.setQuestion),x=f.useMemo(()=>t?t.questions.reduce((h,N)=>{var E;const v=(E=n[N.header])==null?void 0:E.trim(),o=r[N.header];if(N.multiSelect){const w=Array.isArray(o)?[...o]:[];return v&&w.push(v),w.length>0&&(h[N.header]=w),h}const m=v||(typeof o=="string"?o:"");return m&&(h[N.header]=m),h},{}):{},[r,n,t]),j=(t==null?void 0:t.questions.every(h=>h.header in x))??!1;if(!t)return null;const S=async()=>{if(!(!l||b||!j)){u(!0),k(null);try{await G.respondToQuestion(l,t.toolCallId,x),p(s,{...t,status:"answered",answers:x})}catch(h){k(h instanceof Error?h.message:a("interaction.question.failed"))}finally{u(!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:a("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((h,N)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[13px] text-[hsl(var(--deck-ink))] font-mono",children:h.question}),e.jsxs("div",{className:"space-y-1",children:[h.options.map((v,o)=>e.jsxs("button",{type:"button",onClick:()=>{if(h.multiSelect){const m=r[h.header]||[],E=m.includes(v.label)?m.filter(w=>w!==v.label):[...m,v.label];i({...r,[h.header]:E})}else i({...r,[h.header]:v.label}),d({...n,[h.header]:""})},className:M("w-full text-left px-3 py-2 rounded-md border text-[12px] font-mono transition-colors","border-[hsl(var(--deck-border))]",(h.multiSelect?(r[h.header]||[]).includes(v.label):r[h.header]===v.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:v.label}),e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-faint))] mt-1",children:v.description})]},o)),e.jsx("input",{"aria-label":`${h.header} other response`,value:n[h.header]??"",onChange:v=>d({...n,[h.header]:v.target.value}),placeholder:a("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]"})]})]},N)),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 S(),disabled:b||!j,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:[b&&e.jsx($,{className:"h-3.5 w-3.5 animate-spin"}),a("interaction.question.submit")]})]})}function fs({message:t}){const s=t.agentContent,a=y(j=>j.isStreaming&&j.currentAssistantMessageId===t.id);if(!s){const j=Ne(t.content);return j?e.jsx(Re,{content:j}):null}const{toolCalls:r,tasks:i,confirmation:n,question:d,elicitation:b}=s,u=gt(s),c=kt(s);if(!(c.length>0||i.length>0||u.length>0||n||d||b)&&a)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 p=r.length>0&&r.every(j=>j.status==="success"||j.status==="error")&&!a,x=!a;return e.jsxs("div",{className:"space-y-3",children:[c.map(j=>j.type==="thinking"?e.jsx("div",{"data-agent-timeline-block":"thinking",children:e.jsx(ds,{content:j.content})},j.id):j.type==="text"?e.jsx("div",{"data-agent-timeline-block":"text",children:e.jsx(Re,{content:j.content,syntaxHighlight:x})},j.id):e.jsx("div",{"data-agent-timeline-block":"tool_group",children:e.jsx(cs,{toolCalls:r,toolCallIds:j.toolCallIds})},j.id)),i.length>0&&e.jsx(us,{tasks:i}),u.map(j=>e.jsx(hs,{subagent:j},j.id)),n&&e.jsx(xs,{confirmation:n,messageId:t.id}),d&&e.jsx(ps,{question:d,messageId:t.id}),b&&e.jsx(Kt,{elicitation:b,messageId:t.id}),p&&e.jsx(ms,{toolCalls:r})]})}function bs({message:t,showAvatar:s=!0}){var b,u,c,k;const a=t.role==="user";if(t.role==="system"){const l=Ne(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:l})})}if(a){const l=(b=t.metadata)!=null&&b.userShellCommand&&typeof t.metadata.userShellCommand=="object"?t.metadata.userShellCommand:(u=t.metadata)!=null&&u.userShellExecution&&typeof t.metadata.userShellExecution=="object"?t.metadata.userShellExecution:void 0;if(l){const j=typeof l.command=="string"?l.command:"",S=l.status==="running"?"running":l.status==="completed"?"success":"error",h=typeof l.output=="string"?l.output:[typeof l.stdout=="string"?l.stdout:"",typeof l.stderr=="string"&&l.stderr?`stderr:
|
|
55
|
+
`,e.jsx("span",{"data-tool-truncation-notice":!0,children:i.notice})]})]})]})]})]})}function Xe({toolCalls:t}){return t.length===0?null:e.jsx("div",{className:"space-y-2",children:t.map(s=>e.jsx(ls,{tool:s},s.toolCallId))})}function cs({toolCalls:t,toolCallIds:s}){const a=D(),[r,i]=f.useState(!1),n=f.useMemo(()=>new Map(t.map(l=>[l.toolCallId,l])),[t]),d=s.flatMap(l=>{const p=n.get(l);return p?[p]:[]});if(d.length===0)return null;const b=d.filter(l=>l.status==="running").length,u=d.filter(l=>l.status==="error").length,c=[...d].reverse().find(l=>l.status==="running"&&!!l.progressMessage),k=b>0?a(d.length===1?"chat.timeline.tools.runningOne":"chat.timeline.tools.running",{count:d.length}):u>0?a(d.length===1?"chat.timeline.tools.completedOneWithError":"chat.timeline.tools.completedWithErrors",{count:d.length,errors:u}):a(d.length===1?"chat.timeline.tools.completedOne":"chat.timeline.tools.completed",{count:d.length});return e.jsxs("div",{"data-agent-tool-group":!0,className:"py-0.5",children:[e.jsxs("button",{type:"button","aria-expanded":r,onClick:()=>i(l=>!l),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(te,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(se,{className:"h-3.5 w-3.5 shrink-0"}),b>0&&e.jsx($,{className:"h-3 w-3 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"}),e.jsx("span",{children:k}),(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(Xe,{toolCalls:d})})]})}function ds({content:t}){const s=D(),[a,r]=f.useState(!1);return t?e.jsxs("div",{"data-agent-thinking":!0,className:"py-0.5",children:[e.jsxs("button",{type:"button","aria-expanded":a,onClick:()=>r(i=>!i),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:[a?e.jsx(te,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))]"}):e.jsx(se,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{children:s("chat.timeline.thinking")})]}),a&&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 us({tasks:t}){if(t.length===0)return null;const s=t.filter(r=>r.status==="completed").length,a=s===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:a?"✓ All tasks done":`Tasks: ${s}/${t.length}`})})})}function ms({toolCalls:t}){const s=we(r=>r.openFilePreview),a=f.useMemo(()=>{const r=new Map,i=["Write","SearchReplace","Edit","ApplyPatch"];for(const n of t){if(n.status!=="success")continue;const d=n.metadata;if(n.toolName==="ApplyPatch"&&Array.isArray(d==null?void 0:d.changes)){for(const u of d.changes)u&&typeof u=="object"&&"path"in u&&typeof u.path=="string"&&r.set(u.path,{path:u.path,toolName:n.toolName});continue}const b=d==null?void 0:d.file_path;b&&i.includes(n.toolName)&&r.set(b,{path:b,toolName:n.toolName})}return Array.from(r.values())},[t]);return a.length===0?null: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 (",a.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:a.map(({path:r})=>{const i=r.split("/").pop()||r;return e.jsxs("button",{onClick:()=>s({tab:"diff",targetPath:r}),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:r,children:[e.jsx(it,{className:"w-3 h-3"}),i]},r)})})]})}function hs({subagent:t}){var J,W,ae,re;const s=D(),[a,r]=f.useState(null),[i,n]=f.useState(!1),[d,b]=f.useState(null),[u,c]=f.useState(!1),[k,l]=f.useState(""),[p,x]=f.useState(!1),[j,S]=f.useState(null),[h,N]=f.useState(null),[v,o]=f.useState(null),m=y(A=>A.currentSessionRef),E=y(A=>A.isStreaming),w=y(A=>A.isTemporarySession);if(!t)return null;const C=t.status==="running",R=a!==null?a:C,O=t.toolCalls||d||[],U=t.output||t.thinking||O.length>0||t.sessionId,I=h&&h.status!=="running"?h:v,L=(I==null?void 0:I.id)??t.sessionId,V=((J=I==null?void 0:I.restartRecovery)==null?void 0:J.outcome)==="failed",T=!C&&!E&&!w&&!V&&(h==null?void 0:h.status)!=="running"&&!!(L&&m);f.useEffect(()=>{if(!R||C||!t.sessionId||!(m!=null&&m.projectPath)||d!==null||t.toolCalls&&t.toolCalls.length>0)return;let A=!0;return n(!0),G.getMessages({sessionId:t.sessionId,projectPath:m.projectPath}).then(H=>{var _,B;if(!A)return;const q=gt(H),g=new Map;for(const Y of q)if((B=(_=Y.agentContent)==null?void 0:_.toolCalls)!=null&&B.length)for(const he of Y.agentContent.toolCalls)g.has(he.toolCallId)||g.set(he.toolCallId,he);b(Array.from(g.values()))}).finally(()=>{A&&n(!1)}),()=>{A=!1}},[R,C,t.sessionId,t.toolCalls,d,m==null?void 0:m.projectPath]),f.useEffect(()=>{if(!t.sessionId||!m)return;let A=!0;const H=t.rootAgentId??t.sessionId,q=t.resumeDepth??0;return G.listSubagents(m).then(g=>{if(!A)return;o(g.find(B=>B.id===t.sessionId)??null);const _=g.filter(B=>B.id!==t.sessionId&&B.rootAgentId===H&&B.resumeDepth>q).sort((B,Y)=>Y.resumeDepth-B.resumeDepth||Y.lastActiveAt-B.lastActiveAt)[0];_&&N(_)}).catch(()=>{}),()=>{A=!1}},[m==null?void 0:m.sessionId,m==null?void 0:m.projectPath,t.sessionId,t.rootAgentId,t.resumeDepth]),f.useEffect(()=>{if(!h||h.status!=="running"||!m)return;let A=!0;const H=async()=>{try{const _=(await G.listSubagents(m)).find(B=>B.id===h.id);A&&_&&N(_)}catch{}},q=window.setInterval(()=>{H()},1e3);return()=>{A=!1,window.clearInterval(q)}},[m,h==null?void 0:h.id,h==null?void 0:h.status]);const P=async()=>{if(!(!m||!L||!k.trim()||p)){x(!0),S(null);try{const A=await G.resumeSubagent(m,L,k.trim());N(A.session),l(""),c(!1),r(!0)}catch(A){S(A instanceof Error?A.message:s("chat.subagent.resumeFailed"))}finally{x(!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(!R),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:[C&&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(Se,{status:t.status==="completed"?"success":t.status==="failed"?"error":"running"}),t.type==="verification"&&t.verificationVerdict&&e.jsx("span",{"data-verification-verdict":t.verificationVerdict,className:M("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:s("chat.subagent.resumedFromTitle",{id:t.resumedFrom}),children:s("chat.subagent.resumedDepth",{depth:t.resumeDepth??1})})]}),U&&e.jsx(te,{className:M("h-3.5 w-3.5 text-[hsl(var(--deck-ink-muted))] transition-transform",R&&"rotate-180")})]}),!R&&!C&&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}),R&&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})]}),i&&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"}),s("chat.subagent.loadingLogs")]}),!i&&O.length>0&&e.jsx(Xe,{toolCalls:O}),h&&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:s("chat.subagent.resumedAs",{id:h.id,status:h.status,depth:h.resumeDepth??1})}),(((W=h.result)==null?void 0:W.message)||((ae=h.result)==null?void 0:ae.error))&&e.jsx("div",{className:"mt-1 whitespace-pre-wrap text-[hsl(var(--deck-ink))]",children:h.result.message||h.result.error})]}),V&&((re=I==null?void 0:I.result)==null?void 0:re.error)&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:I.result.error}),T&&e.jsxs("div",{className:"space-y-2",children:[u?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":s("chat.subagent.followUpAria"),value:k,onChange:A=>l(A.target.value),placeholder:s("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),S(null)},className:"rounded px-2 py-1 text-[11px] text-[#6B7280] hover:bg-[#F3F4F6] dark:hover:bg-[#27272a]",children:s("chat.subagent.cancel")}),e.jsxs("button",{type:"button",onClick:()=>void P(),disabled:!k.trim()||p,className:"flex items-center gap-1 rounded bg-[#7C3AED] px-2 py-1 text-[11px] font-medium text-white disabled:opacity-50",children:[p&&e.jsx($,{className:"w-3 h-3 animate-spin"}),s("chat.subagent.resumeAgent")]})]})]}):e.jsxs("button",{type:"button","aria-label":s("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(le,{className:"w-3 h-3"}),s("chat.subagent.resume")]}),j&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:j})]})]})]})}function xs({confirmation:t,messageId:s}){const a=D(),[r,i]=f.useState(!1),[n,d]=f.useState(null),b=y(k=>k.currentSessionRef),u=y(k=>k.setConfirmation);if(!t)return null;const c=async(k,l)=>{if(!(!b||r)){i(!0),d(null);try{await G.respondPermission(b,t.toolCallId,{approved:k,scope:l}),u(s,{...t,status:k?"approved":"denied"})}catch(p){d(p instanceof Error?p.message:a("interaction.permission.failed"))}finally{i(!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:a("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}),n&&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:n}),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"}):a("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:a("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:a("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:a("interaction.permission.deny")})]})]})}function ps({question:t,messageId:s}){const a=D(),[r,i]=f.useState({}),[n,d]=f.useState({}),[b,u]=f.useState(!1),[c,k]=f.useState(null),l=y(h=>h.currentSessionRef),p=y(h=>h.setQuestion),x=f.useMemo(()=>t?t.questions.reduce((h,N)=>{var E;const v=(E=n[N.header])==null?void 0:E.trim(),o=r[N.header];if(N.multiSelect){const w=Array.isArray(o)?[...o]:[];return v&&w.push(v),w.length>0&&(h[N.header]=w),h}const m=v||(typeof o=="string"?o:"");return m&&(h[N.header]=m),h},{}):{},[r,n,t]),j=(t==null?void 0:t.questions.every(h=>h.header in x))??!1;if(!t)return null;const S=async()=>{if(!(!l||b||!j)){u(!0),k(null);try{await G.respondToQuestion(l,t.toolCallId,x),p(s,{...t,status:"answered",answers:x})}catch(h){k(h instanceof Error?h.message:a("interaction.question.failed"))}finally{u(!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:a("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((h,N)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[13px] text-[hsl(var(--deck-ink))] font-mono",children:h.question}),e.jsxs("div",{className:"space-y-1",children:[h.options.map((v,o)=>e.jsxs("button",{type:"button",onClick:()=>{if(h.multiSelect){const m=r[h.header]||[],E=m.includes(v.label)?m.filter(w=>w!==v.label):[...m,v.label];i({...r,[h.header]:E})}else i({...r,[h.header]:v.label}),d({...n,[h.header]:""})},className:M("w-full text-left px-3 py-2 rounded-md border text-[12px] font-mono transition-colors","border-[hsl(var(--deck-border))]",(h.multiSelect?(r[h.header]||[]).includes(v.label):r[h.header]===v.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:v.label}),e.jsx("div",{className:"text-[11px] text-[hsl(var(--deck-ink-faint))] mt-1",children:v.description})]},o)),e.jsx("input",{"aria-label":`${h.header} other response`,value:n[h.header]??"",onChange:v=>d({...n,[h.header]:v.target.value}),placeholder:a("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]"})]})]},N)),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 S(),disabled:b||!j,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:[b&&e.jsx($,{className:"h-3.5 w-3.5 animate-spin"}),a("interaction.question.submit")]})]})}function fs({message:t}){const s=t.agentContent,a=y(j=>j.isStreaming&&j.currentAssistantMessageId===t.id);if(!s){const j=Ne(t.content);return j?e.jsx(Re,{content:j}):null}const{toolCalls:r,tasks:i,confirmation:n,question:d,elicitation:b}=s,u=bt(s),c=vt(s);if(!(c.length>0||i.length>0||u.length>0||n||d||b)&&a)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 p=r.length>0&&r.every(j=>j.status==="success"||j.status==="error")&&!a,x=!a;return e.jsxs("div",{className:"space-y-3",children:[c.map(j=>j.type==="thinking"?e.jsx("div",{"data-agent-timeline-block":"thinking",children:e.jsx(ds,{content:j.content})},j.id):j.type==="text"?e.jsx("div",{"data-agent-timeline-block":"text",children:e.jsx(Re,{content:j.content,syntaxHighlight:x})},j.id):e.jsx("div",{"data-agent-timeline-block":"tool_group",children:e.jsx(cs,{toolCalls:r,toolCallIds:j.toolCallIds})},j.id)),i.length>0&&e.jsx(us,{tasks:i}),u.map(j=>e.jsx(hs,{subagent:j},j.id)),n&&e.jsx(xs,{confirmation:n,messageId:t.id}),d&&e.jsx(ps,{question:d,messageId:t.id}),b&&e.jsx(Kt,{elicitation:b,messageId:t.id}),p&&e.jsx(ms,{toolCalls:r})]})}function bs({message:t,showAvatar:s=!0}){var b,u,c,k;const a=t.role==="user";if(t.role==="system"){const l=Ne(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:l})})}if(a){const l=(b=t.metadata)!=null&&b.userShellCommand&&typeof t.metadata.userShellCommand=="object"?t.metadata.userShellCommand:(u=t.metadata)!=null&&u.userShellExecution&&typeof t.metadata.userShellExecution=="object"?t.metadata.userShellExecution:void 0;if(l){const j=typeof l.command=="string"?l.command:"",S=l.status==="running"?"running":l.status==="completed"?"success":"error",h=typeof l.output=="string"?l.output:[typeof l.stdout=="string"?l.stdout:"",typeof l.stderr=="string"&&l.stderr?`stderr:
|
|
56
56
|
${l.stderr}`:""].filter(Boolean).join(`
|
|
57
|
-
`);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:"$"}),j]}),e.jsx(Se,{status:S})]}),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:h||"(no output)"}),typeof l.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 ",l.exitCode,typeof l.durationMs=="number"?` · ${(l.durationMs/1e3).toFixed(3)}s`:"",l.truncated===!0?" · truncated":""]})]})})}const{text:p,images:x}=rs(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(Me,{text:p,label:"Copy message"})}),e.jsxs("div",{className:"bg-[hsl(var(--deck-surface-2))] rounded-lg px-4 py-3 max-w-[85%]",children:[p&&e.jsx("p",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono leading-relaxed whitespace-pre-wrap",children:p}),x.length>0&&e.jsx("div",{className:M("grid gap-2",x.length===1?"grid-cols-1 mt-0":"grid-cols-2 mt-3"),children:x.map((j,S)=>e.jsx("img",{src:j,alt:`attachment-${S+1}`,className:"object-cover w-full max-h-64 rounded-md"},`${j}-${S}`))})]}),e.jsx(as,{})]})}const i=ns(t),n=Ht((c=t.metadata)==null?void 0:c.codeReview),d=Zt((k=t.metadata)==null?void 0:k.structuredOutput);return e.jsxs("div",{"data-chat-message-id":t.id,"data-chat-role":"assistant",className:M("group flex gap-4 justify-start w-full",s?"p-4":"px-4 pt-0 pb-3"),children:[s?e.jsx(ss,{}):e.jsx("div",{className:"w-8 shrink-0"}),e.jsxs("div",{className:"overflow-hidden flex-1 min-w-0",children:[n?e.jsx(zt,{report:n}):d?e.jsx(es,{report:d}):e.jsx(fs,{message:t}),!d&&i.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(Me,{text:i,label:"Copy response"})})]})]})}const vs=f.memo(bs);function gs(t,s,a){return Math.max(0,t+(a-s))}function ks(t,s,a){return Math.min(s,Math.max(0,t)+Math.max(0,a))}function De(t,s){return t?t.querySelector(`[data-chat-message-id="${CSS.escape(s)}"]`):null}function js({turns:t,viewportRef:s,containerRef:a,onRevealTurn:r}){const i=D(),[n,d]=f.useState(null),[b,u]=f.useState(!1),c=f.useRef(null),k=f.useCallback(()=>{var h;const p=s.current,x=a.current;if(!p||!x||t.length===0)return;const j=p.getBoundingClientRect().top;let S=((h=t[0])==null?void 0:h.id)??null;for(const N of t){const v=De(x,N.id);if(v)if(v.getBoundingClientRect().top-j<=24)S=N.id;else break}d(S)},[t,s,a]);f.useEffect(()=>{const p=s.current;if(!p)return;const x=()=>{c.current===null&&(c.current=window.requestAnimationFrame(()=>{c.current=null,k()}))};return k(),p.addEventListener("scroll",x,{passive:!0}),()=>{p.removeEventListener("scroll",x),c.current!==null&&(window.cancelAnimationFrame(c.current),c.current=null)}},[k,s]);const l=f.useCallback(p=>{const x=()=>{const S=De(a.current,p.id);S&&(S.scrollIntoView({behavior:"smooth",block:"start"}),d(p.id))};r(p.index)?x():window.requestAnimationFrame(()=>window.requestAnimationFrame(x))},[a,r]);return t.length<2?null:e.jsx("nav",{"aria-label":i("chat.turns.aria"),className:"absolute right-1 top-1/2 z-20 hidden -translate-y-1/2 sm:block",onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),onFocusCapture:()=>u(!0),onBlurCapture:p=>{p.currentTarget.contains(p.relatedTarget)||u(!1)},children:e.jsxs("div",{className:"relative flex items-center justify-end",children:[e.jsx("ul",{className:M("flex flex-col items-center gap-2 py-2 transition-opacity",b?"opacity-0":"opacity-100"),"aria-hidden":b,children:t.map(p=>e.jsx("li",{children:e.jsx("span",{className:M("block rounded-full transition-all",p.id===n?"h-2 w-2 bg-[hsl(var(--deck-accent))]":"h-1.5 w-1.5 bg-[hsl(var(--deck-ink-faint))]/40")})},p.id))}),e.jsx("div",{className:M("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",b?"pointer-events-auto translate-x-0 opacity-100":"pointer-events-none translate-x-2 opacity-0"),children:t.map((p,x)=>e.jsxs("button",{type:"button",onClick:()=>l(p),className:M("flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors",p.id===n?"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:M("mt-1 h-1.5 w-1.5 shrink-0 rounded-full",p.id===n?"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:i("chat.turns.label",{n:x+1})}),e.jsx("span",{className:"line-clamp-2 text-[12px] leading-4",children:p.preview})]})]},p.id))})]})})}const Ie=80;function ys(t){return typeof t=="string"?t:Array.isArray(t)?t.filter(s=>s.type==="text").map(s=>s.text).join(" "):""}function ws(t){const s=ys(t).replace(/\s+/g," ").trim();return s?s.length>Ie?`${s.slice(0,Ie-1)}…`:s:""}function Ns(t){const s=[];for(let a=0;a<t.length;a+=1){const r=t[a];if(r.role!=="user"||!r.id)continue;const i=ws(r.content);i&&s.push({id:r.id,index:a,preview:i})}return s}const pe=120,fe=80,Ss=96;function X(t){return(t==null?void 0:t.querySelector("[data-radix-scroll-area-viewport]"))??null}function Cs({messages:t,isLoading:s}){const a=D(),r=f.useRef(null),i=f.useRef(null),n=f.useRef(!0),d=f.useRef(t.length),b=f.useRef(null),[u,c]=f.useState(pe),[k,l]=f.useState(!1);f.useEffect(()=>{const o=X(r.current);if(!o||!n.current)return;const m=window.requestAnimationFrame(()=>{o.scrollTop=o.scrollHeight});return()=>window.cancelAnimationFrame(m)},[t]),f.useEffect(()=>{const o=X(r.current);if(!o)return;i.current=o;const m=()=>{const w=o.scrollHeight-o.scrollTop-o.clientHeight<=Ss;n.current=w,l(!w)};return m(),o.addEventListener("scroll",m,{passive:!0}),()=>o.removeEventListener("scroll",m)},[]),f.useEffect(()=>{const o=d.current;d.current=t.length,c(m=>m>=o&&t.length>o?t.length:Math.min(Math.max(m,pe),t.length||pe))},[t.length]);const p=Math.max(t.length-u,0),x=p,j=f.useMemo(()=>t.slice(x),[t,x]),S=f.useMemo(()=>Ns(t),[t]);if(f.useLayoutEffect(()=>{var E;const o=b.current;if(!o)return;const m=X(r.current);if(b.current=null,!!m){if((E=o.element)!=null&&E.isConnected){const w=o.element.getBoundingClientRect().top-o.viewportTop;m.scrollTop+=w;return}m.scrollTop=gs(o.scrollTop,o.scrollHeight,m.scrollHeight)}},[u]),s)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(ve,{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(ot,{className:"w-3 h-3"}),a("chat.list.loading.eyebrow")]}),e.jsx("h2",{className:"mt-2 text-[15px] font-medium text-[hsl(var(--deck-ink))]",children:a("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:a("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((o,m)=>e.jsxs("div",{className:M("flex gap-3",m%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:`${o}%`,animationDelay:`${m*120}ms`}})]},o))})]})});if(t.length===0&&!s)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(ve,{size:44}),e.jsxs("div",{children:[e.jsx("div",{className:"deck-eyebrow text-[hsl(var(--deck-accent))]",children:a("chat.list.empty.eyebrow")}),e.jsx("div",{className:"mt-2 text-[15px] font-medium text-[hsl(var(--deck-ink))]",children:a("chat.list.empty.title")}),e.jsx("div",{className:"mt-1 max-w-xs text-[12px] text-[hsl(var(--deck-ink-muted))]",children:a("chat.list.empty.hint")})]})]})});const h=()=>{const o=X(r.current);o&&(n.current=!0,l(!1),o.scrollTo({top:o.scrollHeight,behavior:"smooth"}))},N=()=>{var m;const o=X(r.current);if(o){const E=((m=r.current)==null?void 0:m.querySelector("[data-chat-message-id]"))??null;b.current={element:E,viewportTop:(E==null?void 0:E.getBoundingClientRect().top)??0,scrollHeight:o.scrollHeight,scrollTop:o.scrollTop}}c(E=>ks(E,t.length,fe))},v=o=>o>=x?!0:(c(t.length),!1);return e.jsxs("div",{ref:r,className:"relative flex-1 min-h-0",children:[e.jsx(lt,{className:"h-full",children:e.jsxs("div",{className:"flex flex-col px-4 pb-4 w-full md:px-6",children:[p>0&&e.jsx("div",{className:"flex justify-center py-3",children:e.jsx("button",{type:"button",onClick:N,"aria-label":a("chat.list.showEarlierWithRemaining",{count:Math.min(p,fe),remaining:p}),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:a("chat.list.showEarlier",{count:Math.min(p,fe)})})}),j.map((o,m)=>{const E=x+m,w=E>0?t[E-1]:null,C=!w||w.role!==o.role||w.role==="user";return e.jsx(vs,{message:o,showAvatar:C},o.id||`msg-${E}`)})]})}),e.jsx(js,{turns:S,viewportRef:i,containerRef:r,onRevealTurn:v}),k&&e.jsxs("button",{type:"button",onClick:h,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(We,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}),a("chat.list.jumpLatest")]})]})}const Ze=f.memo(Cs),ge=St,ke=Ct,je=Et,de=f.forwardRef(({className:t,sideOffset:s=4,...a},r)=>e.jsx(Qe,{ref:r,sideOffset:s,className:M("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),...a}));de.displayName=Qe.displayName;const Es={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 ne(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)}function Ts(t){if(t<60)return`${t}s`;const s=Math.floor(t/60),a=t%60;return a===0?`${s}m`:`${s}m ${a}s`}function Ms(){var U,I,L,V;const t=D(),{locale:s}=ze(),a=y(T=>T.goal),r=y(T=>T.pauseGoal),i=y(T=>T.resumeGoal),n=y(T=>T.editGoal),d=y(T=>T.clearGoal),[b,u]=f.useState(!1),[c,k]=f.useState(!1),[l,p]=f.useState(""),[x,j]=f.useState(null),[S,h]=f.useState(!1);if(f.useEffect(()=>{u(!1),k(!1),p((a==null?void 0:a.objective)??""),h(!1)},[a==null?void 0:a.goalId]),!a)return null;const N=Es[a.status],v=["active","verifying","paused","blocked"].includes(a.status),o=a.status==="active"||a.status==="verifying",m=a.status==="paused"||a.status==="blocked",E=x!==null,w=async(T,P)=>{j(T);try{await P()}finally{j(null)}},C=()=>{p(a.objective),k(!0),u(!0)},R=async T=>{T.preventDefault();const P=l.trim();if(!P||P===a.objective){k(!1);return}await w("edit",()=>n(P)),k(!1)},O=async()=>{await w("delete",d),h(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(ge,{delayDuration:250,children:e.jsxs("section",{"aria-label":t("goal.aria.section"),className:"mx-3 mb-1 shrink-0","data-blade-goal-status":a.status,"data-blade-goal-recovery":(U=a.prematureStop)==null?void 0:U.consecutiveCount,"data-blade-goal-recovery-pattern":(I=a.prematureStop)==null?void 0:I.pattern,"data-blade-goal-verification-stall":(L=a.verificationStall)==null?void 0:L.consecutiveCount,children:[e.jsxs("div",{className:M("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",b&&"rounded-b-none border-b-0"),children:[a.status==="complete"?e.jsx(ct,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500"}):e.jsx(It,{className:M("h-3.5 w-3.5 shrink-0",N.accent)}),e.jsx("span",{className:M("h-1.5 w-1.5 shrink-0 rounded-full",N.dot)}),e.jsx("span",{className:M("shrink-0 text-[10px] font-medium leading-none",N.accent),children:a.status==="verifying"?s==="zh"?"验证中":"Verifying":t(N.labelKey)}),e.jsx("span",{className:"h-3 w-px shrink-0 bg-[hsl(var(--deck-hairline))]"}),e.jsx("button",{type:"button","aria-label":t(b?"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:()=>u(T=>!T),"aria-expanded":b,title:a.objective,children:a.objective}),a.tokensUsed>0&&e.jsxs("span",{className:"hidden shrink-0 text-[10px] tabular-nums text-[hsl(var(--deck-ink-muted))] sm:inline",children:[ne(a.tokensUsed),a.tokenBudget!==void 0&&`/${ne(a.tokenBudget)}`]}),e.jsxs("div",{className:"flex shrink-0 items-center",children:[o&&e.jsx(ie,{label:t("goal.action.pause"),disabled:E,onClick:()=>void w("pause",r),children:x==="pause"?e.jsx($,{className:"animate-spin"}):e.jsx(Tt,{})}),m&&e.jsx(ie,{label:t("goal.action.resume"),disabled:E,onClick:()=>void w("resume",i),children:x==="resume"?e.jsx($,{className:"animate-spin"}):e.jsx(Mt,{})}),e.jsx(ie,{label:t(v?"goal.action.edit":"goal.action.expand"),disabled:!v&&!b,onClick:v?C:()=>u(T=>!T),children:v?e.jsx(Ke,{}):e.jsx(Nt,{})}),e.jsx(ie,{label:t("goal.action.delete"),disabled:E,destructive:!0,onClick:()=>h(!0),children:e.jsx(ee,{})})]})]}),b&&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:c?e.jsxs("form",{onSubmit:R,children:[e.jsx("textarea",{id:"goal-objective",value:l,onChange:T=>p(T.target.value),onKeyDown:T=>{T.key==="Escape"&&k(!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:()=>k(!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(Ge,{className:"h-3 w-3"}),t("goal.action.cancel")]}),e.jsxs("button",{type:"submit",disabled:!l.trim()||x==="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:[x==="edit"?e.jsx($,{className:"h-3 w-3 animate-spin"}):e.jsx(ue,{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:a.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(Ft,{className:"h-3 w-3"}),ne(a.tokensUsed),a.tokenBudget!==void 0&&` / ${ne(a.tokenBudget)}`," ",t("goal.metrics.tokens")]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Bt,{className:"h-3 w-3"}),Ts(a.timeUsedSeconds)]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(le,{className:"h-3 w-3"}),a.continuationCount===1?t("goal.metrics.continuationOne",{n:a.continuationCount}):t("goal.metrics.continuationMany",{n:a.continuationCount})]})]}),a.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(le,{className:"h-3 w-3"}),s==="zh"?"恢复提示":"Recovery nudge"," ",a.prematureStop.consecutiveCount," ·"," ",a.prematureStop.pattern.replaceAll("_"," ")]}),a.completionVerification&&e.jsxs("div",{"data-goal-verification":a.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:["#",a.completionVerification.attempt," ·"," ",a.completionVerification.status.toUpperCase()," ·"," ",((V=a.completionVerification.verifierSessionId)==null?void 0:V.slice(0,12))??"-",a.verificationStall?s==="zh"?` · 重复 ${a.verificationStall.consecutiveCount}/3`:` · repeat ${a.verificationStall.consecutiveCount}/3`:""]}),a.completionVerification.summary&&e.jsx("p",{className:"mt-1 line-clamp-3 whitespace-pre-wrap opacity-80",children:a.completionVerification.summary}),a.completionVerification.evidenceSha256&&e.jsxs("p",{className:"mt-1 font-mono text-[10px] opacity-60",children:["sha256:",a.completionVerification.evidenceSha256.slice(0,12)]})]}),a.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:a.statusReason})]})})]})}),e.jsx(Le,{open:S,onOpenChange:h,children:e.jsxs(Ve,{className:"max-w-[400px] border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsx(Oe,{children:t("goal.dialog.title")}),e.jsx(Ue,{children:t("goal.dialog.description")}),e.jsxs(He,{className:"mt-2",children:[e.jsx("button",{type:"button",onClick:()=>h(!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:x==="delete",onClick:()=>void O(),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:[x==="delete"&&e.jsx($,{className:"w-3.5 h-3.5 animate-spin"}),t("goal.action.delete")]})]})]})})]})}function ie({label:t,children:s,disabled:a,destructive:r,onClick:i}){return e.jsxs(ke,{children:[e.jsx(je,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":t,disabled:a,onClick:i,className:M("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:s})}),e.jsx(de,{side:"top",className:"text-[10px]",children:t})]})}function As(){const t=D(),s=y(u=>u.currentSessionRef),a=y(u=>u.sessions),r=y(u=>u.messages),i=f.useMemo(()=>{var c,k,l,p,x;const u=s?(c=dt(a,s))==null?void 0:c.pendingInteraction:void 0;if(u)return u.type;for(let j=r.length-1;j>=0;j-=1){const S=(k=r[j])==null?void 0:k.agentContent;if(((l=S==null?void 0:S.confirmation)==null?void 0:l.status)==="pending")return"permission";if(((p=S==null?void 0:S.question)==null?void 0:p.status)==="pending")return"question";if(((x=S==null?void 0:S.elicitation)==null?void 0:x.status)==="pending")return"elicitation"}return null},[s,r,a]);if(!i)return null;const n=()=>{const u=document.querySelector(`[data-pending-interaction="${i}"]`);u==null||u.scrollIntoView({block:"center",behavior:"smooth"}),window.setTimeout(()=>u==null?void 0:u.focus(),250)},d=i==="question",b=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(we,{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(d?"interaction.bar.questionTitle":b?"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(d?"interaction.bar.questionHint":b?"interaction.bar.elicitationHint":"interaction.bar.permissionHint")})]}),e.jsxs("button",{type:"button",onClick:n,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(We,{className:"h-3 w-3"}),t("interaction.bar.review")]})]})}const Rs=f.lazy(()=>qe(()=>import("./MarkdownRenderer-fbB4bMCw.js").then(t=>t.M),__vite__mapDeps([0,1,2,3,4,5])).then(t=>({default:t.MarkdownRenderer})));function Fs(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(1)}s`}function $s(){const t=D(),s=y(r=>r.sideConversation),a=y(r=>r.dismissSideConversation);return s?e.jsx("section",{"aria-label":t("chat.side.title"),"data-blade-side-conversation":!0,"data-status":s.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(Dt,{"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")}),s.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(At,{"aria-hidden":!0,className:"h-3 w-3"}),Fs(s.durationMs)]})]}),e.jsx("p",{className:"mt-0.5 break-words font-mono text-[11px] leading-4 text-[hsl(var(--deck-ink-muted))]",children:s.question})]}),e.jsx("button",{type:"button",onClick:a,"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(Ge,{"aria-hidden":!0,className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{"aria-live":"polite","aria-busy":s.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:[s.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")]}),s.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(we,{"aria-hidden":!0,className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"break-words",children:s.error??t("chat.side.failed")})]}),s.status==="completed"&&s.response&&e.jsx(f.Suspense,{fallback:e.jsx("div",{className:"whitespace-pre-wrap break-words font-mono text-[12px] leading-5 text-[hsl(var(--deck-ink))]",children:s.response}),children:e.jsx(Rs,{content:s.response,className:"text-[12px] leading-5 [&_h1]:text-[14px] [&_h2]:text-[13px] [&_h3]:text-[12px]"})})]})]})}):null}function be(t){return Number.isFinite(t)?Math.max(0,t):0}function Ds(t){const s=be(t.totalInputTokens),a=be(t.cacheReadTokens),r=be(t.cacheWriteTokens),i=Math.min(a,s),n=Math.min(r,Math.max(0,s-i)),d=Math.max(0,s-i-n),b=s>0&&(a>0||r>0);return{totalInputTokens:s,cacheReadTokens:i,cacheWriteTokens:n,uncachedInputTokens:d,...b?{hitRate:i/s}:{}}}function Is(t){return t===void 0||!Number.isFinite(t)?"—":`${Math.round(Math.max(0,Math.min(1,t))*100)}%`}const Bs={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:""},_s={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"},K=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString(),oe=t=>{const s=Math.max(0,Math.ceil(t/1e3)),a=Math.floor(s/60),r=s%60;return a>0?`${a}m ${r}s`:`${r}s`};function et(){const t=D(),s=y(N=>N.tokenUsage),a=y(N=>N.isStreaming),r=y(N=>N.agentPhase),i=y(N=>N.providerAdmission),n=y(N=>N.providerCircuit),d=y(N=>N.providerRetry),b=y(N=>N.providerStall),u=y(N=>N.actionStationarity),c=Bs[r]??"",k=(d==null?void 0:d.delayMs)!==void 0?` · ${Math.max(0,Math.ceil(d.delayMs/1e3))}s`:"",l=u?`${t(u.phase==="halted"?"status.phase.actionStationarityStopped":"status.phase.actionStationarityRecovering")} · ${u.toolName} · ${u.runLength}/${u.haltThreshold}`:n?n.phase==="probe"?"Provider · Recovery probe":`Provider · Circuit open${n.retryAfterMs!==void 0?` · probe in ${oe(n.retryAfterMs)}`:""}${n.recoveryRemainingMs!==void 0?` · ${oe(n.recoveryRemainingMs)}`:""}`:i?`Provider · Capacity queue ${i.queuePosition}/${Math.max(i.queueDepth,i.queuePosition)} · ${i.scope} · ${oe(i.waitMs)}`:d?d.mode==="bounded_foreground"?`Provider · Bounded recovery · ${d.attempt}/${d.maxRetries} · ${oe(d.recoveryRemainingMs??0)}`:`Provider · ${t("chat.error.action.retryingTask")} · ${d.attempt}/${d.maxRetries}${k}`:b?`${t("status.phase.providerStall")} · ${Math.ceil(b.durationMs/1e3)}s / ${Math.ceil(b.timeoutMs/1e3)}s`:c?t(c):"",p=s.maxContextTokens>0?Math.round(s.totalTokens/s.maxContextTokens*100):0,x=Ds(s),j=Is(x.hitRate),S=Math.min(p,100),h=p>95?"danger":p>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:M("text-[12px] font-medium",h==="safe"&&"text-[hsl(var(--deck-ink))]",h==="warn"&&"text-amber-600 dark:text-amber-400",h==="danger"&&"text-red-600 dark:text-red-400"),children:K(s.totalTokens)}),e.jsxs("span",{className:"text-[hsl(var(--deck-ink-faint))]",children:["/ ",K(s.maxContextTokens)]})]}),s.isDefaultMaxTokens&&e.jsx(ge,{children:e.jsxs(ke,{children:[e.jsx(je,{asChild:!0,children:e.jsx($t,{className:"h-3 w-3 cursor-help text-[hsl(var(--deck-ink-faint))]"})}),e.jsx(de,{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:M("absolute inset-y-0 left-0 transition-[width] duration-300",h==="safe"&&"bg-[hsl(var(--deck-accent))]",h==="warn"&&"bg-amber-500",h==="danger"&&"bg-red-500"),style:{width:`${S}%`}}),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:M("w-10 text-right tabular-nums text-[hsl(var(--deck-ink-faint))]",h==="warn"&&"text-amber-600 dark:text-amber-400",h==="danger"&&"text-red-600 dark:text-red-400"),children:[p,"%"]})]}),e.jsx(ge,{children:e.jsxs(ke,{children:[e.jsx(je,{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")} ${j}`,children:[e.jsx("span",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:t("status.cache")}),e.jsx("span",{className:M("tabular-nums",x.hitRate===void 0?"text-[hsl(var(--deck-ink-faint))]":"font-medium text-[hsl(var(--deck-accent))]"),children:j})]})}),e.jsx(de,{side:"top",className:"max-w-[280px]",children:x.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:K(x.cacheReadTokens),write:K(x.cacheWriteTokens),uncached:K(x.uncachedInputTokens)})}),s.cacheBreak&&e.jsx("p",{className:"text-[hsl(var(--deck-accent))]",children:t("status.cacheBreak",{reason:t(_s[s.cacheBreak.reason]??"status.cacheBreak.server"),previous:K(s.cacheBreak.previousCacheReadTokens),current:K(s.cacheBreak.cacheReadTokens)})})]})})]})}),e.jsx("div",{className:"flex-1"}),a&&l&&e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("span",{className:"deck-pulse-dot"}),e.jsx("span",{className:"text-[hsl(var(--deck-accent))]",children:l})]})]})}function Ps(){const{locale:t}=ze(),s=ut(o=>o.agentTeamsEnabled),a=y(o=>o.teams),r=y(o=>o.currentSessionRef),i=y(o=>o.loadTeams),[n,d]=f.useState({}),[b,u]=f.useState({}),[c,k]=f.useState({}),[l,p]=f.useState(null),[x,j]=f.useState(null),[S,h]=f.useState(null);if(f.useEffect(()=>{i(r??void 0)},[s,r,i]),!s||!r||a.length===0)return null;const N=async o=>{var E;const m=(E=c[o])==null?void 0:E.trim();if(!(!m||l)){p(o),h(null);try{await Ee.sendMessage(r,o,b[o]??"*",m),k(w=>({...w,[o]:""})),await i(r)}catch(w){h(w instanceof Error?w.message:F(t,"actionFailed"))}finally{p(null)}}},v=async o=>{if(!x){j(o),h(null);try{await Ee.delete(r,o),await i(r)}catch(m){h(m instanceof Error?m.message:F(t,"actionFailed"))}finally{j(null)}}};return e.jsxs("section",{"aria-label":F(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:[S&&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:S}),a.filter(o=>o.status!=="deleted").map(o=>{var w;const m=n[o.name]??o.status==="running",E=o.tasks.filter(C=>C.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:()=>d(C=>({...C,[o.name]:!m})),"aria-label":m?F(t,"collapse"):F(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:m?e.jsx(te,{className:"h-4 w-4"}):e.jsx(se,{className:"h-4 w-4"})}),e.jsx(_t,{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:o.name}),e.jsxs("span",{className:"font-mono text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:[o.status," · ",o.members.length-1," ",F(t,"members")," · ",E,"/",o.tasks.length," ",F(t,"tasks")]})]}),o.description&&e.jsx("p",{className:"truncate font-mono text-[10px] text-[hsl(var(--deck-ink-muted))]",children:o.description})]}),e.jsx("button",{type:"button",onClick:()=>void v(o.name),disabled:x===o.name,"aria-label":F(t,"delete"),title:F(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(ee,{className:"h-3.5 w-3.5"})})]}),m&&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:F(t,"members")}),o.members.map(C=>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":C.status,className:`h-1.5 w-1.5 shrink-0 rounded-full ${C.status==="running"?"bg-emerald-500":C.status==="completed"||C.status==="leader"?"bg-sky-500":C.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:C.name}),e.jsx("span",{className:"font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:C.subagentType}),C.worktreePath&&e.jsx(_e,{className:"h-3 w-3 text-[hsl(var(--deck-ink-faint))]","aria-label":F(t,"worktree")})]},C.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:F(t,"tasks")}),o.tasks.length===0?e.jsx("p",{className:"font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:F(t,"noTasks")}):o.tasks.map(C=>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:["#",C.id]}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10.5px] text-[hsl(var(--deck-ink))]",children:C.subject}),e.jsx("span",{className:"font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:C.status})]},C.id))]})]}),o.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":F(t,"recipient"),value:b[o.name]??"*",onChange:C=>u(R=>({...R,[o.name]:C.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:F(t,"broadcast")}),o.members.filter(C=>C.status!=="leader").map(C=>e.jsx("option",{value:C.name,children:C.name},C.id))]}),e.jsx("input",{value:c[o.name]??"",onChange:C=>k(R=>({...R,[o.name]:C.target.value})),onKeyDown:C=>{C.key==="Enter"&&N(o.name)},placeholder:F(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 N(o.name),disabled:!((w=c[o.name])!=null&&w.trim())||l===o.name,"aria-label":F(t,"send"),title:F(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(Pe,{className:"h-3.5 w-3.5"})})]})]})]},o.name)})]})}function Ls(t){const s=[...t].reverse().find(i=>i.role==="user");if(!s)return null;if(typeof s.content=="string")return{content:s.content,attachments:[]};const a=s.content.filter(i=>i.type==="text").map(i=>i.text).join(`
|
|
58
|
-
`),r=s.content.filter(i=>i.type==="image_url").map((i,n)=>{var b;const d=((b=i.image_url.url.match(/^data:([^;,]+)[;,]/))==null?void 0:b[1])??"application/octet-stream";return{id:`recovery-${s.id}-${n}`,name:`attachment-${n+1}`,mimeType:d,dataUrl:i.image_url.url}});return{content:a,attachments:r}}function Vs({messages:t,isLoading:s,isStreaming:a,isStopping:r,errorMessage:i}){const n=D(),[d,b]=f.useState(!1),u=n(i?"status.phase.error":r?"chat.input.action.stopping":a?"status.phase.running":"preview.files.status.ready");return e.jsxs("details",{"data-preview-status-disclosure":!0,open:d,onToggle:c=>b(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:[a&&e.jsx("span",{className:"deck-pulse-dot"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:u}),e.jsx(se,{className:"h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-90"})]}),d&&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:[i&&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:i}),e.jsx(Ze,{messages:t,isLoading:s}),e.jsx(et,{})]})]})}function Os(){var q;const t=D(),s=y(g=>g.messages),a=y(g=>g.currentSessionRef),r=y(g=>g.isStreaming),i=y(g=>g.isStopping),n=y(g=>g.sessionEventConnectionState),d=y(g=>g.pendingSteeringCount),b=y(g=>g.pendingInputDelivery),u=y(g=>g.recoveredSteeringCount),c=y(g=>g.isLoading),k=y(g=>g.error),l=y(g=>g.errorContext),p=y(g=>g.sessions),x=y(g=>g.sendMessage),j=y(g=>g.abortSession),S=y(g=>g.retryTask),h=y(g=>g.retryingTaskKeys),N=
|
|
57
|
+
`);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:"$"}),j]}),e.jsx(Se,{status:S})]}),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:h||"(no output)"}),typeof l.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 ",l.exitCode,typeof l.durationMs=="number"?` · ${(l.durationMs/1e3).toFixed(3)}s`:"",l.truncated===!0?" · truncated":""]})]})})}const{text:p,images:x}=rs(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(Me,{text:p,label:"Copy message"})}),e.jsxs("div",{className:"bg-[hsl(var(--deck-surface-2))] rounded-lg px-4 py-3 max-w-[85%]",children:[p&&e.jsx("p",{className:"text-[14px] text-[hsl(var(--deck-ink))] font-mono leading-relaxed whitespace-pre-wrap",children:p}),x.length>0&&e.jsx("div",{className:M("grid gap-2",x.length===1?"grid-cols-1 mt-0":"grid-cols-2 mt-3"),children:x.map((j,S)=>e.jsx("img",{src:j,alt:`attachment-${S+1}`,className:"object-cover w-full max-h-64 rounded-md"},`${j}-${S}`))})]}),e.jsx(as,{})]})}const i=ns(t),n=Ht((c=t.metadata)==null?void 0:c.codeReview),d=Zt((k=t.metadata)==null?void 0:k.structuredOutput);return e.jsxs("div",{"data-chat-message-id":t.id,"data-chat-role":"assistant",className:M("group flex gap-4 justify-start w-full",s?"p-4":"px-4 pt-0 pb-3"),children:[s?e.jsx(ss,{}):e.jsx("div",{className:"w-8 shrink-0"}),e.jsxs("div",{className:"overflow-hidden flex-1 min-w-0",children:[n?e.jsx(zt,{report:n}):d?e.jsx(es,{report:d}):e.jsx(fs,{message:t}),!d&&i.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(Me,{text:i,label:"Copy response"})})]})]})}const vs=f.memo(bs);function gs(t,s,a){return Math.max(0,t+(a-s))}function ks(t,s,a){return Math.min(s,Math.max(0,t)+Math.max(0,a))}function De(t,s){return t?t.querySelector(`[data-chat-message-id="${CSS.escape(s)}"]`):null}function js({turns:t,viewportRef:s,containerRef:a,onRevealTurn:r}){const i=D(),[n,d]=f.useState(null),[b,u]=f.useState(!1),c=f.useRef(null),k=f.useCallback(()=>{var h;const p=s.current,x=a.current;if(!p||!x||t.length===0)return;const j=p.getBoundingClientRect().top;let S=((h=t[0])==null?void 0:h.id)??null;for(const N of t){const v=De(x,N.id);if(v)if(v.getBoundingClientRect().top-j<=24)S=N.id;else break}d(S)},[t,s,a]);f.useEffect(()=>{const p=s.current;if(!p)return;const x=()=>{c.current===null&&(c.current=window.requestAnimationFrame(()=>{c.current=null,k()}))};return k(),p.addEventListener("scroll",x,{passive:!0}),()=>{p.removeEventListener("scroll",x),c.current!==null&&(window.cancelAnimationFrame(c.current),c.current=null)}},[k,s]);const l=f.useCallback(p=>{const x=()=>{const S=De(a.current,p.id);S&&(S.scrollIntoView({behavior:"smooth",block:"start"}),d(p.id))};r(p.index)?x():window.requestAnimationFrame(()=>window.requestAnimationFrame(x))},[a,r]);return t.length<2?null:e.jsx("nav",{"aria-label":i("chat.turns.aria"),className:"absolute right-1 top-1/2 z-20 hidden -translate-y-1/2 sm:block",onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),onFocusCapture:()=>u(!0),onBlurCapture:p=>{p.currentTarget.contains(p.relatedTarget)||u(!1)},children:e.jsxs("div",{className:"relative flex items-center justify-end",children:[e.jsx("ul",{className:M("flex flex-col items-center gap-2 py-2 transition-opacity",b?"opacity-0":"opacity-100"),"aria-hidden":b,children:t.map(p=>e.jsx("li",{children:e.jsx("span",{className:M("block rounded-full transition-all",p.id===n?"h-2 w-2 bg-[hsl(var(--deck-accent))]":"h-1.5 w-1.5 bg-[hsl(var(--deck-ink-faint))]/40")})},p.id))}),e.jsx("div",{className:M("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",b?"pointer-events-auto translate-x-0 opacity-100":"pointer-events-none translate-x-2 opacity-0"),children:t.map((p,x)=>e.jsxs("button",{type:"button",onClick:()=>l(p),className:M("flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors",p.id===n?"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:M("mt-1 h-1.5 w-1.5 shrink-0 rounded-full",p.id===n?"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:i("chat.turns.label",{n:x+1})}),e.jsx("span",{className:"line-clamp-2 text-[12px] leading-4",children:p.preview})]})]},p.id))})]})})}const Ie=80;function ys(t){return typeof t=="string"?t:Array.isArray(t)?t.filter(s=>s.type==="text").map(s=>s.text).join(" "):""}function ws(t){const s=ys(t).replace(/\s+/g," ").trim();return s?s.length>Ie?`${s.slice(0,Ie-1)}…`:s:""}function Ns(t){const s=[];for(let a=0;a<t.length;a+=1){const r=t[a];if(r.role!=="user"||!r.id)continue;const i=ws(r.content);i&&s.push({id:r.id,index:a,preview:i})}return s}const pe=120,fe=80,Ss=96;function X(t){return(t==null?void 0:t.querySelector("[data-radix-scroll-area-viewport]"))??null}function Cs({messages:t,isLoading:s}){const a=D(),r=f.useRef(null),i=f.useRef(null),n=f.useRef(!0),d=f.useRef(t.length),b=f.useRef(null),[u,c]=f.useState(pe),[k,l]=f.useState(!1);f.useEffect(()=>{const o=X(r.current);if(!o||!n.current)return;const m=window.requestAnimationFrame(()=>{o.scrollTop=o.scrollHeight});return()=>window.cancelAnimationFrame(m)},[t]),f.useEffect(()=>{const o=X(r.current);if(!o)return;i.current=o;const m=()=>{const w=o.scrollHeight-o.scrollTop-o.clientHeight<=Ss;n.current=w,l(!w)};return m(),o.addEventListener("scroll",m,{passive:!0}),()=>o.removeEventListener("scroll",m)},[]),f.useEffect(()=>{const o=d.current;d.current=t.length,c(m=>m>=o&&t.length>o?t.length:Math.min(Math.max(m,pe),t.length||pe))},[t.length]);const p=Math.max(t.length-u,0),x=p,j=f.useMemo(()=>t.slice(x),[t,x]),S=f.useMemo(()=>Ns(t),[t]);if(f.useLayoutEffect(()=>{var E;const o=b.current;if(!o)return;const m=X(r.current);if(b.current=null,!!m){if((E=o.element)!=null&&E.isConnected){const w=o.element.getBoundingClientRect().top-o.viewportTop;m.scrollTop+=w;return}m.scrollTop=gs(o.scrollTop,o.scrollHeight,m.scrollHeight)}},[u]),s)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(ve,{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(ot,{className:"w-3 h-3"}),a("chat.list.loading.eyebrow")]}),e.jsx("h2",{className:"mt-2 text-[15px] font-medium text-[hsl(var(--deck-ink))]",children:a("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:a("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((o,m)=>e.jsxs("div",{className:M("flex gap-3",m%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:`${o}%`,animationDelay:`${m*120}ms`}})]},o))})]})});if(t.length===0&&!s)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(ve,{size:44}),e.jsxs("div",{children:[e.jsx("div",{className:"deck-eyebrow text-[hsl(var(--deck-accent))]",children:a("chat.list.empty.eyebrow")}),e.jsx("div",{className:"mt-2 text-[15px] font-medium text-[hsl(var(--deck-ink))]",children:a("chat.list.empty.title")}),e.jsx("div",{className:"mt-1 max-w-xs text-[12px] text-[hsl(var(--deck-ink-muted))]",children:a("chat.list.empty.hint")})]})]})});const h=()=>{const o=X(r.current);o&&(n.current=!0,l(!1),o.scrollTo({top:o.scrollHeight,behavior:"smooth"}))},N=()=>{var m;const o=X(r.current);if(o){const E=((m=r.current)==null?void 0:m.querySelector("[data-chat-message-id]"))??null;b.current={element:E,viewportTop:(E==null?void 0:E.getBoundingClientRect().top)??0,scrollHeight:o.scrollHeight,scrollTop:o.scrollTop}}c(E=>ks(E,t.length,fe))},v=o=>o>=x?!0:(c(t.length),!1);return e.jsxs("div",{ref:r,className:"relative flex-1 min-h-0",children:[e.jsx(lt,{className:"h-full",children:e.jsxs("div",{className:"flex flex-col px-4 pb-4 w-full md:px-6",children:[p>0&&e.jsx("div",{className:"flex justify-center py-3",children:e.jsx("button",{type:"button",onClick:N,"aria-label":a("chat.list.showEarlierWithRemaining",{count:Math.min(p,fe),remaining:p}),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:a("chat.list.showEarlier",{count:Math.min(p,fe)})})}),j.map((o,m)=>{const E=x+m,w=E>0?t[E-1]:null,C=!w||w.role!==o.role||w.role==="user";return e.jsx(vs,{message:o,showAvatar:C},o.id||`msg-${E}`)})]})}),e.jsx(js,{turns:S,viewportRef:i,containerRef:r,onRevealTurn:v}),k&&e.jsxs("button",{type:"button",onClick:h,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(We,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}),a("chat.list.jumpLatest")]})]})}const Ze=f.memo(Cs),ge=St,ke=Ct,je=Et,de=f.forwardRef(({className:t,sideOffset:s=4,...a},r)=>e.jsx(Qe,{ref:r,sideOffset:s,className:M("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),...a}));de.displayName=Qe.displayName;const Es={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 ne(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)}function Ts(t){if(t<60)return`${t}s`;const s=Math.floor(t/60),a=t%60;return a===0?`${s}m`:`${s}m ${a}s`}function Ms(){var U,I,L,V;const t=D(),{locale:s}=ze(),a=y(T=>T.goal),r=y(T=>T.pauseGoal),i=y(T=>T.resumeGoal),n=y(T=>T.editGoal),d=y(T=>T.clearGoal),[b,u]=f.useState(!1),[c,k]=f.useState(!1),[l,p]=f.useState(""),[x,j]=f.useState(null),[S,h]=f.useState(!1);if(f.useEffect(()=>{u(!1),k(!1),p((a==null?void 0:a.objective)??""),h(!1)},[a==null?void 0:a.goalId]),!a)return null;const N=Es[a.status],v=["active","verifying","paused","blocked"].includes(a.status),o=a.status==="active"||a.status==="verifying",m=a.status==="paused"||a.status==="blocked",E=x!==null,w=async(T,P)=>{j(T);try{await P()}finally{j(null)}},C=()=>{p(a.objective),k(!0),u(!0)},R=async T=>{T.preventDefault();const P=l.trim();if(!P||P===a.objective){k(!1);return}await w("edit",()=>n(P)),k(!1)},O=async()=>{await w("delete",d),h(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(ge,{delayDuration:250,children:e.jsxs("section",{"aria-label":t("goal.aria.section"),className:"mx-3 mb-1 shrink-0","data-blade-goal-status":a.status,"data-blade-goal-recovery":(U=a.prematureStop)==null?void 0:U.consecutiveCount,"data-blade-goal-recovery-pattern":(I=a.prematureStop)==null?void 0:I.pattern,"data-blade-goal-verification-stall":(L=a.verificationStall)==null?void 0:L.consecutiveCount,children:[e.jsxs("div",{className:M("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",b&&"rounded-b-none border-b-0"),children:[a.status==="complete"?e.jsx(ct,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500"}):e.jsx(It,{className:M("h-3.5 w-3.5 shrink-0",N.accent)}),e.jsx("span",{className:M("h-1.5 w-1.5 shrink-0 rounded-full",N.dot)}),e.jsx("span",{className:M("shrink-0 text-[10px] font-medium leading-none",N.accent),children:a.status==="verifying"?s==="zh"?"验证中":"Verifying":t(N.labelKey)}),e.jsx("span",{className:"h-3 w-px shrink-0 bg-[hsl(var(--deck-hairline))]"}),e.jsx("button",{type:"button","aria-label":t(b?"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:()=>u(T=>!T),"aria-expanded":b,title:a.objective,children:a.objective}),a.tokensUsed>0&&e.jsxs("span",{className:"hidden shrink-0 text-[10px] tabular-nums text-[hsl(var(--deck-ink-muted))] sm:inline",children:[ne(a.tokensUsed),a.tokenBudget!==void 0&&`/${ne(a.tokenBudget)}`]}),e.jsxs("div",{className:"flex shrink-0 items-center",children:[o&&e.jsx(ie,{label:t("goal.action.pause"),disabled:E,onClick:()=>void w("pause",r),children:x==="pause"?e.jsx($,{className:"animate-spin"}):e.jsx(Tt,{})}),m&&e.jsx(ie,{label:t("goal.action.resume"),disabled:E,onClick:()=>void w("resume",i),children:x==="resume"?e.jsx($,{className:"animate-spin"}):e.jsx(Mt,{})}),e.jsx(ie,{label:t(v?"goal.action.edit":"goal.action.expand"),disabled:!v&&!b,onClick:v?C:()=>u(T=>!T),children:v?e.jsx(Ke,{}):e.jsx(Nt,{})}),e.jsx(ie,{label:t("goal.action.delete"),disabled:E,destructive:!0,onClick:()=>h(!0),children:e.jsx(ee,{})})]})]}),b&&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:c?e.jsxs("form",{onSubmit:R,children:[e.jsx("textarea",{id:"goal-objective",value:l,onChange:T=>p(T.target.value),onKeyDown:T=>{T.key==="Escape"&&k(!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:()=>k(!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(Ge,{className:"h-3 w-3"}),t("goal.action.cancel")]}),e.jsxs("button",{type:"submit",disabled:!l.trim()||x==="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:[x==="edit"?e.jsx($,{className:"h-3 w-3 animate-spin"}):e.jsx(ue,{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:a.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(Ft,{className:"h-3 w-3"}),ne(a.tokensUsed),a.tokenBudget!==void 0&&` / ${ne(a.tokenBudget)}`," ",t("goal.metrics.tokens")]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Bt,{className:"h-3 w-3"}),Ts(a.timeUsedSeconds)]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(le,{className:"h-3 w-3"}),a.continuationCount===1?t("goal.metrics.continuationOne",{n:a.continuationCount}):t("goal.metrics.continuationMany",{n:a.continuationCount})]})]}),a.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(le,{className:"h-3 w-3"}),s==="zh"?"恢复提示":"Recovery nudge"," ",a.prematureStop.consecutiveCount," ·"," ",a.prematureStop.pattern.replaceAll("_"," ")]}),a.completionVerification&&e.jsxs("div",{"data-goal-verification":a.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:["#",a.completionVerification.attempt," ·"," ",a.completionVerification.status.toUpperCase()," ·"," ",((V=a.completionVerification.verifierSessionId)==null?void 0:V.slice(0,12))??"-",a.verificationStall?s==="zh"?` · 重复 ${a.verificationStall.consecutiveCount}/3`:` · repeat ${a.verificationStall.consecutiveCount}/3`:""]}),a.completionVerification.summary&&e.jsx("p",{className:"mt-1 line-clamp-3 whitespace-pre-wrap opacity-80",children:a.completionVerification.summary}),a.completionVerification.evidenceSha256&&e.jsxs("p",{className:"mt-1 font-mono text-[10px] opacity-60",children:["sha256:",a.completionVerification.evidenceSha256.slice(0,12)]})]}),a.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:a.statusReason})]})})]})}),e.jsx(Le,{open:S,onOpenChange:h,children:e.jsxs(Ve,{className:"max-w-[400px] border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsx(Oe,{children:t("goal.dialog.title")}),e.jsx(Ue,{children:t("goal.dialog.description")}),e.jsxs(He,{className:"mt-2",children:[e.jsx("button",{type:"button",onClick:()=>h(!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:x==="delete",onClick:()=>void O(),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:[x==="delete"&&e.jsx($,{className:"w-3.5 h-3.5 animate-spin"}),t("goal.action.delete")]})]})]})})]})}function ie({label:t,children:s,disabled:a,destructive:r,onClick:i}){return e.jsxs(ke,{children:[e.jsx(je,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":t,disabled:a,onClick:i,className:M("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:s})}),e.jsx(de,{side:"top",className:"text-[10px]",children:t})]})}function As(){const t=D(),s=y(u=>u.currentSessionRef),a=y(u=>u.sessions),r=y(u=>u.messages),i=f.useMemo(()=>{var c,k,l,p,x;const u=s?(c=dt(a,s))==null?void 0:c.pendingInteraction:void 0;if(u)return u.type;for(let j=r.length-1;j>=0;j-=1){const S=(k=r[j])==null?void 0:k.agentContent;if(((l=S==null?void 0:S.confirmation)==null?void 0:l.status)==="pending")return"permission";if(((p=S==null?void 0:S.question)==null?void 0:p.status)==="pending")return"question";if(((x=S==null?void 0:S.elicitation)==null?void 0:x.status)==="pending")return"elicitation"}return null},[s,r,a]);if(!i)return null;const n=()=>{const u=document.querySelector(`[data-pending-interaction="${i}"]`);u==null||u.scrollIntoView({block:"center",behavior:"smooth"}),window.setTimeout(()=>u==null?void 0:u.focus(),250)},d=i==="question",b=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(ye,{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(d?"interaction.bar.questionTitle":b?"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(d?"interaction.bar.questionHint":b?"interaction.bar.elicitationHint":"interaction.bar.permissionHint")})]}),e.jsxs("button",{type:"button",onClick:n,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(We,{className:"h-3 w-3"}),t("interaction.bar.review")]})]})}const Rs=f.lazy(()=>qe(()=>import("./MarkdownRenderer-CxcqGo57.js").then(t=>t.M),__vite__mapDeps([0,1,2,3,4,5])).then(t=>({default:t.MarkdownRenderer})));function Fs(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(1)}s`}function $s(){const t=D(),s=y(r=>r.sideConversation),a=y(r=>r.dismissSideConversation);return s?e.jsx("section",{"aria-label":t("chat.side.title"),"data-blade-side-conversation":!0,"data-status":s.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(Dt,{"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")}),s.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(At,{"aria-hidden":!0,className:"h-3 w-3"}),Fs(s.durationMs)]})]}),e.jsx("p",{className:"mt-0.5 break-words font-mono text-[11px] leading-4 text-[hsl(var(--deck-ink-muted))]",children:s.question})]}),e.jsx("button",{type:"button",onClick:a,"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(Ge,{"aria-hidden":!0,className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{"aria-live":"polite","aria-busy":s.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:[s.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")]}),s.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(ye,{"aria-hidden":!0,className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"break-words",children:s.error??t("chat.side.failed")})]}),s.status==="completed"&&s.response&&e.jsx(f.Suspense,{fallback:e.jsx("div",{className:"whitespace-pre-wrap break-words font-mono text-[12px] leading-5 text-[hsl(var(--deck-ink))]",children:s.response}),children:e.jsx(Rs,{content:s.response,className:"text-[12px] leading-5 [&_h1]:text-[14px] [&_h2]:text-[13px] [&_h3]:text-[12px]"})})]})]})}):null}function be(t){return Number.isFinite(t)?Math.max(0,t):0}function Ds(t){const s=be(t.totalInputTokens),a=be(t.cacheReadTokens),r=be(t.cacheWriteTokens),i=Math.min(a,s),n=Math.min(r,Math.max(0,s-i)),d=Math.max(0,s-i-n),b=s>0&&(a>0||r>0);return{totalInputTokens:s,cacheReadTokens:i,cacheWriteTokens:n,uncachedInputTokens:d,...b?{hitRate:i/s}:{}}}function Is(t){return t===void 0||!Number.isFinite(t)?"—":`${Math.round(Math.max(0,Math.min(1,t))*100)}%`}const Bs={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:""},_s={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"},K=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString(),oe=t=>{const s=Math.max(0,Math.ceil(t/1e3)),a=Math.floor(s/60),r=s%60;return a>0?`${a}m ${r}s`:`${r}s`};function et(){const t=D(),s=y(N=>N.tokenUsage),a=y(N=>N.isStreaming),r=y(N=>N.agentPhase),i=y(N=>N.providerAdmission),n=y(N=>N.providerCircuit),d=y(N=>N.providerRetry),b=y(N=>N.providerStall),u=y(N=>N.actionStationarity),c=Bs[r]??"",k=(d==null?void 0:d.delayMs)!==void 0?` · ${Math.max(0,Math.ceil(d.delayMs/1e3))}s`:"",l=u?`${t(u.phase==="halted"?"status.phase.actionStationarityStopped":"status.phase.actionStationarityRecovering")} · ${u.toolName} · ${u.runLength}/${u.haltThreshold}`:n?n.phase==="probe"?"Provider · Recovery probe":`Provider · Circuit open${n.retryAfterMs!==void 0?` · probe in ${oe(n.retryAfterMs)}`:""}${n.recoveryRemainingMs!==void 0?` · ${oe(n.recoveryRemainingMs)}`:""}`:i?`Provider · Capacity queue ${i.queuePosition}/${Math.max(i.queueDepth,i.queuePosition)} · ${i.scope} · ${oe(i.waitMs)}`:d?d.mode==="bounded_foreground"?`Provider · Bounded recovery · ${d.attempt}/${d.maxRetries} · ${oe(d.recoveryRemainingMs??0)}`:`Provider · ${t("chat.error.action.retryingTask")} · ${d.attempt}/${d.maxRetries}${k}`:b?`${t("status.phase.providerStall")} · ${Math.ceil(b.durationMs/1e3)}s / ${Math.ceil(b.timeoutMs/1e3)}s`:c?t(c):"",p=s.maxContextTokens>0?Math.round(s.totalTokens/s.maxContextTokens*100):0,x=Ds(s),j=Is(x.hitRate),S=Math.min(p,100),h=p>95?"danger":p>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:M("text-[12px] font-medium",h==="safe"&&"text-[hsl(var(--deck-ink))]",h==="warn"&&"text-amber-600 dark:text-amber-400",h==="danger"&&"text-red-600 dark:text-red-400"),children:K(s.totalTokens)}),e.jsxs("span",{className:"text-[hsl(var(--deck-ink-faint))]",children:["/ ",K(s.maxContextTokens)]})]}),s.isDefaultMaxTokens&&e.jsx(ge,{children:e.jsxs(ke,{children:[e.jsx(je,{asChild:!0,children:e.jsx($t,{className:"h-3 w-3 cursor-help text-[hsl(var(--deck-ink-faint))]"})}),e.jsx(de,{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:M("absolute inset-y-0 left-0 transition-[width] duration-300",h==="safe"&&"bg-[hsl(var(--deck-accent))]",h==="warn"&&"bg-amber-500",h==="danger"&&"bg-red-500"),style:{width:`${S}%`}}),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:M("w-10 text-right tabular-nums text-[hsl(var(--deck-ink-faint))]",h==="warn"&&"text-amber-600 dark:text-amber-400",h==="danger"&&"text-red-600 dark:text-red-400"),children:[p,"%"]})]}),e.jsx(ge,{children:e.jsxs(ke,{children:[e.jsx(je,{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")} ${j}`,children:[e.jsx("span",{className:"deck-eyebrow text-[hsl(var(--deck-ink-faint))]",children:t("status.cache")}),e.jsx("span",{className:M("tabular-nums",x.hitRate===void 0?"text-[hsl(var(--deck-ink-faint))]":"font-medium text-[hsl(var(--deck-accent))]"),children:j})]})}),e.jsx(de,{side:"top",className:"max-w-[280px]",children:x.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:K(x.cacheReadTokens),write:K(x.cacheWriteTokens),uncached:K(x.uncachedInputTokens)})}),s.cacheBreak&&e.jsx("p",{className:"text-[hsl(var(--deck-accent))]",children:t("status.cacheBreak",{reason:t(_s[s.cacheBreak.reason]??"status.cacheBreak.server"),previous:K(s.cacheBreak.previousCacheReadTokens),current:K(s.cacheBreak.cacheReadTokens)})})]})})]})}),e.jsx("div",{className:"flex-1"}),a&&l&&e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("span",{className:"deck-pulse-dot"}),e.jsx("span",{className:"text-[hsl(var(--deck-accent))]",children:l})]})]})}function Ps(){const{locale:t}=ze(),s=ut(o=>o.agentTeamsEnabled),a=y(o=>o.teams),r=y(o=>o.currentSessionRef),i=y(o=>o.loadTeams),[n,d]=f.useState({}),[b,u]=f.useState({}),[c,k]=f.useState({}),[l,p]=f.useState(null),[x,j]=f.useState(null),[S,h]=f.useState(null);if(f.useEffect(()=>{i(r??void 0)},[s,r,i]),!s||!r||a.length===0)return null;const N=async o=>{var E;const m=(E=c[o])==null?void 0:E.trim();if(!(!m||l)){p(o),h(null);try{await Ee.sendMessage(r,o,b[o]??"*",m),k(w=>({...w,[o]:""})),await i(r)}catch(w){h(w instanceof Error?w.message:F(t,"actionFailed"))}finally{p(null)}}},v=async o=>{if(!x){j(o),h(null);try{await Ee.delete(r,o),await i(r)}catch(m){h(m instanceof Error?m.message:F(t,"actionFailed"))}finally{j(null)}}};return e.jsxs("section",{"aria-label":F(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:[S&&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:S}),a.filter(o=>o.status!=="deleted").map(o=>{var w;const m=n[o.name]??o.status==="running",E=o.tasks.filter(C=>C.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:()=>d(C=>({...C,[o.name]:!m})),"aria-label":m?F(t,"collapse"):F(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:m?e.jsx(te,{className:"h-4 w-4"}):e.jsx(se,{className:"h-4 w-4"})}),e.jsx(_t,{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:o.name}),e.jsxs("span",{className:"font-mono text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:[o.status," · ",o.members.length-1," ",F(t,"members")," · ",E,"/",o.tasks.length," ",F(t,"tasks")]})]}),o.description&&e.jsx("p",{className:"truncate font-mono text-[10px] text-[hsl(var(--deck-ink-muted))]",children:o.description})]}),e.jsx("button",{type:"button",onClick:()=>void v(o.name),disabled:x===o.name,"aria-label":F(t,"delete"),title:F(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(ee,{className:"h-3.5 w-3.5"})})]}),m&&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:F(t,"members")}),o.members.map(C=>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":C.status,className:`h-1.5 w-1.5 shrink-0 rounded-full ${C.status==="running"?"bg-emerald-500":C.status==="completed"||C.status==="leader"?"bg-sky-500":C.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:C.name}),e.jsx("span",{className:"font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:C.subagentType}),C.worktreePath&&e.jsx(_e,{className:"h-3 w-3 text-[hsl(var(--deck-ink-faint))]","aria-label":F(t,"worktree")})]},C.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:F(t,"tasks")}),o.tasks.length===0?e.jsx("p",{className:"font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:F(t,"noTasks")}):o.tasks.map(C=>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:["#",C.id]}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10.5px] text-[hsl(var(--deck-ink))]",children:C.subject}),e.jsx("span",{className:"font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:C.status})]},C.id))]})]}),o.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":F(t,"recipient"),value:b[o.name]??"*",onChange:C=>u(R=>({...R,[o.name]:C.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:F(t,"broadcast")}),o.members.filter(C=>C.status!=="leader").map(C=>e.jsx("option",{value:C.name,children:C.name},C.id))]}),e.jsx("input",{value:c[o.name]??"",onChange:C=>k(R=>({...R,[o.name]:C.target.value})),onKeyDown:C=>{C.key==="Enter"&&N(o.name)},placeholder:F(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 N(o.name),disabled:!((w=c[o.name])!=null&&w.trim())||l===o.name,"aria-label":F(t,"send"),title:F(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(Pe,{className:"h-3.5 w-3.5"})})]})]})]},o.name)})]})}function Ls(t){const s=[...t].reverse().find(i=>i.role==="user");if(!s)return null;if(typeof s.content=="string")return{content:s.content,attachments:[]};const a=s.content.filter(i=>i.type==="text").map(i=>i.text).join(`
|
|
58
|
+
`),r=s.content.filter(i=>i.type==="image_url").map((i,n)=>{var b;const d=((b=i.image_url.url.match(/^data:([^;,]+)[;,]/))==null?void 0:b[1])??"application/octet-stream";return{id:`recovery-${s.id}-${n}`,name:`attachment-${n+1}`,mimeType:d,dataUrl:i.image_url.url}});return{content:a,attachments:r}}function Vs({messages:t,isLoading:s,isStreaming:a,isStopping:r,errorMessage:i}){const n=D(),[d,b]=f.useState(!1),u=n(i?"status.phase.error":r?"chat.input.action.stopping":a?"status.phase.running":"preview.files.status.ready");return e.jsxs("details",{"data-preview-status-disclosure":!0,open:d,onToggle:c=>b(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:[a&&e.jsx("span",{className:"deck-pulse-dot"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:u}),e.jsx(se,{className:"h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-90"})]}),d&&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:[i&&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:i}),e.jsx(Ze,{messages:t,isLoading:s}),e.jsx(et,{})]})]})}function Os(){var q;const t=D(),s=y(g=>g.messages),a=y(g=>g.currentSessionRef),r=y(g=>g.isStreaming),i=y(g=>g.isStopping),n=y(g=>g.sessionEventConnectionState),d=y(g=>g.pendingSteeringCount),b=y(g=>g.pendingInputDelivery),u=y(g=>g.recoveredSteeringCount),c=y(g=>g.isLoading),k=y(g=>g.error),l=y(g=>g.errorContext),p=y(g=>g.sessions),x=y(g=>g.sendMessage),j=y(g=>g.abortSession),S=y(g=>g.retryTask),h=y(g=>g.retryingTaskKeys),N=we(g=>g.openSettings),v=y(g=>g.reconnectSessionEvents),o=y(g=>g.clearError),[m,E]=f.useState(null),w=a?p.find(g=>g.sessionId===a.sessionId&&g.projectPath===a.projectPath):void 0,C=!!k&&((l==null?void 0:l.kind)==="navigation"||!(l!=null&&l.sessionRef)||Be(l.sessionRef,a)),R=(l==null?void 0:l.failureCode)??((q=w==null?void 0:w.taskFailure)==null?void 0:q.code),O=(l==null?void 0:l.kind)==="execution"&&R?t(kt(R)):k==="queue_full"?t("chat.error.queueFull"):k==="turn_unavailable"||k==="turn_active"?t("chat.error.turnChanged"):k,U=n==="connecting"||n==="reconnecting",I=r&&n!=="connected",L=a?`session:${Z(a)}`:"session:temporary",V=f.useMemo(()=>Ls(s),[s]),T=a?Z(a):"temporary-session",P=!!(a&&(w!=null&&w.taskRetryAvailable)&&(!R||jt(R)))&&((l==null?void 0:l.kind)==="execution"||(l==null?void 0:l.kind)==="task_action"),J=(l==null?void 0:l.kind)==="execution"&&(R==="authentication"||R==="permission"||R==="model_unavailable"),W=a?h.includes(Z(a)):!1;f.useEffect(()=>{E(null)},[T]);const ae=async g=>x({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(_=>({type:"image",content:_.dataUrl,mimeType:_.mimeType,name:_.name}))}),re=()=>j(),A=async()=>{if(J){o(),N("models");return}if(P&&a){o(),await S(a).catch(()=>{});return}if((l==null?void 0:l.kind)==="execution"&&V){E({...V,revision:Date.now()}),o();return}o(),requestAnimationFrame(()=>pt())},H=P?t(W?"chat.error.action.retryingTask":"chat.error.action.retryTask"):J?t("chat.error.action.checkModels"):(l==null?void 0:l.kind)==="execution"&&V?t("chat.error.action.editResend"):(l==null?void 0:l.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:[C&&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(ye,{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((l==null?void 0:l.kind)==="submission"?"chat.error.title.submission":(l==null?void 0:l.kind)==="execution"?"chat.error.title.execution":(l==null?void 0:l.kind)==="navigation"?"chat.error.title.navigation":"chat.error.title.generic")})," ",O]}),H&&e.jsxs("button",{type:"button",onClick:()=>void A(),disabled:W,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:[P?W?e.jsx($,{className:"h-3 w-3 animate-spin"}):e.jsx(le,{className:"h-3 w-3"}):e.jsx(Ke,{className:"h-3 w-3"}),H]}),e.jsx("button",{type:"button",onClick:o,"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:"✕"})]}),(U||n==="offline")&&e.jsxs("div",{role:n==="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:[U?e.jsx($,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(mt,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1",children:t(U?"chat.connection.reconnecting":"chat.connection.offline")}),n==="offline"&&e.jsxs("button",{type:"button",onClick:()=>void v().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(ht,{className:"h-3 w-3"}),t("chat.connection.retry")]})]}),e.jsx(Pt,{}),e.jsx(Ze,{messages:s,isLoading:c},a?Z(a):"temporary-session"),e.jsx(Ps,{}),e.jsx($s,{})]}),e.jsxs("div",{"data-chat-composer-dock":!0,className:"contents",children:[e.jsx(Vs,{messages:s,isLoading:c,isStreaming:r,isStopping:i,errorMessage:C?O:null},T),e.jsx(As,{}),e.jsx(Ms,{}),e.jsx(xt,{draftKey:L,draft:m==null?void 0:m.content,draftAttachments:m==null?void 0:m.attachments,draftRevision:m==null?void 0:m.revision,onSend:ae,onAbort:re,disabled:c||I,isStreaming:r,isStopping:i,pendingSteeringCount:d,pendingInputDelivery:b,recoveredSteeringCount:u,workspacePath:a==null?void 0:a.projectPath},L),e.jsx("div",{"data-chat-primary-status":!0,className:"contents",children:e.jsx(et,{})})]})]})}const Zs=Object.freeze(Object.defineProperty({__proto__:null,ChatView:Os},Symbol.toStringTag,{value:"Module"}));export{Je as C,Zs as a};
|
package/dist/web/assets/{CodeBlockHighlighter-CjP3le5E.js → CodeBlockHighlighter-BzmHeWKU.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{R as I,j as Ke}from"./vendor-react-DofNRwfy.js";import{f as Ve,p as Se,a as xe,n as Ae,h as Je,s as Qe,d as Ne}from"./MarkdownRenderer-CxcqGo57.js";import"./index-FdbcPJSj.js";import"./vendor-radix-Bc1_Q9tz.js";import"./session-events-Ci1823tS.js";import"./ChatView-CpKiglLV.js";import"./external-link-BTHyQJWk.js";import"./chevrons-up-down-DuC8PppK.js";import"./pause-qlDcCjBJ.js";import"./play-BGPTTFWa.js";import"./clock-3-lYrt_Amt.js";import"./team-QZ9byb3E.js";import"./teamService-Bk8B4hZp.js";function Pe(e,t){if(e==null)return{};var n={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(t.indexOf(a)!==-1)continue;n[a]=e[a]}return n}function et(e,t){if(e==null)return{};var n,a,o=Pe(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a<r.length;a++)n=r[a],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function se(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,a=Array(t);n<t;n++)a[n]=e[n];return a}function tt(e){if(Array.isArray(e))return se(e)}function nt(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function at(e,t){if(e){if(typeof e=="string")return se(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?se(e,t):void 0}}function ot(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
2
2
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function le(e){return tt(e)||nt(e)||at(e)||ot()}function Z(e){"@babel/helpers - typeof";return Z=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Z(e)}function rt(e,t){if(Z(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var a=n.call(e,t);if(Z(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function it(e){var t=rt(e,"string");return Z(t)=="symbol"?t:t+""}function Te(e,t,n){return(t=it(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ce(){return ce=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},ce.apply(null,arguments)}function Ee(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,a)}return n}function H(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Ee(Object(n),!0).forEach(function(a){Te(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ee(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function st(e){var t=e.length;if(t===0||t===1)return e;if(t===2)return[e[0],e[1],"".concat(e[0],".").concat(e[1]),"".concat(e[1],".").concat(e[0])];if(t===3)return[e[0],e[1],e[2],"".concat(e[0],".").concat(e[1]),"".concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[0]),"".concat(e[1],".").concat(e[2]),"".concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[1]),"".concat(e[0],".").concat(e[1],".").concat(e[2]),"".concat(e[0],".").concat(e[2],".").concat(e[1]),"".concat(e[1],".").concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[0],".").concat(e[1]),"".concat(e[2],".").concat(e[1],".").concat(e[0])];if(t>=4)return[e[0],e[1],e[2],e[3],"".concat(e[0],".").concat(e[1]),"".concat(e[0],".").concat(e[2]),"".concat(e[0],".").concat(e[3]),"".concat(e[1],".").concat(e[0]),"".concat(e[1],".").concat(e[2]),"".concat(e[1],".").concat(e[3]),"".concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[1]),"".concat(e[2],".").concat(e[3]),"".concat(e[3],".").concat(e[0]),"".concat(e[3],".").concat(e[1]),"".concat(e[3],".").concat(e[2]),"".concat(e[0],".").concat(e[1],".").concat(e[2]),"".concat(e[0],".").concat(e[1],".").concat(e[3]),"".concat(e[0],".").concat(e[2],".").concat(e[1]),"".concat(e[0],".").concat(e[2],".").concat(e[3]),"".concat(e[0],".").concat(e[3],".").concat(e[1]),"".concat(e[0],".").concat(e[3],".").concat(e[2]),"".concat(e[1],".").concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[0],".").concat(e[3]),"".concat(e[1],".").concat(e[2],".").concat(e[0]),"".concat(e[1],".").concat(e[2],".").concat(e[3]),"".concat(e[1],".").concat(e[3],".").concat(e[0]),"".concat(e[1],".").concat(e[3],".").concat(e[2]),"".concat(e[2],".").concat(e[0],".").concat(e[1]),"".concat(e[2],".").concat(e[0],".").concat(e[3]),"".concat(e[2],".").concat(e[1],".").concat(e[0]),"".concat(e[2],".").concat(e[1],".").concat(e[3]),"".concat(e[2],".").concat(e[3],".").concat(e[0]),"".concat(e[2],".").concat(e[3],".").concat(e[1]),"".concat(e[3],".").concat(e[0],".").concat(e[1]),"".concat(e[3],".").concat(e[0],".").concat(e[2]),"".concat(e[3],".").concat(e[1],".").concat(e[0]),"".concat(e[3],".").concat(e[1],".").concat(e[2]),"".concat(e[3],".").concat(e[2],".").concat(e[0]),"".concat(e[3],".").concat(e[2],".").concat(e[1]),"".concat(e[0],".").concat(e[1],".").concat(e[2],".").concat(e[3]),"".concat(e[0],".").concat(e[1],".").concat(e[3],".").concat(e[2]),"".concat(e[0],".").concat(e[2],".").concat(e[1],".").concat(e[3]),"".concat(e[0],".").concat(e[2],".").concat(e[3],".").concat(e[1]),"".concat(e[0],".").concat(e[3],".").concat(e[1],".").concat(e[2]),"".concat(e[0],".").concat(e[3],".").concat(e[2],".").concat(e[1]),"".concat(e[1],".").concat(e[0],".").concat(e[2],".").concat(e[3]),"".concat(e[1],".").concat(e[0],".").concat(e[3],".").concat(e[2]),"".concat(e[1],".").concat(e[2],".").concat(e[0],".").concat(e[3]),"".concat(e[1],".").concat(e[2],".").concat(e[3],".").concat(e[0]),"".concat(e[1],".").concat(e[3],".").concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[3],".").concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[0],".").concat(e[1],".").concat(e[3]),"".concat(e[2],".").concat(e[0],".").concat(e[3],".").concat(e[1]),"".concat(e[2],".").concat(e[1],".").concat(e[0],".").concat(e[3]),"".concat(e[2],".").concat(e[1],".").concat(e[3],".").concat(e[0]),"".concat(e[2],".").concat(e[3],".").concat(e[0],".").concat(e[1]),"".concat(e[2],".").concat(e[3],".").concat(e[1],".").concat(e[0]),"".concat(e[3],".").concat(e[0],".").concat(e[1],".").concat(e[2]),"".concat(e[3],".").concat(e[0],".").concat(e[2],".").concat(e[1]),"".concat(e[3],".").concat(e[1],".").concat(e[0],".").concat(e[2]),"".concat(e[3],".").concat(e[1],".").concat(e[2],".").concat(e[0]),"".concat(e[3],".").concat(e[2],".").concat(e[0],".").concat(e[1]),"".concat(e[3],".").concat(e[2],".").concat(e[1],".").concat(e[0])]}var ie={};function lt(e){if(e.length===0||e.length===1)return e;var t=e.join(".");return ie[t]||(ie[t]=st(e)),ie[t]}function ct(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,a=e.filter(function(r){return r!=="token"}),o=lt(a);return o.reduce(function(r,s){return H(H({},r),n[s])},t)}function Fe(e){return e.join(" ")}function ut(e,t){var n=0;return function(a){return n+=1,a.map(function(o,r){return Ie({node:o,stylesheet:e,useInlineStyles:t,key:"code-segment-".concat(n,"-").concat(r)})})}}function Ie(e){var t=e.node,n=e.stylesheet,a=e.style,o=a===void 0?{}:a,r=e.useInlineStyles,s=e.key,i=t.properties,c=t.type,l=t.tagName,u=t.value;if(c==="text")return u;if(l){var g=ut(n,r),d;if(!r)d=H(H({},i),{},{className:Fe(i.className)});else{var p=Object.keys(n).reduce(function(b,w){return w.split(".").forEach(function(N){b.includes(N)||b.push(N)}),b},[]),f=i.className&&i.className.includes("token")?["token"]:[],v=i.className&&f.concat(i.className.filter(function(b){return!p.includes(b)}));d=H(H({},i),{},{className:Fe(v)||void 0,style:ct(i.className,Object.assign({},i.style,o),n)})}var y=g(t.children);return I.createElement(l,ce({key:s},d),y)}}const dt=function(e,t){var n=e.listLanguages();return n.indexOf(t)!==-1};var gt=["language","children","style","customStyle","codeTagProps","useInlineStyles","showLineNumbers","showInlineLineNumbers","startingLineNumber","lineNumberContainerStyle","lineNumberStyle","wrapLines","wrapLongLines","lineProps","renderer","PreTag","CodeTag","code","astGenerator"];function $e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,a)}return n}function R(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?$e(Object(n),!0).forEach(function(a){Te(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):$e(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}var pt=/\n/g;function ft(e){return e.match(pt)}function ht(e){var t=e.lines,n=e.startingLineNumber,a=e.style;return t.map(function(o,r){var s=r+n;return I.createElement("span",{key:"line-".concat(r),className:"react-syntax-highlighter-line-number",style:typeof a=="function"?a(s):a},"".concat(s,`
|
|
3
3
|
`))})}function bt(e){var t=e.codeString,n=e.codeStyle,a=e.containerStyle,o=a===void 0?{float:"left",paddingRight:"10px"}:a,r=e.numberStyle,s=r===void 0?{}:r,i=e.startingLineNumber;return I.createElement("code",{style:Object.assign({},n,o)},ht({lines:t.replace(/\n$/,"").split(`
|
|
4
4
|
`),style:s,startingLineNumber:i}))}function mt(e){return"".concat(e.toString().length,".25em")}function Re(e,t){return{type:"element",tagName:"span",properties:{key:"line-number--".concat(e),className:["comment","linenumber","react-syntax-highlighter-line-number"],style:t},children:[{type:"text",value:e}]}}function De(e,t,n){var a={display:"inline-block",minWidth:mt(n),paddingRight:"1em",textAlign:"right",userSelect:"none"},o=typeof e=="function"?e(t):e,r=R(R({},a),o);return r}function J(e){var t=e.children,n=e.lineNumber,a=e.lineNumberStyle,o=e.largestLineNumber,r=e.showInlineLineNumbers,s=e.lineProps,i=s===void 0?{}:s,c=e.className,l=c===void 0?[]:c,u=e.showLineNumbers,g=e.wrapLongLines,d=e.wrapLines,p=d===void 0?!1:d,f=p?R({},typeof i=="function"?i(n):i):{};if(f.className=f.className?[].concat(le(f.className.trim().split(/\s+/)),le(l)):l,n&&r){var v=De(a,n,o);t.unshift(Re(n,v))}return g&u&&(f.style=R({display:"flex"},f.style)),{type:"element",tagName:"span",properties:f,children:t}}function ze(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];e.length===void 0&&(e=[e]);for(var a=0;a<e.length;a++){var o=e[a];if(o.type==="text")n.push(J({children:[o],className:le(new Set(t))}));else if(o.children){var r,s=t.concat(((r=o.properties)===null||r===void 0?void 0:r.className)||[]);ze(o.children,s).forEach(function(i){return n.push(i)})}}return n}function yt(e,t,n,a,o,r,s,i,c){var l,u=ze(e.value),g=[],d=-1,p=0;function f(S,k){var x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return J({children:S,lineNumber:k,lineNumberStyle:i,largestLineNumber:s,showInlineLineNumbers:o,lineProps:n,className:x,showLineNumbers:a,wrapLongLines:c,wrapLines:t})}function v(S,k){if(a&&k&&o){var x=De(i,k,s);S.unshift(Re(k,x))}return S}function y(S,k){var x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return t||x.length>0?f(S,k,x):v(S,k)}for(var b=function(){var k=u[p],x=k.children[0].value,E=ft(x);if(E){var j=x.split(`
|