meshy-node 0.7.1 → 0.7.3
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-X6_yBCiT.js +134 -0
- package/dashboard/assets/{DashboardShared-CwzjyKjD.js → DashboardShared-CAhZuVr7.js} +14 -14
- package/dashboard/assets/{DiffTab-JcjmTbSr.js → DiffTab-B9X1MLJB.js} +2 -2
- package/dashboard/assets/{FilesTab-AiSg3g3W.js → FilesTab-hBKGU1Xk.js} +4 -4
- package/dashboard/assets/{PreviewTab-IywNFnSA.js → PreviewTab-BLWRbGFK.js} +2 -2
- package/dashboard/assets/{SharedConversationPage-DqPIB4y2.js → SharedConversationPage-iJnL7wsU.js} +3 -3
- package/dashboard/assets/{file-YSc4rLAQ.js → file-CfRz3Bk5.js} +1 -1
- package/dashboard/assets/index-BJilr1zc.js +321 -0
- package/dashboard/assets/{index-DtAYxdhK.css → index-Dy6nrw83.css} +1 -1
- package/dashboard/assets/{play-B0JrmxjD.js → play-BRxqaYuX.js} +1 -1
- package/dashboard/index.html +2 -2
- package/main.cjs +177 -7
- package/package.json +5 -1
- package/runtime-metadata.json +5 -5
- package/dashboard/assets/DashboardPage-wM8CMREX.js +0 -134
- package/dashboard/assets/index-DspjtpEf.js +0 -321
package/README.md
CHANGED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-hBKGU1Xk.js","assets/index-BJilr1zc.js","assets/index-Dy6nrw83.css","assets/file-CfRz3Bk5.js","assets/DashboardShared-CAhZuVr7.js","assets/PreviewTab-BLWRbGFK.js","assets/play-BRxqaYuX.js","assets/DiffTab-B9X1MLJB.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as xe,r as a,j as e,X as ts,B as V,S as Sa,a as Wn,b as $,d as Gn,g as Qn,e as Yn,I as Xe,C as ys,f as Xn,h as Jn,F as Zn,i as Ca,k as ks,l as Ne,D as Ss,m as er,n as sr,t as ae,o as ye,p as ke,q as Re,s as Se,u as st,v as as,T as tr,w as ar,x as Xt,y as nr,z as St,A as Ct,E as _t,G as _a,H as Da,J as xs,K as tt,L as rr,M as Ea,N as Be,O as Ta,P as or,Q as Ma,R as ns,U as ir,V as rs,W as at,Y as nt,Z as rt,_ as ot,$ as it,a0 as lt,a1 as dt,a2 as ct,a3 as Dt,a4 as lr,a5 as Aa,a6 as La,a7 as dr,a8 as Gs,a9 as Jt,aa as Bs,ab as cr,ac as ur,ad as mr,ae as xr,af as hr,ag as pr,ah as fr,ai as gr,aj as Pa,ak as Ba,al as Ra,am as br,an as Rs,ao as vr,ap as jr,aq as Nr,ar as ut,as as $a,at as wr,au as yr,av as Zt,aw as Et,ax as kr,ay as Sr,az as Cr,aA as _r,aB as ea,aC as Dr,aD as Er,aE as Qs,aF as Tr,aG as sa,aH as Mr,aI as Ar,aJ as Lr,aK as Pr,aL as Br,aM as mt,aN as Rr,aO as $r,aP as Or,aQ as ta,aR as Oa,aS as Fr,aT as Ir,aU as zr,aV as Vr,aW as Ur,aX as Hr,aY as qr,aZ as Kr,a_ as Wr,a$ as Gr,b0 as Qr,b1 as Yr,b2 as Xr,b3 as Jr,b4 as Zr,b5 as eo,b6 as so,b7 as to,b8 as ao,b9 as no,ba as ro,bb as oo,bc as io,bd as lo,be as co,bf as uo}from"./index-BJilr1zc.js";import{r as aa,e as mo,b as Fa,t as Ia,A as Tt,L as ce,g as za,a as xo,c as ho,d as na,f as ra,h as po,i as fo,C as oa,T as Ys,D as ms,I as We,M as xt,j as Va,m as Ua,k as ht,l as go,n as ia,o as bo,p as vo,q as Xs,s as jo,u as No,v as wo}from"./DashboardShared-CAhZuVr7.js";import{P as Mt}from"./play-BRxqaYuX.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 yo=[["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"}]],ko=xe("archive",yo);/**
|
|
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 So=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Co=xe("arrow-up",So);/**
|
|
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 _o=[["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"}]],Do=xe("ellipsis-vertical",_o);/**
|
|
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 Eo=[["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"}]],To=xe("flag",Eo);/**
|
|
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 Mo=[["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"}]],Ha=xe("folder-open",Mo);/**
|
|
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 Ao=[["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"}]],Lo=xe("funnel",Ao);/**
|
|
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 Po=[["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"}]],pt=xe("git-branch",Po);/**
|
|
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 Bo=[["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"}]],Ro=xe("globe",Bo);/**
|
|
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 $o=[["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"}]],ft=xe("history",$o);/**
|
|
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 Oo=[["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"}]],gt=xe("image-plus",Oo);/**
|
|
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 Fo=[["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"}]],Io=xe("laptop",Fo);/**
|
|
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 zo=[["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"}]],At=xe("link-2",zo);/**
|
|
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 Vo=[["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"}]],Uo=xe("list-ordered",Vo);/**
|
|
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 Ho=[["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"}]],Lt=xe("message-square-plus",Ho);/**
|
|
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 qo=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],qa=xe("panel-left-close",qo);/**
|
|
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 Ko=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],Wo=xe("panel-left-open",Ko);/**
|
|
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 Go=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],Pt=xe("panel-right-close",Go);/**
|
|
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 Qo=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],Ka=xe("panel-right-open",Qo);/**
|
|
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 Yo=[["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"}]],gs=xe("pencil",Yo);/**
|
|
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 Xo=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Jo=xe("plus",Xo);/**
|
|
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 Zo=[["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"}]],la=xe("rotate-ccw",Zo);/**
|
|
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 ei=[["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"}]],Wa=xe("send",ei);/**
|
|
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 si=[["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"}]],ti=xe("share-2",si);/**
|
|
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 ai=[["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"}]],ni=xe("sliders-horizontal",ai);/**
|
|
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 ri=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],da=xe("square",ri);/**
|
|
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 oi=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],ii=xe("trash-2",oi),li=new Set(["assigned","running"]);function di(s,t){return s.reduce((n,o)=>o.assignedTo===t&&li.has(o.status)?n+1:n,0)}function bs(s){return(s==null?void 0:s.toLowerCase())==="devtunnel"}function ci(s){return s?bs(s)?"DevTunnel":s.charAt(0).toUpperCase()+s.slice(1):"Direct"}function Bt(s,t){return bs(t??s.transportType)||!!s.devtunnelEndpoint}function Ga(s,t){return!bs(t??s.transportType)}function Qa(s,t){const n=t??s.transportType;return bs(n)?"DevTunnel":s.devtunnelEndpoint?"Direct + DevTunnel":ci(n)}function ca(s,t){return!s&&!t}function ui({routeTaskId:s,creatingTask:t,internalSelectedTaskId:n,sortedTaskIds:o}){return s||(t?null:o[0]??n??null)}function mi(s,t){return[t,...s.filter(n=>n.id!==t.id)]}const xi=new Set(["completed","failed","cancelled","archived"]);function hi(s,t){const n=new Set(t);return new Set(Array.from(s).filter(o=>n.has(o)))}function pi(s,t){const n=new Set(t);if(n.size===0)return!1;const o=s.filter(r=>n.has(r.id));return o.length===n.size&&o.every(r=>xi.has(r.status))}function fi(s,t){var o;const n=new Set(t);return((o=s.find(r=>!n.has(r.id)))==null?void 0:o.id)??null}function Ya(){const[s,t]=a.useState([]),[n,o]=a.useState(null),r=a.useRef(null),i=a.useCallback(()=>{var f;(f=r.current)==null||f.click()},[]),v=a.useCallback(async f=>{const l=Array.from(f.target.files??[]);if(l.length!==0)try{const u=await aa(l);t(w=>[...w,...u]),o(null)}catch(u){o(u instanceof Error?u.message:"Failed to attach image")}finally{f.target.value=""}},[]),g=a.useCallback(async f=>{const l=mo(f.clipboardData);if(l.length!==0){f.preventDefault();try{const u=await aa(l);t(w=>[...w,...u]),o(null)}catch(u){o(u instanceof Error?u.message:"Failed to attach image")}}},[]),N=a.useCallback(f=>{t(l=>l.filter((u,w)=>w!==f))},[]),b=a.useCallback(()=>{t([]),o(null)},[]);return{images:s,error:n,fileInputRef:r,pickImages:i,handleFileChange:v,handlePaste:g,removeImage:N,clearImages:b}}function gi(s){const t=s.map(r=>({...r,displayValue:bi(r)})),n=t.findIndex(r=>r.label.toLowerCase()==="working dir"),o=n>=0?n:0;return{primary:t[o],secondary:t.filter((r,i)=>i!==o)}}function bi(s){return s.label.toLowerCase()==="agent"?za(s.value):s.value}function ua(s){switch(s.toLowerCase()){case"branch":return pt;case"node":return Sa;case"working dir":default:return Ha}}function vi({disabled:s=!1,running:t=!1,canStop:n=!1,hasContent:o=!1}){return t&&!o?{primaryAction:"stop",primaryDisabled:s||!n}:{primaryAction:"send",primaryDisabled:s||!o}}function ji({onSend:s,disabled:t,disabledReason:n="Chat is waiting on the agent.",placeholder:o="Send a follow-up message...",contextItems:r=[],running:i=!1,onStop:v}){const[g,N]=a.useState(""),b=a.useRef(null),{images:f,error:l,fileInputRef:u,pickImages:w,handleFileChange:_,handlePaste:x,removeImage:h,clearImages:c}=Ya(),j=a.useCallback(()=>{b.current&&(b.current.style.height="auto")},[]),S=a.useCallback(()=>{const E=Fa(g,f);E.length===0||t||(s(E),N(""),c(),j())},[g,f,t,s,c,j]),I=a.useCallback(E=>{E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),S())},[S]),A=a.useCallback(()=>{b.current&&(b.current.style.height="auto",b.current.style.height=`${Math.min(b.current.scrollHeight,220)}px`)},[]),B=g.trim().length>0||f.length>0,O=vi({disabled:t,running:i,canStop:i&&!!v,hasContent:B}),U=gi(r),M=U.primary?ua(U.primary.label):Ha,L=i?B?"Enter queues this message for the next turn":v?"Task is running - type to queue, empty button stops task":"Task is running - type to queue a message":t?n:"Enter sends, Shift+Enter adds a line";return e.jsx("div",{"data-chat-input-shell":"true",className:"animate-composer-settle w-full border-t border-border/45 bg-background/42 px-2 py-2 backdrop-blur-xl sm:px-4 sm:py-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:"overflow-hidden rounded-xl border border-border/65 bg-card/88 shadow-[0_30px_92px_-62px_rgba(15,23,42,0.55)] backdrop-blur-xl sm:rounded-xl dark:shadow-[0_30px_92px_-62px_rgba(0,0,0,0.95)]",children:[e.jsx("input",{ref:u,type:"file",accept:"image/*",multiple:!0,onChange:_,className:"hidden"}),U.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:"inline-flex max-w-full items-center gap-1.5 rounded-sm border border-border/55 bg-muted/35 px-1.5 py-0.5",children:[e.jsx(M,{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:U.primary.value,children:U.primary.displayValue})]})}),f.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:f.map((E,X)=>e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:Ia(E),alt:E.filename??`attachment ${X+1}`,className:"h-24 w-24 rounded-xl border border-border/70 object-cover"}),e.jsx("button",{type:"button",onClick:()=>h(X),className:"absolute -top-2 -right-2 flex h-7 w-7 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 ${E.filename??`image ${X+1}`}`,children:e.jsx(ts,{className:"h-3.5 w-3.5"})})]},`${E.filename??"image"}-${X}`))})}),e.jsx("div",{className:"px-2 pb-0 pt-1 sm:px-5 sm:pt-1.5",children:e.jsx("textarea",{ref:b,value:g,onChange:E=>N(E.target.value),onKeyDown:I,onPaste:x,onInput:A,placeholder:o,disabled:t,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.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:[U.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:U.secondary.map(E=>{const X=ua(E.label),H=E.label.toLowerCase()==="agent";return e.jsxs("span",{title:`${E.label}: ${E.value}`,className:"inline-flex min-w-0 max-w-[12rem] items-center gap-1 truncate",children:[H?e.jsx(Tt,{agent:E.value,className:"h-2.5 w-2.5 shrink-0 text-primary/50"}):e.jsx(X,{"data-chat-input-secondary-icon":"true",className:"h-2.5 w-2.5 shrink-0 text-primary/50","aria-hidden":"true"}),e.jsx("span",{className:`truncate ${E.mono?"font-mono":""}`,children:E.displayValue})]},`${E.label}:${E.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(V,{type:"button",variant:"ghost",onClick:w,disabled:t,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(gt,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Images"})]}),e.jsx("span",{title:L,children:e.jsx(V,{onClick:O.primaryAction==="stop"?v:S,disabled:O.primaryDisabled,size:"icon","aria-label":O.primaryAction==="stop"?"Stop running task":i?"Queue message":"Send message",className:"h-7 w-9 shrink-0 rounded-sm bg-primary/90 text-primary-foreground shadow-[0_12px_30px_-18px_hsl(var(--primary)/0.95)] hover:bg-primary",children:O.primaryAction==="stop"?e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Wa,{className:"h-3.5 w-3.5"})})})]})]}),l&&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:l})]})})})}var Ni=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],wi=Ni.reduce((s,t)=>{const n=Wn(`Primitive.${t}`),o=a.forwardRef((r,i)=>{const{asChild:v,...g}=r,N=v?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(N,{...g,ref:i})});return o.displayName=`Primitive.${t}`,{...s,[t]:o}},{}),yi="Label",Xa=a.forwardRef((s,t)=>e.jsx(wi.label,{...s,ref:t,onMouseDown:n=>{var r;n.target.closest("button, input, select, textarea")||((r=s.onMouseDown)==null||r.call(s,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));Xa.displayName=yi;var Ja=Xa;const ki=Gn("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Te=a.forwardRef(({className:s,...t},n)=>e.jsx(Ja,{ref:n,className:$(ki(),s),...t}));Te.displayName=Ja.displayName;function Si(s,t,n){return s!=="auto"?t.find(o=>o.id===s)??null:n.length===1?n[0]??null:null}function Ci(s){return s.trim()||"."}function _i(s){return new Promise(t=>window.setTimeout(t,s))}function Di(s){return!!s&&typeof s=="object"&&typeof s.createdBranch=="string"&&typeof s.currentBranch<"u"}async function Ei(s){let t=s;for(let n=0;n<60;n++){if(t.status==="succeeded"){if(Di(t.result))return t.result;throw new Error("Branch creation completed without branch details")}if(t.status==="failed")throw new Error(t.error||"Branch creation failed");await _i(1e3),t=await Xn(t.id)}throw new Error("Timed out waiting for branch creation")}function ma({value:s,onChange:t,project:n,assignTo:o,nodes:r,assignableNodes:i,layout:v="default",chipClassName:g,chipActiveClassName:N,chipInactiveClassName:b,labelClassName:f,triggerClassName:l}){const[u,w]=a.useState(!1),[_,x]=a.useState(null),[h,c]=a.useState(""),[j,S]=a.useState(!1),[I,A]=a.useState(!1),[B,T]=a.useState(!1),[O,U]=a.useState(null),[M,L]=a.useState(""),[E,X]=a.useState(""),[H,Y]=a.useState(""),[de,ne]=a.useState(!1),Z=a.useRef(null),J=a.useRef(0),q=a.useMemo(()=>Si(o,r,i),[o,r,i]),K=q==null?void 0:q.id,re=a.useMemo(()=>Ci(n),[n]),me=a.useMemo(()=>K?`${K}
|
|
133
|
+
${re}`:"",[K,re]),p=a.useCallback(async(k=0,z=!1)=>{const ee=J.current+1,Me=me;if(J.current=ee,!K){x(null),c("");return}U(null),z||c(""),z?A(!0):S(!0);try{const ve=await Qn(K,{path:re,limit:20,offset:k,allowAbsolute:!0});if(ee!==J.current)return;c(Me),x($e=>z&&$e?{...ve,branches:[...$e.branches,...ve.branches]}:ve)}catch(ve){if(ee!==J.current)return;U(ve instanceof Error?ve.message:"Failed to load branch info"),z||(x(null),c(""))}finally{ee===J.current&&(S(!1),A(!1))}},[K,me,re]);a.useEffect(()=>{if(!K){J.current+=1,x(null),c(""),U(null);return}p()},[K,re,p]),a.useEffect(()=>{const k=s.trim(),z=h===me?_:null,ee=z!=null&&z.available&&z.currentBranch?z.currentBranch:"";k!==ee&&t(ee)},[_,me,h,t,s]),a.useEffect(()=>{if(!u)return;const k=ee=>{Z.current&&(Z.current.contains(ee.target)||w(!1))},z=ee=>{ee.key==="Escape"&&w(!1)};return document.addEventListener("mousedown",k),document.addEventListener("keydown",z),()=>{document.removeEventListener("mousedown",k),document.removeEventListener("keydown",z)}},[u]),a.useEffect(()=>{u&&(X(""),Y(""),ne(!1))},[u,K,re]);const F=a.useCallback(async()=>{if(!K)return;const k=M.trim(),z=de?H.trim():E.trim();if(!(!k||!z)){T(!0),U(null);try{const ee=await Yn(K,{path:re,branchName:k,startPoint:z,limit:20,offset:0,allowAbsolute:!0}),Me=await Ei(ee);c(me),x(Me),t(Me.currentBranch??Me.createdBranch),L(""),X(""),Y(""),ne(!1),w(!1)}catch(ee){U(ee instanceof Error?ee.message:"Failed to create branch")}finally{T(!1)}}},[K,me,re,de,H,M,t,E]),C=h===me?_:null,se=a.useCallback(()=>{C!=null&&C.hasMore&&p(C.branches.length,!0)},[C,p]),m=s.trim()||(C==null?void 0:C.currentBranch)||(C&&!C.available?"No git repo":"Branch"),P=de?H.trim():E.trim(),W=!!(C!=null&&C.available&&M.trim()&&P&&!B),te=v==="composer"?e.jsxs(V,{type:"button",variant:"ghost",onClick:()=>w(k=>!k),title:m,"aria-label":`Branch: ${m}`,className:$(g,l,"min-w-0 max-w-full",s.trim()?N:b),children:[j&&!C?e.jsx(ce,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(pt,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:$("min-w-0 truncate",f),children:m})]}):e.jsxs(V,{type:"button",variant:"outline",onClick:()=>w(k=>!k),className:"h-11 w-full justify-between rounded-2xl border-border/70 bg-background/70 px-4",title:m,children:[e.jsx("span",{className:$("truncate",s.trim()?"font-mono text-foreground":"text-muted-foreground"),children:m}),e.jsx("span",{className:"ml-3 shrink-0 text-xs text-muted-foreground",children:q?q.name:"Manual"})]});return e.jsxs("div",{className:$("relative inline-block",v==="composer"?"min-w-0 shrink-0":"w-full"),ref:Z,children:[v==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Te,{className:"text-sm font-medium",children:"Branch"}),te]}):te,u&&e.jsxs("div",{className:$("absolute z-50 mt-2 w-[240px] overflow-hidden rounded-2xl border border-border/60 bg-background/95 shadow-lg backdrop-blur",v==="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(pt,{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:C!=null&&C.repoRoot?`${C.currentBranch??m} · ${C.repoRoot}`:(C==null?void 0:C.currentBranch)??m,children:(C==null?void 0:C.currentBranch)??m}),j?e.jsx(ce,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground"}):null]}),q?j&&!C?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(ce,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):C&&!C.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(Xe,{value:M,onChange:k=>L(k.target.value),placeholder:"New branch name",className:"h-8 flex-1 rounded-md border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx(V,{type:"button",size:"sm",onClick:()=>void F(),disabled:!W,title:W?"Create branch":"Enter a name and pick a base","aria-label":"Create branch",className:"h-8 w-8 shrink-0 rounded-md p-0",children:B?e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Jo,{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"}),!de&&e.jsxs("button",{type:"button",onClick:()=>ne(!0),className:"flex items-center gap-1 rounded px-1 py-0.5 text-[10px] text-muted-foreground hover:bg-background/60 hover:text-foreground",children:[e.jsx(gs,{className:"h-2.5 w-2.5"}),"Manual"]})]}),de?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Xe,{value:H,onChange:k=>Y(k.target.value),placeholder:"upstream/release/1.0",className:"h-8 flex-1 rounded-md border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx("button",{type:"button",onClick:()=>{ne(!1),Y("")},className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Cancel manual input","aria-label":"Cancel manual input",children:e.jsx(ts,{className:"h-3.5 w-3.5"})})]}):C!=null&&C.branches.length?e.jsxs("div",{className:"max-h-44 overflow-y-auto rounded-md border border-border/40 bg-background/40",children:[C.branches.map(k=>{const z=E===k.ref,ee=k.branch==="main"||k.branch==="master";return e.jsxs("button",{type:"button",onClick:()=>X(k.ref),className:$("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",z&&"bg-background/70"),title:k.ref,children:[e.jsx("span",{className:$("shrink-0 text-[10px]",ee?"text-amber-500 dark:text-amber-400":"text-muted-foreground/60"),"aria-hidden":!0,children:ee?"★":"·"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-foreground",children:k.ref}),z?e.jsx(ys,{className:"h-3 w-3 shrink-0 text-primary"}):null]},k.ref)}),C.hasMore&&e.jsxs("button",{type:"button",onClick:se,disabled:I,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:[I?e.jsx(ce,{className:"h-3 w-3 animate-spin"}):e.jsx(ft,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"rounded-md 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."}),O&&e.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-3 py-1.5 text-[11px] text-destructive",children:O})]})]})}const Ti=20,Mi=3,bt="meshy-working-dir-recents-by-node";function Ai(s){return s.startsWith("/")||s.startsWith("\\\\")||/^[A-Za-z]:[\\/]/.test(s)}function Li(s){const t=s.trim();return t||"."}function vt(s){const t=[],n=new Set;for(const o of s){const r=o.trim();if(!(!r||n.has(r))&&(n.add(r),t.push(r),t.length===Mi))break}return t}function Pi(s,t){const n=t.trim();return vt(n?[n,...s]:s)}function Za(s){if(!s||typeof s!="object"||Array.isArray(s))return{};const t={};for(const[n,o]of Object.entries(s)){if(!n||!Array.isArray(o))continue;const r=o.filter(v=>typeof v=="string"),i=vt(r);i.length>0&&(t[n]=i)}return t}function Bi(s,t,n){if(!t)return s;const o=s[t]??[],r=Pi(o,n);if(r.length===0){if(!(t in s))return s;const{[t]:i,...v}=s;return v}return{...s,[t]:r}}function Ri(s,t){var n;return t?((n=s[t])==null?void 0:n[0])??"":""}function en(s){if(!s||typeof window>"u")return"";try{const t=window.localStorage.getItem(bt);return t?Ri(Za(JSON.parse(t)),s):""}catch{return""}}function $i(s,t,n){return s!=="auto"?t.find(o=>o.id===s)??null:n.length===1?n[0]??null:null}function Oi(s,t){const n=t.trim();return n?Ai(n)||!s?n:`${s.replace(/[/\\]+$/,"")}/${n}`:""}function Fi(s,t){return s?s.isAbsolute?s.currentPath:s.currentPath==="."||s.currentPath===""?s.rootPath||(t==null?void 0:t.workDir)||"Node root":s.currentPath:(t==null?void 0:t.workDir)??"Node root"}function $s({value:s,onChange:t,assignTo:n,nodes:o,assignableNodes:r,layout:i="default",chipClassName:v,chipActiveClassName:g,chipInactiveClassName:N,labelClassName:b,triggerClassName:f,popoverPlacement:l="bottom",popoverAlign:u="start"}){const[w,_]=a.useState(!1),[x,h]=a.useState(null),[c,j]=a.useState(!1),[S,I]=a.useState(!1),[A,B]=a.useState(null),[T,O]=a.useState(""),[U,M]=a.useState(!1),[L,E]=a.useState({}),X=a.useRef(null),H=a.useMemo(()=>$i(n,o,r),[n,o,r]),Y=H==null?void 0:H.id,de=a.useMemo(()=>Y?L[Y]??[]:[],[L,Y]),ne=a.useMemo(()=>s.trim()?Oi(H==null?void 0:H.workDir,s):"Use node default",[s,H==null?void 0:H.workDir]);a.useEffect(()=>{if(!(typeof window>"u"))try{const m=window.localStorage.getItem(bt);if(!m)return;const P=JSON.parse(m);E(Za(P))}catch{}},[]);const Z=a.useCallback(m=>{Y&&E(P=>{const W=Bi(P,Y,m);if(W===P)return P;if(typeof window<"u")try{window.localStorage.setItem(bt,JSON.stringify(W))}catch{}return W})},[Y]),J=a.useCallback((m,P=!0)=>{const W=m.trim();t(W),P&&W&&Z(W),_(!1)},[t,Z]),q=a.useCallback(async(m,P=0,W=!1)=>{if(Y){B(null),W?I(!0):j(!0);try{const te=await Jn(Y,{path:m,limit:Ti,offset:P,directoriesOnly:!0,allowAbsolute:!0});h(k=>W&&k?{...te,entries:[...k.entries,...te.entries]}:te)}catch(te){B(te instanceof Error?te.message:"Failed to browse directories"),W||h(null)}finally{j(!1),I(!1)}}},[Y]),K=a.useRef(s);K.current=s;const re=a.useRef(q);re.current=q,a.useEffect(()=>{if(!w)return;const m=K.current;O(m),M(!1),h(null),B(null),Y&&re.current(Li(m))},[w,Y]),a.useEffect(()=>{if(!w)return;const m=W=>{X.current&&(X.current.contains(W.target)||_(!1))},P=W=>{W.key==="Escape"&&_(!1)};return document.addEventListener("mousedown",m),document.addEventListener("keydown",P),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",P)}},[w]);const me=a.useCallback(m=>{q(m)},[q]),p=a.useCallback(()=>{x&&q(x.currentPath,x.entries.length,!0)},[x,q]),F=i==="composer"?e.jsxs(V,{type:"button",variant:"ghost",onClick:()=>_(m=>!m),title:ne,"aria-label":`Working directory: ${ne}`,className:$(v,f,"min-w-0 max-w-full",s.trim()?g:N),children:[e.jsx(Zn,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:$("min-w-0 truncate",b),children:ne})]}):e.jsxs(V,{type:"button",variant:"outline",onClick:()=>_(m=>!m),className:"h-11 w-full justify-between rounded-2xl border-border/70 bg-background/70 px-4",title:ne,children:[e.jsx("span",{className:$("truncate",s.trim()?"font-mono text-foreground":"text-muted-foreground"),children:ne}),e.jsx("span",{className:"ml-3 shrink-0 text-xs text-muted-foreground",children:H?H.name:"Manual"})]}),C=Fi(x,H),se=!!(x!=null&&x.parentPath);return e.jsxs("div",{className:$("relative inline-block",i==="composer"?"min-w-0 max-w-[60%] shrink":"w-full"),"data-workdir-popover-placement":l,"data-workdir-popover-align":u,ref:X,children:[i==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Te,{className:"text-sm font-medium",children:"Working directory"}),F]}):F,w&&e.jsxs("div",{className:$("absolute z-50 flex max-h-[min(28rem,calc(100vh-5rem))] w-[240px] flex-col overflow-hidden rounded-2xl border border-border/60 bg-background/95 shadow-lg backdrop-blur",l==="top"?"bottom-full mb-2":"top-full mt-2",i==="composer"?u==="end"?"right-0":"left-0":u==="end"?"right-0 w-auto min-w-[240px]":"left-0 right-0 w-auto min-w-[240px]"),children:[de.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(ft,{className:"h-2.5 w-2.5"}),"Recent"]}),e.jsx("div",{className:"flex flex-col",children:de.map(m=>e.jsx("button",{type:"button",onClick:()=>J(m),className:"truncate rounded px-1.5 py-0.5 text-left font-mono text-[11px] text-foreground hover:bg-background/60",title:m,children:m},m))})]}),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:()=>(x==null?void 0:x.parentPath)&&me(x.parentPath),disabled:!se||c,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md 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(Co,{className:"h-3 w-3"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground",title:C,children:C}),x&&e.jsx("button",{type:"button",onClick:()=>J(x.isAbsolute?x.currentPath:x.currentPath==="."?"":x.currentPath),className:"shrink-0 rounded 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:[H?c?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(ce,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):x&&x.entries.length>0?e.jsxs(e.Fragment,{children:[x.entries.map(m=>e.jsxs("div",{className:"group flex items-stretch border-b border-border/30 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>J(m.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 ${m.path}`,children:[e.jsx(Ca,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-[11px] text-foreground",children:m.name})]}),e.jsx("button",{type:"button",onClick:()=>me(m.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 ${m.name}`,children:e.jsx(ks,{className:"h-3.5 w-3.5"})})]},m.path)),x.hasMore&&e.jsxs("button",{type:"button",onClick:p,disabled:S,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:[S?e.jsx(ce,{className:"h-3 w-3 animate-spin"}):e.jsx(ft,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:A??"No subfolders."}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Select a node to browse."}),A&&x&&x.entries.length>0&&e.jsx("div",{className:"border-t border-border/60 px-3 py-1.5 text-[11px] text-destructive",children:A})]}),e.jsx("div",{className:"flex items-center gap-1 border-t border-border/60 bg-background/40 px-2.5 py-1.5",children:U?e.jsxs(e.Fragment,{children:[e.jsx(Xe,{value:T,onChange:m=>O(m.target.value),onKeyDown:m=>{m.key==="Enter"&&T.trim()?(m.preventDefault(),J(T)):m.key==="Escape"&&(m.preventDefault(),M(!1),O(s))},autoFocus:!0,placeholder:"Path (relative or absolute)",className:"h-7 flex-1 rounded-md border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx("button",{type:"button",onClick:()=>J(T),disabled:!T.trim(),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-foreground hover:bg-background/60 disabled:opacity-40",title:"Apply","aria-label":"Apply manual path",children:e.jsx(ys,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{M(!1),O(s)},className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Cancel","aria-label":"Cancel manual path",children:e.jsx(ts,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>{O(s),M(!0)},className:"flex h-7 flex-1 items-center justify-between rounded-md 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(gs,{className:"h-3 w-3"})]})})]})]})}function sn(s,t={}){const n=s.filter(o=>o.status==="online");return t.currentNodeRole!=="follower"||!t.leaderNodeId?n:n.filter(o=>o.id!==t.leaderNodeId)}function Rt({isCurrent:s}){return s?e.jsx(Io,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500 dark:text-emerald-400","aria-label":"current node"}):e.jsx(Ro,{className:"h-3.5 w-3.5 shrink-0 text-sky-500 dark:text-sky-400","aria-label":"remote follower node"})}function jt(s,t){return s.map(n=>{const o=!!t&&n.id===t;return e.jsx(Ne,{value:n.id,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(Rt,{isCurrent:o}),e.jsx("span",{className:"truncate",children:n.name}),e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:o?"current":"remote"})]})},n.id)})}function Ii(s){var o;const t=s.sessionId.trim(),n=s.cwd.trim();return!t||!n||!s.assignTo?null:{title:s.title.trim()||((o=s.defaultTitle)==null?void 0:o.trim())||void 0,agent:s.agent,sessionId:t,cwd:n,assignTo:s.assignTo,priority:s.priority,mode:s.mode??Ss}}function zi(){return tr.map(s=>e.jsx(Ne,{value:s.value,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{children:s.label}),s.description&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:s.description})]})},s.value))}function Vi(s){if(!s)return"unknown time";const t=Date.parse(s);return Number.isNaN(t)?s:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(t)}function Ui({nodes:s,currentNodeRole:t,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,className:v,footerClassName:g,submitLabel:N="Load session",cancelLabel:b="Cancel",autoFocus:f=!1}){const l=a.useMemo(()=>sn(s,{currentNodeRole:t,leaderNodeId:o}),[s,t,o]),u=a.useMemo(()=>{var k;return n&&l.some(z=>z.id===n)?n:((k=l[0])==null?void 0:k.id)??""},[l,n]),[w,_]=a.useState(""),[x,h]=a.useState("codex"),[c,j]=a.useState(""),[S,I]=a.useState(""),[A,B]=a.useState(""),[T,O]=a.useState(u),[U,M]=a.useState("normal"),[L,E]=a.useState(Ss),[X,H]=a.useState(!1),[Y,de]=a.useState([]),[ne,Z]=a.useState(!1),[J,q]=a.useState(null),K=a.useMemo(()=>Y.find(k=>k.sessionId===c)??null,[Y,c]);a.useEffect(()=>{T&&l.some(k=>k.id===T)||O(u)},[T,l,u]),a.useEffect(()=>{j(""),I(""),B("")},[x,T]),a.useEffect(()=>{let k=!1;return T?(Z(!0),q(null),er(T,{agent:x,limit:50}).then(z=>{k||de(z.sessions)}).catch(z=>{k||(de([]),q(z instanceof Error?z.message:"Failed to load native sessions"))}).finally(()=>{k||Z(!1)}),()=>{k=!0}):(de([]),q(null),Z(!1),()=>{k=!0})},[x,T]),a.useEffect(()=>{K&&(I(K.sessionId),B(K.cwd))},[K]);const re=a.useCallback(async k=>{k.preventDefault();const z=Ii({title:w,defaultTitle:K==null?void 0:K.summary,agent:x,sessionId:S,cwd:A,assignTo:T,priority:U,mode:L});if(z){H(!0);try{const ee=await sr(z);r(ee)}catch(ee){ae.error(ee instanceof Error?ee.message:"Failed to load native session")}finally{H(!1)}}},[w,K,x,S,A,T,U,L,r]),me=!!(S.trim()&&A.trim()&&T),[p,F]=a.useState(!1),[C,se]=a.useState(""),m=l.find(k=>k.id===T)??null,P=!!(n&&(m==null?void 0:m.id)===n),W=a.useMemo(()=>{const k=C.trim().toLowerCase();return k?Y.filter(z=>z.summary.toLowerCase().includes(k)||z.sessionId.toLowerCase().includes(k)||z.cwd.toLowerCase().includes(k)):Y},[Y,C]),te="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:re,className:$("space-y-4",v),children:[e.jsxs("div",{className:"rounded-xl border border-border/60 bg-background/54 shadow-[0_24px_86px_-48px_rgba(15,23,42,0.55)] backdrop-blur-xl dark:shadow-[0_24px_86px_-48px_rgba(0,0,0,0.9)]",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-border/50 px-4 py-3",children:[e.jsxs(ye,{value:T,onValueChange:O,children:[e.jsx(ke,{className:$(te),"aria-label":"Node",children:m?e.jsxs(e.Fragment,{children:[e.jsx(Rt,{isCurrent:P}),e.jsx("span",{className:"max-w-[10rem] truncate",children:m.name})]}):e.jsx(Re,{placeholder:"Node"})}),e.jsx(Se,{children:jt(l,n)})]}),e.jsxs(ye,{value:x,onValueChange:k=>h(k),children:[e.jsxs(ke,{className:$(te),"aria-label":"Agent",children:[e.jsx(Tt,{agent:x}),e.jsx("span",{children:x})]}),e.jsx(Se,{children:xo()})]}),e.jsxs("div",{className:"relative ml-auto min-w-0 flex-1 sm:max-w-56",children:[e.jsx(st,{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(Xe,{value:C,onChange:k=>se(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(Te,{className:"text-[10px] font-medium uppercase tracking-[0.2em] text-muted-foreground",children:ne?"Loading...":`${W.length} session${W.length===1?"":"s"}`})}),e.jsxs("div",{className:"relative h-88 overflow-hidden rounded-lg",children:[ne&&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 pt-1",children:[!T&&e.jsx("div",{className:"rounded-lg border border-dashed border-border/60 bg-background/35 px-4 py-6 text-center text-xs text-muted-foreground",children:"Pick a node to load its recent sessions."}),T&&!ne&&W.length===0&&e.jsx("div",{className:"rounded-lg border border-dashed border-border/60 bg-background/35 px-4 py-6 text-center text-xs text-muted-foreground",children:Y.length===0?"No recent sessions on this node. Use Manual session ID under More options.":"No sessions match your filter."}),W.map(k=>{const z=k.sessionId===c;return e.jsxs("button",{type:"button",onClick:()=>j(k.sessionId),className:$("flex w-full flex-col gap-1 rounded-lg border px-3 py-2.5 text-left transition-all duration-200 hover:-translate-y-px",z?"border-primary/45 bg-primary/9 shadow-[0_18px_60px_-44px_hsl(var(--primary)/0.95)]":"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:$("h-2 w-2 shrink-0 rounded-full",z?"bg-primary":"bg-border")}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground",children:k.summary}),e.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.16em] text-muted-foreground",children:Vi(k.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:k.sessionId.slice(0,12)}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),e.jsx("span",{className:"truncate font-mono",children:k.cwd})]})]},k.sessionId)})]})]}),J&&e.jsx("p",{className:"px-1 pt-2 text-[11px] text-destructive",children:J})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{type:"button",onClick:()=>F(k=>!k),className:"flex w-full items-center gap-2 text-[11px] font-medium uppercase tracking-[0.2em] text-muted-foreground transition-colors hover:text-foreground","aria-expanded":p,children:[e.jsx("span",{className:"h-px flex-1 bg-border/60","aria-hidden":!0}),e.jsx("span",{className:"shrink-0",children:p?"Less options":"More options"}),e.jsx(as,{className:$("h-3.5 w-3.5 shrink-0 transition-transform",p&&"rotate-180")}),e.jsx("span",{className:"h-px flex-1 bg-border/60","aria-hidden":!0})]}),p&&e.jsxs("div",{className:"space-y-4 rounded-xl border border-border/60 bg-background/35 p-4",children:[e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Te,{htmlFor:"native-session-id",className:"text-xs font-medium text-muted-foreground",children:"Session ID"}),e.jsx(Xe,{id:"native-session-id",type:"text",value:S,onChange:k=>{j(""),I(k.target.value)},placeholder:"ses_..., thread_..., or UUID",autoFocus:f,className:"h-10 rounded-sm border-border/70 bg-background/70 font-mono text-xs"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Te,{htmlFor:"native-session-title",className:"text-xs font-medium text-muted-foreground",children:"Task title"}),e.jsx(Xe,{id:"native-session-title",type:"text",value:w,onChange:k=>_(k.target.value),placeholder:"Optional",className:"h-10 rounded-sm border-border/70 bg-background/70 text-sm"})]})]}),e.jsx($s,{value:A,onChange:k=>{j(""),B(k)},assignTo:T,nodes:s,assignableNodes:l}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Te,{className:"text-xs font-medium text-muted-foreground",children:"Mode"}),e.jsxs(ye,{value:L,onValueChange:k=>E(k),children:[e.jsx(ke,{className:"h-10 rounded-sm border-border/70 bg-background/70 text-sm",children:e.jsx(Re,{placeholder:"Select mode"})}),e.jsx(Se,{children:zi()})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Te,{className:"text-xs font-medium text-muted-foreground",children:"Priority"}),e.jsxs(ye,{value:U,onValueChange:M,children:[e.jsx(ke,{className:"h-10 rounded-sm border-border/70 bg-background/70 text-sm",children:e.jsx(Re,{placeholder:"Select priority"})}),e.jsxs(Se,{children:[e.jsx(Ne,{value:"low",children:"Low"}),e.jsx(Ne,{value:"normal",children:"Normal"}),e.jsx(Ne,{value:"high",children:"High"}),e.jsx(Ne,{value:"critical",children:"Critical"})]})]})]})]})]})]}),e.jsxs("div",{className:$("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",g),children:[i&&e.jsx(V,{type:"button",variant:"ghost",onClick:i,className:"rounded-sm",children:b}),e.jsx(V,{type:"submit",disabled:!me||X,className:"rounded-sm px-5",children:X?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"h-4 w-4 animate-spin"})," Loading..."]}):N})]})]})}function tn(s,t,n=!1){const o=s.trim();if(o)return o;const r=t.trim().split(`
|
|
134
|
+
`).map(i=>i.trim()).find(Boolean);return r?r.length>72?`${r.slice(0,69).trimEnd()}...`:r:n?"Image task":""}function Hi(s){var v;const t=s.title.trim(),n=tn(s.title,s.description,s.images.length>0),o=s.description.trim()||n,r=s.mode??Ss,i=Fa(s.description,s.images);return!n||!o||!s.agent?null:{title:n,description:o,agent:s.agent,project:s.project.trim()||null,branch:((v=s.branch)==null?void 0:v.trim())||null,payload:{initialMessage:i,mode:r,titleSource:t?"manual":"derived"},priority:s.priority,assignTo:s.assignTo==="auto"?void 0:s.assignTo}}function qi({nodes:s,currentNodeRole:t,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,className:v,footerClassName:g,submitLabel:N="Create chat",cancelLabel:b="Cancel",autoFocus:f=!1,layout:l="default"}){const[u,w]=a.useState(""),[_,x]=a.useState(""),[h,c]=a.useState(Xt),[j,S]=a.useState(Ss),[I,A]=a.useState(""),[B,T]=a.useState(""),[O,U]=a.useState("normal"),M=a.useMemo(()=>sn(s,{currentNodeRole:t,leaderNodeId:o}),[s,t,o]),L=a.useMemo(()=>{var Q;return n&&M.some(fe=>fe.id===n)?n:((Q=M[0])==null?void 0:Q.id)??""},[M,n]),[E,X]=a.useState(L),[H,Y]=a.useState(!1),[de,ne]=a.useState(!1),{images:Z,error:J,fileInputRef:q,pickImages:K,handleFileChange:re,handlePaste:me,removeImage:p}=Ya(),F=a.useMemo(()=>M.find(Q=>Q.id===E)??null,[E,M]),C=!!(n&&(F==null?void 0:F.id)===n),se=za(h),m=ho(j);a.useEffect(()=>{E&&M.some(Q=>Q.id===E)||X(L)},[E,M,L]),a.useEffect(()=>{A(en(E)),T("")},[E]),a.useEffect(()=>{T("")},[I]);const P=a.useCallback(async Q=>{Q.preventDefault();const fe=Hi({title:u,description:_,agent:h,project:I,branch:B,priority:O,assignTo:E,mode:j,images:Z});if(fe){Y(!0);try{const je=await nr(fe);r(je)}catch(je){ae.error(je instanceof Error?je.message:"Failed to create task")}finally{Y(!1)}}},[u,_,h,I,B,O,E,j,Z,r]),W=tn(u,_,Z.length>0),te=!!(W&&h&&E&&(_.trim()||Z.length>0)),k=a.useCallback(Q=>{var fe;Q.nativeEvent.isComposing||Q.key==="Enter"&&(Q.ctrlKey||Q.metaKey)&&te&&!H&&(Q.preventDefault(),(fe=Q.currentTarget.form)==null||fe.requestSubmit())},[te,H]),z=Z.length>0&&e.jsx("div",{className:"flex flex-wrap gap-3",children:Z.map((Q,fe)=>e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:Ia(Q),alt:Q.filename??`attachment ${fe+1}`,className:"h-24 w-24 rounded-2xl border border-border/70 object-cover"}),e.jsx("button",{type:"button",onClick:()=>p(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 ${Q.filename??`image ${fe+1}`}`,children:e.jsx(ts,{className:"h-3.5 w-3.5"})})]},`${Q.filename??"image"}-${fe}`))}),ee=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Te,{className:"text-sm font-medium",children:"Assign to"}),e.jsxs(ye,{value:E,onValueChange:X,children:[e.jsx(ke,{className:"h-11 rounded-lg border-border/70 bg-background/70",children:e.jsx(Re,{placeholder:"Select node"})}),e.jsx(Se,{children:jt(M,n)})]})]}),Me=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Te,{className:"text-sm font-medium",children:"Agent"}),e.jsxs(ye,{value:h,onValueChange:c,children:[e.jsx(ke,{className:"h-11 rounded-lg border-border/70 bg-background/70",children:e.jsx(Re,{placeholder:"Select agent"})}),e.jsx(Se,{children:na()})]})]}),ve=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Te,{className:"text-sm font-medium",children:"Mode"}),e.jsxs(ye,{value:j,onValueChange:Q=>S(Q),children:[e.jsx(ke,{className:"h-11 rounded-lg border-border/70 bg-background/70",children:e.jsx(Re,{placeholder:"Select mode"})}),e.jsx(Se,{children:ra()})]})]}),$e=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Te,{className:"text-sm font-medium",children:"Priority"}),e.jsxs(ye,{value:O,onValueChange:U,children:[e.jsx(ke,{className:"h-11 rounded-lg border-border/70 bg-background/70",children:e.jsx(Re,{placeholder:"Select priority"})}),e.jsxs(Se,{children:[e.jsx(Ne,{value:"low",children:"Low"}),e.jsx(Ne,{value:"normal",children:"Normal"}),e.jsx(Ne,{value:"high",children:"High"}),e.jsx(Ne,{value:"critical",children:"Critical"})]})]})]}),Ae=e.jsx($s,{value:I,onChange:A,assignTo:E,nodes:s,assignableNodes:M}),Je=e.jsx(ma,{value:B,onChange:T,project:I,assignTo:E,nodes:s,assignableNodes:M});return l==="composer"?e.jsxs("form",{onSubmit:P,className:$("space-y-4",v),children:[e.jsx("input",{ref:q,type:"file",accept:"image/*",multiple:!0,onChange:re,className:"hidden"}),(()=>{const Q="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",je="border-border/70 bg-background/55 text-foreground",es=h===Xt,Ce=j===Ss;return e.jsxs("div",{className:"chat-composer space-y-2",children:[e.jsxs("div",{className:"rounded-xl border border-border/60 bg-background/54 shadow-[0_24px_86px_-48px_rgba(15,23,42,0.55)] backdrop-blur-xl dark:shadow-[0_24px_86px_-48px_rgba(0,0,0,0.9)]",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(ye,{value:E,onValueChange:X,children:[e.jsx(ke,{className:$(Q,je,"chat-composer__node-trigger border-transparent bg-transparent hover:bg-background/40"),title:`Assigned node: ${(F==null?void 0:F.name)??"unassigned"}`,"aria-label":`Assigned node: ${(F==null?void 0:F.name)??"unassigned"}`,children:F?e.jsxs(e.Fragment,{children:[e.jsx(Rt,{isCurrent:C}),e.jsx("span",{className:"min-w-0 truncate",children:F.name}),e.jsx("span",{className:"chat-composer__header-meta shrink-0 text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:C?"current":"remote"})]}):e.jsx(Re,{placeholder:"Select node"})}),e.jsx(Se,{children:jt(M,n)})]}),de?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Xe,{id:"task-title-composer",type:"text",value:u,onChange:pe=>w(pe.target.value),onKeyDown:pe=>{(pe.key==="Enter"||pe.key==="Escape")&&(pe.preventDefault(),ne(!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(V,{type:"button",variant:"ghost",size:"icon",onClick:()=>ne(!1),"aria-label":"Save title",className:"h-8 w-8 shrink-0 rounded-sm text-muted-foreground hover:text-foreground",children:e.jsx(ys,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>ne(!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:W||"Title","aria-label":W?`Edit title: ${W}`:"Edit title",children:[e.jsx("span",{className:"chat-composer__title-text max-w-[220px] truncate",children:W||"Title"}),e.jsx(gs,{className:"h-3 w-3 shrink-0"})]})]}),e.jsx("textarea",{id:"task-description",value:_,onChange:pe=>x(pe.target.value),onKeyDown:k,onPaste:me,placeholder:"Ask anything...",rows:4,autoFocus:f,"aria-label":"Opening prompt",className:"min-h-[140px] w-full resize-none overflow-x-hidden overflow-y-auto rounded-xl bg-transparent px-5 pt-2 pb-2 text-[15px] leading-7 text-foreground ring-offset-background placeholder:text-muted-foreground/70 focus-visible:outline-none"}),e.jsxs("div",{className:"chat-composer__rail flex flex-nowrap items-center gap-2 px-3 pb-3",children:[e.jsx(V,{type:"button",variant:"ghost",size:"icon",onClick:K,"aria-label":"Add images",className:"h-9 w-9 shrink-0 rounded-sm text-muted-foreground hover:text-foreground",children:e.jsx(gt,{className:"h-4 w-4"})}),e.jsx("span",{className:"mx-0.5 h-5 w-px bg-border/60","aria-hidden":!0}),e.jsxs(ye,{value:h,onValueChange:c,children:[e.jsxs(ke,{className:$(Q,"chat-composer__icon-trigger",es?fe:je),title:`Agent: ${se}`,"aria-label":`Agent: ${se}`,children:[e.jsx(Tt,{agent:h}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:se})]}),e.jsx(Se,{children:na()})]}),e.jsxs(ye,{value:j,onValueChange:pe=>S(pe),children:[e.jsxs(ke,{className:$(Q,"chat-composer__icon-trigger",Ce?fe:je),title:`Mode: ${m}`,"aria-label":`Mode: ${m}`,children:[e.jsx(ni,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:m})]}),e.jsx(Se,{children:ra()})]}),e.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[e.jsxs(ye,{value:O,onValueChange:U,children:[e.jsx(ke,{"aria-label":`Priority: ${O}`,title:`Priority: ${O}`,className:$("h-9 w-9 justify-center gap-0 rounded-sm p-0 text-xs shadow-none [&>svg:last-child]:hidden",O==="normal"?"border-transparent bg-transparent text-muted-foreground hover:bg-background/40":"border-border/70 bg-background/55",O==="critical"&&"text-destructive",O==="high"&&"text-amber-600 dark:text-amber-400",O==="low"&&"text-muted-foreground"),children:e.jsx(To,{className:$("h-4 w-4",O==="critical"&&"fill-destructive/20")})}),e.jsxs(Se,{children:[e.jsx(Ne,{value:"low",children:"Low"}),e.jsx(Ne,{value:"normal",children:"Normal"}),e.jsx(Ne,{value:"high",children:"High"}),e.jsx(Ne,{value:"critical",children:"Critical"})]})]}),i&&e.jsxs(V,{type:"button",variant:"ghost",size:"sm",onClick:i,"aria-label":b,className:"chat-composer__cancel h-9 rounded-sm px-4 text-xs text-muted-foreground",children:[e.jsx(ts,{className:"chat-composer__cancel-icon h-4 w-4 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label",children:b})]}),e.jsxs(V,{type:"submit",size:"icon",disabled:!te||H,className:"h-10 w-10 rounded-sm shadow-[0_8px_30px_-8px_hsl(var(--primary)/0.6)]",children:[H?e.jsx(ce,{className:"h-4 w-4 animate-spin"}):e.jsx(Wa,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:H?"Creating chat":N})]})]})]})]}),e.jsx("div",{className:"chat-composer__location flex flex-wrap items-center gap-2 px-1",children:(()=>{const pe="border-border/40 bg-muted/40 text-foreground/80 hover:bg-muted/60 hover:text-foreground";return e.jsxs(e.Fragment,{children:[e.jsx($s,{value:I,onChange:A,assignTo:E,nodes:s,assignableNodes:M,layout:"composer",chipClassName:Q,chipActiveClassName:pe,chipInactiveClassName:pe,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"}),e.jsx(ma,{value:B,onChange:T,project:I,assignTo:E,nodes:s,assignableNodes:M,layout:"composer",chipClassName:Q,chipActiveClassName:pe,chipInactiveClassName:pe,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"})]})})()})]})})(),(z||J)&&e.jsxs("div",{className:"space-y-3 rounded-lg border border-border/60 bg-background/45 p-4",children:[z,J&&e.jsx("div",{className:"text-xs text-destructive",children:J}),!J&&e.jsx("div",{className:"text-xs 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:P,className:$("space-y-5",v),children:[e.jsx("input",{ref:q,type:"file",accept:"image/*",multiple:!0,onChange:re,className:"hidden"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Te,{htmlFor:"task-description",className:"text-sm font-medium",children:"Opening prompt"}),e.jsx("textarea",{id:"task-description",value:_,onChange:Q=>x(Q.target.value),onKeyDown:k,onPaste:me,placeholder:"Describe what the agent should do. This becomes the first message in the chat.",rows:6,autoFocus:f,className:"flex min-h-[144px] w-full resize-none overflow-x-hidden overflow-y-auto rounded-xl border border-border/70 bg-background/70 px-4 py-3 text-sm leading-6 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.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(V,{type:"button",variant:"outline",onClick:K,className:"rounded-sm",children:[e.jsx(gt,{className:"h-4 w-4"}),"Add images"]}),e.jsx("p",{className:"text-xs 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."})]}),z,J&&e.jsx("p",{className:"text-xs text-destructive",children:J})]}),e.jsxs("div",{className:"grid gap-5 lg:grid-cols-[minmax(0,1fr)_220px_220px]",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Te,{htmlFor:"task-title",className:"text-sm font-medium",children:"Chat title"}),e.jsx(Xe,{id:"task-title",type:"text",value:u,onChange:Q=>w(Q.target.value),placeholder:"Optional. Leave blank to derive it from the prompt.",className:"h-11 rounded-lg border-border/70 bg-background/70"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:W?`Will appear as: ${W}`:"A title will be generated from the first line of the prompt."})]}),Me,ve]}),Ae,Je,e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[$e,ee]}),e.jsxs("div",{className:$("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",g),children:[i&&e.jsx(V,{type:"button",variant:"ghost",onClick:i,className:"rounded-sm",children:b}),e.jsx(V,{type:"submit",disabled:!te||H,className:"rounded-sm px-5",children:H?"Creating...":N})]})]})}function Ki({nodes:s,currentNodeRole:t,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,defaultMode:v="chat",mode:g,onModeChange:N,layout:b="default",className:f,footerClassName:l,autoFocus:u=!1}){const[w,_]=a.useState(v),x=g!==void 0,h=x?g:w,c=j=>{x||_(j),N==null||N(j)};return e.jsxs("div",{className:$("space-y-4",f),children:[!x&&e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border/60 bg-background/45 p-1",children:[e.jsxs(V,{type:"button",variant:h==="chat"?"default":"ghost",onClick:()=>c("chat"),className:"flex-1 rounded-sm",children:[e.jsx(ar,{className:"h-4 w-4"}),"New chat"]}),e.jsxs(V,{type:"button",variant:h==="native"?"default":"ghost",onClick:()=>c("native"),className:"flex-1 rounded-sm",children:[e.jsx(At,{className:"h-4 w-4"}),"Load session"]})]}),h==="chat"?e.jsx(qi,{nodes:s,currentNodeRole:t,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,footerClassName:l,submitLabel:b==="composer"?"Start chat":"Create chat",cancelLabel:"Cancel",autoFocus:u,layout:b}):e.jsx(Ui,{nodes:s,currentNodeRole:t,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,footerClassName:l,autoFocus:u})]})}const hs="72f988bf-86f1-41af-91ab-2d7cd011db47",an=`${hs} (MSIT)`;function Wi({open:s,onOpenChange:t,onShare:n,onStopShare:o,sharing:r,stopping:i=!1,shareResult:v}){return e.jsx(St,{open:s,onOpenChange:t,children:e.jsxs(Ct,{className:"max-w-md rounded-xl p-5",children:[e.jsx(_t,{className:"sr-only",children:"Share conversation"}),e.jsx(Gi,{onOpenChange:t,onShare:n,onStopShare:o,sharing:r,stopping:i,shareResult:v})]})})}function Gi({onOpenChange:s,onShare:t,onStopShare:n,sharing:o,stopping:r=!1,shareResult:i}){const[v,g]=a.useState((i==null?void 0:i.tenant)??hs),[N,b]=a.useState((i==null?void 0:i.scope)??"chat"),f=i!=null&&i.url?_a(i.url):null,l=o||r;return a.useEffect(()=>{g((i==null?void 0:i.tenant)??hs),b((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-base 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(Qi,{value:v,onChange:g,disabled:l}),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(xa,{active:N==="chat",title:"Chat only",description:"Conversation transcript and opening prompt.",onClick:()=>b("chat")}),e.jsx(xa,{active:N==="filesPreview",title:"Chat, files and preview",description:"Transcript plus task output files and HTML preview.",onClick:()=>b("filesPreview")})]})]}),f&&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:f,className:"min-w-0 flex-1 bg-transparent font-mono text-xs text-foreground outline-none","aria-label":"Shared link"}),e.jsx(V,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-sm text-muted-foreground",onClick:()=>void xs(f,"Shared link copied"),"aria-label":"Copy shared link",title:"Copy shared link",children:e.jsx(Da,{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(V,{variant:"outline",onClick:()=>s(!1),disabled:l,className:"h-8 text-xs",children:i?"Done":"Cancel"}),i&&n&&e.jsxs(V,{variant:"outline",onClick:()=>void n(),disabled:l,className:"h-8 border-destructive/30 text-xs text-destructive hover:bg-destructive/10 hover:text-destructive",children:[r&&e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}),"Stop share"]}),e.jsxs(V,{onClick:()=>void t({tenant:v,scope:N}),disabled:l,className:"h-8 text-xs",children:[o&&e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}),i?"Update link":"Share link"]})]})]})}function Qi({value:s,onChange:t,disabled:n}){const[o,r]=a.useState(!1),[i,v]=a.useState(!1),[g,N]=a.useState(s),b=a.useRef(null);a.useEffect(()=>{N(s)},[s]),a.useEffect(()=>{if(!o)return;const l=w=>{var x;const _=w.target;_ instanceof Node&&((x=b.current)!=null&&x.contains(_)||(r(!1),v(!1)))},u=w=>{w.key==="Escape"&&(r(!1),v(!1))};return document.addEventListener("mousedown",l),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",u)}},[o]);const f=l=>{const u=l.trim();u&&(t(u),N(u),v(!1),r(!1))};return e.jsxs("div",{className:"space-y-2 text-xs",ref:b,children:[e.jsx("div",{className:"font-medium text-foreground",children:"Tenant"}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>!n&&r(l=>!l),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:Yi(s)}),e.jsx(as,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})]}),o&&e.jsxs("div",{className:"absolute left-0 right-0 z-50 mt-2 overflow-hidden rounded-lg border border-border/60 bg-background/95 text-xs shadow-lg backdrop-blur",children:[e.jsxs("button",{type:"button",onClick:()=>f(hs),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:an}),s===hs&&e.jsx(ys,{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:g,onChange:l=>N(l.target.value),onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),f(g))},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:()=>f(g),className:"flex h-7 w-7 items-center justify-center rounded-sm hover:bg-background/60",children:e.jsx(ys,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{N(s),v(!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(ts,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>v(!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(gs,{className:"h-3 w-3"})]})})]})]})]})}function Yi(s){return s===hs?an:s}function xa({active:s,title:t,description:n,onClick:o}){return e.jsxs("button",{type:"button",onClick:o,className:s?"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:t}),e.jsx("div",{className:"mt-1 text-[11px] leading-4 text-muted-foreground",children:n})]})}function Xi(s){const t=s.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 t?t.length>160?`${t.slice(0,157)}...`:t:"Queued follow-up"}function Ji({messages:s,onCancelMessage:t}){return s.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(Uo,{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:s.length})]}),e.jsx("div",{className:"mt-2 space-y-1.5",children:s.map((n,o)=>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:o+1}),e.jsx("span",{className:"min-w-0 flex-1 break-words [overflow-wrap:anywhere]",children:Xi(n.content)}),t&&e.jsx(V,{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:()=>t(n.id),children:e.jsx(ts,{className:"h-3 w-3"})})]},n.id))})]})})}const Zi=30;function el({savedScrollTop:s,scrollHeight:t,clientHeight:n}){const o=Math.max(0,t-n);return Math.min(Math.max(0,s??o),o)}function Js(s){return s.scrollHeight-s.scrollTop-s.clientHeight<Zi}function sl({activeTab:s,activeTaskId:t,contentVersion:n,setActiveTab:o,setInputCollapsed:r}){const i=a.useRef(null),v=a.useRef(t),g=a.useRef(!1),N=a.useRef(0),b=a.useRef(new Map),f=a.useRef(!0),l=a.useCallback((x=v.current)=>{const h=i.current;!h||!x||(b.current.set(x,h.scrollTop),N.current=h.scrollTop,f.current=Js(h))},[]),u=a.useCallback((x=v.current)=>{const h=i.current;!h||!x||(h.scrollTop=el({savedScrollTop:b.current.get(x),scrollHeight:h.scrollHeight,clientHeight:h.clientHeight}),N.current=h.scrollTop,f.current=Js(h))},[]),w=a.useCallback(x=>{const h=x.currentTarget,c=N.current;if(l(),!g.current){if(Js(h)){r(!1),g.current=!0,setTimeout(()=>{g.current=!1},300);return}h.scrollTop<c&&c-h.scrollTop>10&&r(!0),h.scrollTop<=0&&r(!0)}},[l,r]),_=a.useCallback(x=>{s==="transcript"&&l(),o(x),x==="transcript"&&requestAnimationFrame(()=>u())},[s,u,l,o]);return a.useLayoutEffect(()=>{const x=v.current;x&&x!==t&&l(x),v.current=t,s==="transcript"&&requestAnimationFrame(()=>u(t))},[t,s,u,l]),a.useLayoutEffect(()=>{const x=i.current;!x||s!=="transcript"||!t||(f.current&&(x.scrollTop=x.scrollHeight),l(t))},[t,s,n,l]),{handleTranscriptScroll:w,handleTranscriptTabChange:_,transcriptScrollRef:i}}const tl=a.lazy(async()=>({default:(await Dt(()=>import("./FilesTab-hBKGU1Xk.js"),__vite__mapDeps([0,1,2,3,4]))).FilesTab})),al=a.lazy(async()=>({default:(await Dt(()=>import("./PreviewTab-BLWRbGFK.js"),__vite__mapDeps([5,1,2,6]))).PreviewTab})),nl=a.lazy(async()=>({default:(await Dt(()=>import("./DiffTab-B9X1MLJB.js"),__vite__mapDeps([7,1,2,3,4,6]))).DiffTab}));function rl({onToggleTasks:s,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:v,activeTab:g,setActiveTab:N,creatingTask:b,createMode:f,activeTask:l,assignedNode:u,taskLoading:w,transcriptLoading:_,taskError:x,displayEvents:h,initialPromptAlreadyInLogs:c,initialPrompt:j,supportsFollowUp:S,taskUnavailable:I,chatDisabled:A,chatDisabledReason:B,questionBypassEnabled:T,isRunning:O,isStarting:U,hasPendingFollowUp:M,canCancel:L,canRetry:E,onRetry:X,onCancel:H,onReloadNativeTranscript:Y,onShareTask:de,onStopShareTask:ne,onStartCreateTask:Z,onCancelCreateTask:J,onCreateTask:q,onSendMessage:K,onCancelQueuedMessage:re,onQuestionBypassChange:me,onSubmitQuestionResponse:p}){const[F,C]=a.useState(!1),[se,m]=a.useState(!1),[P,W]=a.useState(!1),[te,k]=a.useState(!1),[z,ee]=a.useState(!1),[Me,ve]=a.useState({}),[$e,Ae]=a.useState(new Set),[Je,Q]=a.useState(new Set),fe=(l==null?void 0:l.effectiveProjectPath)??(l==null?void 0:l.project)??"default workspace",je=l?(u==null?void 0:u.name)??tt(l.assignedTo,i==null?void 0:i.nodes,l.assignedNodeName):"unassigned",es=l!=null&&l.assignedTo?e.jsxs(e.Fragment,{children:["Connecting session on node ",e.jsx("span",{className:"font-semibold",children:je}),"..."]}):"Connecting session to an available node...",Ce=l?[{label:"Working dir",value:fe,mono:!0},...l.branch?[{label:"Branch",value:l.branch,mono:!0}]:[],{label:"Agent",value:l.agent,mono:!0},{label:"Node",value:je}]:[],pe=!!(j&&!c),Ge=pe||h.length>0,Oe=O&&Ge,Ve=(U||M||O)&&!Oe,D=(l==null?void 0:l.conversationKind)==="nativeSession",ge=_?"Loading transcript":D?"No transcript imported":"Transcript is warming up",ue=_?"Loading transcript...":D?"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.",Ee=(l==null?void 0:l.queuedMessages)??[],Fe=a.useMemo(()=>po(h),[h]),is=a.useMemo(()=>fo("transcript",Fe.map(Pe=>Pe.event)),[Fe]),be=l&&!$e.has(l.id)?Me[l.id]??l.activeShare??null:null,Le=(l==null?void 0:l.id)??null,we=`${Le??"none"}:${h.length}:${Ee.length}:${pe?1:0}:${_?1:0}`,{handleTranscriptScroll:ls,handleTranscriptTabChange:Ze,transcriptScrollRef:ds}=sl({activeTab:g,activeTaskId:Le,contentVersion:we,setActiveTab:N,setInputCollapsed:C});return b?e.jsx(ol,{onToggleTasks:s,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:v,defaultMode:f,onCancel:J,onCreated:q}):!l&&w?e.jsxs("div",{className:"dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsx("div",{className:"shrink-0 border-b border-border/55 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(Nt,{onToggleTasks:s,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:v})}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-6 py-10 sm:px-8",children:e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-xl border border-primary/20 bg-primary/10 text-primary shadow-sm",children:e.jsx(ce,{className:"h-7 w-7 animate-spin"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-2xl 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(ce,{className:"h-4 w-4 animate-spin"}),"Fetching the selected chat thread..."]})]})]})})]}):l?e.jsxs(Ea,{value:g,onValueChange:Ze,className:"dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/55 bg-card/28 px-3 py-3 sm:px-5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(nn,{desktopTasksOpen:t,mobileTasksPanelOpen:n,onToggleTasks:s}),e.jsx("h2",{className:"min-w-0 truncate text-sm font-semibold tracking-tight text-foreground sm:text-lg",title:l.title,children:l.title}),D&&e.jsx(Be,{variant:"outline",className:"shrink-0 rounded-sm border-sky-500/30 bg-sky-500/10 px-1.5 py-0 text-[10px] leading-4 text-sky-700 shadow-none dark:text-sky-300",children:"Native"}),e.jsx(Ta,{status:l.status}),e.jsx(or,{priority:l.priority}),e.jsx(V,{variant:"outline",size:"icon",onClick:r,title:o?"Hide cluster":"Show cluster","aria-label":o?"Hide cluster":"Show cluster",className:"ml-auto h-7 w-7 shrink-0 rounded-sm border-border/70 bg-background/68",children:o?e.jsx(Pt,{className:"h-4 w-4"}):e.jsx(Ka,{className:"h-4 w-4"})})]}),x&&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:x}),e.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[e.jsxs(Ma,{className:"h-auto max-w-full overflow-x-auto rounded-sm bg-muted/70 p-0.5",children:[e.jsx(ns,{value:"transcript",className:"rounded-sm px-2 py-0.5 text-[11px] sm:px-2.5",children:"Transcript"}),e.jsx(ns,{value:"files",className:"rounded-sm px-2 py-0.5 text-[11px] sm:px-2.5",children:"Files"}),e.jsx(ns,{value:"preview",className:"rounded-sm px-2 py-0.5 text-[11px] sm:px-2.5",children:"Preview"}),e.jsx(ns,{value:"diff",className:"rounded-sm px-2 py-0.5 text-[11px] sm:px-2.5",children:"Diff"})]}),I&&e.jsx(Be,{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-2 text-[10px] text-muted-foreground",children:[e.jsxs("span",{className:"hidden sm:inline",children:["updated ",ir(l.updatedAt)]}),e.jsx("span",{className:"font-mono",children:l.id.slice(0,8)}),E&&e.jsxs(V,{variant:"outline",size:"sm",onClick:X,className:"h-7 shrink-0 rounded-sm px-2 text-[11px]",children:[e.jsx(la,{className:"h-3.5 w-3.5"}),"Retry"]}),D&&Y&&e.jsxs(V,{variant:"outline",size:"sm",onClick:Y,disabled:_,title:"Reload native session transcript",className:"h-7 shrink-0 rounded-sm px-2 text-[11px]",children:[e.jsx(la,{className:$("h-3.5 w-3.5",_&&"animate-spin")}),"Reload"]}),e.jsxs(V,{type:"button",variant:"outline",size:"sm",disabled:I,title:I?"Unavailable tasks cannot be shared.":"Share conversation",className:"h-7 shrink-0 rounded-sm border-primary/30 bg-primary/10 px-2 text-[11px] text-primary hover:bg-primary/15 hover:text-primary disabled:border-border/60 disabled:bg-muted/40 disabled:text-muted-foreground",onClick:()=>W(!0),children:[e.jsx(ti,{className:"h-3.5 w-3.5"}),"Share"]})]})]})]}),e.jsx(rs,{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",{ref:ds,className:"min-h-0 flex-1 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 py-5 sm:px-5",onScroll:ls,children:e.jsxs("div",{className:"mx-auto flex max-w-[72rem] flex-col gap-5",children:[pe&&j&&e.jsx(oa,{event:j,agent:l.agent,questionBypassEnabled:T,onQuestionBypassChange:me,onSubmitQuestionResponse:p,questionResponseDisabled:!S||A}),Fe.map(({event:Pe,subItems:_e},ie)=>e.jsx(oa,{event:Pe,agent:l.agent,subItems:_e,questionBypassEnabled:T,onQuestionBypassChange:me,onSubmitQuestionResponse:p,questionResponseDisabled:!S||A},is[ie])),!Ge&&!Ve&&e.jsxs("div",{className:"rounded-xl border border-dashed border-border/70 bg-background/35 px-5 py-8 text-center",children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground",children:ge}),e.jsx("div",{className:"mt-2 text-[11px] leading-6 text-muted-foreground",children:ue})]}),(!S&&l.result||l.error)&&e.jsxs("div",{className:"space-y-3",children:[!S&&l.result&&e.jsxs("div",{className:"rounded-xl 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&&!Je.has(l.id)&&e.jsxs("div",{className:"rounded-xl 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:()=>Q(Pe=>new Set(Pe).add(l.id)),className:"rounded p-0.5 hover:bg-destructive/20","aria-label":"Dismiss error",children:e.jsx(ts,{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})]})]}),Ve&&e.jsx(ha,{children:es}),Oe&&e.jsx(ha,{children:"The agent is still working on this conversation."})]})}),S?e.jsxs(e.Fragment,{children:[F&&e.jsx(V,{size:"icon",onClick:()=>C(!1),className:"absolute bottom-4 right-4 z-10 h-12 w-12 rounded-lg shadow-lg",children:e.jsx(gs,{className:"h-4 w-4"})}),e.jsxs("div",{className:`shrink-0 ${F?"hidden":""}`,children:[e.jsx(Ji,{messages:Ee,onCancelMessage:re}),e.jsx(ji,{onSend:K,disabled:A,disabledReason:B,contextItems:Ce,placeholder:A?B:O?"Queue a message for the next turn...":"Continue the conversation...",running:O||M,onStop:L?()=>m(!0):void 0})]})]}):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(rs,{value:"files",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(a.Suspense,{fallback:e.jsx(Ys,{label:"Loading files..."}),children:e.jsx(tl,{taskId:l.id})})}),e.jsx(rs,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(a.Suspense,{fallback:e.jsx(Ys,{label:"Loading preview..."}),children:e.jsx(al,{taskId:l.id})})}),e.jsx(rs,{value:"diff",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(a.Suspense,{fallback:e.jsx(Ys,{label:"Loading diff..."}),children:e.jsx(nl,{taskId:l.id})})}),e.jsx(at,{open:se,onOpenChange:m,children:e.jsxs(nt,{children:[e.jsxs(rt,{children:[e.jsx(ot,{children:"Stop this task?"}),e.jsx(it,{children:"The task will stop and move to a cancelled state."})]}),e.jsxs(lt,{children:[e.jsx(dt,{children:"Keep running"}),e.jsx(ct,{onClick:H,children:"Stop task"})]})]})}),e.jsx(Wi,{open:P,onOpenChange:W,sharing:te,stopping:z,shareResult:be,onShare:async Pe=>{if(!l)return null;k(!0);try{const _e=await de(Pe);return _e!=null&&_e.url&&(ve(ie=>({...ie,[l.id]:_e})),Ae(ie=>{const Qe=new Set(ie);return Qe.delete(l.id),Qe})),_e}finally{k(!1)}},onStopShare:async()=>{if(!l)return!1;ee(!0);try{const Pe=await ne();return Pe!==!1&&(ve(_e=>{const ie={..._e};return delete ie[l.id],ie}),Ae(_e=>new Set(_e).add(l.id))),Pe}finally{ee(!1)}}})]}):e.jsxs("div",{className:"dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsx("div",{className:"shrink-0 border-b border-border/55 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(Nt,{onToggleTasks:s,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:v})}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-6 py-10 sm:px-8",children:e.jsxs("div",{className:"w-full max-w-2xl text-center",children:[e.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-xl border border-primary/20 bg-primary/10 text-primary shadow-sm",children:e.jsx(rr,{className:"h-7 w-7"})}),e.jsx("h2",{className:"mt-5 text-xl font-semibold tracking-tight text-foreground sm:text-3xl",children:"No chat selected"}),e.jsx("p",{className:"mx-auto mt-3 max-w-xl text-[11px] leading-6 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(V,{onClick:Z,className:"mt-6 rounded-lg px-5",children:[e.jsx(Lt,{className:"h-4 w-4"}),"Start or load chat"]}),x&&e.jsx("div",{className:"mx-auto mt-4 max-w-lg rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:x})]})})]})}function ha({children:s}){return e.jsxs("div",{className:"agent-progress-banner 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:s})]})}function ol({onToggleTasks:s,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:v,defaultMode:g,onCancel:N,onCreated:b}){var w,_,x;const[f,l]=a.useState(g??"chat");a.useEffect(()=>{g&&l(g)},[g]);const u=e.jsx("div",{className:"flex items-center gap-1 rounded-lg border border-border/60 bg-background/65 p-0.5 text-[11px] font-medium shadow-sm",children:[{value:"chat",label:"New chat",icon:Lt},{value:"native",label:"Load session",icon:At}].map(h=>{const c=h.icon,j=h.value===f;return e.jsxs("button",{type:"button",onClick:()=>l(h.value),"aria-pressed":j,className:$("flex items-center gap-1.5 rounded-sm px-2 py-1 transition-all duration-200",j?"bg-primary text-primary-foreground shadow-[0_8px_24px_-12px_hsl(var(--primary)/0.7)]":"text-muted-foreground hover:bg-background/80 hover:text-foreground"),children:[e.jsx(c,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:h.label})]},h.value)})});return e.jsxs("div",{className:"dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsx("div",{className:"shrink-0 border-b border-border/55 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(Nt,{onToggleTasks:s,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:v,centerSlot:u})}),e.jsx("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center overflow-y-auto px-6 py-10 sm:px-8",children:e.jsx("div",{className:"w-full max-w-2xl",children:e.jsx(Ki,{nodes:(i==null?void 0:i.nodes)??[],currentNodeRole:(w=i==null?void 0:i.self)==null?void 0:w.role,currentNodeId:((_=i==null?void 0:i.self)==null?void 0:_.id)??null,leaderNodeId:((x=i==null?void 0:i.leader)==null?void 0:x.id)??null,mode:f,onModeChange:l,onCreated:b,onCancel:N,autoFocus:!0,layout:"composer"})})})]})}function Nt({onToggleTasks:s,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,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(nn,{desktopTasksOpen:t,mobileTasksPanelOpen:n,onToggleTasks:s})}),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(V,{variant:"outline",size:"icon",onClick:r,title:o?"Hide cluster":"Show cluster","aria-label":o?"Hide cluster":"Show cluster",className:"h-7 w-7 shrink-0 rounded-sm border-border/70 bg-background/68",children:o?e.jsx(Pt,{className:"h-4 w-4"}):e.jsx(Ka,{className:"h-4 w-4"})})]})}function nn({desktopTasksOpen:s,mobileTasksPanelOpen:t,onToggleTasks:n}){var r,i;const o=(i=(r=globalThis.window)==null?void 0:r.matchMedia("(min-width: 1024px)"))!=null&&i.matches?s:t;return e.jsx(V,{variant:"outline",size:"icon",onClick:n,title:o?"Hide tasks":"Show tasks","aria-label":o?"Hide tasks":"Show tasks",className:"h-7 w-7 shrink-0 rounded-sm border-border/70 bg-background/68",children:o?e.jsx(qa,{className:"h-4 w-4"}):e.jsx(Wo,{className:"h-4 w-4"})})}function il({onAdded:s}){const[t,n]=a.useState(""),[o,r]=a.useState(!1),[i,v]=a.useState(null),g=a.useCallback(async N=>{if(N.preventDefault(),!!t.trim()){r(!0),v(null);try{await lr({leaderEndpoint:t.trim(),transport:"devtunnel"}),s()}catch(b){v(b instanceof Error?b.message:"Failed to join node")}finally{r(!1)}}},[t,s]);return e.jsx(Ct,{className:"overflow-hidden border-border/60 bg-transparent p-0 shadow-none sm:max-w-xl",children:e.jsxs("div",{className:"overflow-hidden rounded-xl border border-border/60 bg-background/95 p-0 shadow-[0_40px_120px_-60px_rgba(0,0,0,0.88)] backdrop-blur-xl",children:[e.jsx("div",{className:"border-b border-border/60 px-6 py-5",children:e.jsxs(Aa,{className:"space-y-2 text-left",children:[e.jsx(_t,{className:"text-2xl tracking-tight",children:"Join node"}),e.jsx("p",{className:"text-sm 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:g,className:"space-y-4 px-6 py-5",children:[i&&e.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/10 px-4 py-3 text-sm 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(Te,{htmlFor:"leader-endpoint",children:"Leader endpoint"}),e.jsx(Be,{variant:"outline",className:"rounded-sm border-border/70 bg-background/60 text-[10px] uppercase tracking-[0.16em]",children:"DevTunnel only"})]}),e.jsx(Xe,{id:"leader-endpoint",type:"url",value:t,onChange:N=>n(N.target.value),placeholder:"https://your-leader.devtunnels.ms",className:"h-11 rounded-lg border-border/70 bg-background/70"})]}),e.jsx("div",{className:"rounded-lg border border-border/60 bg-background/45 px-4 py-3 text-sm 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(La,{className:"border-t border-border/60 pt-4",children:e.jsx(V,{type:"submit",disabled:!t.trim()||o,className:"rounded-sm",children:o?"Joining...":"Join node"})})]})]})})}function ll({open:s,onOpenChange:t,onAdded:n}){return e.jsx(St,{open:s,onOpenChange:t,children:e.jsx(il,{onAdded:()=>{t(!1),n()}})})}function Zs({className:s,label:t,orientation:n,panel:o,panelResize:r}){return e.jsx("button",{type:"button","aria-label":t,"aria-orientation":n,"data-dashboard-resize-handle":o,onPointerDown:i=>r.onPointerDown(o,i),onWheel:i=>r.onWheel(o,i),className:$("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",s),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 dl({conversationPanel:s,desktopTasksOpen:t,mobileTaskSidebar:n,mobileTasksPanelOpen:o,mobileTasksPanelRef:r,operationsOpen:i,operationsPanelRef:v,operationsSidecar:g,panelResize:N,taskSidebar:b,terminalPanel:f,onCloseOperations:l,onCloseTaskList:u}){const w={"--dashboard-tasks-width":N.sizes.tasks,"--dashboard-operations-width":N.sizes.operations,"--dashboard-terminal-height":N.sizes.terminal};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",style:w,children:[e.jsxs("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[e.jsx("div",{className:$("relative hidden lg:block lg:shrink-0 lg:transition-all lg:duration-300",t?"lg:mr-2 lg:w-[var(--dashboard-tasks-width)]":"lg:w-0 lg:overflow-hidden"),children:t&&e.jsxs(e.Fragment,{children:[b,e.jsx(Zs,{panel:"tasks",orientation:"vertical",label:"Resize tasks panel",panelResize:N,className:"-right-1 top-0 h-full w-2 cursor-col-resize"})]})}),e.jsxs("section",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-2",children:[e.jsx("div",{className:"min-h-0 flex-1",children:s}),f&&e.jsxs("div",{className:"relative h-[var(--dashboard-terminal-height)] min-h-0 shrink-0",children:[e.jsx(Zs,{panel:"terminal",orientation:"horizontal",label:"Resize terminal panel",panelResize:N,className:"-top-1 left-0 h-2 w-full cursor-row-resize"}),f]})]}),e.jsx("div",{className:$("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&&e.jsxs(e.Fragment,{children:[e.jsx(Zs,{panel:"operations",orientation:"vertical",label:"Resize operations panel",panelResize:N,className:"-left-1 top-0 h-full w-2 cursor-col-resize"}),g]})})]}),i&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close operations panel",onClick:l,className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm xl:hidden"}),e.jsx("div",{ref:v,className:"fixed inset-y-0 right-0 z-40 w-full p-2 sm:max-w-sm sm:p-3 xl:hidden",children:g})]}),o&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close task list",onClick:u,className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm lg:hidden"}),e.jsx("div",{ref:r,className:"fixed inset-y-0 left-0 z-40 w-full p-2 sm:max-w-sm sm:p-3 lg:hidden",children:n})]})]})}const cl=10,os="__all__";function Ue(s){return"session"in s}function pa(s,t){var n;return t&&s.some(o=>o.id===t)?t:((n=s[0])==null?void 0:n.id)??""}function et(s){return s&&(en(s.id)||s.workDir)||""}function As(s,t,n){let o=!1;const r=s.map(i=>Ue(i)&&i.session.id===n.id?(o=!0,{...i,nodeName:t,session:n}):i);return wt(o?r:[...r,{id:`session-${n.id}`,nodeName:t,session:n}])}function rn(s,t){return s.filter(Ue).filter(n=>n.session.nodeId===t).sort((n,o)=>o.session.startedAt-n.session.startedAt)}function ul(s){const t=s.filter(Ue).sort((n,o)=>o.session.startedAt-n.session.startedAt);return{active:t.filter(n=>n.session.status==="running"),completed:t.filter(n=>n.session.status!=="running")}}function ml(s,t){return!!(s&&t&&!s.contains(t))}function xl(s,t,n){var r;if(n===os)return n;const o=rn(s,t);return o.some(i=>i.session.id===n)?n:((r=o[0])==null?void 0:r.session.id)??os}function hl(s,t,n){return n===os?s.filter(o=>!Ue(o)||o.session.nodeId===t):s.filter(o=>Ue(o)&&o.session.nodeId===t&&o.session.id===n)}function wt(s){const t=s.map((o,r)=>({entry:o,index:r})).filter(({entry:o})=>Ue(o)&&o.session.status!=="running").sort((o,r)=>!Ue(o.entry)||!Ue(r.entry)?0:r.entry.session.startedAt-o.entry.session.startedAt||r.index-o.index),n=new Set(t.slice(0,cl).map(({entry:o})=>Ue(o)?o.session.id:""));return s.filter(o=>!Ue(o)||o.session.status==="running"||n.has(o.session.id))}function yt(s){return s.status==="running"?s.pid?`running pid ${s.pid}`:"running":s.status==="exited"?`exit ${s.exitCode??0}`:s.status==="stopped"?"stopped":s.signal?`failed ${s.signal}`:`exit ${s.exitCode??"failed"}`}function pl(s){const t=s.session.command.length>48?`${s.session.command.slice(0,45)}...`:s.session.command;return`${s.nodeName} - ${yt(s.session)} - ${t}`}function on(s,t=48){return s.length>t?`${s.slice(0,t-3)}...`:s}function fl(s,t){return t===os?"All sessions":s?on(s.session.command,34):"Command session"}function fa(s){return s.status==="stopped"?"":s.stderr}function gl({nodes:s,defaultNodeId:t,onClose:n,initialHistory:o=[]}){const[r,i]=a.useState(()=>pa(s,t)),v=a.useMemo(()=>s.find(p=>p.id===r)??s[0]??null,[s,r]),[g,N]=a.useState(()=>et(v)),[b,f]=a.useState(""),[l,u]=a.useState(()=>wt(o)),[w,_]=a.useState(os),[x,h]=a.useState(!1),[c,j]=a.useState(!1),[S,I]=a.useState(!1),[A,B]=a.useState(!1),[T,O]=a.useState(!1),U=a.useRef(null),M=a.useRef(null),L=a.useMemo(()=>s.find(p=>p.id===r)??s[0]??null,[s,r]),E=a.useMemo(()=>rn(l,(L==null?void 0:L.id)??""),[l,L]),X=a.useMemo(()=>ul(E),[E]),H=a.useMemo(()=>E.find(p=>p.session.id===w),[w,E]),Y=a.useMemo(()=>hl(l,(L==null?void 0:L.id)??"",w),[l,L,w]),de=a.useRef((L==null?void 0:L.id)??"");a.useEffect(()=>{r&&s.some(p=>p.id===r)||i(pa(s,t))},[t,s,r]),a.useEffect(()=>{const p=(L==null?void 0:L.id)??"";de.current!==p&&(de.current=p,N(et(L)))},[L]),a.useEffect(()=>{_(p=>xl(l,(L==null?void 0:L.id)??"",x?p:""))},[l,L,x]),a.useEffect(()=>{var p;(p=U.current)==null||p.scrollTo({top:U.current.scrollHeight})},[l]),a.useEffect(()=>{let p=!1;async function F(){const C=await Promise.allSettled(s.map(async se=>({node:se,response:await cr(se.id)})));p||u(se=>C.reduce((m,P)=>P.status!=="fulfilled"?m:P.value.response.sessions.reduce((W,te)=>As(W,P.value.node.name,te),m),se))}return s.length>0&&F(),()=>{p=!0}},[s]),a.useEffect(()=>{const p=l.filter(Ue).filter(C=>C.session.status==="running");if(p.length===0)return;const F=window.setInterval(()=>{for(const C of p)dr(C.session.nodeId,C.session.id).then(se=>u(m=>As(m,C.nodeName,se))).catch(()=>{})},1e3);return()=>window.clearInterval(F)},[l]);const ne=a.useRef(null);async function Z(p){if(p.preventDefault(),!L||!b.trim()||T)return;const F=b.trim(),C=L.name;O(!0),f("");try{const se=await mr(L.id,{command:F,...g.trim()?{cwd:g.trim()}:{}});u(m=>As(m,C,se)),_(se.id),h(!0)}catch(se){u(m=>[...m,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,nodeName:C,command:F,error:se instanceof Error?se.message:"Command failed"}])}finally{O(!1)}}async function J(p,F){p.stopPropagation();const C=await ur(F.session.nodeId,F.session.id);u(se=>As(se,F.nodeName,C))}function q(p){_(p),h(!0),j(!1)}function K(p){c&&ml(M.current,p.target)&&j(!1)}function re(p,F,C,se,m){return e.jsxs("div",{className:"border-t border-border/60 py-1",children:[e.jsxs("button",{type:"button",onClick:se,"aria-label":`Toggle ${p} sessions`,"aria-expanded":!C,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:p}),e.jsx(as,{className:$("h-3 w-3 transition-transform",C&&"-rotate-90")})]}),!C&&(F.length>0?F.map(me):e.jsx("div",{className:"node-terminal__control px-2 py-1 text-muted-foreground",children:m}))]})}function me(p){const F=w===p.session.id,C=p.session.status==="running";return e.jsxs("div",{className:$("node-terminal__control group flex w-full items-center gap-2 px-2 py-1.5 text-left transition-colors hover:bg-muted/65",F&&"bg-primary/10 text-primary"),children:[e.jsxs("button",{type:"button",onClick:()=>q(p.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:$("flex h-4 w-4 shrink-0 items-center justify-center",C?"text-primary":p.session.status==="exited"?"text-emerald-600 dark:text-emerald-300":"text-amber-600 dark:text-amber-300"),children:C?e.jsx(ce,{className:"h-3 w-3 animate-spin"}):p.session.status==="exited"?e.jsx(Jt,{className:"h-3 w-3"}):e.jsx(Bs,{className:"h-3 w-3"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-foreground",children:on(p.session.command,44)}),e.jsxs("span",{className:"node-terminal__small block truncate text-muted-foreground",children:[p.nodeName," · ",yt(p.session)]})]})]}),C&&e.jsx("button",{type:"button",onClick:se=>void J(se,p),"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(da,{className:"h-3 w-3"})})]},p.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:K,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(Gs,{className:"h-3.5 w-3.5"})}):e.jsx(Gs,{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:M,className:"relative min-w-0",children:[e.jsxs("button",{type:"button","aria-label":"Command session","aria-expanded":c,title:H?pl(H):"All sessions",onClick:()=>j(p=>!p),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:fl(H,w)}),e.jsx(as,{className:$("h-3 w-3 shrink-0 text-muted-foreground transition-transform",c&&"rotate-180")})]}),e.jsx("div",{"aria-hidden":!c,className:$("absolute right-0 bottom-9 z-30 w-[19rem] overflow-hidden rounded-xl border border-border/70 bg-popover text-popover-foreground shadow-xl",!c&&"hidden"),children:e.jsxs("div",{className:"max-h-72 overflow-y-auto",children:[e.jsxs("button",{type:"button",onClick:()=>q(os),className:$("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",w===os&&"bg-primary/10 text-primary"),children:[e.jsx(Gs,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:"All sessions"})]}),re("Active",X.active,S,()=>I(p=>!p),"No active sessions"),re("Completed",X.completed,A,()=>B(p=>!p),"No completed sessions")]})})]}),e.jsx("select",{value:(L==null?void 0:L.id)??"",onChange:p=>{i(p.target.value),h(!1),N(et(s.find(F=>F.id===p.target.value)??null))},disabled:T||s.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:s.map(p=>e.jsx("option",{value:p.id,className:"bg-background text-foreground",children:p.name},p.id))}),e.jsx($s,{value:g,onChange:N,assignTo:(L==null?void 0:L.id)??"",nodes:s,assignableNodes:s,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__control",triggerClassName:"terminal-workdir-trigger",popoverPlacement:"top",popoverAlign:"end"})]})]}),e.jsxs("div",{ref:U,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 p;return(p=ne.current)==null?void 0:p.focus()},children:[Y.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:Y.map(p=>Ue(p)?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:[p.nodeName,"$"]}),e.jsx("span",{className:"break-all text-foreground",children:p.session.command}),e.jsxs("span",{className:$("inline-flex items-center gap-1",p.session.status==="running"||p.session.status==="exited"?"text-primary":"text-amber-600 dark:text-amber-300"),children:[p.session.status==="running"?e.jsx(ce,{className:"h-3 w-3 animate-spin"}):p.session.status==="exited"?e.jsx(Jt,{className:"h-3 w-3"}):e.jsx(Bs,{className:"h-3 w-3"}),yt(p.session)]}),p.session.status==="running"&&e.jsx("button",{type:"button",onClick:F=>void J(F,p),"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(da,{className:"h-3 w-3"})})]}),p.session.stdout&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-foreground",children:p.session.stdout}),fa(p.session)&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:fa(p.session)}),(p.session.stdoutTruncated||p.session.stderrTruncated)&&e.jsx("div",{className:"text-muted-foreground",children:"Output truncated to the latest output."})]},p.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:[p.nodeName,"$"]}),e.jsx("span",{className:"break-all text-foreground",children:p.command}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive",children:[e.jsx(Bs,{className:"h-3 w-3"}),"error"]})]}),e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:p.error})]},p.id))}),e.jsxs("form",{onSubmit:Z,className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"shrink-0 text-primary select-none",children:L?`${L.name}$`:"$"}),e.jsx("input",{ref:ne,value:b,onChange:p=>f(p.target.value),disabled:!L||T,placeholder:L?"":"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:!L||!b.trim()||T,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:T?e.jsx(ce,{className:"h-3 w-3 animate-spin"}):e.jsx(Mt,{className:"h-3 w-3"})})]})]})]})})}function $t({nodeId:s,nodeName:t,onOpenSettings:n,onOpenDevBox:o,onStartDevBox:r,showConfigureDevBox:i,showStartDevBox:v,startDevBoxPending:g,className:N}){const[b,f]=a.useState(!1),l=a.useRef(null),u=g?"Starting":"Start DevBox";return a.useEffect(()=>{if(!b)return;const w=x=>{var c;const h=x.target;h instanceof Node&&((c=l.current)!=null&&c.contains(h)||f(!1))},_=x=>{x.key==="Escape"&&f(!1)};return document.addEventListener("mousedown",w),document.addEventListener("keydown",_),()=>{document.removeEventListener("mousedown",w),document.removeEventListener("keydown",_)}},[b]),e.jsxs("div",{ref:l,className:$("relative shrink-0",N),onClick:w=>w.stopPropagation(),children:[e.jsx(V,{type:"button",variant:"ghost",size:"icon","aria-label":`More actions for ${t}`,"aria-haspopup":"menu","aria-expanded":b,title:`More actions for ${t}`,onClick:()=>f(w=>!w),className:$("h-6 w-6 rounded-sm text-muted-foreground hover:bg-background/70 hover:text-foreground",b&&"bg-background/80 text-primary"),children:e.jsx(Do,{className:"h-3.5 w-3.5"})}),b&&e.jsxs("div",{role:"menu",className:"absolute right-0 top-full z-30 mt-1 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:[e.jsxs("button",{type:"button",role:"menuitem","aria-label":`Open ${t} settings`,title:`Open ${t} settings`,onClick:()=>{f(!1),n(s)},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(xr,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:"Settings"})]}),v&&r&&e.jsxs("button",{type:"button",role:"menuitem","aria-label":`${u} for ${t}`,title:`${u} for ${t}`,onClick:()=>{g||(f(!1),r(s))},disabled:g,className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-1.5 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80 disabled:cursor-not-allowed disabled:opacity-60",children:[g?e.jsx(ce,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-primary"}):e.jsx(Mt,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:u})]}),i&&o&&e.jsxs("button",{type:"button",role:"menuitem","aria-label":`Configure DevBox for ${t}`,title:`Configure DevBox for ${t}`,onClick:()=>{f(!1),o(s)},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(hr,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:"Configure DevBox"})]})]})]})}const bl=new Set(["deallocated","hibernate","hibernated","sleep","sleeping","stopped"]),vl=new Set(["startinprogress","starting"]);function ps(s){return!!(s!=null&&s.enabled&&s.name)}function jl(s){const t=s==null?void 0:s.trim().toLowerCase().replace(/[\s_-]+/gu,"");return!!(t&&bl.has(t))}function fs(s){const t=s==null?void 0:s.trim().toLowerCase().replace(/[\s_-]+/gu,"");return!!(t&&vl.has(t))}function Os(s,t,n){return s==="offline"&&jl(t)&&ps(n)}function ga(s,t){return s==="offline"&&ps(t)}function ba(s){return!ps(s)}function Nl({nodeStatus:s,status:t,current:n,selected:o}){const r=o??n;return r&&Os(s,t,r)?r:null}function De(s){return s.scope||`name:${s.name??""}`}function wl({previousKey:s,baseDevBox:t,listed:n}){if(s&&n.some(i=>De(i)===s))return s;if(!ps(t))return n[0]?De(n[0]):"";const o=De(t),r=n.find(i=>De(i)===o)??n.find(i=>i.name===t.name);return r?De(r):o}function yl({cluster:s,systemInfo:t,nodeNameById:n,nodeBlockingTaskCounts:o,eventTypeFilter:r,onEventTypeFilterChange:i,eventTypeOptions:v,filteredEvents:g,sseConnected:N,clusterLoading:b,clusterError:f,promotePending:l,onPromote:u,onAddNode:w,leavePending:_,onLeaveCluster:x,onToggleNodeDevTunnel:h,devTunnelNodeId:c,devBoxStartNodeId:j,devBoxStartingNodeIds:S=new Set,onOpenNodeSettings:I,onOpenDevBox:A,onStartDevBox:B,onClose:T}){var ne,Z,J;const O=((ne=s==null?void 0:s.self)==null?void 0:ne.role)==="leader",U=((Z=s==null?void 0:s.self)==null?void 0:Z.role)==="follower"&&!(s!=null&&s.leader),M=(s==null?void 0:s.self)??null,E=pr((s==null?void 0:s.nodes)??[],M==null?void 0:M.id).filter(q=>q.id!==(M==null?void 0:M.id)),X=s!=null&&s.leader?s.nodes.find(q=>{var K;return q.id===((K=s.leader)==null?void 0:K.id)})??null:null,H=s!=null&&s.leader?s.leader.dashboardOrigin??(X==null?void 0:X.dashboardOrigin)??(t&&s.leader.id===(t.nodeId??t.id)?t.dashboardOrigin:void 0)??s.leader.endpoint:null,Y=(M==null?void 0:M.role)==="leader"&&E.length===0,de=(M==null?void 0:M.role)==="follower";return e.jsx("aside",{className:"dashboard-panel dashboard-panel-muted animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl !border-0",children:e.jsxs(Ea,{defaultValue:"overview",className:"flex h-full min-h-0 flex-col",children:[e.jsxs("div",{className:"shrink-0 bg-card/24 px-2.5 py-2.5 shadow-[0_1px_0_hsl(var(--border)/0.22)]",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold tracking-tight",children:"Operations"}),e.jsx("p",{className:"mt-px text-[9px] text-muted-foreground",children:"Node, cluster, and live events."})]}),e.jsx(V,{variant:"ghost",size:"icon",onClick:T,className:"h-6 w-6 rounded-sm",children:e.jsx(Pt,{className:"h-3.5 w-3.5"})})]}),e.jsxs(Ma,{className:"mt-1.5 grid h-auto w-full grid-cols-3 rounded-sm bg-muted/55 p-0.5",children:[e.jsx(ns,{value:"overview",className:"rounded-sm px-2 py-0.5 text-[10px]",children:"Overview"}),e.jsx(ns,{value:"nodes",className:"rounded-sm px-2 py-0.5 text-[10px]",children:"Nodes"}),e.jsx(ns,{value:"events",className:"rounded-sm px-2 py-0.5 text-[10px]",children:"Live events"})]})]}),e.jsx(rs,{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:[M&&e.jsx(va,{node:M,systemInfo:t,blockingTaskCount:o.get(M.id)??0,devTunnelNodeId:c,onToggleNodeDevTunnel:h,showActions:!1,defaultExpanded:!1,onOpenDevBox:A,devBoxStartingNodeIds:S}),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(Be,{variant:"outline",className:"rounded-sm border-transparent bg-background/60 px-1.5 py-0 text-[9px] leading-4 shadow-sm",children:N?"Connected":"Reconnecting"})]}),b&&!s?e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground",children:[e.jsx(ce,{className:"h-4 w-4 animate-spin"}),"Loading cluster state..."]}):f&&!s?e.jsx("div",{className:"rounded-sm bg-destructive/10 px-2 py-1.5 text-[10px] text-destructive shadow-sm",children:f}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsx(ms,{label:"Term",value:String((s==null?void 0:s.term)??0)}),e.jsx(ms,{label:"Nodes",value:String((s==null?void 0:s.nodes.length)??0)}),e.jsx(ms,{label:"Pending",value:String((s==null?void 0:s.taskSummary.pending)??0)}),e.jsx(ms,{label:"Running",value:String((s==null?void 0:s.taskSummary.running)??0)}),e.jsx(ms,{label:"Completed",value:String((s==null?void 0:s.taskSummary.completed)??0)}),e.jsx(ms,{label:"Failed",value:String((s==null?void 0:s.taskSummary.failed)??0)})]}),e.jsxs("div",{className:"space-y-1.5 rounded-sm bg-background/56 px-2 py-2 shadow-sm",children:[e.jsx(We,{label:"Leader",value:((J=s==null?void 0:s.leader)==null?void 0:J.name)??"None"}),e.jsx(We,{label:"Leader URL",value:H??"Unavailable",mono:!0,action:H?e.jsx(Cs,{label:"Copy leader URL",onClick:()=>void xs(H,"Leader URL copied")}):void 0}),e.jsx(We,{label:"Feed",value:N?"Receiving live updates":"Reconnecting to event stream"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:U&&e.jsxs(V,{variant:"outline",size:"sm",onClick:u,disabled:l,className:"h-6 rounded-sm px-2 text-[10px]",children:[l&&e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}),"Promote self"]})})]})]})]})})}),e.jsx(rs,{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"}),Y?e.jsx(V,{variant:"outline",size:"sm",onClick:w,className:"h-6 rounded-sm px-2 text-[10px]",children:"Join node"}):de?e.jsxs(V,{variant:"outline",size:"sm",onClick:x,disabled:_,className:"h-6 rounded-sm px-2 text-[10px]",children:[_&&e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}),"Leave cluster"]}):null]}),M&&e.jsx(va,{node:M,systemInfo:t,blockingTaskCount:o.get(M.id)??0,devTunnelNodeId:c,onToggleNodeDevTunnel:h,showActions:!0,defaultExpanded:!0,onOpenNodeSettings:O?I:void 0,onOpenDevBox:O?A:void 0,onStartDevBox:O?B:void 0,devBoxStartNodeId:j,devBoxStartingNodeIds:S})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"text-[10px] font-medium text-foreground",children:["Peer nodes (",E.length,")"]}),E.length>0?e.jsx("div",{className:"space-y-1.5",children:E.map(q=>e.jsx(kl,{node:q,isLeader:!!O,blockingTaskCount:o.get(q.id)??0,devTunnelNodeId:c,onToggleNodeDevTunnel:h,onOpenNodeSettings:O?I:void 0,onOpenDevBox:O?A:void 0,onStartDevBox:O?B:void 0,devBoxStartNodeId:j,devBoxStartingNodeIds:S},q.id))}):e.jsx("div",{className:"rounded-sm bg-background/45 px-2 py-2 text-[10px] text-muted-foreground shadow-sm",children:"No peer nodes are connected yet."})]})]})})}),e.jsx(rs,{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(fr,{className:$("h-3.5 w-3.5",N?"text-emerald-500":"text-destructive")}),"Live events"]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsxs(ye,{value:r,onValueChange:i,children:[e.jsx(ke,{className:"h-6 min-w-[10rem] flex-1 rounded-sm border-border/70 bg-background/60 text-[10px] sm:max-w-[14rem] [&>svg]:h-3 [&>svg]:w-3",children:e.jsx(Re,{placeholder:"Event type"})}),e.jsx(Se,{children:v.map(q=>e.jsx(Ne,{value:q,className:"py-1 pl-6 pr-1.5 text-[10px] leading-4",children:q==="all"?"All event types":q},q))})]}),e.jsx(Be,{variant:"outline",className:"rounded-sm border-transparent bg-background/60 px-1.5 py-0 text-[9px] leading-4 shadow-sm",children:N?"Connected":"Reconnecting"})]})]}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(gr,{events:g,maxHeight:"100%",emptyTitle:r==="all"?"No live events yet":"No matching events",emptyDescription:r==="all"?"Cluster activity appears here as it happens.":`No "${r}" events are in the current stream.`,nodeNameById:n,density:"compact"})})]})})]})})}function va({node:s,systemInfo:t,blockingTaskCount:n,devTunnelNodeId:o,onToggleNodeDevTunnel:r,showActions:i=!0,defaultExpanded:v=!1,onOpenNodeSettings:g,onOpenDevBox:N,onStartDevBox:b,devBoxStartNodeId:f,devBoxStartingNodeIds:l}){var B,T,O,U;const[u,w]=a.useState(v),_=(t==null?void 0:t.dashboardOrigin)??s.dashboardOrigin,x=s.devtunnelEndpoint??s.endpoint,h=_??s.endpoint,c=(t==null?void 0:t.workDir)??s.workDir,j=Qa(s,t==null?void 0:t.transportType),S=Bt(s,t==null?void 0:t.transportType),I=S&&bs((t==null?void 0:t.transportType)??s.transportType)?!0:Ga(s,t==null?void 0:t.transportType),A=n>0;return e.jsxs("section",{className:"rounded-lg bg-primary/7 shadow-[0_18px_56px_-42px_hsl(var(--primary)/0.85)]",children:[e.jsxs("div",{className:"w-full px-2.5 py-1.5 text-left",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>w(M=>!M),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[u?e.jsx(as,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(ks,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx(Pa,{status:s.status}),e.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Current node"})]}),e.jsx("a",{href:h,target:"_blank",rel:"noreferrer",className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(Ba,{className:"h-3 w-3"})}),g&&e.jsx($t,{nodeId:s.id,nodeName:s.name,onOpenSettings:g,onOpenDevBox:N,onStartDevBox:b,showConfigureDevBox:(B=s.devbox)==null?void 0:B.enabled,showStartDevBox:Os(s.status,(T=s.devbox)==null?void 0:T.lastStatus,s.devbox)||fs((O=s.devbox)==null?void 0:O.lastStatus)||l.has(s.id),startDevBoxPending:f===s.id||fs((U=s.devbox)==null?void 0:U.lastStatus)||l.has(s.id)})]}),e.jsxs("button",{type:"button",onClick:()=>w(M=>!M),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:s.name}),e.jsx(Ra,{role:s.role,size:"compact"}),e.jsx(Be,{variant:"outline",className:"rounded-sm border-transparent bg-background/60 px-1.5 py-0 text-[9px] leading-4 capitalize shadow-sm",children:s.status})]})]}),u&&e.jsxs("div",{className:"space-y-2 px-2.5 pb-2.5 pt-1.5 shadow-[inset_0_1px_0_hsl(var(--primary)/0.12)]",children:[e.jsxs("div",{className:"space-y-1.5 rounded-sm bg-background/70 px-2 py-1.5 shadow-sm",children:[e.jsx(We,{label:"Node ID",value:s.id,mono:!0}),_&&e.jsx(We,{label:"Dashboard",value:_,mono:!0,action:e.jsx(Cs,{label:"Copy dashboard URL",onClick:()=>void xs(_,"Dashboard URL copied")})}),e.jsx(We,{label:"Node URL",value:x,mono:!0,action:e.jsx(Cs,{label:"Copy node URL",onClick:()=>void xs(x,"Node URL copied")})}),c&&e.jsx(We,{label:"Workspace",value:c,mono:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[e.jsx(xt,{label:"Transport",value:j}),t&&e.jsx(xt,{label:"Uptime",value:br(t.uptime),mono:!0})]}),e.jsx(Va,{capabilities:s.capabilities,action:i&&I?e.jsxs(V,{variant:"outline",size:"sm",onClick:()=>r(s),disabled:o===s.id||A,className:"h-6 rounded-sm px-2 text-[10px]",title:A?"Finish assigned or running tasks before changing remote access":void 0,children:[o===s.id&&e.jsx(ce,{className:"h-3 w-3 animate-spin"}),S?"Disable Remote Access":"Enable Remote Access"]}):void 0}),i&&I&&A&&e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function kl({node:s,isLeader:t,blockingTaskCount:n,devTunnelNodeId:o,onToggleNodeDevTunnel:r,onOpenNodeSettings:i,onOpenDevBox:v,onStartDevBox:g,devBoxStartNodeId:N,devBoxStartingNodeIds:b}){var S,I,A,B;const[f,l]=a.useState(!1),u=s.dashboardOrigin,w=s.devtunnelEndpoint??s.endpoint,_=u??s.endpoint,x=Qa(s),h=Bt(s),c=Ga(s),j=n>0;return e.jsxs("div",{className:"rounded-sm bg-background/54 shadow-sm",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(T=>!T),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[f?e.jsx(as,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):e.jsx(ks,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx(Pa,{status:s.status}),e.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Peer node"})]}),e.jsx("a",{href:_,target:"_blank",rel:"noreferrer",className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(Ba,{className:"h-3 w-3"})}),t&&i&&e.jsx($t,{nodeId:s.id,nodeName:s.name,onOpenSettings:i,onOpenDevBox:v,onStartDevBox:g,showConfigureDevBox:(S=s.devbox)==null?void 0:S.enabled,showStartDevBox:Os(s.status,(I=s.devbox)==null?void 0:I.lastStatus,s.devbox)||fs((A=s.devbox)==null?void 0:A.lastStatus)||b.has(s.id),startDevBoxPending:N===s.id||fs((B=s.devbox)==null?void 0:B.lastStatus)||b.has(s.id)})]}),e.jsxs("button",{type:"button",onClick:()=>l(T=>!T),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:s.name}),e.jsx(Ra,{role:s.role,size:"compact"}),e.jsx(Be,{variant:"outline",className:"rounded-sm border-transparent bg-background/60 px-1.5 py-0 text-[9px] leading-4 capitalize shadow-sm",children:s.status})]})]}),f&&e.jsxs("div",{className:"space-y-2 px-2.5 pb-2.5 pt-1.5 shadow-[inset_0_1px_0_hsl(var(--border)/0.22)]",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(We,{label:"Node ID",value:s.id,mono:!0}),u&&e.jsx(We,{label:"Dashboard",value:u,mono:!0,action:e.jsx(Cs,{label:"Copy dashboard URL",onClick:()=>void xs(u,"Dashboard URL copied")})}),e.jsx(We,{label:"Node URL",value:w,mono:!0,action:e.jsx(Cs,{label:"Copy node URL",onClick:()=>void xs(w,"Node URL copied")})}),s.workDir&&e.jsx(We,{label:"Workspace",value:s.workDir,mono:!0}),e.jsx(xt,{label:"Transport",value:x})]}),e.jsx(Va,{capabilities:s.capabilities,action:t&&c?e.jsxs(V,{variant:"outline",size:"sm",onClick:()=>r(s),disabled:o===s.id||j,className:"h-6 rounded-sm px-2 text-[10px]",title:j?"Finish assigned or running tasks before changing remote access":void 0,children:[o===s.id&&e.jsx(ce,{className:"h-3 w-3 animate-spin"}),h?"Disable Remote Access":"Enable Remote Access"]}):void 0}),t&&c&&j&&e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function Cs({label:s,onClick:t}){return e.jsx(V,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 shrink-0 rounded-sm text-muted-foreground",onClick:t,"aria-label":s,title:s,children:e.jsx(Da,{className:"h-3 w-3"})})}function Sl(s,t,n,o){var g,N;if(!s)return{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Select a task to continue the conversation."};const r=((g=t==null?void 0:t.self)==null?void 0:g.role)==="follower",i=s.assignedTo?((N=t==null?void 0:t.self)==null?void 0:N.id)===s.assignedTo?t.self:t==null?void 0:t.nodes.find(b=>b.id===s.assignedTo):void 0;return s.assignedTo!==null&&(i?i.status==="offline":t?s.assignedNodeAvailable===!1||!t.nodes.some(b=>b.id===s.assignedTo):s.assignedNodeAvailable===!1)?{taskUnavailable:!0,chatDisabled:!0,chatDisabledReason:`${s.assignedNodeName??"Assigned node"} is unavailable. Leave the cluster on that node or re-run the task elsewhere.`}:r?{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..."}:o?{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Queue a message for the next turn..."}:Rs.has(s.status)||s.status==="archived"?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:Rs.has(s.status)?"Task has not started yet...":"Archived tasks are read-only."}:{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Continue the conversation..."}}const Ls="h-6 rounded-sm border-border/70 bg-background/60 px-2 py-0 text-[10px] leading-none shadow-sm [&>svg]:h-3 [&>svg]:w-3",Ps="py-1 pl-6 pr-1.5 text-[10px] leading-4 [&_svg]:h-3 [&_svg]:w-3";function Cl(s,t,n){const o=s.filter(g=>g.status==="completed"),r=new Set((t?o:[...o].sort((g,N)=>N.updatedAt-g.updatedAt).slice(0,Et)).map(g=>g.id));n&&o.some(g=>g.id===n)&&r.add(n);const i=s.filter(g=>g.status!=="completed"||r.has(g.id)),v=o.length-r.size;return{visibleTasks:i,hiddenCompletedCount:Math.max(0,v)}}function ja({toolbarTasks:s,activeTaskId:t,tasksLoading:n,tasksError:o,isLeader:r,scope:i,agentFilter:v,nodeFilter:g,taskKindFilter:N,agentOptions:b,nodeOptions:f,nodeNameById:l,nodeWorkDirById:u,nodeStatusById:w,completedGroupByKey:_,devBoxNodeIds:x=new Set,devBoxStartNodeIds:h=new Set,devBoxStartingNodeIds:c=new Set,leaderNodeId:j,searchQuery:S,selectedTaskIds:I,allVisibleTasksSelected:A,someVisibleTasksSelected:B,canBatchArchive:T,onSearchChange:O,onScopeChange:U,onAgentFilterChange:M,onNodeFilterChange:L,onTaskKindFilterChange:E,onToggleTaskSelected:X,onToggleAllVisibleTasks:H,onBatchArchive:Y,onBatchDelete:de,onCreateTask:ne,onOpenNodeSettings:Z,onOpenDevBox:J,onStartDevBox:q,onLoadCompletedTasks:K,onSelectTask:re,onClose:me}){const[p,F]=a.useState(!!S),[C,se]=a.useState(!1),[m,P]=a.useState(!1),W=a.useRef(null),te=a.useRef(null),k=a.useRef(null),z=I.size,ee=i!=="active"||g!=="all"||v!=="all"||N!=="all",Me=S.trim().length>0,[ve,$e]=a.useState(new Set),[Ae,Je]=a.useState(new Set),[Q,fe]=a.useState(new Set),je=a.useMemo(()=>vr(s,l,j,u),[s,l,j,u]),es=je.length===1,Ce=!es||ee||Me,pe=es&&(ee||Me),Ge=a.useCallback(D=>{$e(ge=>{const ue=new Set(ge);return ue.has(D)?ue.delete(D):ue.add(D),ue})},[]),Oe=a.useCallback(D=>{Je(ge=>{const ue=new Set(ge);return ue.has(D)?ue.delete(D):ue.add(D),ue})},[]),Ve=a.useCallback(D=>{fe(ge=>{const ue=new Set(ge);return ue.add(D),ue})},[]);return a.useEffect(()=>{S&&F(!0)},[S]),a.useEffect(()=>{var D;p&&((D=W.current)==null||D.focus())},[p]),a.useEffect(()=>{if(!p)return;const D=ue=>{var Fe;const Ee=ue.target;Ee instanceof Node&&((Fe=te.current)!=null&&Fe.contains(Ee)||F(!1))},ge=ue=>{ue.key==="Escape"&&F(!1)};return document.addEventListener("mousedown",D),document.addEventListener("keydown",ge),()=>{document.removeEventListener("mousedown",D),document.removeEventListener("keydown",ge)}},[p]),a.useEffect(()=>{if(!m)return;const D=ue=>{var Fe;const Ee=ue.target;Ee instanceof Node&&((Fe=k.current)!=null&&Fe.contains(Ee)||P(!1))},ge=ue=>{ue.key==="Escape"&&P(!1)};return document.addEventListener("mousedown",D),document.addEventListener("keydown",ge),()=>{document.removeEventListener("mousedown",D),document.removeEventListener("keydown",ge)}},[m]),e.jsxs("aside",{className:"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:"shrink-0 border-b border-border/55 bg-card/24 px-3 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[e.jsx("div",{className:"text-lg font-semibold tracking-tight text-foreground",children:"Tasks"}),e.jsx(V,{variant:"ghost",size:"icon",onClick:me,className:"rounded-sm",children:e.jsx(qa,{className:"h-4 w-4"})})]}),e.jsxs("div",{ref:te,className:"mt-4 flex items-center gap-1.5",children:[e.jsxs("div",{ref:k,className:$("relative flex items-stretch transition-[flex] duration-200",p?"flex-[2]":"flex-1"),children:[e.jsxs(V,{onClick:()=>{P(!1),ne("chat")},className:"h-10 flex-1 justify-start rounded-l-sm rounded-r-none px-3 text-left shadow-[0_10px_24px_-18px_hsl(var(--primary)/0.9)]",children:[e.jsx(Lt,{className:"h-4 w-4"}),"New chat"]}),e.jsx(V,{onClick:()=>P(D=>!D),"aria-label":"More chat options","aria-haspopup":"menu","aria-expanded":m,className:"h-10 w-8 rounded-l-none rounded-r-sm border-l border-primary-foreground/20 px-0 shadow-[0_10px_24px_-18px_hsl(var(--primary)/0.9)]",children:e.jsx(as,{className:$("h-3.5 w-3.5 transition-transform",m&&"rotate-180")})}),m&&e.jsx("div",{role:"menu",className:"absolute left-0 right-0 top-full z-20 mt-2 overflow-hidden rounded-lg border border-border/60 bg-popover/96 p-1 shadow-[0_20px_60px_-30px_rgba(0,0,0,0.45)] backdrop-blur-xl",children:e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{P(!1),ne("native")},className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-2 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80",children:[e.jsx(At,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{className:"flex-1 truncate whitespace-nowrap",children:"Load session"}),e.jsx("span",{className:"shrink-0 text-[9px] uppercase tracking-[0.18em] text-muted-foreground",children:"native"})]})})]}),p?e.jsxs("div",{className:"flex min-w-0 flex-[3] items-center gap-1.5",children:[e.jsxs("div",{className:"relative min-w-0 flex-1",children:[e.jsx(st,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(Xe,{ref:W,value:S,onChange:D=>O(D.target.value),placeholder:"Search tasks",className:"h-11 rounded-lg border-border/70 bg-background/68 pl-11 text-[11px]"})]}),e.jsx(V,{variant:"outline",size:"icon",onClick:()=>F(!1),className:"rounded-sm border-border/70 bg-background/68",children:e.jsx(Bs,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(V,{variant:"outline",onClick:()=>F(!0),className:$("rounded-sm border-border/70 bg-background/68 px-3 text-[11px]",S&&"border-primary/40 bg-primary/8 text-primary"),children:[e.jsx(st,{className:"h-4 w-4"}),"Search"]}),e.jsx(V,{variant:C||ee?"secondary":"outline",size:"icon",onClick:()=>se(D=>!D),className:$("shrink-0 rounded-sm border-border/70 bg-background/68",ee&&"border-primary/40 bg-primary/8 text-primary"),title:"Filters",children:e.jsx(Lo,{className:"h-4 w-4"})})]})]}),(C||ee)&&e.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-1 sm:grid-cols-2",children:[e.jsxs(ye,{value:i,onValueChange:D=>U(D),children:[e.jsx(ke,{className:Ls,children:e.jsx(Re,{})}),e.jsx(Se,{children:jr.map(D=>e.jsx(Ne,{value:D.value,className:Ps,children:D.label},D.value))})]}),e.jsxs(ye,{value:g,onValueChange:L,children:[e.jsx(ke,{className:Ls,children:e.jsx(Re,{placeholder:"Node"})}),e.jsx(Se,{children:f.map(D=>e.jsx(Ne,{value:D.value,className:Ps,children:D.label},D.value))})]}),e.jsxs(ye,{value:v,onValueChange:M,children:[e.jsx(ke,{className:Ls,children:e.jsx(Re,{placeholder:"Agent"})}),e.jsx(Se,{children:b.map(D=>e.jsx(Ne,{value:D,className:Ps,children:D==="all"?"All agents":D},D))})]}),e.jsxs(ye,{value:N,onValueChange:D=>E(D),children:[e.jsx(ke,{className:Ls,children:e.jsx(Re,{placeholder:"Type"})}),e.jsx(Se,{children:Nr.map(D=>e.jsx(Ne,{value:D.value,className:Ps,children:D.label},D.value))})]})]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-1.5 py-2",children:je.length>0?e.jsxs("div",{className:"space-y-1",children:[r&&e.jsxs("div",{className:"mb-1 flex items-center justify-between px-0.5 py-0.5",children:[e.jsxs("label",{className:"flex items-center gap-[5px] text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground/75",children:[e.jsx(ut,{className:"h-3 w-3 [&_svg]:h-2.5 [&_svg]:w-2.5",checked:B&&!A?"indeterminate":A,onCheckedChange:D=>H(D===!0),"aria-label":"Select all visible tasks"}),e.jsx("span",{children:"Select all"})]}),z>0&&e.jsx(V,{variant:"ghost",size:"sm",onClick:()=>H(!1),className:"h-5 rounded-sm px-1.5 text-[10px]",children:"Clear"})]}),je.map(D=>{const ge=D.nodeId??"__unassigned__",ue=D.dirs.reduce((be,Le)=>be+Le.tasks.length,0),Ee=Ce&&!pe&&ve.has(ge),Fe=D.nodeId!==null&&w.get(D.nodeId)==="offline",is=!!(r&&D.nodeId&&Z);return e.jsxs("div",{className:"space-y-1",children:[Ce&&e.jsxs("div",{className:"flex w-full items-center gap-1.5 rounded-sm bg-gradient-to-r from-primary/8 to-muted/20 px-2 py-1.5 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:()=>Ge(ge),"aria-expanded":!Ee,className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[e.jsx(ks,{className:$("h-3.5 w-3.5 shrink-0 transition-transform duration-200",!Ee&&"rotate-90")}),e.jsx(Sa,{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:D.nodeName}),e.jsxs(Be,{variant:"outline",className:"shrink-0 whitespace-nowrap rounded-sm border-border/60 bg-background/55 px-1.5 py-0 text-[8px] font-semibold leading-4 text-muted-foreground shadow-none normal-case tracking-normal",children:[ue," task",ue===1?"":"s"]})]})]}),e.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[Fe&&e.jsx(Be,{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"}),D.nodeId===j&&e.jsx(Be,{variant:"outline",className:"rounded-sm border-primary/25 bg-primary/8 px-1 py-0 text-[8px] font-medium leading-3.5 text-primary shadow-none",children:"leader"}),is&&D.nodeId&&Z&&e.jsx($t,{nodeId:D.nodeId,nodeName:D.nodeName,onOpenSettings:Z,onOpenDevBox:J,onStartDevBox:q,showConfigureDevBox:x.has(D.nodeId),showStartDevBox:h.has(D.nodeId)||c.has(D.nodeId),startDevBoxPending:c.has(D.nodeId)})]})]}),e.jsx("div",{className:$("grid transition-[grid-template-rows] duration-300 ease-in-out",Ee?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:"overflow-hidden",children:D.dirs.map(be=>{const Le=`${ge}::${be.path}`,we=Ae.has(Le),ls=$a(be.path),Ze=_==null?void 0:_.get(Le),ds=Ze?{visibleTasks:be.tasks,hiddenCompletedCount:Math.max(0,Ze.total-Ze.returned)}:Cl(be.tasks,Q.has(Le),t),{visibleTasks:Pe,hiddenCompletedCount:_e}=ds;return e.jsxs("div",{className:$("space-y-0.5 rounded-xl",Ce&&"pl-2.5"),children:[e.jsxs("button",{type:"button",onClick:()=>Oe(Le),"aria-expanded":!we,title:be.path,className:"flex w-full items-center gap-1.5 rounded-sm bg-muted/15 px-2 py-1 text-left 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.jsx(ks,{className:$("h-3 w-3 shrink-0 transition-transform duration-200",!we&&"rotate-90")}),e.jsx(Ca,{className:"h-3 w-3 shrink-0 text-muted-foreground/55"}),e.jsx("span",{className:"truncate font-mono",children:ls}),e.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-muted-foreground/40",children:be.tasks.length})]}),e.jsx("div",{className:$("grid transition-[grid-template-rows] duration-300 ease-in-out",we?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:$("overflow-hidden",Ce?"pl-2":"pl-0"),children:e.jsxs("div",{className:"space-y-px py-0.5",children:[Pe.map(ie=>{const Qe=ie.id===t,vs=ie.assignedTo?w.get(ie.assignedTo):void 0,_s=!!ie.assignedTo&&(vs?vs==="offline":ie.assignedNodeAvailable===!1);return e.jsxs("div",{className:$("flex items-center gap-1.5 rounded-sm px-2 py-1.5 outline outline-1 -outline-offset-1 outline-transparent transition-all duration-150",Qe?"bg-primary/10 outline-primary/35":"hover:bg-muted/40 hover:outline-border/50"),children:[r&&e.jsx("div",{className:"flex shrink-0",onClick:cs=>cs.stopPropagation(),children:e.jsx(ut,{className:"h-3 w-3 [&_svg]:h-2.5 [&_svg]:w-2.5",checked:I.has(ie.id),onCheckedChange:cs=>X(ie.id,cs===!0),"aria-label":`Select ${ie.title}`})}),e.jsxs("button",{type:"button",onClick:()=>re(ie.id),"aria-current":Qe?"page":void 0,className:"min-w-0 flex-1 text-left",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:$("h-1.5 w-1.5 shrink-0 rounded-full",wr(ie.status),(ie.status==="running"||ie.status==="assigned")&&"animate-soft-status-pulse")}),e.jsx("span",{className:$("min-w-0 flex-1 truncate text-[10px] font-medium leading-4",Qe?"text-foreground":"text-foreground/80"),children:ie.title}),e.jsx("span",{className:$("ml-1 shrink-0 tabular-nums text-[9px]",Qe?"text-primary/75":"text-muted-foreground/55"),children:yr(ie.updatedAt)}),Qe&&e.jsx("span",{className:"ml-1 h-1.5 w-1.5 shrink-0 rounded-full bg-primary"})]}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-0.5 pl-3",children:[e.jsx(Ta,{status:ie.status,size:"compact"}),e.jsx("span",{className:"font-mono text-[8px] leading-3 text-muted-foreground/55",children:ie.agent}),ie.conversationKind==="nativeSession"&&e.jsx(Be,{variant:"outline",className:"rounded-sm border-sky-500/25 bg-sky-500/8 px-1 py-0 text-[8px] leading-3 text-sky-700 shadow-none dark:text-sky-300",children:"native"}),ie.activeShare&&e.jsx(Be,{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"}),_s&&e.jsx(Be,{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"})]})]})]},ie.id)}),_e>0&&e.jsxs("button",{type:"button",onClick:()=>{Ze&&K?K(Ze):Ve(Le)},className:"mt-1 flex w-full items-center justify-center gap-1 rounded-sm border border-dashed border-border/55 bg-background/35 px-2 py-1 text-[9px] font-medium text-muted-foreground transition-colors hover:border-primary/35 hover:bg-primary/8 hover:text-primary","aria-label":`Load ${_e} more completed tasks in ${ls}`,children:[e.jsx(as,{className:"h-3 w-3"}),"Load ",_e," more completed"]})]})})})]},Le)})})})]},ge)})]}):n?e.jsx("div",{className:"space-y-2 px-1",children:[1,2,3].map(D=>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+D*12}%`,animationDelay:`${D*120}ms`}}),e.jsx("div",{className:"h-2 w-24 animate-pulse rounded-full bg-muted-foreground/10",style:{animationDelay:`${D*120+60}ms`}})]})]})},D))}):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:o||"No tasks match this view."})}),r&&z>0?e.jsxs("div",{className:"shrink-0 border-t border-border/60 px-3 py-3",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.2em] text-muted-foreground",children:"Batch actions"}),e.jsxs("div",{className:"mt-2 text-[10px] font-semibold text-foreground",children:[z," task",z!==1?"s":""," selected"]}),!T&&e.jsx("div",{className:"mt-2 text-[10px] leading-4 text-muted-foreground",children:"Only completed, failed, cancelled, or archived tasks can be archived."}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[e.jsxs(at,{children:[e.jsx(Zt,{asChild:!0,children:e.jsxs(V,{variant:"outline",size:"sm",disabled:!T,className:"h-7 gap-1.5 rounded-sm px-2 text-[10px] [&_svg]:size-3.5",children:[e.jsx(ko,{}),"Archive"]})}),e.jsxs(nt,{children:[e.jsxs(rt,{children:[e.jsxs(ot,{children:["Archive ",z," task",z!==1?"s":"","?"]}),e.jsx(it,{children:"Archived tasks stay hidden from the default task view and can be reopened from the archived scope."})]}),e.jsxs(lt,{children:[e.jsx(dt,{children:"Cancel"}),e.jsx(ct,{onClick:Y,disabled:!T,children:"Archive"})]})]})]}),e.jsxs(at,{children:[e.jsx(Zt,{asChild:!0,children:e.jsxs(V,{variant:"destructive",size:"sm",className:"h-7 gap-1.5 rounded-sm px-2 text-[10px] [&_svg]:size-3.5",children:[e.jsx(ii,{}),"Delete"]})}),e.jsxs(nt,{children:[e.jsxs(rt,{children:[e.jsxs(ot,{children:["Delete ",z," task",z!==1?"s":"","?"]}),e.jsx(it,{children:"This removes the selected tasks and their saved logs."})]}),e.jsxs(lt,{children:[e.jsx(dt,{children:"Cancel"}),e.jsx(ct,{onClick:de,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}):null]})}async function _l(s,t){var n,o;try{const r=await kr(s,t),i={...r,url:_a(r.url)};if((o=(n=globalThis.navigator)==null?void 0:n.clipboard)!=null&&o.writeText)try{await globalThis.navigator.clipboard.writeText(i.url),ae.success("Shared link copied")}catch{ae.success("Shared link created")}else ae.success("Shared link created");return i}catch(r){ae.error(r instanceof Error?r.message:"Failed to create shared link");return}}async function Dl(s){try{return await Sr(s),ae.success("Shared link stopped"),!0}catch(t){return ae.error(t instanceof Error?t.message:"Failed to stop shared link"),!1}}function El(s,t,n){const o=a.useCallback(()=>{t(),n()},[t,n]),r=a.useCallback(async v=>{if(!s)return;const g=await _l(s.id,v);return g&&o(),g},[s,o]),i=a.useCallback(async()=>{if(!s)return!1;const v=await Dl(s.id);return v&&o(),v},[s,o]);return{handleShareTask:r,handleStopShareTask:i}}function Na(s,t,n){const o=a.useRef(t);o.current=t,a.useEffect(()=>{let v=0,g=0;const N=l=>{const u=l.touches[0];u&&(v=u.clientX,g=u.clientY)},b=l=>{var x,h,c,j;const u=l.changedTouches[0];if(!u)return;const w=u.clientX-v;Math.abs(u.clientY-g)>100||Math.abs(w)<50||(w>0?(h=(x=o.current).onSwipeRight)==null||h.call(x):(j=(c=o.current).onSwipeLeft)==null||j.call(c))},f=(s==null?void 0:s.current)??document;return f.addEventListener("touchstart",N,{passive:!0}),f.addEventListener("touchend",b,{passive:!0}),()=>{f.removeEventListener("touchstart",N),f.removeEventListener("touchend",b)}},[s,n==null?void 0:n.threshold,n==null?void 0:n.maxVertical])}const Tl="(min-width: 1024px)",Ml="(min-width: 1800px)";function wa(s){var t,n,o;return((o=(n=(t=globalThis.window)==null?void 0:t.matchMedia)==null?void 0:n.call(t,s))==null?void 0:o.matches)??!1}function Al(){var n,o;const s=(n=globalThis.document)==null?void 0:n.documentElement;if(!s||!((o=globalThis.window)!=null&&o.getComputedStyle))return 16;const t=Number.parseFloat(globalThis.window.getComputedStyle(s).fontSize);return Number.isFinite(t)&&t>0?t:16}function Ll(){const[s,t]=a.useState(()=>Cr(ea(),_r({operationsOpen:wa(Ml)}))),[n,o]=a.useState(!1),r=a.useRef(null),i=a.useRef(null),v=a.useRef(null),g=s.layout.desktopTasksOpen,N=s.layout.operationsOpen,b=s.sizes;a.useEffect(()=>{Dr(ea(),s)},[s]);const f=a.useCallback((h,c)=>{t(j=>{const S=j.layout[h],I=typeof c=="function"?c(S):c;return I===S?j:{...j,layout:{...j.layout,[h]:I}}})},[]),l=a.useCallback(h=>{f("desktopTasksOpen",h)},[f]),u=a.useCallback(h=>{f("operationsOpen",h)},[f]);Na(i,{onSwipeLeft:()=>o(!1)}),Na(v,{onSwipeRight:()=>u(!1)});const w=a.useCallback(()=>{if(wa(Tl)){l(h=>!h);return}o(h=>!h)},[l]);a.useEffect(()=>{var j,S,I;const h=A=>{const B=r.current;if(!B)return;A.preventDefault();const T=Tr(B.panel,B.startSize,B.startClientX,B.startClientY,A.clientX,A.clientY,B.rootFontSize);t(O=>({...O,sizes:{...O.sizes,[B.panel]:T}}))},c=()=>{r.current=null};return(j=globalThis.window)==null||j.addEventListener("pointermove",h),(S=globalThis.window)==null||S.addEventListener("pointerup",c),(I=globalThis.window)==null||I.addEventListener("pointercancel",c),()=>{var A,B,T;(A=globalThis.window)==null||A.removeEventListener("pointermove",h),(B=globalThis.window)==null||B.removeEventListener("pointerup",c),(T=globalThis.window)==null||T.removeEventListener("pointercancel",c)}},[]);const _=a.useCallback((h,c)=>{var j,S;c.preventDefault(),(S=(j=c.currentTarget).setPointerCapture)==null||S.call(j,c.pointerId),r.current={panel:h,startSize:b[h],startClientX:c.clientX,startClientY:c.clientY,rootFontSize:Al()}},[b]),x=a.useCallback((h,c)=>{c.preventDefault(),t(j=>({...j,sizes:{...j.sizes,[h]:Er(h,j.sizes[h],c.deltaY)}}))},[]);return{desktopTasksOpen:g,mobileTasksPanelOpen:n,mobileTasksPanelRef:i,operationsOpen:N,operationsPanelRef:v,panelResize:{sizes:{tasks:Qs(b.tasks),operations:Qs(b.operations),terminal:Qs(b.terminal)},onPointerDown:_,onWheel:x},setMobileTasksPanelOpen:o,setOperationsOpen:u,toggleTasksPanel:w}}function Pl(s,t){const n=t.taskId,o=t.updates;return typeof n!="string"||!o||typeof o!="object"?s:s.map(r=>r.id===n?{...r,...o}:r)}function Bl({isLeader:s,selfId:t}){return{...!s&&t?{assignedTo:t}:{},completedLimitPerProject:Et}}function kt(s){return`${s.assignedTo??"__unassigned__"}::${s.projectPath}`}function Rl(s,t){const n=new Map(s.map(o=>[o.id,o]));for(const o of t)n.set(o.id,o);return Array.from(n.values())}function $l({isLeader:s,selfId:t,sseConnected:n,subscribe:o}){const[r,i]=a.useState([]),[v,g]=a.useState([]),[N,b]=a.useState(!0),[f,l]=a.useState(null),u=a.useRef(null),w=a.useCallback(async()=>{try{const h=await sa(Bl({isLeader:s,selfId:t}));i(h.tasks),g(h.completedGroups??[]),l(null)}catch(h){l(h instanceof Error?h.message:"Failed to load tasks")}finally{b(!1)}},[s,t]),_=a.useCallback(async h=>{if(!h.hasMore||!h.nextCursor)return;const c=await sa({status:"completed",assignedTo:h.assignedTo??"__unassigned__",projectPath:h.projectPath,cursor:h.nextCursor,limit:Et});i(j=>Rl(j,c.tasks)),g(j=>j.map(S=>kt(S)===kt(h)?{...S,returned:Math.min(S.total,S.returned+c.tasks.length),hasMore:c.hasMore===!0,nextCursor:c.nextCursor??null}:S))},[]),x=a.useCallback(()=>{u.current===null&&(u.current=window.setTimeout(()=>{u.current=null,w()},Mr))},[w]);return Ar(w,Br(n)),a.useEffect(()=>()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},[]),a.useEffect(()=>{const h=[o("task.updated",c=>{i(j=>Pl(j,c.data))}),o("task.status",c=>{i(j=>Lr(j,c.data))}),o("task",c=>{Pr(c.type)&&x()})];return()=>h.forEach(c=>c())},[o,x]),{completedGroups:v,fetchTasks:w,loadCompletedTasksPage:_,setTasks:i,tasks:r,tasksError:f,tasksLoading:N}}function ln(s){return s.map(t=>({...t}))}function Ol(s,t){const n=t.get(s);return{logs:n?ln(n.logs):[],transcriptLoading:(n==null?void 0:n.loaded)!==!0}}function Fl(s,t){return t.data.nodeId===s.self.id||t.data.name===s.self.name||t.data.endpoint===s.self.endpoint}function Il({cluster:s,subscribe:t}){a.useEffect(()=>{var n;if(((n=s==null?void 0:s.self)==null?void 0:n.role)==="leader")return t("node",o=>{const r=String(o.data.name??o.data.nodeId??"node"),i=Fl(s,o);o.type==="node.joined"&&!i&&ae.success(`${r} joined the cluster`),o.type==="node.left"&&!i&&ae.message(`${r} left the cluster`)})},[s,t])}const zl=[0,300,1e3,2e3];function Vl({task:s,getActiveTaskId:t,setLogs:n,setPendingMessages:o,setTranscriptLoading:r}){s.conversationKind==="nativeSession"&&(async()=>{try{for(const i of zl){if(i>0&&await new Promise(v=>setTimeout(v,i)),t()!==s.id)return;try{const v=await mt(s.id);if(t()!==s.id||(n(g=>Ua(g,v.logs)),o(g=>ht(g,v.logs)),v.total>0))return}catch{}}}finally{t()===s.id&&(r==null||r(!1))}})()}function Ul(s,t){return De(s??{})===De(t??{})}function Hl(s){return s&&"status"in s&&typeof s.status=="string"?s.status:void 0}function ya(s,t){return{...s,enabled:!0,alwaysOnline:t}}function dn(s){var t,n;return((t=s==null?void 0:s.status)==null?void 0:t.trim())||((n=s==null?void 0:s.lastStatus)==null?void 0:n.trim())||"Unknown"}function ql({operationStarting:s,loading:t,refreshing:n,savedStatus:o,fallbackStatus:r}){return s?"Starting":t?"Listing DevBoxes":n?"Refreshing":o??r}function ka({devbox:s,showStatus:t=!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:s.name}),s.projectName&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",s.projectName]})]}),t&&e.jsx("span",{className:"ml-auto shrink-0 rounded-full border border-border/70 bg-background/70 px-1.5 py-0.5 text-[10px] leading-none text-muted-foreground",children:dn(s)})]})}function Kl({node:s,open:t,startInProgress:n=!1,onOpenChange:o,onRefresh:r}){const i=(s==null?void 0:s.id)??null,v=t&&!n&&ga(s==null?void 0:s.status,(s==null?void 0:s.devbox)??null),[g,N]=a.useState([]),[b,f]=a.useState(()=>s!=null&&s.devbox?De(s.devbox):""),[l,u]=a.useState(()=>(s==null?void 0:s.devbox)??null),[w,_]=a.useState(()=>ba((s==null?void 0:s.devbox)??null)),[x,h]=a.useState(!1),[c,j]=a.useState(v),[S,I]=a.useState(!1),[A,B]=a.useState(!1),[T,O]=a.useState(()=>{var m;return((m=s==null?void 0:s.devbox)==null?void 0:m.alwaysOnline)===!0}),U=a.useMemo(()=>{const m=g.find(P=>De(P)===b);return m||(ps(l)&&De(l)===b?l:void 0)},[l,g,b]),M=Hl(U??void 0),L=w?M??(l==null?void 0:l.lastStatus):(l==null?void 0:l.lastStatus)??M,E=(s==null?void 0:s.status)==="online"||(s==null?void 0:s.status)==="busy"?"Running":"Unknown",X=A||n,H=ql({operationStarting:X,loading:x,refreshing:c,savedStatus:L,fallbackStatus:E}),Y=w&&!!U&&!Ul(l,U),de=(l==null?void 0:l.alwaysOnline)===!0!==T,ne=Nl({nodeStatus:s==null?void 0:s.status,status:H,current:l,selected:U}),Z=!!ne,J=!!U&&(Y||de)&&!Z,q=U??l,K=a.useCallback(async()=>{if(i){j(!0);try{const m=await Rr(i);u(m.devbox),f(De(m.devbox))}catch(m){ae.error(m instanceof Error?m.message:"Failed to refresh DevBox status")}finally{j(!1)}}},[i]),re=a.useCallback(async m=>{h(!0);try{const P=await $r();N(P),f(W=>wl({previousKey:W,baseDevBox:m,listed:P}))}catch(P){ae.error(P instanceof Error?P.message:"Failed to load DevBoxes")}finally{h(!1)}},[]);a.useEffect(()=>{if(!t||!i)return;let m=!1;const P=(s==null?void 0:s.devbox)??null,W=ba(P),te=!n&&ga(s==null?void 0:s.status,P);h(!1),j(te),_(W),u(P),O((P==null?void 0:P.alwaysOnline)===!0),f(ps(P)?De(P):""),N([]);async function k(){te&&await K(),!m&&W&&await re(P)}return k(),()=>{m=!0}},[re,s==null?void 0:s.devbox,s==null?void 0:s.status,i,t,K,n]);async function me(){_(!0),g.length===0&&await re(l)}async function p(){if(!(!s||!U)){I(!0);try{const m=await ta(s.id,ya(U,T));u(m.node.devbox??null),m.node.devbox&&f(De(m.node.devbox)),_(!1),ae.success(`Configured DevBox for ${s.name}`),await(r==null?void 0:r())}catch(m){ae.error(m instanceof Error?m.message:"Failed to configure DevBox")}finally{I(!1)}}}async function F(){if(!(!s||!ne)){B(!0);try{if(U&&(Y||de)){const P=await ta(s.id,ya(U,T));u(P.node.devbox??null),P.node.devbox&&f(De(P.node.devbox)),_(!1)}const{operation:m}=await Oa(s.id);u(P=>P&&{...P,lastStatus:"Starting",checkedAt:Date.now(),operationId:m.id}),ae.success(`Start requested for ${s.name}`),await(r==null?void 0:r())}catch(m){ae.error(m instanceof Error?m.message:"Failed to start DevBox")}finally{B(!1)}}}const C=x?"Loading DevBoxes...":g.length===0?"No DevBoxes available":"Select a DevBox",se=H==="Running"&&(s==null?void 0:s.status)==="offline";return e.jsx(St,{open:t,onOpenChange:o,children:e.jsxs(Ct,{className:"max-w-md gap-4 rounded-lg p-5",children:[e.jsxs(Aa,{className:"space-y-1",children:[e.jsx(_t,{className:"text-sm",children:"Configure DevBox"}),e.jsxs(Or,{className:"text-xs",children:["Bind ",s!=null&&s.name?e.jsx("span",{className:"font-medium text-foreground",children:s.name}):"this node"," to an Azure Dev Box. Meshy will start it when the node is offline."]})]}),e.jsxs("div",{className:"space-y-3",children:[(w||q)&&e.jsxs("div",{className:"flex min-h-9 items-center justify-between gap-3 rounded-xl border border-border/60 bg-muted/20 px-3 py-2 text-xs",children:[e.jsx("div",{className:"min-w-0 flex-1",children:w?e.jsxs(ye,{value:b,onValueChange:f,disabled:x||S||A||g.length===0,children:[e.jsx(ke,{className:"h-7 justify-start gap-2 rounded-none border-0 bg-transparent px-0 text-xs shadow-none focus:ring-0 focus:ring-offset-0 [&>span]:!flex [&>span]:!min-w-0 [&>span]:!flex-1 [&>span]:!items-center",children:x&&!U?e.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}),C]}):U?e.jsx(ka,{devbox:U}):e.jsx(Re,{placeholder:C})}),e.jsx(Se,{children:g.map(m=>e.jsx(Ne,{value:De(m),textValue:`${m.name} ${m.projectName??""} ${dn(m)}`,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(ka,{devbox:m,showStatus:!0})},De(m)))})]}):q&&e.jsxs("div",{className:"min-w-0 truncate",children:[e.jsx("span",{className:"font-medium text-foreground",children:q.name}),q.projectName&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",q.projectName]})]})}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs(Be,{variant:"outline",className:"rounded-full px-2 py-0.5 text-[10px]",children:[(x||c)&&e.jsx(ce,{className:"mr-1 h-2.5 w-2.5 animate-spin"}),H]}),(l==null?void 0:l.name)&&e.jsx(V,{type:"button",variant:"ghost",size:"icon",onClick:()=>{me()},disabled:x||S||X||w,"aria-label":"Edit DevBox binding",title:"Edit DevBox binding",className:"h-6 w-6 rounded-full text-muted-foreground hover:text-foreground",children:x&&w?e.jsx(ce,{className:"h-3 w-3 animate-spin"}):e.jsx(gs,{className:"h-3 w-3"})})]})]}),se&&e.jsx("div",{className:"rounded-xl 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 items-start gap-2 rounded-xl border border-border/60 bg-muted/20 px-3 py-2 text-xs text-foreground",children:[e.jsx(ut,{checked:T,onCheckedChange:m=>O(m===!0),disabled:S||A||X,"aria-label":"Always online",className:"mt-0.5 h-3.5 w-3.5"}),e.jsxs("span",{className:"min-w-0 leading-4",children:[e.jsx("span",{className:"block",children:"Always online"}),e.jsx("span",{className:"block text-[10px] leading-3.5 text-muted-foreground",children:"Meshy will start the DevBox automatically when it is Hibernated or Stopped."})]})]})]}),e.jsxs(La,{className:"gap-2 sm:space-x-0",children:[e.jsx(V,{variant:"ghost",size:"sm",onClick:()=>o(!1),disabled:S||A,className:"h-8 rounded-xl text-xs",children:"Close"}),Z&&e.jsxs(V,{size:"sm",onClick:F,disabled:A,className:"h-8 rounded-xl text-xs",children:[A?e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Mt,{className:"h-3.5 w-3.5"}),"Start DevBox"]}),!Z&&e.jsxs(V,{size:"sm",onClick:p,disabled:!J||S,className:"h-8 rounded-xl text-xs",children:[S&&e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}),"Save"]})]})]})})}async function Wl(s,t=Fr){if(s.length===0)return new Set;const n=new Set(s),[o,r]=await Promise.all([t({kind:"devbox.start",status:"queued"}),t({kind:"devbox.start",status:"running"})]);return new Set([...o,...r].filter(i=>n.has(i.nodeId)).map(i=>i.nodeId))}function Gl({cluster:s,refresh:t}){const[n,o]=a.useState(null),[r,i]=a.useState(null),[v,g]=a.useState(()=>new Set),[N,b]=a.useState(()=>new Set),f=a.useMemo(()=>(s==null?void 0:s.nodes.find(c=>c.id===n))??null,[s==null?void 0:s.nodes,n]),l=a.useMemo(()=>new Set(((s==null?void 0:s.nodes)??[]).filter(c=>{var j;return(j=c.devbox)==null?void 0:j.enabled}).map(c=>c.id)),[s==null?void 0:s.nodes]),u=a.useMemo(()=>new Set(((s==null?void 0:s.nodes)??[]).filter(c=>{var j;return Os(c.status,(j=c.devbox)==null?void 0:j.lastStatus,c.devbox)}).map(c=>c.id)),[s==null?void 0:s.nodes]),w=a.useMemo(()=>new Set(((s==null?void 0:s.nodes)??[]).filter(c=>{var j;return fs((j=c.devbox)==null?void 0:j.lastStatus)}).map(c=>c.id)),[s==null?void 0:s.nodes]),_=a.useMemo(()=>{const c=new Set(v);r&&c.add(r);for(const j of N)c.add(j);for(const j of w)c.add(j);return c},[N,r,v,w]);a.useEffect(()=>{let c=!1;const j=[...l];async function S(){try{const I=await Wl(j);c||b(I)}catch{c||b(new Set)}}return S(),()=>{c=!0}},[l]),a.useEffect(()=>{g(c=>{var I;let j=!1;const S=new Set(c);for(const A of c){const B=s==null?void 0:s.nodes.find(T=>T.id===A);(B==null?void 0:B.status)!=="online"&&(!((I=B==null?void 0:B.devbox)!=null&&I.lastStatus)||fs(B.devbox.lastStatus))||(S.delete(A),j=!0)}return j?S:c})},[s==null?void 0:s.nodes]);const x=a.useCallback(async c=>{const j=s==null?void 0:s.nodes.find(S=>S.id===c);if(j){i(c),g(S=>new Set(S).add(c));try{await Oa(c),ae.success(`Start requested for ${j.name}`),t()}catch(S){g(I=>{const A=new Set(I);return A.delete(c),A}),ae.error(S instanceof Error?S.message:"Failed to start DevBox")}finally{i(null)}}},[s==null?void 0:s.nodes,t]);return{devBoxDialog:e.jsx(Kl,{node:f,open:n!==null,startInProgress:f?_.has(f.id):!1,onOpenChange:c=>{c||o(null)},onRefresh:t}),devBoxNodeIds:l,devBoxStartNodeId:r,devBoxStartNodeIds:u,devBoxStartingNodeIds:_,openDevBox:o,startDevBox:x}}function Ql(s){const[t,n]=a.useState(null),o=a.useCallback(i=>{s&&n(i)},[s]);return{nodeSettingsDialog:e.jsx(Ir,{open:t!==null,onOpenChange:i=>{i||n(null)},initialSelectedNodeId:t??void 0,showTrigger:!1}),openNodeSettings:o}}function Yl({activeTaskId:s,fetchActiveTask:t,setPendingMessages:n,setTask:o,setTasks:r}){const i=a.useCallback((N,b)=>{o(f=>f&&f.id===N?{...f,queuedMessages:b}:f),r(f=>f.map(l=>l.id===N?{...l,queuedMessages:b}:l))},[o,r]),v=a.useCallback(async N=>{if(!s)return!1;const b=`local-${Date.now()}-${Math.random().toString(16).slice(2)}`;n(f=>[...f,{id:b,content:N,timestamp:new Date().toISOString()}]);try{const f=await zr(s,N);return f.queued&&(n(l=>l.filter(u=>u.id!==b)),f.queuedMessages&&i(s,f.queuedMessages)),t(),!0}catch(f){return n(l=>l.filter(u=>u.id!==b)),ae.error(f instanceof Error?f.message:"Failed to send message"),!1}},[s,t,n,i]);return{cancelQueuedMessage:a.useCallback(async N=>{if(s)try{const b=await Vr(s,N);i(s,b.queuedMessages),t()}catch(b){ae.error(b instanceof Error?b.message:"Failed to cancel queued message")}},[s,t,i]),queueFollowUpMessage:v}}function Xl(){var Ht,qt,Kt,Wt,Gt,Qt;const{id:s}=Ur(),t=Hr(),n=qr(),o=Kr(),{cluster:r,systemInfo:i,events:v,sseConnected:g,subscribe:N,refresh:b,loading:f,error:l}=Wr(),u=a.useMemo(()=>Gr(t.state),[t.state]),[w,_]=a.useState(null),[x,h]=a.useState("active"),[c,j]=a.useState("all"),[S,I]=a.useState("all"),[A,B]=a.useState("all"),[T,O]=a.useState(""),U=(o==null?void 0:o.headerSearchQuery)??T,M=(o==null?void 0:o.setHeaderSearchQuery)??O,L=a.useDeferredValue(U),{desktopTasksOpen:E,mobileTasksPanelOpen:X,mobileTasksPanelRef:H,operationsOpen:Y,operationsPanelRef:de,panelResize:ne,setMobileTasksPanelOpen:Z,setOperationsOpen:J,toggleTasksPanel:q}=Ll(),[K,re]=a.useState(()=>!!(u!=null&&u.draftNewTask)),[me,p]=a.useState(()=>(u==null?void 0:u.createMode)??"chat"),[F,C]=a.useState(()=>u!=null&&u.draftNewTask?{route:u.returnRoute??"/",taskId:u.returnTaskId??null}:null),[se,m]=a.useState(!1),[P,W]=a.useState("transcript"),[te,k]=a.useState("all"),[z,ee]=a.useState(!1),[Me,ve]=a.useState(null),[$e,Ae]=a.useState([]),[Je,Q]=a.useState([]),[fe,je]=a.useState(!1),[es,Ce]=a.useState(!1),[pe,Ge]=a.useState(null),[Oe,Ve]=a.useState(new Set),[D,ge]=a.useState(!1),[ue,Ee]=a.useState(!1),[Fe,is]=a.useState(null),be=a.useRef(null),Le=a.useRef(new Map),we=((Ht=r==null?void 0:r.self)==null?void 0:Ht.role)==="leader",ls=(qt=r==null?void 0:r.self)==null?void 0:qt.id;Il({cluster:r,subscribe:N});const{nodeSettingsDialog:Ze,openNodeSettings:ds}=Ql(we),{devBoxDialog:Pe,devBoxNodeIds:_e,devBoxStartNodeId:ie,devBoxStartNodeIds:Qe,devBoxStartingNodeIds:vs,openDevBox:_s,startDevBox:cs}=Gl({cluster:r,refresh:b}),{completedGroups:Ot=[],fetchTasks:Ie,loadCompletedTasksPage:Fs,setTasks:Ft,tasks:Ye,tasksError:cn,tasksLoading:Is}=$l({isLeader:we,selfId:ls,sseConnected:g,subscribe:N}),He=a.useMemo(()=>[...Ye].sort((d,y)=>y.updatedAt-d.updatedAt),[Ye]),qe=a.useMemo(()=>{var d;return((d=[...Ye].sort((y,R)=>R.createdAt-y.createdAt||R.updatedAt-y.updatedAt)[0])==null?void 0:d.id)??null},[Ye]),un=a.useMemo(()=>{const d=new Map;for(const y of(r==null?void 0:r.nodes)??[]){const R=di(He,y.id);R>0&&d.set(y.id,R)}return d},[r==null?void 0:r.nodes,He]),Ke=a.useMemo(()=>He.filter(d=>!Qr(d,r==null?void 0:r.nodes,r==null?void 0:r.self)||!Yr(d,x)||c!=="all"&&d.agent!==c||!Xr(d,A)||S==="unassigned"&&d.assignedTo||S!=="all"&&S!=="unassigned"&&Jr(d.assignedTo,r==null?void 0:r.nodes,d.assignedNodeName)!==S?!1:L.trim()?Zr(d,L):!0),[He,r==null?void 0:r.nodes,r==null?void 0:r.self,x,c,A,S,L]);a.useEffect(()=>{Ve(d=>{const y=hi(d,Ke.map(R=>R.id));return y.size===d.size?d:y})},[Ke]),a.useEffect(()=>{we||Ve(new Set)},[we]);const mn=a.useMemo(()=>["all",...Array.from(new Set(He.map(d=>d.agent))).sort()],[He]),xn=a.useMemo(()=>{const y=Array.from(new Set(He.map(R=>R.assignedTo).filter(R=>!!R))).map(R=>{const he=He.find(oe=>oe.assignedTo===R);return(r==null?void 0:r.nodes.find(oe=>oe.id===R))??{id:R,name:tt(R,r==null?void 0:r.nodes,he==null?void 0:he.assignedNodeName)}}).sort((R,he)=>R.name.localeCompare(he.name));return[{value:"all",label:"All nodes"},{value:"unassigned",label:"Unassigned"},...y.map(R=>({value:R.name.toLowerCase(),label:R.name}))]},[He,r==null?void 0:r.nodes]),It=a.useMemo(()=>{const d=new Map;for(const y of(r==null?void 0:r.nodes)??[])d.set(y.id,y.name);for(const y of He)y.assignedTo&&y.assignedNodeName&&!d.has(y.assignedTo)&&d.set(y.assignedTo,y.assignedNodeName);return d},[r==null?void 0:r.nodes,He]),hn=a.useMemo(()=>{var y;const d=new Map;for(const R of(r==null?void 0:r.nodes)??[])R.workDir&&d.set(R.id,R.workDir);return(y=r==null?void 0:r.self)!=null&&y.workDir&&d.set(r.self.id,r.self.workDir),d},[r]),pn=a.useMemo(()=>{const d=new Map;for(const y of(r==null?void 0:r.nodes)??[])d.set(y.id,y.status);return r!=null&&r.self&&d.set(r.self.id,r.self.status),d},[r]),fn=a.useMemo(()=>new Map(Ot.map(d=>[kt(d),d])),[Ot]),zt=a.useMemo(()=>{const d=new Map;for(const y of(r==null?void 0:r.nodes)??[])y.status!=="offline"&&d.set(y.id,y);return r!=null&&r.self&&r.self.status!=="offline"&&d.set(r.self.id,r.self),Array.from(d.values())},[r]),gn=((Kt=r==null?void 0:r.self)==null?void 0:Kt.id)??((Wt=zt[0])==null?void 0:Wt.id)??null,zs=a.useMemo(()=>["all",...Array.from(new Set(v.map(d=>d.type))).sort()],[v]),bn=a.useMemo(()=>te==="all"?v:v.filter(d=>d.type===te),[v,te]),vn=Ke.length>0&&Ke.every(d=>Oe.has(d.id)),jn=Ke.some(d=>Oe.has(d.id)),Nn=pi(Ke,Oe);a.useEffect(()=>{u!=null&&u.draftNewTask&&(re(!0),C({route:u.returnRoute??"/",taskId:u.returnTaskId??null}))},[u]),a.useEffect(()=>{te!=="all"&&!zs.includes(te)&&k("all")},[te,zs]),a.useEffect(()=>{ca(s,K)&&!w&&qe&&_(qe)},[s,K,w,qe]),a.useEffect(()=>{ca(s,K)&&(w&&Ye.some(d=>d.id===w)||_(qe))},[s,K,w,qe,Ye]);const le=ui({routeTaskId:s,creatingTask:K,internalSelectedTaskId:w,sortedTaskIds:qe?[qe]:[]}),us=a.useMemo(()=>Ye.find(d=>d.id===le)??null,[Ye,le]);a.useEffect(()=>{be.current=le??null},[le]);const ss=a.useCallback(()=>{ve(null),Ae([]),Q([]),Ge(null),Ce(!1)},[]),js=a.useCallback((d,y,R=!0)=>{Le.current.set(d,{logs:ln(y),loaded:R})},[]),ze=a.useCallback(async()=>{const d=le;if(d)try{const y=await eo(d);if(be.current!==d)return;ve(y),Ge(null)}catch(y){if(be.current!==d)return;ss(),Ge(y instanceof Error?y.message:"Failed to load task")}finally{be.current===d&&je(!1)}},[le,ss]),Ds=a.useCallback(async()=>{const d=le;if(d)try{const y=await mt(d);if(be.current!==d)return;Ae(R=>{const he=Ua(R,y.logs);return js(d,he),he}),Q(R=>ht(R,y.logs))}catch{}finally{be.current===d&&Ce(!1)}},[le,js]);a.useEffect(()=>{if(!le){ss(),je(!1);return}W("transcript"),ve(us);const d=Ol(le,Le.current);Ae(d.logs),Q([]),Ge(null),je(!0),Ce(d.transcriptLoading),ze(),Ds()},[le,ss,Ds,ze]),a.useEffect(()=>{if(!le||K||Is||Ye.some(y=>y.id===le))return;const d=qe;_(d),ss(),a.startTransition(()=>{n(d?`/tasks/${d}`:"/",{state:null})})},[le,ss,K,qe,n,Ye,Is]),a.useEffect(()=>{us&&ve(d=>!d||d.id!==us.id?d:{...d,...us})},[us]),a.useEffect(()=>{if(le)return N("task",d=>{const y=d.data.taskId;if(!(typeof y!="string"||y!==le)){if(d.type==="task.output"){const R=d.data.event;if(R){Ae(oe=>{const ws=go(oe,R);return js(le,ws),ws}),Ce(!1);const he=ia(R);he&&Q(oe=>bo(oe,he))}}d.type==="task.updated"&&ze(),d.type==="task.status"&&(ze(),Ds())}})},[N,le,ze,Ds]);const G=Me??us,wn=G!=null&&G.assignedTo?(r==null?void 0:r.nodes.find(d=>d.id===G.assignedTo))??null:null,Ns=o==null?void 0:o.setHeaderTaskContext;a.useEffect(()=>{if(!Ns)return;if(!G){Ns(null);return}const d=G.effectiveProjectPath??G.project??"default workspace";return Ns({taskId:G.id,taskTitle:G.title,nodeName:tt(G.assignedTo,r==null?void 0:r.nodes,G.assignedNodeName),projectLabel:$a(d),projectPath:d}),()=>Ns(null)},[G,r==null?void 0:r.nodes,Ns]);const Vs=Je.length>0,yn=G?so.has(G.agent):!1,Us=(G==null?void 0:G.status)==="running",kn=G?Rs.has(G.status):!1,Sn=G?Rs.has(G.status)||to.has(G.status):!1,Cn=!!(G&&we&&G.status==="failed"),Hs=a.useMemo(()=>Sl(G,r,Vs,!!Us),[G,r,Vs,Us]),qs=a.useMemo(()=>vo([...$e,...Je.map(d=>Xs(d.content,d.timestamp))]),[$e,Je]),Es=a.useMemo(()=>{if(!G||G.conversationKind==="nativeSession")return null;const d=jo(G);if(d.length>0)return Xs(d,new Date(G.createdAt).toISOString());if(qs.length>0)return null;const y=No(G.description||G.title);return y.length>0?Xs(y,new Date(G.createdAt).toISOString()):null},[G,qs]),Ks=a.useMemo(()=>Es?ia(Es):null,[Es]),_n=a.useMemo(()=>Ks?wo($e,Ks):!1,[$e,Ks]),Ws=a.useCallback((d="chat")=>{const y={route:s?`/tasks/${s}`:"/",taskId:le};C(y),p(d),re(!0),a.startTransition(()=>{n("/",{state:{draftNewTask:!0,returnRoute:y.route,returnTaskId:y.taskId,createMode:d}})})},[s,le,n]),Dn=a.useCallback(()=>{const d=(F==null?void 0:F.taskId)??qe;re(!1),C(null),_(d),a.startTransition(()=>{n((F==null?void 0:F.route)??"/",{state:null})})},[F,qe,n]),Vt=a.useCallback(d=>{re(!1),C(null),_(d),a.startTransition(()=>{n(`/tasks/${d}`,{state:null})})},[n]),En=a.useCallback(d=>{be.current=d.id,re(!1),C(null),Ft(y=>mi(y,d)),ve(d),Ae([]),Q([]),Ge(null),je(!1),Ce(d.conversationKind==="nativeSession"),W("transcript"),_(d.id),Vl({task:d,getActiveTaskId:()=>be.current,setLogs:Ae,setPendingMessages:Q,setTranscriptLoading:Ce}),Ie(),a.startTransition(()=>{n(`/tasks/${d.id}`,{state:null})})},[Ie,n]),{cancelQueuedMessage:Tn,queueFollowUpMessage:Ts}=Yl({activeTaskId:le,fetchActiveTask:ze,setPendingMessages:Q,setTask:ve,setTasks:Ft}),Mn=a.useCallback(d=>{Ts(d)},[Ts]),An=a.useCallback(async()=>{const d=le;if(!(!d||(G==null?void 0:G.conversationKind)!=="nativeSession")){Ce(!0);try{const y=await mt(d);if(be.current!==d)return;Ae(y.logs),js(d,y.logs),Q(R=>ht(R,y.logs))}catch(y){ae.error(y instanceof Error?y.message:"Failed to reload transcript")}finally{be.current===d&&Ce(!1)}}},[G==null?void 0:G.conversationKind,le,js]),Ln=a.useCallback(d=>Ts(d),[Ts]),Pn=a.useCallback(async()=>{if(G)try{await ao(G.id),ze(),Ie()}catch(d){ae.error(d instanceof Error?d.message:"Failed to cancel task")}},[G,ze,Ie]),{handleShareTask:Bn,handleStopShareTask:Rn}=El(G,ze,Ie),$n=a.useCallback(async()=>{if(G)try{await no(G.id),ze(),Ie()}catch(d){ae.error(d instanceof Error?d.message:"Failed to retry task")}},[G,ze,Ie]),Ms=a.useCallback((d,y=!1)=>{const R=fi(Ke,d);return _(R),(y||!R)&&ss(),a.startTransition(()=>{n(R?`/tasks/${R}`:"/",{state:null})}),R},[ss,Ke,n]),On=a.useCallback((d,y)=>{Ve(R=>{const he=new Set(R);return y?he.add(d):he.delete(d),he})},[]),Fn=a.useCallback(d=>{if(!d){Ve(new Set);return}Ve(new Set(Ke.map(y=>y.id)))},[Ke]),In=a.useCallback(async()=>{const d=Array.from(Oe);if(d.length!==0)try{const{results:y}=await ro(d),R=y.filter(oe=>!oe.ok),he=y.filter(oe=>oe.ok).map(oe=>oe.id);le&&he.includes(le)&&Ms(he),R.length>0?ae.error(`Failed to archive ${R.length} task(s): ${R.map(oe=>oe.error??oe.id).join(", ")}`):ae.success(`Archived ${he.length} task(s)`),Ve(new Set(R.map(oe=>oe.id))),Ie()}catch(y){ae.error(y instanceof Error?y.message:"Failed to archive tasks")}},[le,Ie,Ms,Oe]),zn=a.useCallback(async()=>{const d=Array.from(Oe);if(d.length!==0)try{const{results:y}=await oo(d),R=y.filter(oe=>!oe.ok),he=y.filter(oe=>oe.ok).map(oe=>oe.id);le&&he.includes(le)&&Ms(he,!0),R.length>0?ae.error(`Failed to delete ${R.length} task(s): ${R.map(oe=>oe.error??oe.id).join(", ")}`):ae.success(`Deleted ${he.length} task(s)`),Ve(new Set(R.map(oe=>oe.id))),Ie()}catch(y){ae.error(y instanceof Error?y.message:"Failed to delete tasks")}},[le,Ie,Ms,Oe]),Vn=a.useCallback(async()=>{ge(!0);try{await io(),b()}catch(d){ae.error(d instanceof Error?d.message:"Failed to promote node")}finally{ge(!1)}},[b]),Un=a.useCallback(async()=>{Ee(!0);try{await lo(),ae.success("This node left the remote cluster and is leading itself again."),Ie(),ze(),b()}catch(d){ae.error(d instanceof Error?d.message:"Failed to leave cluster")}finally{Ee(!1)}},[ze,Ie,b]),Hn=a.useCallback(async d=>{var ws;const y=!Bt(d),R=d.id===((ws=r==null?void 0:r.self)==null?void 0:ws.id),he=R?(i==null?void 0:i.transportType)??d.transportType:d.transportType,oe=R&&!y&&bs(he);is(d.id);try{oe?await co("direct"):await uo(d.id,y),ae.success(y?`Enabled remote access on ${d.name}`:`Disabled remote access on ${d.name}`),b()}catch(Yt){ae.error(Yt instanceof Error?Yt.message:"Failed to update remote access")}finally{is(null)}},[(Gt=r==null?void 0:r.self)==null?void 0:Gt.id,b,i==null?void 0:i.transportType]),qn=a.useCallback(d=>{Fs&&Fs(d).catch(y=>{ae.error(y instanceof Error?y.message:"Failed to load completed tasks")})},[Fs]),Ut={toolbarTasks:Ke,activeTaskId:le,tasksLoading:Is,tasksError:cn,isLeader:we,scope:x,agentFilter:c,nodeFilter:S,taskKindFilter:A,agentOptions:mn,nodeOptions:xn,nodeNameById:It,nodeWorkDirById:hn,nodeStatusById:pn,leaderNodeId:((Qt=r==null?void 0:r.leader)==null?void 0:Qt.id)??null,searchQuery:U,completedGroupByKey:fn,devBoxNodeIds:_e,devBoxStartNodeIds:Qe,devBoxStartingNodeIds:vs,selectedTaskIds:Oe,allVisibleTasksSelected:vn,someVisibleTasksSelected:jn,canBatchArchive:Nn,onSearchChange:M,onScopeChange:h,onAgentFilterChange:j,onNodeFilterChange:I,onTaskKindFilterChange:B,onToggleTaskSelected:On,onToggleAllVisibleTasks:Fn,onBatchArchive:In,onBatchDelete:zn,onCreateTask:Ws,onOpenNodeSettings:we?ds:void 0,onOpenDevBox:we?_s:void 0,onStartDevBox:we?cs:void 0,onLoadCompletedTasks:qn,onSelectTask:Vt,onClose:q},Kn={cluster:r,systemInfo:i,nodeNameById:It,nodeBlockingTaskCounts:un,eventTypeFilter:te,onEventTypeFilterChange:k,eventTypeOptions:zs,filteredEvents:bn,sseConnected:g,clusterLoading:f,clusterError:l,promotePending:D,onPromote:Vn,onAddNode:()=>m(!0),leavePending:ue,onLeaveCluster:Un,onToggleNodeDevTunnel:Hn,devTunnelNodeId:Fe,devBoxStartNodeId:ie,devBoxStartingNodeIds:vs,onOpenNodeSettings:we?ds:void 0,onOpenDevBox:we?_s:void 0,onStartDevBox:we?cs:void 0,onClose:()=>J(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(dl,{desktopTasksOpen:E,mobileTasksPanelOpen:X,mobileTasksPanelRef:H,operationsOpen:Y,operationsPanelRef:de,panelResize:ne,taskSidebar:e.jsx(ja,{...Ut}),operationsSidecar:e.jsx(yl,{...Kn}),terminalPanel:o!=null&&o.terminalOpen?e.jsx(gl,{nodes:zt,defaultNodeId:gn,onClose:()=>o==null?void 0:o.setTerminalOpen(!1)}):void 0,conversationPanel:e.jsx(rl,{onToggleTasks:q,desktopTasksOpen:E,mobileTasksPanelOpen:X,operationsOpen:Y,onToggleOperations:()=>J(d=>!d),cluster:r,sseConnected:g,activeTab:P,setActiveTab:W,creatingTask:K,createMode:me,activeTask:G,assignedNode:wn,taskLoading:fe,transcriptLoading:es,taskError:pe,displayEvents:qs,initialPromptAlreadyInLogs:_n,initialPrompt:Es,supportsFollowUp:yn,taskUnavailable:Hs.taskUnavailable,chatDisabled:Hs.chatDisabled,chatDisabledReason:Hs.chatDisabledReason,questionBypassEnabled:z,isRunning:!!Us,isStarting:kn,hasPendingFollowUp:Vs,canCancel:!!Sn,canRetry:!!Cn,onRetry:$n,onCancel:Pn,onReloadNativeTranscript:An,onShareTask:Bn,onStopShareTask:Rn,onStartCreateTask:Ws,onCancelCreateTask:Dn,onCreateTask:En,onSendMessage:Mn,onCancelQueuedMessage:Tn,onQuestionBypassChange:ee,onSubmitQuestionResponse:Ln}),mobileTaskSidebar:e.jsx(ja,{...Ut,onCreateTask:d=>{Z(!1),Ws(d)},onSelectTask:d=>{Z(!1),Vt(d)},onClose:()=>Z(!1)}),onCloseOperations:()=>J(!1),onCloseTaskList:()=>Z(!1)}),e.jsx(ll,{open:se,onOpenChange:m,onAdded:b}),Ze,Pe]})}const sd=Object.freeze(Object.defineProperty({__proto__:null,DashboardPage:Xl},Symbol.toStringTag,{value:"Module"}));export{sd as D,pt as G};
|