meshy-node 0.9.9 → 0.10.1
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-BJhmjsGE.js +154 -0
- package/dashboard/assets/{DashboardShared-1UhBYL1-.js → DashboardShared-BvbuoP9b.js} +1 -1
- package/dashboard/assets/{DiffTab-BygUE807.js → DiffTab-Bd3CsYCX.js} +4 -4
- package/dashboard/assets/{FilesTab-C67Dnkts.js → FilesTab-Dr_X6U7n.js} +2 -2
- package/dashboard/assets/{MarkdownPreviewFrame-CH3rgET1.js → MarkdownPreviewFrame-xP27WQ5V.js} +1 -1
- package/dashboard/assets/{PreviewTab-C5m4cFxf.js → PreviewTab-DtBT527u.js} +2 -2
- package/dashboard/assets/{SharedConversationPage-CtQLabVf.js → SharedConversationPage-Cp-wV5Db.js} +2 -2
- package/dashboard/assets/{file-Ef280xPz.js → file-BoEYGA7g.js} +1 -1
- package/dashboard/assets/index-BZlZVBzf.js +346 -0
- package/dashboard/assets/index-z8uCUOPA.css +1 -0
- package/dashboard/index.html +2 -2
- package/main.cjs +589 -188
- package/package.json +1 -1
- package/runtime-metadata.json +4 -4
- package/dashboard/assets/DashboardPage-DbD4Z2U0.js +0 -154
- package/dashboard/assets/index-C7-ljTCx.js +0 -341
- package/dashboard/assets/index-CcOCgrkm.css +0 -1
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-Dr_X6U7n.js","assets/index-BZlZVBzf.js","assets/index-z8uCUOPA.css","assets/MarkdownPreviewFrame-xP27WQ5V.js","assets/DashboardShared-BvbuoP9b.js","assets/file-BoEYGA7g.js","assets/PreviewTab-DtBT527u.js","assets/DiffTab-Bd3CsYCX.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as ge,r as a,a as os,f as Sa,m as Ca,j as e,X as rt,Q as Fs,B as J,L as me,S as Ta,b as mo,d as A,e as xo,g as ho,h as po,I as at,P as fo,C as Vt,i as go,k as _a,F as bo,l as Mt,n as We,o as pe,D as qt,p as vo,q as jo,t as ie,s as Se,u as Ce,v as Le,w as Te,x as Ea,y as Qe,T as wo,z as yo,A as _n,E as No,G as Pt,H as Lt,J as Yt,K as Da,M as Aa,N as Tt,O as en,R as ko,U as vt,V as zs,W as So,Y as tn,Z as Ma,_ as Co,$ as $e,a0 as To,a1 as ot,a2 as is,a3 as ls,a4 as ds,a5 as cs,a6 as us,a7 as ms,a8 as xs,a9 as hs,aa as sn,ab as _o,ac as nn,ad as Pa,ae as Eo,af as En,ag as Dn,ah as Ms,ai as Do,aj as Ao,ak as Mo,al as Po,am as Lo,an as js,ao as Io,ap as La,aq as Oo,ar as Bo,as as Ro,at as Ia,au as an,av as Oa,aw as $o,ax as ps,ay as Fo,az as An,aA as rn,aB as zo,aC as on,aD as Ho,aE as Uo,aF as Vo,aG as Ba,aH as Kt,aI as qo,aJ as Hs,aK as Ra,aL as Ko,aM as Wo,aN as Go,aO as Yo,aP as Mn,aQ as Qo,aR as Zo,aS as Ps,aT as Xo,aU as Pn,aV as Jo,aW as ei,aX as ti,aY as Ln,aZ as si,a_ as ni,a$ as Us,b0 as ai,b1 as ri,b2 as $a,b3 as In,b4 as Fa,b5 as oi,b6 as ii,b7 as li,b8 as di,b9 as ci,ba as ui,bb as mi,bc as xi,bd as hi,be as pi,bf as fi,bg as gi,bh as bi,bi as vi,bj as ji,bk as wi,bl as yi,bm as Ni,bn as ki,bo as Si,bp as Ci,bq as Ti,br as _i,bs as Ei,bt as Di,bu as Ai,bv as Mi,bw as Pi,bx as Li,by as Ii,bz as Oi,bA as Bi,bB as Ri}from"./index-BZlZVBzf.js";import{r as On,e as $i,b as za,I as Ha,A as ln,g as Ua,a as Fi,c as zi,t as Hi,d as Bn,f as Rn,h as Ui,i as Vi,C as $n,T as Ls,D as Ct,j as nt,M as Vs,L as qi,m as Va,k as qs,l as Ki,n as Fn,o as Wi,p as Gi,q as Is,s as Yi,u as Qi,v as Zi}from"./DashboardShared-BvbuoP9b.js";import{E as Xi,M as Ji}from"./MarkdownPreviewFrame-xP27WQ5V.js";import{P as ws,D as ts,g as el,a as tl,b as sl}from"./PreviewTab-DtBT527u.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 nl=[["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"}]],al=ge("archive",nl);/**
|
|
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 rl=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],zn=ge("arrow-right",rl);/**
|
|
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 ol=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],qa=ge("arrow-up",ol);/**
|
|
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 il=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Wt=ge("chevron-left",il);/**
|
|
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 ll=[["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"}]],dl=ge("earth",ll);/**
|
|
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 cl=[["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"}]],ul=ge("ellipsis-vertical",cl);/**
|
|
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 ml=[["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"}]],xl=ge("ellipsis",ml);/**
|
|
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 hl=[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]],pl=ge("flag",hl);/**
|
|
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 fl=[["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"}]],ys=ge("folder-open",fl);/**
|
|
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 gl=[["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"}]],bl=ge("funnel",gl);/**
|
|
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 vl=[["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"}]],fs=ge("git-branch",vl);/**
|
|
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 jl=[["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"}]],wl=ge("globe",jl);/**
|
|
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 yl=[["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"}]],gs=ge("history",yl);/**
|
|
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 Nl=[["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"}]],Ks=ge("image-plus",Nl);/**
|
|
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 kl=[["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"}]],Sl=ge("laptop",kl);/**
|
|
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 Cl=[["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"}]],dn=ge("link-2",Cl);/**
|
|
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 Tl=[["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"}]],_l=ge("list-ordered",Tl);/**
|
|
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 El=[["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"}]],Ns=ge("message-square-plus",El);/**
|
|
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 Dl=[["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"}]],Ka=ge("monitor-play",Dl);/**
|
|
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 Al=[["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"}]],It=ge("pencil",Al);/**
|
|
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 Ml=[["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"}]],Pl=ge("rotate-ccw",Ml);/**
|
|
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 Ll=[["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"}]],Wa=ge("rotate-cw",Ll);/**
|
|
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 Il=[["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"}]],Ga=ge("send",Il);/**
|
|
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 Ol=[["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"}]],bs=ge("share-2",Ol);/**
|
|
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 Bl=[["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"}]],Rl=ge("sliders-horizontal",Bl);/**
|
|
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 $l=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Hn=ge("square",$l);/**
|
|
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 Fl=[["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"}]],zl=ge("user-plus",Fl);/**
|
|
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 Hl=[["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"}]],Ul=ge("wifi",Hl);/**
|
|
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 Vl=[["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"}]],ql=ge("zoom-in",Vl);/**
|
|
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 Kl=[["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"}]],Wl=ge("zoom-out",Kl),Gl=new Set(["assigned","running"]);function Yl(t,s){return t.reduce((n,r)=>r.assignedTo===s&&Gl.has(r.status)?n+1:n,0)}function Ot(t){return(t==null?void 0:t.toLowerCase())==="devtunnel"}function Ql(t){return t?Ot(t)?"DevTunnel":t.charAt(0).toUpperCase()+t.slice(1):"Direct"}function cn(t,s){return Ot(s??t.transportType)||!!t.devtunnelEndpoint}function Ya(t,s){return!Ot(s??t.transportType)}function Qa(t,s){const n=s??t.transportType;return Ot(n)?"DevTunnel":t.devtunnelEndpoint?"Direct + DevTunnel":Ql(n)}function Un(t,s){return!t&&!s}function Zl({routeTaskId:t,creatingTask:s,internalSelectedTaskId:n,sortedTaskIds:r}){return t||(s?null:r[0]??n??null)}function Xl({activeTaskId:t,routeTaskId:s,creatingTask:n,tasksLoading:r,loadedTaskIds:o}){return!t||s||n||r?!1:!o.includes(t)}function Jl(t,s){return[s,...t.filter(n=>n.id!==s.id)]}function Za(t,s){const n=t.findIndex(r=>r.id===s.id);return n===-1?[...t,s]:t.map((r,o)=>o===n?s:r)}const ed=new Set(["completed","failed","cancelled","archived"]);function td(t,s){const n=new Set(s);return new Set(Array.from(t).filter(r=>n.has(r)))}function sd(t,s){const n=new Set(s);if(n.size===0)return!1;const r=t.filter(o=>n.has(o.id));return r.length===n.size&&r.every(o=>ed.has(o.status))}function nd(t,s){var r;const n=new Set(s);return((r=t.find(o=>!n.has(o.id)))==null?void 0:r.id)??null}function Xa(){const[t,s]=a.useState([]),[n,r]=a.useState(null),o=a.useRef(null),i=a.useCallback(()=>{var y;(y=o.current)==null||y.click()},[]),d=a.useCallback(async y=>{const g=Array.from(y.target.files??[]);if(g.length!==0)try{const l=await On(g);s(N=>[...N,...l]),r(null)}catch(l){r(l instanceof Error?l.message:"Failed to attach image")}finally{y.target.value=""}},[]),c=a.useCallback(async y=>{const g=$i(y.clipboardData);if(g.length!==0){y.preventDefault();try{const l=await On(g);s(N=>[...N,...l]),r(null)}catch(l){r(l instanceof Error?l.message:"Failed to attach image")}}},[]),f=a.useCallback(y=>{s(g=>g.filter((l,N)=>N!==y))},[]),h=a.useCallback(()=>{s([]),r(null)},[]);return{images:t,error:n,fileInputRef:o,pickImages:i,handleFileChange:d,handlePaste:c,removeImage:f,clearImages:h}}function ad(t){const s=t.map(o=>({...o,displayValue:rd(o)})),n=s.findIndex(o=>o.label.toLowerCase()==="working dir"),r=n>=0?n:0;return{primary:s[r],secondary:s.filter((o,i)=>i!==r)}}function rd(t){return t.label.toLowerCase()==="agent"?Ua(t.value):t.value}function Vn(t){switch(t.toLowerCase()){case"branch":return fs;case"node":return Ta;case"working dir":default:return ys}}function od({disabled:t=!1,running:s=!1,canStop:n=!1,hasContent:r=!1}){return s&&!r?{primaryAction:"stop",primaryDisabled:t||!n}:{primaryAction:"send",primaryDisabled:t||!r}}function id({contentLength:t,disabled:s=!1}){return t>0&&!s}function ld({onSend:t,disabled:s,disabledReason:n="Chat is waiting on the agent.",placeholder:r="Send a follow-up message...",contextItems:o=[],running:i=!1,onStop:d,quickChats:c=[]}){const[f,h]=a.useState(""),[y,g]=a.useState(0),[l,N]=a.useState(0),C=a.useRef(null),{images:v,error:D,fileInputRef:p,pickImages:S,handleFileChange:b,handlePaste:w,removeImage:j,clearImages:_}=Xa(),E=a.useCallback(()=>{C.current&&(C.current.style.height="auto")},[]),X=a.useCallback(()=>{C.current&&(C.current.style.height="auto",C.current.style.height=`${Math.min(C.current.scrollHeight,220)}px`)},[]);a.useEffect(()=>{g(0)},[f,c]);const M=a.useCallback(O=>{h(O.prompt);const Z=()=>{var P;(P=C.current)==null||P.focus(),X()};typeof requestAnimationFrame=="function"?requestAnimationFrame(Z):Z()},[X]),Q=a.useCallback(()=>{const O=os(f,c,y);if(O){M(O);return}const Z=za(f,v);id({contentLength:Z.length,disabled:s})&&(N(P=>P+1),t(Z),h(""),_(),E())},[f,v,s,t,_,E,c,y,M]),B=a.useCallback(O=>{const Z=Sa(f,c);if(Z.length>0&&(O.key==="ArrowDown"||O.key==="ArrowUp")){O.preventDefault(),g(P=>Ca(P,Z.length,O.key==="ArrowDown"?1:-1));return}if(O.key==="Enter"&&!O.shiftKey){O.preventDefault();const P=os(f,c,y);P?M(P):Q()}},[M,Q,c,y,f]),R=f.trim().length>0||v.length>0,V=od({disabled:s,running:i,canStop:i&&!!d,hasContent:R}),K=ad(o),ee=K.primary?Vn(K.primary.label):ys,se=i?R?"Enter queues this message for the next turn":d?"Task is running - type to queue, empty button stops task":"Task is running - type to queue a message":s?n:"Enter sends, Shift+Enter adds a line";return e.jsx("div",{"data-chat-input-shell":"true",className:"chat-input-shell animate-composer-settle w-full bg-background/35 px-2 pb-2 pt-0 sm:px-4 sm:pb-3",children:e.jsx("div",{"data-chat-input-column":"true",className:"mx-auto w-full max-w-[72rem]",children:e.jsxs("div",{"data-chat-input-card":"true",className:"chat-input-card overflow-hidden rounded-xl border border-border/65 bg-card/88 transition-[border-color,box-shadow] duration-200 focus-within:border-primary/50 focus-within:ring-2 focus-within:ring-primary/15 sm:rounded-xl",children:[e.jsx("input",{ref:p,type:"file",accept:"image/*",multiple:!0,onChange:b,className:"hidden"}),K.primary&&e.jsx("div",{"data-chat-input-primary-context":"true",className:"px-2.5 pt-1.5 sm:px-5 sm:pt-2",children:e.jsxs("div",{className:"-ml-1.5 inline-flex max-w-full items-center gap-1.5 rounded-sm bg-muted/45 px-1.5 py-0.5 shadow-[0_10px_28px_-18px_rgba(15,23,42,0.72)] sm:-ml-2 dark:shadow-[0_10px_28px_-18px_rgba(0,0,0,0.95)]",children:[e.jsx(ee,{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:K.primary.value,children:K.primary.displayValue})]})}),v.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:v.map((O,Z)=>e.jsxs("div",{className:"relative",children:[e.jsx(Ha,{image:O,alt:O.filename??`attachment ${Z+1}`,thumbnailClassName:"h-24 w-24 border border-border/70",imageClassName:"h-full w-full"}),e.jsx("button",{type:"button",onClick:()=>j(Z),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 ${O.filename??`image ${Z+1}`}`,children:e.jsx(rt,{className:"h-3 w-3"})})]},`${O.filename??"image"}-${Z}`))})}),e.jsx("div",{className:"px-2 pb-0 pt-1 sm:px-5 sm:pt-1.5",children:e.jsx("textarea",{ref:C,"data-chat-input-textarea":"true",value:f,onChange:O=>h(O.target.value),onKeyDown:B,onPaste:w,onInput:X,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(Fs,{query:f,quickChats:c,selectedIndex:y,onActiveIndexChange:g,onSelect:M}),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:[K.secondary.length>0?e.jsx("div",{"data-chat-input-secondary-context":"true",className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1 pb-0.5 text-[9px] leading-3 text-muted-foreground/72 sm:text-[9px]",children:K.secondary.map(O=>{const Z=Vn(O.label),P=O.label.toLowerCase()==="agent";return e.jsxs("span",{title:`${O.label}: ${O.value}`,className:"inline-flex min-w-0 max-w-[12rem] items-center gap-1 truncate",children:[P?e.jsx(ln,{agent:O.value,className:"h-2.5 w-2.5 shrink-0 text-primary/50"}):e.jsx(Z,{"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 ${O.mono?"font-mono":""}`,children:O.displayValue})]},`${O.label}:${O.value}`)})}):e.jsx("div",{className:"min-w-0 flex-1"}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs(J,{type:"button",variant:"ghost",onClick:S,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(Ks,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Images"})]}),e.jsx("span",{title:se,children:e.jsx(J,{onClick:V.primaryAction==="stop"?d:Q,disabled:V.primaryDisabled,size:"icon","data-chat-send-button":"true","aria-label":V.primaryAction==="stop"?"Stop running task":i?"Queue message":"Send message",className:"chat-send-button h-7 w-9 shrink-0 rounded-sm bg-primary/90 text-primary-foreground shadow-[0_12px_30px_-18px_hsl(var(--primary)/0.95)] transition-transform duration-150 hover:bg-primary active:scale-95",children:V.primaryAction==="stop"?e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Ga,{className:`h-3.5 w-3.5 ${l>0?"animate-chat-send-flight":""}`},l)})})]})]}),D&&e.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-2 py-2 text-[11px] text-destructive sm:px-6 sm:py-3",children:D})]})})})}var dd=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],cd=dd.reduce((t,s)=>{const n=mo(`Primitive.${s}`),r=a.forwardRef((o,i)=>{const{asChild:d,...c}=o,f=d?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(f,{...c,ref:i})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{}),ud="Label",Ja=a.forwardRef((t,s)=>e.jsx(cd.label,{...t,ref:s,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=t.onMouseDown)==null||o.call(t,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));Ja.displayName=ud;var er=Ja;const md=xo("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Re=a.forwardRef(({className:t,...s},n)=>e.jsx(er,{ref:n,className:A(md(),t),...s}));Re.displayName=er.displayName;function xd(t,s,n){return t!=="auto"?s.find(r=>r.id===t)??null:n.length===1?n[0]??null:null}function hd(t){return t.trim()||"."}function pd(t){return new Promise(s=>window.setTimeout(s,t))}function fd(t){return!!t&&typeof t=="object"&&typeof t.createdBranch=="string"&&typeof t.currentBranch<"u"}async function gd(t){let s=t;for(let n=0;n<60;n++){if(s.status==="succeeded"){if(fd(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 pd(1e3),s=await go(s.id)}throw new Error("Timed out waiting for branch creation")}function qn({value:t,onChange:s,project:n,assignTo:r,nodes:o,assignableNodes:i,layout:d="default",chipClassName:c,chipActiveClassName:f,chipInactiveClassName:h,labelClassName:y,triggerClassName:g}){const[l,N]=a.useState(!1),[C,v]=a.useState(null),[D,p]=a.useState(""),[S,b]=a.useState(!1),[w,j]=a.useState(!1),[_,E]=a.useState(!1),[X,M]=a.useState(null),[Q,B]=a.useState(""),[R,ne]=a.useState(""),[V,K]=a.useState(""),[ee,se]=a.useState(!1),O=a.useRef(null),Z=a.useRef(0),P=a.useMemo(()=>xd(r,o,i),[r,o,i]),W=P==null?void 0:P.id,x=a.useMemo(()=>hd(n),[n]),H=a.useMemo(()=>W?`${W}
|
|
153
|
+
${x}`:"",[W,x]),u=a.useCallback(async(G=0,F=!1)=>{const te=Z.current+1,ce=H;if(Z.current=te,!W){v(null),p("");return}M(null),F||p(""),F?j(!0):b(!0);try{const k=await ho(W,{path:x,limit:20,offset:G,allowAbsolute:!0});if(te!==Z.current)return;p(ce),v($=>F&&$?{...k,branches:[...$.branches,...k.branches]}:k)}catch(k){if(te!==Z.current)return;M(k instanceof Error?k.message:"Failed to load branch info"),F||(v(null),p(""))}finally{te===Z.current&&(b(!1),j(!1))}},[W,H,x]);a.useEffect(()=>{if(!W){Z.current+=1,v(null),p(""),M(null);return}u()},[W,x,u]),a.useEffect(()=>{const G=t.trim(),F=D===H?C:null,te=F!=null&&F.available&&F.currentBranch?F.currentBranch:"";G!==te&&s(te)},[C,H,D,s,t]),a.useEffect(()=>{if(!l)return;const G=te=>{O.current&&(O.current.contains(te.target)||N(!1))},F=te=>{te.key==="Escape"&&N(!1)};return document.addEventListener("mousedown",G),document.addEventListener("keydown",F),()=>{document.removeEventListener("mousedown",G),document.removeEventListener("keydown",F)}},[l]),a.useEffect(()=>{l&&(ne(""),K(""),se(!1))},[l,W,x]);const q=a.useCallback(async()=>{if(!W)return;const G=Q.trim(),F=ee?V.trim():R.trim();if(!(!G||!F)){E(!0),M(null);try{const te=await po(W,{path:x,branchName:G,startPoint:F,limit:20,offset:0,allowAbsolute:!0}),ce=await gd(te);p(H),v(ce),s(ce.currentBranch??ce.createdBranch),B(""),ne(""),K(""),se(!1),N(!1)}catch(te){M(te instanceof Error?te.message:"Failed to create branch")}finally{E(!1)}}},[W,H,x,ee,V,Q,s,R]),T=D===H?C:null,U=a.useCallback(()=>{T!=null&&T.hasMore&&u(T.branches.length,!0)},[T,u]),L=t.trim()||(T==null?void 0:T.currentBranch)||(T&&!T.available?"No git repo":"Branch"),le=ee?V.trim():R.trim(),oe=!!(T!=null&&T.available&&Q.trim()&&le&&!_),de=d==="composer"?e.jsxs(J,{type:"button",variant:"ghost",onClick:()=>N(G=>!G),title:L,"aria-label":`Branch: ${L}`,className:A(c,g,"min-w-0 max-w-full",t.trim()?f:h),children:[S&&!T?e.jsx(me,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(fs,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:A("min-w-0 truncate",y),children:L})]}):e.jsxs(J,{type:"button",variant:"outline",onClick:()=>N(G=>!G),className:"h-7 w-full justify-between rounded-sm border-border/70 bg-background/70 px-2.5 text-[11px] shadow-none",title:L,children:[e.jsx("span",{className:A("truncate",t.trim()?"font-mono text-foreground":"text-muted-foreground"),children:L}),e.jsx("span",{className:"ml-2 shrink-0 text-[10px] text-muted-foreground",children:P?P.name:"Manual"})]});return e.jsxs("div",{className:A("relative inline-block",d==="composer"?"min-w-0 shrink-0":"w-full"),ref:O,children:[d==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{className:"text-[10px] font-medium",children:"Branch"}),de]}):de,l&&e.jsxs("div",{className:A("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",d==="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(fs,{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:T!=null&&T.repoRoot?`${T.currentBranch??L} · ${T.repoRoot}`:(T==null?void 0:T.currentBranch)??L,children:(T==null?void 0:T.currentBranch)??L}),S?e.jsx(me,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground"}):null]}),P?S&&!T?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(me,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):T&&!T.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(at,{value:Q,onChange:G=>B(G.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(J,{type:"button",size:"sm",onClick:()=>void q(),disabled:!oe,title:oe?"Create branch":"Enter a name and pick a base","aria-label":"Create branch",className:"h-8 w-8 shrink-0 rounded-sm p-0",children:_?e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(fo,{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"}),!ee&&e.jsxs("button",{type:"button",onClick:()=>se(!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(It,{className:"h-2.5 w-2.5"}),"Manual"]})]}),ee?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(at,{value:V,onChange:G=>K(G.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:()=>{se(!1),K("")},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(rt,{className:"h-3.5 w-3.5"})})]}):T!=null&&T.branches.length?e.jsxs("div",{className:"max-h-44 overflow-y-auto rounded-sm border border-border/40 bg-background/40",children:[T.branches.map(G=>{const F=R===G.ref,te=G.branch==="main"||G.branch==="master";return e.jsxs("button",{type:"button",onClick:()=>ne(G.ref),className:A("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",F&&"bg-background/70"),title:G.ref,children:[e.jsx("span",{className:A("shrink-0 text-[10px]",te?"text-amber-500 dark:text-amber-400":"text-muted-foreground/60"),"aria-hidden":!0,children:te?"★":"·"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-foreground",children:G.ref}),F?e.jsx(Vt,{className:"h-3 w-3 shrink-0 text-primary"}):null]},G.ref)}),T.hasMore&&e.jsxs("button",{type:"button",onClick:U,disabled:w,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:[w?e.jsx(me,{className:"h-3 w-3 animate-spin"}):e.jsx(gs,{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."}),X&&e.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-3 py-1.5 text-[11px] text-destructive",children:X})]})]})}const bd=20,vd=3,Ws="meshy-working-dir-recents-by-node";function jd(t){return t.startsWith("/")||t.startsWith("\\\\")||/^[A-Za-z]:[\\/]/.test(t)}function wd(t){const s=t.trim();return s||"."}function Gs(t){const s=[],n=new Set;for(const r of t){const o=r.trim();if(!(!o||n.has(o))&&(n.add(o),s.push(o),s.length===vd))break}return s}function yd(t,s){const n=s.trim();return Gs(n?[n,...t]:t)}function tr(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 o=r.filter(d=>typeof d=="string"),i=Gs(o);i.length>0&&(s[n]=i)}return s}function Nd(t,s,n){if(!s)return t;const r=t[s]??[],o=yd(r,n);if(o.length===0){if(!(s in t))return t;const{[s]:i,...d}=t;return d}return{...t,[s]:o}}function kd(t,s){var n;return s?((n=t[s])==null?void 0:n[0])??"":""}function sr(t){if(!t||typeof window>"u")return"";try{const s=window.localStorage.getItem(Ws);return s?kd(tr(JSON.parse(s)),t):""}catch{return""}}function Sd(t,s,n){return t!=="auto"?s.find(r=>r.id===t)??null:n.length===1?n[0]??null:null}function Cd(t,s){const n=s.trim();return n?jd(n)||!t?n:`${t.replace(/[/\\]+$/,"")}/${n}`:""}function Td(t,s){return t?t.isAbsolute?t.currentPath:t.currentPath==="."||t.currentPath===""?t.rootPath||(s==null?void 0:s.workDir)||"Node root":t.currentPath:(s==null?void 0:s.workDir)??"Node root"}function vs({value:t,onChange:s,assignTo:n,nodes:r,assignableNodes:o,layout:i="default",chipClassName:d,chipActiveClassName:c,chipInactiveClassName:f,labelClassName:h,triggerClassName:y,popoverPlacement:g="bottom",popoverAlign:l="start"}){const[N,C]=a.useState(!1),[v,D]=a.useState(null),[p,S]=a.useState(!1),[b,w]=a.useState(!1),[j,_]=a.useState(null),[E,X]=a.useState(""),[M,Q]=a.useState(!1),[B,R]=a.useState({}),ne=a.useRef(null),V=a.useMemo(()=>Sd(n,r,o),[n,r,o]),K=V==null?void 0:V.id,ee=a.useMemo(()=>K?B[K]??[]:[],[B,K]),se=a.useMemo(()=>t.trim()?Cd(V==null?void 0:V.workDir,t):"Use node default",[t,V==null?void 0:V.workDir]);a.useEffect(()=>{if(!(typeof window>"u"))try{const L=window.localStorage.getItem(Ws);if(!L)return;const le=JSON.parse(L);R(tr(le))}catch{}},[]);const O=a.useCallback(L=>{K&&R(le=>{const oe=Nd(le,K,L);if(oe===le)return le;if(typeof window<"u")try{window.localStorage.setItem(Ws,JSON.stringify(oe))}catch{}return oe})},[K]),Z=a.useCallback((L,le=!0)=>{const oe=L.trim();s(oe),le&&oe&&O(oe),C(!1)},[s,O]),P=a.useCallback(async(L,le=0,oe=!1)=>{if(K){_(null),oe?w(!0):S(!0);try{const de=await _a(K,{path:L,limit:bd,offset:le,directoriesOnly:!0,allowAbsolute:!0});D(G=>oe&&G?{...de,entries:[...G.entries,...de.entries]}:de)}catch(de){_(de instanceof Error?de.message:"Failed to browse directories"),oe||D(null)}finally{S(!1),w(!1)}}},[K]),W=a.useRef(t);W.current=t;const x=a.useRef(P);x.current=P,a.useEffect(()=>{if(!N)return;const L=W.current;X(L),Q(!1),D(null),_(null),K&&x.current(wd(L))},[N,K]),a.useEffect(()=>{if(!N)return;const L=oe=>{ne.current&&(ne.current.contains(oe.target)||C(!1))},le=oe=>{oe.key==="Escape"&&C(!1)};return document.addEventListener("mousedown",L),document.addEventListener("keydown",le),()=>{document.removeEventListener("mousedown",L),document.removeEventListener("keydown",le)}},[N]);const H=a.useCallback(L=>{P(L)},[P]),u=a.useCallback(()=>{v&&P(v.currentPath,v.entries.length,!0)},[v,P]),q=i==="composer"?e.jsxs(J,{type:"button",variant:"ghost",onClick:()=>C(L=>!L),title:se,"aria-label":`Working directory: ${se}`,className:A(d,y,"min-w-0 max-w-full",t.trim()?c:f),children:[e.jsx(bo,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:A("min-w-0 truncate",h),children:se})]}):e.jsxs(J,{type:"button",variant:"outline",onClick:()=>C(L=>!L),className:"h-7 w-full justify-between rounded-sm border-border/70 bg-background/70 px-2.5 text-[11px] shadow-none",title:se,children:[e.jsx("span",{className:A("truncate",t.trim()?"font-mono text-foreground":"text-muted-foreground"),children:se}),e.jsx("span",{className:"ml-2 shrink-0 text-[10px] text-muted-foreground",children:V?V.name:"Manual"})]}),T=Td(v,V),U=!!(v!=null&&v.parentPath);return e.jsxs("div",{className:A("relative inline-block",i==="composer"?"min-w-0 max-w-[60%] shrink":"w-full"),"data-workdir-popover-placement":g,"data-workdir-popover-align":l,ref:ne,children:[i==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{className:"text-[10px] font-medium",children:"Working directory"}),q]}):q,N&&e.jsxs("div",{className:A("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",g==="top"?"bottom-full mb-2":"top-full mt-2",i==="composer"?l==="end"?"right-0":"left-0":l==="end"?"right-0 w-auto min-w-[240px]":"left-0 right-0 w-auto min-w-[240px]"),children:[ee.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(gs,{className:"h-2.5 w-2.5"}),"Recent"]}),e.jsx("div",{className:"flex flex-col",children:ee.map(L=>e.jsx("button",{type:"button",onClick:()=>Z(L),className:"truncate rounded-sm px-1.5 py-0.5 text-left font-mono text-[11px] text-foreground hover:bg-background/60",title:L,children:L},L))})]}),e.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/60 px-2.5 py-1.5",children:[e.jsx("button",{type:"button",onClick:()=>(v==null?void 0:v.parentPath)&&H(v.parentPath),disabled:!U||p,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(qa,{className:"h-3 w-3"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground",title:T,children:T}),v&&e.jsx("button",{type:"button",onClick:()=>Z(v.isAbsolute?v.currentPath:v.currentPath==="."?"":v.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:[V?p?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(me,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):v&&v.entries.length>0?e.jsxs(e.Fragment,{children:[v.entries.map(L=>e.jsxs("div",{className:"group flex items-stretch border-b border-border/30 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>Z(L.path),className:"flex min-w-0 flex-1 items-center gap-2 px-2.5 py-1.5 text-left hover:bg-background/55",title:`Use ${L.path}`,children:[e.jsx(Mt,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-[11px] text-foreground",children:L.name})]}),e.jsx("button",{type:"button",onClick:()=>H(L.path),className:"flex w-9 shrink-0 items-center justify-center border-l border-border/30 text-muted-foreground hover:bg-background/70 hover:text-foreground",title:"Open subfolder","aria-label":`Open ${L.name}`,children:e.jsx(We,{className:"h-3.5 w-3.5"})})]},L.path)),v.hasMore&&e.jsxs("button",{type:"button",onClick:u,disabled:b,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:[b?e.jsx(me,{className:"h-3 w-3 animate-spin"}):e.jsx(gs,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:j??"No subfolders."}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Select a node to browse."}),j&&v&&v.entries.length>0&&e.jsx("div",{className:"border-t border-border/60 px-3 py-1.5 text-[11px] text-destructive",children:j})]}),e.jsx("div",{className:"flex items-center gap-1 border-t border-border/60 bg-background/40 px-2.5 py-1.5",children:M?e.jsxs(e.Fragment,{children:[e.jsx(at,{value:E,onChange:L=>X(L.target.value),onKeyDown:L=>{L.key==="Enter"&&E.trim()?(L.preventDefault(),Z(E)):L.key==="Escape"&&(L.preventDefault(),Q(!1),X(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:()=>Z(E),disabled:!E.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(Vt,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{Q(!1),X(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(rt,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>{X(t),Q(!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(It,{className:"h-3 w-3"})]})})]})]})}function nr(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 un({isCurrent:t}){return t?e.jsx(Sl,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500 dark:text-emerald-400","aria-label":"current node"}):e.jsx(wl,{className:"h-3.5 w-3.5 shrink-0 text-sky-500 dark:text-sky-400","aria-label":"remote follower node"})}function Ys(t,s){return t.map(n=>{const r=!!s&&n.id===s;return e.jsx(pe,{value:n.id,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(un,{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 _d(t){var r;const s=t.sessionId.trim(),n=t.cwd.trim();return!s||!n||!t.assignTo?null:{title:t.title.trim()||((r=t.defaultTitle)==null?void 0:r.trim())||void 0,agent:t.agent,sessionId:s,cwd:n,assignTo:t.assignTo,priority:t.priority,mode:t.mode??qt}}function Ed(){return wo.map(t=>e.jsx(pe,{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 Dd(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 Kn(t){if(!t.updatedAt)return 0;const s=Date.parse(t.updatedAt);return Number.isNaN(s)?0:s}function Ad(t,s){return Kn(s)-Kn(t)||t.sessionId.localeCompare(s.sessionId)}function Md(t){const s=t.trim().replace(/[\\/]+$/,"");return s?s.split(/[\\/]+/).filter(Boolean).at(-1)??s:"Unknown project"}function Pd(t){const s=new Map;for(const n of[...t].sort(Ad)){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:Md(n),cwd:n,sessions:r}))}function Ld(t,s){const n=new Set(t);return n.has(s)?n.delete(s):n.add(s),n}function Id({nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:r,onCreated:o,onCancel:i,className:d,footerClassName:c,submitLabel:f="Load session",cancelLabel:h="Cancel",autoFocus:y=!1}){const g=a.useMemo(()=>nr(t,{currentNodeRole:s,leaderNodeId:r}),[t,s,r]),l=a.useMemo(()=>{var k;return n&&g.some($=>$.id===n)?n:((k=g[0])==null?void 0:k.id)??""},[g,n]),[N,C]=a.useState(""),[v,D]=a.useState("codex"),[p,S]=a.useState(""),[b,w]=a.useState(""),[j,_]=a.useState(""),[E,X]=a.useState(l),[M,Q]=a.useState("normal"),[B,R]=a.useState(qt),[ne,V]=a.useState(!1),[K,ee]=a.useState([]),[se,O]=a.useState(!1),[Z,P]=a.useState(null),W=a.useMemo(()=>K.find(k=>k.sessionId===p)??null,[K,p]);a.useEffect(()=>{E&&g.some(k=>k.id===E)||X(l)},[E,g,l]),a.useEffect(()=>{S(""),w(""),_("")},[v,E]),a.useEffect(()=>{let k=!1;return E?(O(!0),P(null),vo(E,{agent:v,limit:50}).then($=>{k||ee($.sessions)}).catch($=>{k||(ee([]),P($ instanceof Error?$.message:"Failed to load native sessions"))}).finally(()=>{k||O(!1)}),()=>{k=!0}):(ee([]),P(null),O(!1),()=>{k=!0})},[v,E]),a.useEffect(()=>{W&&(w(W.sessionId),_(W.cwd))},[W]);const x=a.useCallback(async k=>{k.preventDefault();const $=_d({title:N,defaultTitle:W==null?void 0:W.summary,agent:v,sessionId:b,cwd:j,assignTo:E,priority:M,mode:B});if($){V(!0);try{const ue=await jo($);o(ue)}catch(ue){ie.error(ue instanceof Error?ue.message:"Failed to load native session")}finally{V(!1)}}},[N,W,v,b,j,E,M,B,o]),H=!!(b.trim()&&j.trim()&&E),[u,q]=a.useState(!1),[T,U]=a.useState(""),[L,le]=a.useState(()=>new Set),oe=g.find(k=>k.id===E)??null,de=!!(n&&(oe==null?void 0:oe.id)===n),G=a.useMemo(()=>{const k=T.trim().toLowerCase();return k?K.filter($=>$.summary.toLowerCase().includes(k)||$.sessionId.toLowerCase().includes(k)||$.cwd.toLowerCase().includes(k)):K},[K,T]),F=a.useMemo(()=>Pd(G),[G]),te=a.useCallback(k=>{le($=>Ld($,k))},[]),ce="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:x,className:A("space-y-4",d),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(Se,{value:E,onValueChange:X,children:[e.jsx(Ce,{className:A(ce),"aria-label":"Node",children:oe?e.jsxs(e.Fragment,{children:[e.jsx(un,{isCurrent:de}),e.jsx("span",{className:"max-w-[10rem] truncate",children:oe.name})]}):e.jsx(Le,{placeholder:"Node"})}),e.jsx(Te,{children:Ys(g,n)})]}),e.jsxs(Se,{value:v,onValueChange:k=>D(k),children:[e.jsxs(Ce,{className:A(ce),"aria-label":"Agent",children:[e.jsx(ln,{agent:v}),e.jsx("span",{children:v})]}),e.jsx(Te,{children:Fi()})]}),e.jsxs("div",{className:"relative ml-auto min-w-0 flex-1 sm:max-w-56",children:[e.jsx(Ea,{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(at,{value:T,onChange:k=>U(k.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(Re,{className:"text-[10px] font-medium uppercase tracking-[0.2em] text-muted-foreground",children:se?"Loading...":`${G.length} session${G.length===1?"":"s"}`})}),e.jsxs("div",{className:"relative h-88 overflow-hidden rounded-sm",children:[se&&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:[!E&&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."}),E&&!se&&G.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:K.length===0?"No recent sessions on this node. Use Manual session ID under More options.":"No sessions match your filter."}),F.map(k=>e.jsxs("section",{className:"space-y-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>te(k.cwd),"aria-expanded":!L.has(k.cwd),className:"sticky top-0 z-[1] flex w-full items-center gap-2 border-b border-border/50 bg-background/95 px-1 py-1.5 text-left text-[10px] text-muted-foreground backdrop-blur transition-colors hover:bg-background",children:[e.jsx(Qe,{className:A("h-3.5 w-3.5 shrink-0 transition-transform",L.has(k.cwd)&&"-rotate-90")}),e.jsx(ys,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate text-xs font-medium text-foreground",children:k.folderName}),e.jsxs("span",{className:"shrink-0 uppercase tracking-[0.16em]",children:[k.sessions.length," session",k.sessions.length===1?"":"s"]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-right font-mono",children:k.cwd})]}),!L.has(k.cwd)&&k.sessions.map($=>{const ue=$.sessionId===p;return e.jsxs("button",{type:"button",onClick:()=>S($.sessionId),className:A("flex w-full flex-col gap-1 rounded-sm border px-2.5 py-2 text-left transition-colors duration-200",ue?"border-primary/45 bg-primary/9 shadow-none":"border-border/55 bg-background/40 hover:border-border hover:bg-background/65"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:A("h-2 w-2 shrink-0 rounded-full",ue?"bg-primary":"bg-border")}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",children:$.summary}),e.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.16em] text-muted-foreground",children:Dd($.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:$.sessionId.slice(0,12)}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),e.jsx("span",{className:"truncate font-mono",children:$.cwd})]})]},$.sessionId)})]},k.cwd))]})]}),Z&&e.jsx("p",{className:"px-1 pt-2 text-[11px] text-destructive",children:Z})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:()=>q(k=>!k),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":u,children:[e.jsx("span",{className:"shrink-0",children:u?"Less options":"More options"}),e.jsx(Qe,{className:A("h-3.5 w-3.5 shrink-0 transition-transform",u&&"rotate-180")})]}),u&&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(Re,{htmlFor:"native-session-id",className:"text-[10px] font-medium text-muted-foreground",children:"Session ID"}),e.jsx(at,{id:"native-session-id",type:"text",value:b,onChange:k=>{S(""),w(k.target.value)},placeholder:"ses_..., thread_..., or UUID",autoFocus:y,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(Re,{htmlFor:"native-session-title",className:"text-[10px] font-medium text-muted-foreground",children:"Task title"}),e.jsx(at,{id:"native-session-title",type:"text",value:N,onChange:k=>C(k.target.value),placeholder:"Optional",className:"h-7 rounded-sm border-border/70 bg-background/70 text-[11px] shadow-none"})]})]}),e.jsx(vs,{value:j,onChange:k=>{S(""),_(k)},assignTo:E,nodes:t,assignableNodes:g}),e.jsxs("div",{className:"grid gap-2.5 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(Re,{className:"text-[10px] font-medium text-muted-foreground",children:"Mode"}),e.jsxs(Se,{value:B,onValueChange:k=>R(k),children:[e.jsx(Ce,{className:"h-7 rounded-sm border-border/70 bg-background/70 text-[11px] shadow-none",children:e.jsx(Le,{placeholder:"Select mode"})}),e.jsx(Te,{children:Ed()})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(Re,{className:"text-[10px] font-medium text-muted-foreground",children:"Priority"}),e.jsxs(Se,{value:M,onValueChange:Q,children:[e.jsx(Ce,{className:"h-7 rounded-sm border-border/70 bg-background/70 text-[11px] shadow-none",children:e.jsx(Le,{placeholder:"Select priority"})}),e.jsxs(Te,{children:[e.jsx(pe,{value:"low",children:"Low"}),e.jsx(pe,{value:"normal",children:"Normal"}),e.jsx(pe,{value:"high",children:"High"}),e.jsx(pe,{value:"critical",children:"Critical"})]})]})]})]})]})]}),e.jsxs("div",{className:A("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",c),children:[i&&e.jsx(J,{type:"button",variant:"ghost",onClick:i,className:"rounded-sm",children:h}),e.jsx(J,{type:"submit",disabled:!H||ne,className:"rounded-sm px-5",children:ne?e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"h-4 w-4 animate-spin"})," Loading..."]}):f})]})]})}function ar(t,s,n=!1){const r=t.trim();if(r)return r;const o=s.trim().split(`
|
|
154
|
+
`).map(i=>i.trim()).find(Boolean);return o?o.length>72?`${o.slice(0,69).trimEnd()}...`:o:n?"Image task":""}function Od(t){var d;const s=t.title.trim(),n=ar(t.title,t.description,t.images.length>0),r=t.description.trim()||n,o=t.mode??qt,i=za(t.description,t.images);return!n||!r||!t.agent?null:{title:n,description:r,agent:t.agent,project:t.project.trim()||null,branch:((d=t.branch)==null?void 0:d.trim())||null,payload:{initialMessage:i,mode:o,titleSource:s?"manual":"derived"},priority:t.priority,assignTo:t.assignTo==="auto"?void 0:t.assignTo}}function Bd({nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:r,initialAssignTo:o,initialProject:i,onCreated:d,onCancel:c,className:f,footerClassName:h,submitLabel:y="Create chat",cancelLabel:g="Cancel",autoFocus:l=!1,layout:N="default",quickChats:C=[]}){const[v,D]=a.useState(""),[p,S]=a.useState(""),[b,w]=a.useState(0),[j,_]=a.useState(_n),[E,X]=a.useState(qt),[M,Q]=a.useState((i==null?void 0:i.trim())??""),B=a.useRef(i!==void 0),[R,ne]=a.useState(""),[V,K]=a.useState("normal"),ee=a.useMemo(()=>nr(t,{currentNodeRole:s,leaderNodeId:r}),[t,s,r]),se=a.useMemo(()=>{var ae;return o&&ee.some(fe=>fe.id===o)?o:n&&ee.some(fe=>fe.id===n)?n:((ae=ee[0])==null?void 0:ae.id)??""},[ee,n,o]),[O,Z]=a.useState(se),[P,W]=a.useState(!1),[x,H]=a.useState(!1),{images:u,error:q,fileInputRef:T,pickImages:U,handleFileChange:L,handlePaste:le,removeImage:oe}=Xa(),de=a.useMemo(()=>ee.find(ae=>ae.id===O)??null,[O,ee]),G=!!(n&&(de==null?void 0:de.id)===n),F=Ua(j),te=zi(E);a.useEffect(()=>{O&&ee.some(ae=>ae.id===O)||Z(se)},[O,ee,se]),a.useEffect(()=>{if(B.current){B.current=!1;return}Q(sr(O)),ne("")},[O]),a.useEffect(()=>{ne("")},[M]),a.useEffect(()=>{w(0)},[p,C]);const ce=a.useCallback(ae=>{S(ae.prompt)},[]),k=a.useCallback(async ae=>{ae.preventDefault();const fe=os(p,C,b);if(fe){ce(fe);return}const ye=Od({title:v,description:p,agent:j,project:M,branch:R,priority:V,assignTo:O,mode:E,images:u});if(ye){W(!0);try{const Ee=await No(ye);d(Ee)}catch(Ee){ie.error(Ee instanceof Error?Ee.message:"Failed to create task")}finally{W(!1)}}},[v,p,j,M,R,V,O,E,u,d,C,b,ce]),$=ar(v,p,u.length>0),ue=!!($&&j&&O&&(p.trim()||u.length>0)),we=a.useCallback(ae=>{var ye;if(ae.nativeEvent.isComposing)return;const fe=Sa(p,C);if(fe.length>0&&(ae.key==="ArrowDown"||ae.key==="ArrowUp")){ae.preventDefault(),w(Ee=>Ca(Ee,fe.length,ae.key==="ArrowDown"?1:-1));return}if(ae.key==="Enter"){const Ee=os(p,C,b);if(Ee&&!ae.shiftKey){ae.preventDefault(),ce(Ee);return}}ae.key==="Enter"&&(ae.ctrlKey||ae.metaKey)&&ue&&!P&&(ae.preventDefault(),(ye=ae.currentTarget.form)==null||ye.requestSubmit())},[ce,ue,p,C,b,P]),Fe=u.length>0&&e.jsx("div",{className:"flex flex-wrap gap-3",children:u.map((ae,fe)=>e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:Hi(ae),alt:ae.filename??`attachment ${fe+1}`,className:"h-20 w-20 rounded-sm border border-border/70 object-cover"}),e.jsx("button",{type:"button",onClick:()=>oe(fe),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 ${ae.filename??`image ${fe+1}`}`,children:e.jsx(rt,{className:"h-3.5 w-3.5"})})]},`${ae.filename??"image"}-${fe}`))}),ze=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{className:"text-[11px] font-medium",children:"Assign to"}),e.jsxs(Se,{value:O,onValueChange:Z,children:[e.jsx(Ce,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Le,{placeholder:"Select node"})}),e.jsx(Te,{children:Ys(ee,n)})]})]}),Ue=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{className:"text-[11px] font-medium",children:"Agent"}),e.jsxs(Se,{value:j,onValueChange:_,children:[e.jsx(Ce,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Le,{placeholder:"Select agent"})}),e.jsx(Te,{children:Bn()})]})]}),_e=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{className:"text-[11px] font-medium",children:"Mode"}),e.jsxs(Se,{value:E,onValueChange:ae=>X(ae),children:[e.jsx(Ce,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Le,{placeholder:"Select mode"})}),e.jsx(Te,{children:Rn()})]})]}),it=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{className:"text-[11px] font-medium",children:"Priority"}),e.jsxs(Se,{value:V,onValueChange:K,children:[e.jsx(Ce,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Le,{placeholder:"Select priority"})}),e.jsxs(Te,{children:[e.jsx(pe,{value:"low",children:"Low"}),e.jsx(pe,{value:"normal",children:"Normal"}),e.jsx(pe,{value:"high",children:"High"}),e.jsx(pe,{value:"critical",children:"Critical"})]})]})]}),He=e.jsx(vs,{value:M,onChange:Q,assignTo:O,nodes:t,assignableNodes:ee}),Ze=e.jsx(qn,{value:R,onChange:ne,project:M,assignTo:O,nodes:t,assignableNodes:ee});return N==="composer"?e.jsxs("form",{onSubmit:k,className:A("space-y-4",f),children:[e.jsx("input",{ref:T,type:"file",accept:"image/*",multiple:!0,onChange:L,className:"hidden"}),(()=>{const ae="chat-composer__chip h-9 w-auto gap-1.5 rounded-sm px-3.5 text-xs shadow-none transition-colors",fe="border-transparent bg-transparent text-muted-foreground hover:bg-background/40 hover:text-foreground",ye="border-border/70 bg-background/55 text-foreground",Ee=j===_n,lt=E===qt;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(Se,{value:O,onValueChange:Z,children:[e.jsx(Ce,{className:A(ae,ye,"chat-composer__node-trigger border-transparent bg-transparent hover:bg-background/40"),title:`Assigned node: ${(de==null?void 0:de.name)??"unassigned"}`,"aria-label":`Assigned node: ${(de==null?void 0:de.name)??"unassigned"}`,children:de?e.jsxs(e.Fragment,{children:[e.jsx(un,{isCurrent:G}),e.jsx("span",{className:"min-w-0 truncate",children:de.name}),e.jsx("span",{className:"chat-composer__header-meta shrink-0 text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:G?"current":"remote"})]}):e.jsx(Le,{placeholder:"Select node"})}),e.jsx(Te,{children:Ys(ee,n)})]}),x?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(at,{id:"task-title-composer",type:"text",value:v,onChange:Ne=>D(Ne.target.value),onKeyDown:Ne=>{(Ne.key==="Enter"||Ne.key==="Escape")&&(Ne.preventDefault(),H(!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(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>H(!1),"aria-label":"Save title",className:"h-8 w-8 shrink-0 rounded-sm text-muted-foreground hover:text-foreground",children:e.jsx(Vt,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>H(!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:$||"Title","aria-label":$?`Edit title: ${$}`:"Edit title",children:[e.jsx("span",{className:"chat-composer__title-text max-w-[220px] truncate",children:$||"Title"}),e.jsx(It,{className:"h-3 w-3 shrink-0"})]})]}),e.jsx("textarea",{id:"task-description",value:p,onChange:Ne=>S(Ne.target.value),onKeyDown:we,onPaste:le,placeholder:"Ask anything...",rows:4,autoFocus:l,"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(Fs,{query:p,quickChats:C,selectedIndex:b,onActiveIndexChange:w,onSelect:ce}),e.jsxs("div",{className:"chat-composer__rail flex flex-nowrap items-center gap-2 px-3 pb-3",children:[e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:U,"aria-label":"Add images",className:"h-9 w-9 shrink-0 rounded-sm text-muted-foreground hover:text-foreground",children:e.jsx(Ks,{className:"h-4 w-4"})}),e.jsx("span",{className:"mx-0.5 h-5 w-px bg-border/60","aria-hidden":!0}),e.jsxs(Se,{value:j,onValueChange:_,children:[e.jsxs(Ce,{className:A(ae,"chat-composer__icon-trigger",Ee?fe:ye),title:`Agent: ${F}`,"aria-label":`Agent: ${F}`,children:[e.jsx(ln,{agent:j}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:F})]}),e.jsx(Te,{children:Bn()})]}),e.jsxs(Se,{value:E,onValueChange:Ne=>X(Ne),children:[e.jsxs(Ce,{className:A(ae,"chat-composer__icon-trigger",lt?fe:ye),title:`Mode: ${te}`,"aria-label":`Mode: ${te}`,children:[e.jsx(Rl,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:te})]}),e.jsx(Te,{children:Rn()})]}),e.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[e.jsxs(Se,{value:V,onValueChange:K,children:[e.jsx(Ce,{"aria-label":`Priority: ${V}`,title:`Priority: ${V}`,className:A("h-9 w-9 justify-center gap-0 rounded-sm p-0 text-xs shadow-none [&>svg:last-child]:hidden",V==="normal"?"border-transparent bg-transparent text-muted-foreground hover:bg-background/40":"border-border/70 bg-background/55",V==="critical"&&"text-destructive",V==="high"&&"text-amber-600 dark:text-amber-400",V==="low"&&"text-muted-foreground"),children:e.jsx(pl,{className:A("h-4 w-4",V==="critical"&&"fill-destructive/20")})}),e.jsxs(Te,{children:[e.jsx(pe,{value:"low",children:"Low"}),e.jsx(pe,{value:"normal",children:"Normal"}),e.jsx(pe,{value:"high",children:"High"}),e.jsx(pe,{value:"critical",children:"Critical"})]})]}),c&&e.jsxs(J,{type:"button",variant:"ghost",size:"sm",onClick:c,"aria-label":g,className:"chat-composer__cancel h-9 rounded-sm px-4 text-xs text-muted-foreground",children:[e.jsx(rt,{className:"chat-composer__cancel-icon h-4 w-4 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label",children:g})]}),e.jsxs(J,{type:"submit",size:"icon",disabled:!ue||P,className:"h-10 w-10 rounded-sm shadow-[0_8px_30px_-8px_hsl(var(--primary)/0.6)]",children:[P?e.jsx(me,{className:"h-4 w-4 animate-spin"}):e.jsx(Ga,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:P?"Creating chat":y})]})]})]})]}),e.jsx("div",{className:"chat-composer__location flex flex-wrap items-center gap-2 px-1",children:(()=>{const Ne="border-border/40 bg-muted/40 text-foreground/80 hover:bg-muted/60 hover:text-foreground";return e.jsxs(e.Fragment,{children:[e.jsx(vs,{value:M,onChange:Q,assignTo:O,nodes:t,assignableNodes:ee,layout:"composer",chipClassName:ae,chipActiveClassName:Ne,chipInactiveClassName:Ne,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"}),e.jsx(qn,{value:R,onChange:ne,project:M,assignTo:O,nodes:t,assignableNodes:ee,layout:"composer",chipClassName:ae,chipActiveClassName:Ne,chipInactiveClassName:Ne,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"})]})})()})]})})(),(Fe||q)&&e.jsxs("div",{className:"space-y-2 rounded-sm border border-border/60 bg-background/45 p-2.5",children:[Fe,q&&e.jsx("div",{className:"text-[11px] text-destructive",children:q}),!q&&e.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Ctrl/Cmd+Enter starts the chat. Enter adds a new line. Paste screenshots directly into the prompt box or use the Images button."})]})]}):e.jsxs("form",{onSubmit:k,className:A("space-y-4",f),children:[e.jsx("input",{ref:T,type:"file",accept:"image/*",multiple:!0,onChange:L,className:"hidden"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{htmlFor:"task-description",className:"text-[11px] font-medium",children:"Opening prompt"}),e.jsx("textarea",{id:"task-description",value:p,onChange:ae=>S(ae.target.value),onKeyDown:we,onPaste:le,placeholder:"Describe what the agent should do. This becomes the first message in the chat.",rows:6,autoFocus:l,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(Fs,{query:p,quickChats:C,selectedIndex:b,onActiveIndexChange:w,onSelect:ce}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(J,{type:"button",variant:"outline",onClick:U,className:"rounded-sm",children:[e.jsx(Ks,{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."})]}),Fe,q&&e.jsx("p",{className:"text-[11px] text-destructive",children:q})]}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1fr)_190px_190px]",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{htmlFor:"task-title",className:"text-[11px] font-medium",children:"Chat title"}),e.jsx(at,{id:"task-title",type:"text",value:v,onChange:ae=>D(ae.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:$?`Will appear as: ${$}`:"A title will be generated from the first line of the prompt."})]}),Ue,_e]}),He,Ze,e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[it,ze]}),e.jsxs("div",{className:A("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",h),children:[c&&e.jsx(J,{type:"button",variant:"ghost",onClick:c,className:"rounded-sm",children:g}),e.jsx(J,{type:"submit",disabled:!ue||P,className:"rounded-sm px-5",children:P?"Creating...":y})]})]})}function Rd({nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:r,initialAssignTo:o,initialProject:i,onCreated:d,onCancel:c,defaultMode:f="chat",mode:h,onModeChange:y,layout:g="default",className:l,footerClassName:N,autoFocus:C=!1,quickChats:v=[]}){const[D,p]=a.useState(f),S=h!==void 0,b=S?h:D,w=j=>{S||p(j),y==null||y(j)};return e.jsxs("div",{className:A("space-y-4",l),children:[!S&&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(J,{type:"button",variant:b==="chat"?"default":"ghost",onClick:()=>w("chat"),className:"h-7 flex-1 rounded-sm shadow-none",children:[e.jsx(yo,{className:"h-4 w-4"}),"New chat"]}),e.jsxs(J,{type:"button",variant:b==="native"?"default":"ghost",onClick:()=>w("native"),className:"h-7 flex-1 rounded-sm shadow-none",children:[e.jsx(dn,{className:"h-4 w-4"}),"Load session"]})]}),b==="chat"?e.jsx(Bd,{nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:r,initialAssignTo:o,initialProject:i,onCreated:d,onCancel:c,footerClassName:N,submitLabel:g==="composer"?"Start chat":"Create chat",cancelLabel:"Cancel",autoFocus:C,layout:g,quickChats:v},`${o??""}:${i??""}`):e.jsx(Id,{nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:r,onCreated:d,onCancel:c,footerClassName:N,autoFocus:C})]})}function $d({onClick:t,running:s}){return e.jsxs(J,{size:"icon",onClick:t,"aria-label":s?"Open composer - task running":"Open composer",title:s?"Task running - open composer":"Open composer",className:A("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(It,{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 Wn({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 Fd({hasVisibleTranscriptEvents:t,hasTranscriptProgress:s,inputCollapsed:n}){return{collapsedButtonRunning:s&&t&&n,showDockedProgress:s&&t&&!n,showInlineProgress:s&&!t}}const _t="72f988bf-86f1-41af-91ab-2d7cd011db47",rr=`${_t} (MSIT)`;function zd({open:t,onOpenChange:s,onShare:n,onStopShare:r,sharing:o,stopping:i=!1,shareResult:d}){return e.jsx(Pt,{open:t,onOpenChange:s,children:e.jsxs(Lt,{className:"max-w-md rounded-sm p-4",children:[e.jsx(Yt,{className:"sr-only",children:"Share conversation"}),e.jsx(Hd,{onOpenChange:s,onShare:n,onStopShare:r,sharing:o,stopping:i,shareResult:d})]})})}function Hd({onOpenChange:t,onShare:s,onStopShare:n,sharing:r,stopping:o=!1,shareResult:i}){const[d,c]=a.useState((i==null?void 0:i.tenant)??_t),[f,h]=a.useState((i==null?void 0:i.scope)??"chat"),y=i!=null&&i.url?Da(i.url):null,g=r||o;return a.useEffect(()=>{c((i==null?void 0:i.tenant)??_t),h((i==null?void 0:i.scope)??"chat")},[i==null?void 0:i.shareId,i==null?void 0:i.tenant,i==null?void 0: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(Ud,{value:d,onChange:c,disabled:g}),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(Gn,{active:f==="chat",title:"Chat only",description:"Conversation transcript and opening prompt.",onClick:()=>h("chat")}),e.jsx(Gn,{active:f==="filesPreview",title:"Chat, files and preview",description:"Transcript plus task output files and HTML preview.",onClick:()=>h("filesPreview")})]})]}),y&&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:y,className:"min-w-0 flex-1 bg-transparent font-mono text-xs text-foreground outline-none","aria-label":"Shared link"}),e.jsx(J,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-sm text-muted-foreground",onClick:()=>void Tt(y,"Shared link copied"),"aria-label":"Copy shared link",title:"Copy shared link",children:e.jsx(Aa,{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(J,{variant:"outline",onClick:()=>t(!1),disabled:g,className:"h-8 text-xs",children:i?"Done":"Cancel"}),i&&n&&e.jsxs(J,{variant:"outline",onClick:()=>void n(),disabled:g,className:"h-8 border-destructive/30 text-xs text-destructive hover:bg-destructive/10 hover:text-destructive",children:[o&&e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}),"Stop share"]}),e.jsxs(J,{onClick:()=>void s({tenant:d,scope:f}),disabled:g,className:"h-8 text-xs",children:[r&&e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}),i?"Update link":"Share link"]})]})]})}function Ud({value:t,onChange:s,disabled:n}){const[r,o]=a.useState(!1),[i,d]=a.useState(!1),[c,f]=a.useState(t),h=a.useRef(null);a.useEffect(()=>{f(t)},[t]),a.useEffect(()=>{if(!r)return;const g=N=>{var v;const C=N.target;C instanceof Node&&((v=h.current)!=null&&v.contains(C)||(o(!1),d(!1)))},l=N=>{N.key==="Escape"&&(o(!1),d(!1))};return document.addEventListener("mousedown",g),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",l)}},[r]);const y=g=>{const l=g.trim();l&&(s(l),f(l),d(!1),o(!1))};return e.jsxs("div",{className:"space-y-2 text-xs",ref:h,children:[e.jsx("div",{className:"font-medium text-foreground",children:"Tenant"}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>!n&&o(g=>!g),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:Vd(t)}),e.jsx(Qe,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})]}),r&&e.jsxs("div",{className:"absolute left-0 right-0 z-50 mt-2 overflow-hidden rounded-sm border border-border/60 bg-background/95 text-xs shadow-[0_16px_48px_-34px_rgba(0,0,0,0.45)] backdrop-blur",children:[e.jsxs("button",{type:"button",onClick:()=>y(_t),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:rr}),t===_t&&e.jsx(Vt,{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:g=>f(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),y(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:()=>y(c),className:"flex h-7 w-7 items-center justify-center rounded-sm hover:bg-background/60",children:e.jsx(Vt,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{f(t),d(!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(rt,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>d(!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(It,{className:"h-3 w-3"})]})})]})]})]})}function Vd(t){return t===_t?rr:t}function Gn({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 qd(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 Kd({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(_l,{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 o=n.content.filter(i=>i.type==="image");return e.jsxs("div",{className:"flex min-w-0 items-start gap-2 text-[11px] leading-5 text-muted-foreground",children:[e.jsx("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-sm bg-primary/10 text-[10px] font-medium text-primary",children:r+1}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"break-words [overflow-wrap:anywhere]",children:qd(n.content)}),o.length>0&&e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:o.map((i,d)=>e.jsx(Ha,{image:i,alt:i.filename??`queued attachment ${d+1}`,thumbnailClassName:"h-14 w-14 border border-border/65",imageClassName:"h-full w-full"},`${i.filename??"image"}-${d}`))})]}),s&&e.jsx(J,{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(rt,{className:"h-3 w-3"})})]},n.id)})})]})})}const Wd="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",Gd=[{value:"transcript",label:"Transcript",icon:ko},{value:"files",label:"Files",icon:Mt,activeIcon:ys},{value:"diff",label:"Diff",icon:fs},{value:"preview",label:"Preview",icon:Xi}];function Yd({activeTab:t}){return e.jsx(en,{className:"h-auto max-w-full justify-start gap-2 overflow-x-auto rounded-sm !bg-muted/40 !p-0.5 !shadow-none",children:Gd.map(s=>{const n=s.value===t&&s.activeIcon?s.activeIcon:s.icon;return e.jsx(vt,{value:s.value,title:s.label,"aria-label":s.label,className:Wd,children:e.jsx(n,{className:"h-3.5 w-3.5","aria-hidden":"true"})},s.value)})})}const Yn="h-[1.625rem] rounded-sm !border-0 !bg-transparent px-2 text-[10.5px] font-medium text-primary !shadow-none hover:!bg-transparent hover:text-primary/80 focus-visible:ring-1 focus-visible:ring-ring/50 focus-visible:ring-offset-0",bt={content:"max-w-[20rem] gap-2.5 rounded-lg border-0 p-3.5 shadow-[0_18px_70px_-44px_rgba(0,0,0,0.72)] sm:max-w-[20rem]",header:"space-y-1 text-left",title:"text-[13px] leading-4",description:"text-[11px] leading-4",footer:"gap-1 pt-0 sm:space-x-1",cancel:`${Yn} mt-0`,action:Yn},Qd=30,Zd=1600;function Xd({savedScrollTop:t,scrollHeight:s,clientHeight:n}){const r=Math.max(0,s-n);return Math.min(Math.max(0,t??r),r)}function Os(t){return t.scrollHeight-t.scrollTop-t.clientHeight<Qd}function Qn({explicitBottomStickUntil:t,now:s,wasAtBottom:n}){return n||t>s}function Jd({atTop:t,inputCollapseDisabled:s,scrollingUp:n}){return!s&&(n||t)}function ec({activeTab:t,activeTaskId:s,contentVersion:n,inputCollapseDisabled:r=!1,setActiveTab:o,setInputCollapsed:i}){const d=a.useRef(null),c=a.useRef(s),f=a.useRef(!1),h=a.useRef(0),y=a.useRef(new Map),g=a.useRef(0),l=a.useRef(!0),N=a.useCallback((b=c.current)=>{const w=d.current;!w||!b||(y.current.set(b,w.scrollTop),h.current=w.scrollTop,l.current=Os(w))},[]),C=a.useCallback((b=c.current)=>{const w=d.current;!w||!b||(w.scrollTop=Xd({savedScrollTop:y.current.get(b),scrollHeight:w.scrollHeight,clientHeight:w.clientHeight}),h.current=w.scrollTop,l.current=Os(w))},[]),v=a.useCallback((b,w=c.current)=>{b.scrollTop=b.scrollHeight,h.current=b.scrollTop,l.current=!0,w&&y.current.set(w,b.scrollTop)},[]),D=a.useCallback((b=c.current)=>{const w=d.current;g.current=Date.now()+Zd,w&&(v(w,b),requestAnimationFrame(()=>{v(w,b),requestAnimationFrame(()=>v(w,b))}))},[v]),p=a.useCallback(b=>{const w=b.currentTarget,j=h.current,_=w.scrollTop<j&&j-w.scrollTop>10,E=w.scrollTop<=0;if(N(),!f.current){if(Os(w)){i(!1),f.current=!0,setTimeout(()=>{f.current=!1},300);return}(_||E)&&(g.current=0,Jd({atTop:E,inputCollapseDisabled:r,scrollingUp:_})&&i(!0))}},[r,N,i]),S=a.useCallback(b=>{t==="transcript"&&N(),o(b),b==="transcript"&&requestAnimationFrame(()=>C())},[t,C,N,o]);return a.useLayoutEffect(()=>{r&&i(!1)},[r,i]),a.useLayoutEffect(()=>{const b=c.current;b&&b!==s&&N(b),c.current=s,t==="transcript"&&requestAnimationFrame(()=>C(s))},[s,t,C,N]),a.useLayoutEffect(()=>{const b=d.current;if(!b||t!=="transcript"||!s)return;Qn({explicitBottomStickUntil:g.current,now:Date.now(),wasAtBottom:l.current})&&v(b,s),N(s)},[s,t,n,N,v]),a.useLayoutEffect(()=>{const b=d.current,w=b==null?void 0:b.firstElementChild;if(!b||!w||t!=="transcript"||typeof ResizeObserver>"u")return;const j=new ResizeObserver(()=>{Qn({explicitBottomStickUntil:g.current,now:Date.now(),wasAtBottom:l.current})?v(b):N()});return j.observe(b),j.observe(w),()=>j.disconnect()},[t,s,N,v]),{handleTranscriptScroll:p,handleTranscriptTabChange:S,scrollTranscriptToBottom:D,transcriptScrollRef:d}}function or(t=700){const[s,n]=a.useState(!1),r=a.useRef(null),o=a.useCallback(()=>{n(!0),r.current!==null&&clearTimeout(r.current),r.current=setTimeout(()=>{n(!1),r.current=null},t)},[t]);return a.useEffect(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]),{markScrollbarActive:o,scrollbarActive:s}}const mn="pointer-events-auto h-5 w-5 shrink-0 rounded-full bg-muted/65 text-muted-foreground hover:bg-muted hover:text-foreground",Et="h-3.5 w-3.5",tc=a.lazy(async()=>({default:(await sn(()=>import("./FilesTab-Dr_X6U7n.js"),__vite__mapDeps([0,1,2,3,4,5]))).FilesTab})),sc=a.lazy(async()=>({default:(await sn(()=>import("./PreviewTab-DtBT527u.js").then(s=>s.c),__vite__mapDeps([6,1,2]))).PreviewTab})),nc=a.lazy(async()=>({default:(await sn(()=>import("./DiffTab-Bd3CsYCX.js"),__vite__mapDeps([7,1,2,5,4,3,6]))).DiffTab}));function ac({onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:o,cluster:i,sseConnected:d,activeTab:c,setActiveTab:f,creatingTask:h,createMode:y,createDefaults:g,activeTask:l,assignedNode:N,taskLoading:C,transcriptLoading:v,taskError:D,displayEvents:p,initialPromptAlreadyInLogs:S,initialPrompt:b,supportsFollowUp:w,taskUnavailable:j,chatDisabled:_,chatDisabledReason:E,questionBypassEnabled:X,isRunning:M,isStarting:Q,hasPendingFollowUp:B,canCancel:R,canRetry:ne,onRetry:V,onCancel:K,onReloadNativeTranscript:ee,onShareTask:se,onStopShareTask:O,onStartCreateTask:Z,onCancelCreateTask:P,onCreateTask:W,onSendMessage:x,onCancelQueuedMessage:H,onQuestionBypassChange:u,onSubmitQuestionResponse:q,quickChats:T=[]}){const[U,L]=a.useState(!1),[le,oe]=a.useState(!1),[de,G]=a.useState(!1),[F,te]=a.useState(!1),[ce,k]=a.useState(!1),[$,ue]=a.useState({}),[we,Fe]=a.useState(new Set),[ze,Ue]=a.useState(new Set),[_e,it]=a.useState(null),He=(l==null?void 0:l.effectiveProjectPath)??(l==null?void 0:l.project)??"default workspace",Ze=l?(N==null?void 0:N.name)??zs(l.assignedTo,i==null?void 0:i.nodes,l.assignedNodeName):"unassigned",ae=l!=null&&l.assignedTo?e.jsxs(e.Fragment,{children:["Connecting session on node ",e.jsx("span",{className:"font-semibold",children:Ze}),"..."]}):"Connecting session to an available node...",fe=l?[{label:"Working dir",value:He,mono:!0},...l.branch?[{label:"Branch",value:l.branch,mono:!0}]:[],{label:"Agent",value:l.agent,mono:!0},{label:"Node",value:Ze}]:[],ye=!!(b&&!S),Ee=ye||p.length>0,lt=M&&Ee,Ne=(Q||B||M)&&!lt,Ge=lt?"The agent is still working on this conversation.":Ne?ae:null,{collapsedButtonRunning:wt,showDockedProgress:yt,showInlineProgress:Oe}=Fd({hasTranscriptProgress:!!Ge,hasVisibleTranscriptEvents:Ee,inputCollapsed:U}),z=(l==null?void 0:l.conversationKind)==="nativeSession",xe=v?"Loading transcript":z?"No transcript imported":"Transcript is warming up",De=v?"Loading transcript...":z?"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.",ut=(l==null?void 0:l.queuedMessages)??[],pt=a.useMemo(()=>Ui(p),[p]),Nt=a.useMemo(()=>Vi("transcript",pt.map(ve=>ve.event)),[pt]),Me=l&&!we.has(l.id)?$[l.id]??l.activeShare??null:null,Be=(l==null?void 0:l.id)??null,kt=`${Be??"none"}:${p.length}:${ut.length}:${ye?1:0}:${v?1:0}:${Oe?1:0}`,{handleTranscriptScroll:ft,handleTranscriptTabChange:Xe,scrollTranscriptToBottom:gt,transcriptScrollRef:Bt}=ec({activeTab:c,activeTaskId:Be,contentVersion:kt,inputCollapseDisabled:!!Ge,setActiveTab:f,setInputCollapsed:L}),{markScrollbarActive:dt,scrollbarActive:ke}=or(),ct=a.useCallback(ve=>{dt(),ft(ve)},[ft,dt]),mt=a.useCallback(ve=>{it(Ae=>({path:ve,requestId:((Ae==null?void 0:Ae.requestId)??0)+1})),Xe("files")},[Xe]),Pe=a.useCallback(ve=>{gt(),x(ve)},[x,gt]);return a.useEffect(()=>{it(null)},[Be]),h?e.jsx(rc,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:o,cluster:i,sseConnected:d,defaultMode:y,createDefaults:g,onCancel:P,onCreated:W,quickChats:T}):!l&&C?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(Qs,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:o,cluster:i,sseConnected:d})}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-4 py-6 sm:px-6",children:e.jsxs("div",{className:"space-y-3 text-center",children:[e.jsx("div",{className:"mx-auto flex h-10 w-10 items-center justify-center rounded-sm border border-primary/20 bg-primary/10 text-primary shadow-none",children:e.jsx(me,{className:"h-5 w-5 animate-spin"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:"Loading conversation"}),e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[11px] text-muted-foreground",children:[e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}),"Fetching the selected chat thread..."]})]})]})})]}):l?e.jsxs(tn,{value:c,onValueChange:Xe,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(ir,{desktopTasksOpen:s,mobileTasksPanelOpen:n,onToggleTasks:t,className:"lg:hidden"}),e.jsx(J,{variant:"ghost",size:"icon",onClick:o,title:r?"Hide cluster":"Show cluster","aria-label":r?"Hide cluster":"Show cluster",className:A(mn,"xl:hidden"),children:r?e.jsx(We,{className:Et}):e.jsx(Wt,{className:Et})})]}),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:l.title,children:l.title}),e.jsx(Ma,{status:l.status,isNative:z}),l.priority!=="normal"&&e.jsx(Co,{priority:l.priority})]}),D&&e.jsx("div",{className:"mt-2 w-fit rounded-sm border border-destructive/25 bg-destructive/10 px-2 py-1 text-[11px] text-destructive",children:D}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 pl-5 sm:pl-6 lg:pl-0",children:[e.jsx(Yd,{activeTab:c}),j&&e.jsx($e,{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:To(l.updatedAt)}),ne&&e.jsxs(J,{variant:"ghost",size:"sm",onClick:V,"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(Pl,{className:"h-3.5 w-3.5"}),"Retry"]}),z&&ee&&e.jsx(J,{variant:"ghost",size:"icon",onClick:ee,disabled:v,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(Wa,{className:A("h-3.5 w-3.5",v&&"animate-spin")})}),e.jsx(J,{type:"button",variant:"ghost",size:"icon",disabled:j,title:j?"Unavailable tasks cannot be shared.":"Share conversation","aria-label":j?"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:()=>G(!0),children:e.jsx(bs,{className:"h-3.5 w-3.5"})})]})]})]}),e.jsx(ot,{value:"transcript",className:"mt-0 min-h-0 flex-1",children:e.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[e.jsx("div",{className:"relative min-h-0 flex-1",children:e.jsx("div",{ref:Bt,"data-transcript-scroll":"true",className:A("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",ke&&"scrollbar-line-active"),onScroll:ct,children:e.jsxs("div",{"data-transcript-scroll-content":"true",className:"mx-auto flex max-w-[72rem] flex-col gap-4",children:[ye&&b&&e.jsx($n,{event:b,agent:l.agent,taskRootPath:l.effectiveProjectPath,onOpenFilePath:mt,questionBypassEnabled:X,onQuestionBypassChange:u,onSubmitQuestionResponse:q,questionResponseDisabled:!w||_}),pt.map(({event:ve,subItems:Ae},Ve)=>e.jsx($n,{event:ve,agent:l.agent,subItems:Ae,taskRootPath:l.effectiveProjectPath,onOpenFilePath:mt,questionBypassEnabled:X,onQuestionBypassChange:u,onSubmitQuestionResponse:q,questionResponseDisabled:!w||_},Nt[Ve])),!Ee&&!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:xe}),e.jsx("div",{className:"mt-2 text-[11px] leading-6 text-muted-foreground",children:De})]}),(!w&&l.result||l.error)&&e.jsxs("div",{className:"space-y-3",children:[!w&&l.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(l.result,null,2)})]}),l.error&&!ze.has(l.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:()=>Ue(ve=>new Set(ve).add(l.id)),className:"rounded p-0.5 hover:bg-destructive/20","aria-label":"Dismiss error",children:e.jsx(rt,{className:"h-3.5 w-3.5"})})]}),e.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-[11px] leading-5",children:l.error})]})]}),Oe&&Ge&&e.jsx(Wn,{children:Ge})]})})}),yt&&Ge&&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(Wn,{children:Ge})})}),w?e.jsxs(e.Fragment,{children:[U&&e.jsx($d,{running:wt,onClick:()=>{L(!1),gt(),requestAnimationFrame(()=>{var ve;return(ve=document.querySelector('[data-chat-input-textarea="true"]'))==null?void 0:ve.focus()})}}),e.jsxs("div",{className:`shrink-0 ${U?"hidden":""}`,children:[e.jsx(Kd,{messages:ut,onCancelMessage:H}),e.jsx(ld,{onSend:Pe,disabled:_,disabledReason:E,contextItems:fe,placeholder:_?E:M?"Queue a message for the next turn...":"Continue the conversation...",running:M||B,onStop:R?()=>oe(!0):void 0,quickChats:T})]})]}):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(ot,{value:"files",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(a.Suspense,{fallback:e.jsx(Ls,{label:"Loading files..."}),children:e.jsx(tc,{taskId:l.id,requestedFilePath:(_e==null?void 0:_e.path)??null,requestedFileRequestId:(_e==null?void 0:_e.requestId)??0})})}),e.jsx(ot,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(a.Suspense,{fallback:e.jsx(Ls,{label:"Loading preview..."}),children:e.jsx(sc,{taskId:l.id})})}),e.jsx(ot,{value:"diff",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(a.Suspense,{fallback:e.jsx(Ls,{label:"Loading diff..."}),children:e.jsx(nc,{taskId:l.id})})}),e.jsx(is,{open:le,onOpenChange:oe,children:e.jsxs(ls,{className:bt.content,children:[e.jsxs(ds,{className:bt.header,children:[e.jsx(cs,{className:bt.title,children:"Stop this task?"}),e.jsx(us,{className:bt.description,children:"The task will stop and move to a cancelled state."})]}),e.jsxs(ms,{className:bt.footer,children:[e.jsx(xs,{className:bt.cancel,children:"Keep running"}),e.jsx(hs,{className:bt.action,onClick:K,children:"Stop task"})]})]})}),e.jsx(zd,{open:de,onOpenChange:G,sharing:F,stopping:ce,shareResult:Me,onShare:async ve=>{if(!l)return null;te(!0);try{const Ae=await se(ve);return Ae!=null&&Ae.url&&(ue(Ve=>({...Ve,[l.id]:Ae})),Fe(Ve=>{const qe=new Set(Ve);return qe.delete(l.id),qe})),Ae}finally{te(!1)}},onStopShare:async()=>{if(!l)return!1;k(!0);try{const ve=await O();return ve!==!1&&(ue(Ae=>{const Ve={...Ae};return delete Ve[l.id],Ve}),Fe(Ae=>new Set(Ae).add(l.id))),ve}finally{k(!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(Qs,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:o,cluster:i,sseConnected:d})}),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(So,{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(J,{onClick:()=>Z(),className:"mt-4 h-8 rounded-sm px-3",children:[e.jsx(Ns,{className:"h-3.5 w-3.5"}),"Start or load chat"]}),D&&e.jsx("div",{className:"mx-auto mt-3 max-w-md rounded-sm border border-destructive/20 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:D})]})})]})}function rc({onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:o,cluster:i,sseConnected:d,defaultMode:c,createDefaults:f,onCancel:h,onCreated:y,quickChats:g}){var v,D,p;const[l,N]=a.useState(c??"chat");a.useEffect(()=>{c&&N(c)},[c]);const C=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:Ns},{value:"native",label:"Load session",icon:dn}].map(S=>{const b=S.icon,w=S.value===l;return e.jsxs("button",{type:"button",onClick:()=>N(S.value),"aria-pressed":w,className:A("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",w?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-background/80 hover:text-foreground"),children:[e.jsx(b,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:S.label})]},S.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(Qs,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:o,cluster:i,sseConnected:d,centerSlot:C})}),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(Rd,{nodes:(i==null?void 0:i.nodes)??[],currentNodeRole:(v=i==null?void 0:i.self)==null?void 0:v.role,currentNodeId:((D=i==null?void 0:i.self)==null?void 0:D.id)??null,leaderNodeId:((p=i==null?void 0:i.leader)==null?void 0:p.id)??null,initialAssignTo:f==null?void 0:f.assignTo,initialProject:f==null?void 0:f.project,mode:l,onModeChange:N,onCreated:y,onCancel:h,autoFocus:!0,layout:"composer",quickChats:g})})})]})}function Qs({onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:o,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(ir,{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(J,{variant:"ghost",size:"icon",onClick:o,title:r?"Hide cluster":"Show cluster","aria-label":r?"Hide cluster":"Show cluster",className:A(mn,"xl:hidden"),children:r?e.jsx(We,{className:Et}):e.jsx(Wt,{className:Et})})]})}function ir({className:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,onToggleTasks:r}){var i,d;const o=(d=(i=globalThis.window)==null?void 0:i.matchMedia("(min-width: 1024px)"))!=null&&d.matches?s:n;return e.jsx(J,{variant:"ghost",size:"icon",onClick:r,title:o?"Hide tasks":"Show tasks","aria-label":o?"Hide tasks":"Show tasks",className:A(mn,t),children:o?e.jsx(Wt,{className:Et}):e.jsx(We,{className:Et})})}function oc({onAdded:t}){const[s,n]=a.useState(""),[r,o]=a.useState(!1),[i,d]=a.useState(null),c=a.useCallback(async f=>{if(f.preventDefault(),!!s.trim()){o(!0),d(null);try{await _o({leaderEndpoint:s.trim(),transport:"devtunnel"}),t()}catch(h){d(h instanceof Error?h.message:"Failed to join node")}finally{o(!1)}}},[s,t]);return e.jsx(Lt,{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(nn,{className:"space-y-1 text-left",children:[e.jsx(Yt,{className:"text-sm tracking-tight",children:"Join node"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Verify the remote leader's DevTunnel endpoint, sync this node's tasks to that leader, and join the cluster as a follower."})]})}),e.jsxs("form",{onSubmit: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(Re,{htmlFor:"leader-endpoint",children:"Leader endpoint"}),e.jsx($e,{variant:"outline",className:"rounded-sm border-border/70 bg-background/60 text-[10px] uppercase tracking-[0.16em]",children:"DevTunnel only"})]}),e.jsx(at,{id:"leader-endpoint",type:"url",value:s,onChange:f=>n(f.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(Pa,{className:"border-t border-border/60 pt-3",children:e.jsx(J,{type:"submit",disabled:!s.trim()||r,className:"rounded-sm",children:r?"Joining...":"Join node"})})]})]})})}function ic({open:t,onOpenChange:s,onAdded:n}){return e.jsx(Pt,{open:t,onOpenChange:s,children:e.jsx(oc,{onAdded:()=>{s(!1),n()}})})}const lc="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",dc="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",cc="h-2.5 w-2.5";function lr({className:t,label:s,orientation:n,panel:r,panelResize:o}){return e.jsx("button",{type:"button","aria-label":s,"aria-orientation":n,"data-dashboard-resize-handle":r,onPointerDown:i=>o.onPointerDown(r,i),onWheel:i=>o.onWheel(r,i),className:A("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 uc({className:t,label:s,onToggle:n,side:r,visible:o}){const i=r==="left"?o?Wt:We:o?We:Wt;return e.jsx("button",{type:"button","aria-label":s,title:s,onClick:n,className:A(lc,t),children:e.jsx("span",{className:dc,"aria-hidden":"true",children:e.jsx(i,{className:cc,strokeWidth:2.1})})})}function Zn({className:t,label:s,onToggle:n,panel:r,panelResize:o,screen:i,side:d,visible:c}){const f=i==="lg"?"lg:block":"xl:block",h=i==="lg"?"lg:flex":"xl:flex";return e.jsxs("div",{className:A("group absolute top-0 z-30 hidden h-full w-4",f,t),children:[r&&e.jsx(lr,{panel:r,orientation:"vertical",label:`Resize ${r} panel`,panelResize:o,className:"left-1/2 top-0 h-full w-2 -translate-x-1/2 cursor-col-resize"}),e.jsx(uc,{side:d,visible:c,label:s,onToggle:n,className:A(h,"left-1/2 -translate-x-1/2 group-hover:opacity-100")})]})}function mc({conversationPanel:t,desktopTasksOpen:s,mobileTaskSidebar:n,mobileTasksPanelOpen:r,mobileTasksPanelRef:o,operationsOpen:i,operationsPanelRef:d,operationsSidecar:c,panelResize:f,taskSidebar:h,terminalPanel:y,onCloseOperations:g,onCloseTaskList:l,onToggleOperations:N,onToggleTasks:C}){const v={"--dashboard-tasks-width":f.sizes.tasks,"--dashboard-operations-width":f.sizes.operations,"--dashboard-terminal-height":f.sizes.terminal};return e.jsxs("div",{className:"dashboard-workspace flex h-full min-h-0 flex-col overflow-hidden",style:v,children:[e.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[e.jsx(Zn,{screen:"lg",side:"left",visible:s,label:s?"Hide tasks":"Show tasks",onToggle:C,panel:s?"tasks":void 0,panelResize:f,className:s?"left-[var(--dashboard-tasks-width)] -translate-x-1/2":"left-0"}),e.jsx("div",{className:A("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&&h}),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}),y&&e.jsxs("div",{className:"relative h-[var(--dashboard-terminal-height)] min-h-0 shrink-0",children:[e.jsx(lr,{panel:"terminal",orientation:"horizontal",label:"Resize terminal panel",panelResize:f,className:"-top-1 left-0 h-2 w-full cursor-row-resize"}),y]})]}),e.jsx(Zn,{screen:"xl",side:"right",visible:i,label:i?"Hide cluster":"Show cluster",onToggle:N,panel:i?"operations":void 0,panelResize:f,className:i?"right-[var(--dashboard-operations-width)] translate-x-1/2":"right-0"}),e.jsx("div",{className:A("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:g,className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm xl:hidden"}),e.jsx("div",{ref:d,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:l,className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm lg:hidden"}),e.jsx("div",{ref:o,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 xc=10,jt="__all__";function Ye(t){return"session"in t}function Xn(t,s){var n;return s&&t.some(r=>r.id===s)?s:((n=t[0])==null?void 0:n.id)??""}function Bs(t){return t&&(sr(t.id)||t.workDir)||""}function ss(t,s,n){let r=!1;const o=t.map(i=>Ye(i)&&i.session.id===n.id?(r=!0,{...i,nodeName:s,session:n}):i);return Zs(r?o:[...o,{id:`session-${n.id}`,nodeName:s,session:n}])}function dr(t,s){return t.filter(Ye).filter(n=>n.session.nodeId===s).sort((n,r)=>r.session.startedAt-n.session.startedAt)}function hc(t){const s=t.filter(Ye).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 pc(t,s){return!!(t&&s&&!t.contains(s))}function fc(t,s,n){var o;if(n===jt)return n;const r=dr(t,s);return r.some(i=>i.session.id===n)?n:((o=r[0])==null?void 0:o.session.id)??jt}function gc(t,s,n){return n===jt?t.filter(r=>!Ye(r)||r.session.nodeId===s):t.filter(r=>Ye(r)&&r.session.nodeId===s&&r.session.id===n)}function Zs(t){const s=t.map((r,o)=>({entry:r,index:o})).filter(({entry:r})=>Ye(r)&&r.session.status!=="running").sort((r,o)=>!Ye(r.entry)||!Ye(o.entry)?0:o.entry.session.startedAt-r.entry.session.startedAt||o.index-r.index),n=new Set(s.slice(0,xc).map(({entry:r})=>Ye(r)?r.session.id:""));return t.filter(r=>!Ye(r)||r.session.status==="running"||n.has(r.session.id))}function Xs(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 bc(t){const s=t.session.command.length>48?`${t.session.command.slice(0,45)}...`:t.session.command;return`${t.nodeName} - ${Xs(t.session)} - ${s}`}function cr(t,s=48){return t.length>s?`${t.slice(0,s-3)}...`:t}function vc(t,s){return s===jt?"All sessions":t?cr(t.session.command,34):"Command session"}function Jn(t){return t.status==="stopped"?"":t.stderr}function jc({nodes:t,defaultNodeId:s,onClose:n,initialHistory:r=[]}){const[o,i]=a.useState(()=>Xn(t,s)),d=a.useMemo(()=>t.find(u=>u.id===o)??t[0]??null,[t,o]),[c,f]=a.useState(()=>Bs(d)),[h,y]=a.useState(""),[g,l]=a.useState(()=>Zs(r)),[N,C]=a.useState(jt),[v,D]=a.useState(!1),[p,S]=a.useState(!1),[b,w]=a.useState(!1),[j,_]=a.useState(!1),[E,X]=a.useState(!1),M=a.useRef(null),Q=a.useRef(null),B=a.useMemo(()=>t.find(u=>u.id===o)??t[0]??null,[t,o]),R=a.useMemo(()=>dr(g,(B==null?void 0:B.id)??""),[g,B]),ne=a.useMemo(()=>hc(R),[R]),V=a.useMemo(()=>R.find(u=>u.session.id===N),[N,R]),K=a.useMemo(()=>gc(g,(B==null?void 0:B.id)??"",N),[g,B,N]),ee=a.useRef((B==null?void 0:B.id)??"");a.useEffect(()=>{o&&t.some(u=>u.id===o)||i(Xn(t,s))},[s,t,o]),a.useEffect(()=>{const u=(B==null?void 0:B.id)??"";ee.current!==u&&(ee.current=u,f(Bs(B)))},[B]),a.useEffect(()=>{C(u=>fc(g,(B==null?void 0:B.id)??"",v?u:""))},[g,B,v]),a.useEffect(()=>{var u;(u=M.current)==null||u.scrollTo({top:M.current.scrollHeight})},[g]),a.useEffect(()=>{let u=!1;async function q(){const T=await Promise.allSettled(t.map(async U=>({node:U,response:await Do(U.id)})));u||l(U=>T.reduce((L,le)=>le.status!=="fulfilled"?L:le.value.response.sessions.reduce((oe,de)=>ss(oe,le.value.node.name,de),L),U))}return t.length>0&&q(),()=>{u=!0}},[t]),a.useEffect(()=>{const u=g.filter(Ye).filter(T=>T.session.status==="running");if(u.length===0)return;const q=window.setInterval(()=>{for(const T of u)Eo(T.session.nodeId,T.session.id).then(U=>l(L=>ss(L,T.nodeName,U))).catch(()=>{})},1e3);return()=>window.clearInterval(q)},[g]);const se=a.useRef(null);async function O(u){if(u.preventDefault(),!B||!h.trim()||E)return;const q=h.trim(),T=B.name;X(!0),y("");try{const U=await Mo(B.id,{command:q,...c.trim()?{cwd:c.trim()}:{}});l(L=>ss(L,T,U)),C(U.id),D(!0)}catch(U){l(L=>[...L,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,nodeName:T,command:q,error:U instanceof Error?U.message:"Command failed"}])}finally{X(!1)}}async function Z(u,q){u.stopPropagation();const T=await Ao(q.session.nodeId,q.session.id);l(U=>ss(U,q.nodeName,T))}function P(u){C(u),D(!0),S(!1)}function W(u){p&&pc(Q.current,u.target)&&S(!1)}function x(u,q,T,U,L){return e.jsxs("div",{className:"border-t border-border/60 py-1",children:[e.jsxs("button",{type:"button",onClick:U,"aria-label":`Toggle ${u} sessions`,"aria-expanded":!T,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:u}),e.jsx(Qe,{className:A("h-3 w-3 transition-transform",T&&"-rotate-90")})]}),!T&&(q.length>0?q.map(H):e.jsx("div",{className:"node-terminal__control px-2 py-1 text-muted-foreground",children:L}))]})}function H(u){const q=N===u.session.id,T=u.session.status==="running";return e.jsxs("div",{className:A("node-terminal__control group flex w-full items-center gap-2 px-2 py-1.5 text-left transition-colors hover:bg-muted/65",q&&"bg-primary/10 text-primary"),children:[e.jsxs("button",{type:"button",onClick:()=>P(u.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:A("flex h-4 w-4 shrink-0 items-center justify-center",T?"text-primary":u.session.status==="exited"?"text-emerald-600 dark:text-emerald-300":"text-amber-600 dark:text-amber-300"),children:T?e.jsx(me,{className:"h-3 w-3 animate-spin"}):u.session.status==="exited"?e.jsx(Dn,{className:"h-3 w-3"}):e.jsx(Ms,{className:"h-3 w-3"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-foreground",children:cr(u.session.command,44)}),e.jsxs("span",{className:"node-terminal__small block truncate text-muted-foreground",children:[u.nodeName," · ",Xs(u.session)]})]})]}),T&&e.jsx("button",{type:"button",onClick:U=>void Z(U,u),"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(Hn,{className:"h-3 w-3"})})]},u.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:W,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(rt,{className:"h-3.5 w-3.5"})}):e.jsx(En,{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:Q,className:"relative min-w-0",children:[e.jsxs("button",{type:"button","aria-label":"Command session","aria-expanded":p,title:V?bc(V):"All sessions",onClick:()=>S(u=>!u),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:vc(V,N)}),e.jsx(Qe,{className:A("h-3 w-3 shrink-0 text-muted-foreground transition-transform",p&&"rotate-180")})]}),e.jsx("div",{"aria-hidden":!p,className:A("absolute right-0 bottom-9 z-30 w-[19rem] overflow-hidden rounded-xl border border-border/70 bg-popover text-popover-foreground shadow-xl",!p&&"hidden"),children:e.jsxs("div",{className:"max-h-72 overflow-y-auto",children:[e.jsxs("button",{type:"button",onClick:()=>P(jt),className:A("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",N===jt&&"bg-primary/10 text-primary"),children:[e.jsx(En,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:"All sessions"})]}),x("Active",ne.active,b,()=>w(u=>!u),"No active sessions"),x("Completed",ne.completed,j,()=>_(u=>!u),"No completed sessions")]})})]}),e.jsx("select",{value:(B==null?void 0:B.id)??"",onChange:u=>{i(u.target.value),D(!1),f(Bs(t.find(q=>q.id===u.target.value)??null))},disabled:E||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(u=>e.jsx("option",{value:u.id,className:"bg-background text-foreground",children:u.name},u.id))}),e.jsx(vs,{value:c,onChange:f,assignTo:(B==null?void 0:B.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:M,className:"node-terminal__body min-h-0 flex-1 overflow-y-auto bg-muted/22 px-3 py-2 font-mono cursor-text",onClick:()=>{var u;return(u=se.current)==null?void 0:u.focus()},children:[K.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:K.map(u=>Ye(u)?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:[u.nodeName,"$"]}),e.jsx("span",{className:"break-all text-foreground",children:u.session.command}),e.jsxs("span",{className:A("inline-flex items-center gap-1",u.session.status==="running"||u.session.status==="exited"?"text-primary":"text-amber-600 dark:text-amber-300"),children:[u.session.status==="running"?e.jsx(me,{className:"h-3 w-3 animate-spin"}):u.session.status==="exited"?e.jsx(Dn,{className:"h-3 w-3"}):e.jsx(Ms,{className:"h-3 w-3"}),Xs(u.session)]}),u.session.status==="running"&&e.jsx("button",{type:"button",onClick:q=>void Z(q,u),"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(Hn,{className:"h-3 w-3"})})]}),u.session.stdout&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-foreground",children:u.session.stdout}),Jn(u.session)&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:Jn(u.session)}),(u.session.stdoutTruncated||u.session.stderrTruncated)&&e.jsx("div",{className:"text-muted-foreground",children:"Output truncated to the latest output."})]},u.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:[u.nodeName,"$"]}),e.jsx("span",{className:"break-all text-foreground",children:u.command}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive",children:[e.jsx(Ms,{className:"h-3 w-3"}),"error"]})]}),e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:u.error})]},u.id))}),e.jsxs("form",{onSubmit:O,className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"shrink-0 text-primary select-none",children:B?`${B.name}$`:"$"}),e.jsx("input",{ref:se,value:h,onChange:u=>y(u.target.value),disabled:!B||E,placeholder:B?"":"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:!B||!h.trim()||E,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:E?e.jsx(me,{className:"h-3 w-3 animate-spin"}):e.jsx(ws,{className:"h-3 w-3"})})]})]})]})})}function xn({nodeId:t,nodeName:s,onOpenSettings:n,onOpenServicePreview:r,onOpenCapabilities:o,onOpenDevBox:i,onStartDevBox:d,onToggleRemoteAccess:c,remoteAccessLabel:f,remoteAccessPending:h,remoteAccessDisabled:y,remoteAccessDisabledReason:g,showConfigureDevBox:l,showStartDevBox:N,startDevBoxPending:C,className:v}){const[D,p]=a.useState(!1),[S,b]=a.useState(null),w=a.useRef(null),j=a.useRef(null),_=C?"Starting":"Start DevBox",E=f!=null&&f.startsWith("Disable")?Po:Ul;a.useLayoutEffect(()=>{if(!D){b(null);return}const M=()=>{const Q=j.current,B=w.current;if(!Q||!B)return;const R=Q.getBoundingClientRect(),ne=B.getBoundingClientRect();b(yc({left:R.left,right:R.right,bottom:R.bottom,top:R.top},{width:ne.width,height:ne.height},{width:window.innerWidth,height:window.innerHeight},Nc()))};return M(),window.addEventListener("resize",M),window.addEventListener("scroll",M,!0),()=>{window.removeEventListener("resize",M),window.removeEventListener("scroll",M,!0)}},[D]),a.useEffect(()=>{if(!D)return;const M=B=>{var ne,V;const R=B.target;R instanceof Node&&!((ne=w.current)!=null&&ne.contains(R))&&!((V=j.current)!=null&&V.contains(R))&&p(!1)},Q=B=>{B.key==="Escape"&&p(!1)};return document.addEventListener("mousedown",M),document.addEventListener("keydown",Q),()=>{document.removeEventListener("mousedown",M),document.removeEventListener("keydown",Q)}},[D]);const X=D?e.jsxs("div",{ref:w,"data-node-action-menu-portal":"true",role:"menu",style:wc(S),onClick:M=>M.stopPropagation(),onPointerDown:M=>M.stopPropagation(),className:"fixed z-[130] min-w-40 overflow-hidden whitespace-nowrap rounded-sm border border-border/65 bg-popover/96 p-1 normal-case tracking-normal shadow-[0_18px_48px_-28px_rgba(0,0,0,0.45)] backdrop-blur-xl",children:[n&&e.jsxs("button",{type:"button",role:"menuitem","aria-label":`Open ${s} settings`,title:`Open ${s} settings`,onClick:M=>{M.stopPropagation(),p(!1),n(t)},className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-1.5 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80",children:[e.jsx(Lo,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:"Settings"})]}),r&&e.jsxs("button",{type:"button",role:"menuitem","aria-label":`Preview service on ${s}`,title:`Preview service on ${s}`,onClick:M=>{M.stopPropagation(),p(!1),r(t)},className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-1.5 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80",children:[e.jsx(Ka,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:"Preview service"})]}),o&&e.jsxs("button",{type:"button",role:"menuitem","aria-label":`Open ${s} capabilities`,title:`Open ${s} capabilities`,onClick:M=>{M.stopPropagation(),p(!1),o(t)},className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-1.5 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80",children:[e.jsx(js,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:"Capabilities"})]}),f&&c&&e.jsxs("button",{type:"button",role:"menuitem","aria-label":`${f} for ${s}`,title:g??`${f} for ${s}`,onClick:M=>{M.stopPropagation(),!(h||y)&&(p(!1),c())},disabled:h||y,className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-1.5 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80 disabled:cursor-not-allowed disabled:opacity-60",children:[h?e.jsx(me,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-primary"}):e.jsx(E,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:f})]}),N&&d&&e.jsxs("button",{type:"button",role:"menuitem","aria-label":`${_} for ${s}`,title:`${_} for ${s}`,onClick:M=>{M.stopPropagation(),!C&&(p(!1),d(t))},disabled:C,className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-1.5 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80 disabled:cursor-not-allowed disabled:opacity-60",children:[C?e.jsx(me,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-primary"}):e.jsx(ws,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:_})]}),l&&i&&e.jsxs("button",{type:"button",role:"menuitem","aria-label":`Configure DevBox for ${s}`,title:`Configure DevBox for ${s}`,onClick:M=>{M.stopPropagation(),p(!1),i(t)},className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-1.5 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80",children:[e.jsx(Io,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:"Configure DevBox"})]})]}):null;return e.jsxs("div",{"data-node-action-menu":"true",className:A("relative shrink-0",D&&"z-[120]",v),onClick:M=>M.stopPropagation(),onPointerDown:M=>M.stopPropagation(),children:[e.jsx(J,{ref:j,type:"button",variant:"ghost",size:"icon","aria-label":`More actions for ${s}`,"aria-haspopup":"menu","aria-expanded":D,title:`More actions for ${s}`,onClick:M=>{M.stopPropagation(),p(Q=>(Q||b(null),!Q))},className:A("h-6 w-6 rounded-sm text-muted-foreground hover:bg-background/70 hover:text-foreground",D&&"bg-background/80 text-primary"),children:e.jsx(ul,{className:"h-3.5 w-3.5"})}),X&&(typeof document>"u"?X:La.createPortal(X,document.body))]})}function wc(t){return t?{left:t.left,top:t.top}:{left:0,top:0,visibility:"hidden"}}function yc(t,s,n,r=1){const d=s.width||160,c=s.height||0,f=Number.isFinite(r)&&r>0?r:1,h=Math.max(8,Math.min(t.right-d,n.width-d-8)),y=t.bottom+4,g=(t.top??t.bottom)-c-4,l=y+c>n.height-8&&g>=8?g:y;return{left:Math.round(h/f),top:Math.round(l/f)}}function Nc(){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 kc=new Set(["deallocated","hibernate","hibernated","sleep","sleeping","stopped"]),Sc=new Set(["startinprogress","starting"]);function Dt(t){return!!(t!=null&&t.enabled&&t.name)}function Cc(t){const s=t==null?void 0:t.trim().toLowerCase().replace(/[\s_-]+/gu,"");return!!(s&&kc.has(s))}function At(t){const s=t==null?void 0:t.trim().toLowerCase().replace(/[\s_-]+/gu,"");return!!(s&&Sc.has(s))}function ks(t,s,n){return t==="offline"&&Cc(s)&&Dt(n)}function ea(t,s){return t==="offline"&&Dt(s)}function ta(t){return!Dt(t)}function Tc({nodeStatus:t,status:s,current:n,selected:r}){const o=r??n;return o&&ks(t,s,o)?o:null}function Ie(t){return t.scope||`name:${t.name??""}`}function _c({previousKey:t,baseDevBox:s,listed:n}){if(t&&n.some(i=>Ie(i)===t))return t;if(!Dt(s))return n[0]?Ie(n[0]):"";const r=Ie(s),o=n.find(i=>Ie(i)===r)??n.find(i=>i.name===s.name);return o?Ie(o):r}function Ec(t){return t==="nodes"||t==="events"?t:"overview"}function Dc({cluster:t,systemInfo:s,nodeNameById:n,nodeBlockingTaskCounts:r,eventTypeFilter:o,onEventTypeFilterChange:i,eventTypeOptions:d,filteredEvents:c,sseConnected:f,clusterLoading:h,clusterError:y,promotePending:g,onPromote:l,onAddNode:N,leavePending:C,onLeaveCluster:v,onToggleNodeDevTunnel:D,devTunnelNodeId:p,devBoxStartNodeId:S,devBoxStartingNodeIds:b=new Set,activeTab:w,onTabChange:j,onOpenNodeSettings:_,onOpenNodeCapabilities:E,onOpenDevBox:X,onStartDevBox:M}){var H,u,q;const Q=((H=t==null?void 0:t.self)==null?void 0:H.role)==="leader",B=((u=t==null?void 0:t.self)==null?void 0:u.role)==="follower"&&!(t!=null&&t.leader),R=(t==null?void 0:t.self)??null,V=Oo((t==null?void 0:t.nodes)??[],R==null?void 0:R.id).filter(T=>T.id!==(R==null?void 0:R.id)),K=t!=null&&t.leader?t.nodes.find(T=>{var U;return T.id===((U=t.leader)==null?void 0:U.id)})??null:null,ee=t!=null&&t.leader?t.leader.dashboardOrigin??(K==null?void 0:K.dashboardOrigin)??(s&&t.leader.id===(s.nodeId??s.id)?s.dashboardOrigin:void 0)??t.leader.endpoint:null,se=(R==null?void 0:R.role)==="leader"&&V.length===0,O=(R==null?void 0:R.role)==="follower",[Z,P]=a.useState("overview"),W=w??Z;function x(T){const U=Ec(T);P(U),j==null||j(U)}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(tn,{value:W,onValueChange:x,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(en,{className:"grid h-auto w-full grid-cols-3 rounded-sm bg-muted/55 p-0.5",children:[e.jsx(vt,{value:"overview",className:"rounded-sm px-2 py-0.5 text-[10px]",children:"Overview"}),e.jsx(vt,{value:"nodes",className:"rounded-sm px-2 py-0.5 text-[10px]",children:"Nodes"}),e.jsx(vt,{value:"events",className:"rounded-sm px-2 py-0.5 text-[10px]",children:"Live events"})]})}),e.jsx(ot,{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:[R&&e.jsx(sa,{node:R,systemInfo:s,blockingTaskCount:r.get(R.id)??0,devTunnelNodeId:p,onToggleNodeDevTunnel:D,showActions:!1,defaultExpanded:!1,onOpenDevBox:X,devBoxStartingNodeIds:b}),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($e,{variant:"secondary",className:"rounded-sm border-0 bg-muted/60 px-1.5 py-0 text-[9px] leading-4 shadow-none",children:f?"Connected":"Reconnecting"})]}),h&&!t?e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground",children:[e.jsx(me,{className:"h-4 w-4 animate-spin"}),"Loading cluster state..."]}):y&&!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:y}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsx(Ct,{label:"Term",value:String((t==null?void 0:t.term)??0)}),e.jsx(Ct,{label:"Nodes",value:String((t==null?void 0:t.nodes.length)??0)}),e.jsx(Ct,{label:"Pending",value:String((t==null?void 0:t.taskSummary.pending)??0)}),e.jsx(Ct,{label:"Running",value:String((t==null?void 0:t.taskSummary.running)??0)}),e.jsx(Ct,{label:"Completed",value:String((t==null?void 0:t.taskSummary.completed)??0)}),e.jsx(Ct,{label:"Failed",value:String((t==null?void 0: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(nt,{label:"Leader",value:((q=t==null?void 0:t.leader)==null?void 0:q.name)??"None"}),e.jsx(nt,{label:"Leader URL",value:ee??"Unavailable",mono:!0,action:ee?e.jsx(Gt,{label:"Copy leader URL",onClick:()=>void Tt(ee,"Leader URL copied")}):void 0}),e.jsx(nt,{label:"Feed",value:f?"Receiving live updates":"Reconnecting to event stream"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:B&&e.jsxs(J,{variant:"secondary",size:"sm",onClick:l,disabled:g,className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",children:[g&&e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}),"Promote self"]})})]})]})]})})}),e.jsx(ot,{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"}),se?e.jsxs(J,{variant:"secondary",size:"sm",onClick:N,className:"h-6 border-0 bg-primary px-2 text-[10px] text-primary-foreground shadow-none hover:bg-primary/90",children:[e.jsx(zl,{className:"h-3 w-3"}),"Join node"]}):O?e.jsxs(J,{variant:"secondary",size:"sm",onClick:v,disabled:C,className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",children:[C&&e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}),"Leave cluster"]}):null]}),R&&e.jsx(sa,{node:R,systemInfo:s,blockingTaskCount:r.get(R.id)??0,devTunnelNodeId:p,onToggleNodeDevTunnel:D,showActions:!0,defaultExpanded:!0,onOpenNodeSettings:Q?_:void 0,onOpenNodeCapabilities:Q?E:void 0,onOpenDevBox:Q?X:void 0,onStartDevBox:Q?M:void 0,devBoxStartNodeId:S,devBoxStartingNodeIds:b})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"text-[10px] font-medium text-foreground",children:["Peer nodes (",V.length,")"]}),V.length>0?e.jsx("div",{className:"space-y-1.5",children:V.map(T=>e.jsx(Ac,{node:T,isLeader:!!Q,blockingTaskCount:r.get(T.id)??0,devTunnelNodeId:p,onToggleNodeDevTunnel:D,onOpenNodeSettings:Q?_:void 0,onOpenNodeCapabilities:Q?E:void 0,onOpenDevBox:Q?X:void 0,onStartDevBox:Q?M:void 0,devBoxStartNodeId:S,devBoxStartingNodeIds:b},T.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(ot,{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(Bo,{className:A("h-3.5 w-3.5",f?"text-emerald-500":"text-destructive")}),"Live events"]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsxs(Se,{value:o,onValueChange:i,children:[e.jsx(Ce,{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(Le,{placeholder:"Event type"})}),e.jsx(Te,{className:"shadow-none",children:d.map(T=>e.jsx(pe,{value:T,className:"py-1 pl-6 pr-1.5 text-[10px] leading-4",children:T==="all"?"All event types":T},T))})]}),e.jsx($e,{variant:"secondary",className:"rounded-sm border-0 bg-muted/60 px-1.5 py-0 text-[9px] leading-4 shadow-none",children:f?"Connected":"Reconnecting"})]})]}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(Ro,{events:c,maxHeight:"100%",emptyTitle:o==="all"?"No live events yet":"No matching events",emptyDescription:o==="all"?"Cluster activity appears here as it happens.":`No "${o}" events are in the current stream.`,nodeNameById:n,density:"compact"})})]})})]})})}function sa({node:t,systemInfo:s,blockingTaskCount:n,devTunnelNodeId:r,onToggleNodeDevTunnel:o,showActions:i=!0,defaultExpanded:d=!1,onOpenNodeSettings:c,onOpenNodeCapabilities:f,onOpenDevBox:h,onStartDevBox:y,devBoxStartNodeId:g,devBoxStartingNodeIds:l}){var E,X,M,Q;const[N,C]=a.useState(d),v=(s==null?void 0:s.dashboardOrigin)??t.dashboardOrigin,D=t.devtunnelEndpoint??t.endpoint,p=v??t.endpoint,S=(s==null?void 0:s.workDir)??t.workDir,b=Qa(t,s==null?void 0:s.transportType),w=cn(t,s==null?void 0:s.transportType),j=w&&Ot((s==null?void 0:s.transportType)??t.transportType)?!0:Ya(t,s==null?void 0:s.transportType),_=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:()=>C(B=>!B),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[N?e.jsx(Qe,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(We,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx(Ia,{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:p,target:"_blank",rel:"noreferrer",className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(an,{className:"h-3 w-3"})}),(c||f||i&&j)&&e.jsx(xn,{nodeId:t.id,nodeName:t.name,onOpenSettings:c,onOpenCapabilities:f,onOpenDevBox:h,onStartDevBox:y,onToggleRemoteAccess:i&&j?()=>o(t):void 0,remoteAccessLabel:i&&j?w?"Disable Remote Access":"Enable Remote Access":void 0,remoteAccessPending:r===t.id,remoteAccessDisabled:_,remoteAccessDisabledReason:_?"Finish assigned or running tasks before changing remote access":void 0,showConfigureDevBox:(E=t.devbox)==null?void 0:E.enabled,showStartDevBox:ks(t.status,(X=t.devbox)==null?void 0:X.lastStatus,t.devbox)||At((M=t.devbox)==null?void 0:M.lastStatus)||l.has(t.id),startDevBoxPending:g===t.id||At((Q=t.devbox)==null?void 0:Q.lastStatus)||l.has(t.id)})]}),e.jsxs("button",{type:"button",onClick:()=>C(B=>!B),className:"mt-1 flex min-w-0 items-center gap-1 pl-5 text-left",children:[e.jsx("span",{className:"text-[10px] font-semibold tracking-tight text-foreground",children:t.name}),e.jsx(Oa,{role:t.role,size:"compact"}),e.jsx($e,{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})]})]}),N&&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(nt,{label:"Node ID",value:t.id,mono:!0}),v&&e.jsx(nt,{label:"Dashboard",value:v,mono:!0,action:e.jsx(Gt,{label:"Copy dashboard URL",onClick:()=>void Tt(v,"Dashboard URL copied")})}),e.jsx(nt,{label:"Node URL",value:D,mono:!0,action:e.jsx(Gt,{label:"Copy node URL",onClick:()=>void Tt(D,"Node URL copied")})}),S&&e.jsx(nt,{label:"Workspace",value:S,mono:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[e.jsx(Vs,{label:"Transport",value:b}),s&&e.jsx(Vs,{label:"Uptime",value:$o(s.uptime),mono:!0})]}),i&&f&&e.jsxs(J,{variant:"secondary",size:"sm",onClick:()=>f(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(js,{className:"h-3 w-3"}),"Capabilities"]}),i&&j&&_&&e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function Ac({node:t,isLeader:s,blockingTaskCount:n,devTunnelNodeId:r,onToggleNodeDevTunnel:o,onOpenNodeSettings:i,onOpenNodeCapabilities:d,onOpenDevBox:c,onStartDevBox:f,devBoxStartNodeId:h,devBoxStartingNodeIds:y}){var w,j,_,E;const[g,l]=a.useState(!1),N=t.dashboardOrigin,C=t.devtunnelEndpoint??t.endpoint,v=N??t.endpoint,D=Qa(t),p=cn(t),S=Ya(t),b=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:()=>l(X=>!X),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[g?e.jsx(Qe,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):e.jsx(We,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx(Ia,{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:v,target:"_blank",rel:"noreferrer",className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(an,{className:"h-3 w-3"})}),s&&(i||d||S)&&e.jsx(xn,{nodeId:t.id,nodeName:t.name,onOpenSettings:i,onOpenCapabilities:d,onOpenDevBox:c,onStartDevBox:f,onToggleRemoteAccess:S?()=>o(t):void 0,remoteAccessLabel:S?p?"Disable Remote Access":"Enable Remote Access":void 0,remoteAccessPending:r===t.id,remoteAccessDisabled:b,remoteAccessDisabledReason:b?"Finish assigned or running tasks before changing remote access":void 0,showConfigureDevBox:(w=t.devbox)==null?void 0:w.enabled,showStartDevBox:ks(t.status,(j=t.devbox)==null?void 0:j.lastStatus,t.devbox)||At((_=t.devbox)==null?void 0:_.lastStatus)||y.has(t.id),startDevBoxPending:h===t.id||At((E=t.devbox)==null?void 0:E.lastStatus)||y.has(t.id)})]}),e.jsxs("button",{type:"button",onClick:()=>l(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(Oa,{role:t.role,size:"compact"}),e.jsx($e,{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})]})]}),g&&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(nt,{label:"Node ID",value:t.id,mono:!0}),N&&e.jsx(nt,{label:"Dashboard",value:N,mono:!0,action:e.jsx(Gt,{label:"Copy dashboard URL",onClick:()=>void Tt(N,"Dashboard URL copied")})}),e.jsx(nt,{label:"Node URL",value:C,mono:!0,action:e.jsx(Gt,{label:"Copy node URL",onClick:()=>void Tt(C,"Node URL copied")})}),t.workDir&&e.jsx(nt,{label:"Workspace",value:t.workDir,mono:!0}),e.jsx(Vs,{label:"Transport",value:D})]}),s&&d&&e.jsxs(J,{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(js,{className:"h-3 w-3"}),"Capabilities"]}),s&&S&&b&&e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function Gt({label:t,onClick:s}){return e.jsx(J,{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(Aa,{className:"h-3 w-3"})})}function Mc(t,s,n,r){var c,f;if(!t)return{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Select a task to continue the conversation."};const o=((c=s==null?void 0:s.self)==null?void 0:c.role)==="follower",i=t.assignedTo?((f=s==null?void 0:s.self)==null?void 0:f.id)===t.assignedTo?s.self:s==null?void 0:s.nodes.find(h=>h.id===t.assignedTo):void 0;return t.assignedTo!==null&&(i?i.status==="offline":s?t.assignedNodeAvailable===!1||!s.nodes.some(h=>h.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.`}:o?{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..."}:ps.has(t.status)||t.status==="archived"?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:ps.has(t.status)?"Task has not started yet...":"Archived tasks are read-only."}:{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Continue the conversation..."}}const ur=.5,mr=1.75,na=.1;function Pc({node:t,open:s,onOpenChange:n}){const[r,o]=a.useState(ts),[i,d]=a.useState(null),[c,f]=a.useState(1),[h,y]=a.useState(!1),[g,l]=a.useState(null);a.useEffect(()=>{o(ts),d(null),f(1),y(!1),l(null)},[t==null?void 0:t.id,s]);const N=a.useCallback(async b=>{if(!t)return;const w=b??Number.parseInt(r.trim()||ts,10);if(!Number.isInteger(w)||w<1||w>65535){l("Enter a port between 1 and 65535");return}y(!0),l(null);try{const j=await Fo(t.id,{port:w});d(j),o(String(w)),An("preview.created",{result:"success",previewType:"service-port"})}catch(j){l(j instanceof Error?j.message:"Failed to create service preview"),An("preview.failed",{result:"failed",previewType:"service-port"})}finally{y(!1)}},[t,r]),C=a.useCallback(()=>{typeof(i==null?void 0:i.port)=="number"&&N(i.port)},[i==null?void 0:i.port,N]);a.useEffect(()=>{if(!i)return;const b=i.expiresAt-Date.now()-5e3;if(b<=0){C();return}const w=window.setTimeout(C,b);return()=>window.clearTimeout(w)},[C,i]);const v=i?el(i):null,D=(t==null?void 0:t.name)??"Node",p=Lc(c),S={width:`${100/c}%`,height:`${100/c}%`,transform:`scale(${c})`,transformOrigin:"top left"};return e.jsx(Pt,{open:s,onOpenChange:n,children:e.jsxs(Lt,{onOpenAutoFocus:b=>b.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(Yt,{className:"flex min-w-0 items-center gap-1.5 text-[12px] font-semibold text-foreground",children:[e.jsx(Ka,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{className:"shrink-0",children:"Preview service"}),e.jsx("span",{className:"min-w-0 truncate font-mono text-[10px] font-medium text-muted-foreground",children:D})]}),e.jsx(rn,{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:b=>{b.preventDefault(),N()},children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:["Port",e.jsx(at,{type:"text",min:1,max:65535,inputMode:"numeric",value:r,onChange:b=>o(b.target.value),placeholder:ts,"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(J,{type:"submit",variant:"ghost",size:"sm",disabled:h,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:[h?e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ws,{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:Ic(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(J,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-none",onClick:()=>f(b=>aa(b,-na)),disabled:c<=ur,title:"Zoom out","aria-label":"Zoom out preview",children:e.jsx(Wl,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>f(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:p}),e.jsx(J,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-none",onClick:()=>f(b=>aa(b,na)),disabled:c>=mr,title:"Zoom in","aria-label":"Zoom in preview",children:e.jsx(ql,{className:"h-3.5 w-3.5"})})]}),e.jsx(J,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-sm",onClick:C,title:"Refresh",children:e.jsx(zo,{className:"h-3.5 w-3.5"})}),e.jsx(J,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-sm",asChild:!0,title:"Open in new tab",children:e.jsx("a",{href:v??i.previewUrl,target:"_blank",rel:"noopener noreferrer",children:e.jsx(an,{className:"h-3.5 w-3.5"})})})]})]})]}),g&&e.jsx("div",{className:"shrink-0 border-b border-destructive/20 bg-destructive/5 px-3 py-1.5 text-[11px] text-destructive",children:g}),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:sl(i),style:S,className:"h-full w-full border-0",sandbox:tl(i),title:`${D} Service Preview`})}):e.jsx("div",{className:"flex h-full min-h-56 items-center justify-center rounded-sm border border-dashed border-border/65 bg-background/35 px-3 text-center text-[11px] text-muted-foreground",children:"No service preview running."})})]})})}function aa(t,s){return xr(Math.round((t+s)*100)/100)}function xr(t){return Number.isFinite(t)?Math.min(mr,Math.max(ur,t)):1}function Lc(t){return`${Math.round(xr(t)*100)}%`}function Ic(t){const s=Math.max(0,Math.round((t-Date.now())/1e3));if(s<60)return`${s}s`;const n=Math.floor(s/60),r=s%60;return`${n}m ${r}s`}function Oc({dirPath:t,label:s,taskCount:n,collapsed:r,onToggle:o,onCreateTask:i,onOpenCapabilities:d}){return e.jsxs("div",{className:"group/project-row flex w-full items-stretch rounded-sm bg-muted/15 text-[9px] font-medium text-muted-foreground/70 transition-all duration-150 hover:bg-muted/30 hover:text-foreground active:scale-[0.98] active:bg-muted/40",children:[e.jsxs("button",{type:"button",onClick:o,"aria-expanded":!r,title:t,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-l-sm px-2 py-1 text-left",children:[e.jsx(We,{className:A("h-3 w-3 shrink-0 transition-transform duration-200",!r&&"rotate-90")}),e.jsx(Mt,{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})]}),d&&e.jsx("button",{type:"button",onClick:d,"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(js,{className:"h-2.5 w-2.5"})}),e.jsx("button",{type:"button",onClick:i,"aria-label":`New chat in ${t}`,title:`New chat in ${t}`,className:"pointer-events-none ml-auto flex h-4 w-4 shrink-0 translate-y-px self-center items-center justify-center rounded-sm text-muted-foreground/50 opacity-0 transition-all hover:bg-primary/10 hover:text-primary focus-visible:pointer-events-auto focus-visible:opacity-100 group-hover/project-row:pointer-events-auto group-hover/project-row:opacity-100",children:e.jsx(Ns,{className:"h-2.5 w-2.5"})})]})}const hr="meshy-task-sidebar-tree-state";function ra(t){return Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}function Rs(){var t;try{return((t=globalThis.window)==null?void 0:t.localStorage)??globalThis.localStorage??null}catch{return null}}function oa(t){if(!t)return{collapsedNodes:[],collapsedDirs:[]};try{const s=t.getItem(hr);if(!s)return{collapsedNodes:[],collapsedDirs:[]};const n=JSON.parse(s);return{collapsedNodes:ra(n.collapsedNodes),collapsedDirs:ra(n.collapsedDirs)}}catch{return{collapsedNodes:[],collapsedDirs:[]}}}function Bc(t,s){if(t)try{t.setItem(hr,JSON.stringify(s))}catch{}}function ia(t,s){if(!t.has(s))return t;const n=new Set(t);return n.delete(s),n}function Rc(t,s){if(!s)return null;for(const n of t){const r=n.nodeId??"__unassigned__";for(const o of n.dirs)if(o.tasks.some(i=>i.id===s))return{nodeKey:r,dirKey:`${r}::${o.path}`}}return null}function la(t,s,n){return n?{collapsedNodes:ia(t,n.nodeKey),collapsedDirs:ia(s,n.dirKey)}:{collapsedNodes:t,collapsedDirs:s}}function $c(t,s,n){const r=t.filter(c=>c.status==="completed"),o=new Set((s?r:[...r].sort((c,f)=>f.updatedAt-c.updatedAt).slice(0,on)).map(c=>c.id));n&&r.some(c=>c.id===n)&&o.add(n);const i=t.filter(c=>c.status!=="completed"||o.has(c.id)),d=r.length-o.size;return{visibleTasks:i,hiddenCompletedCount:Math.max(0,d)}}const ns="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",as="py-1 pl-6 pr-1.5 text-[10px] leading-4 [&_svg]:h-3 [&_svg]:w-3";function da({toolbarTasks:t,activeTaskId:s,tasksLoading:n,tasksError:r,isLeader:o,scope:i,agentFilter:d,nodeFilter:c,taskKindFilter:f,agentOptions:h,nodeOptions:y,nodeNameById:g,nodeWorkDirById:l,nodeStatusById:N,completedGroupByKey:C,devBoxNodeIds:v=new Set,devBoxStartNodeIds:D=new Set,devBoxStartingNodeIds:p=new Set,leaderNodeId:S,searchQuery:b,selectedTaskIds:w,allVisibleTasksSelected:j,someVisibleTasksSelected:_,canBatchArchive:E,onScopeChange:X,onAgentFilterChange:M,onNodeFilterChange:Q,onTaskKindFilterChange:B,onToggleTaskSelected:R,onToggleAllVisibleTasks:ne,onBatchArchive:V,onBatchDelete:K,onCreateTask:ee,onOpenNodeSettings:se,onOpenNodeCapabilities:O,onOpenProjectCapabilities:Z,onOpenDevBox:P,onStartDevBox:W,onLoadCompletedTasks:x,onSelectTask:H}){const[u,q]=a.useState(!1),[T,U]=a.useState(()=>w.size>0),[L,le]=a.useState(null),{markScrollbarActive:oe,scrollbarActive:de}=or(),G=w.size,F=!!(o&&(T||G>0)),te=i!=="active"||c!=="all"||d!=="all"||f!=="all",ce=b.trim().length>0,[k,$]=a.useState(()=>new Set(oa(Rs()).collapsedNodes)),[ue,we]=a.useState(()=>new Set(oa(Rs()).collapsedDirs)),[Fe,ze]=a.useState(new Set),Ue=a.useMemo(()=>Ho(t,g,S,l),[t,g,S,l]),_e=a.useMemo(()=>Rc(Ue,s),[Ue,s]),it=a.useRef(null),He=Ue.length===1,Ze=Ue.length>0,ae=He&&(te||ce),fe=!!(o&&(Ue.length>0||G>0)),ye=a.useCallback(z=>{$(xe=>{const De=new Set(xe);return De.has(z)?De.delete(z):De.add(z),De})},[]),Ee=a.useCallback(z=>{we(xe=>{const De=new Set(xe);return De.has(z)?De.delete(z):De.add(z),De})},[]),lt=a.useCallback(z=>{ze(xe=>{const De=new Set(xe);return De.add(z),De})},[]);a.useEffect(()=>{Bc(Rs(),{collapsedNodes:Array.from(k),collapsedDirs:Array.from(ue)})},[ue,k]),a.useEffect(()=>{if(!_e||!s)return;const z=`${s}:${_e.nodeKey}:${_e.dirKey}`;it.current!==z&&(it.current=z,$(xe=>la(xe,new Set,_e).collapsedNodes),we(xe=>la(new Set,xe,_e).collapsedDirs))},[s,_e]);const Ne=a.useCallback(z=>{U(!0),ne(z)},[ne]),Ge=a.useCallback(()=>{ne(!1),U(!1)},[ne]);a.useEffect(()=>{o||U(!1)},[o]);const wt=F?e.jsxs("label",{className:"flex items-center gap-[5px] text-[9px] font-medium uppercase tracking-[0.12em] text-muted-foreground/75",children:[e.jsx(Kt,{className:"h-3 w-3 [&_svg]:h-2.5 [&_svg]:w-2.5",checked:_&&!j?"indeterminate":j,onCheckedChange:z=>Ne(z===!0),"aria-label":"Select all visible tasks"}),e.jsx("span",{children:"Multi select"})]}):e.jsxs(J,{variant:"ghost",size:"sm",onClick:()=>U(!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(qi,{className:"h-3 w-3"}),"Multi select"]}),yt=G>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:[G," task",G!==1?"s":""," selected"]}),!E&&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,Oe=G>0?e.jsxs("div",{className:"flex flex-wrap justify-end gap-1",children:[e.jsxs(is,{children:[e.jsx(Hs,{asChild:!0,children:e.jsxs(J,{variant:"ghost",size:"sm",disabled:!E,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(al,{}),"Archive"]})}),e.jsxs(ls,{children:[e.jsxs(ds,{children:[e.jsxs(cs,{children:["Archive ",G," task",G!==1?"s":"","?"]}),e.jsx(us,{children:"Archived tasks stay hidden from the default task view and can be reopened from the archived scope."})]}),e.jsxs(ms,{children:[e.jsx(xs,{children:"Cancel"}),e.jsx(hs,{onClick:V,disabled:!E,children:"Archive"})]})]})]}),e.jsxs(is,{children:[e.jsx(Hs,{asChild:!0,children:e.jsxs(J,{variant:"destructive",size:"sm",className:"h-5 gap-1 rounded-sm px-1.5 text-[8px] [&_svg]:size-3",children:[e.jsx(Ra,{}),"Delete"]})}),e.jsxs(ls,{children:[e.jsxs(ds,{children:[e.jsxs(cs,{children:["Delete ",G," task",G!==1?"s":"","?"]}),e.jsx(us,{children:"This removes the selected tasks and their saved logs."})]}),e.jsxs(ms,{children:[e.jsx(xs,{children:"Cancel"}),e.jsx(hs,{onClick:K,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(J,{onClick:()=>ee("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(Ns,{className:"h-3.5 w-3.5"}),"New chat"]}),e.jsxs(J,{variant:"outline",onClick:()=>ee("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(dn,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Load session"]})]}),e.jsx(J,{variant:"ghost",size:"icon",onClick:()=>q(z=>!z),className:A("ml-auto h-8 w-8 shrink-0 rounded-sm text-muted-foreground shadow-none hover:bg-muted/55 hover:text-foreground",(u||te)&&"bg-primary/8 text-primary hover:bg-primary/12 hover:text-primary"),title:"Filters",children:e.jsx(bl,{className:"h-3.5 w-3.5"})})]}),(u||te)&&e.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-1 sm:grid-cols-2",children:[e.jsxs(Se,{value:i,onValueChange:z=>X(z),children:[e.jsx(Ce,{className:ns,children:e.jsx(Le,{})}),e.jsx(Te,{children:Uo.map(z=>e.jsx(pe,{value:z.value,className:as,children:z.label},z.value))})]}),e.jsxs(Se,{value:c,onValueChange:Q,children:[e.jsx(Ce,{className:ns,children:e.jsx(Le,{placeholder:"Node"})}),e.jsx(Te,{children:y.map(z=>e.jsx(pe,{value:z.value,className:as,children:z.label},z.value))})]}),e.jsxs(Se,{value:d,onValueChange:M,children:[e.jsx(Ce,{className:ns,children:e.jsx(Le,{placeholder:"Agent"})}),e.jsx(Te,{children:h.map(z=>e.jsx(pe,{value:z,className:as,children:z==="all"?"All agents":z},z))})]}),e.jsxs(Se,{value:f,onValueChange:z=>B(z),children:[e.jsx(Ce,{className:ns,children:e.jsx(Le,{placeholder:"Type"})}),e.jsx(Te,{children:Vo.map(z=>e.jsx(pe,{value:z.value,className:as,children:z.label},z.value))})]})]})]}),e.jsx("div",{className:A("scrollbar-line min-h-0 flex-1 overflow-y-auto pl-2.5 pr-1.5 py-2",de&&"scrollbar-line-active"),onScroll:oe,children:Ue.length>0?e.jsx("div",{className:"space-y-1",children:Ue.map(z=>{const xe=z.nodeId??"__unassigned__",De=z.dirs.reduce((Me,Be)=>Me+Be.tasks.length,0),ut=Ze&&!ae&&k.has(xe),pt=z.nodeId!==null&&N.get(z.nodeId)==="offline",Nt=!!(o&&z.nodeId);return e.jsxs("div",{className:"space-y-1",children:[Ze&&e.jsxs("div",{className:"flex w-full items-stretch rounded-sm bg-gradient-to-r from-primary/8 to-muted/20 text-left text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground transition-all duration-150 hover:from-primary/12 hover:to-muted/30 hover:text-foreground active:scale-[0.99] active:from-primary/15",children:[e.jsxs("button",{type:"button",onClick:()=>ye(xe),"aria-expanded":!ut,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-sm px-2 py-1.5 text-left",children:[e.jsx(We,{className:A("h-3.5 w-3.5 shrink-0 transition-transform duration-200",!ut&&"rotate-90")}),e.jsx(Ta,{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:z.nodeName}),e.jsxs($e,{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:[De," task",De===1?"":"s"]})]}),e.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[pt&&e.jsx($e,{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"}),z.nodeId===S&&e.jsx($e,{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"})]})]}),Nt&&z.nodeId&&e.jsx("span",{className:"flex shrink-0 items-center pr-1.5",children:e.jsx(xn,{nodeId:z.nodeId,nodeName:z.nodeName,onOpenSettings:se,onOpenServicePreview:()=>le({id:z.nodeId,name:z.nodeName}),onOpenCapabilities:O,onOpenDevBox:P,onStartDevBox:W,showConfigureDevBox:v.has(z.nodeId),showStartDevBox:D.has(z.nodeId)||p.has(z.nodeId),startDevBoxPending:p.has(z.nodeId)})})]}),e.jsx("div",{className:A("grid transition-[grid-template-rows] duration-300 ease-in-out",ut?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:"overflow-hidden",children:z.dirs.map(Me=>{const Be=`${xe}::${Me.path}`,kt=ue.has(Be),ft=Ba(Me.path),Xe=C==null?void 0:C.get(Be),gt=Xe?{visibleTasks:Me.tasks,hiddenCompletedCount:Math.max(0,Xe.total-Xe.returned)}:$c(Me.tasks,Fe.has(Be),s),{visibleTasks:Bt,hiddenCompletedCount:dt}=gt;return e.jsxs("div",{className:A("space-y-0.5 rounded-xl",Ze&&"pl-2.5"),children:[e.jsx(Oc,{dirPath:Me.path,label:ft,taskCount:Me.tasks.length,collapsed:kt,onToggle:()=>Ee(Be),onCreateTask:()=>ee("chat",{assignTo:z.nodeId,project:Me.path==="default workspace"?"":Me.path}),onOpenCapabilities:z.nodeId&&Z?()=>Z(z.nodeId,Me.path==="default workspace"?(l==null?void 0:l.get(z.nodeId))??Me.path:Me.path):void 0}),e.jsx("div",{className:A("grid transition-[grid-template-rows] duration-300 ease-in-out",kt?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:A("overflow-hidden",Ze?"pl-2":"pl-0"),children:e.jsxs("div",{className:"space-y-px py-0.5",children:[Bt.map(ke=>{const ct=ke.id===s,mt=ke.assignedTo?N.get(ke.assignedTo):void 0,Pe=!!ke.assignedTo&&(mt?mt==="offline":ke.assignedNodeAvailable===!1);return e.jsxs("div",{className:A("animate-task-row-reveal relative flex items-center gap-1.5 rounded-sm px-2 py-1.5 transition-all duration-150",ct?'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:[F&&e.jsx("div",{className:"flex shrink-0",onClick:ve=>ve.stopPropagation(),children:e.jsx(Kt,{className:"h-3 w-3 [&_svg]:h-2.5 [&_svg]:w-2.5",checked:w.has(ke.id),onCheckedChange:ve=>R(ke.id,ve===!0),"aria-label":`Select ${ke.title}`})}),e.jsxs("button",{type:"button",onClick:()=>H(ke.id),"aria-current":ct?"page":void 0,className:"relative min-w-0 flex-1 pr-8 text-left",children:[e.jsx("div",{className:"flex items-center gap-1.5 pr-1",children:e.jsx("span",{className:A("min-w-0 flex-1 truncate text-[10px] font-medium leading-4",ct?"text-foreground":"text-foreground/80"),children:ke.title})}),e.jsx("span",{className:A("absolute right-0 top-0 shrink-0 tabular-nums text-[8px] leading-4",ct?"text-primary/75":"text-muted-foreground/55"),children:qo(ke.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:ke.agent}),ke.activeShare&&e.jsx($e,{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"}),Pe&&e.jsx($e,{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(Ma,{status:ke.status,isNative:ke.conversationKind==="nativeSession",size:"compact",className:"absolute bottom-1 right-0"})]})]},ke.id)}),dt>0&&e.jsxs("button",{type:"button",onClick:()=>{Xe&&x?x(Xe):lt(Be)},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 ${dt} more completed tasks in ${ft}`,children:[e.jsx(Qe,{className:"h-3 w-3"}),"Load ",dt," more completed"]})]})})})]},Be)})})})]},xe)})}):n?e.jsx("div",{className:"space-y-2 px-1",children:[1,2,3].map(z=>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+z*12}%`,animationDelay:`${z*120}ms`}}),e.jsx("div",{className:"h-2 w-24 animate-pulse rounded-full bg-muted-foreground/10",style:{animationDelay:`${z*120+60}ms`}})]})]})},z))}):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."})}),fe?e.jsx("div",{className:"shrink-0 px-2.5 pb-2.5 pt-1.5",children:F&&G>0?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[yt,e.jsx(J,{variant:"ghost",size:"sm",onClick:Ge,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:wt}),Oe]})]}):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:wt}),F&&e.jsx(J,{variant:"ghost",size:"sm",onClick:Ge,className:"h-5 shrink-0 rounded-sm px-1.5 text-[9px]",children:"Done"})]})}):null]}),e.jsx(Pc,{node:L,open:L!==null,onOpenChange:z=>{z||le(null)}})]})}async function Fc(t,s){var n,r;try{const o=await Ko(t,s),i={...o,url:Da(o.url)};if((r=(n=globalThis.navigator)==null?void 0:n.clipboard)!=null&&r.writeText)try{await globalThis.navigator.clipboard.writeText(i.url),ie.success("Shared link copied")}catch{ie.success("Shared link created")}else ie.success("Shared link created");return i}catch(o){ie.error(o instanceof Error?o.message:"Failed to create shared link");return}}async function zc(t){try{return await Wo(t),ie.success("Shared link stopped"),!0}catch(s){return ie.error(s instanceof Error?s.message:"Failed to stop shared link"),!1}}function Hc(t,s,n){const r=a.useCallback(()=>{s(),n()},[s,n]),o=a.useCallback(async d=>{if(!t)return;const c=await Fc(t.id,d);return c&&r(),c},[t,r]),i=a.useCallback(async()=>{if(!t)return!1;const d=await zc(t.id);return d&&r(),d},[t,r]);return{handleShareTask:o,handleStopShareTask:i}}function ca(t,s,n){const r=a.useRef(s);r.current=s,a.useEffect(()=>{let d=0,c=0;const f=g=>{const l=g.touches[0];l&&(d=l.clientX,c=l.clientY)},h=g=>{var v,D,p,S;const l=g.changedTouches[0];if(!l)return;const N=l.clientX-d;Math.abs(l.clientY-c)>100||Math.abs(N)<50||(N>0?(D=(v=r.current).onSwipeRight)==null||D.call(v):(S=(p=r.current).onSwipeLeft)==null||S.call(p))},y=(t==null?void 0:t.current)??document;return y.addEventListener("touchstart",f,{passive:!0}),y.addEventListener("touchend",h,{passive:!0}),()=>{y.removeEventListener("touchstart",f),y.removeEventListener("touchend",h)}},[t,n==null?void 0:n.threshold,n==null?void 0:n.maxVertical])}const Uc="(min-width: 1024px)",Vc="(min-width: 1800px)";function ua(t){var s,n,r;return((r=(n=(s=globalThis.window)==null?void 0:s.matchMedia)==null?void 0:n.call(s,t))==null?void 0:r.matches)??!1}function qc(){var n,r;const t=(n=globalThis.document)==null?void 0:n.documentElement;if(!t||!((r=globalThis.window)!=null&&r.getComputedStyle))return 16;const s=Number.parseFloat(globalThis.window.getComputedStyle(t).fontSize);return Number.isFinite(s)&&s>0?s:16}function Kc(){const[t,s]=a.useState(()=>Go(Mn(),Yo({operationsOpen:ua(Vc)}))),[n,r]=a.useState(!1),o=a.useRef(null),i=a.useRef(null),d=a.useRef(null),c=t.layout.desktopTasksOpen,f=t.layout.operationsOpen,h=t.sizes;a.useEffect(()=>{Qo(Mn(),t)},[t]);const y=a.useCallback((D,p)=>{s(S=>{const b=S.layout[D],w=typeof p=="function"?p(b):p;return w===b?S:{...S,layout:{...S.layout,[D]:w}}})},[]),g=a.useCallback(D=>{y("desktopTasksOpen",D)},[y]),l=a.useCallback(D=>{y("operationsOpen",D)},[y]);ca(i,{onSwipeLeft:()=>r(!1)}),ca(d,{onSwipeRight:()=>l(!1)});const N=a.useCallback(()=>{if(ua(Uc)){g(D=>!D);return}r(D=>!D)},[g]);a.useEffect(()=>{var S,b,w;const D=j=>{const _=o.current;if(!_)return;j.preventDefault();const E=Xo(_.panel,_.startSize,_.startClientX,_.startClientY,j.clientX,j.clientY,_.rootFontSize);s(X=>({...X,sizes:{...X.sizes,[_.panel]:E}}))},p=()=>{o.current=null};return(S=globalThis.window)==null||S.addEventListener("pointermove",D),(b=globalThis.window)==null||b.addEventListener("pointerup",p),(w=globalThis.window)==null||w.addEventListener("pointercancel",p),()=>{var j,_,E;(j=globalThis.window)==null||j.removeEventListener("pointermove",D),(_=globalThis.window)==null||_.removeEventListener("pointerup",p),(E=globalThis.window)==null||E.removeEventListener("pointercancel",p)}},[]);const C=a.useCallback((D,p)=>{var S,b;p.preventDefault(),(b=(S=p.currentTarget).setPointerCapture)==null||b.call(S,p.pointerId),o.current={panel:D,startSize:h[D],startClientX:p.clientX,startClientY:p.clientY,rootFontSize:qc()}},[h]),v=a.useCallback((D,p)=>{p.preventDefault(),s(S=>({...S,sizes:{...S.sizes,[D]:Zo(D,S.sizes[D],p.deltaY)}}))},[]);return{desktopTasksOpen:c,mobileTasksPanelOpen:n,mobileTasksPanelRef:i,operationsOpen:f,operationsPanelRef:d,panelResize:{sizes:{tasks:Ps(h.tasks),operations:Ps(h.operations),terminal:Ps(h.terminal)},onPointerDown:C,onWheel:v},setMobileTasksPanelOpen:r,setOperationsOpen:l,toggleTasksPanel:N}}function Wc(t,s){const n=s.taskId,r=s.updates;return typeof n!="string"||!r||typeof r!="object"?t:t.map(o=>o.id===n?{...o,...r}:o)}const Gc="notify_desktop_task";function Yc(t=pr()){var n,r;const s=(r=(n=t==null?void 0:t.__TAURI__)==null?void 0:n.core)==null?void 0:r.invoke;return typeof s=="function"?s:null}async function Qc(t,s=pr()){const n=Yc(s);return n?(await n(Gc,t),!0):!1}function Zc(t,s){const n=[];for(const r of s){const o=Xc(r.status);if(!o)continue;const i=t.get(r.id);!i||i.status===r.status||n.push({taskId:r.id,title:r.title.trim()||"Meshy task",status:o,assignedNodeName:r.assignedNodeName??null,projectPath:r.effectiveProjectPath??r.project??null})}return n}function Xc(t){return t==="completed"||t==="failed"?t:null}function pr(){return typeof window>"u"?null:window}function Jc({isLeader:t,selfId:s}){return{...!t&&s?{assignedTo:s}:{},completedLimitPerProject:on}}function Js(t){return`${t.assignedTo??"__unassigned__"}::${t.projectPath}`}function eu(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 tu(t,s,n=new Set){return!s||n.has(s.id)||t.some(r=>r.id===s.id)?t:Za(t,s)}function su({isLeader:t,selfId:s,sseConnected:n,preservedTask:r,subscribe:o}){const[i,d]=a.useState([]),[c,f]=a.useState([]),[h,y]=a.useState(!0),[g,l]=a.useState(null),N=a.useRef(new Set),C=a.useRef(null),v=a.useRef(null),D=a.useCallback(async()=>{try{const w=await Pn(Jc({isLeader:t,selfId:s}));d(tu(w.tasks,r,N.current)),f(w.completedGroups??[]),l(null)}catch(w){l(w instanceof Error?w.message:"Failed to load tasks")}finally{y(!1)}},[t,r,s]),p=a.useCallback(async w=>{if(!w.hasMore||!w.nextCursor)return;const j=await Pn({status:"completed",assignedTo:w.assignedTo??"__unassigned__",projectPath:w.projectPath,cursor:w.nextCursor,limit:on});d(_=>eu(_,j.tasks)),f(_=>_.map(E=>Js(E)===Js(w)?{...E,returned:Math.min(E.total,E.returned+j.tasks.length),hasMore:j.hasMore===!0,nextCursor:j.nextCursor??null}:E))},[]),S=a.useCallback(()=>{v.current===null&&(v.current=window.setTimeout(()=>{v.current=null,D()},Jo))},[D]),b=a.useCallback(w=>{const j=new Set(w);if(j.size!==0){for(const _ of j)N.current.add(_);d(_=>_.filter(E=>!j.has(E.id)))}},[]);return ei(D,ni(n)),a.useEffect(()=>()=>{v.current!==null&&(window.clearTimeout(v.current),v.current=null)},[]),a.useEffect(()=>{const w=C.current;if(w)for(const j of Zc(w,i))Qc(j).catch(()=>{});C.current=new Map(i.map(j=>[j.id,j]))},[i]),a.useEffect(()=>{const w=[o("task.updated",j=>{d(_=>Wc(_,j.data))}),o("task.status",j=>{d(_=>ti(_,j.data))}),o("node",j=>{Ln(j.type)&&S()}),o("task",j=>{if(j.type==="task.deleted"){const _=j.data.taskId;typeof _=="string"&&N.current.add(_),d(E=>si(E,j.data))}Ln(j.type)&&S()})];return()=>w.forEach(j=>j())},[o,S]),{completedGroups:c,fetchTasks:D,loadCompletedTasksPage:p,removeTasksFromList:b,setTasks:d,tasks:i,tasksError:g,tasksLoading:h}}function fr(t){return t.map(s=>({...s}))}function nu(t,s){const n=s.get(t);return{logs:n?fr(n.logs):[],transcriptLoading:(n==null?void 0:n.loaded)!==!0}}function au(t,s){return s.data.nodeId===t.self.id||s.data.name===t.self.name||s.data.endpoint===t.self.endpoint}function ru(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==null?void 0:s.get(r))??r:"node"}function ou({cluster:t,subscribe:s}){a.useEffect(()=>{var r;if(((r=t==null?void 0:t.self)==null?void 0:r.role)!=="leader")return;const n=new Map(t.nodes.map(o=>[o.id,o.name]));return n.set(t.self.id,t.self.name),s("node",o=>{const i=ru(o,n),d=au(t,o);o.type==="node.joined"&&!d&&ie.success(`${i} joined the cluster`),o.type==="node.left"&&!d&&ie.message(`${i} left the cluster`)})},[t,s])}const iu=[0,300,1e3,2e3];function lu({task:t,getActiveTaskId:s,setLogs:n,setPendingMessages:r,setTranscriptLoading:o}){t.conversationKind==="nativeSession"&&(async()=>{try{for(const i of iu){if(i>0&&await new Promise(d=>setTimeout(d,i)),s()!==t.id)return;try{const d=await Us(t.id);if(s()!==t.id||(n(c=>Va(c,d.logs)),r(c=>qs(c,d.logs)),d.total>0))return}catch{}}}finally{s()===t.id&&(o==null||o(!1))}})()}const gr=8;function du(t,s){return Ie(t??{})===Ie(s??{})}function cu(t){return t&&"status"in t&&typeof t.status=="string"?t.status:void 0}function ma(t,s){return{...t,enabled:!0,alwaysOnline:s}}function br(t){var s,n;return((s=t==null?void 0:t.status)==null?void 0:s.trim())||((n=t==null?void 0:t.lastStatus)==null?void 0:n.trim())||"Unknown"}function uu({operationStarting:t,loading:s,refreshing:n,savedStatus:r,fallbackStatus:o}){return t?"Starting":s?"Listing DevBoxes":n?"Refreshing":r??o}async function mu(t,s=$a){return(await s({nodeId:t,kind:"devbox.start"})).filter(r=>r.kind==="devbox.start").sort((r,o)=>(o.updatedAt??o.createdAt)-(r.updatedAt??r.createdAt)).slice(0,gr)}function xu(t){return t.charAt(0).toUpperCase()+t.slice(1)}function hu(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 pu(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function xa(t,s){const n=pu(t),r=n==null?void 0:n[s];return typeof r=="string"&&r.trim()?r.trim():null}function fu(t){if(t.status==="failed")return t.error||"Operation failed";const s=xa(t.result,"operationId");if(s)return`MCP operation ${s}`;const n=xa(t.payload,"previousStatus");return n?`Previous DevBox status: ${n}`:t.status==="succeeded"?"Completed":"Waiting for completion"}function gu(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 ha({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:br(t)})]})}function bu({error:t,loading:s,onToggle:n,open:r,operations:o}){return e.jsxs("div",{className:"min-w-0 max-w-full overflow-hidden rounded-sm border border-border/60 bg-muted/20 text-xs",children:[e.jsxs("button",{type:"button",onClick:n,"aria-expanded":r,className:"flex h-8 w-full items-center gap-2 px-3 text-left text-[11px] text-foreground hover:bg-muted/30",children:[e.jsx(Qe,{className:A("h-3 w-3 shrink-0 text-muted-foreground transition-transform",!r&&"-rotate-90")}),e.jsx(gs,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:"Operations history"}),s&&e.jsx(me,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground"}),!s&&o.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:o.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&&o.length===0&&e.jsxs("div",{className:"flex h-7 items-center gap-2 px-1 text-[10px] text-muted-foreground",children:[e.jsx(me,{className:"h-3 w-3 animate-spin"}),"Loading operations"]}),t&&e.jsx("div",{className:"px-1 py-1 text-[10px] text-destructive",children:t}),!s&&!t&&o.length===0&&e.jsx("div",{className:"px-1 py-1 text-[10px] text-muted-foreground",children:"No DevBox operations yet."}),o.map(i=>{const d=fu(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:hu(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:d,children:e.jsx("span",{className:"inline-block min-w-max",children:d})})]}),e.jsx("span",{className:A("shrink-0 rounded-sm border px-1.5 py-0 text-[10px] leading-4",gu(i.status)),children:xu(i.status)})]},i.id)})]})]})}function vu({node:t,open:s,startInProgress:n=!1,onOpenChange:r,onRefresh:o}){const i=(t==null?void 0:t.id)??null,d=s&&!n&&ea(t==null?void 0:t.status,(t==null?void 0:t.devbox)??null),[c,f]=a.useState([]),[h,y]=a.useState(()=>t!=null&&t.devbox?Ie(t.devbox):""),[g,l]=a.useState(()=>(t==null?void 0:t.devbox)??null),[N,C]=a.useState(()=>ta((t==null?void 0:t.devbox)??null)),[v,D]=a.useState(!1),[p,S]=a.useState(d),[b,w]=a.useState(!1),[j,_]=a.useState(!1),[E,X]=a.useState(()=>{var k;return((k=t==null?void 0:t.devbox)==null?void 0:k.alwaysOnline)===!0}),[M,Q]=a.useState(!1),[B,R]=a.useState([]),[ne,V]=a.useState(!1),[K,ee]=a.useState(null),se=a.useMemo(()=>{const k=c.find($=>Ie($)===h);return k||(Dt(g)&&Ie(g)===h?g:void 0)},[g,c,h]),O=cu(se??void 0),Z=N?O??(g==null?void 0:g.lastStatus):(g==null?void 0:g.lastStatus)??O,P=(t==null?void 0:t.status)==="online"||(t==null?void 0:t.status)==="busy"?"Running":"Unknown",W=j||n,x=uu({operationStarting:W,loading:v,refreshing:p,savedStatus:Z,fallbackStatus:P}),H=N&&!!se&&!du(g,se),u=(g==null?void 0:g.alwaysOnline)===!0!==E,q=Tc({nodeStatus:t==null?void 0:t.status,status:x,current:g,selected:se}),T=!!q,U=!!se&&(H||u)&&!T,L=se??g,le=a.useCallback(async()=>{if(i){S(!0);try{const k=await ai(i);l(k.devbox),y(Ie(k.devbox))}catch(k){ie.error(k instanceof Error?k.message:"Failed to refresh DevBox status")}finally{S(!1)}}},[i]),oe=a.useCallback(async k=>{D(!0);try{const $=await ri();f($),y(ue=>_c({previousKey:ue,baseDevBox:k,listed:$}))}catch($){ie.error($ instanceof Error?$.message:"Failed to load DevBoxes")}finally{D(!1)}},[]);a.useEffect(()=>{if(!s||!i)return;let k=!1;const $=(t==null?void 0:t.devbox)??null,ue=ta($),we=!n&&ea(t==null?void 0:t.status,$);D(!1),S(we),C(ue),l($),X(($==null?void 0:$.alwaysOnline)===!0),Q(!1),y(Dt($)?Ie($):""),f([]);async function Fe(){we&&await le(),!k&&ue&&await oe($)}return Fe(),()=>{k=!0}},[oe,t==null?void 0:t.devbox,t==null?void 0:t.status,i,s,le,n]),a.useEffect(()=>{if(!s||!i)return;let k=!1;const $=i;async function ue(){V(!0),ee(null),R([]);try{const we=await mu($);if(k)return;R(we)}catch(we){if(k)return;R([]),ee(we instanceof Error?we.message:"Failed to load operation history")}finally{k||V(!1)}}return ue(),()=>{k=!0}},[i,s]);async function de(){C(!0),c.length===0&&await oe(g)}async function G(){if(!(!t||!se)){w(!0);try{const k=await In(t.id,ma(se,E));l(k.node.devbox??null),k.node.devbox&&y(Ie(k.node.devbox)),C(!1),ie.success(`Configured DevBox for ${t.name}`),await(o==null?void 0:o())}catch(k){ie.error(k instanceof Error?k.message:"Failed to configure DevBox")}finally{w(!1)}}}async function F(){if(!(!t||!q)){_(!0);try{if(se&&(H||u)){const $=await In(t.id,ma(se,E));l($.node.devbox??null),$.node.devbox&&y(Ie($.node.devbox)),C(!1)}const{operation:k}=await Fa(t.id);l($=>$&&{...$,lastStatus:"Starting",checkedAt:Date.now(),operationId:k.id}),R($=>[k,...$.filter(ue=>ue.id!==k.id)].slice(0,gr)),ie.success(`Start requested for ${t.name}`),await(o==null?void 0:o())}catch(k){ie.error(k instanceof Error?k.message:"Failed to start DevBox")}finally{_(!1)}}}const te=v?"Loading DevBoxes...":c.length===0?"No DevBoxes available":"Select a DevBox",ce=x==="Running"&&(t==null?void 0:t.status)==="offline";return e.jsx(Pt,{open:s,onOpenChange:r,children:e.jsxs(Lt,{className:"w-[calc(100vw-2rem)] max-w-md grid-cols-[minmax(0,1fr)] gap-3 overflow-hidden rounded-sm p-4",children:[e.jsxs(nn,{className:"min-w-0 max-w-full space-y-1 overflow-hidden",children:[e.jsx(Yt,{className:"text-sm",children:"Configure DevBox"}),e.jsxs(rn,{className:"max-w-full text-xs",children:["Bind ",t!=null&&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:[(N||L)&&e.jsxs("div",{className:"flex min-h-9 w-full min-w-0 max-w-full items-center justify-between gap-3 overflow-hidden rounded-sm border border-border/60 bg-muted/20 px-3 py-2 text-xs",children:[e.jsx("div",{className:"min-w-0 flex-1",children:N?e.jsxs(Se,{value:h,onValueChange:y,disabled:v||b||j||c.length===0,children:[e.jsx(Ce,{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:v&&!se?e.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}),te]}):se?e.jsx(ha,{devbox:se}):e.jsx(Le,{placeholder:te})}),e.jsx(Te,{children:c.map(k=>e.jsx(pe,{value:Ie(k),textValue:`${k.name} ${k.projectName??""} ${br(k)}`,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(ha,{devbox:k,showStatus:!0})},Ie(k)))})]}):L&&e.jsxs("div",{className:"min-w-0 truncate",children:[e.jsx("span",{className:"font-medium text-foreground",children:L.name}),L.projectName&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",L.projectName]})]})}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs($e,{variant:"outline",className:"rounded-sm px-1.5 py-0 text-[10px]",children:[(v||p)&&e.jsx(me,{className:"mr-1 h-2.5 w-2.5 animate-spin"}),x]}),(g==null?void 0:g.name)&&e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>{de()},disabled:v||b||W||N,"aria-label":"Edit DevBox binding",title:"Edit DevBox binding",className:"h-6 w-6 rounded-sm text-muted-foreground hover:text-foreground",children:v&&N?e.jsx(me,{className:"h-3 w-3 animate-spin"}):e.jsx(It,{className:"h-3 w-3"})})]})]}),ce&&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(Kt,{checked:E,onCheckedChange:k=>X(k===!0),disabled:b||j||W,"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(bu,{error:K,loading:ne,onToggle:()=>Q(k=>!k),open:M,operations:B})]}),e.jsxs(Pa,{className:"gap-2 sm:space-x-0",children:[e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>r(!1),disabled:b||j,className:"h-8 rounded-sm text-xs",children:"Close"}),T&&e.jsxs(J,{size:"sm",onClick:F,disabled:j,className:"h-8 rounded-sm text-xs",children:[j?e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ws,{className:"h-3.5 w-3.5"}),"Start DevBox"]}),!T&&e.jsxs(J,{size:"sm",onClick:G,disabled:!U||b,className:"h-8 rounded-sm text-xs",children:[b&&e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}),"Save"]})]})]})})}async function ju(t,s=$a){if(t.length===0)return new Set;const n=new Set(t),[r,o]=await Promise.all([s({kind:"devbox.start",status:"queued"}),s({kind:"devbox.start",status:"running"})]);return new Set([...r,...o].filter(i=>n.has(i.nodeId)).map(i=>i.nodeId))}function wu({cluster:t,refresh:s}){const[n,r]=a.useState(null),[o,i]=a.useState(null),[d,c]=a.useState(()=>new Set),[f,h]=a.useState(()=>new Set),y=a.useMemo(()=>(t==null?void 0:t.nodes.find(p=>p.id===n))??null,[t==null?void 0:t.nodes,n]),g=a.useMemo(()=>new Set(((t==null?void 0:t.nodes)??[]).filter(p=>{var S;return(S=p.devbox)==null?void 0:S.enabled}).map(p=>p.id)),[t==null?void 0:t.nodes]),l=a.useMemo(()=>new Set(((t==null?void 0:t.nodes)??[]).filter(p=>{var S;return ks(p.status,(S=p.devbox)==null?void 0:S.lastStatus,p.devbox)}).map(p=>p.id)),[t==null?void 0:t.nodes]),N=a.useMemo(()=>new Set(((t==null?void 0:t.nodes)??[]).filter(p=>{var S;return At((S=p.devbox)==null?void 0:S.lastStatus)}).map(p=>p.id)),[t==null?void 0:t.nodes]),C=a.useMemo(()=>{const p=new Set(d);o&&p.add(o);for(const S of f)p.add(S);for(const S of N)p.add(S);return p},[f,o,d,N]);a.useEffect(()=>{let p=!1;const S=[...g];async function b(){try{const w=await ju(S);p||h(w)}catch{p||h(new Set)}}return b(),()=>{p=!0}},[g]),a.useEffect(()=>{c(p=>{var w;let S=!1;const b=new Set(p);for(const j of p){const _=t==null?void 0:t.nodes.find(E=>E.id===j);(_==null?void 0:_.status)!=="online"&&(!((w=_==null?void 0:_.devbox)!=null&&w.lastStatus)||At(_.devbox.lastStatus))||(b.delete(j),S=!0)}return S?b:p})},[t==null?void 0:t.nodes]);const v=a.useCallback(async p=>{const S=t==null?void 0:t.nodes.find(b=>b.id===p);if(S){i(p),c(b=>new Set(b).add(p));try{await Fa(p),ie.success(`Start requested for ${S.name}`),s()}catch(b){c(w=>{const j=new Set(w);return j.delete(p),j}),ie.error(b instanceof Error?b.message:"Failed to start DevBox")}finally{i(null)}}},[t==null?void 0:t.nodes,s]);return{devBoxDialog:e.jsx(vu,{node:y,open:n!==null,startInProgress:y?C.has(y.id):!1,onOpenChange:p=>{p||r(null)},onRefresh:s}),devBoxNodeIds:g,devBoxStartNodeId:o,devBoxStartNodeIds:l,devBoxStartingNodeIds:C,openDevBox:r,startDevBox:v}}function yu(t){const[s,n]=a.useState(null),r=a.useCallback(i=>{t&&n(i)},[t]);return{nodeSettingsDialog:e.jsx(oi,{open:s!==null,onOpenChange:i=>{i||n(null)},initialSelectedNodeId:s??void 0,showTrigger:!1}),openNodeSettings:r}}function Nu(t=!1){return!t}function ku({activeTaskId:t,fetchActiveTask:s,isRunning:n=!1,setPendingMessages:r,setTask:o,setTasks:i}){const d=a.useCallback((h,y)=>{o(g=>g&&g.id===h?{...g,queuedMessages:y}:g),i(g=>g.map(l=>l.id===h?{...l,queuedMessages:y}:l))},[o,i]),c=a.useCallback(async h=>{if(!t)return!1;const y=`local-${Date.now()}-${Math.random().toString(16).slice(2)}`,g=Nu(n);g&&r(l=>[...l,{id:y,content:h,timestamp:new Date().toISOString()}]);try{const l=await ii(t,h);return l.queued&&(g&&r(N=>N.filter(C=>C.id!==y)),l.queuedMessages&&d(t,l.queuedMessages)),s(),!0}catch(l){return g&&r(N=>N.filter(C=>C.id!==y)),ie.error(l instanceof Error?l.message:"Failed to send message"),!1}},[t,s,n,r,d]);return{cancelQueuedMessage:a.useCallback(async h=>{if(t)try{const y=await li(t,h);d(t,y.queuedMessages),s()}catch(y){ie.error(y instanceof Error?y.message:"Failed to cancel queued message")}},[t,s,d]),queueFollowUpMessage:c}}const pa="grid-cols-[1.5rem_5.25rem_4rem_minmax(8rem,1fr)_4rem_4rem_6rem]",Su={claudecode:"Claude Code",codex:"Codex",copilot:"Copilot"};function Cu(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(o=>o==null?void 0:o.toLowerCase().includes(n)):!0)}function vr(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 Tu({items:t,selectedIds:s,activeId:n,onToggleSelected:r,onOpenDetail:o}){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:A("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",pa),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:()=>o(i),className:A("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",pa,n===i.id&&"bg-primary/10 text-primary shadow-[inset_2px_0_0_hsl(var(--primary))]"),children:[e.jsx("span",{onClick:d=>d.stopPropagation(),children:e.jsx(Kt,{className:"h-3 w-3",checked:s.has(i.id),onCheckedChange:d=>r(i.id,d===!0),"aria-label":`Select ${i.name}`})}),e.jsx(_u,{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:vr(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 _u({agent:t}){const s=Su[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 fa=320,ga=560,jr=384,ba=360;function Eu(t,s=ga+ba){const n=Math.max(fa,Math.min(ga,s-ba));return Math.min(Math.max(Math.round(t),fa),n)}function Du(t,s,n,r){return Eu(t+s-n,r)}function Au({detail:t,deleting:s=!1,onDelete:n,desktopWidth:r=jr,pending:o=!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:o?"Loading capability metadata...":"No capability selected."});const d=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($e,{variant:"secondary",className:"rounded-sm border-0 bg-card/72 px-1.5 py-0 text-[8px] text-primary",children:t.agent}),e.jsx($e,{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(is,{children:[e.jsx(Hs,{asChild:!0,children:e.jsx(J,{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(Ra,{className:"h-3.5 w-3.5"})})}),e.jsxs(ls,{className:"max-w-[22rem] gap-2 rounded-xl p-4",children:[e.jsxs(ds,{className:"space-y-1",children:[e.jsxs(cs,{className:"text-sm",children:["Delete ",t.name,"?"]}),e.jsxs(us,{className:"text-[11px] leading-4",children:["This removes the selected ",t.kind," from ",t.scope.kind==="global"?"the user profile":"this project","."]})]}),e.jsxs(ms,{className:"gap-1 pt-0 sm:space-x-1",children:[e.jsx(xs,{className:"h-7 rounded-lg px-2 text-[11px]",children:"Cancel"}),e.jsx(hs,{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(rs,{label:"Version",value:t.version??"-"}),e.jsx(rs,{label:"Size",value:vr(t)}),e.jsx(rs,{label:"Files",value:String(t.fileCount)}),e.jsx(rs,{label:"Source",value:t.source??"local"})]}),e.jsxs(tn,{defaultValue:d,className:"mt-2 flex min-h-0 flex-1 flex-col",children:[e.jsxs(en,{className:"grid h-auto grid-cols-2 rounded-sm bg-primary/8 p-0.5",children:[t.kind==="mcp"?e.jsx(vt,{value:"mcp",className:"rounded-sm px-2 py-0.5 text-[9px]",children:"MCP"}):e.jsx(vt,{value:"files",className:"rounded-sm px-2 py-0.5 text-[9px]",children:"Files"}),e.jsx(vt,{value:"readme",className:"rounded-sm px-2 py-0.5 text-[9px]",children:"README"})]}),t.kind==="mcp"?e.jsx(ot,{value:"mcp",className:"mt-2 min-h-0 flex-1 overflow-auto",children:e.jsx(Mu,{detail:t})}):e.jsx(ot,{value:"files",className:"mt-2 min-h-0 flex-1 overflow-auto",children:e.jsx(Pu,{detail:t})}),e.jsx(ot,{value:"readme",className:"mt-2 min-h-0 flex-1 overflow-auto",children:t.readmeMarkdown?e.jsx(Ji,{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(hn,{children:"No README content."})})]},t.id)]})}function Mu({detail:t}){const s=t.mcpPreview??[];return s.length===0?e.jsx(hn,{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 Pu({detail:t}){const s=t.fileTree??[];return s.length===0?e.jsx(hn,{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 hn({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 rs({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 Lu=20,Iu=288,Ou=360,Bu=440;function Ru(){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 $u({triggerRect:t,targetRect:s,viewportRect:n,compact:r,browserOpen:o=!1,portalAlign:i,cssZoom:d=1}){const c=Number.isFinite(d)&&d>0?d:1,f=8,h=n.top+f,y=n.bottom-f,g=n.left+f,l=n.right-f,N=Math.max(0,y-t.bottom-4),C=Math.max(0,t.top-h-4),v=r?C<140&&N>C:N>=220||N>=C,D=v?N:C,p=Math.max(140,y-h),S=r&&o,j=Math.min(p,S?Bu:320,Math.max(S?Ou:140,D)),_=Iu*c,E=i==="end"?t.right-_:t.left,M=(Math.max(g,Math.min(E,l-_))-s.left)/c;if(!v&&!S)return{left:M,bottom:(s.bottom-(t.top-4))/c,maxHeight:j/c};const Q=v?t.bottom+4:t.top-j-4,B=Math.max(h,Math.min(Q,y-j));return{left:M,top:(B-s.top)/c,maxHeight:j/c}}function pn(t){if(!t.workDir)return[];const s=[],n=new Set,r=o=>{!o||n.has(o)||(n.add(o),s.push(o))};r(t.workDir);for(const o of t.workDirFolders??[])r(yr(o)?o:Nr(t.workDir,o));return s}function Fu(t,s){if(t.kind==="global")return{nodeId:s.id,scope:{kind:"global"}};const n=pn(s),r=n.find(o=>o===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 zu(t,s){return{nodeId:t,scope:s}}function va(t,s,n){const r=s.trim();return!r||r==="."?t.workDir??r:n||yr(r)?r:t.workDir?Nr(t.workDir,r):r}function Hu({node:t,scope:s,clusterNodes:n,onSelectionChange:r}){const o=a.useMemo(()=>Ku(n,t),[n,t]),i=a.useMemo(()=>pn(t),[t]),d=a.useMemo(()=>o.map(c=>({value:c.id,label:c.name,description:`${c.role} · ${c.status}`,status:c.status})),[o]);return e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-2",children:[e.jsx(qu,{ariaLabel:"Capability node",value:t.name,description:`${t.role} · ${t.status}`,options:d,selectedValue:t.id,onSelect:c=>{const f=o.find(h=>h.id===c);f&&(r==null||r(Fu(s,f)))}}),e.jsx(wr,{node:t,projectPaths:i,selectedScope:s,onSelect:c=>r==null?void 0:r(zu(t.id,c))}),e.jsx(Uu,{node:t})]})}function Uu({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:A("h-1.5 w-1.5 shrink-0 rounded-full",Ut(t.status))})]})}function wr({node:t,projectPaths:s,selectedScope:n,onSelect:r,compact:o=!1,portal:i=!1,portalAlign:d="start"}){const[c,f]=a.useState(!1),[h,y]=a.useState(null),[g,l]=a.useState(!1),[N,C]=a.useState(!1),[v,D]=a.useState(null),[p,S]=a.useState(!1),[b,w]=a.useState(null),j=a.useRef(null),_=a.useRef(null),E=a.useRef(null),X=a.useMemo(()=>s.map(P=>({value:P,label:wa(P),description:P})),[s]),M=n.kind==="project"?n.projectPath:void 0,Q=n.kind==="global"?"Global":wa(n.projectPath),B=n.kind==="global"?"Global":n.projectPath,R=a.useCallback(()=>{var P;return!i||typeof document>"u"?null:((P=_.current)==null?void 0:P.closest('[data-capability-share-dialog="true"]'))??document.body},[i]),ne=a.useCallback(()=>{if(!i||!_.current||typeof window>"u")return;const P=_.current.getBoundingClientRect(),W=R(),x=W&&W!==document.body?W.getBoundingClientRect():{left:0,top:0,bottom:window.innerHeight};w($u({triggerRect:P,targetRect:x,viewportRect:{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight},compact:o,browserOpen:p,portalAlign:d,cssZoom:Ru()}))},[p,o,R,i,d]);a.useEffect(()=>{c||S(!1)},[c]),a.useEffect(()=>{if(!c)return;const P=W=>{if(!(W.target instanceof Node))return;const x=W.composedPath(),H=j.current?x.includes(j.current):!1,u=E.current?x.includes(E.current):W.target instanceof Element&&!!W.target.closest('[data-capability-scope-menu="true"]');!H&&!u&&f(!1)};return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[c]),a.useEffect(()=>{if(!(!c||!i))return ne(),window.addEventListener("resize",ne),window.addEventListener("scroll",ne,!0),()=>{window.removeEventListener("resize",ne),window.removeEventListener("scroll",ne,!0)}},[c,i,ne]);const V=async(P,W=0,x=!1)=>{if(t.workDir){D(null),x?C(!0):l(!0);try{const H=await _a(t.id,{path:P||".",limit:Lu,offset:W,directoriesOnly:!0,allowAbsolute:!0});y(u=>x&&u?{...H,entries:[...u.entries,...H.entries]}:H)}catch(H){D(H instanceof Error?H.message:"Failed to browse folders"),x||y(null)}finally{l(!1),C(!1)}}};a.useEffect(()=>{!c||!p||!t.workDir||(y(null),D(null),V(M||"."))},[p,c,t.id,t.workDir,M]);const K=(P,W=!1)=>{r({kind:"project",projectPath:va(t,P,W)}),f(!1)},ee=()=>{r({kind:"global"}),f(!1)},se=h?va(t,h.currentPath,h.isAbsolute):M??t.workDir??"",O=i?R():null,Z=e.jsxs("div",{ref:E,"data-capability-scope-menu":"true","aria-hidden":!c,onClick:P=>P.stopPropagation(),onMouseDown:P=>P.stopPropagation(),onPointerDown:P=>P.stopPropagation(),style:i&&b?{left:b.left,top:b.top,bottom:b.bottom,height:o&&p?b.maxHeight:void 0,maxHeight:b.maxHeight}:void 0,className:A(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&&(o?"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:A("px-2 text-[8px] font-semibold uppercase tracking-[0.14em] text-muted-foreground",o?"pb-0.5 pt-0.5 leading-3":"pb-1 pt-1"),children:"Scope"}),e.jsxs("div",{className:A("overflow-y-auto pr-0.5",o?"max-h-32":"max-h-40"),children:[e.jsx(ja,{icon:"global",label:"Global",selected:n.kind==="global",onSelect:ee,compact:o}),X.length>0?X.map(P=>e.jsx(ja,{icon:"folder",label:P.label,description:P.description,selected:M===P.value,onSelect:()=>K(P.value,!0),compact:o},P.value)):e.jsx("div",{className:A("flex items-center px-2 text-muted-foreground",o?"h-7 text-[9px]":"h-8 text-[10px]"),children:"No known projects"})]})]}),e.jsxs("div",{className:A("border-b border-border/55",p?"flex min-h-0 flex-1 flex-col":"shrink-0"),children:[e.jsxs("button",{type:"button","aria-expanded":p,onClick:()=>S(P=>!P),className:A("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",o?"py-1 leading-3":"py-1.5"),children:[e.jsx(Mt,{className:"h-2.5 w-2.5"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:"Browse folders"}),e.jsx(Qe,{className:A("h-3 w-3 shrink-0 transition-transform duration-200",p&&"rotate-180")})]}),p&&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:()=>(h==null?void 0:h.parentPath)&&void V(h.parentPath),disabled:!(h!=null&&h.parentPath)||g,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(qa,{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:se,children:se}),h&&e.jsx("button",{type:"button",onClick:()=>K(h.currentPath,h.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:A("min-h-0 flex-1 overflow-y-auto",o?"min-h-[8.25rem]":"max-h-56"),children:[t.workDir?g?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[9px] text-muted-foreground",children:[e.jsx(me,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading folders..."]}):h&&h.entries.length>0?e.jsxs(e.Fragment,{children:[h.entries.map(P=>e.jsx(Vu,{entry:P,onSelect:()=>K(P.path,h.isAbsolute),onOpen:()=>void V(P.path)},P.path)),h.hasMore&&e.jsxs("button",{type:"button",onClick:()=>void V(h.currentPath,h.entries.length,!0),disabled:N,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:[N?e.jsx(me,{className:"h-3 w-3 animate-spin"}):e.jsx(xl,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"px-3 py-4 text-center text-[9px] text-muted-foreground",children:v??"No subfolders."}):e.jsx("div",{className:"px-3 py-4 text-center text-[9px] text-muted-foreground",children:"This node has no working directory."}),v&&h&&h.entries.length>0&&e.jsx("div",{className:"border-t border-border/60 px-3 py-1.5 text-[9px] text-destructive",children:v})]})]})]})]});return e.jsxs("div",{ref:j,className:"relative min-w-0",children:[e.jsxs("button",{ref:_,type:"button","aria-label":"Capability location","aria-expanded":c,title:B,onClick:()=>f(P=>(P||(S(!1),ne()),!P)),className:A("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",o?"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:A("block truncate font-medium text-foreground",o?"text-[9px] leading-3":"text-[10px] leading-4"),children:Q})}),e.jsx(Qe,{className:A(o?"h-2.5 w-2.5":"h-3 w-3","shrink-0 text-muted-foreground transition-transform",c&&"rotate-180")})]}),i&&O?La.createPortal(Z,O):Z]})}function ja({icon:t,label:s,description:n,selected:r,onSelect:o,compact:i=!1}){const d=t==="global"?dl:Mt;return e.jsxs("button",{type:"button",onClick:o,className:A(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(d,{className:A("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:A("block truncate text-muted-foreground",i?"text-[7px] leading-3":"text-[8px] leading-3"),children:n})]})]})}function Vu({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(Mt,{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(We,{className:"h-3 w-3"})})]})}function qu({ariaLabel:t,value:s,description:n,options:r,selectedValue:o,onSelect:i}){const[d,c]=a.useState(!1),f=a.useRef(null);return a.useEffect(()=>{if(!d)return;const h=y=>{f.current&&y.target instanceof Node&&!f.current.contains(y.target)&&c(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[d]),e.jsxs("div",{ref:f,className:"relative min-w-0",children:[e.jsxs("button",{type:"button","aria-label":t,"aria-expanded":d,title:n??s,onClick:()=>c(h=>!h),className:"flex h-7 min-w-32 max-w-56 items-center gap-1.5 rounded-sm border-0 bg-muted/55 px-2 text-left shadow-none transition-colors hover:bg-muted/70 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:[e.jsx("span",{className:"min-w-0 flex-1",children:e.jsx("span",{className:"block truncate text-[10px] font-medium leading-4 text-foreground",children:s})}),e.jsx(Qe,{className:A("h-3 w-3 shrink-0 text-muted-foreground transition-transform",d&&"rotate-180")})]}),e.jsx("div",{"aria-hidden":!d,className:A("absolute left-0 top-9 z-50 w-64 overflow-hidden rounded-lg border border-border/70 bg-popover text-popover-foreground shadow-none",!d&&"hidden"),children:e.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:r.length>0?r.map(h=>e.jsxs("button",{type:"button",onClick:()=>{i(h.value),c(!1)},className:A("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",h.value===o&&"bg-primary/10 text-primary"),children:[h.status&&e.jsx("span",{className:A("h-1.5 w-1.5 shrink-0 rounded-full",Ut(h.status))}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate font-medium",children:h.label}),h.description&&e.jsx("span",{className:"block truncate text-[9px] text-muted-foreground",children:h.description})]})]},h.value)):e.jsx("div",{className:"px-2 py-2 text-[10px] text-muted-foreground",children:"No projects"})})})]})}function Ku(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 Ut(t){return t==="online"?"bg-emerald-500":t==="offline"?"bg-muted-foreground/45":"bg-amber-500"}function wa(t){return t.split(/[\\/]+/).filter(Boolean).at(-1)??t}function yr(t){return t.startsWith("/")||/^[A-Za-z]:[\\/]/.test(t)}function Nr(t,s){return`${t.replace(/[\\/]+$/,"")}/${s.replace(/^[\\/]+/,"")}`}const Wu="h-6 w-24 rounded-sm px-2 text-[10px] shadow-none",$s="text-[10px]",kr=["claudecode","codex","copilot"],Ht={claudecode:"Claude Code",codex:"Codex",copilot:"Copilot"};function Gu({open:t,sourceNode:s,targetNodes:n,selectedCapabilities:r,previewResults:o=[],embedded:i=!1,onClose:d,onPreviewTargetsChange:c,onShare:f}){const[h,y]=a.useState(()=>new Set(o.length>0?o.map(x=>st(x.nodeId,x.targetAgent)):Qu(s.id,n,r))),[g,l]=a.useState(()=>Object.fromEntries(Zu(s.id,n,r))),[N,C]=a.useState({}),[v,D]=a.useState(!1),[p,S]=a.useState(()=>new Set),[b,w]=a.useState(()=>new Set),j=r.some(x=>x.kind==="plugin"),_=a.useMemo(()=>fn(r).map(x=>({key:st(s.id,x),nodeId:s.id,node:s,label:`Install into ${Ht[x]}`,agentLabel:Ht[x],defaultScope:Cr(r),disabled:!1,targetAgent:x})),[r,s]),E=a.useMemo(()=>n.flatMap(x=>{const H={kind:"global"},u=x.status==="offline",q=Sr(r);return q.length===0?[{key:st(x.id),nodeId:x.id,node:x,label:x.name,defaultScope:H,disabled:u}]:q.map(T=>({key:st(x.id,T),nodeId:x.id,node:x,label:`${x.name} / ${Ht[T]}`,agentLabel:Ht[T],defaultScope:H,disabled:u,targetAgent:T}))}),[r,n]),X=a.useMemo(()=>[..._,...E],[_,E]),M=a.useMemo(()=>n.map(x=>({node:x,options:E.filter(H=>H.nodeId===x.id)})).filter(x=>x.options.length>0),[n,E]),Q=a.useMemo(()=>new Map(o.filter(x=>x.capabilityId).map(x=>[ya(x.nodeId,x.capabilityId,x.targetAgent),x])),[o]),B=a.useMemo(()=>new Map(o.map(x=>[st(x.nodeId,x.targetAgent),x])),[o]),R=a.useMemo(()=>X.filter(x=>h.has(x.key)),[h,X]),ne=a.useMemo(()=>R.map(x=>({nodeId:x.nodeId,scope:g[x.key]??x.defaultScope,...x.targetAgent?{targetAgent:x.targetAgent}:{}})),[R,g]),V=a.useMemo(()=>{const x=[],H=new Map;for(const u of R){if(!H.has(u.nodeId)){const q=u.nodeId===s.id?s:n.find(T=>T.id===u.nodeId);H.set(u.nodeId,{nodeId:u.nodeId,node:q,name:(q==null?void 0:q.name)??u.nodeId,options:[]}),x.push(u.nodeId)}H.get(u.nodeId).options.push(u)}return x.map(u=>H.get(u))},[R,s,n]),K=a.useMemo(()=>{const x=Array.from(new Set(r.map(u=>u.agent))),[H]=x;if(H)return x.length===1?Ht[H]:`${x.length} agents`},[r]),ee=M.length+1;a.useEffect(()=>{let x=!1;const H={...g};for(const u of X)H[u.key]||(H[u.key]=u.defaultScope,x=!0);x&&l(H)},[X,g]),a.useEffect(()=>{t&&(c==null||c(ne))},[t,c,ne]),a.useEffect(()=>{t&&(S(new Set),w(new Set))},[t,s.id]),a.useEffect(()=>{if(!i||!t)return;const x=H=>{H.key==="Escape"&&d()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[i,d,t]);const se=x=>{C(Object.fromEntries(R.map(H=>[H.key,x])))},O=async()=>{D(!0);try{await f(R.map(x=>({nodeId:x.nodeId,scope:g[x.key]??x.defaultScope,...x.targetAgent?{targetAgent:x.targetAgent}:{},conflictStrategy:N[x.key]??"overwrite"})))}finally{D(!1)}},Z=x=>{const H=g[x.key]??x.defaultScope,u=`capability-share-target-${Yu(x.key)}`,q=h.has(x.key);return e.jsxs("div",{"data-target-agent":x.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":x.disabled?"true":void 0,children:[e.jsx(Kt,{id:u,disabled:x.disabled,checked:q,onCheckedChange:T=>y(U=>{const L=new Set(U);return T===!0?L.add(x.key):L.delete(x.key),L}),"aria-label":`Select ${x.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:u,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":x.disabled?"true":void 0,children:x.agentLabel??x.label}),e.jsx("div",{className:"flex w-28 shrink-0 justify-end",children:q&&!x.disabled&&e.jsx(wr,{node:x.node,projectPaths:pn(x.node),selectedScope:H,onSelect:T=>l(U=>({...U,[x.key]:T})),compact:!0,portal:!0,portalAlign:"end"})})]},x.key)},P=(x,H,u,q)=>{const T=p.has(x.id),U=R.filter(L=>L.nodeId===x.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":T,onClick:()=>S(L=>Na(L,x.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(We,{className:A("h-3 w-3 shrink-0 text-muted-foreground transition-transform duration-200",T&&"rotate-90")}),e.jsx("span",{className:A("h-1.5 w-1.5 shrink-0 rounded-full",Ut(x.status))}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-semibold text-foreground",title:x.name,children:x.name}),U>0&&e.jsxs("span",{className:"shrink-0 text-[8px] font-medium text-primary",children:[U," selected"]}),e.jsx("span",{className:"shrink-0 text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:H?"this node":"remote"}),x.status==="offline"&&e.jsx($e,{variant:"outline",className:"rounded-sm px-1 py-0 text-[8px]",children:"offline"}),q>0&&e.jsxs("span",{className:"sr-only",children:[q," agents"]})]}),e.jsx("div",{className:A("grid transition-[grid-template-rows] duration-200 ease-out",T?"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:u})})})]},x.id)},W=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(bs,{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:A("h-1.5 w-1.5 shrink-0 rounded-full",Ut(s.status))}),e.jsx("span",{className:"truncate font-semibold text-foreground",title:s.name,children:s.name}),K&&e.jsxs("span",{className:"shrink-0 text-muted-foreground",children:["· ",K]})]}),e.jsx(zn,{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:R.length})," selected · ",ee," ",ee===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:[P(s,!0,j?e.jsx("div",{className:"px-2 py-2 text-[10px] text-muted-foreground",children:"Cross-agent plugin installs are not supported."}):_.length===0?e.jsx("div",{className:"px-2 py-2 text-[10px] text-muted-foreground",children:"No alternate agents available for this selection."}):_.map(Z),_.length),M.map(x=>P(x.node,!1,x.options.map(Z),x.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(x=>e.jsx("button",{type:"button",onClick:()=>se(x),className:"h-5 rounded-[3px] px-1.5 text-[9px] capitalize text-muted-foreground transition-colors hover:bg-muted/70 hover:text-foreground",children:x},x))})]})]}),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:R.length===0?e.jsx("div",{className:"py-8 text-center text-[11px] text-muted-foreground",children:"Select a target to preview conflicts."}):V.map(x=>{const H=!b.has(x.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":H,onClick:()=>w(u=>Na(u,x.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(We,{className:A("h-3 w-3 shrink-0 text-muted-foreground transition-transform duration-200",H&&"rotate-90")}),x.node&&e.jsx("span",{className:A("h-1.5 w-1.5 shrink-0 rounded-full",Ut(x.node.status))}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[10px] font-semibold text-foreground",children:x.name}),e.jsxs("span",{className:"shrink-0 text-[8px] text-muted-foreground",children:[x.options.length," ",x.options.length===1?"agent":"agents"]})]}),e.jsx("div",{className:A("grid transition-[grid-template-rows] duration-200 ease-out",H?"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:x.options.map(u=>{const q=N[u.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:u.agentLabel??"Matching agent"}),e.jsxs(Se,{value:q,onValueChange:T=>C(U=>({...U,[u.key]:T})),children:[e.jsx(Ce,{className:Wu,children:e.jsx(Le,{})}),e.jsxs(Te,{className:"shadow-none",children:[e.jsx(pe,{value:"overwrite",className:$s,children:"Overwrite"}),e.jsx(pe,{value:"skip",className:$s,children:"Skip"}),e.jsx(pe,{value:"abort",className:$s,children:"Abort"})]})]})]}),e.jsx("div",{className:"space-y-px",children:r.map(T=>{const U=Q.get(ya(u.nodeId,T.id,u.targetAgent))??(r.length===1?B.get(u.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:T.name}),e.jsx("span",{className:U!=null&&U.conflict?"text-amber-500":U?"text-emerald-500":"text-muted-foreground",children:U?U.conflict?`exists${U.currentVersion?` v${U.currentVersion}`:""}`:"new install":"checking"}),(U==null?void 0:U.sourceVersion)&&e.jsxs("span",{className:"shrink-0 text-muted-foreground",children:[e.jsx(zn,{className:"inline h-2.5 w-2.5"})," v",U.sourceVersion]})]},T.id)})})]},u.key)})})})})]},x.nodeId)})})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 border-t border-border/55 px-4 py-3",children:[e.jsx(J,{variant:"ghost",onClick:d,className:"h-7 rounded-sm px-3 text-[11px]",children:"Cancel"}),e.jsxs(J,{onClick:O,disabled:v||R.length===0,className:"h-7 rounded-sm px-3 text-[11px]",children:[v?e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(bs,{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:x=>{x.target===x.currentTarget&&d()},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:x=>x.stopPropagation(),children:[W,e.jsxs("button",{type:"button",onClick:d,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(rt,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})}):null:e.jsx(Pt,{open:t,onOpenChange:x=>{x||d()},children:e.jsx(Lt,{"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:W})})}function st(t,s){return s?`agent:${t}:${s}`:`node:${t}`}function Yu(t){return t.replace(/[^a-zA-Z0-9_-]/g,"-")}function ya(t,s,n){return`${st(t,n)}\0${s}`}function Na(t,s){const n=new Set(t);return n.has(s)?n.delete(s):n.add(s),n}function Qu(t,s,n){const r=s.find(i=>i.status!=="offline");if(r)return[st(r.id,Xu(n))];const o=fn(n)[0];return o?[st(t,o)]:[]}function Zu(t,s,n){const r=Sr(n);return[...s.flatMap(o=>r.length===0?[[st(o.id),{kind:"global"}]]:r.map(i=>[st(o.id,i),{kind:"global"}])),...fn(n).map(o=>[st(t,o),Cr(n)])]}function Sr(t){return t.length===0||t.some(s=>s.kind==="plugin")?[]:kr}function Xu(t){var s;if(!(t.length===0||t.some(n=>n.kind==="plugin")))return(s=t[0])==null?void 0:s.agent}function fn(t){if(t.length===0||t.some(n=>n.kind==="plugin"))return[];const s=new Set(t.map(n=>n.agent));return kr.filter(n=>!s.has(n))}function Cr(t){var s;return((s=t[0])==null?void 0:s.scope)??{kind:"global"}}const ka="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",ht="py-0.5 pl-6 pr-1.5 text-[9px] leading-4 [&_svg]:h-3 [&_svg]:w-3",Tr="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",Ju="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 em(t,s,n,r){return n.map(o=>({sourceNodeId:t,capabilityId:o.id,sourceScope:s,targets:r.map(i=>({nodeId:i.nodeId,scope:i.scope,...i.targetAgent?{targetAgent:i.targetAgent}:{}}))}))}function tm(t,s,n,r){return n.map(o=>({sourceNodeId:t,capabilityId:o.id,sourceScope:s,targets:r}))}function sm({loading:t,onRefresh:s}){return e.jsxs(J,{variant:"ghost",onClick:s,disabled:t,"aria-busy":t,className:A(Tr,"min-w-[4.5rem]"),children:[e.jsx(Wa,{className:A("h-2.5 w-2.5",t&&"animate-spin")}),t?"Refreshing":"Refresh"]})}function nm({selectedCount:t,loading:s,onClearSelection:n,onRefresh:r,onShare:o}){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(J,{type:"button",variant:"ghost",onClick:n,disabled:t===0,className:Tr,children:[e.jsx(rt,{className:"h-2.5 w-2.5"}),"Selected: ",t," / Clear"]})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(sm,{loading:s,onRefresh:r}),e.jsxs(J,{type:"button",variant:"ghost",onClick:o,disabled:t===0,className:Ju,children:[e.jsx(bs,{className:"h-2.5 w-2.5"}),"Share"]})]})]})}function am({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 rm({visible:t}){return t?e.jsx("div",{className:"absolute inset-2.5 z-10 flex items-center justify-center rounded-sm border border-border/60 bg-background/85 shadow-sm backdrop-blur-sm",children:e.jsxs("div",{className:"flex w-full max-w-80 flex-col items-center gap-3 px-5 text-center",children:[e.jsxs("div",{className:"relative flex h-10 w-10 items-center justify-center rounded-full border border-primary/25 bg-primary/8",children:[e.jsx("span",{className:"absolute inset-0 rounded-full border border-primary/20 animate-ping"}),e.jsx(me,{className:"relative h-4 w-4 animate-spin text-primary"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground",children:"Loading capabilities"}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Reading agent skills, plugins, and MCP servers for this selection."})]}),e.jsxs("div",{className:"grid w-full gap-1.5","aria-hidden":"true",children:[e.jsx("span",{className:"h-1.5 rounded-full bg-muted animate-pulse"}),e.jsx("span",{className:"mx-auto h-1.5 w-3/4 rounded-full bg-muted/70 animate-pulse"})]})]})}):null}function om({open:t,node:s,scope:n,clusterNodes:r,onOpenChange:o,onSelectionChange:i}){const[d,c]=a.useState([]),[f,h]=a.useState([]),[y,g]=a.useState(!1),[l,N]=a.useState(""),[C,v]=a.useState("all"),[D,p]=a.useState("all"),[S,b]=a.useState(new Set),[w,j]=a.useState(null),[_,E]=a.useState(null),[X,M]=a.useState(!1),[Q,B]=a.useState(null),[R,ne]=a.useState(!1),[V,K]=a.useState([]),[ee,se]=a.useState(jr),[O,Z]=a.useState(null),P=a.useMemo(()=>Cu(d,{search:l,agent:C,kind:D}),[C,d,D,l]),W=a.useMemo(()=>d.filter(F=>S.has(F.id)),[d,S]),x=a.useMemo(()=>r.filter(F=>F.id!==s.id),[r,s.id]),H=n.kind==="project"?n.projectPath:"global",u=async()=>{g(!0);try{const F=await ci(s.id,{scope:n});c(F.items),h((F.errors??[]).map(te=>`${te.agent}: ${te.message}`))}catch(F){h([F instanceof Error?F.message:"Failed to load capabilities"])}finally{g(!1)}};a.useEffect(()=>{t&&(b(new Set),j(null),E(null),M(!1),K([]),c([]),h([]),u())},[t,s.id,n.kind,H]),a.useEffect(()=>{if(!O)return;const F=ce=>{se(Du(O.startWidth,O.startClientX,ce.clientX,window.innerWidth))},te=()=>Z(null);return window.addEventListener("pointermove",F),window.addEventListener("pointerup",te),()=>{window.removeEventListener("pointermove",F),window.removeEventListener("pointerup",te)}},[O]);const q=F=>{F.preventDefault(),Z({startClientX:F.clientX,startWidth:ee})},T=()=>{Z(null),M(!1),j(null),E(null)},U=()=>{b(new Set),K([])},L=async F=>{j(F.id),M(!0),E(null);const te=await ui(s.id,F.id,n);E(te.detail)},le=a.useCallback(async F=>{if(W.length===0||F.length===0){K([]);return}K([]);try{const te=em(s.id,n,W,F),ce=await Promise.all(te.map(k=>di(k)));K(ce.flatMap((k,$)=>k.results.map(ue=>{var we;return{...ue,capabilityId:(we=te[$])==null?void 0:we.capabilityId}})))}catch{K([])}},[s.id,n,W]),oe=()=>{K([]),ne(!0)},de=async F=>{const te=tm(s.id,n,W,F);te.length!==0&&(await Promise.all(te.map(ce=>xi(ce))),ie.success(`${te.length} capability share request${te.length===1?"":"s"} completed`),ne(!1))},G=async()=>{if(!(!_||Q)){B(_.id);try{const F=await mi(s.id,_.id,n);F.status==="deleted"?(ie.success(`Deleted ${_.name}`),c(te=>te.filter(ce=>ce.id!==_.id)),b(te=>{const ce=new Set(te);return ce.delete(_.id),ce}),j(null),E(null),M(!1),await u()):(ie.info(F.message??"Capability was not found"),j(null),E(null),M(!1),await u())}catch(F){ie.error(F instanceof Error?F.message:"Failed to delete capability")}finally{B(null)}}};return e.jsx(e.Fragment,{children:e.jsx(Pt,{open:t,onOpenChange:o,children:e.jsxs(Lt,{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(nn,{className:"border-b border-border/55 bg-card/28 px-4 py-2.5 text-left",children:[e.jsx(Yt,{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(Hu,{node:s,scope:n,clusterNodes:r,onSelectionChange:i}),e.jsxs(rn,{"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(Ea,{className:"pointer-events-none absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-muted-foreground"}),e.jsx(at,{value:l,onChange:F=>N(F.target.value),placeholder:"Search capabilities",className:"h-7 rounded-sm border-0 bg-muted/55 pl-6 text-[10px] shadow-none"})]}),e.jsxs(Se,{value:C,onValueChange:F=>v(F),children:[e.jsx(Ce,{className:A("w-28",ka),children:e.jsx(Le,{})}),e.jsxs(Te,{className:"shadow-none",children:[e.jsx(pe,{value:"all",className:ht,children:"Agent: All"}),e.jsx(pe,{value:"claudecode",className:ht,children:"Claude Code"}),e.jsx(pe,{value:"codex",className:ht,children:"Codex"}),e.jsx(pe,{value:"copilot",className:ht,children:"Copilot"})]})]}),e.jsxs(Se,{value:D,onValueChange:F=>p(F),children:[e.jsx(Ce,{className:A("w-24",ka),children:e.jsx(Le,{})}),e.jsxs(Te,{className:"shadow-none",children:[e.jsx(pe,{value:"all",className:ht,children:"Kind: All"}),e.jsx(pe,{value:"skill",className:ht,children:"Skill"}),e.jsx(pe,{value:"plugin",className:ht,children:"Plugin"}),e.jsx(pe,{value:"mcp",className:ht,children:"MCP"})]})]})]}),f.length>0&&e.jsx("div",{className:"rounded-sm bg-amber-500/10 px-2 py-1 text-[10px] text-amber-600",children:f.join(" · ")}),e.jsx(Tu,{items:P,selectedIds:S,activeId:w,onToggleSelected:(F,te)=>b(ce=>{const k=new Set(ce);return te?k.add(F):k.delete(F),k}),onOpenDetail:L}),e.jsx(nm,{selectedCount:S.size,loading:y,onClearSelection:U,onRefresh:u,onShare:oe}),e.jsx(rm,{visible:y&&d.length===0})]}),X&&e.jsxs(e.Fragment,{children:[e.jsx(am,{onBeginResize:q,onFold:T}),e.jsx(Au,{detail:_,deleting:Q===(_==null?void 0:_.id),desktopWidth:ee,onDelete:_?G:void 0,pending:!_})]})]}),R&&e.jsx(Gu,{open:R,sourceNode:s,targetNodes:x,selectedCapabilities:W,previewResults:V,embedded:!0,onClose:()=>ne(!1),onPreviewTargetsChange:le,onShare:de})]})})})}function im(t){const[s,n]=a.useState(null),r=a.useMemo(()=>s?(t==null?void 0:t.nodes.find(f=>f.id===s.nodeId))??((t==null?void 0:t.self.id)===s.nodeId?t.self:null)??null:null,[t,s]),o=a.useCallback(f=>{n({nodeId:f,scope:{kind:"global"}})},[]),i=a.useCallback((f,h)=>{n({nodeId:f,scope:{kind:"project",projectPath:h}})},[]),d=a.useCallback(f=>{n(f)},[]);return{capabilitiesDialog:s&&r&&t?e.jsx(om,{open:!0,node:r,scope:s.scope,clusterNodes:t.nodes,onOpenChange:f=>{f||n(null)},onSelectionChange:d}):null,openNodeCapabilities:o,openProjectCapabilities:i}}function lm(){var wn,yn,Nn,kn,Sn,Cn;const{id:t}=hi(),s=pi(),n=fi(),r=gi(),{cluster:o,systemInfo:i,events:d,sseConnected:c,subscribe:f,refresh:h,loading:y,error:g}=bi(),l=a.useMemo(()=>vi(s.state),[s.state]),[N,C]=a.useState(null),[v,D]=a.useState("active"),[p,S]=a.useState("all"),[b,w]=a.useState("all"),[j,_]=a.useState("all"),E=(r==null?void 0:r.headerSearchQuery)??"",X=a.useDeferredValue(E),{desktopTasksOpen:M,mobileTasksPanelOpen:Q,mobileTasksPanelRef:B,operationsOpen:R,operationsPanelRef:ne,panelResize:V,setMobileTasksPanelOpen:K,setOperationsOpen:ee,toggleTasksPanel:se}=Kc(),[O,Z]=a.useState(()=>!!(l!=null&&l.draftNewTask)),[P,W]=a.useState(()=>(l==null?void 0:l.createMode)??"chat"),[x,H]=a.useState(()=>(l==null?void 0:l.createDefaults)??null),[u,q]=a.useState(()=>l!=null&&l.draftNewTask?{route:l.returnRoute??"/",taskId:l.returnTaskId??null}:null),[T,U]=a.useState(!1),[L,le]=a.useState("transcript"),[oe,de]=a.useState("overview"),[G,F]=a.useState("all"),[te,ce]=a.useState(!1),[k,$]=a.useState(null),[ue,we]=a.useState([]),[Fe,ze]=a.useState([]),[Ue,_e]=a.useState(!1),[it,He]=a.useState(!1),[Ze,ae]=a.useState(null),[fe,ye]=a.useState(new Set),[Ee,lt]=a.useState(!1),[Ne,Ge]=a.useState(!1),[wt,yt]=a.useState(null),Oe=a.useRef(null),z=a.useRef(new Map),xe=((wn=o==null?void 0:o.self)==null?void 0:wn.role)==="leader",De=(yn=o==null?void 0:o.self)==null?void 0:yn.id,{quickChats:ut}=ji();ou({cluster:o,subscribe:f});const{nodeSettingsDialog:pt,openNodeSettings:Nt}=yu(xe),{capabilitiesDialog:Me,openNodeCapabilities:Be,openProjectCapabilities:kt}=im(o),{devBoxDialog:ft,devBoxNodeIds:Xe,devBoxStartNodeId:gt,devBoxStartNodeIds:Bt,devBoxStartingNodeIds:dt,openDevBox:ke,startDevBox:ct}=wu({cluster:o,refresh:h}),{completedGroups:mt=[],fetchTasks:Pe,loadCompletedTasksPage:ve,removeTasksFromList:Ae,setTasks:Ve,tasks:qe,tasksError:_r,tasksLoading:Ss}=su({isLeader:xe,selfId:De,sseConnected:c,preservedTask:k,subscribe:f});a.useEffect(()=>wi(()=>{de("events"),ee(!0)}),[ee]);const Je=a.useMemo(()=>[...qe].sort((m,I)=>I.updatedAt-m.updatedAt),[qe]),et=a.useMemo(()=>{var m;return((m=[...qe].sort((I,Y)=>Y.createdAt-I.createdAt||Y.updatedAt-I.updatedAt)[0])==null?void 0:m.id)??null},[qe]),Er=a.useMemo(()=>{const m=new Map;for(const I of(o==null?void 0:o.nodes)??[]){const Y=Yl(Je,I.id);Y>0&&m.set(I.id,Y)}return m},[o==null?void 0:o.nodes,Je]),tt=a.useMemo(()=>Je.filter(m=>!yi(m,o==null?void 0:o.nodes,o==null?void 0:o.self)||!Ni(m,v)||p!=="all"&&m.agent!==p||!ki(m,j)||b==="unassigned"&&m.assignedTo||b!=="all"&&b!=="unassigned"&&Si(m.assignedTo,o==null?void 0:o.nodes,m.assignedNodeName)!==b?!1:X.trim()?Ci(m,X):!0),[Je,o==null?void 0:o.nodes,o==null?void 0:o.self,v,p,j,b,X]);a.useEffect(()=>{ye(m=>{const I=td(m,tt.map(Y=>Y.id));return I.size===m.size?m:I})},[tt]),a.useEffect(()=>{xe||ye(new Set)},[xe]);const Dr=a.useMemo(()=>["all",...Array.from(new Set(Je.map(m=>m.agent))).sort()],[Je]),Ar=a.useMemo(()=>{const I=Array.from(new Set(Je.map(Y=>Y.assignedTo).filter(Y=>!!Y))).map(Y=>{const je=Je.find(he=>he.assignedTo===Y);return(o==null?void 0:o.nodes.find(he=>he.id===Y))??{id:Y,name:zs(Y,o==null?void 0:o.nodes,je==null?void 0:je.assignedNodeName)}}).sort((Y,je)=>Y.name.localeCompare(je.name));return[{value:"all",label:"All nodes"},{value:"unassigned",label:"Unassigned"},...I.map(Y=>({value:Y.name.toLowerCase(),label:Y.name}))]},[Je,o==null?void 0:o.nodes]),gn=a.useMemo(()=>{const m=new Map;for(const I of(o==null?void 0:o.nodes)??[])m.set(I.id,I.name);for(const I of Je)I.assignedTo&&I.assignedNodeName&&!m.has(I.assignedTo)&&m.set(I.assignedTo,I.assignedNodeName);return m},[o==null?void 0:o.nodes,Je]),Mr=a.useMemo(()=>{var I;const m=new Map;for(const Y of(o==null?void 0:o.nodes)??[])Y.workDir&&m.set(Y.id,Y.workDir);return(I=o==null?void 0:o.self)!=null&&I.workDir&&m.set(o.self.id,o.self.workDir),m},[o]),Pr=a.useMemo(()=>{const m=new Map;for(const I of(o==null?void 0:o.nodes)??[])m.set(I.id,I.status);return o!=null&&o.self&&m.set(o.self.id,o.self.status),m},[o]),Lr=a.useMemo(()=>new Map(mt.map(m=>[Js(m),m])),[mt]),bn=a.useMemo(()=>{const m=new Map;for(const I of(o==null?void 0:o.nodes)??[])I.status!=="offline"&&m.set(I.id,I);return o!=null&&o.self&&o.self.status!=="offline"&&m.set(o.self.id,o.self),Array.from(m.values())},[o]),Ir=((Nn=o==null?void 0:o.self)==null?void 0:Nn.id)??((kn=bn[0])==null?void 0:kn.id)??null,Rt=a.useMemo(()=>d.filter(Ti),[d]),Cs=a.useMemo(()=>["all",...Array.from(new Set(Rt.map(m=>m.type))).sort()],[Rt]),Or=a.useMemo(()=>G==="all"?Rt:Rt.filter(m=>m.type===G),[Rt,G]),Br=tt.length>0&&tt.every(m=>fe.has(m.id)),Rr=tt.some(m=>fe.has(m.id)),$r=sd(tt,fe);a.useEffect(()=>{l!=null&&l.draftNewTask&&(Z(!0),W(l.createMode??"chat"),H(l.createDefaults??null),q({route:l.returnRoute??"/",taskId:l.returnTaskId??null}))},[l]),a.useEffect(()=>{G!=="all"&&!Cs.includes(G)&&F("all")},[G,Cs]),a.useEffect(()=>{Un(t,O)&&!N&&et&&C(et)},[t,O,N,et]),a.useEffect(()=>{Un(t,O)&&(N&&qe.some(m=>m.id===N)||C(et))},[t,O,N,et,qe]);const be=Zl({routeTaskId:t,creatingTask:O,internalSelectedTaskId:N,sortedTaskIds:et?[et]:[]}),St=a.useMemo(()=>qe.find(m=>m.id===be)??null,[qe,be]);a.useEffect(()=>{Oe.current=be??null},[be]);const xt=a.useCallback(()=>{$(null),we([]),ze([]),ae(null),He(!1)},[]),$t=a.useCallback((m,I,Y=!0)=>{z.current.set(m,{logs:fr(I),loaded:Y})},[]),Ke=a.useCallback(async()=>{const m=be;if(m)try{const I=await _i(m);if(Oe.current!==m)return;$(I),Ve(Y=>Za(Y,I)),ae(null)}catch(I){if(Oe.current!==m)return;xt(),ae(I instanceof Error?I.message:"Failed to load task")}finally{Oe.current===m&&_e(!1)}},[be,xt,Ve]),Qt=a.useCallback(async()=>{const m=be;if(m)try{const I=await Us(m);if(Oe.current!==m)return;we(Y=>{const je=Va(Y,I.logs);return $t(m,je),je}),ze(Y=>qs(Y,I.logs))}catch{}finally{Oe.current===m&&He(!1)}},[be,$t]);a.useEffect(()=>{if(!be){xt(),_e(!1);return}le("transcript"),$(St);const m=nu(be,z.current);we(m.logs),ze([]),ae(null),_e(!0),He(m.transcriptLoading),Ke(),Qt()},[be,xt,Qt,Ke]),a.useEffect(()=>{if(!Xl({activeTaskId:be,routeTaskId:t,creatingTask:O,tasksLoading:Ss,loadedTaskIds:qe.map(I=>I.id)}))return;const m=et;C(m),xt(),a.startTransition(()=>{n(m?`/tasks/${m}`:"/",{state:null})})},[be,xt,O,et,n,t,qe,Ss]),a.useEffect(()=>{St&&$(m=>!m||m.id!==St.id?m:{...m,...St})},[St]),a.useEffect(()=>{if(be)return f("task",m=>{const I=m.data.taskId;if(!(typeof I!="string"||I!==be)){if(m.type==="task.output"){const Y=m.data.event;if(Y){we(he=>{const zt=Ki(he,Y);return $t(be,zt),zt}),He(!1);const je=Fn(Y);je&&ze(he=>Wi(he,je))}}m.type==="task.updated"&&Ke(),m.type==="task.status"&&(Ke(),Qt())}})},[f,be,Ke,Qt]);const re=k??St,Fr=re!=null&&re.assignedTo?(o==null?void 0:o.nodes.find(m=>m.id===re.assignedTo))??null:null,Ft=r==null?void 0:r.setHeaderTaskContext;a.useEffect(()=>{if(!Ft)return;if(!re){Ft(null);return}const m=re.effectiveProjectPath??re.project??"default workspace";return Ft({taskId:re.id,taskTitle:re.title,nodeName:zs(re.assignedTo,o==null?void 0:o.nodes,re.assignedNodeName),projectLabel:Ba(m),projectPath:m}),()=>Ft(null)},[re,o==null?void 0:o.nodes,Ft]);const Ts=Fe.length>0,zr=re?Ei.has(re.agent):!1,Zt=(re==null?void 0:re.status)==="running",Hr=re?ps.has(re.status):!1,Ur=re?ps.has(re.status)||Di.has(re.status):!1,Vr=!!(re&&xe&&re.status==="failed"),_s=a.useMemo(()=>Mc(re,o,Ts,!!Zt),[re,o,Ts,Zt]),Es=a.useMemo(()=>Gi([...ue,...Fe.map(m=>Is(m.content,m.timestamp))]),[ue,Fe]),Xt=a.useMemo(()=>{if(!re||re.conversationKind==="nativeSession")return null;const m=Yi(re);if(m.length>0)return Is(m,new Date(re.createdAt).toISOString());if(Es.length>0)return null;const I=Qi(re.description||re.title);return I.length>0?Is(I,new Date(re.createdAt).toISOString()):null},[re,Es]),Ds=a.useMemo(()=>Xt?Fn(Xt):null,[Xt]),qr=a.useMemo(()=>Ds?Zi(ue,Ds):!1,[ue,Ds]),As=a.useCallback((m="chat",I)=>{const Y={route:t?`/tasks/${t}`:"/",taskId:be};q(Y),W(m),H(I??null),Z(!0),a.startTransition(()=>{n("/",{state:{draftNewTask:!0,returnRoute:Y.route,returnTaskId:Y.taskId,createMode:m,createDefaults:I}})})},[t,be,n]),Kr=a.useCallback(()=>{const m=(u==null?void 0:u.taskId)??et;Z(!1),q(null),H(null),C(m),a.startTransition(()=>{n((u==null?void 0:u.route)??"/",{state:null})})},[u,et,n]),vn=a.useCallback(m=>{Z(!1),q(null),H(null),C(m),a.startTransition(()=>{n(`/tasks/${m}`,{state:null})})},[n]),Wr=a.useCallback(m=>{Oe.current=m.id,Z(!1),q(null),H(null),Ve(I=>Jl(I,m)),$(m),we([]),ze([]),ae(null),_e(!1),He(m.conversationKind==="nativeSession"),le("transcript"),C(m.id),lu({task:m,getActiveTaskId:()=>Oe.current,setLogs:we,setPendingMessages:ze,setTranscriptLoading:He}),Pe(),a.startTransition(()=>{n(`/tasks/${m.id}`,{state:null})})},[Pe,n]),{cancelQueuedMessage:Gr,queueFollowUpMessage:Jt}=ku({activeTaskId:be,fetchActiveTask:Ke,isRunning:Zt,setPendingMessages:ze,setTask:$,setTasks:Ve}),Yr=a.useCallback(m=>{Jt(m)},[Jt]),Qr=a.useCallback(async()=>{const m=be;if(!(!m||(re==null?void 0:re.conversationKind)!=="nativeSession")){He(!0);try{const I=await Us(m);if(Oe.current!==m)return;we(I.logs),$t(m,I.logs),ze(Y=>qs(Y,I.logs))}catch(I){ie.error(I instanceof Error?I.message:"Failed to reload transcript")}finally{Oe.current===m&&He(!1)}}},[re==null?void 0:re.conversationKind,be,$t]),Zr=a.useCallback(m=>Jt(m),[Jt]),Xr=a.useCallback(async()=>{if(re)try{await Ai(re.id),Ke(),Pe()}catch(m){ie.error(m instanceof Error?m.message:"Failed to cancel task")}},[re,Ke,Pe]),{handleShareTask:Jr,handleStopShareTask:eo}=Hc(re,Ke,Pe),to=a.useCallback(async()=>{if(re)try{await Mi(re.id),Ke(),Pe()}catch(m){ie.error(m instanceof Error?m.message:"Failed to retry task")}},[re,Ke,Pe]),es=a.useCallback((m,I=!1)=>{const Y=nd(tt,m);return C(Y),(I||!Y)&&xt(),a.startTransition(()=>{n(Y?`/tasks/${Y}`:"/",{state:null})}),Y},[xt,tt,n]),so=a.useCallback((m,I)=>{ye(Y=>{const je=new Set(Y);return I?je.add(m):je.delete(m),je})},[]),no=a.useCallback(m=>{if(!m){ye(new Set);return}ye(new Set(tt.map(I=>I.id)))},[tt]),ao=a.useCallback(async()=>{const m=Array.from(fe);if(m.length!==0)try{const{results:I}=await Pi(m),Y=I.filter(he=>!he.ok),je=I.filter(he=>he.ok).map(he=>he.id);be&&je.includes(be)&&es(je),Y.length>0?ie.error(`Failed to archive ${Y.length} task(s): ${Y.map(he=>he.error??he.id).join(", ")}`):ie.success(`Archived ${je.length} task(s)`),ye(new Set(Y.map(he=>he.id))),Pe()}catch(I){ie.error(I instanceof Error?I.message:"Failed to archive tasks")}},[be,Pe,es,fe]),ro=a.useCallback(async()=>{const m=Array.from(fe);if(m.length!==0)try{const{results:I}=await Li(m),Y=I.filter(he=>!he.ok),je=I.filter(he=>he.ok).map(he=>he.id);je.length>0&&Ae(je),be&&je.includes(be)&&es(je,!0),Y.length>0?ie.error(`Failed to delete ${Y.length} task(s): ${Y.map(he=>he.error??he.id).join(", ")}`):ie.success(`Deleted ${je.length} task(s)`),ye(new Set(Y.map(he=>he.id))),Pe()}catch(I){ie.error(I instanceof Error?I.message:"Failed to delete tasks")}},[be,Pe,es,Ae,fe]),oo=a.useCallback(async()=>{lt(!0);try{await Ii(),h()}catch(m){ie.error(m instanceof Error?m.message:"Failed to promote node")}finally{lt(!1)}},[h]),io=a.useCallback(async()=>{Ge(!0);try{await Oi(),ie.success("This node left the remote cluster and is leading itself again."),Pe(),Ke(),h()}catch(m){ie.error(m instanceof Error?m.message:"Failed to leave cluster")}finally{Ge(!1)}},[Ke,Pe,h]),lo=a.useCallback(async m=>{var zt;const I=!cn(m),Y=m.id===((zt=o==null?void 0:o.self)==null?void 0:zt.id),je=Y?(i==null?void 0:i.transportType)??m.transportType:m.transportType,he=Y&&!I&&Ot(je);yt(m.id);try{he?await Bi("direct"):await Ri(m.id,I),ie.success(I?`Enabled remote access on ${m.name}`:`Disabled remote access on ${m.name}`),h()}catch(Tn){ie.error(Tn instanceof Error?Tn.message:"Failed to update remote access")}finally{yt(null)}},[(Sn=o==null?void 0:o.self)==null?void 0:Sn.id,h,i==null?void 0:i.transportType]),co=a.useCallback(m=>{ve&&ve(m).catch(I=>{ie.error(I instanceof Error?I.message:"Failed to load completed tasks")})},[ve]),jn={toolbarTasks:tt,activeTaskId:be,tasksLoading:Ss,tasksError:_r,isLeader:xe,scope:v,agentFilter:p,nodeFilter:b,taskKindFilter:j,agentOptions:Dr,nodeOptions:Ar,nodeNameById:gn,nodeWorkDirById:Mr,nodeStatusById:Pr,leaderNodeId:((Cn=o==null?void 0:o.leader)==null?void 0:Cn.id)??null,searchQuery:E,completedGroupByKey:Lr,devBoxNodeIds:Xe,devBoxStartNodeIds:Bt,devBoxStartingNodeIds:dt,selectedTaskIds:fe,allVisibleTasksSelected:Br,someVisibleTasksSelected:Rr,canBatchArchive:$r,onScopeChange:D,onAgentFilterChange:S,onNodeFilterChange:w,onTaskKindFilterChange:_,onToggleTaskSelected:so,onToggleAllVisibleTasks:no,onBatchArchive:ao,onBatchDelete:ro,onCreateTask:As,onOpenNodeSettings:xe?Nt:void 0,onOpenNodeCapabilities:xe?Be:void 0,onOpenProjectCapabilities:xe?kt:void 0,onOpenDevBox:xe?ke:void 0,onStartDevBox:xe?ct:void 0,onLoadCompletedTasks:co,onSelectTask:vn},uo={cluster:o,systemInfo:i,nodeNameById:gn,nodeBlockingTaskCounts:Er,eventTypeFilter:G,onEventTypeFilterChange:F,activeTab:oe,onTabChange:de,eventTypeOptions:Cs,filteredEvents:Or,sseConnected:c,clusterLoading:y,clusterError:g,promotePending:Ee,onPromote:oo,onAddNode:()=>U(!0),leavePending:Ne,onLeaveCluster:io,onToggleNodeDevTunnel:lo,devTunnelNodeId:wt,devBoxStartNodeId:gt,devBoxStartingNodeIds:dt,onOpenNodeSettings:xe?Nt:void 0,onOpenNodeCapabilities:xe?Be:void 0,onOpenDevBox:xe?ke:void 0,onStartDevBox:xe?ct:void 0};return e.jsxs(e.Fragment,{children:[e.jsx(mc,{desktopTasksOpen:M,mobileTasksPanelOpen:Q,mobileTasksPanelRef:B,operationsOpen:R,operationsPanelRef:ne,panelResize:V,taskSidebar:e.jsx(da,{...jn}),operationsSidecar:e.jsx(Dc,{...uo}),terminalPanel:r!=null&&r.terminalOpen?e.jsx(jc,{nodes:bn,defaultNodeId:Ir,onClose:()=>r==null?void 0:r.setTerminalOpen(!1)}):void 0,conversationPanel:e.jsx(ac,{onToggleTasks:se,desktopTasksOpen:M,mobileTasksPanelOpen:Q,operationsOpen:R,onToggleOperations:()=>ee(m=>!m),cluster:o,sseConnected:c,activeTab:L,setActiveTab:le,creatingTask:O,createMode:P,createDefaults:x,activeTask:re,assignedNode:Fr,taskLoading:Ue,transcriptLoading:it,taskError:Ze,displayEvents:Es,initialPromptAlreadyInLogs:qr,initialPrompt:Xt,supportsFollowUp:zr,taskUnavailable:_s.taskUnavailable,chatDisabled:_s.chatDisabled,chatDisabledReason:_s.chatDisabledReason,questionBypassEnabled:te,isRunning:!!Zt,isStarting:Hr,hasPendingFollowUp:Ts,canCancel:!!Ur,canRetry:!!Vr,onRetry:to,onCancel:Xr,onReloadNativeTranscript:Qr,onShareTask:Jr,onStopShareTask:eo,onStartCreateTask:As,onCancelCreateTask:Kr,onCreateTask:Wr,onSendMessage:Yr,onCancelQueuedMessage:Gr,onQuestionBypassChange:ce,onSubmitQuestionResponse:Zr,quickChats:ut}),mobileTaskSidebar:e.jsx(da,{...jn,onCreateTask:(m,I)=>{K(!1),As(m,I)},onSelectTask:m=>{K(!1),vn(m)}}),onCloseOperations:()=>ee(!1),onCloseTaskList:()=>K(!1),onToggleOperations:()=>ee(m=>!m),onToggleTasks:se}),e.jsx(ic,{open:T,onOpenChange:U,onAdded:h}),pt,ft,Me]})}const xm=Object.freeze(Object.defineProperty({__proto__:null,DashboardPage:lm},Symbol.toStringTag,{value:"Module"}));export{qa as A,xm as D,fs as G};
|