meshy-node 0.10.10 → 1.0.0
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-kK0-et4p.js +211 -0
- package/dashboard/assets/{DashboardShared-DihTM-xx.js → DashboardShared-B-MhNC7V.js} +23 -23
- package/dashboard/assets/{DiffTab-BuC8qgFb.js → DiffTab-xXmdkadb.js} +2 -2
- package/dashboard/assets/{FilesTab-jvuvGCqQ.js → FilesTab-tVrm_BOK.js} +2 -2
- package/dashboard/assets/{MarkdownPreviewFrame-CwXixe62.js → MarkdownPreviewFrame-Bh67Y-4b.js} +1 -1
- package/dashboard/assets/{PreviewTab-oRD3Wntx.js → PreviewTab-kRFQ5bQf.js} +5 -5
- package/dashboard/assets/SharedConversationPage-CYSWbDBC.js +2 -0
- package/dashboard/assets/{file-CoTh89vx.js → file-eGew3MDA.js} +1 -1
- package/dashboard/assets/index-DJ824ClY.css +1 -0
- package/dashboard/assets/index-rujLgCBM.js +326 -0
- package/dashboard/index.html +2 -2
- package/main.cjs +16 -4
- package/package.json +1 -1
- package/runtime-metadata.json +4 -4
- package/dashboard/assets/DashboardPage-Dr7Q3ARl.js +0 -191
- package/dashboard/assets/SharedConversationPage-Psgl27Kx.js +0 -2
- package/dashboard/assets/index-BBHpcOD3.js +0 -346
- package/dashboard/assets/index-CE-vUwSy.css +0 -1
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-tVrm_BOK.js","assets/index-rujLgCBM.js","assets/index-DJ824ClY.css","assets/MarkdownPreviewFrame-Bh67Y-4b.js","assets/DashboardShared-B-MhNC7V.js","assets/file-eGew3MDA.js","assets/PreviewTab-kRFQ5bQf.js","assets/DiffTab-xXmdkadb.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as ue,r as o,a as Hs,f as go,m as bo,j as e,X as dt,Q as Wn,B as Z,L as fe,S as Zs,b as bl,d as L,e as vl,g as wl,h as yl,I as ct,P as jl,C as Ts,i as Nl,k as vo,F as us,l as ut,n as Oe,D as As,o as kl,p as Sl,t as ce,q as $e,s as qe,u as Je,v as He,w as wo,x as st,T as Cl,y as Tl,z as Bs,A as Al,E as mt,G as ht,H as bt,J as yo,K as jo,M as Ds,N as ur,O as El,R as zt,U as Ml,V as Qn,W as Dl,Y as No,Z as mr,_ as ko,$ as _l,a0 as Le,a1 as Pl,a2 as Nt,a3 as Ut,a4 as $t,a5 as qt,a6 as Ht,a7 as Vt,a8 as Kt,a9 as Gt,aa as Wt,ab as hr,ac as Il,ad as Et,ae as fr,af as Rl,ag as Ur,ah as Yn,ai as hn,aj as Ll,ak as Bl,al as Ol,am as Fl,an as zl,ao as Ul,ap as So,aq as Mt,ar as Co,as as $l,at as ql,au as yt,av as xr,aw as pr,ax as Hl,ay as $r,az as Vl,aA as ys,aB as Kl,aC as Gl,aD as Xs,aE as Wl,aF as _s,aG as Ql,aH as gr,aI as Yl,aJ as Jl,aK as br,aL as Zl,aM as Vs,aN as Xl,aO as qr,aP as vr,aQ as wr,aR as ec,aS as tc,aT as sc,aU as nc,aV as To,aW as Es,aX as rc,aY as Jn,aZ as ac,a_ as oc,a$ as ic,b0 as lc,b1 as Hr,b2 as cc,b3 as dc,b4 as fn,b5 as uc,b6 as Vr,b7 as mc,b8 as hc,b9 as fc,ba as Kr,bb as xc,bc as pc,bd as Zn,be as gc,bf as bc,bg as Ao,bh as Gr,bi as Eo,bj as vc,bk as Wr,bl as wc,bm as yc,bn as jc,bo as Nc,bp as kc,bq as Sc,br as Qr,bs as Cc,bt as Tc,bu as Ac,bv as Ec,bw as Mc,bx as Dc,by as _c,bz as Pc,bA as Ic,bB as Rc,bC as Lc,bD as Bc,bE as Oc,bF as Fc,bG as zc,bH as Uc,bI as $c,bJ as qc,bK as Hc,bL as Vc,bM as Kc,bN as Gc,bO as Wc,bP as Qc,bQ as Yc,bR as Jc,bS as Zc}from"./index-rujLgCBM.js";import{r as Yr,e as Xc,b as Mo,g as Do,a as kt,A as At,I as yr,c as _o,T as Po,d as ed,i as Io,f as td,p as Ro,h as sd,j as Jr,k as Zr,l as nd,m as rd,n as ad,C as Xr,o as xn,q as jr,D as as,s as lt,M as Xn,L as od,t as id,u as ld,v as Lo,w as er,x as cd,y as pn,z as dd,B as ud,E as md}from"./DashboardShared-B-MhNC7V.js";import{E as hd,M as fd}from"./MarkdownPreviewFrame-Bh67Y-4b.js";import{P as en,D as Os,g as xd,a as pd,b as gd}from"./PreviewTab-kRFQ5bQf.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 bd=[["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"}]],Bo=ue("archive",bd);/**
|
|
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 vd=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],ea=ue("arrow-right",vd);/**
|
|
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 wd=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Oo=ue("arrow-up",wd);/**
|
|
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 yd=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],Fo=ue("at-sign",yd);/**
|
|
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 jd=[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]],zo=ue("brain-circuit",jd);/**
|
|
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 Nd=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Ks=ue("chevron-left",Nd);/**
|
|
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 kd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],ta=ue("clock",kd);/**
|
|
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 Sd=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],Cd=ue("cpu",Sd);/**
|
|
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 Td=[["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"}]],Ad=ue("earth",Td);/**
|
|
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 Ed=[["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"}]],Nr=ue("ellipsis-vertical",Ed);/**
|
|
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 Md=[["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"}]],Dd=ue("ellipsis",Md);/**
|
|
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 _d=[["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"}]],tn=ue("folder-open",_d);/**
|
|
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 Pd=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],Uo=ue("folder-tree",Pd);/**
|
|
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 Id=[["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"}]],Rd=ue("funnel",Id);/**
|
|
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 Ld=[["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"}]],Gs=ue("git-branch",Ld);/**
|
|
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 Bd=[["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"}]],Od=ue("globe",Bd);/**
|
|
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 Fd=[["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"}]],Ws=ue("history",Fd);/**
|
|
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 zd=[["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"}]],tr=ue("image-plus",zd);/**
|
|
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 Ud=[["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"}]],$d=ue("laptop",Ud);/**
|
|
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 qd=[["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"}]],kr=ue("link-2",qd);/**
|
|
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 Hd=[["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"}]],Vd=ue("list-ordered",Hd);/**
|
|
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 Kd=[["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"}]],Ps=ue("message-square-plus",Kd);/**
|
|
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 Gd=[["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"}]],$o=ue("monitor-play",Gd);/**
|
|
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 Wd=[["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"}]],Yt=ue("pencil",Wd);/**
|
|
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 Qd=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]],Yd=ue("pin-off",Qd);/**
|
|
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 Jd=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],qo=ue("pin",Jd);/**
|
|
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 Zd=[["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"}]],Ho=ue("qr-code",Zd);/**
|
|
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 Xd=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],Vo=ue("radio",Xd);/**
|
|
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 eu=[["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"}]],tu=ue("rotate-ccw",eu);/**
|
|
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 su=[["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"}]],Ko=ue("rotate-cw",su);/**
|
|
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 nu=[["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"}]],Go=ue("send",nu);/**
|
|
158
|
+
* @license lucide-react v1.7.0 - ISC
|
|
159
|
+
*
|
|
160
|
+
* This source code is licensed under the ISC license.
|
|
161
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
162
|
+
*/const ru=[["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"}]],Qs=ue("share-2",ru);/**
|
|
163
|
+
* @license lucide-react v1.7.0 - ISC
|
|
164
|
+
*
|
|
165
|
+
* This source code is licensed under the ISC license.
|
|
166
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
167
|
+
*/const au=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],ou=ue("shield",au);/**
|
|
168
|
+
* @license lucide-react v1.7.0 - ISC
|
|
169
|
+
*
|
|
170
|
+
* This source code is licensed under the ISC license.
|
|
171
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
172
|
+
*/const iu=[["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"}]],lu=ue("sliders-horizontal",iu);/**
|
|
173
|
+
* @license lucide-react v1.7.0 - ISC
|
|
174
|
+
*
|
|
175
|
+
* This source code is licensed under the ISC license.
|
|
176
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
177
|
+
*/const cu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],sa=ue("square",cu);/**
|
|
178
|
+
* @license lucide-react v1.7.0 - ISC
|
|
179
|
+
*
|
|
180
|
+
* This source code is licensed under the ISC license.
|
|
181
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
182
|
+
*/const du=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],gn=ue("triangle-alert",du);/**
|
|
183
|
+
* @license lucide-react v1.7.0 - ISC
|
|
184
|
+
*
|
|
185
|
+
* This source code is licensed under the ISC license.
|
|
186
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
187
|
+
*/const uu=[["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"}]],mu=ue("user-plus",uu);/**
|
|
188
|
+
* @license lucide-react v1.7.0 - ISC
|
|
189
|
+
*
|
|
190
|
+
* This source code is licensed under the ISC license.
|
|
191
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
192
|
+
*/const hu=[["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"}]],fu=ue("wifi",hu);/**
|
|
193
|
+
* @license lucide-react v1.7.0 - ISC
|
|
194
|
+
*
|
|
195
|
+
* This source code is licensed under the ISC license.
|
|
196
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
197
|
+
*/const xu=[["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"}]],pu=ue("zoom-in",xu);/**
|
|
198
|
+
* @license lucide-react v1.7.0 - ISC
|
|
199
|
+
*
|
|
200
|
+
* This source code is licensed under the ISC license.
|
|
201
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
202
|
+
*/const gu=[["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"}]],bu=ue("zoom-out",gu),vu=new Set(["assigned","running"]);function wu(t,s){return t.reduce((n,r)=>r.assignedTo===s&&vu.has(r.status)?n+1:n,0)}function ms(t){return t?.toLowerCase()==="devtunnel"}function yu(t){return t?ms(t)?"DevTunnel":t.charAt(0).toUpperCase()+t.slice(1):"Direct"}function Sr(t,s){return ms(s??t.transportType)||!!t.devtunnelEndpoint}function Wo(t,s){return!ms(s??t.transportType)}function Qo(t,s){const n=s??t.transportType;return ms(n)?"DevTunnel":t.devtunnelEndpoint?"Direct + DevTunnel":yu(n)}function na(t,s){return!t&&!s}function ju({routeTaskId:t,creatingTask:s,internalSelectedTaskId:n,sortedTaskIds:r}){return t||(s?null:r[0]??n??null)}function Nu({activeTaskId:t,routeTaskId:s,creatingTask:n,tasksLoading:r,loadedTaskIds:a}){return!t||s||n||r?!1:!a.includes(t)}function ku(t,s){return[s,...t.filter(n=>n.id!==s.id)]}function Cr(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 Su=new Set(["completed","failed","cancelled","archived"]);function Cu(t,s){const n=new Set(s);return new Set(Array.from(t).filter(r=>n.has(r)))}function Tu(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=>Su.has(a.status))}function Au(t,s){const n=new Set(s);return t.find(r=>!n.has(r.id))?.id??null}function Yo(){const[t,s]=o.useState([]),[n,r]=o.useState(null),a=o.useRef(null),i=o.useCallback(()=>{a.current?.click()},[]),l=o.useCallback(async p=>{const u=Array.from(p.target.files??[]);if(u.length!==0)try{const h=await Yr(u);s(f=>[...f,...h]),r(null)}catch(h){r(h instanceof Error?h.message:"Failed to attach image")}finally{p.target.value=""}},[]),c=o.useCallback(async p=>{const u=Xc(p.clipboardData);if(u.length!==0){p.preventDefault();try{const h=await Yr(u);s(f=>[...f,...h]),r(null)}catch(h){r(h instanceof Error?h.message:"Failed to attach image")}}},[]),d=o.useCallback(p=>{s(u=>u.filter((h,f)=>f!==p))},[]),m=o.useCallback(()=>{s([]),r(null)},[]);return{images:t,error:n,fileInputRef:a,pickImages:i,handleFileChange:l,handlePaste:c,removeImage:d,clearImages:m}}function Eu({disabled:t=!1,running:s=!1,canStop:n=!1,hasContent:r=!1}){return s&&(!r||n&&t)?{primaryAction:"stop",primaryDisabled:!n}:{primaryAction:"send",primaryDisabled:t||!r}}function Mu({contentLength:t,disabled:s=!1}){return t>0&&!s}const Du=/^[a-zA-Z0-9_-]+$/,Jo=/[a-zA-Z0-9_-]/,_u=176;function Pu(t){const s=t.map(a=>({...a,displayValue:Iu(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 Iu(t){return t.label.toLowerCase()==="agent"?kt(t.value):t.value}function ra(t){switch(t.toLowerCase()){case"branch":return Gs;case"node":return Zs;default:return tn}}function Ru(t){return Array.from(new Set(t.map(s=>s.trim()).filter(Boolean)))}function Zo(t,s){return Number.isFinite(s)?Math.max(0,Math.min(t.length,Math.trunc(s))):t.length}function Lu(t,s){const n=Zo(t,s),a=t.slice(0,n).match(/@([a-zA-Z0-9_-]*)$/);if(!a||a.index===void 0)return;const i=a.index+1,l=t.slice(n).match(/^[a-zA-Z0-9_-]*/),c=n+(l?.[0].length??0),d=t.slice(i,c);if(!(d.length>0&&!Du.test(d)))return{query:d.toLowerCase(),range:{start:a.index,end:c}}}function Bu(t,s){const n=new Map(s.map(i=>[i.toLowerCase(),i])),r=/@([a-zA-Z0-9_-]+)/g;let a;for(;(a=r.exec(t))!==null;){const i=(a[1]??"").toLowerCase(),l=n.get(i);if(!l)continue;const c=a.index+a[0].length;if(!(c<t.length&&Jo.test(t[c]??"")))return{targetAgent:l,query:i,range:{start:a.index,end:c}}}}function sr(t,s){const n=t.slice(0,s.start);let r=t.slice(s.end);return n.length===0?r.trimStart():r.length===0?n.trimEnd():(/\s$/.test(n)&&/^\s/.test(r)?r=r.trimStart():!/\s$/.test(n)&&!/^\s/.test(r)&&(r=" "+r),n+r)}function aa(t,s,n){const r=Ru(s),a=typeof n=="number",i=Lu(t,a?n:t.length);if(i){const c=r.filter(p=>p.toLowerCase().startsWith(i.query)),d=r.find(p=>p.toLowerCase()===i.query),m=!!d&&(i.range.end===t.length||!Jo.test(t[i.range.end]??""));return{...m?{targetAgent:d}:{},query:i.query,strippedText:m?sr(t,i.range):t,matches:c,...a?{mentionRange:i.range}:{}}}const l=Bu(t,r);return l?{targetAgent:l.targetAgent,query:l.query,strippedText:sr(t,l.range),matches:[l.targetAgent],...a?{mentionRange:l.range}:{}}:{strippedText:t,matches:[]}}function Ou(t,s,n){if(t.length===0)return 0;const r=s?t.indexOf(s):-1;if(r>=0)return r;const a=n?t.indexOf(n):-1;return a>=0?a:0}function Fu(t,s){return t.query!==void 0&&t.matches.length>0&&!t.targetAgent&&!s}function zu(t,s){if(!s)return{value:t.replace(/^@[a-zA-Z0-9_-]*\s*/,""),cursorPosition:0};const n=sr(t,s);return{value:n,cursorPosition:Math.min(s.start,n.length)}}function Uu(t,s){const n=window.getComputedStyle(t);["boxSizing","width","fontFamily","fontSize","fontWeight","fontStyle","letterSpacing","textTransform","wordSpacing","textIndent","lineHeight","paddingTop","paddingRight","paddingBottom","paddingLeft","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth"].forEach(a=>{s.style[a]=n[a]})}function $u(t,s){if(typeof window>"u")return;const n=t.ownerDocument,r=n.createElement("div"),a=n.createElement("span"),i=Zo(t.value,s);Uu(t,r),r.style.position="absolute",r.style.visibility="hidden",r.style.whiteSpace="pre-wrap",r.style.overflowWrap="break-word",r.style.overflow="hidden",r.style.top="0",r.style.left="-9999px",r.style.height="auto",r.textContent=t.value.slice(0,i),a.textContent="",r.appendChild(a),n.body.appendChild(r);const l={left:a.offsetLeft-t.scrollLeft,top:a.offsetTop-t.scrollTop};return r.remove(),l}function qu({cardClientWidth:t,cardRectWidth:s}){const n=s/t;return Number.isFinite(n)&&n>0?n:1}function Hu({boundaryRectBottom:t,boundaryRectTop:s,cardRectTop:n,cardWidth:r,caretLeft:a,caretTop:i,cssZoom:l=1,lineHeight:c,matchCount:d,textareaOffsetLeft:m,textareaOffsetTop:p,viewportHeight:u}){const h=Number.isFinite(l)&&l>0?l:1,f=Math.min(Math.max(d,1)*28+4,220),w=f*h,g=m/h,N=p/h,b=s??0,k=t??u,y=Math.max(8,r-_u-8),x=Math.max(8,Math.min(g+a,y)),v=N+i+c+4,S=n+v*h,A=N+i-f-4,I=n+(N+i)*h,E=k-S-8,B=I-b-8,M=Math.max(8,(b-n+8)/h);if(E<w&&B>E)return{left:x,top:Math.max(M,A)};const D=Math.max(M,(k-n-w-8)/h);return{left:x,top:Math.max(M,Math.min(v,D))}}function Vu(t,s,n){const r=t.closest('[data-chat-input-card="true"]'),a=$u(t,s);if(!r||!a)return;const i=t.getBoundingClientRect(),l=r.getBoundingClientRect(),c=r.closest(".dashboard-conversation-panel")?.getBoundingClientRect(),d=Number.parseFloat(window.getComputedStyle(t).lineHeight)||18;return Hu({boundaryRectBottom:c?.bottom,boundaryRectTop:c?.top,cardRectTop:l.top,cardWidth:r.clientWidth,caretLeft:a.left,caretTop:a.top,cssZoom:qu({cardRectWidth:l.width,cardClientWidth:r.clientWidth}),lineHeight:d,matchCount:n,textareaOffsetLeft:i.left-l.left,textareaOffsetTop:i.top-l.top,viewportHeight:window.innerHeight})}function Ku({onSend:t,disabled:s,disabledReason:n="Chat is waiting on the agent.",placeholder:r="Send a follow-up message...",contextItems:a=[],agent:i,currentAgent:l,taskId:c,model:d,availableAgents:m=[],selectedTargetAgent:p,onTargetAgentChange:u,running:h=!1,onStop:f,quickChats:w=[]}){const[g,N]=o.useState(""),[b,k]=o.useState(),[y,x]=o.useState(c),[v,S]=o.useState(),[A,I]=o.useState(),[E,B]=o.useState(!1),[M,D]=o.useState(0),[P,O]=o.useState(0),[Q,te]=o.useState(0),Y=o.useRef(null),H=o.useRef(void 0),{images:se,error:$,fileInputRef:X,pickImages:j,handleFileChange:W,handlePaste:T,removeImage:ee,clearImages:R}=Yo();c!==y&&(x(c),k(void 0));const V=o.useCallback((G=Y.current)=>{G&&D(G.selectionStart??G.value.length)},[]),F=o.useCallback((G=M,ge=1)=>{Y.current&&I(Vu(Y.current,G,ge))},[M]),le=o.useCallback(()=>{Y.current&&(Y.current.style.height="auto")},[]),ie=o.useCallback(()=>{Y.current&&(Y.current.style.height="auto",Y.current.style.height=Math.min(Y.current.scrollHeight,220).toString()+"px",V(Y.current))},[V]);o.useEffect(()=>{O(0)},[g,w]);const me=p??b,J=o.useMemo(()=>aa(g,m,M),[m,M,g]),K=Fu(J,E),_=Ou(J.matches,v,l),ne=J.matches[_];o.useEffect(()=>{S(void 0),B(!1)},[l,J.query,J.matches.join("|")]),o.useEffect(()=>{if(!K){I(void 0);return}const G=J.mentionRange?.end??M,ge=()=>F(G,J.matches.length);if(typeof requestAnimationFrame!="function"){ge();return}const be=requestAnimationFrame(ge);return()=>cancelAnimationFrame(be)},[J.matches.length,J.mentionRange?.end,M,K,F]);const q=o.useCallback(G=>{u?u(G):k(G)},[u]),ae=o.useCallback(G=>{N(G.prompt);const ge=()=>{Y.current?.focus(),ie()};typeof requestAnimationFrame=="function"?requestAnimationFrame(ge):ge()},[ie]),ye=o.useCallback(()=>{const G=Hs(g,w,P);if(G){ae(G);return}const ge=aa(g,m,M),be=ge.targetAgent??me,et=ge.targetAgent?ge.strippedText:g,_e=Mo(et,se);Mu({contentLength:_e.length,disabled:s})&&(te(nt=>nt+1),t(_e,be?{targetAgent:be}:void 0),N(""),q(void 0),R(),le())},[g,se,m,M,me,s,t,q,R,le,w,P,ae]),xe=o.useCallback((G,ge=J.mentionRange)=>{q(G),N(et=>{const _e=zu(et,ge);return H.current=_e.cursorPosition,D(_e.cursorPosition),_e.value});const be=()=>{Y.current?.focus(),H.current!==void 0&&(Y.current?.setSelectionRange(H.current,H.current),H.current=void 0),ie()};typeof requestAnimationFrame=="function"?requestAnimationFrame(be):be()},[ie,J.mentionRange,q]),Ze=o.useCallback(G=>{if(K&&G.key==="Escape"){G.preventDefault(),B(!0);return}if(K&&(G.key==="ArrowDown"||G.key==="ArrowUp")){G.preventDefault();const be=J.matches.length;if(be===0)return;const et=G.key==="ArrowDown"?1:-1,_e=(_+et+be)%be;S(J.matches[_e]);return}if(K&&G.key==="Enter"&&!G.shiftKey&&ne){G.preventDefault(),xe(ne,J.mentionRange);return}const ge=go(g,w);if(ge.length>0&&(G.key==="ArrowDown"||G.key==="ArrowUp")){G.preventDefault(),O(be=>bo(be,ge.length,G.key==="ArrowDown"?1:-1));return}if(G.key==="Enter"&&!G.shiftKey){G.preventDefault();const be=Hs(g,w,P);be?ae(be):ye()}},[xe,ae,ye,J.matches,J.mentionRange,w,P,ne,_,K,g]),Ae=g.trim().length>0||se.length>0,Re=Eu({disabled:s,running:h,canStop:h&&!!f,hasContent:Ae}),De=Pu(a),Ve=De.primary?ra(De.primary.label):tn,Ke=i?Do(i,d):null,je=l?kt(l):null,Be=s?n:h?Ae?"Enter queues this message for the next turn":f?"Task is running - type to queue, empty button stops task":"Task is running - type to queue a message":"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 relative overflow-visible 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:X,type:"file",accept:"image/*",multiple:!0,onChange:W,className:"hidden"}),l&&je&&e.jsxs("span",{"data-current-agent":l,title:`Active agent: ${je}`,className:"absolute right-2 top-1.5 z-10 inline-flex h-4 max-w-[8.5rem] items-center gap-1 rounded-sm bg-primary/12 px-1.5 text-[8px] font-medium leading-3 text-primary sm:right-4 sm:top-2",children:[e.jsx(At,{agent:l,className:"h-2.5 w-2.5 shrink-0 text-primary/75"}),e.jsx("span",{className:"truncate",children:je})]}),De.primary&&e.jsx("div",{"data-chat-input-primary-context":"true",className:`px-2.5 pt-1.5 sm:px-5 sm:pt-2 ${l?"pr-24 sm:pr-32":""}`,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(Ve,{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:De.primary.value,children:De.primary.displayValue})]})}),se.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:se.map((G,ge)=>e.jsxs("div",{className:"relative",children:[e.jsx(yr,{image:G,alt:G.filename??`attachment ${ge+1}`,thumbnailClassName:"h-24 w-24 border border-border/70",imageClassName:"h-full w-full"}),e.jsx("button",{type:"button",onClick:()=>ee(ge),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 ${G.filename??`image ${ge+1}`}`,children:e.jsx(dt,{className:"h-3 w-3"})})]},`${G.filename??"image"}-${ge}`))})}),e.jsx("div",{className:"px-2 pb-0 pt-1 sm:px-5 sm:pt-1.5",children:e.jsx("textarea",{ref:Y,"data-chat-input-textarea":"true",value:g,onChange:G=>{N(G.target.value),V(G.currentTarget)},onKeyDown:Ze,onKeyUp:G=>V(G.currentTarget),onClick:G=>V(G.currentTarget),onSelect:G=>V(G.currentTarget),onScroll:()=>F(M,J.matches.length),onPaste:T,onInput:ie,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(Wn,{query:g,quickChats:w,selectedIndex:P,onActiveIndexChange:O,onSelect:ae}),K&&e.jsx("div",{"data-agent-mention-menu":"true",className:"absolute z-20 flex w-44 max-w-[calc(100%-1rem)] flex-col overflow-hidden rounded-sm border border-border/60 bg-popover/95 p-0.5 text-popover-foreground shadow-[0_16px_42px_-24px_rgba(0,0,0,0.85)]",style:A?{left:A.left,top:A.top}:{left:8,top:"50%"},children:J.matches.map((G,ge)=>e.jsxs("button",{type:"button",onMouseDown:be=>be.preventDefault(),onMouseEnter:()=>S(G),onClick:()=>xe(G,J.mentionRange),className:["flex h-7 w-full items-center gap-1.5 rounded-sm px-1.5 text-left text-[10px] transition-colors hover:bg-muted/55 hover:text-foreground",ge===_?"bg-primary/10 text-primary":"text-muted-foreground"].join(" "),children:[e.jsx(At,{agent:G,className:"h-3 w-3 shrink-0 text-primary/60"}),e.jsx("span",{className:"truncate",children:kt(G)})]},G))}),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:[me||De.secondary.length>0?e.jsxs("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:[me&&e.jsxs("span",{"data-chat-input-target-agent":me,title:`Send to ${kt(me)}`,className:"inline-flex h-6 max-w-[11rem] items-center gap-1.5 rounded-sm bg-primary/10 px-1.5 text-[10px] leading-3 text-primary",children:[e.jsx(Fo,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),e.jsx(At,{agent:me,className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:kt(me)}),e.jsx("button",{type:"button",onClick:()=>q(void 0),className:"-mr-0.5 inline-flex h-4 w-4 items-center justify-center rounded-sm text-primary/70 hover:bg-primary/15 hover:text-primary","aria-label":"Clear target agent",children:e.jsx(dt,{className:"h-2.5 w-2.5"})})]}),De.secondary.map(G=>{const ge=ra(G.label),be=G.label.toLowerCase()==="agent";return e.jsxs("span",{title:`${G.label}: ${G.value}`,className:"inline-flex min-w-0 max-w-[12rem] items-center gap-1 truncate",children:[be?e.jsx(At,{agent:G.value,className:"h-2.5 w-2.5 shrink-0 text-primary/50"}):e.jsx(ge,{"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 ${G.mono?"font-mono":""}`,children:G.displayValue})]},`${G.label}:${G.value}`)})]}):e.jsx("div",{className:"min-w-0 flex-1"}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[Ke&&e.jsxs("span",{"data-chat-input-model-display":"true","aria-label":`Model: ${Ke}`,title:`Model: ${Ke}`,className:"inline-flex h-7 max-w-[9rem] shrink-0 items-center gap-1.5 truncate rounded-sm px-2 text-[10px] text-muted-foreground",children:[e.jsx(zo,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),Ke]}),e.jsxs(Z,{type:"button",variant:"ghost",onClick:j,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(tr,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Images"})]}),e.jsx("span",{title:Be,children:e.jsx(Z,{onClick:Re.primaryAction==="stop"?f:ye,disabled:Re.primaryDisabled,size:"icon","data-chat-send-button":"true","aria-label":Re.primaryAction==="stop"?"Stop running task":h?"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:Re.primaryAction==="stop"?e.jsx(fe,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Go,{className:`h-3.5 w-3.5 ${Q>0?"animate-chat-send-flight":""}`},Q)})})]})]}),$&&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:$})]})})})}var Gu=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Wu=Gu.reduce((t,s)=>{const n=bl(`Primitive.${s}`),r=o.forwardRef((a,i)=>{const{asChild:l,...c}=a,d=l?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(d,{...c,ref:i})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{}),Qu="Label",Xo=o.forwardRef((t,s)=>e.jsx(Wu.label,{...t,ref:s,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(t.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));Xo.displayName=Qu;var ei=Xo;const Yu=vl("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),tt=o.forwardRef(({className:t,...s},n)=>e.jsx(ei,{ref:n,className:L(Yu(),t),...s}));tt.displayName=ei.displayName;function oa({agent:t,query:s,onSelect:n}){const r=_o(t,s);return r?e.jsx("div",{"data-codex-goal-command":"true",className:"mx-2 mb-0.5 rounded-sm bg-background/70 p-0.5 shadow-none sm:mx-5",children:e.jsx("div",{role:"listbox","aria-label":"Codex commands",children:e.jsxs("button",{type:"button",role:"option","aria-selected":"true",onClick:n,className:"flex h-8 w-full min-w-0 items-center gap-2 rounded-sm px-2 text-left transition-colors hover:bg-muted/50 hover:text-foreground",children:[e.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-sm bg-primary/10 text-primary",children:e.jsx(Po,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),e.jsx("span",{className:"shrink-0 text-[11px] font-medium text-foreground",children:r.label}),e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:r.description})]})})}):null}function Ju(t,s,n){return t!=="auto"?s.find(r=>r.id===t)??null:n.length===1?n[0]??null:null}function Zu(t){return t.trim()||"."}function Xu(t){return new Promise(s=>window.setTimeout(s,t))}function em(t){return!!t&&typeof t=="object"&&typeof t.createdBranch=="string"&&typeof t.currentBranch<"u"}async function tm(t){let s=t;for(let n=0;n<60;n++){if(s.status==="succeeded"){if(em(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 Xu(1e3),s=await Nl(s.id)}throw new Error("Timed out waiting for branch creation")}function ia({value:t,onChange:s,project:n,assignTo:r,nodes:a,assignableNodes:i,layout:l="default",chipClassName:c,chipActiveClassName:d,chipInactiveClassName:m,labelClassName:p,triggerClassName:u}){const[h,f]=o.useState(!1),[w,g]=o.useState(null),[N,b]=o.useState(""),[k,y]=o.useState(!1),[x,v]=o.useState(!1),[S,A]=o.useState(!1),[I,E]=o.useState(null),[B,M]=o.useState(""),[D,P]=o.useState(""),[O,Q]=o.useState(""),[te,Y]=o.useState(!1),H=o.useRef(null),se=o.useRef(0),$=o.useMemo(()=>Ju(r,a,i),[r,a,i]),X=$?.id,j=o.useMemo(()=>Zu(n),[n]),W=o.useMemo(()=>X?`${X}
|
|
203
|
+
${j}`:"",[X,j]),T=o.useCallback(async(J=0,K=!1)=>{const _=se.current+1,ne=W;if(se.current=_,!X){g(null),b("");return}E(null),K||b(""),K?v(!0):y(!0);try{const q=await wl(X,{path:j,limit:20,offset:J,allowAbsolute:!0});if(_!==se.current)return;b(ne),g(ae=>K&&ae?{...q,branches:[...ae.branches,...q.branches]}:q)}catch(q){if(_!==se.current)return;E(q instanceof Error?q.message:"Failed to load branch info"),K||(g(null),b(""))}finally{_===se.current&&(y(!1),v(!1))}},[X,W,j]);o.useEffect(()=>{if(!X){se.current+=1,g(null),b(""),E(null);return}T()},[X,j,T]),o.useEffect(()=>{const J=t.trim(),K=N===W?w:null,_=K?.available&&K.currentBranch?K.currentBranch:"";J!==_&&s(_)},[w,W,N,s,t]),o.useEffect(()=>{if(!h)return;const J=_=>{H.current&&(H.current.contains(_.target)||f(!1))},K=_=>{_.key==="Escape"&&f(!1)};return document.addEventListener("mousedown",J),document.addEventListener("keydown",K),()=>{document.removeEventListener("mousedown",J),document.removeEventListener("keydown",K)}},[h]),o.useEffect(()=>{h&&(P(""),Q(""),Y(!1))},[h,X,j]);const ee=o.useCallback(async()=>{if(!X)return;const J=B.trim(),K=te?O.trim():D.trim();if(!(!J||!K)){A(!0),E(null);try{const _=await yl(X,{path:j,branchName:J,startPoint:K,limit:20,offset:0,allowAbsolute:!0}),ne=await tm(_);b(W),g(ne),s(ne.currentBranch??ne.createdBranch),M(""),P(""),Q(""),Y(!1),f(!1)}catch(_){E(_ instanceof Error?_.message:"Failed to create branch")}finally{A(!1)}}},[X,W,j,te,O,B,s,D]),R=N===W?w:null,V=o.useCallback(()=>{R?.hasMore&&T(R.branches.length,!0)},[R,T]),F=t.trim()||R?.currentBranch||(R&&!R.available?"No git repo":"Branch"),le=te?O.trim():D.trim(),ie=!!(R?.available&&B.trim()&&le&&!S),me=l==="composer"?e.jsxs(Z,{type:"button",variant:"ghost",onClick:()=>f(J=>!J),title:F,"aria-label":`Branch: ${F}`,className:L(c,u,"min-w-0 max-w-full",t.trim()?d:m),children:[k&&!R?e.jsx(fe,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(Gs,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:L("min-w-0 truncate",p),children:F})]}):e.jsxs(Z,{type:"button",variant:"outline",onClick:()=>f(J=>!J),className:"h-7 w-full justify-between rounded-sm border-border/70 bg-background/70 px-2.5 text-[11px] shadow-none",title:F,children:[e.jsx("span",{className:L("truncate",t.trim()?"font-mono text-foreground":"text-muted-foreground"),children:F}),e.jsx("span",{className:"ml-2 shrink-0 text-[10px] text-muted-foreground",children:$?$.name:"Manual"})]});return e.jsxs("div",{className:L("relative inline-block",l==="composer"?"min-w-0 shrink-0":"w-full"),ref:H,children:[l==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{className:"text-[10px] font-medium",children:"Branch"}),me]}):me,h&&e.jsxs("div",{className:L("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(Gs,{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:R?.repoRoot?`${R.currentBranch??F} · ${R.repoRoot}`:R?.currentBranch??F,children:R?.currentBranch??F}),k?e.jsx(fe,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground"}):null]}),$?k&&!R?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(fe,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):R&&!R.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(ct,{value:B,onChange:J=>M(J.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(Z,{type:"button",size:"sm",onClick:()=>{ee()},disabled:!ie,title:ie?"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:S?e.jsx(fe,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(jl,{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"}),!te&&e.jsxs("button",{type:"button",onClick:()=>Y(!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(Yt,{className:"h-2.5 w-2.5"}),"Manual"]})]}),te?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ct,{value:O,onChange:J=>Q(J.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:()=>{Y(!1),Q("")},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(dt,{className:"h-3.5 w-3.5"})})]}):R?.branches.length?e.jsxs("div",{className:"max-h-44 overflow-y-auto rounded-sm border border-border/40 bg-background/40",children:[R.branches.map(J=>{const K=D===J.ref,_=J.branch==="main"||J.branch==="master";return e.jsxs("button",{type:"button",onClick:()=>P(J.ref),className:L("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",K&&"bg-background/70"),title:J.ref,children:[e.jsx("span",{className:L("shrink-0 text-[10px]",_?"text-amber-500 dark:text-amber-400":"text-muted-foreground/60"),"aria-hidden":!0,children:_?"★":"·"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-foreground",children:J.ref}),K?e.jsx(Ts,{className:"h-3 w-3 shrink-0 text-primary"}):null]},J.ref)}),R.hasMore&&e.jsxs("button",{type:"button",onClick:V,disabled:x,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:[x?e.jsx(fe,{className:"h-3 w-3 animate-spin"}):e.jsx(Ws,{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})]})]})}function sm({images:t,removeImage:s}){return e.jsx("div",{className:"flex flex-wrap gap-3",children:t.map((n,r)=>e.jsxs("div",{className:"relative",children:[e.jsx(yr,{image:n,alt:n.filename??`attachment ${r+1}`,thumbnailClassName:"h-20 w-20 border border-border/70",imageClassName:"h-full w-full"}),e.jsx("button",{type:"button",onClick:()=>s(r),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 ${n.filename??`image ${r+1}`}`,children:e.jsx(dt,{className:"h-3.5 w-3.5"})})]},`${n.filename??"image"}-${r}`))})}const nm=20,rm=3,nr="meshy-working-dir-recents-by-node";function am(t){return t.startsWith("/")||t.startsWith("\\\\")||/^[A-Za-z]:[\\/]/.test(t)}function om(t){const s=t.trim();return s||"."}function rr(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===rm))break}return s}function im(t,s){const n=s.trim();return rr(n?[n,...t]:t)}function ti(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=rr(a);i.length>0&&(s[n]=i)}return s}function lm(t,s,n){if(!s)return t;const r=t[s]??[],a=im(r,n);if(a.length===0){if(!(s in t))return t;const{[s]:i,...l}=t;return l}return{...t,[s]:a}}function cm(t,s){return s?t[s]?.[0]??"":""}function si(t){if(!t||typeof window>"u")return"";try{const s=window.localStorage.getItem(nr);return s?cm(ti(JSON.parse(s)),t):""}catch{return""}}function dm(t,s,n){return t!=="auto"?s.find(r=>r.id===t)??null:n.length===1?n[0]??null:null}function um(t,s){const n=s.trim();return n?am(n)||!t?n:`${t.replace(/[/\\]+$/,"")}/${n}`:""}function mm(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 Ys({value:t,onChange:s,assignTo:n,nodes:r,assignableNodes:a,layout:i="default",chipClassName:l,chipActiveClassName:c,chipInactiveClassName:d,labelClassName:m,triggerClassName:p,popoverPlacement:u="bottom",popoverAlign:h="start"}){const[f,w]=o.useState(!1),[g,N]=o.useState(null),[b,k]=o.useState(!1),[y,x]=o.useState(!1),[v,S]=o.useState(null),[A,I]=o.useState(""),[E,B]=o.useState(!1),[M,D]=o.useState({}),P=o.useRef(null),O=o.useMemo(()=>dm(n,r,a),[n,r,a]),Q=O?.id,te=o.useMemo(()=>Q?M[Q]??[]:[],[M,Q]),Y=o.useMemo(()=>t.trim()?um(O?.workDir,t):"Use node default",[t,O?.workDir]);o.useEffect(()=>{if(!(typeof window>"u"))try{const F=window.localStorage.getItem(nr);if(!F)return;const le=JSON.parse(F);D(ti(le))}catch{}},[]);const H=o.useCallback(F=>{Q&&D(le=>{const ie=lm(le,Q,F);if(ie===le)return le;if(typeof window<"u")try{window.localStorage.setItem(nr,JSON.stringify(ie))}catch{}return ie})},[Q]),se=o.useCallback((F,le=!0)=>{const ie=F.trim();s(ie),le&&ie&&H(ie),w(!1)},[s,H]),$=o.useCallback(async(F,le=0,ie=!1)=>{if(Q){S(null),ie?x(!0):k(!0);try{const me=await vo(Q,{path:F,limit:nm,offset:le,directoriesOnly:!0,allowAbsolute:!0});N(J=>ie&&J?{...me,entries:[...J.entries,...me.entries]}:me)}catch(me){S(me instanceof Error?me.message:"Failed to browse directories"),ie||N(null)}finally{k(!1),x(!1)}}},[Q]),X=o.useRef(t);X.current=t;const j=o.useRef($);j.current=$,o.useEffect(()=>{if(!f)return;const F=X.current;I(F),B(!1),N(null),S(null),Q&&j.current(om(F))},[f,Q]),o.useEffect(()=>{if(!f)return;const F=ie=>{P.current&&(P.current.contains(ie.target)||w(!1))},le=ie=>{ie.key==="Escape"&&w(!1)};return document.addEventListener("mousedown",F),document.addEventListener("keydown",le),()=>{document.removeEventListener("mousedown",F),document.removeEventListener("keydown",le)}},[f]);const W=o.useCallback(F=>{$(F)},[$]),T=o.useCallback(()=>{g&&$(g.currentPath,g.entries.length,!0)},[g,$]),ee=i==="composer"?e.jsxs(Z,{type:"button",variant:"ghost",onClick:()=>w(F=>!F),title:Y,"aria-label":`Working directory: ${Y}`,className:L(l,p,"min-w-0 max-w-full",t.trim()?c:d),children:[e.jsx(Uo,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:L("min-w-0 truncate",m),children:Y})]}):e.jsxs(Z,{type:"button",variant:"outline",onClick:()=>w(F=>!F),className:"h-7 w-full justify-between rounded-sm border-border/70 bg-background/70 px-2.5 text-[11px] shadow-none",title:Y,children:[e.jsx("span",{className:L("truncate",t.trim()?"font-mono text-foreground":"text-muted-foreground"),children:Y}),e.jsx("span",{className:"ml-2 shrink-0 text-[10px] text-muted-foreground",children:O?O.name:"Manual"})]}),R=mm(g,O),V=!!g?.parentPath;return e.jsxs("div",{className:L("relative inline-block",i==="composer"?"min-w-0 max-w-[60%] shrink":"w-full"),"data-workdir-popover-placement":u,"data-workdir-popover-align":h,ref:P,children:[i==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{className:"text-[10px] font-medium",children:"Working directory"}),ee]}):ee,f&&e.jsxs("div",{className:L("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",u==="top"?"bottom-full mb-2":"top-full mt-2",i==="composer"?h==="end"?"right-0":"left-0":h==="end"?"right-0 w-auto min-w-[240px]":"left-0 right-0 w-auto min-w-[240px]"),children:[te.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(Ws,{className:"h-2.5 w-2.5"}),"Recent"]}),e.jsx("div",{className:"flex flex-col",children:te.map(F=>e.jsx("button",{type:"button",onClick:()=>se(F),className:"truncate rounded-sm px-1.5 py-0.5 text-left font-mono text-[11px] text-foreground hover:bg-background/60",title:F,children:F},F))})]}),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:()=>g?.parentPath&&W(g.parentPath),disabled:!V||b,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(Oo,{className:"h-3 w-3"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground",title:R,children:R}),g&&e.jsx("button",{type:"button",onClick:()=>se(g.isAbsolute?g.currentPath:g.currentPath==="."?"":g.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:[O?b?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(fe,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):g&&g.entries.length>0?e.jsxs(e.Fragment,{children:[g.entries.map(F=>e.jsxs("div",{className:"group flex items-stretch border-b border-border/30 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>se(F.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 ${F.path}`,children:[e.jsx(us,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-[11px] text-foreground",children:F.name})]}),e.jsx("button",{type:"button",onClick:()=>W(F.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 ${F.name}`,children:e.jsx(ut,{className:"h-3.5 w-3.5"})})]},F.path)),g.hasMore&&e.jsxs("button",{type:"button",onClick:T,disabled:y,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:[y?e.jsx(fe,{className:"h-3 w-3 animate-spin"}):e.jsx(Ws,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:v??"No subfolders."}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Select a node to browse."}),v&&g&&g.entries.length>0&&e.jsx("div",{className:"border-t border-border/60 px-3 py-1.5 text-[11px] text-destructive",children:v})]}),e.jsx("div",{className:"flex items-center gap-1 border-t border-border/60 bg-background/40 px-2.5 py-1.5",children:E?e.jsxs(e.Fragment,{children:[e.jsx(ct,{value:A,onChange:F=>I(F.target.value),onKeyDown:F=>{F.key==="Enter"&&A.trim()?(F.preventDefault(),se(A)):F.key==="Escape"&&(F.preventDefault(),B(!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:()=>se(A),disabled:!A.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(Ts,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{B(!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(dt,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>{I(t),B(!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(Yt,{className:"h-3 w-3"})]})})]})]})}function ni(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 Tr({isCurrent:t}){return t?e.jsx($d,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500 dark:text-emerald-400","aria-label":"current node"}):e.jsx(Od,{className:"h-3.5 w-3.5 shrink-0 text-sky-500 dark:text-sky-400","aria-label":"remote follower node"})}function ar(t,s){return t.map(n=>{const r=!!s&&n.id===s;return e.jsx(Oe,{value:n.id,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(Tr,{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 hm(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??As}}function fm(){return Cl.map(t=>e.jsx(Oe,{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 xm(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 la(t){if(!t.updatedAt)return 0;const s=Date.parse(t.updatedAt);return Number.isNaN(s)?0:s}function pm(t,s){return la(s)-la(t)||t.sessionId.localeCompare(s.sessionId)}function gm(t){const s=t.trim().replace(/[\\/]+$/,"");return s?s.split(/[\\/]+/).filter(Boolean).at(-1)??s:"Unknown project"}function bm(t){const s=new Map;for(const n of[...t].sort(pm)){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:gm(n),cwd:n,sessions:r}))}function vm(t,s){const n=new Set(t);return n.has(s)?n.delete(s):n.add(s),n}function wm({nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:r,onCreated:a,onCancel:i,className:l,footerClassName:c,submitLabel:d="Load session",cancelLabel:m="Cancel",autoFocus:p=!1}){const u=o.useMemo(()=>ni(t,{currentNodeRole:s,leaderNodeId:r}),[t,s,r]),h=o.useMemo(()=>n&&u.some(_=>_.id===n)?n:u[0]?.id??"",[u,n]),[f,w]=o.useState(""),[g,N]=o.useState("codex"),[b,k]=o.useState(""),[y,x]=o.useState(""),[v,S]=o.useState(""),[A,I]=o.useState(h),[E,B]=o.useState(As),[M,D]=o.useState(!1),[P,O]=o.useState([]),[Q,te]=o.useState(!1),[Y,H]=o.useState(null),se=o.useMemo(()=>P.find(_=>_.sessionId===b)??null,[P,b]);o.useEffect(()=>{A&&u.some(_=>_.id===A)||I(h)},[A,u,h]),o.useEffect(()=>{k(""),x(""),S("")},[g,A]),o.useEffect(()=>{let _=!1;return A?(te(!0),H(null),kl(A,{agent:g,limit:50}).then(ne=>{_||O(ne.sessions)}).catch(ne=>{_||(O([]),H(ne instanceof Error?ne.message:"Failed to load native sessions"))}).finally(()=>{_||te(!1)}),()=>{_=!0}):(O([]),H(null),te(!1),()=>{_=!0})},[g,A]),o.useEffect(()=>{se&&(x(se.sessionId),S(se.cwd))},[se]);const $=o.useCallback(async _=>{_.preventDefault();const ne=hm({title:f,defaultTitle:se?.summary,agent:g,sessionId:y,cwd:v,assignTo:A,priority:"normal",mode:E});if(ne){D(!0);try{const q=await Sl(ne);a(q)}catch(q){ce.error(q instanceof Error?q.message:"Failed to load native session")}finally{D(!1)}}},[f,se,g,y,v,A,E,a]),X=!!(y.trim()&&v.trim()&&A),[j,W]=o.useState(!1),[T,ee]=o.useState(""),[R,V]=o.useState(()=>new Set),F=u.find(_=>_.id===A)??null,le=!!(n&&F?.id===n),ie=o.useMemo(()=>{const _=T.trim().toLowerCase();return _?P.filter(ne=>ne.summary.toLowerCase().includes(_)||ne.sessionId.toLowerCase().includes(_)||ne.cwd.toLowerCase().includes(_)):P},[P,T]),me=o.useMemo(()=>bm(ie),[ie]),J=o.useCallback(_=>{V(ne=>vm(ne,_))},[]),K="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:$,className:L("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($e,{value:A,onValueChange:I,children:[e.jsx(qe,{className:L(K),"aria-label":"Node",children:F?e.jsxs(e.Fragment,{children:[e.jsx(Tr,{isCurrent:le}),e.jsx("span",{className:"max-w-[10rem] truncate",children:F.name})]}):e.jsx(Je,{placeholder:"Node"})}),e.jsx(He,{children:ar(u,n)})]}),e.jsxs($e,{value:g,onValueChange:_=>N(_),children:[e.jsxs(qe,{className:L(K),"aria-label":"Agent",children:[e.jsx(At,{agent:g}),e.jsx("span",{children:g})]}),e.jsx(He,{children:ed()})]}),e.jsxs("div",{className:"relative ml-auto min-w-0 flex-1 sm:max-w-56",children:[e.jsx(wo,{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(ct,{value:T,onChange:_=>ee(_.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(tt,{className:"text-[10px] font-medium uppercase tracking-[0.2em] text-muted-foreground",children:Q?"Loading...":`${ie.length} session${ie.length===1?"":"s"}`})}),e.jsxs("div",{className:"relative h-88 overflow-hidden rounded-sm",children:[Q&&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:[!A&&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."}),A&&!Q&&ie.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:P.length===0?"No recent sessions on this node. Use Manual session ID under More options.":"No sessions match your filter."}),me.map(_=>e.jsxs("section",{className:"space-y-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>J(_.cwd),"aria-expanded":!R.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(st,{className:L("h-3.5 w-3.5 shrink-0 transition-transform",R.has(_.cwd)&&"-rotate-90")}),e.jsx(tn,{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})]}),!R.has(_.cwd)&&_.sessions.map(ne=>{const q=ne.sessionId===b;return e.jsxs("button",{type:"button",onClick:()=>k(ne.sessionId),className:L("flex w-full flex-col gap-1 rounded-sm border px-2.5 py-2 text-left transition-colors duration-200",q?"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:L("h-2 w-2 shrink-0 rounded-full",q?"bg-primary":"bg-border")}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",children:ne.summary}),e.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.16em] text-muted-foreground",children:xm(ne.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:ne.sessionId.slice(0,12)}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),e.jsx("span",{className:"truncate font-mono",children:ne.cwd})]})]},ne.sessionId)})]},_.cwd))]})]}),Y&&e.jsx("p",{className:"px-1 pt-2 text-[11px] text-destructive",children:Y})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:()=>W(_=>!_),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(st,{className:L("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(tt,{htmlFor:"native-session-id",className:"text-[10px] font-medium text-muted-foreground",children:"Session ID"}),e.jsx(ct,{id:"native-session-id",type:"text",value:y,onChange:_=>{k(""),x(_.target.value)},placeholder:"ses_..., thread_..., or UUID",autoFocus:p,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(tt,{htmlFor:"native-session-title",className:"text-[10px] font-medium text-muted-foreground",children:"Task title"}),e.jsx(ct,{id:"native-session-title",type:"text",value:f,onChange:_=>w(_.target.value),placeholder:"Optional",className:"h-7 rounded-sm border-border/70 bg-background/70 text-[11px] shadow-none"})]})]}),e.jsx(Ys,{value:v,onChange:_=>{k(""),S(_)},assignTo:A,nodes:t,assignableNodes:u}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(tt,{className:"text-[10px] font-medium text-muted-foreground",children:"Mode"}),e.jsxs($e,{value:E,onValueChange:_=>B(_),children:[e.jsx(qe,{className:"h-7 rounded-sm border-border/70 bg-background/70 text-[11px] shadow-none",children:e.jsx(Je,{placeholder:"Select mode"})}),e.jsx(He,{children:fm()})]})]})]})]}),e.jsxs("div",{className:L("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",c),children:[i&&e.jsx(Z,{type:"button",variant:"ghost",onClick:i,className:"rounded-sm",children:m}),e.jsx(Z,{type:"submit",disabled:!X||M,className:"rounded-sm px-5",children:M?e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"h-4 w-4 animate-spin"})," Loading..."]}):d})]})]})}const bn="__agent-default__";function ri({agent:t,value:s,onChange:n,triggerClassName:r,contentClassName:a="max-h-80",chip:i=!1}){const l=Do(t,s);return o.useEffect(()=>{s&&!Io(t,s)&&n("")},[t,s,n]),e.jsxs($e,{value:s||bn,onValueChange:c=>n(c===bn?"":c),children:[e.jsx(qe,{"aria-label":`Model: ${l}`,title:`Model: ${l}`,className:r,children:i?e.jsxs(e.Fragment,{children:[e.jsx(zo,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:l})]}):e.jsx(Je,{placeholder:"Agent default"})}),e.jsxs(He,{className:a,children:[e.jsx(Oe,{value:bn,className:"py-1 text-[11px]",children:"Agent default"}),td(t)]})]})}function ym(t){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{className:"text-[11px] font-medium",children:"Model"}),e.jsx(ri,{...t,triggerClassName:"h-8 rounded-sm border-border/70 bg-background/70"})]})}function ai(t,s,n=!1){const r=t.trim();if(r)return r;const a=s.trim().split(`
|
|
204
|
+
`).map(i=>i.trim()).find(Boolean);return a?a.length>72?`${a.slice(0,69).trimEnd()}...`:a:n?"Image task":""}function jm(t){const s=t.title.trim(),n=Ro(t.agent,t.description),r=n.prompt,a=ai(t.title,r,t.images.length>0),i=r.trim()||a,l=t.mode??As,c=t.model?.trim(),d=c&&Io(t.agent,c)?c:"",m=n.isGoal?n.commandPrompt:r,p=Mo(m,t.images);return!a||!i||!t.agent?null:{title:a,description:i,agent:t.agent,project:t.project.trim()||null,branch:t.branch?.trim()||null,payload:{initialMessage:p,mode:l,...d?{model:d}:{},...n.isGoal?{goal:!0}:{},titleSource:s?"manual":"derived"},priority:t.priority,assignTo:t.assignTo==="auto"?void 0:t.assignTo}}function Nm({nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:r,initialAssignTo:a,initialProject:i,onCreated:l,onCancel:c,className:d,footerClassName:m,submitLabel:p="Create chat",cancelLabel:u="Cancel",autoFocus:h=!1,layout:f="default",defaultTaskAgent:w,quickChats:g=[]}){const[N,b]=o.useState(""),[k,y]=o.useState(""),[x,v]=o.useState(0),[S,A]=o.useState(()=>Bs(w)),I=o.useRef(!1),[E,B]=o.useState(""),[M,D]=o.useState(As),[P,O]=o.useState(i?.trim()??""),Q=o.useRef(i!==void 0),[te,Y]=o.useState(""),H=o.useMemo(()=>ni(t,{currentNodeRole:s,leaderNodeId:r}),[t,s,r]),se=o.useMemo(()=>a&&H.some(re=>re.id===a)?a:n&&H.some(re=>re.id===n)?n:H[0]?.id??"",[H,n,a]),[$,X]=o.useState(se),[j,W]=o.useState(!1),[T,ee]=o.useState(!1),{images:R,error:V,fileInputRef:F,pickImages:le,handleFileChange:ie,handlePaste:me,removeImage:J}=Yo(),K=o.useRef(null),_=o.useMemo(()=>H.find(re=>re.id===$)??null,[$,H]),ne=!!(n&&_?.id===n),q=kt(S),ae=sd(M),ye=o.useMemo(()=>Ro(S,k),[S,k]),xe=o.useMemo(()=>_o(S,k),[S,k]),Ze=ye.prompt,Ae=o.useMemo(()=>ye.isGoal||xe?[]:g,[ye.isGoal,xe,g]);o.useEffect(()=>{$&&H.some(re=>re.id===$)||X(se)},[$,H,se]),o.useEffect(()=>{I.current||A(Bs(w))},[w]);const ft=o.useCallback(re=>{I.current=!0,A(Bs(re))},[]);o.useEffect(()=>{if(Q.current){Q.current=!1;return}O(si($)),Y("")},[$]),o.useEffect(()=>{Y("")},[P]),o.useEffect(()=>{v(0)},[k,g,S]);const Re=o.useCallback(re=>{y(re.prompt)},[]),De=o.useCallback(()=>{y(xe?.value??"/goal "),v(0),!(typeof window>"u")&&window.setTimeout(()=>{const re=K.current;re?.focus();const Ne=re?.value.length??0;re?.setSelectionRange(Ne,Ne)},0)},[xe]),Ve=o.useCallback(async re=>{if(re.preventDefault(),xe){De();return}const Ne=Hs(k,Ae,x);if(Ne){Re(Ne);return}const Te=jm({title:N,description:k,agent:S,model:E,project:P,branch:te,priority:"normal",assignTo:$,mode:M,images:R});if(Te){W(!0);try{const ve=await Al(Te);l(ve)}catch(ve){ce.error(ve instanceof Error?ve.message:"Failed to create task")}finally{W(!1)}}},[N,k,S,E,P,te,$,M,R,l,Ae,x,Re,xe,De]),Ke=ai(N,Ze,R.length>0),je=!xe&&!!(Ke&&S&&$&&(Ze.trim()||R.length>0)),Be=o.useCallback(re=>{if(re.nativeEvent.isComposing)return;if(xe&&(re.key==="ArrowDown"||re.key==="ArrowUp")){re.preventDefault();return}const Ne=go(k,Ae);if(Ne.length>0&&(re.key==="ArrowDown"||re.key==="ArrowUp")){re.preventDefault(),v(Te=>bo(Te,Ne.length,re.key==="ArrowDown"?1:-1));return}if(re.key==="Enter"){if(xe&&!re.shiftKey){re.preventDefault(),De();return}const Te=Hs(k,Ae,x);if(Te&&!re.shiftKey){re.preventDefault(),Re(Te);return}}re.key==="Enter"&&(re.ctrlKey||re.metaKey)&&je&&!j&&(re.preventDefault(),re.currentTarget.form?.requestSubmit())},[De,Re,Ae,je,k,xe,x,j]),G=R.length>0?e.jsx(sm,{images:R,removeImage:J}):null,ge=e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{className:"text-[11px] font-medium",children:"Assign to"}),e.jsxs($e,{value:$,onValueChange:X,children:[e.jsx(qe,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Je,{placeholder:"Select node"})}),e.jsx(He,{children:ar(H,n)})]})]}),be=e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{className:"text-[11px] font-medium",children:"Agent"}),e.jsxs($e,{value:S,onValueChange:ft,children:[e.jsx(qe,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Je,{placeholder:"Select agent"})}),e.jsx(He,{children:Jr()})]})]}),et=e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{className:"text-[11px] font-medium",children:"Mode"}),e.jsxs($e,{value:M,onValueChange:re=>D(re),children:[e.jsx(qe,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Je,{placeholder:"Select mode"})}),e.jsx(He,{children:Zr()})]})]}),_e=e.jsx(Ys,{value:P,onChange:O,assignTo:$,nodes:t,assignableNodes:H}),nt=e.jsx(ia,{value:te,onChange:Y,project:P,assignTo:$,nodes:t,assignableNodes:H});return f==="composer"?e.jsxs("form",{onSubmit:Ve,className:L("space-y-4",d),children:[e.jsx("input",{ref:F,type:"file",accept:"image/*",multiple:!0,onChange:ie,className:"hidden"}),(()=>{const re="chat-composer__chip h-9 min-w-0 w-auto gap-1.5 rounded-sm px-3.5 text-xs shadow-none transition-colors [&>span]:min-w-0",Ne="border-transparent bg-transparent text-muted-foreground hover:bg-background/40 hover:text-foreground",Te="border-border/70 bg-background/55 text-foreground",ve=S===Bs(w),rt=M===As;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($e,{value:$,onValueChange:X,children:[e.jsx(qe,{className:L(re,Te,"chat-composer__node-trigger border-transparent bg-transparent hover:bg-background/40"),title:`Assigned node: ${_?.name??"unassigned"}`,"aria-label":`Assigned node: ${_?.name??"unassigned"}`,children:_?e.jsxs(e.Fragment,{children:[e.jsx(Tr,{isCurrent:ne}),e.jsx("span",{className:"min-w-0 truncate",children:_.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(Je,{placeholder:"Select node"})}),e.jsx(He,{children:ar(H,n)})]}),T?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ct,{id:"task-title-composer",type:"text",value:N,onChange:Pe=>b(Pe.target.value),onKeyDown:Pe=>{(Pe.key==="Enter"||Pe.key==="Escape")&&(Pe.preventDefault(),ee(!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(Z,{type:"button",variant:"ghost",size:"icon",onClick:()=>ee(!1),"aria-label":"Save title",className:"h-8 w-8 shrink-0 rounded-sm text-muted-foreground hover:text-foreground",children:e.jsx(Ts,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>ee(!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:Ke||"Title","aria-label":Ke?`Edit title: ${Ke}`:"Edit title",children:[e.jsx("span",{className:"chat-composer__title-text max-w-[220px] truncate",children:Ke||"Title"}),e.jsx(Yt,{className:"h-3 w-3 shrink-0"})]})]}),e.jsx("textarea",{id:"task-description",ref:K,value:k,onChange:Pe=>y(Pe.target.value),onKeyDown:Be,onPaste:me,placeholder:"Ask anything...",rows:4,autoFocus:h,"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(oa,{agent:S,query:k,onSelect:De}),e.jsx(Wn,{query:k,quickChats:Ae,selectedIndex:x,onActiveIndexChange:v,onSelect:Re}),e.jsxs("div",{className:"chat-composer__rail flex min-w-0 flex-nowrap items-center gap-2 px-3 pb-3",children:[e.jsx(Z,{type:"button",variant:"ghost",size:"icon",onClick:le,"aria-label":"Add images",className:"h-9 w-9 shrink-0 rounded-sm text-muted-foreground hover:text-foreground",children:e.jsx(tr,{className:"h-4 w-4"})}),e.jsx("span",{className:"mx-0.5 h-5 w-px bg-border/60","aria-hidden":!0}),e.jsxs($e,{value:S,onValueChange:ft,children:[e.jsxs(qe,{className:L(re,"chat-composer__icon-trigger",ve?Ne:Te),title:`Agent: ${q}`,"aria-label":`Agent: ${q}`,children:[e.jsx(At,{agent:S}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:q})]}),e.jsx(He,{children:Jr()})]}),e.jsx(ri,{agent:S,value:E,onChange:B,chip:!0,triggerClassName:L(re,"chat-composer__icon-trigger",E?Te:Ne),contentClassName:"max-h-80 shadow-none"}),e.jsxs($e,{value:M,onValueChange:Pe=>D(Pe),children:[e.jsxs(qe,{className:L(re,"chat-composer__icon-trigger",rt?Ne:Te),title:`Mode: ${ae}`,"aria-label":`Mode: ${ae}`,children:[e.jsx(lu,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:ae})]}),e.jsx(He,{children:Zr()})]}),e.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[c&&e.jsxs(Z,{type:"button",variant:"ghost",size:"sm",onClick:c,"aria-label":u,className:"chat-composer__cancel h-9 rounded-sm px-4 text-xs text-muted-foreground",children:[e.jsx(dt,{className:"chat-composer__cancel-icon h-4 w-4 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label",children:u})]}),e.jsxs(Z,{type:"submit",size:"icon",disabled:!je||j,className:"h-10 w-10 rounded-sm shadow-[0_8px_30px_-8px_hsl(var(--primary)/0.6)]",children:[j?e.jsx(fe,{className:"h-4 w-4 animate-spin"}):e.jsx(Go,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:j?"Creating chat":p})]})]})]})]}),e.jsx("div",{className:"chat-composer__location flex flex-wrap items-center gap-2 px-1",children:(()=>{const Pe="border-border/40 bg-muted/40 text-foreground/80 hover:bg-muted/60 hover:text-foreground";return e.jsxs(e.Fragment,{children:[e.jsx(Ys,{value:P,onChange:O,assignTo:$,nodes:t,assignableNodes:H,layout:"composer",chipClassName:re,chipActiveClassName:Pe,chipInactiveClassName:Pe,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"}),e.jsx(ia,{value:te,onChange:Y,project:P,assignTo:$,nodes:t,assignableNodes:H,layout:"composer",chipClassName:re,chipActiveClassName:Pe,chipInactiveClassName:Pe,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"})]})})()})]})})(),(G||V)&&e.jsxs("div",{className:"space-y-2 rounded-sm border border-border/60 bg-background/45 p-2.5",children:[G,V&&e.jsx("div",{className:"text-[11px] text-destructive",children:V}),!V&&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:Ve,className:L("space-y-4",d),children:[e.jsx("input",{ref:F,type:"file",accept:"image/*",multiple:!0,onChange:ie,className:"hidden"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{htmlFor:"task-description",className:"text-[11px] font-medium",children:"Opening prompt"}),e.jsx("textarea",{id:"task-description",ref:K,value:k,onChange:re=>y(re.target.value),onKeyDown:Be,onPaste:me,placeholder:"Describe what the agent should do. This becomes the first message in the chat.",rows:6,autoFocus:h,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(oa,{agent:S,query:k,onSelect:De}),e.jsx(Wn,{query:k,quickChats:Ae,selectedIndex:x,onActiveIndexChange:v,onSelect:Re}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(Z,{type:"button",variant:"outline",onClick:le,className:"rounded-sm",children:[e.jsx(tr,{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."})]}),G,V&&e.jsx("p",{className:"text-[11px] text-destructive",children:V})]}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1fr)_170px_190px_150px]",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{htmlFor:"task-title",className:"text-[11px] font-medium",children:"Chat title"}),e.jsx(ct,{id:"task-title",type:"text",value:N,onChange:re=>b(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:Ke?`Will appear as: ${Ke}`:"A title will be generated from the first line of the prompt."})]}),be,e.jsx(ym,{agent:S,value:E,onChange:B}),et]}),_e,nt,ge,e.jsxs("div",{className:L("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",m),children:[c&&e.jsx(Z,{type:"button",variant:"ghost",onClick:c,className:"rounded-sm",children:u}),e.jsx(Z,{type:"submit",disabled:!je||j,className:"rounded-sm px-5",children:j?"Creating...":p})]})]})}function km({nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:r,initialAssignTo:a,initialProject:i,onCreated:l,onCancel:c,defaultMode:d="chat",mode:m,onModeChange:p,layout:u="default",className:h,footerClassName:f,autoFocus:w=!1,quickChats:g=[],defaultTaskAgent:N}){const[b,k]=o.useState(d),y=m!==void 0,x=y?m:b,v=S=>{y||k(S),p?.(S)};return e.jsxs("div",{className:L("space-y-4",h),children:[!y&&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(Z,{type:"button",variant:x==="chat"?"default":"ghost",onClick:()=>v("chat"),className:"h-7 flex-1 rounded-sm shadow-none",children:[e.jsx(Tl,{className:"h-4 w-4"}),"New chat"]}),e.jsxs(Z,{type:"button",variant:x==="native"?"default":"ghost",onClick:()=>v("native"),className:"h-7 flex-1 rounded-sm shadow-none",children:[e.jsx(kr,{className:"h-4 w-4"}),"Load session"]})]}),x==="chat"?e.jsx(Nm,{nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:r,initialAssignTo:a,initialProject:i,onCreated:l,onCancel:c,footerClassName:f,submitLabel:u==="composer"?"Start chat":"Create chat",cancelLabel:"Cancel",autoFocus:w,layout:u,defaultTaskAgent:N,quickChats:g},`${a??""}:${i??""}`):e.jsx(wm,{nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:r,onCreated:l,onCancel:c,footerClassName:f,autoFocus:w})]})}function Sm({onClick:t,running:s}){return e.jsxs(Z,{size:"icon",onClick:t,"aria-label":s?"Open composer - task running":"Open composer",title:s?"Task running - open composer":"Open composer",className:L("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(Yt,{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 ca({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 Cm({hasVisibleTranscriptEvents:t,hasTranscriptProgress:s,inputCollapsed:n}){return{collapsedButtonRunning:s&&t&&n,showDockedProgress:s&&t&&!n,showInlineProgress:s&&!t}}const ls="72f988bf-86f1-41af-91ab-2d7cd011db47",oi=`${ls} (MSIT)`;function Tm({open:t,onOpenChange:s,onShare:n,onStopShare:r,sharing:a,stopping:i=!1,shareResult:l}){return e.jsx(mt,{open:t,onOpenChange:s,children:e.jsxs(ht,{className:"max-w-md rounded-sm p-4",children:[e.jsx(bt,{className:"sr-only",children:"Share conversation"}),e.jsx(Am,{onOpenChange:s,onShare:n,onStopShare:r,sharing:a,stopping:i,shareResult:l})]})})}function Am({onOpenChange:t,onShare:s,onStopShare:n,sharing:r,stopping:a=!1,shareResult:i}){const[l,c]=o.useState(i?.tenant??ls),[d,m]=o.useState(i?.scope??"chat"),p=i?.url?yo(i.url):null,u=r||a;return o.useEffect(()=>{c(i?.tenant??ls),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(Em,{value:l,onChange:c,disabled:u}),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(da,{active:d==="chat",title:"Chat only",description:"Conversation transcript and opening prompt.",onClick:()=>m("chat")}),e.jsx(da,{active:d==="filesPreview",title:"Chat, files and preview",description:"Transcript plus task output files and HTML preview.",onClick:()=>m("filesPreview")})]})]}),p&&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:p,className:"min-w-0 flex-1 bg-transparent font-mono text-xs text-foreground outline-none","aria-label":"Shared link"}),e.jsx(Z,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-sm text-muted-foreground",onClick:()=>{Ds(p,"Shared link copied")},"aria-label":"Copy shared link",title:"Copy shared link",children:e.jsx(jo,{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(Z,{variant:"outline",onClick:()=>t(!1),disabled:u,className:"h-8 text-xs",children:i?"Done":"Cancel"}),i&&n&&e.jsxs(Z,{variant:"outline",onClick:()=>{n()},disabled:u,className:"h-8 border-destructive/30 text-xs text-destructive hover:bg-destructive/10 hover:text-destructive",children:[a&&e.jsx(fe,{className:"h-3.5 w-3.5 animate-spin"}),"Stop share"]}),e.jsxs(Z,{onClick:()=>{s({tenant:l,scope:d})},disabled:u,className:"h-8 text-xs",children:[r&&e.jsx(fe,{className:"h-3.5 w-3.5 animate-spin"}),i?"Update link":"Share link"]})]})]})}function Em({value:t,onChange:s,disabled:n}){const[r,a]=o.useState(!1),[i,l]=o.useState(!1),[c,d]=o.useState(t),m=o.useRef(null);o.useEffect(()=>{d(t)},[t]),o.useEffect(()=>{if(!r)return;const u=f=>{const w=f.target;w instanceof Node&&(m.current?.contains(w)||(a(!1),l(!1)))},h=f=>{f.key==="Escape"&&(a(!1),l(!1))};return document.addEventListener("mousedown",u),document.addEventListener("keydown",h),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",h)}},[r]);const p=u=>{const h=u.trim();h&&(s(h),d(h),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(u=>!u),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:Mm(t)}),e.jsx(st,{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:()=>p(ls),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:oi}),t===ls&&e.jsx(Ts,{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:c,onChange:u=>d(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),p(c))},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:()=>p(c),className:"flex h-7 w-7 items-center justify-center rounded-sm hover:bg-background/60",children:e.jsx(Ts,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{d(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(dt,{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(Yt,{className:"h-3 w-3"})]})})]})]})]})}function Mm(t){return t===ls?oi:t}function da({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 Dm(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 _m({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(Vd,{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:[n.targetAgent&&e.jsxs("div",{"data-queued-message-target-agent":n.targetAgent,className:"mb-0.5 inline-flex h-5 max-w-[11rem] items-center gap-1 rounded-sm bg-primary/10 px-1.5 text-[10px] leading-3 text-primary",title:`Send to ${kt(n.targetAgent)}`,children:[e.jsx(Fo,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),e.jsx(At,{agent:n.targetAgent,className:"h-3 w-3 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:kt(n.targetAgent)})]}),e.jsx("div",{className:"break-words [overflow-wrap:anywhere]",children:Dm(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(yr,{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(Z,{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(dt,{className:"h-3 w-3"})})]},n.id)})})]})})}const Pm="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",Im=[{value:"transcript",label:"Transcript",icon:El},{value:"files",label:"Files",icon:us,activeIcon:tn},{value:"diff",label:"Diff",icon:Gs},{value:"preview",label:"Preview",icon:hd}];function Rm({activeTab:t}){return e.jsx(ur,{className:"h-auto max-w-full justify-start gap-2 overflow-x-auto rounded-sm !bg-muted/40 !p-0.5 !shadow-none",children:Im.map(s=>{const n=s.value===t&&s.activeIcon?s.activeIcon:s.icon;return e.jsx(zt,{value:s.value,title:s.label,"aria-label":s.label,className:Pm,children:e.jsx(n,{className:"h-3.5 w-3.5","aria-hidden":"true"})},s.value)})})}const ii="pointer-events-auto h-5 w-5 shrink-0 rounded-sm bg-muted/65 text-muted-foreground hover:bg-muted hover:text-foreground",Js="h-3.5 w-3.5";function or({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(li,{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(ci,{operationsOpen:r,onToggleOperations:a,className:"xl:hidden"})]})}function li({className:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,onToggleTasks:r}){const a=globalThis.window?.matchMedia("(min-width: 1024px)")?.matches?s:n;return e.jsx(Z,{variant:"ghost",size:"icon",onClick:r,title:a?"Hide tasks":"Show tasks","aria-label":a?"Hide tasks":"Show tasks",className:L(ii,t),children:a?e.jsx(Ks,{className:Js}):e.jsx(ut,{className:Js})})}function ci({className:t,operationsOpen:s,onToggleOperations:n}){return e.jsx(Z,{variant:"ghost",size:"icon",onClick:n,title:s?"Hide cluster":"Show cluster","aria-label":s?"Hide cluster":"Show cluster",className:L(ii,t),children:s?e.jsx(ut,{className:Js}):e.jsx(Ks,{className:Js})})}const ua="h-7 w-7 rounded-sm border-0 bg-primary/10 text-primary backdrop-blur hover:bg-primary/20 hover:text-primary";function Lm({active:t,onScrollToBottom:s,onScrollToTop:n}){return e.jsxs("div",{className:L("pointer-events-none absolute right-3 top-1/2 z-10 flex -translate-y-1/2 flex-col gap-2 opacity-0 transition-opacity duration-200 group-hover:pointer-events-auto group-hover:opacity-100",t&&"pointer-events-auto opacity-100"),children:[e.jsx(Z,{type:"button",variant:"ghost",size:"icon",className:ua,onClick:n,"aria-label":"Scroll to top",title:"Scroll to top",children:e.jsx(Ml,{className:"h-4 w-4"})}),e.jsx(Z,{type:"button",variant:"ghost",size:"icon",className:ua,onClick:s,"aria-label":"Scroll to bottom",title:"Scroll to bottom",children:e.jsx(st,{className:"h-4 w-4"})})]})}function Bm(t){if(t.type!=="agent.handoff")return null;const s=typeof t.fromAgent=="string"&&t.fromAgent.trim()?t.fromAgent.trim():"agent",n=typeof t.toAgent=="string"&&t.toAgent.trim()?t.toAgent.trim():"";return n?{fromAgent:s,toAgent:n}:null}function Om({fromAgent:t,toAgent:s}){return e.jsx("div",{className:"flex w-full justify-center py-0.5","data-agent-handoff":s,children:e.jsxs("div",{className:"inline-flex h-6 max-w-full items-center gap-1.5 rounded-sm border border-border/45 bg-muted/22 px-2 text-[10px] leading-3 text-muted-foreground/78",children:[e.jsx(At,{agent:t,className:"h-3 w-3 shrink-0 text-muted-foreground/65","aria-hidden":"true"}),e.jsxs("span",{className:"truncate",children:[kt(t)," to ",kt(s)]}),e.jsx(At,{agent:s,className:"h-3 w-3 shrink-0 text-primary/60","aria-hidden":"true"})]})})}const ma="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",Ft={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:`${ma} mt-0`,action:ma},Fm=30,zm=1600;function Um({savedScrollTop:t,scrollHeight:s,clientHeight:n}){const r=Math.max(0,s-n);return Math.min(Math.max(0,t??r),r)}function vn(t){return t.scrollHeight-t.scrollTop-t.clientHeight<Fm}function ha({explicitBottomStickUntil:t,now:s,wasAtBottom:n}){return n||t>s}function wn(t,s){return!!(s&&(t===s||t.contains(s)))}function yn(t){const s=t.ownerDocument.getSelection();if(!s||s.isCollapsed||s.rangeCount===0)return!1;if(wn(t,s.anchorNode)||wn(t,s.focusNode))return!0;for(let n=0;n<s.rangeCount;n+=1)if(wn(t,s.getRangeAt(n).commonAncestorContainer))return!0;return!1}function $m({atTop:t,inputCollapseDisabled:s,scrollingUp:n}){return!s&&(n||t)}function qm({activeTab:t,activeTaskId:s,contentVersion:n,inputCollapseDisabled:r=!1,setActiveTab:a,setInputCollapsed:i}){const l=o.useRef(null),c=o.useRef(s),d=o.useRef(!1),m=o.useRef(0),p=o.useRef(new Map),u=o.useRef(0),h=o.useRef(!0),f=o.useCallback((x=c.current)=>{const v=l.current;!v||!x||(p.current.set(x,v.scrollTop),m.current=v.scrollTop,h.current=vn(v))},[]),w=o.useCallback((x=c.current)=>{const v=l.current;!v||!x||(v.scrollTop=Um({savedScrollTop:p.current.get(x),scrollHeight:v.scrollHeight,clientHeight:v.clientHeight}),m.current=v.scrollTop,h.current=vn(v))},[]),g=o.useCallback((x,v=c.current)=>{x.scrollTop=x.scrollHeight,m.current=x.scrollTop,h.current=!0,v&&p.current.set(v,x.scrollTop)},[]),N=o.useCallback((x=c.current)=>{const v=l.current;u.current=Date.now()+zm,v&&(g(v,x),requestAnimationFrame(()=>{g(v,x),requestAnimationFrame(()=>g(v,x))}))},[g]),b=o.useCallback((x=c.current)=>{const v=l.current;u.current=0,v&&(v.scrollTop=0,m.current=0,h.current=!1,x&&p.current.set(x,0))},[]),k=o.useCallback(x=>{const v=x.currentTarget,S=m.current,A=v.scrollTop<S&&S-v.scrollTop>10,I=v.scrollTop<=0,E=yn(v);if(f(),E){u.current=0;return}if(!d.current){if(vn(v)){i(!1),d.current=!0,setTimeout(()=>{d.current=!1},300);return}(A||I)&&(u.current=0,$m({atTop:I,inputCollapseDisabled:r,scrollingUp:A})&&i(!0))}},[r,f,i]),y=o.useCallback(x=>{t==="transcript"&&f(),a(x),x==="transcript"&&requestAnimationFrame(()=>w())},[t,w,f,a]);return o.useLayoutEffect(()=>{r&&i(!1)},[r,i]),o.useLayoutEffect(()=>{const x=c.current;x&&x!==s&&f(x),c.current=s,t==="transcript"&&requestAnimationFrame(()=>w(s))},[s,t,w,f]),o.useLayoutEffect(()=>{const x=l.current;if(!x||t!=="transcript"||!s)return;const v=ha({explicitBottomStickUntil:u.current,now:Date.now(),wasAtBottom:h.current});if(yn(x)){u.current=0,f(s);return}v&&g(x,s),f(s)},[s,t,n,f,g]),o.useLayoutEffect(()=>{const x=l.current,v=x?.firstElementChild;if(!x||!v||t!=="transcript"||typeof ResizeObserver>"u")return;const S=new ResizeObserver(()=>{if(yn(x)){u.current=0,f();return}ha({explicitBottomStickUntil:u.current,now:Date.now(),wasAtBottom:h.current})?g(x):f()});return S.observe(x),S.observe(v),()=>S.disconnect()},[t,s,f,g]),{handleTranscriptScroll:k,handleTranscriptTabChange:y,scrollTranscriptToBottom:N,scrollTranscriptToTop:b,transcriptScrollRef:l}}function di(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 Hm="harness";function Vm(t){return typeof t=="object"&&t!==null}function Km(t){return typeof t=="string"&&t.trim().length>0?t.trim():""}function Gm(t){return Vm(t.agentSessions)?Object.keys(t.agentSessions).map(s=>s.trim()).filter(Boolean):[]}function ui(t){return Km(t.payload.activeAgent)||t.agent}function mi(t){return new Set([t.agent,ui(t),...Gm(t.payload)].filter(Boolean)).size>1}function hi(t){return mi(t)?Hm:t.agent}const Wm=o.lazy(async()=>({default:(await hr(()=>import("./FilesTab-tVrm_BOK.js"),__vite__mapDeps([0,1,2,3,4,5]))).FilesTab})),Qm=o.lazy(async()=>({default:(await hr(()=>import("./PreviewTab-kRFQ5bQf.js").then(s=>s.c),__vite__mapDeps([6,1,2]))).PreviewTab})),Ym=o.lazy(async()=>({default:(await hr(()=>import("./DiffTab-xXmdkadb.js"),__vite__mapDeps([7,1,2,5,4,3,6]))).DiffTab}));function Jm({onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:a,cluster:i,activeTab:l,setActiveTab:c,creatingTask:d,createMode:m,createDefaults:p,activeTask:u,assignedNode:h,taskLoading:f,transcriptLoading:w,taskError:g,displayEvents:N,initialPromptAlreadyInLogs:b,initialPrompt:k,supportsFollowUp:y,taskUnavailable:x,chatDisabled:v,chatDisabledReason:S,questionBypassEnabled:A,isRunning:I,isStarting:E,hasPendingFollowUp:B,canCancel:M,canRetry:D,onRetry:P,onCancel:O,onReloadNativeTranscript:Q,onShareTask:te,onStopShareTask:Y,onStartCreateTask:H,onCancelCreateTask:se,onCreateTask:$,onSendMessage:X,onCancelQueuedMessage:j,onQuestionBypassChange:W,onSubmitQuestionResponse:T,quickChats:ee=[]}){const[R,V]=o.useState(!1),[F,le]=o.useState(!1),[ie,me]=o.useState(!1),[J,K]=o.useState(!1),[_,ne]=o.useState(!1),[q,ae]=o.useState({}),[ye,xe]=o.useState(new Set),[Ze,Ae]=o.useState(new Set),[ft,Re]=o.useState(null),[De,Ve]=o.useState(null),Ke=u?.effectiveProjectPath??u?.project??"default workspace",je=u?h?.name??Qn(u.assignedTo,i?.nodes,u.assignedNodeName):"unassigned",Be=u?hi(u):"",G=u?ui(u):"",ge=u&&mi(u)?G:void 0,be=u?.assignedTo?e.jsxs(e.Fragment,{children:["Connecting session on node ",e.jsx("span",{className:"font-semibold",children:je}),"..."]}):"Connecting session to an available node...",et=u?[{label:"Working dir",value:Ke,mono:!0},...u.branch?[{label:"Branch",value:u.branch,mono:!0}]:[],{label:"Agent",value:Be,mono:!0},{label:"Node",value:je}]:[],_e=!!(k&&!b),nt=_e||N.length>0,re=I&&nt,Ne=(E||B||I)&&!re,Te=re?"The agent is still working on this conversation.":Ne?be:null,{collapsedButtonRunning:ve,showDockedProgress:rt,showInlineProgress:Pe}=Cm({hasTranscriptProgress:!!Te,hasVisibleTranscriptEvents:nt,inputCollapsed:R}),Dt=u?.conversationKind==="nativeSession",xt=nd(u),hs=w?"Loading transcript":Dt?"No transcript imported":"Transcript is warming up",Xt=w?"Loading transcript...":Dt?"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.",St=u?.queuedMessages??[],vt=o.useMemo(()=>rd(N),[N]),fs=o.useMemo(()=>{let he=u?.agent??"";return vt.map(ke=>{const Ge=Bm(ke.event);if(Ge)return he=Ge.toAgent,{...ke,agent:he,handoff:Ge};const Ue=typeof ke.event.agent=="string"&&ke.event.agent.trim()?ke.event.agent.trim():he;return{...ke,agent:Ue,handoff:null}})},[u?.agent,vt]),xs=o.useMemo(()=>{const he=u?.assignedTo?u.assignedTo===i?.self?.id?h?.supportedAgents??i.self.supportedAgents:h?.supportedAgents:i?.self?.supportedAgents;return Dl({nodeSupportedAgents:he,taskAgent:u?.agent,activeAgent:typeof u?.payload.activeAgent=="string"?u.payload.activeAgent:void 0})},[h?.supportedAgents,i?.self?.id,i?.self?.supportedAgents,u?.assignedTo,u?.agent,u?.payload.activeAgent]),_t=o.useMemo(()=>vt.findIndex(({event:he})=>Zm(he)),[vt]),Bt=o.useMemo(()=>ad("transcript",vt.map(he=>he.event)),[vt]),es=u&&!ye.has(u.id)?q[u.id]??u.activeShare??null:null,Ct=u?.id??null,ts=`${Ct??"none"}:${N.length}:${St.length}:${_e?1:0}:${w?1:0}:${Pe?1:0}`,{handleTranscriptScroll:Fe,handleTranscriptTabChange:at,scrollTranscriptToBottom:wt,scrollTranscriptToTop:Tt,transcriptScrollRef:U}=qm({activeTab:l,activeTaskId:Ct,contentVersion:ts,inputCollapseDisabled:!!Te,setActiveTab:c,setInputCollapsed:V}),{markScrollbarActive:ze,scrollbarActive:Ie}=di(),We=o.useCallback(he=>{ze(),Fe(he)},[Fe,ze]),Qe=o.useCallback(he=>{Re(ke=>({path:he,requestId:(ke?.requestId??0)+1})),at("files")},[at]),ss=o.useCallback(he=>{Ve(ke=>({path:he,requestId:(ke?.requestId??0)+1})),at("preview")},[at]),pe=o.useCallback((he,ke)=>{wt(),X(he,ke)},[X,wt]);return o.useEffect(()=>{Re(null),Ve(null)},[Ct]),d?e.jsx(Xm,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:a,cluster:i,defaultMode:m,createDefaults:p,onCancel:se,onCreated:$,quickChats:ee}):!u&&f?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(or,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:a})}),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(fe,{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(fe,{className:"h-3.5 w-3.5 animate-spin"}),"Fetching the selected chat thread..."]})]})]})})]}):u?e.jsxs(mr,{value:l,onValueChange:at,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(li,{desktopTasksOpen:s,mobileTasksPanelOpen:n,onToggleTasks:t,className:"lg:hidden"}),e.jsx(ci,{operationsOpen:r,onToggleOperations:a,className:"xl:hidden"})]}),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(ko,{status:u.status,isNative:Dt}),xt&&e.jsxs("span",{"data-task-goal-label":"true",title:"Codex goal",className:"inline-flex h-5 shrink-0 items-center gap-1 rounded-sm bg-primary/10 px-1.5 text-[9px] font-semibold uppercase tracking-[0.12em] text-primary",children:[e.jsx(Po,{className:"h-3 w-3","aria-hidden":"true"}),"Goal"]}),u.priority!=="normal"&&e.jsx(_l,{priority:u.priority})]}),g&&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:g}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 pl-5 sm:pl-6 lg:pl-0",children:[e.jsx(Rm,{activeTab:l}),x&&e.jsx(Le,{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:Pl(u.updatedAt)}),D&&e.jsxs(Z,{variant:"ghost",size:"sm",onClick:P,"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(tu,{className:"h-3.5 w-3.5"}),"Retry"]}),Dt&&Q&&e.jsx(Z,{variant:"ghost",size:"icon",onClick:Q,disabled:w,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(Ko,{className:L("h-3.5 w-3.5",w&&"animate-spin")})}),e.jsx(Z,{type:"button",variant:"ghost",size:"icon",disabled:x,title:x?"Unavailable tasks cannot be shared.":"Share conversation","aria-label":x?"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:()=>me(!0),children:e.jsx(Qs,{className:"h-3.5 w-3.5"})})]})]})]}),e.jsx(Nt,{value:"transcript",className:"mt-0 min-h-0 flex-1",children:e.jsxs("div",{className:"group 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:U,"data-transcript-scroll":"true",className:L("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",Ie&&"scrollbar-line-active"),onScroll:We,children:e.jsxs("div",{"data-transcript-scroll-content":"true",className:"mx-auto flex max-w-[72rem] flex-col gap-4",children:[_e&&k&&e.jsx(Xr,{event:k,agent:u.agent,sentAsGoal:xt,taskRootPath:u.effectiveProjectPath,onOpenFilePath:Qe,questionBypassEnabled:A,onQuestionBypassChange:W,onSubmitQuestionResponse:T,questionResponseDisabled:!y||v}),fs.map(({event:he,subItems:ke,agent:Ge,handoff:Ue},Ot)=>Ue?e.jsx(Om,{fromAgent:Ue.fromAgent,toAgent:Ue.toAgent},Bt[Ot]):e.jsx(Xr,{event:he,agent:Ge,subItems:ke,sentAsGoal:xt&&!_e&&Ot===_t,taskRootPath:u.effectiveProjectPath,onOpenFilePath:Qe,questionBypassEnabled:A,onQuestionBypassChange:W,onSubmitQuestionResponse:T,questionResponseDisabled:!y||v},Bt[Ot])),!nt&&!Ne&&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:hs}),e.jsx("div",{className:"mt-2 text-[11px] leading-6 text-muted-foreground",children:Xt})]}),(!y&&u.result||u.error)&&e.jsxs("div",{className:"space-y-3",children:[!y&&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&&!Ze.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:()=>Ae(he=>new Set(he).add(u.id)),className:"rounded p-0.5 hover:bg-destructive/20","aria-label":"Dismiss error",children:e.jsx(dt,{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})]})]}),Pe&&Te&&e.jsx(ca,{children:Te})]})})}),e.jsx(Lm,{active:Ie,onScrollToBottom:()=>wt(),onScrollToTop:()=>Tt()}),rt&&Te&&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(ca,{children:Te})})}),y?e.jsxs(e.Fragment,{children:[R&&e.jsx(Sm,{running:ve,onClick:()=>{V(!1),wt(),requestAnimationFrame(()=>document.querySelector('[data-chat-input-textarea="true"]')?.focus())}}),e.jsxs("div",{className:`shrink-0 ${R?"hidden":""}`,children:[e.jsx(_m,{messages:St,onCancelMessage:j}),e.jsx(Ku,{onSend:pe,disabled:v,disabledReason:S,contextItems:et,agent:u.agent,currentAgent:ge,taskId:u.id,availableAgents:xs,model:typeof u.payload.model=="string"?u.payload.model:null,placeholder:v?S:I?"Queue a message for the next turn...":"Continue the conversation...",running:I||E||B,onStop:M?()=>le(!0):void 0,quickChats:ee})]})]}):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(Nt,{value:"files",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx(xn,{label:"Loading files..."}),children:e.jsx(Wm,{taskId:u.id,requestedFilePath:ft?.path??null,requestedFileRequestId:ft?.requestId??0,onPreviewFile:ss})})}),e.jsx(Nt,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx(xn,{label:"Loading preview..."}),children:e.jsx(Qm,{taskId:u.id,requestedEntryPath:De?.path??null,requestedEntryRequestId:De?.requestId??0})})}),e.jsx(Nt,{value:"diff",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx(xn,{label:"Loading diff..."}),children:e.jsx(Ym,{taskId:u.id})})}),e.jsx(Ut,{open:F,onOpenChange:le,children:e.jsxs($t,{className:Ft.content,children:[e.jsxs(qt,{className:Ft.header,children:[e.jsx(Ht,{className:Ft.title,children:"Stop this task?"}),e.jsx(Vt,{className:Ft.description,children:"The task will stop and move to a cancelled state."})]}),e.jsxs(Kt,{className:Ft.footer,children:[e.jsx(Gt,{className:Ft.cancel,children:"Keep running"}),e.jsx(Wt,{className:Ft.action,onClick:O,children:"Stop task"})]})]})}),e.jsx(Tm,{open:ie,onOpenChange:me,sharing:J,stopping:_,shareResult:es,onShare:async he=>{if(!u)return null;K(!0);try{const ke=await te(he);return ke?.url&&(ae(Ge=>({...Ge,[u.id]:ke})),xe(Ge=>{const Ue=new Set(Ge);return Ue.delete(u.id),Ue})),ke}finally{K(!1)}},onStopShare:async()=>{if(!u)return!1;ne(!0);try{const he=await Y();return he!==!1&&(ae(ke=>{const Ge={...ke};return delete Ge[u.id],Ge}),xe(ke=>new Set(ke).add(u.id))),he}finally{ne(!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(or,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:a})}),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(No,{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(Z,{onClick:()=>H(),className:"mt-4 h-8 rounded-sm px-3",children:[e.jsx(Ps,{className:"h-3.5 w-3.5"}),"Start or load chat"]}),g&&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:g})]})})]})}function Zm(t){return t.type!=="user"||t.isMeta===!0||t.isSidechain===!0?!1:!!jr(t)?.some(n=>n.type==="text"||n.type==="image")}function Xm({onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:a,cluster:i,defaultMode:l,createDefaults:c,onCancel:d,onCreated:m,quickChats:p}){const[u,h]=o.useState(l??"chat");o.useEffect(()=>{l&&h(l)},[l]);const f=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:Ps},{value:"native",label:"Load session",icon:kr}].map(w=>{const g=w.icon,N=w.value===u;return e.jsxs("button",{type:"button",onClick:()=>h(w.value),"aria-pressed":N,className:L("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",N?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-background/80 hover:text-foreground"),children:[e.jsx(g,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:w.label})]},w.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(or,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:a,centerSlot:f})}),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(km,{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:h,onCreated:m,onCancel:d,autoFocus:!0,layout:"composer",defaultTaskAgent:i?.self.settingsSnapshot?.defaultTaskAgent,quickChats:p})})})]})}function eh({onAdded:t}){const[s,n]=o.useState(""),[r,a]=o.useState(!1),[i,l]=o.useState(null),c=o.useCallback(async d=>{if(d.preventDefault(),!!s.trim()){a(!0),l(null);try{await Il({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(ht,{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(Et,{className:"space-y-1 text-left",children:[e.jsx(bt,{className:"text-sm tracking-tight",children:"Join node"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Verify the remote leader's DevTunnel Node URL, sync this node's tasks to that leader, and join the cluster as a follower."})]})}),e.jsxs("form",{onSubmit:c,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(tt,{htmlFor:"leader-endpoint",children:"Leader Node URL"}),e.jsx(Le,{variant:"outline",className:"rounded-sm border-border/70 bg-background/60 text-[10px] uppercase tracking-[0.16em]",children:"DevTunnel only"})]}),e.jsx(ct,{id:"leader-endpoint",type:"url",value:s,onChange:d=>n(d.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(fr,{className:"border-t border-border/60 pt-3",children:e.jsx(Z,{type:"submit",disabled:!s.trim()||r,className:"rounded-sm",children:r?"Joining...":"Join node"})})]})]})})}function th({open:t,onOpenChange:s,onAdded:n}){return e.jsx(mt,{open:t,onOpenChange:s,children:e.jsx(eh,{onAdded:()=>{s(!1),n()}})})}const sh="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",nh="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",rh="h-2.5 w-2.5";function fi({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:L("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 ah({className:t,label:s,onToggle:n,side:r,visible:a}){const i=r==="left"?a?Ks:ut:a?ut:Ks;return e.jsx("button",{type:"button","aria-label":s,title:s,onClick:n,className:L(sh,t),children:e.jsx("span",{className:nh,"aria-hidden":"true",children:e.jsx(i,{className:rh,strokeWidth:2.1})})})}function fa({className:t,label:s,onToggle:n,panel:r,panelResize:a,screen:i,side:l,visible:c}){const d=i==="lg"?"lg:block":"xl:block",m=i==="lg"?"lg:flex":"xl:flex";return e.jsxs("div",{className:L("group absolute top-0 z-30 hidden h-full w-4",d,t),children:[r&&e.jsx(fi,{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(ah,{side:l,visible:c,label:s,onToggle:n,className:L(m,"left-1/2 -translate-x-1/2 group-hover:opacity-100")})]})}function oh({conversationPanel:t,desktopTasksOpen:s,mobileTaskSidebar:n,mobileTasksPanelOpen:r,mobileTasksPanelRef:a,operationsOpen:i,operationsPanelRef:l,operationsSidecar:c,panelResize:d,taskSidebar:m,terminalPanel:p,onCloseOperations:u,onCloseTaskList:h,onToggleOperations:f,onToggleTasks:w}){const g={"--dashboard-tasks-width":d.sizes.tasks,"--dashboard-operations-width":d.sizes.operations,"--dashboard-terminal-height":d.sizes.terminal};return e.jsxs("div",{className:"dashboard-workspace flex h-full min-h-0 flex-col overflow-hidden",style:g,children:[e.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[e.jsx(fa,{screen:"lg",side:"left",visible:s,label:s?"Hide tasks":"Show tasks",onToggle:w,panel:s?"tasks":void 0,panelResize:d,className:s?"left-[var(--dashboard-tasks-width)] -translate-x-1/2":"left-0"}),e.jsx("div",{className:L("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}),p&&e.jsxs("div",{className:"relative h-[var(--dashboard-terminal-height)] min-h-0 shrink-0",children:[e.jsx(fi,{panel:"terminal",orientation:"horizontal",label:"Resize terminal panel",panelResize:d,className:"-top-1 left-0 h-2 w-full cursor-row-resize"}),p]})]}),e.jsx(fa,{screen:"xl",side:"right",visible:i,label:i?"Hide cluster":"Show cluster",onToggle:f,panel:i?"operations":void 0,panelResize:d,className:i?"right-[var(--dashboard-operations-width)] translate-x-1/2":"right-0"}),e.jsx("div",{className:L("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&&c})]}),i&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close operations panel",onClick:u,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:c})]}),r&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close task list",onClick:h,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 ih=10,Qt="__all__";function it(t){return"session"in t}function xa(t,s){return s&&t.some(n=>n.id===s)?s:t[0]?.id??""}function jn(t){return t&&(si(t.id)||t.workDir)||""}function Fs(t,s,n){let r=!1;const a=t.map(i=>it(i)&&i.session.id===n.id?(r=!0,{...i,nodeName:s,session:n}):i);return ir(r?a:[...a,{id:`session-${n.id}`,nodeName:s,session:n}])}function xi(t,s){return t.filter(it).filter(n=>n.session.nodeId===s).sort((n,r)=>r.session.startedAt-n.session.startedAt)}function lh(t){const s=t.filter(it).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 ch(t,s){return!!(t&&s&&!t.contains(s))}function dh(t,s,n){if(n===Qt)return n;const r=xi(t,s);return r.some(a=>a.session.id===n)?n:r[0]?.session.id??Qt}function uh(t,s,n){return n===Qt?t.filter(r=>!it(r)||r.session.nodeId===s):t.filter(r=>it(r)&&r.session.nodeId===s&&r.session.id===n)}function ir(t){const s=t.map((r,a)=>({entry:r,index:a})).filter(({entry:r})=>it(r)&&r.session.status!=="running").sort((r,a)=>!it(r.entry)||!it(a.entry)?0:a.entry.session.startedAt-r.entry.session.startedAt||a.index-r.index),n=new Set(s.slice(0,ih).map(({entry:r})=>it(r)?r.session.id:""));return t.filter(r=>!it(r)||r.session.status==="running"||n.has(r.session.id))}function lr(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 mh(t){const s=t.session.command.length>48?`${t.session.command.slice(0,45)}...`:t.session.command;return`${t.nodeName} - ${lr(t.session)} - ${s}`}function pi(t,s=48){return t.length>s?`${t.slice(0,s-3)}...`:t}function hh(t,s){return s===Qt?"All sessions":t?pi(t.session.command,34):"Command session"}function pa(t){return t.status==="stopped"?"":t.stderr}function fh({nodes:t,defaultNodeId:s,onClose:n,initialHistory:r=[]}){const[a,i]=o.useState(()=>xa(t,s)),l=o.useMemo(()=>t.find(T=>T.id===a)??t[0]??null,[t,a]),[c,d]=o.useState(()=>jn(l)),[m,p]=o.useState(""),[u,h]=o.useState(()=>ir(r)),[f,w]=o.useState(Qt),[g,N]=o.useState(!1),[b,k]=o.useState(!1),[y,x]=o.useState(!1),[v,S]=o.useState(!1),[A,I]=o.useState(!1),E=o.useRef(null),B=o.useRef(null),M=o.useMemo(()=>t.find(T=>T.id===a)??t[0]??null,[t,a]),D=o.useMemo(()=>xi(u,M?.id??""),[u,M]),P=o.useMemo(()=>lh(D),[D]),O=o.useMemo(()=>D.find(T=>T.session.id===f),[f,D]),Q=o.useMemo(()=>uh(u,M?.id??"",f),[u,M,f]),te=o.useRef(M?.id??"");o.useEffect(()=>{a&&t.some(T=>T.id===a)||i(xa(t,s))},[s,t,a]),o.useEffect(()=>{const T=M?.id??"";te.current!==T&&(te.current=T,d(jn(M)))},[M]),o.useEffect(()=>{w(T=>dh(u,M?.id??"",g?T:""))},[u,M,g]),o.useEffect(()=>{E.current?.scrollTo({top:E.current.scrollHeight})},[u]),o.useEffect(()=>{let T=!1;async function ee(){const R=await Promise.allSettled(t.map(async V=>({node:V,response:await Ll(V.id)})));T||h(V=>R.reduce((F,le)=>le.status!=="fulfilled"?F:le.value.response.sessions.reduce((ie,me)=>Fs(ie,le.value.node.name,me),F),V))}return t.length>0&&ee(),()=>{T=!0}},[t]),o.useEffect(()=>{const T=u.filter(it).filter(R=>R.session.status==="running");if(T.length===0)return;const ee=window.setInterval(()=>{for(const R of T)Rl(R.session.nodeId,R.session.id).then(V=>h(F=>Fs(F,R.nodeName,V))).catch(()=>{})},1e3);return()=>window.clearInterval(ee)},[u]);const Y=o.useRef(null);async function H(T){if(T.preventDefault(),!M||!m.trim()||A)return;const ee=m.trim(),R=M.name;I(!0),p("");try{const V=await Ol(M.id,{command:ee,...c.trim()?{cwd:c.trim()}:{}});h(F=>Fs(F,R,V)),w(V.id),N(!0)}catch(V){h(F=>[...F,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,nodeName:R,command:ee,error:V instanceof Error?V.message:"Command failed"}])}finally{I(!1)}}async function se(T,ee){T.stopPropagation();const R=await Bl(ee.session.nodeId,ee.session.id);h(V=>Fs(V,ee.nodeName,R))}function $(T){w(T),N(!0),k(!1)}function X(T){b&&ch(B.current,T.target)&&k(!1)}function j(T,ee,R,V,F){return e.jsxs("div",{className:"border-t border-border/60 py-1",children:[e.jsxs("button",{type:"button",onClick:V,"aria-label":`Toggle ${T} sessions`,"aria-expanded":!R,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:T}),e.jsx(st,{className:L("h-3 w-3 transition-transform",R&&"-rotate-90")})]}),!R&&(ee.length>0?ee.map(W):e.jsx("div",{className:"node-terminal__control px-2 py-1 text-muted-foreground",children:F}))]})}function W(T){const ee=f===T.session.id,R=T.session.status==="running";return e.jsxs("div",{className:L("node-terminal__control group flex w-full items-center gap-2 px-2 py-1.5 text-left transition-colors hover:bg-muted/65",ee&&"bg-primary/10 text-primary"),children:[e.jsxs("button",{type:"button",onClick:()=>$(T.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:L("flex h-4 w-4 shrink-0 items-center justify-center",R?"text-primary":T.session.status==="exited"?"text-emerald-600 dark:text-emerald-300":"text-amber-600 dark:text-amber-300"),children:R?e.jsx(fe,{className:"h-3 w-3 animate-spin"}):T.session.status==="exited"?e.jsx(Yn,{className:"h-3 w-3"}):e.jsx(hn,{className:"h-3 w-3"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-foreground",children:pi(T.session.command,44)}),e.jsxs("span",{className:"node-terminal__small block truncate text-muted-foreground",children:[T.nodeName," · ",lr(T.session)]})]})]}),R&&e.jsx("button",{type:"button",onClick:V=>{se(V,T)},"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(sa,{className:"h-3 w-3"})})]},T.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:X,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(dt,{className:"h-3.5 w-3.5"})}):e.jsx(Ur,{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:B,className:"relative min-w-0",children:[e.jsxs("button",{type:"button","aria-label":"Command session","aria-expanded":b,title:O?mh(O):"All sessions",onClick:()=>k(T=>!T),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:hh(O,f)}),e.jsx(st,{className:L("h-3 w-3 shrink-0 text-muted-foreground transition-transform",b&&"rotate-180")})]}),e.jsx("div",{"aria-hidden":!b,className:L("absolute right-0 bottom-9 z-30 w-[19rem] overflow-hidden rounded-xl border border-border/70 bg-popover text-popover-foreground shadow-xl",!b&&"hidden"),children:e.jsxs("div",{className:"max-h-72 overflow-y-auto",children:[e.jsxs("button",{type:"button",onClick:()=>$(Qt),className:L("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",f===Qt&&"bg-primary/10 text-primary"),children:[e.jsx(Ur,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:"All sessions"})]}),j("Active",P.active,y,()=>x(T=>!T),"No active sessions"),j("Completed",P.completed,v,()=>S(T=>!T),"No completed sessions")]})})]}),e.jsx("select",{value:M?.id??"",onChange:T=>{i(T.target.value),N(!1),d(jn(t.find(ee=>ee.id===T.target.value)??null))},disabled:A||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(T=>e.jsx("option",{value:T.id,className:"bg-background text-foreground",children:T.name},T.id))}),e.jsx(Ys,{value:c,onChange:d,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:E,className:"node-terminal__body min-h-0 flex-1 overflow-y-auto bg-muted/22 px-3 py-2 font-mono cursor-text",onClick:()=>Y.current?.focus(),children:[Q.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:Q.map(T=>it(T)?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:[T.nodeName,"$"]}),e.jsx("span",{className:"break-all text-foreground",children:T.session.command}),e.jsxs("span",{className:L("inline-flex items-center gap-1",T.session.status==="running"||T.session.status==="exited"?"text-primary":"text-amber-600 dark:text-amber-300"),children:[T.session.status==="running"?e.jsx(fe,{className:"h-3 w-3 animate-spin"}):T.session.status==="exited"?e.jsx(Yn,{className:"h-3 w-3"}):e.jsx(hn,{className:"h-3 w-3"}),lr(T.session)]}),T.session.status==="running"&&e.jsx("button",{type:"button",onClick:ee=>{se(ee,T)},"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(sa,{className:"h-3 w-3"})})]}),T.session.stdout&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-foreground",children:T.session.stdout}),pa(T.session)&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:pa(T.session)}),(T.session.stdoutTruncated||T.session.stderrTruncated)&&e.jsx("div",{className:"text-muted-foreground",children:"Output truncated to the latest output."})]},T.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:[T.nodeName,"$"]}),e.jsx("span",{className:"break-all text-foreground",children:T.command}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive",children:[e.jsx(hn,{className:"h-3 w-3"}),"error"]})]}),e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:T.error})]},T.id))}),e.jsxs("form",{onSubmit:H,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:Y,value:m,onChange:T=>p(T.target.value),disabled:!M||A,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()||A,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:A?e.jsx(fe,{className:"h-3 w-3 animate-spin"}):e.jsx(en,{className:"h-3 w-3"})})]})]})]})})}var os={},Nn,ga;function xh(){return ga||(ga=1,Nn=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Nn}var kn={},Rt={},ba;function Jt(){if(ba)return Rt;ba=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 Rt.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},Rt.getSymbolTotalCodewords=function(r){return s[r]},Rt.getBCHDigit=function(n){let r=0;for(;n!==0;)r++,n>>>=1;return r},Rt.setToSJISFunction=function(r){if(typeof r!="function")throw new Error('"toSJISFunc" is not a valid function.');t=r},Rt.isKanjiModeEnabled=function(){return typeof t<"u"},Rt.toSJIS=function(r){return t(r)},Rt}var Sn={},va;function Ar(){return va||(va=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}}})(Sn)),Sn}var Cn,wa;function ph(){if(wa)return Cn;wa=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++}},Cn=t,Cn}var Tn,ya;function gh(){if(ya)return Tn;ya=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]},Tn=t,Tn}var An={},ja;function bh(){return ja||(ja=1,(function(t){const s=Jt().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,c=[i-7];for(let d=1;d<a-1;d++)c[d]=c[d-1]-l;return c.push(6),c.reverse()},t.getPositions=function(r){const a=[],i=t.getRowColCoords(r),l=i.length;for(let c=0;c<l;c++)for(let d=0;d<l;d++)c===0&&d===0||c===0&&d===l-1||c===l-1&&d===0||a.push([i[c],i[d]]);return a}})(An)),An}var En={},Na;function vh(){if(Na)return En;Na=1;const t=Jt().getSymbolSize,s=7;return En.getPositions=function(r){const a=t(r);return[[0,0],[a-s,0],[0,a-s]]},En}var Mn={},ka;function wh(){return ka||(ka=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,c=0,d=0,m=null,p=null;for(let u=0;u<i;u++){c=d=0,m=p=null;for(let h=0;h<i;h++){let f=a.get(u,h);f===m?c++:(c>=5&&(l+=s.N1+(c-5)),m=f,c=1),f=a.get(h,u),f===p?d++:(d>=5&&(l+=s.N1+(d-5)),p=f,d=1)}c>=5&&(l+=s.N1+(c-5)),d>=5&&(l+=s.N1+(d-5))}return l},t.getPenaltyN2=function(a){const i=a.size;let l=0;for(let c=0;c<i-1;c++)for(let d=0;d<i-1;d++){const m=a.get(c,d)+a.get(c,d+1)+a.get(c+1,d)+a.get(c+1,d+1);(m===4||m===0)&&l++}return l*s.N2},t.getPenaltyN3=function(a){const i=a.size;let l=0,c=0,d=0;for(let m=0;m<i;m++){c=d=0;for(let p=0;p<i;p++)c=c<<1&2047|a.get(m,p),p>=10&&(c===1488||c===93)&&l++,d=d<<1&2047|a.get(p,m),p>=10&&(d===1488||d===93)&&l++}return l*s.N3},t.getPenaltyN4=function(a){let i=0;const l=a.data.length;for(let d=0;d<l;d++)i+=a.data[d];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 c=0;c<l;c++)for(let d=0;d<l;d++)i.isReserved(d,c)||i.xor(d,c,n(a,d,c))},t.getBestMask=function(a,i){const l=Object.keys(t.Patterns).length;let c=0,d=1/0;for(let m=0;m<l;m++){i(m),t.applyMask(m,a);const p=t.getPenaltyN1(a)+t.getPenaltyN2(a)+t.getPenaltyN3(a)+t.getPenaltyN4(a);t.applyMask(m,a),p<d&&(d=p,c=m)}return c}})(Mn)),Mn}var zs={},Sa;function gi(){if(Sa)return zs;Sa=1;const t=Ar(),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 zs.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}},zs.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}},zs}var Dn={},js={},Ca;function yh(){if(Ca)return js;Ca=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]})(),js.log=function(r){if(r<1)throw new Error("log("+r+")");return s[r]},js.exp=function(r){return t[r]},js.mul=function(r,a){return r===0||a===0?0:t[s[r]+s[a]]},js}var Ta;function jh(){return Ta||(Ta=1,(function(t){const s=yh();t.mul=function(r,a){const i=new Uint8Array(r.length+a.length-1);for(let l=0;l<r.length;l++)for(let c=0;c<a.length;c++)i[l+c]^=s.mul(r[l],a[c]);return i},t.mod=function(r,a){let i=new Uint8Array(r);for(;i.length-a.length>=0;){const l=i[0];for(let d=0;d<a.length;d++)i[d]^=s.mul(a[d],l);let c=0;for(;c<i.length&&i[c]===0;)c++;i=i.slice(c)}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}})(Dn)),Dn}var _n,Aa;function Nh(){if(Aa)return _n;Aa=1;const t=jh();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 c=new Uint8Array(this.degree);return c.set(i,l),c}return i},_n=s,_n}var Pn={},In={},Rn={},Ea;function bi(){return Ea||(Ea=1,Rn.isValid=function(s){return!isNaN(s)&&s>=1&&s<=40}),Rn}var jt={},Ma;function vi(){if(Ma)return jt;Ma=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
|
|
205
|
+
]))+`;jt.KANJI=new RegExp(n,"g"),jt.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),jt.BYTE=new RegExp(r,"g"),jt.NUMERIC=new RegExp(t,"g"),jt.ALPHANUMERIC=new RegExp(s,"g");const a=new RegExp("^"+n+"$"),i=new RegExp("^"+t+"$"),l=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return jt.testKanji=function(d){return a.test(d)},jt.testNumeric=function(d){return i.test(d)},jt.testAlphanumeric=function(d){return l.test(d)},jt}var Da;function Zt(){return Da||(Da=1,(function(t){const s=bi(),n=vi();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}}})(In)),In}var _a;function kh(){return _a||(_a=1,(function(t){const s=Jt(),n=gi(),r=Ar(),a=Zt(),i=bi(),l=7973,c=s.getBCHDigit(l);function d(h,f,w){for(let g=1;g<=40;g++)if(f<=t.getCapacity(g,w,h))return g}function m(h,f){return a.getCharCountIndicator(h,f)+4}function p(h,f){let w=0;return h.forEach(function(g){const N=m(g.mode,f);w+=N+g.getBitsLength()}),w}function u(h,f){for(let w=1;w<=40;w++)if(p(h,w)<=t.getCapacity(w,f,a.MIXED))return w}t.from=function(f,w){return i.isValid(f)?parseInt(f,10):w},t.getCapacity=function(f,w,g){if(!i.isValid(f))throw new Error("Invalid QR Code version");typeof g>"u"&&(g=a.BYTE);const N=s.getSymbolTotalCodewords(f),b=n.getTotalCodewordsCount(f,w),k=(N-b)*8;if(g===a.MIXED)return k;const y=k-m(g,f);switch(g){case a.NUMERIC:return Math.floor(y/10*3);case a.ALPHANUMERIC:return Math.floor(y/11*2);case a.KANJI:return Math.floor(y/13);case a.BYTE:default:return Math.floor(y/8)}},t.getBestVersionForData=function(f,w){let g;const N=r.from(w,r.M);if(Array.isArray(f)){if(f.length>1)return u(f,N);if(f.length===0)return 1;g=f[0]}else g=f;return d(g.mode,g.getLength(),N)},t.getEncodedBits=function(f){if(!i.isValid(f)||f<7)throw new Error("Invalid QR Code version");let w=f<<12;for(;s.getBCHDigit(w)-c>=0;)w^=l<<s.getBCHDigit(w)-c;return f<<12|w}})(Pn)),Pn}var Ln={},Pa;function Sh(){if(Pa)return Ln;Pa=1;const t=Jt(),s=1335,n=21522,r=t.getBCHDigit(s);return Ln.getEncodedBits=function(i,l){const c=i.bit<<3|l;let d=c<<10;for(;t.getBCHDigit(d)-r>=0;)d^=s<<t.getBCHDigit(d)-r;return(c<<10|d)^n},Ln}var Bn={},On,Ia;function Ch(){if(Ia)return On;Ia=1;const t=Zt();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 c=this.data.length-a;c>0&&(i=this.data.substr(a),l=parseInt(i,10),r.put(l,c*3+1))},On=s,On}var Fn,Ra;function Th(){if(Ra)return Fn;Ra=1;const t=Zt(),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)},Fn=n,Fn}var zn,La;function Ah(){if(La)return zn;La=1;const t=Zt();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)},zn=s,zn}var Un,Ba;function Eh(){if(Ba)return Un;Ba=1;const t=Zt(),s=Jt();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]+`
|
|
206
|
+
Make sure your charset is UTF-8`);i=(i>>>8&255)*192+(i&255),r.put(i,13)}},Un=n,Un}var $n={exports:{}},Oa;function Mh(){return Oa||(Oa=1,(function(t){var s={single_source_shortest_paths:function(n,r,a){var i={},l={};l[r]=0;var c=s.PriorityQueue.make();c.push(r,0);for(var d,m,p,u,h,f,w,g,N;!c.empty();){d=c.pop(),m=d.value,u=d.cost,h=n[m]||{};for(p in h)h.hasOwnProperty(p)&&(f=h[p],w=u+f,g=l[p],N=typeof l[p]>"u",(N||g>w)&&(l[p]=w,c.push(p,w),i[p]=m))}if(typeof a<"u"&&typeof l[a]>"u"){var b=["Could not find a path from ",r," to ",a,"."].join("");throw new Error(b)}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})($n)),$n.exports}var Fa;function Dh(){return Fa||(Fa=1,(function(t){const s=Zt(),n=Ch(),r=Th(),a=Ah(),i=Eh(),l=vi(),c=Jt(),d=Mh();function m(b){return unescape(encodeURIComponent(b)).length}function p(b,k,y){const x=[];let v;for(;(v=b.exec(y))!==null;)x.push({data:v[0],index:v.index,mode:k,length:v[0].length});return x}function u(b){const k=p(l.NUMERIC,s.NUMERIC,b),y=p(l.ALPHANUMERIC,s.ALPHANUMERIC,b);let x,v;return c.isKanjiModeEnabled()?(x=p(l.BYTE,s.BYTE,b),v=p(l.KANJI,s.KANJI,b)):(x=p(l.BYTE_KANJI,s.BYTE,b),v=[]),k.concat(y,x,v).sort(function(A,I){return A.index-I.index}).map(function(A){return{data:A.data,mode:A.mode,length:A.length}})}function h(b,k){switch(k){case s.NUMERIC:return n.getBitsLength(b);case s.ALPHANUMERIC:return r.getBitsLength(b);case s.KANJI:return i.getBitsLength(b);case s.BYTE:return a.getBitsLength(b)}}function f(b){return b.reduce(function(k,y){const x=k.length-1>=0?k[k.length-1]:null;return x&&x.mode===y.mode?(k[k.length-1].data+=y.data,k):(k.push(y),k)},[])}function w(b){const k=[];for(let y=0;y<b.length;y++){const x=b[y];switch(x.mode){case s.NUMERIC:k.push([x,{data:x.data,mode:s.ALPHANUMERIC,length:x.length},{data:x.data,mode:s.BYTE,length:x.length}]);break;case s.ALPHANUMERIC:k.push([x,{data:x.data,mode:s.BYTE,length:x.length}]);break;case s.KANJI:k.push([x,{data:x.data,mode:s.BYTE,length:m(x.data)}]);break;case s.BYTE:k.push([{data:x.data,mode:s.BYTE,length:m(x.data)}])}}return k}function g(b,k){const y={},x={start:{}};let v=["start"];for(let S=0;S<b.length;S++){const A=b[S],I=[];for(let E=0;E<A.length;E++){const B=A[E],M=""+S+E;I.push(M),y[M]={node:B,lastCount:0},x[M]={};for(let D=0;D<v.length;D++){const P=v[D];y[P]&&y[P].node.mode===B.mode?(x[P][M]=h(y[P].lastCount+B.length,B.mode)-h(y[P].lastCount,B.mode),y[P].lastCount+=B.length):(y[P]&&(y[P].lastCount=B.length),x[P][M]=h(B.length,B.mode)+4+s.getCharCountIndicator(B.mode,k))}}v=I}for(let S=0;S<v.length;S++)x[v[S]].end=0;return{map:x,table:y}}function N(b,k){let y;const x=s.getBestModeForData(b);if(y=s.from(k,x),y!==s.BYTE&&y.bit<x.bit)throw new Error('"'+b+'" cannot be encoded with mode '+s.toString(y)+`.
|
|
207
|
+
Suggested mode is: `+s.toString(x));switch(y===s.KANJI&&!c.isKanjiModeEnabled()&&(y=s.BYTE),y){case s.NUMERIC:return new n(b);case s.ALPHANUMERIC:return new r(b);case s.KANJI:return new i(b);case s.BYTE:return new a(b)}}t.fromArray=function(k){return k.reduce(function(y,x){return typeof x=="string"?y.push(N(x,null)):x.data&&y.push(N(x.data,x.mode)),y},[])},t.fromString=function(k,y){const x=u(k,c.isKanjiModeEnabled()),v=w(x),S=g(v,y),A=d.find_path(S.map,"start","end"),I=[];for(let E=1;E<A.length-1;E++)I.push(S.table[A[E]].node);return t.fromArray(f(I))},t.rawSplit=function(k){return t.fromArray(u(k,c.isKanjiModeEnabled()))}})(Bn)),Bn}var za;function _h(){if(za)return kn;za=1;const t=Jt(),s=Ar(),n=ph(),r=gh(),a=bh(),i=vh(),l=wh(),c=gi(),d=Nh(),m=kh(),p=Sh(),u=Zt(),h=Dh();function f(S,A){const I=S.size,E=i.getPositions(A);for(let B=0;B<E.length;B++){const M=E[B][0],D=E[B][1];for(let P=-1;P<=7;P++)if(!(M+P<=-1||I<=M+P))for(let O=-1;O<=7;O++)D+O<=-1||I<=D+O||(P>=0&&P<=6&&(O===0||O===6)||O>=0&&O<=6&&(P===0||P===6)||P>=2&&P<=4&&O>=2&&O<=4?S.set(M+P,D+O,!0,!0):S.set(M+P,D+O,!1,!0))}}function w(S){const A=S.size;for(let I=8;I<A-8;I++){const E=I%2===0;S.set(I,6,E,!0),S.set(6,I,E,!0)}}function g(S,A){const I=a.getPositions(A);for(let E=0;E<I.length;E++){const B=I[E][0],M=I[E][1];for(let D=-2;D<=2;D++)for(let P=-2;P<=2;P++)D===-2||D===2||P===-2||P===2||D===0&&P===0?S.set(B+D,M+P,!0,!0):S.set(B+D,M+P,!1,!0)}}function N(S,A){const I=S.size,E=m.getEncodedBits(A);let B,M,D;for(let P=0;P<18;P++)B=Math.floor(P/3),M=P%3+I-8-3,D=(E>>P&1)===1,S.set(B,M,D,!0),S.set(M,B,D,!0)}function b(S,A,I){const E=S.size,B=p.getEncodedBits(A,I);let M,D;for(M=0;M<15;M++)D=(B>>M&1)===1,M<6?S.set(M,8,D,!0):M<8?S.set(M+1,8,D,!0):S.set(E-15+M,8,D,!0),M<8?S.set(8,E-M-1,D,!0):M<9?S.set(8,15-M-1+1,D,!0):S.set(8,15-M-1,D,!0);S.set(E-8,8,1,!0)}function k(S,A){const I=S.size;let E=-1,B=I-1,M=7,D=0;for(let P=I-1;P>0;P-=2)for(P===6&&P--;;){for(let O=0;O<2;O++)if(!S.isReserved(B,P-O)){let Q=!1;D<A.length&&(Q=(A[D]>>>M&1)===1),S.set(B,P-O,Q),M--,M===-1&&(D++,M=7)}if(B+=E,B<0||I<=B){B-=E,E=-E;break}}}function y(S,A,I){const E=new n;I.forEach(function(O){E.put(O.mode.bit,4),E.put(O.getLength(),u.getCharCountIndicator(O.mode,S)),O.write(E)});const B=t.getSymbolTotalCodewords(S),M=c.getTotalCodewordsCount(S,A),D=(B-M)*8;for(E.getLengthInBits()+4<=D&&E.put(0,4);E.getLengthInBits()%8!==0;)E.putBit(0);const P=(D-E.getLengthInBits())/8;for(let O=0;O<P;O++)E.put(O%2?17:236,8);return x(E,S,A)}function x(S,A,I){const E=t.getSymbolTotalCodewords(A),B=c.getTotalCodewordsCount(A,I),M=E-B,D=c.getBlocksCount(A,I),P=E%D,O=D-P,Q=Math.floor(E/D),te=Math.floor(M/D),Y=te+1,H=Q-te,se=new d(H);let $=0;const X=new Array(D),j=new Array(D);let W=0;const T=new Uint8Array(S.buffer);for(let le=0;le<D;le++){const ie=le<O?te:Y;X[le]=T.slice($,$+ie),j[le]=se.encode(X[le]),$+=ie,W=Math.max(W,ie)}const ee=new Uint8Array(E);let R=0,V,F;for(V=0;V<W;V++)for(F=0;F<D;F++)V<X[F].length&&(ee[R++]=X[F][V]);for(V=0;V<H;V++)for(F=0;F<D;F++)ee[R++]=j[F][V];return ee}function v(S,A,I,E){let B;if(Array.isArray(S))B=h.fromArray(S);else if(typeof S=="string"){let Q=A;if(!Q){const te=h.rawSplit(S);Q=m.getBestVersionForData(te,I)}B=h.fromString(S,Q||40)}else throw new Error("Invalid data");const M=m.getBestVersionForData(B,I);if(!M)throw new Error("The amount of data is too big to be stored in a QR Code");if(!A)A=M;else if(A<M)throw new Error(`
|
|
208
|
+
The chosen QR Code version cannot contain this amount of data.
|
|
209
|
+
Minimum version required to store current data is: `+M+`.
|
|
210
|
+
`);const D=y(A,I,B),P=t.getSymbolSize(A),O=new r(P);return f(O,A),w(O),g(O,A),b(O,I,0),A>=7&&N(O,A),k(O,D),isNaN(E)&&(E=l.getBestMask(O,b.bind(null,O,I))),l.applyMask(E,O),b(O,I,E),{modules:O,version:A,errorCorrectionLevel:I,maskPattern:E,segments:B}}return kn.create=function(A,I){if(typeof A>"u"||A==="")throw new Error("No input text");let E=s.M,B,M;return typeof I<"u"&&(E=s.from(I.errorCorrectionLevel,s.M),B=m.from(I.version),M=l.from(I.maskPattern),I.toSJISFunc&&t.setToSJISFunction(I.toSJISFunc)),v(A,B,E,M)},kn}var qn={},Hn={},Ua;function wi(){return Ua||(Ua=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,c=a.modules.data,d=t.getScale(l,i),m=Math.floor((l+i.margin*2)*d),p=i.margin*d,u=[i.color.light,i.color.dark];for(let h=0;h<m;h++)for(let f=0;f<m;f++){let w=(h*m+f)*4,g=i.color.light;if(h>=p&&f>=p&&h<m-p&&f<m-p){const N=Math.floor((h-p)/d),b=Math.floor((f-p)/d);g=u[c[N*l+b]?1:0]}r[w++]=g.r,r[w++]=g.g,r[w++]=g.b,r[w]=g.a}}})(Hn)),Hn}var $a;function Ph(){return $a||($a=1,(function(t){const s=wi();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,c){let d=c,m=l;typeof d>"u"&&(!l||!l.getContext)&&(d=l,l=void 0),l||(m=r()),d=s.getOptions(d);const p=s.getImageWidth(i.modules.size,d),u=m.getContext("2d"),h=u.createImageData(p,p);return s.qrToImageData(h.data,i,d),n(u,m,p),u.putImageData(h,0,0),m},t.renderToDataURL=function(i,l,c){let d=c;typeof d>"u"&&(!l||!l.getContext)&&(d=l,l=void 0),d||(d={});const m=t.render(i,l,d),p=d.type||"image/png",u=d.rendererOpts||{};return m.toDataURL(p,u.quality)}})(qn)),qn}var Vn={},qa;function Ih(){if(qa)return Vn;qa=1;const t=wi();function s(a,i){const l=a.a/255,c=i+'="'+a.hex+'"';return l<1?c+" "+i+'-opacity="'+l.toFixed(2).slice(1)+'"':c}function n(a,i,l){let c=a+i;return typeof l<"u"&&(c+=" "+l),c}function r(a,i,l){let c="",d=0,m=!1,p=0;for(let u=0;u<a.length;u++){const h=Math.floor(u%i),f=Math.floor(u/i);!h&&!m&&(m=!0),a[u]?(p++,u>0&&h>0&&a[u-1]||(c+=m?n("M",h+l,.5+f+l):n("m",d,0),d=0,m=!1),h+1<i&&a[u+1]||(c+=n("h",p),p=0)):d++}return c}return Vn.render=function(i,l,c){const d=t.getOptions(l),m=i.modules.size,p=i.modules.data,u=m+d.margin*2,h=d.color.light.a?"<path "+s(d.color.light,"fill")+' d="M0 0h'+u+"v"+u+'H0z"/>':"",f="<path "+s(d.color.dark,"stroke")+' d="'+r(p,m,d.margin)+'"/>',w='viewBox="0 0 '+u+" "+u+'"',N='<svg xmlns="http://www.w3.org/2000/svg" '+(d.width?'width="'+d.width+'" height="'+d.width+'" ':"")+w+' shape-rendering="crispEdges">'+h+f+`</svg>
|
|
211
|
+
`;return typeof c=="function"&&c(null,N),N},Vn}var Ha;function Rh(){if(Ha)return os;Ha=1;const t=xh(),s=_h(),n=Ph(),r=Ih();function a(i,l,c,d,m){const p=[].slice.call(arguments,1),u=p.length,h=typeof p[u-1]=="function";if(!h&&!t())throw new Error("Callback required as last argument");if(h){if(u<2)throw new Error("Too few arguments provided");u===2?(m=c,c=l,l=d=void 0):u===3&&(l.getContext&&typeof m>"u"?(m=d,d=void 0):(m=d,d=c,c=l,l=void 0))}else{if(u<1)throw new Error("Too few arguments provided");return u===1?(c=l,l=d=void 0):u===2&&!l.getContext&&(d=c,c=l,l=void 0),new Promise(function(f,w){try{const g=s.create(c,d);f(i(g,l,d))}catch(g){w(g)}})}try{const f=s.create(c,d);m(null,i(f,l,d))}catch(f){m(f)}}return os.create=s.create,os.toCanvas=a.bind(null,n.render),os.toDataURL=a.bind(null,n.renderToDataURL),os.toString=a.bind(null,function(i,l,c){return r.render(i,c)}),os}var Lh=Rh();function yi(t){return Lh.toDataURL(t,{errorCorrectionLevel:"M",margin:2,scale:8,color:{dark:"#111827ff",light:"#ffffffff"}})}function Bh({title:t,description:s,triggerLabel:n,qrValue:r,displayValue:a,hint:i,imageAlt:l,copyLabel:c,copiedMessage:d}){const[m,p]=o.useState(!1),[u,h]=o.useState(null),[f,w]=o.useState(null);return o.useEffect(()=>{if(!m)return;let g=!1;return h(null),w(null),yi(r).then(N=>{g||h(N)}).catch(()=>{g||w("QR code unavailable")}),()=>{g=!0}},[m,r]),e.jsxs(mt,{open:m,onOpenChange:p,children:[e.jsx(So,{asChild:!0,children:e.jsx(Z,{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":n,title:n,children:e.jsx(Ho,{className:"h-3 w-3"})})}),e.jsxs(ht,{className:"max-w-[20rem] gap-2 p-3",children:[e.jsxs(Et,{className:"space-y-1 text-left",children:[e.jsx(bt,{className:"text-[12px]",children:t}),e.jsx(Mt,{children:s})]}),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:u?e.jsx("img",{src:u,alt:l,className:"h-full w-full"}):f?e.jsx("span",{children:f}):e.jsx(fe,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),e.jsx("div",{className:"w-full rounded-sm bg-primary/10 px-2 py-1 text-center text-[10px] font-medium text-foreground",children:i}),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:a}),e.jsx(Z,{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:()=>{Ds(a,d)},children:c})]})]})]})}function Oh(t,s){const n=Date.parse(t)-s;if(!Number.isFinite(n)||n<=0)return"expired";const r=Math.ceil(n/1e3),a=Math.floor(r/60),i=r%60;return a>0?`${a}m ${i.toString().padStart(2,"0")}s`:`${r}s`}function Fh(t,s){return t?t.invitation.status==="active"&&Date.parse(t.invitation.expiresAt)<=s?"expired":t.invitation.status:"loading"}function zh(t){switch(t){case"active":return{label:"Active",tone:"bg-emerald-500/10 text-emerald-500",icon:ta};case"consumed":return{label:"Paired",tone:"bg-emerald-500/10 text-emerald-500",icon:Yn};case"expired":return{label:"Expired",tone:"bg-amber-500/10 text-amber-500",icon:gn};case"cancelled":return{label:"Cancelled",tone:"bg-destructive/10 text-destructive",icon:gn};case"error":return{label:"Unavailable",tone:"bg-destructive/10 text-destructive",icon:gn};default:return{label:"Loading",tone:"bg-muted text-muted-foreground",icon:ta}}}function Uh({nodeName:t,nodeEndpoint:s}){const[n,r]=o.useState(!1),[a,i]=o.useState(null),[l,c]=o.useState(null),[d,m]=o.useState(null),[p,u]=o.useState(!1),[h,f]=o.useState(()=>Date.now()),w=`Show ${t} mobile pairing QR code`,g=o.useMemo(()=>a?Fl(a.qr):null,[a]),N=d?"error":Fh(a,h),b=zh(N),k=b.icon,y=o.useCallback(async()=>{u(!0),m(null),c(null);try{const x=await zl();i(x),f(Date.now())}catch(x){i(null),m(x instanceof Error?x.message:"Mobile pairing QR unavailable")}finally{u(!1)}},[]);return o.useEffect(()=>{n&&y()},[n,y]),o.useEffect(()=>{if(!n)return;const x=window.setInterval(()=>f(Date.now()),1e3);return()=>window.clearInterval(x)},[n]),o.useEffect(()=>{if(!n||!a||N!=="active")return;let x=!1;const v=window.setInterval(()=>{Ul(a.invitation.pairingId).then(S=>{x||i(A=>A&&{...A,invitation:S.invitation})}).catch(()=>{x||m("Pairing status unavailable")})},2e3);return()=>{x=!0,window.clearInterval(v)}},[n,a?.invitation.pairingId,N]),o.useEffect(()=>{if(!n||!g)return;let x=!1;return c(null),yi(g).then(v=>{x||c(v)}).catch(()=>{x||m("QR code unavailable")}),()=>{x=!0}},[n,g]),e.jsxs(mt,{open:n,onOpenChange:r,children:[e.jsx(So,{asChild:!0,children:e.jsx(Z,{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":w,title:w,children:e.jsx(Ho,{className:"h-3 w-3"})})}),e.jsxs(ht,{className:"max-w-[20rem] gap-2 p-3",children:[e.jsxs(Et,{className:"space-y-1 text-left",children:[e.jsx(bt,{className:"text-[12px]",children:"Mobile pairing QR"}),e.jsx(Mt,{children:t})]}),e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsxs("div",{className:"relative flex h-52 w-52 items-center justify-center rounded-sm bg-white p-2 text-[10px] text-muted-foreground",children:[l?e.jsx("img",{src:l,alt:`${t} mobile pairing QR code`,className:"h-full w-full"}):d?e.jsx("span",{className:"px-3 text-center",children:d}):e.jsx(fe,{className:"h-5 w-5 animate-spin text-muted-foreground"}),l&&N!=="active"?e.jsxs("div",{className:"absolute inset-2 flex items-center justify-center rounded-sm bg-background/85 px-3 text-center text-[10px] font-medium text-foreground",children:[b.label,". Refresh to create a new QR."]}):null]}),e.jsxs("div",{className:"grid w-full grid-cols-[1fr_auto] items-center gap-2 rounded-sm bg-muted/45 px-2 py-1.5",children:[e.jsxs("div",{className:"min-w-0 space-y-0.5",children:[e.jsx("div",{className:"truncate font-mono text-[9px] leading-3 text-foreground",children:a?.invitation.apiBaseUrl??s}),e.jsx("div",{className:"text-[9px] leading-3 text-muted-foreground",children:a?`${a.invitation.usedCount}/${a.invitation.maxUses} used - ${Oh(a.invitation.expiresAt,h)}`:"Creating invitation"})]}),e.jsxs("div",{className:`flex h-5 items-center gap-1 rounded-sm px-1.5 text-[9px] font-medium ${b.tone}`,children:[e.jsx(k,{className:"h-3 w-3"}),b.label]})]}),e.jsx("div",{className:"w-full rounded-sm bg-primary/10 px-2 py-1 text-center text-[10px] font-medium text-foreground",children:"Scan with Meshy Mobile"}),e.jsxs("div",{className:"grid w-full grid-cols-2 gap-2",children:[e.jsx(Z,{type:"button",variant:"secondary",size:"sm",className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",onClick:()=>{Ds(a?.invitation.apiBaseUrl??s,"Node URL copied")},children:"Copy URL"}),e.jsxs(Z,{type:"button",variant:"secondary",size:"sm",className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",disabled:p,onClick:()=>{y()},children:[p?e.jsx(fe,{className:"mr-1 h-3 w-3 animate-spin"}):e.jsx(Co,{className:"mr-1 h-3 w-3"}),"Refresh"]})]})]})]})]})}function $h({nodeName:t,dashboardUrl:s}){const n=`Show ${t} dashboard QR code`;return e.jsx(Bh,{title:"Dashboard URL QR",description:t,triggerLabel:n,qrValue:s,displayValue:s,hint:"Scan with Edge to view the dashboard",imageAlt:`${t} dashboard URL QR code`,copyLabel:"Copy dashboard URL",copiedMessage:"Dashboard URL copied"})}function qh(t){return t?{left:t.left,top:t.top}:{left:0,top:0,visibility:"hidden"}}function Hh(t,s,n,r=1){const l=s.width||160,c=s.height||0,d=Number.isFinite(r)&&r>0?r:1,m=t.right-t.left<1,p=t.right+4,u=m?p+l<=n.width-8?p:Math.max(8,t.left-4-l):Math.max(8,Math.min(t.right-l,n.width-l-8)),h=t.bottom+4,f=(t.top??t.bottom)-c-4,w=h+c>n.height-8&&f>=8?f:h;return{left:Math.round(u/d),top:Math.round(w/d)}}function Vh(){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 Er="fixed z-[130] min-w-36 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";function Mr({contextOpen:t=!1,contextPosition:s=null,defaultOpen:n=!1,onContextOpenChange:r}){const[a,i]=o.useState(n),[l,c]=o.useState(null),d=o.useRef(null),m=o.useRef(null),p=a||t,u=o.useCallback(()=>{i(!1),r?.(!1)},[r]),h=o.useCallback(()=>{i(f=>(f||c(null),r?.(!1),!f))},[r]);return o.useLayoutEffect(()=>{if(!p){c(null);return}const f=()=>{const w=d.current;if(!w)return;const g=w.getBoundingClientRect(),N=t&&s?{left:s.left,right:s.left,top:s.top,bottom:s.top}:m.current?.getBoundingClientRect();N&&c(Hh({left:N.left,right:N.right,top:N.top,bottom:N.bottom},{width:g.width,height:g.height},{width:window.innerWidth,height:window.innerHeight},Vh()))};return f(),window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),()=>{window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!0)}},[t,s,p]),o.useEffect(()=>{if(!p)return;const f=g=>{const N=g.target;N instanceof Node&&!d.current?.contains(N)&&!m.current?.contains(N)&&u()},w=g=>{g.key==="Escape"&&u()};return document.addEventListener("mousedown",f),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",w)}},[p,u]),{open:p,menuRef:d,triggerRef:m,menuStyle:qh(l),closeMenu:u,toggleButton:h}}function Xe({ariaLabel:t,children:s,destructive:n,disabled:r,icon:a,onClick:i,pending:l,title:c}){return e.jsxs("button",{type:"button",role:"menuitem","aria-label":t,title:c,disabled:r||l,onClick:d=>{d.stopPropagation(),!r&&!l&&i()},className:L("flex w-full items-center gap-1.5 rounded-sm px-2 py-1 text-left text-[10px] font-medium text-foreground transition-colors hover:bg-muted/80 disabled:cursor-not-allowed disabled:opacity-60",n&&"text-destructive hover:bg-destructive/10"),children:[l?e.jsx(fe,{className:"h-3 w-3 animate-spin text-primary"}):a,e.jsx("span",{children:s})]})}function Ns({formatDateTime:t,name:s,status:n,statusVariant:r}){return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-sm border border-border/60 bg-background/70 px-2.5 py-1.5",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground",children:s}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:t(n?.checkedAt)})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[typeof n?.authenticated=="boolean"&&e.jsx(Le,{variant:n.authenticated?"default":"outline",className:"rounded-sm text-[10px] uppercase tracking-[0.14em]",children:n.authenticated?"auth ok":"auth required"}),e.jsx(Le,{variant:r(n?.status),className:"rounded-sm text-[10px] uppercase tracking-[0.14em]",children:n?.status??"unknown"})]})]})}function Ce({label:t,value:s,mono:n=!1}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-border/45 py-1 last:border-b-0 last:pb-0 first:pt-0",children:[e.jsx("span",{className:"shrink-0 text-[9px] uppercase tracking-[0.16em] text-muted-foreground/80",children:t}),e.jsx("span",{className:L("min-w-0 break-words text-right text-[11px] leading-4 text-foreground/90",n&&"break-all font-mono text-[10px]"),children:s})]})}function is({icon:t,title:s,description:n,children:r,className:a}){return e.jsxs("section",{className:L("rounded-sm border border-border/60 bg-background/70 shadow-none",a),children:[e.jsxs("header",{className:"border-b border-border/45 px-2.5 pb-1.5 pt-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-semibold text-foreground",children:[e.jsx("span",{className:"text-primary",children:t}),s]}),n&&e.jsx("p",{className:"mt-0.5 text-[9px] leading-3.5 text-muted-foreground",children:n})]}),e.jsx("div",{className:"px-2.5 py-1.5",children:r})]})}function Kh({nodeId:t,nodeName:s,node:n}){const r=$l(),a=r?.cluster??null,i=r?.systemInfo??null,c=a?.nodes.find(k=>k.id===t)??null??n??null,d=c?ql(c,i):null,m=!!(i&&c&&c.id===i.nodeId),p=m||!!c?.settingsSnapshot,u=c?.name??n?.name??s,h=c?.status,f=c?.role,w=c?.transportType??d?.transportType??"direct",g=c?.capabilities??[],N=c?.supportedAgents??[],b=d?.startupRequirements?.components??d?.components??{};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("section",{className:"relative rounded-sm border border-border/65 bg-background/75 p-2.5 shadow-none",children:[!m&&c?.settingsSnapshot&&e.jsxs(Le,{variant:"outline",className:"absolute right-2.5 top-2 rounded-sm border-border/70 bg-background/60 px-1.5 py-0 text-[9px] uppercase tracking-[0.14em] whitespace-nowrap",children:["Updated ",yt(c.settingsSnapshot.collectedAt)]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsxs("span",{className:"flex items-center gap-1.5 rounded-sm border border-border/70 bg-background/75 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:[h&&e.jsx(xr,{status:h}),e.jsx("span",{className:"font-medium text-foreground",children:u})]}),f&&e.jsx(pr,{role:f,size:"compact"}),e.jsx(Le,{variant:"outline",className:"rounded-sm border-border/70 bg-background/60 px-1.5 py-0 text-[9px] uppercase tracking-[0.14em]",children:w}),c&&e.jsx(Le,{variant:m?"default":"outline",className:"rounded-sm px-1.5 py-0 text-[9px] uppercase tracking-[0.14em]",children:m?"Live local session":"Leader-synced snapshot"}),d&&d.uptime>0&&e.jsxs(Le,{variant:"outline",className:"gap-1 rounded-sm border-border/70 bg-background/60 px-1.5 py-0 text-[9px] uppercase tracking-[0.14em]",children:[e.jsx(Vo,{className:"h-2.5 w-2.5"}),"Uptime ",Hl(d.uptime)]})]})]}),!p&&c&&e.jsx("div",{className:"rounded-sm border border-dashed border-border/65 bg-muted/20 px-2.5 py-1.5 text-[10px] leading-4 text-muted-foreground",children:"This node has not synced a runtime snapshot to the leader yet. Host, access, and startup details appear after the next keepalive."}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsx(is,{icon:e.jsx(Zs,{className:"h-3.5 w-3.5"}),title:"Identity",description:"Cluster role, endpoint, and node-scoped state.",className:"sm:col-span-2",children:e.jsxs("div",{className:"grid gap-x-4 sm:grid-cols-2",children:[e.jsx(Ce,{label:"Node ID",value:t,mono:!0}),e.jsx(Ce,{label:"Status",value:h??"Unavailable"}),e.jsx(Ce,{label:"Role",value:f??"Unavailable"}),e.jsx(Ce,{label:"Endpoint",value:c?.endpoint??"Unavailable",mono:!!c?.endpoint}),e.jsx(Ce,{label:"Joined",value:yt(c?.joinedAt)}),e.jsx(Ce,{label:"Heartbeat",value:yt(c?.lastHeartbeat)}),e.jsx(Ce,{label:"Capabilities",value:g.length>0?g.join(", "):"None"}),e.jsx(Ce,{label:"Agents",value:N.length>0?N.join(", "):"None"})]})}),e.jsxs(is,{icon:e.jsx(Cd,{className:"h-3.5 w-3.5"}),title:"OS info",description:"Host and resource details.",children:[e.jsx(Ce,{label:"Host",value:d?.os?.hostname??"Unavailable"}),e.jsx(Ce,{label:"Platform",value:d?.os?`${d.os.platform} ${d.os.release}`:"Unavailable"}),e.jsx(Ce,{label:"Arch",value:d?.os?.arch??"Unavailable"}),e.jsx(Ce,{label:"CPU",value:d?.os?.cpuModel??"Unavailable"}),e.jsx(Ce,{label:"Cores",value:d?.os?String(d.os.cpuCount):"Unavailable"}),e.jsx(Ce,{label:"Memory",value:d?.os?`${$r(d.os.freeMemoryBytes)} free / ${$r(d.os.totalMemoryBytes)} total`:"Unavailable"})]}),e.jsxs(is,{icon:e.jsx(Vl,{className:"h-3.5 w-3.5"}),title:"Access surface",description:"How this node is reachable.",children:[e.jsx(Ce,{label:"Transport",value:w}),e.jsx(Ce,{label:"Node URL",value:c?.endpoint??"Unavailable",mono:!!c?.endpoint}),e.jsx(Ce,{label:"Node tunnel",value:c?.devtunnelEndpoint??"Disabled",mono:!!c?.devtunnelEndpoint}),e.jsx(Ce,{label:"Dashboard URL",value:c?.dashboardOrigin??d?.localDashboardOrigin??"Unavailable",mono:!!(c?.dashboardOrigin||d?.localDashboardOrigin)}),e.jsx(Ce,{label:"Local dashboard",value:d?.localDashboardOrigin??"Unavailable",mono:!!d?.localDashboardOrigin})]}),e.jsxs(is,{icon:e.jsx(ou,{className:"h-3.5 w-3.5"}),title:"Auth",description:"Bearer-auth and trusted access posture.",children:[e.jsx(Ce,{label:"Enabled",value:d?.auth?d.auth.enabled?"Yes":"No":"Unavailable"}),e.jsx(Ce,{label:"Same tenant",value:d?.auth?d.auth.allowSameTenant?"Allowed":"Off":"Unavailable"}),e.jsx(Ce,{label:"Allowed users",value:d?.auth?.allowedUsers.length?d.auth.allowedUsers.join(", "):"None"})]}),e.jsxs(is,{icon:e.jsx(Uo,{className:"h-3.5 w-3.5"}),title:"Paths",description:"Workspace and runtime paths.",children:[e.jsx(Ce,{label:"Work dir",value:d?.runtime?.workDir??c?.workDir??"Unavailable",mono:!!(d?.runtime?.workDir??c?.workDir)}),e.jsx(Ce,{label:"Storage",value:d?.runtime?.storagePath??"Unavailable",mono:!!d?.runtime?.storagePath}),e.jsx(Ce,{label:"Process cwd",value:d?.runtime?.cwd??"Unavailable",mono:!!d?.runtime?.cwd}),e.jsx(Ce,{label:"Started",value:yt(d?.runtime?.startedAt)}),e.jsx(Ce,{label:"PID",value:d?.runtime?String(d.runtime.pid):"Unavailable",mono:!!d?.runtime})]}),e.jsxs(is,{icon:e.jsx(Kl,{className:"h-3.5 w-3.5"}),title:"Startup checks",description:"Dependency preflight from node startup.",className:"sm:col-span-2",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2 rounded-sm border border-border/55 bg-background/65 px-2.5 py-1.5",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] text-foreground",children:[e.jsx(No,{className:"h-3 w-3 text-primary"}),"Last checked"]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:yt(d?.startupRequirements?.lastCheckedAt)})]}),e.jsxs("div",{className:"grid gap-1.5 sm:grid-cols-2",children:[e.jsx(Ns,{formatDateTime:yt,name:"Azure CLI",status:b.az,statusVariant:ys}),e.jsx(Ns,{formatDateTime:yt,name:"DevTunnel",status:b.devtunnel,statusVariant:ys}),e.jsx(Ns,{formatDateTime:yt,name:"Claude Code",status:b.claude,statusVariant:ys}),e.jsx(Ns,{formatDateTime:yt,name:"Codex",status:b.codex,statusVariant:ys}),e.jsx(Ns,{formatDateTime:yt,name:"Copilot CLI",status:b.copilot,statusVariant:ys})]})]})]})]})}function Gh({nodeId:t,nodeName:s,node:n,open:r,onOpenChange:a}){return e.jsx(mt,{open:r,onOpenChange:a,children:e.jsxs(ht,{className:"max-h-[min(82vh,40rem)] max-w-[min(88vw,44rem)] gap-3 overflow-y-auto rounded-sm border-border/70 bg-background/96 p-4 backdrop-blur-xl",children:[e.jsxs(Et,{className:"space-y-1",children:[e.jsxs(bt,{className:"flex items-center gap-1.5 text-[13px]",children:[e.jsx(Zs,{className:"h-3.5 w-3.5 text-primary"}),"Node properties"]}),e.jsxs(Mt,{className:"truncate text-[10px] leading-4 text-muted-foreground",children:["Runtime environment, connectivity, and preflight details for ",n?.name??s,"."]})]}),e.jsx(Kh,{nodeId:t,nodeName:s,node:n})]})})}function Dr({nodeId:t,nodeName:s,node:n,contextOpen:r=!1,contextPosition:a=null,defaultOpen:i=!1,onContextOpenChange:l,onOpenSettings:c,onOpenServicePreview:d,onOpenCapabilities:m,onOpenDevBox:p,onStartDevBox:u,onToggleRemoteAccess:h,remoteAccessLabel:f,remoteAccessPending:w,remoteAccessDisabled:g,remoteAccessDisabledReason:N,showConfigureDevBox:b,showStartDevBox:k,startDevBoxPending:y,className:x}){const{open:v,menuRef:S,triggerRef:A,menuStyle:I,closeMenu:E,toggleButton:B}=Mr({contextOpen:r,contextPosition:a,defaultOpen:i,onContextOpenChange:l}),[M,D]=o.useState(!1),P=y?"Starting":"Start DevBox",O=f?.startsWith("Disable")?Gl:fu,Q=v?e.jsxs("div",{ref:S,"data-node-action-menu-portal":"true",role:"menu",style:I,onClick:te=>te.stopPropagation(),onPointerDown:te=>te.stopPropagation(),className:Er,children:[c&&e.jsx(Xe,{ariaLabel:`Open ${s} settings`,title:`Open ${s} settings`,icon:e.jsx(Wl,{className:"h-3 w-3 shrink-0 text-primary"}),onClick:()=>{E(),c(t)},children:"Settings"}),d&&e.jsx(Xe,{ariaLabel:`Preview service on ${s}`,title:`Preview service on ${s}`,icon:e.jsx($o,{className:"h-3 w-3 shrink-0 text-primary"}),onClick:()=>{E(),d(t)},children:"Preview service"}),m&&e.jsx(Xe,{ariaLabel:`Open ${s} capabilities`,title:`Open ${s} capabilities`,icon:e.jsx(_s,{className:"h-3 w-3 shrink-0 text-primary"}),onClick:()=>{E(),m(t)},children:"Capabilities"}),f&&h&&e.jsx(Xe,{ariaLabel:`${f} for ${s}`,title:N??`${f} for ${s}`,icon:e.jsx(O,{className:"h-3 w-3 shrink-0 text-primary"}),pending:w,disabled:g,onClick:()=>{E(),h()},children:f}),k&&u&&e.jsx(Xe,{ariaLabel:`${P} for ${s}`,title:`${P} for ${s}`,icon:e.jsx(en,{className:"h-3 w-3 shrink-0 text-primary"}),pending:y,onClick:()=>{E(),u(t)},children:P}),b&&p&&e.jsx(Xe,{ariaLabel:`Configure DevBox for ${s}`,title:`Configure DevBox for ${s}`,icon:e.jsx(Ql,{className:"h-3 w-3 shrink-0 text-primary"}),onClick:()=>{E(),p(t)},children:"Configure DevBox"}),e.jsx(Xe,{ariaLabel:`Properties for ${s}`,title:`Properties for ${s}`,icon:e.jsx(gr,{className:"h-3 w-3 shrink-0 text-primary"}),onClick:()=>{E(),D(!0)},children:"Properties"})]}):null;return e.jsxs("div",{"data-node-action-menu":"true",className:L("relative shrink-0",v&&"z-[120]",x),onClick:te=>te.stopPropagation(),onPointerDown:te=>te.stopPropagation(),children:[e.jsx(Z,{ref:A,type:"button",variant:"ghost",size:"icon","aria-label":`More actions for ${s}`,"aria-haspopup":"menu","aria-expanded":v,title:`More actions for ${s}`,onClick:te=>{te.stopPropagation(),B()},className:L("h-6 w-6 rounded-sm text-muted-foreground hover:bg-background/70 hover:text-foreground",v&&"bg-background/80 text-primary"),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})}),Q&&(typeof document>"u"?Q:Xs.createPortal(Q,document.body)),M&&e.jsx(Gh,{nodeId:t,nodeName:s,node:n,open:M,onOpenChange:D})]})}const Wh=new Set(["deallocated","hibernate","hibernated","sleep","sleeping","stopped"]),Qh=new Set(["startinprogress","starting"]);function cs(t){return!!(t?.enabled&&t.name)}function Yh(t){const s=t?.trim().toLowerCase().replace(/[\s_-]+/gu,"");return!!(s&&Wh.has(s))}function ds(t){const s=t?.trim().toLowerCase().replace(/[\s_-]+/gu,"");return!!(s&&Qh.has(s))}function sn(t,s,n){return t==="offline"&&Yh(s)&&cs(n)}function Va(t,s){return t==="offline"&&cs(s)}function Ka(t){return!cs(t)}function Jh({nodeStatus:t,status:s,current:n,selected:r}){const a=r??n;return a&&sn(t,s,a)?a:null}function Ye(t){return t.scope||`name:${t.name??""}`}function Zh({previousKey:t,baseDevBox:s,listed:n}){if(t&&n.some(i=>Ye(i)===t))return t;if(!cs(s))return n[0]?Ye(n[0]):"";const r=Ye(s),a=n.find(i=>Ye(i)===r)??n.find(i=>i.name===s.name);return a?Ye(a):r}function Xh(t){return t==="nodes"||t==="events"?t:"overview"}function ef({cluster:t,systemInfo:s,nodeNameById:n,nodeBlockingTaskCounts:r,eventTypeFilter:a,onEventTypeFilterChange:i,eventTypeOptions:l,filteredEvents:c,sseConnected:d,clusterLoading:m,clusterError:p,promotePending:u,onPromote:h,onAddNode:f,leavePending:w,onLeaveCluster:g,onToggleNodeDevTunnel:N,devTunnelNodeId:b,devBoxStartNodeId:k,devBoxStartingNodeIds:y=new Set,activeTab:x,onTabChange:v,onOpenNodeSettings:S,onOpenNodeCapabilities:A,onOpenDevBox:I,onStartDevBox:E}){const B=t?.self?.role==="leader",M=t?.self?.role==="follower"&&!t?.leader,D=t?.self??null,O=Yl(t?.nodes??[],D?.id).filter(R=>R.id!==D?.id),Q=t?.leader?t.nodes.find(R=>R.id===t.leader?.id)??null:null,te=t?.leader?t.leader.dashboardOrigin??Q?.dashboardOrigin??(s&&t.leader.id===(s.nodeId??s.id)?s.dashboardOrigin:void 0)??t.leader.endpoint:null,Y=t?.leader?Q?.devtunnelEndpoint??t.leader.endpoint:null,H=t?.leader?.name??Q?.name??"Leader",se=!!(t?.leader?.id&&t.leader.id===D?.id),$=D?.role==="leader"&&O.length===0,X=D?.role==="follower",[j,W]=o.useState("overview"),T=x??j;function ee(R){const V=Xh(R);W(V),v?.(V)}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(mr,{value:T,onValueChange:ee,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(ur,{className:"grid h-auto w-full grid-cols-3 rounded-sm bg-muted/55 p-0.5",children:[e.jsx(zt,{value:"overview",className:"rounded-sm px-2 py-0.5 text-[10px]",children:"Overview"}),e.jsx(zt,{value:"nodes",className:"rounded-sm px-2 py-0.5 text-[10px]",children:"Nodes"}),e.jsx(zt,{value:"events",className:"rounded-sm px-2 py-0.5 text-[10px]",children:"Live events"})]})}),e.jsx(Nt,{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:[D&&e.jsx(Ga,{node:D,systemInfo:s,blockingTaskCount:r.get(D.id)??0,devTunnelNodeId:b,onToggleNodeDevTunnel:N,showActions:!1,defaultExpanded:!1,onOpenDevBox:I,devBoxStartingNodeIds:y}),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(Le,{variant:"secondary",className:"rounded-sm border-0 bg-muted/60 px-1.5 py-0 text-[9px] leading-4 shadow-none",children:d?"Connected":"Reconnecting"})]}),m&&!t?e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground",children:[e.jsx(fe,{className:"h-4 w-4 animate-spin"}),"Loading cluster state..."]}):p&&!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:p}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsx(as,{label:"Term",value:String(t?.term??0)}),e.jsx(as,{label:"Nodes",value:String(t?.nodes.length??0)}),e.jsx(as,{label:"Pending",value:String(t?.taskSummary.pending??0)}),e.jsx(as,{label:"Running",value:String(t?.taskSummary.running??0)}),e.jsx(as,{label:"Completed",value:String(t?.taskSummary.completed??0)}),e.jsx(as,{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(lt,{label:"Leader",value:t?.leader?.name??"None"}),e.jsx(lt,{label:"Leader Dashboard URL",value:te??"Unavailable",mono:!0,action:te?e.jsx(Pr,{nodeName:H,dashboardUrl:te,copyLabel:"Copy leader dashboard URL",copiedMessage:"Leader Dashboard URL copied"}):void 0}),Y&&e.jsx(lt,{label:"Leader Node URL",value:Y,mono:!0,action:e.jsx(_r,{nodeName:H,nodeEndpoint:Y,copyLabel:"Copy leader node URL",copiedMessage:"Leader Node URL copied",showPairingQr:se})}),e.jsx(lt,{label:"Feed",value:d?"Receiving live updates":"Reconnecting to event stream"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:M&&e.jsxs(Z,{variant:"secondary",size:"sm",onClick:h,disabled:u,className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",children:[u&&e.jsx(fe,{className:"h-3.5 w-3.5 animate-spin"}),"Promote self"]})})]})]})]})})}),e.jsx(Nt,{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"}),$?e.jsxs(Z,{variant:"secondary",size:"sm",onClick:f,className:"h-6 border-0 bg-primary px-2 text-[10px] text-primary-foreground shadow-none hover:bg-primary/90",children:[e.jsx(mu,{className:"h-3 w-3"}),"Join node"]}):X?e.jsxs(Z,{variant:"secondary",size:"sm",onClick:g,disabled:w,className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",children:[w&&e.jsx(fe,{className:"h-3.5 w-3.5 animate-spin"}),"Leave cluster"]}):null]}),D&&e.jsx(Ga,{node:D,systemInfo:s,blockingTaskCount:r.get(D.id)??0,devTunnelNodeId:b,onToggleNodeDevTunnel:N,showActions:!0,defaultExpanded:!0,onOpenNodeSettings:B?S:void 0,onOpenNodeCapabilities:B?A:void 0,onOpenDevBox:B?I:void 0,onStartDevBox:B?E:void 0,devBoxStartNodeId:k,devBoxStartingNodeIds:y})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"text-[10px] font-medium text-foreground",children:["Peer nodes (",O.length,")"]}),O.length>0?e.jsx("div",{className:"space-y-1.5",children:O.map(R=>e.jsx(tf,{node:R,isLeader:!!B,blockingTaskCount:r.get(R.id)??0,devTunnelNodeId:b,onToggleNodeDevTunnel:N,onOpenNodeSettings:B?S:void 0,onOpenNodeCapabilities:B?A:void 0,onOpenDevBox:B?I:void 0,onStartDevBox:B?E:void 0,devBoxStartNodeId:k,devBoxStartingNodeIds:y},R.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(Nt,{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(Vo,{className:L("h-3.5 w-3.5",d?"text-emerald-500":"text-destructive")}),"Live events"]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsxs($e,{value:a,onValueChange:i,children:[e.jsx(qe,{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(Je,{placeholder:"Event type"})}),e.jsx(He,{className:"shadow-none",children:l.map(R=>e.jsx(Oe,{value:R,className:"py-1 pl-6 pr-1.5 text-[10px] leading-4",children:R==="all"?"All event types":R},R))})]}),e.jsx(Le,{variant:"secondary",className:"rounded-sm border-0 bg-muted/60 px-1.5 py-0 text-[9px] leading-4 shadow-none",children:d?"Connected":"Reconnecting"})]})]}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(Jl,{events:c,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 Ga({node:t,systemInfo:s,blockingTaskCount:n,devTunnelNodeId:r,onToggleNodeDevTunnel:a,showActions:i=!0,defaultExpanded:l=!1,onOpenNodeSettings:c,onOpenNodeCapabilities:d,onOpenDevBox:m,onStartDevBox:p,devBoxStartNodeId:u,devBoxStartingNodeIds:h}){const[f,w]=o.useState(l),g=s?.dashboardOrigin??t.dashboardOrigin,N=t.devtunnelEndpoint??t.endpoint,b=g??t.endpoint,k=s?.workDir??t.workDir,y=Qo(t,s?.transportType),x=Sr(t,s?.transportType),v=x&&ms(s?.transportType??t.transportType)?!0:Wo(t,s?.transportType),S=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:()=>w(A=>!A),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[f?e.jsx(st,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(ut,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx(xr,{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:b,target:"_blank",rel:"noreferrer",className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(br,{className:"h-3 w-3"})}),(c||d||i&&v)&&e.jsx(Dr,{nodeId:t.id,nodeName:t.name,node:t,onOpenSettings:c,onOpenCapabilities:d,onOpenDevBox:m,onStartDevBox:p,onToggleRemoteAccess:i&&v?()=>a(t):void 0,remoteAccessLabel:i&&v?x?"Disable Remote Access":"Enable Remote Access":void 0,remoteAccessPending:r===t.id,remoteAccessDisabled:S,remoteAccessDisabledReason:S?"Finish assigned or running tasks before changing remote access":void 0,showConfigureDevBox:t.devbox?.enabled,showStartDevBox:sn(t.status,t.devbox?.lastStatus,t.devbox)||ds(t.devbox?.lastStatus)||h.has(t.id),startDevBoxPending:u===t.id||ds(t.devbox?.lastStatus)||h.has(t.id)})]}),e.jsxs("button",{type:"button",onClick:()=>w(A=>!A),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(pr,{role:t.role,size:"compact"}),e.jsx(Le,{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-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(lt,{label:"Node ID",value:t.id,mono:!0}),g&&e.jsx(lt,{label:"Dashboard",value:g,mono:!0,action:e.jsx(Pr,{nodeName:t.name,dashboardUrl:g})}),e.jsx(lt,{label:"Node URL",value:N,mono:!0,action:e.jsx(_r,{nodeName:t.name,nodeEndpoint:N})}),k&&e.jsx(lt,{label:"Workspace",value:k,mono:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[e.jsx(Xn,{label:"Transport",value:y}),s&&e.jsx(Xn,{label:"Uptime",value:Zl(s.uptime),mono:!0})]}),i&&d&&e.jsxs(Z,{variant:"secondary",size:"sm",onClick:()=>d(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(_s,{className:"h-3 w-3"}),"Capabilities"]}),i&&v&&S&&e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function tf({node:t,isLeader:s,blockingTaskCount:n,devTunnelNodeId:r,onToggleNodeDevTunnel:a,onOpenNodeSettings:i,onOpenNodeCapabilities:l,onOpenDevBox:c,onStartDevBox:d,devBoxStartNodeId:m,devBoxStartingNodeIds:p}){const[u,h]=o.useState(!1),f=t.dashboardOrigin,w=t.devtunnelEndpoint??t.endpoint,g=f??t.endpoint,N=Qo(t),b=Sr(t),k=Wo(t),y=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:()=>h(x=>!x),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[u?e.jsx(st,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):e.jsx(ut,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx(xr,{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:g,target:"_blank",rel:"noreferrer",className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(br,{className:"h-3 w-3"})}),s&&(i||l||k)&&e.jsx(Dr,{nodeId:t.id,nodeName:t.name,node:t,onOpenSettings:i,onOpenCapabilities:l,onOpenDevBox:c,onStartDevBox:d,onToggleRemoteAccess:k?()=>a(t):void 0,remoteAccessLabel:k?b?"Disable Remote Access":"Enable Remote Access":void 0,remoteAccessPending:r===t.id,remoteAccessDisabled:y,remoteAccessDisabledReason:y?"Finish assigned or running tasks before changing remote access":void 0,showConfigureDevBox:t.devbox?.enabled,showStartDevBox:sn(t.status,t.devbox?.lastStatus,t.devbox)||ds(t.devbox?.lastStatus)||p.has(t.id),startDevBoxPending:m===t.id||ds(t.devbox?.lastStatus)||p.has(t.id)})]}),e.jsxs("button",{type:"button",onClick:()=>h(x=>!x),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(pr,{role:t.role,size:"compact"}),e.jsx(Le,{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})]})]}),u&&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(lt,{label:"Node ID",value:t.id,mono:!0}),f&&e.jsx(lt,{label:"Dashboard",value:f,mono:!0,action:e.jsx(Pr,{nodeName:t.name,dashboardUrl:f})}),e.jsx(lt,{label:"Node URL",value:w,mono:!0,action:e.jsx(_r,{nodeName:t.name,nodeEndpoint:w,showPairingQr:!1})}),t.workDir&&e.jsx(lt,{label:"Workspace",value:t.workDir,mono:!0}),e.jsx(Xn,{label:"Transport",value:N})]}),s&&l&&e.jsxs(Z,{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(_s,{className:"h-3 w-3"}),"Capabilities"]}),s&&k&&y&&e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function _r({nodeName:t,nodeEndpoint:s,copyLabel:n="Copy node URL",copiedMessage:r="Node URL copied",showPairingQr:a=!0}){return e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[a?e.jsx(Uh,{nodeName:t,nodeEndpoint:s}):null,e.jsx(ji,{label:n,onClick:()=>{Ds(s,r)}})]})}function Pr({nodeName:t,dashboardUrl:s,copyLabel:n="Copy dashboard URL",copiedMessage:r="Dashboard URL copied"}){return e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[e.jsx($h,{nodeName:t,dashboardUrl:s}),e.jsx(ji,{label:n,onClick:()=>{Ds(s,r)}})]})}function ji({label:t,onClick:s}){return e.jsx(Z,{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(jo,{className:"h-3 w-3"})})}function sf(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(c=>c.id===t.assignedTo):void 0;return t.assignedTo!==null&&(i?i.status==="offline":s?t.assignedNodeAvailable===!1||!s.nodes.some(c=>c.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..."}:Vs.has(t.status)||t.status==="archived"?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:Vs.has(t.status)?"Task has not started yet...":"Archived tasks are read-only."}:{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Continue the conversation..."}}const Ni=.5,ki=1.75,Wa=.1;function nf({node:t,open:s,onOpenChange:n}){const[r,a]=o.useState(Os),[i,l]=o.useState(null),[c,d]=o.useState(1),[m,p]=o.useState(!1),[u,h]=o.useState(null);o.useEffect(()=>{a(Os),l(null),d(1),p(!1),h(null)},[t?.id,s]);const f=o.useCallback(async y=>{if(!t)return;const x=y??Number.parseInt(r.trim()||Os,10);if(!Number.isInteger(x)||x<1||x>65535){h("Enter a port between 1 and 65535");return}p(!0),h(null);try{const v=await Xl(t.id,{port:x});l(v),a(String(x)),qr("preview.created",{result:"success",previewType:"service-port"})}catch(v){h(v instanceof Error?v.message:"Failed to create service preview"),qr("preview.failed",{result:"failed",previewType:"service-port"})}finally{p(!1)}},[t,r]),w=o.useCallback(()=>{typeof i?.port=="number"&&f(i.port)},[i?.port,f]);o.useEffect(()=>{if(!i)return;const y=i.expiresAt-Date.now()-5e3;if(y<=0){w();return}const x=window.setTimeout(w,y);return()=>window.clearTimeout(x)},[w,i]);const g=i?xd(i):null,N=t?.name??"Node",b=rf(c),k={width:`${100/c}%`,height:`${100/c}%`,transform:`scale(${c})`,transformOrigin:"top left"};return e.jsx(mt,{open:s,onOpenChange:n,children:e.jsxs(ht,{onOpenAutoFocus:y=>y.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(bt,{className:"flex min-w-0 items-center gap-1.5 text-[12px] font-semibold text-foreground",children:[e.jsx($o,{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:N})]}),e.jsx(Mt,{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:y=>{y.preventDefault(),f()},children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:["Port",e.jsx(ct,{type:"text",min:1,max:65535,inputMode:"numeric",value:r,onChange:y=>a(y.target.value),placeholder:Os,"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(Z,{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(fe,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(en,{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:af(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(Z,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-none",onClick:()=>d(y=>Qa(y,-Wa)),disabled:c<=Ni,title:"Zoom out","aria-label":"Zoom out preview",children:e.jsx(bu,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>d(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:b}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-none",onClick:()=>d(y=>Qa(y,Wa)),disabled:c>=ki,title:"Zoom in","aria-label":"Zoom in preview",children:e.jsx(pu,{className:"h-3.5 w-3.5"})})]}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-sm",onClick:w,title:"Refresh",children:e.jsx(Co,{className:"h-3.5 w-3.5"})}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-sm",asChild:!0,title:"Open in new tab",children:e.jsx("a",{href:g??i.previewUrl,target:"_blank",rel:"noopener noreferrer",children:e.jsx(br,{className:"h-3.5 w-3.5"})})})]})]})]}),u&&e.jsx("div",{className:"shrink-0 border-b border-destructive/20 bg-destructive/5 px-3 py-1.5 text-[11px] text-destructive",children:u}),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:gd(i),style:k,className:"h-full w-full border-0",sandbox:pd(i),title:`${N} 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 Qa(t,s){return Si(Math.round((t+s)*100)/100)}function Si(t){return Number.isFinite(t)?Math.min(ki,Math.max(Ni,t)):1}function rf(t){return`${Math.round(Si(t)*100)}%`}function af(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`}const of=new Set(["completed","failed","cancelled","archived"]);function lf(t){return typeof t=="object"&&t!==null}function Ci(t){return typeof t=="string"&&t.trim().length>0?t.trim():""}function cr(t){return typeof t!="number"||!Number.isFinite(t)?"Unavailable":new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(t))}function cf(t){return t==="nativeSession"?"Native session":"Meshy chat"}function df(t){return t.effectiveProjectPath??t.project??"default workspace"}function uf(t){return lf(t.agentSessions)?Object.keys(t.agentSessions).map(s=>s.trim()).filter(Boolean):[]}function mf(t){const s=new Set;t.agent&&s.add(t.agent);const n=Ci(t.payload.activeAgent);n&&s.add(n);for(const r of uf(t.payload))s.add(r);return Array.from(s).join(", ")||"None"}function hf(t){return t.status!=="running"?"None":Ci(t.payload.activeAgent)||t.agent||"None"}function ff(t){return t.assignedNodeName??t.assignedTo??"Unassigned"}function xf(t){const s=t.reduce((n,r)=>Math.max(n,r.updatedAt),0);return s>0?cr(s):"No task activity"}function ks(t,s){return t.filter(n=>s.has(n.status)).length}function Ti({rows:t}){return e.jsx("div",{className:"overflow-hidden rounded-sm border border-border/55 bg-background/35",children:t.map(s=>e.jsxs("div",{className:"grid grid-cols-[5.75rem_minmax(0,1fr)] gap-2 border-b border-border/45 px-2 py-1.5 last:border-b-0",children:[e.jsx("div",{className:"min-w-0 break-words text-[9px] font-semibold uppercase tracking-[0.12em] text-muted-foreground/70",children:s.label}),e.jsx("div",{className:s.mono?"min-w-0 break-all font-mono text-[10px] leading-4 text-foreground/85":"min-w-0 break-words text-[10px] leading-4 text-foreground/85",children:s.value})]},s.label))})}function pf({task:t}){const s=of.has(t.status),n=[{label:"Status",value:t.status},{label:"Kind",value:cf(t.conversationKind)},{label:"Priority",value:t.priority},{label:"Created",value:cr(t.createdAt)},{label:s?"Finished":"Updated",value:cr(t.updatedAt)}];return n.push({label:"Assigned node",value:ff(t)},{label:"Workspace",value:df(t),mono:!0}),t.branch&&n.push({label:"Branch",value:t.branch,mono:!0}),n.push({label:"Task agents",value:mf(t)},{label:"Running agents",value:hf(t)},{label:"Retries",value:`${t.retryCount}/${t.maxRetries}`},{label:"Created by",value:t.createdBy},{label:"Task ID",value:t.id,mono:!0}),e.jsx(Ti,{rows:n})}function gf({dirPath:t,nodeId:s,nodeName:n,nodeStatus:r,tasks:a,unloadedCompletedCount:i=0}){const l=Math.max(0,i),c=ks(a,new Set(["completed"]))+l,d=ks(a,new Set(["failed","cancelled"])),m=ks(a,new Set(["archived"])),p=[{label:"Path",value:t,mono:!0},{label:"Node",value:n??s??"Unassigned"},{label:"Node ID",value:s??"Unassigned",mono:!!s},{label:"Node status",value:r??"unknown"},{label:"Task count",value:String(a.length+l)},{label:"Assigned",value:String(ks(a,new Set(["assigned"])))},{label:"Running",value:String(ks(a,new Set(["running"])))},{label:"Completed",value:String(c)},{label:"Failed / cancelled",value:String(d)},{label:"Archived",value:String(m)},{label:"Latest update",value:xf(a)}];return e.jsx(Ti,{rows:p})}function bf({task:t,open:s,onOpenChange:n}){return e.jsx(mt,{open:s,onOpenChange:n,children:e.jsxs(ht,{className:"max-w-[25rem] gap-3 rounded-sm border-border/70 bg-background/96 p-4 backdrop-blur-xl",children:[e.jsxs(Et,{className:"space-y-1",children:[e.jsx(bt,{className:"text-[13px]",children:"Task properties"}),e.jsx(Mt,{className:"truncate text-[10px] leading-4 text-muted-foreground",children:t.title})]}),e.jsx(pf,{task:t})]})})}function vf({dirPath:t,nodeId:s,nodeName:n,nodeStatus:r,tasks:a,unloadedCompletedCount:i,open:l,onOpenChange:c}){return e.jsx(mt,{open:l,onOpenChange:c,children:e.jsxs(ht,{className:"max-w-[25rem] gap-3 rounded-sm border-border/70 bg-background/96 p-4 backdrop-blur-xl",children:[e.jsxs(Et,{className:"space-y-1",children:[e.jsx(bt,{className:"text-[13px]",children:"Project properties"}),e.jsx(Mt,{className:"truncate text-[10px] leading-4 text-muted-foreground",children:t})]}),e.jsx(gf,{dirPath:t,nodeId:s,nodeName:n,nodeStatus:r,tasks:a,unloadedCompletedCount:i})]})})}function wf({dirPath:t,nodeId:s,nodeName:n,nodeStatus:r,tasks:a=[],unloadedCompletedCount:i,contextOpen:l=!1,contextPosition:c=null,defaultOpen:d=!1,onContextOpenChange:m,onCreateTask:p,onOpenCapabilities:u}){const{open:h,menuRef:f,triggerRef:w,menuStyle:g,closeMenu:N,toggleButton:b}=Mr({contextOpen:l,contextPosition:c,defaultOpen:d,onContextOpenChange:m}),[k,y]=o.useState(!1),x=h?e.jsxs("div",{ref:f,role:"menu",style:g,onClick:v=>v.stopPropagation(),onPointerDown:v=>v.stopPropagation(),className:Er,children:[e.jsx(Xe,{icon:e.jsx(Ps,{className:"h-3 w-3 text-primary"}),onClick:()=>{N(),p()},children:"New chat"}),u&&e.jsx(Xe,{icon:e.jsx(_s,{className:"h-3 w-3 text-primary"}),onClick:()=>{N(),u()},children:"Capabilities"}),e.jsx(Xe,{icon:e.jsx(gr,{className:"h-3 w-3 text-primary"}),onClick:()=>{N(),y(!0)},children:"Properties"})]}):null;return e.jsxs("div",{className:L("relative flex shrink-0 items-center self-center pr-1",h&&"z-[120]"),onClick:v=>v.stopPropagation(),onPointerDown:v=>v.stopPropagation(),children:[e.jsx("button",{ref:w,type:"button","aria-label":`More actions for ${t}`,"aria-haspopup":"menu","aria-expanded":h,title:`More actions for ${t}`,onClick:v=>{v.stopPropagation(),b()},className:L("pointer-events-none flex h-4 w-4 shrink-0 translate-y-px 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",h&&"pointer-events-auto bg-primary/10 text-primary opacity-100"),children:e.jsx(Nr,{className:"h-2.5 w-2.5"})}),x&&(typeof document>"u"?x:Xs.createPortal(x,document.body)),k&&e.jsx(vf,{dirPath:t,nodeId:s,nodeName:n,nodeStatus:r,tasks:a,unloadedCompletedCount:i,open:k,onOpenChange:y})]})}function yf({dirPath:t,label:s,taskCount:n,tasks:r,unloadedCompletedCount:a,nodeId:i,nodeName:l,nodeStatus:c,collapsed:d,onToggle:m,onCreateTask:p,onOpenCapabilities:u}){const[h,f]=o.useState(!1),[w,g]=o.useState(null);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",onContextMenu:N=>{N.preventDefault(),N.stopPropagation(),f(!0),g({left:N.clientX,top:N.clientY})},children:[e.jsxs("button",{type:"button",onClick:m,"aria-expanded":!d,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(ut,{className:L("h-3 w-3 shrink-0 transition-transform duration-200",!d&&"rotate-90")}),e.jsx(us,{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})]}),u&&e.jsx("button",{type:"button",onClick:u,"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(_s,{className:"h-2.5 w-2.5"})}),e.jsx("button",{type:"button",onClick:p,"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(Ps,{className:"h-2.5 w-2.5"})}),e.jsx(wf,{dirPath:t,nodeId:i,nodeName:l,nodeStatus:c,tasks:r,unloadedCompletedCount:a,contextOpen:h,contextPosition:h?w:null,onContextOpenChange:N=>{N||(f(!1),g(null))},onCreateTask:p,onOpenCapabilities:u})]})}function Ya(t,s){if(!t.has(s))return t;const n=new Set(t);return n.delete(s),n}function jf(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 Ja(t,s,n){return n?{collapsedNodes:Ya(t,n.nodeKey),collapsedDirs:Ya(s,n.dirKey)}:{collapsedNodes:t,collapsedDirs:s}}function Nf(t,s,n){const r=t.filter(d=>d.status==="completed"),a=new Set(r.filter(Ms).map(d=>d.id)),i=new Set((s?r:[...r].sort((d,m)=>m.updatedAt-d.updatedAt).slice(0,vr)).map(d=>d.id));for(const d of a)i.add(d);n&&r.some(d=>d.id===n)&&i.add(n);const l=Ai(t.filter(d=>d.status!=="completed"||i.has(d.id))),c=r.length-i.size;return{visibleTasks:l,hiddenCompletedCount:Math.max(0,c)}}function Ms(t){return t.pinnedOnTop===!0}function Ai(t){return[...t].sort((s,n)=>{const r=Number(Ms(n))-Number(Ms(s));if(r!==0)return r;const a=n.updatedAt-s.updatedAt;if(a!==0)return a;const i=n.createdAt-s.createdAt;return i!==0?i:s.id.localeCompare(n.id)})}const kf=new Set(["completed","failed","cancelled"]);function Sf({task:t,contextOpen:s=!1,contextPosition:n=null,defaultOpen:r=!1,onContextOpenChange:a,onUpdateTitle:i,onDeleteTask:l,onArchiveTask:c,onTogglePinned:d}){const{open:m,menuRef:p,triggerRef:u,menuStyle:h,closeMenu:f,toggleButton:w}=Mr({contextOpen:s,contextPosition:n,defaultOpen:r,onContextOpenChange:a}),[g,N]=o.useState(!1),[b,k]=o.useState(!1),[y,x]=o.useState(!1),[v,S]=o.useState(!1),[A,I]=o.useState(t.title),[E,B]=o.useState(null),M=Ms(t),D=kf.has(t.status),P=t.status==="archived"?"Task is already archived":"Only completed, failed, or cancelled tasks can be archived";o.useEffect(()=>{I(t.title)},[t.id,t.title]);async function O(H,se){if(!(!se||E)){B(H);try{await se(),f()}finally{B(null)}}}const Q=A.trim(),te=Q===t.title,Y=m?e.jsxs("div",{ref:p,role:"menu",style:h,onClick:H=>H.stopPropagation(),onPointerDown:H=>H.stopPropagation(),className:Er,children:[i&&e.jsx(Xe,{icon:e.jsx(Yt,{className:"h-3 w-3 text-primary"}),onClick:()=>{f(),N(!0)},children:"Update title"}),d&&e.jsx(Xe,{icon:M?e.jsx(Yd,{className:"h-3 w-3 text-primary"}):e.jsx(qo,{className:"h-3 w-3 text-primary"}),pending:E==="pin",onClick:()=>O("pin",()=>d(t,!M)),children:M?"Unpin from top":"Pin on top"}),c&&e.jsx(Xe,{icon:e.jsx(Bo,{className:"h-3 w-3 text-primary"}),disabled:!D,pending:E==="archive",title:D?"Archive task":P,onClick:()=>{D&&(f(),x(!0))},children:"Archive"}),l&&e.jsx(Xe,{destructive:!0,icon:e.jsx(wr,{className:"h-3 w-3 text-destructive"}),onClick:()=>{f(),S(!0)},children:"Delete"}),e.jsx(Xe,{icon:e.jsx(gr,{className:"h-3 w-3 text-primary"}),onClick:()=>{f(),k(!0)},children:"Properties"})]}):null;return e.jsxs("div",{className:L("relative shrink-0",m&&"z-[120]"),onClick:H=>H.stopPropagation(),onPointerDown:H=>H.stopPropagation(),children:[e.jsx(Z,{ref:u,type:"button",variant:"ghost",size:"icon","aria-label":`More actions for ${t.title}`,"aria-haspopup":"menu","aria-expanded":m,title:`More actions for ${t.title}`,onClick:H=>{H.stopPropagation(),w()},className:L("h-5 w-5 rounded-sm text-muted-foreground/55 opacity-0 transition-all duration-150 pointer-events-none hover:bg-background/70 hover:text-foreground focus-visible:pointer-events-auto focus-visible:opacity-100 group-hover/task-row:pointer-events-auto group-hover/task-row:opacity-100",m&&"pointer-events-auto bg-background/80 text-primary opacity-100"),children:e.jsx(Nr,{className:"h-3 w-3"})}),Y&&(typeof document>"u"?Y:Xs.createPortal(Y,document.body)),b&&e.jsx(bf,{task:t,open:b,onOpenChange:k}),g&&i&&e.jsx(mt,{open:g,onOpenChange:N,children:e.jsxs(ht,{className:"rounded-sm sm:max-w-sm",children:[e.jsxs(Et,{children:[e.jsx(bt,{children:"Update task title"}),e.jsx(Mt,{children:"Rename this task in the tree and transcript header."})]}),e.jsxs("form",{className:"space-y-3",onSubmit:H=>{H.preventDefault(),O("title",async()=>{!Q||te||(await i?.(t,Q),N(!1))})},children:[e.jsx(ct,{value:A,onChange:H=>I(H.target.value),className:"h-8 rounded-sm border-border/70 text-[11px] shadow-none focus-visible:ring-1 focus-visible:ring-offset-0","aria-label":"Task title",autoFocus:!0}),e.jsxs(fr,{children:[e.jsx(Z,{type:"button",variant:"ghost",size:"sm",className:"h-7 rounded-sm px-2 text-[11px]",onClick:()=>N(!1),children:"Cancel"}),e.jsxs(Z,{type:"submit",size:"sm",className:"h-7 rounded-sm px-2 text-[11px]",disabled:!Q||te||E==="title",children:[E==="title"&&e.jsx(fe,{className:"h-3.5 w-3.5 animate-spin"}),"Save"]})]})]})]})}),y&&c&&e.jsx(Ut,{open:y,onOpenChange:x,children:e.jsxs($t,{children:[e.jsxs(qt,{children:[e.jsx(Ht,{children:"Archive this task?"}),e.jsx(Vt,{children:"This task leaves the default active view immediately."})]}),e.jsxs(Kt,{children:[e.jsx(Gt,{autoFocus:!0,children:"Cancel"}),e.jsx(Wt,{onClick:()=>O("archive",async()=>{await c?.(t),x(!1)}),disabled:E==="archive",children:"Archive"})]})]})}),v&&l&&e.jsx(Ut,{open:v,onOpenChange:S,children:e.jsxs($t,{children:[e.jsxs(qt,{children:[e.jsx(Ht,{children:"Delete this task and saved logs?"}),e.jsx(Vt,{children:"This cannot be undone."})]}),e.jsxs(Kt,{children:[e.jsx(Gt,{autoFocus:!0,children:"Cancel"}),e.jsx(Wt,{onClick:()=>O("delete",async()=>{await l?.(t),S(!1)}),disabled:E==="delete",className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}const Ei="meshy-task-sidebar-tree-state";function Za(t){return Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}function Kn(){try{return globalThis.window?.localStorage??globalThis.localStorage??null}catch{return null}}function Xa(t){if(!t)return{collapsedNodes:[],collapsedDirs:[]};try{const s=t.getItem(Ei);if(!s)return{collapsedNodes:[],collapsedDirs:[]};const n=JSON.parse(s);return{collapsedNodes:Za(n.collapsedNodes),collapsedDirs:Za(n.collapsedDirs)}}catch{return{collapsedNodes:[],collapsedDirs:[]}}}function Cf(t,s){if(t)try{t.setItem(Ei,JSON.stringify(s))}catch{}}const Us="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",$s="py-1 pl-6 pr-1.5 text-[10px] leading-4 [&_svg]:h-3 [&_svg]:w-3";function eo({toolbarTasks:t,activeTaskId:s,tasksLoading:n,tasksError:r,isLeader:a,scope:i,agentFilter:l,nodeFilter:c,taskKindFilter:d,agentOptions:m,nodeOptions:p,nodeNameById:u,nodeWorkDirById:h,nodeStatusById:f,nodeInfoById:w,completedGroupByKey:g,devBoxNodeIds:N=new Set,devBoxStartNodeIds:b=new Set,devBoxStartingNodeIds:k=new Set,leaderNodeId:y,searchQuery:x,selectedTaskIds:v,allVisibleTasksSelected:S,someVisibleTasksSelected:A,canBatchArchive:I,onScopeChange:E,onAgentFilterChange:B,onNodeFilterChange:M,onTaskKindFilterChange:D,onToggleTaskSelected:P,onToggleAllVisibleTasks:O,onBatchArchive:Q,onBatchDelete:te,onUpdateTaskTitle:Y,onDeleteTask:H,onArchiveTask:se,onToggleTaskPinned:$,onCreateTask:X,onOpenNodeSettings:j,onOpenNodeCapabilities:W,onOpenProjectCapabilities:T,onOpenDevBox:ee,onStartDevBox:R,onLoadCompletedTasks:V,onSelectTask:F}){const[le,ie]=o.useState(!1),[me,J]=o.useState(()=>v.size>0),[K,_]=o.useState(!1),[ne,q]=o.useState(null),[ae,ye]=o.useState(null),[xe,Ze]=o.useState(null),[Ae,ft]=o.useState(null),[Re,De]=o.useState(null),{markScrollbarActive:Ve,scrollbarActive:Ke}=di(),je=v.size,Be=!!(a&&(me||je>0)),G=i!=="active"||c!=="all"||l!=="all"||d!=="all",ge=x.trim().length>0,[be,et]=o.useState(()=>new Set(Xa(Kn()).collapsedNodes)),[_e,nt]=o.useState(()=>new Set(Xa(Kn()).collapsedDirs)),[re,Ne]=o.useState(new Set),Te=o.useMemo(()=>ec({nodeStatusById:f,nodeNameById:u,nodeWorkDirById:h,nodeFilter:c,searchQuery:x}),[f,u,h,c,x]),ve=o.useMemo(()=>tc(t,u,y,h,Te),[t,u,y,h,Te]),rt=o.useMemo(()=>jf(ve,s),[ve,s]),Pe=o.useRef(null),Dt=ve.length===1,xt=ve.length>0,hs=Dt&&(G||ge),Xt=!!(a&&(t.length>0||je>0)),St=!!(a&&Y&&H&&se&&$),vt=o.useCallback(U=>{et(ze=>{const Ie=new Set(ze);return Ie.has(U)?Ie.delete(U):Ie.add(U),Ie})},[]),fs=o.useCallback(U=>{nt(ze=>{const Ie=new Set(ze);return Ie.has(U)?Ie.delete(U):Ie.add(U),Ie})},[]),xs=o.useCallback(U=>{Ne(ze=>{const Ie=new Set(ze);return Ie.add(U),Ie})},[]);o.useEffect(()=>{Cf(Kn(),{collapsedNodes:Array.from(be),collapsedDirs:Array.from(_e)})},[_e,be]),o.useEffect(()=>{if(!rt||!s)return;const U=`${s}:${rt.nodeKey}:${rt.dirKey}`;Pe.current!==U&&(Pe.current=U,et(ze=>Ja(ze,new Set,rt).collapsedNodes),nt(ze=>Ja(new Set,ze,rt).collapsedDirs))},[s,rt]);const _t=o.useCallback(U=>{J(!0),O(U)},[O]),Bt=o.useCallback(U=>{if(U===!0&&!S){J(!0),_(!0);return}_t(U===!0)},[S,_t]),es=o.useCallback(()=>{_t(!0),_(!1)},[_t]),Ct=o.useCallback(()=>{O(!1),J(!1),_(!1)},[O]),ts=o.useCallback(()=>{ye(null),Ze(null)},[]),Fe=o.useCallback(()=>{ft(null),De(null)},[]);o.useEffect(()=>{a||(J(!1),_(!1))},[a]);const at=Be?e.jsxs(Ut,{open:K,onOpenChange:_,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(Es,{className:"h-3 w-3 [&_svg]:h-2.5 [&_svg]:w-2.5",checked:A&&!S?"indeterminate":S,onCheckedChange:Bt,"aria-label":"Select all visible tasks"}),e.jsx("span",{children:"Select all"})]}),K&&e.jsxs($t,{children:[e.jsxs(qt,{children:[e.jsx(Ht,{children:"Select every visible task?"}),e.jsx(Vt,{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(Kt,{children:[e.jsx(Gt,{autoFocus:!0,children:"Cancel"}),e.jsx(Wt,{onClick:es,children:"Select all"})]})]})]}):e.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>J(!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(od,{className:"h-3 w-3"}),"Multi select"]}),wt=je>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:[je," task",je!==1?"s":""," selected"]}),!I&&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,Tt=je>0?e.jsxs("div",{className:"flex flex-wrap justify-end gap-1",children:[e.jsxs(Ut,{children:[e.jsx(Jn,{asChild:!0,children:e.jsxs(Z,{variant:"ghost",size:"sm",disabled:!I,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(Bo,{}),"Archive"]})}),e.jsxs($t,{children:[e.jsxs(qt,{children:[e.jsxs(Ht,{children:["Archive ",je," selected task",je!==1?"s":"","?"]}),e.jsx(Vt,{children:"These tasks leave the default view immediately. Cancel if any selected task still needs to stay visible in active work."})]}),e.jsxs(Kt,{children:[e.jsx(Gt,{autoFocus:!0,children:"Cancel"}),e.jsx(Wt,{onClick:Q,disabled:!I,children:"Archive"})]})]})]}),e.jsxs(Ut,{children:[e.jsx(Jn,{asChild:!0,children:e.jsxs(Z,{variant:"destructive",size:"sm",className:"h-5 gap-1 rounded-sm px-1.5 text-[8px] [&_svg]:size-3",children:[e.jsx(wr,{}),"Delete"]})}),e.jsxs($t,{children:[e.jsxs(qt,{children:[e.jsxs(Ht,{children:["Delete ",je," selected task",je!==1?"s":""," and saved logs?"]}),e.jsx(Vt,{children:"This cannot be undone. Cancel unless you are certain every selected task and log should be removed now."})]}),e.jsxs(Kt,{children:[e.jsx(Gt,{autoFocus:!0,children:"Cancel"}),e.jsx(Wt,{onClick:te,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(Z,{onClick:()=>X("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(Ps,{className:"h-3.5 w-3.5"}),"New chat"]}),e.jsxs(Z,{variant:"outline",onClick:()=>X("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(kr,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Load session"]})]}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>ie(U=>!U),className:L("ml-auto h-8 w-8 shrink-0 rounded-sm text-muted-foreground shadow-none hover:bg-muted/55 hover:text-foreground",(le||G)&&"bg-primary/8 text-primary hover:bg-primary/12 hover:text-primary"),title:"Filters",children:e.jsx(Rd,{className:"h-3.5 w-3.5"})})]}),(le||G)&&e.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-1 sm:grid-cols-2",children:[e.jsxs($e,{value:i,onValueChange:U=>E(U),children:[e.jsx(qe,{className:Us,children:e.jsx(Je,{})}),e.jsx(He,{children:sc.map(U=>e.jsx(Oe,{value:U.value,className:$s,children:U.label},U.value))})]}),e.jsxs($e,{value:c,onValueChange:M,children:[e.jsx(qe,{className:Us,children:e.jsx(Je,{placeholder:"Node"})}),e.jsx(He,{children:p.map(U=>e.jsx(Oe,{value:U.value,className:$s,children:U.label},U.value))})]}),e.jsxs($e,{value:l,onValueChange:B,children:[e.jsx(qe,{className:Us,children:e.jsx(Je,{placeholder:"Agent"})}),e.jsx(He,{children:m.map(U=>e.jsx(Oe,{value:U,className:$s,children:U==="all"?"All agents":U},U))})]}),e.jsxs($e,{value:d,onValueChange:U=>D(U),children:[e.jsx(qe,{className:Us,children:e.jsx(Je,{placeholder:"Type"})}),e.jsx(He,{children:nc.map(U=>e.jsx(Oe,{value:U.value,className:$s,children:U.label},U.value))})]})]})]}),e.jsx("div",{className:L("scrollbar-line min-h-0 flex-1 overflow-y-auto pl-2.5 pr-1.5 py-2",Ke&&"scrollbar-line-active"),onScroll:Ve,children:ve.length>0?e.jsx("div",{className:"space-y-1",children:ve.map(U=>{const ze=U.nodeId??"__unassigned__",Ie=U.dirs.reduce((pe,he)=>pe+he.tasks.length,0),We=xt&&!hs&&be.has(ze),Qe=U.nodeId!==null&&f.get(U.nodeId)==="offline",ss=!!(a&&U.nodeId);return e.jsxs("div",{className:"space-y-1",children:[xt&&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",onContextMenu:pe=>{!ss||!U.nodeId||(pe.preventDefault(),pe.stopPropagation(),ft(U.nodeId),De({left:pe.clientX,top:pe.clientY}))},children:[e.jsxs("button",{type:"button",onClick:()=>vt(ze),"aria-expanded":!We,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-sm px-2 py-1.5 text-left",children:[e.jsx(ut,{className:L("h-3.5 w-3.5 shrink-0 transition-transform duration-200",!We&&"rotate-90")}),e.jsx(Zs,{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:U.nodeName}),e.jsxs(Le,{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:[Ie," task",Ie===1?"":"s"]})]}),e.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[Qe&&e.jsx(Le,{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"}),U.nodeId===y&&e.jsx(Le,{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"})]})]}),ss&&U.nodeId&&e.jsx("span",{className:"flex shrink-0 items-center pr-1.5",children:e.jsx(Dr,{nodeId:U.nodeId,nodeName:U.nodeName,node:U.nodeId?w?.get(U.nodeId):void 0,contextOpen:Ae===U.nodeId,contextPosition:Ae===U.nodeId?Re:null,onContextOpenChange:pe=>{pe||Fe()},onOpenSettings:j,onOpenServicePreview:()=>q({id:U.nodeId,name:U.nodeName}),onOpenCapabilities:W,onOpenDevBox:ee,onStartDevBox:R,showConfigureDevBox:N.has(U.nodeId),showStartDevBox:b.has(U.nodeId)||k.has(U.nodeId),startDevBoxPending:k.has(U.nodeId)})})]}),e.jsx("div",{className:L("grid transition-[grid-template-rows] duration-300 ease-in-out",We?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:"overflow-hidden",children:U.dirs.map(pe=>{const he=`${ze}::${pe.path}`,ke=_e.has(he),Ge=To(pe.path),Ue=g?.get(he),Ot=Ue?{visibleTasks:Ai(pe.tasks),hiddenCompletedCount:Math.max(0,Ue.total-Ue.returned)}:Nf(pe.tasks,re.has(he),s),{visibleTasks:nn,hiddenCompletedCount:ps}=Ot;return e.jsxs("div",{className:L("space-y-0.5 rounded-xl",xt&&"pl-2.5"),children:[e.jsx(yf,{dirPath:pe.path,label:Ge,taskCount:pe.tasks.length,tasks:pe.tasks,unloadedCompletedCount:Ue?Math.max(0,Ue.total-Ue.returned):0,nodeId:U.nodeId,nodeName:U.nodeName,nodeStatus:U.nodeId?f.get(U.nodeId):void 0,collapsed:ke,onToggle:()=>fs(he),onCreateTask:()=>X("chat",{assignTo:U.nodeId,project:pe.path==="default workspace"?"":pe.path}),onOpenCapabilities:U.nodeId&&T?()=>T(U.nodeId,pe.path==="default workspace"?h?.get(U.nodeId)??pe.path:pe.path):void 0}),e.jsx("div",{className:L("grid transition-[grid-template-rows] duration-300 ease-in-out",ke?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:L("overflow-hidden",xt?"pl-2":"pl-0"),children:e.jsxs("div",{className:"space-y-px py-0.5",children:[nn.map(Ee=>{const ns=Ee.id===s,Pt=Ee.assignedTo?f.get(Ee.assignedTo):void 0,gs=!!Ee.assignedTo&&(Pt?Pt==="offline":Ee.assignedNodeAvailable===!1),rn=hi(Ee),an=Ms(Ee);return e.jsxs("div",{onContextMenu:ot=>{ot.preventDefault(),ot.stopPropagation(),ye(Ee.id),Ze({left:ot.clientX,top:ot.clientY})},className:L("group/task-row animate-task-row-reveal relative flex items-center gap-1.5 rounded-sm px-2 py-1.5 transition-all duration-150",ns?'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:[Be&&e.jsx("div",{className:"flex shrink-0",onClick:ot=>ot.stopPropagation(),children:e.jsx(Es,{className:"h-3 w-3 [&_svg]:h-2.5 [&_svg]:w-2.5",checked:v.has(Ee.id),onCheckedChange:ot=>P(Ee.id,ot===!0),"aria-label":`Select ${Ee.title}`})}),e.jsxs("button",{type:"button",onClick:()=>F(Ee.id),"aria-current":ns?"page":void 0,className:"relative min-w-0 flex-1 pr-8 text-left",children:[e.jsxs("div",{className:"flex items-center gap-1.5 pr-1",children:[an&&e.jsx("span",{role:"img","aria-label":"Pinned to top",title:"Pinned to top",className:"flex shrink-0",children:e.jsx(qo,{className:"h-2.5 w-2.5 -rotate-45 text-primary"})}),e.jsx("span",{className:L("min-w-0 flex-1 truncate text-[10px] font-medium leading-4",ns?"text-foreground":"text-foreground/80"),children:Ee.title})]}),e.jsx("span",{className:L("absolute right-0 top-0 shrink-0 tabular-nums text-[8px] leading-4",ns?"text-primary/75":"text-muted-foreground/55"),children:rc(Ee.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:rn}),Ee.activeShare&&e.jsx(Le,{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"}),gs&&e.jsx(Le,{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(ko,{status:Ee.status,isNative:Ee.conversationKind==="nativeSession",size:"compact",className:"absolute bottom-1 right-0"})]}),e.jsx(Sf,{task:Ee,contextOpen:ae===Ee.id,contextPosition:ae===Ee.id?xe:null,onContextOpenChange:ot=>{ot||ts()},onUpdateTitle:St?Y:void 0,onDeleteTask:St?H:void 0,onArchiveTask:St?se:void 0,onTogglePinned:St?$:void 0})]},Ee.id)}),ps>0&&e.jsxs("button",{type:"button",onClick:()=>{Ue&&V?V(Ue):xs(he)},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 ${ps} more completed tasks in ${Ge}`,children:[e.jsx(st,{className:"h-3 w-3"}),"Load ",ps," more completed"]})]})})})]},he)})})})]},ze)})}):n?e.jsx("div",{className:"space-y-2 px-1",children:[1,2,3].map(U=>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+U*12}%`,animationDelay:`${U*120}ms`}}),e.jsx("div",{className:"h-2 w-24 animate-pulse rounded-full bg-muted-foreground/10",style:{animationDelay:`${U*120+60}ms`}})]})]})},U))}):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."})}),Xt?e.jsx("div",{className:"shrink-0 px-2.5 pb-2.5 pt-1.5",children:Be&&je>0?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[wt,e.jsx(Z,{variant:"ghost",size:"sm",onClick:Ct,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:at}),Tt]})]}):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:at}),Be&&e.jsx(Z,{variant:"ghost",size:"sm",onClick:Ct,className:"h-5 shrink-0 rounded-sm px-1.5 text-[9px]",children:"Done"})]})}):null]}),e.jsx(nf,{node:ne,open:ne!==null,onOpenChange:U=>{U||q(null)}})]})}async function Tf(t,s){try{const n=await ac(t,s),r={...n,url:yo(n.url)};if(globalThis.navigator?.clipboard?.writeText)try{await globalThis.navigator.clipboard.writeText(r.url),ce.success("Shared link copied")}catch{ce.success("Shared link created")}else ce.success("Shared link created");return r}catch(n){ce.error(n instanceof Error?n.message:"Failed to create shared link");return}}async function Af(t){try{return await oc(t),ce.success("Shared link stopped"),!0}catch(s){return ce.error(s instanceof Error?s.message:"Failed to stop shared link"),!1}}function Ef(t,s,n){const r=o.useCallback(()=>{s(),n()},[s,n]),a=o.useCallback(async l=>{if(!t)return;const c=await Tf(t.id,l);return c&&r(),c},[t,r]),i=o.useCallback(async()=>{if(!t)return!1;const l=await Af(t.id);return l&&r(),l},[t,r]);return{handleShareTask:a,handleStopShareTask:i}}function to(t,s,n){const r=o.useRef(s);r.current=s,o.useEffect(()=>{let l=0,c=0;const d=u=>{const h=u.touches[0];h&&(l=h.clientX,c=h.clientY)},m=u=>{const h=u.changedTouches[0];if(!h)return;const f=h.clientX-l;Math.abs(h.clientY-c)>100||Math.abs(f)<50||(f>0?r.current.onSwipeRight?.():r.current.onSwipeLeft?.())},p=t?.current??document;return p.addEventListener("touchstart",d,{passive:!0}),p.addEventListener("touchend",m,{passive:!0}),()=>{p.removeEventListener("touchstart",d),p.removeEventListener("touchend",m)}},[t,n?.threshold,n?.maxVertical])}const Mf="(min-width: 1024px)",Df="(min-width: 1800px)";function so(t){return globalThis.window?.matchMedia?.(t)?.matches??!1}function _f(){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 Pf(){const[t,s]=o.useState(()=>ic(Hr(),lc({operationsOpen:so(Df)}))),[n,r]=o.useState(!1),a=o.useRef(null),i=o.useRef(null),l=o.useRef(null),c=t.layout.desktopTasksOpen,d=t.layout.operationsOpen,m=t.sizes;o.useEffect(()=>{cc(Hr(),t)},[t]);const p=o.useCallback((N,b)=>{s(k=>{const y=k.layout[N],x=typeof b=="function"?b(y):b;return x===y?k:{...k,layout:{...k.layout,[N]:x}}})},[]),u=o.useCallback(N=>{p("desktopTasksOpen",N)},[p]),h=o.useCallback(N=>{p("operationsOpen",N)},[p]);to(i,{onSwipeLeft:()=>r(!1)}),to(l,{onSwipeRight:()=>h(!1)});const f=o.useCallback(()=>{if(so(Mf)){u(N=>!N);return}r(N=>!N)},[u]);o.useEffect(()=>{const N=k=>{const y=a.current;if(!y)return;k.preventDefault();const x=uc(y.panel,y.startSize,y.startClientX,y.startClientY,k.clientX,k.clientY,y.rootFontSize);s(v=>({...v,sizes:{...v.sizes,[y.panel]:x}}))},b=()=>{a.current=null};return globalThis.window?.addEventListener("pointermove",N),globalThis.window?.addEventListener("pointerup",b),globalThis.window?.addEventListener("pointercancel",b),()=>{globalThis.window?.removeEventListener("pointermove",N),globalThis.window?.removeEventListener("pointerup",b),globalThis.window?.removeEventListener("pointercancel",b)}},[]);const w=o.useCallback((N,b)=>{b.preventDefault(),b.currentTarget.setPointerCapture?.(b.pointerId),a.current={panel:N,startSize:m[N],startClientX:b.clientX,startClientY:b.clientY,rootFontSize:_f()}},[m]),g=o.useCallback((N,b)=>{b.preventDefault(),s(k=>({...k,sizes:{...k.sizes,[N]:dc(N,k.sizes[N],b.deltaY)}}))},[]);return{desktopTasksOpen:c,mobileTasksPanelOpen:n,mobileTasksPanelRef:i,operationsOpen:d,operationsPanelRef:l,panelResize:{sizes:{tasks:fn(m.tasks),operations:fn(m.operations),terminal:fn(m.terminal)},onPointerDown:w,onWheel:g},setMobileTasksPanelOpen:r,setOperationsOpen:h,toggleTasksPanel:f}}function If(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 Rf="notify_desktop_task";function Lf(t=Mi()){const s=t?.__TAURI__?.core?.invoke;return typeof s=="function"?s:null}async function Bf(t,s=Mi()){const n=Lf(s);return n?(await n(Rf,t),!0):!1}function Of(t,s){const n=[];for(const r of s){const a=Ff(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 Ff(t){return t==="completed"||t==="failed"?t:null}function Mi(){return typeof window>"u"?null:window}function zf({isLeader:t,selfId:s}){return{...!t&&s?{assignedTo:s}:{},completedLimitPerProject:vr}}function dr(t){return`${t.assignedTo??"__unassigned__"}::${t.projectPath}`}function Uf(t,s,n,r,a){if(dr(t)!==dr(s))return t;const i=new Set(n.map(c=>c.id)),l=r.filter(c=>!i.has(c.id)).length;return{...t,returned:Math.min(t.total,t.returned+l),hasMore:a.hasMore===!0,nextCursor:a.nextCursor??null}}function $f(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 qf(t,s,n=new Set){return!s||n.has(s.id)||t.some(r=>r.id===s.id)?t:Cr(t,s)}function Hf({isLeader:t,selfId:s,sseConnected:n,preservedTask:r,subscribe:a}){const[i,l]=o.useState([]),[c,d]=o.useState([]),[m,p]=o.useState(!0),[u,h]=o.useState(null),f=o.useRef(new Set),w=o.useRef(null),g=o.useRef(null),N=o.useCallback(async()=>{try{const x=await Vr(zf({isLeader:t,selfId:s}));l(qf(x.tasks,r,f.current)),d(x.completedGroups??[]),h(null)}catch(x){h(x instanceof Error?x.message:"Failed to load tasks")}finally{p(!1)}},[t,r,s]),b=o.useCallback(async x=>{if(!x.hasMore||!x.nextCursor)return;const v=await Vr({status:"completed",assignedTo:x.assignedTo??"__unassigned__",projectPath:x.projectPath,cursor:x.nextCursor,limit:vr});l(S=>$f(S,v.tasks)),d(S=>S.map(A=>Uf(A,x,i,v.tasks,v)))},[i]),k=o.useCallback(()=>{g.current===null&&(g.current=window.setTimeout(()=>{g.current=null,N()},mc))},[N]),y=o.useCallback(x=>{const v=new Set(x);if(v.size!==0){for(const S of v)f.current.add(S);l(S=>S.filter(A=>!v.has(A.id)))}},[]);return hc(N,pc(n)),o.useEffect(()=>()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),o.useEffect(()=>{const x=w.current;if(x)for(const v of Of(x,i))Bf(v).catch(()=>{});w.current=new Map(i.map(v=>[v.id,v]))},[i]),o.useEffect(()=>{const x=[a("task.updated",v=>{l(S=>If(S,v.data))}),a("task.status",v=>{l(S=>fc(S,v.data))}),a("node",v=>{Kr(v.type)&&k()}),a("task",v=>{if(v.type==="task.deleted"){const S=v.data.taskId;typeof S=="string"&&f.current.add(S),l(A=>xc(A,v.data))}Kr(v.type)&&k()})];return()=>x.forEach(v=>v())},[a,k]),{completedGroups:c,fetchTasks:N,loadCompletedTasksPage:b,removeTasksFromList:y,setTasks:l,tasks:i,tasksError:u,tasksLoading:m}}function Ir(t){return t.map(s=>({...s}))}function Vf(t,s){const n=s.get(t);return{logs:n?Ir(n.logs):[],transcriptLoading:n?.loaded!==!0}}function Kf(t,s){return s.data.nodeId===t.self.id||s.data.name===t.self.name||s.data.endpoint===t.self.endpoint}function Gf(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 Wf({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=Gf(r,n),i=Kf(t,r);r.type==="node.joined"&&!i&&ce.success(`${a} joined the cluster`),r.type==="node.left"&&!i&&ce.message(`${a} left the cluster`)})},[t,s])}function Qf({localCount:t,checkpointTotal:s}){const n=Math.max(0,Math.floor(t));if(s===void 0)return{after:n};const r=Math.max(0,Math.floor(s));return n>=r?null:{after:n,minTotal:r}}function Yf({activeTaskId:t,cacheTranscript:s,fetchActiveLogs:n,fetchActiveTask:r,logs:a,setLogs:i,setPendingMessages:l,setTranscriptLoading:c,sseConnected:d,subscribe:m}){const p=o.useRef([]),u=o.useRef(d),h=o.useRef(!1),f=o.useRef(!1),w=o.useRef(void 0);o.useEffect(()=>{p.current=Ir(a)},[a]);const g=o.useCallback(N=>{if(h.current){f.current=!0,N!==void 0&&(w.current=Math.max(w.current??0,N));return}const b=Qf({localCount:p.current.length,checkpointTotal:N});b&&(h.current=!0,n(b).finally(()=>{if(h.current=!1,!f.current)return;f.current=!1;const k=w.current;w.current=void 0,g(k)}))},[n]);o.useEffect(()=>{if(t)return m("task",N=>{const b=N.data.taskId;if(!(typeof b!="string"||b!==t)){if(N.type==="task.output"){const k=N.data.event;if(k){i(x=>{const v=id(x,k);return s(t,v),v}),c(!1);const y=jr(k);y&&l(x=>ld(x,y))}}if(N.type==="task.updated"&&r(),N.type==="task.logs.ready"){const k=N.data.total;g(typeof k=="number"?k:void 0)}N.type==="task.status"&&(r(),g())}})},[t,s,n,r,g,i,l,c,m]),o.useEffect(()=>{const N=u.current;u.current=d,!N&&d&&t&&g()},[t,g,d])}const Jf=[0,300,1e3,2e3];function Zf({task:t,getActiveTaskId:s,setLogs:n,setPendingMessages:r,setTranscriptLoading:a}){t.conversationKind==="nativeSession"&&(async()=>{try{for(const i of Jf){if(i>0&&await new Promise(l=>setTimeout(l,i)),s()!==t.id)return;try{const l=await Zn(t.id);if(s()!==t.id||(n(c=>Lo(c,l.logs)),r(c=>er(c,l.logs)),l.total>0))return}catch{}}}finally{s()===t.id&&a?.(!1)}})()}const Di=8;function Xf(t,s){return Ye(t??{})===Ye(s??{})}function ex(t){return t&&"status"in t&&typeof t.status=="string"?t.status:void 0}function no(t,s){return{...t,enabled:!0,alwaysOnline:s}}function _i(t){return t?.status?.trim()||t?.lastStatus?.trim()||"Unknown"}function tx({operationStarting:t,loading:s,refreshing:n,savedStatus:r,fallbackStatus:a}){return t?"Starting":s?"Listing DevBoxes":n?"Refreshing":r??a}async function sx(t,s=Ao){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,Di)}function nx(t){return t.charAt(0).toUpperCase()+t.slice(1)}function rx(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 ax(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function ro(t,s){const r=ax(t)?.[s];return typeof r=="string"&&r.trim()?r.trim():null}function ox(t){if(t.status==="failed")return t.error||"Operation failed";const s=ro(t.result,"operationId");if(s)return`MCP operation ${s}`;const n=ro(t.payload,"previousStatus");return n?`Previous DevBox status: ${n}`:t.status==="succeeded"?"Completed":"Waiting for completion"}function ix(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 ao({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:_i(t)})]})}function lx({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(st,{className:L("h-3 w-3 shrink-0 text-muted-foreground transition-transform",!r&&"-rotate-90")}),e.jsx(Ws,{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(fe,{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(fe,{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=ox(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:rx(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:L("shrink-0 rounded-sm border px-1.5 py-0 text-[10px] leading-4",ix(i.status)),children:nx(i.status)})]},i.id)})]})]})}function cx({node:t,open:s,startInProgress:n=!1,onOpenChange:r,onRefresh:a}){const i=t?.id??null,l=s&&!n&&Va(t?.status,t?.devbox??null),[c,d]=o.useState([]),[m,p]=o.useState(()=>t?.devbox?Ye(t.devbox):""),[u,h]=o.useState(()=>t?.devbox??null),[f,w]=o.useState(()=>Ka(t?.devbox??null)),[g,N]=o.useState(!1),[b,k]=o.useState(l),[y,x]=o.useState(!1),[v,S]=o.useState(!1),[A,I]=o.useState(()=>t?.devbox?.alwaysOnline===!0),[E,B]=o.useState(!1),[M,D]=o.useState([]),[P,O]=o.useState(!1),[Q,te]=o.useState(null),Y=o.useMemo(()=>{const q=c.find(ae=>Ye(ae)===m);return q||(cs(u)&&Ye(u)===m?u:void 0)},[u,c,m]),H=ex(Y??void 0),se=f?H??u?.lastStatus:u?.lastStatus??H,$=t?.status==="online"||t?.status==="busy"?"Running":"Unknown",X=v||n,j=tx({operationStarting:X,loading:g,refreshing:b,savedStatus:se,fallbackStatus:$}),W=f&&!!Y&&!Xf(u,Y),T=u?.alwaysOnline===!0!==A,ee=Jh({nodeStatus:t?.status,status:j,current:u,selected:Y}),R=!!ee,V=!!Y&&(W||T)&&!R,F=Y??u,le=o.useCallback(async()=>{if(i){k(!0);try{const q=await gc(i);h(q.devbox),p(Ye(q.devbox))}catch(q){ce.error(q instanceof Error?q.message:"Failed to refresh DevBox status")}finally{k(!1)}}},[i]),ie=o.useCallback(async q=>{N(!0);try{const ae=await bc();d(ae),p(ye=>Zh({previousKey:ye,baseDevBox:q,listed:ae}))}catch(ae){ce.error(ae instanceof Error?ae.message:"Failed to load DevBoxes")}finally{N(!1)}},[]);o.useEffect(()=>{if(!s||!i)return;let q=!1;const ae=t?.devbox??null,ye=Ka(ae),xe=!n&&Va(t?.status,ae);N(!1),k(xe),w(ye),h(ae),I(ae?.alwaysOnline===!0),B(!1),p(cs(ae)?Ye(ae):""),d([]);async function Ze(){xe&&await le(),!q&&ye&&await ie(ae)}return Ze(),()=>{q=!0}},[ie,t?.devbox,t?.status,i,s,le,n]),o.useEffect(()=>{if(!s||!i)return;let q=!1;const ae=i;async function ye(){O(!0),te(null),D([]);try{const xe=await sx(ae);if(q)return;D(xe)}catch(xe){if(q)return;D([]),te(xe instanceof Error?xe.message:"Failed to load operation history")}finally{q||O(!1)}}return ye(),()=>{q=!0}},[i,s]);async function me(){w(!0),c.length===0&&await ie(u)}async function J(){if(!(!t||!Y)){x(!0);try{const q=await Gr(t.id,no(Y,A));h(q.node.devbox??null),q.node.devbox&&p(Ye(q.node.devbox)),w(!1),ce.success(`Configured DevBox for ${t.name}`),await a?.()}catch(q){ce.error(q instanceof Error?q.message:"Failed to configure DevBox")}finally{x(!1)}}}async function K(){if(!(!t||!ee)){S(!0);try{if(Y&&(W||T)){const ae=await Gr(t.id,no(Y,A));h(ae.node.devbox??null),ae.node.devbox&&p(Ye(ae.node.devbox)),w(!1)}const{operation:q}=await Eo(t.id);h(ae=>ae&&{...ae,lastStatus:"Starting",checkedAt:Date.now(),operationId:q.id}),D(ae=>[q,...ae.filter(ye=>ye.id!==q.id)].slice(0,Di)),ce.success(`Start requested for ${t.name}`),await a?.()}catch(q){ce.error(q instanceof Error?q.message:"Failed to start DevBox")}finally{S(!1)}}}const _=g?"Loading DevBoxes...":c.length===0?"No DevBoxes available":"Select a DevBox",ne=j==="Running"&&t?.status==="offline";return e.jsx(mt,{open:s,onOpenChange:r,children:e.jsxs(ht,{className:"w-[calc(100vw-2rem)] max-w-md grid-cols-[minmax(0,1fr)] gap-3 overflow-hidden rounded-sm p-4",children:[e.jsxs(Et,{className:"min-w-0 max-w-full space-y-1 overflow-hidden",children:[e.jsx(bt,{className:"text-sm",children:"Configure DevBox"}),e.jsxs(Mt,{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:[(f||F)&&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:f?e.jsxs($e,{value:m,onValueChange:p,disabled:g||y||v||c.length===0,children:[e.jsx(qe,{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:g&&!Y?e.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(fe,{className:"h-3.5 w-3.5 animate-spin"}),_]}):Y?e.jsx(ao,{devbox:Y}):e.jsx(Je,{placeholder:_})}),e.jsx(He,{children:c.map(q=>e.jsx(Oe,{value:Ye(q),textValue:`${q.name} ${q.projectName??""} ${_i(q)}`,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(ao,{devbox:q,showStatus:!0})},Ye(q)))})]}):F&&e.jsxs("div",{className:"min-w-0 truncate",children:[e.jsx("span",{className:"font-medium text-foreground",children:F.name}),F.projectName&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",F.projectName]})]})}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs(Le,{variant:"outline",className:"rounded-sm px-1.5 py-0 text-[10px]",children:[(g||b)&&e.jsx(fe,{className:"mr-1 h-2.5 w-2.5 animate-spin"}),j]}),u?.name&&e.jsx(Z,{type:"button",variant:"ghost",size:"icon",onClick:()=>{me()},disabled:g||y||X||f,"aria-label":"Edit DevBox binding",title:"Edit DevBox binding",className:"h-6 w-6 rounded-sm text-muted-foreground hover:text-foreground",children:g&&f?e.jsx(fe,{className:"h-3 w-3 animate-spin"}):e.jsx(Yt,{className:"h-3 w-3"})})]})]}),ne&&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(Es,{checked:A,onCheckedChange:q=>I(q===!0),disabled:y||v||X,"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(lx,{error:Q,loading:P,onToggle:()=>B(q=>!q),open:E,operations:M})]}),e.jsxs(fr,{className:"gap-2 sm:space-x-0",children:[e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>r(!1),disabled:y||v,className:"h-8 rounded-sm text-xs",children:"Close"}),R&&e.jsxs(Z,{size:"sm",onClick:K,disabled:v,className:"h-8 rounded-sm text-xs",children:[v?e.jsx(fe,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(en,{className:"h-3.5 w-3.5"}),"Start DevBox"]}),!R&&e.jsxs(Z,{size:"sm",onClick:J,disabled:!V||y,className:"h-8 rounded-sm text-xs",children:[y&&e.jsx(fe,{className:"h-3.5 w-3.5 animate-spin"}),"Save"]})]})]})})}async function dx(t,s=Ao){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 ux({cluster:t,refresh:s}){const[n,r]=o.useState(null),[a,i]=o.useState(null),[l,c]=o.useState(()=>new Set),[d,m]=o.useState(()=>new Set),p=o.useMemo(()=>t?.nodes.find(b=>b.id===n)??null,[t?.nodes,n]),u=o.useMemo(()=>new Set((t?.nodes??[]).filter(b=>b.devbox?.enabled).map(b=>b.id)),[t?.nodes]),h=o.useMemo(()=>new Set((t?.nodes??[]).filter(b=>sn(b.status,b.devbox?.lastStatus,b.devbox)).map(b=>b.id)),[t?.nodes]),f=o.useMemo(()=>new Set((t?.nodes??[]).filter(b=>ds(b.devbox?.lastStatus)).map(b=>b.id)),[t?.nodes]),w=o.useMemo(()=>{const b=new Set(l);a&&b.add(a);for(const k of d)b.add(k);for(const k of f)b.add(k);return b},[d,a,l,f]);o.useEffect(()=>{let b=!1;const k=[...u];async function y(){try{const x=await dx(k);b||m(x)}catch{b||m(new Set)}}return y(),()=>{b=!0}},[u]),o.useEffect(()=>{c(b=>{let k=!1;const y=new Set(b);for(const x of b){const v=t?.nodes.find(S=>S.id===x);v?.status!=="online"&&(!v?.devbox?.lastStatus||ds(v.devbox.lastStatus))||(y.delete(x),k=!0)}return k?y:b})},[t?.nodes]);const g=o.useCallback(async b=>{const k=t?.nodes.find(y=>y.id===b);if(k){i(b),c(y=>new Set(y).add(b));try{await Eo(b),ce.success(`Start requested for ${k.name}`),s()}catch(y){c(x=>{const v=new Set(x);return v.delete(b),v}),ce.error(y instanceof Error?y.message:"Failed to start DevBox")}finally{i(null)}}},[t?.nodes,s]);return{devBoxDialog:e.jsx(cx,{node:p,open:n!==null,startInProgress:p?w.has(p.id):!1,onOpenChange:b=>{b||r(null)},onRefresh:s}),devBoxNodeIds:u,devBoxStartNodeId:a,devBoxStartNodeIds:h,devBoxStartingNodeIds:w,openDevBox:r,startDevBox:g}}function mx(t){const[s,n]=o.useState(null),r=o.useCallback(i=>{t&&n(i)},[t]);return{nodeSettingsDialog:e.jsx(vc,{open:s!==null,onOpenChange:i=>{i||n(null)},initialSelectedNodeId:s??void 0,showTrigger:!1}),openNodeSettings:r}}function hx(t=!1){return!t}function fx({activeTaskId:t,fetchActiveTask:s,isRunning:n=!1,setPendingMessages:r,setTask:a,setTasks:i}){const l=o.useCallback((m,p)=>{a(u=>u&&u.id===m?{...u,queuedMessages:p}:u),i(u=>u.map(h=>h.id===m?{...h,queuedMessages:p}:h))},[a,i]),c=o.useCallback(async(m,p={})=>{if(!t)return!1;const u=`local-${Date.now()}-${Math.random().toString(16).slice(2)}`,h=hx(n);h&&r(f=>[...f,{id:u,content:m,timestamp:new Date().toISOString()}]);try{const f=p.targetAgent?await Wr(t,m,p.targetAgent):await Wr(t,m);return f.queued&&(h&&r(w=>w.filter(g=>g.id!==u)),f.queuedMessages&&l(t,f.queuedMessages)),s(),!0}catch(f){return h&&r(w=>w.filter(g=>g.id!==u)),ce.error(f instanceof Error?f.message:"Failed to send message"),!1}},[t,s,n,r,l]);return{cancelQueuedMessage:o.useCallback(async m=>{if(t)try{const p=await wc(t,m);l(t,p.queuedMessages),s()}catch(p){ce.error(p instanceof Error?p.message:"Failed to cancel queued message")}},[t,s,l]),queueFollowUpMessage:c}}const oo="grid-cols-[1.5rem_5.25rem_4rem_minmax(8rem,1fr)_4rem_4rem_6rem]",xx={claudecode:"Claude Code",codex:"Codex",copilot:"Copilot"};function px(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 Pi(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 gx({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:L("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",oo),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:L("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",oo,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(Es,{className:"h-3 w-3",checked:s.has(i.id),onCheckedChange:l=>r(i.id,l===!0),"aria-label":`Select ${i.name}`})}),e.jsx(bx,{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:Pi(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 bx({agent:t}){const s=xx[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 io=320,lo=560,Ii=384,co=360;function vx(t,s=lo+co){const n=Math.max(io,Math.min(lo,s-co));return Math.min(Math.max(Math.round(t),io),n)}function wx(t,s,n,r){return vx(t+s-n,r)}function yx({detail:t,deleting:s=!1,onDelete:n,desktopWidth:r=Ii,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(Le,{variant:"secondary",className:"rounded-sm border-0 bg-card/72 px-1.5 py-0 text-[8px] text-primary",children:t.agent}),e.jsx(Le,{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(Ut,{children:[e.jsx(Jn,{asChild:!0,children:e.jsx(Z,{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(wr,{className:"h-3.5 w-3.5"})})}),e.jsxs($t,{className:"max-w-[22rem] gap-2 rounded-xl p-4",children:[e.jsxs(qt,{className:"space-y-1",children:[e.jsxs(Ht,{className:"text-sm",children:["Delete ",t.name,"?"]}),e.jsxs(Vt,{className:"text-[11px] leading-4",children:["This removes the selected ",t.kind," from ",t.scope.kind==="global"?"the user profile":"this project","."]})]}),e.jsxs(Kt,{className:"gap-1 pt-0 sm:space-x-1",children:[e.jsx(Gt,{className:"h-7 rounded-lg px-2 text-[11px]",children:"Cancel"}),e.jsx(Wt,{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(qs,{label:"Version",value:t.version??"-"}),e.jsx(qs,{label:"Size",value:Pi(t)}),e.jsx(qs,{label:"Files",value:String(t.fileCount)}),e.jsx(qs,{label:"Source",value:t.source??"local"})]}),e.jsxs(mr,{defaultValue:l,className:"mt-2 flex min-h-0 flex-1 flex-col",children:[e.jsxs(ur,{className:"grid h-auto grid-cols-2 rounded-sm bg-primary/8 p-0.5",children:[t.kind==="mcp"?e.jsx(zt,{value:"mcp",className:"rounded-sm px-2 py-0.5 text-[9px]",children:"MCP"}):e.jsx(zt,{value:"files",className:"rounded-sm px-2 py-0.5 text-[9px]",children:"Files"}),e.jsx(zt,{value:"readme",className:"rounded-sm px-2 py-0.5 text-[9px]",children:"README"})]}),t.kind==="mcp"?e.jsx(Nt,{value:"mcp",className:"mt-2 min-h-0 flex-1 overflow-auto",children:e.jsx(jx,{detail:t})}):e.jsx(Nt,{value:"files",className:"mt-2 min-h-0 flex-1 overflow-auto",children:e.jsx(Nx,{detail:t})}),e.jsx(Nt,{value:"readme",className:"mt-2 min-h-0 flex-1 overflow-auto",children:t.readmeMarkdown?e.jsx(fd,{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(Rr,{children:"No README content."})})]},t.id)]})}function jx({detail:t}){const s=t.mcpPreview??[];return s.length===0?e.jsx(Rr,{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 Nx({detail:t}){const s=t.fileTree??[];return s.length===0?e.jsx(Rr,{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 Rr({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 qs({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 kx=20,Sx=288,Cx=360,Tx=440;function Ax(){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 Ex({triggerRect:t,targetRect:s,viewportRect:n,compact:r,browserOpen:a=!1,portalAlign:i,cssZoom:l=1}){const c=Number.isFinite(l)&&l>0?l:1,d=8,m=n.top+d,p=n.bottom-d,u=n.left+d,h=n.right-d,f=Math.max(0,p-t.bottom-4),w=Math.max(0,t.top-m-4),g=r?w<140&&f>w:f>=220||f>=w,N=g?f:w,b=Math.max(140,p-m),k=r&&a,v=Math.min(b,k?Tx:320,Math.max(k?Cx:140,N)),S=Sx*c,A=i==="end"?t.right-S:t.left,E=(Math.max(u,Math.min(A,h-S))-s.left)/c;if(!g&&!k)return{left:E,bottom:(s.bottom-(t.top-4))/c,maxHeight:v/c};const B=g?t.bottom+4:t.top-v-4,M=Math.max(m,Math.min(B,p-v));return{left:E,top:(M-s.top)/c,maxHeight:v/c}}function Lr(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(Li(a)?a:Bi(t.workDir,a));return s}function Mx(t,s){if(t.kind==="global")return{nodeId:s.id,scope:{kind:"global"}};const n=Lr(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 Dx(t,s){return{nodeId:t,scope:s}}function uo(t,s,n){const r=s.trim();return!r||r==="."?t.workDir??r:n||Li(r)?r:t.workDir?Bi(t.workDir,r):r}function _x({node:t,scope:s,clusterNodes:n,onSelectionChange:r}){const a=o.useMemo(()=>Lx(n,t),[n,t]),i=o.useMemo(()=>Lr(t),[t]),l=o.useMemo(()=>a.map(c=>({value:c.id,label:c.name,description:`${c.role} · ${c.status}`,status:c.status})),[a]);return e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-2",children:[e.jsx(Rx,{ariaLabel:"Capability node",value:t.name,description:`${t.role} · ${t.status}`,options:l,selectedValue:t.id,onSelect:c=>{const d=a.find(m=>m.id===c);d&&r?.(Mx(s,d))}}),e.jsx(Ri,{node:t,projectPaths:i,selectedScope:s,onSelect:c=>r?.(Dx(t.id,c))}),e.jsx(Px,{node:t})]})}function Px({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:L("h-1.5 w-1.5 shrink-0 rounded-full",Cs(t.status))})]})}function Ri({node:t,projectPaths:s,selectedScope:n,onSelect:r,compact:a=!1,portal:i=!1,portalAlign:l="start"}){const[c,d]=o.useState(!1),[m,p]=o.useState(null),[u,h]=o.useState(!1),[f,w]=o.useState(!1),[g,N]=o.useState(null),[b,k]=o.useState(!1),[y,x]=o.useState(null),v=o.useRef(null),S=o.useRef(null),A=o.useRef(null),I=o.useMemo(()=>s.map($=>({value:$,label:ho($),description:$})),[s]),E=n.kind==="project"?n.projectPath:void 0,B=n.kind==="global"?"Global":ho(n.projectPath),M=n.kind==="global"?"Global":n.projectPath,D=o.useCallback(()=>!i||typeof document>"u"?null:S.current?.closest('[data-capability-share-dialog="true"]')??document.body,[i]),P=o.useCallback(()=>{if(!i||!S.current||typeof window>"u")return;const $=S.current.getBoundingClientRect(),X=D(),j=X&&X!==document.body?X.getBoundingClientRect():{left:0,top:0,bottom:window.innerHeight};x(Ex({triggerRect:$,targetRect:j,viewportRect:{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight},compact:a,browserOpen:b,portalAlign:l,cssZoom:Ax()}))},[b,a,D,i,l]);o.useEffect(()=>{c||k(!1)},[c]),o.useEffect(()=>{if(!c)return;const $=X=>{if(!(X.target instanceof Node))return;const j=X.composedPath(),W=v.current?j.includes(v.current):!1,T=A.current?j.includes(A.current):X.target instanceof Element&&!!X.target.closest('[data-capability-scope-menu="true"]');!W&&!T&&d(!1)};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[c]),o.useEffect(()=>{if(!(!c||!i))return P(),window.addEventListener("resize",P),window.addEventListener("scroll",P,!0),()=>{window.removeEventListener("resize",P),window.removeEventListener("scroll",P,!0)}},[c,i,P]);const O=async($,X=0,j=!1)=>{if(t.workDir){N(null),j?w(!0):h(!0);try{const W=await vo(t.id,{path:$||".",limit:kx,offset:X,directoriesOnly:!0,allowAbsolute:!0});p(T=>j&&T?{...W,entries:[...T.entries,...W.entries]}:W)}catch(W){N(W instanceof Error?W.message:"Failed to browse folders"),j||p(null)}finally{h(!1),w(!1)}}};o.useEffect(()=>{!c||!b||!t.workDir||(p(null),N(null),O(E||"."))},[b,c,t.id,t.workDir,E]);const Q=($,X=!1)=>{r({kind:"project",projectPath:uo(t,$,X)}),d(!1)},te=()=>{r({kind:"global"}),d(!1)},Y=m?uo(t,m.currentPath,m.isAbsolute):E??t.workDir??"",H=i?D():null,se=e.jsxs("div",{ref:A,"data-capability-scope-menu":"true","aria-hidden":!c,onClick:$=>$.stopPropagation(),onMouseDown:$=>$.stopPropagation(),onPointerDown:$=>$.stopPropagation(),style:i&&y?{left:y.left,top:y.top,bottom:y.bottom,height:a&&b?y.maxHeight:void 0,maxHeight:y.maxHeight}:void 0,className:L(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"),!c&&"hidden"),children:[e.jsxs("div",{className:"shrink-0 border-b border-border/55 p-1",children:[e.jsx("div",{className:L("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:L("overflow-y-auto pr-0.5",a?"max-h-32":"max-h-40"),children:[e.jsx(mo,{icon:"global",label:"Global",selected:n.kind==="global",onSelect:te,compact:a}),I.length>0?I.map($=>e.jsx(mo,{icon:"folder",label:$.label,description:$.description,selected:E===$.value,onSelect:()=>Q($.value,!0),compact:a},$.value)):e.jsx("div",{className:L("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:L("border-b border-border/55",b?"flex min-h-0 flex-1 flex-col":"shrink-0"),children:[e.jsxs("button",{type:"button","aria-expanded":b,onClick:()=>k($=>!$),className:L("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(us,{className:"h-2.5 w-2.5"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:"Browse folders"}),e.jsx(st,{className:L("h-3 w-3 shrink-0 transition-transform duration-200",b&&"rotate-180")})]}),b&&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 O(m.parentPath),disabled:!m?.parentPath||u,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(Oo,{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:Y,children:Y}),m&&e.jsx("button",{type:"button",onClick:()=>Q(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:L("min-h-0 flex-1 overflow-y-auto",a?"min-h-[8.25rem]":"max-h-56"),children:[t.workDir?u?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[9px] text-muted-foreground",children:[e.jsx(fe,{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(Ix,{entry:$,onSelect:()=>Q($.path,m.isAbsolute),onOpen:()=>{O($.path)}},$.path)),m.hasMore&&e.jsxs("button",{type:"button",onClick:()=>{O(m.currentPath,m.entries.length,!0)},disabled:f,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:[f?e.jsx(fe,{className:"h-3 w-3 animate-spin"}):e.jsx(Dd,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"px-3 py-4 text-center text-[9px] text-muted-foreground",children:g??"No subfolders."}):e.jsx("div",{className:"px-3 py-4 text-center text-[9px] text-muted-foreground",children:"This node has no working directory."}),g&&m&&m.entries.length>0&&e.jsx("div",{className:"border-t border-border/60 px-3 py-1.5 text-[9px] text-destructive",children:g})]})]})]})]});return e.jsxs("div",{ref:v,className:"relative min-w-0",children:[e.jsxs("button",{ref:S,type:"button","aria-label":"Capability location","aria-expanded":c,title:M,onClick:()=>d($=>($||(k(!1),P()),!$)),className:L("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:L("block truncate font-medium text-foreground",a?"text-[9px] leading-3":"text-[10px] leading-4"),children:B})}),e.jsx(st,{className:L(a?"h-2.5 w-2.5":"h-3 w-3","shrink-0 text-muted-foreground transition-transform",c&&"rotate-180")})]}),i&&H?Xs.createPortal(se,H):se]})}function mo({icon:t,label:s,description:n,selected:r,onSelect:a,compact:i=!1}){const l=t==="global"?Ad:us;return e.jsxs("button",{type:"button",onClick:a,className:L(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:L("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:L("block truncate text-muted-foreground",i?"text-[7px] leading-3":"text-[8px] leading-3"),children:n})]})]})}function Ix({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(us,{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(ut,{className:"h-3 w-3"})})]})}function Rx({ariaLabel:t,value:s,description:n,options:r,selectedValue:a,onSelect:i}){const[l,c]=o.useState(!1),d=o.useRef(null);return o.useEffect(()=>{if(!l)return;const m=p=>{d.current&&p.target instanceof Node&&!d.current.contains(p.target)&&c(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[l]),e.jsxs("div",{ref:d,className:"relative min-w-0",children:[e.jsxs("button",{type:"button","aria-label":t,"aria-expanded":l,title:n??s,onClick:()=>c(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(st,{className:L("h-3 w-3 shrink-0 text-muted-foreground transition-transform",l&&"rotate-180")})]}),e.jsx("div",{"aria-hidden":!l,className:L("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),c(!1)},className:L("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:L("h-1.5 w-1.5 shrink-0 rounded-full",Cs(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 Lx(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 Cs(t){return t==="online"?"bg-emerald-500":t==="offline"?"bg-muted-foreground/45":"bg-amber-500"}function ho(t){return t.split(/[\\/]+/).filter(Boolean).at(-1)??t}function Li(t){return t.startsWith("/")||/^[A-Za-z]:[\\/]/.test(t)}function Bi(t,s){return`${t.replace(/[\\/]+$/,"")}/${s.replace(/^[\\/]+/,"")}`}const Bx="h-6 w-24 rounded-sm px-2 text-[10px] shadow-none",Gn="text-[10px]",Oi=["claudecode","codex","copilot"],Ss={claudecode:"Claude Code",codex:"Codex",copilot:"Copilot"};function Ox({open:t,sourceNode:s,targetNodes:n,selectedCapabilities:r,previewResults:a=[],embedded:i=!1,onClose:l,onPreviewTargetsChange:c,onShare:d}){const[m,p]=o.useState(()=>new Set(a.length>0?a.map(j=>gt(j.nodeId,j.targetAgent)):zx(s.id,n,r))),[u,h]=o.useState(()=>Object.fromEntries(Ux(s.id,n,r))),[f,w]=o.useState({}),[g,N]=o.useState(!1),[b,k]=o.useState(()=>new Set),[y,x]=o.useState(()=>new Set),v=r.some(j=>j.kind==="plugin"),S=o.useMemo(()=>Br(r).map(j=>({key:gt(s.id,j),nodeId:s.id,node:s,label:`Install into ${Ss[j]}`,agentLabel:Ss[j],defaultScope:zi(r),disabled:!1,targetAgent:j})),[r,s]),A=o.useMemo(()=>n.flatMap(j=>{const W={kind:"global"},T=j.status==="offline",ee=Fi(r);return ee.length===0?[{key:gt(j.id),nodeId:j.id,node:j,label:j.name,defaultScope:W,disabled:T}]:ee.map(R=>({key:gt(j.id,R),nodeId:j.id,node:j,label:`${j.name} / ${Ss[R]}`,agentLabel:Ss[R],defaultScope:W,disabled:T,targetAgent:R}))}),[r,n]),I=o.useMemo(()=>[...S,...A],[S,A]),E=o.useMemo(()=>n.map(j=>({node:j,options:A.filter(W=>W.nodeId===j.id)})).filter(j=>j.options.length>0),[n,A]),B=o.useMemo(()=>new Map(a.filter(j=>j.capabilityId).map(j=>[fo(j.nodeId,j.capabilityId,j.targetAgent),j])),[a]),M=o.useMemo(()=>new Map(a.map(j=>[gt(j.nodeId,j.targetAgent),j])),[a]),D=o.useMemo(()=>I.filter(j=>m.has(j.key)),[m,I]),P=o.useMemo(()=>D.map(j=>({nodeId:j.nodeId,scope:u[j.key]??j.defaultScope,...j.targetAgent?{targetAgent:j.targetAgent}:{}})),[D,u]),O=o.useMemo(()=>{const j=[],W=new Map;for(const T of D){if(!W.has(T.nodeId)){const ee=T.nodeId===s.id?s:n.find(R=>R.id===T.nodeId);W.set(T.nodeId,{nodeId:T.nodeId,node:ee,name:ee?.name??T.nodeId,options:[]}),j.push(T.nodeId)}W.get(T.nodeId).options.push(T)}return j.map(T=>W.get(T))},[D,s,n]),Q=o.useMemo(()=>{const j=Array.from(new Set(r.map(T=>T.agent))),[W]=j;if(W)return j.length===1?Ss[W]:`${j.length} agents`},[r]),te=E.length+1;o.useEffect(()=>{let j=!1;const W={...u};for(const T of I)W[T.key]||(W[T.key]=T.defaultScope,j=!0);j&&h(W)},[I,u]),o.useEffect(()=>{t&&c?.(P)},[t,c,P]),o.useEffect(()=>{t&&(k(new Set),x(new Set))},[t,s.id]),o.useEffect(()=>{if(!i||!t)return;const j=W=>{W.key==="Escape"&&l()};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[i,l,t]);const Y=j=>{w(Object.fromEntries(D.map(W=>[W.key,j])))},H=async()=>{N(!0);try{await d(D.map(j=>({nodeId:j.nodeId,scope:u[j.key]??j.defaultScope,...j.targetAgent?{targetAgent:j.targetAgent}:{},conflictStrategy:f[j.key]??"overwrite"})))}finally{N(!1)}},se=j=>{const W=u[j.key]??j.defaultScope,T=`capability-share-target-${Fx(j.key)}`,ee=m.has(j.key);return e.jsxs("div",{"data-target-agent":j.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":j.disabled?"true":void 0,children:[e.jsx(Es,{id:T,disabled:j.disabled,checked:ee,onCheckedChange:R=>p(V=>{const F=new Set(V);return R===!0?F.add(j.key):F.delete(j.key),F}),"aria-label":`Select ${j.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:T,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":j.disabled?"true":void 0,children:j.agentLabel??j.label}),e.jsx("div",{className:"flex w-28 shrink-0 justify-end",children:ee&&!j.disabled&&e.jsx(Ri,{node:j.node,projectPaths:Lr(j.node),selectedScope:W,onSelect:R=>h(V=>({...V,[j.key]:R})),compact:!0,portal:!0,portalAlign:"end"})})]},j.key)},$=(j,W,T,ee)=>{const R=b.has(j.id),V=D.filter(F=>F.nodeId===j.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":R,onClick:()=>k(F=>xo(F,j.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(ut,{className:L("h-3 w-3 shrink-0 text-muted-foreground transition-transform duration-200",R&&"rotate-90")}),e.jsx("span",{className:L("h-1.5 w-1.5 shrink-0 rounded-full",Cs(j.status))}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-semibold text-foreground",title:j.name,children:j.name}),V>0&&e.jsxs("span",{className:"shrink-0 text-[8px] font-medium text-primary",children:[V," selected"]}),e.jsx("span",{className:"shrink-0 text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:W?"this node":"remote"}),j.status==="offline"&&e.jsx(Le,{variant:"outline",className:"rounded-sm px-1 py-0 text-[8px]",children:"offline"}),ee>0&&e.jsxs("span",{className:"sr-only",children:[ee," agents"]})]}),e.jsx("div",{className:L("grid transition-[grid-template-rows] duration-200 ease-out",R?"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:T})})})]},j.id)},X=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(Qs,{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:L("h-1.5 w-1.5 shrink-0 rounded-full",Cs(s.status))}),e.jsx("span",{className:"truncate font-semibold text-foreground",title:s.name,children:s.name}),Q&&e.jsxs("span",{className:"shrink-0 text-muted-foreground",children:["· ",Q]})]}),e.jsx(ea,{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:D.length})," selected · ",te," ",te===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,v?e.jsx("div",{className:"px-2 py-2 text-[10px] text-muted-foreground",children:"Cross-agent plugin installs are not supported."}):S.length===0?e.jsx("div",{className:"px-2 py-2 text-[10px] text-muted-foreground",children:"No alternate agents available for this selection."}):S.map(se),S.length),E.map(j=>$(j.node,!1,j.options.map(se),j.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(j=>e.jsx("button",{type:"button",onClick:()=>Y(j),className:"h-5 rounded-[3px] px-1.5 text-[9px] capitalize text-muted-foreground transition-colors hover:bg-muted/70 hover:text-foreground",children:j},j))})]})]}),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:D.length===0?e.jsx("div",{className:"py-8 text-center text-[11px] text-muted-foreground",children:"Select a target to preview conflicts."}):O.map(j=>{const W=!y.has(j.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":W,onClick:()=>x(T=>xo(T,j.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(ut,{className:L("h-3 w-3 shrink-0 text-muted-foreground transition-transform duration-200",W&&"rotate-90")}),j.node&&e.jsx("span",{className:L("h-1.5 w-1.5 shrink-0 rounded-full",Cs(j.node.status))}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[10px] font-semibold text-foreground",children:j.name}),e.jsxs("span",{className:"shrink-0 text-[8px] text-muted-foreground",children:[j.options.length," ",j.options.length===1?"agent":"agents"]})]}),e.jsx("div",{className:L("grid transition-[grid-template-rows] duration-200 ease-out",W?"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:j.options.map(T=>{const ee=f[T.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:T.agentLabel??"Matching agent"}),e.jsxs($e,{value:ee,onValueChange:R=>w(V=>({...V,[T.key]:R})),children:[e.jsx(qe,{className:Bx,children:e.jsx(Je,{})}),e.jsxs(He,{className:"shadow-none",children:[e.jsx(Oe,{value:"overwrite",className:Gn,children:"Overwrite"}),e.jsx(Oe,{value:"skip",className:Gn,children:"Skip"}),e.jsx(Oe,{value:"abort",className:Gn,children:"Abort"})]})]})]}),e.jsx("div",{className:"space-y-px",children:r.map(R=>{const V=B.get(fo(T.nodeId,R.id,T.targetAgent))??(r.length===1?M.get(T.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:R.name}),e.jsx("span",{className:V?.conflict?"text-amber-500":V?"text-emerald-500":"text-muted-foreground",children:V?V.conflict?`exists${V.currentVersion?` v${V.currentVersion}`:""}`:"new install":"checking"}),V?.sourceVersion&&e.jsxs("span",{className:"shrink-0 text-muted-foreground",children:[e.jsx(ea,{className:"inline h-2.5 w-2.5"})," v",V.sourceVersion]})]},R.id)})})]},T.key)})})})})]},j.nodeId)})})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 border-t border-border/55 px-4 py-3",children:[e.jsx(Z,{variant:"ghost",onClick:l,className:"h-7 rounded-sm px-3 text-[11px]",children:"Cancel"}),e.jsxs(Z,{onClick:H,disabled:g||D.length===0,className:"h-7 rounded-sm px-3 text-[11px]",children:[g?e.jsx(fe,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Qs,{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:j=>{j.target===j.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:j=>j.stopPropagation(),children:[X,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(dt,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})}):null:e.jsx(mt,{open:t,onOpenChange:j=>{j||l()},children:e.jsx(ht,{"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:X})})}function gt(t,s){return s?`agent:${t}:${s}`:`node:${t}`}function Fx(t){return t.replace(/[^a-zA-Z0-9_-]/g,"-")}function fo(t,s,n){return`${gt(t,n)}\0${s}`}function xo(t,s){const n=new Set(t);return n.has(s)?n.delete(s):n.add(s),n}function zx(t,s,n){const r=s.find(i=>i.status!=="offline");if(r)return[gt(r.id,$x(n))];const a=Br(n)[0];return a?[gt(t,a)]:[]}function Ux(t,s,n){const r=Fi(n);return[...s.flatMap(a=>r.length===0?[[gt(a.id),{kind:"global"}]]:r.map(i=>[gt(a.id,i),{kind:"global"}])),...Br(n).map(a=>[gt(t,a),zi(n)])]}function Fi(t){return t.length===0||t.some(s=>s.kind==="plugin")?[]:Oi}function $x(t){if(!(t.length===0||t.some(s=>s.kind==="plugin")))return t[0]?.agent}function Br(t){if(t.length===0||t.some(n=>n.kind==="plugin"))return[];const s=new Set(t.map(n=>n.agent));return Oi.filter(n=>!s.has(n))}function zi(t){return t[0]?.scope??{kind:"global"}}const po="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",Lt="py-0.5 pl-6 pr-1.5 text-[9px] leading-4 [&_svg]:h-3 [&_svg]:w-3",Ui="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",qx="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 Hx(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 Vx(t,s,n,r){return n.map(a=>({sourceNodeId:t,capabilityId:a.id,sourceScope:s,targets:r}))}function Kx({loading:t,onRefresh:s}){return e.jsxs(Z,{variant:"ghost",onClick:s,disabled:t,"aria-busy":t,className:L(Ui,"min-w-[4.5rem]"),children:[e.jsx(Ko,{className:L("h-2.5 w-2.5",t&&"animate-spin")}),t?"Refreshing":"Refresh"]})}function Gx({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(Z,{type:"button",variant:"ghost",onClick:n,disabled:t===0,className:Ui,children:[e.jsx(dt,{className:"h-2.5 w-2.5"}),"Selected: ",t," / Clear"]})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Kx,{loading:s,onRefresh:r}),e.jsxs(Z,{type:"button",variant:"ghost",onClick:a,disabled:t===0,className:qx,children:[e.jsx(Qs,{className:"h-2.5 w-2.5"}),"Share"]})]})]})}function Wx({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 Qx({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(fe,{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 Yx({open:t,node:s,scope:n,clusterNodes:r,onOpenChange:a,onSelectionChange:i}){const[l,c]=o.useState([]),[d,m]=o.useState([]),[p,u]=o.useState(!1),[h,f]=o.useState(""),[w,g]=o.useState("all"),[N,b]=o.useState("all"),[k,y]=o.useState(new Set),[x,v]=o.useState(null),[S,A]=o.useState(null),[I,E]=o.useState(!1),[B,M]=o.useState(null),[D,P]=o.useState(!1),[O,Q]=o.useState([]),[te,Y]=o.useState(Ii),[H,se]=o.useState(null),$=o.useMemo(()=>px(l,{search:h,agent:w,kind:N}),[w,l,N,h]),X=o.useMemo(()=>l.filter(K=>k.has(K.id)),[l,k]),j=o.useMemo(()=>r.filter(K=>K.id!==s.id),[r,s.id]),W=n.kind==="project"?n.projectPath:"global",T=async()=>{u(!0);try{const K=await jc(s.id,{scope:n});c(K.items),m((K.errors??[]).map(_=>`${_.agent}: ${_.message}`))}catch(K){m([K instanceof Error?K.message:"Failed to load capabilities"])}finally{u(!1)}};o.useEffect(()=>{t&&(y(new Set),v(null),A(null),E(!1),Q([]),c([]),m([]),T())},[t,s.id,n.kind,W]),o.useEffect(()=>{if(!H)return;const K=ne=>{Y(wx(H.startWidth,H.startClientX,ne.clientX,window.innerWidth))},_=()=>se(null);return window.addEventListener("pointermove",K),window.addEventListener("pointerup",_),()=>{window.removeEventListener("pointermove",K),window.removeEventListener("pointerup",_)}},[H]);const ee=K=>{K.preventDefault(),se({startClientX:K.clientX,startWidth:te})},R=()=>{se(null),E(!1),v(null),A(null)},V=()=>{y(new Set),Q([])},F=async K=>{v(K.id),E(!0),A(null);const _=await Nc(s.id,K.id,n);A(_.detail)},le=o.useCallback(async K=>{if(X.length===0||K.length===0){Q([]);return}Q([]);try{const _=Hx(s.id,n,X,K),ne=await Promise.all(_.map(q=>yc(q)));Q(ne.flatMap((q,ae)=>q.results.map(ye=>({...ye,capabilityId:_[ae]?.capabilityId}))))}catch{Q([])}},[s.id,n,X]),ie=()=>{Q([]),P(!0)},me=async K=>{const _=Vx(s.id,n,X,K);_.length!==0&&(await Promise.all(_.map(ne=>Sc(ne))),ce.success(`${_.length} capability share request${_.length===1?"":"s"} completed`),P(!1))},J=async()=>{if(!(!S||B)){M(S.id);try{const K=await kc(s.id,S.id,n);K.status==="deleted"?(ce.success(`Deleted ${S.name}`),c(_=>_.filter(ne=>ne.id!==S.id)),y(_=>{const ne=new Set(_);return ne.delete(S.id),ne}),v(null),A(null),E(!1),await T()):(ce.info(K.message??"Capability was not found"),v(null),A(null),E(!1),await T())}catch(K){ce.error(K instanceof Error?K.message:"Failed to delete capability")}finally{M(null)}}};return e.jsx(e.Fragment,{children:e.jsx(mt,{open:t,onOpenChange:a,children:e.jsxs(ht,{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(Et,{className:"border-b border-border/55 bg-card/28 px-4 py-2.5 text-left",children:[e.jsx(bt,{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(_x,{node:s,scope:n,clusterNodes:r,onSelectionChange:i}),e.jsxs(Mt,{"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(wo,{className:"pointer-events-none absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-muted-foreground"}),e.jsx(ct,{value:h,onChange:K=>f(K.target.value),placeholder:"Search capabilities",className:"h-7 rounded-sm border-0 bg-muted/55 pl-6 text-[10px] shadow-none"})]}),e.jsxs($e,{value:w,onValueChange:K=>g(K),children:[e.jsx(qe,{className:L("w-28",po),children:e.jsx(Je,{})}),e.jsxs(He,{className:"shadow-none",children:[e.jsx(Oe,{value:"all",className:Lt,children:"Agent: All"}),e.jsx(Oe,{value:"claudecode",className:Lt,children:"Claude Code"}),e.jsx(Oe,{value:"codex",className:Lt,children:"Codex"}),e.jsx(Oe,{value:"copilot",className:Lt,children:"Copilot"})]})]}),e.jsxs($e,{value:N,onValueChange:K=>b(K),children:[e.jsx(qe,{className:L("w-24",po),children:e.jsx(Je,{})}),e.jsxs(He,{className:"shadow-none",children:[e.jsx(Oe,{value:"all",className:Lt,children:"Kind: All"}),e.jsx(Oe,{value:"skill",className:Lt,children:"Skill"}),e.jsx(Oe,{value:"plugin",className:Lt,children:"Plugin"}),e.jsx(Oe,{value:"mcp",className:Lt,children:"MCP"})]})]})]}),d.length>0&&e.jsx("div",{className:"rounded-sm bg-amber-500/10 px-2 py-1 text-[10px] text-amber-600",children:d.join(" · ")}),e.jsx(gx,{items:$,selectedIds:k,activeId:x,onToggleSelected:(K,_)=>y(ne=>{const q=new Set(ne);return _?q.add(K):q.delete(K),q}),onOpenDetail:F}),e.jsx(Gx,{selectedCount:k.size,loading:p,onClearSelection:V,onRefresh:T,onShare:ie}),e.jsx(Qx,{visible:p&&l.length===0})]}),I&&e.jsxs(e.Fragment,{children:[e.jsx(Wx,{onBeginResize:ee,onFold:R}),e.jsx(yx,{detail:S,deleting:B===S?.id,desktopWidth:te,onDelete:S?J:void 0,pending:!S})]})]}),D&&e.jsx(Ox,{open:D,sourceNode:s,targetNodes:j,selectedCapabilities:X,previewResults:O,embedded:!0,onClose:()=>P(!1),onPreviewTargetsChange:le,onShare:me})]})})})}function Jx(t){const[s,n]=o.useState(null),r=o.useMemo(()=>s?t?.nodes.find(d=>d.id===s.nodeId)??(t?.self.id===s.nodeId?t.self:null)??null:null,[t,s]),a=o.useCallback(d=>{n({nodeId:d,scope:{kind:"global"}})},[]),i=o.useCallback((d,m)=>{n({nodeId:d,scope:{kind:"project",projectPath:m}})},[]),l=o.useCallback(d=>{n(d)},[]);return{capabilitiesDialog:s&&r&&t?e.jsx(Yx,{open:!0,node:r,scope:s.scope,clusterNodes:t.nodes,onOpenChange:d=>{d||n(null)},onSelectionChange:l}):null,openNodeCapabilities:a,openProjectCapabilities:i}}function Zx({activeTaskId:t,fetchTasks:s,navigateToNextVisibleTask:n,removeTasksFromList:r,setTask:a,setTasks:i}){const l=o.useCallback(u=>{i(h=>Cr(h,u)),a(h=>h?.id===u.id?{...h,...u}:h)},[a,i]),c=o.useCallback(async(u,h)=>{try{const f=await Qr(u.id,{title:h});l(f),ce.success("Task title updated"),s()}catch(f){ce.error(f instanceof Error?f.message:"Failed to update task title")}},[s,l]),d=o.useCallback(async(u,h)=>{try{const f=await Qr(u.id,{pinnedOnTop:h});l(f),ce.success(h?"Task pinned":"Task unpinned"),s()}catch(f){ce.error(f instanceof Error?f.message:"Failed to update task pin")}},[s,l]),m=o.useCallback(async u=>{try{const h=await Cc(u.id);l(h),t===u.id&&n([u.id]),ce.success("Task archived"),s()}catch(h){ce.error(h instanceof Error?h.message:"Failed to archive task")}},[t,s,n,l]),p=o.useCallback(async u=>{try{await Tc(u.id),r([u.id]),t===u.id&&n([u.id],!0),ce.success("Task deleted"),s()}catch(h){ce.error(h instanceof Error?h.message:"Failed to delete task")}},[t,s,n,r]);return{handleArchiveTask:m,handleDeleteTask:p,handleToggleTaskPinned:d,handleUpdateTaskTitle:c}}function Xx(){const{id:t}=Ac(),s=Ec(),n=Mc(),r=Dc(),{cluster:a,systemInfo:i,events:l,sseConnected:c,subscribe:d,refresh:m,loading:p,error:u}=_c(),h=o.useMemo(()=>Pc(s.state),[s.state]),[f,w]=o.useState(null),[g,N]=o.useState("active"),[b,k]=o.useState("all"),[y,x]=o.useState("all"),[v,S]=o.useState("all"),A=r?.headerSearchQuery??"",I=o.useDeferredValue(A),{desktopTasksOpen:E,mobileTasksPanelOpen:B,mobileTasksPanelRef:M,operationsOpen:D,operationsPanelRef:P,panelResize:O,setMobileTasksPanelOpen:Q,setOperationsOpen:te,toggleTasksPanel:Y}=Pf(),[H,se]=o.useState(()=>!!h?.draftNewTask),[$,X]=o.useState(()=>h?.createMode??"chat"),[j,W]=o.useState(()=>h?.createDefaults??null),[T,ee]=o.useState(()=>h?.draftNewTask?{route:h.returnRoute??"/",taskId:h.returnTaskId??null}:null),[R,V]=o.useState(!1),[F,le]=o.useState("transcript"),[ie,me]=o.useState("overview"),[J,K]=o.useState("all"),[_,ne]=o.useState(!1),[q,ae]=o.useState(null),[ye,xe]=o.useState([]),[Ze,Ae]=o.useState([]),[ft,Re]=o.useState(!1),[De,Ve]=o.useState(!1),[Ke,je]=o.useState(null),[Be,G]=o.useState(new Set),[ge,be]=o.useState(!1),[et,_e]=o.useState(!1),[nt,re]=o.useState(null),Ne=o.useRef(null),Te=o.useRef(new Map),ve=a?.self?.role==="leader",rt=a?.self?.id,{quickChats:Pe}=Ic();Wf({cluster:a,subscribe:d});const{nodeSettingsDialog:Dt,openNodeSettings:xt}=mx(ve),{capabilitiesDialog:hs,openNodeCapabilities:Xt,openProjectCapabilities:St}=Jx(a),{devBoxDialog:vt,devBoxNodeIds:fs,devBoxStartNodeId:xs,devBoxStartNodeIds:_t,devBoxStartingNodeIds:Bt,openDevBox:es,startDevBox:Ct}=ux({cluster:a,refresh:m}),{completedGroups:ts=[],fetchTasks:Fe,loadCompletedTasksPage:at,removeTasksFromList:wt,setTasks:Tt,tasks:U,tasksError:ze,tasksLoading:Ie}=Hf({isLeader:ve,selfId:rt,sseConnected:c,preservedTask:q,subscribe:d});o.useEffect(()=>Rc(()=>{me("events"),te(!0)}),[te]);const We=o.useMemo(()=>[...U].sort((C,z)=>z.updatedAt-C.updatedAt),[U]),Qe=o.useMemo(()=>[...U].sort((C,z)=>z.createdAt-C.createdAt||z.updatedAt-C.updatedAt)[0]?.id??null,[U]),ss=o.useMemo(()=>{const C=new Map;for(const z of a?.nodes??[]){const oe=wu(We,z.id);oe>0&&C.set(z.id,oe)}return C},[a?.nodes,We]),pe=o.useMemo(()=>We.filter(C=>!Lc(C,a?.nodes,a?.self)||!Bc(C,g)||b!=="all"&&C.agent!==b||!Oc(C,v)||y==="unassigned"&&C.assignedTo||y!=="all"&&y!=="unassigned"&&Fc(C.assignedTo,a?.nodes,C.assignedNodeName)!==y?!1:I.trim()?zc(C,I):!0),[We,a?.nodes,a?.self,g,b,v,y,I]);o.useEffect(()=>{G(C=>{const z=Cu(C,pe.map(oe=>oe.id));return z.size===C.size?C:z})},[pe]),o.useEffect(()=>{ve||G(new Set)},[ve]);const he=o.useMemo(()=>["all",...Array.from(new Set(We.map(C=>C.agent))).sort()],[We]),ke=o.useMemo(()=>{const z=Array.from(new Set(We.map(oe=>oe.assignedTo).filter(oe=>!!oe))).map(oe=>{const Me=We.find(we=>we.assignedTo===oe);return a?.nodes.find(we=>we.id===oe)??{id:oe,name:Qn(oe,a?.nodes,Me?.assignedNodeName)}}).sort((oe,Me)=>oe.name.localeCompare(Me.name));return[{value:"all",label:"All nodes"},{value:"unassigned",label:"Unassigned"},...z.map(oe=>({value:oe.name.toLowerCase(),label:oe.name}))]},[We,a?.nodes]),Ge=o.useMemo(()=>{const C=new Map;for(const z of a?.nodes??[])C.set(z.id,z.name);for(const z of We)z.assignedTo&&z.assignedNodeName&&!C.has(z.assignedTo)&&C.set(z.assignedTo,z.assignedNodeName);return C},[a?.nodes,We]),Ue=o.useMemo(()=>{const C=new Map;for(const z of a?.nodes??[])z.workDir&&C.set(z.id,z.workDir);return a?.self?.workDir&&C.set(a.self.id,a.self.workDir),C},[a]),Ot=o.useMemo(()=>{const C=new Map;for(const z of a?.nodes??[])C.set(z.id,z.status);return a?.self&&C.set(a.self.id,a.self.status),C},[a]),nn=o.useMemo(()=>{const C=new Map;for(const z of a?.nodes??[])C.set(z.id,z);return a?.self&&C.set(a.self.id,a.self),C},[a]),ps=o.useMemo(()=>new Map(ts.map(C=>[dr(C),C])),[ts]),Ee=o.useMemo(()=>{const C=new Map;for(const z of a?.nodes??[])z.status!=="offline"&&C.set(z.id,z);return a?.self&&a.self.status!=="offline"&&C.set(a.self.id,a.self),Array.from(C.values())},[a]),ns=a?.self?.id??Ee[0]?.id??null,Pt=o.useMemo(()=>l.filter(Uc),[l]),gs=o.useMemo(()=>["all",...Array.from(new Set(Pt.map(C=>C.type))).sort()],[Pt]),rn=o.useMemo(()=>J==="all"?Pt:Pt.filter(C=>C.type===J),[Pt,J]),an=pe.length>0&&pe.every(C=>Be.has(C.id)),ot=pe.some(C=>Be.has(C.id)),$i=Tu(pe,Be);o.useEffect(()=>{h?.draftNewTask&&(se(!0),X(h.createMode??"chat"),W(h.createDefaults??null),ee({route:h.returnRoute??"/",taskId:h.returnTaskId??null}))},[h]),o.useEffect(()=>{J!=="all"&&!gs.includes(J)&&K("all")},[J,gs]),o.useEffect(()=>{na(t,H)&&!f&&Qe&&w(Qe)},[t,H,f,Qe]),o.useEffect(()=>{na(t,H)&&(f&&U.some(C=>C.id===f)||w(Qe))},[t,H,f,Qe,U]);const Se=ju({routeTaskId:t,creatingTask:H,internalSelectedTaskId:f,sortedTaskIds:Qe?[Qe]:[]}),rs=o.useMemo(()=>U.find(C=>C.id===Se)??null,[U,Se]);o.useEffect(()=>{Ne.current=Se??null},[Se]);const It=o.useCallback(()=>{ae(null),xe([]),Ae([]),je(null),Ve(!1)},[]),bs=o.useCallback((C,z,oe=!0)=>{Te.current.set(C,{logs:Ir(z),loaded:oe})},[]),pt=o.useCallback(async()=>{const C=Se;if(C)try{const z=await $c(C);if(Ne.current!==C)return;ae(z),Tt(oe=>Cr(oe,z)),je(null)}catch(z){if(Ne.current!==C)return;It(),je(z instanceof Error?z.message:"Failed to load task")}finally{Ne.current===C&&Re(!1)}},[Se,It,Tt]),on=o.useCallback(async(C={})=>{const z=Se;if(z)try{const oe=await Zn(z,C.after,{minTotal:C.minTotal});if(Ne.current!==z)return;xe(Me=>{const we=Lo(Me,oe.logs);return bs(z,we),we}),Ae(Me=>er(Me,oe.logs))}catch{}finally{Ne.current===z&&Ve(!1)}},[Se,bs]);o.useEffect(()=>{if(!Se){It(),Re(!1);return}le("transcript"),ae(rs);const C=Vf(Se,Te.current);xe(C.logs),Ae([]),je(null),Re(!0),Ve(C.transcriptLoading),pt(),on()},[Se,It,on,pt]),o.useEffect(()=>{if(!Nu({activeTaskId:Se,routeTaskId:t,creatingTask:H,tasksLoading:Ie,loadedTaskIds:U.map(z=>z.id)}))return;const C=Qe;w(C),It(),o.startTransition(()=>{n(C?`/tasks/${C}`:"/",{state:null})})},[Se,It,H,Qe,n,t,U,Ie]),o.useEffect(()=>{rs&&ae(C=>!C||C.id!==rs.id?C:{...C,...rs})},[rs]),Yf({activeTaskId:Se,cacheTranscript:bs,fetchActiveLogs:on,fetchActiveTask:pt,logs:ye,setLogs:xe,setPendingMessages:Ae,setTranscriptLoading:Ve,sseConnected:c,subscribe:d});const de=q??rs,qi=de?.assignedTo?a?.nodes.find(C=>C.id===de.assignedTo)??null:null,vs=r?.setHeaderTaskContext;o.useEffect(()=>{if(!vs)return;if(!de){vs(null);return}const C=de.effectiveProjectPath??de.project??"default workspace";return vs({taskId:de.id,taskTitle:de.title,nodeName:Qn(de.assignedTo,a?.nodes,de.assignedNodeName),projectLabel:To(C),projectPath:C}),()=>vs(null)},[de,a?.nodes,vs]);const ln=Ze.length>0,Hi=de?qc.has(de.agent):!1,Is=de?.status==="running",Vi=de?Vs.has(de.status):!1,Ki=de?Vs.has(de.status)||Hc.has(de.status):!1,Gi=!!(de&&ve&&de.status==="failed"),cn=o.useMemo(()=>sf(de,a,ln,!!Is),[de,a,ln,Is]),dn=o.useMemo(()=>cd([...ye,...Ze.map(C=>pn(C.content,C.timestamp))]),[ye,Ze]),Rs=o.useMemo(()=>{if(!de||de.conversationKind==="nativeSession")return null;const C=dd(de);if(C.length>0)return pn(C,new Date(de.createdAt).toISOString());if(dn.length>0)return null;const z=ud(de.description||de.title);return z.length>0?pn(z,new Date(de.createdAt).toISOString()):null},[de,dn]),un=o.useMemo(()=>Rs?jr(Rs):null,[Rs]),Wi=o.useMemo(()=>un?md(ye,un):!1,[ye,un]),mn=o.useCallback((C="chat",z)=>{const oe={route:t?`/tasks/${t}`:"/",taskId:Se};ee(oe),X(C),W(z??null),se(!0),o.startTransition(()=>{n("/",{state:{draftNewTask:!0,returnRoute:oe.route,returnTaskId:oe.taskId,createMode:C,createDefaults:z}})})},[t,Se,n]),Qi=o.useCallback(()=>{const C=T?.taskId??Qe;se(!1),ee(null),W(null),w(C),o.startTransition(()=>{n(T?.route??"/",{state:null})})},[T,Qe,n]),Or=o.useCallback(C=>{se(!1),ee(null),W(null),w(C),o.startTransition(()=>{n(`/tasks/${C}`,{state:null})})},[n]),Yi=o.useCallback(C=>{Ne.current=C.id,se(!1),ee(null),W(null),Tt(z=>ku(z,C)),ae(C),xe([]),Ae([]),je(null),Re(!1),Ve(C.conversationKind==="nativeSession"),le("transcript"),w(C.id),Zf({task:C,getActiveTaskId:()=>Ne.current,setLogs:xe,setPendingMessages:Ae,setTranscriptLoading:Ve}),Fe(),o.startTransition(()=>{n(`/tasks/${C.id}`,{state:null})})},[Fe,n]),{cancelQueuedMessage:Ji,queueFollowUpMessage:Ls}=fx({activeTaskId:Se,fetchActiveTask:pt,isRunning:Is,setPendingMessages:Ae,setTask:ae,setTasks:Tt}),Zi=o.useCallback((C,z)=>{Ls(C,z)},[Ls]),Xi=o.useCallback(async()=>{const C=Se;if(!(!C||de?.conversationKind!=="nativeSession")){Ve(!0);try{const z=await Zn(C);if(Ne.current!==C)return;xe(z.logs),bs(C,z.logs),Ae(oe=>er(oe,z.logs))}catch(z){ce.error(z instanceof Error?z.message:"Failed to reload transcript")}finally{Ne.current===C&&Ve(!1)}}},[de?.conversationKind,Se,bs]),el=o.useCallback(C=>Ls(C),[Ls]),tl=o.useCallback(async()=>{if(de)try{await Vc(de.id),pt(),Fe()}catch(C){ce.error(C instanceof Error?C.message:"Failed to cancel task")}},[de,pt,Fe]),{handleShareTask:sl,handleStopShareTask:nl}=Ef(de,pt,Fe),rl=o.useCallback(async()=>{if(de)try{await Kc(de.id),pt(),Fe()}catch(C){ce.error(C instanceof Error?C.message:"Failed to retry task")}},[de,pt,Fe]),ws=o.useCallback((C,z=!1)=>{const oe=Au(pe,C);return w(oe),(z||!oe)&&It(),o.startTransition(()=>{n(oe?`/tasks/${oe}`:"/",{state:null})}),oe},[It,pe,n]),{handleArchiveTask:al,handleDeleteTask:ol,handleToggleTaskPinned:il,handleUpdateTaskTitle:ll}=Zx({activeTaskId:Se,fetchTasks:Fe,navigateToNextVisibleTask:ws,removeTasksFromList:wt,setTask:ae,setTasks:Tt}),cl=o.useCallback((C,z)=>{G(oe=>{const Me=new Set(oe);return z?Me.add(C):Me.delete(C),Me})},[]),dl=o.useCallback(C=>{if(!C){G(new Set);return}G(new Set(pe.map(z=>z.id)))},[pe]),ul=o.useCallback(async()=>{const C=Array.from(Be);if(C.length!==0)try{const{results:z}=await Gc(C),oe=z.filter(we=>!we.ok),Me=z.filter(we=>we.ok).map(we=>we.id);Se&&Me.includes(Se)&&ws(Me),oe.length>0?ce.error(`Failed to archive ${oe.length} task(s): ${oe.map(we=>we.error??we.id).join(", ")}`):ce.success(`Archived ${Me.length} task(s)`),G(new Set(oe.map(we=>we.id))),Fe()}catch(z){ce.error(z instanceof Error?z.message:"Failed to archive tasks")}},[Se,Fe,ws,Be]),ml=o.useCallback(async()=>{const C=Array.from(Be);if(C.length!==0)try{const{results:z}=await Wc(C),oe=z.filter(we=>!we.ok),Me=z.filter(we=>we.ok).map(we=>we.id);Me.length>0&&wt(Me),Se&&Me.includes(Se)&&ws(Me,!0),oe.length>0?ce.error(`Failed to delete ${oe.length} task(s): ${oe.map(we=>we.error??we.id).join(", ")}`):ce.success(`Deleted ${Me.length} task(s)`),G(new Set(oe.map(we=>we.id))),Fe()}catch(z){ce.error(z instanceof Error?z.message:"Failed to delete tasks")}},[Se,Fe,ws,wt,Be]),hl=o.useCallback(async()=>{be(!0);try{await Qc(),m()}catch(C){ce.error(C instanceof Error?C.message:"Failed to promote node")}finally{be(!1)}},[m]),fl=o.useCallback(async()=>{_e(!0);try{await Yc(),ce.success("This node left the remote cluster and is leading itself again."),Fe(),pt(),m()}catch(C){ce.error(C instanceof Error?C.message:"Failed to leave cluster")}finally{_e(!1)}},[pt,Fe,m]),xl=o.useCallback(async C=>{const z=!Sr(C),oe=C.id===a?.self?.id,Me=oe?i?.transportType??C.transportType:C.transportType,we=oe&&!z&&ms(Me);re(C.id);try{we?await Jc("direct"):await Zc(C.id,z),ce.success(z?`Enabled remote access on ${C.name}`:`Disabled remote access on ${C.name}`),m()}catch(zr){ce.error(zr instanceof Error?zr.message:"Failed to update remote access")}finally{re(null)}},[a?.self?.id,m,i?.transportType]),pl=o.useCallback(C=>{at&&at(C).catch(z=>{ce.error(z instanceof Error?z.message:"Failed to load completed tasks")})},[at]),Fr={toolbarTasks:pe,activeTaskId:Se,tasksLoading:Ie,tasksError:ze,isLeader:ve,scope:g,agentFilter:b,nodeFilter:y,taskKindFilter:v,agentOptions:he,nodeOptions:ke,nodeNameById:Ge,nodeWorkDirById:Ue,nodeStatusById:Ot,nodeInfoById:nn,leaderNodeId:a?.leader?.id??null,searchQuery:A,completedGroupByKey:ps,devBoxNodeIds:fs,devBoxStartNodeIds:_t,devBoxStartingNodeIds:Bt,selectedTaskIds:Be,allVisibleTasksSelected:an,someVisibleTasksSelected:ot,canBatchArchive:$i,onScopeChange:N,onAgentFilterChange:k,onNodeFilterChange:x,onTaskKindFilterChange:S,onToggleTaskSelected:cl,onToggleAllVisibleTasks:dl,onUpdateTaskTitle:ll,onDeleteTask:ol,onArchiveTask:al,onToggleTaskPinned:il,onBatchArchive:ul,onBatchDelete:ml,onCreateTask:mn,onOpenNodeSettings:ve?xt:void 0,onOpenNodeCapabilities:ve?Xt:void 0,onOpenProjectCapabilities:ve?St:void 0,onOpenDevBox:ve?es:void 0,onStartDevBox:ve?Ct:void 0,onLoadCompletedTasks:pl,onSelectTask:Or},gl={cluster:a,systemInfo:i,nodeNameById:Ge,nodeBlockingTaskCounts:ss,eventTypeFilter:J,onEventTypeFilterChange:K,activeTab:ie,onTabChange:me,eventTypeOptions:gs,filteredEvents:rn,sseConnected:c,clusterLoading:p,clusterError:u,promotePending:ge,onPromote:hl,onAddNode:()=>V(!0),leavePending:et,onLeaveCluster:fl,onToggleNodeDevTunnel:xl,devTunnelNodeId:nt,devBoxStartNodeId:xs,devBoxStartingNodeIds:Bt,onOpenNodeSettings:ve?xt:void 0,onOpenNodeCapabilities:ve?Xt:void 0,onOpenDevBox:ve?es:void 0,onStartDevBox:ve?Ct:void 0};return e.jsxs(e.Fragment,{children:[e.jsx(oh,{desktopTasksOpen:E,mobileTasksPanelOpen:B,mobileTasksPanelRef:M,operationsOpen:D,operationsPanelRef:P,panelResize:O,taskSidebar:e.jsx(eo,{...Fr}),operationsSidecar:e.jsx(ef,{...gl}),terminalPanel:r?.terminalOpen?e.jsx(fh,{nodes:Ee,defaultNodeId:ns,onClose:()=>r?.setTerminalOpen(!1)}):void 0,conversationPanel:e.jsx(Jm,{onToggleTasks:Y,desktopTasksOpen:E,mobileTasksPanelOpen:B,operationsOpen:D,onToggleOperations:()=>te(C=>!C),cluster:a,sseConnected:c,activeTab:F,setActiveTab:le,creatingTask:H,createMode:$,createDefaults:j,activeTask:de,assignedNode:qi,taskLoading:ft,transcriptLoading:De,taskError:Ke,displayEvents:dn,initialPromptAlreadyInLogs:Wi,initialPrompt:Rs,supportsFollowUp:Hi,taskUnavailable:cn.taskUnavailable,chatDisabled:cn.chatDisabled,chatDisabledReason:cn.chatDisabledReason,questionBypassEnabled:_,isRunning:!!Is,isStarting:Vi,hasPendingFollowUp:ln,canCancel:!!Ki,canRetry:!!Gi,onRetry:rl,onCancel:tl,onReloadNativeTranscript:Xi,onShareTask:sl,onStopShareTask:nl,onStartCreateTask:mn,onCancelCreateTask:Qi,onCreateTask:Yi,onSendMessage:Zi,onCancelQueuedMessage:Ji,onQuestionBypassChange:ne,onSubmitQuestionResponse:el,quickChats:Pe}),mobileTaskSidebar:e.jsx(eo,{...Fr,onCreateTask:(C,z)=>{Q(!1),mn(C,z)},onSelectTask:C=>{Q(!1),Or(C)}}),onCloseOperations:()=>te(!1),onCloseTaskList:()=>Q(!1),onToggleOperations:()=>te(C=>!C),onToggleTasks:Y}),e.jsx(th,{open:R,onOpenChange:V,onAdded:m}),Dt,vt,hs]})}const rp=Object.freeze(Object.defineProperty({__proto__:null,DashboardPage:Xx},Symbol.toStringTag,{value:"Module"}));export{Oo as A,rp as D,Gs as G};
|