meshy-node 0.5.1 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dashboard/assets/DashboardPage-pZti6jEL.js +129 -0
- package/dashboard/assets/{DashboardShared-CfKjChkE.js → DashboardShared-D7zc-yh8.js} +1 -1
- package/dashboard/assets/{DiffTab-CHex6isk.js → DiffTab-CAEFXyW_.js} +1 -1
- package/dashboard/assets/{FilesTab-BCF4QVC7.js → FilesTab-Z7ofEslt.js} +1 -1
- package/dashboard/assets/{PreviewTab-kHR8XJHu.js → PreviewTab-2MoQNLMM.js} +1 -1
- package/dashboard/assets/{SharedConversationPage-DQObdkaU.js → SharedConversationPage-ZkyofiFZ.js} +3 -3
- package/dashboard/assets/{file-CivHJbXQ.js → file-Cwm3-BLo.js} +1 -1
- package/dashboard/assets/{folder-CiTzsQ19.js → folder-BXMAsfGn.js} +1 -1
- package/dashboard/assets/index-BS822Af4.css +1 -0
- package/dashboard/assets/{index-BzTROrJe.js → index-CK-fup_F.js} +19 -19
- package/dashboard/assets/{play-Bn74sNWK.js → play-BO4AI_wC.js} +1 -1
- package/dashboard/index.html +2 -2
- package/main.cjs +126 -90
- package/package.json +1 -1
- package/runtime-metadata.json +5 -5
- package/dashboard/assets/DashboardPage-CHasRg3S.js +0 -124
- package/dashboard/assets/index-BOC8nP24.css +0 -1
package/README.md
CHANGED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-Z7ofEslt.js","assets/index-CK-fup_F.js","assets/index-BS822Af4.css","assets/folder-BXMAsfGn.js","assets/file-Cwm3-BLo.js","assets/PreviewTab-2MoQNLMM.js","assets/play-BO4AI_wC.js","assets/DiffTab-CAEFXyW_.js","assets/DashboardShared-D7zc-yh8.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as xe,r as t,j as e,a as Ga,b as E,d as Ja,e as Ya,D as Ft,f as Xa,g as Ot,B as Ae,I as Be,h as Qa,i as $,X as We,k as Za,l as en,C as as,m as sn,n as tn,F as an,o as ns,S as ge,p as rs,q as nn,s as rn,t as pe,u as Se,v as Ce,w as Pe,x as Te,y as Gs,z as Ge,T as Js,A as It,E as on,G as ln,H as Bt,J as zt,K as Qe,L as Ut,M as Vt,N as Ht,P as dn,O as Kt,Q as He,R as cn,U as Ke,V as Ds,W as As,Y as Ms,Z as Ls,_ as Ps,$ as Rs,a0 as $s,a1 as Fs,a2 as Ys,a3 as un,a4 as Cs,a5 as ft,a6 as hs,a7 as xn,a8 as mn,a9 as hn,aa as pn,ab as fn,ac as gn,ad as bn,ae as qt,af as Wt,ag as Gt,ah as vn,ai as ps,aj as jn,ak as Nn,al as kn,am as gt,an as wn,ao as yn,ap as Sn,aq as bt,ar as Cn,as as Tn,at as En,au as _n,av as Dn,aw as An,ax as Mn,ay as Ln,az as Jt,aA as Pn,aB as Rn,aC as $n,aD as Fn,aE as On,aF as In,aG as Bn,aH as zn,aI as Un,aJ as Vn,aK as Hn,aL as Kn,aM as qn,aN as Wn,aO as Gn,aP as Jn,aQ as Yn,aR as Xn,aS as Qn,aT as Zn,aU as er,aV as sr,aW as tr,aX as ar}from"./index-CK-fup_F.js";import{r as vt,e as nr,b as Yt,t as Xt,L as be,C as jt,a as rr,T as Ts,D as Xe,I as Oe,M as Os,c as Qt,m as Zt,d as ea,f as or,g as Nt,h as ir,i as lr,j as Es,k as dr,n as cr,l as ur}from"./DashboardShared-D7zc-yh8.js";import{F as xr}from"./folder-BXMAsfGn.js";import{P as mr}from"./play-BO4AI_wC.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 hr=[["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"}]],pr=xe("archive",hr);/**
|
|
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 fr=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],gr=xe("arrow-up",fr);/**
|
|
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 br=[["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"}]],vr=xe("ellipsis-vertical",br);/**
|
|
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 jr=[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]],Nr=xe("flag",jr);/**
|
|
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 kr=[["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"}]],wr=xe("funnel",kr);/**
|
|
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 yr=[["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"}]],kt=xe("git-branch",yr);/**
|
|
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 Sr=[["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"}]],Cr=xe("globe",Sr);/**
|
|
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 Tr=[["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"}]],Is=xe("history",Tr);/**
|
|
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 Er=[["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"}]],Bs=xe("image-plus",Er);/**
|
|
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 _r=[["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"}]],Dr=xe("laptop",_r);/**
|
|
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 Ar=[["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"}]],Xs=xe("link-2",Ar);/**
|
|
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 Mr=[["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"}]],Qs=xe("message-square-plus",Mr);/**
|
|
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 Lr=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],sa=xe("panel-left-close",Lr);/**
|
|
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 Pr=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],Rr=xe("panel-left-open",Pr);/**
|
|
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 $r=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],Zs=xe("panel-right-close",$r);/**
|
|
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 Fr=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],ta=xe("panel-right-open",Fr);/**
|
|
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 Or=[["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"}]],is=xe("pencil",Or);/**
|
|
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 Ir=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Br=xe("plus",Ir);/**
|
|
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 zr=[["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"}]],Ur=xe("rotate-ccw",zr);/**
|
|
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 Vr=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],zs=xe("search",Vr);/**
|
|
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 Hr=[["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"}]],aa=xe("send",Hr);/**
|
|
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 Kr=[["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"}]],qr=xe("share-2",Kr);/**
|
|
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 Wr=[["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"}]],Gr=xe("sliders-horizontal",Wr);/**
|
|
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 Jr=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],wt=xe("square",Jr);/**
|
|
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 Yr=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Xr=xe("trash-2",Yr),Qr=new Set(["assigned","running"]);function Zr(s,a){return s.reduce((n,o)=>o.assignedTo===a&&Qr.has(o.status)?n+1:n,0)}function es(s){return(s==null?void 0:s.toLowerCase())==="devtunnel"}function eo(s){return s?es(s)?"DevTunnel":s.charAt(0).toUpperCase()+s.slice(1):"Direct"}function et(s,a){return es(a??s.transportType)||!!s.devtunnelEndpoint}function na(s,a){return!es(a??s.transportType)}function ra(s,a){const n=a??s.transportType;return es(n)?"DevTunnel":s.devtunnelEndpoint?"Direct + DevTunnel":eo(n)}function yt(s,a){return!s&&!a}function so({routeTaskId:s,creatingTask:a,internalSelectedTaskId:n,sortedTaskIds:o}){return s||(a?null:n??o[0]??null)}function to(s,a){return[a,...s.filter(n=>n.id!==a.id)]}const ao=new Set(["completed","failed","cancelled","archived"]);function no(s,a){const n=new Set(a);return new Set(Array.from(s).filter(o=>n.has(o)))}function ro(s,a){const n=new Set(a);if(n.size===0)return!1;const o=s.filter(r=>n.has(r.id));return o.length===n.size&&o.every(r=>ao.has(r.status))}function oo(s,a){var o;const n=new Set(a);return((o=s.find(r=>!n.has(r.id)))==null?void 0:o.id)??null}var io=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],lo=io.reduce((s,a)=>{const n=Ga(`Primitive.${a}`),o=t.forwardRef((r,i)=>{const{asChild:x,...v}=r,k=x?n:a;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(k,{...v,ref:i})});return o.displayName=`Primitive.${a}`,{...s,[a]:o}},{}),co="Label",oa=t.forwardRef((s,a)=>e.jsx(lo.label,{...s,ref:a,onMouseDown:n=>{var r;n.target.closest("button, input, select, textarea")||((r=s.onMouseDown)==null||r.call(s,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));oa.displayName=co;var ia=oa;const uo=Ja("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),_e=t.forwardRef(({className:s,...a},n)=>e.jsx(ia,{ref:n,className:E(uo(),s),...a}));_e.displayName=ia.displayName;function xo({onAdded:s}){const[a,n]=t.useState(""),[o,r]=t.useState(!1),[i,x]=t.useState(null),v=t.useCallback(async k=>{if(k.preventDefault(),!!a.trim()){r(!0),x(null);try{await Ya({leaderEndpoint:a.trim(),transport:"devtunnel"}),s()}catch(j){x(j instanceof Error?j.message:"Failed to join node")}finally{r(!1)}}},[a,s]);return e.jsx(Ft,{className:"overflow-hidden border-border/60 bg-transparent p-0 shadow-none sm:max-w-xl",children:e.jsxs("div",{className:"overflow-hidden rounded-[28px] border border-border/60 bg-background/95 p-0 shadow-[0_40px_120px_-60px_rgba(0,0,0,0.88)] backdrop-blur-xl",children:[e.jsx("div",{className:"border-b border-border/60 px-6 py-5",children:e.jsxs(Xa,{className:"space-y-2 text-left",children:[e.jsx(Ot,{className:"text-2xl tracking-tight",children:"Join node"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Verify the remote leader's DevTunnel endpoint, sync this node's tasks to that leader, and join the cluster as a follower."})]})}),e.jsxs("form",{onSubmit:v,className:"space-y-4 px-6 py-5",children:[i&&e.jsx("div",{className:"rounded-[20px] border border-destructive/20 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:i}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(_e,{htmlFor:"leader-endpoint",children:"Leader endpoint"}),e.jsx(Ae,{variant:"outline",className:"rounded-[11px] border-border/70 bg-background/60 text-[10px] uppercase tracking-[0.16em]",children:"DevTunnel only"})]}),e.jsx(Be,{id:"leader-endpoint",type:"url",value:a,onChange:k=>n(k.target.value),placeholder:"https://your-leader.devtunnels.ms",className:"h-11 rounded-[18px] border-border/70 bg-background/70"})]}),e.jsx("div",{className:"rounded-[20px] border border-border/60 bg-background/45 px-4 py-3 text-sm text-muted-foreground",children:"This does not switch the local node transport or auto-enable a local DevTunnel. Leaving later will detach this node from the remote leader and make it leader of its own cluster again."}),e.jsx(Qa,{className:"border-t border-border/60 pt-4",children:e.jsx($,{type:"submit",disabled:!a.trim()||o,className:"rounded-[16px]",children:o?"Joining...":"Join node"})})]})]})})}function la(){const[s,a]=t.useState([]),[n,o]=t.useState(null),r=t.useRef(null),i=t.useCallback(()=>{var N;(N=r.current)==null||N.click()},[]),x=t.useCallback(async N=>{const d=Array.from(N.target.files??[]);if(d.length!==0)try{const u=await vt(d);a(b=>[...b,...u]),o(null)}catch(u){o(u instanceof Error?u.message:"Failed to attach image")}finally{N.target.value=""}},[]),v=t.useCallback(async N=>{const d=nr(N.clipboardData);if(d.length!==0){N.preventDefault();try{const u=await vt(d);a(b=>[...b,...u]),o(null)}catch(u){o(u instanceof Error?u.message:"Failed to attach image")}}},[]),k=t.useCallback(N=>{a(d=>d.filter((u,b)=>b!==N))},[]),j=t.useCallback(()=>{a([]),o(null)},[]);return{images:s,error:n,fileInputRef:r,pickImages:i,handleFileChange:x,handlePaste:v,removeImage:k,clearImages:j}}function mo({onSend:s,disabled:a,disabledReason:n="Chat is waiting on the agent.",placeholder:o="Send a follow-up message...",contextItems:r=[],running:i=!1,onStop:x}){const[v,k]=t.useState(""),j=t.useRef(null),{images:N,error:d,fileInputRef:u,pickImages:b,handleFileChange:w,handlePaste:p,removeImage:P,clearImages:M}=la(),_=t.useCallback(()=>{j.current&&(j.current.style.height="auto")},[]),X=t.useCallback(()=>{const L=Yt(v,N);L.length===0||a||(s(L),k(""),M(),_())},[v,N,a,s,M,_]),Q=t.useCallback(L=>{L.key==="Enter"&&!L.shiftKey&&(L.preventDefault(),X())},[X]),re=t.useCallback(()=>{j.current&&(j.current.style.height="auto",j.current.style.height=`${Math.min(j.current.scrollHeight,220)}px`)},[]),F=!a&&!i&&(v.trim().length>0||N.length>0),R=i&&!!x,q=i?x?"Task is running — click to stop":"Task is running...":a?n:"Enter sends, Shift+Enter adds a line";return e.jsxs("div",{className:"animate-composer-settle border-t border-border/45 bg-background/42 px-2 py-2 backdrop-blur-xl sm:px-4 sm:py-3",children:[r.length>0&&e.jsx("div",{className:"flex flex-wrap items-center gap-1.5 px-2 pb-2.5",children:r.map(L=>e.jsxs("div",{className:"inline-flex max-w-full items-center gap-1.5 rounded-[13px] border border-border/60 bg-muted/40 px-2 py-1 text-[11px] shadow-sm",children:[e.jsx("span",{className:"shrink-0 text-[9px] font-medium uppercase tracking-[0.12em] text-muted-foreground/80",children:L.label}),e.jsx("span",{className:`truncate text-foreground/90 ${L.mono?"font-mono text-[11px]":""}`,children:L.value})]},`${L.label}:${L.value}`))}),e.jsxs("div",{className:"overflow-hidden rounded-[26px] border border-border/65 bg-card/88 shadow-[0_30px_92px_-62px_rgba(15,23,42,0.55)] backdrop-blur-xl sm:rounded-[30px] dark:shadow-[0_30px_92px_-62px_rgba(0,0,0,0.95)]",children:[e.jsx("input",{ref:u,type:"file",accept:"image/*",multiple:!0,onChange:w,className:"hidden"}),N.length>0&&e.jsx("div",{className:"px-2 pt-3 sm:px-6 sm:pt-6",children:e.jsx("div",{className:"flex flex-wrap gap-3",children:N.map((L,O)=>e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:Xt(L),alt:L.filename??`attachment ${O+1}`,className:"h-24 w-24 rounded-[22px] border border-border/70 object-cover"}),e.jsx("button",{type:"button",onClick:()=>P(O),className:"absolute -top-2 -right-2 flex h-7 w-7 items-center justify-center rounded-[12px] border border-border/70 bg-background text-muted-foreground shadow-sm transition-all hover:-translate-y-px hover:text-foreground","aria-label":`Remove ${L.filename??`image ${O+1}`}`,children:e.jsx(We,{className:"h-3.5 w-3.5"})})]},`${L.filename??"image"}-${O}`))})}),e.jsxs("div",{className:"flex items-end gap-1.5 px-2 pt-3 pb-3 sm:px-6 sm:pt-4 sm:pb-4",children:[e.jsx("textarea",{ref:j,value:v,onChange:L=>k(L.target.value),onKeyDown:Q,onPaste:p,onInput:re,placeholder:o,disabled:a,rows:1,className:"min-h-[2.5rem] flex-1 resize-none bg-transparent px-0 py-1 text-[11px] leading-7 text-foreground placeholder:text-muted-foreground/70 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),e.jsxs($,{type:"button",variant:"ghost",onClick:b,disabled:a,className:"mb-0.5 h-8 shrink-0 gap-1.5 rounded-[14px] px-2.5 text-[11px] text-muted-foreground hover:text-foreground sm:px-2.5",title:"Attach images",children:[e.jsx(Bs,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Images"})]}),e.jsx("span",{title:q,children:e.jsx($,{onClick:i?x:X,disabled:i?!R:!F,size:"icon","aria-label":i?"Stop running task":"Send message",className:"mb-0.5 h-8 w-10 shrink-0 rounded-[14px] bg-primary/90 text-primary-foreground shadow-[0_12px_30px_-18px_hsl(var(--primary)/0.95)] hover:bg-primary",children:i?e.jsx(be,{className:"h-4 w-4 animate-spin"}):e.jsx(aa,{className:"h-4 w-4"})})})]}),d&&e.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-2 py-2 text-[11px] text-destructive sm:px-6 sm:py-3",children:d})]})]})}function ho(s,a,n){return s!=="auto"?a.find(o=>o.id===s)??null:n.length===1?n[0]??null:null}function po(s){return s.trim()||"."}function fo(s){return new Promise(a=>window.setTimeout(a,s))}function go(s){return!!s&&typeof s=="object"&&typeof s.createdBranch=="string"&&typeof s.currentBranch<"u"}async function bo(s){let a=s;for(let n=0;n<60;n++){if(a.status==="succeeded"){if(go(a.result))return a.result;throw new Error("Branch creation completed without branch details")}if(a.status==="failed")throw new Error(a.error||"Branch creation failed");await fo(1e3),a=await sn(a.id)}throw new Error("Timed out waiting for branch creation")}function St({value:s,onChange:a,project:n,assignTo:o,nodes:r,assignableNodes:i,layout:x="default",chipClassName:v,chipActiveClassName:k,chipInactiveClassName:j,labelClassName:N,triggerClassName:d}){const[u,b]=t.useState(!1),[w,p]=t.useState(null),[P,M]=t.useState(""),[_,X]=t.useState(!1),[Q,re]=t.useState(!1),[F,R]=t.useState(!1),[q,L]=t.useState(null),[O,C]=t.useState(""),[U,ne]=t.useState(""),[B,z]=t.useState(""),[I,J]=t.useState(!1),se=t.useRef(null),Y=t.useRef(0),Z=t.useMemo(()=>ho(o,r,i),[o,r,i]),V=Z==null?void 0:Z.id,ae=t.useMemo(()=>po(n),[n]),ie=t.useMemo(()=>V?`${V}
|
|
128
|
+
${ae}`:"",[V,ae]),c=t.useCallback(async(m=0,A=!1)=>{const K=Y.current+1,ke=ie;if(Y.current=K,!V){p(null),M("");return}L(null),A||M(""),A?re(!0):X(!0);try{const ye=await Za(V,{path:ae,limit:20,offset:m,allowAbsolute:!0});if(K!==Y.current)return;M(ke),p(we=>A&&we?{...ye,branches:[...we.branches,...ye.branches]}:ye)}catch(ye){if(K!==Y.current)return;L(ye instanceof Error?ye.message:"Failed to load branch info"),A||(p(null),M(""))}finally{K===Y.current&&(X(!1),re(!1))}},[V,ie,ae]);t.useEffect(()=>{if(!V){Y.current+=1,p(null),M(""),L(null);return}c()},[V,ae,c]),t.useEffect(()=>{const m=s.trim(),A=P===ie?w:null,K=A!=null&&A.available&&A.currentBranch?A.currentBranch:"";m!==K&&a(K)},[w,ie,P,a,s]),t.useEffect(()=>{if(!u)return;const m=K=>{se.current&&(se.current.contains(K.target)||b(!1))},A=K=>{K.key==="Escape"&&b(!1)};return document.addEventListener("mousedown",m),document.addEventListener("keydown",A),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",A)}},[u]),t.useEffect(()=>{u&&(ne(""),z(""),J(!1))},[u,V,ae]);const D=t.useCallback(async()=>{if(!V)return;const m=O.trim(),A=I?B.trim():U.trim();if(!(!m||!A)){R(!0),L(null);try{const K=await en(V,{path:ae,branchName:m,startPoint:A,limit:20,offset:0,allowAbsolute:!0}),ke=await bo(K);M(ie),p(ke),a(ke.currentBranch??ke.createdBranch),C(""),ne(""),z(""),J(!1),b(!1)}catch(K){L(K instanceof Error?K.message:"Failed to create branch")}finally{R(!1)}}},[V,ie,ae,I,B,O,a,U]),g=P===ie?w:null,G=t.useCallback(()=>{g!=null&&g.hasMore&&c(g.branches.length,!0)},[g,c]),h=s.trim()||(g==null?void 0:g.currentBranch)||(g&&!g.available?"No git repo":"Branch"),oe=I?B.trim():U.trim(),H=!!(g!=null&&g.available&&O.trim()&&oe&&!F),ue=x==="composer"?e.jsxs($,{type:"button",variant:"ghost",onClick:()=>b(m=>!m),title:h,"aria-label":`Branch: ${h}`,className:E(v,d,"min-w-0 max-w-full",s.trim()?k:j),children:[_&&!g?e.jsx(be,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(kt,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:E("min-w-0 truncate",N),children:h})]}):e.jsxs($,{type:"button",variant:"outline",onClick:()=>b(m=>!m),className:"h-11 w-full justify-between rounded-2xl border-border/70 bg-background/70 px-4",title:h,children:[e.jsx("span",{className:E("truncate",s.trim()?"font-mono text-foreground":"text-muted-foreground"),children:h}),e.jsx("span",{className:"ml-3 shrink-0 text-xs text-muted-foreground",children:Z?Z.name:"Manual"})]});return e.jsxs("div",{className:E("relative inline-block",x==="composer"?"min-w-0 shrink-0":"w-full"),ref:se,children:[x==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Branch"}),ue]}):ue,u&&e.jsxs("div",{className:E("absolute z-50 mt-2 w-[240px] overflow-hidden rounded-2xl border border-border/60 bg-background/95 shadow-lg backdrop-blur",x==="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(kt,{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:g!=null&&g.repoRoot?`${g.currentBranch??h} · ${g.repoRoot}`:(g==null?void 0:g.currentBranch)??h,children:(g==null?void 0:g.currentBranch)??h}),_?e.jsx(be,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground"}):null]}),Z?_&&!g?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(be,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):g&&!g.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(Be,{value:O,onChange:m=>C(m.target.value),placeholder:"New branch name",className:"h-8 flex-1 rounded-md border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx($,{type:"button",size:"sm",onClick:()=>void D(),disabled:!H,title:H?"Create branch":"Enter a name and pick a base","aria-label":"Create branch",className:"h-8 w-8 shrink-0 rounded-md p-0",children:F?e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Br,{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"}),!I&&e.jsxs("button",{type:"button",onClick:()=>J(!0),className:"flex items-center gap-1 rounded px-1 py-0.5 text-[10px] text-muted-foreground hover:bg-background/60 hover:text-foreground",children:[e.jsx(is,{className:"h-2.5 w-2.5"}),"Manual"]})]}),I?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Be,{value:B,onChange:m=>z(m.target.value),placeholder:"upstream/release/1.0",className:"h-8 flex-1 rounded-md border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx("button",{type:"button",onClick:()=>{J(!1),z("")},className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Cancel manual input","aria-label":"Cancel manual input",children:e.jsx(We,{className:"h-3.5 w-3.5"})})]}):g!=null&&g.branches.length?e.jsxs("div",{className:"max-h-44 overflow-y-auto rounded-md border border-border/40 bg-background/40",children:[g.branches.map(m=>{const A=U===m.ref,K=m.branch==="main"||m.branch==="master";return e.jsxs("button",{type:"button",onClick:()=>ne(m.ref),className:E("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",A&&"bg-background/70"),title:m.ref,children:[e.jsx("span",{className:E("shrink-0 text-[10px]",K?"text-amber-500 dark:text-amber-400":"text-muted-foreground/60"),"aria-hidden":!0,children:K?"★":"·"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-foreground",children:m.ref}),A?e.jsx(as,{className:"h-3 w-3 shrink-0 text-primary"}):null]},m.ref)}),g.hasMore&&e.jsxs("button",{type:"button",onClick:G,disabled:Q,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:[Q?e.jsx(be,{className:"h-3 w-3 animate-spin"}):e.jsx(Is,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"rounded-md border border-dashed border-border/40 px-2.5 py-2 text-[11px] text-muted-foreground",children:"No remote branches found."})]})]})}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Select a specific node first."}),q&&e.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-3 py-1.5 text-[11px] text-destructive",children:q})]})]})}const vo=20,jo=3,Us="meshy-working-dir-recents-by-node";function No(s){return s.startsWith("/")||s.startsWith("\\\\")||/^[A-Za-z]:[\\/]/.test(s)}function ko(s){const a=s.trim();return a||"."}function Vs(s){const a=[],n=new Set;for(const o of s){const r=o.trim();if(!(!r||n.has(r))&&(n.add(r),a.push(r),a.length===jo))break}return a}function wo(s,a){const n=a.trim();return Vs(n?[n,...s]:s)}function da(s){if(!s||typeof s!="object"||Array.isArray(s))return{};const a={};for(const[n,o]of Object.entries(s)){if(!n||!Array.isArray(o))continue;const r=o.filter(x=>typeof x=="string"),i=Vs(r);i.length>0&&(a[n]=i)}return a}function yo(s,a,n){if(!a)return s;const o=s[a]??[],r=wo(o,n);if(r.length===0){if(!(a in s))return s;const{[a]:i,...x}=s;return x}return{...s,[a]:r}}function So(s,a){var n;return a?((n=s[a])==null?void 0:n[0])??"":""}function ca(s){if(!s||typeof window>"u")return"";try{const a=window.localStorage.getItem(Us);return a?So(da(JSON.parse(a)),s):""}catch{return""}}function Co(s,a,n){return s!=="auto"?a.find(o=>o.id===s)??null:n.length===1?n[0]??null:null}function To(s,a){const n=a.trim();return n?No(n)||!s?n:`${s.replace(/[/\\]+$/,"")}/${n}`:""}function Eo(s,a){return s?s.isAbsolute?s.currentPath:s.currentPath==="."||s.currentPath===""?s.rootPath||(a==null?void 0:a.workDir)||"Node root":s.currentPath:(a==null?void 0:a.workDir)??"Node root"}function fs({value:s,onChange:a,assignTo:n,nodes:o,assignableNodes:r,layout:i="default",chipClassName:x,chipActiveClassName:v,chipInactiveClassName:k,labelClassName:j,triggerClassName:N,popoverPlacement:d="bottom",popoverAlign:u="start"}){const[b,w]=t.useState(!1),[p,P]=t.useState(null),[M,_]=t.useState(!1),[X,Q]=t.useState(!1),[re,F]=t.useState(null),[R,q]=t.useState(""),[L,O]=t.useState(!1),[C,U]=t.useState({}),ne=t.useRef(null),B=t.useMemo(()=>Co(n,o,r),[n,o,r]),z=B==null?void 0:B.id,I=t.useMemo(()=>z?C[z]??[]:[],[C,z]),J=t.useMemo(()=>s.trim()?To(B==null?void 0:B.workDir,s):"Use node default",[s,B==null?void 0:B.workDir]);t.useEffect(()=>{if(!(typeof window>"u"))try{const h=window.localStorage.getItem(Us);if(!h)return;const oe=JSON.parse(h);U(da(oe))}catch{}},[]);const se=t.useCallback(h=>{z&&U(oe=>{const H=yo(oe,z,h);if(H===oe)return oe;if(typeof window<"u")try{window.localStorage.setItem(Us,JSON.stringify(H))}catch{}return H})},[z]),Y=t.useCallback((h,oe=!0)=>{const H=h.trim();a(H),oe&&H&&se(H),w(!1)},[a,se]),Z=t.useCallback(async(h,oe=0,H=!1)=>{if(z){F(null),H?Q(!0):_(!0);try{const ue=await tn(z,{path:h,limit:vo,offset:oe,directoriesOnly:!0,allowAbsolute:!0});P(m=>H&&m?{...ue,entries:[...m.entries,...ue.entries]}:ue)}catch(ue){F(ue instanceof Error?ue.message:"Failed to browse directories"),H||P(null)}finally{_(!1),Q(!1)}}},[z]),V=t.useRef(s);V.current=s;const ae=t.useRef(Z);ae.current=Z,t.useEffect(()=>{if(!b)return;const h=V.current;q(h),O(!1),P(null),F(null),z&&ae.current(ko(h))},[b,z]),t.useEffect(()=>{if(!b)return;const h=H=>{ne.current&&(ne.current.contains(H.target)||w(!1))},oe=H=>{H.key==="Escape"&&w(!1)};return document.addEventListener("mousedown",h),document.addEventListener("keydown",oe),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",oe)}},[b]);const ie=t.useCallback(h=>{Z(h)},[Z]),c=t.useCallback(()=>{p&&Z(p.currentPath,p.entries.length,!0)},[p,Z]),D=i==="composer"?e.jsxs($,{type:"button",variant:"ghost",onClick:()=>w(h=>!h),title:J,"aria-label":`Working directory: ${J}`,className:E(x,N,"min-w-0 max-w-full",s.trim()?v:k),children:[e.jsx(an,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:E("min-w-0 truncate",j),children:J})]}):e.jsxs($,{type:"button",variant:"outline",onClick:()=>w(h=>!h),className:"h-11 w-full justify-between rounded-2xl border-border/70 bg-background/70 px-4",title:J,children:[e.jsx("span",{className:E("truncate",s.trim()?"font-mono text-foreground":"text-muted-foreground"),children:J}),e.jsx("span",{className:"ml-3 shrink-0 text-xs text-muted-foreground",children:B?B.name:"Manual"})]}),g=Eo(p,B),G=!!(p!=null&&p.parentPath);return e.jsxs("div",{className:E("relative inline-block",i==="composer"?"min-w-0 max-w-[60%] shrink":"w-full"),"data-workdir-popover-placement":d,"data-workdir-popover-align":u,ref:ne,children:[i==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Working directory"}),D]}):D,b&&e.jsxs("div",{className:E("absolute z-50 flex max-h-[min(28rem,calc(100vh-5rem))] w-[240px] flex-col overflow-hidden rounded-2xl border border-border/60 bg-background/95 shadow-lg backdrop-blur",d==="top"?"bottom-full mb-2":"top-full mt-2",i==="composer"?u==="end"?"right-0":"left-0":u==="end"?"right-0 w-auto min-w-[240px]":"left-0 right-0 w-auto min-w-[240px]"),children:[I.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(Is,{className:"h-2.5 w-2.5"}),"Recent"]}),e.jsx("div",{className:"flex flex-col",children:I.map(h=>e.jsx("button",{type:"button",onClick:()=>Y(h),className:"truncate rounded px-1.5 py-0.5 text-left font-mono text-[11px] text-foreground hover:bg-background/60",title:h,children:h},h))})]}),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:()=>(p==null?void 0:p.parentPath)&&ie(p.parentPath),disabled:!G||M,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-border/60 text-muted-foreground transition-colors hover:bg-background/60 hover:text-foreground disabled:opacity-40",title:"Parent directory",children:e.jsx(gr,{className:"h-3 w-3"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground",title:g,children:g}),p&&e.jsx("button",{type:"button",onClick:()=>Y(p.isAbsolute?p.currentPath:p.currentPath==="."?"":p.currentPath),className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium text-foreground hover:bg-background/60",title:"Use this folder",children:"Use"})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:[B?M?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(be,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):p&&p.entries.length>0?e.jsxs(e.Fragment,{children:[p.entries.map(h=>e.jsxs("div",{className:"group flex items-stretch border-b border-border/30 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>Y(h.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 ${h.path}`,children:[e.jsx(xr,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-[11px] text-foreground",children:h.name})]}),e.jsx("button",{type:"button",onClick:()=>ie(h.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 ${h.name}`,children:e.jsx(ns,{className:"h-3.5 w-3.5"})})]},h.path)),p.hasMore&&e.jsxs("button",{type:"button",onClick:c,disabled:X,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:[X?e.jsx(be,{className:"h-3 w-3 animate-spin"}):e.jsx(Is,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:re??"No subfolders."}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Select a node to browse."}),re&&p&&p.entries.length>0&&e.jsx("div",{className:"border-t border-border/60 px-3 py-1.5 text-[11px] text-destructive",children:re})]}),e.jsx("div",{className:"flex items-center gap-1 border-t border-border/60 bg-background/40 px-2.5 py-1.5",children:L?e.jsxs(e.Fragment,{children:[e.jsx(Be,{value:R,onChange:h=>q(h.target.value),onKeyDown:h=>{h.key==="Enter"&&R.trim()?(h.preventDefault(),Y(R)):h.key==="Escape"&&(h.preventDefault(),O(!1),q(s))},autoFocus:!0,placeholder:"Path (relative or absolute)",className:"h-7 flex-1 rounded-md border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx("button",{type:"button",onClick:()=>Y(R),disabled:!R.trim(),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-foreground hover:bg-background/60 disabled:opacity-40",title:"Apply","aria-label":"Apply manual path",children:e.jsx(as,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{O(!1),q(s)},className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Cancel","aria-label":"Cancel manual path",children:e.jsx(We,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>{q(s),O(!0)},className:"flex h-7 flex-1 items-center justify-between rounded-md px-1.5 text-[11px] text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Enter a manual path",children:[e.jsx("span",{children:"Manual input"}),e.jsx(is,{className:"h-3 w-3"})]})})]})]})}function ua(s,a={}){const n=s.filter(o=>o.status==="online");return a.currentNodeRole!=="follower"||!a.leaderNodeId?n:n.filter(o=>o.id!==a.leaderNodeId)}function st({isCurrent:s}){return s?e.jsx(Dr,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500 dark:text-emerald-400","aria-label":"current node"}):e.jsx(Cr,{className:"h-3.5 w-3.5 shrink-0 text-sky-500 dark:text-sky-400","aria-label":"remote follower node"})}function Hs(s,a){return s.map(n=>{const o=!!a&&n.id===a;return e.jsx(ge,{value:n.id,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(st,{isCurrent:o}),e.jsx("span",{className:"truncate",children:n.name}),e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:o?"current":"remote"})]})},n.id)})}function _o(s){var o;const a=s.sessionId.trim(),n=s.cwd.trim();return!a||!n||!s.assignTo?null:{title:s.title.trim()||((o=s.defaultTitle)==null?void 0:o.trim())||void 0,agent:s.agent,sessionId:a,cwd:n,assignTo:s.assignTo,priority:s.priority,mode:s.mode??rs}}function Do(){return Js.map(s=>e.jsx(ge,{value:s.value,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{children:s.label}),s.description&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:s.description})]})},s.value))}function Ao(s){if(!s)return"unknown time";const a=Date.parse(s);return Number.isNaN(a)?s:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(a)}function Mo({nodes:s,currentNodeRole:a,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,className:x,footerClassName:v,submitLabel:k="Load session",cancelLabel:j="Cancel",autoFocus:N=!1}){const d=t.useMemo(()=>ua(s,{currentNodeRole:a,leaderNodeId:o}),[s,a,o]),u=t.useMemo(()=>{var m;return n&&d.some(A=>A.id===n)?n:((m=d[0])==null?void 0:m.id)??""},[d,n]),[b,w]=t.useState(""),[p,P]=t.useState("codex"),[M,_]=t.useState(""),[X,Q]=t.useState(""),[re,F]=t.useState(""),[R,q]=t.useState(u),[L,O]=t.useState("normal"),[C,U]=t.useState(rs),[ne,B]=t.useState(!1),[z,I]=t.useState([]),[J,se]=t.useState(!1),[Y,Z]=t.useState(null),V=t.useMemo(()=>z.find(m=>m.sessionId===M)??null,[z,M]);t.useEffect(()=>{R&&d.some(m=>m.id===R)||q(u)},[R,d,u]),t.useEffect(()=>{_(""),Q(""),F("")},[p,R]),t.useEffect(()=>{let m=!1;return R?(se(!0),Z(null),nn(R,{agent:p,limit:50}).then(A=>{m||I(A.sessions)}).catch(A=>{m||(I([]),Z(A instanceof Error?A.message:"Failed to load native sessions"))}).finally(()=>{m||se(!1)}),()=>{m=!0}):(I([]),Z(null),se(!1),()=>{m=!0})},[p,R]),t.useEffect(()=>{V&&(Q(V.sessionId),F(V.cwd))},[V]);const ae=t.useCallback(async m=>{m.preventDefault();const A=_o({title:b,defaultTitle:V==null?void 0:V.summary,agent:p,sessionId:X,cwd:re,assignTo:R,priority:L,mode:C});if(A){B(!0);try{const K=await rn(A);r(K)}catch(K){pe.error(K instanceof Error?K.message:"Failed to load native session")}finally{B(!1)}}},[b,V,p,X,re,R,L,C,r]),ie=!!(X.trim()&&re.trim()&&R),[c,D]=t.useState(!1),[g,G]=t.useState(""),h=d.find(m=>m.id===R)??null,oe=!!(n&&(h==null?void 0:h.id)===n),H=t.useMemo(()=>{const m=g.trim().toLowerCase();return m?z.filter(A=>A.summary.toLowerCase().includes(m)||A.sessionId.toLowerCase().includes(m)||A.cwd.toLowerCase().includes(m)):z},[z,g]),ue="h-9 w-auto gap-1.5 rounded-[15px] border-border/60 bg-background/60 px-3 text-xs shadow-none transition-colors hover:bg-background/80";return e.jsxs("form",{onSubmit:ae,className:E("space-y-4",x),children:[e.jsxs("div",{className:"rounded-[26px] border border-border/60 bg-background/54 shadow-[0_24px_86px_-48px_rgba(15,23,42,0.55)] backdrop-blur-xl dark:shadow-[0_24px_86px_-48px_rgba(0,0,0,0.9)]",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-border/50 px-4 py-3",children:[e.jsxs(Se,{value:R,onValueChange:q,children:[e.jsx(Ce,{className:E(ue),"aria-label":"Node",children:h?e.jsxs(e.Fragment,{children:[e.jsx(st,{isCurrent:oe}),e.jsx("span",{className:"max-w-[10rem] truncate",children:h.name})]}):e.jsx(Pe,{placeholder:"Node"})}),e.jsx(Te,{children:Hs(d,n)})]}),e.jsxs(Se,{value:p,onValueChange:m=>P(m),children:[e.jsxs(Ce,{className:E(ue),"aria-label":"Agent",children:[e.jsx(Gs,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{children:p})]}),e.jsxs(Te,{children:[e.jsx(ge,{value:"codex",children:"codex"}),e.jsx(ge,{value:"claudecode",children:"claudecode"})]})]}),e.jsxs("div",{className:"relative ml-auto min-w-0 flex-1 sm:max-w-56",children:[e.jsx(zs,{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(Be,{value:g,onChange:m=>G(m.target.value),placeholder:"Filter sessions",className:"h-9 rounded-[15px] 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(_e,{className:"text-[10px] font-medium uppercase tracking-[0.2em] text-muted-foreground",children:J?"Loading...":`${H.length} session${H.length===1?"":"s"}`})}),e.jsxs("div",{className:"relative h-88 overflow-hidden rounded-[20px]",children:[J&&e.jsx("div",{className:"absolute inset-x-0 top-0 z-10 h-0.5 overflow-hidden bg-primary/10",children:e.jsx("div",{className:"h-full w-1/3 animate-indeterminate-bar bg-primary/70"})}),e.jsxs("div",{className:"h-full space-y-1.5 overflow-y-auto pr-1 pt-1",children:[!R&&e.jsx("div",{className:"rounded-[18px] border border-dashed border-border/60 bg-background/35 px-4 py-6 text-center text-xs text-muted-foreground",children:"Pick a node to load its recent sessions."}),R&&!J&&H.length===0&&e.jsx("div",{className:"rounded-[18px] border border-dashed border-border/60 bg-background/35 px-4 py-6 text-center text-xs text-muted-foreground",children:z.length===0?"No recent sessions on this node. Use Manual session ID under More options.":"No sessions match your filter."}),H.map(m=>{const A=m.sessionId===M;return e.jsxs("button",{type:"button",onClick:()=>_(m.sessionId),className:E("flex w-full flex-col gap-1 rounded-[18px] border px-3 py-2.5 text-left transition-all duration-200 hover:-translate-y-px",A?"border-primary/45 bg-primary/9 shadow-[0_18px_60px_-44px_hsl(var(--primary)/0.95)]":"border-border/55 bg-background/40 hover:border-border hover:bg-background/65"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:E("h-2 w-2 shrink-0 rounded-full",A?"bg-primary":"bg-border")}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground",children:m.summary}),e.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.16em] text-muted-foreground",children:Ao(m.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:m.sessionId.slice(0,12)}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),e.jsx("span",{className:"truncate font-mono",children:m.cwd})]})]},m.sessionId)})]})]}),Y&&e.jsx("p",{className:"px-1 pt-2 text-[11px] text-destructive",children:Y})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{type:"button",onClick:()=>D(m=>!m),className:"flex w-full items-center gap-2 text-[11px] font-medium uppercase tracking-[0.2em] text-muted-foreground transition-colors hover:text-foreground","aria-expanded":c,children:[e.jsx("span",{className:"h-px flex-1 bg-border/60","aria-hidden":!0}),e.jsx("span",{className:"shrink-0",children:c?"Less options":"More options"}),e.jsx(Ge,{className:E("h-3.5 w-3.5 shrink-0 transition-transform",c&&"rotate-180")}),e.jsx("span",{className:"h-px flex-1 bg-border/60","aria-hidden":!0})]}),c&&e.jsxs("div",{className:"space-y-4 rounded-[22px] border border-border/60 bg-background/35 p-4",children:[e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{htmlFor:"native-session-id",className:"text-xs font-medium text-muted-foreground",children:"Session ID"}),e.jsx(Be,{id:"native-session-id",type:"text",value:X,onChange:m=>{_(""),Q(m.target.value)},placeholder:"ses_... or thread_...",autoFocus:N,className:"h-10 rounded-[16px] border-border/70 bg-background/70 font-mono text-xs"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{htmlFor:"native-session-title",className:"text-xs font-medium text-muted-foreground",children:"Task title"}),e.jsx(Be,{id:"native-session-title",type:"text",value:b,onChange:m=>w(m.target.value),placeholder:"Optional",className:"h-10 rounded-[16px] border-border/70 bg-background/70 text-sm"})]})]}),e.jsx(fs,{value:re,onChange:m=>{_(""),F(m)},assignTo:R,nodes:s,assignableNodes:d}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-xs font-medium text-muted-foreground",children:"Mode"}),e.jsxs(Se,{value:C,onValueChange:m=>U(m),children:[e.jsx(Ce,{className:"h-10 rounded-[16px] border-border/70 bg-background/70 text-sm",children:e.jsx(Pe,{placeholder:"Select mode"})}),e.jsx(Te,{children:Do()})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-xs font-medium text-muted-foreground",children:"Priority"}),e.jsxs(Se,{value:L,onValueChange:O,children:[e.jsx(Ce,{className:"h-10 rounded-[16px] border-border/70 bg-background/70 text-sm",children:e.jsx(Pe,{placeholder:"Select priority"})}),e.jsxs(Te,{children:[e.jsx(ge,{value:"low",children:"Low"}),e.jsx(ge,{value:"normal",children:"Normal"}),e.jsx(ge,{value:"high",children:"High"}),e.jsx(ge,{value:"critical",children:"Critical"})]})]})]})]})]})]}),e.jsxs("div",{className:E("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",v),children:[i&&e.jsx($,{type:"button",variant:"ghost",onClick:i,className:"rounded-[16px]",children:j}),e.jsx($,{type:"submit",disabled:!ie||ne,className:"rounded-[16px] px-5",children:ne?e.jsxs(e.Fragment,{children:[e.jsx(be,{className:"h-4 w-4 animate-spin"})," Loading..."]}):k})]})]})}function Ct(){return It.map(s=>e.jsx(ge,{value:s.value,disabled:s.disabled,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{children:s.label}),s.description&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:s.description})]})},s.value))}function Tt(){return Js.map(s=>e.jsx(ge,{value:s.value,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{children:s.label}),s.description&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:s.description})]})},s.value))}function Lo(s){var a;return((a=It.find(n=>n.value===s))==null?void 0:a.label)??s}function Po(s){var a;return((a=Js.find(n=>n.value===s))==null?void 0:a.label)??s}function xa(s,a,n=!1){const o=s.trim();if(o)return o;const r=a.trim().split(`
|
|
129
|
+
`).map(i=>i.trim()).find(Boolean);return r?r.length>72?`${r.slice(0,69).trimEnd()}...`:r:n?"Image task":""}function Ro(s){var x;const a=s.title.trim(),n=xa(s.title,s.description,s.images.length>0),o=s.description.trim()||n,r=s.mode??rs,i=Yt(s.description,s.images);return!n||!o||!s.agent?null:{title:n,description:o,agent:s.agent,project:s.project.trim()||null,branch:((x=s.branch)==null?void 0:x.trim())||null,payload:{initialMessage:i,mode:r,titleSource:a?"manual":"derived"},priority:s.priority,assignTo:s.assignTo==="auto"?void 0:s.assignTo}}function $o({nodes:s,currentNodeRole:a,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,className:x,footerClassName:v,submitLabel:k="Create chat",cancelLabel:j="Cancel",autoFocus:N=!1,layout:d="default"}){const[u,b]=t.useState(""),[w,p]=t.useState(""),[P,M]=t.useState("claudecode"),[_,X]=t.useState(rs),[Q,re]=t.useState(""),[F,R]=t.useState(""),[q,L]=t.useState("normal"),O=t.useMemo(()=>ua(s,{currentNodeRole:a,leaderNodeId:o}),[s,a,o]),C=t.useMemo(()=>{var S;return n&&O.some(W=>W.id===n)?n:((S=O[0])==null?void 0:S.id)??""},[O,n]),[U,ne]=t.useState(C),[B,z]=t.useState(!1),[I,J]=t.useState(!1),{images:se,error:Y,fileInputRef:Z,pickImages:V,handleFileChange:ae,handlePaste:ie,removeImage:c}=la(),D=t.useMemo(()=>O.find(S=>S.id===U)??null,[U,O]),g=!!(n&&(D==null?void 0:D.id)===n),G=Lo(P),h=Po(_);t.useEffect(()=>{U&&O.some(S=>S.id===U)||ne(C)},[U,O,C]),t.useEffect(()=>{re(ca(U)),R("")},[U]),t.useEffect(()=>{R("")},[Q]);const oe=t.useCallback(async S=>{S.preventDefault();const W=Ro({title:u,description:w,agent:P,project:Q,branch:F,priority:q,assignTo:U,mode:_,images:se});if(W){z(!0);try{const le=await ln(W);r(le)}catch(le){pe.error(le instanceof Error?le.message:"Failed to create task")}finally{z(!1)}}},[u,w,P,Q,F,q,U,_,se,r]),H=xa(u,w,se.length>0),ue=!!(H&&P&&U&&(w.trim()||se.length>0)),m=t.useCallback(S=>{var W;S.nativeEvent.isComposing||S.key==="Enter"&&(S.ctrlKey||S.metaKey)&&ue&&!B&&(S.preventDefault(),(W=S.currentTarget.form)==null||W.requestSubmit())},[ue,B]),A=se.length>0&&e.jsx("div",{className:"flex flex-wrap gap-3",children:se.map((S,W)=>e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:Xt(S),alt:S.filename??`attachment ${W+1}`,className:"h-24 w-24 rounded-2xl border border-border/70 object-cover"}),e.jsx("button",{type:"button",onClick:()=>c(W),className:"absolute -top-2 -right-2 flex h-6 w-6 items-center justify-center rounded-[10px] border border-border/70 bg-background text-muted-foreground shadow-sm transition-all hover:-translate-y-px hover:text-foreground","aria-label":`Remove ${S.filename??`image ${W+1}`}`,children:e.jsx(We,{className:"h-3.5 w-3.5"})})]},`${S.filename??"image"}-${W}`))}),K=e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Assign to"}),e.jsxs(Se,{value:U,onValueChange:ne,children:[e.jsx(Ce,{className:"h-11 rounded-[18px] border-border/70 bg-background/70",children:e.jsx(Pe,{placeholder:"Select node"})}),e.jsx(Te,{children:Hs(O,n)})]})]}),ke=e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Agent"}),e.jsxs(Se,{value:P,onValueChange:M,children:[e.jsx(Ce,{className:"h-11 rounded-[18px] border-border/70 bg-background/70",children:e.jsx(Pe,{placeholder:"Select agent"})}),e.jsx(Te,{children:Ct()})]})]}),ye=e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Mode"}),e.jsxs(Se,{value:_,onValueChange:S=>X(S),children:[e.jsx(Ce,{className:"h-11 rounded-[18px] border-border/70 bg-background/70",children:e.jsx(Pe,{placeholder:"Select mode"})}),e.jsx(Te,{children:Tt()})]})]}),we=e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Priority"}),e.jsxs(Se,{value:q,onValueChange:L,children:[e.jsx(Ce,{className:"h-11 rounded-[18px] border-border/70 bg-background/70",children:e.jsx(Pe,{placeholder:"Select priority"})}),e.jsxs(Te,{children:[e.jsx(ge,{value:"low",children:"Low"}),e.jsx(ge,{value:"normal",children:"Normal"}),e.jsx(ge,{value:"high",children:"High"}),e.jsx(ge,{value:"critical",children:"Critical"})]})]})]}),y=e.jsx(fs,{value:Q,onChange:re,assignTo:U,nodes:s,assignableNodes:O}),me=e.jsx(St,{value:F,onChange:R,project:Q,assignTo:U,nodes:s,assignableNodes:O});return d==="composer"?e.jsxs("form",{onSubmit:oe,className:E("space-y-4",x),children:[e.jsx("input",{ref:Z,type:"file",accept:"image/*",multiple:!0,onChange:ae,className:"hidden"}),(()=>{const S="chat-composer__chip h-9 w-auto gap-1.5 rounded-[15px] px-3.5 text-xs shadow-none transition-colors",W="border-transparent bg-transparent text-muted-foreground hover:bg-background/40 hover:text-foreground",le="border-border/70 bg-background/55 text-foreground",Me=P==="claudecode",Le=_===rs;return e.jsxs("div",{className:"chat-composer space-y-2",children:[e.jsxs("div",{className:"rounded-[26px] border border-border/60 bg-background/54 shadow-[0_24px_86px_-48px_rgba(15,23,42,0.55)] backdrop-blur-xl dark:shadow-[0_24px_86px_-48px_rgba(0,0,0,0.9)]",children:[e.jsxs("div",{className:"chat-composer__header flex min-w-0 items-center justify-between gap-3 px-4 pt-3",children:[e.jsxs(Se,{value:U,onValueChange:ne,children:[e.jsx(Ce,{className:E(S,le,"chat-composer__node-trigger border-transparent bg-transparent hover:bg-background/40"),title:`Assigned node: ${(D==null?void 0:D.name)??"unassigned"}`,"aria-label":`Assigned node: ${(D==null?void 0:D.name)??"unassigned"}`,children:D?e.jsxs(e.Fragment,{children:[e.jsx(st,{isCurrent:g}),e.jsx("span",{className:"min-w-0 truncate",children:D.name}),e.jsx("span",{className:"chat-composer__header-meta shrink-0 text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:g?"current":"remote"})]}):e.jsx(Pe,{placeholder:"Select node"})}),e.jsx(Te,{children:Hs(O,n)})]}),I?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Be,{id:"task-title-composer",type:"text",value:u,onChange:ce=>b(ce.target.value),onKeyDown:ce=>{(ce.key==="Enter"||ce.key==="Escape")&&(ce.preventDefault(),J(!1))},autoFocus:!0,placeholder:"Chat title",className:"h-8 w-48 min-w-0 rounded-[13px] border-border/70 bg-background/55 px-3 text-xs shadow-none"}),e.jsx($,{type:"button",variant:"ghost",size:"icon",onClick:()=>J(!1),"aria-label":"Save title",className:"h-8 w-8 shrink-0 rounded-[12px] text-muted-foreground hover:text-foreground",children:e.jsx(as,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>J(!0),className:"chat-composer__title-button flex min-w-0 items-center gap-1.5 rounded-[13px] px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-background/55 hover:text-foreground",title:H||"Title","aria-label":H?`Edit title: ${H}`:"Edit title",children:[e.jsx("span",{className:"chat-composer__title-text max-w-[220px] truncate",children:H||"Title"}),e.jsx(is,{className:"h-3 w-3 shrink-0"})]})]}),e.jsx("textarea",{id:"task-description",value:w,onChange:ce=>p(ce.target.value),onKeyDown:m,onPaste:ie,placeholder:"Ask anything...",rows:4,autoFocus:N,"aria-label":"Opening prompt",className:"min-h-[140px] w-full resize-none rounded-[24px] bg-transparent px-5 pt-2 pb-2 text-[15px] leading-7 text-foreground ring-offset-background placeholder:text-muted-foreground/70 focus-visible:outline-none"}),e.jsxs("div",{className:"chat-composer__rail flex flex-nowrap items-center gap-2 px-3 pb-3",children:[e.jsx($,{type:"button",variant:"ghost",size:"icon",onClick:V,"aria-label":"Add images",className:"h-9 w-9 shrink-0 rounded-[14px] text-muted-foreground hover:text-foreground",children:e.jsx(Bs,{className:"h-4 w-4"})}),e.jsx("span",{className:"mx-0.5 h-5 w-px bg-border/60","aria-hidden":!0}),e.jsxs(Se,{value:P,onValueChange:M,children:[e.jsxs(Ce,{className:E(S,"chat-composer__icon-trigger",Me?W:le),title:`Agent: ${G}`,"aria-label":`Agent: ${G}`,children:[e.jsx(Gs,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:G})]}),e.jsx(Te,{children:Ct()})]}),e.jsxs(Se,{value:_,onValueChange:ce=>X(ce),children:[e.jsxs(Ce,{className:E(S,"chat-composer__icon-trigger",Le?W:le),title:`Mode: ${h}`,"aria-label":`Mode: ${h}`,children:[e.jsx(Gr,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:h})]}),e.jsx(Te,{children:Tt()})]}),e.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[e.jsxs(Se,{value:q,onValueChange:L,children:[e.jsx(Ce,{"aria-label":`Priority: ${q}`,title:`Priority: ${q}`,className:E("h-9 w-9 justify-center gap-0 rounded-[14px] p-0 text-xs shadow-none [&>svg:last-child]:hidden",q==="normal"?"border-transparent bg-transparent text-muted-foreground hover:bg-background/40":"border-border/70 bg-background/55",q==="critical"&&"text-destructive",q==="high"&&"text-amber-600 dark:text-amber-400",q==="low"&&"text-muted-foreground"),children:e.jsx(Nr,{className:E("h-4 w-4",q==="critical"&&"fill-destructive/20")})}),e.jsxs(Te,{children:[e.jsx(ge,{value:"low",children:"Low"}),e.jsx(ge,{value:"normal",children:"Normal"}),e.jsx(ge,{value:"high",children:"High"}),e.jsx(ge,{value:"critical",children:"Critical"})]})]}),i&&e.jsxs($,{type:"button",variant:"ghost",size:"sm",onClick:i,"aria-label":j,className:"chat-composer__cancel h-9 rounded-[14px] px-4 text-xs text-muted-foreground",children:[e.jsx(We,{className:"chat-composer__cancel-icon h-4 w-4 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label",children:j})]}),e.jsxs($,{type:"submit",size:"icon",disabled:!ue||B,className:"h-10 w-10 rounded-[16px] shadow-[0_8px_30px_-8px_hsl(var(--primary)/0.6)]",children:[B?e.jsx(be,{className:"h-4 w-4 animate-spin"}):e.jsx(aa,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:B?"Creating chat":k})]})]})]})]}),e.jsx("div",{className:"chat-composer__location flex flex-wrap items-center gap-2 px-1",children:(()=>{const ce="border-border/40 bg-muted/40 text-foreground/80 hover:bg-muted/60 hover:text-foreground";return e.jsxs(e.Fragment,{children:[e.jsx(fs,{value:Q,onChange:re,assignTo:U,nodes:s,assignableNodes:O,layout:"composer",chipClassName:S,chipActiveClassName:ce,chipInactiveClassName:ce,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"}),e.jsx(St,{value:F,onChange:R,project:Q,assignTo:U,nodes:s,assignableNodes:O,layout:"composer",chipClassName:S,chipActiveClassName:ce,chipInactiveClassName:ce,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"})]})})()})]})})(),(A||Y)&&e.jsxs("div",{className:"space-y-3 rounded-[20px] border border-border/60 bg-background/45 p-4",children:[A,Y&&e.jsx("div",{className:"text-xs text-destructive",children:Y}),!Y&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Ctrl/Cmd+Enter starts the chat. Enter adds a new line. Paste screenshots directly into the prompt box or use the Images button."})]})]}):e.jsxs("form",{onSubmit:oe,className:E("space-y-5",x),children:[e.jsx("input",{ref:Z,type:"file",accept:"image/*",multiple:!0,onChange:ae,className:"hidden"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"task-description",className:"text-sm font-medium",children:"Opening prompt"}),e.jsx("textarea",{id:"task-description",value:w,onChange:S=>p(S.target.value),onKeyDown:m,onPaste:ie,placeholder:"Describe what the agent should do. This becomes the first message in the chat.",rows:6,autoFocus:N,className:"flex min-h-[144px] w-full resize-none rounded-[22px] border border-border/70 bg-background/70 px-4 py-3 text-sm leading-6 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs($,{type:"button",variant:"outline",onClick:V,className:"rounded-[16px]",children:[e.jsx(Bs,{className:"h-4 w-4"}),"Add images"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Ctrl/Cmd+Enter starts the chat. Enter adds a new line. Upload or paste screenshots and reference images with the opening prompt."})]}),A,Y&&e.jsx("p",{className:"text-xs text-destructive",children:Y})]}),e.jsxs("div",{className:"grid gap-5 lg:grid-cols-[minmax(0,1fr)_220px_220px]",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"task-title",className:"text-sm font-medium",children:"Chat title"}),e.jsx(Be,{id:"task-title",type:"text",value:u,onChange:S=>b(S.target.value),placeholder:"Optional. Leave blank to derive it from the prompt.",className:"h-11 rounded-[18px] border-border/70 bg-background/70"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:H?`Will appear as: ${H}`:"A title will be generated from the first line of the prompt."})]}),ke,ye]}),y,me,e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[we,K]}),e.jsxs("div",{className:E("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",v),children:[i&&e.jsx($,{type:"button",variant:"ghost",onClick:i,className:"rounded-[16px]",children:j}),e.jsx($,{type:"submit",disabled:!ue||B,className:"rounded-[16px] px-5",children:B?"Creating...":k})]})]})}function Fo({nodes:s,currentNodeRole:a,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,defaultMode:x="chat",mode:v,onModeChange:k,layout:j="default",className:N,footerClassName:d,autoFocus:u=!1}){const[b,w]=t.useState(x),p=v!==void 0,P=p?v:b,M=_=>{p||w(_),k==null||k(_)};return e.jsxs("div",{className:E("space-y-4",N),children:[!p&&e.jsxs("div",{className:"flex items-center gap-2 rounded-[20px] border border-border/60 bg-background/45 p-1",children:[e.jsxs($,{type:"button",variant:P==="chat"?"default":"ghost",onClick:()=>M("chat"),className:"flex-1 rounded-[16px]",children:[e.jsx(on,{className:"h-4 w-4"}),"New chat"]}),e.jsxs($,{type:"button",variant:P==="native"?"default":"ghost",onClick:()=>M("native"),className:"flex-1 rounded-[16px]",children:[e.jsx(Xs,{className:"h-4 w-4"}),"Load session"]})]}),P==="chat"?e.jsx($o,{nodes:s,currentNodeRole:a,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,footerClassName:d,submitLabel:j==="composer"?"Start chat":"Create chat",cancelLabel:"Cancel",autoFocus:u,layout:j}):e.jsx(Mo,{nodes:s,currentNodeRole:a,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,footerClassName:d,autoFocus:u})]})}const Ze="72f988bf-86f1-41af-91ab-2d7cd011db47",ma=`${Ze} (MSIT)`;function Oo({open:s,onOpenChange:a,onShare:n,onStopShare:o,sharing:r,stopping:i=!1,shareResult:x}){return e.jsx(Bt,{open:s,onOpenChange:a,children:e.jsxs(Ft,{className:"max-w-md rounded-[22px] p-5",children:[e.jsx(Ot,{className:"sr-only",children:"Share conversation"}),e.jsx(Io,{onOpenChange:a,onShare:n,onStopShare:o,sharing:r,stopping:i,shareResult:x})]})})}function Io({onOpenChange:s,onShare:a,onStopShare:n,sharing:o,stopping:r=!1,shareResult:i}){const[x,v]=t.useState((i==null?void 0:i.tenant)??Ze),[k,j]=t.useState((i==null?void 0:i.scope)??"chat"),N=(i==null?void 0:i.url)??null,d=o||r;return t.useEffect(()=>{v((i==null?void 0:i.tenant)??Ze),j((i==null?void 0:i.scope)??"chat")},[i==null?void 0:i.shareId,i==null?void 0:i.tenant,i==null?void 0:i.scope]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h2",{className:"text-base font-semibold leading-none tracking-tight",children:"Share conversation"}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"Create a tenant-gated link for this task."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(Bo,{value:x,onChange:v,disabled:d}),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(Et,{active:k==="chat",title:"Chat only",description:"Conversation transcript and opening prompt.",onClick:()=>j("chat")}),e.jsx(Et,{active:k==="filesPreview",title:"Chat, files and preview",description:"Transcript plus task output files and HTML preview.",onClick:()=>j("filesPreview")})]})]}),N&&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-[16px] border border-border/70 bg-muted/30 px-3 py-2",children:[e.jsx("input",{readOnly:!0,value:N,className:"min-w-0 flex-1 bg-transparent font-mono text-xs text-foreground outline-none","aria-label":"Shared link"}),e.jsx($,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-[12px] text-muted-foreground",onClick:()=>void Qe(N,"Shared link copied"),"aria-label":"Copy shared link",title:"Copy shared link",children:e.jsx(zt,{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($,{variant:"outline",onClick:()=>s(!1),disabled:d,className:"h-8 text-xs",children:i?"Done":"Cancel"}),i&&n&&e.jsxs($,{variant:"outline",onClick:()=>void n(),disabled:d,className:"h-8 border-destructive/30 text-xs text-destructive hover:bg-destructive/10 hover:text-destructive",children:[r&&e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}),"Stop share"]}),e.jsxs($,{onClick:()=>void a({tenant:x,scope:k}),disabled:d,className:"h-8 text-xs",children:[o&&e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}),i?"Update link":"Share link"]})]})]})}function Bo({value:s,onChange:a,disabled:n}){const[o,r]=t.useState(!1),[i,x]=t.useState(!1),[v,k]=t.useState(s),j=t.useRef(null);t.useEffect(()=>{k(s)},[s]),t.useEffect(()=>{if(!o)return;const d=b=>{var p;const w=b.target;w instanceof Node&&((p=j.current)!=null&&p.contains(w)||(r(!1),x(!1)))},u=b=>{b.key==="Escape"&&(r(!1),x(!1))};return document.addEventListener("mousedown",d),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",u)}},[o]);const N=d=>{const u=d.trim();u&&(a(u),k(u),x(!1),r(!1))};return e.jsxs("div",{className:"space-y-2 text-xs",ref:j,children:[e.jsx("div",{className:"font-medium text-foreground",children:"Tenant"}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>!n&&r(d=>!d),disabled:n,className:"flex h-9 w-full items-center justify-between gap-2 rounded-[15px] 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:zo(s)}),e.jsx(Ge,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})]}),o&&e.jsxs("div",{className:"absolute left-0 right-0 z-50 mt-2 overflow-hidden rounded-[18px] border border-border/60 bg-background/95 text-xs shadow-lg backdrop-blur",children:[e.jsxs("button",{type:"button",onClick:()=>N(Ze),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:ma}),s===Ze&&e.jsx(as,{className:"h-3.5 w-3.5 shrink-0 text-primary"})]}),e.jsx("div",{className:"border-t border-border/60 bg-background/40 px-2.5 py-1.5",children:i?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{value:v,onChange:d=>k(d.target.value),onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),N(v))},autoFocus:!0,placeholder:"Tenant ID",className:"h-7 min-w-0 flex-1 rounded-[11px] 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:()=>N(v),className:"flex h-7 w-7 items-center justify-center rounded-[11px] hover:bg-background/60",children:e.jsx(as,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{k(s),x(!1)},className:"flex h-7 w-7 items-center justify-center rounded-[11px] text-muted-foreground hover:bg-background/60 hover:text-foreground",children:e.jsx(We,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>x(!0),className:"flex h-7 w-full items-center justify-between rounded-[11px] 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(is,{className:"h-3 w-3"})]})})]})]})]})}function zo(s){return s===Ze?ma:s}function Et({active:s,title:a,description:n,onClick:o}){return e.jsxs("button",{type:"button",onClick:o,className:s?"rounded-[15px] border border-primary/45 bg-primary/10 px-3 py-2 text-left shadow-sm":"rounded-[15px] 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:a}),e.jsx("div",{className:"mt-1 text-[11px] leading-4 text-muted-foreground",children:n})]})}const Uo=t.lazy(async()=>({default:(await Ys(()=>import("./FilesTab-Z7ofEslt.js"),__vite__mapDeps([0,1,2,3,4]))).FilesTab})),Vo=t.lazy(async()=>({default:(await Ys(()=>import("./PreviewTab-2MoQNLMM.js"),__vite__mapDeps([5,1,2,6]))).PreviewTab})),Ho=t.lazy(async()=>({default:(await Ys(()=>import("./DiffTab-CAEFXyW_.js"),__vite__mapDeps([7,1,2,4,3,8,6]))).DiffTab}));function Ko({onToggleTasks:s,desktopTasksOpen:a,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:x,activeTab:v,setActiveTab:k,creatingTask:j,createMode:N,activeTask:d,assignedNode:u,taskLoading:b,taskError:w,displayEvents:p,initialPromptAlreadyInLogs:P,initialPrompt:M,supportsFollowUp:_,taskUnavailable:X,chatDisabled:Q,chatDisabledReason:re,questionBypassEnabled:F,isRunning:R,isStarting:q,hasPendingFollowUp:L,canCancel:O,canRetry:C,onRetry:U,onCancel:ne,onShareTask:B,onStopShareTask:z,onStartCreateTask:I,onCancelCreateTask:J,onCreateTask:se,onSendMessage:Y,onQuestionBypassChange:Z,onSubmitQuestionResponse:V,messagesEndRef:ae}){const[ie,c]=t.useState(!1),[D,g]=t.useState(!1),[G,h]=t.useState(!1),[oe,H]=t.useState(!1),[ue,m]=t.useState(!1),[A,K]=t.useState({}),[ke,ye]=t.useState(new Set),[we,y]=t.useState(new Set),me=t.useRef(0),S=t.useRef(!1),W=t.useRef(null),le=t.useRef(0),Me=t.useCallback(Ee=>{const ve=Ee.currentTarget,fe=me.current;if(me.current=ve.scrollTop,S.current)return;if(ve.scrollHeight-ve.scrollTop-ve.clientHeight<30){c(!1),S.current=!0,setTimeout(()=>{S.current=!1},300);return}ve.scrollTop<fe&&fe-ve.scrollTop>10&&c(!0),ve.scrollTop<=0&&c(!0)},[]),Le=(d==null?void 0:d.effectiveProjectPath)??(d==null?void 0:d.project)??"default workspace",ce=d?(u==null?void 0:u.name)??Ut(d.assignedTo,i==null?void 0:i.nodes,d.assignedNodeName):"unassigned",Ve=d!=null&&d.assignedTo?e.jsxs(e.Fragment,{children:["Connecting session on node ",e.jsx("span",{className:"font-medium text-foreground",children:ce}),"..."]}):"Connecting session to an available node...",Je=d?[{label:"Working dir",value:Le,mono:!0},...d.branch?[{label:"Branch",value:d.branch,mono:!0}]:[],{label:"Agent",value:d.agent,mono:!0},{label:"Node",value:ce}]:[],je=!!(M&&!P),ze=je||p.length>0,ss=R&&ze,Ie=(q||L||R)&&!ss,$e=(d==null?void 0:d.conversationKind)==="nativeSession",gs=d&&!ke.has(d.id)?A[d.id]??d.activeShare??null:null;return j?e.jsx(qo,{onToggleTasks:s,desktopTasksOpen:a,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:x,defaultMode:N,onCancel:J,onCreated:se}):!d&&b?e.jsxs("div",{className:"dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-[28px]",children:[e.jsx("div",{className:"shrink-0 border-b border-border/55 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(Ks,{onToggleTasks:s,desktopTasksOpen:a,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:x})}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-6 py-10 sm:px-8",children:e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-[22px] border border-primary/20 bg-primary/10 text-primary shadow-sm",children:e.jsx(be,{className:"h-7 w-7 animate-spin"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-2xl font-semibold tracking-tight text-foreground",children:"Loading conversation"}),e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[11px] text-muted-foreground",children:[e.jsx(be,{className:"h-4 w-4 animate-spin"}),"Fetching the selected chat thread..."]})]})]})})]}):d?e.jsxs(Vt,{value:v,onValueChange:Ee=>{v==="transcript"&&W.current&&(le.current=W.current.scrollTop),k(Ee),Ee==="transcript"&&requestAnimationFrame(()=>{W.current&&(W.current.scrollTop=le.current)})},className:"dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-[28px]",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/55 bg-card/28 px-3 py-3 sm:px-5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ha,{desktopTasksOpen:a,mobileTasksPanelOpen:n,onToggleTasks:s}),e.jsx("h2",{className:"min-w-0 truncate text-sm font-semibold tracking-tight text-foreground sm:text-lg",title:d.title,children:d.title}),$e&&e.jsx(Ae,{variant:"outline",className:"shrink-0 rounded-[11px] border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300",children:"Native session"}),e.jsx(Ht,{status:d.status}),e.jsx(dn,{priority:d.priority}),e.jsx($,{variant:"outline",size:"icon",onClick:r,title:o?"Hide cluster":"Show cluster","aria-label":o?"Hide cluster":"Show cluster",className:"ml-auto h-7 w-7 shrink-0 rounded-[12px] border-border/70 bg-background/68",children:o?e.jsx(Zs,{className:"h-4 w-4"}):e.jsx(ta,{className:"h-4 w-4"})})]}),w&&e.jsx("div",{className:"mt-2 w-fit rounded-[12px] border border-destructive/25 bg-destructive/10 px-2 py-1 text-[11px] text-destructive",children:w}),e.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[e.jsxs(Kt,{className:"h-auto max-w-full overflow-x-auto rounded-[16px] bg-muted/70 p-0.5",children:[e.jsx(He,{value:"transcript",className:"rounded-[12px] px-2 py-0.5 text-[11px] sm:px-2.5",children:"Transcript"}),e.jsx(He,{value:"files",className:"rounded-[12px] px-2 py-0.5 text-[11px] sm:px-2.5",children:"Files"}),e.jsx(He,{value:"preview",className:"rounded-[12px] px-2 py-0.5 text-[11px] sm:px-2.5",children:"Preview"}),e.jsx(He,{value:"diff",className:"rounded-[12px] px-2 py-0.5 text-[11px] sm:px-2.5",children:"Diff"})]}),R&&e.jsx(Ae,{variant:"outline",className:"hidden rounded-[11px] border-amber-500/30 bg-amber-500/10 text-amber-700 sm:inline-flex dark:text-amber-300",children:"Working"}),X&&e.jsx(Ae,{variant:"outline",className:"hidden rounded-[11px] border-destructive/25 bg-destructive/10 text-destructive sm:inline-flex",children:"Unavailable"}),e.jsxs("div",{className:"ml-auto flex items-center gap-2 text-[10px] text-muted-foreground",children:[e.jsxs("span",{className:"hidden sm:inline",children:["updated ",cn(d.updatedAt)]}),e.jsx("span",{className:"font-mono",children:d.id.slice(0,8)}),C&&e.jsxs($,{variant:"outline",size:"sm",onClick:U,className:"h-7 shrink-0 rounded-[12px] px-2 text-[11px]",children:[e.jsx(Ur,{className:"h-3.5 w-3.5"}),"Retry"]}),e.jsxs($,{type:"button",variant:"outline",size:"sm",disabled:X,title:X?"Unavailable tasks cannot be shared.":"Share conversation",className:"h-7 shrink-0 rounded-[12px] border-primary/30 bg-primary/10 px-2 text-[11px] text-primary hover:bg-primary/15 hover:text-primary disabled:border-border/60 disabled:bg-muted/40 disabled:text-muted-foreground",onClick:()=>h(!0),children:[e.jsx(qr,{className:"h-3.5 w-3.5"}),"Share"]})]})]})]}),e.jsx(Ke,{value:"transcript",className:"mt-0 min-h-0 flex-1",children:e.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[e.jsx("div",{ref:W,className:"min-h-0 flex-1 touch-pan-y overflow-x-hidden overflow-y-auto overscroll-x-none bg-gradient-to-b from-background/15 via-transparent to-background/35 px-3 py-5 sm:px-5",onScroll:Me,children:e.jsxs("div",{className:"mx-auto flex max-w-[72rem] flex-col gap-5",children:[je&&M&&e.jsx(jt,{event:M,questionBypassEnabled:F,onQuestionBypassChange:Z,onSubmitQuestionResponse:V,questionResponseDisabled:!_||Q}),p.map((Ee,ve)=>e.jsx(jt,{event:Ee,questionBypassEnabled:F,onQuestionBypassChange:Z,onSubmitQuestionResponse:V,questionResponseDisabled:!_||Q},rr("transcript",Ee,ve))),!ze&&!Ie&&e.jsxs("div",{className:"rounded-[28px] border border-dashed border-border/70 bg-background/35 px-5 py-8 text-center",children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground",children:"Transcript is warming up"}),e.jsx("div",{className:"mt-2 text-[11px] leading-6 text-muted-foreground",children:b?"Fetching task output...":$e?"This native session is attached. Transcript starts after the next message you send from Meshy.":"The opening prompt has been stored, but the agent has not emitted conversation output yet."})]}),(!_&&d.result||d.error)&&e.jsxs("div",{className:"space-y-3",children:[!_&&d.result&&e.jsxs("div",{className:"rounded-[26px] 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(d.result,null,2)})]}),d.error&&!we.has(d.id)&&e.jsxs("div",{className:"rounded-[26px] 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:()=>y(Ee=>new Set(Ee).add(d.id)),className:"rounded p-0.5 hover:bg-destructive/20","aria-label":"Dismiss error",children:e.jsx(We,{className:"h-3.5 w-3.5"})})]}),e.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-[11px] leading-5",children:d.error})]})]}),Ie&&e.jsx(_t,{children:Ve}),ss&&e.jsx(_t,{children:"The agent is still working on this conversation."}),e.jsx("div",{ref:ae})]})}),_?e.jsxs(e.Fragment,{children:[ie&&e.jsx($,{size:"icon",onClick:()=>c(!1),className:"absolute bottom-4 right-4 z-10 h-12 w-12 rounded-[18px] shadow-lg",children:e.jsx(is,{className:"h-4 w-4"})}),e.jsx("div",{className:`shrink-0 ${ie?"hidden":""}`,children:e.jsx("div",{className:"mx-auto w-full max-w-[72rem]",children:e.jsx(mo,{onSend:Y,disabled:Q,disabledReason:re,contextItems:Je,placeholder:Q?re:"Continue the conversation...",running:R||L,onStop:O?()=>g(!0):void 0})})})]}):e.jsx("div",{className:"shrink-0 border-t border-border/60 px-3 py-3 text-[11px] text-muted-foreground sm:px-5",children:"This task does not expose follow-up chat messages. Use Files, Preview, or Diff to inspect the result."})]})}),e.jsx(Ke,{value:"files",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(t.Suspense,{fallback:e.jsx(Ts,{label:"Loading files..."}),children:e.jsx(Uo,{taskId:d.id})})}),e.jsx(Ke,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(t.Suspense,{fallback:e.jsx(Ts,{label:"Loading preview..."}),children:e.jsx(Vo,{taskId:d.id})})}),e.jsx(Ke,{value:"diff",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(t.Suspense,{fallback:e.jsx(Ts,{label:"Loading diff..."}),children:e.jsx(Ho,{taskId:d.id})})}),e.jsx(Ds,{open:D,onOpenChange:g,children:e.jsxs(As,{children:[e.jsxs(Ms,{children:[e.jsx(Ls,{children:"Stop this task?"}),e.jsx(Ps,{children:"The task will stop and move to a cancelled state."})]}),e.jsxs(Rs,{children:[e.jsx($s,{children:"Keep running"}),e.jsx(Fs,{onClick:ne,children:"Stop task"})]})]})}),e.jsx(Oo,{open:G,onOpenChange:h,sharing:oe,stopping:ue,shareResult:gs,onShare:async Ee=>{if(!d)return null;H(!0);try{const ve=await B(Ee);return ve!=null&&ve.url&&(K(fe=>({...fe,[d.id]:ve})),ye(fe=>{const ts=new Set(fe);return ts.delete(d.id),ts})),ve}finally{H(!1)}},onStopShare:async()=>{if(!d)return!1;m(!0);try{const Ee=await z();return Ee!==!1&&(K(ve=>{const fe={...ve};return delete fe[d.id],fe}),ye(ve=>new Set(ve).add(d.id))),Ee}finally{m(!1)}}})]}):e.jsxs("div",{className:"dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-[28px]",children:[e.jsx("div",{className:"shrink-0 border-b border-border/55 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(Ks,{onToggleTasks:s,desktopTasksOpen:a,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:x})}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-6 py-10 sm:px-8",children:e.jsxs("div",{className:"w-full max-w-2xl text-center",children:[e.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-[22px] border border-primary/20 bg-primary/10 text-primary shadow-sm",children:e.jsx(Gs,{className:"h-7 w-7"})}),e.jsx("h2",{className:"mt-5 text-xl font-semibold tracking-tight text-foreground sm:text-3xl",children:"No chat selected"}),e.jsx("p",{className:"mx-auto mt-3 max-w-xl text-[11px] leading-6 text-muted-foreground",children:"Open a task from the left sidebar to continue the conversation, or start a new task or load a native session."}),e.jsxs($,{onClick:I,className:"mt-6 rounded-[18px] px-5",children:[e.jsx(Qs,{className:"h-4 w-4"}),"Start or load chat"]}),w&&e.jsx("div",{className:"mx-auto mt-4 max-w-lg rounded-[20px] border border-destructive/20 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:w})]})})]})}function _t({children:s}){return e.jsxs("div",{className:"flex items-center gap-1.5 rounded-[18px] border border-border/60 bg-background/55 px-3 py-2 text-[11px] text-muted-foreground shadow-sm",children:[e.jsx(be,{className:"h-4 w-4 shrink-0 animate-spin"}),e.jsx("div",{className:"min-w-0 leading-5",children:s})]})}function qo({onToggleTasks:s,desktopTasksOpen:a,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:x,defaultMode:v,onCancel:k,onCreated:j}){var b,w,p;const[N,d]=t.useState(v??"chat");t.useEffect(()=>{v&&d(v)},[v]);const u=e.jsx("div",{className:"flex items-center gap-1 rounded-[18px] border border-border/60 bg-background/65 p-0.5 text-[11px] font-medium shadow-sm",children:[{value:"chat",label:"New chat",icon:Qs},{value:"native",label:"Load session",icon:Xs}].map(P=>{const M=P.icon,_=P.value===N;return e.jsxs("button",{type:"button",onClick:()=>d(P.value),"aria-pressed":_,className:E("flex items-center gap-1.5 rounded-[14px] px-2 py-1 transition-all duration-200",_?"bg-primary text-primary-foreground shadow-[0_8px_24px_-12px_hsl(var(--primary)/0.7)]":"text-muted-foreground hover:bg-background/80 hover:text-foreground"),children:[e.jsx(M,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:P.label})]},P.value)})});return e.jsxs("div",{className:"dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-[28px]",children:[e.jsx("div",{className:"shrink-0 border-b border-border/55 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(Ks,{onToggleTasks:s,desktopTasksOpen:a,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:x,centerSlot:u})}),e.jsx("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center overflow-y-auto px-6 py-10 sm:px-8",children:e.jsx("div",{className:"w-full max-w-2xl",children:e.jsx(Fo,{nodes:(i==null?void 0:i.nodes)??[],currentNodeRole:(b=i==null?void 0:i.self)==null?void 0:b.role,currentNodeId:((w=i==null?void 0:i.self)==null?void 0:w.id)??null,leaderNodeId:((p=i==null?void 0:i.leader)==null?void 0:p.id)??null,mode:N,onModeChange:d,onCreated:j,onCancel:k,autoFocus:!0,layout:"composer"})})})]})}function Ks({onToggleTasks:s,desktopTasksOpen:a,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,centerSlot:i}){return e.jsxs("div",{className:"relative flex w-full items-center justify-between gap-1.5",children:[e.jsx("div",{className:"flex min-w-0 items-center gap-1.5",children:e.jsx(ha,{desktopTasksOpen:a,mobileTasksPanelOpen:n,onToggleTasks:s})}),i&&e.jsx("div",{className:"pointer-events-none absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",children:e.jsx("div",{className:"pointer-events-auto",children:i})}),e.jsx($,{variant:"outline",size:"icon",onClick:r,title:o?"Hide cluster":"Show cluster","aria-label":o?"Hide cluster":"Show cluster",className:"h-7 w-7 shrink-0 rounded-[12px] border-border/70 bg-background/68",children:o?e.jsx(Zs,{className:"h-4 w-4"}):e.jsx(ta,{className:"h-4 w-4"})})]})}function ha({desktopTasksOpen:s,mobileTasksPanelOpen:a,onToggleTasks:n}){var r,i;const o=(i=(r=globalThis.window)==null?void 0:r.matchMedia("(min-width: 1024px)"))!=null&&i.matches?s:a;return e.jsx($,{variant:"outline",size:"icon",onClick:n,title:o?"Hide tasks":"Show tasks","aria-label":o?"Hide tasks":"Show tasks",className:"h-7 w-7 shrink-0 rounded-[12px] border-border/70 bg-background/68",children:o?e.jsx(sa,{className:"h-4 w-4"}):e.jsx(Rr,{className:"h-4 w-4"})})}const Wo=10,qe="__all__";function Re(s){return"session"in s}function Dt(s,a){var n;return a&&s.some(o=>o.id===a)?a:((n=s[0])==null?void 0:n.id)??""}function _s(s){return s&&(ca(s.id)||s.workDir)||""}function ms(s,a,n){let o=!1;const r=s.map(i=>Re(i)&&i.session.id===n.id?(o=!0,{...i,nodeName:a,session:n}):i);return qs(o?r:[...r,{id:`session-${n.id}`,nodeName:a,session:n}])}function pa(s,a){return s.filter(Re).filter(n=>n.session.nodeId===a).sort((n,o)=>o.session.startedAt-n.session.startedAt)}function Go(s){const a=s.filter(Re).sort((n,o)=>o.session.startedAt-n.session.startedAt);return{active:a.filter(n=>n.session.status==="running"),completed:a.filter(n=>n.session.status!=="running")}}function Jo(s,a){return!!(s&&a&&!s.contains(a))}function Yo(s,a,n){var r;if(n===qe)return n;const o=pa(s,a);return o.some(i=>i.session.id===n)?n:((r=o[0])==null?void 0:r.session.id)??qe}function Xo(s,a,n){return n===qe?s.filter(o=>!Re(o)||o.session.nodeId===a):s.filter(o=>Re(o)&&o.session.nodeId===a&&o.session.id===n)}function qs(s){const a=s.map((o,r)=>({entry:o,index:r})).filter(({entry:o})=>Re(o)&&o.session.status!=="running").sort((o,r)=>!Re(o.entry)||!Re(r.entry)?0:r.entry.session.startedAt-o.entry.session.startedAt||r.index-o.index),n=new Set(a.slice(0,Wo).map(({entry:o})=>Re(o)?o.session.id:""));return s.filter(o=>!Re(o)||o.session.status==="running"||n.has(o.session.id))}function Ws(s){return s.status==="running"?s.pid?`running pid ${s.pid}`:"running":s.status==="exited"?`exit ${s.exitCode??0}`:s.status==="stopped"?"stopped":s.signal?`failed ${s.signal}`:`exit ${s.exitCode??"failed"}`}function Qo(s){const a=s.session.command.length>48?`${s.session.command.slice(0,45)}...`:s.session.command;return`${s.nodeName} - ${Ws(s.session)} - ${a}`}function fa(s,a=48){return s.length>a?`${s.slice(0,a-3)}...`:s}function Zo(s,a){return a===qe?"All sessions":s?fa(s.session.command,34):"Command session"}function At(s){return s.status==="stopped"?"":s.stderr}function ei({nodes:s,defaultNodeId:a,onClose:n,initialHistory:o=[]}){const[r,i]=t.useState(()=>Dt(s,a)),x=t.useMemo(()=>s.find(c=>c.id===r)??s[0]??null,[s,r]),[v,k]=t.useState(()=>_s(x)),[j,N]=t.useState(""),[d,u]=t.useState(()=>qs(o)),[b,w]=t.useState(qe),[p,P]=t.useState(!1),[M,_]=t.useState(!1),[X,Q]=t.useState(!1),[re,F]=t.useState(!1),[R,q]=t.useState(!1),L=t.useRef(null),O=t.useRef(null),C=t.useMemo(()=>s.find(c=>c.id===r)??s[0]??null,[s,r]),U=t.useMemo(()=>pa(d,(C==null?void 0:C.id)??""),[d,C]),ne=t.useMemo(()=>Go(U),[U]),B=t.useMemo(()=>U.find(c=>c.session.id===b),[b,U]),z=t.useMemo(()=>Xo(d,(C==null?void 0:C.id)??"",b),[d,C,b]),I=t.useRef((C==null?void 0:C.id)??"");t.useEffect(()=>{r&&s.some(c=>c.id===r)||i(Dt(s,a))},[a,s,r]),t.useEffect(()=>{const c=(C==null?void 0:C.id)??"";I.current!==c&&(I.current=c,k(_s(C)))},[C]),t.useEffect(()=>{w(c=>Yo(d,(C==null?void 0:C.id)??"",p?c:""))},[d,C,p]),t.useEffect(()=>{var c;(c=L.current)==null||c.scrollTo({top:L.current.scrollHeight})},[d]),t.useEffect(()=>{let c=!1;async function D(){const g=await Promise.allSettled(s.map(async G=>({node:G,response:await xn(G.id)})));c||u(G=>g.reduce((h,oe)=>oe.status!=="fulfilled"?h:oe.value.response.sessions.reduce((H,ue)=>ms(H,oe.value.node.name,ue),h),G))}return s.length>0&&D(),()=>{c=!0}},[s]),t.useEffect(()=>{const c=d.filter(Re).filter(g=>g.session.status==="running");if(c.length===0)return;const D=window.setInterval(()=>{for(const g of c)un(g.session.nodeId,g.session.id).then(G=>u(h=>ms(h,g.nodeName,G))).catch(()=>{})},1e3);return()=>window.clearInterval(D)},[d]);const J=t.useRef(null);async function se(c){if(c.preventDefault(),!C||!j.trim()||R)return;const D=j.trim(),g=C.name;q(!0),N("");try{const G=await hn(C.id,{command:D,...v.trim()?{cwd:v.trim()}:{}});u(h=>ms(h,g,G)),w(G.id),P(!0)}catch(G){u(h=>[...h,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,nodeName:g,command:D,error:G instanceof Error?G.message:"Command failed"}])}finally{q(!1)}}async function Y(c,D){c.stopPropagation();const g=await mn(D.session.nodeId,D.session.id);u(G=>ms(G,D.nodeName,g))}function Z(c){w(c),P(!0),_(!1)}function V(c){M&&Jo(O.current,c.target)&&_(!1)}function ae(c,D,g,G,h){return e.jsxs("div",{className:"border-t border-border/60 py-1",children:[e.jsxs("button",{type:"button",onClick:G,"aria-label":`Toggle ${c} sessions`,"aria-expanded":!g,className:"flex w-full items-center justify-between gap-2 px-2 pb-1 pt-0.5 text-left text-[10px] 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(Ge,{className:E("h-3 w-3 transition-transform",g&&"-rotate-90")})]}),!g&&(D.length>0?D.map(ie):e.jsx("div",{className:"px-2 py-1 text-[11px] text-muted-foreground",children:h}))]})}function ie(c){const D=b===c.session.id,g=c.session.status==="running";return e.jsxs("div",{className:E("group flex w-full items-center gap-2 px-2 py-1.5 text-left text-[11px] transition-colors hover:bg-muted/65",D&&"bg-primary/10 text-primary"),children:[e.jsxs("button",{type:"button",onClick:()=>Z(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:E("flex h-4 w-4 shrink-0 items-center justify-center",g?"text-primary":c.session.status==="exited"?"text-emerald-600 dark:text-emerald-300":"text-amber-600 dark:text-amber-300"),children:g?e.jsx(be,{className:"h-3 w-3 animate-spin"}):c.session.status==="exited"?e.jsx(ft,{className:"h-3 w-3"}):e.jsx(hs,{className:"h-3 w-3"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-foreground",children:fa(c.session.command,44)}),e.jsxs("span",{className:"block truncate text-[10px] text-muted-foreground",children:[c.nodeName," · ",Ws(c.session)]})]})]}),g&&e.jsx("button",{type:"button",onClick:G=>void Y(G,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(wt,{className:"h-3 w-3"})})]},c.session.id)}return e.jsx("section",{className:"dashboard-panel animate-composer-settle shrink-0 overflow-visible rounded-[24px]","aria-label":"Node terminal",onClick:V,children:e.jsxs("div",{className:"flex 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:"flex min-w-0 items-center gap-2 text-[11px] 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(Cs,{className:"h-3.5 w-3.5"})}):e.jsx(Cs,{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:O,className:"relative min-w-0",children:[e.jsxs("button",{type:"button","aria-label":"Command session","aria-expanded":M,title:B?Qo(B):"All sessions",onClick:()=>_(c=>!c),className:"flex h-7 max-w-[14rem] list-none items-center gap-1.5 rounded-[10px] border border-border/70 bg-background/70 px-2 text-[11px] 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:Zo(B,b)}),e.jsx(Ge,{className:E("h-3 w-3 shrink-0 text-muted-foreground transition-transform",M&&"rotate-180")})]}),e.jsx("div",{"aria-hidden":!M,className:E("absolute right-0 bottom-9 z-30 w-[19rem] overflow-hidden rounded-xl border border-border/70 bg-popover text-popover-foreground shadow-xl",!M&&"hidden"),children:e.jsxs("div",{className:"max-h-72 overflow-y-auto",children:[e.jsxs("button",{type:"button",onClick:()=>Z(qe),className:E("flex w-full items-center gap-2 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",b===qe&&"bg-primary/10 text-primary"),children:[e.jsx(Cs,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:"All sessions"})]}),ae("Active",ne.active,X,()=>Q(c=>!c),"No active sessions"),ae("Completed",ne.completed,re,()=>F(c=>!c),"No completed sessions")]})})]}),e.jsx("select",{value:(C==null?void 0:C.id)??"",onChange:c=>{i(c.target.value),P(!1),k(_s(s.find(D=>D.id===c.target.value)??null))},disabled:R||s.length===0,"aria-label":"Terminal node",className:"h-7 max-w-[11rem] rounded-[10px] border border-border/70 bg-background/70 px-2 text-[11px] text-foreground outline-none transition-colors hover:bg-muted/65 disabled:opacity-50",children:s.map(c=>e.jsx("option",{value:c.id,className:"bg-background text-foreground",children:c.name},c.id))}),e.jsx(fs,{value:v,onChange:k,assignTo:(C==null?void 0:C.id)??"",nodes:s,assignableNodes:s,layout:"composer",chipClassName:"h-7 max-w-[18rem] rounded-[10px] border border-border/70 bg-background/70 px-2 text-[11px] text-foreground hover:bg-muted/65",chipActiveClassName:"font-mono",chipInactiveClassName:"text-muted-foreground",labelClassName:"text-[11px]",triggerClassName:"terminal-workdir-trigger",popoverPlacement:"top",popoverAlign:"end"})]})]}),e.jsxs("div",{ref:L,className:"max-h-64 min-h-[8rem] overflow-y-auto bg-muted/22 px-3 py-2 font-mono text-[11px] leading-5 cursor-text",onClick:()=>{var c;return(c=J.current)==null?void 0:c.focus()},children:[z.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:z.map(c=>Re(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:E("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(be,{className:"h-3 w-3 animate-spin"}):c.session.status==="exited"?e.jsx(ft,{className:"h-3 w-3"}):e.jsx(hs,{className:"h-3 w-3"}),Ws(c.session)]}),c.session.status==="running"&&e.jsx("button",{type:"button",onClick:D=>void Y(D,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(wt,{className:"h-3 w-3"})})]}),c.session.stdout&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-foreground",children:c.session.stdout}),At(c.session)&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:At(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(hs,{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:se,className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"shrink-0 text-primary select-none",children:C?`${C.name}$`:"$"}),e.jsx("input",{ref:J,value:j,onChange:c=>N(c.target.value),disabled:!C||R,placeholder:C?"":"No online nodes available",className:"flex-1 min-w-0 bg-transparent border-none outline-none text-foreground placeholder:text-muted-foreground font-mono text-[11px] caret-primary disabled:opacity-50",autoComplete:"off",spellCheck:!1}),e.jsx("button",{type:"submit","aria-label":"Run",title:"Run",disabled:!C||!j.trim()||R,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:R?e.jsx(be,{className:"h-3 w-3 animate-spin"}):e.jsx(mr,{className:"h-3 w-3"})})]})]})]})})}function tt({nodeId:s,nodeName:a,onOpenSettings:n,className:o}){const[r,i]=t.useState(!1),x=t.useRef(null);return t.useEffect(()=>{if(!r)return;const v=j=>{var d;const N=j.target;N instanceof Node&&((d=x.current)!=null&&d.contains(N)||i(!1))},k=j=>{j.key==="Escape"&&i(!1)};return document.addEventListener("mousedown",v),document.addEventListener("keydown",k),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("keydown",k)}},[r]),e.jsxs("div",{ref:x,className:E("relative shrink-0",o),onClick:v=>v.stopPropagation(),children:[e.jsx($,{type:"button",variant:"ghost",size:"icon","aria-label":`More actions for ${a}`,"aria-haspopup":"menu","aria-expanded":r,title:`More actions for ${a}`,onClick:()=>i(v=>!v),className:E("h-6 w-6 rounded-[10px] text-muted-foreground hover:bg-background/70 hover:text-foreground",r&&"bg-background/80 text-primary"),children:e.jsx(vr,{className:"h-3.5 w-3.5"})}),r&&e.jsx("div",{role:"menu",className:"absolute right-0 top-full z-30 mt-1 min-w-28 overflow-hidden rounded-[13px] border border-border/65 bg-popover/96 p-1 shadow-[0_18px_48px_-28px_rgba(0,0,0,0.45)] backdrop-blur-xl",children:e.jsxs("button",{type:"button",role:"menuitem","aria-label":`Open ${a} settings`,title:`Open ${a} settings`,onClick:()=>{i(!1),n(s)},className:"flex w-full items-center gap-1.5 rounded-[10px] px-2 py-1.5 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80",children:[e.jsx(pn,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:"Settings"})]})})]})}function Mt({cluster:s,systemInfo:a,nodeNameById:n,nodeBlockingTaskCounts:o,eventTypeFilter:r,onEventTypeFilterChange:i,eventTypeOptions:x,filteredEvents:v,sseConnected:k,clusterLoading:j,clusterError:N,promotePending:d,onPromote:u,onAddNode:b,leavePending:w,onLeaveCluster:p,onToggleNodeDevTunnel:P,devTunnelNodeId:M,onOpenNodeSettings:_,onClose:X}){var ne,B,z;const Q=((ne=s==null?void 0:s.self)==null?void 0:ne.role)==="leader",re=((B=s==null?void 0:s.self)==null?void 0:B.role)==="follower"&&!(s!=null&&s.leader),F=(s==null?void 0:s.self)??null,q=fn((s==null?void 0:s.nodes)??[],F==null?void 0:F.id).filter(I=>I.id!==(F==null?void 0:F.id)),L=s!=null&&s.leader?s.nodes.find(I=>{var J;return I.id===((J=s.leader)==null?void 0:J.id)})??null:null,O=s!=null&&s.leader?s.leader.dashboardOrigin??(L==null?void 0:L.dashboardOrigin)??(a&&s.leader.id===(a.nodeId??a.id)?a.dashboardOrigin:void 0)??s.leader.endpoint:null,C=(F==null?void 0:F.role)==="leader"&&q.length===0,U=(F==null?void 0:F.role)==="follower";return e.jsx("aside",{className:"dashboard-panel dashboard-panel-muted animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-[28px]",children:e.jsxs(Vt,{defaultValue:"overview",className:"flex h-full min-h-0 flex-col",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/55 bg-card/24 px-3 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-semibold tracking-tight",children:"Operations"}),e.jsx("p",{className:"mt-0.5 text-[10px] text-muted-foreground",children:"Node, cluster, and live events."})]}),e.jsx($,{variant:"ghost",size:"icon",onClick:X,className:"h-7 w-7 rounded-[12px]",children:e.jsx(Zs,{className:"h-4 w-4"})})]}),e.jsxs(Kt,{className:"mt-2 grid h-auto w-full grid-cols-3 rounded-[16px] bg-muted/70 p-0.5",children:[e.jsx(He,{value:"overview",className:"rounded-[12px] px-2 py-0.5 text-[11px]",children:"Overview"}),e.jsx(He,{value:"nodes",className:"rounded-[12px] px-2 py-0.5 text-[11px]",children:"Nodes"}),e.jsx(He,{value:"events",className:"rounded-[12px] px-2 py-0.5 text-[11px]",children:"Live events"})]})]}),e.jsx(Ke,{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-3 py-3",children:e.jsxs("div",{className:"space-y-4",children:[F&&e.jsx(Lt,{node:F,systemInfo:a,blockingTaskCount:o.get(F.id)??0,devTunnelNodeId:M,onToggleNodeDevTunnel:P,showActions:!1,defaultExpanded:!1}),e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground",children:"Cluster snapshot"}),e.jsx(Ae,{variant:"outline",className:"rounded-[11px] border-border/70 bg-background/60",children:k?"Connected":"Reconnecting"})]}),j&&!s?e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[e.jsx(be,{className:"h-4 w-4 animate-spin"}),"Loading cluster state..."]}):N&&!s?e.jsx("div",{className:"rounded-[18px] border border-destructive/20 bg-destructive/10 px-2.5 py-2 text-[11px] text-destructive",children:N}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(Xe,{label:"Term",value:String((s==null?void 0:s.term)??0)}),e.jsx(Xe,{label:"Nodes",value:String((s==null?void 0:s.nodes.length)??0)}),e.jsx(Xe,{label:"Pending",value:String((s==null?void 0:s.taskSummary.pending)??0)}),e.jsx(Xe,{label:"Running",value:String((s==null?void 0:s.taskSummary.running)??0)}),e.jsx(Xe,{label:"Completed",value:String((s==null?void 0:s.taskSummary.completed)??0)}),e.jsx(Xe,{label:"Failed",value:String((s==null?void 0:s.taskSummary.failed)??0)})]}),e.jsxs("div",{className:"space-y-2 rounded-[18px] border border-border/60 bg-background/52 px-2.5 py-2.5 shadow-sm",children:[e.jsx(Oe,{label:"Leader",value:((z=s==null?void 0:s.leader)==null?void 0:z.name)??"None"}),e.jsx(Oe,{label:"Leader URL",value:O??"Unavailable",mono:!0,action:O?e.jsx(os,{label:"Copy leader URL",onClick:()=>void Qe(O,"Leader URL copied")}):void 0}),e.jsx(Oe,{label:"Feed",value:k?"Receiving live updates":"Reconnecting to event stream"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:re&&e.jsxs($,{variant:"outline",size:"sm",onClick:u,disabled:d,className:"h-7 rounded-[12px] px-2.5 text-[11px]",children:[d&&e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}),"Promote self"]})})]})]})]})})}),e.jsx(Ke,{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-3 py-3",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground",children:"This node"}),C?e.jsx($,{variant:"outline",size:"sm",onClick:b,className:"h-7 rounded-[12px] px-2.5 text-[11px]",children:"Join node"}):U?e.jsxs($,{variant:"outline",size:"sm",onClick:p,disabled:w,className:"h-7 rounded-[12px] px-2.5 text-[11px]",children:[w&&e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}),"Leave cluster"]}):null]}),F&&e.jsx(Lt,{node:F,systemInfo:a,blockingTaskCount:o.get(F.id)??0,devTunnelNodeId:M,onToggleNodeDevTunnel:P,showActions:!0,defaultExpanded:!0,onOpenNodeSettings:Q?_:void 0})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"text-[11px] font-medium text-foreground",children:["Peer nodes (",q.length,")"]}),q.length>0?e.jsx("div",{className:"space-y-2",children:q.map(I=>e.jsx(si,{node:I,isLeader:!!Q,blockingTaskCount:o.get(I.id)??0,devTunnelNodeId:M,onToggleNodeDevTunnel:P,onOpenNodeSettings:Q?_:void 0},I.id))}):e.jsx("div",{className:"rounded-[20px] border border-dashed border-border/70 bg-background/35 px-3 py-3 text-[11px] text-muted-foreground",children:"No peer nodes are connected yet."})]})]})})}),e.jsx(Ke,{value:"events",className:"mt-0 min-h-0 flex-1",children:e.jsxs("div",{className:"flex h-full min-h-0 flex-col px-3 py-3",children:[e.jsxs("div",{className:"mb-3 space-y-2",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium text-foreground",children:[e.jsx(gn,{className:E("h-4 w-4",k?"text-emerald-500":"text-destructive")}),"Live events"]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsxs(Se,{value:r,onValueChange:i,children:[e.jsx(Ce,{className:"h-7 min-w-[11rem] flex-1 rounded-[13px] border-border/70 bg-background/60 text-[11px] sm:max-w-[15rem]",children:e.jsx(Pe,{placeholder:"Event type"})}),e.jsx(Te,{children:x.map(I=>e.jsx(ge,{value:I,className:"text-[11px]",children:I==="all"?"All event types":I},I))})]}),e.jsx(Ae,{variant:"outline",className:"rounded-[11px] border-border/70 bg-background/60",children:k?"Connected":"Reconnecting"})]})]}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(bn,{events:v,maxHeight:"100%",emptyTitle:r==="all"?"No live events yet":"No matching events",emptyDescription:r==="all"?"Cluster activity appears here as it happens.":`No "${r}" events are in the current stream.`,nodeNameById:n})})]})})]})})}function Lt({node:s,systemInfo:a,blockingTaskCount:n,devTunnelNodeId:o,onToggleNodeDevTunnel:r,showActions:i=!0,defaultExpanded:x=!1,onOpenNodeSettings:v}){const[k,j]=t.useState(x),N=(a==null?void 0:a.dashboardOrigin)??s.dashboardOrigin,d=s.devtunnelEndpoint??s.endpoint,u=N??s.endpoint,b=(a==null?void 0:a.workDir)??s.workDir,w=ra(s,a==null?void 0:a.transportType),p=et(s,a==null?void 0:a.transportType),P=p&&es((a==null?void 0:a.transportType)??s.transportType)?!0:na(s,a==null?void 0:a.transportType),M=n>0;return e.jsxs("section",{className:"rounded-[22px] border border-primary/20 bg-primary/8 shadow-[0_24px_80px_-60px_hsl(var(--primary)/0.9)]",children:[e.jsxs("div",{className:"w-full px-3 py-2 text-left",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>j(_=>!_),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[k?e.jsx(Ge,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):e.jsx(ns,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx(qt,{status:s.status}),e.jsx("span",{className:"text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:"Current node"})]}),e.jsx("a",{href:u,target:"_blank",rel:"noreferrer",className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(Wt,{className:"h-3.5 w-3.5"})}),v&&e.jsx(tt,{nodeId:s.id,nodeName:s.name,onOpenSettings:v})]}),e.jsxs("button",{type:"button",onClick:()=>j(_=>!_),className:"mt-1.5 flex min-w-0 items-center gap-1.5 pl-6 text-left",children:[e.jsx("span",{className:"text-[11px] font-semibold tracking-tight text-foreground",children:s.name}),e.jsx(Gt,{role:s.role}),e.jsx(Ae,{variant:"outline",className:"rounded-[11px] border-primary/30 bg-background/60 text-[10px] capitalize",children:s.status})]})]}),k&&e.jsxs("div",{className:"space-y-3 border-t border-primary/15 px-3 pb-3 pt-2.5",children:[e.jsxs("div",{className:"space-y-2 rounded-[16px] border border-primary/20 bg-background/72 px-2 py-2 shadow-sm",children:[e.jsx(Oe,{label:"Node ID",value:s.id,mono:!0}),N&&e.jsx(Oe,{label:"Dashboard",value:N,mono:!0,action:e.jsx(os,{label:"Copy dashboard URL",onClick:()=>void Qe(N,"Dashboard URL copied")})}),e.jsx(Oe,{label:"Node URL",value:d,mono:!0,action:e.jsx(os,{label:"Copy node URL",onClick:()=>void Qe(d,"Node URL copied")})}),b&&e.jsx(Oe,{label:"Workspace",value:b,mono:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1.5",children:[e.jsx(Os,{label:"Transport",value:w}),a&&e.jsx(Os,{label:"Uptime",value:vn(a.uptime),mono:!0})]}),e.jsx(Qt,{capabilities:s.capabilities,action:i&&P?e.jsxs($,{variant:"outline",size:"sm",onClick:()=>r(s),disabled:o===s.id||M,className:"h-7 rounded-[12px] px-2.5 text-[11px]",title:M?"Finish assigned or running tasks before changing remote access":void 0,children:[o===s.id&&e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}),p?"Disable Remote Access":"Enable Remote Access"]}):void 0}),i&&P&&M&&e.jsxs("div",{className:"text-[11px] text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function si({node:s,isLeader:a,blockingTaskCount:n,devTunnelNodeId:o,onToggleNodeDevTunnel:r,onOpenNodeSettings:i}){const[x,v]=t.useState(!1),k=s.dashboardOrigin,j=s.devtunnelEndpoint??s.endpoint,N=k??s.endpoint,d=ra(s),u=et(s),b=na(s),w=n>0;return e.jsxs("div",{className:"rounded-[18px] border border-border/60 bg-background/50 shadow-sm",children:[e.jsxs("div",{className:"w-full px-3 py-2 text-left",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>v(p=>!p),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[x?e.jsx(Ge,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(ns,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx(qt,{status:s.status}),e.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:"Peer node"})]}),e.jsx("a",{href:N,target:"_blank",rel:"noreferrer",className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(Wt,{className:"h-3.5 w-3.5"})}),a&&i&&e.jsx(tt,{nodeId:s.id,nodeName:s.name,onOpenSettings:i})]}),e.jsxs("button",{type:"button",onClick:()=>v(p=>!p),className:"mt-1 flex min-w-0 items-center gap-1.5 pl-5 text-left",children:[e.jsx("span",{className:"text-[11px] font-semibold text-foreground",children:s.name}),e.jsx(Gt,{role:s.role}),e.jsx(Ae,{variant:"outline",className:"rounded-[11px] border-border/70 bg-background/60 text-[10px] capitalize",children:s.status})]})]}),x&&e.jsxs("div",{className:"space-y-3 border-t border-border/50 px-3 pb-3 pt-2.5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Oe,{label:"Node ID",value:s.id,mono:!0}),k&&e.jsx(Oe,{label:"Dashboard",value:k,mono:!0,action:e.jsx(os,{label:"Copy dashboard URL",onClick:()=>void Qe(k,"Dashboard URL copied")})}),e.jsx(Oe,{label:"Node URL",value:j,mono:!0,action:e.jsx(os,{label:"Copy node URL",onClick:()=>void Qe(j,"Node URL copied")})}),s.workDir&&e.jsx(Oe,{label:"Workspace",value:s.workDir,mono:!0}),e.jsx(Os,{label:"Transport",value:d})]}),e.jsx(Qt,{capabilities:s.capabilities,action:a&&b?e.jsxs($,{variant:"outline",size:"sm",onClick:()=>r(s),disabled:o===s.id||w,className:"h-7 rounded-[12px] px-2.5 text-[11px]",title:w?"Finish assigned or running tasks before changing remote access":void 0,children:[o===s.id&&e.jsx(be,{className:"h-3.5 w-3.5 animate-spin"}),u?"Disable Remote Access":"Enable Remote Access"]}):void 0}),a&&b&&w&&e.jsxs("div",{className:"text-[11px] text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function os({label:s,onClick:a}){return e.jsx($,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-[12px] text-muted-foreground",onClick:a,"aria-label":s,title:s,children:e.jsx(zt,{className:"h-3.5 w-3.5"})})}function ti(s,a,n,o){var x;if(!s)return{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Select a task to continue the conversation."};const r=((x=a==null?void 0:a.self)==null?void 0:x.role)==="follower";return s.assignedTo!==null&&s.assignedNodeAvailable===!1?{taskUnavailable:!0,chatDisabled:!0,chatDisabledReason:`${s.assignedNodeName??"Assigned node"} is unavailable. Leave the cluster on that node or re-run the task elsewhere.`}:r?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Follower nodes are read-only. Use the leader dashboard to manage chat, or leave the cluster first."}:n||o?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Waiting for the current turn to finish..."}:ps.has(s.status)||s.status==="archived"?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:ps.has(s.status)?"Task has not started yet...":"Archived tasks are read-only."}:{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Continue the conversation..."}}function Pt({toolbarTasks:s,activeTaskId:a,tasksLoading:n,tasksError:o,isLeader:r,scope:i,agentFilter:x,nodeFilter:v,taskKindFilter:k,agentOptions:j,nodeOptions:N,nodeNameById:d,nodeStatusById:u,leaderNodeId:b,searchQuery:w,selectedTaskIds:p,allVisibleTasksSelected:P,someVisibleTasksSelected:M,canBatchArchive:_,onSearchChange:X,onScopeChange:Q,onAgentFilterChange:re,onNodeFilterChange:F,onTaskKindFilterChange:R,onToggleTaskSelected:q,onToggleAllVisibleTasks:L,onBatchArchive:O,onBatchDelete:C,onCreateTask:U,onOpenNodeSettings:ne,onSelectTask:B,onClose:z}){const[I,J]=t.useState(!!w),[se,Y]=t.useState(!1),[Z,V]=t.useState(!1),ae=t.useRef(null),ie=t.useRef(null),c=t.useRef(null),D=p.size,g=i!=="active"||v!=="all"||x!=="all"||k!=="all",G=w.trim().length>0,[h,oe]=t.useState(new Set),[H,ue]=t.useState(new Set),m=t.useMemo(()=>jn(s,d,b),[s,d,b]),A=m.length===1,K=!A||g||G,ke=A&&(g||G),ye=t.useCallback(y=>{oe(me=>{const S=new Set(me);return S.has(y)?S.delete(y):S.add(y),S})},[]),we=t.useCallback(y=>{ue(me=>{const S=new Set(me);return S.has(y)?S.delete(y):S.add(y),S})},[]);return t.useEffect(()=>{w&&J(!0)},[w]),t.useEffect(()=>{var y;I&&((y=ae.current)==null||y.focus())},[I]),t.useEffect(()=>{if(!I)return;const y=S=>{var le;const W=S.target;W instanceof Node&&((le=ie.current)!=null&&le.contains(W)||J(!1))},me=S=>{S.key==="Escape"&&J(!1)};return document.addEventListener("mousedown",y),document.addEventListener("keydown",me),()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",me)}},[I]),t.useEffect(()=>{if(!Z)return;const y=S=>{var le;const W=S.target;W instanceof Node&&((le=c.current)!=null&&le.contains(W)||V(!1))},me=S=>{S.key==="Escape"&&V(!1)};return document.addEventListener("mousedown",y),document.addEventListener("keydown",me),()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",me)}},[Z]),e.jsxs("aside",{className:"dashboard-panel dashboard-panel-muted animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-[28px]",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/55 bg-card/24 px-3 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[e.jsx("div",{className:"text-lg font-semibold tracking-tight text-foreground",children:"Tasks"}),e.jsx($,{variant:"ghost",size:"icon",onClick:z,className:"rounded-[12px]",children:e.jsx(sa,{className:"h-4 w-4"})})]}),e.jsxs("div",{ref:ie,className:"mt-4 flex items-center gap-1.5",children:[e.jsxs("div",{ref:c,className:E("relative flex items-stretch transition-[flex] duration-200",I?"flex-[2]":"flex-1"),children:[e.jsxs($,{onClick:()=>{V(!1),U("chat")},className:"h-11 flex-1 justify-start rounded-l-[18px] rounded-r-none px-3 text-left shadow-[0_18px_48px_-30px_hsl(var(--primary)/0.95)]",children:[e.jsx(Qs,{className:"h-4 w-4"}),"New chat"]}),e.jsx($,{onClick:()=>V(y=>!y),"aria-label":"More chat options","aria-haspopup":"menu","aria-expanded":Z,className:"h-11 w-9 rounded-l-none rounded-r-[18px] border-l border-primary-foreground/20 px-0 shadow-[0_18px_48px_-30px_hsl(var(--primary)/0.95)]",children:e.jsx(Ge,{className:E("h-3.5 w-3.5 transition-transform",Z&&"rotate-180")})}),Z&&e.jsx("div",{role:"menu",className:"absolute left-0 right-0 top-full z-20 mt-2 overflow-hidden rounded-[18px] border border-border/60 bg-popover/96 p-1 shadow-[0_20px_60px_-30px_rgba(0,0,0,0.45)] backdrop-blur-xl",children:e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{V(!1),U("native")},className:"flex w-full items-center gap-1.5 rounded-[13px] px-2 py-2 text-left text-[11px] font-medium text-foreground transition-colors hover:bg-muted/80",children:[e.jsx(Xs,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{className:"flex-1 truncate whitespace-nowrap",children:"Load session"}),e.jsx("span",{className:"shrink-0 text-[9px] uppercase tracking-[0.18em] text-muted-foreground",children:"native"})]})})]}),I?e.jsxs("div",{className:"flex min-w-0 flex-[3] items-center gap-1.5",children:[e.jsxs("div",{className:"relative min-w-0 flex-1",children:[e.jsx(zs,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(Be,{ref:ae,value:w,onChange:y=>X(y.target.value),placeholder:"Search tasks",className:"h-11 rounded-[18px] border-border/70 bg-background/68 pl-11 text-[11px]"})]}),e.jsx($,{variant:"outline",size:"icon",onClick:()=>J(!1),className:"rounded-[14px] border-border/70 bg-background/68",children:e.jsx(hs,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs($,{variant:"outline",onClick:()=>J(!0),className:E("rounded-[14px] border-border/70 bg-background/68 px-3 text-[11px]",w&&"border-primary/40 bg-primary/8 text-primary"),children:[e.jsx(zs,{className:"h-4 w-4"}),"Search"]}),e.jsx($,{variant:se||g?"secondary":"outline",size:"icon",onClick:()=>Y(y=>!y),className:E("shrink-0 rounded-[14px] border-border/70 bg-background/68",g&&"border-primary/40 bg-primary/8 text-primary"),title:"Filters",children:e.jsx(wr,{className:"h-4 w-4"})})]})]}),(se||g)&&e.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:[e.jsxs(Se,{value:i,onValueChange:y=>Q(y),children:[e.jsx(Ce,{className:"h-7 rounded-[13px] border-border/70 bg-background/60 text-[12px]",children:e.jsx(Pe,{})}),e.jsx(Te,{children:Nn.map(y=>e.jsx(ge,{value:y.value,className:"text-[12px]",children:y.label},y.value))})]}),e.jsxs(Se,{value:v,onValueChange:F,children:[e.jsx(Ce,{className:"h-7 rounded-[13px] border-border/70 bg-background/60 text-[12px]",children:e.jsx(Pe,{placeholder:"Node"})}),e.jsx(Te,{children:N.map(y=>e.jsx(ge,{value:y.value,className:"text-[12px]",children:y.label},y.value))})]}),e.jsxs(Se,{value:x,onValueChange:re,children:[e.jsx(Ce,{className:"h-7 rounded-[13px] border-border/70 bg-background/60 text-[12px]",children:e.jsx(Pe,{placeholder:"Agent"})}),e.jsx(Te,{children:j.map(y=>e.jsx(ge,{value:y,className:"text-[12px]",children:y==="all"?"All agents":y},y))})]}),e.jsxs(Se,{value:k,onValueChange:y=>R(y),children:[e.jsx(Ce,{className:"h-7 rounded-[13px] border-border/70 bg-background/60 text-[12px]",children:e.jsx(Pe,{placeholder:"Type"})}),e.jsx(Te,{children:kn.map(y=>e.jsx(ge,{value:y.value,className:"text-[12px]",children:y.label},y.value))})]})]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-2 py-2",children:m.length>0?e.jsxs("div",{className:"space-y-1",children:[r&&e.jsxs("div",{className:"mb-1 flex items-center justify-between px-1 py-1",children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:[e.jsx(gt,{checked:M&&!P?"indeterminate":P,onCheckedChange:y=>L(y===!0),"aria-label":"Select all visible tasks"}),e.jsx("span",{children:"Select all"})]}),D>0&&e.jsx($,{variant:"ghost",size:"sm",onClick:()=>L(!1),className:"h-7 rounded-[12px] px-2 text-[11px]",children:"Clear"})]}),m.map(y=>{const me=y.nodeId??"__unassigned__",S=y.dirs.reduce((Le,ce)=>Le+ce.tasks.length,0),W=K&&!ke&&h.has(me),le=y.nodeId!==null&&u.get(y.nodeId)==="offline",Me=!!(r&&y.nodeId&&ne);return e.jsxs("div",{className:"space-y-1",children:[K&&e.jsxs("div",{className:"flex w-full items-center gap-1.5 rounded-[15px] bg-gradient-to-r from-primary/8 to-muted/20 px-2 py-1.5 text-left text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground transition-all duration-150 hover:from-primary/12 hover:to-muted/30 hover:text-foreground active:scale-[0.99] active:from-primary/15",children:[e.jsxs("button",{type:"button",onClick:()=>ye(me),"aria-expanded":!W,className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[e.jsx(ns,{className:E("h-3.5 w-3.5 shrink-0 transition-transform duration-200",!W&&"rotate-90")}),e.jsxs("span",{className:"min-w-0 flex items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0 truncate",children:y.nodeName}),e.jsxs(Ae,{variant:"outline",className:"rounded-[8px] border-border/60 bg-background/55 px-1.5 py-0 text-[8px] font-semibold leading-4 text-muted-foreground shadow-none normal-case tracking-normal",children:[S," task",S===1?"":"s"]})]})]}),e.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[le&&e.jsx(Ae,{variant:"outline",className:"rounded-[8px] border-destructive/25 bg-destructive/10 px-1 py-0 text-[8px] font-semibold leading-3 text-destructive shadow-none",children:"offline"}),y.nodeId===b&&e.jsx(Ae,{variant:"outline",className:"rounded-[9px] border-primary/25 bg-primary/8 px-1.5 py-0 text-[9px] font-semibold leading-4 text-primary shadow-none",children:"leader"}),Me&&y.nodeId&&ne&&e.jsx(tt,{nodeId:y.nodeId,nodeName:y.nodeName,onOpenSettings:ne})]})]}),e.jsx("div",{className:E("grid transition-[grid-template-rows] duration-300 ease-in-out",W?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:"overflow-hidden",children:y.dirs.map(Le=>{const ce=`${me}::${Le.path}`,Ve=H.has(ce),Je=wn(Le.path);return e.jsxs("div",{className:E("space-y-0.5 rounded-xl",K&&"pl-3"),children:[e.jsxs("button",{type:"button",onClick:()=>we(ce),"aria-expanded":!Ve,title:Le.path,className:"flex w-full items-center gap-1.5 rounded-[12px] bg-muted/15 px-2 py-1 text-left text-[10px] font-medium text-muted-foreground/70 transition-all duration-150 hover:bg-muted/30 hover:text-foreground active:scale-[0.98] active:bg-muted/40",children:[e.jsx(ns,{className:E("h-3 w-3 shrink-0 transition-transform duration-200",!Ve&&"rotate-90")}),e.jsx("span",{className:"truncate font-mono",children:Je}),e.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-muted-foreground/40",children:Le.tasks.length})]}),e.jsx("div",{className:E("grid transition-[grid-template-rows] duration-300 ease-in-out",Ve?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:E("overflow-hidden",K?"pl-2":"pl-0"),children:e.jsx("div",{className:"space-y-1.5 border-l border-border/35 py-1 pl-2.5 ml-1.5",children:Le.tasks.map(je=>e.jsxs("div",{className:E("flex items-center gap-1.5 rounded-[18px] border px-2.5 py-1.5 transition-all duration-200","hover:-translate-y-px",je.id===a?"border-primary/45 bg-primary/9 shadow-[0_24px_80px_-54px_hsl(var(--primary)/0.95)]":"border-border/58 bg-background/46 hover:border-border hover:bg-background/70 hover:shadow-[0_10px_28px_-18px_rgba(0,0,0,0.35)]"),children:[r&&e.jsx("div",{className:"flex shrink-0",onClick:ze=>ze.stopPropagation(),children:e.jsx(gt,{checked:p.has(je.id),onCheckedChange:ze=>q(je.id,ze===!0),"aria-label":`Select ${je.title}`})}),e.jsxs("button",{type:"button",onClick:()=>B(je.id),className:"min-w-0 flex-1 text-left",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:E("h-1.5 w-1.5 shrink-0 rounded-full",yn(je.status),(je.status==="running"||je.status==="assigned")&&"animate-soft-status-pulse")}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:je.title}),e.jsx("span",{className:"ml-1 shrink-0 tabular-nums text-[10px] text-muted-foreground/55",children:Sn(je.updatedAt)})]}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-1 pl-3",children:[e.jsx(Ht,{status:je.status}),e.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/60",children:je.agent}),je.conversationKind==="nativeSession"&&e.jsx(Ae,{variant:"outline",className:"border-sky-500/25 bg-sky-500/10 text-[10px] text-sky-700 dark:text-sky-300",children:"native"}),je.activeShare&&e.jsx(Ae,{variant:"outline",className:"border-primary/25 bg-primary/10 text-[10px] text-primary",children:"shared"}),je.assignedNodeAvailable===!1&&e.jsx(Ae,{variant:"outline",className:"border-destructive/25 bg-destructive/10 text-[10px] text-destructive",children:"unavailable"})]})]})]},je.id))})})})]},ce)})})})]},me)})]}):n?e.jsx("div",{className:"space-y-2 px-1",children:[1,2,3].map(y=>e.jsx("div",{className:"rounded-[24px] 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+y*12}%`,animationDelay:`${y*120}ms`}}),e.jsx("div",{className:"h-2 w-24 animate-pulse rounded-full bg-muted-foreground/10",style:{animationDelay:`${y*120+60}ms`}})]})]})},y))}):e.jsx("div",{className:"rounded-[24px] border border-dashed border-border/70 bg-background/35 px-3 py-5 text-[11px] text-muted-foreground",children:o||"No tasks match this view."})}),r&&D>0?e.jsxs("div",{className:"shrink-0 border-t border-border/60 px-3 py-3",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:"Batch actions"}),e.jsxs("div",{className:"mt-2 text-[11px] font-semibold text-foreground",children:[D," task",D!==1?"s":""," selected"]}),!_&&e.jsx("div",{className:"mt-2 text-[11px] text-muted-foreground",children:"Only completed, failed, cancelled, or archived tasks can be archived."}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[e.jsxs(Ds,{children:[e.jsx(bt,{asChild:!0,children:e.jsxs($,{variant:"outline",size:"sm",disabled:!_,className:"rounded-[14px]",children:[e.jsx(pr,{className:"h-3.5 w-3.5"}),"Archive"]})}),e.jsxs(As,{children:[e.jsxs(Ms,{children:[e.jsxs(Ls,{children:["Archive ",D," task",D!==1?"s":"","?"]}),e.jsx(Ps,{children:"Archived tasks stay hidden from the default task view and can be reopened from the archived scope."})]}),e.jsxs(Rs,{children:[e.jsx($s,{children:"Cancel"}),e.jsx(Fs,{onClick:O,disabled:!_,children:"Archive"})]})]})]}),e.jsxs(Ds,{children:[e.jsx(bt,{asChild:!0,children:e.jsxs($,{variant:"destructive",size:"sm",className:"rounded-[14px]",children:[e.jsx(Xr,{className:"h-3.5 w-3.5"}),"Delete"]})}),e.jsxs(As,{children:[e.jsxs(Ms,{children:[e.jsxs(Ls,{children:["Delete ",D," task",D!==1?"s":"","?"]}),e.jsx(Ps,{children:"This removes the selected tasks and their saved logs."})]}),e.jsxs(Rs,{children:[e.jsx($s,{children:"Cancel"}),e.jsx(Fs,{onClick:C,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}):null]})}async function ai(s,a){var n,o;try{const r=await Cn(s,a);if((o=(n=globalThis.navigator)==null?void 0:n.clipboard)!=null&&o.writeText)try{await globalThis.navigator.clipboard.writeText(r.url),pe.success("Shared link copied")}catch{pe.success("Shared link created")}else pe.success("Shared link created");return r}catch(r){pe.error(r instanceof Error?r.message:"Failed to create shared link");return}}async function ni(s){try{return await Tn(s),pe.success("Shared link stopped"),!0}catch(a){return pe.error(a instanceof Error?a.message:"Failed to stop shared link"),!1}}function ri(s,a,n){const o=t.useCallback(()=>{a(),n()},[a,n]),r=t.useCallback(async x=>{if(!s)return;const v=await ai(s.id,x);return v&&o(),v},[s,o]),i=t.useCallback(async()=>{if(!s)return!1;const x=await ni(s.id);return x&&o(),x},[s,o]);return{handleShareTask:r,handleStopShareTask:i}}function Rt(s,a,n){const o=t.useRef(a);o.current=a,t.useEffect(()=>{let x=0,v=0;const k=d=>{const u=d.touches[0];u&&(x=u.clientX,v=u.clientY)},j=d=>{var p,P,M,_;const u=d.changedTouches[0];if(!u)return;const b=u.clientX-x;Math.abs(u.clientY-v)>100||Math.abs(b)<50||(b>0?(P=(p=o.current).onSwipeRight)==null||P.call(p):(_=(M=o.current).onSwipeLeft)==null||_.call(M))},N=(s==null?void 0:s.current)??document;return N.addEventListener("touchstart",k,{passive:!0}),N.addEventListener("touchend",j,{passive:!0}),()=>{N.removeEventListener("touchstart",k),N.removeEventListener("touchend",j)}},[s,n==null?void 0:n.threshold,n==null?void 0:n.maxVertical])}const oi="(min-width: 1024px)",ii="(min-width: 1800px)";function $t(s){var a,n,o;return((o=(n=(a=globalThis.window)==null?void 0:a.matchMedia)==null?void 0:n.call(a,s))==null?void 0:o.matches)??!1}function li(){const[s,a]=t.useState(!0),[n,o]=t.useState(!1),[r,i]=t.useState(()=>$t(ii)),x=t.useRef(null),v=t.useRef(null);Rt(x,{onSwipeLeft:()=>o(!1)}),Rt(v,{onSwipeRight:()=>i(!1)});const k=t.useCallback(()=>{if($t(oi)){a(j=>!j);return}o(j=>!j)},[]);return{desktopTasksOpen:s,mobileTasksPanelOpen:n,mobileTasksPanelRef:x,operationsOpen:r,operationsPanelRef:v,setMobileTasksPanelOpen:o,setOperationsOpen:i,toggleTasksPanel:k}}function di(s,a){const n=a.taskId,o=a.updates;return typeof n!="string"||!o||typeof o!="object"?s:s.map(r=>r.id===n?{...r,...o}:r)}function ci({isLeader:s,selfId:a}){return{assignedTo:!s&&a?a:void 0}}function ui({isLeader:s,selfId:a,sseConnected:n,subscribe:o}){const[r,i]=t.useState([]),[x,v]=t.useState(!0),[k,j]=t.useState(null),N=t.useRef(null),d=t.useCallback(async()=>{try{const b=await En(ci({isLeader:s,selfId:a}));i(b),j(null)}catch(b){j(b instanceof Error?b.message:"Failed to load tasks")}finally{v(!1)}},[s,a]),u=t.useCallback(()=>{N.current===null&&(N.current=window.setTimeout(()=>{N.current=null,d()},_n))},[d]);return Dn(d,Ln(n)),t.useEffect(()=>()=>{N.current!==null&&(window.clearTimeout(N.current),N.current=null)},[]),t.useEffect(()=>{const b=[o("task.updated",w=>{i(p=>di(p,w.data))}),o("task.status",w=>{i(p=>An(p,w.data))}),o("task",w=>{Mn(w.type)&&u()})];return()=>b.forEach(w=>w())},[o,u]),{fetchTasks:d,setTasks:i,tasks:r,tasksError:k,tasksLoading:x}}function xi(s,a){return a.data.nodeId===s.self.id||a.data.name===s.self.name||a.data.endpoint===s.self.endpoint}function mi({cluster:s,subscribe:a}){t.useEffect(()=>{var n;if(((n=s==null?void 0:s.self)==null?void 0:n.role)==="leader")return a("node",o=>{const r=String(o.data.name??o.data.nodeId??"node"),i=xi(s,o);o.type==="node.joined"&&!i&&pe.success(`${r} joined the cluster`),o.type==="node.left"&&!i&&pe.message(`${r} left the cluster`)})},[s,a])}const hi=[0,300,1e3,2e3];function pi({task:s,getActiveTaskId:a,setLogs:n,setPendingMessages:o}){s.conversationKind==="nativeSession"&&(async()=>{for(const r of hi){if(r>0&&await new Promise(i=>setTimeout(i,r)),a()!==s.id)return;try{const i=await Jt(s.id);if(a()!==s.id||(n(x=>Zt(x,i.logs)),o(x=>ea(x,i.logs)),i.total>0))return}catch{}}})()}function fi(s){const[a,n]=t.useState(null),o=t.useCallback(i=>{s&&n(i)},[s]);return{nodeSettingsDialog:e.jsx(Pn,{open:a!==null,onOpenChange:i=>{i||n(null)},initialSelectedNodeId:a??void 0,showTrigger:!1}),openNodeSettings:o}}function gi(){var lt,dt,ct,ut,xt,mt;const{id:s}=Rn(),a=$n(),n=Fn(),o=On(),{cluster:r,systemInfo:i,events:x,sseConnected:v,subscribe:k,refresh:j,loading:N,error:d}=In(),u=t.useMemo(()=>Bn(a.state),[a.state]),[b,w]=t.useState(null),[p,P]=t.useState("active"),[M,_]=t.useState("all"),[X,Q]=t.useState("all"),[re,F]=t.useState("all"),[R,q]=t.useState(""),L=t.useDeferredValue(R),{desktopTasksOpen:O,mobileTasksPanelOpen:C,mobileTasksPanelRef:U,operationsOpen:ne,operationsPanelRef:B,setMobileTasksPanelOpen:z,setOperationsOpen:I,toggleTasksPanel:J}=li(),[se,Y]=t.useState(()=>!!(u!=null&&u.draftNewTask)),[Z,V]=t.useState(()=>(u==null?void 0:u.createMode)??"chat"),[ae,ie]=t.useState(()=>u!=null&&u.draftNewTask?{route:u.returnRoute??"/",taskId:u.returnTaskId??null}:null),[c,D]=t.useState(!1),[g,G]=t.useState("transcript"),[h,oe]=t.useState("all"),[H,ue]=t.useState(!1),[m,A]=t.useState(null),[K,ke]=t.useState([]),[ye,we]=t.useState([]),[y,me]=t.useState(!1),[S,W]=t.useState(null),[le,Me]=t.useState(new Set),[Le,ce]=t.useState(!1),[Ve,Je]=t.useState(!1),[je,ze]=t.useState(null),ss=t.useRef(null),Ie=t.useRef(null),$e=((lt=r==null?void 0:r.self)==null?void 0:lt.role)==="leader",gs=(dt=r==null?void 0:r.self)==null?void 0:dt.id;mi({cluster:r,subscribe:k});const{nodeSettingsDialog:Ee,openNodeSettings:ve}=fi($e),{fetchTasks:fe,setTasks:ts,tasks:Ue,tasksError:ga,tasksLoading:bs}=ui({isLeader:$e,selfId:gs,sseConnected:v,subscribe:k}),Ne=t.useMemo(()=>[...Ue].sort((l,f)=>f.updatedAt-l.updatedAt),[Ue]),ba=t.useMemo(()=>{const l=new Map;for(const f of(r==null?void 0:r.nodes)??[]){const T=Zr(Ne,f.id);T>0&&l.set(f.id,T)}return l},[r==null?void 0:r.nodes,Ne]),Fe=t.useMemo(()=>Ne.filter(l=>!zn(l,r==null?void 0:r.nodes,r==null?void 0:r.self)||!Un(l,p)||M!=="all"&&l.agent!==M||!Vn(l,re)||X==="unassigned"&&l.assignedTo||X!=="all"&&X!=="unassigned"&&Hn(l.assignedTo,r==null?void 0:r.nodes,l.assignedNodeName)!==X?!1:L.trim()?Kn(l,L):!0),[Ne,r==null?void 0:r.nodes,r==null?void 0:r.self,p,M,re,X,L]);t.useEffect(()=>{Me(l=>{const f=no(l,Fe.map(T=>T.id));return f.size===l.size?l:f})},[Fe]),t.useEffect(()=>{$e||Me(new Set)},[$e]);const va=t.useMemo(()=>["all",...Array.from(new Set(Ne.map(l=>l.agent))).sort()],[Ne]),ja=t.useMemo(()=>{const f=Array.from(new Set(Ne.map(T=>T.assignedTo).filter(T=>!!T))).map(T=>{const he=Ne.find(te=>te.assignedTo===T);return(r==null?void 0:r.nodes.find(te=>te.id===T))??{id:T,name:Ut(T,r==null?void 0:r.nodes,he==null?void 0:he.assignedNodeName)}}).sort((T,he)=>T.name.localeCompare(he.name));return[{value:"all",label:"All nodes"},{value:"unassigned",label:"Unassigned"},...f.map(T=>({value:T.name.toLowerCase(),label:T.name}))]},[Ne,r==null?void 0:r.nodes]),at=t.useMemo(()=>{const l=new Map;for(const f of(r==null?void 0:r.nodes)??[])l.set(f.id,f.name);for(const f of Ne)f.assignedTo&&f.assignedNodeName&&!l.has(f.assignedTo)&&l.set(f.assignedTo,f.assignedNodeName);return l},[r==null?void 0:r.nodes,Ne]),Na=t.useMemo(()=>{const l=new Map;for(const f of(r==null?void 0:r.nodes)??[])l.set(f.id,f.status);return r!=null&&r.self&&l.set(r.self.id,r.self.status),l},[r]),nt=t.useMemo(()=>{const l=new Map;for(const f of(r==null?void 0:r.nodes)??[])f.status!=="offline"&&l.set(f.id,f);return r!=null&&r.self&&r.self.status!=="offline"&&l.set(r.self.id,r.self),Array.from(l.values())},[r]),ka=((ct=r==null?void 0:r.self)==null?void 0:ct.id)??((ut=nt[0])==null?void 0:ut.id)??null,vs=t.useMemo(()=>["all",...Array.from(new Set(x.map(l=>l.type))).sort()],[x]),wa=t.useMemo(()=>h==="all"?x:x.filter(l=>l.type===h),[x,h]),ya=Fe.length>0&&Fe.every(l=>le.has(l.id)),Sa=Fe.some(l=>le.has(l.id)),Ca=ro(Fe,le);t.useEffect(()=>{u!=null&&u.draftNewTask&&(Y(!0),ie({route:u.returnRoute??"/",taskId:u.returnTaskId??null}))},[u]),t.useEffect(()=>{h!=="all"&&!vs.includes(h)&&oe("all")},[h,vs]),t.useEffect(()=>{yt(s,se)&&!b&&Ne[0]&&w(Ne[0].id)},[s,se,b,Ne]),t.useEffect(()=>{var l;yt(s,se)&&(b&&Ue.some(f=>f.id===b)||w(((l=Ne[0])==null?void 0:l.id)??null))},[s,se,b,Ne,Ue]);const de=so({routeTaskId:s,creatingTask:se,internalSelectedTaskId:b,sortedTaskIds:Ne.map(l=>l.id)}),Ye=t.useMemo(()=>Ue.find(l=>l.id===de)??null,[Ue,de]);t.useEffect(()=>{Ie.current=de??null},[de]);const ls=t.useCallback(()=>{A(null),ke([]),we([]),W(null)},[]),De=t.useCallback(async()=>{const l=de;if(l)try{const f=await qn(l);if(Ie.current!==l)return;A(f),W(null)}catch(f){if(Ie.current!==l)return;A(null),ke([]),we([]),W(f instanceof Error?f.message:"Failed to load task")}finally{Ie.current===l&&me(!1)}},[de]),ds=t.useCallback(async()=>{const l=de;if(l)try{const f=await Jt(l);if(Ie.current!==l)return;ke(T=>Zt(T,f.logs)),we(T=>ea(T,f.logs))}catch{}},[de]);t.useEffect(()=>{if(!de){A(null),ke([]),we([]),W(null),me(!1);return}G("transcript"),A(Ye),ke([]),we([]),W(null),me(!0),De(),ds()},[de,ds,De]),t.useEffect(()=>{var f;if(!de||se||bs||Ue.some(T=>T.id===de))return;const l=((f=Ne[0])==null?void 0:f.id)??null;w(l),ls(),t.startTransition(()=>{n(l?`/tasks/${l}`:"/",{state:null})})},[de,ls,se,n,Ne,Ue,bs]),t.useEffect(()=>{Ye&&A(l=>!l||l.id!==Ye.id?l:{...l,...Ye})},[Ye]),t.useEffect(()=>{if(de)return k("task",l=>{const f=l.data.taskId;if(!(typeof f!="string"||f!==de)){if(l.type==="task.output"){const T=l.data.event;if(T){ke(te=>or(te,T));const he=Nt(T);he&&we(te=>ir(te,he))}}l.type==="task.updated"&&De(),l.type==="task.status"&&(De(),ds())}})},[k,de,De,ds]),t.useEffect(()=>{var l;g==="transcript"&&((l=ss.current)==null||l.scrollIntoView({behavior:"smooth"}))},[K,ye,g]);const ee=m??Ye,Ta=ee!=null&&ee.assignedTo?(r==null?void 0:r.nodes.find(l=>l.id===ee.assignedTo))??null:null,js=ye.length>0,Ea=ee?Wn.has(ee.agent):!1,Ns=(ee==null?void 0:ee.status)==="running",_a=ee?ps.has(ee.status):!1,Da=ee?ps.has(ee.status)||Gn.has(ee.status):!1,Aa=!!(ee&&$e&&ee.status==="failed"),ks=t.useMemo(()=>ti(ee,r,js,!!Ns),[ee,r,js,Ns]),ws=t.useMemo(()=>lr([...K,...ye.map(l=>Es(l.content,l.timestamp))]),[K,ye]),cs=t.useMemo(()=>{if(!ee||ee.conversationKind==="nativeSession")return null;const l=dr(ee);if(l.length>0)return Es(l,new Date(ee.createdAt).toISOString());if(ws.length>0)return null;const f=cr(ee.description||ee.title);return f.length>0?Es(f,new Date(ee.createdAt).toISOString()):null},[ee,ws]),ys=t.useMemo(()=>cs?Nt(cs):null,[cs]),Ma=t.useMemo(()=>ys?ur(K,ys):!1,[K,ys]),Ss=t.useCallback((l="chat")=>{const f={route:s?`/tasks/${s}`:"/",taskId:de};ie(f),V(l),Y(!0),t.startTransition(()=>{n("/",{state:{draftNewTask:!0,returnRoute:f.route,returnTaskId:f.taskId,createMode:l}})})},[s,de,n]),La=t.useCallback(()=>{var f;const l=(ae==null?void 0:ae.taskId)??((f=Ne[0])==null?void 0:f.id)??null;Y(!1),ie(null),w(l),t.startTransition(()=>{n((ae==null?void 0:ae.route)??"/",{state:null})})},[ae,Ne,n]),rt=t.useCallback(l=>{Y(!1),ie(null),w(l),t.startTransition(()=>{n(`/tasks/${l}`,{state:null})})},[n]),Pa=t.useCallback(l=>{Ie.current=l.id,Y(!1),ie(null),ts(f=>to(f,l)),A(l),ke([]),we([]),W(null),me(!1),G("transcript"),w(l.id),pi({task:l,getActiveTaskId:()=>Ie.current,setLogs:ke,setPendingMessages:we}),fe(),t.startTransition(()=>{n(`/tasks/${l.id}`,{state:null})})},[fe,n]),us=t.useCallback(async l=>{if(!de)return!1;const f=`local-${Date.now()}-${Math.random().toString(16).slice(2)}`;we(T=>[...T,{id:f,content:l,timestamp:new Date().toISOString()}]);try{return await Jn(de,l),De(),!0}catch(T){return we(he=>he.filter(te=>te.id!==f)),pe.error(T instanceof Error?T.message:"Failed to send message"),!1}},[de,De]),Ra=t.useCallback(l=>{us(l)},[us]),$a=t.useCallback(l=>us(l),[us]),Fa=t.useCallback(async()=>{if(ee)try{await Yn(ee.id),De(),fe()}catch(l){pe.error(l instanceof Error?l.message:"Failed to cancel task")}},[ee,De,fe]),{handleShareTask:Oa,handleStopShareTask:Ia}=ri(ee,De,fe),Ba=t.useCallback(async()=>{if(ee)try{await Xn(ee.id),De(),fe()}catch(l){pe.error(l instanceof Error?l.message:"Failed to retry task")}},[ee,De,fe]),xs=t.useCallback((l,f=!1)=>{const T=oo(Fe,l);return w(T),(f||!T)&&ls(),t.startTransition(()=>{n(T?`/tasks/${T}`:"/",{state:null})}),T},[ls,Fe,n]),za=t.useCallback((l,f)=>{Me(T=>{const he=new Set(T);return f?he.add(l):he.delete(l),he})},[]),Ua=t.useCallback(l=>{if(!l){Me(new Set);return}Me(new Set(Fe.map(f=>f.id)))},[Fe]),Va=t.useCallback(async()=>{const l=Array.from(le);if(l.length!==0)try{const{results:f}=await Qn(l),T=f.filter(te=>!te.ok),he=f.filter(te=>te.ok).map(te=>te.id);de&&he.includes(de)&&xs(he),T.length>0?pe.error(`Failed to archive ${T.length} task(s): ${T.map(te=>te.error??te.id).join(", ")}`):pe.success(`Archived ${he.length} task(s)`),Me(new Set(T.map(te=>te.id))),fe()}catch(f){pe.error(f instanceof Error?f.message:"Failed to archive tasks")}},[de,fe,xs,le]),Ha=t.useCallback(async()=>{const l=Array.from(le);if(l.length!==0)try{const{results:f}=await Zn(l),T=f.filter(te=>!te.ok),he=f.filter(te=>te.ok).map(te=>te.id);de&&he.includes(de)&&xs(he,!0),T.length>0?pe.error(`Failed to delete ${T.length} task(s): ${T.map(te=>te.error??te.id).join(", ")}`):pe.success(`Deleted ${he.length} task(s)`),Me(new Set(T.map(te=>te.id))),fe()}catch(f){pe.error(f instanceof Error?f.message:"Failed to delete tasks")}},[de,fe,xs,le]),Ka=t.useCallback(async()=>{ce(!0);try{await er(),j()}catch(l){pe.error(l instanceof Error?l.message:"Failed to promote node")}finally{ce(!1)}},[j]),qa=t.useCallback(async()=>{Je(!0);try{await sr(),pe.success("This node left the remote cluster and is leading itself again."),fe(),De(),j()}catch(l){pe.error(l instanceof Error?l.message:"Failed to leave cluster")}finally{Je(!1)}},[De,fe,j]),Wa=t.useCallback(async l=>{var ht;const f=!et(l),T=l.id===((ht=r==null?void 0:r.self)==null?void 0:ht.id),he=T?(i==null?void 0:i.transportType)??l.transportType:l.transportType,te=T&&!f&&es(he);ze(l.id);try{te?await tr("direct"):await ar(l.id,f),pe.success(f?`Enabled remote access on ${l.name}`:`Disabled remote access on ${l.name}`),j()}catch(pt){pe.error(pt instanceof Error?pt.message:"Failed to update remote access")}finally{ze(null)}},[(xt=r==null?void 0:r.self)==null?void 0:xt.id,j,i==null?void 0:i.transportType]),ot={toolbarTasks:Fe,activeTaskId:de,tasksLoading:bs,tasksError:ga,isLeader:$e,scope:p,agentFilter:M,nodeFilter:X,taskKindFilter:re,agentOptions:va,nodeOptions:ja,nodeNameById:at,nodeStatusById:Na,leaderNodeId:((mt=r==null?void 0:r.leader)==null?void 0:mt.id)??null,searchQuery:R,selectedTaskIds:le,allVisibleTasksSelected:ya,someVisibleTasksSelected:Sa,canBatchArchive:Ca,onSearchChange:q,onScopeChange:P,onAgentFilterChange:_,onNodeFilterChange:Q,onTaskKindFilterChange:F,onToggleTaskSelected:za,onToggleAllVisibleTasks:Ua,onBatchArchive:Va,onBatchDelete:Ha,onCreateTask:Ss,onOpenNodeSettings:$e?ve:void 0,onSelectTask:rt,onClose:J},it={cluster:r,systemInfo:i,nodeNameById:at,nodeBlockingTaskCounts:ba,eventTypeFilter:h,onEventTypeFilterChange:oe,eventTypeOptions:vs,filteredEvents:wa,sseConnected:v,clusterLoading:N,clusterError:d,promotePending:Le,onPromote:Ka,onAddNode:()=>D(!0),leavePending:Ve,onLeaveCluster:qa,onToggleNodeDevTunnel:Wa,devTunnelNodeId:je,onOpenNodeSettings:$e?ve:void 0,onClose:()=>I(!1)};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden pb-2",children:[e.jsxs("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[e.jsx("div",{className:E("hidden lg:block lg:shrink-0 lg:transition-all lg:duration-300",O?"lg:mr-3 lg:w-[24rem]":"lg:w-0 lg:overflow-hidden"),children:O&&e.jsx(Pt,{...ot})}),e.jsxs("section",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-3",children:[e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(Ko,{onToggleTasks:J,desktopTasksOpen:O,mobileTasksPanelOpen:C,operationsOpen:ne,onToggleOperations:()=>I(l=>!l),cluster:r,sseConnected:v,activeTab:g,setActiveTab:G,creatingTask:se,createMode:Z,activeTask:ee,assignedNode:Ta,taskLoading:y,taskError:S,displayEvents:ws,initialPromptAlreadyInLogs:Ma,initialPrompt:cs,supportsFollowUp:Ea,taskUnavailable:ks.taskUnavailable,chatDisabled:ks.chatDisabled,chatDisabledReason:ks.chatDisabledReason,questionBypassEnabled:H,isRunning:!!Ns,isStarting:_a,hasPendingFollowUp:js,canCancel:!!Da,canRetry:!!Aa,onRetry:Ba,onCancel:Fa,onShareTask:Oa,onStopShareTask:Ia,onStartCreateTask:Ss,onCancelCreateTask:La,onCreateTask:Pa,onSendMessage:Ra,onQuestionBypassChange:ue,onSubmitQuestionResponse:$a,messagesEndRef:ss})}),(o==null?void 0:o.terminalOpen)&&e.jsx(ei,{nodes:nt,defaultNodeId:ka,onClose:()=>o==null?void 0:o.setTerminalOpen(!1)})]}),e.jsx("div",{className:E("hidden xl:block xl:shrink-0 xl:transition-all xl:duration-300",ne?"xl:ml-3 xl:w-[26rem]":"xl:w-0 xl:overflow-hidden"),children:ne&&e.jsx(Mt,{...it})})]}),ne&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close operations panel",onClick:()=>I(!1),className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm xl:hidden"}),e.jsx("div",{ref:B,className:"fixed inset-y-0 right-0 z-40 w-full p-2 sm:max-w-sm sm:p-3 xl:hidden",children:e.jsx(Mt,{...it})})]}),C&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close task list",onClick:()=>z(!1),className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm lg:hidden"}),e.jsx("div",{ref:U,className:"fixed inset-y-0 left-0 z-40 w-full p-2 sm:max-w-sm sm:p-3 lg:hidden",children:e.jsx(Pt,{...ot,onCreateTask:l=>{z(!1),Ss(l)},onSelectTask:l=>{z(!1),rt(l)},onClose:()=>z(!1)})})]}),e.jsx(Bt,{open:c,onOpenChange:D,children:e.jsx(xo,{onAdded:()=>{D(!1),j()}})}),Ee]})}const ki=Object.freeze(Object.defineProperty({__proto__:null,DashboardPage:gi},Symbol.toStringTag,{value:"Module"}));export{ki as D,kt as G};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as h,r as g,j as n,i as P,C as T,b as E,X as oe,y as ie,J as Q,
|
|
1
|
+
import{c as h,r as g,j as n,i as P,C as T,b as E,X as oe,y as ie,J as Q,b2 as ae,z as ce,B as le}from"./index-CK-fup_F.js";/**
|
|
2
2
|
* @license lucide-react v1.7.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as l,
|
|
1
|
+
import{r as l,ba as P,b4 as O,j as e,B as g,b as N,z as $,o as T}from"./index-CK-fup_F.js";import{G as R}from"./DashboardPage-pZti6jEL.js";import{F as _}from"./file-Cwm3-BLo.js";import{F as B}from"./folder-BXMAsfGn.js";import"./DashboardShared-D7zc-yh8.js";import"./play-BO4AI_wC.js";function D(r,t){if(!(r!=null&&r.trim()))return[];const s=r.split(`
|
|
2
2
|
`),n=[];let a=[];const d=()=>{if(a.length===0)return;const c=a.join(`
|
|
3
3
|
`).trim();if(!c){a=[];return}const i=A(a);if(!i){a=[];return}n.push({id:`${t}:${i}`,path:i,section:t,patch:c}),a=[]};for(const c of s)c.startsWith("diff --git ")&&a.length>0&&d(),a.push(c);return d(),n}function I(r){const t=[];for(const s of[...r].sort((n,a)=>n.path.localeCompare(a.path))){const n=s.path.split("/").filter(Boolean);let a=t,d="";n.forEach((c,i)=>{d=d?`${d}/${c}`:c;const h=i===n.length-1;let u=a.find(b=>b.name===c);u||(u=h?{type:"file",name:c,path:d,item:s}:{type:"folder",name:c,path:d,children:[]},a.push(u)),h||(u.children??(u.children=[]),a=u.children)})}return t}function G(r){const t=[];let s="";for(const n of r.split("/").filter(Boolean).slice(0,-1))s=s?`${s}/${n}`:n,t.push(s);return t}function z(r){return r.filter(t=>t&&!t.endsWith("/")).map(t=>({id:`untracked:${t}`,path:t,section:"untracked"}))}function A(r){var d,c;const t=(d=r.find(i=>i.startsWith("+++ ")))==null?void 0:d.slice(4).trim();if(t&&t!=="/dev/null")return w(t);const s=(c=r.find(i=>i.startsWith("--- ")))==null?void 0:c.slice(4).trim();if(s&&s!=="/dev/null")return w(s);const n=r.find(i=>i.startsWith("diff --git "));if(!n)return null;const a=n.match(/^diff --git a\/(.+?) b\/(.+)$/);return a?w(a[2]||a[1]||""):null}function w(r){return r.replace(/^[ab]\//,"")}const y={staged:"Staged",unstaged:"Unstaged",untracked:"Untracked"};function se({taskId:r}){const[t,s]=l.useState(null),[n,a]=l.useState(!0),[d,c]=l.useState(null),[i,h]=l.useState(null),[u,b]=l.useState(null),[L,v]=l.useState(!1),[M,k]=l.useState(null),S=l.useCallback(async()=>{a(!0),c(null),s(null);try{const o=await P(r);s(o)}catch(o){c(o instanceof Error?o.message:"Failed to load diff")}finally{a(!1)}},[r]);l.useEffect(()=>{S()},[S]);const F=l.useMemo(()=>D(t==null?void 0:t.staged,"staged"),[t==null?void 0:t.staged]),E=l.useMemo(()=>D(t==null?void 0:t.unstaged,"unstaged"),[t==null?void 0:t.unstaged]),C=l.useMemo(()=>z((t==null?void 0:t.untrackedFiles)??[]),[t==null?void 0:t.untrackedFiles]),j=l.useMemo(()=>[{section:"staged",items:F},{section:"unstaged",items:E},{section:"untracked",items:C}],[F,E,C]),p=l.useMemo(()=>j.flatMap(o=>o.items),[j]),f=l.useMemo(()=>p.find(o=>o.id===i)??p[0]??null,[p,i]);return l.useEffect(()=>{var o;(!i||!p.some(m=>m.id===i))&&h(((o=p[0])==null?void 0:o.id)??null)},[p,i]),l.useEffect(()=>{if(b(null),k(null),v(!1),!f||f.section!=="untracked")return;if(f.path.endsWith("/")){k("This untracked path is a directory. Open the Files tab to inspect its contents.");return}let o=!1;return v(!0),O(r,f.path).then(m=>{o||b(m)}).catch(m=>{o||k(m instanceof Error?m.message:"Failed to load file content")}).finally(()=>{o||v(!1)}),()=>{o=!0}},[f,r]),n?e.jsx(x,{tone:"muted",children:"Loading diff..."}):d?e.jsx(x,{tone:"destructive",children:d}):t!=null&&t.available?p.length>0?e.jsxs("div",{className:"grid h-full min-h-0 grid-cols-1 lg:grid-cols-[18rem_minmax(0,1fr)]",children:[e.jsxs("aside",{className:"flex min-h-0 flex-col border-b border-border/60 bg-background/30 lg:border-b-0 lg:border-r",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/60 px-3 py-2.5",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.24em] text-muted-foreground",children:"Repository diff"}),e.jsx("div",{className:"mt-1.5 flex items-start justify-between gap-2",children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] font-semibold text-foreground",children:[e.jsx(R,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:t.branch??"detached HEAD"})]}),t.repoRoot&&e.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-muted-foreground",children:t.repoRoot})]})}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:j.map(o=>e.jsxs(g,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 text-[10px]",children:[y[o.section]," ",o.items.length]},o.section))})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-1.5",children:e.jsx("div",{className:"space-y-1.5",children:j.map(({section:o,items:m})=>e.jsx(J,{section:o,items:m,selectedId:(f==null?void 0:f.id)??null,onSelect:h},o))})})]}),e.jsx("section",{className:"min-h-0 flex flex-col bg-card/10",children:f?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shrink-0 border-b border-border/60 px-3 py-2.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(g,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 text-[10px]",children:y[f.section]}),f.section==="untracked"?e.jsx(g,{variant:"secondary",className:"rounded-full text-[10px]",children:"File content"}):e.jsx(g,{variant:"secondary",className:"rounded-full text-[10px]",children:"Diff patch"})]}),e.jsx("div",{className:"mt-1.5 break-all font-mono text-[10px] text-muted-foreground",children:f.path})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-2.5",children:f.section==="untracked"?e.jsx(q,{loading:L,error:M,content:u}):e.jsx(H,{patch:f.patch??""})})]}):e.jsx(x,{tone:"muted",children:"Select a file to inspect."})})]}):e.jsx(x,{tone:"muted",children:"Working tree is clean."}):e.jsx(x,{tone:"muted",children:"Task working directory is not inside a Git repository."})}function J({section:r,items:t,selectedId:s,onSelect:n}){const a=l.useMemo(()=>I(t),[t]),d=l.useMemo(()=>t.find(u=>u.id===s)??null,[t,s]),c=l.useMemo(()=>new Set(d?G(d.path):[]),[d]),[i,h]=l.useState(!0);return e.jsxs("section",{className:"rounded-[16px] border border-border/60 bg-background/35",children:[e.jsxs("button",{type:"button",onClick:()=>h(u=>!u),"aria-expanded":i,className:N("flex w-full items-center justify-between gap-2 px-2.5 py-1.5 text-left transition-colors hover:bg-background/55",i?"border-b border-border/60":""),children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[i?e.jsx($,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(T,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"text-[12px] font-medium text-foreground",children:y[r]})]}),e.jsx(g,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 text-[10px]",children:t.length})]}),i&&e.jsx("div",{className:"p-1.5",children:a.length>0?e.jsx("div",{className:"space-y-0.5",children:a.map(u=>e.jsx(U,{node:u,depth:0,selectedId:s,expandedAncestorPaths:c,onSelect:n},`${r}:${u.path}`))}):e.jsx("div",{className:"rounded-[12px] border border-dashed border-border/70 bg-background/30 px-2.5 py-1.5 text-[11px] text-muted-foreground",children:"No files."})})]})}function U({node:r,depth:t,selectedId:s,expandedAncestorPaths:n,onSelect:a}){var d;return r.type==="folder"?e.jsx(V,{node:r,depth:t,selectedId:s,expandedAncestorPaths:n,onSelect:a}):e.jsxs("button",{type:"button",onClick:()=>{r.item&&a(r.item.id)},className:N("flex w-full cursor-pointer items-center gap-1.5 rounded-[10px] px-1.5 py-1 text-left transition-colors",((d=r.item)==null?void 0:d.id)===s?"bg-primary/10 text-foreground":"text-foreground/90 hover:bg-background/55"),style:{paddingLeft:`${t*12+6}px`},children:[e.jsx(_,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-[12px]",children:r.name})]})}function V({node:r,depth:t,selectedId:s,expandedAncestorPaths:n,onSelect:a}){const[d,c]=l.useState(!0);return l.useEffect(()=>{n.has(r.path)&&c(!0)},[n,r.path]),e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>c(i=>!i),"aria-expanded":d,className:"flex w-full cursor-pointer select-none items-center gap-1.5 rounded-[10px] px-1.5 py-1 text-left text-[12px] text-muted-foreground transition-colors hover:bg-background/55 hover:text-foreground",style:{paddingLeft:`${t*12+6}px`},children:[d?e.jsx($,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(T,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx(B,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:r.name})]}),d&&e.jsx("div",{className:"space-y-0.5",children:(r.children??[]).map(i=>e.jsx(U,{node:i,depth:t+1,selectedId:s,expandedAncestorPaths:n,onSelect:a},i.path))})]})}function H({patch:r}){const t=r.split(`
|
|
4
4
|
`);return e.jsxs("div",{className:"rounded-[20px] border border-border/60 bg-background/55",children:[e.jsxs("div",{className:"border-b border-border/60 px-3 py-2",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:"File diff"}),e.jsxs("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:[t.length," lines"]})]}),e.jsx("div",{className:"font-mono text-[11px] leading-5",children:t.map((s,n)=>e.jsxs("div",{className:N("grid grid-cols-[44px_minmax(0,1fr)] gap-3 px-3 py-0.5",K(s)),children:[e.jsx("span",{className:"select-none text-right text-muted-foreground/55",children:n+1}),e.jsx("span",{className:"whitespace-pre-wrap break-all text-foreground",children:s||" "})]},`${n}-${s}`))})]})}function q({loading:r,error:t,content:s}){if(r)return e.jsx(x,{tone:"muted",children:"Loading file content..."});if(t)return e.jsx(x,{tone:"destructive",children:t});if(!s)return e.jsx(x,{tone:"muted",children:"Select an untracked file to preview its content."});if(s.kind==="image"){const n=s.content?`data:${s.mimeType};base64,${s.content}`:s.downloadUrl;return n?e.jsx("div",{className:"flex min-h-[20rem] items-center justify-center rounded-[28px] border border-border/60 bg-background/55 p-4",children:e.jsx("img",{src:n,alt:s.path,className:"max-h-full max-w-full rounded-[20px] object-contain shadow-[0_24px_90px_-52px_rgba(0,0,0,0.65)]"})}):e.jsx(x,{tone:"muted",children:"Image preview is not available."})}if(s.kind==="pdf"&&s.downloadUrl)return e.jsx("div",{className:"h-full min-h-[24rem] overflow-hidden rounded-[28px] border border-border/60 bg-background/55",children:e.jsx("iframe",{src:s.downloadUrl,title:s.path,className:"h-full w-full border-0"})});if(s.kind==="json"){let n=s.content;try{n=JSON.stringify(JSON.parse(s.content),null,2)}catch{}return e.jsx(W,{content:n,truncated:s.truncated})}return s.kind==="markdown"||s.kind==="text"||s.kind==="html"?e.jsx(W,{content:s.content,truncated:s.truncated}):e.jsx(x,{tone:"muted",children:"This file cannot be previewed inline."})}function W({content:r,truncated:t}){return e.jsxs("div",{className:"rounded-[20px] border border-border/60 bg-background/55",children:[e.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap px-3 py-3 font-mono text-[11px] leading-5 text-foreground",children:r}),t&&e.jsx("div",{className:"border-t border-border/60 px-3 py-2 text-[11px] text-muted-foreground",children:"Content truncated. Open the Files tab to inspect the full artifact."})]})}function x({children:r,tone:t}){return e.jsx("div",{className:N("flex h-full min-h-[12rem] items-center justify-center rounded-[20px] text-[12px]",t==="muted"?"text-muted-foreground":"text-destructive"),children:r})}function K(r){return r.startsWith("@@")?"bg-sky-500/10":r.startsWith("+")&&!r.startsWith("+++")?"bg-emerald-500/10":r.startsWith("-")&&!r.startsWith("---")?"bg-destructive/10":r.startsWith("diff ")||r.startsWith("index ")||r.startsWith("---")||r.startsWith("+++")?"bg-muted/45":""}export{se as DiffTab};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as Ze,
|
|
1
|
+
import{c as Ze,b3 as Dt,j as y,r as re,b4 as Ar,b5 as Pr,b6 as zr,B as rn,i as Me,o as jr,b as Te}from"./index-CK-fup_F.js";import{F as Lr}from"./folder-BXMAsfGn.js";import{F as Fr}from"./file-Cwm3-BLo.js";/**
|
|
2
2
|
* @license lucide-react v1.7.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as z,j as e,I as W,i as u,
|
|
1
|
+
import{c as z,j as e,I as W,i as u,b7 as T,af as B,r as a,b8 as X,b6 as Y,H as Z,D as ee,g as se,b9 as re,B as U}from"./index-CK-fup_F.js";import{P as te}from"./play-BO4AI_wC.js";/**
|
|
2
2
|
* @license lucide-react v1.7.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|