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