meshy-node 0.9.10 → 0.10.2
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/README.md +1 -1
- package/dashboard/assets/DashboardPage-BaHExl1O.css +1 -0
- package/dashboard/assets/DashboardPage-t7hNJ6ER.js +166 -0
- package/dashboard/assets/DashboardShared-DKoU9m12.js +79 -0
- package/dashboard/assets/DiffTab-CHGam55q.js +23 -0
- package/dashboard/assets/FilesTab-CHjCfHQI.js +11 -0
- package/dashboard/assets/MarkdownPreviewFrame-CizfMkZT.js +13 -0
- package/dashboard/assets/PreviewTab-B8thlxN1.js +21 -0
- package/dashboard/assets/SharedConversationPage-fseaPX1s.js +2 -0
- package/dashboard/assets/{file-BO3_w-is.js → file-RHsnzvWQ.js} +1 -1
- package/dashboard/assets/index-CeG71j20.css +1 -0
- package/dashboard/assets/index-DxmS1OIF.js +346 -0
- package/dashboard/index.html +2 -2
- package/main.cjs +33763 -9439
- package/package.json +2 -2
- package/runtime-metadata.json +5 -5
- package/dashboard/assets/DashboardPage-DL4PakzK.js +0 -154
- package/dashboard/assets/DashboardPage-i714dDoR.css +0 -1
- package/dashboard/assets/DashboardShared-DfyXgvZj.js +0 -79
- package/dashboard/assets/DiffTab-3q3jwsm4.js +0 -23
- package/dashboard/assets/FilesTab-jB5PuAMB.js +0 -11
- package/dashboard/assets/MarkdownPreviewFrame-B1baNbJd.js +0 -12
- package/dashboard/assets/PreviewTab-5-N4l7V3.js +0 -21
- package/dashboard/assets/SharedConversationPage-D8TaynWN.js +0 -2
- package/dashboard/assets/index-C8zHV8VY.js +0 -341
- package/dashboard/assets/index-Dsqqe-oH.css +0 -1
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-CHjCfHQI.js","assets/index-DxmS1OIF.js","assets/index-CeG71j20.css","assets/MarkdownPreviewFrame-CizfMkZT.js","assets/DashboardShared-DKoU9m12.js","assets/file-RHsnzvWQ.js","assets/PreviewTab-B8thlxN1.js","assets/DiffTab-CHGam55q.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as pe,r as o,a as ys,f as Ta,m as Ea,j as e,X as nt,Q as jn,B as ee,L as me,S as Aa,b as gi,d as O,e as bi,g as vi,h as wi,I as st,P as yi,C as os,i as ji,k as Da,F as Ni,l as Bt,n as Ke,o as xe,D as is,p as ki,q as Si,t as de,s as Ne,u as ke,v as Pe,w as Se,x as _a,y as Qe,T as Ci,z as Ti,A as sr,E as Ei,G as yt,H as jt,J as Ot,K as Ma,M as Pa,N as Ft,O as Ln,R as Ai,U as vt,V as Nn,W as Di,Y as Bn,Z as Ia,_ as _i,$ as Ue,a0 as Mi,a1 as lt,a2 as Jt,a3 as Zt,a4 as Xt,a5 as es,a6 as ts,a7 as ss,a8 as ns,a9 as rs,aa as On,ab as Pi,ac as Ts,ad as Ra,ae as Ii,af as nr,ag as rr,ah as $s,ai as Ri,aj as Li,ak as Bi,al as Oi,am as Fi,an as Es,ao as zi,ap as Ui,aq as As,ar as $i,as as La,at as qi,au as Vi,av as Hi,aw as Ba,ax as Fn,ay as Oa,az as Ki,aA as js,aB as Gi,aC as ar,aD as Wi,aE as zn,aF as Qi,aG as Yi,aH as Ji,aI as Fa,aJ as ls,aK as Zi,aL as kn,aM as za,aN as Xi,aO as el,aP as tl,aQ as sl,aR as or,aS as nl,aT as rl,aU as qs,aV as al,aW as ir,aX as ol,aY as il,aZ as ll,a_ as lr,a$ as dl,b0 as cl,b1 as Sn,b2 as ul,b3 as ml,b4 as Ua,b5 as dr,b6 as $a,b7 as hl,b8 as fl,b9 as xl,ba as pl,bb as gl,bc as bl,bd as vl,be as wl,bf as yl,bg as jl,bh as Nl,bi as kl,bj as Sl,bk as Cl,bl as Tl,bm as El,bn as Al,bo as Dl,bp as _l,bq as Ml,br as Pl,bs as Il,bt as Rl,bu as Ll,bv as Bl,bw as Ol,bx as Fl,by as zl,bz as Ul,bA as $l,bB as ql,bC as Vl,bD as Hl}from"./index-DxmS1OIF.js";import{r as cr,e as Kl,b as qa,I as Va,A as Un,g as Ha,a as Gl,c as Wl,t as Ql,d as ur,f as mr,h as Yl,i as Jl,C as hr,T as Vs,D as _t,j as We,M as Cn,L as Zl,m as Ka,k as Tn,l as Xl,n as fr,o as ed,p as td,q as Hs,s as sd,u as nd,v as rd}from"./DashboardShared-DKoU9m12.js";import{E as ad,M as od}from"./MarkdownPreviewFrame-CizfMkZT.js";import{P as Ds,D as xs,g as id,a as ld,b as dd}from"./PreviewTab-B8thlxN1.js";/**
|
|
3
|
+
* @license lucide-react v1.7.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 cd=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],ud=pe("archive",cd);/**
|
|
8
|
+
* @license lucide-react v1.7.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 md=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],xr=pe("arrow-right",md);/**
|
|
13
|
+
* @license lucide-react v1.7.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 hd=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Ga=pe("arrow-up",hd);/**
|
|
18
|
+
* @license lucide-react v1.7.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 fd=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],ds=pe("chevron-left",fd);/**
|
|
23
|
+
* @license lucide-react v1.7.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 xd=[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],pd=pe("earth",xd);/**
|
|
28
|
+
* @license lucide-react v1.7.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 gd=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],bd=pe("ellipsis-vertical",gd);/**
|
|
33
|
+
* @license lucide-react v1.7.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 vd=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],wd=pe("ellipsis",vd);/**
|
|
38
|
+
* @license lucide-react v1.7.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 yd=[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]],jd=pe("flag",yd);/**
|
|
43
|
+
* @license lucide-react v1.7.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 Nd=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],_s=pe("folder-open",Nd);/**
|
|
48
|
+
* @license lucide-react v1.7.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 kd=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],Sd=pe("funnel",kd);/**
|
|
53
|
+
* @license lucide-react v1.7.0 - ISC
|
|
54
|
+
*
|
|
55
|
+
* This source code is licensed under the ISC license.
|
|
56
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
57
|
+
*/const Cd=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],Ns=pe("git-branch",Cd);/**
|
|
58
|
+
* @license lucide-react v1.7.0 - ISC
|
|
59
|
+
*
|
|
60
|
+
* This source code is licensed under the ISC license.
|
|
61
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
62
|
+
*/const Td=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],Ed=pe("globe",Td);/**
|
|
63
|
+
* @license lucide-react v1.7.0 - ISC
|
|
64
|
+
*
|
|
65
|
+
* This source code is licensed under the ISC license.
|
|
66
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
67
|
+
*/const Ad=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],ks=pe("history",Ad);/**
|
|
68
|
+
* @license lucide-react v1.7.0 - ISC
|
|
69
|
+
*
|
|
70
|
+
* This source code is licensed under the ISC license.
|
|
71
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
72
|
+
*/const Dd=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],En=pe("image-plus",Dd);/**
|
|
73
|
+
* @license lucide-react v1.7.0 - ISC
|
|
74
|
+
*
|
|
75
|
+
* This source code is licensed under the ISC license.
|
|
76
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
77
|
+
*/const _d=[["path",{d:"M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z",key:"1pdavp"}],["path",{d:"M20.054 15.987H3.946",key:"14rxg9"}]],Md=pe("laptop",_d);/**
|
|
78
|
+
* @license lucide-react v1.7.0 - ISC
|
|
79
|
+
*
|
|
80
|
+
* This source code is licensed under the ISC license.
|
|
81
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
82
|
+
*/const Pd=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],$n=pe("link-2",Pd);/**
|
|
83
|
+
* @license lucide-react v1.7.0 - ISC
|
|
84
|
+
*
|
|
85
|
+
* This source code is licensed under the ISC license.
|
|
86
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
87
|
+
*/const Id=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],Rd=pe("list-ordered",Id);/**
|
|
88
|
+
* @license lucide-react v1.7.0 - ISC
|
|
89
|
+
*
|
|
90
|
+
* This source code is licensed under the ISC license.
|
|
91
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
92
|
+
*/const Ld=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]],Ms=pe("message-square-plus",Ld);/**
|
|
93
|
+
* @license lucide-react v1.7.0 - ISC
|
|
94
|
+
*
|
|
95
|
+
* This source code is licensed under the ISC license.
|
|
96
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
97
|
+
*/const Bd=[["path",{d:"M15.033 9.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56V7.648a.645.645 0 0 1 .967-.56z",key:"vbtd3f"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",key:"x3v2xh"}]],Wa=pe("monitor-play",Bd);/**
|
|
98
|
+
* @license lucide-react v1.7.0 - ISC
|
|
99
|
+
*
|
|
100
|
+
* This source code is licensed under the ISC license.
|
|
101
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
102
|
+
*/const Od=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],zt=pe("pencil",Od);/**
|
|
103
|
+
* @license lucide-react v1.7.0 - ISC
|
|
104
|
+
*
|
|
105
|
+
* This source code is licensed under the ISC license.
|
|
106
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
107
|
+
*/const Fd=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],zd=pe("qr-code",Fd);/**
|
|
108
|
+
* @license lucide-react v1.7.0 - ISC
|
|
109
|
+
*
|
|
110
|
+
* This source code is licensed under the ISC license.
|
|
111
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
112
|
+
*/const Ud=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],$d=pe("rotate-ccw",Ud);/**
|
|
113
|
+
* @license lucide-react v1.7.0 - ISC
|
|
114
|
+
*
|
|
115
|
+
* This source code is licensed under the ISC license.
|
|
116
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
117
|
+
*/const qd=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Qa=pe("rotate-cw",qd);/**
|
|
118
|
+
* @license lucide-react v1.7.0 - ISC
|
|
119
|
+
*
|
|
120
|
+
* This source code is licensed under the ISC license.
|
|
121
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
122
|
+
*/const Vd=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Ya=pe("send",Vd);/**
|
|
123
|
+
* @license lucide-react v1.7.0 - ISC
|
|
124
|
+
*
|
|
125
|
+
* This source code is licensed under the ISC license.
|
|
126
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
127
|
+
*/const Hd=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],Ss=pe("share-2",Hd);/**
|
|
128
|
+
* @license lucide-react v1.7.0 - ISC
|
|
129
|
+
*
|
|
130
|
+
* This source code is licensed under the ISC license.
|
|
131
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
132
|
+
*/const Kd=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],Gd=pe("sliders-horizontal",Kd);/**
|
|
133
|
+
* @license lucide-react v1.7.0 - ISC
|
|
134
|
+
*
|
|
135
|
+
* This source code is licensed under the ISC license.
|
|
136
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
137
|
+
*/const Wd=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],pr=pe("square",Wd);/**
|
|
138
|
+
* @license lucide-react v1.7.0 - ISC
|
|
139
|
+
*
|
|
140
|
+
* This source code is licensed under the ISC license.
|
|
141
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
142
|
+
*/const Qd=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],Yd=pe("user-plus",Qd);/**
|
|
143
|
+
* @license lucide-react v1.7.0 - ISC
|
|
144
|
+
*
|
|
145
|
+
* This source code is licensed under the ISC license.
|
|
146
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
147
|
+
*/const Jd=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],Zd=pe("wifi",Jd);/**
|
|
148
|
+
* @license lucide-react v1.7.0 - ISC
|
|
149
|
+
*
|
|
150
|
+
* This source code is licensed under the ISC license.
|
|
151
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
152
|
+
*/const Xd=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],ec=pe("zoom-in",Xd);/**
|
|
153
|
+
* @license lucide-react v1.7.0 - ISC
|
|
154
|
+
*
|
|
155
|
+
* This source code is licensed under the ISC license.
|
|
156
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
157
|
+
*/const tc=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],sc=pe("zoom-out",tc),nc=new Set(["assigned","running"]);function rc(t,s){return t.reduce((n,r)=>r.assignedTo===s&&nc.has(r.status)?n+1:n,0)}function Ut(t){return t?.toLowerCase()==="devtunnel"}function ac(t){return t?Ut(t)?"DevTunnel":t.charAt(0).toUpperCase()+t.slice(1):"Direct"}function qn(t,s){return Ut(s??t.transportType)||!!t.devtunnelEndpoint}function Ja(t,s){return!Ut(s??t.transportType)}function Za(t,s){const n=s??t.transportType;return Ut(n)?"DevTunnel":t.devtunnelEndpoint?"Direct + DevTunnel":ac(n)}function gr(t,s){return!t&&!s}function oc({routeTaskId:t,creatingTask:s,internalSelectedTaskId:n,sortedTaskIds:r}){return t||(s?null:r[0]??n??null)}function ic({activeTaskId:t,routeTaskId:s,creatingTask:n,tasksLoading:r,loadedTaskIds:a}){return!t||s||n||r?!1:!a.includes(t)}function lc(t,s){return[s,...t.filter(n=>n.id!==s.id)]}function Xa(t,s){const n=t.findIndex(r=>r.id===s.id);return n===-1?[...t,s]:t.map((r,a)=>a===n?s:r)}const dc=new Set(["completed","failed","cancelled","archived"]);function cc(t,s){const n=new Set(s);return new Set(Array.from(t).filter(r=>n.has(r)))}function uc(t,s){const n=new Set(s);if(n.size===0)return!1;const r=t.filter(a=>n.has(a.id));return r.length===n.size&&r.every(a=>dc.has(a.status))}function mc(t,s){const n=new Set(s);return t.find(r=>!n.has(r.id))?.id??null}function eo(){const[t,s]=o.useState([]),[n,r]=o.useState(null),a=o.useRef(null),i=o.useCallback(()=>{a.current?.click()},[]),l=o.useCallback(async g=>{const f=Array.from(g.target.files??[]);if(f.length!==0)try{const u=await cr(f);s(p=>[...p,...u]),r(null)}catch(u){r(u instanceof Error?u.message:"Failed to attach image")}finally{g.target.value=""}},[]),d=o.useCallback(async g=>{const f=Kl(g.clipboardData);if(f.length!==0){g.preventDefault();try{const u=await cr(f);s(p=>[...p,...u]),r(null)}catch(u){r(u instanceof Error?u.message:"Failed to attach image")}}},[]),c=o.useCallback(g=>{s(f=>f.filter((u,p)=>p!==g))},[]),m=o.useCallback(()=>{s([]),r(null)},[]);return{images:t,error:n,fileInputRef:a,pickImages:i,handleFileChange:l,handlePaste:d,removeImage:c,clearImages:m}}function hc(t){const s=t.map(a=>({...a,displayValue:fc(a)})),n=s.findIndex(a=>a.label.toLowerCase()==="working dir"),r=n>=0?n:0;return{primary:s[r],secondary:s.filter((a,i)=>i!==r)}}function fc(t){return t.label.toLowerCase()==="agent"?Ha(t.value):t.value}function br(t){switch(t.toLowerCase()){case"branch":return Ns;case"node":return Aa;default:return _s}}function xc({disabled:t=!1,running:s=!1,canStop:n=!1,hasContent:r=!1}){return s&&!r?{primaryAction:"stop",primaryDisabled:t||!n}:{primaryAction:"send",primaryDisabled:t||!r}}function pc({contentLength:t,disabled:s=!1}){return t>0&&!s}function gc({onSend:t,disabled:s,disabledReason:n="Chat is waiting on the agent.",placeholder:r="Send a follow-up message...",contextItems:a=[],running:i=!1,onStop:l,quickChats:d=[]}){const[c,m]=o.useState(""),[g,f]=o.useState(0),[u,p]=o.useState(0),N=o.useRef(null),{images:y,error:D,fileInputRef:h,pickImages:E,handleFileChange:x,handlePaste:b,removeImage:S,clearImages:T}=eo(),C=o.useCallback(()=>{N.current&&(N.current.style.height="auto")},[]),I=o.useCallback(()=>{N.current&&(N.current.style.height="auto",N.current.style.height=`${Math.min(N.current.scrollHeight,220)}px`)},[]);o.useEffect(()=>{f(0)},[c,d]);const k=o.useCallback(F=>{m(F.prompt);const X=()=>{N.current?.focus(),I()};typeof requestAnimationFrame=="function"?requestAnimationFrame(X):X()},[I]),P=o.useCallback(()=>{const F=ys(c,d,g);if(F){k(F);return}const X=qa(c,y);pc({contentLength:X.length,disabled:s})&&(p($=>$+1),t(X),m(""),T(),C())},[c,y,s,t,T,C,d,g,k]),M=o.useCallback(F=>{const X=Ta(c,d);if(X.length>0&&(F.key==="ArrowDown"||F.key==="ArrowUp")){F.preventDefault(),f($=>Ea($,X.length,F.key==="ArrowDown"?1:-1));return}if(F.key==="Enter"&&!F.shiftKey){F.preventDefault();const $=ys(c,d,g);$?k($):P()}},[k,P,d,g,c]),A=c.trim().length>0||y.length>0,R=xc({disabled:s,running:i,canStop:i&&!!l,hasContent:A}),H=hc(a),Z=H.primary?br(H.primary.label):_s,te=i?A?"Enter queues this message for the next turn":l?"Task is running - type to queue, empty button stops task":"Task is running - type to queue a message":s?n:"Enter sends, Shift+Enter adds a line";return e.jsx("div",{"data-chat-input-shell":"true",className:"chat-input-shell animate-composer-settle w-full bg-background/35 px-2 pb-2 pt-0 sm:px-4 sm:pb-3",children:e.jsx("div",{"data-chat-input-column":"true",className:"mx-auto w-full max-w-[72rem]",children:e.jsxs("div",{"data-chat-input-card":"true",className:"chat-input-card overflow-hidden rounded-xl border border-border/65 bg-card/88 transition-[border-color,box-shadow] duration-200 focus-within:border-primary/50 focus-within:ring-2 focus-within:ring-primary/15 sm:rounded-xl",children:[e.jsx("input",{ref:h,type:"file",accept:"image/*",multiple:!0,onChange:x,className:"hidden"}),H.primary&&e.jsx("div",{"data-chat-input-primary-context":"true",className:"px-2.5 pt-1.5 sm:px-5 sm:pt-2",children:e.jsxs("div",{className:"-ml-1.5 inline-flex max-w-full items-center gap-1.5 rounded-sm bg-muted/45 px-1.5 py-0.5 shadow-[0_10px_28px_-18px_rgba(15,23,42,0.72)] sm:-ml-2 dark:shadow-[0_10px_28px_-18px_rgba(0,0,0,0.95)]",children:[e.jsx(Z,{className:"h-2.5 w-2.5 shrink-0 text-primary/45","aria-hidden":"true"}),e.jsx("span",{className:"truncate font-mono text-[9px] leading-3 text-muted-foreground/72",title:H.primary.value,children:H.primary.displayValue})]})}),y.length>0&&e.jsx("div",{className:"px-2 pt-2.5 sm:px-5 sm:pt-4",children:e.jsx("div",{className:"flex flex-wrap gap-3",children:y.map((F,X)=>e.jsxs("div",{className:"relative",children:[e.jsx(Va,{image:F,alt:F.filename??`attachment ${X+1}`,thumbnailClassName:"h-24 w-24 border border-border/70",imageClassName:"h-full w-full"}),e.jsx("button",{type:"button",onClick:()=>S(X),className:"absolute -right-1.5 -top-1.5 flex h-5 w-5 items-center justify-center rounded-sm border border-border/70 bg-background text-muted-foreground shadow-sm transition-all hover:-translate-y-px hover:text-foreground","aria-label":`Remove ${F.filename??`image ${X+1}`}`,children:e.jsx(nt,{className:"h-3 w-3"})})]},`${F.filename??"image"}-${X}`))})}),e.jsx("div",{className:"px-2 pb-0 pt-1 sm:px-5 sm:pt-1.5",children:e.jsx("textarea",{ref:N,"data-chat-input-textarea":"true",value:c,onChange:F=>m(F.target.value),onKeyDown:M,onPaste:b,onInput:I,placeholder:r,disabled:s,rows:1,className:"min-h-[1.35rem] w-full resize-none overflow-x-hidden overflow-y-auto bg-transparent px-0 py-0 text-[11px] leading-[1.35rem] text-foreground placeholder:text-[10px] placeholder:text-muted-foreground/65 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"})}),e.jsx(jn,{query:c,quickChats:d,selectedIndex:g,onActiveIndexChange:f,onSelect:k}),e.jsxs("div",{className:"flex items-end justify-between gap-2 px-2 pb-1.5 pt-0.5 sm:px-5 sm:pb-2.5",children:[H.secondary.length>0?e.jsx("div",{"data-chat-input-secondary-context":"true",className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1 pb-0.5 text-[9px] leading-3 text-muted-foreground/72 sm:text-[9px]",children:H.secondary.map(F=>{const X=br(F.label),$=F.label.toLowerCase()==="agent";return e.jsxs("span",{title:`${F.label}: ${F.value}`,className:"inline-flex min-w-0 max-w-[12rem] items-center gap-1 truncate",children:[$?e.jsx(Un,{agent:F.value,className:"h-2.5 w-2.5 shrink-0 text-primary/50"}):e.jsx(X,{"data-chat-input-secondary-icon":"true",className:"h-2.5 w-2.5 shrink-0 text-primary/50","aria-hidden":"true"}),e.jsx("span",{className:`truncate ${F.mono?"font-mono":""}`,children:F.displayValue})]},`${F.label}:${F.value}`)})}):e.jsx("div",{className:"min-w-0 flex-1"}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs(ee,{type:"button",variant:"ghost",onClick:E,disabled:s,className:"h-7 shrink-0 gap-1.5 rounded-sm px-2 text-[10px] text-muted-foreground hover:text-foreground sm:px-2",title:"Attach images",children:[e.jsx(En,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Images"})]}),e.jsx("span",{title:te,children:e.jsx(ee,{onClick:R.primaryAction==="stop"?l:P,disabled:R.primaryDisabled,size:"icon","data-chat-send-button":"true","aria-label":R.primaryAction==="stop"?"Stop running task":i?"Queue message":"Send message",className:"chat-send-button h-7 w-9 shrink-0 rounded-sm bg-primary/90 text-primary-foreground shadow-[0_12px_30px_-18px_hsl(var(--primary)/0.95)] transition-transform duration-150 hover:bg-primary active:scale-95",children:R.primaryAction==="stop"?e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Ya,{className:`h-3.5 w-3.5 ${u>0?"animate-chat-send-flight":""}`},u)})})]})]}),D&&e.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-2 py-2 text-[11px] text-destructive sm:px-6 sm:py-3",children:D})]})})})}var bc=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],vc=bc.reduce((t,s)=>{const n=gi(`Primitive.${s}`),r=o.forwardRef((a,i)=>{const{asChild:l,...d}=a,c=l?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(c,{...d,ref:i})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{}),wc="Label",to=o.forwardRef((t,s)=>e.jsx(vc.label,{...t,ref:s,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(t.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));to.displayName=wc;var so=to;const yc=bi("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),ze=o.forwardRef(({className:t,...s},n)=>e.jsx(so,{ref:n,className:O(yc(),t),...s}));ze.displayName=so.displayName;function jc(t,s,n){return t!=="auto"?s.find(r=>r.id===t)??null:n.length===1?n[0]??null:null}function Nc(t){return t.trim()||"."}function kc(t){return new Promise(s=>window.setTimeout(s,t))}function Sc(t){return!!t&&typeof t=="object"&&typeof t.createdBranch=="string"&&typeof t.currentBranch<"u"}async function Cc(t){let s=t;for(let n=0;n<60;n++){if(s.status==="succeeded"){if(Sc(s.result))return s.result;throw new Error("Branch creation completed without branch details")}if(s.status==="failed")throw new Error(s.error||"Branch creation failed");await kc(1e3),s=await ji(s.id)}throw new Error("Timed out waiting for branch creation")}function vr({value:t,onChange:s,project:n,assignTo:r,nodes:a,assignableNodes:i,layout:l="default",chipClassName:d,chipActiveClassName:c,chipInactiveClassName:m,labelClassName:g,triggerClassName:f}){const[u,p]=o.useState(!1),[N,y]=o.useState(null),[D,h]=o.useState(""),[E,x]=o.useState(!1),[b,S]=o.useState(!1),[T,C]=o.useState(!1),[I,k]=o.useState(null),[P,M]=o.useState(""),[A,B]=o.useState(""),[R,H]=o.useState(""),[Z,te]=o.useState(!1),F=o.useRef(null),X=o.useRef(0),$=o.useMemo(()=>jc(r,a,i),[r,a,i]),Y=$?.id,w=o.useMemo(()=>Nc(n),[n]),V=o.useMemo(()=>Y?`${Y}
|
|
158
|
+
${w}`:"",[Y,w]),j=o.useCallback(async(ne=0,Q=!1)=>{const J=X.current+1,le=V;if(X.current=J,!Y){y(null),h("");return}k(null),Q||h(""),Q?S(!0):x(!0);try{const _=await vi(Y,{path:w,limit:20,offset:ne,allowAbsolute:!0});if(J!==X.current)return;h(le),y(G=>Q&&G?{..._,branches:[...G.branches,..._.branches]}:_)}catch(_){if(J!==X.current)return;k(_ instanceof Error?_.message:"Failed to load branch info"),Q||(y(null),h(""))}finally{J===X.current&&(x(!1),S(!1))}},[Y,V,w]);o.useEffect(()=>{if(!Y){X.current+=1,y(null),h(""),k(null);return}j()},[Y,w,j]),o.useEffect(()=>{const ne=t.trim(),Q=D===V?N:null,J=Q?.available&&Q.currentBranch?Q.currentBranch:"";ne!==J&&s(J)},[N,V,D,s,t]),o.useEffect(()=>{if(!u)return;const ne=J=>{F.current&&(F.current.contains(J.target)||p(!1))},Q=J=>{J.key==="Escape"&&p(!1)};return document.addEventListener("mousedown",ne),document.addEventListener("keydown",Q),()=>{document.removeEventListener("mousedown",ne),document.removeEventListener("keydown",Q)}},[u]),o.useEffect(()=>{u&&(B(""),H(""),te(!1))},[u,Y,w]);const q=o.useCallback(async()=>{if(!Y)return;const ne=P.trim(),Q=Z?R.trim():A.trim();if(!(!ne||!Q)){C(!0),k(null);try{const J=await wi(Y,{path:w,branchName:ne,startPoint:Q,limit:20,offset:0,allowAbsolute:!0}),le=await Cc(J);h(V),y(le),s(le.currentBranch??le.createdBranch),M(""),B(""),H(""),te(!1),p(!1)}catch(J){k(J instanceof Error?J.message:"Failed to create branch")}finally{C(!1)}}},[Y,V,w,Z,R,P,s,A]),z=D===V?N:null,W=o.useCallback(()=>{z?.hasMore&&j(z.branches.length,!0)},[z,j]),L=t.trim()||z?.currentBranch||(z&&!z.available?"No git repo":"Branch"),ae=Z?R.trim():A.trim(),oe=!!(z?.available&&P.trim()&&ae&&!T),he=l==="composer"?e.jsxs(ee,{type:"button",variant:"ghost",onClick:()=>p(ne=>!ne),title:L,"aria-label":`Branch: ${L}`,className:O(d,f,"min-w-0 max-w-full",t.trim()?c:m),children:[E&&!z?e.jsx(me,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(Ns,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:O("min-w-0 truncate",g),children:L})]}):e.jsxs(ee,{type:"button",variant:"outline",onClick:()=>p(ne=>!ne),className:"h-7 w-full justify-between rounded-sm border-border/70 bg-background/70 px-2.5 text-[11px] shadow-none",title:L,children:[e.jsx("span",{className:O("truncate",t.trim()?"font-mono text-foreground":"text-muted-foreground"),children:L}),e.jsx("span",{className:"ml-2 shrink-0 text-[10px] text-muted-foreground",children:$?$.name:"Manual"})]});return e.jsxs("div",{className:O("relative inline-block",l==="composer"?"min-w-0 shrink-0":"w-full"),ref:F,children:[l==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(ze,{className:"text-[10px] font-medium",children:"Branch"}),he]}):he,u&&e.jsxs("div",{className:O("absolute z-50 mt-2 w-[240px] overflow-hidden rounded-sm border border-border/60 bg-background/95 shadow-[0_16px_48px_-34px_rgba(0,0,0,0.45)] backdrop-blur",l==="composer"?"left-0":"left-0 right-0 w-auto min-w-[240px]"),children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border/60 px-3 py-2",children:[e.jsx(Ns,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-foreground",title:z?.repoRoot?`${z.currentBranch??L} · ${z.repoRoot}`:z?.currentBranch??L,children:z?.currentBranch??L}),E?e.jsx(me,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground"}):null]}),$?E&&!z?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(me,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):z&&!z.available?e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Not a git repository."}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"space-y-2 px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(st,{value:P,onChange:ne=>M(ne.target.value),placeholder:"New branch name",className:"h-8 flex-1 rounded-sm border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx(ee,{type:"button",size:"sm",onClick:()=>{q()},disabled:!oe,title:oe?"Create branch":"Enter a name and pick a base","aria-label":"Create branch",className:"h-8 w-8 shrink-0 rounded-sm p-0",children:T?e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(yi,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Base from"}),!Z&&e.jsxs("button",{type:"button",onClick:()=>te(!0),className:"flex items-center gap-1 rounded-sm px-1 py-0.5 text-[10px] text-muted-foreground hover:bg-background/60 hover:text-foreground",children:[e.jsx(zt,{className:"h-2.5 w-2.5"}),"Manual"]})]}),Z?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(st,{value:R,onChange:ne=>H(ne.target.value),placeholder:"upstream/release/1.0",className:"h-8 flex-1 rounded-sm border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx("button",{type:"button",onClick:()=>{te(!1),H("")},className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Cancel manual input","aria-label":"Cancel manual input",children:e.jsx(nt,{className:"h-3.5 w-3.5"})})]}):z?.branches.length?e.jsxs("div",{className:"max-h-44 overflow-y-auto rounded-sm border border-border/40 bg-background/40",children:[z.branches.map(ne=>{const Q=A===ne.ref,J=ne.branch==="main"||ne.branch==="master";return e.jsxs("button",{type:"button",onClick:()=>B(ne.ref),className:O("flex w-full items-center gap-2 border-b border-border/20 px-2.5 py-1.5 text-left text-[11px] last:border-b-0 hover:bg-background/60",Q&&"bg-background/70"),title:ne.ref,children:[e.jsx("span",{className:O("shrink-0 text-[10px]",J?"text-amber-500 dark:text-amber-400":"text-muted-foreground/60"),"aria-hidden":!0,children:J?"★":"·"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-foreground",children:ne.ref}),Q?e.jsx(os,{className:"h-3 w-3 shrink-0 text-primary"}):null]},ne.ref)}),z.hasMore&&e.jsxs("button",{type:"button",onClick:W,disabled:b,className:"flex w-full items-center justify-center gap-1 border-t border-border/20 py-1 text-[10px] text-muted-foreground hover:bg-background/60 hover:text-foreground disabled:opacity-50",children:[b?e.jsx(me,{className:"h-3 w-3 animate-spin"}):e.jsx(ks,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"rounded-sm border border-dashed border-border/40 px-2.5 py-2 text-[11px] text-muted-foreground",children:"No remote branches found."})]})]})}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Select a specific node first."}),I&&e.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-3 py-1.5 text-[11px] text-destructive",children:I})]})]})}const Tc=20,Ec=3,An="meshy-working-dir-recents-by-node";function Ac(t){return t.startsWith("/")||t.startsWith("\\\\")||/^[A-Za-z]:[\\/]/.test(t)}function Dc(t){const s=t.trim();return s||"."}function Dn(t){const s=[],n=new Set;for(const r of t){const a=r.trim();if(!(!a||n.has(a))&&(n.add(a),s.push(a),s.length===Ec))break}return s}function _c(t,s){const n=s.trim();return Dn(n?[n,...t]:t)}function no(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const s={};for(const[n,r]of Object.entries(t)){if(!n||!Array.isArray(r))continue;const a=r.filter(l=>typeof l=="string"),i=Dn(a);i.length>0&&(s[n]=i)}return s}function Mc(t,s,n){if(!s)return t;const r=t[s]??[],a=_c(r,n);if(a.length===0){if(!(s in t))return t;const{[s]:i,...l}=t;return l}return{...t,[s]:a}}function Pc(t,s){return s?t[s]?.[0]??"":""}function ro(t){if(!t||typeof window>"u")return"";try{const s=window.localStorage.getItem(An);return s?Pc(no(JSON.parse(s)),t):""}catch{return""}}function Ic(t,s,n){return t!=="auto"?s.find(r=>r.id===t)??null:n.length===1?n[0]??null:null}function Rc(t,s){const n=s.trim();return n?Ac(n)||!t?n:`${t.replace(/[/\\]+$/,"")}/${n}`:""}function Lc(t,s){return t?t.isAbsolute?t.currentPath:t.currentPath==="."||t.currentPath===""?t.rootPath||s?.workDir||"Node root":t.currentPath:s?.workDir??"Node root"}function Cs({value:t,onChange:s,assignTo:n,nodes:r,assignableNodes:a,layout:i="default",chipClassName:l,chipActiveClassName:d,chipInactiveClassName:c,labelClassName:m,triggerClassName:g,popoverPlacement:f="bottom",popoverAlign:u="start"}){const[p,N]=o.useState(!1),[y,D]=o.useState(null),[h,E]=o.useState(!1),[x,b]=o.useState(!1),[S,T]=o.useState(null),[C,I]=o.useState(""),[k,P]=o.useState(!1),[M,A]=o.useState({}),B=o.useRef(null),R=o.useMemo(()=>Ic(n,r,a),[n,r,a]),H=R?.id,Z=o.useMemo(()=>H?M[H]??[]:[],[M,H]),te=o.useMemo(()=>t.trim()?Rc(R?.workDir,t):"Use node default",[t,R?.workDir]);o.useEffect(()=>{if(!(typeof window>"u"))try{const L=window.localStorage.getItem(An);if(!L)return;const ae=JSON.parse(L);A(no(ae))}catch{}},[]);const F=o.useCallback(L=>{H&&A(ae=>{const oe=Mc(ae,H,L);if(oe===ae)return ae;if(typeof window<"u")try{window.localStorage.setItem(An,JSON.stringify(oe))}catch{}return oe})},[H]),X=o.useCallback((L,ae=!0)=>{const oe=L.trim();s(oe),ae&&oe&&F(oe),N(!1)},[s,F]),$=o.useCallback(async(L,ae=0,oe=!1)=>{if(H){T(null),oe?b(!0):E(!0);try{const he=await Da(H,{path:L,limit:Tc,offset:ae,directoriesOnly:!0,allowAbsolute:!0});D(ne=>oe&&ne?{...he,entries:[...ne.entries,...he.entries]}:he)}catch(he){T(he instanceof Error?he.message:"Failed to browse directories"),oe||D(null)}finally{E(!1),b(!1)}}},[H]),Y=o.useRef(t);Y.current=t;const w=o.useRef($);w.current=$,o.useEffect(()=>{if(!p)return;const L=Y.current;I(L),P(!1),D(null),T(null),H&&w.current(Dc(L))},[p,H]),o.useEffect(()=>{if(!p)return;const L=oe=>{B.current&&(B.current.contains(oe.target)||N(!1))},ae=oe=>{oe.key==="Escape"&&N(!1)};return document.addEventListener("mousedown",L),document.addEventListener("keydown",ae),()=>{document.removeEventListener("mousedown",L),document.removeEventListener("keydown",ae)}},[p]);const V=o.useCallback(L=>{$(L)},[$]),j=o.useCallback(()=>{y&&$(y.currentPath,y.entries.length,!0)},[y,$]),q=i==="composer"?e.jsxs(ee,{type:"button",variant:"ghost",onClick:()=>N(L=>!L),title:te,"aria-label":`Working directory: ${te}`,className:O(l,g,"min-w-0 max-w-full",t.trim()?d:c),children:[e.jsx(Ni,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:O("min-w-0 truncate",m),children:te})]}):e.jsxs(ee,{type:"button",variant:"outline",onClick:()=>N(L=>!L),className:"h-7 w-full justify-between rounded-sm border-border/70 bg-background/70 px-2.5 text-[11px] shadow-none",title:te,children:[e.jsx("span",{className:O("truncate",t.trim()?"font-mono text-foreground":"text-muted-foreground"),children:te}),e.jsx("span",{className:"ml-2 shrink-0 text-[10px] text-muted-foreground",children:R?R.name:"Manual"})]}),z=Lc(y,R),W=!!y?.parentPath;return e.jsxs("div",{className:O("relative inline-block",i==="composer"?"min-w-0 max-w-[60%] shrink":"w-full"),"data-workdir-popover-placement":f,"data-workdir-popover-align":u,ref:B,children:[i==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(ze,{className:"text-[10px] font-medium",children:"Working directory"}),q]}):q,p&&e.jsxs("div",{className:O("absolute z-50 flex max-h-[min(28rem,calc(100vh-5rem))] w-[240px] flex-col overflow-hidden rounded-sm border border-border/60 bg-background/95 shadow-[0_16px_48px_-34px_rgba(0,0,0,0.45)] backdrop-blur",f==="top"?"bottom-full mb-2":"top-full mt-2",i==="composer"?u==="end"?"right-0":"left-0":u==="end"?"right-0 w-auto min-w-[240px]":"left-0 right-0 w-auto min-w-[240px]"),children:[Z.length>0&&e.jsxs("div",{className:"border-b border-border/60 px-3 py-2",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1 text-[10px] text-muted-foreground",children:[e.jsx(ks,{className:"h-2.5 w-2.5"}),"Recent"]}),e.jsx("div",{className:"flex flex-col",children:Z.map(L=>e.jsx("button",{type:"button",onClick:()=>X(L),className:"truncate rounded-sm px-1.5 py-0.5 text-left font-mono text-[11px] text-foreground hover:bg-background/60",title:L,children:L},L))})]}),e.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/60 px-2.5 py-1.5",children:[e.jsx("button",{type:"button",onClick:()=>y?.parentPath&&V(y.parentPath),disabled:!W||h,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-sm border border-border/60 text-muted-foreground transition-colors hover:bg-background/60 hover:text-foreground disabled:opacity-40",title:"Parent directory",children:e.jsx(Ga,{className:"h-3 w-3"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground",title:z,children:z}),y&&e.jsx("button",{type:"button",onClick:()=>X(y.isAbsolute?y.currentPath:y.currentPath==="."?"":y.currentPath),className:"shrink-0 rounded-sm px-1.5 py-0.5 text-[10px] font-medium text-foreground hover:bg-background/60",title:"Use this folder",children:"Use"})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:[R?h?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(me,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):y&&y.entries.length>0?e.jsxs(e.Fragment,{children:[y.entries.map(L=>e.jsxs("div",{className:"group flex items-stretch border-b border-border/30 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>X(L.path),className:"flex min-w-0 flex-1 items-center gap-2 px-2.5 py-1.5 text-left hover:bg-background/55",title:`Use ${L.path}`,children:[e.jsx(Bt,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-[11px] text-foreground",children:L.name})]}),e.jsx("button",{type:"button",onClick:()=>V(L.path),className:"flex w-9 shrink-0 items-center justify-center border-l border-border/30 text-muted-foreground hover:bg-background/70 hover:text-foreground",title:"Open subfolder","aria-label":`Open ${L.name}`,children:e.jsx(Ke,{className:"h-3.5 w-3.5"})})]},L.path)),y.hasMore&&e.jsxs("button",{type:"button",onClick:j,disabled:x,className:"flex w-full items-center justify-center gap-1 border-t border-border/40 py-1 text-[10px] text-muted-foreground hover:bg-background/60 hover:text-foreground disabled:opacity-50",children:[x?e.jsx(me,{className:"h-3 w-3 animate-spin"}):e.jsx(ks,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:S??"No subfolders."}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Select a node to browse."}),S&&y&&y.entries.length>0&&e.jsx("div",{className:"border-t border-border/60 px-3 py-1.5 text-[11px] text-destructive",children:S})]}),e.jsx("div",{className:"flex items-center gap-1 border-t border-border/60 bg-background/40 px-2.5 py-1.5",children:k?e.jsxs(e.Fragment,{children:[e.jsx(st,{value:C,onChange:L=>I(L.target.value),onKeyDown:L=>{L.key==="Enter"&&C.trim()?(L.preventDefault(),X(C)):L.key==="Escape"&&(L.preventDefault(),P(!1),I(t))},autoFocus:!0,placeholder:"Path (relative or absolute)",className:"h-7 flex-1 rounded-sm border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx("button",{type:"button",onClick:()=>X(C),disabled:!C.trim(),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-sm text-foreground hover:bg-background/60 disabled:opacity-40",title:"Apply","aria-label":"Apply manual path",children:e.jsx(os,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{P(!1),I(t)},className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Cancel","aria-label":"Cancel manual path",children:e.jsx(nt,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>{I(t),P(!0)},className:"flex h-7 flex-1 items-center justify-between rounded-sm px-1.5 text-[11px] text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Enter a manual path",children:[e.jsx("span",{children:"Manual input"}),e.jsx(zt,{className:"h-3 w-3"})]})})]})]})}function ao(t,s={}){const n=t.filter(r=>r.status==="online");return s.currentNodeRole!=="follower"||!s.leaderNodeId?n:n.filter(r=>r.id!==s.leaderNodeId)}function Vn({isCurrent:t}){return t?e.jsx(Md,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500 dark:text-emerald-400","aria-label":"current node"}):e.jsx(Ed,{className:"h-3.5 w-3.5 shrink-0 text-sky-500 dark:text-sky-400","aria-label":"remote follower node"})}function _n(t,s){return t.map(n=>{const r=!!s&&n.id===s;return e.jsx(xe,{value:n.id,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(Vn,{isCurrent:r}),e.jsx("span",{className:"truncate",children:n.name}),e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:r?"current":"remote"})]})},n.id)})}function Bc(t){const s=t.sessionId.trim(),n=t.cwd.trim();return!s||!n||!t.assignTo?null:{title:t.title.trim()||t.defaultTitle?.trim()||void 0,agent:t.agent,sessionId:s,cwd:n,assignTo:t.assignTo,priority:t.priority,mode:t.mode??is}}function Oc(){return Ci.map(t=>e.jsx(xe,{value:t.value,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{children:t.label}),t.description&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:t.description})]})},t.value))}function Fc(t){if(!t)return"unknown time";const s=Date.parse(t);return Number.isNaN(s)?t:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(s)}function wr(t){if(!t.updatedAt)return 0;const s=Date.parse(t.updatedAt);return Number.isNaN(s)?0:s}function zc(t,s){return wr(s)-wr(t)||t.sessionId.localeCompare(s.sessionId)}function Uc(t){const s=t.trim().replace(/[\\/]+$/,"");return s?s.split(/[\\/]+/).filter(Boolean).at(-1)??s:"Unknown project"}function $c(t){const s=new Map;for(const n of[...t].sort(zc)){const r=s.get(n.cwd);if(r){r.push(n);continue}s.set(n.cwd,[n])}return Array.from(s.entries()).map(([n,r])=>({folderName:Uc(n),cwd:n,sessions:r}))}function qc(t,s){const n=new Set(t);return n.has(s)?n.delete(s):n.add(s),n}function Vc({nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:r,onCreated:a,onCancel:i,className:l,footerClassName:d,submitLabel:c="Load session",cancelLabel:m="Cancel",autoFocus:g=!1}){const f=o.useMemo(()=>ao(t,{currentNodeRole:s,leaderNodeId:r}),[t,s,r]),u=o.useMemo(()=>n&&f.some(_=>_.id===n)?n:f[0]?.id??"",[f,n]),[p,N]=o.useState(""),[y,D]=o.useState("codex"),[h,E]=o.useState(""),[x,b]=o.useState(""),[S,T]=o.useState(""),[C,I]=o.useState(u),[k,P]=o.useState("normal"),[M,A]=o.useState(is),[B,R]=o.useState(!1),[H,Z]=o.useState([]),[te,F]=o.useState(!1),[X,$]=o.useState(null),Y=o.useMemo(()=>H.find(_=>_.sessionId===h)??null,[H,h]);o.useEffect(()=>{C&&f.some(_=>_.id===C)||I(u)},[C,f,u]),o.useEffect(()=>{E(""),b(""),T("")},[y,C]),o.useEffect(()=>{let _=!1;return C?(F(!0),$(null),ki(C,{agent:y,limit:50}).then(G=>{_||Z(G.sessions)}).catch(G=>{_||(Z([]),$(G instanceof Error?G.message:"Failed to load native sessions"))}).finally(()=>{_||F(!1)}),()=>{_=!0}):(Z([]),$(null),F(!1),()=>{_=!0})},[y,C]),o.useEffect(()=>{Y&&(b(Y.sessionId),T(Y.cwd))},[Y]);const w=o.useCallback(async _=>{_.preventDefault();const G=Bc({title:p,defaultTitle:Y?.summary,agent:y,sessionId:x,cwd:S,assignTo:C,priority:k,mode:M});if(G){R(!0);try{const ue=await Si(G);a(ue)}catch(ue){de.error(ue instanceof Error?ue.message:"Failed to load native session")}finally{R(!1)}}},[p,Y,y,x,S,C,k,M,a]),V=!!(x.trim()&&S.trim()&&C),[j,q]=o.useState(!1),[z,W]=o.useState(""),[L,ae]=o.useState(()=>new Set),oe=f.find(_=>_.id===C)??null,he=!!(n&&oe?.id===n),ne=o.useMemo(()=>{const _=z.trim().toLowerCase();return _?H.filter(G=>G.summary.toLowerCase().includes(_)||G.sessionId.toLowerCase().includes(_)||G.cwd.toLowerCase().includes(_)):H},[H,z]),Q=o.useMemo(()=>$c(ne),[ne]),J=o.useCallback(_=>{ae(G=>qc(G,_))},[]),le="h-9 w-auto gap-1.5 rounded-sm border-border/60 bg-background/60 px-3 text-xs shadow-none transition-colors hover:bg-background/80";return e.jsxs("form",{onSubmit:w,className:O("space-y-4",l),children:[e.jsxs("div",{className:"rounded-sm border border-border/60 bg-background/54 shadow-none backdrop-blur-xl",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-border/50 px-3 py-2.5",children:[e.jsxs(Ne,{value:C,onValueChange:I,children:[e.jsx(ke,{className:O(le),"aria-label":"Node",children:oe?e.jsxs(e.Fragment,{children:[e.jsx(Vn,{isCurrent:he}),e.jsx("span",{className:"max-w-[10rem] truncate",children:oe.name})]}):e.jsx(Pe,{placeholder:"Node"})}),e.jsx(Se,{children:_n(f,n)})]}),e.jsxs(Ne,{value:y,onValueChange:_=>D(_),children:[e.jsxs(ke,{className:O(le),"aria-label":"Agent",children:[e.jsx(Un,{agent:y}),e.jsx("span",{children:y})]}),e.jsx(Se,{children:Gl()})]}),e.jsxs("div",{className:"relative ml-auto min-w-0 flex-1 sm:max-w-56",children:[e.jsx(_a,{className:"pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx(st,{value:z,onChange:_=>W(_.target.value),placeholder:"Filter sessions",className:"h-9 rounded-sm border-border/60 bg-background/60 pl-9 text-xs shadow-none"})]})]}),e.jsxs("div",{className:"px-3 py-3",children:[e.jsx("div",{className:"flex items-center justify-between px-1 pb-2",children:e.jsx(ze,{className:"text-[10px] font-medium uppercase tracking-[0.2em] text-muted-foreground",children:te?"Loading...":`${ne.length} session${ne.length===1?"":"s"}`})}),e.jsxs("div",{className:"relative h-88 overflow-hidden rounded-sm",children:[te&&e.jsx("div",{className:"absolute inset-x-0 top-0 z-10 h-0.5 overflow-hidden bg-primary/10",children:e.jsx("div",{className:"h-full w-1/3 animate-indeterminate-bar bg-primary/70"})}),e.jsxs("div",{className:"h-full space-y-1.5 overflow-y-auto pr-1",children:[!C&&e.jsx("div",{className:"rounded-sm border border-dashed border-border/60 bg-background/35 px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Pick a node to load its recent sessions."}),C&&!te&&ne.length===0&&e.jsx("div",{className:"rounded-sm border border-dashed border-border/60 bg-background/35 px-3 py-4 text-center text-[11px] text-muted-foreground",children:H.length===0?"No recent sessions on this node. Use Manual session ID under More options.":"No sessions match your filter."}),Q.map(_=>e.jsxs("section",{className:"space-y-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>J(_.cwd),"aria-expanded":!L.has(_.cwd),className:"sticky top-0 z-[1] flex w-full items-center gap-2 border-b border-border/50 bg-background/95 px-1 py-1.5 text-left text-[10px] text-muted-foreground backdrop-blur transition-colors hover:bg-background",children:[e.jsx(Qe,{className:O("h-3.5 w-3.5 shrink-0 transition-transform",L.has(_.cwd)&&"-rotate-90")}),e.jsx(_s,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate text-xs font-medium text-foreground",children:_.folderName}),e.jsxs("span",{className:"shrink-0 uppercase tracking-[0.16em]",children:[_.sessions.length," session",_.sessions.length===1?"":"s"]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-right font-mono",children:_.cwd})]}),!L.has(_.cwd)&&_.sessions.map(G=>{const ue=G.sessionId===h;return e.jsxs("button",{type:"button",onClick:()=>E(G.sessionId),className:O("flex w-full flex-col gap-1 rounded-sm border px-2.5 py-2 text-left transition-colors duration-200",ue?"border-primary/45 bg-primary/9 shadow-none":"border-border/55 bg-background/40 hover:border-border hover:bg-background/65"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:O("h-2 w-2 shrink-0 rounded-full",ue?"bg-primary":"bg-border")}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",children:G.summary}),e.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.16em] text-muted-foreground",children:Fc(G.updatedAt)})]}),e.jsxs("div",{className:"flex items-center gap-2 pl-4 text-[10px] text-muted-foreground",children:[e.jsx("span",{className:"font-mono",children:G.sessionId.slice(0,12)}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),e.jsx("span",{className:"truncate font-mono",children:G.cwd})]})]},G.sessionId)})]},_.cwd))]})]}),X&&e.jsx("p",{className:"px-1 pt-2 text-[11px] text-destructive",children:X})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:()=>q(_=>!_),className:"inline-flex h-6 items-center gap-1.5 rounded-sm px-1.5 text-[10px] font-medium uppercase tracking-[0.16em] text-muted-foreground transition-colors hover:bg-muted/45 hover:text-foreground","aria-expanded":j,children:[e.jsx("span",{className:"shrink-0",children:j?"Less options":"More options"}),e.jsx(Qe,{className:O("h-3.5 w-3.5 shrink-0 transition-transform",j&&"rotate-180")})]}),j&&e.jsxs("div",{className:"space-y-2 rounded-sm border border-border/60 bg-background/30 p-2.5",children:[e.jsxs("div",{className:"grid gap-2.5 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(ze,{htmlFor:"native-session-id",className:"text-[10px] font-medium text-muted-foreground",children:"Session ID"}),e.jsx(st,{id:"native-session-id",type:"text",value:x,onChange:_=>{E(""),b(_.target.value)},placeholder:"ses_..., thread_..., or UUID",autoFocus:g,className:"h-7 rounded-sm border-border/70 bg-background/70 font-mono text-[11px] shadow-none"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ze,{htmlFor:"native-session-title",className:"text-[10px] font-medium text-muted-foreground",children:"Task title"}),e.jsx(st,{id:"native-session-title",type:"text",value:p,onChange:_=>N(_.target.value),placeholder:"Optional",className:"h-7 rounded-sm border-border/70 bg-background/70 text-[11px] shadow-none"})]})]}),e.jsx(Cs,{value:S,onChange:_=>{E(""),T(_)},assignTo:C,nodes:t,assignableNodes:f}),e.jsxs("div",{className:"grid gap-2.5 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(ze,{className:"text-[10px] font-medium text-muted-foreground",children:"Mode"}),e.jsxs(Ne,{value:M,onValueChange:_=>A(_),children:[e.jsx(ke,{className:"h-7 rounded-sm border-border/70 bg-background/70 text-[11px] shadow-none",children:e.jsx(Pe,{placeholder:"Select mode"})}),e.jsx(Se,{children:Oc()})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ze,{className:"text-[10px] font-medium text-muted-foreground",children:"Priority"}),e.jsxs(Ne,{value:k,onValueChange:P,children:[e.jsx(ke,{className:"h-7 rounded-sm border-border/70 bg-background/70 text-[11px] shadow-none",children:e.jsx(Pe,{placeholder:"Select priority"})}),e.jsxs(Se,{children:[e.jsx(xe,{value:"low",children:"Low"}),e.jsx(xe,{value:"normal",children:"Normal"}),e.jsx(xe,{value:"high",children:"High"}),e.jsx(xe,{value:"critical",children:"Critical"})]})]})]})]})]})]}),e.jsxs("div",{className:O("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",d),children:[i&&e.jsx(ee,{type:"button",variant:"ghost",onClick:i,className:"rounded-sm",children:m}),e.jsx(ee,{type:"submit",disabled:!V||B,className:"rounded-sm px-5",children:B?e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"h-4 w-4 animate-spin"})," Loading..."]}):c})]})]})}function oo(t,s,n=!1){const r=t.trim();if(r)return r;const a=s.trim().split(`
|
|
159
|
+
`).map(i=>i.trim()).find(Boolean);return a?a.length>72?`${a.slice(0,69).trimEnd()}...`:a:n?"Image task":""}function Hc(t){const s=t.title.trim(),n=oo(t.title,t.description,t.images.length>0),r=t.description.trim()||n,a=t.mode??is,i=qa(t.description,t.images);return!n||!r||!t.agent?null:{title:n,description:r,agent:t.agent,project:t.project.trim()||null,branch:t.branch?.trim()||null,payload:{initialMessage:i,mode:a,titleSource:s?"manual":"derived"},priority:t.priority,assignTo:t.assignTo==="auto"?void 0:t.assignTo}}function Kc({nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:r,initialAssignTo:a,initialProject:i,onCreated:l,onCancel:d,className:c,footerClassName:m,submitLabel:g="Create chat",cancelLabel:f="Cancel",autoFocus:u=!1,layout:p="default",quickChats:N=[]}){const[y,D]=o.useState(""),[h,E]=o.useState(""),[x,b]=o.useState(0),[S,T]=o.useState(sr),[C,I]=o.useState(is),[k,P]=o.useState(i?.trim()??""),M=o.useRef(i!==void 0),[A,B]=o.useState(""),[R,H]=o.useState("normal"),Z=o.useMemo(()=>ao(t,{currentNodeRole:s,leaderNodeId:r}),[t,s,r]),te=o.useMemo(()=>a&&Z.some(re=>re.id===a)?a:n&&Z.some(re=>re.id===n)?n:Z[0]?.id??"",[Z,n,a]),[F,X]=o.useState(te),[$,Y]=o.useState(!1),[w,V]=o.useState(!1),{images:j,error:q,fileInputRef:z,pickImages:W,handleFileChange:L,handlePaste:ae,removeImage:oe}=eo(),he=o.useMemo(()=>Z.find(re=>re.id===F)??null,[F,Z]),ne=!!(n&&he?.id===n),Q=Ha(S),J=Wl(C);o.useEffect(()=>{F&&Z.some(re=>re.id===F)||X(te)},[F,Z,te]),o.useEffect(()=>{if(M.current){M.current=!1;return}P(ro(F)),B("")},[F]),o.useEffect(()=>{B("")},[k]),o.useEffect(()=>{b(0)},[h,N]);const le=o.useCallback(re=>{E(re.prompt)},[]),_=o.useCallback(async re=>{re.preventDefault();const ge=ys(h,N,x);if(ge){le(ge);return}const ve=Hc({title:y,description:h,agent:S,project:k,branch:A,priority:R,assignTo:F,mode:C,images:j});if(ve){Y(!0);try{const qe=await Ei(ve);l(qe)}catch(qe){de.error(qe instanceof Error?qe.message:"Failed to create task")}finally{Y(!1)}}},[y,h,S,k,A,R,F,C,j,l,N,x,le]),G=oo(y,h,j.length>0),ue=!!(G&&S&&F&&(h.trim()||j.length>0)),ye=o.useCallback(re=>{if(re.nativeEvent.isComposing)return;const ge=Ta(h,N);if(ge.length>0&&(re.key==="ArrowDown"||re.key==="ArrowUp")){re.preventDefault(),b(ve=>Ea(ve,ge.length,re.key==="ArrowDown"?1:-1));return}if(re.key==="Enter"){const ve=ys(h,N,x);if(ve&&!re.shiftKey){re.preventDefault(),le(ve);return}}re.key==="Enter"&&(re.ctrlKey||re.metaKey)&&ue&&!$&&(re.preventDefault(),re.currentTarget.form?.requestSubmit())},[le,ue,h,N,x,$]),Ie=j.length>0&&e.jsx("div",{className:"flex flex-wrap gap-3",children:j.map((re,ge)=>e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:Ql(re),alt:re.filename??`attachment ${ge+1}`,className:"h-20 w-20 rounded-sm border border-border/70 object-cover"}),e.jsx("button",{type:"button",onClick:()=>oe(ge),className:"absolute -top-2 -right-2 flex h-6 w-6 items-center justify-center rounded-sm border border-border/70 bg-background text-muted-foreground shadow-sm transition-all hover:-translate-y-px hover:text-foreground","aria-label":`Remove ${re.filename??`image ${ge+1}`}`,children:e.jsx(nt,{className:"h-3.5 w-3.5"})})]},`${re.filename??"image"}-${ge}`))}),Be=e.jsxs("div",{className:"space-y-2",children:[e.jsx(ze,{className:"text-[11px] font-medium",children:"Assign to"}),e.jsxs(Ne,{value:F,onValueChange:X,children:[e.jsx(ke,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Pe,{placeholder:"Select node"})}),e.jsx(Se,{children:_n(Z,n)})]})]}),pt=e.jsxs("div",{className:"space-y-2",children:[e.jsx(ze,{className:"text-[11px] font-medium",children:"Agent"}),e.jsxs(Ne,{value:S,onValueChange:T,children:[e.jsx(ke,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Pe,{placeholder:"Select agent"})}),e.jsx(Se,{children:ur()})]})]}),Ye=e.jsxs("div",{className:"space-y-2",children:[e.jsx(ze,{className:"text-[11px] font-medium",children:"Mode"}),e.jsxs(Ne,{value:C,onValueChange:re=>I(re),children:[e.jsx(ke,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Pe,{placeholder:"Select mode"})}),e.jsx(Se,{children:mr()})]})]}),$e=e.jsxs("div",{className:"space-y-2",children:[e.jsx(ze,{className:"text-[11px] font-medium",children:"Priority"}),e.jsxs(Ne,{value:R,onValueChange:H,children:[e.jsx(ke,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Pe,{placeholder:"Select priority"})}),e.jsxs(Se,{children:[e.jsx(xe,{value:"low",children:"Low"}),e.jsx(xe,{value:"normal",children:"Normal"}),e.jsx(xe,{value:"high",children:"High"}),e.jsx(xe,{value:"critical",children:"Critical"})]})]})]}),Te=e.jsx(Cs,{value:k,onChange:P,assignTo:F,nodes:t,assignableNodes:Z}),dt=e.jsx(vr,{value:A,onChange:B,project:k,assignTo:F,nodes:t,assignableNodes:Z});return p==="composer"?e.jsxs("form",{onSubmit:_,className:O("space-y-4",c),children:[e.jsx("input",{ref:z,type:"file",accept:"image/*",multiple:!0,onChange:L,className:"hidden"}),(()=>{const re="chat-composer__chip h-9 w-auto gap-1.5 rounded-sm px-3.5 text-xs shadow-none transition-colors",ge="border-transparent bg-transparent text-muted-foreground hover:bg-background/40 hover:text-foreground",ve="border-border/70 bg-background/55 text-foreground",qe=S===sr,ct=C===is;return e.jsxs("div",{className:"chat-composer space-y-2",children:[e.jsxs("div",{className:"chat-composer__card rounded-sm border border-border/60 bg-background/54 shadow-none backdrop-blur-xl",children:[e.jsxs("div",{className:"chat-composer__header flex min-w-0 items-center justify-between gap-3 px-4 pt-3",children:[e.jsxs(Ne,{value:F,onValueChange:X,children:[e.jsx(ke,{className:O(re,ve,"chat-composer__node-trigger border-transparent bg-transparent hover:bg-background/40"),title:`Assigned node: ${he?.name??"unassigned"}`,"aria-label":`Assigned node: ${he?.name??"unassigned"}`,children:he?e.jsxs(e.Fragment,{children:[e.jsx(Vn,{isCurrent:ne}),e.jsx("span",{className:"min-w-0 truncate",children:he.name}),e.jsx("span",{className:"chat-composer__header-meta shrink-0 text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:ne?"current":"remote"})]}):e.jsx(Pe,{placeholder:"Select node"})}),e.jsx(Se,{children:_n(Z,n)})]}),w?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(st,{id:"task-title-composer",type:"text",value:y,onChange:je=>D(je.target.value),onKeyDown:je=>{(je.key==="Enter"||je.key==="Escape")&&(je.preventDefault(),V(!1))},autoFocus:!0,placeholder:"Chat title",className:"h-8 w-48 min-w-0 rounded-sm border-border/70 bg-background/55 px-3 text-xs shadow-none"}),e.jsx(ee,{type:"button",variant:"ghost",size:"icon",onClick:()=>V(!1),"aria-label":"Save title",className:"h-8 w-8 shrink-0 rounded-sm text-muted-foreground hover:text-foreground",children:e.jsx(os,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>V(!0),className:"chat-composer__title-button flex min-w-0 items-center gap-1.5 rounded-sm px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-background/55 hover:text-foreground",title:G||"Title","aria-label":G?`Edit title: ${G}`:"Edit title",children:[e.jsx("span",{className:"chat-composer__title-text max-w-[220px] truncate",children:G||"Title"}),e.jsx(zt,{className:"h-3 w-3 shrink-0"})]})]}),e.jsx("textarea",{id:"task-description",value:h,onChange:je=>E(je.target.value),onKeyDown:ye,onPaste:ae,placeholder:"Ask anything...",rows:4,autoFocus:u,"aria-label":"Opening prompt",className:"min-h-[140px] w-full resize-none overflow-x-hidden overflow-y-auto rounded-sm bg-transparent px-5 pt-2 pb-2 text-xs leading-5 text-foreground ring-offset-background placeholder:text-muted-foreground/70 focus-visible:outline-none"}),e.jsx(jn,{query:h,quickChats:N,selectedIndex:x,onActiveIndexChange:b,onSelect:le}),e.jsxs("div",{className:"chat-composer__rail flex flex-nowrap items-center gap-2 px-3 pb-3",children:[e.jsx(ee,{type:"button",variant:"ghost",size:"icon",onClick:W,"aria-label":"Add images",className:"h-9 w-9 shrink-0 rounded-sm text-muted-foreground hover:text-foreground",children:e.jsx(En,{className:"h-4 w-4"})}),e.jsx("span",{className:"mx-0.5 h-5 w-px bg-border/60","aria-hidden":!0}),e.jsxs(Ne,{value:S,onValueChange:T,children:[e.jsxs(ke,{className:O(re,"chat-composer__icon-trigger",qe?ge:ve),title:`Agent: ${Q}`,"aria-label":`Agent: ${Q}`,children:[e.jsx(Un,{agent:S}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:Q})]}),e.jsx(Se,{children:ur()})]}),e.jsxs(Ne,{value:C,onValueChange:je=>I(je),children:[e.jsxs(ke,{className:O(re,"chat-composer__icon-trigger",ct?ge:ve),title:`Mode: ${J}`,"aria-label":`Mode: ${J}`,children:[e.jsx(Gd,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:J})]}),e.jsx(Se,{children:mr()})]}),e.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[e.jsxs(Ne,{value:R,onValueChange:H,children:[e.jsx(ke,{"aria-label":`Priority: ${R}`,title:`Priority: ${R}`,className:O("h-9 w-9 justify-center gap-0 rounded-sm p-0 text-xs shadow-none [&>svg:last-child]:hidden",R==="normal"?"border-transparent bg-transparent text-muted-foreground hover:bg-background/40":"border-border/70 bg-background/55",R==="critical"&&"text-destructive",R==="high"&&"text-amber-600 dark:text-amber-400",R==="low"&&"text-muted-foreground"),children:e.jsx(jd,{className:O("h-4 w-4",R==="critical"&&"fill-destructive/20")})}),e.jsxs(Se,{children:[e.jsx(xe,{value:"low",children:"Low"}),e.jsx(xe,{value:"normal",children:"Normal"}),e.jsx(xe,{value:"high",children:"High"}),e.jsx(xe,{value:"critical",children:"Critical"})]})]}),d&&e.jsxs(ee,{type:"button",variant:"ghost",size:"sm",onClick:d,"aria-label":f,className:"chat-composer__cancel h-9 rounded-sm px-4 text-xs text-muted-foreground",children:[e.jsx(nt,{className:"chat-composer__cancel-icon h-4 w-4 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label",children:f})]}),e.jsxs(ee,{type:"submit",size:"icon",disabled:!ue||$,className:"h-10 w-10 rounded-sm shadow-[0_8px_30px_-8px_hsl(var(--primary)/0.6)]",children:[$?e.jsx(me,{className:"h-4 w-4 animate-spin"}):e.jsx(Ya,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:$?"Creating chat":g})]})]})]})]}),e.jsx("div",{className:"chat-composer__location flex flex-wrap items-center gap-2 px-1",children:(()=>{const je="border-border/40 bg-muted/40 text-foreground/80 hover:bg-muted/60 hover:text-foreground";return e.jsxs(e.Fragment,{children:[e.jsx(Cs,{value:k,onChange:P,assignTo:F,nodes:t,assignableNodes:Z,layout:"composer",chipClassName:re,chipActiveClassName:je,chipInactiveClassName:je,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"}),e.jsx(vr,{value:A,onChange:B,project:k,assignTo:F,nodes:t,assignableNodes:Z,layout:"composer",chipClassName:re,chipActiveClassName:je,chipInactiveClassName:je,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"})]})})()})]})})(),(Ie||q)&&e.jsxs("div",{className:"space-y-2 rounded-sm border border-border/60 bg-background/45 p-2.5",children:[Ie,q&&e.jsx("div",{className:"text-[11px] text-destructive",children:q}),!q&&e.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Ctrl/Cmd+Enter starts the chat. Enter adds a new line. Paste screenshots directly into the prompt box or use the Images button."})]})]}):e.jsxs("form",{onSubmit:_,className:O("space-y-4",c),children:[e.jsx("input",{ref:z,type:"file",accept:"image/*",multiple:!0,onChange:L,className:"hidden"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ze,{htmlFor:"task-description",className:"text-[11px] font-medium",children:"Opening prompt"}),e.jsx("textarea",{id:"task-description",value:h,onChange:re=>E(re.target.value),onKeyDown:ye,onPaste:ae,placeholder:"Describe what the agent should do. This becomes the first message in the chat.",rows:6,autoFocus:u,className:"flex min-h-[128px] w-full resize-none overflow-x-hidden overflow-y-auto rounded-sm border border-border/70 bg-background/70 px-3 py-2 text-xs leading-5 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"}),e.jsx(jn,{query:h,quickChats:N,selectedIndex:x,onActiveIndexChange:b,onSelect:le}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(ee,{type:"button",variant:"outline",onClick:W,className:"rounded-sm",children:[e.jsx(En,{className:"h-4 w-4"}),"Add images"]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Ctrl/Cmd+Enter starts the chat. Enter adds a new line. Upload or paste screenshots and reference images with the opening prompt."})]}),Ie,q&&e.jsx("p",{className:"text-[11px] text-destructive",children:q})]}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1fr)_190px_190px]",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ze,{htmlFor:"task-title",className:"text-[11px] font-medium",children:"Chat title"}),e.jsx(st,{id:"task-title",type:"text",value:y,onChange:re=>D(re.target.value),placeholder:"Optional. Leave blank to derive it from the prompt.",className:"h-8 rounded-sm border-border/70 bg-background/70"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:G?`Will appear as: ${G}`:"A title will be generated from the first line of the prompt."})]}),pt,Ye]}),Te,dt,e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[$e,Be]}),e.jsxs("div",{className:O("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",m),children:[d&&e.jsx(ee,{type:"button",variant:"ghost",onClick:d,className:"rounded-sm",children:f}),e.jsx(ee,{type:"submit",disabled:!ue||$,className:"rounded-sm px-5",children:$?"Creating...":g})]})]})}function Gc({nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:r,initialAssignTo:a,initialProject:i,onCreated:l,onCancel:d,defaultMode:c="chat",mode:m,onModeChange:g,layout:f="default",className:u,footerClassName:p,autoFocus:N=!1,quickChats:y=[]}){const[D,h]=o.useState(c),E=m!==void 0,x=E?m:D,b=S=>{E||h(S),g?.(S)};return e.jsxs("div",{className:O("space-y-4",u),children:[!E&&e.jsxs("div",{className:"flex h-8 items-center gap-0.5 rounded-sm border border-border/60 bg-background/45 p-0.5",children:[e.jsxs(ee,{type:"button",variant:x==="chat"?"default":"ghost",onClick:()=>b("chat"),className:"h-7 flex-1 rounded-sm shadow-none",children:[e.jsx(Ti,{className:"h-4 w-4"}),"New chat"]}),e.jsxs(ee,{type:"button",variant:x==="native"?"default":"ghost",onClick:()=>b("native"),className:"h-7 flex-1 rounded-sm shadow-none",children:[e.jsx($n,{className:"h-4 w-4"}),"Load session"]})]}),x==="chat"?e.jsx(Kc,{nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:r,initialAssignTo:a,initialProject:i,onCreated:l,onCancel:d,footerClassName:p,submitLabel:f==="composer"?"Start chat":"Create chat",cancelLabel:"Cancel",autoFocus:N,layout:f,quickChats:y},`${a??""}:${i??""}`):e.jsx(Vc,{nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:r,onCreated:l,onCancel:d,footerClassName:p,autoFocus:N})]})}function Wc({onClick:t,running:s}){return e.jsxs(ee,{size:"icon",onClick:t,"aria-label":s?"Open composer - task running":"Open composer",title:s?"Task running - open composer":"Open composer",className:O("absolute bottom-4 right-4 z-10 h-12 w-12 overflow-visible rounded-lg shadow-lg",s&&"animate-soft-status-pulse bg-primary/90 text-primary-foreground hover:bg-primary"),children:[e.jsx(zt,{className:"h-4 w-4"}),s&&e.jsx("span",{"aria-hidden":"true","data-running-indicator":"true",className:"pointer-events-none absolute right-1.5 top-1.5 h-2 w-2 rounded-full bg-primary-foreground shadow-[0_0_0_2px_hsl(var(--primary))]"})]})}function yr({children:t}){return e.jsxs("div",{className:"agent-progress-banner animate-message-receive flex items-center gap-1.5 rounded-lg bg-transparent px-1 py-1 text-[11px]",children:[e.jsx("span",{className:"agent-progress-terminal-spinner h-4 w-4 shrink-0","aria-hidden":"true"}),e.jsx("div",{className:"agent-progress-sweep-text min-w-0 leading-5",children:t})]})}function Qc({hasVisibleTranscriptEvents:t,hasTranscriptProgress:s,inputCollapsed:n}){return{collapsedButtonRunning:s&&t&&n,showDockedProgress:s&&t&&!n,showInlineProgress:s&&!t}}const Pt="72f988bf-86f1-41af-91ab-2d7cd011db47",io=`${Pt} (MSIT)`;function Yc({open:t,onOpenChange:s,onShare:n,onStopShare:r,sharing:a,stopping:i=!1,shareResult:l}){return e.jsx(yt,{open:t,onOpenChange:s,children:e.jsxs(jt,{className:"max-w-md rounded-sm p-4",children:[e.jsx(Ot,{className:"sr-only",children:"Share conversation"}),e.jsx(Jc,{onOpenChange:s,onShare:n,onStopShare:r,sharing:a,stopping:i,shareResult:l})]})})}function Jc({onOpenChange:t,onShare:s,onStopShare:n,sharing:r,stopping:a=!1,shareResult:i}){const[l,d]=o.useState(i?.tenant??Pt),[c,m]=o.useState(i?.scope??"chat"),g=i?.url?Ma(i.url):null,f=r||a;return o.useEffect(()=>{d(i?.tenant??Pt),m(i?.scope??"chat")},[i?.shareId,i?.tenant,i?.scope]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h2",{className:"text-sm font-semibold leading-none tracking-tight",children:"Share conversation"}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"Create a tenant-gated link for this task."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(Zc,{value:l,onChange:d,disabled:f}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:"Access"}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(jr,{active:c==="chat",title:"Chat only",description:"Conversation transcript and opening prompt.",onClick:()=>m("chat")}),e.jsx(jr,{active:c==="filesPreview",title:"Chat, files and preview",description:"Transcript plus task output files and HTML preview.",onClick:()=>m("filesPreview")})]})]}),g&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:"Shared link"}),e.jsxs("div",{className:"flex items-center gap-2 rounded-sm border border-border/70 bg-muted/30 px-3 py-2",children:[e.jsx("input",{readOnly:!0,value:g,className:"min-w-0 flex-1 bg-transparent font-mono text-xs text-foreground outline-none","aria-label":"Shared link"}),e.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-sm text-muted-foreground",onClick:()=>{Ft(g,"Shared link copied")},"aria-label":"Copy shared link",title:"Copy shared link",children:e.jsx(Pa,{className:"h-3.5 w-3.5"})})]})]})]}),e.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e.jsx(ee,{variant:"outline",onClick:()=>t(!1),disabled:f,className:"h-8 text-xs",children:i?"Done":"Cancel"}),i&&n&&e.jsxs(ee,{variant:"outline",onClick:()=>{n()},disabled:f,className:"h-8 border-destructive/30 text-xs text-destructive hover:bg-destructive/10 hover:text-destructive",children:[a&&e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}),"Stop share"]}),e.jsxs(ee,{onClick:()=>{s({tenant:l,scope:c})},disabled:f,className:"h-8 text-xs",children:[r&&e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}),i?"Update link":"Share link"]})]})]})}function Zc({value:t,onChange:s,disabled:n}){const[r,a]=o.useState(!1),[i,l]=o.useState(!1),[d,c]=o.useState(t),m=o.useRef(null);o.useEffect(()=>{c(t)},[t]),o.useEffect(()=>{if(!r)return;const f=p=>{const N=p.target;N instanceof Node&&(m.current?.contains(N)||(a(!1),l(!1)))},u=p=>{p.key==="Escape"&&(a(!1),l(!1))};return document.addEventListener("mousedown",f),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",u)}},[r]);const g=f=>{const u=f.trim();u&&(s(u),c(u),l(!1),a(!1))};return e.jsxs("div",{className:"space-y-2 text-xs",ref:m,children:[e.jsx("div",{className:"font-medium text-foreground",children:"Tenant"}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>!n&&a(f=>!f),disabled:n,className:"flex h-9 w-full items-center justify-between gap-2 rounded-sm border border-border/70 bg-background/70 px-3 text-left text-xs text-foreground shadow-sm outline-none transition-colors hover:bg-background disabled:opacity-50",children:[e.jsx("span",{className:"min-w-0 truncate font-mono",children:Xc(t)}),e.jsx(Qe,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})]}),r&&e.jsxs("div",{className:"absolute left-0 right-0 z-50 mt-2 overflow-hidden rounded-sm border border-border/60 bg-background/95 text-xs shadow-[0_16px_48px_-34px_rgba(0,0,0,0.45)] backdrop-blur",children:[e.jsxs("button",{type:"button",onClick:()=>g(Pt),className:"flex w-full items-center justify-between gap-2 px-3 py-2 text-left hover:bg-background/60",children:[e.jsx("span",{className:"min-w-0 truncate font-mono text-[11px]",children:io}),t===Pt&&e.jsx(os,{className:"h-3.5 w-3.5 shrink-0 text-primary"})]}),e.jsx("div",{className:"border-t border-border/60 bg-background/40 px-2.5 py-1.5",children:i?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{value:d,onChange:f=>c(f.target.value),onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),g(d))},autoFocus:!0,placeholder:"Tenant ID",className:"h-7 min-w-0 flex-1 rounded-sm border border-border/60 bg-background/70 px-2 font-mono text-[11px] outline-none focus:ring-2 focus:ring-ring"}),e.jsx("button",{type:"button",onClick:()=>g(d),className:"flex h-7 w-7 items-center justify-center rounded-sm hover:bg-background/60",children:e.jsx(os,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{c(t),l(!1)},className:"flex h-7 w-7 items-center justify-center rounded-sm text-muted-foreground hover:bg-background/60 hover:text-foreground",children:e.jsx(nt,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>l(!0),className:"flex h-7 w-full items-center justify-between rounded-sm px-1.5 text-[11px] text-muted-foreground hover:bg-background/60 hover:text-foreground",children:[e.jsx("span",{children:"Manual tenant ID"}),e.jsx(zt,{className:"h-3 w-3"})]})})]})]})]})}function Xc(t){return t===Pt?io:t}function jr({active:t,title:s,description:n,onClick:r}){return e.jsxs("button",{type:"button",onClick:r,className:t?"rounded-sm border border-primary/45 bg-primary/10 px-3 py-2 text-left shadow-sm":"rounded-sm border border-border/70 bg-background px-3 py-2 text-left shadow-sm hover:bg-muted/50",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:s}),e.jsx("div",{className:"mt-1 text-[11px] leading-4 text-muted-foreground",children:n})]})}function eu(t){const s=t.map(n=>n.type==="text"?n.text:n.type==="image"?n.filename?`Image: ${n.filename}`:"Image attachment":n.isError?`Tool result error: ${n.content}`:`Tool result: ${n.content}`).join(" ").replace(/\s+/g," ").trim();return s?s.length>160?`${s.slice(0,157)}...`:s:"Queued follow-up"}function tu({messages:t,onCancelMessage:s}){return t.length===0?null:e.jsx("div",{className:"border-t border-border/55 bg-card/30 px-3 py-2 sm:px-5",children:e.jsxs("div",{className:"mx-auto max-w-[72rem] rounded-sm border border-border/65 bg-background/58 px-3 py-2 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium text-foreground",children:[e.jsx(Rd,{className:"h-3.5 w-3.5 text-primary"}),"Queued messages",e.jsx("span",{className:"ml-auto rounded-sm border border-border/60 bg-muted/60 px-1.5 py-0 text-[10px] text-muted-foreground",children:t.length})]}),e.jsx("div",{className:"mt-2 space-y-1.5",children:t.map((n,r)=>{const a=n.content.filter(i=>i.type==="image");return e.jsxs("div",{className:"flex min-w-0 items-start gap-2 text-[11px] leading-5 text-muted-foreground",children:[e.jsx("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-sm bg-primary/10 text-[10px] font-medium text-primary",children:r+1}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"break-words [overflow-wrap:anywhere]",children:eu(n.content)}),a.length>0&&e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:a.map((i,l)=>e.jsx(Va,{image:i,alt:i.filename??`queued attachment ${l+1}`,thumbnailClassName:"h-14 w-14 border border-border/65",imageClassName:"h-full w-full"},`${i.filename??"image"}-${l}`))})]}),s&&e.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 shrink-0 rounded-sm text-muted-foreground hover:text-destructive",title:"Cancel queued message","aria-label":"Cancel queued message",onClick:()=>s(n.id),children:e.jsx(nt,{className:"h-3 w-3"})})]},n.id)})})]})})}const su="h-6 w-6 rounded-none border-b border-transparent !bg-transparent p-0 text-muted-foreground !shadow-none hover:text-foreground data-[state=active]:border-primary data-[state=active]:!bg-transparent data-[state=active]:text-primary data-[state=active]:!shadow-none",nu=[{value:"transcript",label:"Transcript",icon:Ai},{value:"files",label:"Files",icon:Bt,activeIcon:_s},{value:"diff",label:"Diff",icon:Ns},{value:"preview",label:"Preview",icon:ad}];function ru({activeTab:t}){return e.jsx(Ln,{className:"h-auto max-w-full justify-start gap-2 overflow-x-auto rounded-sm !bg-muted/40 !p-0.5 !shadow-none",children:nu.map(s=>{const n=s.value===t&&s.activeIcon?s.activeIcon:s.icon;return e.jsx(vt,{value:s.value,title:s.label,"aria-label":s.label,className:su,children:e.jsx(n,{className:"h-3.5 w-3.5","aria-hidden":"true"})},s.value)})})}const Nr="h-[1.625rem] rounded-sm !border-0 !bg-transparent px-2 text-[10.5px] font-medium text-primary !shadow-none hover:!bg-transparent hover:text-primary/80 focus-visible:ring-1 focus-visible:ring-ring/50 focus-visible:ring-offset-0",bt={content:"max-w-[20rem] gap-2.5 rounded-lg border-0 p-3.5 shadow-[0_18px_70px_-44px_rgba(0,0,0,0.72)] sm:max-w-[20rem]",header:"space-y-1 text-left",title:"text-[13px] leading-4",description:"text-[11px] leading-4",footer:"gap-1 pt-0 sm:space-x-1",cancel:`${Nr} mt-0`,action:Nr},au=30,ou=1600;function iu({savedScrollTop:t,scrollHeight:s,clientHeight:n}){const r=Math.max(0,s-n);return Math.min(Math.max(0,t??r),r)}function Ks(t){return t.scrollHeight-t.scrollTop-t.clientHeight<au}function kr({explicitBottomStickUntil:t,now:s,wasAtBottom:n}){return n||t>s}function Gs(t,s){return!!(s&&(t===s||t.contains(s)))}function Ws(t){const s=t.ownerDocument.getSelection();if(!s||s.isCollapsed||s.rangeCount===0)return!1;if(Gs(t,s.anchorNode)||Gs(t,s.focusNode))return!0;for(let n=0;n<s.rangeCount;n+=1)if(Gs(t,s.getRangeAt(n).commonAncestorContainer))return!0;return!1}function lu({atTop:t,inputCollapseDisabled:s,scrollingUp:n}){return!s&&(n||t)}function du({activeTab:t,activeTaskId:s,contentVersion:n,inputCollapseDisabled:r=!1,setActiveTab:a,setInputCollapsed:i}){const l=o.useRef(null),d=o.useRef(s),c=o.useRef(!1),m=o.useRef(0),g=o.useRef(new Map),f=o.useRef(0),u=o.useRef(!0),p=o.useCallback((x=d.current)=>{const b=l.current;!b||!x||(g.current.set(x,b.scrollTop),m.current=b.scrollTop,u.current=Ks(b))},[]),N=o.useCallback((x=d.current)=>{const b=l.current;!b||!x||(b.scrollTop=iu({savedScrollTop:g.current.get(x),scrollHeight:b.scrollHeight,clientHeight:b.clientHeight}),m.current=b.scrollTop,u.current=Ks(b))},[]),y=o.useCallback((x,b=d.current)=>{x.scrollTop=x.scrollHeight,m.current=x.scrollTop,u.current=!0,b&&g.current.set(b,x.scrollTop)},[]),D=o.useCallback((x=d.current)=>{const b=l.current;f.current=Date.now()+ou,b&&(y(b,x),requestAnimationFrame(()=>{y(b,x),requestAnimationFrame(()=>y(b,x))}))},[y]),h=o.useCallback(x=>{const b=x.currentTarget,S=m.current,T=b.scrollTop<S&&S-b.scrollTop>10,C=b.scrollTop<=0,I=Ws(b);if(p(),I){f.current=0;return}if(!c.current){if(Ks(b)){i(!1),c.current=!0,setTimeout(()=>{c.current=!1},300);return}(T||C)&&(f.current=0,lu({atTop:C,inputCollapseDisabled:r,scrollingUp:T})&&i(!0))}},[r,p,i]),E=o.useCallback(x=>{t==="transcript"&&p(),a(x),x==="transcript"&&requestAnimationFrame(()=>N())},[t,N,p,a]);return o.useLayoutEffect(()=>{r&&i(!1)},[r,i]),o.useLayoutEffect(()=>{const x=d.current;x&&x!==s&&p(x),d.current=s,t==="transcript"&&requestAnimationFrame(()=>N(s))},[s,t,N,p]),o.useLayoutEffect(()=>{const x=l.current;if(!x||t!=="transcript"||!s)return;const b=kr({explicitBottomStickUntil:f.current,now:Date.now(),wasAtBottom:u.current});if(Ws(x)){f.current=0,p(s);return}b&&y(x,s),p(s)},[s,t,n,p,y]),o.useLayoutEffect(()=>{const x=l.current,b=x?.firstElementChild;if(!x||!b||t!=="transcript"||typeof ResizeObserver>"u")return;const S=new ResizeObserver(()=>{if(Ws(x)){f.current=0,p();return}kr({explicitBottomStickUntil:f.current,now:Date.now(),wasAtBottom:u.current})?y(x):p()});return S.observe(x),S.observe(b),()=>S.disconnect()},[t,s,p,y]),{handleTranscriptScroll:h,handleTranscriptTabChange:E,scrollTranscriptToBottom:D,transcriptScrollRef:l}}function lo(t=700){const[s,n]=o.useState(!1),r=o.useRef(null),a=o.useCallback(()=>{n(!0),r.current!==null&&clearTimeout(r.current),r.current=setTimeout(()=>{n(!1),r.current=null},t)},[t]);return o.useEffect(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]),{markScrollbarActive:a,scrollbarActive:s}}const Hn="pointer-events-auto h-5 w-5 shrink-0 rounded-full bg-muted/65 text-muted-foreground hover:bg-muted hover:text-foreground",It="h-3.5 w-3.5",cu=o.lazy(async()=>({default:(await On(()=>import("./FilesTab-CHjCfHQI.js"),__vite__mapDeps([0,1,2,3,4,5]))).FilesTab})),uu=o.lazy(async()=>({default:(await On(()=>import("./PreviewTab-B8thlxN1.js").then(s=>s.c),__vite__mapDeps([6,1,2]))).PreviewTab})),mu=o.lazy(async()=>({default:(await On(()=>import("./DiffTab-CHGam55q.js"),__vite__mapDeps([7,1,2,5,4,3,6]))).DiffTab}));function hu({onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:a,cluster:i,sseConnected:l,activeTab:d,setActiveTab:c,creatingTask:m,createMode:g,createDefaults:f,activeTask:u,assignedNode:p,taskLoading:N,transcriptLoading:y,taskError:D,displayEvents:h,initialPromptAlreadyInLogs:E,initialPrompt:x,supportsFollowUp:b,taskUnavailable:S,chatDisabled:T,chatDisabledReason:C,questionBypassEnabled:I,isRunning:k,isStarting:P,hasPendingFollowUp:M,canCancel:A,canRetry:B,onRetry:R,onCancel:H,onReloadNativeTranscript:Z,onShareTask:te,onStopShareTask:F,onStartCreateTask:X,onCancelCreateTask:$,onCreateTask:Y,onSendMessage:w,onCancelQueuedMessage:V,onQuestionBypassChange:j,onSubmitQuestionResponse:q,quickChats:z=[]}){const[W,L]=o.useState(!1),[ae,oe]=o.useState(!1),[he,ne]=o.useState(!1),[Q,J]=o.useState(!1),[le,_]=o.useState(!1),[G,ue]=o.useState({}),[ye,Ie]=o.useState(new Set),[Be,pt]=o.useState(new Set),[Ye,$e]=o.useState(null),Te=u?.effectiveProjectPath??u?.project??"default workspace",dt=u?p?.name??Nn(u.assignedTo,i?.nodes,u.assignedNodeName):"unassigned",re=u?.assignedTo?e.jsxs(e.Fragment,{children:["Connecting session on node ",e.jsx("span",{className:"font-semibold",children:dt}),"..."]}):"Connecting session to an available node...",ge=u?[{label:"Working dir",value:Te,mono:!0},...u.branch?[{label:"Branch",value:u.branch,mono:!0}]:[],{label:"Agent",value:u.agent,mono:!0},{label:"Node",value:dt}]:[],ve=!!(x&&!E),qe=ve||h.length>0,ct=k&&qe,je=(P||M||k)&&!ct,Je=ct?"The agent is still working on this conversation.":je?re:null,{collapsedButtonRunning:ut,showDockedProgress:St,showInlineProgress:Oe}=Qc({hasTranscriptProgress:!!Je,hasVisibleTranscriptEvents:qe,inputCollapsed:W}),rt=u?.conversationKind==="nativeSession",Ce=y?"Loading transcript":rt?"No transcript imported":"Transcript is warming up",$t=y?"Loading transcript...":rt?"Meshy could not find imported history for this native session yet.":"The opening prompt has been stored, but the agent has not emitted conversation output yet.",Ct=u?.queuedMessages??[],K=o.useMemo(()=>Yl(h),[h]),Ee=o.useMemo(()=>Jl("transcript",K.map(ce=>ce.event)),[K]),Ae=u&&!ye.has(u.id)?G[u.id]??u.activeShare??null:null,at=u?.id??null,qt=`${at??"none"}:${h.length}:${Ct.length}:${ve?1:0}:${y?1:0}:${Oe?1:0}`,{handleTranscriptScroll:Tt,handleTranscriptTabChange:De,scrollTranscriptToBottom:Ve,transcriptScrollRef:Et}=du({activeTab:d,activeTaskId:at,contentVersion:qt,inputCollapseDisabled:!!Je,setActiveTab:c,setInputCollapsed:L}),{markScrollbarActive:mt,scrollbarActive:ot}=lo(),At=o.useCallback(ce=>{mt(),Tt(ce)},[Tt,mt]),gt=o.useCallback(ce=>{$e(Me=>({path:ce,requestId:(Me?.requestId??0)+1})),De("files")},[De]),_e=o.useCallback(ce=>{Ve(),w(ce)},[w,Ve]);return o.useEffect(()=>{$e(null)},[at]),m?e.jsx(fu,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:a,cluster:i,sseConnected:l,defaultMode:g,createDefaults:f,onCancel:$,onCreated:Y,quickChats:z}):!u&&N?e.jsxs("div",{className:"dashboard-conversation-panel dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsx("div",{className:"dashboard-conversation-panel__header shrink-0 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(Mn,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:a,cluster:i,sseConnected:l})}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-4 py-6 sm:px-6",children:e.jsxs("div",{className:"space-y-3 text-center",children:[e.jsx("div",{className:"mx-auto flex h-10 w-10 items-center justify-center rounded-sm border border-primary/20 bg-primary/10 text-primary shadow-none",children:e.jsx(me,{className:"h-5 w-5 animate-spin"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:"Loading conversation"}),e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[11px] text-muted-foreground",children:[e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}),"Fetching the selected chat thread..."]})]})]})})]}):u?e.jsxs(Bn,{value:d,onValueChange:De,className:"dashboard-conversation-panel dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsxs("div",{className:"dashboard-conversation-panel__header relative shrink-0 bg-card/28 px-3 pb-0.5 pt-1 sm:px-5 sm:pt-1.5",children:[e.jsxs("div",{className:"pointer-events-none absolute left-1 right-1 top-2 flex items-center justify-between sm:left-1.5 sm:right-1.5 sm:top-2.5",children:[e.jsx(co,{desktopTasksOpen:s,mobileTasksPanelOpen:n,onToggleTasks:t,className:"lg:hidden"}),e.jsx(ee,{variant:"ghost",size:"icon",onClick:a,title:r?"Hide cluster":"Show cluster","aria-label":r?"Hide cluster":"Show cluster",className:O(Hn,"xl:hidden"),children:r?e.jsx(Ke,{className:It}):e.jsx(ds,{className:It})})]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 pl-5 sm:pl-6 lg:pl-0",children:[e.jsx("h2",{className:"min-w-0 truncate text-[13px] font-semibold leading-5 text-foreground sm:text-[15px]",title:u.title,children:u.title}),e.jsx(Ia,{status:u.status,isNative:rt}),u.priority!=="normal"&&e.jsx(_i,{priority:u.priority})]}),D&&e.jsx("div",{className:"mt-2 w-fit rounded-sm border border-destructive/25 bg-destructive/10 px-2 py-1 text-[11px] text-destructive",children:D}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 pl-5 sm:pl-6 lg:pl-0",children:[e.jsx(ru,{activeTab:d}),S&&e.jsx(Ue,{variant:"outline",className:"hidden rounded-sm border-destructive/25 bg-destructive/10 text-destructive sm:inline-flex",children:"Unavailable"}),e.jsxs("div",{className:"ml-auto flex items-center gap-1 text-[10px] text-muted-foreground",children:[e.jsx("span",{className:"hidden rounded-sm bg-muted/65 px-1.5 py-0.5 tabular-nums sm:inline-flex",children:Mi(u.updatedAt)}),B&&e.jsxs(ee,{variant:"ghost",size:"sm",onClick:R,"aria-label":"Retry task",title:"Retry task",className:"h-7 shrink-0 rounded-sm border-0 bg-primary/10 px-2 text-[10px] text-primary shadow-none hover:bg-primary/15 hover:text-primary",children:[e.jsx($d,{className:"h-3.5 w-3.5"}),"Retry"]}),rt&&Z&&e.jsx(ee,{variant:"ghost",size:"icon",onClick:Z,disabled:y,title:"Reload native session transcript","aria-label":"Reload native session transcript",className:"h-6 w-6 shrink-0 rounded-sm text-muted-foreground hover:bg-muted/55 hover:text-foreground",children:e.jsx(Qa,{className:O("h-3.5 w-3.5",y&&"animate-spin")})}),e.jsx(ee,{type:"button",variant:"ghost",size:"icon",disabled:S,title:S?"Unavailable tasks cannot be shared.":"Share conversation","aria-label":S?"Unavailable tasks cannot be shared.":"Share conversation",className:"h-6 w-6 shrink-0 rounded-sm text-primary hover:bg-primary/10 hover:text-primary disabled:bg-transparent disabled:text-muted-foreground",onClick:()=>ne(!0),children:e.jsx(Ss,{className:"h-3.5 w-3.5"})})]})]})]}),e.jsx(lt,{value:"transcript",className:"mt-0 min-h-0 flex-1",children:e.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[e.jsx("div",{className:"relative min-h-0 flex-1",children:e.jsx("div",{ref:Et,"data-transcript-scroll":"true",className:O("scrollbar-line h-full min-h-0 touch-pan-y overflow-x-hidden overflow-y-auto overscroll-x-none bg-gradient-to-b from-background/15 via-transparent to-background/35 px-3 pb-4 pt-4 sm:px-5",ot&&"scrollbar-line-active"),onScroll:At,children:e.jsxs("div",{"data-transcript-scroll-content":"true",className:"mx-auto flex max-w-[72rem] flex-col gap-4",children:[ve&&x&&e.jsx(hr,{event:x,agent:u.agent,taskRootPath:u.effectiveProjectPath,onOpenFilePath:gt,questionBypassEnabled:I,onQuestionBypassChange:j,onSubmitQuestionResponse:q,questionResponseDisabled:!b||T}),K.map(({event:ce,subItems:Me},Re)=>e.jsx(hr,{event:ce,agent:u.agent,subItems:Me,taskRootPath:u.effectiveProjectPath,onOpenFilePath:gt,questionBypassEnabled:I,onQuestionBypassChange:j,onSubmitQuestionResponse:q,questionResponseDisabled:!b||T},Ee[Re])),!qe&&!je&&e.jsxs("div",{className:"rounded-sm border border-dashed border-border/70 bg-background/35 px-3 py-4 text-center",children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground",children:Ce}),e.jsx("div",{className:"mt-2 text-[11px] leading-6 text-muted-foreground",children:$t})]}),(!b&&u.result||u.error)&&e.jsxs("div",{className:"space-y-3",children:[!b&&u.result&&e.jsxs("div",{className:"rounded-sm border border-border/70 bg-card/80 px-3 py-3",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:"Stored result"}),e.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-[11px] leading-5 text-muted-foreground",children:JSON.stringify(u.result,null,2)})]}),u.error&&!Be.has(u.id)&&e.jsxs("div",{className:"rounded-sm border border-destructive/20 bg-destructive/10 px-3 py-3 text-destructive",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em]",children:"Stored error"}),e.jsx("button",{onClick:()=>pt(ce=>new Set(ce).add(u.id)),className:"rounded p-0.5 hover:bg-destructive/20","aria-label":"Dismiss error",children:e.jsx(nt,{className:"h-3.5 w-3.5"})})]}),e.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-[11px] leading-5",children:u.error})]})]}),Oe&&Je&&e.jsx(yr,{children:Je})]})})}),St&&Je&&e.jsx("div",{"data-docked-progress":"true",className:"shrink-0 bg-background/35 px-3 py-1 sm:px-5",children:e.jsx("div",{className:"mx-auto max-w-[72rem]",children:e.jsx(yr,{children:Je})})}),b?e.jsxs(e.Fragment,{children:[W&&e.jsx(Wc,{running:ut,onClick:()=>{L(!1),Ve(),requestAnimationFrame(()=>document.querySelector('[data-chat-input-textarea="true"]')?.focus())}}),e.jsxs("div",{className:`shrink-0 ${W?"hidden":""}`,children:[e.jsx(tu,{messages:Ct,onCancelMessage:V}),e.jsx(gc,{onSend:_e,disabled:T,disabledReason:C,contextItems:ge,placeholder:T?C:k?"Queue a message for the next turn...":"Continue the conversation...",running:k||M,onStop:A?()=>oe(!0):void 0,quickChats:z})]})]}):e.jsx("div",{className:"shrink-0 border-t border-border/60 px-3 py-3 text-[11px] text-muted-foreground sm:px-5",children:"This task does not expose follow-up chat messages. Use Files, Preview, or Diff to inspect the result."})]})}),e.jsx(lt,{value:"files",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx(Vs,{label:"Loading files..."}),children:e.jsx(cu,{taskId:u.id,requestedFilePath:Ye?.path??null,requestedFileRequestId:Ye?.requestId??0})})}),e.jsx(lt,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx(Vs,{label:"Loading preview..."}),children:e.jsx(uu,{taskId:u.id})})}),e.jsx(lt,{value:"diff",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx(Vs,{label:"Loading diff..."}),children:e.jsx(mu,{taskId:u.id})})}),e.jsx(Jt,{open:ae,onOpenChange:oe,children:e.jsxs(Zt,{className:bt.content,children:[e.jsxs(Xt,{className:bt.header,children:[e.jsx(es,{className:bt.title,children:"Stop this task?"}),e.jsx(ts,{className:bt.description,children:"The task will stop and move to a cancelled state."})]}),e.jsxs(ss,{className:bt.footer,children:[e.jsx(ns,{className:bt.cancel,children:"Keep running"}),e.jsx(rs,{className:bt.action,onClick:H,children:"Stop task"})]})]})}),e.jsx(Yc,{open:he,onOpenChange:ne,sharing:Q,stopping:le,shareResult:Ae,onShare:async ce=>{if(!u)return null;J(!0);try{const Me=await te(ce);return Me?.url&&(ue(Re=>({...Re,[u.id]:Me})),Ie(Re=>{const Fe=new Set(Re);return Fe.delete(u.id),Fe})),Me}finally{J(!1)}},onStopShare:async()=>{if(!u)return!1;_(!0);try{const ce=await F();return ce!==!1&&(ue(Me=>{const Re={...Me};return delete Re[u.id],Re}),Ie(Me=>new Set(Me).add(u.id))),ce}finally{_(!1)}}})]}):e.jsxs("div",{className:"dashboard-conversation-panel dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsx("div",{className:"dashboard-conversation-panel__header shrink-0 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(Mn,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:a,cluster:i,sseConnected:l})}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-4 py-6 sm:px-6",children:e.jsxs("div",{className:"w-full max-w-lg text-center",children:[e.jsx("div",{className:"mx-auto flex h-10 w-10 items-center justify-center rounded-sm border border-primary/20 bg-primary/10 text-primary shadow-none",children:e.jsx(Di,{className:"h-5 w-5"})}),e.jsx("h2",{className:"mt-3 text-sm font-semibold tracking-tight text-foreground sm:text-[15px]",children:"No chat selected"}),e.jsx("p",{className:"mx-auto mt-2 max-w-md text-[11px] leading-5 text-muted-foreground",children:"Open a task from the left sidebar to continue the conversation, or start a new task or load a native session."}),e.jsxs(ee,{onClick:()=>X(),className:"mt-4 h-8 rounded-sm px-3",children:[e.jsx(Ms,{className:"h-3.5 w-3.5"}),"Start or load chat"]}),D&&e.jsx("div",{className:"mx-auto mt-3 max-w-md rounded-sm border border-destructive/20 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:D})]})})]})}function fu({onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:a,cluster:i,sseConnected:l,defaultMode:d,createDefaults:c,onCancel:m,onCreated:g,quickChats:f}){const[u,p]=o.useState(d??"chat");o.useEffect(()=>{d&&p(d)},[d]);const N=e.jsx("div",{className:"flex h-8 items-center gap-0.5 overflow-hidden rounded-sm border border-border/60 bg-background/65 p-0.5 text-[11px] font-medium shadow-none",children:[{value:"chat",label:"New chat",icon:Ms},{value:"native",label:"Load session",icon:$n}].map(y=>{const D=y.icon,h=y.value===u;return e.jsxs("button",{type:"button",onClick:()=>p(y.value),"aria-pressed":h,className:O("flex h-7 min-w-28 items-center justify-center gap-1.5 rounded-sm border border-transparent px-2.5 transition-colors duration-150",h?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-background/80 hover:text-foreground"),children:[e.jsx(D,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:y.label})]},y.value)})});return e.jsxs("div",{className:"dashboard-conversation-panel dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsx("div",{className:"dashboard-conversation-panel__header shrink-0 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(Mn,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:a,cluster:i,sseConnected:l,centerSlot:N})}),e.jsx("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center overflow-y-auto px-4 py-6 sm:px-6",children:e.jsx("div",{className:"w-full max-w-2xl",children:e.jsx(Gc,{nodes:i?.nodes??[],currentNodeRole:i?.self?.role,currentNodeId:i?.self?.id??null,leaderNodeId:i?.leader?.id??null,initialAssignTo:c?.assignTo,initialProject:c?.project,mode:u,onModeChange:p,onCreated:g,onCancel:m,autoFocus:!0,layout:"composer",quickChats:f})})})]})}function Mn({onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:a,centerSlot:i}){return e.jsxs("div",{className:"relative flex w-full items-center justify-between gap-1.5",children:[e.jsx("div",{className:"flex min-w-0 items-center gap-1.5",children:e.jsx(co,{desktopTasksOpen:s,mobileTasksPanelOpen:n,onToggleTasks:t,className:"lg:hidden"})}),i&&e.jsx("div",{className:"pointer-events-none absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",children:e.jsx("div",{className:"pointer-events-auto",children:i})}),e.jsx(ee,{variant:"ghost",size:"icon",onClick:a,title:r?"Hide cluster":"Show cluster","aria-label":r?"Hide cluster":"Show cluster",className:O(Hn,"xl:hidden"),children:r?e.jsx(Ke,{className:It}):e.jsx(ds,{className:It})})]})}function co({className:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,onToggleTasks:r}){const a=globalThis.window?.matchMedia("(min-width: 1024px)")?.matches?s:n;return e.jsx(ee,{variant:"ghost",size:"icon",onClick:r,title:a?"Hide tasks":"Show tasks","aria-label":a?"Hide tasks":"Show tasks",className:O(Hn,t),children:a?e.jsx(ds,{className:It}):e.jsx(Ke,{className:It})})}function xu({onAdded:t}){const[s,n]=o.useState(""),[r,a]=o.useState(!1),[i,l]=o.useState(null),d=o.useCallback(async c=>{if(c.preventDefault(),!!s.trim()){a(!0),l(null);try{await Pi({leaderEndpoint:s.trim(),transport:"devtunnel"}),t()}catch(m){l(m instanceof Error?m.message:"Failed to join node")}finally{a(!1)}}},[s,t]);return e.jsx(jt,{className:"overflow-hidden border-border/60 bg-transparent p-0 shadow-none sm:max-w-xl",children:e.jsxs("div",{className:"overflow-hidden rounded-sm border border-border/60 bg-background/95 p-0 shadow-[0_28px_90px_-58px_rgba(0,0,0,0.88)] backdrop-blur-xl",children:[e.jsx("div",{className:"border-b border-border/60 px-3.5 py-2.5",children:e.jsxs(Ts,{className:"space-y-1 text-left",children:[e.jsx(Ot,{className:"text-sm tracking-tight",children:"Join node"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Verify the remote leader's DevTunnel endpoint, sync this node's tasks to that leader, and join the cluster as a follower."})]})}),e.jsxs("form",{onSubmit:d,className:"space-y-3 px-3.5 py-3",children:[i&&e.jsx("div",{className:"rounded-sm border border-destructive/20 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:i}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(ze,{htmlFor:"leader-endpoint",children:"Leader endpoint"}),e.jsx(Ue,{variant:"outline",className:"rounded-sm border-border/70 bg-background/60 text-[10px] uppercase tracking-[0.16em]",children:"DevTunnel only"})]}),e.jsx(st,{id:"leader-endpoint",type:"url",value:s,onChange:c=>n(c.target.value),placeholder:"https://your-leader.devtunnels.ms",className:"h-8 rounded-sm border-border/70 bg-background/70"})]}),e.jsx("div",{className:"rounded-sm border border-border/60 bg-background/45 px-3 py-2 text-[11px] text-muted-foreground",children:"This does not switch the local node transport or auto-enable a local DevTunnel. Leaving later will detach this node from the remote leader and make it leader of its own cluster again."}),e.jsx(Ra,{className:"border-t border-border/60 pt-3",children:e.jsx(ee,{type:"submit",disabled:!s.trim()||r,className:"rounded-sm",children:r?"Joining...":"Join node"})})]})]})})}function pu({open:t,onOpenChange:s,onAdded:n}){return e.jsx(yt,{open:t,onOpenChange:s,children:e.jsx(xu,{onAdded:()=>{s(!1),n()}})})}const gu="absolute top-1/2 z-30 hidden h-10 w-4 -translate-y-1/2 items-center justify-center rounded-full text-muted-foreground opacity-0 outline-none transition-opacity duration-150 hover:opacity-100 focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/55",bu="flex h-7 w-3.5 items-center justify-center rounded-full bg-muted/85 shadow-[0_12px_24px_-20px_rgba(0,0,0,0.9)] backdrop-blur-sm transition-colors hover:bg-card hover:text-foreground",vu="h-2.5 w-2.5";function uo({className:t,label:s,orientation:n,panel:r,panelResize:a}){return e.jsx("button",{type:"button","aria-label":s,"aria-orientation":n,"data-dashboard-resize-handle":r,onPointerDown:i=>a.onPointerDown(r,i),onWheel:i=>a.onWheel(r,i),className:O("group absolute z-20 hidden touch-none rounded-sm bg-transparent outline-none transition-colors hover:bg-primary/12 focus-visible:bg-primary/12 focus-visible:ring-2 focus-visible:ring-ring/70 lg:block",t),children:e.jsx("span",{className:"pointer-events-none absolute inset-0 opacity-0 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100"})})}function wu({className:t,label:s,onToggle:n,side:r,visible:a}){const i=r==="left"?a?ds:Ke:a?Ke:ds;return e.jsx("button",{type:"button","aria-label":s,title:s,onClick:n,className:O(gu,t),children:e.jsx("span",{className:bu,"aria-hidden":"true",children:e.jsx(i,{className:vu,strokeWidth:2.1})})})}function Sr({className:t,label:s,onToggle:n,panel:r,panelResize:a,screen:i,side:l,visible:d}){const c=i==="lg"?"lg:block":"xl:block",m=i==="lg"?"lg:flex":"xl:flex";return e.jsxs("div",{className:O("group absolute top-0 z-30 hidden h-full w-4",c,t),children:[r&&e.jsx(uo,{panel:r,orientation:"vertical",label:`Resize ${r} panel`,panelResize:a,className:"left-1/2 top-0 h-full w-2 -translate-x-1/2 cursor-col-resize"}),e.jsx(wu,{side:l,visible:d,label:s,onToggle:n,className:O(m,"left-1/2 -translate-x-1/2 group-hover:opacity-100")})]})}function yu({conversationPanel:t,desktopTasksOpen:s,mobileTaskSidebar:n,mobileTasksPanelOpen:r,mobileTasksPanelRef:a,operationsOpen:i,operationsPanelRef:l,operationsSidecar:d,panelResize:c,taskSidebar:m,terminalPanel:g,onCloseOperations:f,onCloseTaskList:u,onToggleOperations:p,onToggleTasks:N}){const y={"--dashboard-tasks-width":c.sizes.tasks,"--dashboard-operations-width":c.sizes.operations,"--dashboard-terminal-height":c.sizes.terminal};return e.jsxs("div",{className:"dashboard-workspace flex h-full min-h-0 flex-col overflow-hidden",style:y,children:[e.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[e.jsx(Sr,{screen:"lg",side:"left",visible:s,label:s?"Hide tasks":"Show tasks",onToggle:N,panel:s?"tasks":void 0,panelResize:c,className:s?"left-[var(--dashboard-tasks-width)] -translate-x-1/2":"left-0"}),e.jsx("div",{className:O("dashboard-workspace__tasks-panel relative hidden lg:block lg:shrink-0 lg:transition-all lg:duration-300",s?"lg:mr-2 lg:w-[var(--dashboard-tasks-width)]":"lg:w-0 lg:overflow-hidden"),children:s&&m}),e.jsxs("section",{className:"dashboard-workspace__primary flex min-h-0 min-w-0 flex-1 flex-col gap-2",children:[e.jsx("div",{className:"min-h-0 flex-1",children:t}),g&&e.jsxs("div",{className:"relative h-[var(--dashboard-terminal-height)] min-h-0 shrink-0",children:[e.jsx(uo,{panel:"terminal",orientation:"horizontal",label:"Resize terminal panel",panelResize:c,className:"-top-1 left-0 h-2 w-full cursor-row-resize"}),g]})]}),e.jsx(Sr,{screen:"xl",side:"right",visible:i,label:i?"Hide cluster":"Show cluster",onToggle:p,panel:i?"operations":void 0,panelResize:c,className:i?"right-[var(--dashboard-operations-width)] translate-x-1/2":"right-0"}),e.jsx("div",{className:O("dashboard-workspace__operations-panel relative hidden xl:block xl:shrink-0 xl:transition-all xl:duration-300",i?"xl:ml-2 xl:w-[var(--dashboard-operations-width)]":"xl:w-0 xl:overflow-hidden"),children:i&&d})]}),i&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close operations panel",onClick:f,className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm xl:hidden"}),e.jsx("div",{ref:l,className:"fixed bottom-0 right-0 top-[var(--dashboard-mobile-overlay-top)] z-40 w-full p-2 sm:max-w-sm sm:p-3 xl:hidden",children:d})]}),r&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close task list",onClick:u,className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm lg:hidden"}),e.jsx("div",{ref:a,className:"fixed bottom-0 left-0 top-[var(--dashboard-mobile-overlay-top)] z-40 w-full p-2 sm:max-w-sm sm:p-3 lg:hidden",children:n})]})]})}const ju=10,wt="__all__";function Ge(t){return"session"in t}function Cr(t,s){return s&&t.some(n=>n.id===s)?s:t[0]?.id??""}function Qs(t){return t&&(ro(t.id)||t.workDir)||""}function ps(t,s,n){let r=!1;const a=t.map(i=>Ge(i)&&i.session.id===n.id?(r=!0,{...i,nodeName:s,session:n}):i);return Pn(r?a:[...a,{id:`session-${n.id}`,nodeName:s,session:n}])}function mo(t,s){return t.filter(Ge).filter(n=>n.session.nodeId===s).sort((n,r)=>r.session.startedAt-n.session.startedAt)}function Nu(t){const s=t.filter(Ge).sort((n,r)=>r.session.startedAt-n.session.startedAt);return{active:s.filter(n=>n.session.status==="running"),completed:s.filter(n=>n.session.status!=="running")}}function ku(t,s){return!!(t&&s&&!t.contains(s))}function Su(t,s,n){if(n===wt)return n;const r=mo(t,s);return r.some(a=>a.session.id===n)?n:r[0]?.session.id??wt}function Cu(t,s,n){return n===wt?t.filter(r=>!Ge(r)||r.session.nodeId===s):t.filter(r=>Ge(r)&&r.session.nodeId===s&&r.session.id===n)}function Pn(t){const s=t.map((r,a)=>({entry:r,index:a})).filter(({entry:r})=>Ge(r)&&r.session.status!=="running").sort((r,a)=>!Ge(r.entry)||!Ge(a.entry)?0:a.entry.session.startedAt-r.entry.session.startedAt||a.index-r.index),n=new Set(s.slice(0,ju).map(({entry:r})=>Ge(r)?r.session.id:""));return t.filter(r=>!Ge(r)||r.session.status==="running"||n.has(r.session.id))}function In(t){return t.status==="running"?t.pid?`running pid ${t.pid}`:"running":t.status==="exited"?`exit ${t.exitCode??0}`:t.status==="stopped"?"stopped":t.signal?`failed ${t.signal}`:`exit ${t.exitCode??"failed"}`}function Tu(t){const s=t.session.command.length>48?`${t.session.command.slice(0,45)}...`:t.session.command;return`${t.nodeName} - ${In(t.session)} - ${s}`}function ho(t,s=48){return t.length>s?`${t.slice(0,s-3)}...`:t}function Eu(t,s){return s===wt?"All sessions":t?ho(t.session.command,34):"Command session"}function Tr(t){return t.status==="stopped"?"":t.stderr}function Au({nodes:t,defaultNodeId:s,onClose:n,initialHistory:r=[]}){const[a,i]=o.useState(()=>Cr(t,s)),l=o.useMemo(()=>t.find(j=>j.id===a)??t[0]??null,[t,a]),[d,c]=o.useState(()=>Qs(l)),[m,g]=o.useState(""),[f,u]=o.useState(()=>Pn(r)),[p,N]=o.useState(wt),[y,D]=o.useState(!1),[h,E]=o.useState(!1),[x,b]=o.useState(!1),[S,T]=o.useState(!1),[C,I]=o.useState(!1),k=o.useRef(null),P=o.useRef(null),M=o.useMemo(()=>t.find(j=>j.id===a)??t[0]??null,[t,a]),A=o.useMemo(()=>mo(f,M?.id??""),[f,M]),B=o.useMemo(()=>Nu(A),[A]),R=o.useMemo(()=>A.find(j=>j.session.id===p),[p,A]),H=o.useMemo(()=>Cu(f,M?.id??"",p),[f,M,p]),Z=o.useRef(M?.id??"");o.useEffect(()=>{a&&t.some(j=>j.id===a)||i(Cr(t,s))},[s,t,a]),o.useEffect(()=>{const j=M?.id??"";Z.current!==j&&(Z.current=j,c(Qs(M)))},[M]),o.useEffect(()=>{N(j=>Su(f,M?.id??"",y?j:""))},[f,M,y]),o.useEffect(()=>{k.current?.scrollTo({top:k.current.scrollHeight})},[f]),o.useEffect(()=>{let j=!1;async function q(){const z=await Promise.allSettled(t.map(async W=>({node:W,response:await Ri(W.id)})));j||u(W=>z.reduce((L,ae)=>ae.status!=="fulfilled"?L:ae.value.response.sessions.reduce((oe,he)=>ps(oe,ae.value.node.name,he),L),W))}return t.length>0&&q(),()=>{j=!0}},[t]),o.useEffect(()=>{const j=f.filter(Ge).filter(z=>z.session.status==="running");if(j.length===0)return;const q=window.setInterval(()=>{for(const z of j)Ii(z.session.nodeId,z.session.id).then(W=>u(L=>ps(L,z.nodeName,W))).catch(()=>{})},1e3);return()=>window.clearInterval(q)},[f]);const te=o.useRef(null);async function F(j){if(j.preventDefault(),!M||!m.trim()||C)return;const q=m.trim(),z=M.name;I(!0),g("");try{const W=await Bi(M.id,{command:q,...d.trim()?{cwd:d.trim()}:{}});u(L=>ps(L,z,W)),N(W.id),D(!0)}catch(W){u(L=>[...L,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,nodeName:z,command:q,error:W instanceof Error?W.message:"Command failed"}])}finally{I(!1)}}async function X(j,q){j.stopPropagation();const z=await Li(q.session.nodeId,q.session.id);u(W=>ps(W,q.nodeName,z))}function $(j){N(j),D(!0),E(!1)}function Y(j){h&&ku(P.current,j.target)&&E(!1)}function w(j,q,z,W,L){return e.jsxs("div",{className:"border-t border-border/60 py-1",children:[e.jsxs("button",{type:"button",onClick:W,"aria-label":`Toggle ${j} sessions`,"aria-expanded":!z,className:"node-terminal__small flex w-full items-center justify-between gap-2 px-2 pb-1 pt-0.5 text-left font-medium uppercase tracking-normal text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:[e.jsx("span",{children:j}),e.jsx(Qe,{className:O("h-3 w-3 transition-transform",z&&"-rotate-90")})]}),!z&&(q.length>0?q.map(V):e.jsx("div",{className:"node-terminal__control px-2 py-1 text-muted-foreground",children:L}))]})}function V(j){const q=p===j.session.id,z=j.session.status==="running";return e.jsxs("div",{className:O("node-terminal__control group flex w-full items-center gap-2 px-2 py-1.5 text-left transition-colors hover:bg-muted/65",q&&"bg-primary/10 text-primary"),children:[e.jsxs("button",{type:"button",onClick:()=>$(j.session.id),className:"flex min-w-0 flex-1 items-center gap-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:[e.jsx("span",{className:O("flex h-4 w-4 shrink-0 items-center justify-center",z?"text-primary":j.session.status==="exited"?"text-emerald-600 dark:text-emerald-300":"text-amber-600 dark:text-amber-300"),children:z?e.jsx(me,{className:"h-3 w-3 animate-spin"}):j.session.status==="exited"?e.jsx(rr,{className:"h-3 w-3"}):e.jsx($s,{className:"h-3 w-3"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-foreground",children:ho(j.session.command,44)}),e.jsxs("span",{className:"node-terminal__small block truncate text-muted-foreground",children:[j.nodeName," · ",In(j.session)]})]})]}),z&&e.jsx("button",{type:"button",onClick:W=>{X(W,j)},"aria-label":"Stop terminal session from selector",title:"Stop terminal session",className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:e.jsx(pr,{className:"h-3 w-3"})})]},j.session.id)}return e.jsx("section",{className:"dashboard-panel node-terminal animate-composer-settle flex h-full min-h-0 shrink-0 overflow-visible rounded-xl","aria-label":"Node terminal",onClick:Y,children:e.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col overflow-visible rounded-[inherit] bg-card/72 text-card-foreground",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-border/60 px-3 py-2",children:[e.jsxs("div",{className:"node-terminal__header flex min-w-0 items-center gap-2 font-medium",children:[n?e.jsx("button",{type:"button",onClick:n,"aria-label":"Close terminal",title:"Close terminal",className:"flex h-6 w-6 items-center justify-center rounded-md text-primary transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:e.jsx(nt,{className:"h-3.5 w-3.5"})}):e.jsx(nr,{className:"h-3.5 w-3.5 text-primary"}),e.jsx("span",{children:"Terminal"})]}),e.jsxs("div",{className:"ml-auto flex min-w-0 flex-wrap items-center justify-end gap-2",children:[e.jsxs("div",{ref:P,className:"relative min-w-0",children:[e.jsxs("button",{type:"button","aria-label":"Command session","aria-expanded":h,title:R?Tu(R):"All sessions",onClick:()=>E(j=>!j),className:"node-terminal__control flex h-7 max-w-[14rem] list-none items-center gap-1.5 rounded-sm border border-border/70 bg-background/70 px-2 text-foreground outline-none transition-colors hover:bg-muted/65 focus-visible:ring-2 focus-visible:ring-ring/70 [&::-webkit-details-marker]:hidden",children:[e.jsx("span",{className:"min-w-0 truncate",children:Eu(R,p)}),e.jsx(Qe,{className:O("h-3 w-3 shrink-0 text-muted-foreground transition-transform",h&&"rotate-180")})]}),e.jsx("div",{"aria-hidden":!h,className:O("absolute right-0 bottom-9 z-30 w-[19rem] overflow-hidden rounded-xl border border-border/70 bg-popover text-popover-foreground shadow-xl",!h&&"hidden"),children:e.jsxs("div",{className:"max-h-72 overflow-y-auto",children:[e.jsxs("button",{type:"button",onClick:()=>$(wt),className:O("node-terminal__control flex w-full items-center gap-2 px-2 py-1.5 text-left transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",p===wt&&"bg-primary/10 text-primary"),children:[e.jsx(nr,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:"All sessions"})]}),w("Active",B.active,x,()=>b(j=>!j),"No active sessions"),w("Completed",B.completed,S,()=>T(j=>!j),"No completed sessions")]})})]}),e.jsx("select",{value:M?.id??"",onChange:j=>{i(j.target.value),D(!1),c(Qs(t.find(q=>q.id===j.target.value)??null))},disabled:C||t.length===0,"aria-label":"Terminal node",className:"node-terminal__control h-7 max-w-[11rem] rounded-sm border border-border/70 bg-background/70 px-2 text-foreground outline-none transition-colors hover:bg-muted/65 disabled:opacity-50",children:t.map(j=>e.jsx("option",{value:j.id,className:"bg-background text-foreground",children:j.name},j.id))}),e.jsx(Cs,{value:d,onChange:c,assignTo:M?.id??"",nodes:t,assignableNodes:t,layout:"composer",chipClassName:"node-terminal__control h-7 max-w-[18rem] rounded-sm border border-border/70 bg-background/70 px-2 text-foreground hover:bg-muted/65",chipActiveClassName:"font-mono",chipInactiveClassName:"text-muted-foreground",labelClassName:"node-terminal__workdir",triggerClassName:"terminal-workdir-trigger",popoverPlacement:"top",popoverAlign:"end"})]})]}),e.jsxs("div",{ref:k,className:"node-terminal__body min-h-0 flex-1 overflow-y-auto bg-muted/22 px-3 py-2 font-mono cursor-text",onClick:()=>te.current?.focus(),children:[H.length===0?e.jsx("div",{className:"text-muted-foreground mb-2",children:"Commands run on the selected node and stay visible while running or after exit."}):e.jsx("div",{className:"space-y-3 mb-2",children:H.map(j=>Ge(j)?e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-muted-foreground",children:[e.jsxs("span",{className:"text-primary",children:[j.nodeName,"$"]}),e.jsx("span",{className:"break-all text-foreground",children:j.session.command}),e.jsxs("span",{className:O("inline-flex items-center gap-1",j.session.status==="running"||j.session.status==="exited"?"text-primary":"text-amber-600 dark:text-amber-300"),children:[j.session.status==="running"?e.jsx(me,{className:"h-3 w-3 animate-spin"}):j.session.status==="exited"?e.jsx(rr,{className:"h-3 w-3"}):e.jsx($s,{className:"h-3 w-3"}),In(j.session)]}),j.session.status==="running"&&e.jsx("button",{type:"button",onClick:q=>{X(q,j)},"aria-label":"Stop terminal session",title:"Stop terminal session",className:"inline-flex h-5 w-5 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted/65 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:e.jsx(pr,{className:"h-3 w-3"})})]}),j.session.stdout&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-foreground",children:j.session.stdout}),Tr(j.session)&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:Tr(j.session)}),(j.session.stdoutTruncated||j.session.stderrTruncated)&&e.jsx("div",{className:"text-muted-foreground",children:"Output truncated to the latest output."})]},j.id):e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-muted-foreground",children:[e.jsxs("span",{className:"text-primary",children:[j.nodeName,"$"]}),e.jsx("span",{className:"break-all text-foreground",children:j.command}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive",children:[e.jsx($s,{className:"h-3 w-3"}),"error"]})]}),e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:j.error})]},j.id))}),e.jsxs("form",{onSubmit:F,className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"shrink-0 text-primary select-none",children:M?`${M.name}$`:"$"}),e.jsx("input",{ref:te,value:m,onChange:j=>g(j.target.value),disabled:!M||C,placeholder:M?"":"No online nodes available",className:"node-terminal__input flex-1 min-w-0 bg-transparent border-none outline-none text-foreground placeholder:text-muted-foreground font-mono caret-primary disabled:opacity-50",autoComplete:"off",spellCheck:!1}),e.jsx("button",{type:"submit","aria-label":"Run",title:"Run",disabled:!M||!m.trim()||C,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md text-primary transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70 disabled:pointer-events-none disabled:text-muted-foreground disabled:opacity-50",children:C?e.jsx(me,{className:"h-3 w-3 animate-spin"}):e.jsx(Ds,{className:"h-3 w-3"})})]})]})]})})}var Mt={},Ys,Er;function Du(){return Er||(Er=1,Ys=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Ys}var Js={},ft={},Ar;function Nt(){if(Ar)return ft;Ar=1;let t;const s=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return ft.getSymbolSize=function(r){if(!r)throw new Error('"version" cannot be null or undefined');if(r<1||r>40)throw new Error('"version" should be in range from 1 to 40');return r*4+17},ft.getSymbolTotalCodewords=function(r){return s[r]},ft.getBCHDigit=function(n){let r=0;for(;n!==0;)r++,n>>>=1;return r},ft.setToSJISFunction=function(r){if(typeof r!="function")throw new Error('"toSJISFunc" is not a valid function.');t=r},ft.isKanjiModeEnabled=function(){return typeof t<"u"},ft.toSJIS=function(r){return t(r)},ft}var Zs={},Dr;function Kn(){return Dr||(Dr=1,(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function s(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+n)}}t.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},t.from=function(r,a){if(t.isValid(r))return r;try{return s(r)}catch{return a}}})(Zs)),Zs}var Xs,_r;function _u(){if(_r)return Xs;_r=1;function t(){this.buffer=[],this.length=0}return t.prototype={get:function(s){const n=Math.floor(s/8);return(this.buffer[n]>>>7-s%8&1)===1},put:function(s,n){for(let r=0;r<n;r++)this.putBit((s>>>n-r-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(s){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),s&&(this.buffer[n]|=128>>>this.length%8),this.length++}},Xs=t,Xs}var en,Mr;function Mu(){if(Mr)return en;Mr=1;function t(s){if(!s||s<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=s,this.data=new Uint8Array(s*s),this.reservedBit=new Uint8Array(s*s)}return t.prototype.set=function(s,n,r,a){const i=s*this.size+n;this.data[i]=r,a&&(this.reservedBit[i]=!0)},t.prototype.get=function(s,n){return this.data[s*this.size+n]},t.prototype.xor=function(s,n,r){this.data[s*this.size+n]^=r},t.prototype.isReserved=function(s,n){return this.reservedBit[s*this.size+n]},en=t,en}var tn={},Pr;function Pu(){return Pr||(Pr=1,(function(t){const s=Nt().getSymbolSize;t.getRowColCoords=function(r){if(r===1)return[];const a=Math.floor(r/7)+2,i=s(r),l=i===145?26:Math.ceil((i-13)/(2*a-2))*2,d=[i-7];for(let c=1;c<a-1;c++)d[c]=d[c-1]-l;return d.push(6),d.reverse()},t.getPositions=function(r){const a=[],i=t.getRowColCoords(r),l=i.length;for(let d=0;d<l;d++)for(let c=0;c<l;c++)d===0&&c===0||d===0&&c===l-1||d===l-1&&c===0||a.push([i[d],i[c]]);return a}})(tn)),tn}var sn={},Ir;function Iu(){if(Ir)return sn;Ir=1;const t=Nt().getSymbolSize,s=7;return sn.getPositions=function(r){const a=t(r);return[[0,0],[a-s,0],[0,a-s]]},sn}var nn={},Rr;function Ru(){return Rr||(Rr=1,(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const s={N1:3,N2:3,N3:40,N4:10};t.isValid=function(a){return a!=null&&a!==""&&!isNaN(a)&&a>=0&&a<=7},t.from=function(a){return t.isValid(a)?parseInt(a,10):void 0},t.getPenaltyN1=function(a){const i=a.size;let l=0,d=0,c=0,m=null,g=null;for(let f=0;f<i;f++){d=c=0,m=g=null;for(let u=0;u<i;u++){let p=a.get(f,u);p===m?d++:(d>=5&&(l+=s.N1+(d-5)),m=p,d=1),p=a.get(u,f),p===g?c++:(c>=5&&(l+=s.N1+(c-5)),g=p,c=1)}d>=5&&(l+=s.N1+(d-5)),c>=5&&(l+=s.N1+(c-5))}return l},t.getPenaltyN2=function(a){const i=a.size;let l=0;for(let d=0;d<i-1;d++)for(let c=0;c<i-1;c++){const m=a.get(d,c)+a.get(d,c+1)+a.get(d+1,c)+a.get(d+1,c+1);(m===4||m===0)&&l++}return l*s.N2},t.getPenaltyN3=function(a){const i=a.size;let l=0,d=0,c=0;for(let m=0;m<i;m++){d=c=0;for(let g=0;g<i;g++)d=d<<1&2047|a.get(m,g),g>=10&&(d===1488||d===93)&&l++,c=c<<1&2047|a.get(g,m),g>=10&&(c===1488||c===93)&&l++}return l*s.N3},t.getPenaltyN4=function(a){let i=0;const l=a.data.length;for(let c=0;c<l;c++)i+=a.data[c];return Math.abs(Math.ceil(i*100/l/5)-10)*s.N4};function n(r,a,i){switch(r){case t.Patterns.PATTERN000:return(a+i)%2===0;case t.Patterns.PATTERN001:return a%2===0;case t.Patterns.PATTERN010:return i%3===0;case t.Patterns.PATTERN011:return(a+i)%3===0;case t.Patterns.PATTERN100:return(Math.floor(a/2)+Math.floor(i/3))%2===0;case t.Patterns.PATTERN101:return a*i%2+a*i%3===0;case t.Patterns.PATTERN110:return(a*i%2+a*i%3)%2===0;case t.Patterns.PATTERN111:return(a*i%3+(a+i)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}t.applyMask=function(a,i){const l=i.size;for(let d=0;d<l;d++)for(let c=0;c<l;c++)i.isReserved(c,d)||i.xor(c,d,n(a,c,d))},t.getBestMask=function(a,i){const l=Object.keys(t.Patterns).length;let d=0,c=1/0;for(let m=0;m<l;m++){i(m),t.applyMask(m,a);const g=t.getPenaltyN1(a)+t.getPenaltyN2(a)+t.getPenaltyN3(a)+t.getPenaltyN4(a);t.applyMask(m,a),g<c&&(c=g,d=m)}return d}})(nn)),nn}var gs={},Lr;function fo(){if(Lr)return gs;Lr=1;const t=Kn(),s=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],n=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return gs.getBlocksCount=function(a,i){switch(i){case t.L:return s[(a-1)*4+0];case t.M:return s[(a-1)*4+1];case t.Q:return s[(a-1)*4+2];case t.H:return s[(a-1)*4+3];default:return}},gs.getTotalCodewordsCount=function(a,i){switch(i){case t.L:return n[(a-1)*4+0];case t.M:return n[(a-1)*4+1];case t.Q:return n[(a-1)*4+2];case t.H:return n[(a-1)*4+3];default:return}},gs}var rn={},Qt={},Br;function Lu(){if(Br)return Qt;Br=1;const t=new Uint8Array(512),s=new Uint8Array(256);return(function(){let r=1;for(let a=0;a<255;a++)t[a]=r,s[r]=a,r<<=1,r&256&&(r^=285);for(let a=255;a<512;a++)t[a]=t[a-255]})(),Qt.log=function(r){if(r<1)throw new Error("log("+r+")");return s[r]},Qt.exp=function(r){return t[r]},Qt.mul=function(r,a){return r===0||a===0?0:t[s[r]+s[a]]},Qt}var Or;function Bu(){return Or||(Or=1,(function(t){const s=Lu();t.mul=function(r,a){const i=new Uint8Array(r.length+a.length-1);for(let l=0;l<r.length;l++)for(let d=0;d<a.length;d++)i[l+d]^=s.mul(r[l],a[d]);return i},t.mod=function(r,a){let i=new Uint8Array(r);for(;i.length-a.length>=0;){const l=i[0];for(let c=0;c<a.length;c++)i[c]^=s.mul(a[c],l);let d=0;for(;d<i.length&&i[d]===0;)d++;i=i.slice(d)}return i},t.generateECPolynomial=function(r){let a=new Uint8Array([1]);for(let i=0;i<r;i++)a=t.mul(a,new Uint8Array([1,s.exp(i)]));return a}})(rn)),rn}var an,Fr;function Ou(){if(Fr)return an;Fr=1;const t=Bu();function s(n){this.genPoly=void 0,this.degree=n,this.degree&&this.initialize(this.degree)}return s.prototype.initialize=function(r){this.degree=r,this.genPoly=t.generateECPolynomial(this.degree)},s.prototype.encode=function(r){if(!this.genPoly)throw new Error("Encoder not initialized");const a=new Uint8Array(r.length+this.degree);a.set(r);const i=t.mod(a,this.genPoly),l=this.degree-i.length;if(l>0){const d=new Uint8Array(this.degree);return d.set(i,l),d}return i},an=s,an}var on={},ln={},dn={},zr;function xo(){return zr||(zr=1,dn.isValid=function(s){return!isNaN(s)&&s>=1&&s<=40}),dn}var it={},Ur;function po(){if(Ur)return it;Ur=1;const t="[0-9]+",s="[A-Z $%*+\\-./:]+";let n="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";n=n.replace(/u/g,"\\u");const r="(?:(?![A-Z0-9 $%*+\\-./:]|"+n+`)(?:.|[\r
|
|
160
|
+
]))+`;it.KANJI=new RegExp(n,"g"),it.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),it.BYTE=new RegExp(r,"g"),it.NUMERIC=new RegExp(t,"g"),it.ALPHANUMERIC=new RegExp(s,"g");const a=new RegExp("^"+n+"$"),i=new RegExp("^"+t+"$"),l=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return it.testKanji=function(c){return a.test(c)},it.testNumeric=function(c){return i.test(c)},it.testAlphanumeric=function(c){return l.test(c)},it}var $r;function kt(){return $r||($r=1,(function(t){const s=xo(),n=po();t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(i,l){if(!i.ccBits)throw new Error("Invalid mode: "+i);if(!s.isValid(l))throw new Error("Invalid version: "+l);return l>=1&&l<10?i.ccBits[0]:l<27?i.ccBits[1]:i.ccBits[2]},t.getBestModeForData=function(i){return n.testNumeric(i)?t.NUMERIC:n.testAlphanumeric(i)?t.ALPHANUMERIC:n.testKanji(i)?t.KANJI:t.BYTE},t.toString=function(i){if(i&&i.id)return i.id;throw new Error("Invalid mode")},t.isValid=function(i){return i&&i.bit&&i.ccBits};function r(a){if(typeof a!="string")throw new Error("Param is not a string");switch(a.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+a)}}t.from=function(i,l){if(t.isValid(i))return i;try{return r(i)}catch{return l}}})(ln)),ln}var qr;function Fu(){return qr||(qr=1,(function(t){const s=Nt(),n=fo(),r=Kn(),a=kt(),i=xo(),l=7973,d=s.getBCHDigit(l);function c(u,p,N){for(let y=1;y<=40;y++)if(p<=t.getCapacity(y,N,u))return y}function m(u,p){return a.getCharCountIndicator(u,p)+4}function g(u,p){let N=0;return u.forEach(function(y){const D=m(y.mode,p);N+=D+y.getBitsLength()}),N}function f(u,p){for(let N=1;N<=40;N++)if(g(u,N)<=t.getCapacity(N,p,a.MIXED))return N}t.from=function(p,N){return i.isValid(p)?parseInt(p,10):N},t.getCapacity=function(p,N,y){if(!i.isValid(p))throw new Error("Invalid QR Code version");typeof y>"u"&&(y=a.BYTE);const D=s.getSymbolTotalCodewords(p),h=n.getTotalCodewordsCount(p,N),E=(D-h)*8;if(y===a.MIXED)return E;const x=E-m(y,p);switch(y){case a.NUMERIC:return Math.floor(x/10*3);case a.ALPHANUMERIC:return Math.floor(x/11*2);case a.KANJI:return Math.floor(x/13);case a.BYTE:default:return Math.floor(x/8)}},t.getBestVersionForData=function(p,N){let y;const D=r.from(N,r.M);if(Array.isArray(p)){if(p.length>1)return f(p,D);if(p.length===0)return 1;y=p[0]}else y=p;return c(y.mode,y.getLength(),D)},t.getEncodedBits=function(p){if(!i.isValid(p)||p<7)throw new Error("Invalid QR Code version");let N=p<<12;for(;s.getBCHDigit(N)-d>=0;)N^=l<<s.getBCHDigit(N)-d;return p<<12|N}})(on)),on}var cn={},Vr;function zu(){if(Vr)return cn;Vr=1;const t=Nt(),s=1335,n=21522,r=t.getBCHDigit(s);return cn.getEncodedBits=function(i,l){const d=i.bit<<3|l;let c=d<<10;for(;t.getBCHDigit(c)-r>=0;)c^=s<<t.getBCHDigit(c)-r;return(d<<10|c)^n},cn}var un={},mn,Hr;function Uu(){if(Hr)return mn;Hr=1;const t=kt();function s(n){this.mode=t.NUMERIC,this.data=n.toString()}return s.getBitsLength=function(r){return 10*Math.floor(r/3)+(r%3?r%3*3+1:0)},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(r){let a,i,l;for(a=0;a+3<=this.data.length;a+=3)i=this.data.substr(a,3),l=parseInt(i,10),r.put(l,10);const d=this.data.length-a;d>0&&(i=this.data.substr(a),l=parseInt(i,10),r.put(l,d*3+1))},mn=s,mn}var hn,Kr;function $u(){if(Kr)return hn;Kr=1;const t=kt(),s=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function n(r){this.mode=t.ALPHANUMERIC,this.data=r}return n.getBitsLength=function(a){return 11*Math.floor(a/2)+6*(a%2)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(a){let i;for(i=0;i+2<=this.data.length;i+=2){let l=s.indexOf(this.data[i])*45;l+=s.indexOf(this.data[i+1]),a.put(l,11)}this.data.length%2&&a.put(s.indexOf(this.data[i]),6)},hn=n,hn}var fn,Gr;function qu(){if(Gr)return fn;Gr=1;const t=kt();function s(n){this.mode=t.BYTE,typeof n=="string"?this.data=new TextEncoder().encode(n):this.data=new Uint8Array(n)}return s.getBitsLength=function(r){return r*8},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(n){for(let r=0,a=this.data.length;r<a;r++)n.put(this.data[r],8)},fn=s,fn}var xn,Wr;function Vu(){if(Wr)return xn;Wr=1;const t=kt(),s=Nt();function n(r){this.mode=t.KANJI,this.data=r}return n.getBitsLength=function(a){return a*13},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(r){let a;for(a=0;a<this.data.length;a++){let i=s.toSJIS(this.data[a]);if(i>=33088&&i<=40956)i-=33088;else if(i>=57408&&i<=60351)i-=49472;else throw new Error("Invalid SJIS character: "+this.data[a]+`
|
|
161
|
+
Make sure your charset is UTF-8`);i=(i>>>8&255)*192+(i&255),r.put(i,13)}},xn=n,xn}var pn={exports:{}},Qr;function Hu(){return Qr||(Qr=1,(function(t){var s={single_source_shortest_paths:function(n,r,a){var i={},l={};l[r]=0;var d=s.PriorityQueue.make();d.push(r,0);for(var c,m,g,f,u,p,N,y,D;!d.empty();){c=d.pop(),m=c.value,f=c.cost,u=n[m]||{};for(g in u)u.hasOwnProperty(g)&&(p=u[g],N=f+p,y=l[g],D=typeof l[g]>"u",(D||y>N)&&(l[g]=N,d.push(g,N),i[g]=m))}if(typeof a<"u"&&typeof l[a]>"u"){var h=["Could not find a path from ",r," to ",a,"."].join("");throw new Error(h)}return i},extract_shortest_path_from_predecessor_list:function(n,r){for(var a=[],i=r;i;)a.push(i),n[i],i=n[i];return a.reverse(),a},find_path:function(n,r,a){var i=s.single_source_shortest_paths(n,r,a);return s.extract_shortest_path_from_predecessor_list(i,a)},PriorityQueue:{make:function(n){var r=s.PriorityQueue,a={},i;n=n||{};for(i in r)r.hasOwnProperty(i)&&(a[i]=r[i]);return a.queue=[],a.sorter=n.sorter||r.default_sorter,a},default_sorter:function(n,r){return n.cost-r.cost},push:function(n,r){var a={value:n,cost:r};this.queue.push(a),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t.exports=s})(pn)),pn.exports}var Yr;function Ku(){return Yr||(Yr=1,(function(t){const s=kt(),n=Uu(),r=$u(),a=qu(),i=Vu(),l=po(),d=Nt(),c=Hu();function m(h){return unescape(encodeURIComponent(h)).length}function g(h,E,x){const b=[];let S;for(;(S=h.exec(x))!==null;)b.push({data:S[0],index:S.index,mode:E,length:S[0].length});return b}function f(h){const E=g(l.NUMERIC,s.NUMERIC,h),x=g(l.ALPHANUMERIC,s.ALPHANUMERIC,h);let b,S;return d.isKanjiModeEnabled()?(b=g(l.BYTE,s.BYTE,h),S=g(l.KANJI,s.KANJI,h)):(b=g(l.BYTE_KANJI,s.BYTE,h),S=[]),E.concat(x,b,S).sort(function(C,I){return C.index-I.index}).map(function(C){return{data:C.data,mode:C.mode,length:C.length}})}function u(h,E){switch(E){case s.NUMERIC:return n.getBitsLength(h);case s.ALPHANUMERIC:return r.getBitsLength(h);case s.KANJI:return i.getBitsLength(h);case s.BYTE:return a.getBitsLength(h)}}function p(h){return h.reduce(function(E,x){const b=E.length-1>=0?E[E.length-1]:null;return b&&b.mode===x.mode?(E[E.length-1].data+=x.data,E):(E.push(x),E)},[])}function N(h){const E=[];for(let x=0;x<h.length;x++){const b=h[x];switch(b.mode){case s.NUMERIC:E.push([b,{data:b.data,mode:s.ALPHANUMERIC,length:b.length},{data:b.data,mode:s.BYTE,length:b.length}]);break;case s.ALPHANUMERIC:E.push([b,{data:b.data,mode:s.BYTE,length:b.length}]);break;case s.KANJI:E.push([b,{data:b.data,mode:s.BYTE,length:m(b.data)}]);break;case s.BYTE:E.push([{data:b.data,mode:s.BYTE,length:m(b.data)}])}}return E}function y(h,E){const x={},b={start:{}};let S=["start"];for(let T=0;T<h.length;T++){const C=h[T],I=[];for(let k=0;k<C.length;k++){const P=C[k],M=""+T+k;I.push(M),x[M]={node:P,lastCount:0},b[M]={};for(let A=0;A<S.length;A++){const B=S[A];x[B]&&x[B].node.mode===P.mode?(b[B][M]=u(x[B].lastCount+P.length,P.mode)-u(x[B].lastCount,P.mode),x[B].lastCount+=P.length):(x[B]&&(x[B].lastCount=P.length),b[B][M]=u(P.length,P.mode)+4+s.getCharCountIndicator(P.mode,E))}}S=I}for(let T=0;T<S.length;T++)b[S[T]].end=0;return{map:b,table:x}}function D(h,E){let x;const b=s.getBestModeForData(h);if(x=s.from(E,b),x!==s.BYTE&&x.bit<b.bit)throw new Error('"'+h+'" cannot be encoded with mode '+s.toString(x)+`.
|
|
162
|
+
Suggested mode is: `+s.toString(b));switch(x===s.KANJI&&!d.isKanjiModeEnabled()&&(x=s.BYTE),x){case s.NUMERIC:return new n(h);case s.ALPHANUMERIC:return new r(h);case s.KANJI:return new i(h);case s.BYTE:return new a(h)}}t.fromArray=function(E){return E.reduce(function(x,b){return typeof b=="string"?x.push(D(b,null)):b.data&&x.push(D(b.data,b.mode)),x},[])},t.fromString=function(E,x){const b=f(E,d.isKanjiModeEnabled()),S=N(b),T=y(S,x),C=c.find_path(T.map,"start","end"),I=[];for(let k=1;k<C.length-1;k++)I.push(T.table[C[k]].node);return t.fromArray(p(I))},t.rawSplit=function(E){return t.fromArray(f(E,d.isKanjiModeEnabled()))}})(un)),un}var Jr;function Gu(){if(Jr)return Js;Jr=1;const t=Nt(),s=Kn(),n=_u(),r=Mu(),a=Pu(),i=Iu(),l=Ru(),d=fo(),c=Ou(),m=Fu(),g=zu(),f=kt(),u=Ku();function p(T,C){const I=T.size,k=i.getPositions(C);for(let P=0;P<k.length;P++){const M=k[P][0],A=k[P][1];for(let B=-1;B<=7;B++)if(!(M+B<=-1||I<=M+B))for(let R=-1;R<=7;R++)A+R<=-1||I<=A+R||(B>=0&&B<=6&&(R===0||R===6)||R>=0&&R<=6&&(B===0||B===6)||B>=2&&B<=4&&R>=2&&R<=4?T.set(M+B,A+R,!0,!0):T.set(M+B,A+R,!1,!0))}}function N(T){const C=T.size;for(let I=8;I<C-8;I++){const k=I%2===0;T.set(I,6,k,!0),T.set(6,I,k,!0)}}function y(T,C){const I=a.getPositions(C);for(let k=0;k<I.length;k++){const P=I[k][0],M=I[k][1];for(let A=-2;A<=2;A++)for(let B=-2;B<=2;B++)A===-2||A===2||B===-2||B===2||A===0&&B===0?T.set(P+A,M+B,!0,!0):T.set(P+A,M+B,!1,!0)}}function D(T,C){const I=T.size,k=m.getEncodedBits(C);let P,M,A;for(let B=0;B<18;B++)P=Math.floor(B/3),M=B%3+I-8-3,A=(k>>B&1)===1,T.set(P,M,A,!0),T.set(M,P,A,!0)}function h(T,C,I){const k=T.size,P=g.getEncodedBits(C,I);let M,A;for(M=0;M<15;M++)A=(P>>M&1)===1,M<6?T.set(M,8,A,!0):M<8?T.set(M+1,8,A,!0):T.set(k-15+M,8,A,!0),M<8?T.set(8,k-M-1,A,!0):M<9?T.set(8,15-M-1+1,A,!0):T.set(8,15-M-1,A,!0);T.set(k-8,8,1,!0)}function E(T,C){const I=T.size;let k=-1,P=I-1,M=7,A=0;for(let B=I-1;B>0;B-=2)for(B===6&&B--;;){for(let R=0;R<2;R++)if(!T.isReserved(P,B-R)){let H=!1;A<C.length&&(H=(C[A]>>>M&1)===1),T.set(P,B-R,H),M--,M===-1&&(A++,M=7)}if(P+=k,P<0||I<=P){P-=k,k=-k;break}}}function x(T,C,I){const k=new n;I.forEach(function(R){k.put(R.mode.bit,4),k.put(R.getLength(),f.getCharCountIndicator(R.mode,T)),R.write(k)});const P=t.getSymbolTotalCodewords(T),M=d.getTotalCodewordsCount(T,C),A=(P-M)*8;for(k.getLengthInBits()+4<=A&&k.put(0,4);k.getLengthInBits()%8!==0;)k.putBit(0);const B=(A-k.getLengthInBits())/8;for(let R=0;R<B;R++)k.put(R%2?17:236,8);return b(k,T,C)}function b(T,C,I){const k=t.getSymbolTotalCodewords(C),P=d.getTotalCodewordsCount(C,I),M=k-P,A=d.getBlocksCount(C,I),B=k%A,R=A-B,H=Math.floor(k/A),Z=Math.floor(M/A),te=Z+1,F=H-Z,X=new c(F);let $=0;const Y=new Array(A),w=new Array(A);let V=0;const j=new Uint8Array(T.buffer);for(let ae=0;ae<A;ae++){const oe=ae<R?Z:te;Y[ae]=j.slice($,$+oe),w[ae]=X.encode(Y[ae]),$+=oe,V=Math.max(V,oe)}const q=new Uint8Array(k);let z=0,W,L;for(W=0;W<V;W++)for(L=0;L<A;L++)W<Y[L].length&&(q[z++]=Y[L][W]);for(W=0;W<F;W++)for(L=0;L<A;L++)q[z++]=w[L][W];return q}function S(T,C,I,k){let P;if(Array.isArray(T))P=u.fromArray(T);else if(typeof T=="string"){let H=C;if(!H){const Z=u.rawSplit(T);H=m.getBestVersionForData(Z,I)}P=u.fromString(T,H||40)}else throw new Error("Invalid data");const M=m.getBestVersionForData(P,I);if(!M)throw new Error("The amount of data is too big to be stored in a QR Code");if(!C)C=M;else if(C<M)throw new Error(`
|
|
163
|
+
The chosen QR Code version cannot contain this amount of data.
|
|
164
|
+
Minimum version required to store current data is: `+M+`.
|
|
165
|
+
`);const A=x(C,I,P),B=t.getSymbolSize(C),R=new r(B);return p(R,C),N(R),y(R,C),h(R,I,0),C>=7&&D(R,C),E(R,A),isNaN(k)&&(k=l.getBestMask(R,h.bind(null,R,I))),l.applyMask(k,R),h(R,I,k),{modules:R,version:C,errorCorrectionLevel:I,maskPattern:k,segments:P}}return Js.create=function(C,I){if(typeof C>"u"||C==="")throw new Error("No input text");let k=s.M,P,M;return typeof I<"u"&&(k=s.from(I.errorCorrectionLevel,s.M),P=m.from(I.version),M=l.from(I.maskPattern),I.toSJISFunc&&t.setToSJISFunction(I.toSJISFunc)),S(C,P,k,M)},Js}var gn={},bn={},Zr;function go(){return Zr||(Zr=1,(function(t){function s(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let r=n.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+n);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(i){return[i,i]}))),r.length===6&&r.push("F","F");const a=parseInt(r.join(""),16);return{r:a>>24&255,g:a>>16&255,b:a>>8&255,a:a&255,hex:"#"+r.slice(0,6).join("")}}t.getOptions=function(r){r||(r={}),r.color||(r.color={});const a=typeof r.margin>"u"||r.margin===null||r.margin<0?4:r.margin,i=r.width&&r.width>=21?r.width:void 0,l=r.scale||4;return{width:i,scale:i?4:l,margin:a,color:{dark:s(r.color.dark||"#000000ff"),light:s(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},t.getScale=function(r,a){return a.width&&a.width>=r+a.margin*2?a.width/(r+a.margin*2):a.scale},t.getImageWidth=function(r,a){const i=t.getScale(r,a);return Math.floor((r+a.margin*2)*i)},t.qrToImageData=function(r,a,i){const l=a.modules.size,d=a.modules.data,c=t.getScale(l,i),m=Math.floor((l+i.margin*2)*c),g=i.margin*c,f=[i.color.light,i.color.dark];for(let u=0;u<m;u++)for(let p=0;p<m;p++){let N=(u*m+p)*4,y=i.color.light;if(u>=g&&p>=g&&u<m-g&&p<m-g){const D=Math.floor((u-g)/c),h=Math.floor((p-g)/c);y=f[d[D*l+h]?1:0]}r[N++]=y.r,r[N++]=y.g,r[N++]=y.b,r[N]=y.a}}})(bn)),bn}var Xr;function Wu(){return Xr||(Xr=1,(function(t){const s=go();function n(a,i,l){a.clearRect(0,0,i.width,i.height),i.style||(i.style={}),i.height=l,i.width=l,i.style.height=l+"px",i.style.width=l+"px"}function r(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}t.render=function(i,l,d){let c=d,m=l;typeof c>"u"&&(!l||!l.getContext)&&(c=l,l=void 0),l||(m=r()),c=s.getOptions(c);const g=s.getImageWidth(i.modules.size,c),f=m.getContext("2d"),u=f.createImageData(g,g);return s.qrToImageData(u.data,i,c),n(f,m,g),f.putImageData(u,0,0),m},t.renderToDataURL=function(i,l,d){let c=d;typeof c>"u"&&(!l||!l.getContext)&&(c=l,l=void 0),c||(c={});const m=t.render(i,l,c),g=c.type||"image/png",f=c.rendererOpts||{};return m.toDataURL(g,f.quality)}})(gn)),gn}var vn={},ea;function Qu(){if(ea)return vn;ea=1;const t=go();function s(a,i){const l=a.a/255,d=i+'="'+a.hex+'"';return l<1?d+" "+i+'-opacity="'+l.toFixed(2).slice(1)+'"':d}function n(a,i,l){let d=a+i;return typeof l<"u"&&(d+=" "+l),d}function r(a,i,l){let d="",c=0,m=!1,g=0;for(let f=0;f<a.length;f++){const u=Math.floor(f%i),p=Math.floor(f/i);!u&&!m&&(m=!0),a[f]?(g++,f>0&&u>0&&a[f-1]||(d+=m?n("M",u+l,.5+p+l):n("m",c,0),c=0,m=!1),u+1<i&&a[f+1]||(d+=n("h",g),g=0)):c++}return d}return vn.render=function(i,l,d){const c=t.getOptions(l),m=i.modules.size,g=i.modules.data,f=m+c.margin*2,u=c.color.light.a?"<path "+s(c.color.light,"fill")+' d="M0 0h'+f+"v"+f+'H0z"/>':"",p="<path "+s(c.color.dark,"stroke")+' d="'+r(g,m,c.margin)+'"/>',N='viewBox="0 0 '+f+" "+f+'"',D='<svg xmlns="http://www.w3.org/2000/svg" '+(c.width?'width="'+c.width+'" height="'+c.width+'" ':"")+N+' shape-rendering="crispEdges">'+u+p+`</svg>
|
|
166
|
+
`;return typeof d=="function"&&d(null,D),D},vn}var ta;function Yu(){if(ta)return Mt;ta=1;const t=Du(),s=Gu(),n=Wu(),r=Qu();function a(i,l,d,c,m){const g=[].slice.call(arguments,1),f=g.length,u=typeof g[f-1]=="function";if(!u&&!t())throw new Error("Callback required as last argument");if(u){if(f<2)throw new Error("Too few arguments provided");f===2?(m=d,d=l,l=c=void 0):f===3&&(l.getContext&&typeof m>"u"?(m=c,c=void 0):(m=c,c=d,d=l,l=void 0))}else{if(f<1)throw new Error("Too few arguments provided");return f===1?(d=l,l=c=void 0):f===2&&!l.getContext&&(c=d,d=l,l=void 0),new Promise(function(p,N){try{const y=s.create(d,c);p(i(y,l,c))}catch(y){N(y)}})}try{const p=s.create(d,c);m(null,i(p,l,c))}catch(p){m(p)}}return Mt.create=s.create,Mt.toCanvas=a.bind(null,n.render),Mt.toDataURL=a.bind(null,n.renderToDataURL),Mt.toString=a.bind(null,function(i,l,d){return r.render(i,d)}),Mt}var Ju=Yu();function Zu(t){return Oi(t)}function Xu(t){return Ju.toDataURL(t,{errorCorrectionLevel:"M",margin:2,scale:8,color:{dark:"#111827ff",light:"#ffffffff"}})}function em({nodeName:t,nodeEndpoint:s}){const[n,r]=o.useState(!1),[a,i]=o.useState(null),[l,d]=o.useState(null),c=o.useMemo(()=>Zu({nodeName:t,nodeEndpoint:s}),[s,t]),m=`Show ${t} Node QR code`;return o.useEffect(()=>{if(!n)return;let g=!1;return i(null),d(null),Xu(c).then(f=>{g||i(f)}).catch(()=>{g||d("QR code unavailable")}),()=>{g=!0}},[n,c]),e.jsxs(yt,{open:n,onOpenChange:r,children:[e.jsx(Fi,{asChild:!0,children:e.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"h-4 w-4 shrink-0 rounded-sm p-0 text-muted-foreground opacity-70 hover:bg-muted/45 hover:opacity-100 [&_svg]:size-2.5","aria-label":m,title:m,children:e.jsx(zd,{className:"h-3 w-3"})})}),e.jsxs(jt,{className:"max-w-[20rem] gap-2 p-3",children:[e.jsxs(Ts,{className:"space-y-1 text-left",children:[e.jsx(Ot,{className:"text-[12px]",children:"Node URL QR"}),e.jsx(Es,{children:t})]}),e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"flex h-52 w-52 items-center justify-center rounded-sm bg-white p-2 text-[10px] text-muted-foreground",children:a?e.jsx("img",{src:a,alt:`${t} Node URL QR code`,className:"h-full w-full"}):l?e.jsx("span",{children:l}):e.jsx(me,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),e.jsx("div",{className:"w-full rounded-sm bg-muted/45 px-2 py-1.5 font-mono text-[9px] leading-[0.95rem] text-foreground break-all",children:s}),e.jsx(ee,{type:"button",variant:"secondary",size:"sm",className:"h-6 w-full border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",onClick:()=>{Ft(s,"Node URL copied")},children:"Copy node URL"})]})]})]})}function Gn({nodeId:t,nodeName:s,onOpenSettings:n,onOpenServicePreview:r,onOpenCapabilities:a,onOpenDevBox:i,onStartDevBox:l,onToggleRemoteAccess:d,remoteAccessLabel:c,remoteAccessPending:m,remoteAccessDisabled:g,remoteAccessDisabledReason:f,showConfigureDevBox:u,showStartDevBox:p,startDevBoxPending:N,className:y}){const[D,h]=o.useState(!1),[E,x]=o.useState(null),b=o.useRef(null),S=o.useRef(null),T=N?"Starting":"Start DevBox",C=c?.startsWith("Disable")?zi:Zd;o.useLayoutEffect(()=>{if(!D){x(null);return}const k=()=>{const P=S.current,M=b.current;if(!P||!M)return;const A=P.getBoundingClientRect(),B=M.getBoundingClientRect();x(sm({left:A.left,right:A.right,bottom:A.bottom,top:A.top},{width:B.width,height:B.height},{width:window.innerWidth,height:window.innerHeight},nm()))};return k(),window.addEventListener("resize",k),window.addEventListener("scroll",k,!0),()=>{window.removeEventListener("resize",k),window.removeEventListener("scroll",k,!0)}},[D]),o.useEffect(()=>{if(!D)return;const k=M=>{const A=M.target;A instanceof Node&&!b.current?.contains(A)&&!S.current?.contains(A)&&h(!1)},P=M=>{M.key==="Escape"&&h(!1)};return document.addEventListener("mousedown",k),document.addEventListener("keydown",P),()=>{document.removeEventListener("mousedown",k),document.removeEventListener("keydown",P)}},[D]);const I=D?e.jsxs("div",{ref:b,"data-node-action-menu-portal":"true",role:"menu",style:tm(E),onClick:k=>k.stopPropagation(),onPointerDown:k=>k.stopPropagation(),className:"fixed z-[130] min-w-40 overflow-hidden whitespace-nowrap rounded-sm border border-border/65 bg-popover/96 p-1 normal-case tracking-normal shadow-[0_18px_48px_-28px_rgba(0,0,0,0.45)] backdrop-blur-xl",children:[n&&e.jsxs("button",{type:"button",role:"menuitem","aria-label":`Open ${s} settings`,title:`Open ${s} settings`,onClick:k=>{k.stopPropagation(),h(!1),n(t)},className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-1.5 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80",children:[e.jsx(Ui,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:"Settings"})]}),r&&e.jsxs("button",{type:"button",role:"menuitem","aria-label":`Preview service on ${s}`,title:`Preview service on ${s}`,onClick:k=>{k.stopPropagation(),h(!1),r(t)},className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-1.5 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80",children:[e.jsx(Wa,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:"Preview service"})]}),a&&e.jsxs("button",{type:"button",role:"menuitem","aria-label":`Open ${s} capabilities`,title:`Open ${s} capabilities`,onClick:k=>{k.stopPropagation(),h(!1),a(t)},className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-1.5 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80",children:[e.jsx(As,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:"Capabilities"})]}),c&&d&&e.jsxs("button",{type:"button",role:"menuitem","aria-label":`${c} for ${s}`,title:f??`${c} for ${s}`,onClick:k=>{k.stopPropagation(),!(m||g)&&(h(!1),d())},disabled:m||g,className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-1.5 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80 disabled:cursor-not-allowed disabled:opacity-60",children:[m?e.jsx(me,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-primary"}):e.jsx(C,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:c})]}),p&&l&&e.jsxs("button",{type:"button",role:"menuitem","aria-label":`${T} for ${s}`,title:`${T} for ${s}`,onClick:k=>{k.stopPropagation(),!N&&(h(!1),l(t))},disabled:N,className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-1.5 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80 disabled:cursor-not-allowed disabled:opacity-60",children:[N?e.jsx(me,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-primary"}):e.jsx(Ds,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:T})]}),u&&i&&e.jsxs("button",{type:"button",role:"menuitem","aria-label":`Configure DevBox for ${s}`,title:`Configure DevBox for ${s}`,onClick:k=>{k.stopPropagation(),h(!1),i(t)},className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-1.5 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80",children:[e.jsx($i,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:"Configure DevBox"})]})]}):null;return e.jsxs("div",{"data-node-action-menu":"true",className:O("relative shrink-0",D&&"z-[120]",y),onClick:k=>k.stopPropagation(),onPointerDown:k=>k.stopPropagation(),children:[e.jsx(ee,{ref:S,type:"button",variant:"ghost",size:"icon","aria-label":`More actions for ${s}`,"aria-haspopup":"menu","aria-expanded":D,title:`More actions for ${s}`,onClick:k=>{k.stopPropagation(),h(P=>(P||x(null),!P))},className:O("h-6 w-6 rounded-sm text-muted-foreground hover:bg-background/70 hover:text-foreground",D&&"bg-background/80 text-primary"),children:e.jsx(bd,{className:"h-3.5 w-3.5"})}),I&&(typeof document>"u"?I:La.createPortal(I,document.body))]})}function tm(t){return t?{left:t.left,top:t.top}:{left:0,top:0,visibility:"hidden"}}function sm(t,s,n,r=1){const l=s.width||160,d=s.height||0,c=Number.isFinite(r)&&r>0?r:1,m=Math.max(8,Math.min(t.right-l,n.width-l-8)),g=t.bottom+4,f=(t.top??t.bottom)-d-4,u=g+d>n.height-8&&f>=8?f:g;return{left:Math.round(m/c),top:Math.round(u/c)}}function nm(){if(typeof window>"u"||typeof document>"u")return 1;const t=window.getComputedStyle(document.documentElement),s=t.zoom||t.getPropertyValue("--ui-zoom"),n=Number.parseFloat(s);return Number.isFinite(n)&&n>0?n:1}const rm=new Set(["deallocated","hibernate","hibernated","sleep","sleeping","stopped"]),am=new Set(["startinprogress","starting"]);function Rt(t){return!!(t?.enabled&&t.name)}function om(t){const s=t?.trim().toLowerCase().replace(/[\s_-]+/gu,"");return!!(s&&rm.has(s))}function Lt(t){const s=t?.trim().toLowerCase().replace(/[\s_-]+/gu,"");return!!(s&&am.has(s))}function Ps(t,s,n){return t==="offline"&&om(s)&&Rt(n)}function sa(t,s){return t==="offline"&&Rt(s)}function na(t){return!Rt(t)}function im({nodeStatus:t,status:s,current:n,selected:r}){const a=r??n;return a&&Ps(t,s,a)?a:null}function Le(t){return t.scope||`name:${t.name??""}`}function lm({previousKey:t,baseDevBox:s,listed:n}){if(t&&n.some(i=>Le(i)===t))return t;if(!Rt(s))return n[0]?Le(n[0]):"";const r=Le(s),a=n.find(i=>Le(i)===r)??n.find(i=>i.name===s.name);return a?Le(a):r}function dm(t){return t==="nodes"||t==="events"?t:"overview"}function cm({cluster:t,systemInfo:s,nodeNameById:n,nodeBlockingTaskCounts:r,eventTypeFilter:a,onEventTypeFilterChange:i,eventTypeOptions:l,filteredEvents:d,sseConnected:c,clusterLoading:m,clusterError:g,promotePending:f,onPromote:u,onAddNode:p,leavePending:N,onLeaveCluster:y,onToggleNodeDevTunnel:D,devTunnelNodeId:h,devBoxStartNodeId:E,devBoxStartingNodeIds:x=new Set,activeTab:b,onTabChange:S,onOpenNodeSettings:T,onOpenNodeCapabilities:C,onOpenDevBox:I,onStartDevBox:k}){const P=t?.self?.role==="leader",M=t?.self?.role==="follower"&&!t?.leader,A=t?.self??null,R=qi(t?.nodes??[],A?.id).filter(q=>q.id!==A?.id),H=t?.leader?t.nodes.find(q=>q.id===t.leader?.id)??null:null,Z=t?.leader?t.leader.dashboardOrigin??H?.dashboardOrigin??(s&&t.leader.id===(s.nodeId??s.id)?s.dashboardOrigin:void 0)??t.leader.endpoint:null,te=t?.leader?H?.devtunnelEndpoint??t.leader.endpoint:null,F=t?.leader?.name??H?.name??"Leader",X=A?.role==="leader"&&R.length===0,$=A?.role==="follower",[Y,w]=o.useState("overview"),V=b??Y;function j(q){const z=dm(q);w(z),S?.(z)}return e.jsx("aside",{className:"dashboard-operations-sidecar dashboard-panel dashboard-panel-muted animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:e.jsxs(Bn,{value:V,onValueChange:j,className:"flex h-full min-h-0 flex-col",children:[e.jsx("div",{className:"dashboard-operations-sidecar__header shrink-0 bg-card/24 px-2.5 py-2",children:e.jsxs(Ln,{className:"grid h-auto w-full grid-cols-3 rounded-sm bg-muted/55 p-0.5",children:[e.jsx(vt,{value:"overview",className:"rounded-sm px-2 py-0.5 text-[10px]",children:"Overview"}),e.jsx(vt,{value:"nodes",className:"rounded-sm px-2 py-0.5 text-[10px]",children:"Nodes"}),e.jsx(vt,{value:"events",className:"rounded-sm px-2 py-0.5 text-[10px]",children:"Live events"})]})}),e.jsx(lt,{value:"overview",className:"mt-0 min-h-0 flex-1",children:e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-y-auto px-2 py-2",children:e.jsxs("div",{className:"space-y-2.5",children:[A&&e.jsx(ra,{node:A,systemInfo:s,blockingTaskCount:r.get(A.id)??0,devTunnelNodeId:h,onToggleNodeDevTunnel:D,showActions:!1,defaultExpanded:!1,onOpenDevBox:I,devBoxStartingNodeIds:x}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[e.jsx("div",{className:"text-[10px] font-medium text-foreground",children:"Cluster snapshot"}),e.jsx(Ue,{variant:"secondary",className:"rounded-sm border-0 bg-muted/60 px-1.5 py-0 text-[9px] leading-4 shadow-none",children:c?"Connected":"Reconnecting"})]}),m&&!t?e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground",children:[e.jsx(me,{className:"h-4 w-4 animate-spin"}),"Loading cluster state..."]}):g&&!t?e.jsx("div",{className:"rounded-sm border border-destructive/20 bg-destructive/10 px-2 py-1.5 text-[10px] text-destructive shadow-none",children:g}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsx(_t,{label:"Term",value:String(t?.term??0)}),e.jsx(_t,{label:"Nodes",value:String(t?.nodes.length??0)}),e.jsx(_t,{label:"Pending",value:String(t?.taskSummary.pending??0)}),e.jsx(_t,{label:"Running",value:String(t?.taskSummary.running??0)}),e.jsx(_t,{label:"Completed",value:String(t?.taskSummary.completed??0)}),e.jsx(_t,{label:"Failed",value:String(t?.taskSummary.failed??0)})]}),e.jsxs("div",{className:"space-y-1.5 rounded-sm bg-muted/45 px-2 py-2 shadow-none",children:[e.jsx(We,{label:"Leader",value:t?.leader?.name??"None"}),e.jsx(We,{label:"Leader URL",value:Z??"Unavailable",mono:!0,action:Z?e.jsx(Is,{label:"Copy leader URL",onClick:()=>{Ft(Z,"Leader URL copied")}}):void 0}),te&&e.jsx(We,{label:"Node URL",value:te,mono:!0,action:e.jsx(Wn,{nodeName:F,nodeEndpoint:te})}),e.jsx(We,{label:"Feed",value:c?"Receiving live updates":"Reconnecting to event stream"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:M&&e.jsxs(ee,{variant:"secondary",size:"sm",onClick:u,disabled:f,className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",children:[f&&e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}),"Promote self"]})})]})]})]})})}),e.jsx(lt,{value:"nodes",className:"mt-0 min-h-0 flex-1",children:e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-y-auto px-2 py-2",children:e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[e.jsx("div",{className:"text-[10px] font-medium text-foreground",children:"This node"}),X?e.jsxs(ee,{variant:"secondary",size:"sm",onClick:p,className:"h-6 border-0 bg-primary px-2 text-[10px] text-primary-foreground shadow-none hover:bg-primary/90",children:[e.jsx(Yd,{className:"h-3 w-3"}),"Join node"]}):$?e.jsxs(ee,{variant:"secondary",size:"sm",onClick:y,disabled:N,className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",children:[N&&e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}),"Leave cluster"]}):null]}),A&&e.jsx(ra,{node:A,systemInfo:s,blockingTaskCount:r.get(A.id)??0,devTunnelNodeId:h,onToggleNodeDevTunnel:D,showActions:!0,defaultExpanded:!0,onOpenNodeSettings:P?T:void 0,onOpenNodeCapabilities:P?C:void 0,onOpenDevBox:P?I:void 0,onStartDevBox:P?k:void 0,devBoxStartNodeId:E,devBoxStartingNodeIds:x})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"text-[10px] font-medium text-foreground",children:["Peer nodes (",R.length,")"]}),R.length>0?e.jsx("div",{className:"space-y-1.5",children:R.map(q=>e.jsx(um,{node:q,isLeader:!!P,blockingTaskCount:r.get(q.id)??0,devTunnelNodeId:h,onToggleNodeDevTunnel:D,onOpenNodeSettings:P?T:void 0,onOpenNodeCapabilities:P?C:void 0,onOpenDevBox:P?I:void 0,onStartDevBox:P?k:void 0,devBoxStartNodeId:E,devBoxStartingNodeIds:x},q.id))}):e.jsx("div",{className:"rounded-sm bg-muted/45 px-2 py-2 text-[10px] text-muted-foreground shadow-none",children:"No peer nodes are connected yet."})]})]})})}),e.jsx(lt,{value:"events",className:"mt-0 min-h-0 flex-1",children:e.jsxs("div",{className:"flex h-full min-h-0 flex-col px-2 py-2",children:[e.jsxs("div",{className:"mb-2 space-y-1.5",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium text-foreground",children:[e.jsx(Vi,{className:O("h-3.5 w-3.5",c?"text-emerald-500":"text-destructive")}),"Live events"]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsxs(Ne,{value:a,onValueChange:i,children:[e.jsx(ke,{className:"h-6 min-w-[10rem] flex-1 rounded-sm border-0 bg-muted/60 text-[10px] shadow-none sm:max-w-[14rem] [&>svg]:h-3 [&>svg]:w-3",children:e.jsx(Pe,{placeholder:"Event type"})}),e.jsx(Se,{className:"shadow-none",children:l.map(q=>e.jsx(xe,{value:q,className:"py-1 pl-6 pr-1.5 text-[10px] leading-4",children:q==="all"?"All event types":q},q))})]}),e.jsx(Ue,{variant:"secondary",className:"rounded-sm border-0 bg-muted/60 px-1.5 py-0 text-[9px] leading-4 shadow-none",children:c?"Connected":"Reconnecting"})]})]}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(Hi,{events:d,maxHeight:"100%",emptyTitle:a==="all"?"No live events yet":"No matching events",emptyDescription:a==="all"?"Cluster activity appears here as it happens.":`No "${a}" events are in the current stream.`,nodeNameById:n,density:"compact"})})]})})]})})}function ra({node:t,systemInfo:s,blockingTaskCount:n,devTunnelNodeId:r,onToggleNodeDevTunnel:a,showActions:i=!0,defaultExpanded:l=!1,onOpenNodeSettings:d,onOpenNodeCapabilities:c,onOpenDevBox:m,onStartDevBox:g,devBoxStartNodeId:f,devBoxStartingNodeIds:u}){const[p,N]=o.useState(l),y=s?.dashboardOrigin??t.dashboardOrigin,D=t.devtunnelEndpoint??t.endpoint,h=y??t.endpoint,E=s?.workDir??t.workDir,x=Za(t,s?.transportType),b=qn(t,s?.transportType),S=b&&Ut(s?.transportType??t.transportType)?!0:Ja(t,s?.transportType),T=n>0;return e.jsxs("section",{className:"dashboard-operations-node-card bg-primary/8 shadow-none",children:[e.jsxs("div",{className:"w-full px-2.5 py-1.5 text-left",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>N(C=>!C),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[p?e.jsx(Qe,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(Ke,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx(Ba,{status:t.status}),e.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Current node"})]}),e.jsx("a",{href:h,target:"_blank",rel:"noreferrer",className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(Fn,{className:"h-3 w-3"})}),(d||c||i&&S)&&e.jsx(Gn,{nodeId:t.id,nodeName:t.name,onOpenSettings:d,onOpenCapabilities:c,onOpenDevBox:m,onStartDevBox:g,onToggleRemoteAccess:i&&S?()=>a(t):void 0,remoteAccessLabel:i&&S?b?"Disable Remote Access":"Enable Remote Access":void 0,remoteAccessPending:r===t.id,remoteAccessDisabled:T,remoteAccessDisabledReason:T?"Finish assigned or running tasks before changing remote access":void 0,showConfigureDevBox:t.devbox?.enabled,showStartDevBox:Ps(t.status,t.devbox?.lastStatus,t.devbox)||Lt(t.devbox?.lastStatus)||u.has(t.id),startDevBoxPending:f===t.id||Lt(t.devbox?.lastStatus)||u.has(t.id)})]}),e.jsxs("button",{type:"button",onClick:()=>N(C=>!C),className:"mt-1 flex min-w-0 items-center gap-1 pl-5 text-left",children:[e.jsx("span",{className:"text-[10px] font-semibold tracking-tight text-foreground",children:t.name}),e.jsx(Oa,{role:t.role,size:"compact"}),e.jsx(Ue,{variant:"secondary",className:"rounded-sm border-0 bg-background/65 px-1.5 py-0 text-[9px] leading-4 capitalize shadow-none",children:t.status})]})]}),p&&e.jsxs("div",{className:"space-y-2 bg-primary/5 px-2.5 pb-2.5 pt-1.5",children:[e.jsxs("div",{className:"space-y-1.5 rounded-sm bg-muted/45 px-2 py-1.5 shadow-none",children:[e.jsx(We,{label:"Node ID",value:t.id,mono:!0}),y&&e.jsx(We,{label:"Dashboard",value:y,mono:!0,action:e.jsx(Is,{label:"Copy dashboard URL",onClick:()=>{Ft(y,"Dashboard URL copied")}})}),e.jsx(We,{label:"Node URL",value:D,mono:!0,action:e.jsx(Wn,{nodeName:t.name,nodeEndpoint:D})}),E&&e.jsx(We,{label:"Workspace",value:E,mono:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[e.jsx(Cn,{label:"Transport",value:x}),s&&e.jsx(Cn,{label:"Uptime",value:Ki(s.uptime),mono:!0})]}),i&&c&&e.jsxs(ee,{variant:"secondary",size:"sm",onClick:()=>c(t.id),"aria-label":`Open ${t.name} capabilities`,className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",children:[e.jsx(As,{className:"h-3 w-3"}),"Capabilities"]}),i&&S&&T&&e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function um({node:t,isLeader:s,blockingTaskCount:n,devTunnelNodeId:r,onToggleNodeDevTunnel:a,onOpenNodeSettings:i,onOpenNodeCapabilities:l,onOpenDevBox:d,onStartDevBox:c,devBoxStartNodeId:m,devBoxStartingNodeIds:g}){const[f,u]=o.useState(!1),p=t.dashboardOrigin,N=t.devtunnelEndpoint??t.endpoint,y=p??t.endpoint,D=Za(t),h=qn(t),E=Ja(t),x=n>0;return e.jsxs("div",{className:"dashboard-operations-node-card bg-muted/45 shadow-none",children:[e.jsxs("div",{className:"w-full px-2.5 py-1.5 text-left",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>u(b=>!b),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[f?e.jsx(Qe,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):e.jsx(Ke,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx(Ba,{status:t.status}),e.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Peer node"})]}),e.jsx("a",{href:y,target:"_blank",rel:"noreferrer",className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(Fn,{className:"h-3 w-3"})}),s&&(i||l||E)&&e.jsx(Gn,{nodeId:t.id,nodeName:t.name,onOpenSettings:i,onOpenCapabilities:l,onOpenDevBox:d,onStartDevBox:c,onToggleRemoteAccess:E?()=>a(t):void 0,remoteAccessLabel:E?h?"Disable Remote Access":"Enable Remote Access":void 0,remoteAccessPending:r===t.id,remoteAccessDisabled:x,remoteAccessDisabledReason:x?"Finish assigned or running tasks before changing remote access":void 0,showConfigureDevBox:t.devbox?.enabled,showStartDevBox:Ps(t.status,t.devbox?.lastStatus,t.devbox)||Lt(t.devbox?.lastStatus)||g.has(t.id),startDevBoxPending:m===t.id||Lt(t.devbox?.lastStatus)||g.has(t.id)})]}),e.jsxs("button",{type:"button",onClick:()=>u(b=>!b),className:"mt-1 flex min-w-0 items-center gap-1 pl-4 text-left",children:[e.jsx("span",{className:"text-[10px] font-semibold text-foreground",children:t.name}),e.jsx(Oa,{role:t.role,size:"compact"}),e.jsx(Ue,{variant:"secondary",className:"rounded-sm border-0 bg-background/65 px-1.5 py-0 text-[9px] leading-4 capitalize shadow-none",children:t.status})]})]}),f&&e.jsxs("div",{className:"space-y-2 bg-muted/35 px-2.5 pb-2.5 pt-1.5",children:[e.jsxs("div",{className:"space-y-1.5 rounded-sm bg-background/55 px-2 py-1.5 shadow-none",children:[e.jsx(We,{label:"Node ID",value:t.id,mono:!0}),p&&e.jsx(We,{label:"Dashboard",value:p,mono:!0,action:e.jsx(Is,{label:"Copy dashboard URL",onClick:()=>{Ft(p,"Dashboard URL copied")}})}),e.jsx(We,{label:"Node URL",value:N,mono:!0,action:e.jsx(Wn,{nodeName:t.name,nodeEndpoint:N})}),t.workDir&&e.jsx(We,{label:"Workspace",value:t.workDir,mono:!0}),e.jsx(Cn,{label:"Transport",value:D})]}),s&&l&&e.jsxs(ee,{variant:"secondary",size:"sm",onClick:()=>l(t.id),"aria-label":`Open ${t.name} capabilities`,className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",children:[e.jsx(As,{className:"h-3 w-3"}),"Capabilities"]}),s&&E&&x&&e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function Wn({nodeName:t,nodeEndpoint:s}){return e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[e.jsx(em,{nodeName:t,nodeEndpoint:s}),e.jsx(Is,{label:"Copy node URL",onClick:()=>{Ft(s,"Node URL copied")}})]})}function Is({label:t,onClick:s}){return e.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"h-4 w-4 shrink-0 rounded-sm p-0 text-muted-foreground opacity-70 hover:bg-muted/45 hover:opacity-100 [&_svg]:size-2.5",onClick:s,"aria-label":t,title:t,children:e.jsx(Pa,{className:"h-3 w-3"})})}function mm(t,s,n,r){if(!t)return{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Select a task to continue the conversation."};const a=s?.self?.role==="follower",i=t.assignedTo?s?.self?.id===t.assignedTo?s.self:s?.nodes.find(d=>d.id===t.assignedTo):void 0;return t.assignedTo!==null&&(i?i.status==="offline":s?t.assignedNodeAvailable===!1||!s.nodes.some(d=>d.id===t.assignedTo):t.assignedNodeAvailable===!1)?{taskUnavailable:!0,chatDisabled:!0,chatDisabledReason:`${t.assignedNodeName??"Assigned node"} is unavailable. Leave the cluster on that node or re-run the task elsewhere.`}:a?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Follower nodes are read-only. Use the leader dashboard to manage chat, or leave the cluster first."}:n?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Sending message..."}:r?{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Queue a message for the next turn..."}:js.has(t.status)||t.status==="archived"?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:js.has(t.status)?"Task has not started yet...":"Archived tasks are read-only."}:{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Continue the conversation..."}}const bo=.5,vo=1.75,aa=.1;function hm({node:t,open:s,onOpenChange:n}){const[r,a]=o.useState(xs),[i,l]=o.useState(null),[d,c]=o.useState(1),[m,g]=o.useState(!1),[f,u]=o.useState(null);o.useEffect(()=>{a(xs),l(null),c(1),g(!1),u(null)},[t?.id,s]);const p=o.useCallback(async x=>{if(!t)return;const b=x??Number.parseInt(r.trim()||xs,10);if(!Number.isInteger(b)||b<1||b>65535){u("Enter a port between 1 and 65535");return}g(!0),u(null);try{const S=await Gi(t.id,{port:b});l(S),a(String(b)),ar("preview.created",{result:"success",previewType:"service-port"})}catch(S){u(S instanceof Error?S.message:"Failed to create service preview"),ar("preview.failed",{result:"failed",previewType:"service-port"})}finally{g(!1)}},[t,r]),N=o.useCallback(()=>{typeof i?.port=="number"&&p(i.port)},[i?.port,p]);o.useEffect(()=>{if(!i)return;const x=i.expiresAt-Date.now()-5e3;if(x<=0){N();return}const b=window.setTimeout(N,x);return()=>window.clearTimeout(b)},[N,i]);const y=i?id(i):null,D=t?.name??"Node",h=fm(d),E={width:`${100/d}%`,height:`${100/d}%`,transform:`scale(${d})`,transformOrigin:"top left"};return e.jsx(yt,{open:s,onOpenChange:n,children:e.jsxs(jt,{onOpenAutoFocus:x=>x.preventDefault(),className:"flex h-[min(82vh,44rem)] max-w-[min(92vw,72rem)] flex-col gap-0 overflow-hidden p-0",children:[e.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border/60 px-3 py-2 pr-9",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs(Ot,{className:"flex min-w-0 items-center gap-1.5 text-[12px] font-semibold text-foreground",children:[e.jsx(Wa,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{className:"shrink-0",children:"Preview service"}),e.jsx("span",{className:"min-w-0 truncate font-mono text-[10px] font-medium text-muted-foreground",children:D})]}),e.jsx(Es,{className:"sr-only",children:"Preview a service port running on the selected node."})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs("form",{className:"flex items-center gap-1.5",onSubmit:x=>{x.preventDefault(),p()},children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:["Port",e.jsx(st,{type:"text",min:1,max:65535,inputMode:"numeric",value:r,onChange:x=>a(x.target.value),placeholder:xs,"aria-label":"Node service preview port",className:"h-6 w-20 rounded-sm border-0 bg-muted/55 px-2 text-[11px] shadow-none focus:bg-muted/55 focus:outline-none focus-visible:border-0 focus-visible:bg-muted/55 focus-visible:ring-0 focus-visible:ring-offset-0"})]}),e.jsxs(ee,{type:"submit",variant:"ghost",size:"sm",disabled:m,className:"h-6 rounded-sm border-0 bg-primary/10 px-2 text-[11px] text-primary shadow-none hover:bg-primary/15 hover:text-primary",children:[m?e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Ds,{className:"h-3.5 w-3.5"}),"Preview"]})]}),i&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"hidden shrink-0 text-[10px] text-muted-foreground sm:inline",children:xm(i.expiresAt)}),e.jsxs("div",{className:"flex h-6 shrink-0 items-center overflow-hidden rounded-sm border border-border/55 bg-muted/35",children:[e.jsx(ee,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-none",onClick:()=>c(x=>oa(x,-aa)),disabled:d<=bo,title:"Zoom out","aria-label":"Zoom out preview",children:e.jsx(sc,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>c(1),className:"h-6 min-w-11 border-x border-border/45 px-1.5 text-center font-mono text-[10px] text-muted-foreground transition-colors hover:bg-muted/55 hover:text-foreground",title:"Reset zoom","aria-label":"Reset preview zoom",children:h}),e.jsx(ee,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-none",onClick:()=>c(x=>oa(x,aa)),disabled:d>=vo,title:"Zoom in","aria-label":"Zoom in preview",children:e.jsx(ec,{className:"h-3.5 w-3.5"})})]}),e.jsx(ee,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-sm",onClick:N,title:"Refresh",children:e.jsx(Wi,{className:"h-3.5 w-3.5"})}),e.jsx(ee,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-sm",asChild:!0,title:"Open in new tab",children:e.jsx("a",{href:y??i.previewUrl,target:"_blank",rel:"noopener noreferrer",children:e.jsx(Fn,{className:"h-3.5 w-3.5"})})})]})]})]}),f&&e.jsx("div",{className:"shrink-0 border-b border-destructive/20 bg-destructive/5 px-3 py-1.5 text-[11px] text-destructive",children:f}),e.jsx("div",{className:"min-h-0 flex-1 p-2",children:i?e.jsx("div",{className:"h-full overflow-hidden rounded-sm border border-border/60 bg-white shadow-none",children:e.jsx("iframe",{src:dd(i),style:E,className:"h-full w-full border-0",sandbox:ld(i),title:`${D} Service Preview`})}):e.jsx("div",{className:"flex h-full min-h-56 items-center justify-center rounded-sm border border-dashed border-border/65 bg-background/35 px-3 text-center text-[11px] text-muted-foreground",children:"No service preview running."})})]})})}function oa(t,s){return wo(Math.round((t+s)*100)/100)}function wo(t){return Number.isFinite(t)?Math.min(vo,Math.max(bo,t)):1}function fm(t){return`${Math.round(wo(t)*100)}%`}function xm(t){const s=Math.max(0,Math.round((t-Date.now())/1e3));if(s<60)return`${s}s`;const n=Math.floor(s/60),r=s%60;return`${n}m ${r}s`}function pm({dirPath:t,label:s,taskCount:n,collapsed:r,onToggle:a,onCreateTask:i,onOpenCapabilities:l}){return e.jsxs("div",{className:"group/project-row flex w-full items-stretch rounded-sm bg-muted/15 text-[9px] font-medium text-muted-foreground/70 transition-all duration-150 hover:bg-muted/30 hover:text-foreground active:scale-[0.98] active:bg-muted/40",children:[e.jsxs("button",{type:"button",onClick:a,"aria-expanded":!r,title:t,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-l-sm px-2 py-1 text-left",children:[e.jsx(Ke,{className:O("h-3 w-3 shrink-0 transition-transform duration-200",!r&&"rotate-90")}),e.jsx(Bt,{className:"h-3 w-3 shrink-0 text-muted-foreground/55"}),e.jsx("span",{className:"min-w-0 truncate font-mono",children:s}),e.jsx("span",{className:"ml-2 shrink-0 rounded-sm bg-background/55 px-1 py-0 tabular-nums text-[8px] font-medium leading-3 text-muted-foreground/45",children:n})]}),l&&e.jsx("button",{type:"button",onClick:l,"aria-label":`Capabilities for ${t}`,title:`Capabilities for ${t}`,className:"pointer-events-none mr-0.5 flex h-4 w-4 shrink-0 translate-y-px self-center items-center justify-center rounded-sm text-muted-foreground/50 opacity-0 transition-all hover:bg-primary/10 hover:text-primary focus-visible:pointer-events-auto focus-visible:opacity-100 group-hover/project-row:pointer-events-auto group-hover/project-row:opacity-100",children:e.jsx(As,{className:"h-2.5 w-2.5"})}),e.jsx("button",{type:"button",onClick:i,"aria-label":`New chat in ${t}`,title:`New chat in ${t}`,className:"pointer-events-none ml-auto flex h-4 w-4 shrink-0 translate-y-px self-center items-center justify-center rounded-sm text-muted-foreground/50 opacity-0 transition-all hover:bg-primary/10 hover:text-primary focus-visible:pointer-events-auto focus-visible:opacity-100 group-hover/project-row:pointer-events-auto group-hover/project-row:opacity-100",children:e.jsx(Ms,{className:"h-2.5 w-2.5"})})]})}const yo="meshy-task-sidebar-tree-state";function ia(t){return Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}function wn(){try{return globalThis.window?.localStorage??globalThis.localStorage??null}catch{return null}}function la(t){if(!t)return{collapsedNodes:[],collapsedDirs:[]};try{const s=t.getItem(yo);if(!s)return{collapsedNodes:[],collapsedDirs:[]};const n=JSON.parse(s);return{collapsedNodes:ia(n.collapsedNodes),collapsedDirs:ia(n.collapsedDirs)}}catch{return{collapsedNodes:[],collapsedDirs:[]}}}function gm(t,s){if(t)try{t.setItem(yo,JSON.stringify(s))}catch{}}function da(t,s){if(!t.has(s))return t;const n=new Set(t);return n.delete(s),n}function bm(t,s){if(!s)return null;for(const n of t){const r=n.nodeId??"__unassigned__";for(const a of n.dirs)if(a.tasks.some(i=>i.id===s))return{nodeKey:r,dirKey:`${r}::${a.path}`}}return null}function ca(t,s,n){return n?{collapsedNodes:da(t,n.nodeKey),collapsedDirs:da(s,n.dirKey)}:{collapsedNodes:t,collapsedDirs:s}}function vm(t,s,n){const r=t.filter(d=>d.status==="completed"),a=new Set((s?r:[...r].sort((d,c)=>c.updatedAt-d.updatedAt).slice(0,zn)).map(d=>d.id));n&&r.some(d=>d.id===n)&&a.add(n);const i=t.filter(d=>d.status!=="completed"||a.has(d.id)),l=r.length-a.size;return{visibleTasks:i,hiddenCompletedCount:Math.max(0,l)}}const bs="h-6 rounded-sm border-0 bg-muted/45 px-2 py-0 text-[10px] leading-none text-foreground shadow-none hover:bg-muted/65 focus:bg-muted/65 focus:ring-0 focus:ring-offset-0 [&>svg]:h-3 [&>svg]:w-3",vs="py-1 pl-6 pr-1.5 text-[10px] leading-4 [&_svg]:h-3 [&_svg]:w-3";function ua({toolbarTasks:t,activeTaskId:s,tasksLoading:n,tasksError:r,isLeader:a,scope:i,agentFilter:l,nodeFilter:d,taskKindFilter:c,agentOptions:m,nodeOptions:g,nodeNameById:f,nodeWorkDirById:u,nodeStatusById:p,completedGroupByKey:N,devBoxNodeIds:y=new Set,devBoxStartNodeIds:D=new Set,devBoxStartingNodeIds:h=new Set,leaderNodeId:E,searchQuery:x,selectedTaskIds:b,allVisibleTasksSelected:S,someVisibleTasksSelected:T,canBatchArchive:C,onScopeChange:I,onAgentFilterChange:k,onNodeFilterChange:P,onTaskKindFilterChange:M,onToggleTaskSelected:A,onToggleAllVisibleTasks:B,onBatchArchive:R,onBatchDelete:H,onCreateTask:Z,onOpenNodeSettings:te,onOpenNodeCapabilities:F,onOpenProjectCapabilities:X,onOpenDevBox:$,onStartDevBox:Y,onLoadCompletedTasks:w,onSelectTask:V}){const[j,q]=o.useState(!1),[z,W]=o.useState(()=>b.size>0),[L,ae]=o.useState(!1),[oe,he]=o.useState(null),{markScrollbarActive:ne,scrollbarActive:Q}=lo(),J=b.size,le=!!(a&&(z||J>0)),_=i!=="active"||d!=="all"||l!=="all"||c!=="all",G=x.trim().length>0,[ue,ye]=o.useState(()=>new Set(la(wn()).collapsedNodes)),[Ie,Be]=o.useState(()=>new Set(la(wn()).collapsedDirs)),[pt,Ye]=o.useState(new Set),$e=o.useMemo(()=>Qi(t,f,E,u),[t,f,E,u]),Te=o.useMemo(()=>bm($e,s),[$e,s]),dt=o.useRef(null),re=$e.length===1,ge=$e.length>0,ve=re&&(_||G),qe=!!(a&&($e.length>0||J>0)),ct=o.useCallback(K=>{ye(Ee=>{const Ae=new Set(Ee);return Ae.has(K)?Ae.delete(K):Ae.add(K),Ae})},[]),je=o.useCallback(K=>{Be(Ee=>{const Ae=new Set(Ee);return Ae.has(K)?Ae.delete(K):Ae.add(K),Ae})},[]),Je=o.useCallback(K=>{Ye(Ee=>{const Ae=new Set(Ee);return Ae.add(K),Ae})},[]);o.useEffect(()=>{gm(wn(),{collapsedNodes:Array.from(ue),collapsedDirs:Array.from(Ie)})},[Ie,ue]),o.useEffect(()=>{if(!Te||!s)return;const K=`${s}:${Te.nodeKey}:${Te.dirKey}`;dt.current!==K&&(dt.current=K,ye(Ee=>ca(Ee,new Set,Te).collapsedNodes),Be(Ee=>ca(new Set,Ee,Te).collapsedDirs))},[s,Te]);const ut=o.useCallback(K=>{W(!0),B(K)},[B]),St=o.useCallback(K=>{if(K===!0&&!S){W(!0),ae(!0);return}ut(K===!0)},[S,ut]),Oe=o.useCallback(()=>{ut(!0),ae(!1)},[ut]),rt=o.useCallback(()=>{B(!1),W(!1),ae(!1)},[B]);o.useEffect(()=>{a||(W(!1),ae(!1))},[a]);const Ce=le?e.jsxs(Jt,{open:L,onOpenChange:ae,children:[e.jsxs("label",{className:"flex items-center gap-[5px] text-[9px] font-medium uppercase tracking-[0.12em] text-muted-foreground/75",children:[e.jsx(ls,{className:"h-3 w-3 [&_svg]:h-2.5 [&_svg]:w-2.5",checked:T&&!S?"indeterminate":S,onCheckedChange:St,"aria-label":"Select all visible tasks"}),e.jsx("span",{children:"Select all"})]}),L&&e.jsxs(Zt,{children:[e.jsxs(Xt,{children:[e.jsx(es,{children:"Select every visible task?"}),e.jsx(ts,{children:"This will select every task currently shown in the rail and expose bulk archive/delete actions. Cancel now unless you intend to act on all visible tasks together."})]}),e.jsxs(ss,{children:[e.jsx(ns,{autoFocus:!0,children:"Cancel"}),e.jsx(rs,{onClick:Oe,children:"Select all"})]})]})]}):e.jsxs(ee,{variant:"ghost",size:"sm",onClick:()=>W(!0),className:"h-5 rounded-sm px-1.5 text-[9px] font-medium uppercase tracking-[0.12em] text-muted-foreground/75 hover:text-foreground",children:[e.jsx(Zl,{className:"h-3 w-3"}),"Multi select"]}),$t=J>0?e.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[e.jsxs("div",{className:"text-[9px] font-semibold leading-3 text-foreground",children:[J," task",J!==1?"s":""," selected"]}),!C&&e.jsx("div",{className:"max-w-48 text-[9px] leading-3.5 text-muted-foreground",children:"Only completed, failed, cancelled, or archived tasks can be archived."})]}):null,Ct=J>0?e.jsxs("div",{className:"flex flex-wrap justify-end gap-1",children:[e.jsxs(Jt,{children:[e.jsx(kn,{asChild:!0,children:e.jsxs(ee,{variant:"ghost",size:"sm",disabled:!C,className:"h-5 gap-1 rounded-sm bg-muted/45 px-1.5 text-[8px] text-foreground/80 shadow-none hover:bg-muted/65 [&_svg]:size-3",children:[e.jsx(ud,{}),"Archive"]})}),e.jsxs(Zt,{children:[e.jsxs(Xt,{children:[e.jsxs(es,{children:["Archive ",J," selected task",J!==1?"s":"","?"]}),e.jsx(ts,{children:"These tasks leave the default view immediately. Cancel if any selected task still needs to stay visible in active work."})]}),e.jsxs(ss,{children:[e.jsx(ns,{autoFocus:!0,children:"Cancel"}),e.jsx(rs,{onClick:R,disabled:!C,children:"Archive"})]})]})]}),e.jsxs(Jt,{children:[e.jsx(kn,{asChild:!0,children:e.jsxs(ee,{variant:"destructive",size:"sm",className:"h-5 gap-1 rounded-sm px-1.5 text-[8px] [&_svg]:size-3",children:[e.jsx(za,{}),"Delete"]})}),e.jsxs(Zt,{children:[e.jsxs(Xt,{children:[e.jsxs(es,{children:["Delete ",J," selected task",J!==1?"s":""," and saved logs?"]}),e.jsx(ts,{children:"This cannot be undone. Cancel unless you are certain every selected task and log should be removed now."})]}),e.jsxs(ss,{children:[e.jsx(ns,{autoFocus:!0,children:"Cancel"}),e.jsx(rs,{onClick:H,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]}):null;return e.jsxs(e.Fragment,{children:[e.jsxs("aside",{className:"dashboard-task-sidebar dashboard-panel dashboard-panel-muted animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsxs("div",{className:"dashboard-task-sidebar__header shrink-0 bg-card/24 px-2.5 py-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("div",{className:"flex min-w-0 items-stretch gap-1.5",children:[e.jsxs(ee,{onClick:()=>Z("chat"),className:"h-8 w-[6.75rem] justify-start rounded-sm px-2.5 text-left text-[11px] shadow-[0_10px_24px_-18px_hsl(var(--primary)/0.9)]",children:[e.jsx(Ms,{className:"h-3.5 w-3.5"}),"New chat"]}),e.jsxs(ee,{variant:"outline",onClick:()=>Z("native"),className:"h-8 w-[7.75rem] justify-start rounded-sm border-0 bg-muted/45 px-2.5 text-left text-[11px] text-foreground shadow-none hover:bg-muted/65 hover:text-foreground",children:[e.jsx($n,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Load session"]})]}),e.jsx(ee,{variant:"ghost",size:"icon",onClick:()=>q(K=>!K),className:O("ml-auto h-8 w-8 shrink-0 rounded-sm text-muted-foreground shadow-none hover:bg-muted/55 hover:text-foreground",(j||_)&&"bg-primary/8 text-primary hover:bg-primary/12 hover:text-primary"),title:"Filters",children:e.jsx(Sd,{className:"h-3.5 w-3.5"})})]}),(j||_)&&e.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-1 sm:grid-cols-2",children:[e.jsxs(Ne,{value:i,onValueChange:K=>I(K),children:[e.jsx(ke,{className:bs,children:e.jsx(Pe,{})}),e.jsx(Se,{children:Yi.map(K=>e.jsx(xe,{value:K.value,className:vs,children:K.label},K.value))})]}),e.jsxs(Ne,{value:d,onValueChange:P,children:[e.jsx(ke,{className:bs,children:e.jsx(Pe,{placeholder:"Node"})}),e.jsx(Se,{children:g.map(K=>e.jsx(xe,{value:K.value,className:vs,children:K.label},K.value))})]}),e.jsxs(Ne,{value:l,onValueChange:k,children:[e.jsx(ke,{className:bs,children:e.jsx(Pe,{placeholder:"Agent"})}),e.jsx(Se,{children:m.map(K=>e.jsx(xe,{value:K,className:vs,children:K==="all"?"All agents":K},K))})]}),e.jsxs(Ne,{value:c,onValueChange:K=>M(K),children:[e.jsx(ke,{className:bs,children:e.jsx(Pe,{placeholder:"Type"})}),e.jsx(Se,{children:Ji.map(K=>e.jsx(xe,{value:K.value,className:vs,children:K.label},K.value))})]})]})]}),e.jsx("div",{className:O("scrollbar-line min-h-0 flex-1 overflow-y-auto pl-2.5 pr-1.5 py-2",Q&&"scrollbar-line-active"),onScroll:ne,children:$e.length>0?e.jsx("div",{className:"space-y-1",children:$e.map(K=>{const Ee=K.nodeId??"__unassigned__",Ae=K.dirs.reduce((De,Ve)=>De+Ve.tasks.length,0),at=ge&&!ve&&ue.has(Ee),qt=K.nodeId!==null&&p.get(K.nodeId)==="offline",Tt=!!(a&&K.nodeId);return e.jsxs("div",{className:"space-y-1",children:[ge&&e.jsxs("div",{className:"flex w-full items-stretch rounded-sm bg-gradient-to-r from-primary/8 to-muted/20 text-left text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground transition-all duration-150 hover:from-primary/12 hover:to-muted/30 hover:text-foreground active:scale-[0.99] active:from-primary/15",children:[e.jsxs("button",{type:"button",onClick:()=>ct(Ee),"aria-expanded":!at,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-sm px-2 py-1.5 text-left",children:[e.jsx(Ke,{className:O("h-3.5 w-3.5 shrink-0 transition-transform duration-200",!at&&"rotate-90")}),e.jsx(Aa,{className:"h-3 w-3 shrink-0 text-muted-foreground/55"}),e.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:K.nodeName}),e.jsxs(Ue,{variant:"outline",className:"shrink-0 whitespace-nowrap rounded-sm border-transparent bg-background/55 px-1.5 py-0 text-[7px] font-semibold leading-3.5 text-muted-foreground shadow-none normal-case tracking-normal",children:[Ae," task",Ae===1?"":"s"]})]}),e.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[qt&&e.jsx(Ue,{variant:"outline",className:"rounded-sm border-destructive/25 bg-destructive/10 px-1 py-0 text-[8px] font-semibold leading-3 text-destructive shadow-none",children:"offline"}),K.nodeId===E&&e.jsx(Ue,{variant:"outline",className:"rounded-sm border-transparent bg-primary/8 px-1 py-0 text-[8px] font-medium leading-3.5 text-primary shadow-none",children:"leader"})]})]}),Tt&&K.nodeId&&e.jsx("span",{className:"flex shrink-0 items-center pr-1.5",children:e.jsx(Gn,{nodeId:K.nodeId,nodeName:K.nodeName,onOpenSettings:te,onOpenServicePreview:()=>he({id:K.nodeId,name:K.nodeName}),onOpenCapabilities:F,onOpenDevBox:$,onStartDevBox:Y,showConfigureDevBox:y.has(K.nodeId),showStartDevBox:D.has(K.nodeId)||h.has(K.nodeId),startDevBoxPending:h.has(K.nodeId)})})]}),e.jsx("div",{className:O("grid transition-[grid-template-rows] duration-300 ease-in-out",at?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:"overflow-hidden",children:K.dirs.map(De=>{const Ve=`${Ee}::${De.path}`,Et=Ie.has(Ve),mt=Fa(De.path),ot=N?.get(Ve),At=ot?{visibleTasks:De.tasks,hiddenCompletedCount:Math.max(0,ot.total-ot.returned)}:vm(De.tasks,pt.has(Ve),s),{visibleTasks:gt,hiddenCompletedCount:_e}=At;return e.jsxs("div",{className:O("space-y-0.5 rounded-xl",ge&&"pl-2.5"),children:[e.jsx(pm,{dirPath:De.path,label:mt,taskCount:De.tasks.length,collapsed:Et,onToggle:()=>je(Ve),onCreateTask:()=>Z("chat",{assignTo:K.nodeId,project:De.path==="default workspace"?"":De.path}),onOpenCapabilities:K.nodeId&&X?()=>X(K.nodeId,De.path==="default workspace"?u?.get(K.nodeId)??De.path:De.path):void 0}),e.jsx("div",{className:O("grid transition-[grid-template-rows] duration-300 ease-in-out",Et?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:O("overflow-hidden",ge?"pl-2":"pl-0"),children:e.jsxs("div",{className:"space-y-px py-0.5",children:[gt.map(ce=>{const Me=ce.id===s,Re=ce.assignedTo?p.get(ce.assignedTo):void 0,Fe=!!ce.assignedTo&&(Re?Re==="offline":ce.assignedNodeAvailable===!1);return e.jsxs("div",{className:O("animate-task-row-reveal relative flex items-center gap-1.5 rounded-sm px-2 py-1.5 transition-all duration-150",Me?'bg-primary/10 before:absolute before:left-0 before:top-1/2 before:h-1/2 before:w-[2px] before:-translate-y-1/2 before:rounded-full before:bg-primary before:content-[""]':"hover:bg-muted/40"),children:[le&&e.jsx("div",{className:"flex shrink-0",onClick:Vt=>Vt.stopPropagation(),children:e.jsx(ls,{className:"h-3 w-3 [&_svg]:h-2.5 [&_svg]:w-2.5",checked:b.has(ce.id),onCheckedChange:Vt=>A(ce.id,Vt===!0),"aria-label":`Select ${ce.title}`})}),e.jsxs("button",{type:"button",onClick:()=>V(ce.id),"aria-current":Me?"page":void 0,className:"relative min-w-0 flex-1 pr-8 text-left",children:[e.jsx("div",{className:"flex items-center gap-1.5 pr-1",children:e.jsx("span",{className:O("min-w-0 flex-1 truncate text-[10px] font-medium leading-4",Me?"text-foreground":"text-foreground/80"),children:ce.title})}),e.jsx("span",{className:O("absolute right-0 top-0 shrink-0 tabular-nums text-[8px] leading-4",Me?"text-primary/75":"text-muted-foreground/55"),children:Zi(ce.updatedAt)}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-0.5",children:[e.jsx("span",{className:"rounded-sm bg-muted/35 px-1 py-0 font-mono text-[8px] leading-3 text-muted-foreground/65",children:ce.agent}),ce.activeShare&&e.jsx(Ue,{variant:"outline",className:"rounded-sm border-primary/25 bg-primary/8 px-1 py-0 text-[8px] leading-3 text-primary shadow-none",children:"shared"}),Fe&&e.jsx(Ue,{variant:"outline",className:"rounded-sm border-destructive/25 bg-destructive/8 px-1 py-0 text-[8px] leading-3 text-destructive shadow-none",children:"unavailable"})]}),e.jsx(Ia,{status:ce.status,isNative:ce.conversationKind==="nativeSession",size:"compact",className:"absolute bottom-1 right-0"})]})]},ce.id)}),_e>0&&e.jsxs("button",{type:"button",onClick:()=>{ot&&w?w(ot):Je(Ve)},className:"mt-1 flex w-full items-center justify-center gap-1 rounded-sm border border-dashed border-border/55 bg-background/35 px-2 py-1 text-[9px] font-medium text-muted-foreground transition-colors hover:border-primary/35 hover:bg-primary/8 hover:text-primary","aria-label":`Load ${_e} more completed tasks in ${mt}`,children:[e.jsx(Qe,{className:"h-3 w-3"}),"Load ",_e," more completed"]})]})})})]},Ve)})})})]},Ee)})}):n?e.jsx("div",{className:"space-y-2 px-1",children:[1,2,3].map(K=>e.jsx("div",{className:"rounded-xl border border-border/40 bg-background/30 px-3 py-3",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"mt-1 h-2.5 w-2.5 shrink-0 animate-pulse rounded-full bg-muted-foreground/20"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-2.5 animate-pulse rounded-full bg-muted-foreground/15",style:{width:`${60+K*12}%`,animationDelay:`${K*120}ms`}}),e.jsx("div",{className:"h-2 w-24 animate-pulse rounded-full bg-muted-foreground/10",style:{animationDelay:`${K*120+60}ms`}})]})]})},K))}):e.jsx("div",{className:"rounded-xl border border-dashed border-border/70 bg-background/35 px-3 py-5 text-[11px] text-muted-foreground",children:r||"No tasks match this view."})}),qe?e.jsx("div",{className:"shrink-0 px-2.5 pb-2.5 pt-1.5",children:le&&J>0?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[$t,e.jsx(ee,{variant:"ghost",size:"sm",onClick:rt,className:"h-5 shrink-0 rounded-sm px-1.5 text-[9px]",children:"Clear"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"flex min-w-0 shrink-0 items-center",children:Ce}),Ct]})]}):e.jsxs("div",{className:"flex items-end justify-between gap-2",children:[e.jsx("div",{className:"flex min-w-0 shrink-0 items-center",children:Ce}),le&&e.jsx(ee,{variant:"ghost",size:"sm",onClick:rt,className:"h-5 shrink-0 rounded-sm px-1.5 text-[9px]",children:"Done"})]})}):null]}),e.jsx(hm,{node:oe,open:oe!==null,onOpenChange:K=>{K||he(null)}})]})}async function wm(t,s){try{const n=await Xi(t,s),r={...n,url:Ma(n.url)};if(globalThis.navigator?.clipboard?.writeText)try{await globalThis.navigator.clipboard.writeText(r.url),de.success("Shared link copied")}catch{de.success("Shared link created")}else de.success("Shared link created");return r}catch(n){de.error(n instanceof Error?n.message:"Failed to create shared link");return}}async function ym(t){try{return await el(t),de.success("Shared link stopped"),!0}catch(s){return de.error(s instanceof Error?s.message:"Failed to stop shared link"),!1}}function jm(t,s,n){const r=o.useCallback(()=>{s(),n()},[s,n]),a=o.useCallback(async l=>{if(!t)return;const d=await wm(t.id,l);return d&&r(),d},[t,r]),i=o.useCallback(async()=>{if(!t)return!1;const l=await ym(t.id);return l&&r(),l},[t,r]);return{handleShareTask:a,handleStopShareTask:i}}function ma(t,s,n){const r=o.useRef(s);r.current=s,o.useEffect(()=>{let l=0,d=0;const c=f=>{const u=f.touches[0];u&&(l=u.clientX,d=u.clientY)},m=f=>{const u=f.changedTouches[0];if(!u)return;const p=u.clientX-l;Math.abs(u.clientY-d)>100||Math.abs(p)<50||(p>0?r.current.onSwipeRight?.():r.current.onSwipeLeft?.())},g=t?.current??document;return g.addEventListener("touchstart",c,{passive:!0}),g.addEventListener("touchend",m,{passive:!0}),()=>{g.removeEventListener("touchstart",c),g.removeEventListener("touchend",m)}},[t,n?.threshold,n?.maxVertical])}const Nm="(min-width: 1024px)",km="(min-width: 1800px)";function ha(t){return globalThis.window?.matchMedia?.(t)?.matches??!1}function Sm(){const t=globalThis.document?.documentElement;if(!t||!globalThis.window?.getComputedStyle)return 16;const s=Number.parseFloat(globalThis.window.getComputedStyle(t).fontSize);return Number.isFinite(s)&&s>0?s:16}function Cm(){const[t,s]=o.useState(()=>tl(or(),sl({operationsOpen:ha(km)}))),[n,r]=o.useState(!1),a=o.useRef(null),i=o.useRef(null),l=o.useRef(null),d=t.layout.desktopTasksOpen,c=t.layout.operationsOpen,m=t.sizes;o.useEffect(()=>{nl(or(),t)},[t]);const g=o.useCallback((D,h)=>{s(E=>{const x=E.layout[D],b=typeof h=="function"?h(x):h;return b===x?E:{...E,layout:{...E.layout,[D]:b}}})},[]),f=o.useCallback(D=>{g("desktopTasksOpen",D)},[g]),u=o.useCallback(D=>{g("operationsOpen",D)},[g]);ma(i,{onSwipeLeft:()=>r(!1)}),ma(l,{onSwipeRight:()=>u(!1)});const p=o.useCallback(()=>{if(ha(Nm)){f(D=>!D);return}r(D=>!D)},[f]);o.useEffect(()=>{const D=E=>{const x=a.current;if(!x)return;E.preventDefault();const b=al(x.panel,x.startSize,x.startClientX,x.startClientY,E.clientX,E.clientY,x.rootFontSize);s(S=>({...S,sizes:{...S.sizes,[x.panel]:b}}))},h=()=>{a.current=null};return globalThis.window?.addEventListener("pointermove",D),globalThis.window?.addEventListener("pointerup",h),globalThis.window?.addEventListener("pointercancel",h),()=>{globalThis.window?.removeEventListener("pointermove",D),globalThis.window?.removeEventListener("pointerup",h),globalThis.window?.removeEventListener("pointercancel",h)}},[]);const N=o.useCallback((D,h)=>{h.preventDefault(),h.currentTarget.setPointerCapture?.(h.pointerId),a.current={panel:D,startSize:m[D],startClientX:h.clientX,startClientY:h.clientY,rootFontSize:Sm()}},[m]),y=o.useCallback((D,h)=>{h.preventDefault(),s(E=>({...E,sizes:{...E.sizes,[D]:rl(D,E.sizes[D],h.deltaY)}}))},[]);return{desktopTasksOpen:d,mobileTasksPanelOpen:n,mobileTasksPanelRef:i,operationsOpen:c,operationsPanelRef:l,panelResize:{sizes:{tasks:qs(m.tasks),operations:qs(m.operations),terminal:qs(m.terminal)},onPointerDown:N,onWheel:y},setMobileTasksPanelOpen:r,setOperationsOpen:u,toggleTasksPanel:p}}function Tm(t,s){const n=s.taskId,r=s.updates;return typeof n!="string"||!r||typeof r!="object"?t:t.map(a=>a.id===n?{...a,...r}:a)}const Em="notify_desktop_task";function Am(t=jo()){const s=t?.__TAURI__?.core?.invoke;return typeof s=="function"?s:null}async function Dm(t,s=jo()){const n=Am(s);return n?(await n(Em,t),!0):!1}function _m(t,s){const n=[];for(const r of s){const a=Mm(r.status);if(!a)continue;const i=t.get(r.id);!i||i.status===r.status||n.push({taskId:r.id,title:r.title.trim()||"Meshy task",status:a,assignedNodeName:r.assignedNodeName??null,projectPath:r.effectiveProjectPath??r.project??null})}return n}function Mm(t){return t==="completed"||t==="failed"?t:null}function jo(){return typeof window>"u"?null:window}function Pm({isLeader:t,selfId:s}){return{...!t&&s?{assignedTo:s}:{},completedLimitPerProject:zn}}function Rn(t){return`${t.assignedTo??"__unassigned__"}::${t.projectPath}`}function Im(t,s){const n=new Map(t.map(r=>[r.id,r]));for(const r of s)n.set(r.id,r);return Array.from(n.values())}function Rm(t,s,n=new Set){return!s||n.has(s.id)||t.some(r=>r.id===s.id)?t:Xa(t,s)}function Lm({isLeader:t,selfId:s,sseConnected:n,preservedTask:r,subscribe:a}){const[i,l]=o.useState([]),[d,c]=o.useState([]),[m,g]=o.useState(!0),[f,u]=o.useState(null),p=o.useRef(new Set),N=o.useRef(null),y=o.useRef(null),D=o.useCallback(async()=>{try{const b=await ir(Pm({isLeader:t,selfId:s}));l(Rm(b.tasks,r,p.current)),c(b.completedGroups??[]),u(null)}catch(b){u(b instanceof Error?b.message:"Failed to load tasks")}finally{g(!1)}},[t,r,s]),h=o.useCallback(async b=>{if(!b.hasMore||!b.nextCursor)return;const S=await ir({status:"completed",assignedTo:b.assignedTo??"__unassigned__",projectPath:b.projectPath,cursor:b.nextCursor,limit:zn});l(T=>Im(T,S.tasks)),c(T=>T.map(C=>Rn(C)===Rn(b)?{...C,returned:Math.min(C.total,C.returned+S.tasks.length),hasMore:S.hasMore===!0,nextCursor:S.nextCursor??null}:C))},[]),E=o.useCallback(()=>{y.current===null&&(y.current=window.setTimeout(()=>{y.current=null,D()},ol))},[D]),x=o.useCallback(b=>{const S=new Set(b);if(S.size!==0){for(const T of S)p.current.add(T);l(T=>T.filter(C=>!S.has(C.id)))}},[]);return il(D,cl(n)),o.useEffect(()=>()=>{y.current!==null&&(window.clearTimeout(y.current),y.current=null)},[]),o.useEffect(()=>{const b=N.current;if(b)for(const S of _m(b,i))Dm(S).catch(()=>{});N.current=new Map(i.map(S=>[S.id,S]))},[i]),o.useEffect(()=>{const b=[a("task.updated",S=>{l(T=>Tm(T,S.data))}),a("task.status",S=>{l(T=>ll(T,S.data))}),a("node",S=>{lr(S.type)&&E()}),a("task",S=>{if(S.type==="task.deleted"){const T=S.data.taskId;typeof T=="string"&&p.current.add(T),l(C=>dl(C,S.data))}lr(S.type)&&E()})];return()=>b.forEach(S=>S())},[a,E]),{completedGroups:d,fetchTasks:D,loadCompletedTasksPage:h,removeTasksFromList:x,setTasks:l,tasks:i,tasksError:f,tasksLoading:m}}function No(t){return t.map(s=>({...s}))}function Bm(t,s){const n=s.get(t);return{logs:n?No(n.logs):[],transcriptLoading:n?.loaded!==!0}}function Om(t,s){return s.data.nodeId===t.self.id||s.data.name===t.self.name||s.data.endpoint===t.self.endpoint}function Fm(t,s){const n=t.data.name;if(typeof n=="string"&&n.length>0)return n;const r=t.data.nodeId;return typeof r=="string"?s?.get(r)??r:"node"}function zm({cluster:t,subscribe:s}){o.useEffect(()=>{if(t?.self?.role!=="leader")return;const n=new Map(t.nodes.map(r=>[r.id,r.name]));return n.set(t.self.id,t.self.name),s("node",r=>{const a=Fm(r,n),i=Om(t,r);r.type==="node.joined"&&!i&&de.success(`${a} joined the cluster`),r.type==="node.left"&&!i&&de.message(`${a} left the cluster`)})},[t,s])}const Um=[0,300,1e3,2e3];function $m({task:t,getActiveTaskId:s,setLogs:n,setPendingMessages:r,setTranscriptLoading:a}){t.conversationKind==="nativeSession"&&(async()=>{try{for(const i of Um){if(i>0&&await new Promise(l=>setTimeout(l,i)),s()!==t.id)return;try{const l=await Sn(t.id);if(s()!==t.id||(n(d=>Ka(d,l.logs)),r(d=>Tn(d,l.logs)),l.total>0))return}catch{}}}finally{s()===t.id&&a?.(!1)}})()}const ko=8;function qm(t,s){return Le(t??{})===Le(s??{})}function Vm(t){return t&&"status"in t&&typeof t.status=="string"?t.status:void 0}function fa(t,s){return{...t,enabled:!0,alwaysOnline:s}}function So(t){return t?.status?.trim()||t?.lastStatus?.trim()||"Unknown"}function Hm({operationStarting:t,loading:s,refreshing:n,savedStatus:r,fallbackStatus:a}){return t?"Starting":s?"Listing DevBoxes":n?"Refreshing":r??a}async function Km(t,s=Ua){return(await s({nodeId:t,kind:"devbox.start"})).filter(r=>r.kind==="devbox.start").sort((r,a)=>(a.updatedAt??a.createdAt)-(r.updatedAt??r.createdAt)).slice(0,ko)}function Gm(t){return t.charAt(0).toUpperCase()+t.slice(1)}function Wm(t){const s=t.completedAt??t.startedAt??t.updatedAt??t.createdAt;return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(s))}function Qm(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function xa(t,s){const r=Qm(t)?.[s];return typeof r=="string"&&r.trim()?r.trim():null}function Ym(t){if(t.status==="failed")return t.error||"Operation failed";const s=xa(t.result,"operationId");if(s)return`MCP operation ${s}`;const n=xa(t.payload,"previousStatus");return n?`Previous DevBox status: ${n}`:t.status==="succeeded"?"Completed":"Waiting for completion"}function Jm(t){return t==="succeeded"?"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":t==="failed"?"border-destructive/30 bg-destructive/10 text-destructive":t==="running"?"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300":"border-border/70 bg-muted/40 text-muted-foreground"}function pa({devbox:t,showStatus:s=!1}){return e.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:[e.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[e.jsx("span",{className:"font-medium",children:t.name}),t.projectName&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",t.projectName]})]}),s&&e.jsx("span",{className:"ml-auto shrink-0 rounded-sm border border-border/70 bg-background/70 px-1.5 py-0 text-[10px] leading-none text-muted-foreground",children:So(t)})]})}function Zm({error:t,loading:s,onToggle:n,open:r,operations:a}){return e.jsxs("div",{className:"min-w-0 max-w-full overflow-hidden rounded-sm border border-border/60 bg-muted/20 text-xs",children:[e.jsxs("button",{type:"button",onClick:n,"aria-expanded":r,className:"flex h-8 w-full items-center gap-2 px-3 text-left text-[11px] text-foreground hover:bg-muted/30",children:[e.jsx(Qe,{className:O("h-3 w-3 shrink-0 text-muted-foreground transition-transform",!r&&"-rotate-90")}),e.jsx(ks,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:"Operations history"}),s&&e.jsx(me,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground"}),!s&&a.length>0&&e.jsx("span",{className:"shrink-0 rounded-sm border border-border/70 bg-background/60 px-1.5 py-0 text-[10px] leading-none text-muted-foreground",children:a.length})]}),r&&e.jsxs("div",{className:"max-h-44 min-w-0 max-w-full overflow-y-auto border-t border-border/50 px-2 py-1.5",children:[s&&a.length===0&&e.jsxs("div",{className:"flex h-7 items-center gap-2 px-1 text-[10px] text-muted-foreground",children:[e.jsx(me,{className:"h-3 w-3 animate-spin"}),"Loading operations"]}),t&&e.jsx("div",{className:"px-1 py-1 text-[10px] text-destructive",children:t}),!s&&!t&&a.length===0&&e.jsx("div",{className:"px-1 py-1 text-[10px] text-muted-foreground",children:"No DevBox operations yet."}),a.map(i=>{const l=Ym(i);return e.jsxs("div",{className:"flex w-full min-w-0 max-w-full items-start gap-2 overflow-hidden rounded-sm px-1 py-1.5 text-[11px] hover:bg-background/40",children:[e.jsxs("div",{className:"min-w-0 flex-1 overflow-hidden",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-medium text-foreground",children:"Start DevBox"}),e.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:Wm(i)})]}),e.jsx("div",{className:"mt-0.5 w-full min-w-0 max-w-full overflow-x-auto whitespace-nowrap text-[10px] leading-3.5 text-muted-foreground",title:l,children:e.jsx("span",{className:"inline-block min-w-max",children:l})})]}),e.jsx("span",{className:O("shrink-0 rounded-sm border px-1.5 py-0 text-[10px] leading-4",Jm(i.status)),children:Gm(i.status)})]},i.id)})]})]})}function Xm({node:t,open:s,startInProgress:n=!1,onOpenChange:r,onRefresh:a}){const i=t?.id??null,l=s&&!n&&sa(t?.status,t?.devbox??null),[d,c]=o.useState([]),[m,g]=o.useState(()=>t?.devbox?Le(t.devbox):""),[f,u]=o.useState(()=>t?.devbox??null),[p,N]=o.useState(()=>na(t?.devbox??null)),[y,D]=o.useState(!1),[h,E]=o.useState(l),[x,b]=o.useState(!1),[S,T]=o.useState(!1),[C,I]=o.useState(()=>t?.devbox?.alwaysOnline===!0),[k,P]=o.useState(!1),[M,A]=o.useState([]),[B,R]=o.useState(!1),[H,Z]=o.useState(null),te=o.useMemo(()=>{const _=d.find(G=>Le(G)===m);return _||(Rt(f)&&Le(f)===m?f:void 0)},[f,d,m]),F=Vm(te??void 0),X=p?F??f?.lastStatus:f?.lastStatus??F,$=t?.status==="online"||t?.status==="busy"?"Running":"Unknown",Y=S||n,w=Hm({operationStarting:Y,loading:y,refreshing:h,savedStatus:X,fallbackStatus:$}),V=p&&!!te&&!qm(f,te),j=f?.alwaysOnline===!0!==C,q=im({nodeStatus:t?.status,status:w,current:f,selected:te}),z=!!q,W=!!te&&(V||j)&&!z,L=te??f,ae=o.useCallback(async()=>{if(i){E(!0);try{const _=await ul(i);u(_.devbox),g(Le(_.devbox))}catch(_){de.error(_ instanceof Error?_.message:"Failed to refresh DevBox status")}finally{E(!1)}}},[i]),oe=o.useCallback(async _=>{D(!0);try{const G=await ml();c(G),g(ue=>lm({previousKey:ue,baseDevBox:_,listed:G}))}catch(G){de.error(G instanceof Error?G.message:"Failed to load DevBoxes")}finally{D(!1)}},[]);o.useEffect(()=>{if(!s||!i)return;let _=!1;const G=t?.devbox??null,ue=na(G),ye=!n&&sa(t?.status,G);D(!1),E(ye),N(ue),u(G),I(G?.alwaysOnline===!0),P(!1),g(Rt(G)?Le(G):""),c([]);async function Ie(){ye&&await ae(),!_&&ue&&await oe(G)}return Ie(),()=>{_=!0}},[oe,t?.devbox,t?.status,i,s,ae,n]),o.useEffect(()=>{if(!s||!i)return;let _=!1;const G=i;async function ue(){R(!0),Z(null),A([]);try{const ye=await Km(G);if(_)return;A(ye)}catch(ye){if(_)return;A([]),Z(ye instanceof Error?ye.message:"Failed to load operation history")}finally{_||R(!1)}}return ue(),()=>{_=!0}},[i,s]);async function he(){N(!0),d.length===0&&await oe(f)}async function ne(){if(!(!t||!te)){b(!0);try{const _=await dr(t.id,fa(te,C));u(_.node.devbox??null),_.node.devbox&&g(Le(_.node.devbox)),N(!1),de.success(`Configured DevBox for ${t.name}`),await a?.()}catch(_){de.error(_ instanceof Error?_.message:"Failed to configure DevBox")}finally{b(!1)}}}async function Q(){if(!(!t||!q)){T(!0);try{if(te&&(V||j)){const G=await dr(t.id,fa(te,C));u(G.node.devbox??null),G.node.devbox&&g(Le(G.node.devbox)),N(!1)}const{operation:_}=await $a(t.id);u(G=>G&&{...G,lastStatus:"Starting",checkedAt:Date.now(),operationId:_.id}),A(G=>[_,...G.filter(ue=>ue.id!==_.id)].slice(0,ko)),de.success(`Start requested for ${t.name}`),await a?.()}catch(_){de.error(_ instanceof Error?_.message:"Failed to start DevBox")}finally{T(!1)}}}const J=y?"Loading DevBoxes...":d.length===0?"No DevBoxes available":"Select a DevBox",le=w==="Running"&&t?.status==="offline";return e.jsx(yt,{open:s,onOpenChange:r,children:e.jsxs(jt,{className:"w-[calc(100vw-2rem)] max-w-md grid-cols-[minmax(0,1fr)] gap-3 overflow-hidden rounded-sm p-4",children:[e.jsxs(Ts,{className:"min-w-0 max-w-full space-y-1 overflow-hidden",children:[e.jsx(Ot,{className:"text-sm",children:"Configure DevBox"}),e.jsxs(Es,{className:"max-w-full text-xs",children:["Bind ",t?.name?e.jsx("span",{className:"font-medium text-foreground",children:t.name}):"this node"," to an Azure Dev Box. Meshy will start it when the node is offline."]})]}),e.jsxs("div",{className:"min-w-0 max-w-full space-y-3 overflow-hidden",children:[(p||L)&&e.jsxs("div",{className:"flex min-h-9 w-full min-w-0 max-w-full items-center justify-between gap-3 overflow-hidden rounded-sm border border-border/60 bg-muted/20 px-3 py-2 text-xs",children:[e.jsx("div",{className:"min-w-0 flex-1",children:p?e.jsxs(Ne,{value:m,onValueChange:g,disabled:y||x||S||d.length===0,children:[e.jsx(ke,{className:"h-7 justify-start gap-2 rounded-none border-0 bg-transparent px-0 text-xs shadow-none focus:ring-0 focus:ring-offset-0 [&>span]:!flex [&>span]:!min-w-0 [&>span]:!flex-1 [&>span]:!items-center",children:y&&!te?e.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}),J]}):te?e.jsx(pa,{devbox:te}):e.jsx(Pe,{placeholder:J})}),e.jsx(Se,{children:d.map(_=>e.jsx(xe,{value:Le(_),textValue:`${_.name} ${_.projectName??""} ${So(_)}`,className:"pl-2 pr-7 text-xs [&>span:first-child]:left-auto [&>span:first-child]:right-2 [&>span:last-child]:w-full",children:e.jsx(pa,{devbox:_,showStatus:!0})},Le(_)))})]}):L&&e.jsxs("div",{className:"min-w-0 truncate",children:[e.jsx("span",{className:"font-medium text-foreground",children:L.name}),L.projectName&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",L.projectName]})]})}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs(Ue,{variant:"outline",className:"rounded-sm px-1.5 py-0 text-[10px]",children:[(y||h)&&e.jsx(me,{className:"mr-1 h-2.5 w-2.5 animate-spin"}),w]}),f?.name&&e.jsx(ee,{type:"button",variant:"ghost",size:"icon",onClick:()=>{he()},disabled:y||x||Y||p,"aria-label":"Edit DevBox binding",title:"Edit DevBox binding",className:"h-6 w-6 rounded-sm text-muted-foreground hover:text-foreground",children:y&&p?e.jsx(me,{className:"h-3 w-3 animate-spin"}):e.jsx(zt,{className:"h-3 w-3"})})]})]}),le&&e.jsx("div",{className:"rounded-sm border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300",children:"DevBox is running, but the Meshy node is not connected yet."}),e.jsxs("label",{className:"flex min-h-9 w-full min-w-0 max-w-full items-start gap-2 overflow-hidden rounded-sm border border-border/60 bg-muted/20 px-3 py-2 text-xs text-foreground",children:[e.jsx(ls,{checked:C,onCheckedChange:_=>I(_===!0),disabled:x||S||Y,"aria-label":"Always online",className:"mt-0.5 h-3.5 w-3.5"}),e.jsxs("span",{className:"min-w-0 leading-4",children:[e.jsx("span",{className:"block",children:"Always online"}),e.jsx("span",{className:"block text-[10px] leading-3.5 text-muted-foreground",children:"Meshy will start the DevBox automatically when it is Hibernated or Stopped."})]})]}),e.jsx(Zm,{error:H,loading:B,onToggle:()=>P(_=>!_),open:k,operations:M})]}),e.jsxs(Ra,{className:"gap-2 sm:space-x-0",children:[e.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>r(!1),disabled:x||S,className:"h-8 rounded-sm text-xs",children:"Close"}),z&&e.jsxs(ee,{size:"sm",onClick:Q,disabled:S,className:"h-8 rounded-sm text-xs",children:[S?e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Ds,{className:"h-3.5 w-3.5"}),"Start DevBox"]}),!z&&e.jsxs(ee,{size:"sm",onClick:ne,disabled:!W||x,className:"h-8 rounded-sm text-xs",children:[x&&e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}),"Save"]})]})]})})}async function eh(t,s=Ua){if(t.length===0)return new Set;const n=new Set(t),[r,a]=await Promise.all([s({kind:"devbox.start",status:"queued"}),s({kind:"devbox.start",status:"running"})]);return new Set([...r,...a].filter(i=>n.has(i.nodeId)).map(i=>i.nodeId))}function th({cluster:t,refresh:s}){const[n,r]=o.useState(null),[a,i]=o.useState(null),[l,d]=o.useState(()=>new Set),[c,m]=o.useState(()=>new Set),g=o.useMemo(()=>t?.nodes.find(h=>h.id===n)??null,[t?.nodes,n]),f=o.useMemo(()=>new Set((t?.nodes??[]).filter(h=>h.devbox?.enabled).map(h=>h.id)),[t?.nodes]),u=o.useMemo(()=>new Set((t?.nodes??[]).filter(h=>Ps(h.status,h.devbox?.lastStatus,h.devbox)).map(h=>h.id)),[t?.nodes]),p=o.useMemo(()=>new Set((t?.nodes??[]).filter(h=>Lt(h.devbox?.lastStatus)).map(h=>h.id)),[t?.nodes]),N=o.useMemo(()=>{const h=new Set(l);a&&h.add(a);for(const E of c)h.add(E);for(const E of p)h.add(E);return h},[c,a,l,p]);o.useEffect(()=>{let h=!1;const E=[...f];async function x(){try{const b=await eh(E);h||m(b)}catch{h||m(new Set)}}return x(),()=>{h=!0}},[f]),o.useEffect(()=>{d(h=>{let E=!1;const x=new Set(h);for(const b of h){const S=t?.nodes.find(T=>T.id===b);S?.status!=="online"&&(!S?.devbox?.lastStatus||Lt(S.devbox.lastStatus))||(x.delete(b),E=!0)}return E?x:h})},[t?.nodes]);const y=o.useCallback(async h=>{const E=t?.nodes.find(x=>x.id===h);if(E){i(h),d(x=>new Set(x).add(h));try{await $a(h),de.success(`Start requested for ${E.name}`),s()}catch(x){d(b=>{const S=new Set(b);return S.delete(h),S}),de.error(x instanceof Error?x.message:"Failed to start DevBox")}finally{i(null)}}},[t?.nodes,s]);return{devBoxDialog:e.jsx(Xm,{node:g,open:n!==null,startInProgress:g?N.has(g.id):!1,onOpenChange:h=>{h||r(null)},onRefresh:s}),devBoxNodeIds:f,devBoxStartNodeId:a,devBoxStartNodeIds:u,devBoxStartingNodeIds:N,openDevBox:r,startDevBox:y}}function sh(t){const[s,n]=o.useState(null),r=o.useCallback(i=>{t&&n(i)},[t]);return{nodeSettingsDialog:e.jsx(hl,{open:s!==null,onOpenChange:i=>{i||n(null)},initialSelectedNodeId:s??void 0,showTrigger:!1}),openNodeSettings:r}}function nh(t=!1){return!t}function rh({activeTaskId:t,fetchActiveTask:s,isRunning:n=!1,setPendingMessages:r,setTask:a,setTasks:i}){const l=o.useCallback((m,g)=>{a(f=>f&&f.id===m?{...f,queuedMessages:g}:f),i(f=>f.map(u=>u.id===m?{...u,queuedMessages:g}:u))},[a,i]),d=o.useCallback(async m=>{if(!t)return!1;const g=`local-${Date.now()}-${Math.random().toString(16).slice(2)}`,f=nh(n);f&&r(u=>[...u,{id:g,content:m,timestamp:new Date().toISOString()}]);try{const u=await fl(t,m);return u.queued&&(f&&r(p=>p.filter(N=>N.id!==g)),u.queuedMessages&&l(t,u.queuedMessages)),s(),!0}catch(u){return f&&r(p=>p.filter(N=>N.id!==g)),de.error(u instanceof Error?u.message:"Failed to send message"),!1}},[t,s,n,r,l]);return{cancelQueuedMessage:o.useCallback(async m=>{if(t)try{const g=await xl(t,m);l(t,g.queuedMessages),s()}catch(g){de.error(g instanceof Error?g.message:"Failed to cancel queued message")}},[t,s,l]),queueFollowUpMessage:d}}const ga="grid-cols-[1.5rem_5.25rem_4rem_minmax(8rem,1fr)_4rem_4rem_6rem]",ah={claudecode:"Claude Code",codex:"Codex",copilot:"Copilot"};function oh(t,s){const n=s.search.trim().toLowerCase();return t.filter(r=>s.agent!=="all"&&r.agent!==s.agent||s.kind!=="all"&&r.kind!==s.kind?!1:n?[r.name,r.description,r.source,r.version,r.agent,r.kind].some(a=>a?.toLowerCase().includes(n)):!0)}function Co(t){return t.kind==="mcp"?"-":t.sizeBytes<1024?`${t.sizeBytes} B`:t.sizeBytes<1024*1024?`${Math.round(t.sizeBytes/1024)} KB`:`${(t.sizeBytes/1024/1024).toFixed(1)} MB`}function ih({items:t,selectedIds:s,activeId:n,onToggleSelected:r,onOpenDetail:a}){return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden rounded-sm border border-border/60 bg-card/35",children:[e.jsxs("div",{className:O("grid shrink-0 gap-2 border-b border-border/55 bg-primary/6 px-2 py-1.5 text-[8px] font-semibold uppercase tracking-[0.14em] text-muted-foreground",ga),children:[e.jsx("span",{}),e.jsx("span",{children:"Agent"}),e.jsx("span",{children:"Kind"}),e.jsx("span",{children:"Name"}),e.jsx("span",{children:"Ver"}),e.jsx("span",{children:"Size"}),e.jsx("span",{children:"Source"})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:t.length>0?t.map(i=>e.jsxs("button",{type:"button",onClick:()=>a(i),className:O("grid h-7 w-full items-center gap-2 border-b border-border/30 px-2 text-left text-[10px] transition-colors hover:bg-primary/6",ga,n===i.id&&"bg-primary/10 text-primary shadow-[inset_2px_0_0_hsl(var(--primary))]"),children:[e.jsx("span",{onClick:l=>l.stopPropagation(),children:e.jsx(ls,{className:"h-3 w-3",checked:s.has(i.id),onCheckedChange:l=>r(i.id,l===!0),"aria-label":`Select ${i.name}`})}),e.jsx(lh,{agent:i.agent}),e.jsx("span",{children:i.kind}),e.jsx("span",{className:"truncate font-medium text-foreground",children:i.name}),e.jsx("span",{className:"truncate text-muted-foreground",children:i.version??"-"}),e.jsx("span",{className:"truncate text-muted-foreground",children:Co(i)}),e.jsx("span",{className:"truncate text-muted-foreground",children:i.source??"local"})]},i.id)):e.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-muted-foreground",children:"No capabilities match this view."})})]})}function lh({agent:t}){const s=ah[t];return e.jsx("span",{className:"block min-w-0 truncate text-[10px] font-medium leading-3 text-muted-foreground",title:s,children:s})}const ba=320,va=560,To=384,wa=360;function dh(t,s=va+wa){const n=Math.max(ba,Math.min(va,s-wa));return Math.min(Math.max(Math.round(t),ba),n)}function ch(t,s,n,r){return dh(t+s-n,r)}function uh({detail:t,deleting:s=!1,onDelete:n,desktopWidth:r=To,pending:a=!1}){const i={"--capability-detail-width":`${r}px`};if(!t)return e.jsx("aside",{"data-capability-detail-panel":"true",style:i,className:"hidden min-h-0 shrink-0 animate-panel-settle bg-gradient-to-b from-primary/6 via-card/28 to-background/60 px-3 py-3 text-[11px] text-muted-foreground lg:block lg:w-[var(--capability-detail-width)]",children:a?"Loading capability metadata...":"No capability selected."});const l=t.kind==="mcp"?"mcp":"files";return e.jsxs("aside",{"data-capability-detail-panel":"true",style:i,className:"flex min-h-0 w-full shrink-0 animate-panel-settle flex-col bg-gradient-to-b from-primary/6 via-card/28 to-background/60 px-3 py-2.5 lg:w-[var(--capability-detail-width)]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[e.jsx("div",{className:"truncate text-[13px] font-semibold leading-5 text-foreground",children:t.name}),e.jsxs("div",{className:"flex shrink-0 flex-wrap gap-1",children:[e.jsx(Ue,{variant:"secondary",className:"rounded-sm border-0 bg-card/72 px-1.5 py-0 text-[8px] text-primary",children:t.agent}),e.jsx(Ue,{variant:"outline",className:"rounded-sm border-0 bg-card/72 px-1.5 py-0 text-[8px] text-primary/90",children:t.kind})]})]}),n&&e.jsxs(Jt,{children:[e.jsx(kn,{asChild:!0,children:e.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-sm text-muted-foreground hover:text-destructive","aria-label":"Delete capability",title:"Delete capability",disabled:s,children:e.jsx(za,{className:"h-3.5 w-3.5"})})}),e.jsxs(Zt,{className:"max-w-[22rem] gap-2 rounded-xl p-4",children:[e.jsxs(Xt,{className:"space-y-1",children:[e.jsxs(es,{className:"text-sm",children:["Delete ",t.name,"?"]}),e.jsxs(ts,{className:"text-[11px] leading-4",children:["This removes the selected ",t.kind," from ",t.scope.kind==="global"?"the user profile":"this project","."]})]}),e.jsxs(ss,{className:"gap-1 pt-0 sm:space-x-1",children:[e.jsx(ns,{className:"h-7 rounded-lg px-2 text-[11px]",children:"Cancel"}),e.jsx(rs,{className:"h-7 rounded-lg px-2 text-[11px]",onClick:n,disabled:s,children:"Delete"})]})]})]})]}),e.jsxs("div",{className:"mt-1 grid grid-cols-2 gap-1 text-[9px]",children:[e.jsx(ws,{label:"Version",value:t.version??"-"}),e.jsx(ws,{label:"Size",value:Co(t)}),e.jsx(ws,{label:"Files",value:String(t.fileCount)}),e.jsx(ws,{label:"Source",value:t.source??"local"})]}),e.jsxs(Bn,{defaultValue:l,className:"mt-2 flex min-h-0 flex-1 flex-col",children:[e.jsxs(Ln,{className:"grid h-auto grid-cols-2 rounded-sm bg-primary/8 p-0.5",children:[t.kind==="mcp"?e.jsx(vt,{value:"mcp",className:"rounded-sm px-2 py-0.5 text-[9px]",children:"MCP"}):e.jsx(vt,{value:"files",className:"rounded-sm px-2 py-0.5 text-[9px]",children:"Files"}),e.jsx(vt,{value:"readme",className:"rounded-sm px-2 py-0.5 text-[9px]",children:"README"})]}),t.kind==="mcp"?e.jsx(lt,{value:"mcp",className:"mt-2 min-h-0 flex-1 overflow-auto",children:e.jsx(mh,{detail:t})}):e.jsx(lt,{value:"files",className:"mt-2 min-h-0 flex-1 overflow-auto",children:e.jsx(hh,{detail:t})}),e.jsx(lt,{value:"readme",className:"mt-2 min-h-0 flex-1 overflow-auto",children:t.readmeMarkdown?e.jsx(od,{content:t.readmeMarkdown,className:"overflow-hidden rounded-sm border-0 bg-background/70 shadow-none [&>div:first-child>div]:border-0 [&>div:first-child]:border-b-0",previewClassName:"px-3 py-2 text-[11px] leading-5",rawClassName:"text-[10px] leading-4"}):e.jsx(Qn,{children:"No README content."})})]},t.id)]})}function mh({detail:t}){const s=t.mcpPreview??[];return s.length===0?e.jsx(Qn,{children:"No MCP entries."}):e.jsx("div",{className:"space-y-1.5",children:s.map(n=>e.jsxs("div",{className:"rounded-sm bg-card/72 p-2 text-[10px] shadow-none",children:[e.jsx("div",{className:"font-semibold text-foreground",children:n.serverName}),e.jsx("pre",{className:"mt-1 max-h-64 overflow-auto rounded-sm bg-background/55 px-2 py-1 whitespace-pre-wrap break-all font-mono text-[9px] leading-4 text-muted-foreground",children:JSON.stringify(n.config,null,2)})]},n.serverName))})}function hh({detail:t}){const s=t.fileTree??[];return s.length===0?e.jsx(Qn,{children:"No files."}):e.jsx("div",{className:"space-y-1 overflow-auto rounded-sm bg-card/72 p-2 font-mono text-[9px] leading-4 text-muted-foreground shadow-none",children:s.map(n=>e.jsx("div",{children:n.relPath},n.relPath))})}function Qn({children:t}){return e.jsx("div",{className:"rounded-sm bg-primary/5 px-2 py-6 text-center text-[10px] text-muted-foreground",children:t})}function ws({label:t,value:s}){return e.jsxs("div",{className:"rounded-sm bg-card/72 px-2 py-0.5 shadow-none",children:[e.jsx("div",{className:"text-[7px] uppercase tracking-[0.14em] text-muted-foreground",children:t}),e.jsx("div",{className:"truncate text-[9px] font-medium text-foreground",children:s})]})}const fh=20,xh=288,ph=360,gh=440;function bh(){if(typeof window>"u"||typeof document>"u")return 1;const t=window.getComputedStyle(document.documentElement),s=t.zoom||t.getPropertyValue("--ui-zoom"),n=Number.parseFloat(s);return Number.isFinite(n)&&n>0?n:1}function vh({triggerRect:t,targetRect:s,viewportRect:n,compact:r,browserOpen:a=!1,portalAlign:i,cssZoom:l=1}){const d=Number.isFinite(l)&&l>0?l:1,c=8,m=n.top+c,g=n.bottom-c,f=n.left+c,u=n.right-c,p=Math.max(0,g-t.bottom-4),N=Math.max(0,t.top-m-4),y=r?N<140&&p>N:p>=220||p>=N,D=y?p:N,h=Math.max(140,g-m),E=r&&a,S=Math.min(h,E?gh:320,Math.max(E?ph:140,D)),T=xh*d,C=i==="end"?t.right-T:t.left,k=(Math.max(f,Math.min(C,u-T))-s.left)/d;if(!y&&!E)return{left:k,bottom:(s.bottom-(t.top-4))/d,maxHeight:S/d};const P=y?t.bottom+4:t.top-S-4,M=Math.max(m,Math.min(P,g-S));return{left:k,top:(M-s.top)/d,maxHeight:S/d}}function Yn(t){if(!t.workDir)return[];const s=[],n=new Set,r=a=>{!a||n.has(a)||(n.add(a),s.push(a))};r(t.workDir);for(const a of t.workDirFolders??[])r(Ao(a)?a:Do(t.workDir,a));return s}function wh(t,s){if(t.kind==="global")return{nodeId:s.id,scope:{kind:"global"}};const n=Yn(s),r=n.find(a=>a===t.projectPath);return r?{nodeId:s.id,scope:{kind:"project",projectPath:r}}:n[0]?{nodeId:s.id,scope:{kind:"project",projectPath:n[0]}}:{nodeId:s.id,scope:{kind:"global"}}}function yh(t,s){return{nodeId:t,scope:s}}function ya(t,s,n){const r=s.trim();return!r||r==="."?t.workDir??r:n||Ao(r)?r:t.workDir?Do(t.workDir,r):r}function jh({node:t,scope:s,clusterNodes:n,onSelectionChange:r}){const a=o.useMemo(()=>Ch(n,t),[n,t]),i=o.useMemo(()=>Yn(t),[t]),l=o.useMemo(()=>a.map(d=>({value:d.id,label:d.name,description:`${d.role} · ${d.status}`,status:d.status})),[a]);return e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-2",children:[e.jsx(Sh,{ariaLabel:"Capability node",value:t.name,description:`${t.role} · ${t.status}`,options:l,selectedValue:t.id,onSelect:d=>{const c=a.find(m=>m.id===d);c&&r?.(wh(s,c))}}),e.jsx(Eo,{node:t,projectPaths:i,selectedScope:s,onSelect:d=>r?.(yh(t.id,d))}),e.jsx(Nh,{node:t})]})}function Nh({node:t}){return e.jsxs("div",{"data-capability-node-meta":"true",className:"flex min-w-0 items-center gap-1 border-0 bg-transparent px-0.5 text-[8px] leading-3 text-muted-foreground",title:`${t.role} · ${t.status}`,children:[e.jsx("span",{className:"truncate capitalize",children:t.role}),e.jsx("span",{className:O("h-1.5 w-1.5 shrink-0 rounded-full",as(t.status))})]})}function Eo({node:t,projectPaths:s,selectedScope:n,onSelect:r,compact:a=!1,portal:i=!1,portalAlign:l="start"}){const[d,c]=o.useState(!1),[m,g]=o.useState(null),[f,u]=o.useState(!1),[p,N]=o.useState(!1),[y,D]=o.useState(null),[h,E]=o.useState(!1),[x,b]=o.useState(null),S=o.useRef(null),T=o.useRef(null),C=o.useRef(null),I=o.useMemo(()=>s.map($=>({value:$,label:Na($),description:$})),[s]),k=n.kind==="project"?n.projectPath:void 0,P=n.kind==="global"?"Global":Na(n.projectPath),M=n.kind==="global"?"Global":n.projectPath,A=o.useCallback(()=>!i||typeof document>"u"?null:T.current?.closest('[data-capability-share-dialog="true"]')??document.body,[i]),B=o.useCallback(()=>{if(!i||!T.current||typeof window>"u")return;const $=T.current.getBoundingClientRect(),Y=A(),w=Y&&Y!==document.body?Y.getBoundingClientRect():{left:0,top:0,bottom:window.innerHeight};b(vh({triggerRect:$,targetRect:w,viewportRect:{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight},compact:a,browserOpen:h,portalAlign:l,cssZoom:bh()}))},[h,a,A,i,l]);o.useEffect(()=>{d||E(!1)},[d]),o.useEffect(()=>{if(!d)return;const $=Y=>{if(!(Y.target instanceof Node))return;const w=Y.composedPath(),V=S.current?w.includes(S.current):!1,j=C.current?w.includes(C.current):Y.target instanceof Element&&!!Y.target.closest('[data-capability-scope-menu="true"]');!V&&!j&&c(!1)};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[d]),o.useEffect(()=>{if(!(!d||!i))return B(),window.addEventListener("resize",B),window.addEventListener("scroll",B,!0),()=>{window.removeEventListener("resize",B),window.removeEventListener("scroll",B,!0)}},[d,i,B]);const R=async($,Y=0,w=!1)=>{if(t.workDir){D(null),w?N(!0):u(!0);try{const V=await Da(t.id,{path:$||".",limit:fh,offset:Y,directoriesOnly:!0,allowAbsolute:!0});g(j=>w&&j?{...V,entries:[...j.entries,...V.entries]}:V)}catch(V){D(V instanceof Error?V.message:"Failed to browse folders"),w||g(null)}finally{u(!1),N(!1)}}};o.useEffect(()=>{!d||!h||!t.workDir||(g(null),D(null),R(k||"."))},[h,d,t.id,t.workDir,k]);const H=($,Y=!1)=>{r({kind:"project",projectPath:ya(t,$,Y)}),c(!1)},Z=()=>{r({kind:"global"}),c(!1)},te=m?ya(t,m.currentPath,m.isAbsolute):k??t.workDir??"",F=i?A():null,X=e.jsxs("div",{ref:C,"data-capability-scope-menu":"true","aria-hidden":!d,onClick:$=>$.stopPropagation(),onMouseDown:$=>$.stopPropagation(),onPointerDown:$=>$.stopPropagation(),style:i&&x?{left:x.left,top:x.top,bottom:x.bottom,height:a&&h?x.maxHeight:void 0,maxHeight:x.maxHeight}:void 0,className:O(i?"absolute z-[80] flex w-72 flex-col overflow-hidden rounded-lg border border-border/70 bg-popover text-popover-foreground shadow-none pointer-events-auto":"absolute left-0 z-50 flex max-h-[28rem] w-72 flex-col overflow-hidden rounded-lg border border-border/70 bg-popover text-popover-foreground shadow-none",!i&&(a?"top-7":"top-9"),!d&&"hidden"),children:[e.jsxs("div",{className:"shrink-0 border-b border-border/55 p-1",children:[e.jsx("div",{className:O("px-2 text-[8px] font-semibold uppercase tracking-[0.14em] text-muted-foreground",a?"pb-0.5 pt-0.5 leading-3":"pb-1 pt-1"),children:"Scope"}),e.jsxs("div",{className:O("overflow-y-auto pr-0.5",a?"max-h-32":"max-h-40"),children:[e.jsx(ja,{icon:"global",label:"Global",selected:n.kind==="global",onSelect:Z,compact:a}),I.length>0?I.map($=>e.jsx(ja,{icon:"folder",label:$.label,description:$.description,selected:k===$.value,onSelect:()=>H($.value,!0),compact:a},$.value)):e.jsx("div",{className:O("flex items-center px-2 text-muted-foreground",a?"h-7 text-[9px]":"h-8 text-[10px]"),children:"No known projects"})]})]}),e.jsxs("div",{className:O("border-b border-border/55",h?"flex min-h-0 flex-1 flex-col":"shrink-0"),children:[e.jsxs("button",{type:"button","aria-expanded":h,onClick:()=>E($=>!$),className:O("flex w-full items-center gap-1 px-2 text-left text-[8px] font-semibold uppercase tracking-[0.14em] text-muted-foreground transition-colors hover:bg-muted/45 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",a?"py-1 leading-3":"py-1.5"),children:[e.jsx(Bt,{className:"h-2.5 w-2.5"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:"Browse folders"}),e.jsx(Qe,{className:O("h-3 w-3 shrink-0 transition-transform duration-200",h&&"rotate-180")})]}),h&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"shrink-0 px-2 pb-1.5",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>m?.parentPath&&void R(m.parentPath),disabled:!m?.parentPath||f,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground disabled:opacity-40",title:"Parent directory",children:e.jsx(Ga,{className:"h-2.5 w-2.5"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate font-mono text-[9px] text-muted-foreground",title:te,children:te}),m&&e.jsx("button",{type:"button",onClick:()=>H(m.currentPath,m.isAbsolute),className:"shrink-0 rounded px-1.5 py-0.5 text-[9px] font-medium text-foreground hover:bg-muted/60",title:"Use this folder",children:"Use"})]})}),e.jsxs("div",{className:O("min-h-0 flex-1 overflow-y-auto",a?"min-h-[8.25rem]":"max-h-56"),children:[t.workDir?f?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[9px] text-muted-foreground",children:[e.jsx(me,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading folders..."]}):m&&m.entries.length>0?e.jsxs(e.Fragment,{children:[m.entries.map($=>e.jsx(kh,{entry:$,onSelect:()=>H($.path,m.isAbsolute),onOpen:()=>{R($.path)}},$.path)),m.hasMore&&e.jsxs("button",{type:"button",onClick:()=>{R(m.currentPath,m.entries.length,!0)},disabled:p,className:"flex w-full items-center justify-center gap-1 border-t border-border/40 py-1 text-[9px] text-muted-foreground hover:bg-muted/60 hover:text-foreground disabled:opacity-50",children:[p?e.jsx(me,{className:"h-3 w-3 animate-spin"}):e.jsx(wd,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"px-3 py-4 text-center text-[9px] text-muted-foreground",children:y??"No subfolders."}):e.jsx("div",{className:"px-3 py-4 text-center text-[9px] text-muted-foreground",children:"This node has no working directory."}),y&&m&&m.entries.length>0&&e.jsx("div",{className:"border-t border-border/60 px-3 py-1.5 text-[9px] text-destructive",children:y})]})]})]})]});return e.jsxs("div",{ref:S,className:"relative min-w-0",children:[e.jsxs("button",{ref:T,type:"button","aria-label":"Capability location","aria-expanded":d,title:M,onClick:()=>c($=>($||(E(!1),B()),!$)),className:O("flex min-w-0 items-center gap-1.5 rounded-sm border-0 bg-muted/55 text-left shadow-none transition-colors hover:bg-muted/70 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",a?"h-5 w-24 max-w-28 px-1.5":"h-7 min-w-32 max-w-56 px-2"),children:[e.jsx("span",{className:"min-w-0 flex-1",children:e.jsx("span",{className:O("block truncate font-medium text-foreground",a?"text-[9px] leading-3":"text-[10px] leading-4"),children:P})}),e.jsx(Qe,{className:O(a?"h-2.5 w-2.5":"h-3 w-3","shrink-0 text-muted-foreground transition-transform",d&&"rotate-180")})]}),i&&F?La.createPortal(X,F):X]})}function ja({icon:t,label:s,description:n,selected:r,onSelect:a,compact:i=!1}){const l=t==="global"?pd:Bt;return e.jsxs("button",{type:"button",onClick:a,className:O(i?"flex h-7 w-full items-center gap-1.5 rounded-md px-2 text-left text-[9px]":"flex h-8 w-full items-center gap-1.5 rounded-md px-2 text-left text-[10px]","transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",r&&"bg-primary/10 text-primary"),children:[e.jsx(l,{className:O("shrink-0 text-muted-foreground",i?"h-2.5 w-2.5":"h-3 w-3",r&&"text-primary")}),e.jsxs("span",{className:"flex min-w-0 flex-1 flex-col justify-center",children:[e.jsx("span",{className:"block truncate font-medium leading-3",children:s}),n&&e.jsx("span",{className:O("block truncate text-muted-foreground",i?"text-[7px] leading-3":"text-[8px] leading-3"),children:n})]})]})}function kh({entry:t,onOpen:s,onSelect:n}){return e.jsxs("div",{className:"group flex items-stretch border-b border-border/30 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:n,className:"flex min-w-0 flex-1 items-center gap-1.5 px-2 py-1 text-left text-[9px] hover:bg-muted/55",title:`Use ${t.path}`,children:[e.jsx(Bt,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-foreground",children:t.name})]}),e.jsx("button",{type:"button",onClick:s,className:"flex w-7 shrink-0 items-center justify-center border-l border-border/30 text-muted-foreground hover:bg-muted/65 hover:text-foreground",title:"Open subfolder","aria-label":`Open ${t.name}`,children:e.jsx(Ke,{className:"h-3 w-3"})})]})}function Sh({ariaLabel:t,value:s,description:n,options:r,selectedValue:a,onSelect:i}){const[l,d]=o.useState(!1),c=o.useRef(null);return o.useEffect(()=>{if(!l)return;const m=g=>{c.current&&g.target instanceof Node&&!c.current.contains(g.target)&&d(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[l]),e.jsxs("div",{ref:c,className:"relative min-w-0",children:[e.jsxs("button",{type:"button","aria-label":t,"aria-expanded":l,title:n??s,onClick:()=>d(m=>!m),className:"flex h-7 min-w-32 max-w-56 items-center gap-1.5 rounded-sm border-0 bg-muted/55 px-2 text-left shadow-none transition-colors hover:bg-muted/70 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:[e.jsx("span",{className:"min-w-0 flex-1",children:e.jsx("span",{className:"block truncate text-[10px] font-medium leading-4 text-foreground",children:s})}),e.jsx(Qe,{className:O("h-3 w-3 shrink-0 text-muted-foreground transition-transform",l&&"rotate-180")})]}),e.jsx("div",{"aria-hidden":!l,className:O("absolute left-0 top-9 z-50 w-64 overflow-hidden rounded-lg border border-border/70 bg-popover text-popover-foreground shadow-none",!l&&"hidden"),children:e.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:r.length>0?r.map(m=>e.jsxs("button",{type:"button",onClick:()=>{i(m.value),d(!1)},className:O("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[11px] transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",m.value===a&&"bg-primary/10 text-primary"),children:[m.status&&e.jsx("span",{className:O("h-1.5 w-1.5 shrink-0 rounded-full",as(m.status))}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate font-medium",children:m.label}),m.description&&e.jsx("span",{className:"block truncate text-[9px] text-muted-foreground",children:m.description})]})]},m.value)):e.jsx("div",{className:"px-2 py-2 text-[10px] text-muted-foreground",children:"No projects"})})})]})}function Ch(t,s){const n=new Map;for(const r of t)n.set(r.id,r);return n.set(s.id,s),Array.from(n.values())}function as(t){return t==="online"?"bg-emerald-500":t==="offline"?"bg-muted-foreground/45":"bg-amber-500"}function Na(t){return t.split(/[\\/]+/).filter(Boolean).at(-1)??t}function Ao(t){return t.startsWith("/")||/^[A-Za-z]:[\\/]/.test(t)}function Do(t,s){return`${t.replace(/[\\/]+$/,"")}/${s.replace(/^[\\/]+/,"")}`}const Th="h-6 w-24 rounded-sm px-2 text-[10px] shadow-none",yn="text-[10px]",_o=["claudecode","codex","copilot"],Yt={claudecode:"Claude Code",codex:"Codex",copilot:"Copilot"};function Eh({open:t,sourceNode:s,targetNodes:n,selectedCapabilities:r,previewResults:a=[],embedded:i=!1,onClose:l,onPreviewTargetsChange:d,onShare:c}){const[m,g]=o.useState(()=>new Set(a.length>0?a.map(w=>tt(w.nodeId,w.targetAgent)):Dh(s.id,n,r))),[f,u]=o.useState(()=>Object.fromEntries(_h(s.id,n,r))),[p,N]=o.useState({}),[y,D]=o.useState(!1),[h,E]=o.useState(()=>new Set),[x,b]=o.useState(()=>new Set),S=r.some(w=>w.kind==="plugin"),T=o.useMemo(()=>Jn(r).map(w=>({key:tt(s.id,w),nodeId:s.id,node:s,label:`Install into ${Yt[w]}`,agentLabel:Yt[w],defaultScope:Po(r),disabled:!1,targetAgent:w})),[r,s]),C=o.useMemo(()=>n.flatMap(w=>{const V={kind:"global"},j=w.status==="offline",q=Mo(r);return q.length===0?[{key:tt(w.id),nodeId:w.id,node:w,label:w.name,defaultScope:V,disabled:j}]:q.map(z=>({key:tt(w.id,z),nodeId:w.id,node:w,label:`${w.name} / ${Yt[z]}`,agentLabel:Yt[z],defaultScope:V,disabled:j,targetAgent:z}))}),[r,n]),I=o.useMemo(()=>[...T,...C],[T,C]),k=o.useMemo(()=>n.map(w=>({node:w,options:C.filter(V=>V.nodeId===w.id)})).filter(w=>w.options.length>0),[n,C]),P=o.useMemo(()=>new Map(a.filter(w=>w.capabilityId).map(w=>[ka(w.nodeId,w.capabilityId,w.targetAgent),w])),[a]),M=o.useMemo(()=>new Map(a.map(w=>[tt(w.nodeId,w.targetAgent),w])),[a]),A=o.useMemo(()=>I.filter(w=>m.has(w.key)),[m,I]),B=o.useMemo(()=>A.map(w=>({nodeId:w.nodeId,scope:f[w.key]??w.defaultScope,...w.targetAgent?{targetAgent:w.targetAgent}:{}})),[A,f]),R=o.useMemo(()=>{const w=[],V=new Map;for(const j of A){if(!V.has(j.nodeId)){const q=j.nodeId===s.id?s:n.find(z=>z.id===j.nodeId);V.set(j.nodeId,{nodeId:j.nodeId,node:q,name:q?.name??j.nodeId,options:[]}),w.push(j.nodeId)}V.get(j.nodeId).options.push(j)}return w.map(j=>V.get(j))},[A,s,n]),H=o.useMemo(()=>{const w=Array.from(new Set(r.map(j=>j.agent))),[V]=w;if(V)return w.length===1?Yt[V]:`${w.length} agents`},[r]),Z=k.length+1;o.useEffect(()=>{let w=!1;const V={...f};for(const j of I)V[j.key]||(V[j.key]=j.defaultScope,w=!0);w&&u(V)},[I,f]),o.useEffect(()=>{t&&d?.(B)},[t,d,B]),o.useEffect(()=>{t&&(E(new Set),b(new Set))},[t,s.id]),o.useEffect(()=>{if(!i||!t)return;const w=V=>{V.key==="Escape"&&l()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[i,l,t]);const te=w=>{N(Object.fromEntries(A.map(V=>[V.key,w])))},F=async()=>{D(!0);try{await c(A.map(w=>({nodeId:w.nodeId,scope:f[w.key]??w.defaultScope,...w.targetAgent?{targetAgent:w.targetAgent}:{},conflictStrategy:p[w.key]??"overwrite"})))}finally{D(!1)}},X=w=>{const V=f[w.key]??w.defaultScope,j=`capability-share-target-${Ah(w.key)}`,q=m.has(w.key);return e.jsxs("div",{"data-target-agent":w.targetAgent,className:"flex min-h-6 items-center gap-2 px-2 py-0.5 transition-colors hover:bg-muted/35 data-[disabled=true]:opacity-55","data-disabled":w.disabled?"true":void 0,children:[e.jsx(ls,{id:j,disabled:w.disabled,checked:q,onCheckedChange:z=>g(W=>{const L=new Set(W);return z===!0?L.add(w.key):L.delete(w.key),L}),"aria-label":`Select ${w.label} as a share target`,"data-share-target-checkbox":!0,className:"h-3.5 w-3.5 border-border/70 bg-background/80 shadow-none data-[state=checked]:border-primary data-[state=checked]:bg-primary [&_svg]:h-3 [&_svg]:w-3"}),e.jsx("label",{htmlFor:j,className:"min-w-0 flex-1 cursor-pointer truncate text-[10px] font-medium leading-4 text-foreground data-[disabled=true]:cursor-not-allowed","data-disabled":w.disabled?"true":void 0,children:w.agentLabel??w.label}),e.jsx("div",{className:"flex w-28 shrink-0 justify-end",children:q&&!w.disabled&&e.jsx(Eo,{node:w.node,projectPaths:Yn(w.node),selectedScope:V,onSelect:z=>u(W=>({...W,[w.key]:z})),compact:!0,portal:!0,portalAlign:"end"})})]},w.key)},$=(w,V,j,q)=>{const z=h.has(w.id),W=A.filter(L=>L.nodeId===w.id).length;return e.jsxs("div",{className:"overflow-hidden rounded-sm border border-border/45 bg-muted/15",children:[e.jsxs("button",{type:"button","aria-expanded":z,onClick:()=>E(L=>Sa(L,w.id)),className:"flex w-full items-center gap-2 border-b border-border/35 bg-primary/5 px-2 py-1.5 text-left transition-colors hover:bg-primary/10",children:[e.jsx(Ke,{className:O("h-3 w-3 shrink-0 text-muted-foreground transition-transform duration-200",z&&"rotate-90")}),e.jsx("span",{className:O("h-1.5 w-1.5 shrink-0 rounded-full",as(w.status))}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-semibold text-foreground",title:w.name,children:w.name}),W>0&&e.jsxs("span",{className:"shrink-0 text-[8px] font-medium text-primary",children:[W," selected"]}),e.jsx("span",{className:"shrink-0 text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:V?"this node":"remote"}),w.status==="offline"&&e.jsx(Ue,{variant:"outline",className:"rounded-sm px-1 py-0 text-[8px]",children:"offline"}),q>0&&e.jsxs("span",{className:"sr-only",children:[q," agents"]})]}),e.jsx("div",{className:O("grid transition-[grid-template-rows] duration-200 ease-out",z?"grid-rows-[1fr]":"grid-rows-[0fr]"),children:e.jsx("div",{className:"min-h-0 overflow-hidden",children:e.jsx("div",{className:"divide-y divide-border/25",children:j})})})]},w.id)},Y=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-b border-border/55 px-4 py-3 text-left",children:[e.jsxs("h2",{id:"capability-share-title",className:"flex items-center gap-2 text-sm font-semibold leading-none tracking-tight",children:[e.jsx(Ss,{className:"h-4 w-4 text-primary"}),"Share ",r.length," ",r.length===1?"capability":"capabilities"]}),e.jsx("p",{id:"capability-share-description",className:"mt-1.5 text-[11px] text-muted-foreground",children:"Copies each capability into the matching agent on the selected targets. Plugins install into their matching agent."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2.5 gap-y-1 border-b border-border/55 bg-muted/15 px-4 py-2 text-[11px]",children:[e.jsx("span",{className:"text-[8px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Source"}),e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:O("h-1.5 w-1.5 shrink-0 rounded-full",as(s.status))}),e.jsx("span",{className:"truncate font-semibold text-foreground",title:s.name,children:s.name}),H&&e.jsxs("span",{className:"shrink-0 text-muted-foreground",children:["· ",H]})]}),e.jsx(xr,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/70"}),e.jsx("span",{className:"text-[8px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Targets"}),e.jsxs("span",{className:"text-muted-foreground",children:[e.jsx("span",{className:"font-semibold text-foreground",children:A.length})," selected · ",Z," ",Z===1?"node":"nodes"]})]}),e.jsxs("div",{className:"grid gap-4 p-4 lg:grid-cols-[17rem_minmax(0,1fr)]",children:[e.jsx("section",{className:"min-w-0",children:e.jsxs("div",{className:"max-h-[56vh] space-y-2 overflow-y-auto pr-0.5",children:[$(s,!0,S?e.jsx("div",{className:"px-2 py-2 text-[10px] text-muted-foreground",children:"Cross-agent plugin installs are not supported."}):T.length===0?e.jsx("div",{className:"px-2 py-2 text-[10px] text-muted-foreground",children:"No alternate agents available for this selection."}):T.map(X),T.length),k.map(w=>$(w.node,!1,w.options.map(X),w.options.length))]})}),e.jsxs("section",{className:"min-w-0",children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[e.jsx("div",{className:"text-[8px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Conflict preview"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[8px] uppercase tracking-[0.12em] text-muted-foreground/70",children:"Set all"}),e.jsx("div",{className:"inline-flex items-center rounded-sm border border-border/55 bg-muted/20 p-px",children:["overwrite","skip","abort"].map(w=>e.jsx("button",{type:"button",onClick:()=>te(w),className:"h-5 rounded-[3px] px-1.5 text-[9px] capitalize text-muted-foreground transition-colors hover:bg-muted/70 hover:text-foreground",children:w},w))})]})]}),e.jsx("div",{className:"max-h-[56vh] min-h-32 overflow-y-auto rounded-sm border border-border/55 bg-background/45 p-2",children:A.length===0?e.jsx("div",{className:"py-8 text-center text-[11px] text-muted-foreground",children:"Select a target to preview conflicts."}):R.map(w=>{const V=!x.has(w.nodeId);return e.jsxs("div",{className:"mb-1.5 overflow-hidden rounded-sm border border-border/35 bg-muted/10 last:mb-0",children:[e.jsxs("button",{type:"button","aria-expanded":V,onClick:()=>b(j=>Sa(j,w.nodeId)),className:"flex w-full items-center gap-1.5 border-b border-border/30 bg-primary/5 px-2 py-1 text-left transition-colors hover:bg-primary/10",children:[e.jsx(Ke,{className:O("h-3 w-3 shrink-0 text-muted-foreground transition-transform duration-200",V&&"rotate-90")}),w.node&&e.jsx("span",{className:O("h-1.5 w-1.5 shrink-0 rounded-full",as(w.node.status))}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[10px] font-semibold text-foreground",children:w.name}),e.jsxs("span",{className:"shrink-0 text-[8px] text-muted-foreground",children:[w.options.length," ",w.options.length===1?"agent":"agents"]})]}),e.jsx("div",{className:O("grid transition-[grid-template-rows] duration-200 ease-out",V?"grid-rows-[1fr]":"grid-rows-[0fr]"),children:e.jsx("div",{className:"min-h-0 overflow-hidden",children:e.jsx("div",{className:"space-y-1 p-1.5",children:w.options.map(j=>{const q=p[j.key]??"overwrite";return e.jsxs("div",{className:"rounded-sm bg-background/45 px-2 py-1",children:[e.jsxs("div",{className:"mb-0.5 flex items-center justify-between gap-2",children:[e.jsx("span",{className:"min-w-0 truncate text-[9px] font-medium leading-4 text-foreground",children:j.agentLabel??"Matching agent"}),e.jsxs(Ne,{value:q,onValueChange:z=>N(W=>({...W,[j.key]:z})),children:[e.jsx(ke,{className:Th,children:e.jsx(Pe,{})}),e.jsxs(Se,{className:"shadow-none",children:[e.jsx(xe,{value:"overwrite",className:yn,children:"Overwrite"}),e.jsx(xe,{value:"skip",className:yn,children:"Skip"}),e.jsx(xe,{value:"abort",className:yn,children:"Abort"})]})]})]}),e.jsx("div",{className:"space-y-px",children:r.map(z=>{const W=P.get(ka(j.nodeId,z.id,j.targetAgent))??(r.length===1?M.get(j.key):void 0);return e.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] leading-4",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:z.name}),e.jsx("span",{className:W?.conflict?"text-amber-500":W?"text-emerald-500":"text-muted-foreground",children:W?W.conflict?`exists${W.currentVersion?` v${W.currentVersion}`:""}`:"new install":"checking"}),W?.sourceVersion&&e.jsxs("span",{className:"shrink-0 text-muted-foreground",children:[e.jsx(xr,{className:"inline h-2.5 w-2.5"})," v",W.sourceVersion]})]},z.id)})})]},j.key)})})})})]},w.nodeId)})})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 border-t border-border/55 px-4 py-3",children:[e.jsx(ee,{variant:"ghost",onClick:l,className:"h-7 rounded-sm px-3 text-[11px]",children:"Cancel"}),e.jsxs(ee,{onClick:F,disabled:y||A.length===0,className:"h-7 rounded-sm px-3 text-[11px]",children:[y?e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Ss,{className:"h-3.5 w-3.5"}),"Share"]})]})]});return i?t?e.jsx("div",{className:"absolute inset-0 z-[80] flex items-center justify-center bg-background/70 p-4 backdrop-blur-[2px]",onMouseDown:w=>{w.target===w.currentTarget&&l()},children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"capability-share-title","aria-describedby":"capability-share-description","data-capability-share-dialog":"true",className:"relative grid w-full max-w-3xl gap-0 overflow-visible rounded-xl border-0 bg-background text-foreground shadow-[0_34px_110px_-54px_rgba(0,0,0,0.55)]",onMouseDown:w=>w.stopPropagation(),children:[Y,e.jsxs("button",{type:"button",onClick:l,className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[e.jsx(nt,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})}):null:e.jsx(yt,{open:t,onOpenChange:w=>{w||l()},children:e.jsx(jt,{"aria-labelledby":"capability-share-title","aria-describedby":"capability-share-description","data-capability-share-dialog":"true",className:"max-w-3xl gap-0 overflow-visible rounded-xl border-0 p-0",children:Y})})}function tt(t,s){return s?`agent:${t}:${s}`:`node:${t}`}function Ah(t){return t.replace(/[^a-zA-Z0-9_-]/g,"-")}function ka(t,s,n){return`${tt(t,n)}\0${s}`}function Sa(t,s){const n=new Set(t);return n.has(s)?n.delete(s):n.add(s),n}function Dh(t,s,n){const r=s.find(i=>i.status!=="offline");if(r)return[tt(r.id,Mh(n))];const a=Jn(n)[0];return a?[tt(t,a)]:[]}function _h(t,s,n){const r=Mo(n);return[...s.flatMap(a=>r.length===0?[[tt(a.id),{kind:"global"}]]:r.map(i=>[tt(a.id,i),{kind:"global"}])),...Jn(n).map(a=>[tt(t,a),Po(n)])]}function Mo(t){return t.length===0||t.some(s=>s.kind==="plugin")?[]:_o}function Mh(t){if(!(t.length===0||t.some(s=>s.kind==="plugin")))return t[0]?.agent}function Jn(t){if(t.length===0||t.some(n=>n.kind==="plugin"))return[];const s=new Set(t.map(n=>n.agent));return _o.filter(n=>!s.has(n))}function Po(t){return t[0]?.scope??{kind:"global"}}const Ca="h-7 rounded-sm border-0 bg-muted/55 px-2 text-[9px] leading-none shadow-none hover:bg-muted/70 [&>svg]:h-3 [&>svg]:w-3",xt="py-0.5 pl-6 pr-1.5 text-[9px] leading-4 [&_svg]:h-3 [&_svg]:w-3",Io="h-5 rounded-sm bg-muted/55 px-1.5 text-[9px] font-medium text-foreground shadow-none border-0 hover:bg-muted/75 hover:text-foreground disabled:text-muted-foreground [&_svg]:size-2.5",Ph="h-5 rounded-sm bg-primary px-2 text-[9px] font-medium text-primary-foreground shadow-none border-0 hover:bg-primary/90 hover:text-primary-foreground disabled:bg-primary/45 disabled:text-primary-foreground/80 [&_svg]:size-2.5";function Ih(t,s,n,r){return n.map(a=>({sourceNodeId:t,capabilityId:a.id,sourceScope:s,targets:r.map(i=>({nodeId:i.nodeId,scope:i.scope,...i.targetAgent?{targetAgent:i.targetAgent}:{}}))}))}function Rh(t,s,n,r){return n.map(a=>({sourceNodeId:t,capabilityId:a.id,sourceScope:s,targets:r}))}function Lh({loading:t,onRefresh:s}){return e.jsxs(ee,{variant:"ghost",onClick:s,disabled:t,"aria-busy":t,className:O(Io,"min-w-[4.5rem]"),children:[e.jsx(Qa,{className:O("h-2.5 w-2.5",t&&"animate-spin")}),t?"Refreshing":"Refresh"]})}function Bh({selectedCount:t,loading:s,onClearSelection:n,onRefresh:r,onShare:a}){return e.jsxs("div",{className:"flex items-center justify-between gap-2 bg-card/15 px-0.5 pt-1.5 text-[9px] text-muted-foreground",children:[e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(ee,{type:"button",variant:"ghost",onClick:n,disabled:t===0,className:Io,children:[e.jsx(nt,{className:"h-2.5 w-2.5"}),"Selected: ",t," / Clear"]})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Lh,{loading:s,onRefresh:r}),e.jsxs(ee,{type:"button",variant:"ghost",onClick:a,disabled:t===0,className:Ph,children:[e.jsx(Ss,{className:"h-2.5 w-2.5"}),"Share"]})]})]})}function Oh({onBeginResize:t,onFold:s}){const n=r=>{r.key!=="Enter"&&r.key!==" "||(r.preventDefault(),s())};return e.jsx("div",{role:"separator","aria-label":"Fold capability detail panel","aria-orientation":"vertical",title:"Fold details",tabIndex:0,onClick:s,onKeyDown:n,onPointerDown:t,className:"hidden w-1 shrink-0 cursor-col-resize items-center justify-center bg-primary/10 transition-colors hover:bg-primary/22 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70 lg:flex",children:e.jsx("span",{className:"h-8 w-px rounded-full bg-primary/45"})})}function Fh({visible:t}){return t?e.jsx("div",{className:"absolute inset-2.5 z-10 flex items-center justify-center rounded-sm border border-border/60 bg-background/85 shadow-sm backdrop-blur-sm",children:e.jsxs("div",{className:"flex w-full max-w-80 flex-col items-center gap-3 px-5 text-center",children:[e.jsxs("div",{className:"relative flex h-10 w-10 items-center justify-center rounded-full border border-primary/25 bg-primary/8",children:[e.jsx("span",{className:"absolute inset-0 rounded-full border border-primary/20 animate-ping"}),e.jsx(me,{className:"relative h-4 w-4 animate-spin text-primary"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground",children:"Loading capabilities"}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Reading agent skills, plugins, and MCP servers for this selection."})]}),e.jsxs("div",{className:"grid w-full gap-1.5","aria-hidden":"true",children:[e.jsx("span",{className:"h-1.5 rounded-full bg-muted animate-pulse"}),e.jsx("span",{className:"mx-auto h-1.5 w-3/4 rounded-full bg-muted/70 animate-pulse"})]})]})}):null}function zh({open:t,node:s,scope:n,clusterNodes:r,onOpenChange:a,onSelectionChange:i}){const[l,d]=o.useState([]),[c,m]=o.useState([]),[g,f]=o.useState(!1),[u,p]=o.useState(""),[N,y]=o.useState("all"),[D,h]=o.useState("all"),[E,x]=o.useState(new Set),[b,S]=o.useState(null),[T,C]=o.useState(null),[I,k]=o.useState(!1),[P,M]=o.useState(null),[A,B]=o.useState(!1),[R,H]=o.useState([]),[Z,te]=o.useState(To),[F,X]=o.useState(null),$=o.useMemo(()=>oh(l,{search:u,agent:N,kind:D}),[N,l,D,u]),Y=o.useMemo(()=>l.filter(Q=>E.has(Q.id)),[l,E]),w=o.useMemo(()=>r.filter(Q=>Q.id!==s.id),[r,s.id]),V=n.kind==="project"?n.projectPath:"global",j=async()=>{f(!0);try{const Q=await gl(s.id,{scope:n});d(Q.items),m((Q.errors??[]).map(J=>`${J.agent}: ${J.message}`))}catch(Q){m([Q instanceof Error?Q.message:"Failed to load capabilities"])}finally{f(!1)}};o.useEffect(()=>{t&&(x(new Set),S(null),C(null),k(!1),H([]),d([]),m([]),j())},[t,s.id,n.kind,V]),o.useEffect(()=>{if(!F)return;const Q=le=>{te(ch(F.startWidth,F.startClientX,le.clientX,window.innerWidth))},J=()=>X(null);return window.addEventListener("pointermove",Q),window.addEventListener("pointerup",J),()=>{window.removeEventListener("pointermove",Q),window.removeEventListener("pointerup",J)}},[F]);const q=Q=>{Q.preventDefault(),X({startClientX:Q.clientX,startWidth:Z})},z=()=>{X(null),k(!1),S(null),C(null)},W=()=>{x(new Set),H([])},L=async Q=>{S(Q.id),k(!0),C(null);const J=await bl(s.id,Q.id,n);C(J.detail)},ae=o.useCallback(async Q=>{if(Y.length===0||Q.length===0){H([]);return}H([]);try{const J=Ih(s.id,n,Y,Q),le=await Promise.all(J.map(_=>pl(_)));H(le.flatMap((_,G)=>_.results.map(ue=>({...ue,capabilityId:J[G]?.capabilityId}))))}catch{H([])}},[s.id,n,Y]),oe=()=>{H([]),B(!0)},he=async Q=>{const J=Rh(s.id,n,Y,Q);J.length!==0&&(await Promise.all(J.map(le=>wl(le))),de.success(`${J.length} capability share request${J.length===1?"":"s"} completed`),B(!1))},ne=async()=>{if(!(!T||P)){M(T.id);try{const Q=await vl(s.id,T.id,n);Q.status==="deleted"?(de.success(`Deleted ${T.name}`),d(J=>J.filter(le=>le.id!==T.id)),x(J=>{const le=new Set(J);return le.delete(T.id),le}),S(null),C(null),k(!1),await j()):(de.info(Q.message??"Capability was not found"),S(null),C(null),k(!1),await j())}catch(Q){de.error(Q instanceof Error?Q.message:"Failed to delete capability")}finally{M(null)}}};return e.jsx(e.Fragment,{children:e.jsx(yt,{open:t,onOpenChange:a,children:e.jsxs(jt,{className:"dashboard-panel animate-panel-settle flex h-[min(62vh,33rem)] w-[min(94vw,72rem)] max-w-[min(94vw,72rem)] flex-col gap-0 overflow-hidden rounded-xl p-0",children:[e.jsxs(Ts,{className:"border-b border-border/55 bg-card/28 px-4 py-2.5 text-left",children:[e.jsx(Ot,{className:"sr-only",children:"Capabilities"}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-start justify-between gap-x-4 gap-y-1 pr-10",children:[e.jsx(jh,{node:s,scope:n,clusterNodes:r,onSelectionChange:i}),e.jsxs(Es,{"data-capability-selection-help":"true",className:"ml-auto max-w-[min(32rem,38vw)] space-y-0.5 pt-0.5 text-right text-[9px] leading-[11px] text-muted-foreground",children:[e.jsx("span",{className:"block truncate whitespace-nowrap",children:"Sharing copies into selected agents on target nodes."}),n.kind==="project"&&e.jsx("span",{"data-capability-selection-path":"true",className:"block truncate font-mono text-[7px] leading-[10px] text-muted-foreground/80",title:n.projectPath,children:n.projectPath})]})]})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col lg:flex-row",children:[e.jsxs("main",{className:"relative flex min-w-0 flex-1 flex-col gap-2 bg-gradient-to-b from-primary/4 via-background/20 to-background/40 p-2.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"relative min-w-44 flex-1",children:[e.jsx(_a,{className:"pointer-events-none absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-muted-foreground"}),e.jsx(st,{value:u,onChange:Q=>p(Q.target.value),placeholder:"Search capabilities",className:"h-7 rounded-sm border-0 bg-muted/55 pl-6 text-[10px] shadow-none"})]}),e.jsxs(Ne,{value:N,onValueChange:Q=>y(Q),children:[e.jsx(ke,{className:O("w-28",Ca),children:e.jsx(Pe,{})}),e.jsxs(Se,{className:"shadow-none",children:[e.jsx(xe,{value:"all",className:xt,children:"Agent: All"}),e.jsx(xe,{value:"claudecode",className:xt,children:"Claude Code"}),e.jsx(xe,{value:"codex",className:xt,children:"Codex"}),e.jsx(xe,{value:"copilot",className:xt,children:"Copilot"})]})]}),e.jsxs(Ne,{value:D,onValueChange:Q=>h(Q),children:[e.jsx(ke,{className:O("w-24",Ca),children:e.jsx(Pe,{})}),e.jsxs(Se,{className:"shadow-none",children:[e.jsx(xe,{value:"all",className:xt,children:"Kind: All"}),e.jsx(xe,{value:"skill",className:xt,children:"Skill"}),e.jsx(xe,{value:"plugin",className:xt,children:"Plugin"}),e.jsx(xe,{value:"mcp",className:xt,children:"MCP"})]})]})]}),c.length>0&&e.jsx("div",{className:"rounded-sm bg-amber-500/10 px-2 py-1 text-[10px] text-amber-600",children:c.join(" · ")}),e.jsx(ih,{items:$,selectedIds:E,activeId:b,onToggleSelected:(Q,J)=>x(le=>{const _=new Set(le);return J?_.add(Q):_.delete(Q),_}),onOpenDetail:L}),e.jsx(Bh,{selectedCount:E.size,loading:g,onClearSelection:W,onRefresh:j,onShare:oe}),e.jsx(Fh,{visible:g&&l.length===0})]}),I&&e.jsxs(e.Fragment,{children:[e.jsx(Oh,{onBeginResize:q,onFold:z}),e.jsx(uh,{detail:T,deleting:P===T?.id,desktopWidth:Z,onDelete:T?ne:void 0,pending:!T})]})]}),A&&e.jsx(Eh,{open:A,sourceNode:s,targetNodes:w,selectedCapabilities:Y,previewResults:R,embedded:!0,onClose:()=>B(!1),onPreviewTargetsChange:ae,onShare:he})]})})})}function Uh(t){const[s,n]=o.useState(null),r=o.useMemo(()=>s?t?.nodes.find(c=>c.id===s.nodeId)??(t?.self.id===s.nodeId?t.self:null)??null:null,[t,s]),a=o.useCallback(c=>{n({nodeId:c,scope:{kind:"global"}})},[]),i=o.useCallback((c,m)=>{n({nodeId:c,scope:{kind:"project",projectPath:m}})},[]),l=o.useCallback(c=>{n(c)},[]);return{capabilitiesDialog:s&&r&&t?e.jsx(zh,{open:!0,node:r,scope:s.scope,clusterNodes:t.nodes,onOpenChange:c=>{c||n(null)},onSelectionChange:l}):null,openNodeCapabilities:a,openProjectCapabilities:i}}function $h(){const{id:t}=yl(),s=jl(),n=Nl(),r=kl(),{cluster:a,systemInfo:i,events:l,sseConnected:d,subscribe:c,refresh:m,loading:g,error:f}=Sl(),u=o.useMemo(()=>Cl(s.state),[s.state]),[p,N]=o.useState(null),[y,D]=o.useState("active"),[h,E]=o.useState("all"),[x,b]=o.useState("all"),[S,T]=o.useState("all"),C=r?.headerSearchQuery??"",I=o.useDeferredValue(C),{desktopTasksOpen:k,mobileTasksPanelOpen:P,mobileTasksPanelRef:M,operationsOpen:A,operationsPanelRef:B,panelResize:R,setMobileTasksPanelOpen:H,setOperationsOpen:Z,toggleTasksPanel:te}=Cm(),[F,X]=o.useState(()=>!!u?.draftNewTask),[$,Y]=o.useState(()=>u?.createMode??"chat"),[w,V]=o.useState(()=>u?.createDefaults??null),[j,q]=o.useState(()=>u?.draftNewTask?{route:u.returnRoute??"/",taskId:u.returnTaskId??null}:null),[z,W]=o.useState(!1),[L,ae]=o.useState("transcript"),[oe,he]=o.useState("overview"),[ne,Q]=o.useState("all"),[J,le]=o.useState(!1),[_,G]=o.useState(null),[ue,ye]=o.useState([]),[Ie,Be]=o.useState([]),[pt,Ye]=o.useState(!1),[$e,Te]=o.useState(!1),[dt,re]=o.useState(null),[ge,ve]=o.useState(new Set),[qe,ct]=o.useState(!1),[je,Je]=o.useState(!1),[ut,St]=o.useState(null),Oe=o.useRef(null),rt=o.useRef(new Map),Ce=a?.self?.role==="leader",$t=a?.self?.id,{quickChats:Ct}=Tl();zm({cluster:a,subscribe:c});const{nodeSettingsDialog:K,openNodeSettings:Ee}=sh(Ce),{capabilitiesDialog:Ae,openNodeCapabilities:at,openProjectCapabilities:qt}=Uh(a),{devBoxDialog:Tt,devBoxNodeIds:De,devBoxStartNodeId:Ve,devBoxStartNodeIds:Et,devBoxStartingNodeIds:mt,openDevBox:ot,startDevBox:At}=th({cluster:a,refresh:m}),{completedGroups:gt=[],fetchTasks:_e,loadCompletedTasksPage:ce,removeTasksFromList:Me,setTasks:Re,tasks:Fe,tasksError:Vt,tasksLoading:Rs}=Lm({isLeader:Ce,selfId:$t,sseConnected:d,preservedTask:_,subscribe:c});o.useEffect(()=>El(()=>{he("events"),Z(!0)}),[Z]);const Ze=o.useMemo(()=>[...Fe].sort((v,U)=>U.updatedAt-v.updatedAt),[Fe]),Xe=o.useMemo(()=>[...Fe].sort((v,U)=>U.createdAt-v.createdAt||U.updatedAt-v.updatedAt)[0]?.id??null,[Fe]),Ro=o.useMemo(()=>{const v=new Map;for(const U of a?.nodes??[]){const se=rc(Ze,U.id);se>0&&v.set(U.id,se)}return v},[a?.nodes,Ze]),et=o.useMemo(()=>Ze.filter(v=>!Al(v,a?.nodes,a?.self)||!Dl(v,y)||h!=="all"&&v.agent!==h||!_l(v,S)||x==="unassigned"&&v.assignedTo||x!=="all"&&x!=="unassigned"&&Ml(v.assignedTo,a?.nodes,v.assignedNodeName)!==x?!1:I.trim()?Pl(v,I):!0),[Ze,a?.nodes,a?.self,y,h,S,x,I]);o.useEffect(()=>{ve(v=>{const U=cc(v,et.map(se=>se.id));return U.size===v.size?v:U})},[et]),o.useEffect(()=>{Ce||ve(new Set)},[Ce]);const Lo=o.useMemo(()=>["all",...Array.from(new Set(Ze.map(v=>v.agent))).sort()],[Ze]),Bo=o.useMemo(()=>{const U=Array.from(new Set(Ze.map(se=>se.assignedTo).filter(se=>!!se))).map(se=>{const we=Ze.find(fe=>fe.assignedTo===se);return a?.nodes.find(fe=>fe.id===se)??{id:se,name:Nn(se,a?.nodes,we?.assignedNodeName)}}).sort((se,we)=>se.name.localeCompare(we.name));return[{value:"all",label:"All nodes"},{value:"unassigned",label:"Unassigned"},...U.map(se=>({value:se.name.toLowerCase(),label:se.name}))]},[Ze,a?.nodes]),Zn=o.useMemo(()=>{const v=new Map;for(const U of a?.nodes??[])v.set(U.id,U.name);for(const U of Ze)U.assignedTo&&U.assignedNodeName&&!v.has(U.assignedTo)&&v.set(U.assignedTo,U.assignedNodeName);return v},[a?.nodes,Ze]),Oo=o.useMemo(()=>{const v=new Map;for(const U of a?.nodes??[])U.workDir&&v.set(U.id,U.workDir);return a?.self?.workDir&&v.set(a.self.id,a.self.workDir),v},[a]),Fo=o.useMemo(()=>{const v=new Map;for(const U of a?.nodes??[])v.set(U.id,U.status);return a?.self&&v.set(a.self.id,a.self.status),v},[a]),zo=o.useMemo(()=>new Map(gt.map(v=>[Rn(v),v])),[gt]),Xn=o.useMemo(()=>{const v=new Map;for(const U of a?.nodes??[])U.status!=="offline"&&v.set(U.id,U);return a?.self&&a.self.status!=="offline"&&v.set(a.self.id,a.self),Array.from(v.values())},[a]),Uo=a?.self?.id??Xn[0]?.id??null,Ht=o.useMemo(()=>l.filter(Il),[l]),Ls=o.useMemo(()=>["all",...Array.from(new Set(Ht.map(v=>v.type))).sort()],[Ht]),$o=o.useMemo(()=>ne==="all"?Ht:Ht.filter(v=>v.type===ne),[Ht,ne]),qo=et.length>0&&et.every(v=>ge.has(v.id)),Vo=et.some(v=>ge.has(v.id)),Ho=uc(et,ge);o.useEffect(()=>{u?.draftNewTask&&(X(!0),Y(u.createMode??"chat"),V(u.createDefaults??null),q({route:u.returnRoute??"/",taskId:u.returnTaskId??null}))},[u]),o.useEffect(()=>{ne!=="all"&&!Ls.includes(ne)&&Q("all")},[ne,Ls]),o.useEffect(()=>{gr(t,F)&&!p&&Xe&&N(Xe)},[t,F,p,Xe]),o.useEffect(()=>{gr(t,F)&&(p&&Fe.some(v=>v.id===p)||N(Xe))},[t,F,p,Xe,Fe]);const be=oc({routeTaskId:t,creatingTask:F,internalSelectedTaskId:p,sortedTaskIds:Xe?[Xe]:[]}),Dt=o.useMemo(()=>Fe.find(v=>v.id===be)??null,[Fe,be]);o.useEffect(()=>{Oe.current=be??null},[be]);const ht=o.useCallback(()=>{G(null),ye([]),Be([]),re(null),Te(!1)},[]),Kt=o.useCallback((v,U,se=!0)=>{rt.current.set(v,{logs:No(U),loaded:se})},[]),He=o.useCallback(async()=>{const v=be;if(v)try{const U=await Rl(v);if(Oe.current!==v)return;G(U),Re(se=>Xa(se,U)),re(null)}catch(U){if(Oe.current!==v)return;ht(),re(U instanceof Error?U.message:"Failed to load task")}finally{Oe.current===v&&Ye(!1)}},[be,ht,Re]),cs=o.useCallback(async()=>{const v=be;if(v)try{const U=await Sn(v);if(Oe.current!==v)return;ye(se=>{const we=Ka(se,U.logs);return Kt(v,we),we}),Be(se=>Tn(se,U.logs))}catch{}finally{Oe.current===v&&Te(!1)}},[be,Kt]);o.useEffect(()=>{if(!be){ht(),Ye(!1);return}ae("transcript"),G(Dt);const v=Bm(be,rt.current);ye(v.logs),Be([]),re(null),Ye(!0),Te(v.transcriptLoading),He(),cs()},[be,ht,cs,He]),o.useEffect(()=>{if(!ic({activeTaskId:be,routeTaskId:t,creatingTask:F,tasksLoading:Rs,loadedTaskIds:Fe.map(U=>U.id)}))return;const v=Xe;N(v),ht(),o.startTransition(()=>{n(v?`/tasks/${v}`:"/",{state:null})})},[be,ht,F,Xe,n,t,Fe,Rs]),o.useEffect(()=>{Dt&&G(v=>!v||v.id!==Dt.id?v:{...v,...Dt})},[Dt]),o.useEffect(()=>{if(be)return c("task",v=>{const U=v.data.taskId;if(!(typeof U!="string"||U!==be)){if(v.type==="task.output"){const se=v.data.event;if(se){ye(fe=>{const Wt=Xl(fe,se);return Kt(be,Wt),Wt}),Te(!1);const we=fr(se);we&&Be(fe=>ed(fe,we))}}v.type==="task.updated"&&He(),v.type==="task.status"&&(He(),cs())}})},[c,be,He,cs]);const ie=_??Dt,Ko=ie?.assignedTo?a?.nodes.find(v=>v.id===ie.assignedTo)??null:null,Gt=r?.setHeaderTaskContext;o.useEffect(()=>{if(!Gt)return;if(!ie){Gt(null);return}const v=ie.effectiveProjectPath??ie.project??"default workspace";return Gt({taskId:ie.id,taskTitle:ie.title,nodeName:Nn(ie.assignedTo,a?.nodes,ie.assignedNodeName),projectLabel:Fa(v),projectPath:v}),()=>Gt(null)},[ie,a?.nodes,Gt]);const Bs=Ie.length>0,Go=ie?Ll.has(ie.agent):!1,us=ie?.status==="running",Wo=ie?js.has(ie.status):!1,Qo=ie?js.has(ie.status)||Bl.has(ie.status):!1,Yo=!!(ie&&Ce&&ie.status==="failed"),Os=o.useMemo(()=>mm(ie,a,Bs,!!us),[ie,a,Bs,us]),Fs=o.useMemo(()=>td([...ue,...Ie.map(v=>Hs(v.content,v.timestamp))]),[ue,Ie]),ms=o.useMemo(()=>{if(!ie||ie.conversationKind==="nativeSession")return null;const v=sd(ie);if(v.length>0)return Hs(v,new Date(ie.createdAt).toISOString());if(Fs.length>0)return null;const U=nd(ie.description||ie.title);return U.length>0?Hs(U,new Date(ie.createdAt).toISOString()):null},[ie,Fs]),zs=o.useMemo(()=>ms?fr(ms):null,[ms]),Jo=o.useMemo(()=>zs?rd(ue,zs):!1,[ue,zs]),Us=o.useCallback((v="chat",U)=>{const se={route:t?`/tasks/${t}`:"/",taskId:be};q(se),Y(v),V(U??null),X(!0),o.startTransition(()=>{n("/",{state:{draftNewTask:!0,returnRoute:se.route,returnTaskId:se.taskId,createMode:v,createDefaults:U}})})},[t,be,n]),Zo=o.useCallback(()=>{const v=j?.taskId??Xe;X(!1),q(null),V(null),N(v),o.startTransition(()=>{n(j?.route??"/",{state:null})})},[j,Xe,n]),er=o.useCallback(v=>{X(!1),q(null),V(null),N(v),o.startTransition(()=>{n(`/tasks/${v}`,{state:null})})},[n]),Xo=o.useCallback(v=>{Oe.current=v.id,X(!1),q(null),V(null),Re(U=>lc(U,v)),G(v),ye([]),Be([]),re(null),Ye(!1),Te(v.conversationKind==="nativeSession"),ae("transcript"),N(v.id),$m({task:v,getActiveTaskId:()=>Oe.current,setLogs:ye,setPendingMessages:Be,setTranscriptLoading:Te}),_e(),o.startTransition(()=>{n(`/tasks/${v.id}`,{state:null})})},[_e,n]),{cancelQueuedMessage:ei,queueFollowUpMessage:hs}=rh({activeTaskId:be,fetchActiveTask:He,isRunning:us,setPendingMessages:Be,setTask:G,setTasks:Re}),ti=o.useCallback(v=>{hs(v)},[hs]),si=o.useCallback(async()=>{const v=be;if(!(!v||ie?.conversationKind!=="nativeSession")){Te(!0);try{const U=await Sn(v);if(Oe.current!==v)return;ye(U.logs),Kt(v,U.logs),Be(se=>Tn(se,U.logs))}catch(U){de.error(U instanceof Error?U.message:"Failed to reload transcript")}finally{Oe.current===v&&Te(!1)}}},[ie?.conversationKind,be,Kt]),ni=o.useCallback(v=>hs(v),[hs]),ri=o.useCallback(async()=>{if(ie)try{await Ol(ie.id),He(),_e()}catch(v){de.error(v instanceof Error?v.message:"Failed to cancel task")}},[ie,He,_e]),{handleShareTask:ai,handleStopShareTask:oi}=jm(ie,He,_e),ii=o.useCallback(async()=>{if(ie)try{await Fl(ie.id),He(),_e()}catch(v){de.error(v instanceof Error?v.message:"Failed to retry task")}},[ie,He,_e]),fs=o.useCallback((v,U=!1)=>{const se=mc(et,v);return N(se),(U||!se)&&ht(),o.startTransition(()=>{n(se?`/tasks/${se}`:"/",{state:null})}),se},[ht,et,n]),li=o.useCallback((v,U)=>{ve(se=>{const we=new Set(se);return U?we.add(v):we.delete(v),we})},[]),di=o.useCallback(v=>{if(!v){ve(new Set);return}ve(new Set(et.map(U=>U.id)))},[et]),ci=o.useCallback(async()=>{const v=Array.from(ge);if(v.length!==0)try{const{results:U}=await zl(v),se=U.filter(fe=>!fe.ok),we=U.filter(fe=>fe.ok).map(fe=>fe.id);be&&we.includes(be)&&fs(we),se.length>0?de.error(`Failed to archive ${se.length} task(s): ${se.map(fe=>fe.error??fe.id).join(", ")}`):de.success(`Archived ${we.length} task(s)`),ve(new Set(se.map(fe=>fe.id))),_e()}catch(U){de.error(U instanceof Error?U.message:"Failed to archive tasks")}},[be,_e,fs,ge]),ui=o.useCallback(async()=>{const v=Array.from(ge);if(v.length!==0)try{const{results:U}=await Ul(v),se=U.filter(fe=>!fe.ok),we=U.filter(fe=>fe.ok).map(fe=>fe.id);we.length>0&&Me(we),be&&we.includes(be)&&fs(we,!0),se.length>0?de.error(`Failed to delete ${se.length} task(s): ${se.map(fe=>fe.error??fe.id).join(", ")}`):de.success(`Deleted ${we.length} task(s)`),ve(new Set(se.map(fe=>fe.id))),_e()}catch(U){de.error(U instanceof Error?U.message:"Failed to delete tasks")}},[be,_e,fs,Me,ge]),mi=o.useCallback(async()=>{ct(!0);try{await $l(),m()}catch(v){de.error(v instanceof Error?v.message:"Failed to promote node")}finally{ct(!1)}},[m]),hi=o.useCallback(async()=>{Je(!0);try{await ql(),de.success("This node left the remote cluster and is leading itself again."),_e(),He(),m()}catch(v){de.error(v instanceof Error?v.message:"Failed to leave cluster")}finally{Je(!1)}},[He,_e,m]),fi=o.useCallback(async v=>{const U=!qn(v),se=v.id===a?.self?.id,we=se?i?.transportType??v.transportType:v.transportType,fe=se&&!U&&Ut(we);St(v.id);try{fe?await Vl("direct"):await Hl(v.id,U),de.success(U?`Enabled remote access on ${v.name}`:`Disabled remote access on ${v.name}`),m()}catch(Wt){de.error(Wt instanceof Error?Wt.message:"Failed to update remote access")}finally{St(null)}},[a?.self?.id,m,i?.transportType]),xi=o.useCallback(v=>{ce&&ce(v).catch(U=>{de.error(U instanceof Error?U.message:"Failed to load completed tasks")})},[ce]),tr={toolbarTasks:et,activeTaskId:be,tasksLoading:Rs,tasksError:Vt,isLeader:Ce,scope:y,agentFilter:h,nodeFilter:x,taskKindFilter:S,agentOptions:Lo,nodeOptions:Bo,nodeNameById:Zn,nodeWorkDirById:Oo,nodeStatusById:Fo,leaderNodeId:a?.leader?.id??null,searchQuery:C,completedGroupByKey:zo,devBoxNodeIds:De,devBoxStartNodeIds:Et,devBoxStartingNodeIds:mt,selectedTaskIds:ge,allVisibleTasksSelected:qo,someVisibleTasksSelected:Vo,canBatchArchive:Ho,onScopeChange:D,onAgentFilterChange:E,onNodeFilterChange:b,onTaskKindFilterChange:T,onToggleTaskSelected:li,onToggleAllVisibleTasks:di,onBatchArchive:ci,onBatchDelete:ui,onCreateTask:Us,onOpenNodeSettings:Ce?Ee:void 0,onOpenNodeCapabilities:Ce?at:void 0,onOpenProjectCapabilities:Ce?qt:void 0,onOpenDevBox:Ce?ot:void 0,onStartDevBox:Ce?At:void 0,onLoadCompletedTasks:xi,onSelectTask:er},pi={cluster:a,systemInfo:i,nodeNameById:Zn,nodeBlockingTaskCounts:Ro,eventTypeFilter:ne,onEventTypeFilterChange:Q,activeTab:oe,onTabChange:he,eventTypeOptions:Ls,filteredEvents:$o,sseConnected:d,clusterLoading:g,clusterError:f,promotePending:qe,onPromote:mi,onAddNode:()=>W(!0),leavePending:je,onLeaveCluster:hi,onToggleNodeDevTunnel:fi,devTunnelNodeId:ut,devBoxStartNodeId:Ve,devBoxStartingNodeIds:mt,onOpenNodeSettings:Ce?Ee:void 0,onOpenNodeCapabilities:Ce?at:void 0,onOpenDevBox:Ce?ot:void 0,onStartDevBox:Ce?At:void 0};return e.jsxs(e.Fragment,{children:[e.jsx(yu,{desktopTasksOpen:k,mobileTasksPanelOpen:P,mobileTasksPanelRef:M,operationsOpen:A,operationsPanelRef:B,panelResize:R,taskSidebar:e.jsx(ua,{...tr}),operationsSidecar:e.jsx(cm,{...pi}),terminalPanel:r?.terminalOpen?e.jsx(Au,{nodes:Xn,defaultNodeId:Uo,onClose:()=>r?.setTerminalOpen(!1)}):void 0,conversationPanel:e.jsx(hu,{onToggleTasks:te,desktopTasksOpen:k,mobileTasksPanelOpen:P,operationsOpen:A,onToggleOperations:()=>Z(v=>!v),cluster:a,sseConnected:d,activeTab:L,setActiveTab:ae,creatingTask:F,createMode:$,createDefaults:w,activeTask:ie,assignedNode:Ko,taskLoading:pt,transcriptLoading:$e,taskError:dt,displayEvents:Fs,initialPromptAlreadyInLogs:Jo,initialPrompt:ms,supportsFollowUp:Go,taskUnavailable:Os.taskUnavailable,chatDisabled:Os.chatDisabled,chatDisabledReason:Os.chatDisabledReason,questionBypassEnabled:J,isRunning:!!us,isStarting:Wo,hasPendingFollowUp:Bs,canCancel:!!Qo,canRetry:!!Yo,onRetry:ii,onCancel:ri,onReloadNativeTranscript:si,onShareTask:ai,onStopShareTask:oi,onStartCreateTask:Us,onCancelCreateTask:Zo,onCreateTask:Xo,onSendMessage:ti,onCancelQueuedMessage:ei,onQuestionBypassChange:le,onSubmitQuestionResponse:ni,quickChats:Ct}),mobileTaskSidebar:e.jsx(ua,{...tr,onCreateTask:(v,U)=>{H(!1),Us(v,U)},onSelectTask:v=>{H(!1),er(v)}}),onCloseOperations:()=>Z(!1),onCloseTaskList:()=>H(!1),onToggleOperations:()=>Z(v=>!v),onToggleTasks:te}),e.jsx(pu,{open:z,onOpenChange:W,onAdded:m}),K,Tt,Ae]})}const Gh=Object.freeze(Object.defineProperty({__proto__:null,DashboardPage:$h},Symbol.toStringTag,{value:"Module"}));export{Ga as A,Gh as D,Ns as G};
|