blade-code 0.10.93 → 0.10.95
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blade.js +2 -2
- package/dist/{chunk-0pnj92hk.js → chunk-09ya3a21.js} +1 -1
- package/dist/{chunk-3p7c1dsk.js → chunk-2f0wn3ne.js} +1 -1
- package/dist/{chunk-fkhtff66.js → chunk-2ge1zqts.js} +1 -1
- package/dist/{chunk-qern9m2c.js → chunk-2zzc7g29.js} +1 -1
- package/dist/{chunk-7jgj63tj.js → chunk-3aayczyy.js} +1 -1
- package/dist/{chunk-wgd4ject.js → chunk-4fmyjf1x.js} +1 -1
- package/dist/chunk-4hb71f98.js +1 -0
- package/dist/{chunk-7wf2acxx.js → chunk-4p69xraf.js} +1 -1
- package/dist/{chunk-gynpj5sv.js → chunk-4smdhn1h.js} +1 -1
- package/dist/{chunk-m4tpqesg.js → chunk-871g570t.js} +255 -255
- package/dist/{chunk-05fctawm.js → chunk-8pvsw4gw.js} +1 -1
- package/dist/{chunk-xh4pgtj2.js → chunk-bd4nqrtm.js} +1 -1
- package/dist/{chunk-mmd1hx8c.js → chunk-bxtqcgvs.js} +1 -1
- package/dist/{chunk-t7nj9vg8.js → chunk-cbafxem4.js} +1 -1
- package/dist/{chunk-96pnk11m.js → chunk-cnnht4m3.js} +1 -1
- package/dist/{chunk-7b718dgf.js → chunk-cvybf60x.js} +1 -1
- package/dist/{chunk-xby5w74x.js → chunk-e5ht9d18.js} +1 -1
- package/dist/{chunk-61efg3yh.js → chunk-eqbcxa12.js} +1 -1
- package/dist/{chunk-37csc3d2.js → chunk-es4evt6m.js} +1 -1
- package/dist/{chunk-9h756tk9.js → chunk-esstp9h0.js} +2 -2
- package/dist/{chunk-93rvs2hb.js → chunk-f66cptes.js} +1 -1
- package/dist/chunk-gnzcz6e1.js +1 -0
- package/dist/{chunk-5rtjx9xk.js → chunk-h2a3edj4.js} +1 -1
- package/dist/{chunk-scfwdpph.js → chunk-hajer580.js} +1 -1
- package/dist/{chunk-qr3w31ys.js → chunk-hfd00skc.js} +1 -1
- package/dist/{chunk-nht2hy5h.js → chunk-hqb6qxzj.js} +1 -1
- package/dist/{chunk-n23chvhe.js → chunk-hrpqz2jv.js} +1 -1
- package/dist/{chunk-tt3n8gnq.js → chunk-ktt7vmqz.js} +1 -1
- package/dist/{chunk-sbrj2czw.js → chunk-qp165b79.js} +1 -1
- package/dist/{chunk-v7rnx21e.js → chunk-rjw8pj7t.js} +1 -1
- package/dist/{chunk-fyms8zy1.js → chunk-rrav5aea.js} +1 -1
- package/dist/chunk-s2erwc49.js +8 -0
- package/dist/{chunk-b9bbyzk4.js → chunk-sckqp0t9.js} +1 -1
- package/dist/{chunk-hn1xztva.js → chunk-vt99w0vh.js} +1 -1
- package/dist/{chunk-ns5vb2p4.js → chunk-vxwqsmqg.js} +1 -1
- package/dist/{chunk-9kfk68qj.js → chunk-wwzc3ryj.js} +1 -1
- package/dist/{chunk-82n941y8.js → chunk-xm8w4jaa.js} +1 -1
- package/dist/web/assets/{ChatView-D-UBHYgT.js → ChatView-CpKiglLV.js} +7 -7
- package/dist/web/assets/{CodeBlockHighlighter-CjP3le5E.js → CodeBlockHighlighter-BzmHeWKU.js} +1 -1
- package/dist/web/assets/FilePreview-uShTCL2_.js +59 -0
- package/dist/web/assets/{KanbanBoard-CRu-0zva.js → KanbanBoard-CnZoKZFy.js} +2 -2
- package/dist/web/assets/{MarkdownRenderer-fbB4bMCw.js → MarkdownRenderer-CxcqGo57.js} +3 -3
- package/dist/web/assets/{SettingsModal-RAG8JMXx.js → SettingsModal-Bu5uH8ic.js} +2 -2
- package/dist/web/assets/{TaskSwitcher-DC-7RPBv.js → TaskSwitcher-BDwk7i6w.js} +6 -6
- package/dist/web/assets/{TerminalPanel-CCB3heKF.js → TerminalPanel-PiLhnW-8.js} +2 -2
- package/dist/web/assets/{arrow-left-Dwndq437.js → arrow-left-B7RwOx8T.js} +1 -1
- package/dist/web/assets/{calendar-clock-CNd8rd6n.js → calendar-clock-BeSXiMFw.js} +1 -1
- package/dist/web/assets/{chevrons-up-down-DGxAunkR.js → chevrons-up-down-DuC8PppK.js} +1 -1
- package/dist/web/assets/{clock-3-BEqhPeh5.js → clock-3-lYrt_Amt.js} +1 -1
- package/dist/web/assets/{external-link-ClLpF7at.js → external-link-BTHyQJWk.js} +1 -1
- package/dist/web/assets/{folder-B5LF32bS.js → folder-CX6zAF9w.js} +1 -1
- package/dist/web/assets/{index-DI8ZWdWH.js → index-B5mUEr6D.js} +3 -3
- package/dist/web/assets/{index-BgdiwWDg.js → index-FdbcPJSj.js} +56 -56
- package/dist/web/assets/index-zY4JU9fd.css +1 -0
- package/dist/web/assets/{pause-B39o8olb.js → pause-qlDcCjBJ.js} +1 -1
- package/dist/web/assets/{play-Bmh7JaqQ.js → play-BGPTTFWa.js} +1 -1
- package/dist/web/assets/session-events-Ci1823tS.js +22 -0
- package/dist/web/assets/{teamService-4Cn4uKC9.js → teamService-Bk8B4hZp.js} +1 -1
- package/dist/web/assets/{vendor-radix-DXRuAJHH.js → vendor-radix-Bc1_Q9tz.js} +1 -1
- package/dist/web/assets/{vendor-react-DG5dkZ_t.js → vendor-react-DofNRwfy.js} +1 -1
- package/dist/web/index.html +5 -5
- package/package.json +1 -1
- package/dist/chunk-fs8ra760.js +0 -8
- package/dist/chunk-jaegtaq3.js +0 -1
- package/dist/chunk-z2asrfm1.js +0 -1
- package/dist/web/assets/FilePreview-DRJTAYmL.js +0 -54
- package/dist/web/assets/index-C8M-7zAh.css +0 -1
- package/dist/web/assets/session-events-Bgir_Gl_.js +0 -22
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-B5mUEr6D.js","assets/vendor-react-DofNRwfy.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as re,j as U,a3 as Ue,am as mr,r as Ke,L as Re,an as xr,U as W,S as vr,y as Bt,R as Ot,B as br,N as qt,u as he,$ as lt,n as Ht,o as Gt,F as Vt,ao as gr,a as Te,s as $e,ap as nt,l as kr,X as wr,x as yr,_ as jr}from"./index-FdbcPJSj.js";import{r as i,j as e}from"./vendor-react-DofNRwfy.js";import{o as wt,l as yt}from"./session-events-Ci1823tS.js";import{A as Nr,C as Sr}from"./chevrons-up-down-DuC8PppK.js";import{A as Er,E as jt}from"./external-link-BTHyQJWk.js";import{A as Cr}from"./arrow-left-B7RwOx8T.js";import{A as Tr,F as Lr}from"./folder-CX6zAF9w.js";import"./vendor-radix-Bc1_Q9tz.js";/**
|
|
3
|
+
* @license lucide-react v0.300.0 - ISC
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the ISC license.
|
|
6
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/const Rr=re("AppWindow",[["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}],["path",{d:"M10 4v4",key:"pp8u80"}],["path",{d:"M2 8h20",key:"d11cs7"}],["path",{d:"M6 4v4",key:"1svtjw"}]]);/**
|
|
8
|
+
* @license lucide-react v0.300.0 - ISC
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the ISC license.
|
|
11
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/const Pr=re("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);/**
|
|
13
|
+
* @license lucide-react v0.300.0 - ISC
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the ISC license.
|
|
16
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/const Ir=re("ChevronsDownUp",[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]]);/**
|
|
18
|
+
* @license lucide-react v0.300.0 - ISC
|
|
19
|
+
*
|
|
20
|
+
* This source code is licensed under the ISC license.
|
|
21
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
+
*/const Ge=re("FileCode",[["path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z",key:"1nnpy2"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}],["path",{d:"m10 13-2 2 2 2",key:"17smn8"}],["path",{d:"m14 17 2-2-2-2",key:"14mezr"}]]);/**
|
|
23
|
+
* @license lucide-react v0.300.0 - ISC
|
|
24
|
+
*
|
|
25
|
+
* This source code is licensed under the ISC license.
|
|
26
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
+
*/const Dr=re("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/**
|
|
28
|
+
* @license lucide-react v0.300.0 - ISC
|
|
29
|
+
*
|
|
30
|
+
* This source code is licensed under the ISC license.
|
|
31
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
32
|
+
*/const Nt=re("MonitorUp",[["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}],["path",{d:"M12 13V7",key:"h0r20n"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/**
|
|
33
|
+
* @license lucide-react v0.300.0 - ISC
|
|
34
|
+
*
|
|
35
|
+
* This source code is licensed under the ISC license.
|
|
36
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
37
|
+
*/const St=re("MousePointer2",[["path",{d:"m4 4 7.07 17 2.51-7.39L21 11.07z",key:"1vqm48"}]]);/**
|
|
38
|
+
* @license lucide-react v0.300.0 - ISC
|
|
39
|
+
*
|
|
40
|
+
* This source code is licensed under the ISC license.
|
|
41
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
42
|
+
*/const Fr=re("TerminalSquare",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);/**
|
|
43
|
+
* @license lucide-react v0.300.0 - ISC
|
|
44
|
+
*
|
|
45
|
+
* This source code is licensed under the ISC license.
|
|
46
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
47
|
+
*/const Ar=re("UserRound",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]);/**
|
|
48
|
+
* @license lucide-react v0.300.0 - ISC
|
|
49
|
+
*
|
|
50
|
+
* This source code is licensed under the ISC license.
|
|
51
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
52
|
+
*/const Mr=re("Wifi",[["path",{d:"M5 13a10 10 0 0 1 14 0",key:"6v8j51"}],["path",{d:"M8.5 16.5a5 5 0 0 1 7 0",key:"sej527"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["line",{x1:"12",x2:"12.01",y1:"20",y2:"20",key:"of4bc4"}]]),Kt=i.createContext(null);function Jt(t){const n=i.useContext(Kt);if(!n)throw new Error(`${t} must be used within <Tabs>`);return n}function Ur({value:t,onValueChange:n,className:r,children:s}){const l=i.useMemo(()=>({value:t,setValue:n}),[t,n]);return e.jsx(Kt.Provider,{value:l,children:e.jsx("div",{className:r,children:s})})}function $r({className:t,children:n}){return e.jsx("div",{role:"tablist",className:U("inline-flex items-center",t),children:n})}function Oe({value:t,className:n,children:r}){const{value:s,setValue:l}=Jt("TabsTrigger"),a=s===t;return e.jsx("button",{type:"button",role:"tab","aria-selected":a,"data-state":a?"active":"inactive",onClick:()=>l(t),className:U("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 qe({value:t,className:n,children:r,forceMount:s=!1}){const{value:l}=Jt("TabsContent"),a=l===t;return!a&&!s?null:e.jsx("div",{role:"tabpanel",hidden:!a,className:n,children:r})}const zr={"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 Wr(t){const n=t.replace("#",""),r=parseInt(n.substring(0,2),16),s=parseInt(n.substring(2,4),16),l=parseInt(n.substring(4,6),16);return(.299*r+.587*s+.114*l)/255<.5}function _r(t){return{base:Wr(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 Et=new Set;function Ct(t,n){const r=n.toLowerCase().replace(/\s+/g,"-"),s=zr[r];if(!s)return"vs-dark";if(!Et.has(r)){const l=_r(s);t.editor.defineTheme(r,l),Et.add(r)}return r}function Ee(t,n,r={}){const s=mr.parse(t),l=new URLSearchParams({projectPath:s.projectPath});for(const[a,b]of Object.entries(r))b!==void 0&&l.set(a,String(b));return`/sessions/${encodeURIComponent(s.sessionId)}/browser/${n}?${l.toString()}`}const ce={navigate:async(t,n)=>Ue(Ee(t,"navigate"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),snapshot:async(t,n={})=>Ue(Ee(t,"snapshot",n)),interact:async(t,n)=>Ue(Ee(t,"interact"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),inspect:async(t,n)=>Ue(Ee(t,"inspect",n)),screenshot:async(t,n={})=>{var s;const r=await fetch(Ee(t,"inspect",{...n,target:"screenshot"}));if(!r.ok){const l=await r.json().catch(()=>{});throw new Error(((s=l==null?void 0:l.error)==null?void 0:s.message)||"Failed to capture browser image")}return r.blob()},reset:async t=>{await Ue(Ee(t,"reset"),{method:"POST"})}},Br={en:{frameTitle:"Project preview",empty:"No preview open",loading:"Loading preview…"},zh:{frameTitle:"项目预览",empty:"未打开项目预览",loading:"正在加载预览…"}};function Or({url:t,revision:n,loadState:r,onLoad:s,onError:l}){const{locale:a}=Ke(),b=Br[a];return e.jsx("section",{"data-preview-browser":!0,className:"relative h-full min-h-0 overflow-hidden bg-white",children:t?e.jsxs(e.Fragment,{children:[e.jsx("iframe",{"data-preview-browser-frame":!0,src:t,title:b.frameTitle,sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts",referrerPolicy:"no-referrer",onLoad:s,onError:l,className:"block h-full w-full border-0 bg-white"},`${t}:${n}`),r==="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(Re,{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:b.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(Ge,{className:"h-5 w-5"})}),e.jsx("span",{className:"font-mono text-[11px] text-[hsl(var(--deck-ink-muted))]",children:b.empty})]})})}const qr={en:{unavailable:"No active Session",empty:"No Test page",screenshotAlt:"Chromium page",selectedRef:"Selected ref",noRef:"No ref selected",valuePlaceholder:"Input value",click:"Click selected element",fill:"Fill selected control",scrollUp:"Scroll up",scrollDown:"Scroll down",snapshot:"Refresh snapshot",reset:"Reset Test browser",dom:"DOM",console:"Console",network:"Network",errors:"Errors",noEntries:"No entries",user:"User",agent:"Agent",sourceAria:"Test browser source"},zh:{unavailable:"没有活动 Session",empty:"未打开测试页面",screenshotAlt:"Chromium 页面",selectedRef:"已选 ref",noRef:"未选择 ref",valuePlaceholder:"输入内容",click:"点击已选元素",fill:"填入已选控件",scrollUp:"向上滚动",scrollDown:"向下滚动",snapshot:"刷新快照",reset:"重置测试浏览器",dom:"DOM",console:"控制台",network:"网络",errors:"错误",noEntries:"暂无记录",user:"用户",agent:"Agent",sourceAria:"测试浏览器来源"}};function Hr(t){return t.split(`
|
|
53
|
+
`).map(n=>{var r;return{text:n,ref:(r=n.match(/\[ref=([a-z][a-z0-9]*)\]/))==null?void 0:r[1]}})}function Gr(t){return[t.kind,t.level,t.method,t.status,t.url,t.text].filter(n=>n!==void 0&&n!=="").join(" · ")}function Vr({source:t,agentAvailable:n,sessionAvailable:r,observation:s,screenshotUrl:l,interaction:a,pointerRevision:b,busy:c,error:w,diagnostics:m,diagnosticsLoading:g,onInteract:d,onInspect:y,onSnapshot:D,onReset:x,onSourceChange:j}){const{locale:k}=Ke(),v=qr[k],[L,F]=i.useState(null),[C,G]=i.useState(""),[z,pe]=i.useState("dom"),Q=i.useRef(null),[_,me]=i.useState({left:0,top:0,width:0,height:0}),A=t==="agent",xe=i.useMemo(()=>Hr((s==null?void 0:s.snapshot)??""),[s==null?void 0:s.snapshot]),V=z==="dom"?[]:m[z]??[];i.useEffect(()=>{F(null)},[s==null?void 0:s.snapshotId]),i.useEffect(()=>{A&&pe("dom")},[A]);const se=i.useCallback(()=>{const h=Q.current,E=a==null?void 0:a.viewport;if(!h||!E||E.width<=0||E.height<=0){me({left:0,top:0,width:0,height:0});return}const $=h.getBoundingClientRect(),O=Math.min($.width/E.width,$.height/E.height),K=E.width*O,ae=E.height*O;me({left:($.width-K)/2,top:($.height-ae)/2,width:K,height:ae})},[a==null?void 0:a.viewport]);i.useEffect(()=>{se();const h=Q.current;if(!h||typeof ResizeObserver>"u")return;const E=new ResizeObserver(se);return E.observe(h),()=>E.disconnect()},[se,l]);const B=i.useMemo(()=>{const h=a==null?void 0:a.targetBox,E=a==null?void 0:a.viewport;if(!h||!E||_.width<=0||_.height<=0)return null;const $=Math.min(E.width,Math.max(0,h.x+h.width/2)),O=Math.min(E.height,Math.max(0,h.y+h.height/2));return{left:_.left+$/E.width*_.width,top:_.top+O/E.height*_.height}},[a,_]),ne=h=>{A&&h!=="dom"||(pe(h),h!=="dom"&&y(h))};return e.jsxs("section",{"data-browser-test":!0,"data-browser-source":t,"data-browser-snapshot-id":s==null?void 0:s.snapshotId,className:"flex h-full min-h-0 flex-col bg-[hsl(var(--deck-canvas))]",children:[e.jsxs("div",{ref:Q,className:"relative flex min-h-0 flex-1 items-center justify-center overflow-hidden bg-neutral-950",children:[l?e.jsx("img",{"data-browser-test-screenshot":!0,src:l,alt:v.screenshotAlt,onLoad:se,className:"h-full w-full object-contain"}):e.jsxs("div",{className:"flex flex-col items-center gap-3 text-[hsl(var(--deck-ink-faint))]",children:[e.jsx(Rr,{className:"h-7 w-7"}),e.jsx("span",{className:"font-mono text-[11px]",children:r?v.empty:v.unavailable})]}),A&&B&&e.jsxs("div",{"data-browser-agent-pointer":!0,"data-browser-action":a==null?void 0:a.action,className:"pointer-events-none absolute z-10 transition-[left,top] duration-300 ease-out",style:B,children:[e.jsx("span",{className:"absolute -left-2 -top-2 h-4 w-4 animate-ping rounded-full bg-cyan-400/70"},b),e.jsx(St,{className:"relative h-5 w-5 fill-white text-neutral-950 drop-shadow-[0_1px_2px_rgba(0,0,0,0.8)]"})]}),c&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/35",children:e.jsx(Re,{className:"h-5 w-5 animate-spin text-white"})}),w&&e.jsx("div",{role:"alert",className:"absolute inset-x-0 bottom-0 border-t border-red-500/30 bg-red-950/90 px-3 py-2 font-mono text-[10.5px] text-red-200",children:w})]}),e.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-y border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface-2))] px-2",children:[e.jsx("div",{role:"group","aria-label":v.sourceAria,className:"flex h-7 shrink-0 items-center border border-[hsl(var(--deck-border))]",children:[["user",v.user,Ar],["agent",v.agent,xr]].map(([h,E,$])=>e.jsxs("button",{type:"button",disabled:h==="agent"&&!n,"aria-pressed":t===h,onClick:()=>j(h),className:U("flex h-full items-center gap-1 border-r border-[hsl(var(--deck-border))] px-1.5 font-mono text-[9.5px] text-[hsl(var(--deck-ink-muted))] last:border-r-0 disabled:opacity-40",t===h&&"bg-[hsl(var(--deck-canvas-veil))] text-[hsl(var(--deck-ink))]"),children:[e.jsx($,{className:"h-3 w-3"}),e.jsx("span",{children:E})]},h))}),e.jsx("span",{title:L?`${v.selectedRef}: ${L}`:v.noRef,className:"w-20 shrink-0 truncate font-mono text-[10px] text-[hsl(var(--deck-ink-muted))]",children:L??"ref"}),e.jsx(W,{type:"button",variant:"ghost",size:"icon",disabled:A||!L||c,title:v.click,"aria-label":v.click,onClick:()=>{L&&d({kind:"click"},L)},className:"h-7 w-7 rounded-md",children:e.jsx(St,{className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"flex h-7 min-w-0 flex-1 items-center border border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-canvas))] px-2",children:[e.jsx("input",{value:C,onChange:h=>G(h.target.value),disabled:A,placeholder:v.valuePlaceholder,"aria-label":v.valuePlaceholder,className:"min-w-0 flex-1 bg-transparent font-mono text-[10.5px] outline-none"}),e.jsx(W,{type:"button",variant:"ghost",size:"icon",disabled:A||!L||!C||c,title:v.fill,"aria-label":v.fill,onClick:()=>{L&&d({kind:"fill",value:C},L)},className:"h-6 w-6 rounded-md",children:e.jsx(vr,{className:"h-3 w-3"})})]}),e.jsx(W,{type:"button",variant:"ghost",size:"icon",disabled:A||!s||c,title:v.scrollUp,"aria-label":v.scrollUp,onClick:()=>void d({kind:"scroll",direction:"up",amount:560}),className:"h-7 w-7 rounded-md",children:e.jsx(Pr,{className:"h-3.5 w-3.5"})}),e.jsx(W,{type:"button",variant:"ghost",size:"icon",disabled:A||!s||c,title:v.scrollDown,"aria-label":v.scrollDown,onClick:()=>void d({kind:"scroll",direction:"down",amount:560}),className:"h-7 w-7 rounded-md",children:e.jsx(Nr,{className:"h-3.5 w-3.5"})}),e.jsx(W,{type:"button",variant:"ghost",size:"icon",disabled:A||!s||c,title:v.snapshot,"aria-label":v.snapshot,onClick:()=>void D(),className:"h-7 w-7 rounded-md",children:e.jsx(Bt,{className:"h-3.5 w-3.5"})}),e.jsx(W,{type:"button",variant:"ghost",size:"icon",disabled:A||!r||c,title:v.reset,"aria-label":v.reset,onClick:()=>{F(null),x()},className:"h-7 w-7 rounded-md",children:e.jsx(Ot,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"flex h-[38%] min-h-32 shrink-0 flex-col overflow-hidden",children:[e.jsx("div",{role:"tablist",className:"grid h-8 shrink-0 grid-cols-4 border-b border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[["dom",v.dom,br],["console",v.console,Fr],["network",v.network,Mr],["page-errors",v.errors,Er]].map(([h,E,$])=>e.jsxs("button",{type:"button",role:"tab",disabled:A&&h!=="dom","aria-selected":z===h,onClick:()=>ne(h),className:U("flex min-w-0 items-center justify-center gap-1 border-r border-[hsl(var(--deck-border))] px-1 font-mono text-[10px] text-[hsl(var(--deck-ink-muted))] last:border-r-0",z===h&&"bg-[hsl(var(--deck-canvas-veil))] text-[hsl(var(--deck-ink))]"),children:[e.jsx($,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:E})]},h))}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto bg-[hsl(var(--deck-canvas-veil))] p-2 font-mono text-[10px] leading-5 text-[hsl(var(--deck-ink-muted))]",children:z==="dom"?xe.length>0?xe.map((h,E)=>h.ref?e.jsx("button",{type:"button","data-browser-ref":h.ref,disabled:A,onClick:()=>F(h.ref??null),className:U("block w-full whitespace-pre-wrap px-1 text-left hover:bg-[hsl(var(--deck-accent)/0.08)]",L===h.ref&&"bg-[hsl(var(--deck-accent)/0.12)] text-[hsl(var(--deck-ink))]"),children:h.text},`${h.ref}:${E}`):e.jsx("div",{className:"whitespace-pre-wrap px-1",children:h.text},`${h.text}:${E}`)):e.jsx("div",{className:"flex h-full items-center justify-center",children:v.noEntries}):g===z?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(Re,{className:"h-4 w-4 animate-spin"})}):V.length>0?V.map(h=>e.jsx("div",{className:"border-b border-[hsl(var(--deck-border))] px-1 py-1 last:border-b-0",children:Gr(h)},h.sequence)):e.jsx("div",{className:"flex h-full items-center justify-center",children:v.noEntries})})]})]})}const Kr="http://localhost:3000",Jr=2048,Qr=/^(?: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,Xr=/^[a-z\d.-]+:\d+$/i;function Qt(){return typeof window>"u"?void 0:window.location.origin}function ot(t,n=Qt(),r=!1){const s=t.trim();if(!s)return{ok:!1,reason:"empty"};if(s.length>Jr)return{ok:!1,reason:"invalid"};let l=s;const a=l.split(/[/?#]/,1)[0]??"";Qr.test(a)||Xr.test(a)?l=`http://${l}`:l.startsWith("//")?l=`https:${l}`:/^[a-z][a-z\d+.-]*:/i.test(l)||(l=`https://${l}`);let b;try{b=new URL(l)}catch{return{ok:!1,reason:"invalid"}}return b.protocol!=="http:"&&b.protocol!=="https:"?{ok:!1,reason:"protocol"}:b.username||b.password?{ok:!1,reason:"credentials"}:r&&n&&b.origin===n?{ok:!1,reason:"same_origin"}:{ok:!0,url:b.href}}function Yr(t,n=Qt()){return ot(t,n,!0)}function Zr(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 es(t){try{const n=new URL(t).protocol;return n==="http:"||n==="https:"}catch{return!1}}const ts={en:{modeAria:"Browser mode",preview:"Preview",test:"Test",external:"External",noSession:"No active Session",snapshotRefreshed:"The page changed. Snapshot refreshed; select the element again.",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",externalEmpty:"No external page selected",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:{modeAria:"浏览器模式",preview:"预览",test:"测试",external:"外部",noSession:"没有活动 Session",snapshotRefreshed:"页面已变化,快照已刷新,请重新选择元素。",toolbarAria:"浏览器导航",addressAria:"浏览器地址",addressPlaceholder:"输入 HTTP 或 HTTPS 地址",back:"后退",forward:"前进",reload:"刷新页面",go:"打开地址",openExternal:"在系统浏览器中打开",externalEmpty:"未选择外部页面",status:{idle:"空闲",loading:"正在加载…",ready:"就绪",error:"失败"},error:{empty:"请输入地址。",invalid:"请输入有效地址。",protocol:"仅支持 HTTP 与 HTTPS 地址。",credentials:"不允许使用包含凭据的地址。",same_origin:"不能在面板中嵌套 Blade Web 自身地址。"}}};function rs({sessionRef:t=null}){const{locale:n}=Ke(),r=ts[n],s=wt(u=>u.agentActivity),l=t!==null&&s!==null&&s.sessionRef.sessionId===t.sessionId&&s.sessionRef.projectPath===t.projectPath,[a,b]=i.useState("preview"),[c,w]=i.useState("user"),[m,g]=i.useState(Kr),[d,y]=i.useState({entries:[],index:-1}),D=i.useRef(d),[x,j]=i.useState(0),[k,v]=i.useState("idle"),[L,F]=i.useState(null),[C,G]=i.useState(null),[z,pe]=i.useState(null),[Q,_]=i.useState(null),[me,A]=i.useState(!1),[xe,V]=i.useState(null),[se,B]=i.useState(!1),[ne,h]=i.useState(null),[E,$]=i.useState(null),[O,K]=i.useState({}),[ae,ve]=i.useState(null),R=i.useRef(0),X=i.useRef(null),be=i.useRef(null),Y=d.entries[d.index]??null,Z=a==="preview"?Y:a==="test"?c==="agent"&&l?(s==null?void 0:s.url)??null:(C==null?void 0:C.url)??null:E,Je=i.useMemo(()=>{if(!Z)return"";try{return new URL(Z).host}catch{return""}},[Z]),H=a==="preview"?k:a==="test"?c==="agent"&&l?me||(s==null?void 0:s.phase)==="running"?"loading":xe||(s==null?void 0:s.phase)==="error"?"error":Q?"ready":"idle":se?"loading":ne?"error":C?"ready":"idle":E?"ready":"idle",oe=L!==null?r.error[L]:a==="test"?c==="agent"&&l?xe??(s==null?void 0:s.errorCode)??null:ne:null,Pe=u=>{X.current&&URL.revokeObjectURL(X.current),X.current=u,pe(u)},ge=u=>{be.current&&URL.revokeObjectURL(be.current),be.current=u,_(u)};i.useEffect(()=>{const u=R.current+1;return R.current=u,G(null),w("user"),h(null),V(null),A(!1),K({}),Pe(null),ge(null),()=>{R.current===u&&(R.current+=1)}},[t==null?void 0:t.projectPath,t==null?void 0:t.sessionId]),i.useEffect(()=>()=>{X.current&&URL.revokeObjectURL(X.current),be.current&&URL.revokeObjectURL(be.current)},[]),i.useEffect(()=>{!t||!l||!s||(b("test"),w("agent"),F(null),s.url&&g(s.url))},[s==null?void 0:s.revision,l,t]),i.useEffect(()=>{if(!t||!l||!s||!s.pageId||!s.origin||s.frameRevision===0)return;if(!es(s.origin)){A(!1),V(null),ge(null);return}const u=R.current,f=s.frameRevision,N=()=>{const P=wt.getState().agentActivity;return R.current===u&&(P==null?void 0:P.frameRevision)===f&&P.sessionRef.sessionId===t.sessionId&&P.sessionRef.projectPath===t.projectPath};A(!0),V(null),ce.screenshot(t,{source:"agent",pageId:s.pageId,expectedOrigin:s.origin}).then(P=>{N()&&ge(URL.createObjectURL(P))}).catch(P=>{N()&&V(P instanceof Error?P.message:String(P))}).finally(()=>{N()&&A(!1)})},[s==null?void 0:s.frameRevision,s==null?void 0:s.origin,s==null?void 0:s.pageId,l,t]);const Qe=async(u,f,N)=>{const P=await ce.screenshot(u,{pageId:f.pageId,expectedOrigin:f.origin});R.current===N&&Pe(URL.createObjectURL(P))},ee=async(u,f,N)=>{R.current===N&&(G(f),g(f.url),K({}),await Qe(u,f,N))},J=async u=>{if(!t){h(r.noSession);return}const f=R.current;B(!0),h(null);try{const N=await ce.navigate(t,u);await ee(t,N,f)}catch(N){R.current===f&&h(N instanceof Error?N.message:String(N))}finally{R.current===f&&B(!1)}},ze=u=>{const f=Zr(D.current,u);D.current=f,y(f),g(u),v("loading")},Xe=u=>{u.preventDefault();const f=a==="preview"?Yr(m):ot(m);if(!f.ok){F(f.reason);return}if(F(null),a==="preview"){f.url===Y&&j(N=>N+1),ze(f.url);return}if(a==="test"){if(c==="agent")return;J({action:"goto",url:f.url});return}$(f.url),g(f.url),window.open(f.url,"_blank","noopener,noreferrer")},Ne=u=>{const f=D.current.index+u,N=D.current.entries[f];if(!N)return;const P={...D.current,index:f};D.current=P,y(P),g(N),v("loading")},ke=u=>{if(a==="preview"){u==="back"?Ne(-1):u==="forward"?Ne(1):Y&&(v("loading"),j(f=>f+1));return}a==="test"&&c==="user"&&C&&J({action:u,pageId:C.pageId,expectedOrigin:C.origin})},Ie=u=>{b(u),F(null),h(null);const f=u==="preview"?Y:u==="test"?c==="agent"&&l?s==null?void 0:s.url:C==null?void 0:C.url:E;f&&g(f)},De=u=>{if(u==="agent"&&!l)return;w(u),F(null),h(null),V(null);const f=u==="agent"?s==null?void 0:s.url:C==null?void 0:C.url;f&&g(f)},Fe=async(u,f)=>{if(!t||!C)return;const N=C,P=R.current;B(!0),h(null);try{const q=await ce.interact(t,{pageId:N.pageId,snapshotId:N.snapshotId,expectedOrigin:N.origin,...f?{ref:f}:{},action:u});if(q.outcome==="applied")await ee(t,q.observation,P);else if(q.outcome==="applied_observation_failed"){const ue=await ce.snapshot(t,{pageId:q.pageId});await ee(t,ue,P)}else h(q.errorCode)}catch(q){if(R.current===P){const ue=q instanceof Error?q.message:String(q);if(/snapshot is stale/i.test(ue))try{const fe=await ce.snapshot(t,{pageId:N.pageId});await ee(t,fe,P),R.current===P&&h(r.snapshotRefreshed)}catch(fe){R.current===P&&h(fe instanceof Error?fe.message:String(fe))}else h(ue)}}finally{R.current===P&&B(!1)}},We=async()=>{if(!t||!C)return;const u=R.current;B(!0),h(null);try{const f=await ce.snapshot(t,{pageId:C.pageId});await ee(t,f,u)}catch(f){R.current===u&&h(f instanceof Error?f.message:String(f))}finally{R.current===u&&B(!1)}},Ae=async u=>{if(!t||!C)return;const f=R.current;ve(u);try{const N=await ce.inspect(t,{target:u,pageId:C.pageId,expectedOrigin:C.origin});R.current===f&&K(P=>({...P,[u]:N.entries??[]}))}catch(N){R.current===f&&h(N instanceof Error?N.message:String(N))}finally{R.current===f&&ve(null)}},_e=async()=>{if(!t)return;const u=R.current;B(!0),h(null);try{await ce.reset(t),R.current===u&&(G(null),K({}),Pe(null))}catch(f){R.current===u&&h(f instanceof Error?f.message:String(f))}finally{R.current===u&&B(!1)}},ie=()=>{const f=ot(Z??m);if(!f.ok){F(f.reason);return}$(f.url),window.open(f.url,"_blank","noopener,noreferrer")},Se=a==="preview"?d.index>0:a==="test"&&c==="user"&&!!C,de=a==="preview"?d.index>=0&&d.index<d.entries.length-1:a==="test"&&c==="user"&&!!C,we=a==="test"&&c==="agent",te=c==="agent"?me||(s==null?void 0:s.phase)==="running":se;return e.jsxs("section",{"data-browser-panel":!0,"data-browser-mode":a,"data-browser-test-source":c,"data-browser-history-count":d.entries.length,"data-browser-history-index":d.index,className:"flex h-full min-h-0 flex-col bg-[hsl(var(--deck-canvas))]",children:[e.jsx("div",{role:"tablist","aria-label":r.modeAria,className:"grid h-9 shrink-0 grid-cols-3 border-b border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))]",children:[["preview",r.preview,Ge],["test",r.test,Dr],["external",r.external,Nt]].map(([u,f,N])=>e.jsxs("button",{type:"button",role:"tab","aria-selected":a===u,onClick:()=>Ie(u),className:U("flex min-w-0 items-center justify-center gap-1.5 border-r border-[hsl(var(--deck-border))] px-2 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))] last:border-r-0",a===u&&"bg-[hsl(var(--deck-canvas-veil))] text-[hsl(var(--deck-ink))]"),children:[e.jsx(N,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:f})]},u))}),e.jsxs("form",{"aria-label":r.toolbarAria,onSubmit:Xe,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(W,{type:"button",variant:"ghost",size:"icon",disabled:!Se||a==="test"&&te,"aria-label":r.back,title:r.back,onClick:()=>ke("back"),className:"h-8 w-8 rounded-md text-[hsl(var(--deck-ink-muted))]",children:e.jsx(Cr,{className:"h-4 w-4"})}),e.jsx(W,{type:"button",variant:"ghost",size:"icon",disabled:!de||a==="test"&&te,"aria-label":r.forward,title:r.forward,onClick:()=>ke("forward"),className:"h-8 w-8 rounded-md text-[hsl(var(--deck-ink-muted))]",children:e.jsx(Tr,{className:"h-4 w-4"})}),e.jsx(W,{type:"button",variant:"ghost",size:"icon",disabled:a==="external"||we||!Z||a==="test"&&te,"aria-label":r.reload,title:r.reload,onClick:()=>ke("reload"),className:"h-8 w-8 rounded-md text-[hsl(var(--deck-ink-muted))]",children:e.jsx(Bt,{className:U("h-4 w-4",H==="loading"&&"animate-spin")})}),e.jsxs("div",{className:U("flex h-8 min-w-0 flex-1 items-center gap-2 rounded-md border bg-[hsl(var(--deck-canvas))] px-2",oe?"border-red-500/70":"border-[hsl(var(--deck-border))] focus-within:border-[hsl(var(--deck-accent)/0.65)]"),children:[e.jsx(Ge,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("input",{"data-browser-panel-address":!0,"data-preview-browser-address":a==="preview"||void 0,value:m,readOnly:we,onChange:u=>{g(u.target.value),F(null)},onKeyDown:u=>{u.key==="Escape"&&Z&&(u.preventDefault(),g(Z),F(null))},"aria-label":r.addressAria,placeholder:r.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(W,{type:"submit",variant:"ghost",size:"icon","aria-label":r.go,title:r.go,disabled:we||a==="test"&&te,className:"h-8 w-8 rounded-md text-[hsl(var(--deck-accent))]",children:H==="loading"?e.jsx(Re,{className:"h-4 w-4 animate-spin"}):e.jsx(qt,{className:"h-4 w-4"})}),e.jsx(W,{type:"button",variant:"ghost",size:"icon",disabled:!Z,"aria-label":r.openExternal,title:r.openExternal,onClick:ie,className:"h-8 w-8 rounded-md text-[hsl(var(--deck-ink-muted))]",children:e.jsx(jt,{className:"h-4 w-4"})})]}),oe&&a!=="test"&&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:oe}),e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:a==="preview"?e.jsx(Or,{url:Y,revision:x,loadState:k,onLoad:()=>v("ready"),onError:()=>v("error")}):a==="test"?e.jsx(Vr,{source:c,agentAvailable:l,sessionAvailable:!!t,observation:c==="agent"?null:C,screenshotUrl:c==="agent"?Q:z,interaction:c==="agent"?s==null?void 0:s.interaction:void 0,pointerRevision:c==="agent"?(s==null?void 0:s.pointerRevision)??0:0,busy:te,error:oe,diagnostics:c==="agent"?{}:O,diagnosticsLoading:c==="agent"?null:ae,onInteract:Fe,onInspect:Ae,onSnapshot:We,onReset:_e,onSourceChange:De}):e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 bg-[hsl(var(--deck-canvas-veil))]",children:[e.jsx(Nt,{className:"h-7 w-7 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("span",{className:"font-mono text-[11px] text-[hsl(var(--deck-ink-muted))]",children:E?new URL(E).host:r.externalEmpty}),e.jsxs(W,{type:"button",variant:"outline",onClick:ie,disabled:!m.trim(),className:"h-8 rounded-md font-mono text-[11px]",children:[e.jsx(jt,{className:"mr-2 h-3.5 w-3.5"}),r.openExternal]})]})}),e.jsxs("div",{"data-browser-panel-status":H,"data-preview-browser-status":a==="preview"?H:void 0,"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:U("h-1.5 w-1.5 shrink-0 rounded-full bg-[hsl(var(--deck-ink-faint))]",H==="loading"&&"bg-amber-500",H==="ready"&&"bg-emerald-500",H==="error"&&"bg-red-500")}),e.jsx("span",{children:r.status[H]})]}),e.jsx("span",{className:"ml-3 truncate",children:Je||r[a]})]})]})}function Ve(t){return t.normalize("NFKC").toLocaleLowerCase().trim()}function ss(t,n,r){const s=Ve(n).split(/\s+/).filter(Boolean);return t.filter(l=>{if(r!=="all"&&l.status!==r)return!1;if(s.length===0)return!0;const a=Ve([l.title,l.subtitle,l.content].filter(Boolean).join(" "));return s.every(b=>a.includes(b))})}function Xt(t){return t.replace(/\/+$/,"").split("/").filter(Boolean).at(-1)||t}function ns(t,n){const r=Ve(n).split(/\s+/).filter(Boolean);return r.length===0?t:t.filter(s=>{const l=Ve([s.filePath,s.summary].filter(Boolean).join(" "));return r.every(a=>l.includes(a))})}function as(t,n,r){return n===0?0:(t+r+n)%n}const Tt=20,Lt=20,Rt=160,Pt=240;function It(t,n){const r=a=>a.replace(/\\/g,"/").replace(/^\.?\//,"").replace(/\/+/g,"/"),s=r(t),l=r(n);return s===l||s.endsWith(`/${l}`)||l.endsWith(`/${s}`)}function os({diffs:t,expanded:n,targetPath:r,onToggle:s,onSetAllExpanded:l}){var x,j;const a=he(),[b,c]=i.useState(""),w=`${b}\0${t.length}\0${((x=t[0])==null?void 0:x.filePath)??""}\0${((j=t.at(-1))==null?void 0:j.filePath)??""}`,[m,g]=i.useState({key:w,count:Tt}),d=m.key===w?m.count:Tt,y=i.useMemo(()=>ns(t,b),[t,b]),D=i.useMemo(()=>{const k=y.slice(0,d);if(!r)return k;const v=y.find(L=>L.filePath&&It(L.filePath,r));return v&&!k.includes(v)?[...k,v]:k},[y,r,d]);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(lt,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-ink-faint))]"}),e.jsx("input",{type:"search","aria-label":a("preview.diff.searchAria"),placeholder:a("preview.diff.searchPlaceholder"),value:b,onChange:k=>c(k.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:[y.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:a("preview.diff.changedFiles",{count:t.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsxs("button",{type:"button",onClick:()=>l(!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(Sr,{className:"h-3 w-3"}),a("preview.diff.expandAll")]}),e.jsxs("button",{type:"button",onClick:()=>l(!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(Ir,{className:"h-3 w-3"}),a("preview.diff.collapseAll")]})]})]})]}),y.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:a("preview.diff.noMatches")}):D.map(k=>{const v=k.filePath||"unknown",L=t.indexOf(k),F=n[v]??L===0,C=!!(r&&It(v,r));return e.jsxs("div",{"data-preview-diff-path":k.filePath,className:U("overflow-hidden rounded-lg border border-[hsl(var(--deck-border))] transition-colors",C&&"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":F,onClick:()=>s(v),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:[F?e.jsx(Ht,{className:"h-4 w-4 text-[hsl(var(--deck-ink-muted))]"}):e.jsx(Gt,{className:"h-4 w-4 text-[hsl(var(--deck-ink-muted))]"}),e.jsx(Vt,{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:Xt(v)}),k.summary&&e.jsx("span",{className:"shrink-0 font-mono text-[11px] text-[hsl(var(--deck-ink-muted))]",children:k.summary})]}),F&&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:k.filePath}),e.jsx(is,{diff:k.diff})]})]},v)}),d<y.length&&e.jsx("div",{className:"flex justify-center pt-1",children:e.jsx("button",{type:"button",onClick:()=>g({key:w,count:Math.min(y.length,d+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:a("preview.diff.showMoreFiles",{count:Math.min(Lt,y.length-d)})})})]})}function is({diff:t}){const n=he(),r=i.useMemo(()=>t.patch.split(`
|
|
54
|
+
`),[t.patch]),[s,l]=i.useState({patch:t.patch,count:Rt}),a=s.patch===t.patch?s.count:Rt,b=r.slice(0,a);let c=0,w=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:b.map((m,g)=>{if(m.startsWith("@@")){const d=/@@ -(?<old>\d+),?(?<oldCount>\d*) \+(?<new>\d+),?(?<newCount>\d*) @@/.exec(m);return d!=null&&d.groups&&(c=Number.parseInt(d.groups.old,10),w=Number.parseInt(d.groups.new,10)),e.jsx(Ce,{line:m},`${m}-${g}`)}if(m.startsWith("---")||m.startsWith("+++")||m.startsWith("Index:")||m.startsWith("==="))return e.jsx(Ce,{line:m},`${m}-${g}`);if(m.startsWith("+")){const d=w++;return e.jsx(Ce,{line:m,oldLine:null,newLine:d},`${m}-${g}`)}if(m.startsWith("-")){const d=c++;return e.jsx(Ce,{line:m,oldLine:d,newLine:null},`${m}-${g}`)}return m.startsWith(" ")?e.jsx(Ce,{line:m,oldLine:c++,newLine:w++},`${m}-${g}`):e.jsx(Ce,{line:m},`${m}-${g}`)})}),a<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:()=>l({patch:t.patch,count:Math.min(r.length,a+Pt)}),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(Pt,r.length-a)})})})]})}function Ce({line:t,oldLine:n,newLine:r}){const s=t.startsWith("---")||t.startsWith("+++")||t.startsWith("Index:")||t.startsWith("==="),l=t.startsWith("@@"),a=t[0],b=s||l?t:t.slice(1),c=s?"text-[hsl(var(--deck-ink-muted))]":a==="+"?"bg-[#22C55E]/10 text-[#166534] dark:bg-[#22C55E]/10 dark:text-[#86efac]":a==="-"?"bg-[#EF4444]/10 text-[#b91c1c] dark:bg-[#EF4444]/10 dark:text-[#fca5a5]":l?"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:U("grid min-w-max grid-cols-[40px_40px_1fr] gap-2 px-3 py-0.5",c),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:b})]})}function ls({nodes:t,expandedDirs:n,childrenCache:r,directoryStates:s,selectedPath:l,onToggleDir:a,onRetryDir:b,onSelectFile:c}){return e.jsx(e.Fragment,{children:t.map(w=>e.jsx(Yt,{node:w,depth:0,expandedDirs:n,childrenCache:r,directoryStates:s,selectedPath:l,onToggleDir:a,onRetryDir:b,onSelectFile:c},w.path))})}function Yt({node:t,depth:n,expandedDirs:r,childrenCache:s,directoryStates:l,selectedPath:a,onToggleDir:b,onRetryDir:c,onSelectFile:w}){const m=he(),g=t.type==="dir",d=!!r[t.path],y=!g&&a===t.path,D=s[t.path]??[],x=l[t.path],j=n*14+24;return e.jsxs("div",{children:[e.jsxs("button",{type:"button","aria-expanded":g?d:void 0,"aria-busy":g&&(x==null?void 0:x.status)==="loading",onClick:()=>g?b(t.path):w(t.path),className:U("flex w-full items-center gap-2 rounded-md px-2 py-1 text-left font-mono text-[12px] transition-colors",y?"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))]",g&&"cursor-pointer"),style:{paddingLeft:n*14+8},children:[g?(x==null?void 0:x.status)==="loading"?e.jsx(Re,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"}):d?e.jsx(gr,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-ink))]"}):e.jsx(Lr,{className:"h-3.5 w-3.5 shrink-0 text-[hsl(var(--deck-ink-muted))]"}):e.jsx(Vt,{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})]}),g&&d&&e.jsxs("div",{children:[(x==null?void 0:x.status)==="loading"&&e.jsx("div",{role:"status",style:{paddingLeft:j},className:"py-1 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:m("preview.files.directoryLoading")}),(x==null?void 0:x.status)==="error"&&e.jsxs("div",{role:"alert",style:{marginLeft:j},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:x.message,children:x.message}),e.jsxs("button",{type:"button",onClick:()=>c(t.path),className:"mt-1 inline-flex items-center gap-1 font-medium underline-offset-2 hover:underline",children:[e.jsx(Ot,{className:"h-2.5 w-2.5"}),m("preview.action.retry")]})]}),(x==null?void 0:x.status)==="loaded"&&D.length===0&&e.jsx("div",{style:{paddingLeft:j},className:"py-1 font-mono text-[10px] text-[hsl(var(--deck-ink-faint))]",children:m("preview.files.directoryEmpty")}),D.map(k=>e.jsx(Yt,{node:k,depth:n+1,expandedDirs:r,childrenCache:s,directoryStates:l,selectedPath:a,onToggleDir:b,onRetryDir:c,onSelectFile:w},k.path))]})]})}const Dt=80,Ft=80;function cs({logs:t}){var x,j;const n=he(),[r,s]=i.useState(""),[l,a]=i.useState("all"),[b,c]=i.useState({}),w=`${l}\0${r}\0${t.length}\0${((x=t[0])==null?void 0:x.id)??""}\0${((j=t.at(-1))==null?void 0:j.id)??""}`,[m,g]=i.useState({key:w,count:Dt}),d=i.useMemo(()=>ss(t,r,l),[l,t,r]),y=m.key===w?m.count:Dt,D=d.slice(0,y);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(lt,{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:k=>s(k.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:[d.length,"/",t.length]})]}),e.jsx("div",{className:"flex items-center gap-1","aria-label":n("preview.logs.filterAria"),children:["all","running","error","success"].map(k=>e.jsx("button",{type:"button","aria-pressed":l===k,onClick:()=>a(k),className:U("rounded-md border px-2 py-1 font-mono text-[9.5px] transition-colors",l===k?"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.${k}`)},k))})]}),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(At,{title:n("preview.logs.emptyTitle"),subtitle:n("preview.logs.emptyHint")}):d.length===0?e.jsx(At,{title:n("preview.logs.noMatches"),subtitle:n("preview.logs.noMatchesHint")}):D.map(k=>{var G;const v=b[k.id],L=(k.content||"").split(`
|
|
55
|
+
`),F=L.length>10||(((G=k.content)==null?void 0:G.length)||0)>800,C=v||!F?L:L.slice(0,8);return e.jsxs("div",{"data-preview-log-id":k.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:k.title}),k.subtitle&&e.jsx("div",{className:"font-mono text-[11px] text-[hsl(var(--deck-ink-muted))]",children:k.subtitle})]}),e.jsx(ds,{status:k.status})]}),k.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:[C.join(`
|
|
56
|
+
`),!v&&F&&`
|
|
57
|
+
…`]}),F&&e.jsxs("button",{type:"button",onClick:()=>c(z=>({...z,[k.id]:!z[k.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:[v?e.jsx(Ht,{className:"h-3 w-3"}):e.jsx(Gt,{className:"h-3 w-3"}),n(v?"preview.logs.collapse":"preview.logs.expand")]})]})]},k.id)}),y<d.length&&e.jsx("div",{className:"flex justify-center",children:e.jsx("button",{type:"button",onClick:()=>g({key:w,count:Math.min(d.length,y+Ft)}),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(Ft,d.length-y)})})})]})]})}function At({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 ds({status:t}){const n=he(),r=n(t==="success"?"preview.logs.status.success":t==="error"?"preview.logs.status.error":"preview.logs.status.running"),s=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:U("rounded-full px-2 py-0.5 font-mono text-[11px]",s),children:r})}const us=640,Zt=360,it=960,Ss=i.forwardRef(function({open:n,maximized:r,disabled:s,onToggleMaximized:l,onTogglePreview:a},b){const c=he(),{locale:w}=Ke(),m=w==="zh"?{maximize:"全屏预览",restore:"还原分栏预览"}:{maximize:"Maximize preview",restore:"Restore split preview"},g=r?m.restore:m.maximize;return e.jsxs(e.Fragment,{children:[n&&e.jsx(W,{variant:"ghost",size:"icon","aria-pressed":!!r,"aria-label":g,title:g,onClick:l,className:U("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(qt,{className:U("h-4 w-4 transition-transform",r&&"rotate-180")})}),e.jsx(W,{ref:b,variant:"ghost",size:"icon",onClick:a,disabled:s,title:c("preview.title"),"aria-label":w==="zh"?"切换预览面板":"Toggle preview panel",className:U("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(Ge,{className:"h-4 w-4"})})]})});function Mt(t){const n=typeof window>"u"?it:Math.max(280,Math.floor(window.innerWidth*.72));return Math.min(it,n,Math.max(Zt,Math.round(t)))}function er(t,n,r){var s;if(t){const l=(s=r==null?void 0:r.taskDelivery)==null?void 0:s.status;return(r==null?void 0:r.taskIsolation)==="worktree"&&r.taskSourceProjectPath&&(l==="applied"||l==="discarded")?{sessionId:t.sessionId,projectPath:r.taskSourceProjectPath}:t}return n?{sessionId:`project:${n}`,projectPath:n}:null}function at(){const t=Te.getState(),n=t.sessions.find(r=>$e({sessionId:r.sessionId,projectPath:r.projectPath},t.currentSessionRef));return er(t.currentSessionRef,t.selectedProjectPath,n)}function Ut(t,n){const r=a=>a.replace(/\\/g,"/").replace(/^\.?\//,"").replace(/\/+/g,"/"),s=r(t),l=r(n);return s===l||s.endsWith(`/${l}`)||l.endsWith(`/${s}`)}const fs=i.lazy(async()=>({default:(await jr(()=>import("./index-B5mUEr6D.js"),__vite__mapDeps([0,1]))).Editor}));function He(t,n){return t instanceof Error?t.message:n}function Es({returnFocusElement:t,maximized:n=!1}={}){var gt,kt;const r=he(),{toggleFilePreview:s,previewWidth:l,setPreviewWidth:a,previewTab:b,setPreviewTab:c,previewTargetPath:w,previewRequestId:m}=yt(),g=Te(o=>o.messages),d=Te(o=>o.currentSessionRef),y=Te(o=>o.sessions),D=Te(o=>o.selectedProjectPath),x=i.useMemo(()=>y.find(o=>$e({sessionId:o.sessionId,projectPath:o.projectPath},d)),[d,y]),j=i.useMemo(()=>er(d,D,x),[x,d,D]),[k,v]=i.useState(b),[L,F]=i.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 1023px)").matches),[C,G]=i.useState(null),[z,pe]=i.useState(!1),[Q,_]=i.useState([]),[me,A]=i.useState({}),[xe,V]=i.useState({}),[se,B]=i.useState(0),[ne,h]=i.useState(!1),[E,$]=i.useState(null),[O,K]=i.useState(""),[ae,ve]=i.useState([]),[R,X]=i.useState(!1),[be,Y]=i.useState(!1),[Z,Je]=i.useState(0),[H,oe]=i.useState(0),[Pe,ge]=i.useState({}),[Qe,ee]=i.useState({}),[J,ze]=i.useState(null),[Xe,Ne]=i.useState(""),[ke,Ie]=i.useState(!1),[De,Fe]=i.useState(null),[We,Ae]=i.useState(!1),_e=i.useRef(j),ie=i.useRef(0),Se=i.useRef(0),de=i.useRef({}),we=i.useRef(0),te=i.useRef(0),u=i.useRef(0),f=i.useRef({}),N=i.useRef({}),P=i.useRef({}),q=i.useRef(null),ue=i.useRef(null),fe=i.useRef(null),ct=i.useRef(null),Ye=i.useRef(l),dt=i.useRef(d),Ze=i.useRef(null);i.useLayoutEffect(()=>{$e(_e.current,j)||(ie.current+=1),_e.current=j},[j]),i.useEffect(()=>{if(typeof window.matchMedia!="function")return;const o=window.matchMedia("(max-width: 1023px)"),p=()=>F(o.matches);return p(),o.addEventListener("change",p),()=>o.removeEventListener("change",p)},[]),i.useEffect(()=>(ct.current=t??(document.activeElement instanceof HTMLElement?document.activeElement:null),()=>{const o=ct.current;requestAnimationFrame(()=>{o!=null&&o.isConnected&&o.focus({preventScroll:!0})})}),[t]),i.useEffect(()=>{var o;L&&((o=fe.current)==null||o.focus({preventScroll:!0}))},[L]);const tr=o=>{var M;if(!L)return;if(o.key==="Escape"){o.preventDefault(),s();return}if(o.key!=="Tab")return;const p=Array.from(((M=ue.current)==null?void 0:M.querySelectorAll('button:not([disabled]), input:not([disabled]), [href], [tabindex]:not([tabindex="-1"])'))??[]).filter(I=>!I.closest("[hidden]"));if(p.length===0)return;const T=p[0],S=p[p.length-1];o.shiftKey&&document.activeElement===T?(o.preventDefault(),S==null||S.focus()):!o.shiftKey&&document.activeElement===S&&(o.preventDefault(),T==null||T.focus())},Me=(o,p)=>p===ie.current&&$e(at(),o),ut=async(o,p="")=>{const T=p?`/suggestions/files/tree?path=${encodeURIComponent(p)}`:"/suggestions/files/tree",S=await fetch(T,{headers:nt(o)});if(!S.ok)throw new Error(r("preview.files.treeFailed"));return(await S.json()).map(I=>({...I,children:I.type==="dir"?[]:void 0}))};i.useEffect(()=>{const o=++Se.current;return(async()=>{if(!j){_([]),h(!1),$(null);return}const T={...j},S=ie.current,M=()=>o===Se.current&&Me(T,S);if(M()){_([]),h(!0),$(null);try{const I=await ut(T);M()&&_(I)}catch(I){M()&&$(He(I,r("preview.files.treeFailed")))}finally{M()&&h(!1)}}})(),()=>{Se.current===o&&(Se.current+=1)}},[se,j==null?void 0:j.projectPath,j==null?void 0:j.sessionId]),i.useEffect(()=>{q.current=null,f.current={},N.current={},P.current={},de.current={},we.current+=1,ze(null),Ne(""),Ie(!1),Fe(null),Ae(!1),ge({}),A({}),V({}),K(""),ve([]),X(!1),Y(!1),oe(0),ee({})},[j==null?void 0:j.projectPath,j==null?void 0:j.sessionId]);const rr=i.useMemo(()=>ps(g),[g]),[sr,ft]=i.useState(null),[nr,et]=i.useState(!1),[ht,pt]=i.useState(null),[ar,or]=i.useState(0),tt=(x==null?void 0:x.taskIsolation)==="worktree"&&((gt=x.taskDelivery)==null?void 0:gt.status)==="discarded",mt=(x==null?void 0:x.taskIsolation)==="worktree"&&!!x.taskDiffStat&&!tt,xt=mt&&!!(x!=null&&x.taskDiffStat&&x.taskDiffStat.changedFiles>0),ye=tt?[]:mt?sr??[]:rr,ir=i.useMemo(()=>hs(g),[g]);i.useEffect(()=>{const o=O.trim(),p=++te.current;if(oe(0),Y(!1),!o||k!=="files"||!j){ve([]),X(!1);return}const T={...j},S=ie.current;X(!0);const M=window.setTimeout(()=>{fetch(`/suggestions/files?q=${encodeURIComponent(o)}&limit=100&type=file`,{headers:nt(T)}).then(async I=>{if(!I.ok)throw new Error(r("preview.files.searchFailed"));return await I.json()}).then(I=>{p===te.current&&Me(T,S)&&(ve(I.filter(le=>!le.endsWith("/"))),Y(!1))}).catch(()=>{p===te.current&&Me(T,S)&&(ve([]),Y(!0))}).finally(()=>{p===te.current&&X(!1)})},160);return()=>window.clearTimeout(M)},[k,O,Z,j==null?void 0:j.projectPath,j==null?void 0:j.sessionId]),i.useEffect(()=>{v(yt.getState().previewTab)},[m]),i.useEffect(()=>{const o=dt.current;if(dt.current=d,d||!D){Ze.current=null;return}const p=!!o||Ze.current!==D;Ze.current=D,p&&k==="diff"&&(v("files"),c("files"))},[k,d==null?void 0:d.projectPath,d==null?void 0:d.sessionId,D,c]),i.useEffect(()=>{var T;if(!w||k!=="diff")return;const o=(T=ye.find(S=>S.filePath&&Ut(S.filePath,w)))==null?void 0:T.filePath;if(!o)return;ee(S=>({...S,[o]:!0}));const p=requestAnimationFrame(()=>{var M,I;const S=Array.from(((M=ue.current)==null?void 0:M.querySelectorAll("[data-preview-diff-path]"))??[]).find(le=>Ut(le.dataset.previewDiffPath??"",w));typeof(S==null?void 0:S.scrollIntoView)=="function"&&S.scrollIntoView({block:"nearest",behavior:"smooth"}),(I=S==null?void 0:S.querySelector("button"))==null||I.focus({preventScroll:!0})});return()=>cancelAnimationFrame(p)},[k,ye,m,w]),i.useEffect(()=>{const o=++u.current;if(ft(null),pt(null),et(!1),!d||!xt)return;const p={...d};return et(!0),kr.getTaskDiff(p).then(T=>{o!==u.current||!$e(Te.getState().currentSessionRef,p)||ft(T.files.map(S=>({filePath:S.path,diff:{patch:S.patch},summary:S.binary?"binary":`+${S.additions} -${S.deletions}${S.truncated?" (truncated)":""}`})))}).catch(T=>{o===u.current&&pt(He(T,r("preview.diff.failedTitle")))}).finally(()=>{o===u.current&&et(!1)}),()=>{u.current===o&&(u.current+=1)}},[x==null?void 0:x.taskCompletedAt,(kt=x==null?void 0:x.taskDelivery)==null?void 0:kt.status,x==null?void 0:x.taskDiffStat,x==null?void 0:x.taskIsolation,d,xt,ar]);const lr=o=>{ee(p=>({...p,[o]:!p[o]}))},cr=o=>{ee(Object.fromEntries(ye.map(p=>[p.filePath||"unknown",o])))},Be=async o=>{const p=at();if(!p)return;const T=ie.current,S=++we.current,M=()=>S===we.current&&q.current===o&&Me(p,T);q.current=o,ze(o),Ne(""),Ie(!0),Fe(null),Ae(!1);try{const I=await fetch(`/suggestions/files/content?path=${encodeURIComponent(o)}`,{headers:nt(p)});if(!I.ok)throw new Error(r("preview.files.contentFailed"));const le=await I.json();M()&&(Ne(le.content||""),Ae(!!le.truncated))}catch(I){M()&&Fe(He(I,r("preview.files.contentFailed")))}finally{M()&&Ie(!1)}},dr=o=>{if(o.key==="ArrowDown"||o.key==="ArrowUp"){o.preventDefault(),oe(p=>as(p,ae.length,o.key==="ArrowDown"?1:-1));return}if(o.key==="Enter"){const p=ae[H];if(!p)return;o.preventDefault(),Be(p);return}o.key==="Escape"&&(o.preventDefault(),K(""))},rt=(o,p)=>{const T={...P.current,[o]:p};P.current=T,V(T)},vt=async o=>{const p=(de.current[o]??0)+1;de.current[o]=p,rt(o,{status:"loading"});const T=at();if(!T)return;const S=ie.current,M=()=>de.current[o]===p&&f.current[o]===!0&&Me(T,S);try{const I=await ut(T,o);if(M()){const le={...N.current,[o]:I};N.current=le,A(le),rt(o,{status:"loaded"})}}catch(I){M()&&rt(o,{status:"error",message:He(I,r("preview.files.treeFailed"))})}},ur=o=>{const p=!f.current[o],T={...f.current,[o]:p};if(f.current=T,ge(T),!p){de.current[o]=(de.current[o]??0)+1;return}N.current[o]||vt(o)},fr=o=>{if(!f.current[o]){const p={...f.current,[o]:!0};f.current=p,ge(p)}vt(o)},hr=o=>{o.preventDefault(),o.currentTarget.setPointerCapture(o.pointerId),Ye.current=l,pe(!0),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},pr=o=>{if(!z)return;const p=Mt(window.innerWidth-o.clientX);Ye.current=p,G(p)},bt=o=>{z&&(o.currentTarget.hasPointerCapture(o.pointerId)&&o.currentTarget.releasePointerCapture(o.pointerId),pe(!1),G(null),a(Ye.current),document.body.style.cursor="",document.body.style.userSelect="")};i.useEffect(()=>()=>{document.body.style.cursor="",document.body.style.userSelect=""},[]);const st=Mt(C??l);return e.jsxs("div",{ref:ue,"data-testid":"file-preview",role:L?"dialog":"complementary","aria-modal":L||void 0,"aria-label":r("preview.title"),onKeyDown:tr,style:n?{width:"100%",maxWidth:"none"}:{width:st,maxWidth:"72vw"},className:U("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":Zt,"aria-valuemax":it,"aria-valuenow":st,"aria-hidden":L||void 0,tabIndex:L?-1:0,onPointerDown:hr,onPointerMove:pr,onPointerUp:bt,onPointerCancel:bt,onDoubleClick:()=>a(us),onKeyDown:o=>{o.key!=="ArrowLeft"&&o.key!=="ArrowRight"||(o.preventDefault(),a(st+(o.key==="ArrowLeft"?24:-24)))},className:U("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))]",z&&"after:bg-[hsl(var(--deck-accent))]")}),e.jsxs(Ur,{value:k,onValueChange:o=>{const p=o;v(p),c(p)},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($r,{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(Oe,{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(Oe,{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(Oe,{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(Oe,{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")})]}),L&&e.jsx(W,{ref:fe,variant:"ghost",size:"icon",onClick:s,"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(wr,{className:"w-4 h-4"})})]}),e.jsx(qe,{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:tt?e.jsx(je,{title:r("preview.diff.discardedTitle"),subtitle:r("preview.diff.discardedHint"),role:"status"}):nr&&ye.length===0?e.jsx(je,{title:r("preview.diff.loadingTitle"),subtitle:r("preview.diff.loadingHint")}):ht&&ye.length===0?e.jsx(je,{title:r("preview.diff.failedTitle"),subtitle:ht,actionLabel:r("preview.action.retry"),onAction:()=>or(o=>o+1),role:"alert"}):ye.length===0?e.jsx(je,{title:r("preview.diff.emptyTitle"),subtitle:r("preview.diff.emptyHint")}):e.jsx(os,{diffs:ye,expanded:Qe,targetPath:w,onToggle:lr,onSetAllExpanded:cr})})}),e.jsx(qe,{value:"files",className:"overflow-hidden flex-1 mt-0",children:e.jsxs("div",{className:"px-4 py-4 h-full",children:[ne&&e.jsx(je,{title:r("preview.files.loadingTitle"),subtitle:r("preview.files.loadingHint")}),!ne&&E&&e.jsx(je,{title:r("preview.files.failedTitle"),subtitle:E,actionLabel:r("preview.action.retry"),onAction:()=>B(o=>o+1),role:"alert"}),!ne&&!E&&Q.length===0&&e.jsx(je,{title:r("preview.files.emptyTitle"),subtitle:r("preview.files.emptyHint")}),!ne&&!E&&Q.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(lt,{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:O,onChange:o=>K(o.target.value),onKeyDown:dr,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))]"}),R&&e.jsx(Re,{className:"h-3 w-3 shrink-0 animate-spin text-[hsl(var(--deck-accent))]"})]})}),e.jsx("div",{role:O?"listbox":void 0,"aria-label":O?r("preview.files.searchResultsAria"):void 0,className:"overflow-y-auto flex-1 p-2 min-h-0",children:O?be?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:()=>Je(o=>o+1),className:"mt-1 underline underline-offset-2",children:r("preview.action.retry")})]}):ae.length>0?ae.map((o,p)=>e.jsxs("button",{type:"button",role:"option","aria-selected":p===H,"data-preview-file-result":p,onMouseEnter:()=>oe(p),onClick:()=>void Be(o),className:U("mb-0.5 flex w-full min-w-0 flex-col rounded-md px-2 py-1.5 text-left font-mono transition-colors",p===H?"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:Xt(o)}),e.jsx("span",{className:"truncate text-[9px] text-[hsl(var(--deck-ink-faint))]",children:o})]},o)):!R&&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(ls,{nodes:Q,expandedDirs:Pe,childrenCache:me,directoryStates:xe,selectedPath:J,onToggleDir:ur,onRetryDir:fr,onSelectFile:Be})})]}),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:J||r("preview.files.selectTitle")}),J&&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":We?"preview.files.status.truncated":"preview.files.status.ready")})]}),We&&!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:[!J&&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")}),J&&De&&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:De}),e.jsx("button",{type:"button",onClick:()=>void Be(J),className:"underline underline-offset-2",children:r("preview.action.retry")})]}),J&&!De&&e.jsx("div",{className:"h-full",children:ke?e.jsx(_t,{}):e.jsx(i.Suspense,{fallback:e.jsx(_t,{}),children:e.jsx(ms,{content:Xe,filename:J})})})]})]})]})]})}),e.jsx(qe,{value:"logs",className:"overflow-hidden flex-1 mt-0",children:e.jsx(cs,{logs:ir})}),e.jsx(qe,{value:"browser",forceMount:!0,className:"overflow-hidden flex-1 min-h-0",children:e.jsx(rs,{sessionRef:d})})]})]})}function je({title:t,subtitle:n,actionLabel:r,onAction:s,role:l}){return e.jsxs("div",{role:l,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&&s&&e.jsx("button",{type:"button",onClick:s,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 hs(t){return t.flatMap(n=>{var l,a,b;const r=[];if((l=n.agentContent)!=null&&l.toolCalls)for(const c of n.agentContent.toolCalls){const w=Wt(c.arguments),m=c.output,g=m?(a=Le(m))!=null&&a.diff?zt(m):m:void 0;r.push({id:`${n.id}-${c.toolCallId}`,title:c.toolName||"Tool",subtitle:c.summary,status:c.status==="success"?"success":c.status==="error"?"error":"running",content:g||(w?`Arguments:
|
|
58
|
+
${w}`:void 0),timestamp:n.timestamp})}const s=n.metadata;if(s){if(s.kind==="tool_call"){const c=s.toolName||"Tool",w=Wt(s.arguments);r.push({id:n.id,title:`Tool Call · ${c}`,subtitle:s.toolKind?String(s.toolKind):void 0,status:s.status==="success"?"success":s.status==="error"?"error":"running",content:w?`Arguments:
|
|
59
|
+
${w}`:void 0,timestamp:n.timestamp})}if(s.kind==="tool_result"){const c=s.toolName||"Tool",w=s.success,m=s.summary,g=s.output,d=g?(b=Le(g))!=null&&b.diff?zt(g):g:void 0;r.push({id:n.id,title:`Tool Result · ${c}`,subtitle:m,status:w===void 0?"running":w?"success":"error",content:d,timestamp:n.timestamp})}}return r})}function ps(t){var s;const n=[],r=new Set;for(let l=t.length-1;l>=0;l-=1){const a=t[l];if((s=a.agentContent)!=null&&s.toolCalls)for(let g=a.agentContent.toolCalls.length-1;g>=0;g-=1){const d=a.agentContent.toolCalls[g],y=d.metadata;if((y==null?void 0:y.kind)==="patch"&&Array.isArray(y.changes)){$t(n,r,y.changes,d.summary);continue}const D=d.output||"",x=Le(D)||Le((y==null?void 0:y.diff_snippet)||"");if(x!=null&&x.diff){const j=(y==null?void 0:y.file_path)||d.toolName||"unknown";if(!r.has(j)){r.add(j);const k=typeof(y==null?void 0:y.oldContent)=="string"?y.oldContent:void 0,v=typeof(y==null?void 0:y.newContent)=="string"?y.newContent:void 0;n.push({diff:x.diff,filePath:j,summary:d.summary,oldContent:k,newContent:v})}}}const b=a.metadata;if(!b||b.kind!=="tool_result")continue;const c=b.metadata;if((c==null?void 0:c.kind)==="patch"&&Array.isArray(c.changes)){$t(n,r,c.changes,b.summary);continue}const w=b.output||(typeof a.content=="string"?a.content:"")||"",m=Le(w)||Le((c==null?void 0:c.diff_snippet)||"");if(m!=null&&m.diff){const g=(c==null?void 0:c.file_path)||b.toolName||"unknown";if(!r.has(g)){r.add(g);const d=typeof(c==null?void 0:c.oldContent)=="string"?c.oldContent:void 0,y=typeof(c==null?void 0:c.newContent)=="string"?c.newContent:void 0;n.push({diff:m.diff,filePath:g,summary:b.summary,oldContent:d,newContent:y})}}}return n.reverse()}function $t(t,n,r,s){for(let l=r.length-1;l>=0;l--){const a=r[l];!a||typeof a!="object"||!("path"in a)||typeof a.path!="string"||!("diff"in a)||typeof a.diff!="string"||n.has(a.path)||(n.add(a.path),t.push({diff:{patch:a.diff,startLine:1,matchLine:1},filePath:a.path,summary:s,oldContent:"oldContent"in a&&typeof a.oldContent=="string"?a.oldContent:void 0,newContent:"newContent"in a&&typeof a.newContent=="string"?a.newContent:void 0}))}}function Le(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 zt(t){return t?t.replace(/<<<DIFF>>>[\s\S]*?<<<\/DIFF>>>/m,"").trim():""}function Wt(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 _t(){const t=he();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 ms({content:t,filename:n}){const{codeTheme:r}=yr(),s=i.useRef(null),[l,a]=i.useState("vs-dark"),b=xs(n),c=w=>{s.current=w;const m=Ct(w,r);a(m)};return i.useEffect(()=>{if(s.current){const w=Ct(s.current,r);a(w)}},[r]),e.jsx(fs,{value:t,language:b,theme:l,height:"100%",beforeMount:c,options:{readOnly:!0,minimap:{enabled:!1},fontSize:12,lineNumbers:"on",wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0}},n)}function xs(t){var s;const n=((s=t.split(".").pop())==null?void 0:s.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{Es as FilePreview,Ss as PreviewControls};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e,r as p}from"./vendor-react-
|
|
1
|
+
import{j as e,r as p}from"./vendor-react-DofNRwfy.js";import{c as G,u as U,b as g,d as q,I as re,J as be,j as P,L as E,R as fe,K as ve,v as ge,M as je,N as Ne,O as ye,t as we,A as Se,D as Pe,e as Te,f as Ce,g as De,h as Ie,Q as se,i as Ae,U as ae,a as o,V as _e,Y as Ke,Z as Ee,$ as Me,a0 as Fe,W as Re,y as Le,a1 as Oe}from"./index-FdbcPJSj.js";import{l as Q}from"./session-events-Ci1823tS.js";import{C as ce}from"./calendar-clock-BeSXiMFw.js";import{C as qe}from"./clock-3-lYrt_Amt.js";import{P as ze}from"./play-BGPTTFWa.js";import{P as Be}from"./pause-qlDcCjBJ.js";import"./vendor-radix-Bc1_Q9tz.js";/**
|
|
2
2
|
* @license lucide-react v0.300.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -13,4 +13,4 @@ import{j as e,r as p}from"./vendor-react-DG5dkZ_t.js";import{c as G,u as U,d as
|
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const Ue=G("Tag",[["path",{d:"M12 2H2v10l9.29 9.29c.94.94 2.48.94 3.42 0l6.58-6.58c.94-.94.94-2.48 0-3.42L12 2Z",key:"14b2ls"}],["path",{d:"M7 7h.01",key:"7u93v4"}]]),Z=["waiting","active","blocked","review"],te={high:0,medium:1,low:2};function Ye(t){return t.taskIsolation!==void 0||t.taskPromptSummary!==void 0||t.taskRetryAvailable===!0}function ne(t){return t.taskSourceProjectPath||t.projectPath}function He(t){return t.pendingInteraction?"blocked":t.taskStatus==="queued"?"waiting":t.taskStatus==="running"?"active":t.taskStatus==="completed"?"review":"blocked"}function We(t,r){if(t.pendingInteraction!==r.pendingInteraction)return t.pendingInteraction?-1:1;const i=te[t.taskPriority??"medium"]-te[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 $e(t){const r={waiting:[],active:[],blocked:[],review:[]};for(const i of t)Ye(i)&&r[He(i)].push(i);for(const i of Z)r[i].sort(We);return r}function Ze(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(ye()==="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 ea({session:t,unread:r,cancelling:i,retrying:u,updating:n,onOpen:m,onInspect:T,onEdit:C,onCancel:y,onRetry:c,onArchive:h}){const l=U(),w=g(t),f=z(w),b=re(t,l),v=Ge[t.taskPriority??"medium"],k=t.taskKind??"feature",x=be(t,l),D=t.taskSourceProjectPath||t.projectPath,I=D.split("/").filter(Boolean).at(-1)||D,M=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:Ze(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}),x&&e.jsx("p",{title:x,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:x}),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[k])}),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(ce,{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(Qe,{className:"h-3.5 w-3.5"})}),S&&e.jsx(K,{label:l("kanban.action.inspect"),onClick:T,tone:"accent",children:e.jsx(Ve,{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(fe,{className:"h-3.5 w-3.5"})}),M&&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(ve,{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(ge,{className:"h-3.5 w-3.5"})}),S&&e.jsx(K,{label:l("kanban.action.archive"),onClick:h,children:e.jsx(je,{className:"h-3.5 w-3.5"})}),e.jsx(K,{label:l("kanban.action.open"),onClick:m,children:e.jsx(Ne,{className:"h-3.5 w-3.5"})})]})]})}const aa={waiting:{title:"kanban.column.waiting",description:"kanban.column.waitingDescription",icon:ze,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:Se,accent:"bg-red-500",iconStyle:"text-red-700 dark:text-red-400"},review:{title:"kanban.column.review",description:"kanban.column.reviewDescription",icon:we,accent:"bg-[hsl(var(--deck-accent))]",iconStyle:"text-[hsl(var(--deck-accent))]"}};function ta({id:t,sessions:r,unreadTaskKeys:i,cancellingTaskKeys:u,retryingTaskKeys:n,updatingTaskKeys:m,taskKey:T,onOpen:C,onInspect:y,onEdit:c,onCancel:h,onRetry:l,onArchive:w}){const f=U(),b=aa[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(k=>{const x=T(k);return e.jsx(ea,{session:k,unread:i.includes(x),cancelling:u.includes(x),retrying:n.includes(x),updating:m.includes(x),onOpen:()=>C(k),onInspect:()=>y(k),onEdit:()=>c(k),onCancel:()=>h(k),onRetry:()=>l(k),onArchive:()=>w(k)},x)}),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 na(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 ra({open:t,onOpenChange:r,projects:i,defaultProjectPath:u,session:n,submitting:m,canCreate:T,onCreate:C,onUpdate:y}){const c=U(),h=!!n,[l,w]=p.useState(""),[f,b]=p.useState(""),[v,k]=p.useState(u??""),[x,D]=p.useState("medium"),[I,M]=p.useState("feature"),[N,A]=p.useState(""),[S,F]=p.useState(null);p.useEffect(()=>{var s;t&&(w((n==null?void 0:n.title)??""),b((n==null?void 0:n.taskPromptSummary)??""),k((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"),M((n==null?void 0:n.taskKind)??"feature"),A(na(n==null?void 0:n.taskDueAt)),F(null))},[u,t,i,n]);const q=async s=>{s.preventDefault();const j=l.trim(),B=f.trim();if(!(!h&&(!B||!v))){F(null);try{h?await y({...j?{title:j}:{},taskPriority:x,taskKind:I,taskDueAt:N?new Date(N).toISOString():null}):await C({...j?{title:j}:{},prompt:B,projectPath:v,taskPriority:x,taskKind:I,...N?{taskDueAt:new Date(N).toISOString()}:{}}),r(!1)}catch(R){F(R instanceof Error?R.message:c("kanban.dialog.submitFailed"))}}};return e.jsx(Pe,{open:t,onOpenChange:r,children:e.jsxs(Te,{className:"max-w-[560px] gap-0 overflow-hidden border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] p-0",children:[e.jsxs(Ce,{className:"border-b border-[hsl(var(--deck-hairline))] px-5 py-4",children:[e.jsx(De,{className:"font-mono text-[15px] text-[hsl(var(--deck-ink))]",children:c(h?"kanban.dialog.editTitle":"kanban.dialog.createTitle")}),e.jsx(Ie,{className:"text-[11.5px] text-[hsl(var(--deck-ink-faint))]",children:c(h?"kanban.dialog.editDescription":"kanban.dialog.createDescription")})]}),e.jsxs("form",{onSubmit:q,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")})]}),!h&&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")})]}),!h&&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=>k(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(Ue,{className:"h-3 w-3"}),c("kanban.field.kind")]}),e.jsxs("select",{value:I,onChange:s=>M(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:x,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(ce,{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"})]})]}),!h&&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(Ae,{className:"border-t border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface-2))]/60 px-5 py-3",children:[e.jsx(ae,{type:"button",variant:"ghost",onClick:()=>r(!1),disabled:m,children:c("kanban.dialog.cancel")}),e.jsxs(ae,{type:"submit",disabled:m||!h&&(!T||!f.trim()||!v),className:"gap-2",children:[m&&e.jsx(E,{className:"h-3.5 w-3.5 animate-spin"}),c(h?"kanban.dialog.save":"kanban.dialog.dispatch")]})]})]})]})})}function ha(){var ee;const t=U(),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),h=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),k=o(a=>a.dispatchTask),x=o(a=>a.updateTask),D=o(a=>a.cancelTask),I=o(a=>a.retryTask),M=o(a=>a.archiveSession),N=o(a=>a.setTaskAdmissionPaused),A=o(a=>a.reconnectTaskEvents),S=o(a=>a.clearError),F=_e(a=>a.currentMode),q=Q(a=>a.setMainView),s=Q(a=>a.boardProjectPath),j=Q(a=>a.setBoardProjectPath),B=Q(a=>a.openFilePreview),[R,ie]=p.useState(""),[le,Y]=p.useState(!1),[oe,H]=p.useState(null),[de,W]=p.useState(!1);p.useEffect(()=>{s&&!i.some(a=>a.path===s&&a.available)&&j(null)},[s,i,j]);const L=r.find(a=>z(g(a))===oe)??null,$=R.trim().toLowerCase(),J=p.useMemo(()=>r.filter(a=>s&&ne(a)!==s?!1:$?[a.sessionId,re(a,t),a.taskPromptSummary,ne(a),a.taskPriority,a.taskKind].filter(Boolean).join(" ").toLowerCase().includes($):!0),[s,$,r,t]),X=p.useMemo(()=>$e(J),[J]),ue=Z.reduce((a,d)=>a+X[d].length,0),_=n==null?void 0:n.taskAdmission,O=_?!_.paused:!0,V=i.filter(a=>a.available),me=s??u??((ee=V[0])==null?void 0:ee.path)??null,he=L?l.includes(z(g(L))):C,ke=async a=>{q("workspace"),await v(g(a))},xe=async a=>{q("workspace"),await v(g(a)),B({tab:"diff"})},pe=async a=>{b(a.projectPath),await k({...a,isolation:"local",permissionMode:F},{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:ue})})]}),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(Ke,{inFlight:_.inFlight,queued:_.queued,maxConcurrent:_.maxConcurrent,compact:!0})}),e.jsxs("button",{type:"button",role:"switch","aria-checked":O,disabled:!_||y,onClick:()=>{N(O).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",O?"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"}):O?e.jsx(qe,{className:"h-3 w-3 fill-current"}):e.jsx(Be,{className:"h-3 w-3"}),t(O?"kanban.autoClaim.running":"kanban.autoClaim.paused")]}),e.jsxs("button",{type:"button",onClick:()=>{if(V.length===0){W(!0);return}H(null),Y(!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(Ee,{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(Me,{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:R,onChange:a=>ie(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")}),V.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(Fe,{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(Re,{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(Le,{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:Z.map(a=>e.jsx(ta,{id:a,sessions:X[a],unreadTaskKeys:w,cancellingTaskKeys:c,retryingTaskKeys:h,updatingTaskKeys:l,taskKey:d=>z(g(d)),onOpen:d=>{ke(d).catch(()=>{})},onInspect:d=>{xe(d).catch(()=>{})},onEdit:d=>{H(z(g(d))),Y(!0)},onCancel:d=>{D(g(d)).catch(()=>{})},onRetry:d=>{I(g(d)).catch(()=>{})},onArchive:d=>{M(g(d))}},a))})}),e.jsx(ra,{open:le,onOpenChange:a=>{Y(a),a||H(null)},projects:i,defaultProjectPath:me,session:L,submitting:he,canCreate:V.length>0,onCreate:pe,onUpdate:async a=>{L&&await x(g(L),a)}}),e.jsx(Oe,{open:de,onOpenChange:W})]})}export{ha as KanbanBoard};
|
|
16
|
+
*/const Ue=G("Tag",[["path",{d:"M12 2H2v10l9.29 9.29c.94.94 2.48.94 3.42 0l6.58-6.58c.94-.94.94-2.48 0-3.42L12 2Z",key:"14b2ls"}],["path",{d:"M7 7h.01",key:"7u93v4"}]]),Z=["waiting","active","blocked","review"],te={high:0,medium:1,low:2};function Ye(t){return t.taskIsolation!==void 0||t.taskPromptSummary!==void 0||t.taskRetryAvailable===!0}function ne(t){return t.taskSourceProjectPath||t.projectPath}function He(t){return t.pendingInteraction?"blocked":t.taskStatus==="queued"?"waiting":t.taskStatus==="running"?"active":t.taskStatus==="completed"?"review":"blocked"}function We(t,r){if(t.pendingInteraction!==r.pendingInteraction)return t.pendingInteraction?-1:1;const i=te[t.taskPriority??"medium"]-te[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 $e(t){const r={waiting:[],active:[],blocked:[],review:[]};for(const i of t)Ye(i)&&r[He(i)].push(i);for(const i of Z)r[i].sort(We);return r}function Ze(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(ye()==="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 ea({session:t,unread:r,cancelling:i,retrying:u,updating:n,onOpen:m,onInspect:T,onEdit:C,onCancel:y,onRetry:c,onArchive:h}){const l=U(),w=g(t),f=q(w),b=re(t,l),v=Ge[t.taskPriority??"medium"],k=t.taskKind??"feature",x=be(t,l),D=t.taskSourceProjectPath||t.projectPath,I=D.split("/").filter(Boolean).at(-1)||D,M=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:Ze(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}),x&&e.jsx("p",{title:x,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:x}),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[k])}),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(ce,{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(Qe,{className:"h-3.5 w-3.5"})}),S&&e.jsx(K,{label:l("kanban.action.inspect"),onClick:T,tone:"accent",children:e.jsx(Ve,{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(fe,{className:"h-3.5 w-3.5"})}),M&&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(ve,{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(ge,{className:"h-3.5 w-3.5"})}),S&&e.jsx(K,{label:l("kanban.action.archive"),onClick:h,children:e.jsx(je,{className:"h-3.5 w-3.5"})}),e.jsx(K,{label:l("kanban.action.open"),onClick:m,children:e.jsx(Ne,{className:"h-3.5 w-3.5"})})]})]})}const aa={waiting:{title:"kanban.column.waiting",description:"kanban.column.waitingDescription",icon:qe,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:Se,accent:"bg-red-500",iconStyle:"text-red-700 dark:text-red-400"},review:{title:"kanban.column.review",description:"kanban.column.reviewDescription",icon:we,accent:"bg-[hsl(var(--deck-accent))]",iconStyle:"text-[hsl(var(--deck-accent))]"}};function ta({id:t,sessions:r,unreadTaskKeys:i,cancellingTaskKeys:u,retryingTaskKeys:n,updatingTaskKeys:m,taskKey:T,onOpen:C,onInspect:y,onEdit:c,onCancel:h,onRetry:l,onArchive:w}){const f=U(),b=aa[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(k=>{const x=T(k);return e.jsx(ea,{session:k,unread:i.includes(x),cancelling:u.includes(x),retrying:n.includes(x),updating:m.includes(x),onOpen:()=>C(k),onInspect:()=>y(k),onEdit:()=>c(k),onCancel:()=>h(k),onRetry:()=>l(k),onArchive:()=>w(k)},x)}),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 na(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 ra({open:t,onOpenChange:r,projects:i,defaultProjectPath:u,session:n,submitting:m,canCreate:T,onCreate:C,onUpdate:y}){const c=U(),h=!!n,[l,w]=p.useState(""),[f,b]=p.useState(""),[v,k]=p.useState(u??""),[x,D]=p.useState("medium"),[I,M]=p.useState("feature"),[N,A]=p.useState(""),[S,F]=p.useState(null);p.useEffect(()=>{var s;t&&(w((n==null?void 0:n.title)??""),b((n==null?void 0:n.taskPromptSummary)??""),k((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"),M((n==null?void 0:n.taskKind)??"feature"),A(na(n==null?void 0:n.taskDueAt)),F(null))},[u,t,i,n]);const z=async s=>{s.preventDefault();const j=l.trim(),B=f.trim();if(!(!h&&(!B||!v))){F(null);try{h?await y({...j?{title:j}:{},taskPriority:x,taskKind:I,taskDueAt:N?new Date(N).toISOString():null}):await C({...j?{title:j}:{},prompt:B,projectPath:v,taskPriority:x,taskKind:I,...N?{taskDueAt:new Date(N).toISOString()}:{}}),r(!1)}catch(R){F(R instanceof Error?R.message:c("kanban.dialog.submitFailed"))}}};return e.jsx(Pe,{open:t,onOpenChange:r,children:e.jsxs(Te,{className:"max-w-[560px] gap-0 overflow-hidden border-[hsl(var(--deck-border))] bg-[hsl(var(--deck-surface))] p-0",children:[e.jsxs(Ce,{className:"border-b border-[hsl(var(--deck-hairline))] px-5 py-4",children:[e.jsx(De,{className:"font-mono text-[15px] text-[hsl(var(--deck-ink))]",children:c(h?"kanban.dialog.editTitle":"kanban.dialog.createTitle")}),e.jsx(Ie,{className:"text-[11.5px] text-[hsl(var(--deck-ink-faint))]",children:c(h?"kanban.dialog.editDescription":"kanban.dialog.createDescription")})]}),e.jsxs("form",{onSubmit:z,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")})]}),!h&&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")})]}),!h&&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=>k(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(Ue,{className:"h-3 w-3"}),c("kanban.field.kind")]}),e.jsxs("select",{value:I,onChange:s=>M(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:x,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(ce,{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"})]})]}),!h&&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(Ae,{className:"border-t border-[hsl(var(--deck-hairline))] bg-[hsl(var(--deck-surface-2))]/60 px-5 py-3",children:[e.jsx(ae,{type:"button",variant:"ghost",onClick:()=>r(!1),disabled:m,children:c("kanban.dialog.cancel")}),e.jsxs(ae,{type:"submit",disabled:m||!h&&(!T||!f.trim()||!v),className:"gap-2",children:[m&&e.jsx(E,{className:"h-3.5 w-3.5 animate-spin"}),c(h?"kanban.dialog.save":"kanban.dialog.dispatch")]})]})]})]})})}function ha(){var ee;const t=U(),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),h=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),k=o(a=>a.dispatchTask),x=o(a=>a.updateTask),D=o(a=>a.cancelTask),I=o(a=>a.retryTask),M=o(a=>a.archiveSession),N=o(a=>a.setTaskAdmissionPaused),A=o(a=>a.reconnectTaskEvents),S=o(a=>a.clearError),F=_e(a=>a.currentMode),z=Q(a=>a.setMainView),s=Q(a=>a.boardProjectPath),j=Q(a=>a.setBoardProjectPath),B=Q(a=>a.openFilePreview),[R,ie]=p.useState(""),[le,Y]=p.useState(!1),[oe,H]=p.useState(null),[de,W]=p.useState(!1);p.useEffect(()=>{s&&!i.some(a=>a.path===s&&a.available)&&j(null)},[s,i,j]);const L=r.find(a=>q(g(a))===oe)??null,$=R.trim().toLowerCase(),J=p.useMemo(()=>r.filter(a=>s&&ne(a)!==s?!1:$?[a.sessionId,re(a,t),a.taskPromptSummary,ne(a),a.taskPriority,a.taskKind].filter(Boolean).join(" ").toLowerCase().includes($):!0),[s,$,r,t]),X=p.useMemo(()=>$e(J),[J]),ue=Z.reduce((a,d)=>a+X[d].length,0),_=n==null?void 0:n.taskAdmission,O=_?!_.paused:!0,V=i.filter(a=>a.available),me=s??u??((ee=V[0])==null?void 0:ee.path)??null,he=L?l.includes(q(g(L))):C,ke=async a=>{z("workspace"),await v(g(a))},xe=async a=>{z("workspace"),await v(g(a)),B({tab:"diff"})},pe=async a=>{b(a.projectPath),await k({...a,isolation:"local",permissionMode:F},{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:ue})})]}),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(Ke,{inFlight:_.inFlight,queued:_.queued,maxConcurrent:_.maxConcurrent,compact:!0})}),e.jsxs("button",{type:"button",role:"switch","aria-checked":O,disabled:!_||y,onClick:()=>{N(O).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",O?"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"}):O?e.jsx(ze,{className:"h-3 w-3 fill-current"}):e.jsx(Be,{className:"h-3 w-3"}),t(O?"kanban.autoClaim.running":"kanban.autoClaim.paused")]}),e.jsxs("button",{type:"button",onClick:()=>{if(V.length===0){W(!0);return}H(null),Y(!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(Ee,{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(Me,{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:R,onChange:a=>ie(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")}),V.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(Fe,{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(Re,{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(Le,{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:Z.map(a=>e.jsx(ta,{id:a,sessions:X[a],unreadTaskKeys:w,cancellingTaskKeys:c,retryingTaskKeys:h,updatingTaskKeys:l,taskKey:d=>q(g(d)),onOpen:d=>{ke(d).catch(()=>{})},onInspect:d=>{xe(d).catch(()=>{})},onEdit:d=>{H(q(g(d))),Y(!0)},onCancel:d=>{D(g(d)).catch(()=>{})},onRetry:d=>{I(g(d)).catch(()=>{})},onArchive:d=>{M(g(d))}},a))})}),e.jsx(ra,{open:le,onOpenChange:a=>{Y(a),a||H(null)},projects:i,defaultProjectPath:me,session:L,submitting:he,canCreate:V.length>0,onCreate:pe,onUpdate:async a=>{L&&await x(g(L),a)}}),e.jsx(Oe,{open:de,onOpenChange:W})]})}export{ha as KanbanBoard};
|