blade-code 0.10.91 → 0.10.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/dist/blade.js +2 -2
  2. package/dist/{chunk-6wbhsgqd.js → chunk-0ayxntzc.js} +2 -2
  3. package/dist/{chunk-y7dtdwqx.js → chunk-0eqk29xr.js} +2 -2
  4. package/dist/{chunk-xrpmfq5d.js → chunk-1tjm9zdt.js} +1 -1
  5. package/dist/chunk-1ydbdbfj.js +1 -0
  6. package/dist/chunk-27y5dt0f.js +10 -0
  7. package/dist/chunk-2rpcwgr9.js +1 -0
  8. package/dist/chunk-30pq99z7.js +1 -0
  9. package/dist/{chunk-vxa67kca.js → chunk-339r521e.js} +3 -3
  10. package/dist/{chunk-j0rkfsdy.js → chunk-36dhm0fm.js} +2 -2
  11. package/dist/{chunk-47xjtzq5.js → chunk-3qtmrh3z.js} +1 -1
  12. package/dist/{chunk-tc1001nx.js → chunk-4cvmfne8.js} +1 -1
  13. package/dist/{chunk-r2nzt9jm.js → chunk-4jbpvete.js} +2 -2
  14. package/dist/chunk-54qgtz5s.js +1 -0
  15. package/dist/{chunk-7mj87nb9.js → chunk-602decf8.js} +3 -3
  16. package/dist/{chunk-ckqz2btx.js → chunk-74yge4ka.js} +1 -1
  17. package/dist/chunk-78agjkm5.js +1 -0
  18. package/dist/{chunk-45a1tsk1.js → chunk-7dqh8bqm.js} +1 -1
  19. package/dist/{chunk-xxk5d2v6.js → chunk-7k5v52ct.js} +1 -1
  20. package/dist/{chunk-yr16h4mj.js → chunk-7tda8v4p.js} +2 -2
  21. package/dist/{chunk-f7p7tzx2.js → chunk-8eh0vp98.js} +2 -2
  22. package/dist/{chunk-sa259vbs.js → chunk-8hry1mq6.js} +2 -2
  23. package/dist/{chunk-rj49h1x1.js → chunk-9318pj5k.js} +1 -1
  24. package/dist/{chunk-rm8w0qg7.js → chunk-am66822r.js} +1 -1
  25. package/dist/{chunk-j6tp0ny9.js → chunk-cadgtmrr.js} +2 -2
  26. package/dist/{chunk-qn8jacbk.js → chunk-cx7g79et.js} +1 -1
  27. package/dist/chunk-d45gd36e.js +1 -0
  28. package/dist/chunk-d83bfr0b.js +2 -0
  29. package/dist/{chunk-8mee32xq.js → chunk-dd99sgf8.js} +1 -1
  30. package/dist/{chunk-x4zy3sez.js → chunk-dj0jfyms.js} +288 -288
  31. package/dist/{chunk-7r2p609r.js → chunk-dq5ry3nq.js} +1 -1
  32. package/dist/{chunk-27h9k89q.js → chunk-dwttn5xg.js} +1 -1
  33. package/dist/{chunk-mh92e9gy.js → chunk-epmxrw4f.js} +1 -1
  34. package/dist/{chunk-e6gfpm6b.js → chunk-fthm9y4q.js} +1 -1
  35. package/dist/{chunk-xhhgpbzs.js → chunk-gbsxnvgg.js} +1 -1
  36. package/dist/chunk-gf2vdsx3.js +1 -0
  37. package/dist/{chunk-hkh2nsam.js → chunk-h4j0nve8.js} +2 -2
  38. package/dist/{chunk-hjkz6k6v.js → chunk-h6fcb6ky.js} +1 -1
  39. package/dist/{chunk-33g68zy1.js → chunk-hrfh7wck.js} +1 -1
  40. package/dist/chunk-jgd76jdj.js +1 -0
  41. package/dist/chunk-jqky08cw.js +1 -0
  42. package/dist/{chunk-c0ecz59a.js → chunk-k8h7k11c.js} +1 -1
  43. package/dist/{chunk-s8hdg5y9.js → chunk-kp40bxpa.js} +2 -2
  44. package/dist/{chunk-50zkdamf.js → chunk-myzmv0ns.js} +2 -2
  45. package/dist/{chunk-7a8j14gg.js → chunk-n4gtzx4x.js} +1 -1
  46. package/dist/{chunk-1mb2y0e0.js → chunk-na1cney5.js} +2 -2
  47. package/dist/{chunk-m5hnyxf3.js → chunk-nh45xp7r.js} +1 -1
  48. package/dist/{chunk-11ajd6hj.js → chunk-nje776xv.js} +2 -2
  49. package/dist/{chunk-k38mgpj8.js → chunk-p8hgymk2.js} +1 -1
  50. package/dist/{chunk-1g5s5vf3.js → chunk-qa4efys0.js} +1 -1
  51. package/dist/{chunk-ff38sxd0.js → chunk-qxm67agj.js} +2 -2
  52. package/dist/{chunk-cwtj154q.js → chunk-qy68f2g6.js} +1 -1
  53. package/dist/{chunk-q15sm6vj.js → chunk-rsh4rw9k.js} +1 -1
  54. package/dist/chunk-rtdvy14c.js +1 -0
  55. package/dist/{chunk-vyk5nxsz.js → chunk-rxbxvq67.js} +2 -2
  56. package/dist/{chunk-bvp5wpz8.js → chunk-rzja9zza.js} +2 -2
  57. package/dist/{chunk-ne5w9ds8.js → chunk-t48zm299.js} +1 -1
  58. package/dist/{chunk-61sg8p2c.js → chunk-t5hfc8xq.js} +1 -1
  59. package/dist/{chunk-anpph83s.js → chunk-va1exak5.js} +1 -1
  60. package/dist/chunk-vy4dz3yz.js +1 -0
  61. package/dist/{chunk-4vng4fc2.js → chunk-w4e6xp05.js} +2 -2
  62. package/dist/{chunk-rxjyc6ff.js → chunk-w63dfcx5.js} +2 -2
  63. package/dist/{chunk-x079eg84.js → chunk-wbfa6xce.js} +2 -2
  64. package/dist/chunk-wm02k4gq.js +1 -0
  65. package/dist/chunk-xdvk6frk.js +1 -0
  66. package/dist/chunk-xphk45bp.js +1 -0
  67. package/dist/{chunk-7avnhnjn.js → chunk-ya5p7mx7.js} +1 -1
  68. package/dist/{chunk-d83meq4k.js → chunk-yjh47zv6.js} +1 -1
  69. package/dist/{chunk-zg73wrze.js → chunk-ysephh7s.js} +1 -1
  70. package/dist/{chunk-pxah309m.js → chunk-z24ha5jk.js} +2 -2
  71. package/dist/{chunk-ebxt5bv1.js → chunk-z5rtzcm4.js} +2 -2
  72. package/dist/chunk-z5xtgfja.js +8 -0
  73. package/dist/{chunk-q8jfwyr4.js → chunk-z6xfknxe.js} +1 -1
  74. package/dist/{chunk-3aejg2jy.js → chunk-zj4kfyer.js} +1 -1
  75. package/dist/{chunk-dm1knbf8.js → chunk-ztp2ff01.js} +2 -2
  76. package/dist/web/assets/ChatView-D-UBHYgT.js +58 -0
  77. package/dist/web/assets/{CodeBlockHighlighter-BR4c98oZ.js → CodeBlockHighlighter-CjP3le5E.js} +2 -2
  78. package/dist/web/assets/FilePreview-DRJTAYmL.js +54 -0
  79. package/dist/web/assets/KanbanBoard-CRu-0zva.js +16 -0
  80. package/dist/web/assets/{MarkdownRenderer-BVPIxk31.js → MarkdownRenderer-fbB4bMCw.js} +12 -12
  81. package/dist/web/assets/{SettingsModal-CuUrUdWR.js → SettingsModal-RAG8JMXx.js} +22 -2
  82. package/dist/web/assets/TaskSwitcher-DC-7RPBv.js +26 -0
  83. package/dist/web/assets/TerminalPanel-CCB3heKF.js +6 -0
  84. package/dist/web/assets/arrow-left-Dwndq437.js +6 -0
  85. package/dist/web/assets/calendar-clock-CNd8rd6n.js +6 -0
  86. package/dist/web/assets/chevrons-up-down-DGxAunkR.js +11 -0
  87. package/dist/web/assets/clock-3-BEqhPeh5.js +6 -0
  88. package/dist/web/assets/external-link-ClLpF7at.js +11 -0
  89. package/dist/web/assets/folder-B5LF32bS.js +11 -0
  90. package/dist/web/assets/index-BgdiwWDg.js +271 -0
  91. package/dist/web/assets/index-C8M-7zAh.css +1 -0
  92. package/dist/web/assets/pause-B39o8olb.js +6 -0
  93. package/dist/web/assets/play-Bmh7JaqQ.js +6 -0
  94. package/dist/web/assets/teamService-4Cn4uKC9.js +1 -0
  95. package/dist/web/index.html +2 -3
  96. package/package.json +1 -1
  97. package/dist/chunk-12e2yj9p.js +0 -2
  98. package/dist/chunk-1gnq2qz3.js +0 -1
  99. package/dist/chunk-3xpgkrnw.js +0 -1
  100. package/dist/chunk-7zjzykx2.js +0 -8
  101. package/dist/chunk-85s1nyaz.js +0 -1
  102. package/dist/chunk-8zvjcxze.js +0 -1
  103. package/dist/chunk-a1hvqk3r.js +0 -1
  104. package/dist/chunk-aj647rtw.js +0 -1
  105. package/dist/chunk-hj41cbd6.js +0 -1
  106. package/dist/chunk-kbgsbq7k.js +0 -1
  107. package/dist/chunk-kq9xrrhg.js +0 -1
  108. package/dist/chunk-nvakshbb.js +0 -1
  109. package/dist/chunk-qsxt9ejm.js +0 -1
  110. package/dist/chunk-s1xrzd14.js +0 -1
  111. package/dist/chunk-scdfsyfc.js +0 -10
  112. package/dist/chunk-tja1sejx.js +0 -1
  113. package/dist/chunk-vs5bmzj8.js +0 -1
  114. package/dist/web/assets/ChatView-juDcmnHV.js +0 -18
  115. package/dist/web/assets/FilePreview-DKgh-Chb.js +0 -8
  116. package/dist/web/assets/KanbanBoard-CQU0UQP8.js +0 -1
  117. package/dist/web/assets/TaskSwitcher-DB7by2ch.js +0 -1
  118. package/dist/web/assets/TerminalPanel-BN9ftZUH.js +0 -1
  119. package/dist/web/assets/index-BdnOTMNi.css +0 -1
  120. package/dist/web/assets/index-ebnhtfFC.js +0 -11
  121. package/dist/web/assets/teamService-CFKFv0qS.js +0 -1
  122. package/dist/web/assets/vendor-icons-CX5BfgqQ.js +0 -431
@@ -1,18 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownRenderer-BVPIxk31.js","assets/index-ebnhtfFC.js","assets/vendor-react-DG5dkZ_t.js","assets/vendor-radix-DXRuAJHH.js","assets/vendor-icons-CX5BfgqQ.js","assets/session-events-Bgir_Gl_.js","assets/index-BdnOTMNi.css"])))=>i.map(i=>d[i]);
2
- import{r as f,j as e}from"./vendor-react-DG5dkZ_t.js";import{u as D,a as y,b as je,s as Be,c as et,d as X,D as Ie,e as _e,f as tt,g as Pe,h as Le,i as Ve,j as M,k as z,B as be,_ as Oe,S as st,l as Ue,m as at,n as rt,C as nt,o as it}from"./index-ebnhtfFC.js";import{Q as Se,O as ot,G as He,Y as lt,L as $,z as Ke,T as Z,C as de,Z as ct,v as dt,_ as ut,B as mt,$ as qe,y as ee,n as te,R as oe,s as ht,H as xt,a0 as ze,U as pt,a1 as ft,a2 as bt,a3 as vt,P as Ge,a4 as gt,X as We,a5 as kt,a6 as jt,f as ye,a7 as yt,a8 as wt,a9 as Nt,aa as St,W as Ct,a as Et}from"./vendor-icons-CX5BfgqQ.js";import{k as Tt,g as Mt,l as At,e as Rt,t as Ft,j as $t}from"./session-events-Bgir_Gl_.js";import{j as Dt,k as Bt,l as It,m as Qe}from"./vendor-radix-DXRuAJHH.js";import{t as F}from"./team-QZ9byb3E.js";import{teamService as Ce}from"./teamService-CFKFv0qS.js";function Ee(t){return t.split("/").filter(Boolean).at(-1)||t}function _t(){const t=D(),s=y(w=>w.sessions),a=y(w=>w.currentSessionRef),r=y(w=>w.taskDeliveryActions),i=y(w=>w.deliverTask),n=je(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=et(u),p=r[X(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(Se,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate text-[hsl(var(--deck-ink))]",children:Ee(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(ot,{className:"h-3 w-3 shrink-0 text-[hsl(var(--deck-accent))]"}):e.jsx(Se,{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(He,{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(lt,{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(Ke,{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(Z,{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(de,{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(Z,{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(ct,{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(Ie,{open:d,onOpenChange:b,children:e.jsxs(_e,{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(tt,{children:[e.jsx(Pe,{children:t("artifact.discardDialog.title")}),e.jsx(Le,{className:"text-[hsl(var(--deck-ink-muted))]",children:t("artifact.discardDialog.description",{project:Ee(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(Ve,{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(Z,{className:"h-3.5 w-3.5"}),t("artifact.discardDialog.confirm")]})]})]})})]})}const Pt=new Set(["completed","stale","failed","aborted","interrupted"]),Lt={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"},Vt={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 le(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function Ot(t){const s=le(t),a=le(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 Ut(t){const s=le(t),a=le(s==null?void 0:s.target);if((s==null?void 0:s.phase)!=="completed"||typeof s.status!="string"||!Pt.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(Ot);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 Ht(t){const{path:s,lineStart:a,lineEnd:r}=t.codeLocation;return a===r?`${s}:L${a}`:`${s}:L${a}-${r}`}function Kt({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",Vt[t.status]),children:[s("chat.review.status"),": ",s(Lt[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:Ht(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 qt({elicitation:t,messageId:s}){const a=D(),r=y(v=>v.currentSessionRef),i=y(v=>v.setElicitation),[n,d]=f.useState(()=>Gt(t.details.fields??[])),[b,u]=f.useState(()=>Wt(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(ue(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 z.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",Qt(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(dt,{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(W,{onClick:N,disabled:c,primary:!0,label:a("interaction.elicitation.open"),icon:e.jsx(ut,{className:"h-3.5 w-3.5"})}),e.jsx(W,{onClick:()=>void S("decline"),disabled:c,label:a("interaction.elicitation.decline")}),e.jsx(W,{onClick:()=>void S("cancel"),disabled:c,label:a("interaction.elicitation.cancel")})]})]}):e.jsxs("div",{className:"space-y-4",children:[x.map(v=>e.jsx(zt,{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(W,{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(W,{onClick:()=>void S("decline"),disabled:c,label:a("interaction.elicitation.decline")}),e.jsx(W,{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 zt({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:Jt(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:Yt(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 W({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 Gt(t){return Object.fromEntries(t.filter(s=>!ue(s)&&s.defaultValue!==void 0).map(s=>[s.name,Array.isArray(s.defaultValue)?[...s.defaultValue]:s.defaultValue]))}function Wt(t){return Object.fromEntries(t.filter(s=>ue(s)&&s.defaultValue!==void 0).map(s=>[s.name,String(s.defaultValue)]))}function Qt(t,s,a){var i;const r={};for(const n of t){if(ue(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 Jt(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 ue(t){return t.type==="string"||t.type==="number"||t.type==="integer"}function Yt(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 Xt(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 Zt({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(mt,{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(de,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(qe,{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 es=f.lazy(()=>Oe(()=>import("./MarkdownRenderer-BVPIxk31.js").then(t=>t.M),__vite__mapDeps([0,1,2,3,4,5,6])).then(t=>({default:t.MarkdownRenderer})));function Te({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(de,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}):e.jsx(qe,{className:"h-3.5 w-3.5"})})}function ts(){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(be,{size:20,pulse:!1})})}function ss(){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 Me(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 as(t){if(typeof t=="string")return{text:Me(t),images:[]};const s=t.filter(r=>r.type==="text").map(r=>r.text).join(`
3
- `),a=t.filter(r=>r.type==="image_url").map(r=>r.image_url.url);return{text:Me(s),images:a}}function we(t){return typeof t=="string"?t:t.filter(s=>s.type==="text").map(s=>s.text).join(`
4
- `)}function rs(t){const s=t.agentContent;return s?Tt(s):we(t.content)}function Ae({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(es,{content:t,syntaxHighlight:s})})}function Ne({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 ns(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 Re=500;function Je(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 Fe(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 he(t,s){if(t.length<=s)return t;if(s<=0)return"";const a=`
5
- ... (display clipped) ...
6
- `,r=s-a.length;if(r<=0)return Fe(t,s);const i=Math.floor(r/3);return`${Je(t,i)}${a}${Fe(t,r-i)}`}function is(t){const s=t.split(`
7
- `),a=s.at(-1),r=a!=null&&a.startsWith("Output truncated")?a:void 0,i=r?s.slice(0,-1).join(`
8
- `):t,n=r?`
9
- ${r}`:"",d=Math.max(0,Re-n.length),u=i.indexOf(`
10
- stderr:
11
- `);let c;if(u>=0&&i.includes(`
12
- stdout:
13
- `)){const k=i.slice(0,u),l=i.slice(u+1),p=Math.max(0,d-1),x=Math.floor(p/2);c=`${he(k,x)}
14
- ${he(l,p-x)}`}else c=he(i,d);return{body:Je(c,d),...r?{notice:r}:{},truncated:!!r||t.length>Re}}function os({tool:t}){const[s,a]=f.useState(!1),r=ns(t.arguments),i=t.output?is(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(ee,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))] shrink-0"}):e.jsx(te,{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(Ne,{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:[`
15
- `,e.jsx("span",{"data-tool-truncation-notice":!0,children:i.notice})]})]})]})]})]})}function Ye({toolCalls:t}){return t.length===0?null:e.jsx("div",{className:"space-y-2",children:t.map(s=>e.jsx(os,{tool:s},s.toolCallId))})}function ls({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(ee,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(te,{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(Ye,{toolCalls:d})})]})}function cs({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(ee,{className:"h-4 w-4 text-[hsl(var(--deck-ink-faint))]"}):e.jsx(te,{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 ds({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 us({toolCalls:t}){const s=je(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(ht,{className:"w-3 h-3"}),i]},r)})})]})}function ms({subagent:t}){var Q,G,se,ae;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,B=h&&h.status!=="running"?h:v,L=(B==null?void 0:B.id)??t.sessionId,V=((Q=B==null?void 0:B.restartRecovery)==null?void 0:Q.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),z.getMessages({sessionId:t.sessionId,projectPath:m.projectPath}).then(H=>{var _,I;if(!A)return;const K=Rt(H),g=new Map;for(const J of K)if((I=(_=J.agentContent)==null?void 0:_.toolCalls)!=null&&I.length)for(const me of J.agentContent.toolCalls)g.has(me.toolCallId)||g.set(me.toolCallId,me);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,K=t.resumeDepth??0;return z.listSubagents(m).then(g=>{if(!A)return;o(g.find(I=>I.id===t.sessionId)??null);const _=g.filter(I=>I.id!==t.sessionId&&I.rootAgentId===H&&I.resumeDepth>K).sort((I,J)=>J.resumeDepth-I.resumeDepth||J.lastActiveAt-I.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 z.listSubagents(m)).find(I=>I.id===h.id);A&&_&&N(_)}catch{}},K=window.setInterval(()=>{H()},1e3);return()=>{A=!1,window.clearInterval(K)}},[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 z.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(Ne,{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(ee,{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(Ye,{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})}),(((G=h.result)==null?void 0:G.message)||((se=h.result)==null?void 0:se.error))&&e.jsx("div",{className:"mt-1 whitespace-pre-wrap text-[hsl(var(--deck-ink))]",children:h.result.message||h.result.error})]}),V&&((ae=B==null?void 0:B.result)==null?void 0:ae.error)&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:B.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(oe,{className:"w-3 h-3"}),s("chat.subagent.resume")]}),j&&e.jsx("div",{role:"alert",className:"text-[11px] text-red-600",children:j})]})]})]})}function hs({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 z.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 xs({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 z.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 ps({message:t}){const s=t.agentContent,a=y(j=>j.isStreaming&&j.currentAssistantMessageId===t.id);if(!s){const j=we(t.content);return j?e.jsx(Ae,{content:j}):null}const{toolCalls:r,tasks:i,confirmation:n,question:d,elicitation:b}=s,u=Mt(s),c=At(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(cs,{content:j.content})},j.id):j.type==="text"?e.jsx("div",{"data-agent-timeline-block":"text",children:e.jsx(Ae,{content:j.content,syntaxHighlight:x})},j.id):e.jsx("div",{"data-agent-timeline-block":"tool_group",children:e.jsx(ls,{toolCalls:r,toolCallIds:j.toolCallIds})},j.id)),i.length>0&&e.jsx(ds,{tasks:i}),u.map(j=>e.jsx(ms,{subagent:j},j.id)),n&&e.jsx(hs,{confirmation:n,messageId:t.id}),d&&e.jsx(xs,{question:d,messageId:t.id}),b&&e.jsx(qt,{elicitation:b,messageId:t.id}),p&&e.jsx(us,{toolCalls:r})]})}function fs({message:t,showAvatar:s=!0}){var b,u,c,k;const a=t.role==="user";if(t.role==="system"){const l=we(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:
16
- ${l.stderr}`:""].filter(Boolean).join(`
17
- `);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(Ne,{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}=as(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(Te,{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(ss,{})]})}const i=rs(t),n=Ut((c=t.metadata)==null?void 0:c.codeReview),d=Xt((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(ts,{}):e.jsx("div",{className:"w-8 shrink-0"}),e.jsxs("div",{className:"overflow-hidden flex-1 min-w-0",children:[n?e.jsx(Kt,{report:n}):d?e.jsx(Zt,{report:d}):e.jsx(ps,{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(Te,{text:i,label:"Copy response"})})]})]})}const bs=f.memo(fs);function vs(t,s,a){return Math.max(0,t+(a-s))}function gs(t,s,a){return Math.min(s,Math.max(0,t)+Math.max(0,a))}function $e(t,s){return t?t.querySelector(`[data-chat-message-id="${CSS.escape(s)}"]`):null}function ks({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=$e(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=$e(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 De=80;function js(t){return typeof t=="string"?t:Array.isArray(t)?t.filter(s=>s.type==="text").map(s=>s.text).join(" "):""}function ys(t){const s=js(t).replace(/\s+/g," ").trim();return s?s.length>De?`${s.slice(0,De-1)}…`:s:""}function ws(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=ys(r.content);i&&s.push({id:r.id,index:a,preview:i})}return s}const xe=120,pe=80,Ns=96;function Y(t){return(t==null?void 0:t.querySelector("[data-radix-scroll-area-viewport]"))??null}function Ss({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(xe),[k,l]=f.useState(!1);f.useEffect(()=>{const o=Y(r.current);if(!o||!n.current)return;const m=window.requestAnimationFrame(()=>{o.scrollTop=o.scrollHeight});return()=>window.cancelAnimationFrame(m)},[t]),f.useEffect(()=>{const o=Y(r.current);if(!o)return;i.current=o;const m=()=>{const w=o.scrollHeight-o.scrollTop-o.clientHeight<=Ns;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,xe),t.length||xe))},[t.length]);const p=Math.max(t.length-u,0),x=p,j=f.useMemo(()=>t.slice(x),[t,x]),S=f.useMemo(()=>ws(t),[t]);if(f.useLayoutEffect(()=>{var E;const o=b.current;if(!o)return;const m=Y(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=vs(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(be,{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(xt,{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(be,{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=Y(r.current);o&&(n.current=!0,l(!1),o.scrollTo({top:o.scrollHeight,behavior:"smooth"}))},N=()=>{var m;const o=Y(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=>gs(E,t.length,pe))},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(st,{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,pe),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,pe)})})}),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(bs,{message:o,showAvatar:C},o.id||`msg-${E}`)})]})}),e.jsx(ks,{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(ze,{className:"h-3.5 w-3.5 text-[hsl(var(--deck-accent))]"}),a("chat.list.jumpLatest")]})]})}const Xe=f.memo(Ss),ve=Dt,ge=Bt,ke=It,ce=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}));ce.displayName=Qe.displayName;const Cs={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 re(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)}function Es(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 Ts(){var U,B,L,V;const t=D(),{locale:s}=Ue(),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=Cs[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(ve,{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":(B=a.prematureStop)==null?void 0:B.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(pt,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500"}):e.jsx(ft,{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:[re(a.tokensUsed),a.tokenBudget!==void 0&&`/${re(a.tokenBudget)}`]}),e.jsxs("div",{className:"flex shrink-0 items-center",children:[o&&e.jsx(ne,{label:t("goal.action.pause"),disabled:E,onClick:()=>void w("pause",r),children:x==="pause"?e.jsx($,{className:"animate-spin"}):e.jsx(bt,{})}),m&&e.jsx(ne,{label:t("goal.action.resume"),disabled:E,onClick:()=>void w("resume",i),children:x==="resume"?e.jsx($,{className:"animate-spin"}):e.jsx(vt,{})}),e.jsx(ne,{label:t(v?"goal.action.edit":"goal.action.expand"),disabled:!v&&!b,onClick:v?C:()=>u(T=>!T),children:v?e.jsx(Ge,{}):e.jsx(gt,{})}),e.jsx(ne,{label:t("goal.action.delete"),disabled:E,destructive:!0,onClick:()=>h(!0),children:e.jsx(Z,{})})]})]}),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(We,{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(de,{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(kt,{className:"h-3 w-3"}),re(a.tokensUsed),a.tokenBudget!==void 0&&` / ${re(a.tokenBudget)}`," ",t("goal.metrics.tokens")]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(jt,{className:"h-3 w-3"}),Es(a.timeUsedSeconds)]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(oe,{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(oe,{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(Ie,{open:S,onOpenChange:h,children:e.jsxs(_e,{className:"max-w-[400px] border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsx(Pe,{children:t("goal.dialog.title")}),e.jsx(Le,{children:t("goal.dialog.description")}),e.jsxs(Ve,{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 ne({label:t,children:s,disabled:a,destructive:r,onClick:i}){return e.jsxs(ge,{children:[e.jsx(ke,{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(ce,{side:"top",className:"text-[10px]",children:t})]})}function Ms(){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=at(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(ze,{className:"h-3 w-3"}),t("interaction.bar.review")]})]})}const As=f.lazy(()=>Oe(()=>import("./MarkdownRenderer-BVPIxk31.js").then(t=>t.M),__vite__mapDeps([0,1,2,3,4,5,6])).then(t=>({default:t.MarkdownRenderer})));function Rs(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(1)}s`}function Fs(){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(yt,{"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(wt,{"aria-hidden":!0,className:"h-3 w-3"}),Rs(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(We,{"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(As,{content:s.response,className:"text-[12px] leading-5 [&_h1]:text-[14px] [&_h2]:text-[13px] [&_h3]:text-[12px]"})})]})]})}):null}function fe(t){return Number.isFinite(t)?Math.max(0,t):0}function $s(t){const s=fe(t.totalInputTokens),a=fe(t.cacheReadTokens),r=fe(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 Ds(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:""},Is={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"},q=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString(),ie=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 Ze(){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 ${ie(n.retryAfterMs)}`:""}${n.recoveryRemainingMs!==void 0?` · ${ie(n.recoveryRemainingMs)}`:""}`:i?`Provider · Capacity queue ${i.queuePosition}/${Math.max(i.queueDepth,i.queuePosition)} · ${i.scope} · ${ie(i.waitMs)}`:d?d.mode==="bounded_foreground"?`Provider · Bounded recovery · ${d.attempt}/${d.maxRetries} · ${ie(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=$s(s),j=Ds(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:q(s.totalTokens)}),e.jsxs("span",{className:"text-[hsl(var(--deck-ink-faint))]",children:["/ ",q(s.maxContextTokens)]})]}),s.isDefaultMaxTokens&&e.jsx(ve,{children:e.jsxs(ge,{children:[e.jsx(ke,{asChild:!0,children:e.jsx(Nt,{className:"h-3 w-3 cursor-help text-[hsl(var(--deck-ink-faint))]"})}),e.jsx(ce,{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(ve,{children:e.jsxs(ge,{children:[e.jsx(ke,{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(ce,{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:q(x.cacheReadTokens),write:q(x.cacheWriteTokens),uncached:q(x.uncachedInputTokens)})}),s.cacheBreak&&e.jsx("p",{className:"text-[hsl(var(--deck-accent))]",children:t("status.cacheBreak",{reason:t(Is[s.cacheBreak.reason]??"status.cacheBreak.server"),previous:q(s.cacheBreak.previousCacheReadTokens),current:q(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 _s(){const{locale:t}=Ue(),s=rt(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 Ce.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 Ce.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(ee,{className:"h-4 w-4"}):e.jsx(te,{className:"h-4 w-4"})}),e.jsx(St,{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(Z,{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(He,{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(Ke,{className:"h-3.5 w-3.5"})})]})]})]},o.name)})]})}function Ps(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(`
18
- `),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 Ls({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(te,{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(Xe,{messages:t,isLoading:s}),e.jsx(Ze,{})]})]})}function Gs(){var K;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=je(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)??((K=w==null?void 0:w.taskFailure)==null?void 0:K.code),O=(l==null?void 0:l.kind)==="execution"&&R?t(Ft(R)):k==="queue_full"?t("chat.error.queueFull"):k==="turn_unavailable"||k==="turn_active"?t("chat.error.turnChanged"):k,U=n==="connecting"||n==="reconnecting",B=r&&n!=="connected",L=a?`session:${X(a)}`:"session:temporary",V=f.useMemo(()=>Ps(s),[s]),T=a?X(a):"temporary-session",P=!!(a&&(w!=null&&w.taskRetryAvailable)&&(!R||$t(R)))&&((l==null?void 0:l.kind)==="execution"||(l==null?void 0:l.kind)==="task_action"),Q=(l==null?void 0:l.kind)==="execution"&&(R==="authentication"||R==="permission"||R==="model_unavailable"),G=a?h.includes(X(a)):!1;f.useEffect(()=>{E(null)},[T]);const se=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}))}),ae=()=>j(),A=async()=>{if(Q){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(()=>it())},H=P?t(G?"chat.error.action.retryingTask":"chat.error.action.retryTask"):Q?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:G,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?G?e.jsx($,{className:"h-3 w-3 animate-spin"}):e.jsx(oe,{className:"h-3 w-3"}):e.jsx(Ge,{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(Ct,{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(Et,{className:"h-3 w-3"}),t("chat.connection.retry")]})]}),e.jsx(_t,{}),e.jsx(Xe,{messages:s,isLoading:c},a?X(a):"temporary-session"),e.jsx(_s,{}),e.jsx(Fs,{})]}),e.jsxs("div",{"data-chat-composer-dock":!0,className:"contents",children:[e.jsx(Ls,{messages:s,isLoading:c,isStreaming:r,isStopping:i,errorMessage:C?O:null},T),e.jsx(Ms,{}),e.jsx(Ts,{}),e.jsx(nt,{draftKey:L,draft:m==null?void 0:m.content,draftAttachments:m==null?void 0:m.attachments,draftRevision:m==null?void 0:m.revision,onSend:se,onAbort:ae,disabled:c||B,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(Ze,{})})]})]})}export{Gs as ChatView};
@@ -1,8 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DI8ZWdWH.js","assets/vendor-react-DG5dkZ_t.js"])))=>i.map(i=>d[i]);
2
- import{j as R,l as wt,t as A,u as W,b as at,a as O,s as J,O as Ie,k as nr,n as sr,_ as ar}from"./index-ebnhtfFC.js";import{r as o,j as e}from"./vendor-react-DG5dkZ_t.js";import{ai as or,ak as ir,a as cr,ar as We,E as jt,_ as lr,L as $e,l as ze,a4 as dr,as as ur,y as Nt,n as Et,s as Ct,d as fr,aq as hr,R as pr,X as mr}from"./vendor-icons-CX5BfgqQ.js";import"./vendor-radix-DXRuAJHH.js";import"./session-events-Bgir_Gl_.js";const St=o.createContext(null);function Tt(t){const n=o.useContext(St);if(!n)throw new Error(`${t} must be used within <Tabs>`);return n}function xr({value:t,onValueChange:n,className:r,children:a}){const c=o.useMemo(()=>({value:t,setValue:n}),[t,n]);return e.jsx(St.Provider,{value:c,children:e.jsx("div",{className:r,children:a})})}function vr({className:t,children:n}){return e.jsx("div",{role:"tablist",className:R("inline-flex items-center",t),children:n})}function ce({value:t,className:n,children:r}){const{value:a,setValue:c}=Tt("TabsTrigger"),i=a===t;return e.jsx("button",{type:"button",role:"tab","aria-selected":i,"data-state":i?"active":"inactive",onClick:()=>c(t),className:R("inline-flex items-center justify-center whitespace-nowrap rounded-sm transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[hsl(var(--deck-accent))]",n),children:r})}function le({value:t,className:n,children:r,forceMount:a=!1}){const{value:c}=Tt("TabsContent"),i=c===t;return!i&&!a?null:e.jsx("div",{role:"tabpanel",hidden:!i,className:n,children:r})}const br={"ayu-dark":{background:{primary:"#0f1419",secondary:"#14191f"},text:{primary:"#e6e1cf",secondary:"#bae67e",muted:"#5c6773"},border:{light:"#2d323b"},syntax:{comment:"#5c6773",string:"#bae67e",number:"#ffcc66",keyword:"#ff8f40",function:"#73d0ff",variable:"#e6e1cf",operator:"#f29e74",type:"#73d0ff",tag:"#ff8f40",attr:"#ffd580",default:"#e6e1cf"}},dracula:{background:{primary:"#282a36",secondary:"#44475a"},text:{primary:"#f8f8f2",secondary:"#f1fa8c",muted:"#6272a4"},border:{light:"#44475a"},syntax:{comment:"#6272a4",string:"#f1fa8c",number:"#bd93f9",keyword:"#ff79c6",function:"#50fa7b",variable:"#f8f8f2",operator:"#ff79c6",type:"#8be9fd",tag:"#ff79c6",attr:"#50fa7b",default:"#f8f8f2"}},monokai:{background:{primary:"#272822",secondary:"#3e3d32"},text:{primary:"#f8f8f2",secondary:"#e6db74",muted:"#75715e"},border:{light:"#3e3d32"},syntax:{comment:"#75715e",string:"#e6db74",number:"#ae81ff",keyword:"#f92672",function:"#a6e22e",variable:"#f8f8f2",operator:"#f92672",type:"#66d9ef",tag:"#f92672",attr:"#a6e22e",default:"#f8f8f2"}},nord:{background:{primary:"#2e3440",secondary:"#3b4252"},text:{primary:"#eceff4",secondary:"#d8dee9",muted:"#4c566a"},border:{light:"#434c5e"},syntax:{comment:"#616e88",string:"#a3be8c",number:"#b48ead",keyword:"#81a1c1",function:"#88c0d0",variable:"#d8dee9",operator:"#81a1c1",type:"#8fbcbb",tag:"#81a1c1",attr:"#8fbcbb",default:"#eceff4"}},"solarized-light":{background:{primary:"#fdf6e3",secondary:"#eee8d5"},text:{primary:"#586e75",secondary:"#657b83",muted:"#93a1a1"},border:{light:"#eee8d5"},syntax:{comment:"#93a1a1",string:"#2aa198",number:"#d33682",keyword:"#859900",function:"#268bd2",variable:"#657b83",operator:"#859900",type:"#b58900",tag:"#268bd2",attr:"#93a1a1",default:"#657b83"}},"solarized-dark":{background:{primary:"#002b36",secondary:"#073642"},text:{primary:"#839496",secondary:"#93a1a1",muted:"#586e75"},border:{light:"#073642"},syntax:{comment:"#586e75",string:"#2aa198",number:"#d33682",keyword:"#859900",function:"#268bd2",variable:"#839496",operator:"#859900",type:"#b58900",tag:"#268bd2",attr:"#93a1a1",default:"#839496"}},"tokyo-night":{background:{primary:"#1a1b26",secondary:"#292e42"},text:{primary:"#a9b1d6",secondary:"#c0caf5",muted:"#565f89"},border:{light:"#292e42"},syntax:{comment:"#565f89",string:"#9ece6a",number:"#ff9e64",keyword:"#bb9af7",function:"#7aa2f7",variable:"#c0caf5",operator:"#89ddff",type:"#7dcfff",tag:"#f7768e",attr:"#7aa2f7",default:"#a9b1d6"}},github:{background:{primary:"#ffffff",secondary:"#f6f8fa"},text:{primary:"#24292f",secondary:"#57606a",muted:"#6e7781"},border:{light:"#d0d7de"},syntax:{comment:"#6e7781",string:"#0a3069",number:"#0550ae",keyword:"#cf222e",function:"#8250df",variable:"#24292f",operator:"#cf222e",type:"#0550ae",tag:"#116329",attr:"#0550ae",default:"#24292f"}},gruvbox:{background:{primary:"#282828",secondary:"#3c3836"},text:{primary:"#ebdbb2",secondary:"#d5c4a1",muted:"#928374"},border:{light:"#3c3836"},syntax:{comment:"#928374",string:"#b8bb26",number:"#d3869b",keyword:"#fb4934",function:"#b8bb26",variable:"#ebdbb2",operator:"#fe8019",type:"#fabd2f",tag:"#fb4934",attr:"#fabd2f",default:"#ebdbb2"}},"one-dark":{background:{primary:"#282c34",secondary:"#21252b"},text:{primary:"#abb2bf",secondary:"#e5c07b",muted:"#5c6370"},border:{light:"#3e4451"},syntax:{comment:"#5c6370",string:"#98c379",number:"#d19a66",keyword:"#c678dd",function:"#61afef",variable:"#e06c75",operator:"#56b6c2",type:"#e5c07b",tag:"#e06c75",attr:"#d19a66",default:"#abb2bf"}},catppuccin:{background:{primary:"#1e1e2e",secondary:"#313244"},text:{primary:"#cdd6f4",secondary:"#f5e0dc",muted:"#6c7086"},border:{light:"#313244"},syntax:{comment:"#6c7086",string:"#a6e3a1",number:"#fab387",keyword:"#cba6f7",function:"#89b4fa",variable:"#f5e0dc",operator:"#89dceb",type:"#f9e2af",tag:"#f38ba8",attr:"#f9e2af",default:"#cdd6f4"}},"rose-pine":{background:{primary:"#191724",secondary:"#1f1d2e"},text:{primary:"#e0def4",secondary:"#908caa",muted:"#6e6a86"},border:{light:"#26233a"},syntax:{comment:"#6e6a86",string:"#f6c177",number:"#ebbcba",keyword:"#c4a7e7",function:"#9ccfd8",variable:"#e0def4",operator:"#31748f",type:"#eb6f92",tag:"#eb6f92",attr:"#c4a7e7",default:"#e0def4"}},kanagawa:{background:{primary:"#1f1f28",secondary:"#2a2a37"},text:{primary:"#dcd7ba",secondary:"#c8c093",muted:"#727169"},border:{light:"#2a2a37"},syntax:{comment:"#727169",string:"#98bb6c",number:"#d27e99",keyword:"#957fb8",function:"#7e9cd8",variable:"#dcd7ba",operator:"#c0a36e",type:"#7aa89f",tag:"#e46876",attr:"#ffa066",default:"#dcd7ba"}}};function kr(t){const n=t.replace("#",""),r=parseInt(n.substring(0,2),16),a=parseInt(n.substring(2,4),16),c=parseInt(n.substring(4,6),16);return(.299*r+.587*a+.114*c)/255<.5}function gr(t){return{base:kr(t.background.primary)?"vs-dark":"vs",inherit:!0,rules:[{token:"",foreground:t.text.primary.replace("#",""),background:t.background.primary.replace("#","")},{token:"comment",foreground:t.syntax.comment.replace("#",""),fontStyle:"italic"},{token:"string",foreground:t.syntax.string.replace("#","")},{token:"number",foreground:t.syntax.number.replace("#","")},{token:"keyword",foreground:t.syntax.keyword.replace("#","")},{token:"type",foreground:t.syntax.type.replace("#","")},{token:"identifier",foreground:t.syntax.variable.replace("#","")},{token:"function",foreground:t.syntax.function.replace("#","")},{token:"variable",foreground:t.syntax.variable.replace("#","")},{token:"operator",foreground:t.syntax.operator.replace("#","")},{token:"delimiter",foreground:t.syntax.operator.replace("#","")},{token:"tag",foreground:t.syntax.tag.replace("#","")},{token:"attribute.name",foreground:t.syntax.attr.replace("#","")},{token:"attribute.value",foreground:t.syntax.string.replace("#","")}],colors:{"editor.background":t.background.primary,"editor.foreground":t.text.primary,"editor.lineHighlightBackground":t.background.secondary,"editor.selectionBackground":`${t.syntax.function}40`,"editorLineNumber.foreground":t.text.muted,"editorLineNumber.activeForeground":t.text.secondary,"editorCursor.foreground":t.text.primary,"editorIndentGuide.background":t.border.light,"editorWidget.background":t.background.secondary,"editorWidget.border":t.border.light,"scrollbarSlider.background":`${t.text.muted}40`,"scrollbarSlider.hoverBackground":`${t.text.muted}60`}}}const ot=new Set;function it(t,n){const r=n.toLowerCase().replace(/\s+/g,"-"),a=br[r];if(!a)return"vs-dark";if(!ot.has(r)){const c=gr(a);t.editor.defineTheme(r,c),ot.add(r)}return r}const yr="http://localhost:3000",wr=2048,jr=/^(?:localhost|127(?:\.\d{1,3}){3}|0\.0\.0\.0|\[::1\]|10(?:\.\d{1,3}){3}|192\.168(?:\.\d{1,3}){2}|172\.(?:1[6-9]|2\d|3[01])(?:\.\d{1,3}){2})(?::\d+)?$/i,Nr=/^[a-z\d.-]+:\d+$/i,Er={en:{toolbarAria:"Browser navigation",addressAria:"Browser address",addressPlaceholder:"Enter an HTTP or HTTPS URL",back:"Go back",forward:"Go forward",reload:"Reload page",go:"Open address",openExternal:"Open in system browser",frameTitle:"Browser preview",emptyTitle:"No page open",status:{idle:"Idle",loading:"Loading…",ready:"Ready",error:"Failed"},error:{empty:"Enter a URL.",invalid:"Enter a valid URL.",protocol:"Only HTTP and HTTPS URLs are supported.",credentials:"URLs containing credentials are not allowed.",same_origin:"The Blade Web origin cannot be embedded in itself."}},zh:{toolbarAria:"浏览器导航",addressAria:"浏览器地址",addressPlaceholder:"输入 HTTP 或 HTTPS 地址",back:"后退",forward:"前进",reload:"刷新页面",go:"打开地址",openExternal:"在系统浏览器中打开",frameTitle:"浏览器预览",emptyTitle:"未打开页面",status:{idle:"空闲",loading:"正在加载…",ready:"就绪",error:"加载失败"},error:{empty:"请输入地址。",invalid:"请输入有效地址。",protocol:"仅支持 HTTP 与 HTTPS 地址。",credentials:"不允许使用包含凭据的地址。",same_origin:"不能在面板中嵌套 Blade Web 自身地址。"}}};function Cr(){return typeof window>"u"?void 0:window.location.origin}function Sr(t,n=Cr()){const r=t.trim();if(!r)return{ok:!1,reason:"empty"};if(r.length>wr)return{ok:!1,reason:"invalid"};let a=r;const c=a.split(/[/?#]/,1)[0]??"";jr.test(c)||Nr.test(c)?a=`http://${a}`:a.startsWith("//")?a=`https:${a}`:/^[a-z][a-z\d+.-]*:/i.test(a)||(a=`https://${a}`);let i;try{i=new URL(a)}catch{return{ok:!1,reason:"invalid"}}return i.protocol!=="http:"&&i.protocol!=="https:"?{ok:!1,reason:"protocol"}:i.username||i.password?{ok:!1,reason:"credentials"}:n&&i.origin===n?{ok:!1,reason:"same_origin"}:{ok:!0,url:i.href}}function Tr(t,n){if(t.entries[t.index]===n)return t;const r=[...t.entries.slice(0,t.index+1),n].slice(-50);return{entries:r,index:r.length-1}}function Rr(){const{locale:t}=wt(),n=Er[t],[r,a]=o.useState(yr),[c,i]=o.useState([]),[k,u]=o.useState(-1),[x,h]=o.useState(0),[m,f]=o.useState("idle"),[v,E]=o.useState(null),l=c[k]??null,b=o.useMemo(()=>{if(!l)return"";try{return new URL(l).host}catch{return""}},[l]),p=N=>{a(N),E(null),f("loading")},j=N=>{const T=Sr(N);if(!T.ok){E(T.reason);return}if(T.url===l){p(T.url),h(V=>V+1);return}const G=Tr({entries:c,index:k},T.url);i(G.entries),u(G.index),p(T.url)},C=N=>{const T=c[N];T&&(u(N),p(T))},D=N=>{N.preventDefault(),j(r)},F=v?n.error[v]:null;return e.jsxs("section",{"data-preview-browser":!0,className:"flex h-full min-h-0 flex-col bg-[hsl(var(--deck-canvas))]",children:[e.jsxs("form",{"aria-label":n.toolbarAria,onSubmit:D,className:"flex h-12 shrink-0 items-center gap-1 border-b border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-2",children:[e.jsx(A,{type:"button",variant:"ghost",size:"icon",disabled:k<=0,"aria-label":n.back,title:n.back,onClick:()=>C(k-1),className:"h-8 w-8 rounded-md text-[hsl(var(--deck-ink-muted))]",children:e.jsx(or,{className:"h-4 w-4"})}),e.jsx(A,{type:"button",variant:"ghost",size:"icon",disabled:k<0||k>=c.length-1,"aria-label":n.forward,title:n.forward,onClick:()=>C(k+1),className:"h-8 w-8 rounded-md text-[hsl(var(--deck-ink-muted))]",children:e.jsx(ir,{className:"h-4 w-4"})}),e.jsx(A,{type:"button",variant:"ghost",size:"icon",disabled:!l,"aria-label":n.reload,title:n.reload,onClick:()=>{l&&(p(l),h(N=>N+1))},className:"h-8 w-8 rounded-md text-[hsl(var(--deck-ink-muted))]",children:e.jsx(cr,{className:R("h-4 w-4",m==="loading"&&"animate-spin")})}),e.jsxs("div",{className:R("flex h-8 min-w-0 flex-1 items-center gap-2 rounded-md border bg-[hsl(var(--deck-canvas))] px-2",v?"border-red-500/70":"border-[hsl(var(--deck-border))] focus-within:border-[hsl(var(--deck-accent)/0.65)]"),children:[e.jsx(We,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("input",{"data-preview-browser-address":!0,value:r,onChange:N=>{a(N.target.value),E(null)},onKeyDown:N=>{N.key==="Escape"&&l&&(N.preventDefault(),a(l),E(null))},"aria-label":n.addressAria,placeholder:n.addressPlaceholder,autoCapitalize:"none",autoComplete:"off",spellCheck:!1,className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-[hsl(var(--deck-ink))] outline-none placeholder:text-[hsl(var(--deck-ink-faint))]"})]}),e.jsx(A,{type:"submit",variant:"ghost",size:"icon","aria-label":n.go,title:n.go,className:"h-8 w-8 rounded-md text-[hsl(var(--deck-accent))]",children:e.jsx(jt,{className:"h-4 w-4"})}),e.jsx(A,{type:"button",variant:"ghost",size:"icon",disabled:!l,"aria-label":n.openExternal,title:n.openExternal,onClick:()=>{l&&window.open(l,"_blank","noopener,noreferrer")},className:"h-8 w-8 rounded-md text-[hsl(var(--deck-ink-muted))]",children:e.jsx(lr,{className:"h-4 w-4"})})]}),F&&e.jsx("div",{role:"alert",className:"shrink-0 border-b border-red-500/25 bg-red-500/10 px-3 py-2 font-mono text-[10.5px] text-red-700 dark:text-red-300",children:F}),e.jsx("div",{"aria-busy":m==="loading",className:"relative min-h-0 flex-1 overflow-hidden bg-white",children:l?e.jsxs(e.Fragment,{children:[e.jsx("iframe",{"data-preview-browser-frame":!0,src:l,title:n.frameTitle,sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts",referrerPolicy:"no-referrer",onLoad:()=>f("ready"),onError:()=>f("error"),className:"block h-full w-full border-0 bg-white"},`${l}:${x}`),m==="loading"&&e.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 flex h-8 items-center justify-center border-b border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas)/0.92)] backdrop-blur-sm",children:[e.jsx($e,{className:"mr-2 h-3.5 w-3.5 animate-spin text-[hsl(var(--deck-accent))]"}),e.jsx("span",{className:"font-mono text-[10.5px] text-[hsl(var(--deck-ink-muted))]",children:n.status.loading})]})]}):e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 bg-[hsl(var(--deck-canvas-veil))] text-center",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] text-[hsl(var(--deck-ink-faint))]",children:e.jsx(We,{className:"h-5 w-5"})}),e.jsx("span",{className:"font-mono text-[11px] text-[hsl(var(--deck-ink-muted))]",children:n.emptyTitle})]})}),e.jsxs("div",{"data-preview-browser-status":m,"aria-live":"polite",className:"flex h-7 shrink-0 items-center justify-between border-t border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:R("h-1.5 w-1.5 shrink-0 rounded-full bg-[hsl(var(--deck-ink-faint))]",m==="loading"&&"bg-amber-500",m==="ready"&&"bg-emerald-500",m==="error"&&"bg-red-500")}),e.jsx("span",{children:n.status[m]})]}),b&&e.jsx("span",{className:"ml-3 truncate",children:b})]})]})}function ue(t){return t.normalize("NFKC").toLocaleLowerCase().trim()}function Dr(t,n,r){const a=ue(n).split(/\s+/).filter(Boolean);return t.filter(c=>{if(r!=="all"&&c.status!==r)return!1;if(a.length===0)return!0;const i=ue([c.title,c.subtitle,c.content].filter(Boolean).join(" "));return a.every(k=>i.includes(k))})}function Rt(t){return t.replace(/\/+$/,"").split("/").filter(Boolean).at(-1)||t}function Lr(t,n){const r=ue(n).split(/\s+/).filter(Boolean);return r.length===0?t:t.filter(a=>{const c=ue([a.filePath,a.summary].filter(Boolean).join(" "));return r.every(i=>c.includes(i))})}function Fr(t,n,r){return n===0?0:(t+r+n)%n}const ct=20,lt=20,dt=160,ut=240;function ft(t,n){const r=i=>i.replace(/\\/g,"/").replace(/^\.?\//,"").replace(/\/+/g,"/"),a=r(t),c=r(n);return a===c||a.endsWith(`/${c}`)||c.endsWith(`/${a}`)}function Pr({diffs:t,expanded:n,targetPath:r,onToggle:a,onSetAllExpanded:c}){var l,b;const i=W(),[k,u]=o.useState(""),x=`${k}\0${t.length}\0${((l=t[0])==null?void 0:l.filePath)??""}\0${((b=t.at(-1))==null?void 0:b.filePath)??""}`,[h,m]=o.useState({key:x,count:ct}),f=h.key===x?h.count:ct,v=o.useMemo(()=>Lr(t,k),[t,k]),E=o.useMemo(()=>{const p=v.slice(0,f);if(!r)return p;const j=v.find(C=>C.filePath&&ft(C.filePath,r));return j&&!p.includes(j)?[...p,j]:p},[v,r,f]);return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"sticky top-0 z-10 space-y-2 bg-[hsl(var(--deck-canvas))] pb-1",children:[e.jsxs("div",{className:"flex h-8 items-center gap-2 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-2 focus-within:border-[hsl(var(--deck-accent)/0.6)]",children:[e.jsx(ze,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("input",{type:"search","aria-label":i("preview.diff.searchAria"),placeholder:i("preview.diff.searchPlaceholder"),value:k,onChange:p=>u(p.target.value),className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-[hsl(var(--deck-ink))] outline-none placeholder:text-[hsl(var(--deck-ink-faint))]"}),e.jsxs("span",{className:"font-mono text-[9px] tabular-nums text-[hsl(var(--deck-ink-faint))]",children:[v.length,"/",t.length]})]}),e.jsxs("div",{className:"flex items-center justify-between font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:[e.jsx("span",{children:i("preview.diff.changedFiles",{count:t.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsxs("button",{type:"button",onClick:()=>c(!0),className:"inline-flex items-center gap-1 rounded px-1.5 py-1 transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(dr,{className:"h-3 w-3"}),i("preview.diff.expandAll")]}),e.jsxs("button",{type:"button",onClick:()=>c(!1),className:"inline-flex items-center gap-1 rounded px-1.5 py-1 transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(ur,{className:"h-3 w-3"}),i("preview.diff.collapseAll")]})]})]})]}),v.length===0?e.jsx("div",{className:"rounded-lg border border-dashed border-[hsl(var(--deck-border))] p-6 text-center font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:i("preview.diff.noMatches")}):E.map(p=>{const j=p.filePath||"unknown",C=t.indexOf(p),D=n[j]??C===0,F=!!(r&&ft(j,r));return e.jsxs("div",{"data-preview-diff-path":p.filePath,className:R("overflow-hidden rounded-lg border border-[hsl(var(--deck-border))] transition-colors",F&&"border-[hsl(var(--deck-accent)/0.7)] bg-[hsl(var(--deck-accent-soft))] ring-1 ring-[hsl(var(--deck-accent)/0.2)]"),children:[e.jsxs("button",{type:"button","aria-expanded":D,onClick:()=>a(j),className:"flex w-full items-center gap-2 bg-[hsl(var(--deck-surface-2))] px-3 py-2 transition-colors hover:bg-[hsl(var(--deck-surface))] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[hsl(var(--deck-accent)/0.65)]",children:[D?e.jsx(Nt,{className:"h-4 w-4 text-[hsl(var(--deck-ink-muted))]"}):e.jsx(Et,{className:"h-4 w-4 text-[hsl(var(--deck-ink-muted))]"}),e.jsx(Ct,{className:"h-4 w-4 text-[hsl(var(--deck-ink-muted))]"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-left font-mono text-[13px] text-[hsl(var(--deck-ink))]",children:Rt(j)}),p.summary&&e.jsx("span",{className:"shrink-0 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))]",children:p.summary})]}),D&&e.jsxs("div",{className:"border-t border-[hsl(var(--deck-border))]",children:[e.jsx("div",{className:"truncate px-3 py-1 font-mono text-[11px] text-[hsl(var(--deck-ink-faint))]",children:p.filePath}),e.jsx(Ir,{diff:p.diff})]})]},j)}),f<v.length&&e.jsx("div",{className:"flex justify-center pt-1",children:e.jsx("button",{type:"button",onClick:()=>m({key:x,count:Math.min(v.length,f+lt)}),className:"rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-3 py-1.5 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:border-[hsl(var(--deck-border-strong))] hover:text-[hsl(var(--deck-ink))]",children:i("preview.diff.showMoreFiles",{count:Math.min(lt,v.length-f)})})})]})}function Ir({diff:t}){const n=W(),r=o.useMemo(()=>t.patch.split(`
3
- `),[t.patch]),[a,c]=o.useState({patch:t.patch,count:dt}),i=a.patch===t.patch?a.count:dt,k=r.slice(0,i);let u=0,x=0;return e.jsxs("div",{className:"overflow-hidden rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[e.jsxs("div",{className:"flex items-center justify-between border-b 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:[e.jsx("span",{children:n("preview.diff.patch")}),t.matchLine&&e.jsx("span",{children:n("preview.diff.line",{line:t.matchLine})})]}),e.jsx("div",{className:"overflow-x-auto font-mono text-[12px]",children:k.map((h,m)=>{if(h.startsWith("@@")){const f=/@@ -(?<old>\d+),?(?<oldCount>\d*) \+(?<new>\d+),?(?<newCount>\d*) @@/.exec(h);return f!=null&&f.groups&&(u=Number.parseInt(f.groups.old,10),x=Number.parseInt(f.groups.new,10)),e.jsx(H,{line:h},`${h}-${m}`)}if(h.startsWith("---")||h.startsWith("+++")||h.startsWith("Index:")||h.startsWith("==="))return e.jsx(H,{line:h},`${h}-${m}`);if(h.startsWith("+")){const f=x++;return e.jsx(H,{line:h,oldLine:null,newLine:f},`${h}-${m}`)}if(h.startsWith("-")){const f=u++;return e.jsx(H,{line:h,oldLine:f,newLine:null},`${h}-${m}`)}return h.startsWith(" ")?e.jsx(H,{line:h,oldLine:u++,newLine:x++},`${h}-${m}`):e.jsx(H,{line:h},`${h}-${m}`)})}),i<r.length&&e.jsx("div",{className:"flex justify-center border-t border-[hsl(var(--deck-border))] p-2",children:e.jsx("button",{type:"button",onClick:()=>c({patch:t.patch,count:Math.min(r.length,i+ut)}),className:"rounded-md border border-[hsl(var(--deck-border))] px-3 py-1 font-mono text-[10.5px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:bg-[hsl(var(--deck-surface-2))] hover:text-[hsl(var(--deck-ink))]",children:n("preview.diff.showMoreLines",{count:Math.min(ut,r.length-i)})})})]})}function H({line:t,oldLine:n,newLine:r}){const a=t.startsWith("---")||t.startsWith("+++")||t.startsWith("Index:")||t.startsWith("==="),c=t.startsWith("@@"),i=t[0],k=a||c?t:t.slice(1),u=a?"text-[hsl(var(--deck-ink-muted))]":i==="+"?"bg-[#22C55E]/10 text-[#166534] dark:bg-[#22C55E]/10 dark:text-[#86efac]":i==="-"?"bg-[#EF4444]/10 text-[#b91c1c] dark:bg-[#EF4444]/10 dark:text-[#fca5a5]":c?"bg-[#DBEAFE] text-[#1d4ed8] dark:bg-[#1e3a8a]/30 dark:text-[#93c5fd]":"text-[hsl(var(--deck-ink))]";return e.jsxs("div",{"data-preview-diff-line":!0,className:R("grid min-w-max grid-cols-[40px_40px_1fr] gap-2 px-3 py-0.5",u),children:[e.jsx("span",{className:"text-right text-[hsl(var(--deck-ink-faint))]",children:n?String(n).padStart(2," "):""}),e.jsx("span",{className:"text-right text-[hsl(var(--deck-ink-faint))]",children:r?String(r).padStart(2," "):""}),e.jsx("span",{className:"whitespace-pre",children:k})]})}function Ar({nodes:t,expandedDirs:n,childrenCache:r,directoryStates:a,selectedPath:c,onToggleDir:i,onRetryDir:k,onSelectFile:u}){return e.jsx(e.Fragment,{children:t.map(x=>e.jsx(Dt,{node:x,depth:0,expandedDirs:n,childrenCache:r,directoryStates:a,selectedPath:c,onToggleDir:i,onRetryDir:k,onSelectFile:u},x.path))})}function Dt({node:t,depth:n,expandedDirs:r,childrenCache:a,directoryStates:c,selectedPath:i,onToggleDir:k,onRetryDir:u,onSelectFile:x}){const h=W(),m=t.type==="dir",f=!!r[t.path],v=!m&&i===t.path,E=a[t.path]??[],l=c[t.path],b=n*14+24;return e.jsxs("div",{children:[e.jsxs("button",{type:"button","aria-expanded":m?f:void 0,"aria-busy":m&&(l==null?void 0:l.status)==="loading",onClick:()=>m?k(t.path):x(t.path),className:R("flex w-full items-center gap-2 rounded-md px-2 py-1 text-left font-mono text-[12px] transition-colors",v?"border border-[#16A34A]/30 bg-[#16A34A]/10 text-[#111827] dark:border-[#22C55E]/30 dark:bg-[#22C55E]/10 dark:text-[#E5E5E5]":"text-[hsl(var(--deck-ink-muted))] hover:bg-[hsl(var(--deck-surface))]",m&&"cursor-pointer"),style:{paddingLeft:n*14+8},children:[m?(l==null?void 0:l.status)==="loading"?e.jsx($e,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"}):f?e.jsx(fr,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-ink))]"}):e.jsx(hr,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-ink-muted))]"}):e.jsx(Ct,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"truncate text-[hsl(var(--deck-ink))]",children:t.name})]}),m&&f&&e.jsxs("div",{children:[(l==null?void 0:l.status)==="loading"&&e.jsx("div",{role:"status",style:{paddingLeft:b},className:"py-1 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:h("preview.files.directoryLoading")}),(l==null?void 0:l.status)==="error"&&e.jsxs("div",{role:"alert",style:{marginLeft:b},className:"my-1 mr-1 rounded-md border border-red-200 bg-red-50/70 px-2 py-1.5 font-mono text-[10px] text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:[e.jsx("div",{className:"truncate",title:l.message,children:l.message}),e.jsxs("button",{type:"button",onClick:()=>u(t.path),className:"mt-1 inline-flex items-center gap-1 font-medium underline-offset-2 hover:underline",children:[e.jsx(pr,{className:"h-2.5 w-2.5"}),h("preview.action.retry")]})]}),(l==null?void 0:l.status)==="loaded"&&E.length===0&&e.jsx("div",{style:{paddingLeft:b},className:"py-1 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:h("preview.files.directoryEmpty")}),E.map(p=>e.jsx(Dt,{node:p,depth:n+1,expandedDirs:r,childrenCache:a,directoryStates:c,selectedPath:i,onToggleDir:k,onRetryDir:u,onSelectFile:x},p.path))]})]})}const ht=80,pt=80;function Wr({logs:t}){var l,b;const n=W(),[r,a]=o.useState(""),[c,i]=o.useState("all"),[k,u]=o.useState({}),x=`${c}\0${r}\0${t.length}\0${((l=t[0])==null?void 0:l.id)??""}\0${((b=t.at(-1))==null?void 0:b.id)??""}`,[h,m]=o.useState({key:x,count:ht}),f=o.useMemo(()=>Dr(t,r,c),[c,t,r]),v=h.key===x?h.count:ht,E=f.slice(0,v);return e.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[e.jsxs("div",{className:"space-y-2 border-b border-[hsl(var(--deck-border))] px-4 py-3",children:[e.jsxs("div",{className:"flex h-8 items-center gap-2 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-2 focus-within:border-[hsl(var(--deck-accent)/0.6)]",children:[e.jsx(ze,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("input",{type:"search","aria-label":n("preview.logs.searchAria"),placeholder:n("preview.logs.searchPlaceholder"),value:r,onChange:p=>a(p.target.value),className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-[hsl(var(--deck-ink))] outline-none placeholder:text-[hsl(var(--deck-ink-faint))]"}),e.jsxs("span",{className:"font-mono text-[9px] tabular-nums text-[hsl(var(--deck-ink-faint))]",children:[f.length,"/",t.length]})]}),e.jsx("div",{className:"flex items-center gap-1","aria-label":n("preview.logs.filterAria"),children:["all","running","error","success"].map(p=>e.jsx("button",{type:"button","aria-pressed":c===p,onClick:()=>i(p),className:R("rounded-md border px-2 py-1 font-mono text-[9.5px] transition-colors",c===p?"border-[hsl(var(--deck-accent)/0.45)] bg-[hsl(var(--deck-accent-soft))] text-[hsl(var(--deck-accent))]":"border-[hsl(var(--deck-border))] text-[hsl(var(--deck-ink-faint))] hover:text-[hsl(var(--deck-ink-muted))]"),children:n(`preview.logs.filter.${p}`)},p))})]}),e.jsxs("div",{className:"min-h-0 flex-1 space-y-3 overflow-y-auto px-4 py-4",children:[t.length===0?e.jsx(mt,{title:n("preview.logs.emptyTitle"),subtitle:n("preview.logs.emptyHint")}):f.length===0?e.jsx(mt,{title:n("preview.logs.noMatches"),subtitle:n("preview.logs.noMatchesHint")}):E.map(p=>{var N;const j=k[p.id],C=(p.content||"").split(`
4
- `),D=C.length>10||(((N=p.content)==null?void 0:N.length)||0)>800,F=j||!D?C:C.slice(0,8);return e.jsxs("div",{"data-preview-log-id":p.id,className:"overflow-hidden rounded-lg border border-[hsl(var(--deck-border))]",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("div",{className:"font-mono text-[12px] text-[hsl(var(--deck-ink))]",children:p.title}),p.subtitle&&e.jsx("div",{className:"font-mono text-[11px] text-[hsl(var(--deck-ink-muted))]",children:p.subtitle})]}),e.jsx(_r,{status:p.status})]}),p.content&&e.jsxs("div",{className:"space-y-2 px-3 py-3",children:[e.jsxs("pre",{className:"overflow-x-auto whitespace-pre-wrap rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] p-3 font-mono text-[12px] text-[hsl(var(--deck-ink))]",children:[F.join(`
5
- `),!j&&D&&`
6
- …`]}),D&&e.jsxs("button",{type:"button",onClick:()=>u(T=>({...T,[p.id]:!T[p.id]})),className:"flex items-center gap-1 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:text-[hsl(var(--deck-ink))]",children:[j?e.jsx(Nt,{className:"h-3 w-3"}):e.jsx(Et,{className:"h-3 w-3"}),n(j?"preview.logs.collapse":"preview.logs.expand")]})]})]},p.id)}),v<f.length&&e.jsx("div",{className:"flex justify-center",children:e.jsx("button",{type:"button",onClick:()=>m({key:x,count:Math.min(f.length,v+pt)}),className:"rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-3 py-1.5 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:border-[hsl(var(--deck-border-strong))] hover:text-[hsl(var(--deck-ink))]",children:n("preview.logs.showMore",{count:Math.min(pt,f.length-v)})})})]})]})}function mt({title:t,subtitle:n}){return e.jsxs("div",{className:"rounded-lg border border-dashed border-[hsl(var(--deck-border))] p-6 text-center",children:[e.jsx("div",{className:"font-mono text-[13px] text-[hsl(var(--deck-ink))]",children:t}),e.jsx("div",{className:"mt-1 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:n})]})}function _r({status:t}){const n=W(),r=n(t==="success"?"preview.logs.status.success":t==="error"?"preview.logs.status.error":"preview.logs.status.running"),a=t==="success"?"bg-[#22C55E] text-white":t==="error"?"bg-[#FEE2E2] text-[#b91c1c] dark:bg-[#EF4444]/20 dark:text-[#fca5a5]":"bg-[hsl(var(--deck-surface))] text-[hsl(var(--deck-ink-muted))]";return e.jsx("span",{className:R("rounded-full px-2 py-0.5 font-mono text-[11px]",a),children:r})}const $r=640,Lt=360,_e=960,Jr=o.forwardRef(function({open:n,maximized:r,disabled:a,onToggleMaximized:c,onTogglePreview:i},k){const u=W(),{locale:x}=wt(),h=x==="zh"?{maximize:"全屏预览",restore:"还原分栏预览"}:{maximize:"Maximize preview",restore:"Restore split preview"},m=r?h.restore:h.maximize;return e.jsxs(e.Fragment,{children:[n&&e.jsx(A,{variant:"ghost",size:"icon","aria-pressed":!!r,"aria-label":m,title:m,onClick:c,className:R("hidden h-8 w-8 rounded-md text-[hsl(var(--deck-ink-faint))] hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))] lg:inline-flex",r&&"bg-[hsl(var(--deck-surface))] text-[hsl(var(--deck-ink))]"),children:e.jsx(jt,{className:R("h-4 w-4 transition-transform",r&&"rotate-180")})}),e.jsx(A,{ref:k,variant:"ghost",size:"icon",onClick:i,disabled:a,title:u("preview.title"),"aria-label":x==="zh"?"切换预览面板":"Toggle preview panel",className:R("h-8 w-8 rounded-md text-[hsl(var(--deck-ink-faint))] hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))]",n&&"bg-[hsl(var(--deck-accent-soft))] text-[hsl(var(--deck-accent))] hover:bg-[hsl(var(--deck-accent-soft))] hover:text-[hsl(var(--deck-accent))]"),children:e.jsx(We,{className:"h-4 w-4"})})]})});function xt(t){const n=typeof window>"u"?_e:Math.max(280,Math.floor(window.innerWidth*.72));return Math.min(_e,n,Math.max(Lt,Math.round(t)))}function Ft(t,n,r){var a;if(t){const c=(a=r==null?void 0:r.taskDelivery)==null?void 0:a.status;return(r==null?void 0:r.taskIsolation)==="worktree"&&r.taskSourceProjectPath&&(c==="applied"||c==="discarded")?{sessionId:t.sessionId,projectPath:r.taskSourceProjectPath}:t}return n?{sessionId:`project:${n}`,projectPath:n}:null}function Ae(){const t=O.getState(),n=t.sessions.find(r=>J({sessionId:r.sessionId,projectPath:r.projectPath},t.currentSessionRef));return Ft(t.currentSessionRef,t.selectedProjectPath,n)}function vt(t,n){const r=i=>i.replace(/\\/g,"/").replace(/^\.?\//,"").replace(/\/+/g,"/"),a=r(t),c=r(n);return a===c||a.endsWith(`/${c}`)||c.endsWith(`/${a}`)}const zr=o.lazy(async()=>({default:(await ar(()=>import("./index-DI8ZWdWH.js"),__vite__mapDeps([0,1]))).Editor}));function de(t,n){return t instanceof Error?t.message:n}function Qr({returnFocusElement:t,maximized:n=!1}={}){var nt,st;const r=W(),{toggleFilePreview:a,previewWidth:c,setPreviewWidth:i,previewTab:k,setPreviewTab:u,previewTargetPath:x,previewRequestId:h}=at(),m=O(s=>s.messages),f=O(s=>s.currentSessionRef),v=O(s=>s.sessions),E=O(s=>s.selectedProjectPath),l=o.useMemo(()=>v.find(s=>J({sessionId:s.sessionId,projectPath:s.projectPath},f)),[f,v]),b=o.useMemo(()=>Ft(f,E,l),[l,f,E]),[p,j]=o.useState(k),[C,D]=o.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 1023px)").matches),[F,N]=o.useState(null),[T,G]=o.useState(!1),[V,fe]=o.useState([]),[Pt,Me]=o.useState({}),[It,Be]=o.useState({}),[At,Wt]=o.useState(0),[Q,he]=o.useState(!1),[X,pe]=o.useState(null),[z,me]=o.useState(""),[Y,Z]=o.useState([]),[qe,ee]=o.useState(!1),[_t,te]=o.useState(!1),[$t,zt]=o.useState(0),[xe,re]=o.useState(0),[Mt,ve]=o.useState({}),[Bt,ne]=o.useState({}),[P,He]=o.useState(null),[qt,be]=o.useState(""),[ke,ge]=o.useState(!1),[ye,we]=o.useState(null),[Oe,je]=o.useState(!1),Ue=o.useRef(b),M=o.useRef(0),se=o.useRef(0),B=o.useRef({}),Ne=o.useRef(0),ae=o.useRef(0),q=o.useRef(0),I=o.useRef({}),oe=o.useRef({}),Ee=o.useRef({}),Ce=o.useRef(null),Se=o.useRef(null),Ge=o.useRef(null),Ve=o.useRef(null),Te=o.useRef(c),Ke=o.useRef(f),Re=o.useRef(null);o.useLayoutEffect(()=>{J(Ue.current,b)||(M.current+=1),Ue.current=b},[b]),o.useEffect(()=>{if(typeof window.matchMedia!="function")return;const s=window.matchMedia("(max-width: 1023px)"),d=()=>D(s.matches);return d(),s.addEventListener("change",d),()=>s.removeEventListener("change",d)},[]),o.useEffect(()=>(Ve.current=t??(document.activeElement instanceof HTMLElement?document.activeElement:null),()=>{const s=Ve.current;requestAnimationFrame(()=>{s!=null&&s.isConnected&&s.focus({preventScroll:!0})})}),[t]),o.useEffect(()=>{var s;C&&((s=Ge.current)==null||s.focus({preventScroll:!0}))},[C]);const Ht=s=>{var S;if(!C)return;if(s.key==="Escape"){s.preventDefault(),a();return}if(s.key!=="Tab")return;const d=Array.from(((S=Se.current)==null?void 0:S.querySelectorAll('button:not([disabled]), input:not([disabled]), [href], [tabindex]:not([tabindex="-1"])'))??[]).filter(w=>!w.closest("[hidden]"));if(d.length===0)return;const y=d[0],g=d[d.length-1];s.shiftKey&&document.activeElement===y?(s.preventDefault(),g==null||g.focus()):!s.shiftKey&&document.activeElement===g&&(s.preventDefault(),y==null||y.focus())},K=(s,d)=>d===M.current&&J(Ae(),s),Je=async(s,d="")=>{const y=d?`/suggestions/files/tree?path=${encodeURIComponent(d)}`:"/suggestions/files/tree",g=await fetch(y,{headers:Ie(s)});if(!g.ok)throw new Error(r("preview.files.treeFailed"));return(await g.json()).map(w=>({...w,children:w.type==="dir"?[]:void 0}))};o.useEffect(()=>{const s=++se.current;return(async()=>{if(!b){fe([]),he(!1),pe(null);return}const y={...b},g=M.current,S=()=>s===se.current&&K(y,g);if(S()){fe([]),he(!0),pe(null);try{const w=await Je(y);S()&&fe(w)}catch(w){S()&&pe(de(w,r("preview.files.treeFailed")))}finally{S()&&he(!1)}}})(),()=>{se.current===s&&(se.current+=1)}},[At,b==null?void 0:b.projectPath,b==null?void 0:b.sessionId]),o.useEffect(()=>{Ce.current=null,I.current={},oe.current={},Ee.current={},B.current={},Ne.current+=1,He(null),be(""),ge(!1),we(null),je(!1),ve({}),Me({}),Be({}),me(""),Z([]),ee(!1),te(!1),re(0),ne({})},[b==null?void 0:b.projectPath,b==null?void 0:b.sessionId]);const Ot=o.useMemo(()=>Br(m),[m]),[Ut,Qe]=o.useState(null),[Gt,De]=o.useState(!1),[Xe,Ye]=o.useState(null),[Vt,Kt]=o.useState(0),Le=(l==null?void 0:l.taskIsolation)==="worktree"&&((nt=l.taskDelivery)==null?void 0:nt.status)==="discarded",Ze=(l==null?void 0:l.taskIsolation)==="worktree"&&!!l.taskDiffStat&&!Le,et=Ze&&!!(l!=null&&l.taskDiffStat&&l.taskDiffStat.changedFiles>0),_=Le?[]:Ze?Ut??[]:Ot,Jt=o.useMemo(()=>Mr(m),[m]);o.useEffect(()=>{const s=z.trim(),d=++ae.current;if(re(0),te(!1),!s||p!=="files"||!b){Z([]),ee(!1);return}const y={...b},g=M.current;ee(!0);const S=window.setTimeout(()=>{fetch(`/suggestions/files?q=${encodeURIComponent(s)}&limit=100&type=file`,{headers:Ie(y)}).then(async w=>{if(!w.ok)throw new Error(r("preview.files.searchFailed"));return await w.json()}).then(w=>{d===ae.current&&K(y,g)&&(Z(w.filter(L=>!L.endsWith("/"))),te(!1))}).catch(()=>{d===ae.current&&K(y,g)&&(Z([]),te(!0))}).finally(()=>{d===ae.current&&ee(!1)})},160);return()=>window.clearTimeout(S)},[p,z,$t,b==null?void 0:b.projectPath,b==null?void 0:b.sessionId]),o.useEffect(()=>{j(at.getState().previewTab)},[h]),o.useEffect(()=>{const s=Ke.current;if(Ke.current=f,f||!E){Re.current=null;return}const d=!!s||Re.current!==E;Re.current=E,d&&p==="diff"&&(j("files"),u("files"))},[p,f==null?void 0:f.projectPath,f==null?void 0:f.sessionId,E,u]),o.useEffect(()=>{var y;if(!x||p!=="diff")return;const s=(y=_.find(g=>g.filePath&&vt(g.filePath,x)))==null?void 0:y.filePath;if(!s)return;ne(g=>({...g,[s]:!0}));const d=requestAnimationFrame(()=>{var S,w;const g=Array.from(((S=Se.current)==null?void 0:S.querySelectorAll("[data-preview-diff-path]"))??[]).find(L=>vt(L.dataset.previewDiffPath??"",x));typeof(g==null?void 0:g.scrollIntoView)=="function"&&g.scrollIntoView({block:"nearest",behavior:"smooth"}),(w=g==null?void 0:g.querySelector("button"))==null||w.focus({preventScroll:!0})});return()=>cancelAnimationFrame(d)},[p,_,h,x]),o.useEffect(()=>{const s=++q.current;if(Qe(null),Ye(null),De(!1),!f||!et)return;const d={...f};return De(!0),nr.getTaskDiff(d).then(y=>{s!==q.current||!J(O.getState().currentSessionRef,d)||Qe(y.files.map(g=>({filePath:g.path,diff:{patch:g.patch},summary:g.binary?"binary":`+${g.additions} -${g.deletions}${g.truncated?" (truncated)":""}`})))}).catch(y=>{s===q.current&&Ye(de(y,r("preview.diff.failedTitle")))}).finally(()=>{s===q.current&&De(!1)}),()=>{q.current===s&&(q.current+=1)}},[l==null?void 0:l.taskCompletedAt,(st=l==null?void 0:l.taskDelivery)==null?void 0:st.status,l==null?void 0:l.taskDiffStat,l==null?void 0:l.taskIsolation,f,et,Vt]);const Qt=s=>{ne(d=>({...d,[s]:!d[s]}))},Xt=s=>{ne(Object.fromEntries(_.map(d=>[d.filePath||"unknown",s])))},ie=async s=>{const d=Ae();if(!d)return;const y=M.current,g=++Ne.current,S=()=>g===Ne.current&&Ce.current===s&&K(d,y);Ce.current=s,He(s),be(""),ge(!0),we(null),je(!1);try{const w=await fetch(`/suggestions/files/content?path=${encodeURIComponent(s)}`,{headers:Ie(d)});if(!w.ok)throw new Error(r("preview.files.contentFailed"));const L=await w.json();S()&&(be(L.content||""),je(!!L.truncated))}catch(w){S()&&we(de(w,r("preview.files.contentFailed")))}finally{S()&&ge(!1)}},Yt=s=>{if(s.key==="ArrowDown"||s.key==="ArrowUp"){s.preventDefault(),re(d=>Fr(d,Y.length,s.key==="ArrowDown"?1:-1));return}if(s.key==="Enter"){const d=Y[xe];if(!d)return;s.preventDefault(),ie(d);return}s.key==="Escape"&&(s.preventDefault(),me(""))},Fe=(s,d)=>{const y={...Ee.current,[s]:d};Ee.current=y,Be(y)},tt=async s=>{const d=(B.current[s]??0)+1;B.current[s]=d,Fe(s,{status:"loading"});const y=Ae();if(!y)return;const g=M.current,S=()=>B.current[s]===d&&I.current[s]===!0&&K(y,g);try{const w=await Je(y,s);if(S()){const L={...oe.current,[s]:w};oe.current=L,Me(L),Fe(s,{status:"loaded"})}}catch(w){S()&&Fe(s,{status:"error",message:de(w,r("preview.files.treeFailed"))})}},Zt=s=>{const d=!I.current[s],y={...I.current,[s]:d};if(I.current=y,ve(y),!d){B.current[s]=(B.current[s]??0)+1;return}oe.current[s]||tt(s)},er=s=>{if(!I.current[s]){const d={...I.current,[s]:!0};I.current=d,ve(d)}tt(s)},tr=s=>{s.preventDefault(),s.currentTarget.setPointerCapture(s.pointerId),Te.current=c,G(!0),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},rr=s=>{if(!T)return;const d=xt(window.innerWidth-s.clientX);Te.current=d,N(d)},rt=s=>{T&&(s.currentTarget.hasPointerCapture(s.pointerId)&&s.currentTarget.releasePointerCapture(s.pointerId),G(!1),N(null),i(Te.current),document.body.style.cursor="",document.body.style.userSelect="")};o.useEffect(()=>()=>{document.body.style.cursor="",document.body.style.userSelect=""},[]);const Pe=xt(F??c);return e.jsxs("div",{ref:Se,"data-testid":"file-preview",role:C?"dialog":"complementary","aria-modal":C||void 0,"aria-label":r("preview.title"),onKeyDown:Ht,style:n?{width:"100%",maxWidth:"none"}:{width:Pe,maxWidth:"72vw"},className:R("relative flex h-full flex-col bg-[hsl(var(--deck-canvas))] max-lg:fixed max-lg:inset-0 max-lg:z-[60] max-lg:!h-dvh max-lg:!w-full max-lg:!max-w-full max-lg:min-w-0 max-lg:border-l-0",n?"absolute inset-0 z-20 min-w-0 border-l-0 shadow-none":"border-l shadow-xl min-w-[360px] shrink-0 border-[hsl(var(--deck-border))]"),children:[!n&&e.jsx("div",{role:"separator","aria-label":r("preview.action.resize"),"aria-orientation":"vertical","aria-valuemin":Lt,"aria-valuemax":_e,"aria-valuenow":Pe,"aria-hidden":C||void 0,tabIndex:C?-1:0,onPointerDown:tr,onPointerMove:rr,onPointerUp:rt,onPointerCancel:rt,onDoubleClick:()=>i($r),onKeyDown:s=>{s.key!=="ArrowLeft"&&s.key!=="ArrowRight"||(s.preventDefault(),i(Pe+(s.key==="ArrowLeft"?24:-24)))},className:R("absolute inset-y-0 -left-1 z-20 w-2 cursor-col-resize touch-none outline-none max-lg:hidden","after:absolute after:inset-y-0 after:left-1/2 after:w-px after:-translate-x-1/2 after:bg-transparent after:transition-colors","hover:after:bg-[hsl(var(--deck-accent)/0.6)] focus-visible:after:bg-[hsl(var(--deck-accent))]",T&&"after:bg-[hsl(var(--deck-accent))]")}),e.jsxs(xr,{value:p,onValueChange:s=>{const d=s;j(d),u(d)},className:"flex flex-col flex-1 min-h-0",children:[e.jsxs("div",{"data-preview-toolbar":!0,className:"flex shrink-0 items-center gap-2 border-b border-[hsl(var(--deck-border))] px-3 py-3",children:[e.jsxs(vr,{className:"grid h-9 min-w-0 flex-1 grid-cols-4 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] p-1",children:[e.jsx(ce,{value:"diff",className:"px-2 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))] data-[state=active]:bg-[hsl(var(--deck-canvas-veil))] data-[state=active]:text-[hsl(var(--deck-ink))]",children:r("preview.tab.diff")}),e.jsx(ce,{value:"files",className:"px-2 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))] data-[state=active]:bg-[hsl(var(--deck-canvas-veil))] data-[state=active]:text-[hsl(var(--deck-ink))]",children:r("preview.tab.files")}),e.jsx(ce,{value:"logs",className:"px-2 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))] data-[state=active]:bg-[hsl(var(--deck-canvas-veil))] data-[state=active]:text-[hsl(var(--deck-ink))]",children:r("preview.tab.logs")}),e.jsx(ce,{value:"browser",className:"px-2 font-mono text-[12px] text-[hsl(var(--deck-ink-muted))] data-[state=active]:bg-[hsl(var(--deck-canvas-veil))] data-[state=active]:text-[hsl(var(--deck-ink))]",children:r("preview.tab.browser")})]}),C&&e.jsx(A,{ref:Ge,variant:"ghost",size:"icon",onClick:a,"aria-label":r("preview.action.close"),title:r("preview.action.close"),className:"h-9 w-9 shrink-0 rounded-md text-[hsl(var(--deck-ink-faint))] hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))]",children:e.jsx(mr,{className:"w-4 h-4"})})]}),e.jsx(le,{value:"diff",className:"overflow-hidden flex-1 mt-0",children:e.jsx("div",{className:"overflow-y-auto px-4 py-4 space-y-3 h-full",children:Le?e.jsx($,{title:r("preview.diff.discardedTitle"),subtitle:r("preview.diff.discardedHint"),role:"status"}):Gt&&_.length===0?e.jsx($,{title:r("preview.diff.loadingTitle"),subtitle:r("preview.diff.loadingHint")}):Xe&&_.length===0?e.jsx($,{title:r("preview.diff.failedTitle"),subtitle:Xe,actionLabel:r("preview.action.retry"),onAction:()=>Kt(s=>s+1),role:"alert"}):_.length===0?e.jsx($,{title:r("preview.diff.emptyTitle"),subtitle:r("preview.diff.emptyHint")}):e.jsx(Pr,{diffs:_,expanded:Bt,targetPath:x,onToggle:Qt,onSetAllExpanded:Xt})})}),e.jsx(le,{value:"files",className:"overflow-hidden flex-1 mt-0",children:e.jsxs("div",{className:"px-4 py-4 h-full",children:[Q&&e.jsx($,{title:r("preview.files.loadingTitle"),subtitle:r("preview.files.loadingHint")}),!Q&&X&&e.jsx($,{title:r("preview.files.failedTitle"),subtitle:X,actionLabel:r("preview.action.retry"),onAction:()=>Wt(s=>s+1),role:"alert"}),!Q&&!X&&V.length===0&&e.jsx($,{title:r("preview.files.emptyTitle"),subtitle:r("preview.files.emptyHint")}),!Q&&!X&&V.length>0&&e.jsxs("div",{className:"grid h-full min-h-0 grid-cols-[minmax(170px,220px)_minmax(0,1fr)] gap-3 max-sm:grid-cols-1 max-sm:grid-rows-[180px_minmax(0,1fr)]",children:[e.jsxs("div",{className:"flex min-h-0 flex-col overflow-hidden rounded-lg border border-[hsl(var(--deck-border))]",children:[e.jsx("div",{className:"border-b border-[hsl(var(--deck-border))] p-2",children:e.jsxs("div",{className:"flex h-8 items-center gap-2 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-2 focus-within:border-[hsl(var(--deck-accent)/0.6)]",children:[e.jsx(ze,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("input",{type:"search","aria-label":r("preview.files.searchAria"),placeholder:r("preview.files.searchPlaceholder"),value:z,onChange:s=>me(s.target.value),onKeyDown:Yt,className:"min-w-0 flex-1 bg-transparent font-mono text-[11px] text-[hsl(var(--deck-ink))] outline-none placeholder:text-[hsl(var(--deck-ink-faint))]"}),qe&&e.jsx($e,{className:"h-3 w-3 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"})]})}),e.jsx("div",{role:z?"listbox":void 0,"aria-label":z?r("preview.files.searchResultsAria"):void 0,className:"overflow-y-auto flex-1 p-2 min-h-0",children:z?_t?e.jsxs("div",{role:"alert",className:"px-2 py-5 text-center font-mono text-[10.5px] text-red-700 dark:text-red-300",children:[e.jsx("div",{children:r("preview.files.searchFailed")}),e.jsx("button",{type:"button",onClick:()=>zt(s=>s+1),className:"mt-1 underline underline-offset-2",children:r("preview.action.retry")})]}):Y.length>0?Y.map((s,d)=>e.jsxs("button",{type:"button",role:"option","aria-selected":d===xe,"data-preview-file-result":d,onMouseEnter:()=>re(d),onClick:()=>void ie(s),className:R("mb-0.5 flex w-full min-w-0 flex-col rounded-md px-2 py-1.5 text-left font-mono transition-colors",d===xe?"bg-[hsl(var(--deck-accent-soft))] text-[hsl(var(--deck-ink))]":"text-[hsl(var(--deck-ink-muted))] hover:bg-[hsl(var(--deck-surface))]"),children:[e.jsx("span",{className:"truncate text-[11.5px]",children:Rt(s)}),e.jsx("span",{className:"truncate text-[9px] text-[hsl(var(--deck-ink-faint))]",children:s})]},s)):!qe&&e.jsx("div",{className:"px-2 py-5 text-center font-mono text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:r("preview.files.noMatches")}):e.jsx(Ar,{nodes:V,expandedDirs:Mt,childrenCache:Pt,directoryStates:It,selectedPath:P,onToggleDir:Zt,onRetryDir:er,onSelectFile:ie})})]}),e.jsxs("div",{className:"border border-[hsl(var(--deck-border))] rounded-lg overflow-hidden flex flex-col min-h-0",children:[e.jsxs("div",{className:"px-3 py-2 bg-[hsl(var(--deck-surface-2))] border-b border-[hsl(var(--deck-border))] text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono flex items-center justify-between",children:[e.jsx("span",{className:"min-w-0 truncate",children:P||r("preview.files.selectTitle")}),P&&e.jsx("span",{className:"ml-2 shrink-0 text-[11px] text-[hsl(var(--deck-ink-faint))] font-mono",children:r(ke?"preview.files.status.loading":Oe?"preview.files.status.truncated":"preview.files.status.ready")})]}),Oe&&!ke&&e.jsx("div",{className:"px-3 py-2 bg-[#FEF3C7] dark:bg-[#111113] border-b border-[hsl(var(--deck-border))] text-[11px] text-[#b45309] dark:text-[#facc15] font-mono",children:r("preview.files.truncatedNotice")}),e.jsxs("div",{className:"flex-1 min-h-0",children:[!P&&e.jsx("div",{className:"h-full flex items-center justify-center text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:r("preview.files.pickHint")}),P&&ye&&e.jsxs("div",{role:"alert",className:"flex h-full flex-col items-center justify-center gap-2 px-4 text-center font-mono text-[12px] text-[#DC2626] dark:text-[#fca5a5]",children:[e.jsx("span",{children:ye}),e.jsx("button",{type:"button",onClick:()=>void ie(P),className:"underline underline-offset-2",children:r("preview.action.retry")})]}),P&&!ye&&e.jsx("div",{className:"h-full",children:ke?e.jsx(yt,{}):e.jsx(o.Suspense,{fallback:e.jsx(yt,{}),children:e.jsx(qr,{content:qt,filename:P})})})]})]})]})]})}),e.jsx(le,{value:"logs",className:"overflow-hidden flex-1 mt-0",children:e.jsx(Wr,{logs:Jt})}),e.jsx(le,{value:"browser",forceMount:!0,className:"overflow-hidden flex-1 min-h-0",children:e.jsx(Rr,{})})]})]})}function $({title:t,subtitle:n,actionLabel:r,onAction:a,role:c}){return e.jsxs("div",{role:c,className:"border border-dashed border-[hsl(var(--deck-border))] rounded-lg p-6 text-center",children:[e.jsx("div",{className:"text-[13px] text-[hsl(var(--deck-ink))] font-mono",children:t}),e.jsx("div",{className:"text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono mt-1",children:n}),r&&a&&e.jsx("button",{type:"button",onClick:a,className:"mt-3 rounded-md border border-[hsl(var(--deck-border))] px-2.5 py-1 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] transition-colors hover:bg-[hsl(var(--deck-surface))] hover:text-[hsl(var(--deck-ink))]",children:r})]})}function Mr(t){return t.flatMap(n=>{var c,i,k;const r=[];if((c=n.agentContent)!=null&&c.toolCalls)for(const u of n.agentContent.toolCalls){const x=gt(u.arguments),h=u.output,m=h?(i=U(h))!=null&&i.diff?kt(h):h:void 0;r.push({id:`${n.id}-${u.toolCallId}`,title:u.toolName||"Tool",subtitle:u.summary,status:u.status==="success"?"success":u.status==="error"?"error":"running",content:m||(x?`Arguments:
7
- ${x}`:void 0),timestamp:n.timestamp})}const a=n.metadata;if(a){if(a.kind==="tool_call"){const u=a.toolName||"Tool",x=gt(a.arguments);r.push({id:n.id,title:`Tool Call · ${u}`,subtitle:a.toolKind?String(a.toolKind):void 0,status:a.status==="success"?"success":a.status==="error"?"error":"running",content:x?`Arguments:
8
- ${x}`:void 0,timestamp:n.timestamp})}if(a.kind==="tool_result"){const u=a.toolName||"Tool",x=a.success,h=a.summary,m=a.output,f=m?(k=U(m))!=null&&k.diff?kt(m):m:void 0;r.push({id:n.id,title:`Tool Result · ${u}`,subtitle:h,status:x===void 0?"running":x?"success":"error",content:f,timestamp:n.timestamp})}}return r})}function Br(t){var a;const n=[],r=new Set;for(let c=t.length-1;c>=0;c-=1){const i=t[c];if((a=i.agentContent)!=null&&a.toolCalls)for(let m=i.agentContent.toolCalls.length-1;m>=0;m-=1){const f=i.agentContent.toolCalls[m],v=f.metadata;if((v==null?void 0:v.kind)==="patch"&&Array.isArray(v.changes)){bt(n,r,v.changes,f.summary);continue}const E=f.output||"",l=U(E)||U((v==null?void 0:v.diff_snippet)||"");if(l!=null&&l.diff){const b=(v==null?void 0:v.file_path)||f.toolName||"unknown";if(!r.has(b)){r.add(b);const p=typeof(v==null?void 0:v.oldContent)=="string"?v.oldContent:void 0,j=typeof(v==null?void 0:v.newContent)=="string"?v.newContent:void 0;n.push({diff:l.diff,filePath:b,summary:f.summary,oldContent:p,newContent:j})}}}const k=i.metadata;if(!k||k.kind!=="tool_result")continue;const u=k.metadata;if((u==null?void 0:u.kind)==="patch"&&Array.isArray(u.changes)){bt(n,r,u.changes,k.summary);continue}const x=k.output||(typeof i.content=="string"?i.content:"")||"",h=U(x)||U((u==null?void 0:u.diff_snippet)||"");if(h!=null&&h.diff){const m=(u==null?void 0:u.file_path)||k.toolName||"unknown";if(!r.has(m)){r.add(m);const f=typeof(u==null?void 0:u.oldContent)=="string"?u.oldContent:void 0,v=typeof(u==null?void 0:u.newContent)=="string"?u.newContent:void 0;n.push({diff:h.diff,filePath:m,summary:k.summary,oldContent:f,newContent:v})}}}return n.reverse()}function bt(t,n,r,a){for(let c=r.length-1;c>=0;c--){const i=r[c];!i||typeof i!="object"||!("path"in i)||typeof i.path!="string"||!("diff"in i)||typeof i.diff!="string"||n.has(i.path)||(n.add(i.path),t.push({diff:{patch:i.diff,startLine:1,matchLine:1},filePath:i.path,summary:a,oldContent:"oldContent"in i&&typeof i.oldContent=="string"?i.oldContent:void 0,newContent:"newContent"in i&&typeof i.newContent=="string"?i.newContent:void 0}))}}function U(t){if(!t)return null;const n=/<<<DIFF>>>\s*([\s\S]*?)\s*<<<\/DIFF>>>/m,r=t.match(n);if(!r)return null;try{return{diff:JSON.parse(r[1])}}catch{return null}}function kt(t){return t?t.replace(/<<<DIFF>>>[\s\S]*?<<<\/DIFF>>>/m,"").trim():""}function gt(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)}function yt(){const t=W();return e.jsx("div",{className:"h-full flex items-center justify-center text-[12px] text-[hsl(var(--deck-ink-muted))] font-mono",children:t("preview.files.editorLoading")})}function qr({content:t,filename:n}){const{codeTheme:r}=sr(),a=o.useRef(null),[c,i]=o.useState("vs-dark"),k=Hr(n),u=x=>{a.current=x;const h=it(x,r);i(h)};return o.useEffect(()=>{if(a.current){const x=it(a.current,r);i(x)}},[r]),e.jsx(zr,{value:t,language:k,theme:c,height:"100%",beforeMount:u,options:{readOnly:!0,minimap:{enabled:!1},fontSize:12,lineNumbers:"on",wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0}},n)}function Hr(t){var a;const n=((a=t.split(".").pop())==null?void 0:a.toLowerCase())||"";return{ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",json:"json",md:"markdown",css:"css",scss:"scss",html:"html",yml:"yaml",yaml:"yaml",go:"go",rs:"rust",py:"python",java:"java",c:"c",cpp:"cpp",h:"cpp",hpp:"cpp",sh:"shell",zsh:"shell",toml:"toml",xml:"xml"}[n]||"plaintext"}export{Qr as FilePreview,Jr as PreviewControls};
@@ -1 +0,0 @@
1
- import{j as e,r as p}from"./vendor-react-DG5dkZ_t.js";import{u as Y,c as g,d as M,p as ne,q as pe,j as P,r as be,D as fe,e as ve,f as ge,g as je,h as Ne,i as ye,t as ee,a as o,v as we,b as Q,w as Se,P as Pe}from"./index-ebnhtfFC.js";import{ab as re,ac as Te,ad as Ce,L as E,R as De,S as Ie,P as Ae,A as _e,E as Ke,U as Ee,f as Fe,a8 as Re,e as se,ae as Oe,a3 as qe,a2 as Le,i as Me,l as Be,c as ze,W as Ue,a as Qe}from"./vendor-icons-CX5BfgqQ.js";import"./vendor-radix-DXRuAJHH.js";import"./session-events-Bgir_Gl_.js";const G=["waiting","active","blocked","review"],ae={high:0,medium:1,low:2};function Ye(t){return t.taskIsolation!==void 0||t.taskPromptSummary!==void 0||t.taskRetryAvailable===!0}function te(t){return t.taskSourceProjectPath||t.projectPath}function Ve(t){return t.pendingInteraction?"blocked":t.taskStatus==="queued"?"waiting":t.taskStatus==="running"?"active":t.taskStatus==="completed"?"review":"blocked"}function He(t,r){if(t.pendingInteraction!==r.pendingInteraction)return t.pendingInteraction?-1:1;const i=ae[t.taskPriority??"medium"]-ae[r.taskPriority??"medium"];if(i!==0)return i;const u=t.taskDueAt?Date.parse(t.taskDueAt):Number.POSITIVE_INFINITY,n=r.taskDueAt?Date.parse(r.taskDueAt):Number.POSITIVE_INFINITY;if(u!==n)return u-n;if(t.taskStatus==="queued"&&r.taskStatus==="queued"){const m=(t.taskQueuePosition??Number.POSITIVE_INFINITY)-(r.taskQueuePosition??Number.POSITIVE_INFINITY);if(m!==0)return m}return r.lastMessageTime.localeCompare(t.lastMessageTime)}function We(t){const r={waiting:[],active:[],blocked:[],review:[]};for(const i of t)Ye(i)&&r[Ve(i)].push(i);for(const i of G)r[i].sort(He);return r}function $e(t){return`TASK-${t.replace(/^task-?/,"").slice(0,6).toUpperCase()}`}const Ge={high:{label:"kanban.priority.high",className:"border-red-200 bg-red-50 text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300"},medium:{label:"kanban.priority.medium",className:"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900/70 dark:bg-amber-950/35 dark:text-amber-300"},low:{label:"kanban.priority.low",className:"border-zinc-200 bg-zinc-50 text-zinc-600 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-400"}},Je={feature:"kanban.kind.feature",bug:"kanban.kind.bug",maintenance:"kanban.kind.maintenance",research:"kanban.kind.research"};function Xe(t){const r=new Date(t);return Number.isNaN(r.getTime())?"":new Intl.DateTimeFormat(be()==="zh"?"zh-CN":"en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(r)}function K({label:t,onClick:r,disabled:i,tone:u="neutral",children:n}){return e.jsx("button",{type:"button","aria-label":t,title:t,disabled:i,onClick:r,className:P("flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-colors focus-visible:outline-none focus-visible:ring-1 disabled:cursor-wait disabled:opacity-45",u==="danger"?"text-red-500 hover:bg-red-500/10 focus-visible:ring-red-500":u==="accent"?"text-[hsl(var(--deck-accent))] hover:bg-[hsl(var(--deck-accent-soft))] focus-visible:ring-[hsl(var(--deck-accent))]":"text-[hsl(var(--deck-ink-faint))] hover:bg-[hsl(var(--deck-surface-2))] hover:text-[hsl(var(--deck-ink))] focus-visible:ring-[hsl(var(--deck-accent))]"),children:n})}function Ze({session:t,unread:r,cancelling:i,retrying:u,updating:n,onOpen:m,onInspect:T,onEdit:C,onCancel:y,onRetry:c,onArchive:k}){const l=Y(),w=g(t),f=M(w),b=ne(t,l),v=Ge[t.taskPriority??"medium"],x=t.taskKind??"feature",h=pe(t,l),D=t.taskSourceProjectPath||t.projectPath,I=D.split("/").filter(Boolean).at(-1)||D,F=t.taskStatus==="queued"||t.taskStatus==="running",N=!!t.taskRetryAvailable&&["failed","interrupted","cancelled"].includes(t.taskStatus),A=!!t.pendingInteraction,S=t.taskStatus==="completed";return e.jsxs("article",{"data-kanban-task":f,className:P("group rounded-md border bg-[hsl(var(--deck-surface))] px-3 py-3 shadow-[0_1px_2px_hsl(var(--deck-ink)/0.04)] transition-[border-color,box-shadow,transform]","border-[hsl(var(--deck-border))] hover:-translate-y-px hover:border-[hsl(var(--deck-border-strong))] hover:shadow-[0_8px_24px_-16px_hsl(var(--deck-ink)/0.35)]",r&&"border-[hsl(var(--deck-accent)/0.55)]"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-mono text-[9.5px] uppercase text-[hsl(var(--deck-ink-faint))]",children:$e(t.sessionId)}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[r&&e.jsx("span",{"aria-label":l("kanban.card.unread"),title:l("kanban.card.unread"),className:"h-1.5 w-1.5 rounded-full bg-[hsl(var(--deck-accent))] shadow-[0_0_6px_hsl(var(--deck-accent-glow)/0.8)]"}),e.jsx("span",{className:"truncate font-mono text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:I})]})]}),e.jsx("button",{type:"button",onClick:m,className:"mt-2 block w-full text-left text-[13px] font-medium leading-[1.45] text-[hsl(var(--deck-ink))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))]",children:b}),h&&e.jsx("p",{title:h,className:P("mt-1.5 line-clamp-2 text-[10.5px] leading-[1.45]",A||t.taskStatus==="failed"?"text-red-600 dark:text-red-400":"text-[hsl(var(--deck-ink-faint))]"),children:h}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-1",children:[e.jsx("span",{className:P("rounded-sm border px-1.5 py-0.5 font-mono text-[9px] font-medium",v.className),children:l(v.label)}),e.jsx("span",{className:"rounded-sm border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-1.5 py-0.5 font-mono text-[9px] text-[hsl(var(--deck-ink-muted))]",children:l(Je[x])}),t.taskDueAt&&e.jsxs("span",{className:P("inline-flex items-center gap-1 rounded-sm border px-1.5 py-0.5 font-mono text-[9px]",Date.parse(t.taskDueAt)<Date.now()&&!S?"border-red-200 bg-red-50 text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300":"border-[hsl(var(--deck-border))] text-[hsl(var(--deck-ink-faint))]"),children:[e.jsx(re,{className:"h-2.5 w-2.5"}),Xe(t.taskDueAt)]})]}),t.taskStatus==="queued"&&t.taskQueuePosition&&e.jsx("div",{className:"mt-2 font-mono text-[9.5px] text-amber-700 dark:text-amber-400",children:l("kanban.card.queuePosition",{position:t.taskQueuePosition,depth:t.taskQueueDepth??t.taskQueuePosition})}),t.taskDiffStat&&e.jsx("div",{className:"mt-2 font-mono text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:l("kanban.card.diff",{files:t.taskDiffStat.changedFiles,additions:t.taskDiffStat.additions,deletions:t.taskDiffStat.deletions})}),e.jsxs("div",{className:"mt-3 flex items-center justify-end gap-0.5 border-t border-[hsl(var(--deck-hairline))] pt-2",children:[A&&e.jsx(K,{label:l("kanban.action.respond"),onClick:m,tone:"danger",children:e.jsx(Te,{className:"h-3.5 w-3.5"})}),S&&e.jsx(K,{label:l("kanban.action.inspect"),onClick:T,tone:"accent",children:e.jsx(Ce,{className:"h-3.5 w-3.5"})}),N&&e.jsx(K,{label:l("kanban.action.retry"),onClick:c,disabled:u,tone:"accent",children:u?e.jsx(E,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(De,{className:"h-3.5 w-3.5"})}),F&&e.jsx(K,{label:l("kanban.action.cancel"),onClick:y,disabled:i,tone:"danger",children:i?e.jsx(E,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Ie,{className:"h-3.5 w-3.5"})}),e.jsx(K,{label:l("kanban.action.edit"),onClick:C,disabled:n,children:n?e.jsx(E,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Ae,{className:"h-3.5 w-3.5"})}),S&&e.jsx(K,{label:l("kanban.action.archive"),onClick:k,children:e.jsx(_e,{className:"h-3.5 w-3.5"})}),e.jsx(K,{label:l("kanban.action.open"),onClick:m,children:e.jsx(Ke,{className:"h-3.5 w-3.5"})})]})]})}const ea={waiting:{title:"kanban.column.waiting",description:"kanban.column.waitingDescription",icon:Re,accent:"bg-amber-400",iconStyle:"text-amber-700 dark:text-amber-400"},active:{title:"kanban.column.active",description:"kanban.column.activeDescription",icon:E,accent:"bg-blue-500",iconStyle:"text-blue-700 dark:text-blue-400"},blocked:{title:"kanban.column.blocked",description:"kanban.column.blockedDescription",icon:Fe,accent:"bg-red-500",iconStyle:"text-red-700 dark:text-red-400"},review:{title:"kanban.column.review",description:"kanban.column.reviewDescription",icon:Ee,accent:"bg-[hsl(var(--deck-accent))]",iconStyle:"text-[hsl(var(--deck-accent))]"}};function aa({id:t,sessions:r,unreadTaskKeys:i,cancellingTaskKeys:u,retryingTaskKeys:n,updatingTaskKeys:m,taskKey:T,onOpen:C,onInspect:y,onEdit:c,onCancel:k,onRetry:l,onArchive:w}){const f=Y(),b=ea[t],v=b.icon;return e.jsxs("section",{"data-kanban-column":t,"aria-labelledby":`kanban-column-${t}`,className:"flex min-h-[180px] min-w-0 flex-col border-t-2 border-[hsl(var(--deck-hairline))] pt-3 md:min-h-[360px]",children:[e.jsxs("header",{className:"mb-3 flex min-h-12 items-start gap-2 px-0.5",children:[e.jsx(v,{className:P("mt-0.5 h-3.5 w-3.5 shrink-0",b.iconStyle,t==="active"&&"animate-spin")}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{id:`kanban-column-${t}`,className:"font-mono text-[11px] font-semibold uppercase text-[hsl(var(--deck-ink))]",children:f(b.title)}),e.jsx("span",{className:"min-w-5 rounded-sm bg-[hsl(var(--deck-surface-2))] px-1.5 py-0.5 text-center font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:r.length})]}),e.jsx("p",{className:"mt-0.5 text-[10px] leading-4 text-[hsl(var(--deck-ink-faint))]",children:f(b.description)})]}),e.jsx("span",{className:P("mt-1 h-1.5 w-1.5 shrink-0 rounded-full",b.accent)})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-2.5",children:[r.map(x=>{const h=T(x);return e.jsx(Ze,{session:x,unread:i.includes(h),cancelling:u.includes(h),retrying:n.includes(h),updating:m.includes(h),onOpen:()=>C(x),onInspect:()=>y(x),onEdit:()=>c(x),onCancel:()=>k(x),onRetry:()=>l(x),onArchive:()=>w(x)},h)}),r.length===0&&e.jsx("div",{className:"flex min-h-28 items-center justify-center rounded-md border border-dashed border-[hsl(var(--deck-border))] px-4 text-center font-mono text-[10px] leading-4 text-[hsl(var(--deck-ink-faint))]",children:f("kanban.column.empty")})]})]})}function ta(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?"":new Date(r.getTime()-r.getTimezoneOffset()*6e4).toISOString().slice(0,16)}function na({open:t,onOpenChange:r,projects:i,defaultProjectPath:u,session:n,submitting:m,canCreate:T,onCreate:C,onUpdate:y}){const c=Y(),k=!!n,[l,w]=p.useState(""),[f,b]=p.useState(""),[v,x]=p.useState(u??""),[h,D]=p.useState("medium"),[I,F]=p.useState("feature"),[N,A]=p.useState(""),[S,R]=p.useState(null);p.useEffect(()=>{var s;t&&(w((n==null?void 0:n.title)??""),b((n==null?void 0:n.taskPromptSummary)??""),x((n==null?void 0:n.taskSourceProjectPath)??(n==null?void 0:n.projectPath)??u??((s=i.find(j=>j.available))==null?void 0:s.path)??""),D((n==null?void 0:n.taskPriority)??"medium"),F((n==null?void 0:n.taskKind)??"feature"),A(ta(n==null?void 0:n.taskDueAt)),R(null))},[u,t,i,n]);const B=async s=>{s.preventDefault();const j=l.trim(),z=f.trim();if(!(!k&&(!z||!v))){R(null);try{k?await y({...j?{title:j}:{},taskPriority:h,taskKind:I,taskDueAt:N?new Date(N).toISOString():null}):await C({...j?{title:j}:{},prompt:z,projectPath:v,taskPriority:h,taskKind:I,...N?{taskDueAt:new Date(N).toISOString()}:{}}),r(!1)}catch(O){R(O instanceof Error?O.message:c("kanban.dialog.submitFailed"))}}};return e.jsx(fe,{open:t,onOpenChange:r,children:e.jsxs(ve,{className:"max-w-[560px] gap-0 overflow-hidden border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] p-0",children:[e.jsxs(ge,{className:"border-b border-[hsl(var(--deck-hairline))] px-5 py-4",children:[e.jsx(je,{className:"font-mono text-[15px] text-[hsl(var(--deck-ink))]",children:c(k?"kanban.dialog.editTitle":"kanban.dialog.createTitle")}),e.jsx(Ne,{className:"text-[11.5px] text-[hsl(var(--deck-ink-faint))]",children:c(k?"kanban.dialog.editDescription":"kanban.dialog.createDescription")})]}),e.jsxs("form",{onSubmit:B,children:[e.jsxs("div",{className:"grid gap-4 px-5 py-5",children:[e.jsxs("label",{className:"grid gap-1.5",children:[e.jsx("span",{className:"font-mono text-[10px] uppercase text-[hsl(var(--deck-ink-muted))]",children:c("kanban.field.title")}),e.jsx("input",{value:l,onChange:s=>w(s.target.value),maxLength:200,className:"field",placeholder:c("kanban.field.titlePlaceholder")})]}),!k&&e.jsxs("label",{className:"grid gap-1.5",children:[e.jsx("span",{className:"font-mono text-[10px] uppercase text-[hsl(var(--deck-ink-muted))]",children:c("kanban.field.prompt")}),e.jsx("textarea",{required:!0,value:f,onChange:s=>b(s.target.value),maxLength:32e3,rows:6,className:"min-h-32 w-full resize-y rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))] px-3 py-2.5 text-[13px] leading-5 text-[hsl(var(--deck-ink))] outline-none placeholder:text-[hsl(var(--deck-ink-faint))] focus:border-[hsl(var(--deck-accent)/0.6)] focus:ring-1 focus:ring-[hsl(var(--deck-accent)/0.35)]",placeholder:c("kanban.field.promptPlaceholder")})]}),!k&&e.jsxs("label",{className:"grid gap-1.5",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-[10px] uppercase text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(se,{className:"h-3 w-3"}),c("kanban.field.project")]}),e.jsx("select",{required:!0,value:v,onChange:s=>x(s.target.value),className:"field",children:i.filter(s=>s.available).map(s=>e.jsx("option",{value:s.path,children:s.name},s.path))})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs("label",{className:"grid gap-1.5",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-[10px] uppercase text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(Oe,{className:"h-3 w-3"}),c("kanban.field.kind")]}),e.jsxs("select",{value:I,onChange:s=>F(s.target.value),className:"field",children:[e.jsx("option",{value:"feature",children:c("kanban.kind.feature")}),e.jsx("option",{value:"bug",children:c("kanban.kind.bug")}),e.jsx("option",{value:"maintenance",children:c("kanban.kind.maintenance")}),e.jsx("option",{value:"research",children:c("kanban.kind.research")})]})]}),e.jsxs("label",{className:"grid gap-1.5",children:[e.jsx("span",{className:"font-mono text-[10px] uppercase text-[hsl(var(--deck-ink-muted))]",children:c("kanban.field.priority")}),e.jsxs("select",{value:h,onChange:s=>D(s.target.value),className:"field",children:[e.jsx("option",{value:"high",children:c("kanban.priority.high")}),e.jsx("option",{value:"medium",children:c("kanban.priority.medium")}),e.jsx("option",{value:"low",children:c("kanban.priority.low")})]})]}),e.jsxs("label",{className:"grid gap-1.5",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-[10px] uppercase text-[hsl(var(--deck-ink-muted))]",children:[e.jsx(re,{className:"h-3 w-3"}),c("kanban.field.dueAt")]}),e.jsx("input",{type:"datetime-local",value:N,onChange:s=>A(s.target.value),className:"field min-w-0"})]})]}),!k&&e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-3 py-2 font-mono text-[10px] text-[hsl(var(--deck-ink-muted))]",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[hsl(var(--deck-accent))]"}),c("kanban.dialog.localExecution")]}),S&&e.jsx("div",{role:"alert",className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[11px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:S})]}),e.jsxs(ye,{className:"border-t border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface-2))]/60 px-5 py-3",children:[e.jsx(ee,{type:"button",variant:"ghost",onClick:()=>r(!1),disabled:m,children:c("kanban.dialog.cancel")}),e.jsxs(ee,{type:"submit",disabled:m||!k&&(!T||!f.trim()||!v),className:"gap-2",children:[m&&e.jsx(E,{className:"h-3.5 w-3.5 animate-spin"}),c(k?"kanban.dialog.save":"kanban.dialog.dispatch")]})]})]})]})})}function oa(){var Z;const t=Y(),r=o(a=>a.sessions),i=o(a=>a.boundProjects),u=o(a=>a.selectedProjectPath),n=o(a=>a.taskWorkspaceInfo),m=o(a=>a.catalogLoadState),T=o(a=>a.taskEventConnectionState),C=o(a=>a.isDispatchingTask),y=o(a=>a.isUpdatingTaskAdmission),c=o(a=>a.cancellingTaskKeys),k=o(a=>a.retryingTaskKeys),l=o(a=>a.updatingTaskKeys),w=o(a=>a.unreadTaskKeys),f=o(a=>a.error),b=o(a=>a.selectProject),v=o(a=>a.selectSession),x=o(a=>a.dispatchTask),h=o(a=>a.updateTask),D=o(a=>a.cancelTask),I=o(a=>a.retryTask),F=o(a=>a.archiveSession),N=o(a=>a.setTaskAdmissionPaused),A=o(a=>a.reconnectTaskEvents),S=o(a=>a.clearError),R=we(a=>a.currentMode),B=Q(a=>a.setMainView),s=Q(a=>a.boardProjectPath),j=Q(a=>a.setBoardProjectPath),z=Q(a=>a.openFilePreview),[O,ce]=p.useState(""),[ie,V]=p.useState(!1),[le,H]=p.useState(null),[oe,W]=p.useState(!1);p.useEffect(()=>{s&&!i.some(a=>a.path===s&&a.available)&&j(null)},[s,i,j]);const q=r.find(a=>M(g(a))===le)??null,$=O.trim().toLowerCase(),J=p.useMemo(()=>r.filter(a=>s&&te(a)!==s?!1:$?[a.sessionId,ne(a,t),a.taskPromptSummary,te(a),a.taskPriority,a.taskKind].filter(Boolean).join(" ").toLowerCase().includes($):!0),[s,$,r,t]),X=p.useMemo(()=>We(J),[J]),de=G.reduce((a,d)=>a+X[d].length,0),_=n==null?void 0:n.taskAdmission,L=_?!_.paused:!0,U=i.filter(a=>a.available),ue=s??u??((Z=U[0])==null?void 0:Z.path)??null,me=q?l.includes(M(g(q))):C,ke=async a=>{B("workspace"),await v(g(a))},xe=async a=>{B("workspace"),await v(g(a)),z({tab:"diff"})},he=async a=>{b(a.projectPath),await x({...a,isolation:"local",permissionMode:R},{selectSession:!1})};return e.jsxs("main",{"data-kanban-board":!0,className:"flex h-full min-w-0 flex-col overflow-hidden bg-[hsl(var(--deck-canvas))] text-[hsl(var(--deck-ink))]",children:[e.jsxs("div",{className:"border-b border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas))] px-4 py-3 sm:px-6",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h1",{className:"font-mono text-[15px] font-semibold",children:t("kanban.title")}),e.jsx("span",{className:"rounded-sm border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-1.5 py-0.5 font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:t("kanban.taskCount",{count:de})})]}),e.jsx("p",{className:"mt-0.5 text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:t("kanban.subtitle")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[_&&e.jsx("div",{className:"hidden rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-2.5 py-1.5 lg:block",children:e.jsx(Se,{inFlight:_.inFlight,queued:_.queued,maxConcurrent:_.maxConcurrent,compact:!0})}),e.jsxs("button",{type:"button",role:"switch","aria-checked":L,disabled:!_||y,onClick:()=>{N(L).catch(()=>{})},className:P("inline-flex h-8 items-center gap-2 rounded-md border px-2.5 font-mono text-[10.5px] transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))] disabled:opacity-45",L?"border-[hsl(var(--deck-accent)/0.45)] bg-[hsl(var(--deck-accent-soft))] text-[hsl(var(--deck-accent))]":"border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] text-[hsl(var(--deck-ink-muted))]"),children:[y?e.jsx(E,{className:"h-3 w-3 animate-spin"}):L?e.jsx(qe,{className:"h-3 w-3 fill-current"}):e.jsx(Le,{className:"h-3 w-3"}),t(L?"kanban.autoClaim.running":"kanban.autoClaim.paused")]}),e.jsxs("button",{type:"button",onClick:()=>{if(U.length===0){W(!0);return}H(null),V(!0)},className:"inline-flex h-8 items-center gap-1.5 rounded-md bg-[hsl(var(--deck-ink))] px-3 font-mono text-[10.5px] font-medium text-[hsl(var(--deck-canvas))] transition-opacity hover:opacity-85 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[hsl(var(--deck-accent))]",children:[e.jsx(Me,{className:"h-3.5 w-3.5"}),t("kanban.action.newTask")]})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[e.jsxs("label",{className:"relative min-w-[180px] flex-1 sm:max-w-[320px]",children:[e.jsx(Be,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("input",{type:"search",value:O,onChange:a=>ce(a.target.value),"aria-label":t("kanban.searchAria"),placeholder:t("kanban.searchPlaceholder"),className:"h-8 w-full rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] pl-8 pr-3 font-mono text-[10.5px] text-[hsl(var(--deck-ink))] outline-none placeholder:text-[hsl(var(--deck-ink-faint))] focus:border-[hsl(var(--deck-accent)/0.55)] focus:ring-1 focus:ring-[hsl(var(--deck-accent)/0.25)]"})]}),e.jsxs("label",{className:"relative",children:[e.jsx(se,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-[hsl(var(--deck-accent))]"}),e.jsxs("select",{value:s??"__all__",onChange:a=>{const d=a.target.value;j(d==="__all__"?null:d),d!=="__all__"&&b(d)},"aria-label":t("kanban.projectFilterAria"),className:"h-8 min-w-[160px] appearance-none rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] pl-8 pr-7 font-mono text-[10.5px] text-[hsl(var(--deck-ink-muted))] outline-none focus:border-[hsl(var(--deck-accent)/0.55)]",children:[e.jsx("option",{value:"__all__",children:t("kanban.projectAll")}),U.map(a=>e.jsx("option",{value:a.path,children:a.name},a.path))]})]}),e.jsx("button",{type:"button",onClick:()=>W(!0),"aria-label":t("projects.bind.action"),title:t("projects.bind.action"),className:"flex h-8 w-8 items-center justify-center rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] text-[hsl(var(--deck-ink-faint))] hover:text-[hsl(var(--deck-accent))]",children:e.jsx(ze,{className:"h-3.5 w-3.5"})}),m==="loading"||m==="hydrating"?e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:[e.jsx(E,{className:"h-3 w-3 animate-spin"}),t("sidebar.catalog.syncing")]}):null]})]}),T==="offline"&&e.jsxs("div",{role:"alert",className:"flex items-center gap-2 border-b border-amber-300/60 bg-amber-50/80 px-4 py-2 text-[10.5px] text-amber-800 dark:border-amber-900/70 dark:bg-amber-950/30 dark:text-amber-300 sm:px-6",children:[e.jsx(Ue,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"flex-1",children:t("kanban.feed.offline")}),e.jsxs("button",{type:"button",onClick:()=>void A().catch(()=>{}),className:"inline-flex h-7 items-center gap-1 rounded-md px-2 font-mono hover:bg-amber-100 dark:hover:bg-amber-900/40",children:[e.jsx(Qe,{className:"h-3 w-3"}),t("taskHome.feed.retry")]})]}),f&&e.jsxs("div",{role:"alert",className:"flex items-center gap-3 border-b border-red-200 bg-red-50 px-4 py-2 text-[10.5px] text-red-700 dark:border-red-900/70 dark:bg-red-950/30 dark:text-red-300 sm:px-6",children:[e.jsx("span",{className:"flex-1",children:f}),e.jsx("button",{type:"button",onClick:S,className:"font-mono underline",children:t("taskHome.error.dismiss")})]}),e.jsx("div",{className:"flex-1 overflow-auto px-4 py-4 sm:px-6",children:e.jsx("div",{className:"grid min-w-0 grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-4",children:G.map(a=>e.jsx(aa,{id:a,sessions:X[a],unreadTaskKeys:w,cancellingTaskKeys:c,retryingTaskKeys:k,updatingTaskKeys:l,taskKey:d=>M(g(d)),onOpen:d=>{ke(d).catch(()=>{})},onInspect:d=>{xe(d).catch(()=>{})},onEdit:d=>{H(M(g(d))),V(!0)},onCancel:d=>{D(g(d)).catch(()=>{})},onRetry:d=>{I(g(d)).catch(()=>{})},onArchive:d=>{F(g(d))}},a))})}),e.jsx(na,{open:ie,onOpenChange:a=>{V(a),a||H(null)},projects:i,defaultProjectPath:ue,session:q,submitting:me,canCreate:U.length>0,onCreate:he,onUpdate:async a=>{q&&await h(g(q),a)}}),e.jsx(Pe,{open:oe,onOpenChange:W})]})}export{oa as KanbanBoard};
@@ -1 +0,0 @@
1
- import{j as n,r as d}from"./vendor-react-DG5dkZ_t.js";import{j as S,H as Te,d as G,c as R,p as De,I as q,J as _,L as Ae,u as Ie,b as p,a as o,M as L,o as Fe,D as Le,e as Pe,N as Re,g as qe,h as Ee,s as Me}from"./index-ebnhtfFC.js";import{ak as ue,i as Be,F as Ke,k as Oe,h as $e,al as We,am as Qe,p as He,an as Ue,ao as ze,l as V,f as me,ap as Ve,U as Ge,aq as _e,G as Je,a8 as Xe,L as P,S as Ye,R as Ze}from"./vendor-icons-CX5BfgqQ.js";import"./vendor-radix-DXRuAJHH.js";import"./session-events-Bgir_Gl_.js";function et(t,r){const s=r.trim().toLocaleLowerCase();return s?t.filter(i=>`${i.label} ${i.description} ${i.keywords}`.toLocaleLowerCase().includes(s)):t}function tt({actions:t,selectedIndex:r,onSelect:s,onRun:i}){return t.map((c,u)=>{const k=u===r,m=c.icon;return n.jsx("div",{id:`command-center-result-${u}`,"data-task-result-index":u,role:"option","aria-selected":k,onMouseEnter:()=>s(u),className:S("group flex min-h-[58px] w-full items-center rounded-lg border border-transparent text-left transition-colors",k?"border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]":"hover:bg-[hsl(var(--deck-surface))]/60"),children:n.jsxs("button",{type:"button",onClick:()=>i(c),className:"flex min-h-[58px] min-w-0 flex-1 items-center gap-3 px-3 py-2 text-left focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-[hsl(var(--deck-accent))]",children:[n.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))] text-[hsl(var(--deck-accent))]",children:n.jsx(m,{className:"h-3.5 w-3.5"})}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"block truncate font-mono text-[12.5px] font-medium text-[hsl(var(--deck-ink))]",children:c.label}),n.jsx("span",{className:"mt-0.5 block truncate text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:c.description})]}),c.shortcut&&n.jsx("span",{className:"shrink-0 rounded border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))] px-1.5 py-0.5 font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:c.shortcut}),n.jsx(ue,{className:S("h-3.5 w-3.5 shrink-0 transition-all",k?"translate-x-0 text-[hsl(var(--deck-accent))] opacity-100":"-translate-x-1 text-[hsl(var(--deck-ink-faint))] opacity-0")})]})},c.id)})}const nt={running:"running active 进行中 运行中",queued:"queued waiting 排队中 等待中",interrupted:"interrupted paused 已暂停 已中断",failed:"failed error 已失败 错误",cancelled:"cancelled canceled 已取消",completed:"completed done finished 已完成 完成"};function J(t){return De(t,Ae)}function st(t){const r=t.lastMessageTime||t.firstMessageTime;if(!r)return"";const s=new Date(r);return Number.isNaN(s.getTime())?"":new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(s)}function E(t){return t.normalize("NFKC").toLocaleLowerCase().trim()}function at(t,r){var i,c;const s=q(t,r);return E([J(t),_(s),s,t.projectPath,t.gitBranch,t.taskWorktreeBranch,t.taskStatus,nt[t.taskStatus],((i=t.pendingInteraction)==null?void 0:i.type)==="question"?"needs answer question attention 等待回答 需要回答":((c=t.pendingInteraction)==null?void 0:c.type)==="elicitation"?"mcp input elicitation attention MCP 输入 等待输入":t.pendingInteraction?"needs approval permission attention 等待审批 需要授权":"",t.sessionId].filter(Boolean).join(" "))}function pe(t,r,s){if(!r)return 0;const i=E(J(t)),c=E(_(q(t,s)));return i===r?500:i.startsWith(r)?400:i.includes(r)?300:c===r?250:c.startsWith(r)?200:100}function rt(t,r,s,i=50){const c=E(r),u=c.split(/\s+/).filter(Boolean),k=new Set;return t.filter(m=>{if(u.length===0)return!0;const h=at(m,s);return u.every(g=>h.includes(g))}).sort((m,h)=>{const g=+!!h.pendingInteraction-+!!m.pendingInteraction;return g!==0?g:pe(h,c,s)-pe(m,c,s)||Te(m,h)}).filter(m=>{const h=G(R(m));return k.has(h)?!1:(k.add(h),!0)}).slice(0,i)}const it={running:"sidebar.group.running",queued:"sidebar.group.queued",interrupted:"sidebar.group.interrupted",failed:"sidebar.group.failed",cancelled:"sidebar.group.cancelled",completed:"sidebar.group.done"};function pt(){const t=Ie(),r=p(e=>e.isTaskSwitcherOpen),s=p(e=>e.taskSwitcherMode),i=p(e=>e.setTaskSwitcherOpen),c=p(e=>e.setTaskSwitcherMode),u=p(e=>e.setMainView),k=p(e=>e.toggleSidebar),m=p(e=>e.isFilePreviewOpen),h=p(e=>e.setFilePreviewOpen),g=p(e=>e.openFilePreview),M=p(e=>e.toggleTerminal),y=p(e=>e.openSettings),b=o(e=>e.sessions),he=o(e=>e.isLoading),C=o(e=>e.catalogLoadState),B=C==="loading"||C==="hydrating",K=o(e=>e.currentSessionRef),X=o(e=>e.isTemporarySession),Y=o(e=>e.startTemporarySession),O=o(e=>e.unreadTaskKeys),ke=o(e=>e.boundProjects),A=o(e=>{var a;return e.selectedProjectPath??((a=e.taskWorkspaceInfo)==null?void 0:a.cwd)??null}),xe=o(e=>e.selectProject),fe=o(e=>e.selectSession),ge=o(e=>e.cancelTask),be=o(e=>e.retryTask),ve=o(e=>e.cancellingTaskKeys),we=o(e=>e.retryingTaskKeys),[v,Z]=d.useState(""),[f,j]=d.useState(0),[ye,$]=d.useState(null),[ee,I]=d.useState(null),te=d.useRef(null),ne=d.useRef(null),se=d.useMemo(()=>[{id:"new-task",label:t("commandCenter.action.newTask"),description:t("commandCenter.action.newTaskDescription"),keywords:"create compose session",icon:Be,shortcut:L("newTask"),run:()=>{u("workspace"),Y(),requestAnimationFrame(()=>Fe())}},{id:"toggle-preview",label:t("commandCenter.action.preview"),description:t("commandCenter.action.previewDescription"),keywords:"diff files logs artifact review",icon:Ke,run:()=>{m?h(!1):g((!K||X)&&p.getState().previewRequestId===0?{tab:"files"}:void 0)}},{id:"toggle-terminal",label:t("commandCenter.action.terminal"),description:t("commandCenter.action.terminalDescription"),keywords:"shell console command line",icon:Oe,run:M},{id:"open-settings",label:t("commandCenter.action.settings"),description:t("commandCenter.action.settingsDescription"),keywords:"preferences general",icon:$e,run:()=>y("general")},{id:"open-models",label:t("commandCenter.action.models"),description:t("commandCenter.action.modelsDescription"),keywords:"provider llm api configuration",icon:We,run:()=>y("models")},{id:"open-shortcuts",label:t("commandCenter.action.shortcuts"),description:t("commandCenter.action.shortcutsDescription"),keywords:"keyboard hotkey key binding",icon:Qe,shortcut:L("openCommands"),run:()=>y("shortcuts")},{id:"open-skills",label:t("commandCenter.action.skills"),description:t("commandCenter.action.skillsDescription"),keywords:"capabilities workflow",icon:He,run:()=>y("skills")},{id:"open-mcp",label:t("commandCenter.action.mcp"),description:t("commandCenter.action.mcpDescription"),keywords:"server tools protocol integration",icon:Ue,run:()=>y("mcp")},{id:"toggle-sidebar",label:t("commandCenter.action.sidebar"),description:t("commandCenter.action.sidebarDescription"),keywords:"navigation layout panel projects",icon:ze,shortcut:L("toggleSidebar"),run:k}],[K,m,X,g,y,h,u,Y,t,k,M]),w=d.useMemo(()=>rt(b,v,A),[A,v,b]),T=d.useMemo(()=>et(se,v),[se,v]),D=s==="tasks"?w.length:T.length,ae=d.useMemo(()=>b.filter(e=>!!e.pendingInteraction).length,[b]),W=s==="tasks"?w[f]??null:null,Q=s==="commands"?T[f]??null:null;d.useEffect(()=>{r&&(Z(""),j(0),$(null),I(null))},[s,r]),d.useEffect(()=>{j(0)},[v]),d.useEffect(()=>{var a,l;const e=(a=ne.current)==null?void 0:a.querySelector(`[data-task-result-index="${f}"]`);(l=e==null?void 0:e.scrollIntoView)==null||l.call(e,{block:"nearest"})},[f]);const re=async e=>{const a=R(e),l=G(a),x=q(e,A);$(l),ke.some(N=>N.path===x)&&xe(x);try{u("workspace"),await fe(a),i(!1)}catch(N){I(N instanceof Error?N.message:t("taskSwitcher.action.failed"))}finally{$(null)}},ie=async(e,a)=>{I(null);try{const l=R(a);e==="cancel"?await ge(l):(await be(l),i(!1))}catch(l){I(l instanceof Error?l.message:t("taskSwitcher.action.failed"))}},ce=e=>{i(!1),requestAnimationFrame(e.run)},je=e=>{e.key==="ArrowDown"?(e.preventDefault(),j(a=>D===0?0:(a+1)%D)):e.key==="ArrowUp"?(e.preventDefault(),j(a=>D===0?0:(a-1+D)%D)):e.key==="Enter"&&W?(e.preventDefault(),re(W)):e.key==="Enter"&&Q?(e.preventDefault(),ce(Q)):e.key==="Escape"&&(e.preventDefault(),i(!1))};return n.jsx(Le,{open:r,onOpenChange:i,children:n.jsxs(Pe,{hideCloseButton:!0,onCloseAutoFocus:Re,className:"top-3 w-[min(680px,calc(100vw-32px))] max-w-none translate-y-0 gap-0 overflow-hidden rounded-xl border-[hsl(var(--deck-border-strong))] bg-[hsl(var(--deck-canvas))] p-0 shadow-2xl sm:top-[18%]",children:[n.jsx(qe,{className:"sr-only",children:t("commandCenter.title")}),n.jsx(Ee,{className:"sr-only",children:t("commandCenter.description")}),n.jsxs("div",{className:"flex h-14 items-center gap-3 border-b border-[hsl(var(--deck-hairline))] px-4",children:[n.jsx(V,{className:"h-4 w-4 shrink-0 text-[hsl(var(--deck-accent))]"}),n.jsx("input",{ref:te,autoFocus:!0,role:"combobox","aria-expanded":"true","aria-controls":"task-switcher-results","aria-activedescendant":W?`task-switcher-result-${f}`:Q?`command-center-result-${f}`:void 0,"aria-label":t(s==="tasks"?"taskSwitcher.searchAria":"commandCenter.searchAria"),placeholder:t(s==="tasks"?"taskSwitcher.placeholder":"commandCenter.placeholder"),value:v,onChange:e=>Z(e.target.value),onKeyDown:je,className:"h-full min-w-0 flex-1 bg-transparent font-mono text-[14px] text-[hsl(var(--deck-ink))] outline-none placeholder:text-[hsl(var(--deck-ink-faint))]"}),n.jsx("span",{className:"rounded border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] px-1.5 py-0.5 font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:"ESC"})]}),n.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 pb-2 pt-3",children:[n.jsx("div",{role:"tablist","aria-label":t("commandCenter.modeAria"),className:"flex items-center gap-0.5 rounded-md border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] p-0.5",children:["tasks","commands"].map(e=>n.jsx("button",{type:"button",role:"tab","aria-selected":s===e,onClick:()=>{c(e),requestAnimationFrame(()=>{var a;return(a=te.current)==null?void 0:a.focus()})},className:S("rounded-[5px] px-2.5 py-1 font-mono text-[9.5px] uppercase tracking-[0.1em] transition-colors",s===e?"bg-[hsl(var(--deck-canvas))] text-[hsl(var(--deck-ink))] shadow-sm":"text-[hsl(var(--deck-ink-faint))] hover:text-[hsl(var(--deck-ink-muted))]"),children:t(e==="tasks"?"commandCenter.mode.tasks":"commandCenter.mode.commands")},e))}),n.jsx("span",{children:n.jsx("span",{className:"font-mono text-[9.5px] uppercase tracking-[0.14em] text-[hsl(var(--deck-ink-faint))]",children:s==="commands"?t("commandCenter.actions",{count:T.length}):v?t("taskSwitcher.results",{count:w.length}):B?b.length===0?t("taskSwitcher.indexing"):t("taskSwitcher.indexingLoaded",{count:b.length}):C==="error"?t("sidebar.catalog.incomplete"):ae>0?t("taskSwitcher.needsAction",{count:ae}):O.length>0?t("taskSwitcher.unread",{count:O.length}):t("taskSwitcher.scope",{count:b.length})})})]}),ee&&n.jsx("div",{role:"alert",className:"mx-4 mb-2 rounded-md border border-red-300/70 bg-red-50 px-3 py-2 font-mono text-[10.5px] text-red-700 dark:border-red-900/70 dark:bg-red-950/35 dark:text-red-300",children:ee}),n.jsxs("div",{id:"task-switcher-results",ref:ne,role:"listbox","aria-label":t(s==="tasks"?"taskSwitcher.resultsAria":"commandCenter.resultsAria"),className:"max-h-[min(460px,60vh)] overflow-y-auto px-2 pb-2",children:[s==="commands"&&n.jsx(tt,{actions:T,selectedIndex:f,onSelect:j,onRun:ce}),s==="tasks"&&w.map((e,a)=>{const l=R(e),x=G(l),N=q(e,A),Ne=_(N),oe=Me(l,K),H=a===f,Se=ye===x,Ce=O.includes(x),F=J(e),le=e.taskStatus==="running"||e.taskStatus==="queued",de=!!e.taskRetryAvailable&&(e.taskStatus==="failed"||e.taskStatus==="interrupted"||e.taskStatus==="cancelled"),U=ve.includes(x),z=we.includes(x);return n.jsxs("div",{id:`task-switcher-result-${a}`,"data-task-result-index":a,"data-session-ref":x,role:"option","aria-selected":H,onMouseEnter:()=>j(a),className:S("group flex min-h-[68px] w-full items-center rounded-lg border border-transparent text-left transition-colors",H?"border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]":"hover:bg-[hsl(var(--deck-surface))]/60"),children:[n.jsxs("button",{type:"button",onClick:()=>void re(e),"aria-label":t("session.action.select",{title:F}),className:"flex min-h-[68px] min-w-0 flex-1 items-center gap-3 px-3 py-2 text-left focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-[hsl(var(--deck-accent))]",children:[n.jsx("span",{className:S("flex h-8 w-8 shrink-0 items-center justify-center rounded-md border bg-[hsl(var(--deck-canvas))]",oe?"border-[hsl(var(--deck-accent)/0.5)] text-[hsl(var(--deck-accent))]":"border-[hsl(var(--deck-border))] text-[hsl(var(--deck-ink-faint))]"),children:e.pendingInteraction?n.jsx(me,{className:"h-3.5 w-3.5 animate-pulse text-amber-600 dark:text-amber-400"}):e.taskStatus==="running"?n.jsx(Ve,{className:"h-3.5 w-3.5 animate-pulse"}):n.jsx(Ge,{className:"h-3.5 w-3.5"})}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"truncate font-mono text-[12.5px] font-medium text-[hsl(var(--deck-ink))]",children:F}),oe&&n.jsx("span",{className:"shrink-0 rounded bg-[hsl(var(--deck-accent-soft))] px-1.5 py-0.5 font-mono text-[8.5px] uppercase tracking-[0.1em] text-[hsl(var(--deck-accent))]",children:t("taskSwitcher.current")}),Ce&&n.jsx("span",{className:"shrink-0 rounded bg-[hsl(var(--deck-accent-soft))] px-1.5 py-0.5 font-mono text-[8.5px] uppercase tracking-[0.1em] text-[hsl(var(--deck-accent))]",children:t("taskSwitcher.new")}),e.pendingInteraction&&n.jsx("span",{className:"shrink-0 rounded bg-amber-100 px-1.5 py-0.5 font-mono text-[8.5px] uppercase tracking-[0.08em] text-amber-800 dark:bg-amber-950/60 dark:text-amber-300",children:t(e.pendingInteraction.type==="question"?"interaction.badge.question":e.pendingInteraction.type==="elicitation"?"interaction.badge.elicitation":"interaction.badge.permission")}),e.taskRetriedFrom&&n.jsx("span",{title:`${t("session.retriedFrom")} ${e.taskRetriedFrom.sessionId.slice(0,6)}`,className:"shrink-0 rounded bg-[hsl(var(--deck-accent-soft))] px-1.5 py-0.5 font-mono text-[8.5px] text-[hsl(var(--deck-accent))]",children:t("session.retryShort")})]}),n.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-2 font-mono text-[9.5px] text-[hsl(var(--deck-ink-faint))]",children:[n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1",children:[n.jsx(_e,{className:"h-2.5 w-2.5 shrink-0"}),n.jsx("span",{className:"truncate",children:Ne})]}),(e.taskWorktreeBranch||e.gitBranch)&&n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1",children:[n.jsx(Je,{className:"h-2.5 w-2.5 shrink-0"}),n.jsx("span",{className:"truncate",children:e.taskWorktreeBranch||e.gitBranch})]}),n.jsx("span",{className:"shrink-0",children:e.taskStatus==="queued"&&e.taskQueuePosition!==void 0&&e.taskQueueDepth!==void 0?t("session.queued",{position:e.taskQueuePosition,depth:e.taskQueueDepth}):e.pendingInteraction?t(e.pendingInteraction.type==="question"?"interaction.badge.question":e.pendingInteraction.type==="elicitation"?"interaction.badge.elicitation":"interaction.badge.permission"):t(it[e.taskStatus])}),n.jsxs("span",{className:"ml-auto inline-flex shrink-0 items-center gap-1",children:[n.jsx(Xe,{className:"h-2.5 w-2.5"}),st(e)]})]})]}),Se?n.jsx(P,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"}):n.jsx(ue,{className:S("h-3.5 w-3.5 shrink-0 transition-all",H?"translate-x-0 text-[hsl(var(--deck-accent))] opacity-100":"-translate-x-1 text-[hsl(var(--deck-ink-faint))] opacity-0")})]}),(le||de)&&n.jsxs("div",{className:"flex shrink-0 items-center pr-2",children:[le&&n.jsx("button",{type:"button","aria-label":t(U?"session.action.stopping":"session.action.stop",{title:F}),disabled:U,onClick:()=>void ie("cancel",e),className:"flex h-8 w-8 items-center justify-center rounded-md text-red-500 transition-colors hover:bg-red-500/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-red-500 disabled:cursor-wait disabled:opacity-60",children:U?n.jsx(P,{className:"h-3.5 w-3.5 animate-spin"}):n.jsx(Ye,{className:"h-3.5 w-3.5"})}),de&&n.jsx("button",{type:"button","aria-label":t(z?"session.action.retrying":"session.action.retry",{title:F}),disabled:z,onClick:()=>void ie("retry",e),className:"flex h-8 w-8 items-center justify-center rounded-md text-[hsl(var(--deck-accent))] transition-colors hover:bg-[hsl(var(--deck-accent-soft))] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[hsl(var(--deck-accent))] disabled:cursor-wait disabled:opacity-60",children:z?n.jsx(P,{className:"h-3.5 w-3.5 animate-spin"}):n.jsx(Ze,{className:"h-3.5 w-3.5"})})]})]},x)}),s==="tasks"&&w.length===0&&B&&n.jsxs("div",{className:"flex min-h-36 items-center justify-center gap-2 font-mono text-[11px] text-[hsl(var(--deck-ink-faint))]",children:[n.jsx(P,{className:"h-3.5 w-3.5 animate-spin text-[hsl(var(--deck-accent))]"}),t("taskSwitcher.indexing")]}),s==="tasks"&&w.length===0&&!B&&C!=="error"&&!he&&n.jsxs("div",{className:"flex min-h-36 flex-col items-center justify-center px-6 text-center",children:[n.jsx(V,{className:"mb-3 h-5 w-5 text-[hsl(var(--deck-ink-faint))]"}),n.jsx("p",{className:"font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:t("taskSwitcher.empty")}),n.jsx("p",{className:"mt-1 text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:t("taskSwitcher.emptyHint")})]}),s==="tasks"&&w.length===0&&C==="error"&&n.jsxs("div",{role:"alert",className:"flex min-h-36 flex-col items-center justify-center px-6 text-center",children:[n.jsx(me,{className:"mb-3 h-5 w-5 text-amber-500"}),n.jsx("p",{className:"font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:t("sidebar.catalog.incomplete")})]}),s==="commands"&&T.length===0&&n.jsxs("div",{className:"flex min-h-36 flex-col items-center justify-center px-6 text-center",children:[n.jsx(V,{className:"mb-3 h-5 w-5 text-[hsl(var(--deck-ink-faint))]"}),n.jsx("p",{className:"font-mono text-[12px] text-[hsl(var(--deck-ink-muted))]",children:t("commandCenter.empty")}),n.jsx("p",{className:"mt-1 text-[10.5px] text-[hsl(var(--deck-ink-faint))]",children:t("commandCenter.emptyHint")})]})]}),n.jsxs("div",{className:"flex items-center gap-4 border-t border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-canvas-veil))] px-4 py-2 font-mono text-[9px] text-[hsl(var(--deck-ink-faint))]",children:[n.jsxs("span",{children:["↑↓ ",t("taskSwitcher.hint.navigate")]}),n.jsxs("span",{children:["↵ ",t("taskSwitcher.hint.open")]}),n.jsxs("span",{className:"ml-auto",children:[L(s==="tasks"?"openCommands":"searchTasks")," ",t(s==="tasks"?"commandCenter.mode.commands":"commandCenter.mode.tasks")]})]})]})})}export{pt as TaskSwitcher};
@@ -1 +0,0 @@
1
- import{r as t,j as a}from"./vendor-react-DG5dkZ_t.js";import{D as A,o as R,L as j}from"./vendor-xterm-DuYZoU4T.js";import{u as C,b as N,Q as F,j as x}from"./index-ebnhtfFC.js";import{k as M,at as S,X as T}from"./vendor-icons-CX5BfgqQ.js";import"./vendor-radix-DXRuAJHH.js";import"./session-events-Bgir_Gl_.js";const $=({workspacePath:b})=>{const c=C(),{isTerminalOpen:l,toggleTerminal:y}=N(),[s,z]=t.useState(!1),[p,u]=t.useState(!1),g=F(),m=t.useRef(null),i=t.useRef(null),h=t.useRef(null),o=t.useRef(null),E=t.useRef(null),B=t.useCallback(()=>{var f;if(((f=o.current)==null?void 0:f.readyState)===WebSocket.OPEN)return;const r=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/terminal/ws`,e=b?`${r}?cwd=${encodeURIComponent(b)}`:r,n=new WebSocket(e);o.current=n,n.onopen=()=>{u(!0)},n.onmessage=w=>{var d;(d=i.current)==null||d.write(w.data)},n.onclose=()=>{u(!1)},n.onerror=()=>{u(!1)}},[b]),k=t.useCallback(()=>{o.current&&(o.current.close(),o.current=null),u(!1)},[]),v=t.useCallback(r=>{var e;((e=o.current)==null?void 0:e.readyState)===WebSocket.OPEN&&o.current.send(r)},[]);return t.useEffect(()=>(E.current=document.activeElement instanceof HTMLElement?document.activeElement:null,()=>{var r;return(r=E.current)==null?void 0:r.focus({preventScroll:!0})}),[]),t.useEffect(()=>{if(!l||!m.current||i.current)return;const r={background:"#ffffff",foreground:"#111827",cursor:"#111827",cursorAccent:"#ffffff",selectionBackground:"#E5E7EB",black:"#111827",red:"#dc2626",green:"#16a34a",yellow:"#ca8a04",blue:"#2563eb",magenta:"#7c3aed",cyan:"#0891b2",white:"#111827",brightBlack:"#6b7280",brightRed:"#ef4444",brightGreen:"#22c55e",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#a855f7",brightCyan:"#22d3ee",brightWhite:"#111827"},e=new A({cursorBlink:!0,cursorStyle:"bar",fontSize:14,fontFamily:"JetBrains Mono, Menlo, Monaco, Consolas, monospace",allowTransparency:!0,scrollback:1e4,theme:g?{background:"#0a0a0a",foreground:"#e4e4e7",cursor:"#e4e4e7",cursorAccent:"#0a0a0a",selectionBackground:"#3f3f46",black:"#18181b",red:"#ef4444",green:"#22c55e",yellow:"#eab308",blue:"#3b82f6",magenta:"#a855f7",cyan:"#06b6d4",white:"#e4e4e7",brightBlack:"#52525b",brightRed:"#f87171",brightGreen:"#4ade80",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#c084fc",brightCyan:"#22d3ee",brightWhite:"#fafafa"}:r}),n=new R,f=new j;e.loadAddon(n),e.loadAddon(f),e.open(m.current),n.fit();const w=requestAnimationFrame(()=>e.focus());return e.onData(d=>{v(d)}),i.current=e,h.current=n,B(),()=>{cancelAnimationFrame(w),k(),e.dispose(),i.current=null,h.current=null}},[l,B,k,v]),t.useEffect(()=>{i.current&&(i.current.options.theme=g?{background:"#0a0a0a",foreground:"#e4e4e7",cursor:"#e4e4e7",cursorAccent:"#0a0a0a",selectionBackground:"#3f3f46",black:"#18181b",red:"#ef4444",green:"#22c55e",yellow:"#eab308",blue:"#3b82f6",magenta:"#a855f7",cyan:"#06b6d4",white:"#e4e4e7",brightBlack:"#52525b",brightRed:"#f87171",brightGreen:"#4ade80",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#c084fc",brightCyan:"#22d3ee",brightWhite:"#fafafa"}:{background:"#ffffff",foreground:"#111827",cursor:"#111827",cursorAccent:"#ffffff",selectionBackground:"#E5E7EB",black:"#111827",red:"#dc2626",green:"#16a34a",yellow:"#ca8a04",blue:"#2563eb",magenta:"#7c3aed",cyan:"#0891b2",white:"#111827",brightBlack:"#6b7280",brightRed:"#ef4444",brightGreen:"#22c55e",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#a855f7",brightCyan:"#22d3ee",brightWhite:"#111827"})},[g]),t.useEffect(()=>{if(!l||s)return;const r=()=>{var n;(n=h.current)==null||n.fit()};window.addEventListener("resize",r);const e=setTimeout(r,100);return()=>{window.removeEventListener("resize",r),clearTimeout(e)}},[l,s]),l?a.jsxs("div",{role:"region","aria-label":c("terminal.title"),className:x("fixed bottom-0 left-0 right-0 z-40 bg-white dark:bg-[#0a0a0a] border-t border-[#E5E7EB] dark:border-zinc-800 transition-all duration-200",s?"h-10":"h-[min(18rem,45dvh)]"),children:[a.jsxs("div",{className:"flex items-center justify-between h-10 px-3 border-b border-[#E5E7EB] dark:border-zinc-800 bg-[#F9FAFB] dark:bg-zinc-900/50",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(M,{className:"h-4 w-4 text-[#9CA3AF] dark:text-zinc-400"}),a.jsx("span",{className:"text-sm text-[#6B7280] dark:text-zinc-400",children:c("terminal.title")}),a.jsx("span",{role:"status","aria-label":c(p?"terminal.status.connected":"terminal.status.disconnected"),className:x("w-2 h-2 rounded-full",p?"bg-green-500":"bg-zinc-600")})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{type:"button",onClick:()=>z(!s),"aria-label":c(s?"terminal.action.restore":"terminal.action.minimize"),className:"p-1.5 rounded hover:bg-[#E5E7EB] text-[#9CA3AF] hover:text-[#111827] dark:hover:bg-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200 transition-colors",children:a.jsx(S,{className:"h-4 w-4"})}),a.jsx("button",{type:"button",onClick:()=>{k(),y()},"aria-label":c("terminal.action.close"),className:"p-1.5 rounded hover:bg-[#E5E7EB] text-[#9CA3AF] hover:text-[#111827] dark:hover:bg-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200 transition-colors",children:a.jsx(T,{className:"h-4 w-4"})})]})]}),a.jsx("div",{ref:m,className:x("h-[calc(100%-40px)] p-2",s&&"hidden")})]}):null};export{$ as TerminalPanel};