meshy-node 0.10.9 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dashboard/assets/DashboardPage-kK0-et4p.js +211 -0
- package/dashboard/assets/{DashboardShared-CrDF53oL.js → DashboardShared-B-MhNC7V.js} +23 -23
- package/dashboard/assets/{DiffTab-CNBS3yRm.js → DiffTab-xXmdkadb.js} +2 -2
- package/dashboard/assets/{FilesTab-BHeht0ZL.js → FilesTab-tVrm_BOK.js} +2 -2
- package/dashboard/assets/{MarkdownPreviewFrame-L2oxne--.js → MarkdownPreviewFrame-Bh67Y-4b.js} +1 -1
- package/dashboard/assets/{PreviewTab-UMpaLVaV.js → PreviewTab-kRFQ5bQf.js} +2 -2
- package/dashboard/assets/SharedConversationPage-CYSWbDBC.js +2 -0
- package/dashboard/assets/{file-BgR9-rpB.js → file-eGew3MDA.js} +1 -1
- package/dashboard/assets/index-DJ824ClY.css +1 -0
- package/dashboard/assets/index-rujLgCBM.js +326 -0
- package/dashboard/index.html +2 -2
- package/main.cjs +882 -772
- package/package.json +1 -1
- package/runtime-metadata.json +4 -4
- package/dashboard/assets/DashboardPage-bZy6ZY6K.js +0 -181
- package/dashboard/assets/SharedConversationPage-CTyYVCbw.js +0 -2
- package/dashboard/assets/index-By1kKB26.css +0 -1
- package/dashboard/assets/index-D260dUEm.js +0 -346
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-BHeht0ZL.js","assets/index-D260dUEm.js","assets/index-By1kKB26.css","assets/MarkdownPreviewFrame-L2oxne--.js","assets/DashboardShared-CrDF53oL.js","assets/file-BgR9-rpB.js","assets/PreviewTab-UMpaLVaV.js","assets/DiffTab-CNBS3yRm.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{c as he,r as o,a as Es,f as Ua,m as $a,j as e,X as it,Q as Dn,B as Z,L as me,S as Ha,b as Hi,d as O,e as Vi,g as Ki,h as Gi,I as ft,P as Wi,C as us,i as Qi,k as Va,F as Yi,l as Kt,n as lt,o as Le,D as ms,p as Ji,q as Zi,t as de,s as Be,u as Oe,v as Ge,w as Fe,x as Ka,y as st,T as Xi,z as el,A as ys,E as tl,G as At,H as Mt,J as Rt,K as Ga,M as Wa,N as hs,O as Gn,R as sl,U as Pt,V as nl,W as _n,Y as rl,Z as al,_ as Wn,$ as Qa,a0 as ol,a1 as Ye,a2 as il,a3 as bt,a4 as ss,a5 as ns,a6 as rs,a7 as as,a8 as os,a9 as is,aa as ls,ab as cs,ac as Qn,ad as ll,ae as xs,af as Ya,ag as cl,ah as xr,ai as Pn,aj as Qs,ak as dl,al as ul,am as ml,an as fl,ao as hl,ap as xl,aq as Ja,ar as ps,as as Za,at as pl,au as gl,av as Ls,aw as bl,ax as Xa,ay as vl,az as wl,aA as yl,aB as eo,aC as Yn,aD as to,aE as Nl,aF as As,aG as jl,aH as pr,aI as Jn,aJ as kl,aK as Sl,aL as Cl,aM as Tl,aN as so,aO as fs,aP as El,aQ as In,aR as no,aS as Al,aT as Ml,aU as Dl,aV as _l,aW as gr,aX as Pl,aY as Il,aZ as Ys,a_ as Rl,a$ as br,b0 as Ll,b1 as Bl,b2 as Ol,b3 as vr,b4 as Fl,b5 as zl,b6 as Rn,b7 as ql,b8 as Ul,b9 as ro,ba as wr,bb as ao,bc as $l,bd as yr,be as Hl,bf as Vl,bg as Kl,bh as Gl,bi as Wl,bj as Ql,bk as Yl,bl as Jl,bm as Zl,bn as Xl,bo as ec,bp as tc,bq as sc,br as nc,bs as rc,bt as ac,bu as oc,bv as ic,bw as lc,bx as cc,by as dc,bz as uc,bA as mc,bB as fc,bC as hc,bD as xc,bE as pc,bF as gc,bG as bc,bH as vc,bI as wc}from"./index-D260dUEm.js";import{r as Nr,e as yc,b as oo,g as io,a as vt,A as wt,I as Zn,c as lo,T as co,d as Nc,i as uo,f as jc,p as mo,h as kc,j as jr,k as kr,l as Sc,m as Cc,n as Tc,C as Sr,o as Js,q as Xn,D as qt,s as ot,M as Ln,L as Ec,t as Ac,u as Mc,v as fo,w as Bn,x as Dc,y as Zs,z as _c,B as Pc,E as Ic}from"./DashboardShared-CrDF53oL.js";import{E as Rc,M as Lc}from"./MarkdownPreviewFrame-L2oxne--.js";import{P as Bs,D as Ns,g as Bc,a as Oc,b as Fc}from"./PreviewTab-UMpaLVaV.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 zc=[["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"}]],qc=he("archive",zc);/**
|
|
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 Uc=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Cr=he("arrow-right",Uc);/**
|
|
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 $c=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],ho=he("arrow-up",$c);/**
|
|
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 Hc=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],xo=he("at-sign",Hc);/**
|
|
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 Vc=[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]],po=he("brain-circuit",Vc);/**
|
|
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 Kc=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Ms=he("chevron-left",Kc);/**
|
|
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 Gc=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],Tr=he("clock",Gc);/**
|
|
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 Wc=[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Qc=he("earth",Wc);/**
|
|
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 Yc=[["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"}]],Jc=he("ellipsis-vertical",Yc);/**
|
|
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 Zc=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],Xc=he("ellipsis",Zc);/**
|
|
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 ed=[["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"}]],Os=he("folder-open",ed);/**
|
|
58
|
-
* @license lucide-react v1.7.0 - ISC
|
|
59
|
-
*
|
|
60
|
-
* This source code is licensed under the ISC license.
|
|
61
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
62
|
-
*/const td=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],sd=he("funnel",td);/**
|
|
63
|
-
* @license lucide-react v1.7.0 - ISC
|
|
64
|
-
*
|
|
65
|
-
* This source code is licensed under the ISC license.
|
|
66
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
67
|
-
*/const nd=[["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"}]],Ds=he("git-branch",nd);/**
|
|
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 rd=[["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"}]],ad=he("globe",rd);/**
|
|
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 od=[["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"}]],_s=he("history",od);/**
|
|
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 id=[["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"}]],On=he("image-plus",id);/**
|
|
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 ld=[["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"}]],cd=he("laptop",ld);/**
|
|
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 dd=[["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"}]],er=he("link-2",dd);/**
|
|
93
|
-
* @license lucide-react v1.7.0 - ISC
|
|
94
|
-
*
|
|
95
|
-
* This source code is licensed under the ISC license.
|
|
96
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
97
|
-
*/const ud=[["path",{d:"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"}]],md=he("list-ordered",ud);/**
|
|
98
|
-
* @license lucide-react v1.7.0 - ISC
|
|
99
|
-
*
|
|
100
|
-
* This source code is licensed under the ISC license.
|
|
101
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
102
|
-
*/const fd=[["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"}]],Fs=he("message-square-plus",fd);/**
|
|
103
|
-
* @license lucide-react v1.7.0 - ISC
|
|
104
|
-
*
|
|
105
|
-
* This source code is licensed under the ISC license.
|
|
106
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
107
|
-
*/const hd=[["path",{d:"M15.033 9.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56V7.648a.645.645 0 0 1 .967-.56z",key:"vbtd3f"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",key:"x3v2xh"}]],go=he("monitor-play",hd);/**
|
|
108
|
-
* @license lucide-react v1.7.0 - ISC
|
|
109
|
-
*
|
|
110
|
-
* This source code is licensed under the ISC license.
|
|
111
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
112
|
-
*/const xd=[["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"}]],Gt=he("pencil",xd);/**
|
|
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 pd=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],bo=he("qr-code",pd);/**
|
|
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 gd=[["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"}]],bd=he("rotate-ccw",gd);/**
|
|
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 vd=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],vo=he("rotate-cw",vd);/**
|
|
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 wd=[["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"}]],wo=he("send",wd);/**
|
|
133
|
-
* @license lucide-react v1.7.0 - ISC
|
|
134
|
-
*
|
|
135
|
-
* This source code is licensed under the ISC license.
|
|
136
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
137
|
-
*/const yd=[["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"}]],Ps=he("share-2",yd);/**
|
|
138
|
-
* @license lucide-react v1.7.0 - ISC
|
|
139
|
-
*
|
|
140
|
-
* This source code is licensed under the ISC license.
|
|
141
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
142
|
-
*/const Nd=[["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"}]],jd=he("sliders-horizontal",Nd);/**
|
|
143
|
-
* @license lucide-react v1.7.0 - ISC
|
|
144
|
-
*
|
|
145
|
-
* This source code is licensed under the ISC license.
|
|
146
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
147
|
-
*/const kd=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Er=he("square",kd);/**
|
|
148
|
-
* @license lucide-react v1.7.0 - ISC
|
|
149
|
-
*
|
|
150
|
-
* This source code is licensed under the ISC license.
|
|
151
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
152
|
-
*/const Sd=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Xs=he("triangle-alert",Sd);/**
|
|
153
|
-
* @license lucide-react v1.7.0 - ISC
|
|
154
|
-
*
|
|
155
|
-
* This source code is licensed under the ISC license.
|
|
156
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
157
|
-
*/const Cd=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],Td=he("user-plus",Cd);/**
|
|
158
|
-
* @license lucide-react v1.7.0 - ISC
|
|
159
|
-
*
|
|
160
|
-
* This source code is licensed under the ISC license.
|
|
161
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
162
|
-
*/const Ed=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],Ad=he("wifi",Ed);/**
|
|
163
|
-
* @license lucide-react v1.7.0 - ISC
|
|
164
|
-
*
|
|
165
|
-
* This source code is licensed under the ISC license.
|
|
166
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
167
|
-
*/const Md=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Dd=he("zoom-in",Md);/**
|
|
168
|
-
* @license lucide-react v1.7.0 - ISC
|
|
169
|
-
*
|
|
170
|
-
* This source code is licensed under the ISC license.
|
|
171
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
172
|
-
*/const _d=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Pd=he("zoom-out",_d),Id=new Set(["assigned","running"]);function Rd(t,s){return t.reduce((n,r)=>r.assignedTo===s&&Id.has(r.status)?n+1:n,0)}function Wt(t){return t?.toLowerCase()==="devtunnel"}function Ld(t){return t?Wt(t)?"DevTunnel":t.charAt(0).toUpperCase()+t.slice(1):"Direct"}function tr(t,s){return Wt(s??t.transportType)||!!t.devtunnelEndpoint}function yo(t,s){return!Wt(s??t.transportType)}function No(t,s){const n=s??t.transportType;return Wt(n)?"DevTunnel":t.devtunnelEndpoint?"Direct + DevTunnel":Ld(n)}function Ar(t,s){return!t&&!s}function Bd({routeTaskId:t,creatingTask:s,internalSelectedTaskId:n,sortedTaskIds:r}){return t||(s?null:r[0]??n??null)}function Od({activeTaskId:t,routeTaskId:s,creatingTask:n,tasksLoading:r,loadedTaskIds:a}){return!t||s||n||r?!1:!a.includes(t)}function Fd(t,s){return[s,...t.filter(n=>n.id!==s.id)]}function jo(t,s){const n=t.findIndex(r=>r.id===s.id);return n===-1?[...t,s]:t.map((r,a)=>a===n?s:r)}const zd=new Set(["completed","failed","cancelled","archived"]);function qd(t,s){const n=new Set(s);return new Set(Array.from(t).filter(r=>n.has(r)))}function Ud(t,s){const n=new Set(s);if(n.size===0)return!1;const r=t.filter(a=>n.has(a.id));return r.length===n.size&&r.every(a=>zd.has(a.status))}function $d(t,s){const n=new Set(s);return t.find(r=>!n.has(r.id))?.id??null}function ko(){const[t,s]=o.useState([]),[n,r]=o.useState(null),a=o.useRef(null),i=o.useCallback(()=>{a.current?.click()},[]),l=o.useCallback(async g=>{const u=Array.from(g.target.files??[]);if(u.length!==0)try{const f=await Nr(u);s(x=>[...x,...f]),r(null)}catch(f){r(f instanceof Error?f.message:"Failed to attach image")}finally{g.target.value=""}},[]),c=o.useCallback(async g=>{const u=yc(g.clipboardData);if(u.length!==0){g.preventDefault();try{const f=await Nr(u);s(x=>[...x,...f]),r(null)}catch(f){r(f instanceof Error?f.message:"Failed to attach image")}}},[]),d=o.useCallback(g=>{s(u=>u.filter((f,x)=>x!==g))},[]),m=o.useCallback(()=>{s([]),r(null)},[]);return{images:t,error:n,fileInputRef:a,pickImages:i,handleFileChange:l,handlePaste:c,removeImage:d,clearImages:m}}function Hd({disabled:t=!1,running:s=!1,canStop:n=!1,hasContent:r=!1}){return s&&(!r||n&&t)?{primaryAction:"stop",primaryDisabled:!n}:{primaryAction:"send",primaryDisabled:t||!r}}function Vd({contentLength:t,disabled:s=!1}){return t>0&&!s}const Kd=/^[a-zA-Z0-9_-]+$/,So=/[a-zA-Z0-9_-]/,Gd=176;function Wd(t){const s=t.map(a=>({...a,displayValue:Qd(a)})),n=s.findIndex(a=>a.label.toLowerCase()==="working dir"),r=n>=0?n:0;return{primary:s[r],secondary:s.filter((a,i)=>i!==r)}}function Qd(t){return t.label.toLowerCase()==="agent"?vt(t.value):t.value}function Mr(t){switch(t.toLowerCase()){case"branch":return Ds;case"node":return Ha;default:return Os}}function Yd(t){return Array.from(new Set(t.map(s=>s.trim()).filter(Boolean)))}function Co(t,s){return Number.isFinite(s)?Math.max(0,Math.min(t.length,Math.trunc(s))):t.length}function Jd(t,s){const n=Co(t,s),a=t.slice(0,n).match(/@([a-zA-Z0-9_-]*)$/);if(!a||a.index===void 0)return;const i=a.index+1,l=t.slice(n).match(/^[a-zA-Z0-9_-]*/),c=n+(l?.[0].length??0),d=t.slice(i,c);if(!(d.length>0&&!Kd.test(d)))return{query:d.toLowerCase(),range:{start:a.index,end:c}}}function Zd(t,s){const n=new Map(s.map(i=>[i.toLowerCase(),i])),r=/@([a-zA-Z0-9_-]+)/g;let a;for(;(a=r.exec(t))!==null;){const i=(a[1]??"").toLowerCase(),l=n.get(i);if(!l)continue;const c=a.index+a[0].length;if(!(c<t.length&&So.test(t[c]??"")))return{targetAgent:l,query:i,range:{start:a.index,end:c}}}}function Fn(t,s){const n=t.slice(0,s.start);let r=t.slice(s.end);return n.length===0?r.trimStart():r.length===0?n.trimEnd():(/\s$/.test(n)&&/^\s/.test(r)?r=r.trimStart():!/\s$/.test(n)&&!/^\s/.test(r)&&(r=" "+r),n+r)}function Dr(t,s,n){const r=Yd(s),a=typeof n=="number",i=Jd(t,a?n:t.length);if(i){const c=r.filter(g=>g.toLowerCase().startsWith(i.query)),d=r.find(g=>g.toLowerCase()===i.query),m=!!d&&(i.range.end===t.length||!So.test(t[i.range.end]??""));return{...m?{targetAgent:d}:{},query:i.query,strippedText:m?Fn(t,i.range):t,matches:c,...a?{mentionRange:i.range}:{}}}const l=Zd(t,r);return l?{targetAgent:l.targetAgent,query:l.query,strippedText:Fn(t,l.range),matches:[l.targetAgent],...a?{mentionRange:l.range}:{}}:{strippedText:t,matches:[]}}function Xd(t,s,n){if(t.length===0)return 0;const r=s?t.indexOf(s):-1;if(r>=0)return r;const a=n?t.indexOf(n):-1;return a>=0?a:0}function eu(t,s){return t.query!==void 0&&t.matches.length>0&&!t.targetAgent&&!s}function tu(t,s){if(!s)return{value:t.replace(/^@[a-zA-Z0-9_-]*\s*/,""),cursorPosition:0};const n=Fn(t,s);return{value:n,cursorPosition:Math.min(s.start,n.length)}}function su(t,s){const n=window.getComputedStyle(t);["boxSizing","width","fontFamily","fontSize","fontWeight","fontStyle","letterSpacing","textTransform","wordSpacing","textIndent","lineHeight","paddingTop","paddingRight","paddingBottom","paddingLeft","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth"].forEach(a=>{s.style[a]=n[a]})}function nu(t,s){if(typeof window>"u")return;const n=t.ownerDocument,r=n.createElement("div"),a=n.createElement("span"),i=Co(t.value,s);su(t,r),r.style.position="absolute",r.style.visibility="hidden",r.style.whiteSpace="pre-wrap",r.style.overflowWrap="break-word",r.style.overflow="hidden",r.style.top="0",r.style.left="-9999px",r.style.height="auto",r.textContent=t.value.slice(0,i),a.textContent="",r.appendChild(a),n.body.appendChild(r);const l={left:a.offsetLeft-t.scrollLeft,top:a.offsetTop-t.scrollTop};return r.remove(),l}function ru({cardClientWidth:t,cardRectWidth:s}){const n=s/t;return Number.isFinite(n)&&n>0?n:1}function au({boundaryRectBottom:t,boundaryRectTop:s,cardRectTop:n,cardWidth:r,caretLeft:a,caretTop:i,cssZoom:l=1,lineHeight:c,matchCount:d,textareaOffsetLeft:m,textareaOffsetTop:g,viewportHeight:u}){const f=Number.isFinite(l)&&l>0?l:1,x=Math.min(Math.max(d,1)*28+4,220),N=x*f,b=m/f,T=g/f,p=s??0,k=t??u,y=Math.max(8,r-Gd-8),h=Math.max(8,Math.min(b+a,y)),v=T+i+c+4,j=n+v*f,E=T+i-x-4,R=n+(T+i)*f,A=k-j-8,L=R-p-8,M=Math.max(8,(p-n+8)/f);if(A<N&&L>A)return{left:h,top:Math.max(M,E)};const D=Math.max(M,(k-n-N-8)/f);return{left:h,top:Math.max(M,Math.min(v,D))}}function ou(t,s,n){const r=t.closest('[data-chat-input-card="true"]'),a=nu(t,s);if(!r||!a)return;const i=t.getBoundingClientRect(),l=r.getBoundingClientRect(),c=r.closest(".dashboard-conversation-panel")?.getBoundingClientRect(),d=Number.parseFloat(window.getComputedStyle(t).lineHeight)||18;return au({boundaryRectBottom:c?.bottom,boundaryRectTop:c?.top,cardRectTop:l.top,cardWidth:r.clientWidth,caretLeft:a.left,caretTop:a.top,cssZoom:ru({cardRectWidth:l.width,cardClientWidth:r.clientWidth}),lineHeight:d,matchCount:n,textareaOffsetLeft:i.left-l.left,textareaOffsetTop:i.top-l.top,viewportHeight:window.innerHeight})}function iu({onSend:t,disabled:s,disabledReason:n="Chat is waiting on the agent.",placeholder:r="Send a follow-up message...",contextItems:a=[],agent:i,currentAgent:l,taskId:c,model:d,availableAgents:m=[],selectedTargetAgent:g,onTargetAgentChange:u,running:f=!1,onStop:x,quickChats:N=[]}){const[b,T]=o.useState(""),[p,k]=o.useState(),[y,h]=o.useState(c),[v,j]=o.useState(),[E,R]=o.useState(),[A,L]=o.useState(!1),[M,D]=o.useState(0),[P,F]=o.useState(0),[Q,re]=o.useState(0),W=o.useRef(null),ee=o.useRef(void 0),{images:se,error:q,fileInputRef:X,pickImages:w,handleFileChange:K,handlePaste:C,removeImage:Y,clearImages:I}=ko();c!==y&&(h(c),k(void 0));const U=o.useCallback((H=W.current)=>{H&&D(H.selectionStart??H.value.length)},[]),B=o.useCallback((H=M,xe=1)=>{W.current&&R(ou(W.current,H,xe))},[M]),le=o.useCallback(()=>{W.current&&(W.current.style.height="auto")},[]),oe=o.useCallback(()=>{W.current&&(W.current.style.height="auto",W.current.style.height=Math.min(W.current.scrollHeight,220).toString()+"px",U(W.current))},[U]);o.useEffect(()=>{F(0)},[b,N]);const ue=g??p,J=o.useMemo(()=>Dr(b,m,M),[m,M,b]),V=eu(J,A),_=Xd(J.matches,v,l),ne=J.matches[_];o.useEffect(()=>{j(void 0),L(!1)},[l,J.query,J.matches.join("|")]),o.useEffect(()=>{if(!V){R(void 0);return}const H=J.mentionRange?.end??M,xe=()=>B(H,J.matches.length);if(typeof requestAnimationFrame!="function"){xe();return}const be=requestAnimationFrame(xe);return()=>cancelAnimationFrame(be)},[J.matches.length,J.mentionRange?.end,M,V,B]);const $=o.useCallback(H=>{u?u(H):k(H)},[u]),ae=o.useCallback(H=>{T(H.prompt);const xe=()=>{W.current?.focus(),oe()};typeof requestAnimationFrame=="function"?requestAnimationFrame(xe):xe()},[oe]),pe=o.useCallback(()=>{const H=Es(b,N,P);if(H){ae(H);return}const xe=Dr(b,m,M),be=xe.targetAgent??ue,Xe=xe.targetAgent?xe.strippedText:b,Ie=oo(Xe,se);Vd({contentLength:Ie.length,disabled:s})&&(re(ct=>ct+1),t(Ie,be?{targetAgent:be}:void 0),T(""),$(void 0),I(),le())},[b,se,m,M,ue,s,t,$,I,le,N,P,ae]),fe=o.useCallback((H,xe=J.mentionRange)=>{$(H),T(Xe=>{const Ie=tu(Xe,xe);return ee.current=Ie.cursorPosition,D(Ie.cursorPosition),Ie.value});const be=()=>{W.current?.focus(),ee.current!==void 0&&(W.current?.setSelectionRange(ee.current,ee.current),ee.current=void 0),oe()};typeof requestAnimationFrame=="function"?requestAnimationFrame(be):be()},[oe,J.mentionRange,$]),Ve=o.useCallback(H=>{if(V&&H.key==="Escape"){H.preventDefault(),L(!0);return}if(V&&(H.key==="ArrowDown"||H.key==="ArrowUp")){H.preventDefault();const be=J.matches.length;if(be===0)return;const Xe=H.key==="ArrowDown"?1:-1,Ie=(_+Xe+be)%be;j(J.matches[Ie]);return}if(V&&H.key==="Enter"&&!H.shiftKey&&ne){H.preventDefault(),fe(ne,J.mentionRange);return}const xe=Ua(b,N);if(xe.length>0&&(H.key==="ArrowDown"||H.key==="ArrowUp")){H.preventDefault(),F(be=>$a(be,xe.length,H.key==="ArrowDown"?1:-1));return}if(H.key==="Enter"&&!H.shiftKey){H.preventDefault();const be=Es(b,N,P);be?ae(be):pe()}},[fe,ae,pe,J.matches,J.mentionRange,N,P,ne,_,V,b]),je=b.trim().length>0||se.length>0,De=Hd({disabled:s,running:f,canStop:f&&!!x,hasContent:je}),Me=Wd(a),Te=Me.primary?Mr(Me.primary.label):Os,Ee=i?io(i,d):null,Pe=l?vt(l):null,Ue=s?n:f?je?"Enter queues this message for the next turn":x?"Task is running - type to queue, empty button stops task":"Task is running - type to queue a message":"Enter sends, Shift+Enter adds a line";return e.jsx("div",{"data-chat-input-shell":"true",className:"chat-input-shell animate-composer-settle w-full bg-background/35 px-2 pb-2 pt-0 sm:px-4 sm:pb-3",children:e.jsx("div",{"data-chat-input-column":"true",className:"mx-auto w-full max-w-[72rem]",children:e.jsxs("div",{"data-chat-input-card":"true",className:"chat-input-card relative overflow-visible rounded-xl border border-border/65 bg-card/88 transition-[border-color,box-shadow] duration-200 focus-within:border-primary/50 focus-within:ring-2 focus-within:ring-primary/15 sm:rounded-xl",children:[e.jsx("input",{ref:X,type:"file",accept:"image/*",multiple:!0,onChange:K,className:"hidden"}),l&&Pe&&e.jsxs("span",{"data-current-agent":l,title:`Active agent: ${Pe}`,className:"absolute right-2 top-1.5 z-10 inline-flex h-4 max-w-[8.5rem] items-center gap-1 rounded-sm bg-primary/12 px-1.5 text-[8px] font-medium leading-3 text-primary sm:right-4 sm:top-2",children:[e.jsx(wt,{agent:l,className:"h-2.5 w-2.5 shrink-0 text-primary/75"}),e.jsx("span",{className:"truncate",children:Pe})]}),Me.primary&&e.jsx("div",{"data-chat-input-primary-context":"true",className:`px-2.5 pt-1.5 sm:px-5 sm:pt-2 ${l?"pr-24 sm:pr-32":""}`,children:e.jsxs("div",{className:"-ml-1.5 inline-flex max-w-full items-center gap-1.5 rounded-sm bg-muted/45 px-1.5 py-0.5 shadow-[0_10px_28px_-18px_rgba(15,23,42,0.72)] sm:-ml-2 dark:shadow-[0_10px_28px_-18px_rgba(0,0,0,0.95)]",children:[e.jsx(Te,{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:Me.primary.value,children:Me.primary.displayValue})]})}),se.length>0&&e.jsx("div",{className:"px-2 pt-2.5 sm:px-5 sm:pt-4",children:e.jsx("div",{className:"flex flex-wrap gap-3",children:se.map((H,xe)=>e.jsxs("div",{className:"relative",children:[e.jsx(Zn,{image:H,alt:H.filename??`attachment ${xe+1}`,thumbnailClassName:"h-24 w-24 border border-border/70",imageClassName:"h-full w-full"}),e.jsx("button",{type:"button",onClick:()=>Y(xe),className:"absolute -right-1.5 -top-1.5 flex h-5 w-5 items-center justify-center rounded-sm border border-border/70 bg-background text-muted-foreground shadow-sm transition-all hover:-translate-y-px hover:text-foreground","aria-label":`Remove ${H.filename??`image ${xe+1}`}`,children:e.jsx(it,{className:"h-3 w-3"})})]},`${H.filename??"image"}-${xe}`))})}),e.jsx("div",{className:"px-2 pb-0 pt-1 sm:px-5 sm:pt-1.5",children:e.jsx("textarea",{ref:W,"data-chat-input-textarea":"true",value:b,onChange:H=>{T(H.target.value),U(H.currentTarget)},onKeyDown:Ve,onKeyUp:H=>U(H.currentTarget),onClick:H=>U(H.currentTarget),onSelect:H=>U(H.currentTarget),onScroll:()=>B(M,J.matches.length),onPaste:C,onInput:oe,placeholder:r,disabled:s,rows:1,className:"min-h-[1.35rem] w-full resize-none overflow-x-hidden overflow-y-auto bg-transparent px-0 py-0 text-[11px] leading-[1.35rem] text-foreground placeholder:text-[10px] placeholder:text-muted-foreground/65 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"})}),e.jsx(Dn,{query:b,quickChats:N,selectedIndex:P,onActiveIndexChange:F,onSelect:ae}),V&&e.jsx("div",{"data-agent-mention-menu":"true",className:"absolute z-20 flex w-44 max-w-[calc(100%-1rem)] flex-col overflow-hidden rounded-sm border border-border/60 bg-popover/95 p-0.5 text-popover-foreground shadow-[0_16px_42px_-24px_rgba(0,0,0,0.85)]",style:E?{left:E.left,top:E.top}:{left:8,top:"50%"},children:J.matches.map((H,xe)=>e.jsxs("button",{type:"button",onMouseDown:be=>be.preventDefault(),onMouseEnter:()=>j(H),onClick:()=>fe(H,J.mentionRange),className:["flex h-7 w-full items-center gap-1.5 rounded-sm px-1.5 text-left text-[10px] transition-colors hover:bg-muted/55 hover:text-foreground",xe===_?"bg-primary/10 text-primary":"text-muted-foreground"].join(" "),children:[e.jsx(wt,{agent:H,className:"h-3 w-3 shrink-0 text-primary/60"}),e.jsx("span",{className:"truncate",children:vt(H)})]},H))}),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:[ue||Me.secondary.length>0?e.jsxs("div",{"data-chat-input-secondary-context":"true",className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1 pb-0.5 text-[9px] leading-3 text-muted-foreground/72 sm:text-[9px]",children:[ue&&e.jsxs("span",{"data-chat-input-target-agent":ue,title:`Send to ${vt(ue)}`,className:"inline-flex h-6 max-w-[11rem] items-center gap-1.5 rounded-sm bg-primary/10 px-1.5 text-[10px] leading-3 text-primary",children:[e.jsx(xo,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),e.jsx(wt,{agent:ue,className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:vt(ue)}),e.jsx("button",{type:"button",onClick:()=>$(void 0),className:"-mr-0.5 inline-flex h-4 w-4 items-center justify-center rounded-sm text-primary/70 hover:bg-primary/15 hover:text-primary","aria-label":"Clear target agent",children:e.jsx(it,{className:"h-2.5 w-2.5"})})]}),Me.secondary.map(H=>{const xe=Mr(H.label),be=H.label.toLowerCase()==="agent";return e.jsxs("span",{title:`${H.label}: ${H.value}`,className:"inline-flex min-w-0 max-w-[12rem] items-center gap-1 truncate",children:[be?e.jsx(wt,{agent:H.value,className:"h-2.5 w-2.5 shrink-0 text-primary/50"}):e.jsx(xe,{"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 ${H.mono?"font-mono":""}`,children:H.displayValue})]},`${H.label}:${H.value}`)})]}):e.jsx("div",{className:"min-w-0 flex-1"}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[Ee&&e.jsxs("span",{"data-chat-input-model-display":"true","aria-label":`Model: ${Ee}`,title:`Model: ${Ee}`,className:"inline-flex h-7 max-w-[9rem] shrink-0 items-center gap-1.5 truncate rounded-sm px-2 text-[10px] text-muted-foreground",children:[e.jsx(po,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),Ee]}),e.jsxs(Z,{type:"button",variant:"ghost",onClick:w,disabled:s,className:"h-7 shrink-0 gap-1.5 rounded-sm px-2 text-[10px] text-muted-foreground hover:text-foreground sm:px-2",title:"Attach images",children:[e.jsx(On,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Images"})]}),e.jsx("span",{title:Ue,children:e.jsx(Z,{onClick:De.primaryAction==="stop"?x:pe,disabled:De.primaryDisabled,size:"icon","data-chat-send-button":"true","aria-label":De.primaryAction==="stop"?"Stop running task":f?"Queue message":"Send message",className:"chat-send-button h-7 w-9 shrink-0 rounded-sm bg-primary/90 text-primary-foreground shadow-[0_12px_30px_-18px_hsl(var(--primary)/0.95)] transition-transform duration-150 hover:bg-primary active:scale-95",children:De.primaryAction==="stop"?e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(wo,{className:`h-3.5 w-3.5 ${Q>0?"animate-chat-send-flight":""}`},Q)})})]})]}),q&&e.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-2 py-2 text-[11px] text-destructive sm:px-6 sm:py-3",children:q})]})})})}var lu=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],cu=lu.reduce((t,s)=>{const n=Hi(`Primitive.${s}`),r=o.forwardRef((a,i)=>{const{asChild:l,...c}=a,d=l?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(d,{...c,ref:i})});return r.displayName=`Primitive.${s}`,{...t,[s]:r}},{}),du="Label",To=o.forwardRef((t,s)=>e.jsx(cu.label,{...t,ref:s,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(t.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));To.displayName=du;var Eo=To;const uu=Vi("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ze=o.forwardRef(({className:t,...s},n)=>e.jsx(Eo,{ref:n,className:O(uu(),t),...s}));Ze.displayName=Eo.displayName;function _r({agent:t,query:s,onSelect:n}){const r=lo(t,s);return r?e.jsx("div",{"data-codex-goal-command":"true",className:"mx-2 mb-0.5 rounded-sm bg-background/70 p-0.5 shadow-none sm:mx-5",children:e.jsx("div",{role:"listbox","aria-label":"Codex commands",children:e.jsxs("button",{type:"button",role:"option","aria-selected":"true",onClick:n,className:"flex h-8 w-full min-w-0 items-center gap-2 rounded-sm px-2 text-left transition-colors hover:bg-muted/50 hover:text-foreground",children:[e.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-sm bg-primary/10 text-primary",children:e.jsx(co,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),e.jsx("span",{className:"shrink-0 text-[11px] font-medium text-foreground",children:r.label}),e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:r.description})]})})}):null}function mu(t,s,n){return t!=="auto"?s.find(r=>r.id===t)??null:n.length===1?n[0]??null:null}function fu(t){return t.trim()||"."}function hu(t){return new Promise(s=>window.setTimeout(s,t))}function xu(t){return!!t&&typeof t=="object"&&typeof t.createdBranch=="string"&&typeof t.currentBranch<"u"}async function pu(t){let s=t;for(let n=0;n<60;n++){if(s.status==="succeeded"){if(xu(s.result))return s.result;throw new Error("Branch creation completed without branch details")}if(s.status==="failed")throw new Error(s.error||"Branch creation failed");await hu(1e3),s=await Qi(s.id)}throw new Error("Timed out waiting for branch creation")}function Pr({value:t,onChange:s,project:n,assignTo:r,nodes:a,assignableNodes:i,layout:l="default",chipClassName:c,chipActiveClassName:d,chipInactiveClassName:m,labelClassName:g,triggerClassName:u}){const[f,x]=o.useState(!1),[N,b]=o.useState(null),[T,p]=o.useState(""),[k,y]=o.useState(!1),[h,v]=o.useState(!1),[j,E]=o.useState(!1),[R,A]=o.useState(null),[L,M]=o.useState(""),[D,P]=o.useState(""),[F,Q]=o.useState(""),[re,W]=o.useState(!1),ee=o.useRef(null),se=o.useRef(0),q=o.useMemo(()=>mu(r,a,i),[r,a,i]),X=q?.id,w=o.useMemo(()=>fu(n),[n]),K=o.useMemo(()=>X?`${X}
|
|
173
|
-
${w}`:"",[X,w]),C=o.useCallback(async(J=0,V=!1)=>{const _=se.current+1,ne=K;if(se.current=_,!X){b(null),p("");return}A(null),V||p(""),V?v(!0):y(!0);try{const $=await Ki(X,{path:w,limit:20,offset:J,allowAbsolute:!0});if(_!==se.current)return;p(ne),b(ae=>V&&ae?{...$,branches:[...ae.branches,...$.branches]}:$)}catch($){if(_!==se.current)return;A($ instanceof Error?$.message:"Failed to load branch info"),V||(b(null),p(""))}finally{_===se.current&&(y(!1),v(!1))}},[X,K,w]);o.useEffect(()=>{if(!X){se.current+=1,b(null),p(""),A(null);return}C()},[X,w,C]),o.useEffect(()=>{const J=t.trim(),V=T===K?N:null,_=V?.available&&V.currentBranch?V.currentBranch:"";J!==_&&s(_)},[N,K,T,s,t]),o.useEffect(()=>{if(!f)return;const J=_=>{ee.current&&(ee.current.contains(_.target)||x(!1))},V=_=>{_.key==="Escape"&&x(!1)};return document.addEventListener("mousedown",J),document.addEventListener("keydown",V),()=>{document.removeEventListener("mousedown",J),document.removeEventListener("keydown",V)}},[f]),o.useEffect(()=>{f&&(P(""),Q(""),W(!1))},[f,X,w]);const Y=o.useCallback(async()=>{if(!X)return;const J=L.trim(),V=re?F.trim():D.trim();if(!(!J||!V)){E(!0),A(null);try{const _=await Gi(X,{path:w,branchName:J,startPoint:V,limit:20,offset:0,allowAbsolute:!0}),ne=await pu(_);p(K),b(ne),s(ne.currentBranch??ne.createdBranch),M(""),P(""),Q(""),W(!1),x(!1)}catch(_){A(_ instanceof Error?_.message:"Failed to create branch")}finally{E(!1)}}},[X,K,w,re,F,L,s,D]),I=T===K?N:null,U=o.useCallback(()=>{I?.hasMore&&C(I.branches.length,!0)},[I,C]),B=t.trim()||I?.currentBranch||(I&&!I.available?"No git repo":"Branch"),le=re?F.trim():D.trim(),oe=!!(I?.available&&L.trim()&&le&&!j),ue=l==="composer"?e.jsxs(Z,{type:"button",variant:"ghost",onClick:()=>x(J=>!J),title:B,"aria-label":`Branch: ${B}`,className:O(c,u,"min-w-0 max-w-full",t.trim()?d:m),children:[k&&!I?e.jsx(me,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(Ds,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:O("min-w-0 truncate",g),children:B})]}):e.jsxs(Z,{type:"button",variant:"outline",onClick:()=>x(J=>!J),className:"h-7 w-full justify-between rounded-sm border-border/70 bg-background/70 px-2.5 text-[11px] shadow-none",title:B,children:[e.jsx("span",{className:O("truncate",t.trim()?"font-mono text-foreground":"text-muted-foreground"),children:B}),e.jsx("span",{className:"ml-2 shrink-0 text-[10px] text-muted-foreground",children:q?q.name:"Manual"})]});return e.jsxs("div",{className:O("relative inline-block",l==="composer"?"min-w-0 shrink-0":"w-full"),ref:ee,children:[l==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ze,{className:"text-[10px] font-medium",children:"Branch"}),ue]}):ue,f&&e.jsxs("div",{className:O("absolute z-50 mt-2 w-[240px] overflow-hidden rounded-sm border border-border/60 bg-background/95 shadow-[0_16px_48px_-34px_rgba(0,0,0,0.45)] backdrop-blur",l==="composer"?"left-0":"left-0 right-0 w-auto min-w-[240px]"),children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border/60 px-3 py-2",children:[e.jsx(Ds,{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:I?.repoRoot?`${I.currentBranch??B} · ${I.repoRoot}`:I?.currentBranch??B,children:I?.currentBranch??B}),k?e.jsx(me,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground"}):null]}),q?k&&!I?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(me,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):I&&!I.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(ft,{value:L,onChange:J=>M(J.target.value),placeholder:"New branch name",className:"h-8 flex-1 rounded-sm border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx(Z,{type:"button",size:"sm",onClick:()=>{Y()},disabled:!oe,title:oe?"Create branch":"Enter a name and pick a base","aria-label":"Create branch",className:"h-8 w-8 shrink-0 rounded-sm p-0",children:j?e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Wi,{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"}),!re&&e.jsxs("button",{type:"button",onClick:()=>W(!0),className:"flex items-center gap-1 rounded-sm px-1 py-0.5 text-[10px] text-muted-foreground hover:bg-background/60 hover:text-foreground",children:[e.jsx(Gt,{className:"h-2.5 w-2.5"}),"Manual"]})]}),re?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ft,{value:F,onChange:J=>Q(J.target.value),placeholder:"upstream/release/1.0",className:"h-8 flex-1 rounded-sm border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx("button",{type:"button",onClick:()=>{W(!1),Q("")},className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Cancel manual input","aria-label":"Cancel manual input",children:e.jsx(it,{className:"h-3.5 w-3.5"})})]}):I?.branches.length?e.jsxs("div",{className:"max-h-44 overflow-y-auto rounded-sm border border-border/40 bg-background/40",children:[I.branches.map(J=>{const V=D===J.ref,_=J.branch==="main"||J.branch==="master";return e.jsxs("button",{type:"button",onClick:()=>P(J.ref),className:O("flex w-full items-center gap-2 border-b border-border/20 px-2.5 py-1.5 text-left text-[11px] last:border-b-0 hover:bg-background/60",V&&"bg-background/70"),title:J.ref,children:[e.jsx("span",{className:O("shrink-0 text-[10px]",_?"text-amber-500 dark:text-amber-400":"text-muted-foreground/60"),"aria-hidden":!0,children:_?"★":"·"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-foreground",children:J.ref}),V?e.jsx(us,{className:"h-3 w-3 shrink-0 text-primary"}):null]},J.ref)}),I.hasMore&&e.jsxs("button",{type:"button",onClick:U,disabled:h,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:[h?e.jsx(me,{className:"h-3 w-3 animate-spin"}):e.jsx(_s,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"rounded-sm border border-dashed border-border/40 px-2.5 py-2 text-[11px] text-muted-foreground",children:"No remote branches found."})]})]})}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Select a specific node first."}),R&&e.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-3 py-1.5 text-[11px] text-destructive",children:R})]})]})}function gu({images:t,removeImage:s}){return e.jsx("div",{className:"flex flex-wrap gap-3",children:t.map((n,r)=>e.jsxs("div",{className:"relative",children:[e.jsx(Zn,{image:n,alt:n.filename??`attachment ${r+1}`,thumbnailClassName:"h-20 w-20 border border-border/70",imageClassName:"h-full w-full"}),e.jsx("button",{type:"button",onClick:()=>s(r),className:"absolute -top-2 -right-2 flex h-6 w-6 items-center justify-center rounded-sm border border-border/70 bg-background text-muted-foreground shadow-sm transition-all hover:-translate-y-px hover:text-foreground","aria-label":`Remove ${n.filename??`image ${r+1}`}`,children:e.jsx(it,{className:"h-3.5 w-3.5"})})]},`${n.filename??"image"}-${r}`))})}const bu=20,vu=3,zn="meshy-working-dir-recents-by-node";function wu(t){return t.startsWith("/")||t.startsWith("\\\\")||/^[A-Za-z]:[\\/]/.test(t)}function yu(t){const s=t.trim();return s||"."}function qn(t){const s=[],n=new Set;for(const r of t){const a=r.trim();if(!(!a||n.has(a))&&(n.add(a),s.push(a),s.length===vu))break}return s}function Nu(t,s){const n=s.trim();return qn(n?[n,...t]:t)}function Ao(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const s={};for(const[n,r]of Object.entries(t)){if(!n||!Array.isArray(r))continue;const a=r.filter(l=>typeof l=="string"),i=qn(a);i.length>0&&(s[n]=i)}return s}function ju(t,s,n){if(!s)return t;const r=t[s]??[],a=Nu(r,n);if(a.length===0){if(!(s in t))return t;const{[s]:i,...l}=t;return l}return{...t,[s]:a}}function ku(t,s){return s?t[s]?.[0]??"":""}function Mo(t){if(!t||typeof window>"u")return"";try{const s=window.localStorage.getItem(zn);return s?ku(Ao(JSON.parse(s)),t):""}catch{return""}}function Su(t,s,n){return t!=="auto"?s.find(r=>r.id===t)??null:n.length===1?n[0]??null:null}function Cu(t,s){const n=s.trim();return n?wu(n)||!t?n:`${t.replace(/[/\\]+$/,"")}/${n}`:""}function Tu(t,s){return t?t.isAbsolute?t.currentPath:t.currentPath==="."||t.currentPath===""?t.rootPath||s?.workDir||"Node root":t.currentPath:s?.workDir??"Node root"}function Is({value:t,onChange:s,assignTo:n,nodes:r,assignableNodes:a,layout:i="default",chipClassName:l,chipActiveClassName:c,chipInactiveClassName:d,labelClassName:m,triggerClassName:g,popoverPlacement:u="bottom",popoverAlign:f="start"}){const[x,N]=o.useState(!1),[b,T]=o.useState(null),[p,k]=o.useState(!1),[y,h]=o.useState(!1),[v,j]=o.useState(null),[E,R]=o.useState(""),[A,L]=o.useState(!1),[M,D]=o.useState({}),P=o.useRef(null),F=o.useMemo(()=>Su(n,r,a),[n,r,a]),Q=F?.id,re=o.useMemo(()=>Q?M[Q]??[]:[],[M,Q]),W=o.useMemo(()=>t.trim()?Cu(F?.workDir,t):"Use node default",[t,F?.workDir]);o.useEffect(()=>{if(!(typeof window>"u"))try{const B=window.localStorage.getItem(zn);if(!B)return;const le=JSON.parse(B);D(Ao(le))}catch{}},[]);const ee=o.useCallback(B=>{Q&&D(le=>{const oe=ju(le,Q,B);if(oe===le)return le;if(typeof window<"u")try{window.localStorage.setItem(zn,JSON.stringify(oe))}catch{}return oe})},[Q]),se=o.useCallback((B,le=!0)=>{const oe=B.trim();s(oe),le&&oe&&ee(oe),N(!1)},[s,ee]),q=o.useCallback(async(B,le=0,oe=!1)=>{if(Q){j(null),oe?h(!0):k(!0);try{const ue=await Va(Q,{path:B,limit:bu,offset:le,directoriesOnly:!0,allowAbsolute:!0});T(J=>oe&&J?{...ue,entries:[...J.entries,...ue.entries]}:ue)}catch(ue){j(ue instanceof Error?ue.message:"Failed to browse directories"),oe||T(null)}finally{k(!1),h(!1)}}},[Q]),X=o.useRef(t);X.current=t;const w=o.useRef(q);w.current=q,o.useEffect(()=>{if(!x)return;const B=X.current;R(B),L(!1),T(null),j(null),Q&&w.current(yu(B))},[x,Q]),o.useEffect(()=>{if(!x)return;const B=oe=>{P.current&&(P.current.contains(oe.target)||N(!1))},le=oe=>{oe.key==="Escape"&&N(!1)};return document.addEventListener("mousedown",B),document.addEventListener("keydown",le),()=>{document.removeEventListener("mousedown",B),document.removeEventListener("keydown",le)}},[x]);const K=o.useCallback(B=>{q(B)},[q]),C=o.useCallback(()=>{b&&q(b.currentPath,b.entries.length,!0)},[b,q]),Y=i==="composer"?e.jsxs(Z,{type:"button",variant:"ghost",onClick:()=>N(B=>!B),title:W,"aria-label":`Working directory: ${W}`,className:O(l,g,"min-w-0 max-w-full",t.trim()?c:d),children:[e.jsx(Yi,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:O("min-w-0 truncate",m),children:W})]}):e.jsxs(Z,{type:"button",variant:"outline",onClick:()=>N(B=>!B),className:"h-7 w-full justify-between rounded-sm border-border/70 bg-background/70 px-2.5 text-[11px] shadow-none",title:W,children:[e.jsx("span",{className:O("truncate",t.trim()?"font-mono text-foreground":"text-muted-foreground"),children:W}),e.jsx("span",{className:"ml-2 shrink-0 text-[10px] text-muted-foreground",children:F?F.name:"Manual"})]}),I=Tu(b,F),U=!!b?.parentPath;return e.jsxs("div",{className:O("relative inline-block",i==="composer"?"min-w-0 max-w-[60%] shrink":"w-full"),"data-workdir-popover-placement":u,"data-workdir-popover-align":f,ref:P,children:[i==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ze,{className:"text-[10px] font-medium",children:"Working directory"}),Y]}):Y,x&&e.jsxs("div",{className:O("absolute z-50 flex max-h-[min(28rem,calc(100vh-5rem))] w-[240px] flex-col overflow-hidden rounded-sm border border-border/60 bg-background/95 shadow-[0_16px_48px_-34px_rgba(0,0,0,0.45)] backdrop-blur",u==="top"?"bottom-full mb-2":"top-full mt-2",i==="composer"?f==="end"?"right-0":"left-0":f==="end"?"right-0 w-auto min-w-[240px]":"left-0 right-0 w-auto min-w-[240px]"),children:[re.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(_s,{className:"h-2.5 w-2.5"}),"Recent"]}),e.jsx("div",{className:"flex flex-col",children:re.map(B=>e.jsx("button",{type:"button",onClick:()=>se(B),className:"truncate rounded-sm px-1.5 py-0.5 text-left font-mono text-[11px] text-foreground hover:bg-background/60",title:B,children:B},B))})]}),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:()=>b?.parentPath&&K(b.parentPath),disabled:!U||p,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-sm border border-border/60 text-muted-foreground transition-colors hover:bg-background/60 hover:text-foreground disabled:opacity-40",title:"Parent directory",children:e.jsx(ho,{className:"h-3 w-3"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground",title:I,children:I}),b&&e.jsx("button",{type:"button",onClick:()=>se(b.isAbsolute?b.currentPath:b.currentPath==="."?"":b.currentPath),className:"shrink-0 rounded-sm px-1.5 py-0.5 text-[10px] font-medium text-foreground hover:bg-background/60",title:"Use this folder",children:"Use"})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:[F?p?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(me,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):b&&b.entries.length>0?e.jsxs(e.Fragment,{children:[b.entries.map(B=>e.jsxs("div",{className:"group flex items-stretch border-b border-border/30 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>se(B.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 ${B.path}`,children:[e.jsx(Kt,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-[11px] text-foreground",children:B.name})]}),e.jsx("button",{type:"button",onClick:()=>K(B.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 ${B.name}`,children:e.jsx(lt,{className:"h-3.5 w-3.5"})})]},B.path)),b.hasMore&&e.jsxs("button",{type:"button",onClick:C,disabled:y,className:"flex w-full items-center justify-center gap-1 border-t border-border/40 py-1 text-[10px] text-muted-foreground hover:bg-background/60 hover:text-foreground disabled:opacity-50",children:[y?e.jsx(me,{className:"h-3 w-3 animate-spin"}):e.jsx(_s,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:v??"No subfolders."}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Select a node to browse."}),v&&b&&b.entries.length>0&&e.jsx("div",{className:"border-t border-border/60 px-3 py-1.5 text-[11px] text-destructive",children:v})]}),e.jsx("div",{className:"flex items-center gap-1 border-t border-border/60 bg-background/40 px-2.5 py-1.5",children:A?e.jsxs(e.Fragment,{children:[e.jsx(ft,{value:E,onChange:B=>R(B.target.value),onKeyDown:B=>{B.key==="Enter"&&E.trim()?(B.preventDefault(),se(E)):B.key==="Escape"&&(B.preventDefault(),L(!1),R(t))},autoFocus:!0,placeholder:"Path (relative or absolute)",className:"h-7 flex-1 rounded-sm border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx("button",{type:"button",onClick:()=>se(E),disabled:!E.trim(),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-sm text-foreground hover:bg-background/60 disabled:opacity-40",title:"Apply","aria-label":"Apply manual path",children:e.jsx(us,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{L(!1),R(t)},className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Cancel","aria-label":"Cancel manual path",children:e.jsx(it,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>{R(t),L(!0)},className:"flex h-7 flex-1 items-center justify-between rounded-sm px-1.5 text-[11px] text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Enter a manual path",children:[e.jsx("span",{children:"Manual input"}),e.jsx(Gt,{className:"h-3 w-3"})]})})]})]})}function Do(t,s={}){const n=t.filter(r=>r.status==="online");return s.currentNodeRole!=="follower"||!s.leaderNodeId?n:n.filter(r=>r.id!==s.leaderNodeId)}function sr({isCurrent:t}){return t?e.jsx(cd,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500 dark:text-emerald-400","aria-label":"current node"}):e.jsx(ad,{className:"h-3.5 w-3.5 shrink-0 text-sky-500 dark:text-sky-400","aria-label":"remote follower node"})}function Un(t,s){return t.map(n=>{const r=!!s&&n.id===s;return e.jsx(Le,{value:n.id,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(sr,{isCurrent:r}),e.jsx("span",{className:"truncate",children:n.name}),e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:r?"current":"remote"})]})},n.id)})}function Eu(t){const s=t.sessionId.trim(),n=t.cwd.trim();return!s||!n||!t.assignTo?null:{title:t.title.trim()||t.defaultTitle?.trim()||void 0,agent:t.agent,sessionId:s,cwd:n,assignTo:t.assignTo,priority:t.priority,mode:t.mode??ms}}function Au(){return Xi.map(t=>e.jsx(Le,{value:t.value,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{children:t.label}),t.description&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:t.description})]})},t.value))}function Mu(t){if(!t)return"unknown time";const s=Date.parse(t);return Number.isNaN(s)?t:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(s)}function Ir(t){if(!t.updatedAt)return 0;const s=Date.parse(t.updatedAt);return Number.isNaN(s)?0:s}function Du(t,s){return Ir(s)-Ir(t)||t.sessionId.localeCompare(s.sessionId)}function _u(t){const s=t.trim().replace(/[\\/]+$/,"");return s?s.split(/[\\/]+/).filter(Boolean).at(-1)??s:"Unknown project"}function Pu(t){const s=new Map;for(const n of[...t].sort(Du)){const r=s.get(n.cwd);if(r){r.push(n);continue}s.set(n.cwd,[n])}return Array.from(s.entries()).map(([n,r])=>({folderName:_u(n),cwd:n,sessions:r}))}function Iu(t,s){const n=new Set(t);return n.has(s)?n.delete(s):n.add(s),n}function Ru({nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:r,onCreated:a,onCancel:i,className:l,footerClassName:c,submitLabel:d="Load session",cancelLabel:m="Cancel",autoFocus:g=!1}){const u=o.useMemo(()=>Do(t,{currentNodeRole:s,leaderNodeId:r}),[t,s,r]),f=o.useMemo(()=>n&&u.some(_=>_.id===n)?n:u[0]?.id??"",[u,n]),[x,N]=o.useState(""),[b,T]=o.useState("codex"),[p,k]=o.useState(""),[y,h]=o.useState(""),[v,j]=o.useState(""),[E,R]=o.useState(f),[A,L]=o.useState(ms),[M,D]=o.useState(!1),[P,F]=o.useState([]),[Q,re]=o.useState(!1),[W,ee]=o.useState(null),se=o.useMemo(()=>P.find(_=>_.sessionId===p)??null,[P,p]);o.useEffect(()=>{E&&u.some(_=>_.id===E)||R(f)},[E,u,f]),o.useEffect(()=>{k(""),h(""),j("")},[b,E]),o.useEffect(()=>{let _=!1;return E?(re(!0),ee(null),Ji(E,{agent:b,limit:50}).then(ne=>{_||F(ne.sessions)}).catch(ne=>{_||(F([]),ee(ne instanceof Error?ne.message:"Failed to load native sessions"))}).finally(()=>{_||re(!1)}),()=>{_=!0}):(F([]),ee(null),re(!1),()=>{_=!0})},[b,E]),o.useEffect(()=>{se&&(h(se.sessionId),j(se.cwd))},[se]);const q=o.useCallback(async _=>{_.preventDefault();const ne=Eu({title:x,defaultTitle:se?.summary,agent:b,sessionId:y,cwd:v,assignTo:E,priority:"normal",mode:A});if(ne){D(!0);try{const $=await Zi(ne);a($)}catch($){de.error($ instanceof Error?$.message:"Failed to load native session")}finally{D(!1)}}},[x,se,b,y,v,E,A,a]),X=!!(y.trim()&&v.trim()&&E),[w,K]=o.useState(!1),[C,Y]=o.useState(""),[I,U]=o.useState(()=>new Set),B=u.find(_=>_.id===E)??null,le=!!(n&&B?.id===n),oe=o.useMemo(()=>{const _=C.trim().toLowerCase();return _?P.filter(ne=>ne.summary.toLowerCase().includes(_)||ne.sessionId.toLowerCase().includes(_)||ne.cwd.toLowerCase().includes(_)):P},[P,C]),ue=o.useMemo(()=>Pu(oe),[oe]),J=o.useCallback(_=>{U(ne=>Iu(ne,_))},[]),V="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:q,className:O("space-y-4",l),children:[e.jsxs("div",{className:"rounded-sm border border-border/60 bg-background/54 shadow-none backdrop-blur-xl",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-border/50 px-3 py-2.5",children:[e.jsxs(Be,{value:E,onValueChange:R,children:[e.jsx(Oe,{className:O(V),"aria-label":"Node",children:B?e.jsxs(e.Fragment,{children:[e.jsx(sr,{isCurrent:le}),e.jsx("span",{className:"max-w-[10rem] truncate",children:B.name})]}):e.jsx(Ge,{placeholder:"Node"})}),e.jsx(Fe,{children:Un(u,n)})]}),e.jsxs(Be,{value:b,onValueChange:_=>T(_),children:[e.jsxs(Oe,{className:O(V),"aria-label":"Agent",children:[e.jsx(wt,{agent:b}),e.jsx("span",{children:b})]}),e.jsx(Fe,{children:Nc()})]}),e.jsxs("div",{className:"relative ml-auto min-w-0 flex-1 sm:max-w-56",children:[e.jsx(Ka,{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(ft,{value:C,onChange:_=>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(Ze,{className:"text-[10px] font-medium uppercase tracking-[0.2em] text-muted-foreground",children:Q?"Loading...":`${oe.length} session${oe.length===1?"":"s"}`})}),e.jsxs("div",{className:"relative h-88 overflow-hidden rounded-sm",children:[Q&&e.jsx("div",{className:"absolute inset-x-0 top-0 z-10 h-0.5 overflow-hidden bg-primary/10",children:e.jsx("div",{className:"h-full w-1/3 animate-indeterminate-bar bg-primary/70"})}),e.jsxs("div",{className:"h-full space-y-1.5 overflow-y-auto pr-1",children:[!E&&e.jsx("div",{className:"rounded-sm border border-dashed border-border/60 bg-background/35 px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Pick a node to load its recent sessions."}),E&&!Q&&oe.length===0&&e.jsx("div",{className:"rounded-sm border border-dashed border-border/60 bg-background/35 px-3 py-4 text-center text-[11px] text-muted-foreground",children:P.length===0?"No recent sessions on this node. Use Manual session ID under More options.":"No sessions match your filter."}),ue.map(_=>e.jsxs("section",{className:"space-y-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>J(_.cwd),"aria-expanded":!I.has(_.cwd),className:"sticky top-0 z-[1] flex w-full items-center gap-2 border-b border-border/50 bg-background/95 px-1 py-1.5 text-left text-[10px] text-muted-foreground backdrop-blur transition-colors hover:bg-background",children:[e.jsx(st,{className:O("h-3.5 w-3.5 shrink-0 transition-transform",I.has(_.cwd)&&"-rotate-90")}),e.jsx(Os,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate text-xs font-medium text-foreground",children:_.folderName}),e.jsxs("span",{className:"shrink-0 uppercase tracking-[0.16em]",children:[_.sessions.length," session",_.sessions.length===1?"":"s"]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-right font-mono",children:_.cwd})]}),!I.has(_.cwd)&&_.sessions.map(ne=>{const $=ne.sessionId===p;return e.jsxs("button",{type:"button",onClick:()=>k(ne.sessionId),className:O("flex w-full flex-col gap-1 rounded-sm border px-2.5 py-2 text-left transition-colors duration-200",$?"border-primary/45 bg-primary/9 shadow-none":"border-border/55 bg-background/40 hover:border-border hover:bg-background/65"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:O("h-2 w-2 shrink-0 rounded-full",$?"bg-primary":"bg-border")}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",children:ne.summary}),e.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.16em] text-muted-foreground",children:Mu(ne.updatedAt)})]}),e.jsxs("div",{className:"flex items-center gap-2 pl-4 text-[10px] text-muted-foreground",children:[e.jsx("span",{className:"font-mono",children:ne.sessionId.slice(0,12)}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),e.jsx("span",{className:"truncate font-mono",children:ne.cwd})]})]},ne.sessionId)})]},_.cwd))]})]}),W&&e.jsx("p",{className:"px-1 pt-2 text-[11px] text-destructive",children:W})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:()=>K(_=>!_),className:"inline-flex h-6 items-center gap-1.5 rounded-sm px-1.5 text-[10px] font-medium uppercase tracking-[0.16em] text-muted-foreground transition-colors hover:bg-muted/45 hover:text-foreground","aria-expanded":w,children:[e.jsx("span",{className:"shrink-0",children:w?"Less options":"More options"}),e.jsx(st,{className:O("h-3.5 w-3.5 shrink-0 transition-transform",w&&"rotate-180")})]}),w&&e.jsxs("div",{className:"space-y-2 rounded-sm border border-border/60 bg-background/30 p-2.5",children:[e.jsxs("div",{className:"grid gap-2.5 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(Ze,{htmlFor:"native-session-id",className:"text-[10px] font-medium text-muted-foreground",children:"Session ID"}),e.jsx(ft,{id:"native-session-id",type:"text",value:y,onChange:_=>{k(""),h(_.target.value)},placeholder:"ses_..., thread_..., or UUID",autoFocus:g,className:"h-7 rounded-sm border-border/70 bg-background/70 font-mono text-[11px] shadow-none"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(Ze,{htmlFor:"native-session-title",className:"text-[10px] font-medium text-muted-foreground",children:"Task title"}),e.jsx(ft,{id:"native-session-title",type:"text",value:x,onChange:_=>N(_.target.value),placeholder:"Optional",className:"h-7 rounded-sm border-border/70 bg-background/70 text-[11px] shadow-none"})]})]}),e.jsx(Is,{value:v,onChange:_=>{k(""),j(_)},assignTo:E,nodes:t,assignableNodes:u}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(Ze,{className:"text-[10px] font-medium text-muted-foreground",children:"Mode"}),e.jsxs(Be,{value:A,onValueChange:_=>L(_),children:[e.jsx(Oe,{className:"h-7 rounded-sm border-border/70 bg-background/70 text-[11px] shadow-none",children:e.jsx(Ge,{placeholder:"Select mode"})}),e.jsx(Fe,{children:Au()})]})]})]})]}),e.jsxs("div",{className:O("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",c),children:[i&&e.jsx(Z,{type:"button",variant:"ghost",onClick:i,className:"rounded-sm",children:m}),e.jsx(Z,{type:"submit",disabled:!X||M,className:"rounded-sm px-5",children:M?e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"h-4 w-4 animate-spin"})," Loading..."]}):d})]})]})}const en="__agent-default__";function _o({agent:t,value:s,onChange:n,triggerClassName:r,contentClassName:a="max-h-80",chip:i=!1}){const l=io(t,s);return o.useEffect(()=>{s&&!uo(t,s)&&n("")},[t,s,n]),e.jsxs(Be,{value:s||en,onValueChange:c=>n(c===en?"":c),children:[e.jsx(Oe,{"aria-label":`Model: ${l}`,title:`Model: ${l}`,className:r,children:i?e.jsxs(e.Fragment,{children:[e.jsx(po,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:l})]}):e.jsx(Ge,{placeholder:"Agent default"})}),e.jsxs(Fe,{className:a,children:[e.jsx(Le,{value:en,className:"py-1 text-[11px]",children:"Agent default"}),jc(t)]})]})}function Lu(t){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ze,{className:"text-[11px] font-medium",children:"Model"}),e.jsx(_o,{...t,triggerClassName:"h-8 rounded-sm border-border/70 bg-background/70"})]})}function Po(t,s,n=!1){const r=t.trim();if(r)return r;const a=s.trim().split(`
|
|
174
|
-
`).map(i=>i.trim()).find(Boolean);return a?a.length>72?`${a.slice(0,69).trimEnd()}...`:a:n?"Image task":""}function Bu(t){const s=t.title.trim(),n=mo(t.agent,t.description),r=n.prompt,a=Po(t.title,r,t.images.length>0),i=r.trim()||a,l=t.mode??ms,c=t.model?.trim(),d=c&&uo(t.agent,c)?c:"",m=n.isGoal?n.commandPrompt:r,g=oo(m,t.images);return!a||!i||!t.agent?null:{title:a,description:i,agent:t.agent,project:t.project.trim()||null,branch:t.branch?.trim()||null,payload:{initialMessage:g,mode:l,...d?{model:d}:{},...n.isGoal?{goal:!0}:{},titleSource:s?"manual":"derived"},priority:t.priority,assignTo:t.assignTo==="auto"?void 0:t.assignTo}}function Ou({nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:r,initialAssignTo:a,initialProject:i,onCreated:l,onCancel:c,className:d,footerClassName:m,submitLabel:g="Create chat",cancelLabel:u="Cancel",autoFocus:f=!1,layout:x="default",defaultTaskAgent:N,quickChats:b=[]}){const[T,p]=o.useState(""),[k,y]=o.useState(""),[h,v]=o.useState(0),[j,E]=o.useState(()=>ys(N)),R=o.useRef(!1),[A,L]=o.useState(""),[M,D]=o.useState(ms),[P,F]=o.useState(i?.trim()??""),Q=o.useRef(i!==void 0),[re,W]=o.useState(""),ee=o.useMemo(()=>Do(t,{currentNodeRole:s,leaderNodeId:r}),[t,s,r]),se=o.useMemo(()=>a&&ee.some(te=>te.id===a)?a:n&&ee.some(te=>te.id===n)?n:ee[0]?.id??"",[ee,n,a]),[q,X]=o.useState(se),[w,K]=o.useState(!1),[C,Y]=o.useState(!1),{images:I,error:U,fileInputRef:B,pickImages:le,handleFileChange:oe,handlePaste:ue,removeImage:J}=ko(),V=o.useRef(null),_=o.useMemo(()=>ee.find(te=>te.id===q)??null,[q,ee]),ne=!!(n&&_?.id===n),$=vt(j),ae=kc(M),pe=o.useMemo(()=>mo(j,k),[j,k]),fe=o.useMemo(()=>lo(j,k),[j,k]),Ve=pe.prompt,je=o.useMemo(()=>pe.isGoal||fe?[]:b,[pe.isGoal,fe,b]);o.useEffect(()=>{q&&ee.some(te=>te.id===q)||X(se)},[q,ee,se]),o.useEffect(()=>{R.current||E(ys(N))},[N]);const ht=o.useCallback(te=>{R.current=!0,E(ys(te))},[]);o.useEffect(()=>{if(Q.current){Q.current=!1;return}F(Mo(q)),W("")},[q]),o.useEffect(()=>{W("")},[P]),o.useEffect(()=>{v(0)},[k,b,j]);const De=o.useCallback(te=>{y(te.prompt)},[]),Me=o.useCallback(()=>{y(fe?.value??"/goal "),v(0),!(typeof window>"u")&&window.setTimeout(()=>{const te=V.current;te?.focus();const ve=te?.value.length??0;te?.setSelectionRange(ve,ve)},0)},[fe]),Te=o.useCallback(async te=>{if(te.preventDefault(),fe){Me();return}const ve=Es(k,je,h);if(ve){De(ve);return}const ke=Bu({title:T,description:k,agent:j,model:A,project:P,branch:re,priority:"normal",assignTo:q,mode:M,images:I});if(ke){K(!0);try{const ye=await tl(ke);l(ye)}catch(ye){de.error(ye instanceof Error?ye.message:"Failed to create task")}finally{K(!1)}}},[T,k,j,A,P,re,q,M,I,l,je,h,De,fe,Me]),Ee=Po(T,Ve,I.length>0),Pe=!fe&&!!(Ee&&j&&q&&(Ve.trim()||I.length>0)),Ue=o.useCallback(te=>{if(te.nativeEvent.isComposing)return;if(fe&&(te.key==="ArrowDown"||te.key==="ArrowUp")){te.preventDefault();return}const ve=Ua(k,je);if(ve.length>0&&(te.key==="ArrowDown"||te.key==="ArrowUp")){te.preventDefault(),v(ke=>$a(ke,ve.length,te.key==="ArrowDown"?1:-1));return}if(te.key==="Enter"){if(fe&&!te.shiftKey){te.preventDefault(),Me();return}const ke=Es(k,je,h);if(ke&&!te.shiftKey){te.preventDefault(),De(ke);return}}te.key==="Enter"&&(te.ctrlKey||te.metaKey)&&Pe&&!w&&(te.preventDefault(),te.currentTarget.form?.requestSubmit())},[Me,De,je,Pe,k,fe,h,w]),H=I.length>0?e.jsx(gu,{images:I,removeImage:J}):null,xe=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ze,{className:"text-[11px] font-medium",children:"Assign to"}),e.jsxs(Be,{value:q,onValueChange:X,children:[e.jsx(Oe,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Ge,{placeholder:"Select node"})}),e.jsx(Fe,{children:Un(ee,n)})]})]}),be=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ze,{className:"text-[11px] font-medium",children:"Agent"}),e.jsxs(Be,{value:j,onValueChange:ht,children:[e.jsx(Oe,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Ge,{placeholder:"Select agent"})}),e.jsx(Fe,{children:jr()})]})]}),Xe=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ze,{className:"text-[11px] font-medium",children:"Mode"}),e.jsxs(Be,{value:M,onValueChange:te=>D(te),children:[e.jsx(Oe,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Ge,{placeholder:"Select mode"})}),e.jsx(Fe,{children:kr()})]})]}),Ie=e.jsx(Is,{value:P,onChange:F,assignTo:q,nodes:t,assignableNodes:ee}),ct=e.jsx(Pr,{value:re,onChange:W,project:P,assignTo:q,nodes:t,assignableNodes:ee});return x==="composer"?e.jsxs("form",{onSubmit:Te,className:O("space-y-4",d),children:[e.jsx("input",{ref:B,type:"file",accept:"image/*",multiple:!0,onChange:oe,className:"hidden"}),(()=>{const te="chat-composer__chip h-9 min-w-0 w-auto gap-1.5 rounded-sm px-3.5 text-xs shadow-none transition-colors [&>span]:min-w-0",ve="border-transparent bg-transparent text-muted-foreground hover:bg-background/40 hover:text-foreground",ke="border-border/70 bg-background/55 text-foreground",ye=j===ys(N),yt=M===ms;return e.jsxs("div",{className:"chat-composer space-y-2",children:[e.jsxs("div",{className:"chat-composer__card rounded-sm border border-border/60 bg-background/54 shadow-none backdrop-blur-xl",children:[e.jsxs("div",{className:"chat-composer__header flex min-w-0 items-center justify-between gap-3 px-4 pt-3",children:[e.jsxs(Be,{value:q,onValueChange:X,children:[e.jsx(Oe,{className:O(te,ke,"chat-composer__node-trigger border-transparent bg-transparent hover:bg-background/40"),title:`Assigned node: ${_?.name??"unassigned"}`,"aria-label":`Assigned node: ${_?.name??"unassigned"}`,children:_?e.jsxs(e.Fragment,{children:[e.jsx(sr,{isCurrent:ne}),e.jsx("span",{className:"min-w-0 truncate",children:_.name}),e.jsx("span",{className:"chat-composer__header-meta shrink-0 text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:ne?"current":"remote"})]}):e.jsx(Ge,{placeholder:"Select node"})}),e.jsx(Fe,{children:Un(ee,n)})]}),C?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ft,{id:"task-title-composer",type:"text",value:T,onChange:_e=>p(_e.target.value),onKeyDown:_e=>{(_e.key==="Enter"||_e.key==="Escape")&&(_e.preventDefault(),Y(!1))},autoFocus:!0,placeholder:"Chat title",className:"h-8 w-48 min-w-0 rounded-sm border-border/70 bg-background/55 px-3 text-xs shadow-none"}),e.jsx(Z,{type:"button",variant:"ghost",size:"icon",onClick:()=>Y(!1),"aria-label":"Save title",className:"h-8 w-8 shrink-0 rounded-sm text-muted-foreground hover:text-foreground",children:e.jsx(us,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>Y(!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:Ee||"Title","aria-label":Ee?`Edit title: ${Ee}`:"Edit title",children:[e.jsx("span",{className:"chat-composer__title-text max-w-[220px] truncate",children:Ee||"Title"}),e.jsx(Gt,{className:"h-3 w-3 shrink-0"})]})]}),e.jsx("textarea",{id:"task-description",ref:V,value:k,onChange:_e=>y(_e.target.value),onKeyDown:Ue,onPaste:ue,placeholder:"Ask anything...",rows:4,autoFocus:f,"aria-label":"Opening prompt",className:"min-h-[140px] w-full resize-none overflow-x-hidden overflow-y-auto rounded-sm bg-transparent px-5 pt-2 pb-2 text-xs leading-5 text-foreground ring-offset-background placeholder:text-muted-foreground/70 focus-visible:outline-none"}),e.jsx(_r,{agent:j,query:k,onSelect:Me}),e.jsx(Dn,{query:k,quickChats:je,selectedIndex:h,onActiveIndexChange:v,onSelect:De}),e.jsxs("div",{className:"chat-composer__rail flex min-w-0 flex-nowrap items-center gap-2 px-3 pb-3",children:[e.jsx(Z,{type:"button",variant:"ghost",size:"icon",onClick:le,"aria-label":"Add images",className:"h-9 w-9 shrink-0 rounded-sm text-muted-foreground hover:text-foreground",children:e.jsx(On,{className:"h-4 w-4"})}),e.jsx("span",{className:"mx-0.5 h-5 w-px bg-border/60","aria-hidden":!0}),e.jsxs(Be,{value:j,onValueChange:ht,children:[e.jsxs(Oe,{className:O(te,"chat-composer__icon-trigger",ye?ve:ke),title:`Agent: ${$}`,"aria-label":`Agent: ${$}`,children:[e.jsx(wt,{agent:j}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:$})]}),e.jsx(Fe,{children:jr()})]}),e.jsx(_o,{agent:j,value:A,onChange:L,chip:!0,triggerClassName:O(te,"chat-composer__icon-trigger",A?ke:ve),contentClassName:"max-h-80 shadow-none"}),e.jsxs(Be,{value:M,onValueChange:_e=>D(_e),children:[e.jsxs(Oe,{className:O(te,"chat-composer__icon-trigger",yt?ve:ke),title:`Mode: ${ae}`,"aria-label":`Mode: ${ae}`,children:[e.jsx(jd,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:ae})]}),e.jsx(Fe,{children:kr()})]}),e.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[c&&e.jsxs(Z,{type:"button",variant:"ghost",size:"sm",onClick:c,"aria-label":u,className:"chat-composer__cancel h-9 rounded-sm px-4 text-xs text-muted-foreground",children:[e.jsx(it,{className:"chat-composer__cancel-icon h-4 w-4 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label",children:u})]}),e.jsxs(Z,{type:"submit",size:"icon",disabled:!Pe||w,className:"h-10 w-10 rounded-sm shadow-[0_8px_30px_-8px_hsl(var(--primary)/0.6)]",children:[w?e.jsx(me,{className:"h-4 w-4 animate-spin"}):e.jsx(wo,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:w?"Creating chat":g})]})]})]})]}),e.jsx("div",{className:"chat-composer__location flex flex-wrap items-center gap-2 px-1",children:(()=>{const _e="border-border/40 bg-muted/40 text-foreground/80 hover:bg-muted/60 hover:text-foreground";return e.jsxs(e.Fragment,{children:[e.jsx(Is,{value:P,onChange:F,assignTo:q,nodes:t,assignableNodes:ee,layout:"composer",chipClassName:te,chipActiveClassName:_e,chipInactiveClassName:_e,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"}),e.jsx(Pr,{value:re,onChange:W,project:P,assignTo:q,nodes:t,assignableNodes:ee,layout:"composer",chipClassName:te,chipActiveClassName:_e,chipInactiveClassName:_e,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"})]})})()})]})})(),(H||U)&&e.jsxs("div",{className:"space-y-2 rounded-sm border border-border/60 bg-background/45 p-2.5",children:[H,U&&e.jsx("div",{className:"text-[11px] text-destructive",children:U}),!U&&e.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Ctrl/Cmd+Enter starts the chat. Enter adds a new line. Paste screenshots directly into the prompt box or use the Images button."})]})]}):e.jsxs("form",{onSubmit:Te,className:O("space-y-4",d),children:[e.jsx("input",{ref:B,type:"file",accept:"image/*",multiple:!0,onChange:oe,className:"hidden"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ze,{htmlFor:"task-description",className:"text-[11px] font-medium",children:"Opening prompt"}),e.jsx("textarea",{id:"task-description",ref:V,value:k,onChange:te=>y(te.target.value),onKeyDown:Ue,onPaste:ue,placeholder:"Describe what the agent should do. This becomes the first message in the chat.",rows:6,autoFocus:f,className:"flex min-h-[128px] w-full resize-none overflow-x-hidden overflow-y-auto rounded-sm border border-border/70 bg-background/70 px-3 py-2 text-xs leading-5 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"}),e.jsx(_r,{agent:j,query:k,onSelect:Me}),e.jsx(Dn,{query:k,quickChats:je,selectedIndex:h,onActiveIndexChange:v,onSelect:De}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(Z,{type:"button",variant:"outline",onClick:le,className:"rounded-sm",children:[e.jsx(On,{className:"h-4 w-4"}),"Add images"]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Ctrl/Cmd+Enter starts the chat. Enter adds a new line. Upload or paste screenshots and reference images with the opening prompt."})]}),H,U&&e.jsx("p",{className:"text-[11px] text-destructive",children:U})]}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1fr)_170px_190px_150px]",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ze,{htmlFor:"task-title",className:"text-[11px] font-medium",children:"Chat title"}),e.jsx(ft,{id:"task-title",type:"text",value:T,onChange:te=>p(te.target.value),placeholder:"Optional. Leave blank to derive it from the prompt.",className:"h-8 rounded-sm border-border/70 bg-background/70"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:Ee?`Will appear as: ${Ee}`:"A title will be generated from the first line of the prompt."})]}),be,e.jsx(Lu,{agent:j,value:A,onChange:L}),Xe]}),Ie,ct,xe,e.jsxs("div",{className:O("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",m),children:[c&&e.jsx(Z,{type:"button",variant:"ghost",onClick:c,className:"rounded-sm",children:u}),e.jsx(Z,{type:"submit",disabled:!Pe||w,className:"rounded-sm px-5",children:w?"Creating...":g})]})]})}function Fu({nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:r,initialAssignTo:a,initialProject:i,onCreated:l,onCancel:c,defaultMode:d="chat",mode:m,onModeChange:g,layout:u="default",className:f,footerClassName:x,autoFocus:N=!1,quickChats:b=[],defaultTaskAgent:T}){const[p,k]=o.useState(d),y=m!==void 0,h=y?m:p,v=j=>{y||k(j),g?.(j)};return e.jsxs("div",{className:O("space-y-4",f),children:[!y&&e.jsxs("div",{className:"flex h-8 items-center gap-0.5 rounded-sm border border-border/60 bg-background/45 p-0.5",children:[e.jsxs(Z,{type:"button",variant:h==="chat"?"default":"ghost",onClick:()=>v("chat"),className:"h-7 flex-1 rounded-sm shadow-none",children:[e.jsx(el,{className:"h-4 w-4"}),"New chat"]}),e.jsxs(Z,{type:"button",variant:h==="native"?"default":"ghost",onClick:()=>v("native"),className:"h-7 flex-1 rounded-sm shadow-none",children:[e.jsx(er,{className:"h-4 w-4"}),"Load session"]})]}),h==="chat"?e.jsx(Ou,{nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:r,initialAssignTo:a,initialProject:i,onCreated:l,onCancel:c,footerClassName:x,submitLabel:u==="composer"?"Start chat":"Create chat",cancelLabel:"Cancel",autoFocus:N,layout:u,defaultTaskAgent:T,quickChats:b},`${a??""}:${i??""}`):e.jsx(Ru,{nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:r,onCreated:l,onCancel:c,footerClassName:x,autoFocus:N})]})}function zu({onClick:t,running:s}){return e.jsxs(Z,{size:"icon",onClick:t,"aria-label":s?"Open composer - task running":"Open composer",title:s?"Task running - open composer":"Open composer",className:O("absolute bottom-4 right-4 z-10 h-12 w-12 overflow-visible rounded-lg shadow-lg",s&&"animate-soft-status-pulse bg-primary/90 text-primary-foreground hover:bg-primary"),children:[e.jsx(Gt,{className:"h-4 w-4"}),s&&e.jsx("span",{"aria-hidden":"true","data-running-indicator":"true",className:"pointer-events-none absolute right-1.5 top-1.5 h-2 w-2 rounded-full bg-primary-foreground shadow-[0_0_0_2px_hsl(var(--primary))]"})]})}function Rr({children:t}){return e.jsxs("div",{className:"agent-progress-banner animate-message-receive flex items-center gap-1.5 rounded-lg bg-transparent px-1 py-1 text-[11px]",children:[e.jsx("span",{className:"agent-progress-terminal-spinner h-4 w-4 shrink-0","aria-hidden":"true"}),e.jsx("div",{className:"agent-progress-sweep-text min-w-0 leading-5",children:t})]})}function qu({hasVisibleTranscriptEvents:t,hasTranscriptProgress:s,inputCollapsed:n}){return{collapsedButtonRunning:s&&t&&n,showDockedProgress:s&&t&&!n,showInlineProgress:s&&!t}}const $t="72f988bf-86f1-41af-91ab-2d7cd011db47",Io=`${$t} (MSIT)`;function Uu({open:t,onOpenChange:s,onShare:n,onStopShare:r,sharing:a,stopping:i=!1,shareResult:l}){return e.jsx(At,{open:t,onOpenChange:s,children:e.jsxs(Mt,{className:"max-w-md rounded-sm p-4",children:[e.jsx(Rt,{className:"sr-only",children:"Share conversation"}),e.jsx($u,{onOpenChange:s,onShare:n,onStopShare:r,sharing:a,stopping:i,shareResult:l})]})})}function $u({onOpenChange:t,onShare:s,onStopShare:n,sharing:r,stopping:a=!1,shareResult:i}){const[l,c]=o.useState(i?.tenant??$t),[d,m]=o.useState(i?.scope??"chat"),g=i?.url?Ga(i.url):null,u=r||a;return o.useEffect(()=>{c(i?.tenant??$t),m(i?.scope??"chat")},[i?.shareId,i?.tenant,i?.scope]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h2",{className:"text-sm font-semibold leading-none tracking-tight",children:"Share conversation"}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"Create a tenant-gated link for this task."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(Hu,{value:l,onChange:c,disabled:u}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:"Access"}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(Lr,{active:d==="chat",title:"Chat only",description:"Conversation transcript and opening prompt.",onClick:()=>m("chat")}),e.jsx(Lr,{active:d==="filesPreview",title:"Chat, files and preview",description:"Transcript plus task output files and HTML preview.",onClick:()=>m("filesPreview")})]})]}),g&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:"Shared link"}),e.jsxs("div",{className:"flex items-center gap-2 rounded-sm border border-border/70 bg-muted/30 px-3 py-2",children:[e.jsx("input",{readOnly:!0,value:g,className:"min-w-0 flex-1 bg-transparent font-mono text-xs text-foreground outline-none","aria-label":"Shared link"}),e.jsx(Z,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-sm text-muted-foreground",onClick:()=>{hs(g,"Shared link copied")},"aria-label":"Copy shared link",title:"Copy shared link",children:e.jsx(Wa,{className:"h-3.5 w-3.5"})})]})]})]}),e.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e.jsx(Z,{variant:"outline",onClick:()=>t(!1),disabled:u,className:"h-8 text-xs",children:i?"Done":"Cancel"}),i&&n&&e.jsxs(Z,{variant:"outline",onClick:()=>{n()},disabled:u,className:"h-8 border-destructive/30 text-xs text-destructive hover:bg-destructive/10 hover:text-destructive",children:[a&&e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}),"Stop share"]}),e.jsxs(Z,{onClick:()=>{s({tenant:l,scope:d})},disabled:u,className:"h-8 text-xs",children:[r&&e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}),i?"Update link":"Share link"]})]})]})}function Hu({value:t,onChange:s,disabled:n}){const[r,a]=o.useState(!1),[i,l]=o.useState(!1),[c,d]=o.useState(t),m=o.useRef(null);o.useEffect(()=>{d(t)},[t]),o.useEffect(()=>{if(!r)return;const u=x=>{const N=x.target;N instanceof Node&&(m.current?.contains(N)||(a(!1),l(!1)))},f=x=>{x.key==="Escape"&&(a(!1),l(!1))};return document.addEventListener("mousedown",u),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",f)}},[r]);const g=u=>{const f=u.trim();f&&(s(f),d(f),l(!1),a(!1))};return e.jsxs("div",{className:"space-y-2 text-xs",ref:m,children:[e.jsx("div",{className:"font-medium text-foreground",children:"Tenant"}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>!n&&a(u=>!u),disabled:n,className:"flex h-9 w-full items-center justify-between gap-2 rounded-sm border border-border/70 bg-background/70 px-3 text-left text-xs text-foreground shadow-sm outline-none transition-colors hover:bg-background disabled:opacity-50",children:[e.jsx("span",{className:"min-w-0 truncate font-mono",children:Vu(t)}),e.jsx(st,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})]}),r&&e.jsxs("div",{className:"absolute left-0 right-0 z-50 mt-2 overflow-hidden rounded-sm border border-border/60 bg-background/95 text-xs shadow-[0_16px_48px_-34px_rgba(0,0,0,0.45)] backdrop-blur",children:[e.jsxs("button",{type:"button",onClick:()=>g($t),className:"flex w-full items-center justify-between gap-2 px-3 py-2 text-left hover:bg-background/60",children:[e.jsx("span",{className:"min-w-0 truncate font-mono text-[11px]",children:Io}),t===$t&&e.jsx(us,{className:"h-3.5 w-3.5 shrink-0 text-primary"})]}),e.jsx("div",{className:"border-t border-border/60 bg-background/40 px-2.5 py-1.5",children:i?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{value:c,onChange:u=>d(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),g(c))},autoFocus:!0,placeholder:"Tenant ID",className:"h-7 min-w-0 flex-1 rounded-sm border border-border/60 bg-background/70 px-2 font-mono text-[11px] outline-none focus:ring-2 focus:ring-ring"}),e.jsx("button",{type:"button",onClick:()=>g(c),className:"flex h-7 w-7 items-center justify-center rounded-sm hover:bg-background/60",children:e.jsx(us,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{d(t),l(!1)},className:"flex h-7 w-7 items-center justify-center rounded-sm text-muted-foreground hover:bg-background/60 hover:text-foreground",children:e.jsx(it,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>l(!0),className:"flex h-7 w-full items-center justify-between rounded-sm px-1.5 text-[11px] text-muted-foreground hover:bg-background/60 hover:text-foreground",children:[e.jsx("span",{children:"Manual tenant ID"}),e.jsx(Gt,{className:"h-3 w-3"})]})})]})]})]})}function Vu(t){return t===$t?Io:t}function Lr({active:t,title:s,description:n,onClick:r}){return e.jsxs("button",{type:"button",onClick:r,className:t?"rounded-sm border border-primary/45 bg-primary/10 px-3 py-2 text-left shadow-sm":"rounded-sm border border-border/70 bg-background px-3 py-2 text-left shadow-sm hover:bg-muted/50",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:s}),e.jsx("div",{className:"mt-1 text-[11px] leading-4 text-muted-foreground",children:n})]})}function Ku(t){const s=t.map(n=>n.type==="text"?n.text:n.type==="image"?n.filename?`Image: ${n.filename}`:"Image attachment":n.isError?`Tool result error: ${n.content}`:`Tool result: ${n.content}`).join(" ").replace(/\s+/g," ").trim();return s?s.length>160?`${s.slice(0,157)}...`:s:"Queued follow-up"}function Gu({messages:t,onCancelMessage:s}){return t.length===0?null:e.jsx("div",{className:"border-t border-border/55 bg-card/30 px-3 py-2 sm:px-5",children:e.jsxs("div",{className:"mx-auto max-w-[72rem] rounded-sm border border-border/65 bg-background/58 px-3 py-2 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium text-foreground",children:[e.jsx(md,{className:"h-3.5 w-3.5 text-primary"}),"Queued messages",e.jsx("span",{className:"ml-auto rounded-sm border border-border/60 bg-muted/60 px-1.5 py-0 text-[10px] text-muted-foreground",children:t.length})]}),e.jsx("div",{className:"mt-2 space-y-1.5",children:t.map((n,r)=>{const a=n.content.filter(i=>i.type==="image");return e.jsxs("div",{className:"flex min-w-0 items-start gap-2 text-[11px] leading-5 text-muted-foreground",children:[e.jsx("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-sm bg-primary/10 text-[10px] font-medium text-primary",children:r+1}),e.jsxs("div",{className:"min-w-0 flex-1",children:[n.targetAgent&&e.jsxs("div",{"data-queued-message-target-agent":n.targetAgent,className:"mb-0.5 inline-flex h-5 max-w-[11rem] items-center gap-1 rounded-sm bg-primary/10 px-1.5 text-[10px] leading-3 text-primary",title:`Send to ${vt(n.targetAgent)}`,children:[e.jsx(xo,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),e.jsx(wt,{agent:n.targetAgent,className:"h-3 w-3 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:vt(n.targetAgent)})]}),e.jsx("div",{className:"break-words [overflow-wrap:anywhere]",children:Ku(n.content)}),a.length>0&&e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:a.map((i,l)=>e.jsx(Zn,{image:i,alt:i.filename??`queued attachment ${l+1}`,thumbnailClassName:"h-14 w-14 border border-border/65",imageClassName:"h-full w-full"},`${i.filename??"image"}-${l}`))})]}),s&&e.jsx(Z,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 shrink-0 rounded-sm text-muted-foreground hover:text-destructive",title:"Cancel queued message","aria-label":"Cancel queued message",onClick:()=>s(n.id),children:e.jsx(it,{className:"h-3 w-3"})})]},n.id)})})]})})}const Wu="h-6 w-6 rounded-none border-b border-transparent !bg-transparent p-0 text-muted-foreground !shadow-none hover:text-foreground data-[state=active]:border-primary data-[state=active]:!bg-transparent data-[state=active]:text-primary data-[state=active]:!shadow-none",Qu=[{value:"transcript",label:"Transcript",icon:sl},{value:"files",label:"Files",icon:Kt,activeIcon:Os},{value:"diff",label:"Diff",icon:Ds},{value:"preview",label:"Preview",icon:Rc}];function Yu({activeTab:t}){return e.jsx(Gn,{className:"h-auto max-w-full justify-start gap-2 overflow-x-auto rounded-sm !bg-muted/40 !p-0.5 !shadow-none",children:Qu.map(s=>{const n=s.value===t&&s.activeIcon?s.activeIcon:s.icon;return e.jsx(Pt,{value:s.value,title:s.label,"aria-label":s.label,className:Wu,children:e.jsx(n,{className:"h-3.5 w-3.5","aria-hidden":"true"})},s.value)})})}const Ro="pointer-events-auto h-5 w-5 shrink-0 rounded-sm bg-muted/65 text-muted-foreground hover:bg-muted hover:text-foreground",Rs="h-3.5 w-3.5";function $n({onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:a,centerSlot:i}){return e.jsxs("div",{className:"relative flex w-full items-center justify-between gap-1.5",children:[e.jsx("div",{className:"flex min-w-0 items-center gap-1.5",children:e.jsx(Lo,{desktopTasksOpen:s,mobileTasksPanelOpen:n,onToggleTasks:t,className:"lg:hidden"})}),i&&e.jsx("div",{className:"pointer-events-none absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",children:e.jsx("div",{className:"pointer-events-auto",children:i})}),e.jsx(Bo,{operationsOpen:r,onToggleOperations:a,className:"xl:hidden"})]})}function Lo({className:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,onToggleTasks:r}){const a=globalThis.window?.matchMedia("(min-width: 1024px)")?.matches?s:n;return e.jsx(Z,{variant:"ghost",size:"icon",onClick:r,title:a?"Hide tasks":"Show tasks","aria-label":a?"Hide tasks":"Show tasks",className:O(Ro,t),children:a?e.jsx(Ms,{className:Rs}):e.jsx(lt,{className:Rs})})}function Bo({className:t,operationsOpen:s,onToggleOperations:n}){return e.jsx(Z,{variant:"ghost",size:"icon",onClick:n,title:s?"Hide cluster":"Show cluster","aria-label":s?"Hide cluster":"Show cluster",className:O(Ro,t),children:s?e.jsx(lt,{className:Rs}):e.jsx(Ms,{className:Rs})})}const Br="h-7 w-7 rounded-sm border-0 bg-primary/10 text-primary backdrop-blur hover:bg-primary/20 hover:text-primary";function Ju({active:t,onScrollToBottom:s,onScrollToTop:n}){return e.jsxs("div",{className:O("pointer-events-none absolute right-3 top-1/2 z-10 flex -translate-y-1/2 flex-col gap-2 opacity-0 transition-opacity duration-200 group-hover:pointer-events-auto group-hover:opacity-100",t&&"pointer-events-auto opacity-100"),children:[e.jsx(Z,{type:"button",variant:"ghost",size:"icon",className:Br,onClick:n,"aria-label":"Scroll to top",title:"Scroll to top",children:e.jsx(nl,{className:"h-4 w-4"})}),e.jsx(Z,{type:"button",variant:"ghost",size:"icon",className:Br,onClick:s,"aria-label":"Scroll to bottom",title:"Scroll to bottom",children:e.jsx(st,{className:"h-4 w-4"})})]})}function Zu(t){if(t.type!=="agent.handoff")return null;const s=typeof t.fromAgent=="string"&&t.fromAgent.trim()?t.fromAgent.trim():"agent",n=typeof t.toAgent=="string"&&t.toAgent.trim()?t.toAgent.trim():"";return n?{fromAgent:s,toAgent:n}:null}function Xu({fromAgent:t,toAgent:s}){return e.jsx("div",{className:"flex w-full justify-center py-0.5","data-agent-handoff":s,children:e.jsxs("div",{className:"inline-flex h-6 max-w-full items-center gap-1.5 rounded-sm border border-border/45 bg-muted/22 px-2 text-[10px] leading-3 text-muted-foreground/78",children:[e.jsx(wt,{agent:t,className:"h-3 w-3 shrink-0 text-muted-foreground/65","aria-hidden":"true"}),e.jsxs("span",{className:"truncate",children:[vt(t)," to ",vt(s)]}),e.jsx(wt,{agent:s,className:"h-3 w-3 shrink-0 text-primary/60","aria-hidden":"true"})]})})}const Or="h-[1.625rem] rounded-sm !border-0 !bg-transparent px-2 text-[10.5px] font-medium text-primary !shadow-none hover:!bg-transparent hover:text-primary/80 focus-visible:ring-1 focus-visible:ring-ring/50 focus-visible:ring-offset-0",_t={content:"max-w-[20rem] gap-2.5 rounded-lg border-0 p-3.5 shadow-[0_18px_70px_-44px_rgba(0,0,0,0.72)] sm:max-w-[20rem]",header:"space-y-1 text-left",title:"text-[13px] leading-4",description:"text-[11px] leading-4",footer:"gap-1 pt-0 sm:space-x-1",cancel:`${Or} mt-0`,action:Or},em=30,tm=1600;function sm({savedScrollTop:t,scrollHeight:s,clientHeight:n}){const r=Math.max(0,s-n);return Math.min(Math.max(0,t??r),r)}function tn(t){return t.scrollHeight-t.scrollTop-t.clientHeight<em}function Fr({explicitBottomStickUntil:t,now:s,wasAtBottom:n}){return n||t>s}function sn(t,s){return!!(s&&(t===s||t.contains(s)))}function nn(t){const s=t.ownerDocument.getSelection();if(!s||s.isCollapsed||s.rangeCount===0)return!1;if(sn(t,s.anchorNode)||sn(t,s.focusNode))return!0;for(let n=0;n<s.rangeCount;n+=1)if(sn(t,s.getRangeAt(n).commonAncestorContainer))return!0;return!1}function nm({atTop:t,inputCollapseDisabled:s,scrollingUp:n}){return!s&&(n||t)}function rm({activeTab:t,activeTaskId:s,contentVersion:n,inputCollapseDisabled:r=!1,setActiveTab:a,setInputCollapsed:i}){const l=o.useRef(null),c=o.useRef(s),d=o.useRef(!1),m=o.useRef(0),g=o.useRef(new Map),u=o.useRef(0),f=o.useRef(!0),x=o.useCallback((h=c.current)=>{const v=l.current;!v||!h||(g.current.set(h,v.scrollTop),m.current=v.scrollTop,f.current=tn(v))},[]),N=o.useCallback((h=c.current)=>{const v=l.current;!v||!h||(v.scrollTop=sm({savedScrollTop:g.current.get(h),scrollHeight:v.scrollHeight,clientHeight:v.clientHeight}),m.current=v.scrollTop,f.current=tn(v))},[]),b=o.useCallback((h,v=c.current)=>{h.scrollTop=h.scrollHeight,m.current=h.scrollTop,f.current=!0,v&&g.current.set(v,h.scrollTop)},[]),T=o.useCallback((h=c.current)=>{const v=l.current;u.current=Date.now()+tm,v&&(b(v,h),requestAnimationFrame(()=>{b(v,h),requestAnimationFrame(()=>b(v,h))}))},[b]),p=o.useCallback((h=c.current)=>{const v=l.current;u.current=0,v&&(v.scrollTop=0,m.current=0,f.current=!1,h&&g.current.set(h,0))},[]),k=o.useCallback(h=>{const v=h.currentTarget,j=m.current,E=v.scrollTop<j&&j-v.scrollTop>10,R=v.scrollTop<=0,A=nn(v);if(x(),A){u.current=0;return}if(!d.current){if(tn(v)){i(!1),d.current=!0,setTimeout(()=>{d.current=!1},300);return}(E||R)&&(u.current=0,nm({atTop:R,inputCollapseDisabled:r,scrollingUp:E})&&i(!0))}},[r,x,i]),y=o.useCallback(h=>{t==="transcript"&&x(),a(h),h==="transcript"&&requestAnimationFrame(()=>N())},[t,N,x,a]);return o.useLayoutEffect(()=>{r&&i(!1)},[r,i]),o.useLayoutEffect(()=>{const h=c.current;h&&h!==s&&x(h),c.current=s,t==="transcript"&&requestAnimationFrame(()=>N(s))},[s,t,N,x]),o.useLayoutEffect(()=>{const h=l.current;if(!h||t!=="transcript"||!s)return;const v=Fr({explicitBottomStickUntil:u.current,now:Date.now(),wasAtBottom:f.current});if(nn(h)){u.current=0,x(s);return}v&&b(h,s),x(s)},[s,t,n,x,b]),o.useLayoutEffect(()=>{const h=l.current,v=h?.firstElementChild;if(!h||!v||t!=="transcript"||typeof ResizeObserver>"u")return;const j=new ResizeObserver(()=>{if(nn(h)){u.current=0,x();return}Fr({explicitBottomStickUntil:u.current,now:Date.now(),wasAtBottom:f.current})?b(h):x()});return j.observe(h),j.observe(v),()=>j.disconnect()},[t,s,x,b]),{handleTranscriptScroll:k,handleTranscriptTabChange:y,scrollTranscriptToBottom:T,scrollTranscriptToTop:p,transcriptScrollRef:l}}function Oo(t=700){const[s,n]=o.useState(!1),r=o.useRef(null),a=o.useCallback(()=>{n(!0),r.current!==null&&clearTimeout(r.current),r.current=setTimeout(()=>{n(!1),r.current=null},t)},[t]);return o.useEffect(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]),{markScrollbarActive:a,scrollbarActive:s}}const am="harness";function om(t){return typeof t=="object"&&t!==null}function im(t){return typeof t=="string"&&t.trim().length>0?t.trim():""}function lm(t){return om(t.agentSessions)?Object.keys(t.agentSessions).map(s=>s.trim()).filter(Boolean):[]}function Fo(t){return im(t.payload.activeAgent)||t.agent}function zo(t){return new Set([t.agent,Fo(t),...lm(t.payload)].filter(Boolean)).size>1}function qo(t){return zo(t)?am:t.agent}const cm=o.lazy(async()=>({default:(await Qn(()=>import("./FilesTab-BHeht0ZL.js"),__vite__mapDeps([0,1,2,3,4,5]))).FilesTab})),dm=o.lazy(async()=>({default:(await Qn(()=>import("./PreviewTab-UMpaLVaV.js").then(s=>s.c),__vite__mapDeps([6,1,2]))).PreviewTab})),um=o.lazy(async()=>({default:(await Qn(()=>import("./DiffTab-CNBS3yRm.js"),__vite__mapDeps([7,1,2,5,4,3,6]))).DiffTab}));function mm({onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:a,cluster:i,activeTab:l,setActiveTab:c,creatingTask:d,createMode:m,createDefaults:g,activeTask:u,assignedNode:f,taskLoading:x,transcriptLoading:N,taskError:b,displayEvents:T,initialPromptAlreadyInLogs:p,initialPrompt:k,supportsFollowUp:y,taskUnavailable:h,chatDisabled:v,chatDisabledReason:j,questionBypassEnabled:E,isRunning:R,isStarting:A,hasPendingFollowUp:L,canCancel:M,canRetry:D,onRetry:P,onCancel:F,onReloadNativeTranscript:Q,onShareTask:re,onStopShareTask:W,onStartCreateTask:ee,onCancelCreateTask:se,onCreateTask:q,onSendMessage:X,onCancelQueuedMessage:w,onQuestionBypassChange:K,onSubmitQuestionResponse:C,quickChats:Y=[]}){const[I,U]=o.useState(!1),[B,le]=o.useState(!1),[oe,ue]=o.useState(!1),[J,V]=o.useState(!1),[_,ne]=o.useState(!1),[$,ae]=o.useState({}),[pe,fe]=o.useState(new Set),[Ve,je]=o.useState(new Set),[ht,De]=o.useState(null),[Me,Te]=o.useState(null),Ee=u?.effectiveProjectPath??u?.project??"default workspace",Pe=u?f?.name??_n(u.assignedTo,i?.nodes,u.assignedNodeName):"unassigned",Ue=u?qo(u):"",H=u?Fo(u):"",xe=u&&zo(u)?H:void 0,be=u?.assignedTo?e.jsxs(e.Fragment,{children:["Connecting session on node ",e.jsx("span",{className:"font-semibold",children:Pe}),"..."]}):"Connecting session to an available node...",Xe=u?[{label:"Working dir",value:Ee,mono:!0},...u.branch?[{label:"Branch",value:u.branch,mono:!0}]:[],{label:"Agent",value:Ue,mono:!0},{label:"Node",value:Pe}]:[],Ie=!!(k&&!p),ct=Ie||T.length>0,te=R&&ct,ve=(A||L||R)&&!te,ke=te?"The agent is still working on this conversation.":ve?be:null,{collapsedButtonRunning:ye,showDockedProgress:yt,showInlineProgress:_e}=qu({hasTranscriptProgress:!!ke,hasVisibleTranscriptEvents:ct,inputCollapsed:I}),Nt=u?.conversationKind==="nativeSession",G=Sc(u),ze=N?"Loading transcript":Nt?"No transcript imported":"Transcript is warming up",Re=N?"Loading transcript...":Nt?"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.",jt=u?.queuedMessages??[],xt=o.useMemo(()=>Cc(T),[T]),Qt=o.useMemo(()=>{let we=u?.agent??"";return xt.map(Ce=>{const Qe=Zu(Ce.event);if(Qe)return we=Qe.toAgent,{...Ce,agent:we,handoff:Qe};const pt=typeof Ce.event.agent=="string"&&Ce.event.agent.trim()?Ce.event.agent.trim():we;return{...Ce,agent:pt,handoff:null}})},[u?.agent,xt]),$e=o.useMemo(()=>{const we=u?.assignedTo?u.assignedTo===i?.self?.id?f?.supportedAgents??i.self.supportedAgents:f?.supportedAgents:i?.self?.supportedAgents;return rl({nodeSupportedAgents:we,taskAgent:u?.agent,activeAgent:typeof u?.payload.activeAgent=="string"?u.payload.activeAgent:void 0})},[f?.supportedAgents,i?.self?.id,i?.self?.supportedAgents,u?.assignedTo,u?.agent,u?.payload.activeAgent]),nt=o.useMemo(()=>xt.findIndex(({event:we})=>fm(we)),[xt]),kt=o.useMemo(()=>Tc("transcript",xt.map(we=>we.event)),[xt]),Dt=u&&!pe.has(u.id)?$[u.id]??u.activeShare??null:null,rt=u?.id??null,Ot=`${rt??"none"}:${T.length}:${jt.length}:${Ie?1:0}:${N?1:0}:${_e?1:0}`,{handleTranscriptScroll:qe,handleTranscriptTabChange:et,scrollTranscriptToBottom:Se,scrollTranscriptToTop:dt,transcriptScrollRef:We}=rm({activeTab:l,activeTaskId:rt,contentVersion:Ot,inputCollapseDisabled:!!ke,setActiveTab:c,setInputCollapsed:U}),{markScrollbarActive:Ft,scrollbarActive:St}=Oo(),He=o.useCallback(we=>{Ft(),qe(we)},[qe,Ft]),Je=o.useCallback(we=>{De(Ce=>({path:we,requestId:(Ce?.requestId??0)+1})),et("files")},[et]),qs=o.useCallback(we=>{Te(Ce=>({path:we,requestId:(Ce?.requestId??0)+1})),et("preview")},[et]),tt=o.useCallback((we,Ce)=>{Se(),X(we,Ce)},[X,Se]);return o.useEffect(()=>{De(null),Te(null)},[rt]),d?e.jsx(hm,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:a,cluster:i,defaultMode:m,createDefaults:g,onCancel:se,onCreated:q,quickChats:Y}):!u&&x?e.jsxs("div",{className:"dashboard-conversation-panel dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsx("div",{className:"dashboard-conversation-panel__header shrink-0 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx($n,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:a})}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-4 py-6 sm:px-6",children:e.jsxs("div",{className:"space-y-3 text-center",children:[e.jsx("div",{className:"mx-auto flex h-10 w-10 items-center justify-center rounded-sm border border-primary/20 bg-primary/10 text-primary shadow-none",children:e.jsx(me,{className:"h-5 w-5 animate-spin"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:"Loading conversation"}),e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[11px] text-muted-foreground",children:[e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}),"Fetching the selected chat thread..."]})]})]})})]}):u?e.jsxs(Wn,{value:l,onValueChange:et,className:"dashboard-conversation-panel dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsxs("div",{className:"dashboard-conversation-panel__header relative shrink-0 bg-card/28 px-3 pb-0.5 pt-1 sm:px-5 sm:pt-1.5",children:[e.jsxs("div",{className:"pointer-events-none absolute left-1 right-1 top-2 flex items-center justify-between sm:left-1.5 sm:right-1.5 sm:top-2.5",children:[e.jsx(Lo,{desktopTasksOpen:s,mobileTasksPanelOpen:n,onToggleTasks:t,className:"lg:hidden"}),e.jsx(Bo,{operationsOpen:r,onToggleOperations:a,className:"xl:hidden"})]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 pl-5 sm:pl-6 lg:pl-0",children:[e.jsx("h2",{className:"min-w-0 truncate text-[13px] font-semibold leading-5 text-foreground sm:text-[15px]",title:u.title,children:u.title}),e.jsx(Qa,{status:u.status,isNative:Nt}),G&&e.jsxs("span",{"data-task-goal-label":"true",title:"Codex goal",className:"inline-flex h-5 shrink-0 items-center gap-1 rounded-sm bg-primary/10 px-1.5 text-[9px] font-semibold uppercase tracking-[0.12em] text-primary",children:[e.jsx(co,{className:"h-3 w-3","aria-hidden":"true"}),"Goal"]}),u.priority!=="normal"&&e.jsx(ol,{priority:u.priority})]}),b&&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:b}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 pl-5 sm:pl-6 lg:pl-0",children:[e.jsx(Yu,{activeTab:l}),h&&e.jsx(Ye,{variant:"outline",className:"hidden rounded-sm border-destructive/25 bg-destructive/10 text-destructive sm:inline-flex",children:"Unavailable"}),e.jsxs("div",{className:"ml-auto flex items-center gap-1 text-[10px] text-muted-foreground",children:[e.jsx("span",{className:"hidden rounded-sm bg-muted/65 px-1.5 py-0.5 tabular-nums sm:inline-flex",children:il(u.updatedAt)}),D&&e.jsxs(Z,{variant:"ghost",size:"sm",onClick:P,"aria-label":"Retry task",title:"Retry task",className:"h-7 shrink-0 rounded-sm border-0 bg-primary/10 px-2 text-[10px] text-primary shadow-none hover:bg-primary/15 hover:text-primary",children:[e.jsx(bd,{className:"h-3.5 w-3.5"}),"Retry"]}),Nt&&Q&&e.jsx(Z,{variant:"ghost",size:"icon",onClick:Q,disabled:N,title:"Reload native session transcript","aria-label":"Reload native session transcript",className:"h-6 w-6 shrink-0 rounded-sm text-muted-foreground hover:bg-muted/55 hover:text-foreground",children:e.jsx(vo,{className:O("h-3.5 w-3.5",N&&"animate-spin")})}),e.jsx(Z,{type:"button",variant:"ghost",size:"icon",disabled:h,title:h?"Unavailable tasks cannot be shared.":"Share conversation","aria-label":h?"Unavailable tasks cannot be shared.":"Share conversation",className:"h-6 w-6 shrink-0 rounded-sm text-primary hover:bg-primary/10 hover:text-primary disabled:bg-transparent disabled:text-muted-foreground",onClick:()=>ue(!0),children:e.jsx(Ps,{className:"h-3.5 w-3.5"})})]})]})]}),e.jsx(bt,{value:"transcript",className:"mt-0 min-h-0 flex-1",children:e.jsxs("div",{className:"group relative flex h-full min-h-0 flex-col",children:[e.jsx("div",{className:"relative min-h-0 flex-1",children:e.jsx("div",{ref:We,"data-transcript-scroll":"true",className:O("scrollbar-line h-full min-h-0 touch-pan-y overflow-x-hidden overflow-y-auto overscroll-x-none bg-gradient-to-b from-background/15 via-transparent to-background/35 px-3 pb-4 pt-4 sm:px-5",St&&"scrollbar-line-active"),onScroll:He,children:e.jsxs("div",{"data-transcript-scroll-content":"true",className:"mx-auto flex max-w-[72rem] flex-col gap-4",children:[Ie&&k&&e.jsx(Sr,{event:k,agent:u.agent,sentAsGoal:G,taskRootPath:u.effectiveProjectPath,onOpenFilePath:Je,questionBypassEnabled:E,onQuestionBypassChange:K,onSubmitQuestionResponse:C,questionResponseDisabled:!y||v}),Qt.map(({event:we,subItems:Ce,agent:Qe,handoff:pt},Yt)=>pt?e.jsx(Xu,{fromAgent:pt.fromAgent,toAgent:pt.toAgent},kt[Yt]):e.jsx(Sr,{event:we,agent:Qe,subItems:Ce,sentAsGoal:G&&!Ie&&Yt===nt,taskRootPath:u.effectiveProjectPath,onOpenFilePath:Je,questionBypassEnabled:E,onQuestionBypassChange:K,onSubmitQuestionResponse:C,questionResponseDisabled:!y||v},kt[Yt])),!ct&&!ve&&e.jsxs("div",{className:"rounded-sm border border-dashed border-border/70 bg-background/35 px-3 py-4 text-center",children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground",children:ze}),e.jsx("div",{className:"mt-2 text-[11px] leading-6 text-muted-foreground",children:Re})]}),(!y&&u.result||u.error)&&e.jsxs("div",{className:"space-y-3",children:[!y&&u.result&&e.jsxs("div",{className:"rounded-sm border border-border/70 bg-card/80 px-3 py-3",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:"Stored result"}),e.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-[11px] leading-5 text-muted-foreground",children:JSON.stringify(u.result,null,2)})]}),u.error&&!Ve.has(u.id)&&e.jsxs("div",{className:"rounded-sm border border-destructive/20 bg-destructive/10 px-3 py-3 text-destructive",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em]",children:"Stored error"}),e.jsx("button",{onClick:()=>je(we=>new Set(we).add(u.id)),className:"rounded p-0.5 hover:bg-destructive/20","aria-label":"Dismiss error",children:e.jsx(it,{className:"h-3.5 w-3.5"})})]}),e.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-[11px] leading-5",children:u.error})]})]}),_e&&ke&&e.jsx(Rr,{children:ke})]})})}),e.jsx(Ju,{active:St,onScrollToBottom:()=>Se(),onScrollToTop:()=>dt()}),yt&&ke&&e.jsx("div",{"data-docked-progress":"true",className:"shrink-0 bg-background/35 px-3 py-1 sm:px-5",children:e.jsx("div",{className:"mx-auto max-w-[72rem]",children:e.jsx(Rr,{children:ke})})}),y?e.jsxs(e.Fragment,{children:[I&&e.jsx(zu,{running:ye,onClick:()=>{U(!1),Se(),requestAnimationFrame(()=>document.querySelector('[data-chat-input-textarea="true"]')?.focus())}}),e.jsxs("div",{className:`shrink-0 ${I?"hidden":""}`,children:[e.jsx(Gu,{messages:jt,onCancelMessage:w}),e.jsx(iu,{onSend:tt,disabled:v,disabledReason:j,contextItems:Xe,agent:u.agent,currentAgent:xe,taskId:u.id,availableAgents:$e,model:typeof u.payload.model=="string"?u.payload.model:null,placeholder:v?j:R?"Queue a message for the next turn...":"Continue the conversation...",running:R||A||L,onStop:M?()=>le(!0):void 0,quickChats:Y})]})]}):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(bt,{value:"files",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx(Js,{label:"Loading files..."}),children:e.jsx(cm,{taskId:u.id,requestedFilePath:ht?.path??null,requestedFileRequestId:ht?.requestId??0,onPreviewFile:qs})})}),e.jsx(bt,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx(Js,{label:"Loading preview..."}),children:e.jsx(dm,{taskId:u.id,requestedEntryPath:Me?.path??null,requestedEntryRequestId:Me?.requestId??0})})}),e.jsx(bt,{value:"diff",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx(Js,{label:"Loading diff..."}),children:e.jsx(um,{taskId:u.id})})}),e.jsx(ss,{open:B,onOpenChange:le,children:e.jsxs(ns,{className:_t.content,children:[e.jsxs(rs,{className:_t.header,children:[e.jsx(as,{className:_t.title,children:"Stop this task?"}),e.jsx(os,{className:_t.description,children:"The task will stop and move to a cancelled state."})]}),e.jsxs(is,{className:_t.footer,children:[e.jsx(ls,{className:_t.cancel,children:"Keep running"}),e.jsx(cs,{className:_t.action,onClick:F,children:"Stop task"})]})]})}),e.jsx(Uu,{open:oe,onOpenChange:ue,sharing:J,stopping:_,shareResult:Dt,onShare:async we=>{if(!u)return null;V(!0);try{const Ce=await re(we);return Ce?.url&&(ae(Qe=>({...Qe,[u.id]:Ce})),fe(Qe=>{const pt=new Set(Qe);return pt.delete(u.id),pt})),Ce}finally{V(!1)}},onStopShare:async()=>{if(!u)return!1;ne(!0);try{const we=await W();return we!==!1&&(ae(Ce=>{const Qe={...Ce};return delete Qe[u.id],Qe}),fe(Ce=>new Set(Ce).add(u.id))),we}finally{ne(!1)}}})]}):e.jsxs("div",{className:"dashboard-conversation-panel dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsx("div",{className:"dashboard-conversation-panel__header shrink-0 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx($n,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:a})}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-4 py-6 sm:px-6",children:e.jsxs("div",{className:"w-full max-w-lg text-center",children:[e.jsx("div",{className:"mx-auto flex h-10 w-10 items-center justify-center rounded-sm border border-primary/20 bg-primary/10 text-primary shadow-none",children:e.jsx(al,{className:"h-5 w-5"})}),e.jsx("h2",{className:"mt-3 text-sm font-semibold tracking-tight text-foreground sm:text-[15px]",children:"No chat selected"}),e.jsx("p",{className:"mx-auto mt-2 max-w-md text-[11px] leading-5 text-muted-foreground",children:"Open a task from the left sidebar to continue the conversation, or start a new task or load a native session."}),e.jsxs(Z,{onClick:()=>ee(),className:"mt-4 h-8 rounded-sm px-3",children:[e.jsx(Fs,{className:"h-3.5 w-3.5"}),"Start or load chat"]}),b&&e.jsx("div",{className:"mx-auto mt-3 max-w-md rounded-sm border border-destructive/20 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:b})]})})]})}function fm(t){return t.type!=="user"||t.isMeta===!0||t.isSidechain===!0?!1:!!Xn(t)?.some(n=>n.type==="text"||n.type==="image")}function hm({onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:a,cluster:i,defaultMode:l,createDefaults:c,onCancel:d,onCreated:m,quickChats:g}){const[u,f]=o.useState(l??"chat");o.useEffect(()=>{l&&f(l)},[l]);const x=e.jsx("div",{className:"flex h-8 items-center gap-0.5 overflow-hidden rounded-sm border border-border/60 bg-background/65 p-0.5 text-[11px] font-medium shadow-none",children:[{value:"chat",label:"New chat",icon:Fs},{value:"native",label:"Load session",icon:er}].map(N=>{const b=N.icon,T=N.value===u;return e.jsxs("button",{type:"button",onClick:()=>f(N.value),"aria-pressed":T,className:O("flex h-7 min-w-28 items-center justify-center gap-1.5 rounded-sm border border-transparent px-2.5 transition-colors duration-150",T?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-background/80 hover:text-foreground"),children:[e.jsx(b,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:N.label})]},N.value)})});return e.jsxs("div",{className:"dashboard-conversation-panel dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsx("div",{className:"dashboard-conversation-panel__header shrink-0 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx($n,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:r,onToggleOperations:a,centerSlot:x})}),e.jsx("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center overflow-y-auto px-4 py-6 sm:px-6",children:e.jsx("div",{className:"w-full max-w-2xl",children:e.jsx(Fu,{nodes:i?.nodes??[],currentNodeRole:i?.self?.role,currentNodeId:i?.self?.id??null,leaderNodeId:i?.leader?.id??null,initialAssignTo:c?.assignTo,initialProject:c?.project,mode:u,onModeChange:f,onCreated:m,onCancel:d,autoFocus:!0,layout:"composer",defaultTaskAgent:i?.self.settingsSnapshot?.defaultTaskAgent,quickChats:g})})})]})}function xm({onAdded:t}){const[s,n]=o.useState(""),[r,a]=o.useState(!1),[i,l]=o.useState(null),c=o.useCallback(async d=>{if(d.preventDefault(),!!s.trim()){a(!0),l(null);try{await ll({leaderEndpoint:s.trim(),transport:"devtunnel"}),t()}catch(m){l(m instanceof Error?m.message:"Failed to join node")}finally{a(!1)}}},[s,t]);return e.jsx(Mt,{className:"overflow-hidden border-border/60 bg-transparent p-0 shadow-none sm:max-w-xl",children:e.jsxs("div",{className:"overflow-hidden rounded-sm border border-border/60 bg-background/95 p-0 shadow-[0_28px_90px_-58px_rgba(0,0,0,0.88)] backdrop-blur-xl",children:[e.jsx("div",{className:"border-b border-border/60 px-3.5 py-2.5",children:e.jsxs(xs,{className:"space-y-1 text-left",children:[e.jsx(Rt,{className:"text-sm tracking-tight",children:"Join node"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Verify the remote leader's DevTunnel Node URL, sync this node's tasks to that leader, and join the cluster as a follower."})]})}),e.jsxs("form",{onSubmit:c,className:"space-y-3 px-3.5 py-3",children:[i&&e.jsx("div",{className:"rounded-sm border border-destructive/20 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:i}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(Ze,{htmlFor:"leader-endpoint",children:"Leader Node URL"}),e.jsx(Ye,{variant:"outline",className:"rounded-sm border-border/70 bg-background/60 text-[10px] uppercase tracking-[0.16em]",children:"DevTunnel only"})]}),e.jsx(ft,{id:"leader-endpoint",type:"url",value:s,onChange:d=>n(d.target.value),placeholder:"https://your-leader.devtunnels.ms",className:"h-8 rounded-sm border-border/70 bg-background/70"})]}),e.jsx("div",{className:"rounded-sm border border-border/60 bg-background/45 px-3 py-2 text-[11px] text-muted-foreground",children:"This does not switch the local node transport or auto-enable a local DevTunnel. Leaving later will detach this node from the remote leader and make it leader of its own cluster again."}),e.jsx(Ya,{className:"border-t border-border/60 pt-3",children:e.jsx(Z,{type:"submit",disabled:!s.trim()||r,className:"rounded-sm",children:r?"Joining...":"Join node"})})]})]})})}function pm({open:t,onOpenChange:s,onAdded:n}){return e.jsx(At,{open:t,onOpenChange:s,children:e.jsx(xm,{onAdded:()=>{s(!1),n()}})})}const gm="absolute top-1/2 z-30 hidden h-10 w-4 -translate-y-1/2 items-center justify-center rounded-full text-muted-foreground opacity-0 outline-none transition-opacity duration-150 hover:opacity-100 focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/55",bm="flex h-7 w-3.5 items-center justify-center rounded-full bg-muted/85 shadow-[0_12px_24px_-20px_rgba(0,0,0,0.9)] backdrop-blur-sm transition-colors hover:bg-card hover:text-foreground",vm="h-2.5 w-2.5";function Uo({className:t,label:s,orientation:n,panel:r,panelResize:a}){return e.jsx("button",{type:"button","aria-label":s,"aria-orientation":n,"data-dashboard-resize-handle":r,onPointerDown:i=>a.onPointerDown(r,i),onWheel:i=>a.onWheel(r,i),className:O("group absolute z-20 hidden touch-none rounded-sm bg-transparent outline-none transition-colors hover:bg-primary/12 focus-visible:bg-primary/12 focus-visible:ring-2 focus-visible:ring-ring/70 lg:block",t),children:e.jsx("span",{className:"pointer-events-none absolute inset-0 opacity-0 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100"})})}function wm({className:t,label:s,onToggle:n,side:r,visible:a}){const i=r==="left"?a?Ms:lt:a?lt:Ms;return e.jsx("button",{type:"button","aria-label":s,title:s,onClick:n,className:O(gm,t),children:e.jsx("span",{className:bm,"aria-hidden":"true",children:e.jsx(i,{className:vm,strokeWidth:2.1})})})}function zr({className:t,label:s,onToggle:n,panel:r,panelResize:a,screen:i,side:l,visible:c}){const d=i==="lg"?"lg:block":"xl:block",m=i==="lg"?"lg:flex":"xl:flex";return e.jsxs("div",{className:O("group absolute top-0 z-30 hidden h-full w-4",d,t),children:[r&&e.jsx(Uo,{panel:r,orientation:"vertical",label:`Resize ${r} panel`,panelResize:a,className:"left-1/2 top-0 h-full w-2 -translate-x-1/2 cursor-col-resize"}),e.jsx(wm,{side:l,visible:c,label:s,onToggle:n,className:O(m,"left-1/2 -translate-x-1/2 group-hover:opacity-100")})]})}function ym({conversationPanel:t,desktopTasksOpen:s,mobileTaskSidebar:n,mobileTasksPanelOpen:r,mobileTasksPanelRef:a,operationsOpen:i,operationsPanelRef:l,operationsSidecar:c,panelResize:d,taskSidebar:m,terminalPanel:g,onCloseOperations:u,onCloseTaskList:f,onToggleOperations:x,onToggleTasks:N}){const b={"--dashboard-tasks-width":d.sizes.tasks,"--dashboard-operations-width":d.sizes.operations,"--dashboard-terminal-height":d.sizes.terminal};return e.jsxs("div",{className:"dashboard-workspace flex h-full min-h-0 flex-col overflow-hidden",style:b,children:[e.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[e.jsx(zr,{screen:"lg",side:"left",visible:s,label:s?"Hide tasks":"Show tasks",onToggle:N,panel:s?"tasks":void 0,panelResize:d,className:s?"left-[var(--dashboard-tasks-width)] -translate-x-1/2":"left-0"}),e.jsx("div",{className:O("dashboard-workspace__tasks-panel relative hidden lg:block lg:shrink-0 lg:transition-all lg:duration-300",s?"lg:mr-2 lg:w-[var(--dashboard-tasks-width)]":"lg:w-0 lg:overflow-hidden"),children:s&&m}),e.jsxs("section",{className:"dashboard-workspace__primary flex min-h-0 min-w-0 flex-1 flex-col gap-2",children:[e.jsx("div",{className:"min-h-0 flex-1",children:t}),g&&e.jsxs("div",{className:"relative h-[var(--dashboard-terminal-height)] min-h-0 shrink-0",children:[e.jsx(Uo,{panel:"terminal",orientation:"horizontal",label:"Resize terminal panel",panelResize:d,className:"-top-1 left-0 h-2 w-full cursor-row-resize"}),g]})]}),e.jsx(zr,{screen:"xl",side:"right",visible:i,label:i?"Hide cluster":"Show cluster",onToggle:x,panel:i?"operations":void 0,panelResize:d,className:i?"right-[var(--dashboard-operations-width)] translate-x-1/2":"right-0"}),e.jsx("div",{className:O("dashboard-workspace__operations-panel relative hidden xl:block xl:shrink-0 xl:transition-all xl:duration-300",i?"xl:ml-2 xl:w-[var(--dashboard-operations-width)]":"xl:w-0 xl:overflow-hidden"),children:i&&c})]}),i&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close operations panel",onClick:u,className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm xl:hidden"}),e.jsx("div",{ref:l,className:"fixed bottom-0 right-0 top-[var(--dashboard-mobile-overlay-top)] z-40 w-full p-2 sm:max-w-sm sm:p-3 xl:hidden",children:c})]}),r&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close task list",onClick:f,className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm lg:hidden"}),e.jsx("div",{ref:a,className:"fixed bottom-0 left-0 top-[var(--dashboard-mobile-overlay-top)] z-40 w-full p-2 sm:max-w-sm sm:p-3 lg:hidden",children:n})]})]})}const Nm=10,It="__all__";function at(t){return"session"in t}function qr(t,s){return s&&t.some(n=>n.id===s)?s:t[0]?.id??""}function rn(t){return t&&(Mo(t.id)||t.workDir)||""}function js(t,s,n){let r=!1;const a=t.map(i=>at(i)&&i.session.id===n.id?(r=!0,{...i,nodeName:s,session:n}):i);return Hn(r?a:[...a,{id:`session-${n.id}`,nodeName:s,session:n}])}function $o(t,s){return t.filter(at).filter(n=>n.session.nodeId===s).sort((n,r)=>r.session.startedAt-n.session.startedAt)}function jm(t){const s=t.filter(at).sort((n,r)=>r.session.startedAt-n.session.startedAt);return{active:s.filter(n=>n.session.status==="running"),completed:s.filter(n=>n.session.status!=="running")}}function km(t,s){return!!(t&&s&&!t.contains(s))}function Sm(t,s,n){if(n===It)return n;const r=$o(t,s);return r.some(a=>a.session.id===n)?n:r[0]?.session.id??It}function Cm(t,s,n){return n===It?t.filter(r=>!at(r)||r.session.nodeId===s):t.filter(r=>at(r)&&r.session.nodeId===s&&r.session.id===n)}function Hn(t){const s=t.map((r,a)=>({entry:r,index:a})).filter(({entry:r})=>at(r)&&r.session.status!=="running").sort((r,a)=>!at(r.entry)||!at(a.entry)?0:a.entry.session.startedAt-r.entry.session.startedAt||a.index-r.index),n=new Set(s.slice(0,Nm).map(({entry:r})=>at(r)?r.session.id:""));return t.filter(r=>!at(r)||r.session.status==="running"||n.has(r.session.id))}function Vn(t){return t.status==="running"?t.pid?`running pid ${t.pid}`:"running":t.status==="exited"?`exit ${t.exitCode??0}`:t.status==="stopped"?"stopped":t.signal?`failed ${t.signal}`:`exit ${t.exitCode??"failed"}`}function Tm(t){const s=t.session.command.length>48?`${t.session.command.slice(0,45)}...`:t.session.command;return`${t.nodeName} - ${Vn(t.session)} - ${s}`}function Ho(t,s=48){return t.length>s?`${t.slice(0,s-3)}...`:t}function Em(t,s){return s===It?"All sessions":t?Ho(t.session.command,34):"Command session"}function Ur(t){return t.status==="stopped"?"":t.stderr}function Am({nodes:t,defaultNodeId:s,onClose:n,initialHistory:r=[]}){const[a,i]=o.useState(()=>qr(t,s)),l=o.useMemo(()=>t.find(C=>C.id===a)??t[0]??null,[t,a]),[c,d]=o.useState(()=>rn(l)),[m,g]=o.useState(""),[u,f]=o.useState(()=>Hn(r)),[x,N]=o.useState(It),[b,T]=o.useState(!1),[p,k]=o.useState(!1),[y,h]=o.useState(!1),[v,j]=o.useState(!1),[E,R]=o.useState(!1),A=o.useRef(null),L=o.useRef(null),M=o.useMemo(()=>t.find(C=>C.id===a)??t[0]??null,[t,a]),D=o.useMemo(()=>$o(u,M?.id??""),[u,M]),P=o.useMemo(()=>jm(D),[D]),F=o.useMemo(()=>D.find(C=>C.session.id===x),[x,D]),Q=o.useMemo(()=>Cm(u,M?.id??"",x),[u,M,x]),re=o.useRef(M?.id??"");o.useEffect(()=>{a&&t.some(C=>C.id===a)||i(qr(t,s))},[s,t,a]),o.useEffect(()=>{const C=M?.id??"";re.current!==C&&(re.current=C,d(rn(M)))},[M]),o.useEffect(()=>{N(C=>Sm(u,M?.id??"",b?C:""))},[u,M,b]),o.useEffect(()=>{A.current?.scrollTo({top:A.current.scrollHeight})},[u]),o.useEffect(()=>{let C=!1;async function Y(){const I=await Promise.allSettled(t.map(async U=>({node:U,response:await dl(U.id)})));C||f(U=>I.reduce((B,le)=>le.status!=="fulfilled"?B:le.value.response.sessions.reduce((oe,ue)=>js(oe,le.value.node.name,ue),B),U))}return t.length>0&&Y(),()=>{C=!0}},[t]),o.useEffect(()=>{const C=u.filter(at).filter(I=>I.session.status==="running");if(C.length===0)return;const Y=window.setInterval(()=>{for(const I of C)cl(I.session.nodeId,I.session.id).then(U=>f(B=>js(B,I.nodeName,U))).catch(()=>{})},1e3);return()=>window.clearInterval(Y)},[u]);const W=o.useRef(null);async function ee(C){if(C.preventDefault(),!M||!m.trim()||E)return;const Y=m.trim(),I=M.name;R(!0),g("");try{const U=await ml(M.id,{command:Y,...c.trim()?{cwd:c.trim()}:{}});f(B=>js(B,I,U)),N(U.id),T(!0)}catch(U){f(B=>[...B,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,nodeName:I,command:Y,error:U instanceof Error?U.message:"Command failed"}])}finally{R(!1)}}async function se(C,Y){C.stopPropagation();const I=await ul(Y.session.nodeId,Y.session.id);f(U=>js(U,Y.nodeName,I))}function q(C){N(C),T(!0),k(!1)}function X(C){p&&km(L.current,C.target)&&k(!1)}function w(C,Y,I,U,B){return e.jsxs("div",{className:"border-t border-border/60 py-1",children:[e.jsxs("button",{type:"button",onClick:U,"aria-label":`Toggle ${C} sessions`,"aria-expanded":!I,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:C}),e.jsx(st,{className:O("h-3 w-3 transition-transform",I&&"-rotate-90")})]}),!I&&(Y.length>0?Y.map(K):e.jsx("div",{className:"node-terminal__control px-2 py-1 text-muted-foreground",children:B}))]})}function K(C){const Y=x===C.session.id,I=C.session.status==="running";return e.jsxs("div",{className:O("node-terminal__control group flex w-full items-center gap-2 px-2 py-1.5 text-left transition-colors hover:bg-muted/65",Y&&"bg-primary/10 text-primary"),children:[e.jsxs("button",{type:"button",onClick:()=>q(C.session.id),className:"flex min-w-0 flex-1 items-center gap-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:[e.jsx("span",{className:O("flex h-4 w-4 shrink-0 items-center justify-center",I?"text-primary":C.session.status==="exited"?"text-emerald-600 dark:text-emerald-300":"text-amber-600 dark:text-amber-300"),children:I?e.jsx(me,{className:"h-3 w-3 animate-spin"}):C.session.status==="exited"?e.jsx(Pn,{className:"h-3 w-3"}):e.jsx(Qs,{className:"h-3 w-3"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-foreground",children:Ho(C.session.command,44)}),e.jsxs("span",{className:"node-terminal__small block truncate text-muted-foreground",children:[C.nodeName," · ",Vn(C.session)]})]})]}),I&&e.jsx("button",{type:"button",onClick:U=>{se(U,C)},"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(Er,{className:"h-3 w-3"})})]},C.session.id)}return e.jsx("section",{className:"dashboard-panel node-terminal animate-composer-settle flex h-full min-h-0 shrink-0 overflow-visible rounded-xl","aria-label":"Node terminal",onClick:X,children:e.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col overflow-visible rounded-[inherit] bg-card/72 text-card-foreground",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-border/60 px-3 py-2",children:[e.jsxs("div",{className:"node-terminal__header flex min-w-0 items-center gap-2 font-medium",children:[n?e.jsx("button",{type:"button",onClick:n,"aria-label":"Close terminal",title:"Close terminal",className:"flex h-6 w-6 items-center justify-center rounded-md text-primary transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:e.jsx(it,{className:"h-3.5 w-3.5"})}):e.jsx(xr,{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:L,className:"relative min-w-0",children:[e.jsxs("button",{type:"button","aria-label":"Command session","aria-expanded":p,title:F?Tm(F):"All sessions",onClick:()=>k(C=>!C),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:Em(F,x)}),e.jsx(st,{className:O("h-3 w-3 shrink-0 text-muted-foreground transition-transform",p&&"rotate-180")})]}),e.jsx("div",{"aria-hidden":!p,className:O("absolute right-0 bottom-9 z-30 w-[19rem] overflow-hidden rounded-xl border border-border/70 bg-popover text-popover-foreground shadow-xl",!p&&"hidden"),children:e.jsxs("div",{className:"max-h-72 overflow-y-auto",children:[e.jsxs("button",{type:"button",onClick:()=>q(It),className:O("node-terminal__control flex w-full items-center gap-2 px-2 py-1.5 text-left transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",x===It&&"bg-primary/10 text-primary"),children:[e.jsx(xr,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:"All sessions"})]}),w("Active",P.active,y,()=>h(C=>!C),"No active sessions"),w("Completed",P.completed,v,()=>j(C=>!C),"No completed sessions")]})})]}),e.jsx("select",{value:M?.id??"",onChange:C=>{i(C.target.value),T(!1),d(rn(t.find(Y=>Y.id===C.target.value)??null))},disabled:E||t.length===0,"aria-label":"Terminal node",className:"node-terminal__control h-7 max-w-[11rem] rounded-sm border border-border/70 bg-background/70 px-2 text-foreground outline-none transition-colors hover:bg-muted/65 disabled:opacity-50",children:t.map(C=>e.jsx("option",{value:C.id,className:"bg-background text-foreground",children:C.name},C.id))}),e.jsx(Is,{value:c,onChange:d,assignTo:M?.id??"",nodes:t,assignableNodes:t,layout:"composer",chipClassName:"node-terminal__control h-7 max-w-[18rem] rounded-sm border border-border/70 bg-background/70 px-2 text-foreground hover:bg-muted/65",chipActiveClassName:"font-mono",chipInactiveClassName:"text-muted-foreground",labelClassName:"node-terminal__workdir",triggerClassName:"terminal-workdir-trigger",popoverPlacement:"top",popoverAlign:"end"})]})]}),e.jsxs("div",{ref:A,className:"node-terminal__body min-h-0 flex-1 overflow-y-auto bg-muted/22 px-3 py-2 font-mono cursor-text",onClick:()=>W.current?.focus(),children:[Q.length===0?e.jsx("div",{className:"text-muted-foreground mb-2",children:"Commands run on the selected node and stay visible while running or after exit."}):e.jsx("div",{className:"space-y-3 mb-2",children:Q.map(C=>at(C)?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:[C.nodeName,"$"]}),e.jsx("span",{className:"break-all text-foreground",children:C.session.command}),e.jsxs("span",{className:O("inline-flex items-center gap-1",C.session.status==="running"||C.session.status==="exited"?"text-primary":"text-amber-600 dark:text-amber-300"),children:[C.session.status==="running"?e.jsx(me,{className:"h-3 w-3 animate-spin"}):C.session.status==="exited"?e.jsx(Pn,{className:"h-3 w-3"}):e.jsx(Qs,{className:"h-3 w-3"}),Vn(C.session)]}),C.session.status==="running"&&e.jsx("button",{type:"button",onClick:Y=>{se(Y,C)},"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(Er,{className:"h-3 w-3"})})]}),C.session.stdout&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-foreground",children:C.session.stdout}),Ur(C.session)&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:Ur(C.session)}),(C.session.stdoutTruncated||C.session.stderrTruncated)&&e.jsx("div",{className:"text-muted-foreground",children:"Output truncated to the latest output."})]},C.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:[C.nodeName,"$"]}),e.jsx("span",{className:"break-all text-foreground",children:C.command}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive",children:[e.jsx(Qs,{className:"h-3 w-3"}),"error"]})]}),e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:C.error})]},C.id))}),e.jsxs("form",{onSubmit:ee,className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"shrink-0 text-primary select-none",children:M?`${M.name}$`:"$"}),e.jsx("input",{ref:W,value:m,onChange:C=>g(C.target.value),disabled:!M||E,placeholder:M?"":"No online nodes available",className:"node-terminal__input flex-1 min-w-0 bg-transparent border-none outline-none text-foreground placeholder:text-muted-foreground font-mono caret-primary disabled:opacity-50",autoComplete:"off",spellCheck:!1}),e.jsx("button",{type:"submit","aria-label":"Run",title:"Run",disabled:!M||!m.trim()||E,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md text-primary transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70 disabled:pointer-events-none disabled:text-muted-foreground disabled:opacity-50",children:E?e.jsx(me,{className:"h-3 w-3 animate-spin"}):e.jsx(Bs,{className:"h-3 w-3"})})]})]})]})})}var Ut={},an,$r;function Mm(){return $r||($r=1,an=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),an}var on={},Tt={},Hr;function Lt(){if(Hr)return Tt;Hr=1;let t;const s=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Tt.getSymbolSize=function(r){if(!r)throw new Error('"version" cannot be null or undefined');if(r<1||r>40)throw new Error('"version" should be in range from 1 to 40');return r*4+17},Tt.getSymbolTotalCodewords=function(r){return s[r]},Tt.getBCHDigit=function(n){let r=0;for(;n!==0;)r++,n>>>=1;return r},Tt.setToSJISFunction=function(r){if(typeof r!="function")throw new Error('"toSJISFunc" is not a valid function.');t=r},Tt.isKanjiModeEnabled=function(){return typeof t<"u"},Tt.toSJIS=function(r){return t(r)},Tt}var ln={},Vr;function nr(){return Vr||(Vr=1,(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function s(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+n)}}t.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},t.from=function(r,a){if(t.isValid(r))return r;try{return s(r)}catch{return a}}})(ln)),ln}var cn,Kr;function Dm(){if(Kr)return cn;Kr=1;function t(){this.buffer=[],this.length=0}return t.prototype={get:function(s){const n=Math.floor(s/8);return(this.buffer[n]>>>7-s%8&1)===1},put:function(s,n){for(let r=0;r<n;r++)this.putBit((s>>>n-r-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(s){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),s&&(this.buffer[n]|=128>>>this.length%8),this.length++}},cn=t,cn}var dn,Gr;function _m(){if(Gr)return dn;Gr=1;function t(s){if(!s||s<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=s,this.data=new Uint8Array(s*s),this.reservedBit=new Uint8Array(s*s)}return t.prototype.set=function(s,n,r,a){const i=s*this.size+n;this.data[i]=r,a&&(this.reservedBit[i]=!0)},t.prototype.get=function(s,n){return this.data[s*this.size+n]},t.prototype.xor=function(s,n,r){this.data[s*this.size+n]^=r},t.prototype.isReserved=function(s,n){return this.reservedBit[s*this.size+n]},dn=t,dn}var un={},Wr;function Pm(){return Wr||(Wr=1,(function(t){const s=Lt().getSymbolSize;t.getRowColCoords=function(r){if(r===1)return[];const a=Math.floor(r/7)+2,i=s(r),l=i===145?26:Math.ceil((i-13)/(2*a-2))*2,c=[i-7];for(let d=1;d<a-1;d++)c[d]=c[d-1]-l;return c.push(6),c.reverse()},t.getPositions=function(r){const a=[],i=t.getRowColCoords(r),l=i.length;for(let c=0;c<l;c++)for(let d=0;d<l;d++)c===0&&d===0||c===0&&d===l-1||c===l-1&&d===0||a.push([i[c],i[d]]);return a}})(un)),un}var mn={},Qr;function Im(){if(Qr)return mn;Qr=1;const t=Lt().getSymbolSize,s=7;return mn.getPositions=function(r){const a=t(r);return[[0,0],[a-s,0],[0,a-s]]},mn}var fn={},Yr;function Rm(){return Yr||(Yr=1,(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const s={N1:3,N2:3,N3:40,N4:10};t.isValid=function(a){return a!=null&&a!==""&&!isNaN(a)&&a>=0&&a<=7},t.from=function(a){return t.isValid(a)?parseInt(a,10):void 0},t.getPenaltyN1=function(a){const i=a.size;let l=0,c=0,d=0,m=null,g=null;for(let u=0;u<i;u++){c=d=0,m=g=null;for(let f=0;f<i;f++){let x=a.get(u,f);x===m?c++:(c>=5&&(l+=s.N1+(c-5)),m=x,c=1),x=a.get(f,u),x===g?d++:(d>=5&&(l+=s.N1+(d-5)),g=x,d=1)}c>=5&&(l+=s.N1+(c-5)),d>=5&&(l+=s.N1+(d-5))}return l},t.getPenaltyN2=function(a){const i=a.size;let l=0;for(let c=0;c<i-1;c++)for(let d=0;d<i-1;d++){const m=a.get(c,d)+a.get(c,d+1)+a.get(c+1,d)+a.get(c+1,d+1);(m===4||m===0)&&l++}return l*s.N2},t.getPenaltyN3=function(a){const i=a.size;let l=0,c=0,d=0;for(let m=0;m<i;m++){c=d=0;for(let g=0;g<i;g++)c=c<<1&2047|a.get(m,g),g>=10&&(c===1488||c===93)&&l++,d=d<<1&2047|a.get(g,m),g>=10&&(d===1488||d===93)&&l++}return l*s.N3},t.getPenaltyN4=function(a){let i=0;const l=a.data.length;for(let d=0;d<l;d++)i+=a.data[d];return Math.abs(Math.ceil(i*100/l/5)-10)*s.N4};function n(r,a,i){switch(r){case t.Patterns.PATTERN000:return(a+i)%2===0;case t.Patterns.PATTERN001:return a%2===0;case t.Patterns.PATTERN010:return i%3===0;case t.Patterns.PATTERN011:return(a+i)%3===0;case t.Patterns.PATTERN100:return(Math.floor(a/2)+Math.floor(i/3))%2===0;case t.Patterns.PATTERN101:return a*i%2+a*i%3===0;case t.Patterns.PATTERN110:return(a*i%2+a*i%3)%2===0;case t.Patterns.PATTERN111:return(a*i%3+(a+i)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}t.applyMask=function(a,i){const l=i.size;for(let c=0;c<l;c++)for(let d=0;d<l;d++)i.isReserved(d,c)||i.xor(d,c,n(a,d,c))},t.getBestMask=function(a,i){const l=Object.keys(t.Patterns).length;let c=0,d=1/0;for(let m=0;m<l;m++){i(m),t.applyMask(m,a);const g=t.getPenaltyN1(a)+t.getPenaltyN2(a)+t.getPenaltyN3(a)+t.getPenaltyN4(a);t.applyMask(m,a),g<d&&(d=g,c=m)}return c}})(fn)),fn}var ks={},Jr;function Vo(){if(Jr)return ks;Jr=1;const t=nr(),s=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],n=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return ks.getBlocksCount=function(a,i){switch(i){case t.L:return s[(a-1)*4+0];case t.M:return s[(a-1)*4+1];case t.Q:return s[(a-1)*4+2];case t.H:return s[(a-1)*4+3];default:return}},ks.getTotalCodewordsCount=function(a,i){switch(i){case t.L:return n[(a-1)*4+0];case t.M:return n[(a-1)*4+1];case t.Q:return n[(a-1)*4+2];case t.H:return n[(a-1)*4+3];default:return}},ks}var hn={},es={},Zr;function Lm(){if(Zr)return es;Zr=1;const t=new Uint8Array(512),s=new Uint8Array(256);return(function(){let r=1;for(let a=0;a<255;a++)t[a]=r,s[r]=a,r<<=1,r&256&&(r^=285);for(let a=255;a<512;a++)t[a]=t[a-255]})(),es.log=function(r){if(r<1)throw new Error("log("+r+")");return s[r]},es.exp=function(r){return t[r]},es.mul=function(r,a){return r===0||a===0?0:t[s[r]+s[a]]},es}var Xr;function Bm(){return Xr||(Xr=1,(function(t){const s=Lm();t.mul=function(r,a){const i=new Uint8Array(r.length+a.length-1);for(let l=0;l<r.length;l++)for(let c=0;c<a.length;c++)i[l+c]^=s.mul(r[l],a[c]);return i},t.mod=function(r,a){let i=new Uint8Array(r);for(;i.length-a.length>=0;){const l=i[0];for(let d=0;d<a.length;d++)i[d]^=s.mul(a[d],l);let c=0;for(;c<i.length&&i[c]===0;)c++;i=i.slice(c)}return i},t.generateECPolynomial=function(r){let a=new Uint8Array([1]);for(let i=0;i<r;i++)a=t.mul(a,new Uint8Array([1,s.exp(i)]));return a}})(hn)),hn}var xn,ea;function Om(){if(ea)return xn;ea=1;const t=Bm();function s(n){this.genPoly=void 0,this.degree=n,this.degree&&this.initialize(this.degree)}return s.prototype.initialize=function(r){this.degree=r,this.genPoly=t.generateECPolynomial(this.degree)},s.prototype.encode=function(r){if(!this.genPoly)throw new Error("Encoder not initialized");const a=new Uint8Array(r.length+this.degree);a.set(r);const i=t.mod(a,this.genPoly),l=this.degree-i.length;if(l>0){const c=new Uint8Array(this.degree);return c.set(i,l),c}return i},xn=s,xn}var pn={},gn={},bn={},ta;function Ko(){return ta||(ta=1,bn.isValid=function(s){return!isNaN(s)&&s>=1&&s<=40}),bn}var gt={},sa;function Go(){if(sa)return gt;sa=1;const t="[0-9]+",s="[A-Z $%*+\\-./:]+";let n="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";n=n.replace(/u/g,"\\u");const r="(?:(?![A-Z0-9 $%*+\\-./:]|"+n+`)(?:.|[\r
|
|
175
|
-
]))+`;gt.KANJI=new RegExp(n,"g"),gt.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),gt.BYTE=new RegExp(r,"g"),gt.NUMERIC=new RegExp(t,"g"),gt.ALPHANUMERIC=new RegExp(s,"g");const a=new RegExp("^"+n+"$"),i=new RegExp("^"+t+"$"),l=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return gt.testKanji=function(d){return a.test(d)},gt.testNumeric=function(d){return i.test(d)},gt.testAlphanumeric=function(d){return l.test(d)},gt}var na;function Bt(){return na||(na=1,(function(t){const s=Ko(),n=Go();t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(i,l){if(!i.ccBits)throw new Error("Invalid mode: "+i);if(!s.isValid(l))throw new Error("Invalid version: "+l);return l>=1&&l<10?i.ccBits[0]:l<27?i.ccBits[1]:i.ccBits[2]},t.getBestModeForData=function(i){return n.testNumeric(i)?t.NUMERIC:n.testAlphanumeric(i)?t.ALPHANUMERIC:n.testKanji(i)?t.KANJI:t.BYTE},t.toString=function(i){if(i&&i.id)return i.id;throw new Error("Invalid mode")},t.isValid=function(i){return i&&i.bit&&i.ccBits};function r(a){if(typeof a!="string")throw new Error("Param is not a string");switch(a.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+a)}}t.from=function(i,l){if(t.isValid(i))return i;try{return r(i)}catch{return l}}})(gn)),gn}var ra;function Fm(){return ra||(ra=1,(function(t){const s=Lt(),n=Vo(),r=nr(),a=Bt(),i=Ko(),l=7973,c=s.getBCHDigit(l);function d(f,x,N){for(let b=1;b<=40;b++)if(x<=t.getCapacity(b,N,f))return b}function m(f,x){return a.getCharCountIndicator(f,x)+4}function g(f,x){let N=0;return f.forEach(function(b){const T=m(b.mode,x);N+=T+b.getBitsLength()}),N}function u(f,x){for(let N=1;N<=40;N++)if(g(f,N)<=t.getCapacity(N,x,a.MIXED))return N}t.from=function(x,N){return i.isValid(x)?parseInt(x,10):N},t.getCapacity=function(x,N,b){if(!i.isValid(x))throw new Error("Invalid QR Code version");typeof b>"u"&&(b=a.BYTE);const T=s.getSymbolTotalCodewords(x),p=n.getTotalCodewordsCount(x,N),k=(T-p)*8;if(b===a.MIXED)return k;const y=k-m(b,x);switch(b){case a.NUMERIC:return Math.floor(y/10*3);case a.ALPHANUMERIC:return Math.floor(y/11*2);case a.KANJI:return Math.floor(y/13);case a.BYTE:default:return Math.floor(y/8)}},t.getBestVersionForData=function(x,N){let b;const T=r.from(N,r.M);if(Array.isArray(x)){if(x.length>1)return u(x,T);if(x.length===0)return 1;b=x[0]}else b=x;return d(b.mode,b.getLength(),T)},t.getEncodedBits=function(x){if(!i.isValid(x)||x<7)throw new Error("Invalid QR Code version");let N=x<<12;for(;s.getBCHDigit(N)-c>=0;)N^=l<<s.getBCHDigit(N)-c;return x<<12|N}})(pn)),pn}var vn={},aa;function zm(){if(aa)return vn;aa=1;const t=Lt(),s=1335,n=21522,r=t.getBCHDigit(s);return vn.getEncodedBits=function(i,l){const c=i.bit<<3|l;let d=c<<10;for(;t.getBCHDigit(d)-r>=0;)d^=s<<t.getBCHDigit(d)-r;return(c<<10|d)^n},vn}var wn={},yn,oa;function qm(){if(oa)return yn;oa=1;const t=Bt();function s(n){this.mode=t.NUMERIC,this.data=n.toString()}return s.getBitsLength=function(r){return 10*Math.floor(r/3)+(r%3?r%3*3+1:0)},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(r){let a,i,l;for(a=0;a+3<=this.data.length;a+=3)i=this.data.substr(a,3),l=parseInt(i,10),r.put(l,10);const c=this.data.length-a;c>0&&(i=this.data.substr(a),l=parseInt(i,10),r.put(l,c*3+1))},yn=s,yn}var Nn,ia;function Um(){if(ia)return Nn;ia=1;const t=Bt(),s=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function n(r){this.mode=t.ALPHANUMERIC,this.data=r}return n.getBitsLength=function(a){return 11*Math.floor(a/2)+6*(a%2)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(a){let i;for(i=0;i+2<=this.data.length;i+=2){let l=s.indexOf(this.data[i])*45;l+=s.indexOf(this.data[i+1]),a.put(l,11)}this.data.length%2&&a.put(s.indexOf(this.data[i]),6)},Nn=n,Nn}var jn,la;function $m(){if(la)return jn;la=1;const t=Bt();function s(n){this.mode=t.BYTE,typeof n=="string"?this.data=new TextEncoder().encode(n):this.data=new Uint8Array(n)}return s.getBitsLength=function(r){return r*8},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(n){for(let r=0,a=this.data.length;r<a;r++)n.put(this.data[r],8)},jn=s,jn}var kn,ca;function Hm(){if(ca)return kn;ca=1;const t=Bt(),s=Lt();function n(r){this.mode=t.KANJI,this.data=r}return n.getBitsLength=function(a){return a*13},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(r){let a;for(a=0;a<this.data.length;a++){let i=s.toSJIS(this.data[a]);if(i>=33088&&i<=40956)i-=33088;else if(i>=57408&&i<=60351)i-=49472;else throw new Error("Invalid SJIS character: "+this.data[a]+`
|
|
176
|
-
Make sure your charset is UTF-8`);i=(i>>>8&255)*192+(i&255),r.put(i,13)}},kn=n,kn}var Sn={exports:{}},da;function Vm(){return da||(da=1,(function(t){var s={single_source_shortest_paths:function(n,r,a){var i={},l={};l[r]=0;var c=s.PriorityQueue.make();c.push(r,0);for(var d,m,g,u,f,x,N,b,T;!c.empty();){d=c.pop(),m=d.value,u=d.cost,f=n[m]||{};for(g in f)f.hasOwnProperty(g)&&(x=f[g],N=u+x,b=l[g],T=typeof l[g]>"u",(T||b>N)&&(l[g]=N,c.push(g,N),i[g]=m))}if(typeof a<"u"&&typeof l[a]>"u"){var p=["Could not find a path from ",r," to ",a,"."].join("");throw new Error(p)}return i},extract_shortest_path_from_predecessor_list:function(n,r){for(var a=[],i=r;i;)a.push(i),n[i],i=n[i];return a.reverse(),a},find_path:function(n,r,a){var i=s.single_source_shortest_paths(n,r,a);return s.extract_shortest_path_from_predecessor_list(i,a)},PriorityQueue:{make:function(n){var r=s.PriorityQueue,a={},i;n=n||{};for(i in r)r.hasOwnProperty(i)&&(a[i]=r[i]);return a.queue=[],a.sorter=n.sorter||r.default_sorter,a},default_sorter:function(n,r){return n.cost-r.cost},push:function(n,r){var a={value:n,cost:r};this.queue.push(a),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t.exports=s})(Sn)),Sn.exports}var ua;function Km(){return ua||(ua=1,(function(t){const s=Bt(),n=qm(),r=Um(),a=$m(),i=Hm(),l=Go(),c=Lt(),d=Vm();function m(p){return unescape(encodeURIComponent(p)).length}function g(p,k,y){const h=[];let v;for(;(v=p.exec(y))!==null;)h.push({data:v[0],index:v.index,mode:k,length:v[0].length});return h}function u(p){const k=g(l.NUMERIC,s.NUMERIC,p),y=g(l.ALPHANUMERIC,s.ALPHANUMERIC,p);let h,v;return c.isKanjiModeEnabled()?(h=g(l.BYTE,s.BYTE,p),v=g(l.KANJI,s.KANJI,p)):(h=g(l.BYTE_KANJI,s.BYTE,p),v=[]),k.concat(y,h,v).sort(function(E,R){return E.index-R.index}).map(function(E){return{data:E.data,mode:E.mode,length:E.length}})}function f(p,k){switch(k){case s.NUMERIC:return n.getBitsLength(p);case s.ALPHANUMERIC:return r.getBitsLength(p);case s.KANJI:return i.getBitsLength(p);case s.BYTE:return a.getBitsLength(p)}}function x(p){return p.reduce(function(k,y){const h=k.length-1>=0?k[k.length-1]:null;return h&&h.mode===y.mode?(k[k.length-1].data+=y.data,k):(k.push(y),k)},[])}function N(p){const k=[];for(let y=0;y<p.length;y++){const h=p[y];switch(h.mode){case s.NUMERIC:k.push([h,{data:h.data,mode:s.ALPHANUMERIC,length:h.length},{data:h.data,mode:s.BYTE,length:h.length}]);break;case s.ALPHANUMERIC:k.push([h,{data:h.data,mode:s.BYTE,length:h.length}]);break;case s.KANJI:k.push([h,{data:h.data,mode:s.BYTE,length:m(h.data)}]);break;case s.BYTE:k.push([{data:h.data,mode:s.BYTE,length:m(h.data)}])}}return k}function b(p,k){const y={},h={start:{}};let v=["start"];for(let j=0;j<p.length;j++){const E=p[j],R=[];for(let A=0;A<E.length;A++){const L=E[A],M=""+j+A;R.push(M),y[M]={node:L,lastCount:0},h[M]={};for(let D=0;D<v.length;D++){const P=v[D];y[P]&&y[P].node.mode===L.mode?(h[P][M]=f(y[P].lastCount+L.length,L.mode)-f(y[P].lastCount,L.mode),y[P].lastCount+=L.length):(y[P]&&(y[P].lastCount=L.length),h[P][M]=f(L.length,L.mode)+4+s.getCharCountIndicator(L.mode,k))}}v=R}for(let j=0;j<v.length;j++)h[v[j]].end=0;return{map:h,table:y}}function T(p,k){let y;const h=s.getBestModeForData(p);if(y=s.from(k,h),y!==s.BYTE&&y.bit<h.bit)throw new Error('"'+p+'" cannot be encoded with mode '+s.toString(y)+`.
|
|
177
|
-
Suggested mode is: `+s.toString(h));switch(y===s.KANJI&&!c.isKanjiModeEnabled()&&(y=s.BYTE),y){case s.NUMERIC:return new n(p);case s.ALPHANUMERIC:return new r(p);case s.KANJI:return new i(p);case s.BYTE:return new a(p)}}t.fromArray=function(k){return k.reduce(function(y,h){return typeof h=="string"?y.push(T(h,null)):h.data&&y.push(T(h.data,h.mode)),y},[])},t.fromString=function(k,y){const h=u(k,c.isKanjiModeEnabled()),v=N(h),j=b(v,y),E=d.find_path(j.map,"start","end"),R=[];for(let A=1;A<E.length-1;A++)R.push(j.table[E[A]].node);return t.fromArray(x(R))},t.rawSplit=function(k){return t.fromArray(u(k,c.isKanjiModeEnabled()))}})(wn)),wn}var ma;function Gm(){if(ma)return on;ma=1;const t=Lt(),s=nr(),n=Dm(),r=_m(),a=Pm(),i=Im(),l=Rm(),c=Vo(),d=Om(),m=Fm(),g=zm(),u=Bt(),f=Km();function x(j,E){const R=j.size,A=i.getPositions(E);for(let L=0;L<A.length;L++){const M=A[L][0],D=A[L][1];for(let P=-1;P<=7;P++)if(!(M+P<=-1||R<=M+P))for(let F=-1;F<=7;F++)D+F<=-1||R<=D+F||(P>=0&&P<=6&&(F===0||F===6)||F>=0&&F<=6&&(P===0||P===6)||P>=2&&P<=4&&F>=2&&F<=4?j.set(M+P,D+F,!0,!0):j.set(M+P,D+F,!1,!0))}}function N(j){const E=j.size;for(let R=8;R<E-8;R++){const A=R%2===0;j.set(R,6,A,!0),j.set(6,R,A,!0)}}function b(j,E){const R=a.getPositions(E);for(let A=0;A<R.length;A++){const L=R[A][0],M=R[A][1];for(let D=-2;D<=2;D++)for(let P=-2;P<=2;P++)D===-2||D===2||P===-2||P===2||D===0&&P===0?j.set(L+D,M+P,!0,!0):j.set(L+D,M+P,!1,!0)}}function T(j,E){const R=j.size,A=m.getEncodedBits(E);let L,M,D;for(let P=0;P<18;P++)L=Math.floor(P/3),M=P%3+R-8-3,D=(A>>P&1)===1,j.set(L,M,D,!0),j.set(M,L,D,!0)}function p(j,E,R){const A=j.size,L=g.getEncodedBits(E,R);let M,D;for(M=0;M<15;M++)D=(L>>M&1)===1,M<6?j.set(M,8,D,!0):M<8?j.set(M+1,8,D,!0):j.set(A-15+M,8,D,!0),M<8?j.set(8,A-M-1,D,!0):M<9?j.set(8,15-M-1+1,D,!0):j.set(8,15-M-1,D,!0);j.set(A-8,8,1,!0)}function k(j,E){const R=j.size;let A=-1,L=R-1,M=7,D=0;for(let P=R-1;P>0;P-=2)for(P===6&&P--;;){for(let F=0;F<2;F++)if(!j.isReserved(L,P-F)){let Q=!1;D<E.length&&(Q=(E[D]>>>M&1)===1),j.set(L,P-F,Q),M--,M===-1&&(D++,M=7)}if(L+=A,L<0||R<=L){L-=A,A=-A;break}}}function y(j,E,R){const A=new n;R.forEach(function(F){A.put(F.mode.bit,4),A.put(F.getLength(),u.getCharCountIndicator(F.mode,j)),F.write(A)});const L=t.getSymbolTotalCodewords(j),M=c.getTotalCodewordsCount(j,E),D=(L-M)*8;for(A.getLengthInBits()+4<=D&&A.put(0,4);A.getLengthInBits()%8!==0;)A.putBit(0);const P=(D-A.getLengthInBits())/8;for(let F=0;F<P;F++)A.put(F%2?17:236,8);return h(A,j,E)}function h(j,E,R){const A=t.getSymbolTotalCodewords(E),L=c.getTotalCodewordsCount(E,R),M=A-L,D=c.getBlocksCount(E,R),P=A%D,F=D-P,Q=Math.floor(A/D),re=Math.floor(M/D),W=re+1,ee=Q-re,se=new d(ee);let q=0;const X=new Array(D),w=new Array(D);let K=0;const C=new Uint8Array(j.buffer);for(let le=0;le<D;le++){const oe=le<F?re:W;X[le]=C.slice(q,q+oe),w[le]=se.encode(X[le]),q+=oe,K=Math.max(K,oe)}const Y=new Uint8Array(A);let I=0,U,B;for(U=0;U<K;U++)for(B=0;B<D;B++)U<X[B].length&&(Y[I++]=X[B][U]);for(U=0;U<ee;U++)for(B=0;B<D;B++)Y[I++]=w[B][U];return Y}function v(j,E,R,A){let L;if(Array.isArray(j))L=f.fromArray(j);else if(typeof j=="string"){let Q=E;if(!Q){const re=f.rawSplit(j);Q=m.getBestVersionForData(re,R)}L=f.fromString(j,Q||40)}else throw new Error("Invalid data");const M=m.getBestVersionForData(L,R);if(!M)throw new Error("The amount of data is too big to be stored in a QR Code");if(!E)E=M;else if(E<M)throw new Error(`
|
|
178
|
-
The chosen QR Code version cannot contain this amount of data.
|
|
179
|
-
Minimum version required to store current data is: `+M+`.
|
|
180
|
-
`);const D=y(E,R,L),P=t.getSymbolSize(E),F=new r(P);return x(F,E),N(F),b(F,E),p(F,R,0),E>=7&&T(F,E),k(F,D),isNaN(A)&&(A=l.getBestMask(F,p.bind(null,F,R))),l.applyMask(A,F),p(F,R,A),{modules:F,version:E,errorCorrectionLevel:R,maskPattern:A,segments:L}}return on.create=function(E,R){if(typeof E>"u"||E==="")throw new Error("No input text");let A=s.M,L,M;return typeof R<"u"&&(A=s.from(R.errorCorrectionLevel,s.M),L=m.from(R.version),M=l.from(R.maskPattern),R.toSJISFunc&&t.setToSJISFunction(R.toSJISFunc)),v(E,L,A,M)},on}var Cn={},Tn={},fa;function Wo(){return fa||(fa=1,(function(t){function s(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let r=n.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+n);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(i){return[i,i]}))),r.length===6&&r.push("F","F");const a=parseInt(r.join(""),16);return{r:a>>24&255,g:a>>16&255,b:a>>8&255,a:a&255,hex:"#"+r.slice(0,6).join("")}}t.getOptions=function(r){r||(r={}),r.color||(r.color={});const a=typeof r.margin>"u"||r.margin===null||r.margin<0?4:r.margin,i=r.width&&r.width>=21?r.width:void 0,l=r.scale||4;return{width:i,scale:i?4:l,margin:a,color:{dark:s(r.color.dark||"#000000ff"),light:s(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},t.getScale=function(r,a){return a.width&&a.width>=r+a.margin*2?a.width/(r+a.margin*2):a.scale},t.getImageWidth=function(r,a){const i=t.getScale(r,a);return Math.floor((r+a.margin*2)*i)},t.qrToImageData=function(r,a,i){const l=a.modules.size,c=a.modules.data,d=t.getScale(l,i),m=Math.floor((l+i.margin*2)*d),g=i.margin*d,u=[i.color.light,i.color.dark];for(let f=0;f<m;f++)for(let x=0;x<m;x++){let N=(f*m+x)*4,b=i.color.light;if(f>=g&&x>=g&&f<m-g&&x<m-g){const T=Math.floor((f-g)/d),p=Math.floor((x-g)/d);b=u[c[T*l+p]?1:0]}r[N++]=b.r,r[N++]=b.g,r[N++]=b.b,r[N]=b.a}}})(Tn)),Tn}var ha;function Wm(){return ha||(ha=1,(function(t){const s=Wo();function n(a,i,l){a.clearRect(0,0,i.width,i.height),i.style||(i.style={}),i.height=l,i.width=l,i.style.height=l+"px",i.style.width=l+"px"}function r(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}t.render=function(i,l,c){let d=c,m=l;typeof d>"u"&&(!l||!l.getContext)&&(d=l,l=void 0),l||(m=r()),d=s.getOptions(d);const g=s.getImageWidth(i.modules.size,d),u=m.getContext("2d"),f=u.createImageData(g,g);return s.qrToImageData(f.data,i,d),n(u,m,g),u.putImageData(f,0,0),m},t.renderToDataURL=function(i,l,c){let d=c;typeof d>"u"&&(!l||!l.getContext)&&(d=l,l=void 0),d||(d={});const m=t.render(i,l,d),g=d.type||"image/png",u=d.rendererOpts||{};return m.toDataURL(g,u.quality)}})(Cn)),Cn}var En={},xa;function Qm(){if(xa)return En;xa=1;const t=Wo();function s(a,i){const l=a.a/255,c=i+'="'+a.hex+'"';return l<1?c+" "+i+'-opacity="'+l.toFixed(2).slice(1)+'"':c}function n(a,i,l){let c=a+i;return typeof l<"u"&&(c+=" "+l),c}function r(a,i,l){let c="",d=0,m=!1,g=0;for(let u=0;u<a.length;u++){const f=Math.floor(u%i),x=Math.floor(u/i);!f&&!m&&(m=!0),a[u]?(g++,u>0&&f>0&&a[u-1]||(c+=m?n("M",f+l,.5+x+l):n("m",d,0),d=0,m=!1),f+1<i&&a[u+1]||(c+=n("h",g),g=0)):d++}return c}return En.render=function(i,l,c){const d=t.getOptions(l),m=i.modules.size,g=i.modules.data,u=m+d.margin*2,f=d.color.light.a?"<path "+s(d.color.light,"fill")+' d="M0 0h'+u+"v"+u+'H0z"/>':"",x="<path "+s(d.color.dark,"stroke")+' d="'+r(g,m,d.margin)+'"/>',N='viewBox="0 0 '+u+" "+u+'"',T='<svg xmlns="http://www.w3.org/2000/svg" '+(d.width?'width="'+d.width+'" height="'+d.width+'" ':"")+N+' shape-rendering="crispEdges">'+f+x+`</svg>
|
|
181
|
-
`;return typeof c=="function"&&c(null,T),T},En}var pa;function Ym(){if(pa)return Ut;pa=1;const t=Mm(),s=Gm(),n=Wm(),r=Qm();function a(i,l,c,d,m){const g=[].slice.call(arguments,1),u=g.length,f=typeof g[u-1]=="function";if(!f&&!t())throw new Error("Callback required as last argument");if(f){if(u<2)throw new Error("Too few arguments provided");u===2?(m=c,c=l,l=d=void 0):u===3&&(l.getContext&&typeof m>"u"?(m=d,d=void 0):(m=d,d=c,c=l,l=void 0))}else{if(u<1)throw new Error("Too few arguments provided");return u===1?(c=l,l=d=void 0):u===2&&!l.getContext&&(d=c,c=l,l=void 0),new Promise(function(x,N){try{const b=s.create(c,d);x(i(b,l,d))}catch(b){N(b)}})}try{const x=s.create(c,d);m(null,i(x,l,d))}catch(x){m(x)}}return Ut.create=s.create,Ut.toCanvas=a.bind(null,n.render),Ut.toDataURL=a.bind(null,n.renderToDataURL),Ut.toString=a.bind(null,function(i,l,c){return r.render(i,c)}),Ut}var Jm=Ym();function Qo(t){return Jm.toDataURL(t,{errorCorrectionLevel:"M",margin:2,scale:8,color:{dark:"#111827ff",light:"#ffffffff"}})}function Zm({title:t,description:s,triggerLabel:n,qrValue:r,displayValue:a,hint:i,imageAlt:l,copyLabel:c,copiedMessage:d}){const[m,g]=o.useState(!1),[u,f]=o.useState(null),[x,N]=o.useState(null);return o.useEffect(()=>{if(!m)return;let b=!1;return f(null),N(null),Qo(r).then(T=>{b||f(T)}).catch(()=>{b||N("QR code unavailable")}),()=>{b=!0}},[m,r]),e.jsxs(At,{open:m,onOpenChange:g,children:[e.jsx(Ja,{asChild:!0,children:e.jsx(Z,{type:"button",variant:"ghost",size:"icon",className:"h-4 w-4 shrink-0 rounded-sm p-0 text-muted-foreground opacity-70 hover:bg-muted/45 hover:opacity-100 [&_svg]:size-2.5","aria-label":n,title:n,children:e.jsx(bo,{className:"h-3 w-3"})})}),e.jsxs(Mt,{className:"max-w-[20rem] gap-2 p-3",children:[e.jsxs(xs,{className:"space-y-1 text-left",children:[e.jsx(Rt,{className:"text-[12px]",children:t}),e.jsx(ps,{children:s})]}),e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"flex h-52 w-52 items-center justify-center rounded-sm bg-white p-2 text-[10px] text-muted-foreground",children:u?e.jsx("img",{src:u,alt:l,className:"h-full w-full"}):x?e.jsx("span",{children:x}):e.jsx(me,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),e.jsx("div",{className:"w-full rounded-sm bg-primary/10 px-2 py-1 text-center text-[10px] font-medium text-foreground",children:i}),e.jsx("div",{className:"w-full rounded-sm bg-muted/45 px-2 py-1.5 font-mono text-[9px] leading-[0.95rem] text-foreground break-all",children:a}),e.jsx(Z,{type:"button",variant:"secondary",size:"sm",className:"h-6 w-full border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",onClick:()=>{hs(a,d)},children:c})]})]})]})}function Xm(t,s){const n=Date.parse(t)-s;if(!Number.isFinite(n)||n<=0)return"expired";const r=Math.ceil(n/1e3),a=Math.floor(r/60),i=r%60;return a>0?`${a}m ${i.toString().padStart(2,"0")}s`:`${r}s`}function ef(t,s){return t?t.invitation.status==="active"&&Date.parse(t.invitation.expiresAt)<=s?"expired":t.invitation.status:"loading"}function tf(t){switch(t){case"active":return{label:"Active",tone:"bg-emerald-500/10 text-emerald-500",icon:Tr};case"consumed":return{label:"Paired",tone:"bg-emerald-500/10 text-emerald-500",icon:Pn};case"expired":return{label:"Expired",tone:"bg-amber-500/10 text-amber-500",icon:Xs};case"cancelled":return{label:"Cancelled",tone:"bg-destructive/10 text-destructive",icon:Xs};case"error":return{label:"Unavailable",tone:"bg-destructive/10 text-destructive",icon:Xs};default:return{label:"Loading",tone:"bg-muted text-muted-foreground",icon:Tr}}}function sf({nodeName:t,nodeEndpoint:s}){const[n,r]=o.useState(!1),[a,i]=o.useState(null),[l,c]=o.useState(null),[d,m]=o.useState(null),[g,u]=o.useState(!1),[f,x]=o.useState(()=>Date.now()),N=`Show ${t} mobile pairing QR code`,b=o.useMemo(()=>a?fl(a.qr):null,[a]),T=d?"error":ef(a,f),p=tf(T),k=p.icon,y=o.useCallback(async()=>{u(!0),m(null),c(null);try{const h=await hl();i(h),x(Date.now())}catch(h){i(null),m(h instanceof Error?h.message:"Mobile pairing QR unavailable")}finally{u(!1)}},[]);return o.useEffect(()=>{n&&y()},[n,y]),o.useEffect(()=>{if(!n)return;const h=window.setInterval(()=>x(Date.now()),1e3);return()=>window.clearInterval(h)},[n]),o.useEffect(()=>{if(!n||!a||T!=="active")return;let h=!1;const v=window.setInterval(()=>{xl(a.invitation.pairingId).then(j=>{h||i(E=>E&&{...E,invitation:j.invitation})}).catch(()=>{h||m("Pairing status unavailable")})},2e3);return()=>{h=!0,window.clearInterval(v)}},[n,a?.invitation.pairingId,T]),o.useEffect(()=>{if(!n||!b)return;let h=!1;return c(null),Qo(b).then(v=>{h||c(v)}).catch(()=>{h||m("QR code unavailable")}),()=>{h=!0}},[n,b]),e.jsxs(At,{open:n,onOpenChange:r,children:[e.jsx(Ja,{asChild:!0,children:e.jsx(Z,{type:"button",variant:"ghost",size:"icon",className:"h-4 w-4 shrink-0 rounded-sm p-0 text-muted-foreground opacity-70 hover:bg-muted/45 hover:opacity-100 [&_svg]:size-2.5","aria-label":N,title:N,children:e.jsx(bo,{className:"h-3 w-3"})})}),e.jsxs(Mt,{className:"max-w-[20rem] gap-2 p-3",children:[e.jsxs(xs,{className:"space-y-1 text-left",children:[e.jsx(Rt,{className:"text-[12px]",children:"Mobile pairing QR"}),e.jsx(ps,{children:t})]}),e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsxs("div",{className:"relative flex h-52 w-52 items-center justify-center rounded-sm bg-white p-2 text-[10px] text-muted-foreground",children:[l?e.jsx("img",{src:l,alt:`${t} mobile pairing QR code`,className:"h-full w-full"}):d?e.jsx("span",{className:"px-3 text-center",children:d}):e.jsx(me,{className:"h-5 w-5 animate-spin text-muted-foreground"}),l&&T!=="active"?e.jsxs("div",{className:"absolute inset-2 flex items-center justify-center rounded-sm bg-background/85 px-3 text-center text-[10px] font-medium text-foreground",children:[p.label,". Refresh to create a new QR."]}):null]}),e.jsxs("div",{className:"grid w-full grid-cols-[1fr_auto] items-center gap-2 rounded-sm bg-muted/45 px-2 py-1.5",children:[e.jsxs("div",{className:"min-w-0 space-y-0.5",children:[e.jsx("div",{className:"truncate font-mono text-[9px] leading-3 text-foreground",children:a?.invitation.apiBaseUrl??s}),e.jsx("div",{className:"text-[9px] leading-3 text-muted-foreground",children:a?`${a.invitation.usedCount}/${a.invitation.maxUses} used - ${Xm(a.invitation.expiresAt,f)}`:"Creating invitation"})]}),e.jsxs("div",{className:`flex h-5 items-center gap-1 rounded-sm px-1.5 text-[9px] font-medium ${p.tone}`,children:[e.jsx(k,{className:"h-3 w-3"}),p.label]})]}),e.jsx("div",{className:"w-full rounded-sm bg-primary/10 px-2 py-1 text-center text-[10px] font-medium text-foreground",children:"Scan with Meshy Mobile"}),e.jsxs("div",{className:"grid w-full grid-cols-2 gap-2",children:[e.jsx(Z,{type:"button",variant:"secondary",size:"sm",className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",onClick:()=>{hs(a?.invitation.apiBaseUrl??s,"Node URL copied")},children:"Copy URL"}),e.jsxs(Z,{type:"button",variant:"secondary",size:"sm",className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",disabled:g,onClick:()=>{y()},children:[g?e.jsx(me,{className:"mr-1 h-3 w-3 animate-spin"}):e.jsx(Za,{className:"mr-1 h-3 w-3"}),"Refresh"]})]})]})]})]})}function nf({nodeName:t,dashboardUrl:s}){const n=`Show ${t} dashboard QR code`;return e.jsx(Zm,{title:"Dashboard URL QR",description:t,triggerLabel:n,qrValue:s,displayValue:s,hint:"Scan with Edge to view the dashboard",imageAlt:`${t} dashboard URL QR code`,copyLabel:"Copy dashboard URL",copiedMessage:"Dashboard URL copied"})}function rr({nodeId:t,nodeName:s,onOpenSettings:n,onOpenServicePreview:r,onOpenCapabilities:a,onOpenDevBox:i,onStartDevBox:l,onToggleRemoteAccess:c,remoteAccessLabel:d,remoteAccessPending:m,remoteAccessDisabled:g,remoteAccessDisabledReason:u,showConfigureDevBox:f,showStartDevBox:x,startDevBoxPending:N,className:b}){const[T,p]=o.useState(!1),[k,y]=o.useState(null),h=o.useRef(null),v=o.useRef(null),j=N?"Starting":"Start DevBox",E=d?.startsWith("Disable")?pl:Ad;o.useLayoutEffect(()=>{if(!T){y(null);return}const A=()=>{const L=v.current,M=h.current;if(!L||!M)return;const D=L.getBoundingClientRect(),P=M.getBoundingClientRect();y(af({left:D.left,right:D.right,bottom:D.bottom,top:D.top},{width:P.width,height:P.height},{width:window.innerWidth,height:window.innerHeight},of()))};return A(),window.addEventListener("resize",A),window.addEventListener("scroll",A,!0),()=>{window.removeEventListener("resize",A),window.removeEventListener("scroll",A,!0)}},[T]),o.useEffect(()=>{if(!T)return;const A=M=>{const D=M.target;D instanceof Node&&!h.current?.contains(D)&&!v.current?.contains(D)&&p(!1)},L=M=>{M.key==="Escape"&&p(!1)};return document.addEventListener("mousedown",A),document.addEventListener("keydown",L),()=>{document.removeEventListener("mousedown",A),document.removeEventListener("keydown",L)}},[T]);const R=T?e.jsxs("div",{ref:h,"data-node-action-menu-portal":"true",role:"menu",style:rf(k),onClick:A=>A.stopPropagation(),onPointerDown:A=>A.stopPropagation(),className:"fixed z-[130] min-w-40 overflow-hidden whitespace-nowrap rounded-sm border border-border/65 bg-popover/96 p-1 normal-case tracking-normal shadow-[0_18px_48px_-28px_rgba(0,0,0,0.45)] backdrop-blur-xl",children:[n&&e.jsxs("button",{type:"button",role:"menuitem","aria-label":`Open ${s} settings`,title:`Open ${s} settings`,onClick:A=>{A.stopPropagation(),p(!1),n(t)},className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-1.5 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80",children:[e.jsx(gl,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:"Settings"})]}),r&&e.jsxs("button",{type:"button",role:"menuitem","aria-label":`Preview service on ${s}`,title:`Preview service on ${s}`,onClick:A=>{A.stopPropagation(),p(!1),r(t)},className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-1.5 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80",children:[e.jsx(go,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:"Preview service"})]}),a&&e.jsxs("button",{type:"button",role:"menuitem","aria-label":`Open ${s} capabilities`,title:`Open ${s} capabilities`,onClick:A=>{A.stopPropagation(),p(!1),a(t)},className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-1.5 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80",children:[e.jsx(Ls,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:"Capabilities"})]}),d&&c&&e.jsxs("button",{type:"button",role:"menuitem","aria-label":`${d} for ${s}`,title:u??`${d} for ${s}`,onClick:A=>{A.stopPropagation(),!(m||g)&&(p(!1),c())},disabled:m||g,className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-1.5 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80 disabled:cursor-not-allowed disabled:opacity-60",children:[m?e.jsx(me,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-primary"}):e.jsx(E,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:d})]}),x&&l&&e.jsxs("button",{type:"button",role:"menuitem","aria-label":`${j} for ${s}`,title:`${j} for ${s}`,onClick:A=>{A.stopPropagation(),!N&&(p(!1),l(t))},disabled:N,className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-1.5 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80 disabled:cursor-not-allowed disabled:opacity-60",children:[N?e.jsx(me,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-primary"}):e.jsx(Bs,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:j})]}),f&&i&&e.jsxs("button",{type:"button",role:"menuitem","aria-label":`Configure DevBox for ${s}`,title:`Configure DevBox for ${s}`,onClick:A=>{A.stopPropagation(),p(!1),i(t)},className:"flex w-full items-center gap-1.5 rounded-sm px-2 py-1.5 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80",children:[e.jsx(bl,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:"Configure DevBox"})]})]}):null;return e.jsxs("div",{"data-node-action-menu":"true",className:O("relative shrink-0",T&&"z-[120]",b),onClick:A=>A.stopPropagation(),onPointerDown:A=>A.stopPropagation(),children:[e.jsx(Z,{ref:v,type:"button",variant:"ghost",size:"icon","aria-label":`More actions for ${s}`,"aria-haspopup":"menu","aria-expanded":T,title:`More actions for ${s}`,onClick:A=>{A.stopPropagation(),p(L=>(L||y(null),!L))},className:O("h-6 w-6 rounded-sm text-muted-foreground hover:bg-background/70 hover:text-foreground",T&&"bg-background/80 text-primary"),children:e.jsx(Jc,{className:"h-3.5 w-3.5"})}),R&&(typeof document>"u"?R:Xa.createPortal(R,document.body))]})}function rf(t){return t?{left:t.left,top:t.top}:{left:0,top:0,visibility:"hidden"}}function af(t,s,n,r=1){const l=s.width||160,c=s.height||0,d=Number.isFinite(r)&&r>0?r:1,m=Math.max(8,Math.min(t.right-l,n.width-l-8)),g=t.bottom+4,u=(t.top??t.bottom)-c-4,f=g+c>n.height-8&&u>=8?u:g;return{left:Math.round(m/d),top:Math.round(f/d)}}function of(){if(typeof window>"u"||typeof document>"u")return 1;const t=window.getComputedStyle(document.documentElement),s=t.zoom||t.getPropertyValue("--ui-zoom"),n=Number.parseFloat(s);return Number.isFinite(n)&&n>0?n:1}const lf=new Set(["deallocated","hibernate","hibernated","sleep","sleeping","stopped"]),cf=new Set(["startinprogress","starting"]);function Ht(t){return!!(t?.enabled&&t.name)}function df(t){const s=t?.trim().toLowerCase().replace(/[\s_-]+/gu,"");return!!(s&&lf.has(s))}function Vt(t){const s=t?.trim().toLowerCase().replace(/[\s_-]+/gu,"");return!!(s&&cf.has(s))}function zs(t,s,n){return t==="offline"&&df(s)&&Ht(n)}function ga(t,s){return t==="offline"&&Ht(s)}function ba(t){return!Ht(t)}function uf({nodeStatus:t,status:s,current:n,selected:r}){const a=r??n;return a&&zs(t,s,a)?a:null}function Ke(t){return t.scope||`name:${t.name??""}`}function mf({previousKey:t,baseDevBox:s,listed:n}){if(t&&n.some(i=>Ke(i)===t))return t;if(!Ht(s))return n[0]?Ke(n[0]):"";const r=Ke(s),a=n.find(i=>Ke(i)===r)??n.find(i=>i.name===s.name);return a?Ke(a):r}function ff(t){return t==="nodes"||t==="events"?t:"overview"}function hf({cluster:t,systemInfo:s,nodeNameById:n,nodeBlockingTaskCounts:r,eventTypeFilter:a,onEventTypeFilterChange:i,eventTypeOptions:l,filteredEvents:c,sseConnected:d,clusterLoading:m,clusterError:g,promotePending:u,onPromote:f,onAddNode:x,leavePending:N,onLeaveCluster:b,onToggleNodeDevTunnel:T,devTunnelNodeId:p,devBoxStartNodeId:k,devBoxStartingNodeIds:y=new Set,activeTab:h,onTabChange:v,onOpenNodeSettings:j,onOpenNodeCapabilities:E,onOpenDevBox:R,onStartDevBox:A}){const L=t?.self?.role==="leader",M=t?.self?.role==="follower"&&!t?.leader,D=t?.self??null,F=vl(t?.nodes??[],D?.id).filter(I=>I.id!==D?.id),Q=t?.leader?t.nodes.find(I=>I.id===t.leader?.id)??null:null,re=t?.leader?t.leader.dashboardOrigin??Q?.dashboardOrigin??(s&&t.leader.id===(s.nodeId??s.id)?s.dashboardOrigin:void 0)??t.leader.endpoint:null,W=t?.leader?Q?.devtunnelEndpoint??t.leader.endpoint:null,ee=t?.leader?.name??Q?.name??"Leader",se=!!(t?.leader?.id&&t.leader.id===D?.id),q=D?.role==="leader"&&F.length===0,X=D?.role==="follower",[w,K]=o.useState("overview"),C=h??w;function Y(I){const U=ff(I);K(U),v?.(U)}return e.jsx("aside",{className:"dashboard-operations-sidecar dashboard-panel dashboard-panel-muted animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:e.jsxs(Wn,{value:C,onValueChange:Y,className:"flex h-full min-h-0 flex-col",children:[e.jsx("div",{className:"dashboard-operations-sidecar__header shrink-0 bg-card/24 px-2.5 py-2",children:e.jsxs(Gn,{className:"grid h-auto w-full grid-cols-3 rounded-sm bg-muted/55 p-0.5",children:[e.jsx(Pt,{value:"overview",className:"rounded-sm px-2 py-0.5 text-[10px]",children:"Overview"}),e.jsx(Pt,{value:"nodes",className:"rounded-sm px-2 py-0.5 text-[10px]",children:"Nodes"}),e.jsx(Pt,{value:"events",className:"rounded-sm px-2 py-0.5 text-[10px]",children:"Live events"})]})}),e.jsx(bt,{value:"overview",className:"mt-0 min-h-0 flex-1",children:e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-y-auto px-2 py-2",children:e.jsxs("div",{className:"space-y-2.5",children:[D&&e.jsx(va,{node:D,systemInfo:s,blockingTaskCount:r.get(D.id)??0,devTunnelNodeId:p,onToggleNodeDevTunnel:T,showActions:!1,defaultExpanded:!1,onOpenDevBox:R,devBoxStartingNodeIds:y}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[e.jsx("div",{className:"text-[10px] font-medium text-foreground",children:"Cluster snapshot"}),e.jsx(Ye,{variant:"secondary",className:"rounded-sm border-0 bg-muted/60 px-1.5 py-0 text-[9px] leading-4 shadow-none",children:d?"Connected":"Reconnecting"})]}),m&&!t?e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground",children:[e.jsx(me,{className:"h-4 w-4 animate-spin"}),"Loading cluster state..."]}):g&&!t?e.jsx("div",{className:"rounded-sm border border-destructive/20 bg-destructive/10 px-2 py-1.5 text-[10px] text-destructive shadow-none",children:g}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsx(qt,{label:"Term",value:String(t?.term??0)}),e.jsx(qt,{label:"Nodes",value:String(t?.nodes.length??0)}),e.jsx(qt,{label:"Pending",value:String(t?.taskSummary.pending??0)}),e.jsx(qt,{label:"Running",value:String(t?.taskSummary.running??0)}),e.jsx(qt,{label:"Completed",value:String(t?.taskSummary.completed??0)}),e.jsx(qt,{label:"Failed",value:String(t?.taskSummary.failed??0)})]}),e.jsxs("div",{className:"space-y-1.5 rounded-sm bg-muted/45 px-2 py-2 shadow-none",children:[e.jsx(ot,{label:"Leader",value:t?.leader?.name??"None"}),e.jsx(ot,{label:"Leader Dashboard URL",value:re??"Unavailable",mono:!0,action:re?e.jsx(or,{nodeName:ee,dashboardUrl:re,copyLabel:"Copy leader dashboard URL",copiedMessage:"Leader Dashboard URL copied"}):void 0}),W&&e.jsx(ot,{label:"Leader Node URL",value:W,mono:!0,action:e.jsx(ar,{nodeName:ee,nodeEndpoint:W,copyLabel:"Copy leader node URL",copiedMessage:"Leader Node URL copied",showPairingQr:se})}),e.jsx(ot,{label:"Feed",value:d?"Receiving live updates":"Reconnecting to event stream"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:M&&e.jsxs(Z,{variant:"secondary",size:"sm",onClick:f,disabled:u,className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",children:[u&&e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}),"Promote self"]})})]})]})]})})}),e.jsx(bt,{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"}),q?e.jsxs(Z,{variant:"secondary",size:"sm",onClick:x,className:"h-6 border-0 bg-primary px-2 text-[10px] text-primary-foreground shadow-none hover:bg-primary/90",children:[e.jsx(Td,{className:"h-3 w-3"}),"Join node"]}):X?e.jsxs(Z,{variant:"secondary",size:"sm",onClick:b,disabled:N,className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",children:[N&&e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}),"Leave cluster"]}):null]}),D&&e.jsx(va,{node:D,systemInfo:s,blockingTaskCount:r.get(D.id)??0,devTunnelNodeId:p,onToggleNodeDevTunnel:T,showActions:!0,defaultExpanded:!0,onOpenNodeSettings:L?j:void 0,onOpenNodeCapabilities:L?E:void 0,onOpenDevBox:L?R:void 0,onStartDevBox:L?A:void 0,devBoxStartNodeId:k,devBoxStartingNodeIds:y})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"text-[10px] font-medium text-foreground",children:["Peer nodes (",F.length,")"]}),F.length>0?e.jsx("div",{className:"space-y-1.5",children:F.map(I=>e.jsx(xf,{node:I,isLeader:!!L,blockingTaskCount:r.get(I.id)??0,devTunnelNodeId:p,onToggleNodeDevTunnel:T,onOpenNodeSettings:L?j:void 0,onOpenNodeCapabilities:L?E:void 0,onOpenDevBox:L?R:void 0,onStartDevBox:L?A:void 0,devBoxStartNodeId:k,devBoxStartingNodeIds:y},I.id))}):e.jsx("div",{className:"rounded-sm bg-muted/45 px-2 py-2 text-[10px] text-muted-foreground shadow-none",children:"No peer nodes are connected yet."})]})]})})}),e.jsx(bt,{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(wl,{className:O("h-3.5 w-3.5",d?"text-emerald-500":"text-destructive")}),"Live events"]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsxs(Be,{value:a,onValueChange:i,children:[e.jsx(Oe,{className:"h-6 min-w-[10rem] flex-1 rounded-sm border-0 bg-muted/60 text-[10px] shadow-none sm:max-w-[14rem] [&>svg]:h-3 [&>svg]:w-3",children:e.jsx(Ge,{placeholder:"Event type"})}),e.jsx(Fe,{className:"shadow-none",children:l.map(I=>e.jsx(Le,{value:I,className:"py-1 pl-6 pr-1.5 text-[10px] leading-4",children:I==="all"?"All event types":I},I))})]}),e.jsx(Ye,{variant:"secondary",className:"rounded-sm border-0 bg-muted/60 px-1.5 py-0 text-[9px] leading-4 shadow-none",children:d?"Connected":"Reconnecting"})]})]}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(yl,{events:c,maxHeight:"100%",emptyTitle:a==="all"?"No live events yet":"No matching events",emptyDescription:a==="all"?"Cluster activity appears here as it happens.":`No "${a}" events are in the current stream.`,nodeNameById:n,density:"compact"})})]})})]})})}function va({node:t,systemInfo:s,blockingTaskCount:n,devTunnelNodeId:r,onToggleNodeDevTunnel:a,showActions:i=!0,defaultExpanded:l=!1,onOpenNodeSettings:c,onOpenNodeCapabilities:d,onOpenDevBox:m,onStartDevBox:g,devBoxStartNodeId:u,devBoxStartingNodeIds:f}){const[x,N]=o.useState(l),b=s?.dashboardOrigin??t.dashboardOrigin,T=t.devtunnelEndpoint??t.endpoint,p=b??t.endpoint,k=s?.workDir??t.workDir,y=No(t,s?.transportType),h=tr(t,s?.transportType),v=h&&Wt(s?.transportType??t.transportType)?!0:yo(t,s?.transportType),j=n>0;return e.jsxs("section",{className:"dashboard-operations-node-card bg-primary/8 shadow-none",children:[e.jsxs("div",{className:"w-full px-2.5 py-1.5 text-left",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>N(E=>!E),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[x?e.jsx(st,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(lt,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx(eo,{status:t.status}),e.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Current node"})]}),e.jsx("a",{href:p,target:"_blank",rel:"noreferrer",className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(Yn,{className:"h-3 w-3"})}),(c||d||i&&v)&&e.jsx(rr,{nodeId:t.id,nodeName:t.name,onOpenSettings:c,onOpenCapabilities:d,onOpenDevBox:m,onStartDevBox:g,onToggleRemoteAccess:i&&v?()=>a(t):void 0,remoteAccessLabel:i&&v?h?"Disable Remote Access":"Enable Remote Access":void 0,remoteAccessPending:r===t.id,remoteAccessDisabled:j,remoteAccessDisabledReason:j?"Finish assigned or running tasks before changing remote access":void 0,showConfigureDevBox:t.devbox?.enabled,showStartDevBox:zs(t.status,t.devbox?.lastStatus,t.devbox)||Vt(t.devbox?.lastStatus)||f.has(t.id),startDevBoxPending:u===t.id||Vt(t.devbox?.lastStatus)||f.has(t.id)})]}),e.jsxs("button",{type:"button",onClick:()=>N(E=>!E),className:"mt-1 flex min-w-0 items-center gap-1 pl-5 text-left",children:[e.jsx("span",{className:"text-[10px] font-semibold tracking-tight text-foreground",children:t.name}),e.jsx(to,{role:t.role,size:"compact"}),e.jsx(Ye,{variant:"secondary",className:"rounded-sm border-0 bg-background/65 px-1.5 py-0 text-[9px] leading-4 capitalize shadow-none",children:t.status})]})]}),x&&e.jsxs("div",{className:"space-y-2 bg-primary/5 px-2.5 pb-2.5 pt-1.5",children:[e.jsxs("div",{className:"space-y-1.5 rounded-sm bg-muted/45 px-2 py-1.5 shadow-none",children:[e.jsx(ot,{label:"Node ID",value:t.id,mono:!0}),b&&e.jsx(ot,{label:"Dashboard",value:b,mono:!0,action:e.jsx(or,{nodeName:t.name,dashboardUrl:b})}),e.jsx(ot,{label:"Node URL",value:T,mono:!0,action:e.jsx(ar,{nodeName:t.name,nodeEndpoint:T})}),k&&e.jsx(ot,{label:"Workspace",value:k,mono:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[e.jsx(Ln,{label:"Transport",value:y}),s&&e.jsx(Ln,{label:"Uptime",value:Nl(s.uptime),mono:!0})]}),i&&d&&e.jsxs(Z,{variant:"secondary",size:"sm",onClick:()=>d(t.id),"aria-label":`Open ${t.name} capabilities`,className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",children:[e.jsx(Ls,{className:"h-3 w-3"}),"Capabilities"]}),i&&v&&j&&e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function xf({node:t,isLeader:s,blockingTaskCount:n,devTunnelNodeId:r,onToggleNodeDevTunnel:a,onOpenNodeSettings:i,onOpenNodeCapabilities:l,onOpenDevBox:c,onStartDevBox:d,devBoxStartNodeId:m,devBoxStartingNodeIds:g}){const[u,f]=o.useState(!1),x=t.dashboardOrigin,N=t.devtunnelEndpoint??t.endpoint,b=x??t.endpoint,T=No(t),p=tr(t),k=yo(t),y=n>0;return e.jsxs("div",{className:"dashboard-operations-node-card bg-muted/45 shadow-none",children:[e.jsxs("div",{className:"w-full px-2.5 py-1.5 text-left",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>f(h=>!h),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[u?e.jsx(st,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):e.jsx(lt,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx(eo,{status:t.status}),e.jsx("span",{className:"text-[9px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:"Peer node"})]}),e.jsx("a",{href:b,target:"_blank",rel:"noreferrer",className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(Yn,{className:"h-3 w-3"})}),s&&(i||l||k)&&e.jsx(rr,{nodeId:t.id,nodeName:t.name,onOpenSettings:i,onOpenCapabilities:l,onOpenDevBox:c,onStartDevBox:d,onToggleRemoteAccess:k?()=>a(t):void 0,remoteAccessLabel:k?p?"Disable Remote Access":"Enable Remote Access":void 0,remoteAccessPending:r===t.id,remoteAccessDisabled:y,remoteAccessDisabledReason:y?"Finish assigned or running tasks before changing remote access":void 0,showConfigureDevBox:t.devbox?.enabled,showStartDevBox:zs(t.status,t.devbox?.lastStatus,t.devbox)||Vt(t.devbox?.lastStatus)||g.has(t.id),startDevBoxPending:m===t.id||Vt(t.devbox?.lastStatus)||g.has(t.id)})]}),e.jsxs("button",{type:"button",onClick:()=>f(h=>!h),className:"mt-1 flex min-w-0 items-center gap-1 pl-4 text-left",children:[e.jsx("span",{className:"text-[10px] font-semibold text-foreground",children:t.name}),e.jsx(to,{role:t.role,size:"compact"}),e.jsx(Ye,{variant:"secondary",className:"rounded-sm border-0 bg-background/65 px-1.5 py-0 text-[9px] leading-4 capitalize shadow-none",children:t.status})]})]}),u&&e.jsxs("div",{className:"space-y-2 bg-muted/35 px-2.5 pb-2.5 pt-1.5",children:[e.jsxs("div",{className:"space-y-1.5 rounded-sm bg-background/55 px-2 py-1.5 shadow-none",children:[e.jsx(ot,{label:"Node ID",value:t.id,mono:!0}),x&&e.jsx(ot,{label:"Dashboard",value:x,mono:!0,action:e.jsx(or,{nodeName:t.name,dashboardUrl:x})}),e.jsx(ot,{label:"Node URL",value:N,mono:!0,action:e.jsx(ar,{nodeName:t.name,nodeEndpoint:N,showPairingQr:!1})}),t.workDir&&e.jsx(ot,{label:"Workspace",value:t.workDir,mono:!0}),e.jsx(Ln,{label:"Transport",value:T})]}),s&&l&&e.jsxs(Z,{variant:"secondary",size:"sm",onClick:()=>l(t.id),"aria-label":`Open ${t.name} capabilities`,className:"h-6 border-0 bg-muted/70 px-2 text-[10px] shadow-none hover:bg-muted",children:[e.jsx(Ls,{className:"h-3 w-3"}),"Capabilities"]}),s&&k&&y&&e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function ar({nodeName:t,nodeEndpoint:s,copyLabel:n="Copy node URL",copiedMessage:r="Node URL copied",showPairingQr:a=!0}){return e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[a?e.jsx(sf,{nodeName:t,nodeEndpoint:s}):null,e.jsx(Yo,{label:n,onClick:()=>{hs(s,r)}})]})}function or({nodeName:t,dashboardUrl:s,copyLabel:n="Copy dashboard URL",copiedMessage:r="Dashboard URL copied"}){return e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[e.jsx(nf,{nodeName:t,dashboardUrl:s}),e.jsx(Yo,{label:n,onClick:()=>{hs(s,r)}})]})}function Yo({label:t,onClick:s}){return e.jsx(Z,{type:"button",variant:"ghost",size:"icon",className:"h-4 w-4 shrink-0 rounded-sm p-0 text-muted-foreground opacity-70 hover:bg-muted/45 hover:opacity-100 [&_svg]:size-2.5",onClick:s,"aria-label":t,title:t,children:e.jsx(Wa,{className:"h-3 w-3"})})}function pf(t,s,n,r){if(!t)return{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Select a task to continue the conversation."};const a=s?.self?.role==="follower",i=t.assignedTo?s?.self?.id===t.assignedTo?s.self:s?.nodes.find(c=>c.id===t.assignedTo):void 0;return t.assignedTo!==null&&(i?i.status==="offline":s?t.assignedNodeAvailable===!1||!s.nodes.some(c=>c.id===t.assignedTo):t.assignedNodeAvailable===!1)?{taskUnavailable:!0,chatDisabled:!0,chatDisabledReason:`${t.assignedNodeName??"Assigned node"} is unavailable. Leave the cluster on that node or re-run the task elsewhere.`}:a?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Follower nodes are read-only. Use the leader dashboard to manage chat, or leave the cluster first."}:n?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Sending message..."}:r?{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Queue a message for the next turn..."}:As.has(t.status)||t.status==="archived"?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:As.has(t.status)?"Task has not started yet...":"Archived tasks are read-only."}:{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Continue the conversation..."}}const Jo=.5,Zo=1.75,wa=.1;function gf({node:t,open:s,onOpenChange:n}){const[r,a]=o.useState(Ns),[i,l]=o.useState(null),[c,d]=o.useState(1),[m,g]=o.useState(!1),[u,f]=o.useState(null);o.useEffect(()=>{a(Ns),l(null),d(1),g(!1),f(null)},[t?.id,s]);const x=o.useCallback(async y=>{if(!t)return;const h=y??Number.parseInt(r.trim()||Ns,10);if(!Number.isInteger(h)||h<1||h>65535){f("Enter a port between 1 and 65535");return}g(!0),f(null);try{const v=await jl(t.id,{port:h});l(v),a(String(h)),pr("preview.created",{result:"success",previewType:"service-port"})}catch(v){f(v instanceof Error?v.message:"Failed to create service preview"),pr("preview.failed",{result:"failed",previewType:"service-port"})}finally{g(!1)}},[t,r]),N=o.useCallback(()=>{typeof i?.port=="number"&&x(i.port)},[i?.port,x]);o.useEffect(()=>{if(!i)return;const y=i.expiresAt-Date.now()-5e3;if(y<=0){N();return}const h=window.setTimeout(N,y);return()=>window.clearTimeout(h)},[N,i]);const b=i?Bc(i):null,T=t?.name??"Node",p=bf(c),k={width:`${100/c}%`,height:`${100/c}%`,transform:`scale(${c})`,transformOrigin:"top left"};return e.jsx(At,{open:s,onOpenChange:n,children:e.jsxs(Mt,{onOpenAutoFocus:y=>y.preventDefault(),className:"flex h-[min(82vh,44rem)] max-w-[min(92vw,72rem)] flex-col gap-0 overflow-hidden p-0",children:[e.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border/60 px-3 py-2 pr-9",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs(Rt,{className:"flex min-w-0 items-center gap-1.5 text-[12px] font-semibold text-foreground",children:[e.jsx(go,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{className:"shrink-0",children:"Preview service"}),e.jsx("span",{className:"min-w-0 truncate font-mono text-[10px] font-medium text-muted-foreground",children:T})]}),e.jsx(ps,{className:"sr-only",children:"Preview a service port running on the selected node."})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs("form",{className:"flex items-center gap-1.5",onSubmit:y=>{y.preventDefault(),x()},children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:["Port",e.jsx(ft,{type:"text",min:1,max:65535,inputMode:"numeric",value:r,onChange:y=>a(y.target.value),placeholder:Ns,"aria-label":"Node service preview port",className:"h-6 w-20 rounded-sm border-0 bg-muted/55 px-2 text-[11px] shadow-none focus:bg-muted/55 focus:outline-none focus-visible:border-0 focus-visible:bg-muted/55 focus-visible:ring-0 focus-visible:ring-offset-0"})]}),e.jsxs(Z,{type:"submit",variant:"ghost",size:"sm",disabled:m,className:"h-6 rounded-sm border-0 bg-primary/10 px-2 text-[11px] text-primary shadow-none hover:bg-primary/15 hover:text-primary",children:[m?e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Bs,{className:"h-3.5 w-3.5"}),"Preview"]})]}),i&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"hidden shrink-0 text-[10px] text-muted-foreground sm:inline",children:vf(i.expiresAt)}),e.jsxs("div",{className:"flex h-6 shrink-0 items-center overflow-hidden rounded-sm border border-border/55 bg-muted/35",children:[e.jsx(Z,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-none",onClick:()=>d(y=>ya(y,-wa)),disabled:c<=Jo,title:"Zoom out","aria-label":"Zoom out preview",children:e.jsx(Pd,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>d(1),className:"h-6 min-w-11 border-x border-border/45 px-1.5 text-center font-mono text-[10px] text-muted-foreground transition-colors hover:bg-muted/55 hover:text-foreground",title:"Reset zoom","aria-label":"Reset preview zoom",children:p}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-none",onClick:()=>d(y=>ya(y,wa)),disabled:c>=Zo,title:"Zoom in","aria-label":"Zoom in preview",children:e.jsx(Dd,{className:"h-3.5 w-3.5"})})]}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-sm",onClick:N,title:"Refresh",children:e.jsx(Za,{className:"h-3.5 w-3.5"})}),e.jsx(Z,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-sm",asChild:!0,title:"Open in new tab",children:e.jsx("a",{href:b??i.previewUrl,target:"_blank",rel:"noopener noreferrer",children:e.jsx(Yn,{className:"h-3.5 w-3.5"})})})]})]})]}),u&&e.jsx("div",{className:"shrink-0 border-b border-destructive/20 bg-destructive/5 px-3 py-1.5 text-[11px] text-destructive",children:u}),e.jsx("div",{className:"min-h-0 flex-1 p-2",children:i?e.jsx("div",{className:"h-full overflow-hidden rounded-sm border border-border/60 bg-white shadow-none",children:e.jsx("iframe",{src:Fc(i),style:k,className:"h-full w-full border-0",sandbox:Oc(i),title:`${T} Service Preview`})}):e.jsx("div",{className:"flex h-full min-h-56 items-center justify-center rounded-sm border border-dashed border-border/65 bg-background/35 px-3 text-center text-[11px] text-muted-foreground",children:"No service preview running."})})]})})}function ya(t,s){return Xo(Math.round((t+s)*100)/100)}function Xo(t){return Number.isFinite(t)?Math.min(Zo,Math.max(Jo,t)):1}function bf(t){return`${Math.round(Xo(t)*100)}%`}function vf(t){const s=Math.max(0,Math.round((t-Date.now())/1e3));if(s<60)return`${s}s`;const n=Math.floor(s/60),r=s%60;return`${n}m ${r}s`}function wf({dirPath:t,label:s,taskCount:n,collapsed:r,onToggle:a,onCreateTask:i,onOpenCapabilities:l}){return e.jsxs("div",{className:"group/project-row flex w-full items-stretch rounded-sm bg-muted/15 text-[9px] font-medium text-muted-foreground/70 transition-all duration-150 hover:bg-muted/30 hover:text-foreground active:scale-[0.98] active:bg-muted/40",children:[e.jsxs("button",{type:"button",onClick:a,"aria-expanded":!r,title:t,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-l-sm px-2 py-1 text-left",children:[e.jsx(lt,{className:O("h-3 w-3 shrink-0 transition-transform duration-200",!r&&"rotate-90")}),e.jsx(Kt,{className:"h-3 w-3 shrink-0 text-muted-foreground/55"}),e.jsx("span",{className:"min-w-0 truncate font-mono",children:s}),e.jsx("span",{className:"ml-2 shrink-0 rounded-sm bg-background/55 px-1 py-0 tabular-nums text-[8px] font-medium leading-3 text-muted-foreground/45",children:n})]}),l&&e.jsx("button",{type:"button",onClick:l,"aria-label":`Capabilities for ${t}`,title:`Capabilities for ${t}`,className:"pointer-events-none mr-0.5 flex h-4 w-4 shrink-0 translate-y-px self-center items-center justify-center rounded-sm text-muted-foreground/50 opacity-0 transition-all hover:bg-primary/10 hover:text-primary focus-visible:pointer-events-auto focus-visible:opacity-100 group-hover/project-row:pointer-events-auto group-hover/project-row:opacity-100",children:e.jsx(Ls,{className:"h-2.5 w-2.5"})}),e.jsx("button",{type:"button",onClick:i,"aria-label":`New chat in ${t}`,title:`New chat in ${t}`,className:"pointer-events-none ml-auto flex h-4 w-4 shrink-0 translate-y-px self-center items-center justify-center rounded-sm text-muted-foreground/50 opacity-0 transition-all hover:bg-primary/10 hover:text-primary focus-visible:pointer-events-auto focus-visible:opacity-100 group-hover/project-row:pointer-events-auto group-hover/project-row:opacity-100",children:e.jsx(Fs,{className:"h-2.5 w-2.5"})})]})}const ei="meshy-task-sidebar-tree-state";function Na(t){return Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}function An(){try{return globalThis.window?.localStorage??globalThis.localStorage??null}catch{return null}}function ja(t){if(!t)return{collapsedNodes:[],collapsedDirs:[]};try{const s=t.getItem(ei);if(!s)return{collapsedNodes:[],collapsedDirs:[]};const n=JSON.parse(s);return{collapsedNodes:Na(n.collapsedNodes),collapsedDirs:Na(n.collapsedDirs)}}catch{return{collapsedNodes:[],collapsedDirs:[]}}}function yf(t,s){if(t)try{t.setItem(ei,JSON.stringify(s))}catch{}}function ka(t,s){if(!t.has(s))return t;const n=new Set(t);return n.delete(s),n}function Nf(t,s){if(!s)return null;for(const n of t){const r=n.nodeId??"__unassigned__";for(const a of n.dirs)if(a.tasks.some(i=>i.id===s))return{nodeKey:r,dirKey:`${r}::${a.path}`}}return null}function Sa(t,s,n){return n?{collapsedNodes:ka(t,n.nodeKey),collapsedDirs:ka(s,n.dirKey)}:{collapsedNodes:t,collapsedDirs:s}}function jf(t,s,n){const r=t.filter(c=>c.status==="completed"),a=new Set((s?r:[...r].sort((c,d)=>d.updatedAt-c.updatedAt).slice(0,Jn)).map(c=>c.id));n&&r.some(c=>c.id===n)&&a.add(n);const i=t.filter(c=>c.status!=="completed"||a.has(c.id)),l=r.length-a.size;return{visibleTasks:i,hiddenCompletedCount:Math.max(0,l)}}const Ss="h-6 rounded-sm border-0 bg-muted/45 px-2 py-0 text-[10px] leading-none text-foreground shadow-none hover:bg-muted/65 focus:bg-muted/65 focus:ring-0 focus:ring-offset-0 [&>svg]:h-3 [&>svg]:w-3",Cs="py-1 pl-6 pr-1.5 text-[10px] leading-4 [&_svg]:h-3 [&_svg]:w-3";function Ca({toolbarTasks:t,activeTaskId:s,tasksLoading:n,tasksError:r,isLeader:a,scope:i,agentFilter:l,nodeFilter:c,taskKindFilter:d,agentOptions:m,nodeOptions:g,nodeNameById:u,nodeWorkDirById:f,nodeStatusById:x,completedGroupByKey:N,devBoxNodeIds:b=new Set,devBoxStartNodeIds:T=new Set,devBoxStartingNodeIds:p=new Set,leaderNodeId:k,searchQuery:y,selectedTaskIds:h,allVisibleTasksSelected:v,someVisibleTasksSelected:j,canBatchArchive:E,onScopeChange:R,onAgentFilterChange:A,onNodeFilterChange:L,onTaskKindFilterChange:M,onToggleTaskSelected:D,onToggleAllVisibleTasks:P,onBatchArchive:F,onBatchDelete:Q,onCreateTask:re,onOpenNodeSettings:W,onOpenNodeCapabilities:ee,onOpenProjectCapabilities:se,onOpenDevBox:q,onStartDevBox:X,onLoadCompletedTasks:w,onSelectTask:K}){const[C,Y]=o.useState(!1),[I,U]=o.useState(()=>h.size>0),[B,le]=o.useState(!1),[oe,ue]=o.useState(null),{markScrollbarActive:J,scrollbarActive:V}=Oo(),_=h.size,ne=!!(a&&(I||_>0)),$=i!=="active"||c!=="all"||l!=="all"||d!=="all",ae=y.trim().length>0,[pe,fe]=o.useState(()=>new Set(ja(An()).collapsedNodes)),[Ve,je]=o.useState(()=>new Set(ja(An()).collapsedDirs)),[ht,De]=o.useState(new Set),Me=o.useMemo(()=>kl({nodeStatusById:x,nodeNameById:u,nodeWorkDirById:f,nodeFilter:c,searchQuery:y}),[x,u,f,c,y]),Te=o.useMemo(()=>Sl(t,u,k,f,Me),[t,u,k,f,Me]),Ee=o.useMemo(()=>Nf(Te,s),[Te,s]),Pe=o.useRef(null),Ue=Te.length===1,H=Te.length>0,xe=Ue&&($||ae),be=!!(a&&(t.length>0||_>0)),Xe=o.useCallback(G=>{fe(ze=>{const Re=new Set(ze);return Re.has(G)?Re.delete(G):Re.add(G),Re})},[]),Ie=o.useCallback(G=>{je(ze=>{const Re=new Set(ze);return Re.has(G)?Re.delete(G):Re.add(G),Re})},[]),ct=o.useCallback(G=>{De(ze=>{const Re=new Set(ze);return Re.add(G),Re})},[]);o.useEffect(()=>{yf(An(),{collapsedNodes:Array.from(pe),collapsedDirs:Array.from(Ve)})},[Ve,pe]),o.useEffect(()=>{if(!Ee||!s)return;const G=`${s}:${Ee.nodeKey}:${Ee.dirKey}`;Pe.current!==G&&(Pe.current=G,fe(ze=>Sa(ze,new Set,Ee).collapsedNodes),je(ze=>Sa(new Set,ze,Ee).collapsedDirs))},[s,Ee]);const te=o.useCallback(G=>{U(!0),P(G)},[P]),ve=o.useCallback(G=>{if(G===!0&&!v){U(!0),le(!0);return}te(G===!0)},[v,te]),ke=o.useCallback(()=>{te(!0),le(!1)},[te]),ye=o.useCallback(()=>{P(!1),U(!1),le(!1)},[P]);o.useEffect(()=>{a||(U(!1),le(!1))},[a]);const yt=ne?e.jsxs(ss,{open:B,onOpenChange:le,children:[e.jsxs("label",{className:"flex items-center gap-[5px] text-[9px] font-medium uppercase tracking-[0.12em] text-muted-foreground/75",children:[e.jsx(fs,{className:"h-3 w-3 [&_svg]:h-2.5 [&_svg]:w-2.5",checked:j&&!v?"indeterminate":v,onCheckedChange:ve,"aria-label":"Select all visible tasks"}),e.jsx("span",{children:"Select all"})]}),B&&e.jsxs(ns,{children:[e.jsxs(rs,{children:[e.jsx(as,{children:"Select every visible task?"}),e.jsx(os,{children:"This will select every task currently shown in the rail and expose bulk archive/delete actions. Cancel now unless you intend to act on all visible tasks together."})]}),e.jsxs(is,{children:[e.jsx(ls,{autoFocus:!0,children:"Cancel"}),e.jsx(cs,{onClick:ke,children:"Select all"})]})]})]}):e.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>U(!0),className:"h-5 rounded-sm px-1.5 text-[9px] font-medium uppercase tracking-[0.12em] text-muted-foreground/75 hover:text-foreground",children:[e.jsx(Ec,{className:"h-3 w-3"}),"Multi select"]}),_e=_>0?e.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[e.jsxs("div",{className:"text-[9px] font-semibold leading-3 text-foreground",children:[_," task",_!==1?"s":""," selected"]}),!E&&e.jsx("div",{className:"max-w-48 text-[9px] leading-3.5 text-muted-foreground",children:"Only completed, failed, cancelled, or archived tasks can be archived."})]}):null,Nt=_>0?e.jsxs("div",{className:"flex flex-wrap justify-end gap-1",children:[e.jsxs(ss,{children:[e.jsx(In,{asChild:!0,children:e.jsxs(Z,{variant:"ghost",size:"sm",disabled:!E,className:"h-5 gap-1 rounded-sm bg-muted/45 px-1.5 text-[8px] text-foreground/80 shadow-none hover:bg-muted/65 [&_svg]:size-3",children:[e.jsx(qc,{}),"Archive"]})}),e.jsxs(ns,{children:[e.jsxs(rs,{children:[e.jsxs(as,{children:["Archive ",_," selected task",_!==1?"s":"","?"]}),e.jsx(os,{children:"These tasks leave the default view immediately. Cancel if any selected task still needs to stay visible in active work."})]}),e.jsxs(is,{children:[e.jsx(ls,{autoFocus:!0,children:"Cancel"}),e.jsx(cs,{onClick:F,disabled:!E,children:"Archive"})]})]})]}),e.jsxs(ss,{children:[e.jsx(In,{asChild:!0,children:e.jsxs(Z,{variant:"destructive",size:"sm",className:"h-5 gap-1 rounded-sm px-1.5 text-[8px] [&_svg]:size-3",children:[e.jsx(no,{}),"Delete"]})}),e.jsxs(ns,{children:[e.jsxs(rs,{children:[e.jsxs(as,{children:["Delete ",_," selected task",_!==1?"s":""," and saved logs?"]}),e.jsx(os,{children:"This cannot be undone. Cancel unless you are certain every selected task and log should be removed now."})]}),e.jsxs(is,{children:[e.jsx(ls,{autoFocus:!0,children:"Cancel"}),e.jsx(cs,{onClick:Q,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]}):null;return e.jsxs(e.Fragment,{children:[e.jsxs("aside",{className:"dashboard-task-sidebar dashboard-panel dashboard-panel-muted animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsxs("div",{className:"dashboard-task-sidebar__header shrink-0 bg-card/24 px-2.5 py-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("div",{className:"flex min-w-0 items-stretch gap-1.5",children:[e.jsxs(Z,{onClick:()=>re("chat"),className:"h-8 w-[6.75rem] justify-start rounded-sm px-2.5 text-left text-[11px] shadow-[0_10px_24px_-18px_hsl(var(--primary)/0.9)]",children:[e.jsx(Fs,{className:"h-3.5 w-3.5"}),"New chat"]}),e.jsxs(Z,{variant:"outline",onClick:()=>re("native"),className:"h-8 w-[7.75rem] justify-start rounded-sm border-0 bg-muted/45 px-2.5 text-left text-[11px] text-foreground shadow-none hover:bg-muted/65 hover:text-foreground",children:[e.jsx(er,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Load session"]})]}),e.jsx(Z,{variant:"ghost",size:"icon",onClick:()=>Y(G=>!G),className:O("ml-auto h-8 w-8 shrink-0 rounded-sm text-muted-foreground shadow-none hover:bg-muted/55 hover:text-foreground",(C||$)&&"bg-primary/8 text-primary hover:bg-primary/12 hover:text-primary"),title:"Filters",children:e.jsx(sd,{className:"h-3.5 w-3.5"})})]}),(C||$)&&e.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-1 sm:grid-cols-2",children:[e.jsxs(Be,{value:i,onValueChange:G=>R(G),children:[e.jsx(Oe,{className:Ss,children:e.jsx(Ge,{})}),e.jsx(Fe,{children:Cl.map(G=>e.jsx(Le,{value:G.value,className:Cs,children:G.label},G.value))})]}),e.jsxs(Be,{value:c,onValueChange:L,children:[e.jsx(Oe,{className:Ss,children:e.jsx(Ge,{placeholder:"Node"})}),e.jsx(Fe,{children:g.map(G=>e.jsx(Le,{value:G.value,className:Cs,children:G.label},G.value))})]}),e.jsxs(Be,{value:l,onValueChange:A,children:[e.jsx(Oe,{className:Ss,children:e.jsx(Ge,{placeholder:"Agent"})}),e.jsx(Fe,{children:m.map(G=>e.jsx(Le,{value:G,className:Cs,children:G==="all"?"All agents":G},G))})]}),e.jsxs(Be,{value:d,onValueChange:G=>M(G),children:[e.jsx(Oe,{className:Ss,children:e.jsx(Ge,{placeholder:"Type"})}),e.jsx(Fe,{children:Tl.map(G=>e.jsx(Le,{value:G.value,className:Cs,children:G.label},G.value))})]})]})]}),e.jsx("div",{className:O("scrollbar-line min-h-0 flex-1 overflow-y-auto pl-2.5 pr-1.5 py-2",V&&"scrollbar-line-active"),onScroll:J,children:Te.length>0?e.jsx("div",{className:"space-y-1",children:Te.map(G=>{const ze=G.nodeId??"__unassigned__",Re=G.dirs.reduce(($e,nt)=>$e+nt.tasks.length,0),jt=H&&!xe&&pe.has(ze),xt=G.nodeId!==null&&x.get(G.nodeId)==="offline",Qt=!!(a&&G.nodeId);return e.jsxs("div",{className:"space-y-1",children:[H&&e.jsxs("div",{className:"flex w-full items-stretch rounded-sm bg-gradient-to-r from-primary/8 to-muted/20 text-left text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground transition-all duration-150 hover:from-primary/12 hover:to-muted/30 hover:text-foreground active:scale-[0.99] active:from-primary/15",children:[e.jsxs("button",{type:"button",onClick:()=>Xe(ze),"aria-expanded":!jt,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-sm px-2 py-1.5 text-left",children:[e.jsx(lt,{className:O("h-3.5 w-3.5 shrink-0 transition-transform duration-200",!jt&&"rotate-90")}),e.jsx(Ha,{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:G.nodeName}),e.jsxs(Ye,{variant:"outline",className:"shrink-0 whitespace-nowrap rounded-sm border-transparent bg-background/55 px-1.5 py-0 text-[7px] font-semibold leading-3.5 text-muted-foreground shadow-none normal-case tracking-normal",children:[Re," task",Re===1?"":"s"]})]}),e.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[xt&&e.jsx(Ye,{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"}),G.nodeId===k&&e.jsx(Ye,{variant:"outline",className:"rounded-sm border-transparent bg-primary/8 px-1 py-0 text-[8px] font-medium leading-3.5 text-primary shadow-none",children:"leader"})]})]}),Qt&&G.nodeId&&e.jsx("span",{className:"flex shrink-0 items-center pr-1.5",children:e.jsx(rr,{nodeId:G.nodeId,nodeName:G.nodeName,onOpenSettings:W,onOpenServicePreview:()=>ue({id:G.nodeId,name:G.nodeName}),onOpenCapabilities:ee,onOpenDevBox:q,onStartDevBox:X,showConfigureDevBox:b.has(G.nodeId),showStartDevBox:T.has(G.nodeId)||p.has(G.nodeId),startDevBoxPending:p.has(G.nodeId)})})]}),e.jsx("div",{className:O("grid transition-[grid-template-rows] duration-300 ease-in-out",jt?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:"overflow-hidden",children:G.dirs.map($e=>{const nt=`${ze}::${$e.path}`,kt=Ve.has(nt),Dt=so($e.path),rt=N?.get(nt),Ot=rt?{visibleTasks:$e.tasks,hiddenCompletedCount:Math.max(0,rt.total-rt.returned)}:jf($e.tasks,ht.has(nt),s),{visibleTasks:qe,hiddenCompletedCount:et}=Ot;return e.jsxs("div",{className:O("space-y-0.5 rounded-xl",H&&"pl-2.5"),children:[e.jsx(wf,{dirPath:$e.path,label:Dt,taskCount:$e.tasks.length,collapsed:kt,onToggle:()=>Ie(nt),onCreateTask:()=>re("chat",{assignTo:G.nodeId,project:$e.path==="default workspace"?"":$e.path}),onOpenCapabilities:G.nodeId&&se?()=>se(G.nodeId,$e.path==="default workspace"?f?.get(G.nodeId)??$e.path:$e.path):void 0}),e.jsx("div",{className:O("grid transition-[grid-template-rows] duration-300 ease-in-out",kt?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:O("overflow-hidden",H?"pl-2":"pl-0"),children:e.jsxs("div",{className:"space-y-px py-0.5",children:[qe.map(Se=>{const dt=Se.id===s,We=Se.assignedTo?x.get(Se.assignedTo):void 0,Ft=!!Se.assignedTo&&(We?We==="offline":Se.assignedNodeAvailable===!1),St=qo(Se);return e.jsxs("div",{className:O("animate-task-row-reveal relative flex items-center gap-1.5 rounded-sm px-2 py-1.5 transition-all duration-150",dt?'bg-primary/10 before:absolute before:left-0 before:top-1/2 before:h-1/2 before:w-[2px] before:-translate-y-1/2 before:rounded-full before:bg-primary before:content-[""]':"hover:bg-muted/40"),children:[ne&&e.jsx("div",{className:"flex shrink-0",onClick:He=>He.stopPropagation(),children:e.jsx(fs,{className:"h-3 w-3 [&_svg]:h-2.5 [&_svg]:w-2.5",checked:h.has(Se.id),onCheckedChange:He=>D(Se.id,He===!0),"aria-label":`Select ${Se.title}`})}),e.jsxs("button",{type:"button",onClick:()=>K(Se.id),"aria-current":dt?"page":void 0,className:"relative min-w-0 flex-1 pr-8 text-left",children:[e.jsx("div",{className:"flex items-center gap-1.5 pr-1",children:e.jsx("span",{className:O("min-w-0 flex-1 truncate text-[10px] font-medium leading-4",dt?"text-foreground":"text-foreground/80"),children:Se.title})}),e.jsx("span",{className:O("absolute right-0 top-0 shrink-0 tabular-nums text-[8px] leading-4",dt?"text-primary/75":"text-muted-foreground/55"),children:El(Se.updatedAt)}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-0.5",children:[e.jsx("span",{className:"rounded-sm bg-muted/35 px-1 py-0 font-mono text-[8px] leading-3 text-muted-foreground/65",children:St}),Se.activeShare&&e.jsx(Ye,{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"}),Ft&&e.jsx(Ye,{variant:"outline",className:"rounded-sm border-destructive/25 bg-destructive/8 px-1 py-0 text-[8px] leading-3 text-destructive shadow-none",children:"unavailable"})]}),e.jsx(Qa,{status:Se.status,isNative:Se.conversationKind==="nativeSession",size:"compact",className:"absolute bottom-1 right-0"})]})]},Se.id)}),et>0&&e.jsxs("button",{type:"button",onClick:()=>{rt&&w?w(rt):ct(nt)},className:"mt-1 flex w-full items-center justify-center gap-1 rounded-sm border border-dashed border-border/55 bg-background/35 px-2 py-1 text-[9px] font-medium text-muted-foreground transition-colors hover:border-primary/35 hover:bg-primary/8 hover:text-primary","aria-label":`Load ${et} more completed tasks in ${Dt}`,children:[e.jsx(st,{className:"h-3 w-3"}),"Load ",et," more completed"]})]})})})]},nt)})})})]},ze)})}):n?e.jsx("div",{className:"space-y-2 px-1",children:[1,2,3].map(G=>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+G*12}%`,animationDelay:`${G*120}ms`}}),e.jsx("div",{className:"h-2 w-24 animate-pulse rounded-full bg-muted-foreground/10",style:{animationDelay:`${G*120+60}ms`}})]})]})},G))}):e.jsx("div",{className:"rounded-xl border border-dashed border-border/70 bg-background/35 px-3 py-5 text-[11px] text-muted-foreground",children:r||"No tasks match this view."})}),be?e.jsx("div",{className:"shrink-0 px-2.5 pb-2.5 pt-1.5",children:ne&&_>0?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[_e,e.jsx(Z,{variant:"ghost",size:"sm",onClick:ye,className:"h-5 shrink-0 rounded-sm px-1.5 text-[9px]",children:"Clear"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"flex min-w-0 shrink-0 items-center",children:yt}),Nt]})]}):e.jsxs("div",{className:"flex items-end justify-between gap-2",children:[e.jsx("div",{className:"flex min-w-0 shrink-0 items-center",children:yt}),ne&&e.jsx(Z,{variant:"ghost",size:"sm",onClick:ye,className:"h-5 shrink-0 rounded-sm px-1.5 text-[9px]",children:"Done"})]})}):null]}),e.jsx(gf,{node:oe,open:oe!==null,onOpenChange:G=>{G||ue(null)}})]})}async function kf(t,s){try{const n=await Al(t,s),r={...n,url:Ga(n.url)};if(globalThis.navigator?.clipboard?.writeText)try{await globalThis.navigator.clipboard.writeText(r.url),de.success("Shared link copied")}catch{de.success("Shared link created")}else de.success("Shared link created");return r}catch(n){de.error(n instanceof Error?n.message:"Failed to create shared link");return}}async function Sf(t){try{return await Ml(t),de.success("Shared link stopped"),!0}catch(s){return de.error(s instanceof Error?s.message:"Failed to stop shared link"),!1}}function Cf(t,s,n){const r=o.useCallback(()=>{s(),n()},[s,n]),a=o.useCallback(async l=>{if(!t)return;const c=await kf(t.id,l);return c&&r(),c},[t,r]),i=o.useCallback(async()=>{if(!t)return!1;const l=await Sf(t.id);return l&&r(),l},[t,r]);return{handleShareTask:a,handleStopShareTask:i}}function Ta(t,s,n){const r=o.useRef(s);r.current=s,o.useEffect(()=>{let l=0,c=0;const d=u=>{const f=u.touches[0];f&&(l=f.clientX,c=f.clientY)},m=u=>{const f=u.changedTouches[0];if(!f)return;const x=f.clientX-l;Math.abs(f.clientY-c)>100||Math.abs(x)<50||(x>0?r.current.onSwipeRight?.():r.current.onSwipeLeft?.())},g=t?.current??document;return g.addEventListener("touchstart",d,{passive:!0}),g.addEventListener("touchend",m,{passive:!0}),()=>{g.removeEventListener("touchstart",d),g.removeEventListener("touchend",m)}},[t,n?.threshold,n?.maxVertical])}const Tf="(min-width: 1024px)",Ef="(min-width: 1800px)";function Ea(t){return globalThis.window?.matchMedia?.(t)?.matches??!1}function Af(){const t=globalThis.document?.documentElement;if(!t||!globalThis.window?.getComputedStyle)return 16;const s=Number.parseFloat(globalThis.window.getComputedStyle(t).fontSize);return Number.isFinite(s)&&s>0?s:16}function Mf(){const[t,s]=o.useState(()=>Dl(gr(),_l({operationsOpen:Ea(Ef)}))),[n,r]=o.useState(!1),a=o.useRef(null),i=o.useRef(null),l=o.useRef(null),c=t.layout.desktopTasksOpen,d=t.layout.operationsOpen,m=t.sizes;o.useEffect(()=>{Pl(gr(),t)},[t]);const g=o.useCallback((T,p)=>{s(k=>{const y=k.layout[T],h=typeof p=="function"?p(y):p;return h===y?k:{...k,layout:{...k.layout,[T]:h}}})},[]),u=o.useCallback(T=>{g("desktopTasksOpen",T)},[g]),f=o.useCallback(T=>{g("operationsOpen",T)},[g]);Ta(i,{onSwipeLeft:()=>r(!1)}),Ta(l,{onSwipeRight:()=>f(!1)});const x=o.useCallback(()=>{if(Ea(Tf)){u(T=>!T);return}r(T=>!T)},[u]);o.useEffect(()=>{const T=k=>{const y=a.current;if(!y)return;k.preventDefault();const h=Rl(y.panel,y.startSize,y.startClientX,y.startClientY,k.clientX,k.clientY,y.rootFontSize);s(v=>({...v,sizes:{...v.sizes,[y.panel]:h}}))},p=()=>{a.current=null};return globalThis.window?.addEventListener("pointermove",T),globalThis.window?.addEventListener("pointerup",p),globalThis.window?.addEventListener("pointercancel",p),()=>{globalThis.window?.removeEventListener("pointermove",T),globalThis.window?.removeEventListener("pointerup",p),globalThis.window?.removeEventListener("pointercancel",p)}},[]);const N=o.useCallback((T,p)=>{p.preventDefault(),p.currentTarget.setPointerCapture?.(p.pointerId),a.current={panel:T,startSize:m[T],startClientX:p.clientX,startClientY:p.clientY,rootFontSize:Af()}},[m]),b=o.useCallback((T,p)=>{p.preventDefault(),s(k=>({...k,sizes:{...k.sizes,[T]:Il(T,k.sizes[T],p.deltaY)}}))},[]);return{desktopTasksOpen:c,mobileTasksPanelOpen:n,mobileTasksPanelRef:i,operationsOpen:d,operationsPanelRef:l,panelResize:{sizes:{tasks:Ys(m.tasks),operations:Ys(m.operations),terminal:Ys(m.terminal)},onPointerDown:N,onWheel:b},setMobileTasksPanelOpen:r,setOperationsOpen:f,toggleTasksPanel:x}}function Df(t,s){const n=s.taskId,r=s.updates;return typeof n!="string"||!r||typeof r!="object"?t:t.map(a=>a.id===n?{...a,...r}:a)}const _f="notify_desktop_task";function Pf(t=ti()){const s=t?.__TAURI__?.core?.invoke;return typeof s=="function"?s:null}async function If(t,s=ti()){const n=Pf(s);return n?(await n(_f,t),!0):!1}function Rf(t,s){const n=[];for(const r of s){const a=Lf(r.status);if(!a)continue;const i=t.get(r.id);!i||i.status===r.status||n.push({taskId:r.id,title:r.title.trim()||"Meshy task",status:a,assignedNodeName:r.assignedNodeName??null,projectPath:r.effectiveProjectPath??r.project??null})}return n}function Lf(t){return t==="completed"||t==="failed"?t:null}function ti(){return typeof window>"u"?null:window}function Bf({isLeader:t,selfId:s}){return{...!t&&s?{assignedTo:s}:{},completedLimitPerProject:Jn}}function Kn(t){return`${t.assignedTo??"__unassigned__"}::${t.projectPath}`}function Of(t,s){const n=new Map(t.map(r=>[r.id,r]));for(const r of s)n.set(r.id,r);return Array.from(n.values())}function Ff(t,s,n=new Set){return!s||n.has(s.id)||t.some(r=>r.id===s.id)?t:jo(t,s)}function zf({isLeader:t,selfId:s,sseConnected:n,preservedTask:r,subscribe:a}){const[i,l]=o.useState([]),[c,d]=o.useState([]),[m,g]=o.useState(!0),[u,f]=o.useState(null),x=o.useRef(new Set),N=o.useRef(null),b=o.useRef(null),T=o.useCallback(async()=>{try{const h=await br(Bf({isLeader:t,selfId:s}));l(Ff(h.tasks,r,x.current)),d(h.completedGroups??[]),f(null)}catch(h){f(h instanceof Error?h.message:"Failed to load tasks")}finally{g(!1)}},[t,r,s]),p=o.useCallback(async h=>{if(!h.hasMore||!h.nextCursor)return;const v=await br({status:"completed",assignedTo:h.assignedTo??"__unassigned__",projectPath:h.projectPath,cursor:h.nextCursor,limit:Jn});l(j=>Of(j,v.tasks)),d(j=>j.map(E=>Kn(E)===Kn(h)?{...E,returned:Math.min(E.total,E.returned+v.tasks.length),hasMore:v.hasMore===!0,nextCursor:v.nextCursor??null}:E))},[]),k=o.useCallback(()=>{b.current===null&&(b.current=window.setTimeout(()=>{b.current=null,T()},Ll))},[T]),y=o.useCallback(h=>{const v=new Set(h);if(v.size!==0){for(const j of v)x.current.add(j);l(j=>j.filter(E=>!v.has(E.id)))}},[]);return Bl(T,zl(n)),o.useEffect(()=>()=>{b.current!==null&&(window.clearTimeout(b.current),b.current=null)},[]),o.useEffect(()=>{const h=N.current;if(h)for(const v of Rf(h,i))If(v).catch(()=>{});N.current=new Map(i.map(v=>[v.id,v]))},[i]),o.useEffect(()=>{const h=[a("task.updated",v=>{l(j=>Df(j,v.data))}),a("task.status",v=>{l(j=>Ol(j,v.data))}),a("node",v=>{vr(v.type)&&k()}),a("task",v=>{if(v.type==="task.deleted"){const j=v.data.taskId;typeof j=="string"&&x.current.add(j),l(E=>Fl(E,v.data))}vr(v.type)&&k()})];return()=>h.forEach(v=>v())},[a,k]),{completedGroups:c,fetchTasks:T,loadCompletedTasksPage:p,removeTasksFromList:y,setTasks:l,tasks:i,tasksError:u,tasksLoading:m}}function ir(t){return t.map(s=>({...s}))}function qf(t,s){const n=s.get(t);return{logs:n?ir(n.logs):[],transcriptLoading:n?.loaded!==!0}}function Uf(t,s){return s.data.nodeId===t.self.id||s.data.name===t.self.name||s.data.endpoint===t.self.endpoint}function $f(t,s){const n=t.data.name;if(typeof n=="string"&&n.length>0)return n;const r=t.data.nodeId;return typeof r=="string"?s?.get(r)??r:"node"}function Hf({cluster:t,subscribe:s}){o.useEffect(()=>{if(t?.self?.role!=="leader")return;const n=new Map(t.nodes.map(r=>[r.id,r.name]));return n.set(t.self.id,t.self.name),s("node",r=>{const a=$f(r,n),i=Uf(t,r);r.type==="node.joined"&&!i&&de.success(`${a} joined the cluster`),r.type==="node.left"&&!i&&de.message(`${a} left the cluster`)})},[t,s])}function Vf({localCount:t,checkpointTotal:s}){const n=Math.max(0,Math.floor(t));if(s===void 0)return{after:n};const r=Math.max(0,Math.floor(s));return n>=r?null:{after:n,minTotal:r}}function Kf({activeTaskId:t,cacheTranscript:s,fetchActiveLogs:n,fetchActiveTask:r,logs:a,setLogs:i,setPendingMessages:l,setTranscriptLoading:c,sseConnected:d,subscribe:m}){const g=o.useRef([]),u=o.useRef(d),f=o.useRef(!1),x=o.useRef(!1),N=o.useRef(void 0);o.useEffect(()=>{g.current=ir(a)},[a]);const b=o.useCallback(T=>{if(f.current){x.current=!0,T!==void 0&&(N.current=Math.max(N.current??0,T));return}const p=Vf({localCount:g.current.length,checkpointTotal:T});p&&(f.current=!0,n(p).finally(()=>{if(f.current=!1,!x.current)return;x.current=!1;const k=N.current;N.current=void 0,b(k)}))},[n]);o.useEffect(()=>{if(t)return m("task",T=>{const p=T.data.taskId;if(!(typeof p!="string"||p!==t)){if(T.type==="task.output"){const k=T.data.event;if(k){i(h=>{const v=Ac(h,k);return s(t,v),v}),c(!1);const y=Xn(k);y&&l(h=>Mc(h,y))}}if(T.type==="task.updated"&&r(),T.type==="task.logs.ready"){const k=T.data.total;b(typeof k=="number"?k:void 0)}T.type==="task.status"&&(r(),b())}})},[t,s,n,r,b,i,l,c,m]),o.useEffect(()=>{const T=u.current;u.current=d,!T&&d&&t&&b()},[t,b,d])}const Gf=[0,300,1e3,2e3];function Wf({task:t,getActiveTaskId:s,setLogs:n,setPendingMessages:r,setTranscriptLoading:a}){t.conversationKind==="nativeSession"&&(async()=>{try{for(const i of Gf){if(i>0&&await new Promise(l=>setTimeout(l,i)),s()!==t.id)return;try{const l=await Rn(t.id);if(s()!==t.id||(n(c=>fo(c,l.logs)),r(c=>Bn(c,l.logs)),l.total>0))return}catch{}}}finally{s()===t.id&&a?.(!1)}})()}const si=8;function Qf(t,s){return Ke(t??{})===Ke(s??{})}function Yf(t){return t&&"status"in t&&typeof t.status=="string"?t.status:void 0}function Aa(t,s){return{...t,enabled:!0,alwaysOnline:s}}function ni(t){return t?.status?.trim()||t?.lastStatus?.trim()||"Unknown"}function Jf({operationStarting:t,loading:s,refreshing:n,savedStatus:r,fallbackStatus:a}){return t?"Starting":s?"Listing DevBoxes":n?"Refreshing":r??a}async function Zf(t,s=ro){return(await s({nodeId:t,kind:"devbox.start"})).filter(r=>r.kind==="devbox.start").sort((r,a)=>(a.updatedAt??a.createdAt)-(r.updatedAt??r.createdAt)).slice(0,si)}function Xf(t){return t.charAt(0).toUpperCase()+t.slice(1)}function eh(t){const s=t.completedAt??t.startedAt??t.updatedAt??t.createdAt;return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(s))}function th(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function Ma(t,s){const r=th(t)?.[s];return typeof r=="string"&&r.trim()?r.trim():null}function sh(t){if(t.status==="failed")return t.error||"Operation failed";const s=Ma(t.result,"operationId");if(s)return`MCP operation ${s}`;const n=Ma(t.payload,"previousStatus");return n?`Previous DevBox status: ${n}`:t.status==="succeeded"?"Completed":"Waiting for completion"}function nh(t){return t==="succeeded"?"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":t==="failed"?"border-destructive/30 bg-destructive/10 text-destructive":t==="running"?"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300":"border-border/70 bg-muted/40 text-muted-foreground"}function Da({devbox:t,showStatus:s=!1}){return e.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:[e.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[e.jsx("span",{className:"font-medium",children:t.name}),t.projectName&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",t.projectName]})]}),s&&e.jsx("span",{className:"ml-auto shrink-0 rounded-sm border border-border/70 bg-background/70 px-1.5 py-0 text-[10px] leading-none text-muted-foreground",children:ni(t)})]})}function rh({error:t,loading:s,onToggle:n,open:r,operations:a}){return e.jsxs("div",{className:"min-w-0 max-w-full overflow-hidden rounded-sm border border-border/60 bg-muted/20 text-xs",children:[e.jsxs("button",{type:"button",onClick:n,"aria-expanded":r,className:"flex h-8 w-full items-center gap-2 px-3 text-left text-[11px] text-foreground hover:bg-muted/30",children:[e.jsx(st,{className:O("h-3 w-3 shrink-0 text-muted-foreground transition-transform",!r&&"-rotate-90")}),e.jsx(_s,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:"Operations history"}),s&&e.jsx(me,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground"}),!s&&a.length>0&&e.jsx("span",{className:"shrink-0 rounded-sm border border-border/70 bg-background/60 px-1.5 py-0 text-[10px] leading-none text-muted-foreground",children:a.length})]}),r&&e.jsxs("div",{className:"max-h-44 min-w-0 max-w-full overflow-y-auto border-t border-border/50 px-2 py-1.5",children:[s&&a.length===0&&e.jsxs("div",{className:"flex h-7 items-center gap-2 px-1 text-[10px] text-muted-foreground",children:[e.jsx(me,{className:"h-3 w-3 animate-spin"}),"Loading operations"]}),t&&e.jsx("div",{className:"px-1 py-1 text-[10px] text-destructive",children:t}),!s&&!t&&a.length===0&&e.jsx("div",{className:"px-1 py-1 text-[10px] text-muted-foreground",children:"No DevBox operations yet."}),a.map(i=>{const l=sh(i);return e.jsxs("div",{className:"flex w-full min-w-0 max-w-full items-start gap-2 overflow-hidden rounded-sm px-1 py-1.5 text-[11px] hover:bg-background/40",children:[e.jsxs("div",{className:"min-w-0 flex-1 overflow-hidden",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-medium text-foreground",children:"Start DevBox"}),e.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground",children:eh(i)})]}),e.jsx("div",{className:"mt-0.5 w-full min-w-0 max-w-full overflow-x-auto whitespace-nowrap text-[10px] leading-3.5 text-muted-foreground",title:l,children:e.jsx("span",{className:"inline-block min-w-max",children:l})})]}),e.jsx("span",{className:O("shrink-0 rounded-sm border px-1.5 py-0 text-[10px] leading-4",nh(i.status)),children:Xf(i.status)})]},i.id)})]})]})}function ah({node:t,open:s,startInProgress:n=!1,onOpenChange:r,onRefresh:a}){const i=t?.id??null,l=s&&!n&&ga(t?.status,t?.devbox??null),[c,d]=o.useState([]),[m,g]=o.useState(()=>t?.devbox?Ke(t.devbox):""),[u,f]=o.useState(()=>t?.devbox??null),[x,N]=o.useState(()=>ba(t?.devbox??null)),[b,T]=o.useState(!1),[p,k]=o.useState(l),[y,h]=o.useState(!1),[v,j]=o.useState(!1),[E,R]=o.useState(()=>t?.devbox?.alwaysOnline===!0),[A,L]=o.useState(!1),[M,D]=o.useState([]),[P,F]=o.useState(!1),[Q,re]=o.useState(null),W=o.useMemo(()=>{const $=c.find(ae=>Ke(ae)===m);return $||(Ht(u)&&Ke(u)===m?u:void 0)},[u,c,m]),ee=Yf(W??void 0),se=x?ee??u?.lastStatus:u?.lastStatus??ee,q=t?.status==="online"||t?.status==="busy"?"Running":"Unknown",X=v||n,w=Jf({operationStarting:X,loading:b,refreshing:p,savedStatus:se,fallbackStatus:q}),K=x&&!!W&&!Qf(u,W),C=u?.alwaysOnline===!0!==E,Y=uf({nodeStatus:t?.status,status:w,current:u,selected:W}),I=!!Y,U=!!W&&(K||C)&&!I,B=W??u,le=o.useCallback(async()=>{if(i){k(!0);try{const $=await ql(i);f($.devbox),g(Ke($.devbox))}catch($){de.error($ instanceof Error?$.message:"Failed to refresh DevBox status")}finally{k(!1)}}},[i]),oe=o.useCallback(async $=>{T(!0);try{const ae=await Ul();d(ae),g(pe=>mf({previousKey:pe,baseDevBox:$,listed:ae}))}catch(ae){de.error(ae instanceof Error?ae.message:"Failed to load DevBoxes")}finally{T(!1)}},[]);o.useEffect(()=>{if(!s||!i)return;let $=!1;const ae=t?.devbox??null,pe=ba(ae),fe=!n&&ga(t?.status,ae);T(!1),k(fe),N(pe),f(ae),R(ae?.alwaysOnline===!0),L(!1),g(Ht(ae)?Ke(ae):""),d([]);async function Ve(){fe&&await le(),!$&&pe&&await oe(ae)}return Ve(),()=>{$=!0}},[oe,t?.devbox,t?.status,i,s,le,n]),o.useEffect(()=>{if(!s||!i)return;let $=!1;const ae=i;async function pe(){F(!0),re(null),D([]);try{const fe=await Zf(ae);if($)return;D(fe)}catch(fe){if($)return;D([]),re(fe instanceof Error?fe.message:"Failed to load operation history")}finally{$||F(!1)}}return pe(),()=>{$=!0}},[i,s]);async function ue(){N(!0),c.length===0&&await oe(u)}async function J(){if(!(!t||!W)){h(!0);try{const $=await wr(t.id,Aa(W,E));f($.node.devbox??null),$.node.devbox&&g(Ke($.node.devbox)),N(!1),de.success(`Configured DevBox for ${t.name}`),await a?.()}catch($){de.error($ instanceof Error?$.message:"Failed to configure DevBox")}finally{h(!1)}}}async function V(){if(!(!t||!Y)){j(!0);try{if(W&&(K||C)){const ae=await wr(t.id,Aa(W,E));f(ae.node.devbox??null),ae.node.devbox&&g(Ke(ae.node.devbox)),N(!1)}const{operation:$}=await ao(t.id);f(ae=>ae&&{...ae,lastStatus:"Starting",checkedAt:Date.now(),operationId:$.id}),D(ae=>[$,...ae.filter(pe=>pe.id!==$.id)].slice(0,si)),de.success(`Start requested for ${t.name}`),await a?.()}catch($){de.error($ instanceof Error?$.message:"Failed to start DevBox")}finally{j(!1)}}}const _=b?"Loading DevBoxes...":c.length===0?"No DevBoxes available":"Select a DevBox",ne=w==="Running"&&t?.status==="offline";return e.jsx(At,{open:s,onOpenChange:r,children:e.jsxs(Mt,{className:"w-[calc(100vw-2rem)] max-w-md grid-cols-[minmax(0,1fr)] gap-3 overflow-hidden rounded-sm p-4",children:[e.jsxs(xs,{className:"min-w-0 max-w-full space-y-1 overflow-hidden",children:[e.jsx(Rt,{className:"text-sm",children:"Configure DevBox"}),e.jsxs(ps,{className:"max-w-full text-xs",children:["Bind ",t?.name?e.jsx("span",{className:"font-medium text-foreground",children:t.name}):"this node"," to an Azure Dev Box. Meshy will start it when the node is offline."]})]}),e.jsxs("div",{className:"min-w-0 max-w-full space-y-3 overflow-hidden",children:[(x||B)&&e.jsxs("div",{className:"flex min-h-9 w-full min-w-0 max-w-full items-center justify-between gap-3 overflow-hidden rounded-sm border border-border/60 bg-muted/20 px-3 py-2 text-xs",children:[e.jsx("div",{className:"min-w-0 flex-1",children:x?e.jsxs(Be,{value:m,onValueChange:g,disabled:b||y||v||c.length===0,children:[e.jsx(Oe,{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:b&&!W?e.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}),_]}):W?e.jsx(Da,{devbox:W}):e.jsx(Ge,{placeholder:_})}),e.jsx(Fe,{children:c.map($=>e.jsx(Le,{value:Ke($),textValue:`${$.name} ${$.projectName??""} ${ni($)}`,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(Da,{devbox:$,showStatus:!0})},Ke($)))})]}):B&&e.jsxs("div",{className:"min-w-0 truncate",children:[e.jsx("span",{className:"font-medium text-foreground",children:B.name}),B.projectName&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",B.projectName]})]})}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs(Ye,{variant:"outline",className:"rounded-sm px-1.5 py-0 text-[10px]",children:[(b||p)&&e.jsx(me,{className:"mr-1 h-2.5 w-2.5 animate-spin"}),w]}),u?.name&&e.jsx(Z,{type:"button",variant:"ghost",size:"icon",onClick:()=>{ue()},disabled:b||y||X||x,"aria-label":"Edit DevBox binding",title:"Edit DevBox binding",className:"h-6 w-6 rounded-sm text-muted-foreground hover:text-foreground",children:b&&x?e.jsx(me,{className:"h-3 w-3 animate-spin"}):e.jsx(Gt,{className:"h-3 w-3"})})]})]}),ne&&e.jsx("div",{className:"rounded-sm border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300",children:"DevBox is running, but the Meshy node is not connected yet."}),e.jsxs("label",{className:"flex min-h-9 w-full min-w-0 max-w-full items-start gap-2 overflow-hidden rounded-sm border border-border/60 bg-muted/20 px-3 py-2 text-xs text-foreground",children:[e.jsx(fs,{checked:E,onCheckedChange:$=>R($===!0),disabled:y||v||X,"aria-label":"Always online",className:"mt-0.5 h-3.5 w-3.5"}),e.jsxs("span",{className:"min-w-0 leading-4",children:[e.jsx("span",{className:"block",children:"Always online"}),e.jsx("span",{className:"block text-[10px] leading-3.5 text-muted-foreground",children:"Meshy will start the DevBox automatically when it is Hibernated or Stopped."})]})]}),e.jsx(rh,{error:Q,loading:P,onToggle:()=>L($=>!$),open:A,operations:M})]}),e.jsxs(Ya,{className:"gap-2 sm:space-x-0",children:[e.jsx(Z,{variant:"ghost",size:"sm",onClick:()=>r(!1),disabled:y||v,className:"h-8 rounded-sm text-xs",children:"Close"}),I&&e.jsxs(Z,{size:"sm",onClick:V,disabled:v,className:"h-8 rounded-sm text-xs",children:[v?e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Bs,{className:"h-3.5 w-3.5"}),"Start DevBox"]}),!I&&e.jsxs(Z,{size:"sm",onClick:J,disabled:!U||y,className:"h-8 rounded-sm text-xs",children:[y&&e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}),"Save"]})]})]})})}async function oh(t,s=ro){if(t.length===0)return new Set;const n=new Set(t),[r,a]=await Promise.all([s({kind:"devbox.start",status:"queued"}),s({kind:"devbox.start",status:"running"})]);return new Set([...r,...a].filter(i=>n.has(i.nodeId)).map(i=>i.nodeId))}function ih({cluster:t,refresh:s}){const[n,r]=o.useState(null),[a,i]=o.useState(null),[l,c]=o.useState(()=>new Set),[d,m]=o.useState(()=>new Set),g=o.useMemo(()=>t?.nodes.find(p=>p.id===n)??null,[t?.nodes,n]),u=o.useMemo(()=>new Set((t?.nodes??[]).filter(p=>p.devbox?.enabled).map(p=>p.id)),[t?.nodes]),f=o.useMemo(()=>new Set((t?.nodes??[]).filter(p=>zs(p.status,p.devbox?.lastStatus,p.devbox)).map(p=>p.id)),[t?.nodes]),x=o.useMemo(()=>new Set((t?.nodes??[]).filter(p=>Vt(p.devbox?.lastStatus)).map(p=>p.id)),[t?.nodes]),N=o.useMemo(()=>{const p=new Set(l);a&&p.add(a);for(const k of d)p.add(k);for(const k of x)p.add(k);return p},[d,a,l,x]);o.useEffect(()=>{let p=!1;const k=[...u];async function y(){try{const h=await oh(k);p||m(h)}catch{p||m(new Set)}}return y(),()=>{p=!0}},[u]),o.useEffect(()=>{c(p=>{let k=!1;const y=new Set(p);for(const h of p){const v=t?.nodes.find(j=>j.id===h);v?.status!=="online"&&(!v?.devbox?.lastStatus||Vt(v.devbox.lastStatus))||(y.delete(h),k=!0)}return k?y:p})},[t?.nodes]);const b=o.useCallback(async p=>{const k=t?.nodes.find(y=>y.id===p);if(k){i(p),c(y=>new Set(y).add(p));try{await ao(p),de.success(`Start requested for ${k.name}`),s()}catch(y){c(h=>{const v=new Set(h);return v.delete(p),v}),de.error(y instanceof Error?y.message:"Failed to start DevBox")}finally{i(null)}}},[t?.nodes,s]);return{devBoxDialog:e.jsx(ah,{node:g,open:n!==null,startInProgress:g?N.has(g.id):!1,onOpenChange:p=>{p||r(null)},onRefresh:s}),devBoxNodeIds:u,devBoxStartNodeId:a,devBoxStartNodeIds:f,devBoxStartingNodeIds:N,openDevBox:r,startDevBox:b}}function lh(t){const[s,n]=o.useState(null),r=o.useCallback(i=>{t&&n(i)},[t]);return{nodeSettingsDialog:e.jsx($l,{open:s!==null,onOpenChange:i=>{i||n(null)},initialSelectedNodeId:s??void 0,showTrigger:!1}),openNodeSettings:r}}function ch(t=!1){return!t}function dh({activeTaskId:t,fetchActiveTask:s,isRunning:n=!1,setPendingMessages:r,setTask:a,setTasks:i}){const l=o.useCallback((m,g)=>{a(u=>u&&u.id===m?{...u,queuedMessages:g}:u),i(u=>u.map(f=>f.id===m?{...f,queuedMessages:g}:f))},[a,i]),c=o.useCallback(async(m,g={})=>{if(!t)return!1;const u=`local-${Date.now()}-${Math.random().toString(16).slice(2)}`,f=ch(n);f&&r(x=>[...x,{id:u,content:m,timestamp:new Date().toISOString()}]);try{const x=g.targetAgent?await yr(t,m,g.targetAgent):await yr(t,m);return x.queued&&(f&&r(N=>N.filter(b=>b.id!==u)),x.queuedMessages&&l(t,x.queuedMessages)),s(),!0}catch(x){return f&&r(N=>N.filter(b=>b.id!==u)),de.error(x instanceof Error?x.message:"Failed to send message"),!1}},[t,s,n,r,l]);return{cancelQueuedMessage:o.useCallback(async m=>{if(t)try{const g=await Hl(t,m);l(t,g.queuedMessages),s()}catch(g){de.error(g instanceof Error?g.message:"Failed to cancel queued message")}},[t,s,l]),queueFollowUpMessage:c}}const _a="grid-cols-[1.5rem_5.25rem_4rem_minmax(8rem,1fr)_4rem_4rem_6rem]",uh={claudecode:"Claude Code",codex:"Codex",copilot:"Copilot"};function mh(t,s){const n=s.search.trim().toLowerCase();return t.filter(r=>s.agent!=="all"&&r.agent!==s.agent||s.kind!=="all"&&r.kind!==s.kind?!1:n?[r.name,r.description,r.source,r.version,r.agent,r.kind].some(a=>a?.toLowerCase().includes(n)):!0)}function ri(t){return t.kind==="mcp"?"-":t.sizeBytes<1024?`${t.sizeBytes} B`:t.sizeBytes<1024*1024?`${Math.round(t.sizeBytes/1024)} KB`:`${(t.sizeBytes/1024/1024).toFixed(1)} MB`}function fh({items:t,selectedIds:s,activeId:n,onToggleSelected:r,onOpenDetail:a}){return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden rounded-sm border border-border/60 bg-card/35",children:[e.jsxs("div",{className:O("grid shrink-0 gap-2 border-b border-border/55 bg-primary/6 px-2 py-1.5 text-[8px] font-semibold uppercase tracking-[0.14em] text-muted-foreground",_a),children:[e.jsx("span",{}),e.jsx("span",{children:"Agent"}),e.jsx("span",{children:"Kind"}),e.jsx("span",{children:"Name"}),e.jsx("span",{children:"Ver"}),e.jsx("span",{children:"Size"}),e.jsx("span",{children:"Source"})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:t.length>0?t.map(i=>e.jsxs("button",{type:"button",onClick:()=>a(i),className:O("grid h-7 w-full items-center gap-2 border-b border-border/30 px-2 text-left text-[10px] transition-colors hover:bg-primary/6",_a,n===i.id&&"bg-primary/10 text-primary shadow-[inset_2px_0_0_hsl(var(--primary))]"),children:[e.jsx("span",{onClick:l=>l.stopPropagation(),children:e.jsx(fs,{className:"h-3 w-3",checked:s.has(i.id),onCheckedChange:l=>r(i.id,l===!0),"aria-label":`Select ${i.name}`})}),e.jsx(hh,{agent:i.agent}),e.jsx("span",{children:i.kind}),e.jsx("span",{className:"truncate font-medium text-foreground",children:i.name}),e.jsx("span",{className:"truncate text-muted-foreground",children:i.version??"-"}),e.jsx("span",{className:"truncate text-muted-foreground",children:ri(i)}),e.jsx("span",{className:"truncate text-muted-foreground",children:i.source??"local"})]},i.id)):e.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-muted-foreground",children:"No capabilities match this view."})})]})}function hh({agent:t}){const s=uh[t];return e.jsx("span",{className:"block min-w-0 truncate text-[10px] font-medium leading-3 text-muted-foreground",title:s,children:s})}const Pa=320,Ia=560,ai=384,Ra=360;function xh(t,s=Ia+Ra){const n=Math.max(Pa,Math.min(Ia,s-Ra));return Math.min(Math.max(Math.round(t),Pa),n)}function ph(t,s,n,r){return xh(t+s-n,r)}function gh({detail:t,deleting:s=!1,onDelete:n,desktopWidth:r=ai,pending:a=!1}){const i={"--capability-detail-width":`${r}px`};if(!t)return e.jsx("aside",{"data-capability-detail-panel":"true",style:i,className:"hidden min-h-0 shrink-0 animate-panel-settle bg-gradient-to-b from-primary/6 via-card/28 to-background/60 px-3 py-3 text-[11px] text-muted-foreground lg:block lg:w-[var(--capability-detail-width)]",children:a?"Loading capability metadata...":"No capability selected."});const l=t.kind==="mcp"?"mcp":"files";return e.jsxs("aside",{"data-capability-detail-panel":"true",style:i,className:"flex min-h-0 w-full shrink-0 animate-panel-settle flex-col bg-gradient-to-b from-primary/6 via-card/28 to-background/60 px-3 py-2.5 lg:w-[var(--capability-detail-width)]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[e.jsx("div",{className:"truncate text-[13px] font-semibold leading-5 text-foreground",children:t.name}),e.jsxs("div",{className:"flex shrink-0 flex-wrap gap-1",children:[e.jsx(Ye,{variant:"secondary",className:"rounded-sm border-0 bg-card/72 px-1.5 py-0 text-[8px] text-primary",children:t.agent}),e.jsx(Ye,{variant:"outline",className:"rounded-sm border-0 bg-card/72 px-1.5 py-0 text-[8px] text-primary/90",children:t.kind})]})]}),n&&e.jsxs(ss,{children:[e.jsx(In,{asChild:!0,children:e.jsx(Z,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-sm text-muted-foreground hover:text-destructive","aria-label":"Delete capability",title:"Delete capability",disabled:s,children:e.jsx(no,{className:"h-3.5 w-3.5"})})}),e.jsxs(ns,{className:"max-w-[22rem] gap-2 rounded-xl p-4",children:[e.jsxs(rs,{className:"space-y-1",children:[e.jsxs(as,{className:"text-sm",children:["Delete ",t.name,"?"]}),e.jsxs(os,{className:"text-[11px] leading-4",children:["This removes the selected ",t.kind," from ",t.scope.kind==="global"?"the user profile":"this project","."]})]}),e.jsxs(is,{className:"gap-1 pt-0 sm:space-x-1",children:[e.jsx(ls,{className:"h-7 rounded-lg px-2 text-[11px]",children:"Cancel"}),e.jsx(cs,{className:"h-7 rounded-lg px-2 text-[11px]",onClick:n,disabled:s,children:"Delete"})]})]})]})]}),e.jsxs("div",{className:"mt-1 grid grid-cols-2 gap-1 text-[9px]",children:[e.jsx(Ts,{label:"Version",value:t.version??"-"}),e.jsx(Ts,{label:"Size",value:ri(t)}),e.jsx(Ts,{label:"Files",value:String(t.fileCount)}),e.jsx(Ts,{label:"Source",value:t.source??"local"})]}),e.jsxs(Wn,{defaultValue:l,className:"mt-2 flex min-h-0 flex-1 flex-col",children:[e.jsxs(Gn,{className:"grid h-auto grid-cols-2 rounded-sm bg-primary/8 p-0.5",children:[t.kind==="mcp"?e.jsx(Pt,{value:"mcp",className:"rounded-sm px-2 py-0.5 text-[9px]",children:"MCP"}):e.jsx(Pt,{value:"files",className:"rounded-sm px-2 py-0.5 text-[9px]",children:"Files"}),e.jsx(Pt,{value:"readme",className:"rounded-sm px-2 py-0.5 text-[9px]",children:"README"})]}),t.kind==="mcp"?e.jsx(bt,{value:"mcp",className:"mt-2 min-h-0 flex-1 overflow-auto",children:e.jsx(bh,{detail:t})}):e.jsx(bt,{value:"files",className:"mt-2 min-h-0 flex-1 overflow-auto",children:e.jsx(vh,{detail:t})}),e.jsx(bt,{value:"readme",className:"mt-2 min-h-0 flex-1 overflow-auto",children:t.readmeMarkdown?e.jsx(Lc,{content:t.readmeMarkdown,className:"overflow-hidden rounded-sm border-0 bg-background/70 shadow-none [&>div:first-child>div]:border-0 [&>div:first-child]:border-b-0",previewClassName:"px-3 py-2 text-[11px] leading-5",rawClassName:"text-[10px] leading-4"}):e.jsx(lr,{children:"No README content."})})]},t.id)]})}function bh({detail:t}){const s=t.mcpPreview??[];return s.length===0?e.jsx(lr,{children:"No MCP entries."}):e.jsx("div",{className:"space-y-1.5",children:s.map(n=>e.jsxs("div",{className:"rounded-sm bg-card/72 p-2 text-[10px] shadow-none",children:[e.jsx("div",{className:"font-semibold text-foreground",children:n.serverName}),e.jsx("pre",{className:"mt-1 max-h-64 overflow-auto rounded-sm bg-background/55 px-2 py-1 whitespace-pre-wrap break-all font-mono text-[9px] leading-4 text-muted-foreground",children:JSON.stringify(n.config,null,2)})]},n.serverName))})}function vh({detail:t}){const s=t.fileTree??[];return s.length===0?e.jsx(lr,{children:"No files."}):e.jsx("div",{className:"space-y-1 overflow-auto rounded-sm bg-card/72 p-2 font-mono text-[9px] leading-4 text-muted-foreground shadow-none",children:s.map(n=>e.jsx("div",{children:n.relPath},n.relPath))})}function lr({children:t}){return e.jsx("div",{className:"rounded-sm bg-primary/5 px-2 py-6 text-center text-[10px] text-muted-foreground",children:t})}function Ts({label:t,value:s}){return e.jsxs("div",{className:"rounded-sm bg-card/72 px-2 py-0.5 shadow-none",children:[e.jsx("div",{className:"text-[7px] uppercase tracking-[0.14em] text-muted-foreground",children:t}),e.jsx("div",{className:"truncate text-[9px] font-medium text-foreground",children:s})]})}const wh=20,yh=288,Nh=360,jh=440;function kh(){if(typeof window>"u"||typeof document>"u")return 1;const t=window.getComputedStyle(document.documentElement),s=t.zoom||t.getPropertyValue("--ui-zoom"),n=Number.parseFloat(s);return Number.isFinite(n)&&n>0?n:1}function Sh({triggerRect:t,targetRect:s,viewportRect:n,compact:r,browserOpen:a=!1,portalAlign:i,cssZoom:l=1}){const c=Number.isFinite(l)&&l>0?l:1,d=8,m=n.top+d,g=n.bottom-d,u=n.left+d,f=n.right-d,x=Math.max(0,g-t.bottom-4),N=Math.max(0,t.top-m-4),b=r?N<140&&x>N:x>=220||x>=N,T=b?x:N,p=Math.max(140,g-m),k=r&&a,v=Math.min(p,k?jh:320,Math.max(k?Nh:140,T)),j=yh*c,E=i==="end"?t.right-j:t.left,A=(Math.max(u,Math.min(E,f-j))-s.left)/c;if(!b&&!k)return{left:A,bottom:(s.bottom-(t.top-4))/c,maxHeight:v/c};const L=b?t.bottom+4:t.top-v-4,M=Math.max(m,Math.min(L,g-v));return{left:A,top:(M-s.top)/c,maxHeight:v/c}}function cr(t){if(!t.workDir)return[];const s=[],n=new Set,r=a=>{!a||n.has(a)||(n.add(a),s.push(a))};r(t.workDir);for(const a of t.workDirFolders??[])r(ii(a)?a:li(t.workDir,a));return s}function Ch(t,s){if(t.kind==="global")return{nodeId:s.id,scope:{kind:"global"}};const n=cr(s),r=n.find(a=>a===t.projectPath);return r?{nodeId:s.id,scope:{kind:"project",projectPath:r}}:n[0]?{nodeId:s.id,scope:{kind:"project",projectPath:n[0]}}:{nodeId:s.id,scope:{kind:"global"}}}function Th(t,s){return{nodeId:t,scope:s}}function La(t,s,n){const r=s.trim();return!r||r==="."?t.workDir??r:n||ii(r)?r:t.workDir?li(t.workDir,r):r}function Eh({node:t,scope:s,clusterNodes:n,onSelectionChange:r}){const a=o.useMemo(()=>_h(n,t),[n,t]),i=o.useMemo(()=>cr(t),[t]),l=o.useMemo(()=>a.map(c=>({value:c.id,label:c.name,description:`${c.role} · ${c.status}`,status:c.status})),[a]);return e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-2",children:[e.jsx(Dh,{ariaLabel:"Capability node",value:t.name,description:`${t.role} · ${t.status}`,options:l,selectedValue:t.id,onSelect:c=>{const d=a.find(m=>m.id===c);d&&r?.(Ch(s,d))}}),e.jsx(oi,{node:t,projectPaths:i,selectedScope:s,onSelect:c=>r?.(Th(t.id,c))}),e.jsx(Ah,{node:t})]})}function Ah({node:t}){return e.jsxs("div",{"data-capability-node-meta":"true",className:"flex min-w-0 items-center gap-1 border-0 bg-transparent px-0.5 text-[8px] leading-3 text-muted-foreground",title:`${t.role} · ${t.status}`,children:[e.jsx("span",{className:"truncate capitalize",children:t.role}),e.jsx("span",{className:O("h-1.5 w-1.5 shrink-0 rounded-full",ds(t.status))})]})}function oi({node:t,projectPaths:s,selectedScope:n,onSelect:r,compact:a=!1,portal:i=!1,portalAlign:l="start"}){const[c,d]=o.useState(!1),[m,g]=o.useState(null),[u,f]=o.useState(!1),[x,N]=o.useState(!1),[b,T]=o.useState(null),[p,k]=o.useState(!1),[y,h]=o.useState(null),v=o.useRef(null),j=o.useRef(null),E=o.useRef(null),R=o.useMemo(()=>s.map(q=>({value:q,label:Oa(q),description:q})),[s]),A=n.kind==="project"?n.projectPath:void 0,L=n.kind==="global"?"Global":Oa(n.projectPath),M=n.kind==="global"?"Global":n.projectPath,D=o.useCallback(()=>!i||typeof document>"u"?null:j.current?.closest('[data-capability-share-dialog="true"]')??document.body,[i]),P=o.useCallback(()=>{if(!i||!j.current||typeof window>"u")return;const q=j.current.getBoundingClientRect(),X=D(),w=X&&X!==document.body?X.getBoundingClientRect():{left:0,top:0,bottom:window.innerHeight};h(Sh({triggerRect:q,targetRect:w,viewportRect:{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight},compact:a,browserOpen:p,portalAlign:l,cssZoom:kh()}))},[p,a,D,i,l]);o.useEffect(()=>{c||k(!1)},[c]),o.useEffect(()=>{if(!c)return;const q=X=>{if(!(X.target instanceof Node))return;const w=X.composedPath(),K=v.current?w.includes(v.current):!1,C=E.current?w.includes(E.current):X.target instanceof Element&&!!X.target.closest('[data-capability-scope-menu="true"]');!K&&!C&&d(!1)};return document.addEventListener("mousedown",q),()=>document.removeEventListener("mousedown",q)},[c]),o.useEffect(()=>{if(!(!c||!i))return P(),window.addEventListener("resize",P),window.addEventListener("scroll",P,!0),()=>{window.removeEventListener("resize",P),window.removeEventListener("scroll",P,!0)}},[c,i,P]);const F=async(q,X=0,w=!1)=>{if(t.workDir){T(null),w?N(!0):f(!0);try{const K=await Va(t.id,{path:q||".",limit:wh,offset:X,directoriesOnly:!0,allowAbsolute:!0});g(C=>w&&C?{...K,entries:[...C.entries,...K.entries]}:K)}catch(K){T(K instanceof Error?K.message:"Failed to browse folders"),w||g(null)}finally{f(!1),N(!1)}}};o.useEffect(()=>{!c||!p||!t.workDir||(g(null),T(null),F(A||"."))},[p,c,t.id,t.workDir,A]);const Q=(q,X=!1)=>{r({kind:"project",projectPath:La(t,q,X)}),d(!1)},re=()=>{r({kind:"global"}),d(!1)},W=m?La(t,m.currentPath,m.isAbsolute):A??t.workDir??"",ee=i?D():null,se=e.jsxs("div",{ref:E,"data-capability-scope-menu":"true","aria-hidden":!c,onClick:q=>q.stopPropagation(),onMouseDown:q=>q.stopPropagation(),onPointerDown:q=>q.stopPropagation(),style:i&&y?{left:y.left,top:y.top,bottom:y.bottom,height:a&&p?y.maxHeight:void 0,maxHeight:y.maxHeight}:void 0,className:O(i?"absolute z-[80] flex w-72 flex-col overflow-hidden rounded-lg border border-border/70 bg-popover text-popover-foreground shadow-none pointer-events-auto":"absolute left-0 z-50 flex max-h-[28rem] w-72 flex-col overflow-hidden rounded-lg border border-border/70 bg-popover text-popover-foreground shadow-none",!i&&(a?"top-7":"top-9"),!c&&"hidden"),children:[e.jsxs("div",{className:"shrink-0 border-b border-border/55 p-1",children:[e.jsx("div",{className:O("px-2 text-[8px] font-semibold uppercase tracking-[0.14em] text-muted-foreground",a?"pb-0.5 pt-0.5 leading-3":"pb-1 pt-1"),children:"Scope"}),e.jsxs("div",{className:O("overflow-y-auto pr-0.5",a?"max-h-32":"max-h-40"),children:[e.jsx(Ba,{icon:"global",label:"Global",selected:n.kind==="global",onSelect:re,compact:a}),R.length>0?R.map(q=>e.jsx(Ba,{icon:"folder",label:q.label,description:q.description,selected:A===q.value,onSelect:()=>Q(q.value,!0),compact:a},q.value)):e.jsx("div",{className:O("flex items-center px-2 text-muted-foreground",a?"h-7 text-[9px]":"h-8 text-[10px]"),children:"No known projects"})]})]}),e.jsxs("div",{className:O("border-b border-border/55",p?"flex min-h-0 flex-1 flex-col":"shrink-0"),children:[e.jsxs("button",{type:"button","aria-expanded":p,onClick:()=>k(q=>!q),className:O("flex w-full items-center gap-1 px-2 text-left text-[8px] font-semibold uppercase tracking-[0.14em] text-muted-foreground transition-colors hover:bg-muted/45 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",a?"py-1 leading-3":"py-1.5"),children:[e.jsx(Kt,{className:"h-2.5 w-2.5"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:"Browse folders"}),e.jsx(st,{className:O("h-3 w-3 shrink-0 transition-transform duration-200",p&&"rotate-180")})]}),p&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"shrink-0 px-2 pb-1.5",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>m?.parentPath&&void F(m.parentPath),disabled:!m?.parentPath||u,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground disabled:opacity-40",title:"Parent directory",children:e.jsx(ho,{className:"h-2.5 w-2.5"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate font-mono text-[9px] text-muted-foreground",title:W,children:W}),m&&e.jsx("button",{type:"button",onClick:()=>Q(m.currentPath,m.isAbsolute),className:"shrink-0 rounded px-1.5 py-0.5 text-[9px] font-medium text-foreground hover:bg-muted/60",title:"Use this folder",children:"Use"})]})}),e.jsxs("div",{className:O("min-h-0 flex-1 overflow-y-auto",a?"min-h-[8.25rem]":"max-h-56"),children:[t.workDir?u?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[9px] text-muted-foreground",children:[e.jsx(me,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading folders..."]}):m&&m.entries.length>0?e.jsxs(e.Fragment,{children:[m.entries.map(q=>e.jsx(Mh,{entry:q,onSelect:()=>Q(q.path,m.isAbsolute),onOpen:()=>{F(q.path)}},q.path)),m.hasMore&&e.jsxs("button",{type:"button",onClick:()=>{F(m.currentPath,m.entries.length,!0)},disabled:x,className:"flex w-full items-center justify-center gap-1 border-t border-border/40 py-1 text-[9px] text-muted-foreground hover:bg-muted/60 hover:text-foreground disabled:opacity-50",children:[x?e.jsx(me,{className:"h-3 w-3 animate-spin"}):e.jsx(Xc,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"px-3 py-4 text-center text-[9px] text-muted-foreground",children:b??"No subfolders."}):e.jsx("div",{className:"px-3 py-4 text-center text-[9px] text-muted-foreground",children:"This node has no working directory."}),b&&m&&m.entries.length>0&&e.jsx("div",{className:"border-t border-border/60 px-3 py-1.5 text-[9px] text-destructive",children:b})]})]})]})]});return e.jsxs("div",{ref:v,className:"relative min-w-0",children:[e.jsxs("button",{ref:j,type:"button","aria-label":"Capability location","aria-expanded":c,title:M,onClick:()=>d(q=>(q||(k(!1),P()),!q)),className:O("flex min-w-0 items-center gap-1.5 rounded-sm border-0 bg-muted/55 text-left shadow-none transition-colors hover:bg-muted/70 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",a?"h-5 w-24 max-w-28 px-1.5":"h-7 min-w-32 max-w-56 px-2"),children:[e.jsx("span",{className:"min-w-0 flex-1",children:e.jsx("span",{className:O("block truncate font-medium text-foreground",a?"text-[9px] leading-3":"text-[10px] leading-4"),children:L})}),e.jsx(st,{className:O(a?"h-2.5 w-2.5":"h-3 w-3","shrink-0 text-muted-foreground transition-transform",c&&"rotate-180")})]}),i&&ee?Xa.createPortal(se,ee):se]})}function Ba({icon:t,label:s,description:n,selected:r,onSelect:a,compact:i=!1}){const l=t==="global"?Qc:Kt;return e.jsxs("button",{type:"button",onClick:a,className:O(i?"flex h-7 w-full items-center gap-1.5 rounded-md px-2 text-left text-[9px]":"flex h-8 w-full items-center gap-1.5 rounded-md px-2 text-left text-[10px]","transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",r&&"bg-primary/10 text-primary"),children:[e.jsx(l,{className:O("shrink-0 text-muted-foreground",i?"h-2.5 w-2.5":"h-3 w-3",r&&"text-primary")}),e.jsxs("span",{className:"flex min-w-0 flex-1 flex-col justify-center",children:[e.jsx("span",{className:"block truncate font-medium leading-3",children:s}),n&&e.jsx("span",{className:O("block truncate text-muted-foreground",i?"text-[7px] leading-3":"text-[8px] leading-3"),children:n})]})]})}function Mh({entry:t,onOpen:s,onSelect:n}){return e.jsxs("div",{className:"group flex items-stretch border-b border-border/30 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:n,className:"flex min-w-0 flex-1 items-center gap-1.5 px-2 py-1 text-left text-[9px] hover:bg-muted/55",title:`Use ${t.path}`,children:[e.jsx(Kt,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-foreground",children:t.name})]}),e.jsx("button",{type:"button",onClick:s,className:"flex w-7 shrink-0 items-center justify-center border-l border-border/30 text-muted-foreground hover:bg-muted/65 hover:text-foreground",title:"Open subfolder","aria-label":`Open ${t.name}`,children:e.jsx(lt,{className:"h-3 w-3"})})]})}function Dh({ariaLabel:t,value:s,description:n,options:r,selectedValue:a,onSelect:i}){const[l,c]=o.useState(!1),d=o.useRef(null);return o.useEffect(()=>{if(!l)return;const m=g=>{d.current&&g.target instanceof Node&&!d.current.contains(g.target)&&c(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[l]),e.jsxs("div",{ref:d,className:"relative min-w-0",children:[e.jsxs("button",{type:"button","aria-label":t,"aria-expanded":l,title:n??s,onClick:()=>c(m=>!m),className:"flex h-7 min-w-32 max-w-56 items-center gap-1.5 rounded-sm border-0 bg-muted/55 px-2 text-left shadow-none transition-colors hover:bg-muted/70 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:[e.jsx("span",{className:"min-w-0 flex-1",children:e.jsx("span",{className:"block truncate text-[10px] font-medium leading-4 text-foreground",children:s})}),e.jsx(st,{className:O("h-3 w-3 shrink-0 text-muted-foreground transition-transform",l&&"rotate-180")})]}),e.jsx("div",{"aria-hidden":!l,className:O("absolute left-0 top-9 z-50 w-64 overflow-hidden rounded-lg border border-border/70 bg-popover text-popover-foreground shadow-none",!l&&"hidden"),children:e.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:r.length>0?r.map(m=>e.jsxs("button",{type:"button",onClick:()=>{i(m.value),c(!1)},className:O("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[11px] transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",m.value===a&&"bg-primary/10 text-primary"),children:[m.status&&e.jsx("span",{className:O("h-1.5 w-1.5 shrink-0 rounded-full",ds(m.status))}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate font-medium",children:m.label}),m.description&&e.jsx("span",{className:"block truncate text-[9px] text-muted-foreground",children:m.description})]})]},m.value)):e.jsx("div",{className:"px-2 py-2 text-[10px] text-muted-foreground",children:"No projects"})})})]})}function _h(t,s){const n=new Map;for(const r of t)n.set(r.id,r);return n.set(s.id,s),Array.from(n.values())}function ds(t){return t==="online"?"bg-emerald-500":t==="offline"?"bg-muted-foreground/45":"bg-amber-500"}function Oa(t){return t.split(/[\\/]+/).filter(Boolean).at(-1)??t}function ii(t){return t.startsWith("/")||/^[A-Za-z]:[\\/]/.test(t)}function li(t,s){return`${t.replace(/[\\/]+$/,"")}/${s.replace(/^[\\/]+/,"")}`}const Ph="h-6 w-24 rounded-sm px-2 text-[10px] shadow-none",Mn="text-[10px]",ci=["claudecode","codex","copilot"],ts={claudecode:"Claude Code",codex:"Codex",copilot:"Copilot"};function Ih({open:t,sourceNode:s,targetNodes:n,selectedCapabilities:r,previewResults:a=[],embedded:i=!1,onClose:l,onPreviewTargetsChange:c,onShare:d}){const[m,g]=o.useState(()=>new Set(a.length>0?a.map(w=>mt(w.nodeId,w.targetAgent)):Lh(s.id,n,r))),[u,f]=o.useState(()=>Object.fromEntries(Bh(s.id,n,r))),[x,N]=o.useState({}),[b,T]=o.useState(!1),[p,k]=o.useState(()=>new Set),[y,h]=o.useState(()=>new Set),v=r.some(w=>w.kind==="plugin"),j=o.useMemo(()=>dr(r).map(w=>({key:mt(s.id,w),nodeId:s.id,node:s,label:`Install into ${ts[w]}`,agentLabel:ts[w],defaultScope:ui(r),disabled:!1,targetAgent:w})),[r,s]),E=o.useMemo(()=>n.flatMap(w=>{const K={kind:"global"},C=w.status==="offline",Y=di(r);return Y.length===0?[{key:mt(w.id),nodeId:w.id,node:w,label:w.name,defaultScope:K,disabled:C}]:Y.map(I=>({key:mt(w.id,I),nodeId:w.id,node:w,label:`${w.name} / ${ts[I]}`,agentLabel:ts[I],defaultScope:K,disabled:C,targetAgent:I}))}),[r,n]),R=o.useMemo(()=>[...j,...E],[j,E]),A=o.useMemo(()=>n.map(w=>({node:w,options:E.filter(K=>K.nodeId===w.id)})).filter(w=>w.options.length>0),[n,E]),L=o.useMemo(()=>new Map(a.filter(w=>w.capabilityId).map(w=>[Fa(w.nodeId,w.capabilityId,w.targetAgent),w])),[a]),M=o.useMemo(()=>new Map(a.map(w=>[mt(w.nodeId,w.targetAgent),w])),[a]),D=o.useMemo(()=>R.filter(w=>m.has(w.key)),[m,R]),P=o.useMemo(()=>D.map(w=>({nodeId:w.nodeId,scope:u[w.key]??w.defaultScope,...w.targetAgent?{targetAgent:w.targetAgent}:{}})),[D,u]),F=o.useMemo(()=>{const w=[],K=new Map;for(const C of D){if(!K.has(C.nodeId)){const Y=C.nodeId===s.id?s:n.find(I=>I.id===C.nodeId);K.set(C.nodeId,{nodeId:C.nodeId,node:Y,name:Y?.name??C.nodeId,options:[]}),w.push(C.nodeId)}K.get(C.nodeId).options.push(C)}return w.map(C=>K.get(C))},[D,s,n]),Q=o.useMemo(()=>{const w=Array.from(new Set(r.map(C=>C.agent))),[K]=w;if(K)return w.length===1?ts[K]:`${w.length} agents`},[r]),re=A.length+1;o.useEffect(()=>{let w=!1;const K={...u};for(const C of R)K[C.key]||(K[C.key]=C.defaultScope,w=!0);w&&f(K)},[R,u]),o.useEffect(()=>{t&&c?.(P)},[t,c,P]),o.useEffect(()=>{t&&(k(new Set),h(new Set))},[t,s.id]),o.useEffect(()=>{if(!i||!t)return;const w=K=>{K.key==="Escape"&&l()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[i,l,t]);const W=w=>{N(Object.fromEntries(D.map(K=>[K.key,w])))},ee=async()=>{T(!0);try{await d(D.map(w=>({nodeId:w.nodeId,scope:u[w.key]??w.defaultScope,...w.targetAgent?{targetAgent:w.targetAgent}:{},conflictStrategy:x[w.key]??"overwrite"})))}finally{T(!1)}},se=w=>{const K=u[w.key]??w.defaultScope,C=`capability-share-target-${Rh(w.key)}`,Y=m.has(w.key);return e.jsxs("div",{"data-target-agent":w.targetAgent,className:"flex min-h-6 items-center gap-2 px-2 py-0.5 transition-colors hover:bg-muted/35 data-[disabled=true]:opacity-55","data-disabled":w.disabled?"true":void 0,children:[e.jsx(fs,{id:C,disabled:w.disabled,checked:Y,onCheckedChange:I=>g(U=>{const B=new Set(U);return I===!0?B.add(w.key):B.delete(w.key),B}),"aria-label":`Select ${w.label} as a share target`,"data-share-target-checkbox":!0,className:"h-3.5 w-3.5 border-border/70 bg-background/80 shadow-none data-[state=checked]:border-primary data-[state=checked]:bg-primary [&_svg]:h-3 [&_svg]:w-3"}),e.jsx("label",{htmlFor:C,className:"min-w-0 flex-1 cursor-pointer truncate text-[10px] font-medium leading-4 text-foreground data-[disabled=true]:cursor-not-allowed","data-disabled":w.disabled?"true":void 0,children:w.agentLabel??w.label}),e.jsx("div",{className:"flex w-28 shrink-0 justify-end",children:Y&&!w.disabled&&e.jsx(oi,{node:w.node,projectPaths:cr(w.node),selectedScope:K,onSelect:I=>f(U=>({...U,[w.key]:I})),compact:!0,portal:!0,portalAlign:"end"})})]},w.key)},q=(w,K,C,Y)=>{const I=p.has(w.id),U=D.filter(B=>B.nodeId===w.id).length;return e.jsxs("div",{className:"overflow-hidden rounded-sm border border-border/45 bg-muted/15",children:[e.jsxs("button",{type:"button","aria-expanded":I,onClick:()=>k(B=>za(B,w.id)),className:"flex w-full items-center gap-2 border-b border-border/35 bg-primary/5 px-2 py-1.5 text-left transition-colors hover:bg-primary/10",children:[e.jsx(lt,{className:O("h-3 w-3 shrink-0 text-muted-foreground transition-transform duration-200",I&&"rotate-90")}),e.jsx("span",{className:O("h-1.5 w-1.5 shrink-0 rounded-full",ds(w.status))}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-semibold text-foreground",title:w.name,children:w.name}),U>0&&e.jsxs("span",{className:"shrink-0 text-[8px] font-medium text-primary",children:[U," selected"]}),e.jsx("span",{className:"shrink-0 text-[8px] font-medium uppercase tracking-[0.14em] text-muted-foreground",children:K?"this node":"remote"}),w.status==="offline"&&e.jsx(Ye,{variant:"outline",className:"rounded-sm px-1 py-0 text-[8px]",children:"offline"}),Y>0&&e.jsxs("span",{className:"sr-only",children:[Y," agents"]})]}),e.jsx("div",{className:O("grid transition-[grid-template-rows] duration-200 ease-out",I?"grid-rows-[1fr]":"grid-rows-[0fr]"),children:e.jsx("div",{className:"min-h-0 overflow-hidden",children:e.jsx("div",{className:"divide-y divide-border/25",children:C})})})]},w.id)},X=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-b border-border/55 px-4 py-3 text-left",children:[e.jsxs("h2",{id:"capability-share-title",className:"flex items-center gap-2 text-sm font-semibold leading-none tracking-tight",children:[e.jsx(Ps,{className:"h-4 w-4 text-primary"}),"Share ",r.length," ",r.length===1?"capability":"capabilities"]}),e.jsx("p",{id:"capability-share-description",className:"mt-1.5 text-[11px] text-muted-foreground",children:"Copies each capability into the matching agent on the selected targets. Plugins install into their matching agent."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2.5 gap-y-1 border-b border-border/55 bg-muted/15 px-4 py-2 text-[11px]",children:[e.jsx("span",{className:"text-[8px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Source"}),e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:O("h-1.5 w-1.5 shrink-0 rounded-full",ds(s.status))}),e.jsx("span",{className:"truncate font-semibold text-foreground",title:s.name,children:s.name}),Q&&e.jsxs("span",{className:"shrink-0 text-muted-foreground",children:["· ",Q]})]}),e.jsx(Cr,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/70"}),e.jsx("span",{className:"text-[8px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Targets"}),e.jsxs("span",{className:"text-muted-foreground",children:[e.jsx("span",{className:"font-semibold text-foreground",children:D.length})," selected · ",re," ",re===1?"node":"nodes"]})]}),e.jsxs("div",{className:"grid gap-4 p-4 lg:grid-cols-[17rem_minmax(0,1fr)]",children:[e.jsx("section",{className:"min-w-0",children:e.jsxs("div",{className:"max-h-[56vh] space-y-2 overflow-y-auto pr-0.5",children:[q(s,!0,v?e.jsx("div",{className:"px-2 py-2 text-[10px] text-muted-foreground",children:"Cross-agent plugin installs are not supported."}):j.length===0?e.jsx("div",{className:"px-2 py-2 text-[10px] text-muted-foreground",children:"No alternate agents available for this selection."}):j.map(se),j.length),A.map(w=>q(w.node,!1,w.options.map(se),w.options.length))]})}),e.jsxs("section",{className:"min-w-0",children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[e.jsx("div",{className:"text-[8px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:"Conflict preview"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[8px] uppercase tracking-[0.12em] text-muted-foreground/70",children:"Set all"}),e.jsx("div",{className:"inline-flex items-center rounded-sm border border-border/55 bg-muted/20 p-px",children:["overwrite","skip","abort"].map(w=>e.jsx("button",{type:"button",onClick:()=>W(w),className:"h-5 rounded-[3px] px-1.5 text-[9px] capitalize text-muted-foreground transition-colors hover:bg-muted/70 hover:text-foreground",children:w},w))})]})]}),e.jsx("div",{className:"max-h-[56vh] min-h-32 overflow-y-auto rounded-sm border border-border/55 bg-background/45 p-2",children:D.length===0?e.jsx("div",{className:"py-8 text-center text-[11px] text-muted-foreground",children:"Select a target to preview conflicts."}):F.map(w=>{const K=!y.has(w.nodeId);return e.jsxs("div",{className:"mb-1.5 overflow-hidden rounded-sm border border-border/35 bg-muted/10 last:mb-0",children:[e.jsxs("button",{type:"button","aria-expanded":K,onClick:()=>h(C=>za(C,w.nodeId)),className:"flex w-full items-center gap-1.5 border-b border-border/30 bg-primary/5 px-2 py-1 text-left transition-colors hover:bg-primary/10",children:[e.jsx(lt,{className:O("h-3 w-3 shrink-0 text-muted-foreground transition-transform duration-200",K&&"rotate-90")}),w.node&&e.jsx("span",{className:O("h-1.5 w-1.5 shrink-0 rounded-full",ds(w.node.status))}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[10px] font-semibold text-foreground",children:w.name}),e.jsxs("span",{className:"shrink-0 text-[8px] text-muted-foreground",children:[w.options.length," ",w.options.length===1?"agent":"agents"]})]}),e.jsx("div",{className:O("grid transition-[grid-template-rows] duration-200 ease-out",K?"grid-rows-[1fr]":"grid-rows-[0fr]"),children:e.jsx("div",{className:"min-h-0 overflow-hidden",children:e.jsx("div",{className:"space-y-1 p-1.5",children:w.options.map(C=>{const Y=x[C.key]??"overwrite";return e.jsxs("div",{className:"rounded-sm bg-background/45 px-2 py-1",children:[e.jsxs("div",{className:"mb-0.5 flex items-center justify-between gap-2",children:[e.jsx("span",{className:"min-w-0 truncate text-[9px] font-medium leading-4 text-foreground",children:C.agentLabel??"Matching agent"}),e.jsxs(Be,{value:Y,onValueChange:I=>N(U=>({...U,[C.key]:I})),children:[e.jsx(Oe,{className:Ph,children:e.jsx(Ge,{})}),e.jsxs(Fe,{className:"shadow-none",children:[e.jsx(Le,{value:"overwrite",className:Mn,children:"Overwrite"}),e.jsx(Le,{value:"skip",className:Mn,children:"Skip"}),e.jsx(Le,{value:"abort",className:Mn,children:"Abort"})]})]})]}),e.jsx("div",{className:"space-y-px",children:r.map(I=>{const U=L.get(Fa(C.nodeId,I.id,C.targetAgent))??(r.length===1?M.get(C.key):void 0);return e.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] leading-4",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:I.name}),e.jsx("span",{className:U?.conflict?"text-amber-500":U?"text-emerald-500":"text-muted-foreground",children:U?U.conflict?`exists${U.currentVersion?` v${U.currentVersion}`:""}`:"new install":"checking"}),U?.sourceVersion&&e.jsxs("span",{className:"shrink-0 text-muted-foreground",children:[e.jsx(Cr,{className:"inline h-2.5 w-2.5"})," v",U.sourceVersion]})]},I.id)})})]},C.key)})})})})]},w.nodeId)})})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 border-t border-border/55 px-4 py-3",children:[e.jsx(Z,{variant:"ghost",onClick:l,className:"h-7 rounded-sm px-3 text-[11px]",children:"Cancel"}),e.jsxs(Z,{onClick:ee,disabled:b||D.length===0,className:"h-7 rounded-sm px-3 text-[11px]",children:[b?e.jsx(me,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Ps,{className:"h-3.5 w-3.5"}),"Share"]})]})]});return i?t?e.jsx("div",{className:"absolute inset-0 z-[80] flex items-center justify-center bg-background/70 p-4 backdrop-blur-[2px]",onMouseDown:w=>{w.target===w.currentTarget&&l()},children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"capability-share-title","aria-describedby":"capability-share-description","data-capability-share-dialog":"true",className:"relative grid w-full max-w-3xl gap-0 overflow-visible rounded-xl border-0 bg-background text-foreground shadow-[0_34px_110px_-54px_rgba(0,0,0,0.55)]",onMouseDown:w=>w.stopPropagation(),children:[X,e.jsxs("button",{type:"button",onClick:l,className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[e.jsx(it,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})}):null:e.jsx(At,{open:t,onOpenChange:w=>{w||l()},children:e.jsx(Mt,{"aria-labelledby":"capability-share-title","aria-describedby":"capability-share-description","data-capability-share-dialog":"true",className:"max-w-3xl gap-0 overflow-visible rounded-xl border-0 p-0",children:X})})}function mt(t,s){return s?`agent:${t}:${s}`:`node:${t}`}function Rh(t){return t.replace(/[^a-zA-Z0-9_-]/g,"-")}function Fa(t,s,n){return`${mt(t,n)}\0${s}`}function za(t,s){const n=new Set(t);return n.has(s)?n.delete(s):n.add(s),n}function Lh(t,s,n){const r=s.find(i=>i.status!=="offline");if(r)return[mt(r.id,Oh(n))];const a=dr(n)[0];return a?[mt(t,a)]:[]}function Bh(t,s,n){const r=di(n);return[...s.flatMap(a=>r.length===0?[[mt(a.id),{kind:"global"}]]:r.map(i=>[mt(a.id,i),{kind:"global"}])),...dr(n).map(a=>[mt(t,a),ui(n)])]}function di(t){return t.length===0||t.some(s=>s.kind==="plugin")?[]:ci}function Oh(t){if(!(t.length===0||t.some(s=>s.kind==="plugin")))return t[0]?.agent}function dr(t){if(t.length===0||t.some(n=>n.kind==="plugin"))return[];const s=new Set(t.map(n=>n.agent));return ci.filter(n=>!s.has(n))}function ui(t){return t[0]?.scope??{kind:"global"}}const qa="h-7 rounded-sm border-0 bg-muted/55 px-2 text-[9px] leading-none shadow-none hover:bg-muted/70 [&>svg]:h-3 [&>svg]:w-3",Et="py-0.5 pl-6 pr-1.5 text-[9px] leading-4 [&_svg]:h-3 [&_svg]:w-3",mi="h-5 rounded-sm bg-muted/55 px-1.5 text-[9px] font-medium text-foreground shadow-none border-0 hover:bg-muted/75 hover:text-foreground disabled:text-muted-foreground [&_svg]:size-2.5",Fh="h-5 rounded-sm bg-primary px-2 text-[9px] font-medium text-primary-foreground shadow-none border-0 hover:bg-primary/90 hover:text-primary-foreground disabled:bg-primary/45 disabled:text-primary-foreground/80 [&_svg]:size-2.5";function zh(t,s,n,r){return n.map(a=>({sourceNodeId:t,capabilityId:a.id,sourceScope:s,targets:r.map(i=>({nodeId:i.nodeId,scope:i.scope,...i.targetAgent?{targetAgent:i.targetAgent}:{}}))}))}function qh(t,s,n,r){return n.map(a=>({sourceNodeId:t,capabilityId:a.id,sourceScope:s,targets:r}))}function Uh({loading:t,onRefresh:s}){return e.jsxs(Z,{variant:"ghost",onClick:s,disabled:t,"aria-busy":t,className:O(mi,"min-w-[4.5rem]"),children:[e.jsx(vo,{className:O("h-2.5 w-2.5",t&&"animate-spin")}),t?"Refreshing":"Refresh"]})}function $h({selectedCount:t,loading:s,onClearSelection:n,onRefresh:r,onShare:a}){return e.jsxs("div",{className:"flex items-center justify-between gap-2 bg-card/15 px-0.5 pt-1.5 text-[9px] text-muted-foreground",children:[e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(Z,{type:"button",variant:"ghost",onClick:n,disabled:t===0,className:mi,children:[e.jsx(it,{className:"h-2.5 w-2.5"}),"Selected: ",t," / Clear"]})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Uh,{loading:s,onRefresh:r}),e.jsxs(Z,{type:"button",variant:"ghost",onClick:a,disabled:t===0,className:Fh,children:[e.jsx(Ps,{className:"h-2.5 w-2.5"}),"Share"]})]})]})}function Hh({onBeginResize:t,onFold:s}){const n=r=>{r.key!=="Enter"&&r.key!==" "||(r.preventDefault(),s())};return e.jsx("div",{role:"separator","aria-label":"Fold capability detail panel","aria-orientation":"vertical",title:"Fold details",tabIndex:0,onClick:s,onKeyDown:n,onPointerDown:t,className:"hidden w-1 shrink-0 cursor-col-resize items-center justify-center bg-primary/10 transition-colors hover:bg-primary/22 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70 lg:flex",children:e.jsx("span",{className:"h-8 w-px rounded-full bg-primary/45"})})}function Vh({visible:t}){return t?e.jsx("div",{className:"absolute inset-2.5 z-10 flex items-center justify-center rounded-sm border border-border/60 bg-background/85 shadow-sm backdrop-blur-sm",children:e.jsxs("div",{className:"flex w-full max-w-80 flex-col items-center gap-3 px-5 text-center",children:[e.jsxs("div",{className:"relative flex h-10 w-10 items-center justify-center rounded-full border border-primary/25 bg-primary/8",children:[e.jsx("span",{className:"absolute inset-0 rounded-full border border-primary/20 animate-ping"}),e.jsx(me,{className:"relative h-4 w-4 animate-spin text-primary"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground",children:"Loading capabilities"}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Reading agent skills, plugins, and MCP servers for this selection."})]}),e.jsxs("div",{className:"grid w-full gap-1.5","aria-hidden":"true",children:[e.jsx("span",{className:"h-1.5 rounded-full bg-muted animate-pulse"}),e.jsx("span",{className:"mx-auto h-1.5 w-3/4 rounded-full bg-muted/70 animate-pulse"})]})]})}):null}function Kh({open:t,node:s,scope:n,clusterNodes:r,onOpenChange:a,onSelectionChange:i}){const[l,c]=o.useState([]),[d,m]=o.useState([]),[g,u]=o.useState(!1),[f,x]=o.useState(""),[N,b]=o.useState("all"),[T,p]=o.useState("all"),[k,y]=o.useState(new Set),[h,v]=o.useState(null),[j,E]=o.useState(null),[R,A]=o.useState(!1),[L,M]=o.useState(null),[D,P]=o.useState(!1),[F,Q]=o.useState([]),[re,W]=o.useState(ai),[ee,se]=o.useState(null),q=o.useMemo(()=>mh(l,{search:f,agent:N,kind:T}),[N,l,T,f]),X=o.useMemo(()=>l.filter(V=>k.has(V.id)),[l,k]),w=o.useMemo(()=>r.filter(V=>V.id!==s.id),[r,s.id]),K=n.kind==="project"?n.projectPath:"global",C=async()=>{u(!0);try{const V=await Kl(s.id,{scope:n});c(V.items),m((V.errors??[]).map(_=>`${_.agent}: ${_.message}`))}catch(V){m([V instanceof Error?V.message:"Failed to load capabilities"])}finally{u(!1)}};o.useEffect(()=>{t&&(y(new Set),v(null),E(null),A(!1),Q([]),c([]),m([]),C())},[t,s.id,n.kind,K]),o.useEffect(()=>{if(!ee)return;const V=ne=>{W(ph(ee.startWidth,ee.startClientX,ne.clientX,window.innerWidth))},_=()=>se(null);return window.addEventListener("pointermove",V),window.addEventListener("pointerup",_),()=>{window.removeEventListener("pointermove",V),window.removeEventListener("pointerup",_)}},[ee]);const Y=V=>{V.preventDefault(),se({startClientX:V.clientX,startWidth:re})},I=()=>{se(null),A(!1),v(null),E(null)},U=()=>{y(new Set),Q([])},B=async V=>{v(V.id),A(!0),E(null);const _=await Gl(s.id,V.id,n);E(_.detail)},le=o.useCallback(async V=>{if(X.length===0||V.length===0){Q([]);return}Q([]);try{const _=zh(s.id,n,X,V),ne=await Promise.all(_.map($=>Vl($)));Q(ne.flatMap(($,ae)=>$.results.map(pe=>({...pe,capabilityId:_[ae]?.capabilityId}))))}catch{Q([])}},[s.id,n,X]),oe=()=>{Q([]),P(!0)},ue=async V=>{const _=qh(s.id,n,X,V);_.length!==0&&(await Promise.all(_.map(ne=>Ql(ne))),de.success(`${_.length} capability share request${_.length===1?"":"s"} completed`),P(!1))},J=async()=>{if(!(!j||L)){M(j.id);try{const V=await Wl(s.id,j.id,n);V.status==="deleted"?(de.success(`Deleted ${j.name}`),c(_=>_.filter(ne=>ne.id!==j.id)),y(_=>{const ne=new Set(_);return ne.delete(j.id),ne}),v(null),E(null),A(!1),await C()):(de.info(V.message??"Capability was not found"),v(null),E(null),A(!1),await C())}catch(V){de.error(V instanceof Error?V.message:"Failed to delete capability")}finally{M(null)}}};return e.jsx(e.Fragment,{children:e.jsx(At,{open:t,onOpenChange:a,children:e.jsxs(Mt,{className:"dashboard-panel animate-panel-settle flex h-[min(62vh,33rem)] w-[min(94vw,72rem)] max-w-[min(94vw,72rem)] flex-col gap-0 overflow-hidden rounded-xl p-0",children:[e.jsxs(xs,{className:"border-b border-border/55 bg-card/28 px-4 py-2.5 text-left",children:[e.jsx(Rt,{className:"sr-only",children:"Capabilities"}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-start justify-between gap-x-4 gap-y-1 pr-10",children:[e.jsx(Eh,{node:s,scope:n,clusterNodes:r,onSelectionChange:i}),e.jsxs(ps,{"data-capability-selection-help":"true",className:"ml-auto max-w-[min(32rem,38vw)] space-y-0.5 pt-0.5 text-right text-[9px] leading-[11px] text-muted-foreground",children:[e.jsx("span",{className:"block truncate whitespace-nowrap",children:"Sharing copies into selected agents on target nodes."}),n.kind==="project"&&e.jsx("span",{"data-capability-selection-path":"true",className:"block truncate font-mono text-[7px] leading-[10px] text-muted-foreground/80",title:n.projectPath,children:n.projectPath})]})]})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col lg:flex-row",children:[e.jsxs("main",{className:"relative flex min-w-0 flex-1 flex-col gap-2 bg-gradient-to-b from-primary/4 via-background/20 to-background/40 p-2.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"relative min-w-44 flex-1",children:[e.jsx(Ka,{className:"pointer-events-none absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-muted-foreground"}),e.jsx(ft,{value:f,onChange:V=>x(V.target.value),placeholder:"Search capabilities",className:"h-7 rounded-sm border-0 bg-muted/55 pl-6 text-[10px] shadow-none"})]}),e.jsxs(Be,{value:N,onValueChange:V=>b(V),children:[e.jsx(Oe,{className:O("w-28",qa),children:e.jsx(Ge,{})}),e.jsxs(Fe,{className:"shadow-none",children:[e.jsx(Le,{value:"all",className:Et,children:"Agent: All"}),e.jsx(Le,{value:"claudecode",className:Et,children:"Claude Code"}),e.jsx(Le,{value:"codex",className:Et,children:"Codex"}),e.jsx(Le,{value:"copilot",className:Et,children:"Copilot"})]})]}),e.jsxs(Be,{value:T,onValueChange:V=>p(V),children:[e.jsx(Oe,{className:O("w-24",qa),children:e.jsx(Ge,{})}),e.jsxs(Fe,{className:"shadow-none",children:[e.jsx(Le,{value:"all",className:Et,children:"Kind: All"}),e.jsx(Le,{value:"skill",className:Et,children:"Skill"}),e.jsx(Le,{value:"plugin",className:Et,children:"Plugin"}),e.jsx(Le,{value:"mcp",className:Et,children:"MCP"})]})]})]}),d.length>0&&e.jsx("div",{className:"rounded-sm bg-amber-500/10 px-2 py-1 text-[10px] text-amber-600",children:d.join(" · ")}),e.jsx(fh,{items:q,selectedIds:k,activeId:h,onToggleSelected:(V,_)=>y(ne=>{const $=new Set(ne);return _?$.add(V):$.delete(V),$}),onOpenDetail:B}),e.jsx($h,{selectedCount:k.size,loading:g,onClearSelection:U,onRefresh:C,onShare:oe}),e.jsx(Vh,{visible:g&&l.length===0})]}),R&&e.jsxs(e.Fragment,{children:[e.jsx(Hh,{onBeginResize:Y,onFold:I}),e.jsx(gh,{detail:j,deleting:L===j?.id,desktopWidth:re,onDelete:j?J:void 0,pending:!j})]})]}),D&&e.jsx(Ih,{open:D,sourceNode:s,targetNodes:w,selectedCapabilities:X,previewResults:F,embedded:!0,onClose:()=>P(!1),onPreviewTargetsChange:le,onShare:ue})]})})})}function Gh(t){const[s,n]=o.useState(null),r=o.useMemo(()=>s?t?.nodes.find(d=>d.id===s.nodeId)??(t?.self.id===s.nodeId?t.self:null)??null:null,[t,s]),a=o.useCallback(d=>{n({nodeId:d,scope:{kind:"global"}})},[]),i=o.useCallback((d,m)=>{n({nodeId:d,scope:{kind:"project",projectPath:m}})},[]),l=o.useCallback(d=>{n(d)},[]);return{capabilitiesDialog:s&&r&&t?e.jsx(Kh,{open:!0,node:r,scope:s.scope,clusterNodes:t.nodes,onOpenChange:d=>{d||n(null)},onSelectionChange:l}):null,openNodeCapabilities:a,openProjectCapabilities:i}}function Wh(){const{id:t}=Yl(),s=Jl(),n=Zl(),r=Xl(),{cluster:a,systemInfo:i,events:l,sseConnected:c,subscribe:d,refresh:m,loading:g,error:u}=ec(),f=o.useMemo(()=>tc(s.state),[s.state]),[x,N]=o.useState(null),[b,T]=o.useState("active"),[p,k]=o.useState("all"),[y,h]=o.useState("all"),[v,j]=o.useState("all"),E=r?.headerSearchQuery??"",R=o.useDeferredValue(E),{desktopTasksOpen:A,mobileTasksPanelOpen:L,mobileTasksPanelRef:M,operationsOpen:D,operationsPanelRef:P,panelResize:F,setMobileTasksPanelOpen:Q,setOperationsOpen:re,toggleTasksPanel:W}=Mf(),[ee,se]=o.useState(()=>!!f?.draftNewTask),[q,X]=o.useState(()=>f?.createMode??"chat"),[w,K]=o.useState(()=>f?.createDefaults??null),[C,Y]=o.useState(()=>f?.draftNewTask?{route:f.returnRoute??"/",taskId:f.returnTaskId??null}:null),[I,U]=o.useState(!1),[B,le]=o.useState("transcript"),[oe,ue]=o.useState("overview"),[J,V]=o.useState("all"),[_,ne]=o.useState(!1),[$,ae]=o.useState(null),[pe,fe]=o.useState([]),[Ve,je]=o.useState([]),[ht,De]=o.useState(!1),[Me,Te]=o.useState(!1),[Ee,Pe]=o.useState(null),[Ue,H]=o.useState(new Set),[xe,be]=o.useState(!1),[Xe,Ie]=o.useState(!1),[ct,te]=o.useState(null),ve=o.useRef(null),ke=o.useRef(new Map),ye=a?.self?.role==="leader",yt=a?.self?.id,{quickChats:_e}=sc();Hf({cluster:a,subscribe:d});const{nodeSettingsDialog:Nt,openNodeSettings:G}=lh(ye),{capabilitiesDialog:ze,openNodeCapabilities:Re,openProjectCapabilities:jt}=Gh(a),{devBoxDialog:xt,devBoxNodeIds:Qt,devBoxStartNodeId:$e,devBoxStartNodeIds:nt,devBoxStartingNodeIds:kt,openDevBox:Dt,startDevBox:rt}=ih({cluster:a,refresh:m}),{completedGroups:Ot=[],fetchTasks:qe,loadCompletedTasksPage:et,removeTasksFromList:Se,setTasks:dt,tasks:We,tasksError:Ft,tasksLoading:St}=zf({isLeader:ye,selfId:yt,sseConnected:c,preservedTask:$,subscribe:d});o.useEffect(()=>nc(()=>{ue("events"),re(!0)}),[re]);const He=o.useMemo(()=>[...We].sort((S,z)=>z.updatedAt-S.updatedAt),[We]),Je=o.useMemo(()=>[...We].sort((S,z)=>z.createdAt-S.createdAt||z.updatedAt-S.updatedAt)[0]?.id??null,[We]),qs=o.useMemo(()=>{const S=new Map;for(const z of a?.nodes??[]){const ie=Rd(He,z.id);ie>0&&S.set(z.id,ie)}return S},[a?.nodes,He]),tt=o.useMemo(()=>He.filter(S=>!rc(S,a?.nodes,a?.self)||!ac(S,b)||p!=="all"&&S.agent!==p||!oc(S,v)||y==="unassigned"&&S.assignedTo||y!=="all"&&y!=="unassigned"&&ic(S.assignedTo,a?.nodes,S.assignedNodeName)!==y?!1:R.trim()?lc(S,R):!0),[He,a?.nodes,a?.self,b,p,v,y,R]);o.useEffect(()=>{H(S=>{const z=qd(S,tt.map(ie=>ie.id));return z.size===S.size?S:z})},[tt]),o.useEffect(()=>{ye||H(new Set)},[ye]);const we=o.useMemo(()=>["all",...Array.from(new Set(He.map(S=>S.agent))).sort()],[He]),Ce=o.useMemo(()=>{const z=Array.from(new Set(He.map(ie=>ie.assignedTo).filter(ie=>!!ie))).map(ie=>{const Ae=He.find(ge=>ge.assignedTo===ie);return a?.nodes.find(ge=>ge.id===ie)??{id:ie,name:_n(ie,a?.nodes,Ae?.assignedNodeName)}}).sort((ie,Ae)=>ie.name.localeCompare(Ae.name));return[{value:"all",label:"All nodes"},{value:"unassigned",label:"Unassigned"},...z.map(ie=>({value:ie.name.toLowerCase(),label:ie.name}))]},[He,a?.nodes]),Qe=o.useMemo(()=>{const S=new Map;for(const z of a?.nodes??[])S.set(z.id,z.name);for(const z of He)z.assignedTo&&z.assignedNodeName&&!S.has(z.assignedTo)&&S.set(z.assignedTo,z.assignedNodeName);return S},[a?.nodes,He]),pt=o.useMemo(()=>{const S=new Map;for(const z of a?.nodes??[])z.workDir&&S.set(z.id,z.workDir);return a?.self?.workDir&&S.set(a.self.id,a.self.workDir),S},[a]),Yt=o.useMemo(()=>{const S=new Map;for(const z of a?.nodes??[])S.set(z.id,z.status);return a?.self&&S.set(a.self.id,a.self.status),S},[a]),fi=o.useMemo(()=>new Map(Ot.map(S=>[Kn(S),S])),[Ot]),ur=o.useMemo(()=>{const S=new Map;for(const z of a?.nodes??[])z.status!=="offline"&&S.set(z.id,z);return a?.self&&a.self.status!=="offline"&&S.set(a.self.id,a.self),Array.from(S.values())},[a]),hi=a?.self?.id??ur[0]?.id??null,Jt=o.useMemo(()=>l.filter(cc),[l]),Us=o.useMemo(()=>["all",...Array.from(new Set(Jt.map(S=>S.type))).sort()],[Jt]),xi=o.useMemo(()=>J==="all"?Jt:Jt.filter(S=>S.type===J),[Jt,J]),pi=tt.length>0&&tt.every(S=>Ue.has(S.id)),gi=tt.some(S=>Ue.has(S.id)),bi=Ud(tt,Ue);o.useEffect(()=>{f?.draftNewTask&&(se(!0),X(f.createMode??"chat"),K(f.createDefaults??null),Y({route:f.returnRoute??"/",taskId:f.returnTaskId??null}))},[f]),o.useEffect(()=>{J!=="all"&&!Us.includes(J)&&V("all")},[J,Us]),o.useEffect(()=>{Ar(t,ee)&&!x&&Je&&N(Je)},[t,ee,x,Je]),o.useEffect(()=>{Ar(t,ee)&&(x&&We.some(S=>S.id===x)||N(Je))},[t,ee,x,Je,We]);const Ne=Bd({routeTaskId:t,creatingTask:ee,internalSelectedTaskId:x,sortedTaskIds:Je?[Je]:[]}),zt=o.useMemo(()=>We.find(S=>S.id===Ne)??null,[We,Ne]);o.useEffect(()=>{ve.current=Ne??null},[Ne]);const Ct=o.useCallback(()=>{ae(null),fe([]),je([]),Pe(null),Te(!1)},[]),Zt=o.useCallback((S,z,ie=!0)=>{ke.current.set(S,{logs:ir(z),loaded:ie})},[]),ut=o.useCallback(async()=>{const S=Ne;if(S)try{const z=await dc(S);if(ve.current!==S)return;ae(z),dt(ie=>jo(ie,z)),Pe(null)}catch(z){if(ve.current!==S)return;Ct(),Pe(z instanceof Error?z.message:"Failed to load task")}finally{ve.current===S&&De(!1)}},[Ne,Ct,dt]),$s=o.useCallback(async(S={})=>{const z=Ne;if(z)try{const ie=await Rn(z,S.after,{minTotal:S.minTotal});if(ve.current!==z)return;fe(Ae=>{const ge=fo(Ae,ie.logs);return Zt(z,ge),ge}),je(Ae=>Bn(Ae,ie.logs))}catch{}finally{ve.current===z&&Te(!1)}},[Ne,Zt]);o.useEffect(()=>{if(!Ne){Ct(),De(!1);return}le("transcript"),ae(zt);const S=qf(Ne,ke.current);fe(S.logs),je([]),Pe(null),De(!0),Te(S.transcriptLoading),ut(),$s()},[Ne,Ct,$s,ut]),o.useEffect(()=>{if(!Od({activeTaskId:Ne,routeTaskId:t,creatingTask:ee,tasksLoading:St,loadedTaskIds:We.map(z=>z.id)}))return;const S=Je;N(S),Ct(),o.startTransition(()=>{n(S?`/tasks/${S}`:"/",{state:null})})},[Ne,Ct,ee,Je,n,t,We,St]),o.useEffect(()=>{zt&&ae(S=>!S||S.id!==zt.id?S:{...S,...zt})},[zt]),Kf({activeTaskId:Ne,cacheTranscript:Zt,fetchActiveLogs:$s,fetchActiveTask:ut,logs:pe,setLogs:fe,setPendingMessages:je,setTranscriptLoading:Te,sseConnected:c,subscribe:d});const ce=$??zt,vi=ce?.assignedTo?a?.nodes.find(S=>S.id===ce.assignedTo)??null:null,Xt=r?.setHeaderTaskContext;o.useEffect(()=>{if(!Xt)return;if(!ce){Xt(null);return}const S=ce.effectiveProjectPath??ce.project??"default workspace";return Xt({taskId:ce.id,taskTitle:ce.title,nodeName:_n(ce.assignedTo,a?.nodes,ce.assignedNodeName),projectLabel:so(S),projectPath:S}),()=>Xt(null)},[ce,a?.nodes,Xt]);const Hs=Ve.length>0,wi=ce?uc.has(ce.agent):!1,gs=ce?.status==="running",yi=ce?As.has(ce.status):!1,Ni=ce?As.has(ce.status)||mc.has(ce.status):!1,ji=!!(ce&&ye&&ce.status==="failed"),Vs=o.useMemo(()=>pf(ce,a,Hs,!!gs),[ce,a,Hs,gs]),Ks=o.useMemo(()=>Dc([...pe,...Ve.map(S=>Zs(S.content,S.timestamp))]),[pe,Ve]),bs=o.useMemo(()=>{if(!ce||ce.conversationKind==="nativeSession")return null;const S=_c(ce);if(S.length>0)return Zs(S,new Date(ce.createdAt).toISOString());if(Ks.length>0)return null;const z=Pc(ce.description||ce.title);return z.length>0?Zs(z,new Date(ce.createdAt).toISOString()):null},[ce,Ks]),Gs=o.useMemo(()=>bs?Xn(bs):null,[bs]),ki=o.useMemo(()=>Gs?Ic(pe,Gs):!1,[pe,Gs]),Ws=o.useCallback((S="chat",z)=>{const ie={route:t?`/tasks/${t}`:"/",taskId:Ne};Y(ie),X(S),K(z??null),se(!0),o.startTransition(()=>{n("/",{state:{draftNewTask:!0,returnRoute:ie.route,returnTaskId:ie.taskId,createMode:S,createDefaults:z}})})},[t,Ne,n]),Si=o.useCallback(()=>{const S=C?.taskId??Je;se(!1),Y(null),K(null),N(S),o.startTransition(()=>{n(C?.route??"/",{state:null})})},[C,Je,n]),mr=o.useCallback(S=>{se(!1),Y(null),K(null),N(S),o.startTransition(()=>{n(`/tasks/${S}`,{state:null})})},[n]),Ci=o.useCallback(S=>{ve.current=S.id,se(!1),Y(null),K(null),dt(z=>Fd(z,S)),ae(S),fe([]),je([]),Pe(null),De(!1),Te(S.conversationKind==="nativeSession"),le("transcript"),N(S.id),Wf({task:S,getActiveTaskId:()=>ve.current,setLogs:fe,setPendingMessages:je,setTranscriptLoading:Te}),qe(),o.startTransition(()=>{n(`/tasks/${S.id}`,{state:null})})},[qe,n]),{cancelQueuedMessage:Ti,queueFollowUpMessage:vs}=dh({activeTaskId:Ne,fetchActiveTask:ut,isRunning:gs,setPendingMessages:je,setTask:ae,setTasks:dt}),Ei=o.useCallback((S,z)=>{vs(S,z)},[vs]),Ai=o.useCallback(async()=>{const S=Ne;if(!(!S||ce?.conversationKind!=="nativeSession")){Te(!0);try{const z=await Rn(S);if(ve.current!==S)return;fe(z.logs),Zt(S,z.logs),je(ie=>Bn(ie,z.logs))}catch(z){de.error(z instanceof Error?z.message:"Failed to reload transcript")}finally{ve.current===S&&Te(!1)}}},[ce?.conversationKind,Ne,Zt]),Mi=o.useCallback(S=>vs(S),[vs]),Di=o.useCallback(async()=>{if(ce)try{await fc(ce.id),ut(),qe()}catch(S){de.error(S instanceof Error?S.message:"Failed to cancel task")}},[ce,ut,qe]),{handleShareTask:_i,handleStopShareTask:Pi}=Cf(ce,ut,qe),Ii=o.useCallback(async()=>{if(ce)try{await hc(ce.id),ut(),qe()}catch(S){de.error(S instanceof Error?S.message:"Failed to retry task")}},[ce,ut,qe]),ws=o.useCallback((S,z=!1)=>{const ie=$d(tt,S);return N(ie),(z||!ie)&&Ct(),o.startTransition(()=>{n(ie?`/tasks/${ie}`:"/",{state:null})}),ie},[Ct,tt,n]),Ri=o.useCallback((S,z)=>{H(ie=>{const Ae=new Set(ie);return z?Ae.add(S):Ae.delete(S),Ae})},[]),Li=o.useCallback(S=>{if(!S){H(new Set);return}H(new Set(tt.map(z=>z.id)))},[tt]),Bi=o.useCallback(async()=>{const S=Array.from(Ue);if(S.length!==0)try{const{results:z}=await xc(S),ie=z.filter(ge=>!ge.ok),Ae=z.filter(ge=>ge.ok).map(ge=>ge.id);Ne&&Ae.includes(Ne)&&ws(Ae),ie.length>0?de.error(`Failed to archive ${ie.length} task(s): ${ie.map(ge=>ge.error??ge.id).join(", ")}`):de.success(`Archived ${Ae.length} task(s)`),H(new Set(ie.map(ge=>ge.id))),qe()}catch(z){de.error(z instanceof Error?z.message:"Failed to archive tasks")}},[Ne,qe,ws,Ue]),Oi=o.useCallback(async()=>{const S=Array.from(Ue);if(S.length!==0)try{const{results:z}=await pc(S),ie=z.filter(ge=>!ge.ok),Ae=z.filter(ge=>ge.ok).map(ge=>ge.id);Ae.length>0&&Se(Ae),Ne&&Ae.includes(Ne)&&ws(Ae,!0),ie.length>0?de.error(`Failed to delete ${ie.length} task(s): ${ie.map(ge=>ge.error??ge.id).join(", ")}`):de.success(`Deleted ${Ae.length} task(s)`),H(new Set(ie.map(ge=>ge.id))),qe()}catch(z){de.error(z instanceof Error?z.message:"Failed to delete tasks")}},[Ne,qe,ws,Se,Ue]),Fi=o.useCallback(async()=>{be(!0);try{await gc(),m()}catch(S){de.error(S instanceof Error?S.message:"Failed to promote node")}finally{be(!1)}},[m]),zi=o.useCallback(async()=>{Ie(!0);try{await bc(),de.success("This node left the remote cluster and is leading itself again."),qe(),ut(),m()}catch(S){de.error(S instanceof Error?S.message:"Failed to leave cluster")}finally{Ie(!1)}},[ut,qe,m]),qi=o.useCallback(async S=>{const z=!tr(S),ie=S.id===a?.self?.id,Ae=ie?i?.transportType??S.transportType:S.transportType,ge=ie&&!z&&Wt(Ae);te(S.id);try{ge?await vc("direct"):await wc(S.id,z),de.success(z?`Enabled remote access on ${S.name}`:`Disabled remote access on ${S.name}`),m()}catch(hr){de.error(hr instanceof Error?hr.message:"Failed to update remote access")}finally{te(null)}},[a?.self?.id,m,i?.transportType]),Ui=o.useCallback(S=>{et&&et(S).catch(z=>{de.error(z instanceof Error?z.message:"Failed to load completed tasks")})},[et]),fr={toolbarTasks:tt,activeTaskId:Ne,tasksLoading:St,tasksError:Ft,isLeader:ye,scope:b,agentFilter:p,nodeFilter:y,taskKindFilter:v,agentOptions:we,nodeOptions:Ce,nodeNameById:Qe,nodeWorkDirById:pt,nodeStatusById:Yt,leaderNodeId:a?.leader?.id??null,searchQuery:E,completedGroupByKey:fi,devBoxNodeIds:Qt,devBoxStartNodeIds:nt,devBoxStartingNodeIds:kt,selectedTaskIds:Ue,allVisibleTasksSelected:pi,someVisibleTasksSelected:gi,canBatchArchive:bi,onScopeChange:T,onAgentFilterChange:k,onNodeFilterChange:h,onTaskKindFilterChange:j,onToggleTaskSelected:Ri,onToggleAllVisibleTasks:Li,onBatchArchive:Bi,onBatchDelete:Oi,onCreateTask:Ws,onOpenNodeSettings:ye?G:void 0,onOpenNodeCapabilities:ye?Re:void 0,onOpenProjectCapabilities:ye?jt:void 0,onOpenDevBox:ye?Dt:void 0,onStartDevBox:ye?rt:void 0,onLoadCompletedTasks:Ui,onSelectTask:mr},$i={cluster:a,systemInfo:i,nodeNameById:Qe,nodeBlockingTaskCounts:qs,eventTypeFilter:J,onEventTypeFilterChange:V,activeTab:oe,onTabChange:ue,eventTypeOptions:Us,filteredEvents:xi,sseConnected:c,clusterLoading:g,clusterError:u,promotePending:xe,onPromote:Fi,onAddNode:()=>U(!0),leavePending:Xe,onLeaveCluster:zi,onToggleNodeDevTunnel:qi,devTunnelNodeId:ct,devBoxStartNodeId:$e,devBoxStartingNodeIds:kt,onOpenNodeSettings:ye?G:void 0,onOpenNodeCapabilities:ye?Re:void 0,onOpenDevBox:ye?Dt:void 0,onStartDevBox:ye?rt:void 0};return e.jsxs(e.Fragment,{children:[e.jsx(ym,{desktopTasksOpen:A,mobileTasksPanelOpen:L,mobileTasksPanelRef:M,operationsOpen:D,operationsPanelRef:P,panelResize:F,taskSidebar:e.jsx(Ca,{...fr}),operationsSidecar:e.jsx(hf,{...$i}),terminalPanel:r?.terminalOpen?e.jsx(Am,{nodes:ur,defaultNodeId:hi,onClose:()=>r?.setTerminalOpen(!1)}):void 0,conversationPanel:e.jsx(mm,{onToggleTasks:W,desktopTasksOpen:A,mobileTasksPanelOpen:L,operationsOpen:D,onToggleOperations:()=>re(S=>!S),cluster:a,sseConnected:c,activeTab:B,setActiveTab:le,creatingTask:ee,createMode:q,createDefaults:w,activeTask:ce,assignedNode:vi,taskLoading:ht,transcriptLoading:Me,taskError:Ee,displayEvents:Ks,initialPromptAlreadyInLogs:ki,initialPrompt:bs,supportsFollowUp:wi,taskUnavailable:Vs.taskUnavailable,chatDisabled:Vs.chatDisabled,chatDisabledReason:Vs.chatDisabledReason,questionBypassEnabled:_,isRunning:!!gs,isStarting:yi,hasPendingFollowUp:Hs,canCancel:!!Ni,canRetry:!!ji,onRetry:Ii,onCancel:Di,onReloadNativeTranscript:Ai,onShareTask:_i,onStopShareTask:Pi,onStartCreateTask:Ws,onCancelCreateTask:Si,onCreateTask:Ci,onSendMessage:Ei,onCancelQueuedMessage:Ti,onQuestionBypassChange:ne,onSubmitQuestionResponse:Mi,quickChats:_e}),mobileTaskSidebar:e.jsx(Ca,{...fr,onCreateTask:(S,z)=>{Q(!1),Ws(S,z)},onSelectTask:S=>{Q(!1),mr(S)}}),onCloseOperations:()=>re(!1),onCloseTaskList:()=>Q(!1),onToggleOperations:()=>re(S=>!S),onToggleTasks:W}),e.jsx(pm,{open:I,onOpenChange:U,onAdded:m}),Nt,xt,ze]})}const Xh=Object.freeze(Object.defineProperty({__proto__:null,DashboardPage:Wh},Symbol.toStringTag,{value:"Module"}));export{ho as A,Xh as D,Ds as G};
|