meshy-node 0.6.1 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # meshy-node
2
2
 
3
- Version: 0.6.1
3
+ Version: 0.6.2
4
4
 
5
5
  This package contains the built Meshy standalone node runtime only.
6
6
  It intentionally excludes repository source files and TypeScript sources.
@@ -0,0 +1,134 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-BoGft5xw.js","assets/index-cc0FQMdy.js","assets/index-DU7NIRxO.css","assets/folder-BmMN0Ktd.js","assets/file-DlRlkTFC.js","assets/DashboardShared-h22ibsrQ.js","assets/PreviewTab-Bv6dERjR.js","assets/play-CsdLI-WG.js","assets/DiffTab-CktFHjP4.js"])))=>i.map(i=>d[i]);
2
+ import{c as me,r as a,j as e,X as Ge,B as R,a as jn,b as $,d as Nn,g as wn,e as yn,I as He,C as ct,f as kn,h as Sn,F as Cn,i as ut,S as pe,T as aa,k as ss,l as na,D as xt,m as Dn,n as En,t as oe,o as ye,p as ke,q as Be,s as Se,u as Ze,v as Tn,w as _n,x as as,y as ns,z as rs,A as ra,E as oa,G as st,H as ia,J as la,K as _e,L as da,P as Mn,M as ca,N as Je,O as An,Q as Ye,R as Rt,U as Ot,V as It,W as Ft,Y as zt,Z as Ut,_ as Vt,$ as qt,a0 as os,a1 as Ln,a2 as ua,a3 as xa,a4 as Bn,a5 as Lt,a6 as As,a7 as Nt,a8 as Pn,a9 as $n,aa as Rn,ab as On,ac as In,ad as Fn,ae as zn,af as Un,ag as ma,ah as ha,ai as pa,aj as Vn,ak as wt,al as qn,am as Hn,an as Kn,ao as Ht,ap as Wn,aq as Gn,ar as Qn,as as Ls,at as Jn,au as Yn,av as Xn,aw as Zn,ax as er,ay as tr,az as sr,aA as ar,aB as fa,aC as nr,aD as rr,aE as or,aF as Bs,aG as ga,aH as ir,aI as lr,aJ as dr,aK as cr,aL as ur,aM as xr,aN as mr,aO as hr,aP as pr,aQ as fr,aR as gr,aS as br,aT as vr,aU as jr,aV as Nr,aW as wr,aX as yr,aY as kr,aZ as Sr,a_ as Cr,a$ as Dr,b0 as Er,b1 as Tr,b2 as _r,b3 as Mr,b4 as Ar}from"./index-cc0FQMdy.js";import{r as Ps,e as Lr,b as ba,t as va,L as ce,C as $s,a as Br,T as Bt,D as tt,I as qe,M as Kt,c as ja,m as Na,d as wa,f as Pr,g as Rs,h as $r,i as Rr,j as Pt,k as Or,n as Ir,l as Fr}from"./DashboardShared-h22ibsrQ.js";import{F as zr}from"./folder-BmMN0Ktd.js";import{P as is}from"./play-CsdLI-WG.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 Ur=[["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"}]],Vr=me("archive",Ur);/**
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 qr=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Hr=me("arrow-up",qr);/**
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 Kr=[["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"}]],Wr=me("ellipsis-vertical",Kr);/**
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 Gr=[["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"}]],Qr=me("flag",Gr);/**
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 Jr=[["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"}]],Yr=me("funnel",Jr);/**
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 Xr=[["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"}]],Os=me("git-branch",Xr);/**
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 Zr=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],eo=me("globe",Zr);/**
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 to=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Wt=me("history",to);/**
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 so=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],Gt=me("image-plus",so);/**
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 ao=[["path",{d:"M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z",key:"1pdavp"}],["path",{d:"M20.054 15.987H3.946",key:"14rxg9"}]],no=me("laptop",ao);/**
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 ro=[["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"}]],ls=me("link-2",ro);/**
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 oo=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],io=me("list-ordered",oo);/**
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 lo=[["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"}]],ds=me("message-square-plus",lo);/**
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 co=[["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"}]],ya=me("panel-left-close",co);/**
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 uo=[["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"}]],xo=me("panel-left-open",uo);/**
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 mo=[["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"}]],cs=me("panel-right-close",mo);/**
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 ho=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],ka=me("panel-right-open",ho);/**
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 po=[["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"}]],ot=me("pencil",po);/**
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 fo=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],go=me("plus",fo);/**
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 bo=[["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"}]],vo=me("rotate-ccw",bo);/**
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 jo=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Qt=me("search",jo);/**
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 No=[["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"}]],Sa=me("send",No);/**
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 wo=[["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"}]],yo=me("share-2",wo);/**
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 ko=[["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"}]],So=me("sliders-horizontal",ko);/**
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 Co=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Is=me("square",Co);/**
128
+ * @license lucide-react v1.7.0 - ISC
129
+ *
130
+ * This source code is licensed under the ISC license.
131
+ * See the LICENSE file in the root directory of this source tree.
132
+ */const Do=[["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"}]],Eo=me("trash-2",Do),To=new Set(["assigned","running"]);function _o(t,s){return t.reduce((n,o)=>o.assignedTo===s&&To.has(o.status)?n+1:n,0)}function it(t){return(t==null?void 0:t.toLowerCase())==="devtunnel"}function Mo(t){return t?it(t)?"DevTunnel":t.charAt(0).toUpperCase()+t.slice(1):"Direct"}function us(t,s){return it(s??t.transportType)||!!t.devtunnelEndpoint}function Ca(t,s){return!it(s??t.transportType)}function Da(t,s){const n=s??t.transportType;return it(n)?"DevTunnel":t.devtunnelEndpoint?"Direct + DevTunnel":Mo(n)}function Fs(t,s){return!t&&!s}function Ao({routeTaskId:t,creatingTask:s,internalSelectedTaskId:n,sortedTaskIds:o}){return t||(s?null:n??o[0]??null)}function Lo(t,s){return[s,...t.filter(n=>n.id!==s.id)]}const Bo=new Set(["completed","failed","cancelled","archived"]);function Po(t,s){const n=new Set(s);return new Set(Array.from(t).filter(o=>n.has(o)))}function $o(t,s){const n=new Set(s);if(n.size===0)return!1;const o=t.filter(r=>n.has(r.id));return o.length===n.size&&o.every(r=>Bo.has(r.status))}function Ro(t,s){var o;const n=new Set(s);return((o=t.find(r=>!n.has(r.id)))==null?void 0:o.id)??null}function Ea(){const[t,s]=a.useState([]),[n,o]=a.useState(null),r=a.useRef(null),i=a.useCallback(()=>{var h;(h=r.current)==null||h.click()},[]),f=a.useCallback(async h=>{const l=Array.from(h.target.files??[]);if(l.length!==0)try{const u=await Ps(l);s(b=>[...b,...u]),o(null)}catch(u){o(u instanceof Error?u.message:"Failed to attach image")}finally{h.target.value=""}},[]),j=a.useCallback(async h=>{const l=Lr(h.clipboardData);if(l.length!==0){h.preventDefault();try{const u=await Ps(l);s(b=>[...b,...u]),o(null)}catch(u){o(u instanceof Error?u.message:"Failed to attach image")}}},[]),w=a.useCallback(h=>{s(l=>l.filter((u,b)=>b!==h))},[]),p=a.useCallback(()=>{s([]),o(null)},[]);return{images:t,error:n,fileInputRef:r,pickImages:i,handleFileChange:f,handlePaste:j,removeImage:w,clearImages:p}}function Oo({disabled:t=!1,running:s=!1,canStop:n=!1,hasContent:o=!1}){return s&&!o?{primaryAction:"stop",primaryDisabled:t||!n}:{primaryAction:"send",primaryDisabled:t||!o}}function Io({onSend:t,disabled:s,disabledReason:n="Chat is waiting on the agent.",placeholder:o="Send a follow-up message...",contextItems:r=[],running:i=!1,onStop:f}){const[j,w]=a.useState(""),p=a.useRef(null),{images:h,error:l,fileInputRef:u,pickImages:b,handleFileChange:C,handlePaste:g,removeImage:M,clearImages:m}=Ea(),y=a.useCallback(()=>{p.current&&(p.current.style.height="auto")},[]),_=a.useCallback(()=>{const N=ba(j,h);N.length===0||s||(t(N),w(""),m(),y())},[j,h,s,t,m,y]),F=a.useCallback(N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),_())},[_]),L=a.useCallback(()=>{p.current&&(p.current.style.height="auto",p.current.style.height=`${Math.min(p.current.scrollHeight,220)}px`)},[]),q=j.trim().length>0||h.length>0,O=Oo({disabled:s,running:i,canStop:i&&!!f,hasContent:q}),U=i?q?"Enter queues this message for the next turn":f?"Task is running - type to queue, empty button stops task":"Task is running - type to queue a message":s?n:"Enter sends, Shift+Enter adds a line";return e.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(N=>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:N.label}),e.jsx("span",{className:`truncate text-foreground/90 ${N.mono?"font-mono text-[11px]":""}`,children:N.value})]},`${N.label}:${N.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:C,className:"hidden"}),h.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:h.map((N,T)=>e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:va(N),alt:N.filename??`attachment ${T+1}`,className:"h-24 w-24 rounded-[22px] border border-border/70 object-cover"}),e.jsx("button",{type:"button",onClick:()=>M(T),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 ${N.filename??`image ${T+1}`}`,children:e.jsx(Ge,{className:"h-3.5 w-3.5"})})]},`${N.filename??"image"}-${T}`))})}),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:p,value:j,onChange:N=>w(N.target.value),onKeyDown:F,onPaste:g,onInput:L,placeholder:o,disabled:s,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(R,{type:"button",variant:"ghost",onClick:b,disabled:s,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(Gt,{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:U,children:e.jsx(R,{onClick:O.primaryAction==="stop"?f:_,disabled:O.primaryDisabled,size:"icon","aria-label":O.primaryAction==="stop"?"Stop running task":i?"Queue message":"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:O.primaryAction==="stop"?e.jsx(ce,{className:"h-4 w-4 animate-spin"}):e.jsx(Sa,{className:"h-4 w-4"})})})]}),l&&e.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-2 py-2 text-[11px] text-destructive sm:px-6 sm:py-3",children:l})]})]})}var Fo=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],zo=Fo.reduce((t,s)=>{const n=jn(`Primitive.${s}`),o=a.forwardRef((r,i)=>{const{asChild:f,...j}=r,w=f?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(w,{...j,ref:i})});return o.displayName=`Primitive.${s}`,{...t,[s]:o}},{}),Uo="Label",Ta=a.forwardRef((t,s)=>e.jsx(zo.label,{...t,ref:s,onMouseDown:n=>{var r;n.target.closest("button, input, select, textarea")||((r=t.onMouseDown)==null||r.call(t,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));Ta.displayName=Uo;var _a=Ta;const Vo=Nn("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Me=a.forwardRef(({className:t,...s},n)=>e.jsx(_a,{ref:n,className:$(Vo(),t),...s}));Me.displayName=_a.displayName;function qo(t,s,n){return t!=="auto"?s.find(o=>o.id===t)??null:n.length===1?n[0]??null:null}function Ho(t){return t.trim()||"."}function Ko(t){return new Promise(s=>window.setTimeout(s,t))}function Wo(t){return!!t&&typeof t=="object"&&typeof t.createdBranch=="string"&&typeof t.currentBranch<"u"}async function Go(t){let s=t;for(let n=0;n<60;n++){if(s.status==="succeeded"){if(Wo(s.result))return s.result;throw new Error("Branch creation completed without branch details")}if(s.status==="failed")throw new Error(s.error||"Branch creation failed");await Ko(1e3),s=await kn(s.id)}throw new Error("Timed out waiting for branch creation")}function zs({value:t,onChange:s,project:n,assignTo:o,nodes:r,assignableNodes:i,layout:f="default",chipClassName:j,chipActiveClassName:w,chipInactiveClassName:p,labelClassName:h,triggerClassName:l}){const[u,b]=a.useState(!1),[C,g]=a.useState(null),[M,m]=a.useState(""),[y,_]=a.useState(!1),[F,L]=a.useState(!1),[q,E]=a.useState(!1),[O,U]=a.useState(null),[N,T]=a.useState(""),[W,se]=a.useState(""),[H,G]=a.useState(""),[ie,ae]=a.useState(!1),Z=a.useRef(null),Q=a.useRef(0),V=a.useMemo(()=>qo(o,r,i),[o,r,i]),K=V==null?void 0:V.id,J=a.useMemo(()=>Ho(n),[n]),de=a.useMemo(()=>K?`${K}
133
+ ${J}`:"",[K,J]),x=a.useCallback(async(v=0,P=!1)=>{const te=Q.current+1,ge=de;if(Q.current=te,!K){g(null),m("");return}U(null),P||m(""),P?L(!0):_(!0);try{const Ce=await wn(K,{path:J,limit:20,offset:v,allowAbsolute:!0});if(te!==Q.current)return;m(ge),g(be=>P&&be?{...Ce,branches:[...be.branches,...Ce.branches]}:Ce)}catch(Ce){if(te!==Q.current)return;U(Ce instanceof Error?Ce.message:"Failed to load branch info"),P||(g(null),m(""))}finally{te===Q.current&&(_(!1),L(!1))}},[K,de,J]);a.useEffect(()=>{if(!K){Q.current+=1,g(null),m(""),U(null);return}x()},[K,J,x]),a.useEffect(()=>{const v=t.trim(),P=M===de?C:null,te=P!=null&&P.available&&P.currentBranch?P.currentBranch:"";v!==te&&s(te)},[C,de,M,s,t]),a.useEffect(()=>{if(!u)return;const v=te=>{Z.current&&(Z.current.contains(te.target)||b(!1))},P=te=>{te.key==="Escape"&&b(!1)};return document.addEventListener("mousedown",v),document.addEventListener("keydown",P),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("keydown",P)}},[u]),a.useEffect(()=>{u&&(se(""),G(""),ae(!1))},[u,K,J]);const B=a.useCallback(async()=>{if(!K)return;const v=N.trim(),P=ie?H.trim():W.trim();if(!(!v||!P)){E(!0),U(null);try{const te=await yn(K,{path:J,branchName:v,startPoint:P,limit:20,offset:0,allowAbsolute:!0}),ge=await Go(te);m(de),g(ge),s(ge.currentBranch??ge.createdBranch),T(""),se(""),G(""),ae(!1),b(!1)}catch(te){U(te instanceof Error?te.message:"Failed to create branch")}finally{E(!1)}}},[K,de,J,ie,H,N,s,W]),k=M===de?C:null,Y=a.useCallback(()=>{k!=null&&k.hasMore&&x(k.branches.length,!0)},[k,x]),c=t.trim()||(k==null?void 0:k.currentBranch)||(k&&!k.available?"No git repo":"Branch"),A=ie?H.trim():W.trim(),I=!!(k!=null&&k.available&&N.trim()&&A&&!q),re=f==="composer"?e.jsxs(R,{type:"button",variant:"ghost",onClick:()=>b(v=>!v),title:c,"aria-label":`Branch: ${c}`,className:$(j,l,"min-w-0 max-w-full",t.trim()?w:p),children:[y&&!k?e.jsx(ce,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(Os,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:$("min-w-0 truncate",h),children:c})]}):e.jsxs(R,{type:"button",variant:"outline",onClick:()=>b(v=>!v),className:"h-11 w-full justify-between rounded-2xl border-border/70 bg-background/70 px-4",title:c,children:[e.jsx("span",{className:$("truncate",t.trim()?"font-mono text-foreground":"text-muted-foreground"),children:c}),e.jsx("span",{className:"ml-3 shrink-0 text-xs text-muted-foreground",children:V?V.name:"Manual"})]});return e.jsxs("div",{className:$("relative inline-block",f==="composer"?"min-w-0 shrink-0":"w-full"),ref:Z,children:[f==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Me,{className:"text-sm font-medium",children:"Branch"}),re]}):re,u&&e.jsxs("div",{className:$("absolute z-50 mt-2 w-[240px] overflow-hidden rounded-2xl border border-border/60 bg-background/95 shadow-lg backdrop-blur",f==="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(Os,{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:k!=null&&k.repoRoot?`${k.currentBranch??c} · ${k.repoRoot}`:(k==null?void 0:k.currentBranch)??c,children:(k==null?void 0:k.currentBranch)??c}),y?e.jsx(ce,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground"}):null]}),V?y&&!k?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(ce,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):k&&!k.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(He,{value:N,onChange:v=>T(v.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(R,{type:"button",size:"sm",onClick:()=>void B(),disabled:!I,title:I?"Create branch":"Enter a name and pick a base","aria-label":"Create branch",className:"h-8 w-8 shrink-0 rounded-md p-0",children:q?e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(go,{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"}),!ie&&e.jsxs("button",{type:"button",onClick:()=>ae(!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(ot,{className:"h-2.5 w-2.5"}),"Manual"]})]}),ie?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(He,{value:H,onChange:v=>G(v.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:()=>{ae(!1),G("")},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(Ge,{className:"h-3.5 w-3.5"})})]}):k!=null&&k.branches.length?e.jsxs("div",{className:"max-h-44 overflow-y-auto rounded-md border border-border/40 bg-background/40",children:[k.branches.map(v=>{const P=W===v.ref,te=v.branch==="main"||v.branch==="master";return e.jsxs("button",{type:"button",onClick:()=>se(v.ref),className:$("flex w-full items-center gap-2 border-b border-border/20 px-2.5 py-1.5 text-left text-[11px] last:border-b-0 hover:bg-background/60",P&&"bg-background/70"),title:v.ref,children:[e.jsx("span",{className:$("shrink-0 text-[10px]",te?"text-amber-500 dark:text-amber-400":"text-muted-foreground/60"),"aria-hidden":!0,children:te?"★":"·"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-foreground",children:v.ref}),P?e.jsx(ct,{className:"h-3 w-3 shrink-0 text-primary"}):null]},v.ref)}),k.hasMore&&e.jsxs("button",{type:"button",onClick:Y,disabled:F,className:"flex w-full items-center justify-center gap-1 border-t border-border/20 py-1 text-[10px] text-muted-foreground hover:bg-background/60 hover:text-foreground disabled:opacity-50",children:[F?e.jsx(ce,{className:"h-3 w-3 animate-spin"}):e.jsx(Wt,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"rounded-md border border-dashed border-border/40 px-2.5 py-2 text-[11px] text-muted-foreground",children:"No remote branches found."})]})]})}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Select a specific node first."}),O&&e.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-3 py-1.5 text-[11px] text-destructive",children:O})]})]})}const Qo=20,Jo=3,Jt="meshy-working-dir-recents-by-node";function Yo(t){return t.startsWith("/")||t.startsWith("\\\\")||/^[A-Za-z]:[\\/]/.test(t)}function Xo(t){const s=t.trim();return s||"."}function Yt(t){const s=[],n=new Set;for(const o of t){const r=o.trim();if(!(!r||n.has(r))&&(n.add(r),s.push(r),s.length===Jo))break}return s}function Zo(t,s){const n=s.trim();return Yt(n?[n,...t]:t)}function Ma(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const s={};for(const[n,o]of Object.entries(t)){if(!n||!Array.isArray(o))continue;const r=o.filter(f=>typeof f=="string"),i=Yt(r);i.length>0&&(s[n]=i)}return s}function ei(t,s,n){if(!s)return t;const o=t[s]??[],r=Zo(o,n);if(r.length===0){if(!(s in t))return t;const{[s]:i,...f}=t;return f}return{...t,[s]:r}}function ti(t,s){var n;return s?((n=t[s])==null?void 0:n[0])??"":""}function Aa(t){if(!t||typeof window>"u")return"";try{const s=window.localStorage.getItem(Jt);return s?ti(Ma(JSON.parse(s)),t):""}catch{return""}}function si(t,s,n){return t!=="auto"?s.find(o=>o.id===t)??null:n.length===1?n[0]??null:null}function ai(t,s){const n=s.trim();return n?Yo(n)||!t?n:`${t.replace(/[/\\]+$/,"")}/${n}`:""}function ni(t,s){return t?t.isAbsolute?t.currentPath:t.currentPath==="."||t.currentPath===""?t.rootPath||(s==null?void 0:s.workDir)||"Node root":t.currentPath:(s==null?void 0:s.workDir)??"Node root"}function yt({value:t,onChange:s,assignTo:n,nodes:o,assignableNodes:r,layout:i="default",chipClassName:f,chipActiveClassName:j,chipInactiveClassName:w,labelClassName:p,triggerClassName:h,popoverPlacement:l="bottom",popoverAlign:u="start"}){const[b,C]=a.useState(!1),[g,M]=a.useState(null),[m,y]=a.useState(!1),[_,F]=a.useState(!1),[L,q]=a.useState(null),[E,O]=a.useState(""),[U,N]=a.useState(!1),[T,W]=a.useState({}),se=a.useRef(null),H=a.useMemo(()=>si(n,o,r),[n,o,r]),G=H==null?void 0:H.id,ie=a.useMemo(()=>G?T[G]??[]:[],[T,G]),ae=a.useMemo(()=>t.trim()?ai(H==null?void 0:H.workDir,t):"Use node default",[t,H==null?void 0:H.workDir]);a.useEffect(()=>{if(!(typeof window>"u"))try{const c=window.localStorage.getItem(Jt);if(!c)return;const A=JSON.parse(c);W(Ma(A))}catch{}},[]);const Z=a.useCallback(c=>{G&&W(A=>{const I=ei(A,G,c);if(I===A)return A;if(typeof window<"u")try{window.localStorage.setItem(Jt,JSON.stringify(I))}catch{}return I})},[G]),Q=a.useCallback((c,A=!0)=>{const I=c.trim();s(I),A&&I&&Z(I),C(!1)},[s,Z]),V=a.useCallback(async(c,A=0,I=!1)=>{if(G){q(null),I?F(!0):y(!0);try{const re=await Sn(G,{path:c,limit:Qo,offset:A,directoriesOnly:!0,allowAbsolute:!0});M(v=>I&&v?{...re,entries:[...v.entries,...re.entries]}:re)}catch(re){q(re instanceof Error?re.message:"Failed to browse directories"),I||M(null)}finally{y(!1),F(!1)}}},[G]),K=a.useRef(t);K.current=t;const J=a.useRef(V);J.current=V,a.useEffect(()=>{if(!b)return;const c=K.current;O(c),N(!1),M(null),q(null),G&&J.current(Xo(c))},[b,G]),a.useEffect(()=>{if(!b)return;const c=I=>{se.current&&(se.current.contains(I.target)||C(!1))},A=I=>{I.key==="Escape"&&C(!1)};return document.addEventListener("mousedown",c),document.addEventListener("keydown",A),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",A)}},[b]);const de=a.useCallback(c=>{V(c)},[V]),x=a.useCallback(()=>{g&&V(g.currentPath,g.entries.length,!0)},[g,V]),B=i==="composer"?e.jsxs(R,{type:"button",variant:"ghost",onClick:()=>C(c=>!c),title:ae,"aria-label":`Working directory: ${ae}`,className:$(f,h,"min-w-0 max-w-full",t.trim()?j:w),children:[e.jsx(Cn,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:$("min-w-0 truncate",p),children:ae})]}):e.jsxs(R,{type:"button",variant:"outline",onClick:()=>C(c=>!c),className:"h-11 w-full justify-between rounded-2xl border-border/70 bg-background/70 px-4",title:ae,children:[e.jsx("span",{className:$("truncate",t.trim()?"font-mono text-foreground":"text-muted-foreground"),children:ae}),e.jsx("span",{className:"ml-3 shrink-0 text-xs text-muted-foreground",children:H?H.name:"Manual"})]}),k=ni(g,H),Y=!!(g!=null&&g.parentPath);return e.jsxs("div",{className:$("relative inline-block",i==="composer"?"min-w-0 max-w-[60%] shrink":"w-full"),"data-workdir-popover-placement":l,"data-workdir-popover-align":u,ref:se,children:[i==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Me,{className:"text-sm font-medium",children:"Working directory"}),B]}):B,b&&e.jsxs("div",{className:$("absolute z-50 flex max-h-[min(28rem,calc(100vh-5rem))] w-[240px] flex-col overflow-hidden rounded-2xl border border-border/60 bg-background/95 shadow-lg backdrop-blur",l==="top"?"bottom-full mb-2":"top-full mt-2",i==="composer"?u==="end"?"right-0":"left-0":u==="end"?"right-0 w-auto min-w-[240px]":"left-0 right-0 w-auto min-w-[240px]"),children:[ie.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(Wt,{className:"h-2.5 w-2.5"}),"Recent"]}),e.jsx("div",{className:"flex flex-col",children:ie.map(c=>e.jsx("button",{type:"button",onClick:()=>Q(c),className:"truncate rounded px-1.5 py-0.5 text-left font-mono text-[11px] text-foreground hover:bg-background/60",title:c,children:c},c))})]}),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:()=>(g==null?void 0:g.parentPath)&&de(g.parentPath),disabled:!Y||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(Hr,{className:"h-3 w-3"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground",title:k,children:k}),g&&e.jsx("button",{type:"button",onClick:()=>Q(g.isAbsolute?g.currentPath:g.currentPath==="."?"":g.currentPath),className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium text-foreground hover:bg-background/60",title:"Use this folder",children:"Use"})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:[H?m?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(ce,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):g&&g.entries.length>0?e.jsxs(e.Fragment,{children:[g.entries.map(c=>e.jsxs("div",{className:"group flex items-stretch border-b border-border/30 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>Q(c.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 ${c.path}`,children:[e.jsx(zr,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-[11px] text-foreground",children:c.name})]}),e.jsx("button",{type:"button",onClick:()=>de(c.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 ${c.name}`,children:e.jsx(ut,{className:"h-3.5 w-3.5"})})]},c.path)),g.hasMore&&e.jsxs("button",{type:"button",onClick:x,disabled:_,className:"flex w-full items-center justify-center gap-1 border-t border-border/40 py-1 text-[10px] text-muted-foreground hover:bg-background/60 hover:text-foreground disabled:opacity-50",children:[_?e.jsx(ce,{className:"h-3 w-3 animate-spin"}):e.jsx(Wt,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:L??"No subfolders."}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Select a node to browse."}),L&&g&&g.entries.length>0&&e.jsx("div",{className:"border-t border-border/60 px-3 py-1.5 text-[11px] text-destructive",children:L})]}),e.jsx("div",{className:"flex items-center gap-1 border-t border-border/60 bg-background/40 px-2.5 py-1.5",children:U?e.jsxs(e.Fragment,{children:[e.jsx(He,{value:E,onChange:c=>O(c.target.value),onKeyDown:c=>{c.key==="Enter"&&E.trim()?(c.preventDefault(),Q(E)):c.key==="Escape"&&(c.preventDefault(),N(!1),O(t))},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:()=>Q(E),disabled:!E.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(ct,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{N(!1),O(t)},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(Ge,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>{O(t),N(!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(ot,{className:"h-3 w-3"})]})})]})]})}function La(t,s={}){const n=t.filter(o=>o.status==="online");return s.currentNodeRole!=="follower"||!s.leaderNodeId?n:n.filter(o=>o.id!==s.leaderNodeId)}function xs({isCurrent:t}){return t?e.jsx(no,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500 dark:text-emerald-400","aria-label":"current node"}):e.jsx(eo,{className:"h-3.5 w-3.5 shrink-0 text-sky-500 dark:text-sky-400","aria-label":"remote follower node"})}function Xt(t,s){return t.map(n=>{const o=!!s&&n.id===s;return e.jsx(pe,{value:n.id,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(xs,{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)})}const ri=["codex","claudecode","copilot"];function ms({agent:t,className:s="h-3.5 w-3.5 shrink-0"}){const n=s;return t==="claudecode"?e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"butt",strokeLinejoin:"miter",className:n,"data-agent-icon":"claudecode","data-agent-shape":"pixel-bot","aria-hidden":"true",children:[e.jsx("path",{d:"M5 9V6h14v3h2v6h-3v3H6v-3H3V9z"}),e.jsx("path",{d:"M8 7v4"}),e.jsx("path",{d:"M16 7v4"}),e.jsx("path",{d:"M7 18v3"}),e.jsx("path",{d:"M11 18v3"}),e.jsx("path",{d:"M15 18v3"})]}):t==="codex"?e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round",className:n,"data-agent-icon":"codex","data-agent-shape":"command-cloud","aria-hidden":"true",children:[e.jsx("path",{d:"M6.85 18.05h9.65a4.35 4.35 0 0 0 .65-8.65 5.45 5.45 0 0 0-10.2-1.65 5.1 5.1 0 0 0-.1 10.3z"}),e.jsx("path",{d:"M9.25 8.9 12 12l-2.75 3.1"}),e.jsx("path",{d:"M14.15 15.1h3.25"})]}):t==="copilot"?e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",className:n,"data-agent-icon":"copilot","data-agent-shape":"pixel-face","aria-hidden":"true",children:[e.jsx("path",{d:"M5.2 4.1h4.65a1.55 1.55 0 0 1 1.55 1.55v4.65a1.55 1.55 0 0 1-1.55 1.55H5.2a1.55 1.55 0 0 1-1.55-1.55V5.65A1.55 1.55 0 0 1 5.2 4.1z"}),e.jsx("path",{d:"M14.15 4.1h4.65a1.55 1.55 0 0 1 1.55 1.55v4.65a1.55 1.55 0 0 1-1.55 1.55h-4.65a1.55 1.55 0 0 1-1.55-1.55V5.65a1.55 1.55 0 0 1 1.55-1.55z"}),e.jsx("path",{d:"M4.5 14.7v3.85h15v-3.85"}),e.jsx("path",{d:"M8.4 14.7v1.9"}),e.jsx("path",{d:"M12 14.7v1.9"}),e.jsx("path",{d:"M15.6 14.7v1.9"}),e.jsx("path",{d:"M7.65 20.25h8.7"})]}):e.jsx(na,{className:n,"data-agent-icon":"generic","aria-hidden":"true"})}function Ba({value:t,label:s,description:n}){return e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(ms,{agent:t}),e.jsx("span",{children:s}),n&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:n})]})}function Us(){return aa.map(t=>e.jsx(pe,{value:t.value,disabled:t.disabled,children:e.jsx(Ba,{value:t.value,label:t.label,description:t.description})},t.value))}function oi(){return ri.map(t=>e.jsx(pe,{value:t,children:e.jsx(Ba,{value:t,label:t})},t))}function Vs(){return ss.map(t=>e.jsx(pe,{value:t.value,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{children:t.label}),t.description&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:t.description})]})},t.value))}function ii(t){var s;return((s=aa.find(n=>n.value===t))==null?void 0:s.label)??t}function li(t){var s;return((s=ss.find(n=>n.value===t))==null?void 0:s.label)??t}function di(t){var o;const s=t.sessionId.trim(),n=t.cwd.trim();return!s||!n||!t.assignTo?null:{title:t.title.trim()||((o=t.defaultTitle)==null?void 0:o.trim())||void 0,agent:t.agent,sessionId:s,cwd:n,assignTo:t.assignTo,priority:t.priority,mode:t.mode??xt}}function ci(){return ss.map(t=>e.jsx(pe,{value:t.value,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{children:t.label}),t.description&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:t.description})]})},t.value))}function ui(t){if(!t)return"unknown time";const s=Date.parse(t);return Number.isNaN(s)?t:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(s)}function xi({nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,className:f,footerClassName:j,submitLabel:w="Load session",cancelLabel:p="Cancel",autoFocus:h=!1}){const l=a.useMemo(()=>La(t,{currentNodeRole:s,leaderNodeId:o}),[t,s,o]),u=a.useMemo(()=>{var v;return n&&l.some(P=>P.id===n)?n:((v=l[0])==null?void 0:v.id)??""},[l,n]),[b,C]=a.useState(""),[g,M]=a.useState("codex"),[m,y]=a.useState(""),[_,F]=a.useState(""),[L,q]=a.useState(""),[E,O]=a.useState(u),[U,N]=a.useState("normal"),[T,W]=a.useState(xt),[se,H]=a.useState(!1),[G,ie]=a.useState([]),[ae,Z]=a.useState(!1),[Q,V]=a.useState(null),K=a.useMemo(()=>G.find(v=>v.sessionId===m)??null,[G,m]);a.useEffect(()=>{E&&l.some(v=>v.id===E)||O(u)},[E,l,u]),a.useEffect(()=>{y(""),F(""),q("")},[g,E]),a.useEffect(()=>{let v=!1;return E?(Z(!0),V(null),Dn(E,{agent:g,limit:50}).then(P=>{v||ie(P.sessions)}).catch(P=>{v||(ie([]),V(P instanceof Error?P.message:"Failed to load native sessions"))}).finally(()=>{v||Z(!1)}),()=>{v=!0}):(ie([]),V(null),Z(!1),()=>{v=!0})},[g,E]),a.useEffect(()=>{K&&(F(K.sessionId),q(K.cwd))},[K]);const J=a.useCallback(async v=>{v.preventDefault();const P=di({title:b,defaultTitle:K==null?void 0:K.summary,agent:g,sessionId:_,cwd:L,assignTo:E,priority:U,mode:T});if(P){H(!0);try{const te=await En(P);r(te)}catch(te){oe.error(te instanceof Error?te.message:"Failed to load native session")}finally{H(!1)}}},[b,K,g,_,L,E,U,T,r]),de=!!(_.trim()&&L.trim()&&E),[x,B]=a.useState(!1),[k,Y]=a.useState(""),c=l.find(v=>v.id===E)??null,A=!!(n&&(c==null?void 0:c.id)===n),I=a.useMemo(()=>{const v=k.trim().toLowerCase();return v?G.filter(P=>P.summary.toLowerCase().includes(v)||P.sessionId.toLowerCase().includes(v)||P.cwd.toLowerCase().includes(v)):G},[G,k]),re="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:J,className:$("space-y-4",f),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(ye,{value:E,onValueChange:O,children:[e.jsx(ke,{className:$(re),"aria-label":"Node",children:c?e.jsxs(e.Fragment,{children:[e.jsx(xs,{isCurrent:A}),e.jsx("span",{className:"max-w-[10rem] truncate",children:c.name})]}):e.jsx(Be,{placeholder:"Node"})}),e.jsx(Se,{children:Xt(l,n)})]}),e.jsxs(ye,{value:g,onValueChange:v=>M(v),children:[e.jsxs(ke,{className:$(re),"aria-label":"Agent",children:[e.jsx(ms,{agent:g}),e.jsx("span",{children:g})]}),e.jsx(Se,{children:oi()})]}),e.jsxs("div",{className:"relative ml-auto min-w-0 flex-1 sm:max-w-56",children:[e.jsx(Qt,{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(He,{value:k,onChange:v=>Y(v.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(Me,{className:"text-[10px] font-medium uppercase tracking-[0.2em] text-muted-foreground",children:ae?"Loading...":`${I.length} session${I.length===1?"":"s"}`})}),e.jsxs("div",{className:"relative h-88 overflow-hidden rounded-[20px]",children:[ae&&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:[!E&&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."}),E&&!ae&&I.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:G.length===0?"No recent sessions on this node. Use Manual session ID under More options.":"No sessions match your filter."}),I.map(v=>{const P=v.sessionId===m;return e.jsxs("button",{type:"button",onClick:()=>y(v.sessionId),className:$("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",P?"border-primary/45 bg-primary/9 shadow-[0_18px_60px_-44px_hsl(var(--primary)/0.95)]":"border-border/55 bg-background/40 hover:border-border hover:bg-background/65"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:$("h-2 w-2 shrink-0 rounded-full",P?"bg-primary":"bg-border")}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground",children:v.summary}),e.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.16em] text-muted-foreground",children:ui(v.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:v.sessionId.slice(0,12)}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),e.jsx("span",{className:"truncate font-mono",children:v.cwd})]})]},v.sessionId)})]})]}),Q&&e.jsx("p",{className:"px-1 pt-2 text-[11px] text-destructive",children:Q})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{type:"button",onClick:()=>B(v=>!v),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":x,children:[e.jsx("span",{className:"h-px flex-1 bg-border/60","aria-hidden":!0}),e.jsx("span",{className:"shrink-0",children:x?"Less options":"More options"}),e.jsx(Ze,{className:$("h-3.5 w-3.5 shrink-0 transition-transform",x&&"rotate-180")}),e.jsx("span",{className:"h-px flex-1 bg-border/60","aria-hidden":!0})]}),x&&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(Me,{htmlFor:"native-session-id",className:"text-xs font-medium text-muted-foreground",children:"Session ID"}),e.jsx(He,{id:"native-session-id",type:"text",value:_,onChange:v=>{y(""),F(v.target.value)},placeholder:"ses_..., thread_..., or UUID",autoFocus:h,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(Me,{htmlFor:"native-session-title",className:"text-xs font-medium text-muted-foreground",children:"Task title"}),e.jsx(He,{id:"native-session-title",type:"text",value:b,onChange:v=>C(v.target.value),placeholder:"Optional",className:"h-10 rounded-[16px] border-border/70 bg-background/70 text-sm"})]})]}),e.jsx(yt,{value:L,onChange:v=>{y(""),q(v)},assignTo:E,nodes:t,assignableNodes:l}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Me,{className:"text-xs font-medium text-muted-foreground",children:"Mode"}),e.jsxs(ye,{value:T,onValueChange:v=>W(v),children:[e.jsx(ke,{className:"h-10 rounded-[16px] border-border/70 bg-background/70 text-sm",children:e.jsx(Be,{placeholder:"Select mode"})}),e.jsx(Se,{children:ci()})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Me,{className:"text-xs font-medium text-muted-foreground",children:"Priority"}),e.jsxs(ye,{value:U,onValueChange:N,children:[e.jsx(ke,{className:"h-10 rounded-[16px] border-border/70 bg-background/70 text-sm",children:e.jsx(Be,{placeholder:"Select priority"})}),e.jsxs(Se,{children:[e.jsx(pe,{value:"low",children:"Low"}),e.jsx(pe,{value:"normal",children:"Normal"}),e.jsx(pe,{value:"high",children:"High"}),e.jsx(pe,{value:"critical",children:"Critical"})]})]})]})]})]})]}),e.jsxs("div",{className:$("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",j),children:[i&&e.jsx(R,{type:"button",variant:"ghost",onClick:i,className:"rounded-[16px]",children:p}),e.jsx(R,{type:"submit",disabled:!de||se,className:"rounded-[16px] px-5",children:se?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"h-4 w-4 animate-spin"})," Loading..."]}):w})]})]})}function Pa(t,s,n=!1){const o=t.trim();if(o)return o;const r=s.trim().split(`
134
+ `).map(i=>i.trim()).find(Boolean);return r?r.length>72?`${r.slice(0,69).trimEnd()}...`:r:n?"Image task":""}function mi(t){var f;const s=t.title.trim(),n=Pa(t.title,t.description,t.images.length>0),o=t.description.trim()||n,r=t.mode??xt,i=ba(t.description,t.images);return!n||!o||!t.agent?null:{title:n,description:o,agent:t.agent,project:t.project.trim()||null,branch:((f=t.branch)==null?void 0:f.trim())||null,payload:{initialMessage:i,mode:r,titleSource:s?"manual":"derived"},priority:t.priority,assignTo:t.assignTo==="auto"?void 0:t.assignTo}}function hi({nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,className:f,footerClassName:j,submitLabel:w="Create chat",cancelLabel:p="Cancel",autoFocus:h=!1,layout:l="default"}){const[u,b]=a.useState(""),[C,g]=a.useState(""),[M,m]=a.useState("claudecode"),[y,_]=a.useState(xt),[F,L]=a.useState(""),[q,E]=a.useState(""),[O,U]=a.useState("normal"),N=a.useMemo(()=>La(t,{currentNodeRole:s,leaderNodeId:o}),[t,s,o]),T=a.useMemo(()=>{var ee;return n&&N.some(ue=>ue.id===n)?n:((ee=N[0])==null?void 0:ee.id)??""},[N,n]),[W,se]=a.useState(T),[H,G]=a.useState(!1),[ie,ae]=a.useState(!1),{images:Z,error:Q,fileInputRef:V,pickImages:K,handleFileChange:J,handlePaste:de,removeImage:x}=Ea(),B=a.useMemo(()=>N.find(ee=>ee.id===W)??null,[W,N]),k=!!(n&&(B==null?void 0:B.id)===n),Y=ii(M),c=li(y);a.useEffect(()=>{W&&N.some(ee=>ee.id===W)||se(T)},[W,N,T]),a.useEffect(()=>{L(Aa(W)),E("")},[W]),a.useEffect(()=>{E("")},[F]);const A=a.useCallback(async ee=>{ee.preventDefault();const ue=mi({title:u,description:C,agent:M,project:F,branch:q,priority:O,assignTo:W,mode:y,images:Z});if(ue){G(!0);try{const he=await _n(ue);r(he)}catch(he){oe.error(he instanceof Error?he.message:"Failed to create task")}finally{G(!1)}}},[u,C,M,F,q,O,W,y,Z,r]),I=Pa(u,C,Z.length>0),re=!!(I&&M&&W&&(C.trim()||Z.length>0)),v=a.useCallback(ee=>{var ue;ee.nativeEvent.isComposing||ee.key==="Enter"&&(ee.ctrlKey||ee.metaKey)&&re&&!H&&(ee.preventDefault(),(ue=ee.currentTarget.form)==null||ue.requestSubmit())},[re,H]),P=Z.length>0&&e.jsx("div",{className:"flex flex-wrap gap-3",children:Z.map((ee,ue)=>e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:va(ee),alt:ee.filename??`attachment ${ue+1}`,className:"h-24 w-24 rounded-2xl border border-border/70 object-cover"}),e.jsx("button",{type:"button",onClick:()=>x(ue),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 ${ee.filename??`image ${ue+1}`}`,children:e.jsx(Ge,{className:"h-3.5 w-3.5"})})]},`${ee.filename??"image"}-${ue}`))}),te=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Me,{className:"text-sm font-medium",children:"Assign to"}),e.jsxs(ye,{value:W,onValueChange:se,children:[e.jsx(ke,{className:"h-11 rounded-[18px] border-border/70 bg-background/70",children:e.jsx(Be,{placeholder:"Select node"})}),e.jsx(Se,{children:Xt(N,n)})]})]}),ge=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Me,{className:"text-sm font-medium",children:"Agent"}),e.jsxs(ye,{value:M,onValueChange:m,children:[e.jsx(ke,{className:"h-11 rounded-[18px] border-border/70 bg-background/70",children:e.jsx(Be,{placeholder:"Select agent"})}),e.jsx(Se,{children:Us()})]})]}),Ce=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Me,{className:"text-sm font-medium",children:"Mode"}),e.jsxs(ye,{value:y,onValueChange:ee=>_(ee),children:[e.jsx(ke,{className:"h-11 rounded-[18px] border-border/70 bg-background/70",children:e.jsx(Be,{placeholder:"Select mode"})}),e.jsx(Se,{children:Vs()})]})]}),be=e.jsxs("div",{className:"space-y-2",children:[e.jsx(Me,{className:"text-sm font-medium",children:"Priority"}),e.jsxs(ye,{value:O,onValueChange:U,children:[e.jsx(ke,{className:"h-11 rounded-[18px] border-border/70 bg-background/70",children:e.jsx(Be,{placeholder:"Select priority"})}),e.jsxs(Se,{children:[e.jsx(pe,{value:"low",children:"Low"}),e.jsx(pe,{value:"normal",children:"Normal"}),e.jsx(pe,{value:"high",children:"High"}),e.jsx(pe,{value:"critical",children:"Critical"})]})]})]}),Ke=e.jsx(yt,{value:F,onChange:L,assignTo:W,nodes:t,assignableNodes:N}),Pe=e.jsx(zs,{value:q,onChange:E,project:F,assignTo:W,nodes:t,assignableNodes:N});return l==="composer"?e.jsxs("form",{onSubmit:A,className:$("space-y-4",f),children:[e.jsx("input",{ref:V,type:"file",accept:"image/*",multiple:!0,onChange:J,className:"hidden"}),(()=>{const ee="chat-composer__chip h-9 w-auto gap-1.5 rounded-[15px] px-3.5 text-xs shadow-none transition-colors",ue="border-transparent bg-transparent text-muted-foreground hover:bg-background/40 hover:text-foreground",he="border-border/70 bg-background/55 text-foreground",S=M==="claudecode",we=y===xt;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(ye,{value:W,onValueChange:se,children:[e.jsx(ke,{className:$(ee,he,"chat-composer__node-trigger border-transparent bg-transparent hover:bg-background/40"),title:`Assigned node: ${(B==null?void 0:B.name)??"unassigned"}`,"aria-label":`Assigned node: ${(B==null?void 0:B.name)??"unassigned"}`,children:B?e.jsxs(e.Fragment,{children:[e.jsx(xs,{isCurrent:k}),e.jsx("span",{className:"min-w-0 truncate",children:B.name}),e.jsx("span",{className:"chat-composer__header-meta shrink-0 text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:k?"current":"remote"})]}):e.jsx(Be,{placeholder:"Select node"})}),e.jsx(Se,{children:Xt(N,n)})]}),ie?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(He,{id:"task-title-composer",type:"text",value:u,onChange:X=>b(X.target.value),onKeyDown:X=>{(X.key==="Enter"||X.key==="Escape")&&(X.preventDefault(),ae(!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(R,{type:"button",variant:"ghost",size:"icon",onClick:()=>ae(!1),"aria-label":"Save title",className:"h-8 w-8 shrink-0 rounded-[12px] text-muted-foreground hover:text-foreground",children:e.jsx(ct,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>ae(!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:I||"Title","aria-label":I?`Edit title: ${I}`:"Edit title",children:[e.jsx("span",{className:"chat-composer__title-text max-w-[220px] truncate",children:I||"Title"}),e.jsx(ot,{className:"h-3 w-3 shrink-0"})]})]}),e.jsx("textarea",{id:"task-description",value:C,onChange:X=>g(X.target.value),onKeyDown:v,onPaste:de,placeholder:"Ask anything...",rows:4,autoFocus:h,"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(R,{type:"button",variant:"ghost",size:"icon",onClick:K,"aria-label":"Add images",className:"h-9 w-9 shrink-0 rounded-[14px] text-muted-foreground hover:text-foreground",children:e.jsx(Gt,{className:"h-4 w-4"})}),e.jsx("span",{className:"mx-0.5 h-5 w-px bg-border/60","aria-hidden":!0}),e.jsxs(ye,{value:M,onValueChange:m,children:[e.jsxs(ke,{className:$(ee,"chat-composer__icon-trigger",S?ue:he),title:`Agent: ${Y}`,"aria-label":`Agent: ${Y}`,children:[e.jsx(ms,{agent:M}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:Y})]}),e.jsx(Se,{children:Us()})]}),e.jsxs(ye,{value:y,onValueChange:X=>_(X),children:[e.jsxs(ke,{className:$(ee,"chat-composer__icon-trigger",we?ue:he),title:`Mode: ${c}`,"aria-label":`Mode: ${c}`,children:[e.jsx(So,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:c})]}),e.jsx(Se,{children:Vs()})]}),e.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[e.jsxs(ye,{value:O,onValueChange:U,children:[e.jsx(ke,{"aria-label":`Priority: ${O}`,title:`Priority: ${O}`,className:$("h-9 w-9 justify-center gap-0 rounded-[14px] p-0 text-xs shadow-none [&>svg:last-child]:hidden",O==="normal"?"border-transparent bg-transparent text-muted-foreground hover:bg-background/40":"border-border/70 bg-background/55",O==="critical"&&"text-destructive",O==="high"&&"text-amber-600 dark:text-amber-400",O==="low"&&"text-muted-foreground"),children:e.jsx(Qr,{className:$("h-4 w-4",O==="critical"&&"fill-destructive/20")})}),e.jsxs(Se,{children:[e.jsx(pe,{value:"low",children:"Low"}),e.jsx(pe,{value:"normal",children:"Normal"}),e.jsx(pe,{value:"high",children:"High"}),e.jsx(pe,{value:"critical",children:"Critical"})]})]}),i&&e.jsxs(R,{type:"button",variant:"ghost",size:"sm",onClick:i,"aria-label":p,className:"chat-composer__cancel h-9 rounded-[14px] px-4 text-xs text-muted-foreground",children:[e.jsx(Ge,{className:"chat-composer__cancel-icon h-4 w-4 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label",children:p})]}),e.jsxs(R,{type:"submit",size:"icon",disabled:!re||H,className:"h-10 w-10 rounded-[16px] shadow-[0_8px_30px_-8px_hsl(var(--primary)/0.6)]",children:[H?e.jsx(ce,{className:"h-4 w-4 animate-spin"}):e.jsx(Sa,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:H?"Creating chat":w})]})]})]})]}),e.jsx("div",{className:"chat-composer__location flex flex-wrap items-center gap-2 px-1",children:(()=>{const X="border-border/40 bg-muted/40 text-foreground/80 hover:bg-muted/60 hover:text-foreground";return e.jsxs(e.Fragment,{children:[e.jsx(yt,{value:F,onChange:L,assignTo:W,nodes:t,assignableNodes:N,layout:"composer",chipClassName:ee,chipActiveClassName:X,chipInactiveClassName:X,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"}),e.jsx(zs,{value:q,onChange:E,project:F,assignTo:W,nodes:t,assignableNodes:N,layout:"composer",chipClassName:ee,chipActiveClassName:X,chipInactiveClassName:X,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"})]})})()})]})})(),(P||Q)&&e.jsxs("div",{className:"space-y-3 rounded-[20px] border border-border/60 bg-background/45 p-4",children:[P,Q&&e.jsx("div",{className:"text-xs text-destructive",children:Q}),!Q&&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:A,className:$("space-y-5",f),children:[e.jsx("input",{ref:V,type:"file",accept:"image/*",multiple:!0,onChange:J,className:"hidden"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Me,{htmlFor:"task-description",className:"text-sm font-medium",children:"Opening prompt"}),e.jsx("textarea",{id:"task-description",value:C,onChange:ee=>g(ee.target.value),onKeyDown:v,onPaste:de,placeholder:"Describe what the agent should do. This becomes the first message in the chat.",rows:6,autoFocus:h,className:"flex min-h-[144px] w-full resize-none 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(R,{type:"button",variant:"outline",onClick:K,className:"rounded-[16px]",children:[e.jsx(Gt,{className:"h-4 w-4"}),"Add images"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Ctrl/Cmd+Enter starts the chat. Enter adds a new line. Upload or paste screenshots and reference images with the opening prompt."})]}),P,Q&&e.jsx("p",{className:"text-xs text-destructive",children:Q})]}),e.jsxs("div",{className:"grid gap-5 lg:grid-cols-[minmax(0,1fr)_220px_220px]",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Me,{htmlFor:"task-title",className:"text-sm font-medium",children:"Chat title"}),e.jsx(He,{id:"task-title",type:"text",value:u,onChange:ee=>b(ee.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:I?`Will appear as: ${I}`:"A title will be generated from the first line of the prompt."})]}),ge,Ce]}),Ke,Pe,e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[be,te]}),e.jsxs("div",{className:$("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",j),children:[i&&e.jsx(R,{type:"button",variant:"ghost",onClick:i,className:"rounded-[16px]",children:p}),e.jsx(R,{type:"submit",disabled:!re||H,className:"rounded-[16px] px-5",children:H?"Creating...":w})]})]})}function pi({nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,defaultMode:f="chat",mode:j,onModeChange:w,layout:p="default",className:h,footerClassName:l,autoFocus:u=!1}){const[b,C]=a.useState(f),g=j!==void 0,M=g?j:b,m=y=>{g||C(y),w==null||w(y)};return e.jsxs("div",{className:$("space-y-4",h),children:[!g&&e.jsxs("div",{className:"flex items-center gap-2 rounded-[20px] border border-border/60 bg-background/45 p-1",children:[e.jsxs(R,{type:"button",variant:M==="chat"?"default":"ghost",onClick:()=>m("chat"),className:"flex-1 rounded-[16px]",children:[e.jsx(Tn,{className:"h-4 w-4"}),"New chat"]}),e.jsxs(R,{type:"button",variant:M==="native"?"default":"ghost",onClick:()=>m("native"),className:"flex-1 rounded-[16px]",children:[e.jsx(ls,{className:"h-4 w-4"}),"Load session"]})]}),M==="chat"?e.jsx(hi,{nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,footerClassName:l,submitLabel:p==="composer"?"Start chat":"Create chat",cancelLabel:"Cancel",autoFocus:u,layout:p}):e.jsx(xi,{nodes:t,currentNodeRole:s,currentNodeId:n,leaderNodeId:o,onCreated:r,onCancel:i,footerClassName:l,autoFocus:u})]})}const at="72f988bf-86f1-41af-91ab-2d7cd011db47",$a=`${at} (MSIT)`;function fi({open:t,onOpenChange:s,onShare:n,onStopShare:o,sharing:r,stopping:i=!1,shareResult:f}){return e.jsx(as,{open:t,onOpenChange:s,children:e.jsxs(ns,{className:"max-w-md rounded-[22px] p-5",children:[e.jsx(rs,{className:"sr-only",children:"Share conversation"}),e.jsx(gi,{onOpenChange:s,onShare:n,onStopShare:o,sharing:r,stopping:i,shareResult:f})]})})}function gi({onOpenChange:t,onShare:s,onStopShare:n,sharing:o,stopping:r=!1,shareResult:i}){const[f,j]=a.useState((i==null?void 0:i.tenant)??at),[w,p]=a.useState((i==null?void 0:i.scope)??"chat"),h=i!=null&&i.url?ra(i.url):null,l=o||r;return a.useEffect(()=>{j((i==null?void 0:i.tenant)??at),p((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(bi,{value:f,onChange:j,disabled:l}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:"Access"}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(qs,{active:w==="chat",title:"Chat only",description:"Conversation transcript and opening prompt.",onClick:()=>p("chat")}),e.jsx(qs,{active:w==="filesPreview",title:"Chat, files and preview",description:"Transcript plus task output files and HTML preview.",onClick:()=>p("filesPreview")})]})]}),h&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:"Shared link"}),e.jsxs("div",{className:"flex items-center gap-2 rounded-[16px] border border-border/70 bg-muted/30 px-3 py-2",children:[e.jsx("input",{readOnly:!0,value:h,className:"min-w-0 flex-1 bg-transparent font-mono text-xs text-foreground outline-none","aria-label":"Shared link"}),e.jsx(R,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-[12px] text-muted-foreground",onClick:()=>void st(h,"Shared link copied"),"aria-label":"Copy shared link",title:"Copy shared link",children:e.jsx(oa,{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(R,{variant:"outline",onClick:()=>t(!1),disabled:l,className:"h-8 text-xs",children:i?"Done":"Cancel"}),i&&n&&e.jsxs(R,{variant:"outline",onClick:()=>void n(),disabled:l,className:"h-8 border-destructive/30 text-xs text-destructive hover:bg-destructive/10 hover:text-destructive",children:[r&&e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}),"Stop share"]}),e.jsxs(R,{onClick:()=>void s({tenant:f,scope:w}),disabled:l,className:"h-8 text-xs",children:[o&&e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}),i?"Update link":"Share link"]})]})]})}function bi({value:t,onChange:s,disabled:n}){const[o,r]=a.useState(!1),[i,f]=a.useState(!1),[j,w]=a.useState(t),p=a.useRef(null);a.useEffect(()=>{w(t)},[t]),a.useEffect(()=>{if(!o)return;const l=b=>{var g;const C=b.target;C instanceof Node&&((g=p.current)!=null&&g.contains(C)||(r(!1),f(!1)))},u=b=>{b.key==="Escape"&&(r(!1),f(!1))};return document.addEventListener("mousedown",l),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",u)}},[o]);const h=l=>{const u=l.trim();u&&(s(u),w(u),f(!1),r(!1))};return e.jsxs("div",{className:"space-y-2 text-xs",ref:p,children:[e.jsx("div",{className:"font-medium text-foreground",children:"Tenant"}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>!n&&r(l=>!l),disabled:n,className:"flex h-9 w-full items-center justify-between gap-2 rounded-[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:vi(t)}),e.jsx(Ze,{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:()=>h(at),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:$a}),t===at&&e.jsx(ct,{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:j,onChange:l=>w(l.target.value),onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),h(j))},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:()=>h(j),className:"flex h-7 w-7 items-center justify-center rounded-[11px] hover:bg-background/60",children:e.jsx(ct,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{w(t),f(!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(Ge,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>f(!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(ot,{className:"h-3 w-3"})]})})]})]})]})}function vi(t){return t===at?$a:t}function qs({active:t,title:s,description:n,onClick:o}){return e.jsxs("button",{type:"button",onClick:o,className:t?"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:s}),e.jsx("div",{className:"mt-1 text-[11px] leading-4 text-muted-foreground",children:n})]})}function ji(t){const s=t.map(n=>n.type==="text"?n.text:n.type==="image"?n.filename?`Image: ${n.filename}`:"Image attachment":n.isError?`Tool result error: ${n.content}`:`Tool result: ${n.content}`).join(" ").replace(/\s+/g," ").trim();return s?s.length>160?`${s.slice(0,157)}...`:s:"Queued follow-up"}function Ni({messages:t,onCancelMessage:s}){return t.length===0?null:e.jsx("div",{className:"border-t border-border/55 bg-card/30 px-3 py-2 sm:px-5",children:e.jsxs("div",{className:"mx-auto max-w-[72rem] rounded-[16px] border border-border/65 bg-background/58 px-3 py-2 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium text-foreground",children:[e.jsx(io,{className:"h-3.5 w-3.5 text-primary"}),"Queued messages",e.jsx("span",{className:"ml-auto rounded-[9px] border border-border/60 bg-muted/60 px-1.5 py-0 text-[10px] text-muted-foreground",children:t.length})]}),e.jsx("div",{className:"mt-2 space-y-1.5",children:t.map((n,o)=>e.jsxs("div",{className:"flex min-w-0 items-start gap-2 text-[11px] leading-5 text-muted-foreground",children:[e.jsx("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-[7px] bg-primary/10 text-[10px] font-medium text-primary",children:o+1}),e.jsx("span",{className:"min-w-0 flex-1 break-words [overflow-wrap:anywhere]",children:ji(n.content)}),s&&e.jsx(R,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 shrink-0 rounded-[8px] text-muted-foreground hover:text-destructive",title:"Cancel queued message","aria-label":"Cancel queued message",onClick:()=>s(n.id),children:e.jsx(Ge,{className:"h-3 w-3"})})]},n.id))})]})})}const wi=a.lazy(async()=>({default:(await os(()=>import("./FilesTab-BoGft5xw.js"),__vite__mapDeps([0,1,2,3,4,5]))).FilesTab})),yi=a.lazy(async()=>({default:(await os(()=>import("./PreviewTab-Bv6dERjR.js"),__vite__mapDeps([6,1,2,7]))).PreviewTab})),ki=a.lazy(async()=>({default:(await os(()=>import("./DiffTab-CktFHjP4.js"),__vite__mapDeps([8,1,2,4,3,5,7]))).DiffTab}));function Si({onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:f,activeTab:j,setActiveTab:w,creatingTask:p,createMode:h,activeTask:l,assignedNode:u,taskLoading:b,taskError:C,displayEvents:g,initialPromptAlreadyInLogs:M,initialPrompt:m,supportsFollowUp:y,taskUnavailable:_,chatDisabled:F,chatDisabledReason:L,questionBypassEnabled:q,isRunning:E,isStarting:O,hasPendingFollowUp:U,canCancel:N,canRetry:T,onRetry:W,onCancel:se,onShareTask:H,onStopShareTask:G,onStartCreateTask:ie,onCancelCreateTask:ae,onCreateTask:Z,onSendMessage:Q,onCancelQueuedMessage:V,onQuestionBypassChange:K,onSubmitQuestionResponse:J,messagesEndRef:de}){const[x,B]=a.useState(!1),[k,Y]=a.useState(!1),[c,A]=a.useState(!1),[I,re]=a.useState(!1),[v,P]=a.useState(!1),[te,ge]=a.useState({}),[Ce,be]=a.useState(new Set),[Ke,Pe]=a.useState(new Set),ee=a.useRef(0),ue=a.useRef(!1),he=a.useRef(null),S=a.useRef(0),we=a.useCallback(Ee=>{const je=Ee.currentTarget,Ue=ee.current;if(ee.current=je.scrollTop,ue.current)return;if(je.scrollHeight-je.scrollTop-je.clientHeight<30){B(!1),ue.current=!0,setTimeout(()=>{ue.current=!1},300);return}je.scrollTop<Ue&&Ue-je.scrollTop>10&&B(!0),je.scrollTop<=0&&B(!0)},[]),X=(l==null?void 0:l.effectiveProjectPath)??(l==null?void 0:l.project)??"default workspace",Ae=l?(u==null?void 0:u.name)??ia(l.assignedTo,i==null?void 0:i.nodes,l.assignedNodeName):"unassigned",Ie=l!=null&&l.assignedTo?e.jsxs(e.Fragment,{children:["Connecting session on node ",e.jsx("span",{className:"font-medium text-foreground",children:Ae}),"..."]}):"Connecting session to an available node...",lt=l?[{label:"Working dir",value:X,mono:!0},...l.branch?[{label:"Branch",value:l.branch,mono:!0}]:[],{label:"Agent",value:l.agent,mono:!0},{label:"Node",value:Ae}]:[],$e=!!(m&&!M),ze=$e||g.length>0,Le=E&&ze,De=(O||U||E)&&!Le,ve=(l==null?void 0:l.conversationKind)==="nativeSession",Qe=(l==null?void 0:l.queuedMessages)??[],ht=l&&!Ce.has(l.id)?te[l.id]??l.activeShare??null:null;return p?e.jsx(Ci,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:f,defaultMode:h,onCancel:ae,onCreated:Z}):!l&&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(Zt,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:f})}),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(ce,{className:"h-7 w-7 animate-spin"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-2xl font-semibold tracking-tight text-foreground",children:"Loading conversation"}),e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[11px] text-muted-foreground",children:[e.jsx(ce,{className:"h-4 w-4 animate-spin"}),"Fetching the selected chat thread..."]})]})]})})]}):l?e.jsxs(la,{value:j,onValueChange:Ee=>{j==="transcript"&&he.current&&(S.current=he.current.scrollTop),w(Ee),Ee==="transcript"&&requestAnimationFrame(()=>{he.current&&(he.current.scrollTop=S.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(Ra,{desktopTasksOpen:s,mobileTasksPanelOpen:n,onToggleTasks:t}),e.jsx("h2",{className:"min-w-0 truncate text-sm font-semibold tracking-tight text-foreground sm:text-lg",title:l.title,children:l.title}),ve&&e.jsx(_e,{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(da,{status:l.status}),e.jsx(Mn,{priority:l.priority}),e.jsx(R,{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(cs,{className:"h-4 w-4"}):e.jsx(ka,{className:"h-4 w-4"})})]}),C&&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:C}),e.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[e.jsxs(ca,{className:"h-auto max-w-full overflow-x-auto rounded-[16px] bg-muted/70 p-0.5",children:[e.jsx(Je,{value:"transcript",className:"rounded-[12px] px-2 py-0.5 text-[11px] sm:px-2.5",children:"Transcript"}),e.jsx(Je,{value:"files",className:"rounded-[12px] px-2 py-0.5 text-[11px] sm:px-2.5",children:"Files"}),e.jsx(Je,{value:"preview",className:"rounded-[12px] px-2 py-0.5 text-[11px] sm:px-2.5",children:"Preview"}),e.jsx(Je,{value:"diff",className:"rounded-[12px] px-2 py-0.5 text-[11px] sm:px-2.5",children:"Diff"})]}),E&&e.jsx(_e,{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"}),_&&e.jsx(_e,{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 ",An(l.updatedAt)]}),e.jsx("span",{className:"font-mono",children:l.id.slice(0,8)}),T&&e.jsxs(R,{variant:"outline",size:"sm",onClick:W,className:"h-7 shrink-0 rounded-[12px] px-2 text-[11px]",children:[e.jsx(vo,{className:"h-3.5 w-3.5"}),"Retry"]}),e.jsxs(R,{type:"button",variant:"outline",size:"sm",disabled:_,title:_?"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:()=>A(!0),children:[e.jsx(yo,{className:"h-3.5 w-3.5"}),"Share"]})]})]})]}),e.jsx(Ye,{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:he,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:we,children:e.jsxs("div",{className:"mx-auto flex max-w-[72rem] flex-col gap-5",children:[$e&&m&&e.jsx($s,{event:m,questionBypassEnabled:q,onQuestionBypassChange:K,onSubmitQuestionResponse:J,questionResponseDisabled:!y||F}),g.map((Ee,je)=>e.jsx($s,{event:Ee,questionBypassEnabled:q,onQuestionBypassChange:K,onSubmitQuestionResponse:J,questionResponseDisabled:!y||F},Br("transcript",Ee,je))),!ze&&!De&&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...":ve?"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."})]}),(!y&&l.result||l.error)&&e.jsxs("div",{className:"space-y-3",children:[!y&&l.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(l.result,null,2)})]}),l.error&&!Ke.has(l.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:()=>Pe(Ee=>new Set(Ee).add(l.id)),className:"rounded p-0.5 hover:bg-destructive/20","aria-label":"Dismiss error",children:e.jsx(Ge,{className:"h-3.5 w-3.5"})})]}),e.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-[11px] leading-5",children:l.error})]})]}),De&&e.jsx(Hs,{children:Ie}),Le&&e.jsx(Hs,{children:"The agent is still working on this conversation."}),e.jsx("div",{ref:de})]})}),y?e.jsxs(e.Fragment,{children:[x&&e.jsx(R,{size:"icon",onClick:()=>B(!1),className:"absolute bottom-4 right-4 z-10 h-12 w-12 rounded-[18px] shadow-lg",children:e.jsx(ot,{className:"h-4 w-4"})}),e.jsxs("div",{className:`shrink-0 ${x?"hidden":""}`,children:[e.jsx(Ni,{messages:Qe,onCancelMessage:V}),e.jsx("div",{className:"mx-auto w-full max-w-[72rem]",children:e.jsx(Io,{onSend:Q,disabled:F,disabledReason:L,contextItems:lt,placeholder:F?L:E?"Queue a message for the next turn...":"Continue the conversation...",running:E||U,onStop:N?()=>Y(!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(Ye,{value:"files",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(a.Suspense,{fallback:e.jsx(Bt,{label:"Loading files..."}),children:e.jsx(wi,{taskId:l.id})})}),e.jsx(Ye,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(a.Suspense,{fallback:e.jsx(Bt,{label:"Loading preview..."}),children:e.jsx(yi,{taskId:l.id})})}),e.jsx(Ye,{value:"diff",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(a.Suspense,{fallback:e.jsx(Bt,{label:"Loading diff..."}),children:e.jsx(ki,{taskId:l.id})})}),e.jsx(Rt,{open:k,onOpenChange:Y,children:e.jsxs(Ot,{children:[e.jsxs(It,{children:[e.jsx(Ft,{children:"Stop this task?"}),e.jsx(zt,{children:"The task will stop and move to a cancelled state."})]}),e.jsxs(Ut,{children:[e.jsx(Vt,{children:"Keep running"}),e.jsx(qt,{onClick:se,children:"Stop task"})]})]})}),e.jsx(fi,{open:c,onOpenChange:A,sharing:I,stopping:v,shareResult:ht,onShare:async Ee=>{if(!l)return null;re(!0);try{const je=await H(Ee);return je!=null&&je.url&&(ge(Ue=>({...Ue,[l.id]:je})),be(Ue=>{const dt=new Set(Ue);return dt.delete(l.id),dt})),je}finally{re(!1)}},onStopShare:async()=>{if(!l)return!1;P(!0);try{const Ee=await G();return Ee!==!1&&(ge(je=>{const Ue={...je};return delete Ue[l.id],Ue}),be(je=>new Set(je).add(l.id))),Ee}finally{P(!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(Zt,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:f})}),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(na,{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(R,{onClick:ie,className:"mt-6 rounded-[18px] px-5",children:[e.jsx(ds,{className:"h-4 w-4"}),"Start or load chat"]}),C&&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:C})]})})]})}function Hs({children:t}){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(ce,{className:"h-4 w-4 shrink-0 animate-spin"}),e.jsx("div",{className:"min-w-0 leading-5",children:t})]})}function Ci({onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:f,defaultMode:j,onCancel:w,onCreated:p}){var b,C,g;const[h,l]=a.useState(j??"chat");a.useEffect(()=>{j&&l(j)},[j]);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:ds},{value:"native",label:"Load session",icon:ls}].map(M=>{const m=M.icon,y=M.value===h;return e.jsxs("button",{type:"button",onClick:()=>l(M.value),"aria-pressed":y,className:$("flex items-center gap-1.5 rounded-[14px] px-2 py-1 transition-all duration-200",y?"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:M.label})]},M.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(Zt,{onToggleTasks:t,desktopTasksOpen:s,mobileTasksPanelOpen:n,operationsOpen:o,onToggleOperations:r,cluster:i,sseConnected:f,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(pi,{nodes:(i==null?void 0:i.nodes)??[],currentNodeRole:(b=i==null?void 0:i.self)==null?void 0:b.role,currentNodeId:((C=i==null?void 0:i.self)==null?void 0:C.id)??null,leaderNodeId:((g=i==null?void 0:i.leader)==null?void 0:g.id)??null,mode:h,onModeChange:l,onCreated:p,onCancel:w,autoFocus:!0,layout:"composer"})})})]})}function Zt({onToggleTasks:t,desktopTasksOpen:s,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(Ra,{desktopTasksOpen:s,mobileTasksPanelOpen:n,onToggleTasks:t})}),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(R,{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(cs,{className:"h-4 w-4"}):e.jsx(ka,{className:"h-4 w-4"})})]})}function Ra({desktopTasksOpen:t,mobileTasksPanelOpen:s,onToggleTasks:n}){var r,i;const o=(i=(r=globalThis.window)==null?void 0:r.matchMedia("(min-width: 1024px)"))!=null&&i.matches?t:s;return e.jsx(R,{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(ya,{className:"h-4 w-4"}):e.jsx(xo,{className:"h-4 w-4"})})}function Di({onAdded:t}){const[s,n]=a.useState(""),[o,r]=a.useState(!1),[i,f]=a.useState(null),j=a.useCallback(async w=>{if(w.preventDefault(),!!s.trim()){r(!0),f(null);try{await Ln({leaderEndpoint:s.trim(),transport:"devtunnel"}),t()}catch(p){f(p instanceof Error?p.message:"Failed to join node")}finally{r(!1)}}},[s,t]);return e.jsx(ns,{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(ua,{className:"space-y-2 text-left",children:[e.jsx(rs,{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:j,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(Me,{htmlFor:"leader-endpoint",children:"Leader endpoint"}),e.jsx(_e,{variant:"outline",className:"rounded-[11px] border-border/70 bg-background/60 text-[10px] uppercase tracking-[0.16em]",children:"DevTunnel only"})]}),e.jsx(He,{id:"leader-endpoint",type:"url",value:s,onChange:w=>n(w.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(xa,{className:"border-t border-border/60 pt-4",children:e.jsx(R,{type:"submit",disabled:!s.trim()||o,className:"rounded-[16px]",children:o?"Joining...":"Join node"})})]})]})})}function Ei({open:t,onOpenChange:s,onAdded:n}){return e.jsx(as,{open:t,onOpenChange:s,children:e.jsx(Di,{onAdded:()=>{s(!1),n()}})})}const Ti=10,Xe="__all__";function Fe(t){return"session"in t}function Ks(t,s){var n;return s&&t.some(o=>o.id===s)?s:((n=t[0])==null?void 0:n.id)??""}function $t(t){return t&&(Aa(t.id)||t.workDir)||""}function jt(t,s,n){let o=!1;const r=t.map(i=>Fe(i)&&i.session.id===n.id?(o=!0,{...i,nodeName:s,session:n}):i);return es(o?r:[...r,{id:`session-${n.id}`,nodeName:s,session:n}])}function Oa(t,s){return t.filter(Fe).filter(n=>n.session.nodeId===s).sort((n,o)=>o.session.startedAt-n.session.startedAt)}function _i(t){const s=t.filter(Fe).sort((n,o)=>o.session.startedAt-n.session.startedAt);return{active:s.filter(n=>n.session.status==="running"),completed:s.filter(n=>n.session.status!=="running")}}function Mi(t,s){return!!(t&&s&&!t.contains(s))}function Ai(t,s,n){var r;if(n===Xe)return n;const o=Oa(t,s);return o.some(i=>i.session.id===n)?n:((r=o[0])==null?void 0:r.session.id)??Xe}function Li(t,s,n){return n===Xe?t.filter(o=>!Fe(o)||o.session.nodeId===s):t.filter(o=>Fe(o)&&o.session.nodeId===s&&o.session.id===n)}function es(t){const s=t.map((o,r)=>({entry:o,index:r})).filter(({entry:o})=>Fe(o)&&o.session.status!=="running").sort((o,r)=>!Fe(o.entry)||!Fe(r.entry)?0:r.entry.session.startedAt-o.entry.session.startedAt||r.index-o.index),n=new Set(s.slice(0,Ti).map(({entry:o})=>Fe(o)?o.session.id:""));return t.filter(o=>!Fe(o)||o.session.status==="running"||n.has(o.session.id))}function ts(t){return t.status==="running"?t.pid?`running pid ${t.pid}`:"running":t.status==="exited"?`exit ${t.exitCode??0}`:t.status==="stopped"?"stopped":t.signal?`failed ${t.signal}`:`exit ${t.exitCode??"failed"}`}function Bi(t){const s=t.session.command.length>48?`${t.session.command.slice(0,45)}...`:t.session.command;return`${t.nodeName} - ${ts(t.session)} - ${s}`}function Ia(t,s=48){return t.length>s?`${t.slice(0,s-3)}...`:t}function Pi(t,s){return s===Xe?"All sessions":t?Ia(t.session.command,34):"Command session"}function Ws(t){return t.status==="stopped"?"":t.stderr}function $i({nodes:t,defaultNodeId:s,onClose:n,initialHistory:o=[]}){const[r,i]=a.useState(()=>Ks(t,s)),f=a.useMemo(()=>t.find(x=>x.id===r)??t[0]??null,[t,r]),[j,w]=a.useState(()=>$t(f)),[p,h]=a.useState(""),[l,u]=a.useState(()=>es(o)),[b,C]=a.useState(Xe),[g,M]=a.useState(!1),[m,y]=a.useState(!1),[_,F]=a.useState(!1),[L,q]=a.useState(!1),[E,O]=a.useState(!1),U=a.useRef(null),N=a.useRef(null),T=a.useMemo(()=>t.find(x=>x.id===r)??t[0]??null,[t,r]),W=a.useMemo(()=>Oa(l,(T==null?void 0:T.id)??""),[l,T]),se=a.useMemo(()=>_i(W),[W]),H=a.useMemo(()=>W.find(x=>x.session.id===b),[b,W]),G=a.useMemo(()=>Li(l,(T==null?void 0:T.id)??"",b),[l,T,b]),ie=a.useRef((T==null?void 0:T.id)??"");a.useEffect(()=>{r&&t.some(x=>x.id===r)||i(Ks(t,s))},[s,t,r]),a.useEffect(()=>{const x=(T==null?void 0:T.id)??"";ie.current!==x&&(ie.current=x,w($t(T)))},[T]),a.useEffect(()=>{C(x=>Ai(l,(T==null?void 0:T.id)??"",g?x:""))},[l,T,g]),a.useEffect(()=>{var x;(x=U.current)==null||x.scrollTo({top:U.current.scrollHeight})},[l]),a.useEffect(()=>{let x=!1;async function B(){const k=await Promise.allSettled(t.map(async Y=>({node:Y,response:await Pn(Y.id)})));x||u(Y=>k.reduce((c,A)=>A.status!=="fulfilled"?c:A.value.response.sessions.reduce((I,re)=>jt(I,A.value.node.name,re),c),Y))}return t.length>0&&B(),()=>{x=!0}},[t]),a.useEffect(()=>{const x=l.filter(Fe).filter(k=>k.session.status==="running");if(x.length===0)return;const B=window.setInterval(()=>{for(const k of x)Bn(k.session.nodeId,k.session.id).then(Y=>u(c=>jt(c,k.nodeName,Y))).catch(()=>{})},1e3);return()=>window.clearInterval(B)},[l]);const ae=a.useRef(null);async function Z(x){if(x.preventDefault(),!T||!p.trim()||E)return;const B=p.trim(),k=T.name;O(!0),h("");try{const Y=await Rn(T.id,{command:B,...j.trim()?{cwd:j.trim()}:{}});u(c=>jt(c,k,Y)),C(Y.id),M(!0)}catch(Y){u(c=>[...c,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,nodeName:k,command:B,error:Y instanceof Error?Y.message:"Command failed"}])}finally{O(!1)}}async function Q(x,B){x.stopPropagation();const k=await $n(B.session.nodeId,B.session.id);u(Y=>jt(Y,B.nodeName,k))}function V(x){C(x),M(!0),y(!1)}function K(x){m&&Mi(N.current,x.target)&&y(!1)}function J(x,B,k,Y,c){return e.jsxs("div",{className:"border-t border-border/60 py-1",children:[e.jsxs("button",{type:"button",onClick:Y,"aria-label":`Toggle ${x} sessions`,"aria-expanded":!k,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:x}),e.jsx(Ze,{className:$("h-3 w-3 transition-transform",k&&"-rotate-90")})]}),!k&&(B.length>0?B.map(de):e.jsx("div",{className:"px-2 py-1 text-[11px] text-muted-foreground",children:c}))]})}function de(x){const B=b===x.session.id,k=x.session.status==="running";return e.jsxs("div",{className:$("group flex w-full items-center gap-2 px-2 py-1.5 text-left text-[11px] transition-colors hover:bg-muted/65",B&&"bg-primary/10 text-primary"),children:[e.jsxs("button",{type:"button",onClick:()=>V(x.session.id),className:"flex min-w-0 flex-1 items-center gap-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:[e.jsx("span",{className:$("flex h-4 w-4 shrink-0 items-center justify-center",k?"text-primary":x.session.status==="exited"?"text-emerald-600 dark:text-emerald-300":"text-amber-600 dark:text-amber-300"),children:k?e.jsx(ce,{className:"h-3 w-3 animate-spin"}):x.session.status==="exited"?e.jsx(As,{className:"h-3 w-3"}):e.jsx(Nt,{className:"h-3 w-3"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-foreground",children:Ia(x.session.command,44)}),e.jsxs("span",{className:"block truncate text-[10px] text-muted-foreground",children:[x.nodeName," · ",ts(x.session)]})]})]}),k&&e.jsx("button",{type:"button",onClick:Y=>void Q(Y,x),"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(Is,{className:"h-3 w-3"})})]},x.session.id)}return e.jsx("section",{className:"dashboard-panel animate-composer-settle shrink-0 overflow-visible rounded-[24px]","aria-label":"Node terminal",onClick:K,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(Lt,{className:"h-3.5 w-3.5"})}):e.jsx(Lt,{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:N,className:"relative min-w-0",children:[e.jsxs("button",{type:"button","aria-label":"Command session","aria-expanded":m,title:H?Bi(H):"All sessions",onClick:()=>y(x=>!x),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:Pi(H,b)}),e.jsx(Ze,{className:$("h-3 w-3 shrink-0 text-muted-foreground transition-transform",m&&"rotate-180")})]}),e.jsx("div",{"aria-hidden":!m,className:$("absolute right-0 bottom-9 z-30 w-[19rem] overflow-hidden rounded-xl border border-border/70 bg-popover text-popover-foreground shadow-xl",!m&&"hidden"),children:e.jsxs("div",{className:"max-h-72 overflow-y-auto",children:[e.jsxs("button",{type:"button",onClick:()=>V(Xe),className:$("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===Xe&&"bg-primary/10 text-primary"),children:[e.jsx(Lt,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:"All sessions"})]}),J("Active",se.active,_,()=>F(x=>!x),"No active sessions"),J("Completed",se.completed,L,()=>q(x=>!x),"No completed sessions")]})})]}),e.jsx("select",{value:(T==null?void 0:T.id)??"",onChange:x=>{i(x.target.value),M(!1),w($t(t.find(B=>B.id===x.target.value)??null))},disabled:E||t.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:t.map(x=>e.jsx("option",{value:x.id,className:"bg-background text-foreground",children:x.name},x.id))}),e.jsx(yt,{value:j,onChange:w,assignTo:(T==null?void 0:T.id)??"",nodes:t,assignableNodes:t,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:U,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 x;return(x=ae.current)==null?void 0:x.focus()},children:[G.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:G.map(x=>Fe(x)?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:[x.nodeName,"$"]}),e.jsx("span",{className:"break-all text-foreground",children:x.session.command}),e.jsxs("span",{className:$("inline-flex items-center gap-1",x.session.status==="running"||x.session.status==="exited"?"text-primary":"text-amber-600 dark:text-amber-300"),children:[x.session.status==="running"?e.jsx(ce,{className:"h-3 w-3 animate-spin"}):x.session.status==="exited"?e.jsx(As,{className:"h-3 w-3"}):e.jsx(Nt,{className:"h-3 w-3"}),ts(x.session)]}),x.session.status==="running"&&e.jsx("button",{type:"button",onClick:B=>void Q(B,x),"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(Is,{className:"h-3 w-3"})})]}),x.session.stdout&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-foreground",children:x.session.stdout}),Ws(x.session)&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:Ws(x.session)}),(x.session.stdoutTruncated||x.session.stderrTruncated)&&e.jsx("div",{className:"text-muted-foreground",children:"Output truncated to the latest output."})]},x.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:[x.nodeName,"$"]}),e.jsx("span",{className:"break-all text-foreground",children:x.command}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive",children:[e.jsx(Nt,{className:"h-3 w-3"}),"error"]})]}),e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:x.error})]},x.id))}),e.jsxs("form",{onSubmit:Z,className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"shrink-0 text-primary select-none",children:T?`${T.name}$`:"$"}),e.jsx("input",{ref:ae,value:p,onChange:x=>h(x.target.value),disabled:!T||E,placeholder:T?"":"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:!T||!p.trim()||E,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md text-primary transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70 disabled:pointer-events-none disabled:text-muted-foreground disabled:opacity-50",children:E?e.jsx(ce,{className:"h-3 w-3 animate-spin"}):e.jsx(is,{className:"h-3 w-3"})})]})]})]})})}function hs({nodeId:t,nodeName:s,onOpenSettings:n,onOpenDevBox:o,onStartDevBox:r,showConfigureDevBox:i,showStartDevBox:f,startDevBoxPending:j,className:w}){const[p,h]=a.useState(!1),l=a.useRef(null),u=j?"Starting":"Start DevBox";return a.useEffect(()=>{if(!p)return;const b=g=>{var m;const M=g.target;M instanceof Node&&((m=l.current)!=null&&m.contains(M)||h(!1))},C=g=>{g.key==="Escape"&&h(!1)};return document.addEventListener("mousedown",b),document.addEventListener("keydown",C),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",C)}},[p]),e.jsxs("div",{ref:l,className:$("relative shrink-0",w),onClick:b=>b.stopPropagation(),children:[e.jsx(R,{type:"button",variant:"ghost",size:"icon","aria-label":`More actions for ${s}`,"aria-haspopup":"menu","aria-expanded":p,title:`More actions for ${s}`,onClick:()=>h(b=>!b),className:$("h-6 w-6 rounded-[10px] text-muted-foreground hover:bg-background/70 hover:text-foreground",p&&"bg-background/80 text-primary"),children:e.jsx(Wr,{className:"h-3.5 w-3.5"})}),p&&e.jsxs("div",{role:"menu",className:"absolute right-0 top-full z-30 mt-1 min-w-40 overflow-hidden whitespace-nowrap rounded-[13px] border border-border/65 bg-popover/96 p-1 normal-case tracking-normal shadow-[0_18px_48px_-28px_rgba(0,0,0,0.45)] backdrop-blur-xl",children:[e.jsxs("button",{type:"button",role:"menuitem","aria-label":`Open ${s} settings`,title:`Open ${s} settings`,onClick:()=>{h(!1),n(t)},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(On,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:"Settings"})]}),f&&r&&e.jsxs("button",{type:"button",role:"menuitem","aria-label":`${u} for ${s}`,title:`${u} for ${s}`,onClick:()=>{j||(h(!1),r(t))},disabled:j,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 disabled:cursor-not-allowed disabled:opacity-60",children:[j?e.jsx(ce,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-primary"}):e.jsx(is,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:u})]}),i&&o&&e.jsxs("button",{type:"button",role:"menuitem","aria-label":`Configure DevBox for ${s}`,title:`Configure DevBox for ${s}`,onClick:()=>{h(!1),o(t)},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(In,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("span",{children:"Configure DevBox"})]})]})]})}const Ri=new Set(["deallocated","hibernate","hibernated","sleep","sleeping","stopped"]),Oi=new Set(["startinprogress","starting"]);function nt(t){return!!(t!=null&&t.enabled&&t.name)}function Ii(t){const s=t==null?void 0:t.trim().toLowerCase().replace(/[\s_-]+/gu,"");return!!(s&&Ri.has(s))}function rt(t){const s=t==null?void 0:t.trim().toLowerCase().replace(/[\s_-]+/gu,"");return!!(s&&Oi.has(s))}function kt(t,s,n){return t==="offline"&&Ii(s)&&nt(n)}function Gs(t,s){return t==="offline"&&nt(s)}function Qs(t){return!nt(t)}function Fi({nodeStatus:t,status:s,current:n,selected:o}){const r=o??n;return r&&kt(t,s,r)?r:null}function Te(t){return t.scope||`name:${t.name??""}`}function zi({previousKey:t,baseDevBox:s,listed:n}){if(t&&n.some(i=>Te(i)===t))return t;if(!nt(s))return n[0]?Te(n[0]):"";const o=Te(s),r=n.find(i=>Te(i)===o)??n.find(i=>i.name===s.name);return r?Te(r):o}function Js({cluster:t,systemInfo:s,nodeNameById:n,nodeBlockingTaskCounts:o,eventTypeFilter:r,onEventTypeFilterChange:i,eventTypeOptions:f,filteredEvents:j,sseConnected:w,clusterLoading:p,clusterError:h,promotePending:l,onPromote:u,onAddNode:b,leavePending:C,onLeaveCluster:g,onToggleNodeDevTunnel:M,devTunnelNodeId:m,devBoxStartNodeId:y,devBoxStartingNodeIds:_=new Set,onOpenNodeSettings:F,onOpenDevBox:L,onStartDevBox:q,onClose:E}){var ae,Z,Q;const O=((ae=t==null?void 0:t.self)==null?void 0:ae.role)==="leader",U=((Z=t==null?void 0:t.self)==null?void 0:Z.role)==="follower"&&!(t!=null&&t.leader),N=(t==null?void 0:t.self)??null,W=Fn((t==null?void 0:t.nodes)??[],N==null?void 0:N.id).filter(V=>V.id!==(N==null?void 0:N.id)),se=t!=null&&t.leader?t.nodes.find(V=>{var K;return V.id===((K=t.leader)==null?void 0:K.id)})??null:null,H=t!=null&&t.leader?t.leader.dashboardOrigin??(se==null?void 0:se.dashboardOrigin)??(s&&t.leader.id===(s.nodeId??s.id)?s.dashboardOrigin:void 0)??t.leader.endpoint:null,G=(N==null?void 0:N.role)==="leader"&&W.length===0,ie=(N==null?void 0:N.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(la,{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(R,{variant:"ghost",size:"icon",onClick:E,className:"h-7 w-7 rounded-[12px]",children:e.jsx(cs,{className:"h-4 w-4"})})]}),e.jsxs(ca,{className:"mt-2 grid h-auto w-full grid-cols-3 rounded-[16px] bg-muted/70 p-0.5",children:[e.jsx(Je,{value:"overview",className:"rounded-[12px] px-2 py-0.5 text-[11px]",children:"Overview"}),e.jsx(Je,{value:"nodes",className:"rounded-[12px] px-2 py-0.5 text-[11px]",children:"Nodes"}),e.jsx(Je,{value:"events",className:"rounded-[12px] px-2 py-0.5 text-[11px]",children:"Live events"})]})]}),e.jsx(Ye,{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:[N&&e.jsx(Ys,{node:N,systemInfo:s,blockingTaskCount:o.get(N.id)??0,devTunnelNodeId:m,onToggleNodeDevTunnel:M,showActions:!1,defaultExpanded:!1,onOpenDevBox:L,devBoxStartingNodeIds:_}),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(_e,{variant:"outline",className:"rounded-[11px] border-border/70 bg-background/60",children:w?"Connected":"Reconnecting"})]}),p&&!t?e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[e.jsx(ce,{className:"h-4 w-4 animate-spin"}),"Loading cluster state..."]}):h&&!t?e.jsx("div",{className:"rounded-[18px] border border-destructive/20 bg-destructive/10 px-2.5 py-2 text-[11px] text-destructive",children:h}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(tt,{label:"Term",value:String((t==null?void 0:t.term)??0)}),e.jsx(tt,{label:"Nodes",value:String((t==null?void 0:t.nodes.length)??0)}),e.jsx(tt,{label:"Pending",value:String((t==null?void 0:t.taskSummary.pending)??0)}),e.jsx(tt,{label:"Running",value:String((t==null?void 0:t.taskSummary.running)??0)}),e.jsx(tt,{label:"Completed",value:String((t==null?void 0:t.taskSummary.completed)??0)}),e.jsx(tt,{label:"Failed",value:String((t==null?void 0:t.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(qe,{label:"Leader",value:((Q=t==null?void 0:t.leader)==null?void 0:Q.name)??"None"}),e.jsx(qe,{label:"Leader URL",value:H??"Unavailable",mono:!0,action:H?e.jsx(mt,{label:"Copy leader URL",onClick:()=>void st(H,"Leader URL copied")}):void 0}),e.jsx(qe,{label:"Feed",value:w?"Receiving live updates":"Reconnecting to event stream"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:U&&e.jsxs(R,{variant:"outline",size:"sm",onClick:u,disabled:l,className:"h-7 rounded-[12px] px-2.5 text-[11px]",children:[l&&e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}),"Promote self"]})})]})]})]})})}),e.jsx(Ye,{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"}),G?e.jsx(R,{variant:"outline",size:"sm",onClick:b,className:"h-7 rounded-[12px] px-2.5 text-[11px]",children:"Join node"}):ie?e.jsxs(R,{variant:"outline",size:"sm",onClick:g,disabled:C,className:"h-7 rounded-[12px] px-2.5 text-[11px]",children:[C&&e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}),"Leave cluster"]}):null]}),N&&e.jsx(Ys,{node:N,systemInfo:s,blockingTaskCount:o.get(N.id)??0,devTunnelNodeId:m,onToggleNodeDevTunnel:M,showActions:!0,defaultExpanded:!0,onOpenNodeSettings:O?F:void 0,onOpenDevBox:O?L:void 0,onStartDevBox:O?q:void 0,devBoxStartNodeId:y,devBoxStartingNodeIds:_})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"text-[11px] font-medium text-foreground",children:["Peer nodes (",W.length,")"]}),W.length>0?e.jsx("div",{className:"space-y-2",children:W.map(V=>e.jsx(Ui,{node:V,isLeader:!!O,blockingTaskCount:o.get(V.id)??0,devTunnelNodeId:m,onToggleNodeDevTunnel:M,onOpenNodeSettings:O?F:void 0,onOpenDevBox:O?L:void 0,onStartDevBox:O?q:void 0,devBoxStartNodeId:y,devBoxStartingNodeIds:_},V.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(Ye,{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(zn,{className:$("h-4 w-4",w?"text-emerald-500":"text-destructive")}),"Live events"]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsxs(ye,{value:r,onValueChange:i,children:[e.jsx(ke,{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(Be,{placeholder:"Event type"})}),e.jsx(Se,{children:f.map(V=>e.jsx(pe,{value:V,className:"text-[11px]",children:V==="all"?"All event types":V},V))})]}),e.jsx(_e,{variant:"outline",className:"rounded-[11px] border-border/70 bg-background/60",children:w?"Connected":"Reconnecting"})]})]}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(Un,{events:j,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 Ys({node:t,systemInfo:s,blockingTaskCount:n,devTunnelNodeId:o,onToggleNodeDevTunnel:r,showActions:i=!0,defaultExpanded:f=!1,onOpenNodeSettings:j,onOpenDevBox:w,onStartDevBox:p,devBoxStartNodeId:h,devBoxStartingNodeIds:l}){var q,E,O,U;const[u,b]=a.useState(f),C=(s==null?void 0:s.dashboardOrigin)??t.dashboardOrigin,g=t.devtunnelEndpoint??t.endpoint,M=C??t.endpoint,m=(s==null?void 0:s.workDir)??t.workDir,y=Da(t,s==null?void 0:s.transportType),_=us(t,s==null?void 0:s.transportType),F=_&&it((s==null?void 0:s.transportType)??t.transportType)?!0:Ca(t,s==null?void 0:s.transportType),L=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:()=>b(N=>!N),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[u?e.jsx(Ze,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):e.jsx(ut,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx(ma,{status:t.status}),e.jsx("span",{className:"text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:"Current node"})]}),e.jsx("a",{href:M,target:"_blank",rel:"noreferrer",className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(ha,{className:"h-3.5 w-3.5"})}),j&&e.jsx(hs,{nodeId:t.id,nodeName:t.name,onOpenSettings:j,onOpenDevBox:w,onStartDevBox:p,showConfigureDevBox:(q=t.devbox)==null?void 0:q.enabled,showStartDevBox:kt(t.status,(E=t.devbox)==null?void 0:E.lastStatus,t.devbox)||rt((O=t.devbox)==null?void 0:O.lastStatus)||l.has(t.id),startDevBoxPending:h===t.id||rt((U=t.devbox)==null?void 0:U.lastStatus)||l.has(t.id)})]}),e.jsxs("button",{type:"button",onClick:()=>b(N=>!N),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:t.name}),e.jsx(pa,{role:t.role}),e.jsx(_e,{variant:"outline",className:"rounded-[11px] border-primary/30 bg-background/60 text-[10px] capitalize",children:t.status})]})]}),u&&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(qe,{label:"Node ID",value:t.id,mono:!0}),C&&e.jsx(qe,{label:"Dashboard",value:C,mono:!0,action:e.jsx(mt,{label:"Copy dashboard URL",onClick:()=>void st(C,"Dashboard URL copied")})}),e.jsx(qe,{label:"Node URL",value:g,mono:!0,action:e.jsx(mt,{label:"Copy node URL",onClick:()=>void st(g,"Node URL copied")})}),m&&e.jsx(qe,{label:"Workspace",value:m,mono:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-1.5",children:[e.jsx(Kt,{label:"Transport",value:y}),s&&e.jsx(Kt,{label:"Uptime",value:Vn(s.uptime),mono:!0})]}),e.jsx(ja,{capabilities:t.capabilities,action:i&&F?e.jsxs(R,{variant:"outline",size:"sm",onClick:()=>r(t),disabled:o===t.id||L,className:"h-7 rounded-[12px] px-2.5 text-[11px]",title:L?"Finish assigned or running tasks before changing remote access":void 0,children:[o===t.id&&e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}),_?"Disable Remote Access":"Enable Remote Access"]}):void 0}),i&&F&&L&&e.jsxs("div",{className:"text-[11px] text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function Ui({node:t,isLeader:s,blockingTaskCount:n,devTunnelNodeId:o,onToggleNodeDevTunnel:r,onOpenNodeSettings:i,onOpenDevBox:f,onStartDevBox:j,devBoxStartNodeId:w,devBoxStartingNodeIds:p}){var _,F,L,q;const[h,l]=a.useState(!1),u=t.dashboardOrigin,b=t.devtunnelEndpoint??t.endpoint,C=u??t.endpoint,g=Da(t),M=us(t),m=Ca(t),y=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:()=>l(E=>!E),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[h?e.jsx(Ze,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(ut,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx(ma,{status:t.status}),e.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:"Peer node"})]}),e.jsx("a",{href:C,target:"_blank",rel:"noreferrer",className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:e.jsx(ha,{className:"h-3.5 w-3.5"})}),s&&i&&e.jsx(hs,{nodeId:t.id,nodeName:t.name,onOpenSettings:i,onOpenDevBox:f,onStartDevBox:j,showConfigureDevBox:(_=t.devbox)==null?void 0:_.enabled,showStartDevBox:kt(t.status,(F=t.devbox)==null?void 0:F.lastStatus,t.devbox)||rt((L=t.devbox)==null?void 0:L.lastStatus)||p.has(t.id),startDevBoxPending:w===t.id||rt((q=t.devbox)==null?void 0:q.lastStatus)||p.has(t.id)})]}),e.jsxs("button",{type:"button",onClick:()=>l(E=>!E),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:t.name}),e.jsx(pa,{role:t.role}),e.jsx(_e,{variant:"outline",className:"rounded-[11px] border-border/70 bg-background/60 text-[10px] capitalize",children:t.status})]})]}),h&&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(qe,{label:"Node ID",value:t.id,mono:!0}),u&&e.jsx(qe,{label:"Dashboard",value:u,mono:!0,action:e.jsx(mt,{label:"Copy dashboard URL",onClick:()=>void st(u,"Dashboard URL copied")})}),e.jsx(qe,{label:"Node URL",value:b,mono:!0,action:e.jsx(mt,{label:"Copy node URL",onClick:()=>void st(b,"Node URL copied")})}),t.workDir&&e.jsx(qe,{label:"Workspace",value:t.workDir,mono:!0}),e.jsx(Kt,{label:"Transport",value:g})]}),e.jsx(ja,{capabilities:t.capabilities,action:s&&m?e.jsxs(R,{variant:"outline",size:"sm",onClick:()=>r(t),disabled:o===t.id||y,className:"h-7 rounded-[12px] px-2.5 text-[11px]",title:y?"Finish assigned or running tasks before changing remote access":void 0,children:[o===t.id&&e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}),M?"Disable Remote Access":"Enable Remote Access"]}):void 0}),s&&m&&y&&e.jsxs("div",{className:"text-[11px] text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function mt({label:t,onClick:s}){return e.jsx(R,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-[12px] text-muted-foreground",onClick:s,"aria-label":t,title:t,children:e.jsx(oa,{className:"h-3.5 w-3.5"})})}function Vi(t,s,n,o){var f;if(!t)return{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Select a task to continue the conversation."};const r=((f=s==null?void 0:s.self)==null?void 0:f.role)==="follower";return t.assignedTo!==null&&t.assignedNodeAvailable===!1?{taskUnavailable:!0,chatDisabled:!0,chatDisabledReason:`${t.assignedNodeName??"Assigned node"} is unavailable. Leave the cluster on that node or re-run the task elsewhere.`}:r?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Follower nodes are read-only. Use the leader dashboard to manage chat, or leave the cluster first."}:n?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Sending message..."}:o?{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Queue a message for the next turn..."}:wt.has(t.status)||t.status==="archived"?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:wt.has(t.status)?"Task has not started yet...":"Archived tasks are read-only."}:{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Continue the conversation..."}}function Xs({toolbarTasks:t,activeTaskId:s,tasksLoading:n,tasksError:o,isLeader:r,scope:i,agentFilter:f,nodeFilter:j,taskKindFilter:w,agentOptions:p,nodeOptions:h,nodeNameById:l,nodeStatusById:u,devBoxNodeIds:b=new Set,devBoxStartNodeIds:C=new Set,devBoxStartingNodeIds:g=new Set,leaderNodeId:M,searchQuery:m,selectedTaskIds:y,allVisibleTasksSelected:_,someVisibleTasksSelected:F,canBatchArchive:L,onSearchChange:q,onScopeChange:E,onAgentFilterChange:O,onNodeFilterChange:U,onTaskKindFilterChange:N,onToggleTaskSelected:T,onToggleAllVisibleTasks:W,onBatchArchive:se,onBatchDelete:H,onCreateTask:G,onOpenNodeSettings:ie,onOpenDevBox:ae,onStartDevBox:Z,onSelectTask:Q,onClose:V}){const[K,J]=a.useState(!!m),[de,x]=a.useState(!1),[B,k]=a.useState(!1),Y=a.useRef(null),c=a.useRef(null),A=a.useRef(null),I=y.size,re=i!=="active"||j!=="all"||f!=="all"||w!=="all",v=m.trim().length>0,[P,te]=a.useState(new Set),[ge,Ce]=a.useState(new Set),be=a.useMemo(()=>qn(t,l,M),[t,l,M]),Ke=be.length===1,Pe=!Ke||re||v,ee=Ke&&(re||v),ue=a.useCallback(S=>{te(we=>{const X=new Set(we);return X.has(S)?X.delete(S):X.add(S),X})},[]),he=a.useCallback(S=>{Ce(we=>{const X=new Set(we);return X.has(S)?X.delete(S):X.add(S),X})},[]);return a.useEffect(()=>{m&&J(!0)},[m]),a.useEffect(()=>{var S;K&&((S=Y.current)==null||S.focus())},[K]),a.useEffect(()=>{if(!K)return;const S=X=>{var Ie;const Ae=X.target;Ae instanceof Node&&((Ie=c.current)!=null&&Ie.contains(Ae)||J(!1))},we=X=>{X.key==="Escape"&&J(!1)};return document.addEventListener("mousedown",S),document.addEventListener("keydown",we),()=>{document.removeEventListener("mousedown",S),document.removeEventListener("keydown",we)}},[K]),a.useEffect(()=>{if(!B)return;const S=X=>{var Ie;const Ae=X.target;Ae instanceof Node&&((Ie=A.current)!=null&&Ie.contains(Ae)||k(!1))},we=X=>{X.key==="Escape"&&k(!1)};return document.addEventListener("mousedown",S),document.addEventListener("keydown",we),()=>{document.removeEventListener("mousedown",S),document.removeEventListener("keydown",we)}},[B]),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(R,{variant:"ghost",size:"icon",onClick:V,className:"rounded-[12px]",children:e.jsx(ya,{className:"h-4 w-4"})})]}),e.jsxs("div",{ref:c,className:"mt-4 flex items-center gap-1.5",children:[e.jsxs("div",{ref:A,className:$("relative flex items-stretch transition-[flex] duration-200",K?"flex-[2]":"flex-1"),children:[e.jsxs(R,{onClick:()=>{k(!1),G("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(ds,{className:"h-4 w-4"}),"New chat"]}),e.jsx(R,{onClick:()=>k(S=>!S),"aria-label":"More chat options","aria-haspopup":"menu","aria-expanded":B,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(Ze,{className:$("h-3.5 w-3.5 transition-transform",B&&"rotate-180")})}),B&&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:()=>{k(!1),G("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(ls,{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"})]})})]}),K?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(Qt,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(He,{ref:Y,value:m,onChange:S=>q(S.target.value),placeholder:"Search tasks",className:"h-11 rounded-[18px] border-border/70 bg-background/68 pl-11 text-[11px]"})]}),e.jsx(R,{variant:"outline",size:"icon",onClick:()=>J(!1),className:"rounded-[14px] border-border/70 bg-background/68",children:e.jsx(Nt,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(R,{variant:"outline",onClick:()=>J(!0),className:$("rounded-[14px] border-border/70 bg-background/68 px-3 text-[11px]",m&&"border-primary/40 bg-primary/8 text-primary"),children:[e.jsx(Qt,{className:"h-4 w-4"}),"Search"]}),e.jsx(R,{variant:de||re?"secondary":"outline",size:"icon",onClick:()=>x(S=>!S),className:$("shrink-0 rounded-[14px] border-border/70 bg-background/68",re&&"border-primary/40 bg-primary/8 text-primary"),title:"Filters",children:e.jsx(Yr,{className:"h-4 w-4"})})]})]}),(de||re)&&e.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:[e.jsxs(ye,{value:i,onValueChange:S=>E(S),children:[e.jsx(ke,{className:"h-7 rounded-[13px] border-border/70 bg-background/60 text-[12px]",children:e.jsx(Be,{})}),e.jsx(Se,{children:Hn.map(S=>e.jsx(pe,{value:S.value,className:"text-[12px]",children:S.label},S.value))})]}),e.jsxs(ye,{value:j,onValueChange:U,children:[e.jsx(ke,{className:"h-7 rounded-[13px] border-border/70 bg-background/60 text-[12px]",children:e.jsx(Be,{placeholder:"Node"})}),e.jsx(Se,{children:h.map(S=>e.jsx(pe,{value:S.value,className:"text-[12px]",children:S.label},S.value))})]}),e.jsxs(ye,{value:f,onValueChange:O,children:[e.jsx(ke,{className:"h-7 rounded-[13px] border-border/70 bg-background/60 text-[12px]",children:e.jsx(Be,{placeholder:"Agent"})}),e.jsx(Se,{children:p.map(S=>e.jsx(pe,{value:S,className:"text-[12px]",children:S==="all"?"All agents":S},S))})]}),e.jsxs(ye,{value:w,onValueChange:S=>N(S),children:[e.jsx(ke,{className:"h-7 rounded-[13px] border-border/70 bg-background/60 text-[12px]",children:e.jsx(Be,{placeholder:"Type"})}),e.jsx(Se,{children:Kn.map(S=>e.jsx(pe,{value:S.value,className:"text-[12px]",children:S.label},S.value))})]})]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-2 py-2",children:be.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(Ht,{checked:F&&!_?"indeterminate":_,onCheckedChange:S=>W(S===!0),"aria-label":"Select all visible tasks"}),e.jsx("span",{children:"Select all"})]}),I>0&&e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>W(!1),className:"h-7 rounded-[12px] px-2 text-[11px]",children:"Clear"})]}),be.map(S=>{const we=S.nodeId??"__unassigned__",X=S.dirs.reduce(($e,ze)=>$e+ze.tasks.length,0),Ae=Pe&&!ee&&P.has(we),Ie=S.nodeId!==null&&u.get(S.nodeId)==="offline",lt=!!(r&&S.nodeId&&ie);return e.jsxs("div",{className:"space-y-1",children:[Pe&&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:()=>ue(we),"aria-expanded":!Ae,className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[e.jsx(ut,{className:$("h-3.5 w-3.5 shrink-0 transition-transform duration-200",!Ae&&"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:S.nodeName}),e.jsxs(_e,{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:[X," task",X===1?"":"s"]})]})]}),e.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[Ie&&e.jsx(_e,{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"}),S.nodeId===M&&e.jsx(_e,{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"}),lt&&S.nodeId&&ie&&e.jsx(hs,{nodeId:S.nodeId,nodeName:S.nodeName,onOpenSettings:ie,onOpenDevBox:ae,onStartDevBox:Z,showConfigureDevBox:b.has(S.nodeId),showStartDevBox:C.has(S.nodeId)||g.has(S.nodeId),startDevBoxPending:g.has(S.nodeId)})]})]}),e.jsx("div",{className:$("grid transition-[grid-template-rows] duration-300 ease-in-out",Ae?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:"overflow-hidden",children:S.dirs.map($e=>{const ze=`${we}::${$e.path}`,Le=ge.has(ze),De=Wn($e.path);return e.jsxs("div",{className:$("space-y-0.5 rounded-xl",Pe&&"pl-3"),children:[e.jsxs("button",{type:"button",onClick:()=>he(ze),"aria-expanded":!Le,title:$e.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(ut,{className:$("h-3 w-3 shrink-0 transition-transform duration-200",!Le&&"rotate-90")}),e.jsx("span",{className:"truncate font-mono",children:De}),e.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-muted-foreground/40",children:$e.tasks.length})]}),e.jsx("div",{className:$("grid transition-[grid-template-rows] duration-300 ease-in-out",Le?"grid-rows-[0fr]":"grid-rows-[1fr]"),children:e.jsx("div",{className:$("overflow-hidden",Pe?"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:$e.tasks.map(ve=>e.jsxs("div",{className:$("flex items-center gap-1.5 rounded-[18px] border px-2.5 py-1.5 transition-all duration-200","hover:-translate-y-px",ve.id===s?"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:Qe=>Qe.stopPropagation(),children:e.jsx(Ht,{checked:y.has(ve.id),onCheckedChange:Qe=>T(ve.id,Qe===!0),"aria-label":`Select ${ve.title}`})}),e.jsxs("button",{type:"button",onClick:()=>Q(ve.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:$("h-1.5 w-1.5 shrink-0 rounded-full",Gn(ve.status),(ve.status==="running"||ve.status==="assigned")&&"animate-soft-status-pulse")}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-medium text-foreground",children:ve.title}),e.jsx("span",{className:"ml-1 shrink-0 tabular-nums text-[10px] text-muted-foreground/55",children:Qn(ve.updatedAt)})]}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-1 pl-3",children:[e.jsx(da,{status:ve.status}),e.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/60",children:ve.agent}),ve.conversationKind==="nativeSession"&&e.jsx(_e,{variant:"outline",className:"border-sky-500/25 bg-sky-500/10 text-[10px] text-sky-700 dark:text-sky-300",children:"native"}),ve.activeShare&&e.jsx(_e,{variant:"outline",className:"border-primary/25 bg-primary/10 text-[10px] text-primary",children:"shared"}),ve.assignedNodeAvailable===!1&&e.jsx(_e,{variant:"outline",className:"border-destructive/25 bg-destructive/10 text-[10px] text-destructive",children:"unavailable"})]})]})]},ve.id))})})})]},ze)})})})]},we)})]}):n?e.jsx("div",{className:"space-y-2 px-1",children:[1,2,3].map(S=>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+S*12}%`,animationDelay:`${S*120}ms`}}),e.jsx("div",{className:"h-2 w-24 animate-pulse rounded-full bg-muted-foreground/10",style:{animationDelay:`${S*120+60}ms`}})]})]})},S))}):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&&I>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:[I," task",I!==1?"s":""," selected"]}),!L&&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(Rt,{children:[e.jsx(Ls,{asChild:!0,children:e.jsxs(R,{variant:"outline",size:"sm",disabled:!L,className:"rounded-[14px]",children:[e.jsx(Vr,{className:"h-3.5 w-3.5"}),"Archive"]})}),e.jsxs(Ot,{children:[e.jsxs(It,{children:[e.jsxs(Ft,{children:["Archive ",I," task",I!==1?"s":"","?"]}),e.jsx(zt,{children:"Archived tasks stay hidden from the default task view and can be reopened from the archived scope."})]}),e.jsxs(Ut,{children:[e.jsx(Vt,{children:"Cancel"}),e.jsx(qt,{onClick:se,disabled:!L,children:"Archive"})]})]})]}),e.jsxs(Rt,{children:[e.jsx(Ls,{asChild:!0,children:e.jsxs(R,{variant:"destructive",size:"sm",className:"rounded-[14px]",children:[e.jsx(Eo,{className:"h-3.5 w-3.5"}),"Delete"]})}),e.jsxs(Ot,{children:[e.jsxs(It,{children:[e.jsxs(Ft,{children:["Delete ",I," task",I!==1?"s":"","?"]}),e.jsx(zt,{children:"This removes the selected tasks and their saved logs."})]}),e.jsxs(Ut,{children:[e.jsx(Vt,{children:"Cancel"}),e.jsx(qt,{onClick:H,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}):null]})}async function qi(t,s){var n,o;try{const r=await Jn(t,s),i={...r,url:ra(r.url)};if((o=(n=globalThis.navigator)==null?void 0:n.clipboard)!=null&&o.writeText)try{await globalThis.navigator.clipboard.writeText(i.url),oe.success("Shared link copied")}catch{oe.success("Shared link created")}else oe.success("Shared link created");return i}catch(r){oe.error(r instanceof Error?r.message:"Failed to create shared link");return}}async function Hi(t){try{return await Yn(t),oe.success("Shared link stopped"),!0}catch(s){return oe.error(s instanceof Error?s.message:"Failed to stop shared link"),!1}}function Ki(t,s,n){const o=a.useCallback(()=>{s(),n()},[s,n]),r=a.useCallback(async f=>{if(!t)return;const j=await qi(t.id,f);return j&&o(),j},[t,o]),i=a.useCallback(async()=>{if(!t)return!1;const f=await Hi(t.id);return f&&o(),f},[t,o]);return{handleShareTask:r,handleStopShareTask:i}}function Zs(t,s,n){const o=a.useRef(s);o.current=s,a.useEffect(()=>{let f=0,j=0;const w=l=>{const u=l.touches[0];u&&(f=u.clientX,j=u.clientY)},p=l=>{var g,M,m,y;const u=l.changedTouches[0];if(!u)return;const b=u.clientX-f;Math.abs(u.clientY-j)>100||Math.abs(b)<50||(b>0?(M=(g=o.current).onSwipeRight)==null||M.call(g):(y=(m=o.current).onSwipeLeft)==null||y.call(m))},h=(t==null?void 0:t.current)??document;return h.addEventListener("touchstart",w,{passive:!0}),h.addEventListener("touchend",p,{passive:!0}),()=>{h.removeEventListener("touchstart",w),h.removeEventListener("touchend",p)}},[t,n==null?void 0:n.threshold,n==null?void 0:n.maxVertical])}const Wi="(min-width: 1024px)",Gi="(min-width: 1800px)";function ea(t){var s,n,o;return((o=(n=(s=globalThis.window)==null?void 0:s.matchMedia)==null?void 0:n.call(s,t))==null?void 0:o.matches)??!1}function Qi(){const[t,s]=a.useState(!0),[n,o]=a.useState(!1),[r,i]=a.useState(()=>ea(Gi)),f=a.useRef(null),j=a.useRef(null);Zs(f,{onSwipeLeft:()=>o(!1)}),Zs(j,{onSwipeRight:()=>i(!1)});const w=a.useCallback(()=>{if(ea(Wi)){s(p=>!p);return}o(p=>!p)},[]);return{desktopTasksOpen:t,mobileTasksPanelOpen:n,mobileTasksPanelRef:f,operationsOpen:r,operationsPanelRef:j,setMobileTasksPanelOpen:o,setOperationsOpen:i,toggleTasksPanel:w}}function Ji(t,s){const n=s.taskId,o=s.updates;return typeof n!="string"||!o||typeof o!="object"?t:t.map(r=>r.id===n?{...r,...o}:r)}function Yi({isLeader:t,selfId:s}){return{assignedTo:!t&&s?s:void 0}}function Xi({isLeader:t,selfId:s,sseConnected:n,subscribe:o}){const[r,i]=a.useState([]),[f,j]=a.useState(!0),[w,p]=a.useState(null),h=a.useRef(null),l=a.useCallback(async()=>{try{const b=await Xn(Yi({isLeader:t,selfId:s}));i(b),p(null)}catch(b){p(b instanceof Error?b.message:"Failed to load tasks")}finally{j(!1)}},[t,s]),u=a.useCallback(()=>{h.current===null&&(h.current=window.setTimeout(()=>{h.current=null,l()},Zn))},[l]);return er(l,ar(n)),a.useEffect(()=>()=>{h.current!==null&&(window.clearTimeout(h.current),h.current=null)},[]),a.useEffect(()=>{const b=[o("task.updated",C=>{i(g=>Ji(g,C.data))}),o("task.status",C=>{i(g=>tr(g,C.data))}),o("task",C=>{sr(C.type)&&u()})];return()=>b.forEach(C=>C())},[o,u]),{fetchTasks:l,setTasks:i,tasks:r,tasksError:w,tasksLoading:f}}function Zi(t,s){return s.data.nodeId===t.self.id||s.data.name===t.self.name||s.data.endpoint===t.self.endpoint}function el({cluster:t,subscribe:s}){a.useEffect(()=>{var n;if(((n=t==null?void 0:t.self)==null?void 0:n.role)==="leader")return s("node",o=>{const r=String(o.data.name??o.data.nodeId??"node"),i=Zi(t,o);o.type==="node.joined"&&!i&&oe.success(`${r} joined the cluster`),o.type==="node.left"&&!i&&oe.message(`${r} left the cluster`)})},[t,s])}const tl=[0,300,1e3,2e3];function sl({task:t,getActiveTaskId:s,setLogs:n,setPendingMessages:o}){t.conversationKind==="nativeSession"&&(async()=>{for(const r of tl){if(r>0&&await new Promise(i=>setTimeout(i,r)),s()!==t.id)return;try{const i=await fa(t.id);if(s()!==t.id||(n(f=>Na(f,i.logs)),o(f=>wa(f,i.logs)),i.total>0))return}catch{}}})()}function al(t,s){return Te(t??{})===Te(s??{})}function nl(t){return t&&"status"in t&&typeof t.status=="string"?t.status:void 0}function ta(t,s){return{...t,enabled:!0,alwaysOnline:s}}function Fa(t){var s,n;return((s=t==null?void 0:t.status)==null?void 0:s.trim())||((n=t==null?void 0:t.lastStatus)==null?void 0:n.trim())||"Unknown"}function rl({operationStarting:t,loading:s,refreshing:n,savedStatus:o,fallbackStatus:r}){return t?"Starting":s?"Listing DevBoxes":n?"Refreshing":o??r}function sa({devbox:t,showStatus:s=!1}){return e.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:[e.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[e.jsx("span",{className:"font-medium",children:t.name}),t.projectName&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",t.projectName]})]}),s&&e.jsx("span",{className:"ml-auto shrink-0 rounded-full border border-border/70 bg-background/70 px-1.5 py-0.5 text-[10px] leading-none text-muted-foreground",children:Fa(t)})]})}function ol({node:t,open:s,startInProgress:n=!1,onOpenChange:o,onRefresh:r}){const i=(t==null?void 0:t.id)??null,f=s&&!n&&Gs(t==null?void 0:t.status,(t==null?void 0:t.devbox)??null),[j,w]=a.useState([]),[p,h]=a.useState(()=>t!=null&&t.devbox?Te(t.devbox):""),[l,u]=a.useState(()=>(t==null?void 0:t.devbox)??null),[b,C]=a.useState(()=>Qs((t==null?void 0:t.devbox)??null)),[g,M]=a.useState(!1),[m,y]=a.useState(f),[_,F]=a.useState(!1),[L,q]=a.useState(!1),[E,O]=a.useState(()=>{var c;return((c=t==null?void 0:t.devbox)==null?void 0:c.alwaysOnline)===!0}),U=a.useMemo(()=>{const c=j.find(A=>Te(A)===p);return c||(nt(l)&&Te(l)===p?l:void 0)},[l,j,p]),N=nl(U??void 0),T=b?N??(l==null?void 0:l.lastStatus):(l==null?void 0:l.lastStatus)??N,W=(t==null?void 0:t.status)==="online"||(t==null?void 0:t.status)==="busy"?"Running":"Unknown",se=L||n,H=rl({operationStarting:se,loading:g,refreshing:m,savedStatus:T,fallbackStatus:W}),G=b&&!!U&&!al(l,U),ie=(l==null?void 0:l.alwaysOnline)===!0!==E,ae=Fi({nodeStatus:t==null?void 0:t.status,status:H,current:l,selected:U}),Z=!!ae,Q=!!U&&(G||ie)&&!Z,V=U??l,K=a.useCallback(async()=>{if(i){y(!0);try{const c=await nr(i);u(c.devbox),h(Te(c.devbox))}catch(c){oe.error(c instanceof Error?c.message:"Failed to refresh DevBox status")}finally{y(!1)}}},[i]),J=a.useCallback(async c=>{M(!0);try{const A=await rr();w(A),h(I=>zi({previousKey:I,baseDevBox:c,listed:A}))}catch(A){oe.error(A instanceof Error?A.message:"Failed to load DevBoxes")}finally{M(!1)}},[]);a.useEffect(()=>{if(!s||!i)return;let c=!1;const A=(t==null?void 0:t.devbox)??null,I=Qs(A),re=!n&&Gs(t==null?void 0:t.status,A);M(!1),y(re),C(I),u(A),O((A==null?void 0:A.alwaysOnline)===!0),h(nt(A)?Te(A):""),w([]);async function v(){re&&await K(),!c&&I&&await J(A)}return v(),()=>{c=!0}},[J,t==null?void 0:t.devbox,t==null?void 0:t.status,i,s,K,n]);async function de(){C(!0),j.length===0&&await J(l)}async function x(){if(!(!t||!U)){F(!0);try{const c=await Bs(t.id,ta(U,E));u(c.node.devbox??null),c.node.devbox&&h(Te(c.node.devbox)),C(!1),oe.success(`Configured DevBox for ${t.name}`),await(r==null?void 0:r())}catch(c){oe.error(c instanceof Error?c.message:"Failed to configure DevBox")}finally{F(!1)}}}async function B(){if(!(!t||!ae)){q(!0);try{if(U&&(G||ie)){const A=await Bs(t.id,ta(U,E));u(A.node.devbox??null),A.node.devbox&&h(Te(A.node.devbox)),C(!1)}const{operation:c}=await ga(t.id);u(A=>A&&{...A,lastStatus:"Starting",checkedAt:Date.now(),operationId:c.id}),oe.success(`Start requested for ${t.name}`),await(r==null?void 0:r())}catch(c){oe.error(c instanceof Error?c.message:"Failed to start DevBox")}finally{q(!1)}}}const k=g?"Loading DevBoxes...":j.length===0?"No DevBoxes available":"Select a DevBox",Y=H==="Running"&&(t==null?void 0:t.status)==="offline";return e.jsx(as,{open:s,onOpenChange:o,children:e.jsxs(ns,{className:"max-w-md gap-4 rounded-[18px] p-5",children:[e.jsxs(ua,{className:"space-y-1",children:[e.jsx(rs,{className:"text-sm",children:"Configure DevBox"}),e.jsxs(or,{className:"text-xs",children:["Bind ",t!=null&&t.name?e.jsx("span",{className:"font-medium text-foreground",children:t.name}):"this node"," to an Azure Dev Box. Meshy will start it when the node is offline."]})]}),e.jsxs("div",{className:"space-y-3",children:[(b||V)&&e.jsxs("div",{className:"flex min-h-9 items-center justify-between gap-3 rounded-xl border border-border/60 bg-muted/20 px-3 py-2 text-xs",children:[e.jsx("div",{className:"min-w-0 flex-1",children:b?e.jsxs(ye,{value:p,onValueChange:h,disabled:g||_||L||j.length===0,children:[e.jsx(ke,{className:"h-7 justify-start gap-2 rounded-none border-0 bg-transparent px-0 text-xs shadow-none focus:ring-0 focus:ring-offset-0 [&>span]:!flex [&>span]:!min-w-0 [&>span]:!flex-1 [&>span]:!items-center",children:g&&!U?e.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}),k]}):U?e.jsx(sa,{devbox:U}):e.jsx(Be,{placeholder:k})}),e.jsx(Se,{children:j.map(c=>e.jsx(pe,{value:Te(c),textValue:`${c.name} ${c.projectName??""} ${Fa(c)}`,className:"pl-2 pr-7 text-xs [&>span:first-child]:left-auto [&>span:first-child]:right-2 [&>span:last-child]:w-full",children:e.jsx(sa,{devbox:c,showStatus:!0})},Te(c)))})]}):V&&e.jsxs("div",{className:"min-w-0 truncate",children:[e.jsx("span",{className:"font-medium text-foreground",children:V.name}),V.projectName&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",V.projectName]})]})}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs(_e,{variant:"outline",className:"rounded-full px-2 py-0.5 text-[10px]",children:[(g||m)&&e.jsx(ce,{className:"mr-1 h-2.5 w-2.5 animate-spin"}),H]}),(l==null?void 0:l.name)&&e.jsx(R,{type:"button",variant:"ghost",size:"icon",onClick:()=>{de()},disabled:g||_||se||b,"aria-label":"Edit DevBox binding",title:"Edit DevBox binding",className:"h-6 w-6 rounded-full text-muted-foreground hover:text-foreground",children:g&&b?e.jsx(ce,{className:"h-3 w-3 animate-spin"}):e.jsx(ot,{className:"h-3 w-3"})})]})]}),Y&&e.jsx("div",{className:"rounded-xl border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300",children:"DevBox is running, but the Meshy node is not connected yet."}),e.jsxs("label",{className:"flex min-h-9 items-start gap-2 rounded-xl border border-border/60 bg-muted/20 px-3 py-2 text-xs text-foreground",children:[e.jsx(Ht,{checked:E,onCheckedChange:c=>O(c===!0),disabled:_||L||se,"aria-label":"Always online",className:"mt-0.5 h-3.5 w-3.5"}),e.jsxs("span",{className:"min-w-0 leading-4",children:[e.jsx("span",{className:"block",children:"Always online"}),e.jsx("span",{className:"block text-[10px] leading-3.5 text-muted-foreground",children:"Meshy will start the DevBox automatically when it is Hibernated or Stopped."})]})]})]}),e.jsxs(xa,{className:"gap-2 sm:space-x-0",children:[e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>o(!1),disabled:_||L,className:"h-8 rounded-xl text-xs",children:"Close"}),Z&&e.jsxs(R,{size:"sm",onClick:B,disabled:L,className:"h-8 rounded-xl text-xs",children:[L?e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(is,{className:"h-3.5 w-3.5"}),"Start DevBox"]}),!Z&&e.jsxs(R,{size:"sm",onClick:x,disabled:!Q||_,className:"h-8 rounded-xl text-xs",children:[_&&e.jsx(ce,{className:"h-3.5 w-3.5 animate-spin"}),"Save"]})]})]})})}async function il(t,s=ir){if(t.length===0)return new Set;const n=new Set(t),[o,r]=await Promise.all([s({kind:"devbox.start",status:"queued"}),s({kind:"devbox.start",status:"running"})]);return new Set([...o,...r].filter(i=>n.has(i.nodeId)).map(i=>i.nodeId))}function ll({cluster:t,refresh:s}){const[n,o]=a.useState(null),[r,i]=a.useState(null),[f,j]=a.useState(()=>new Set),[w,p]=a.useState(()=>new Set),h=a.useMemo(()=>(t==null?void 0:t.nodes.find(m=>m.id===n))??null,[t==null?void 0:t.nodes,n]),l=a.useMemo(()=>new Set(((t==null?void 0:t.nodes)??[]).filter(m=>{var y;return(y=m.devbox)==null?void 0:y.enabled}).map(m=>m.id)),[t==null?void 0:t.nodes]),u=a.useMemo(()=>new Set(((t==null?void 0:t.nodes)??[]).filter(m=>{var y;return kt(m.status,(y=m.devbox)==null?void 0:y.lastStatus,m.devbox)}).map(m=>m.id)),[t==null?void 0:t.nodes]),b=a.useMemo(()=>new Set(((t==null?void 0:t.nodes)??[]).filter(m=>{var y;return rt((y=m.devbox)==null?void 0:y.lastStatus)}).map(m=>m.id)),[t==null?void 0:t.nodes]),C=a.useMemo(()=>{const m=new Set(f);r&&m.add(r);for(const y of w)m.add(y);for(const y of b)m.add(y);return m},[w,r,f,b]);a.useEffect(()=>{let m=!1;const y=[...l];async function _(){try{const F=await il(y);m||p(F)}catch{m||p(new Set)}}return _(),()=>{m=!0}},[l]),a.useEffect(()=>{j(m=>{var F;let y=!1;const _=new Set(m);for(const L of m){const q=t==null?void 0:t.nodes.find(E=>E.id===L);(q==null?void 0:q.status)!=="online"&&(!((F=q==null?void 0:q.devbox)!=null&&F.lastStatus)||rt(q.devbox.lastStatus))||(_.delete(L),y=!0)}return y?_:m})},[t==null?void 0:t.nodes]);const g=a.useCallback(async m=>{const y=t==null?void 0:t.nodes.find(_=>_.id===m);if(y){i(m),j(_=>new Set(_).add(m));try{await ga(m),oe.success(`Start requested for ${y.name}`),s()}catch(_){j(F=>{const L=new Set(F);return L.delete(m),L}),oe.error(_ instanceof Error?_.message:"Failed to start DevBox")}finally{i(null)}}},[t==null?void 0:t.nodes,s]);return{devBoxDialog:e.jsx(ol,{node:h,open:n!==null,startInProgress:h?C.has(h.id):!1,onOpenChange:m=>{m||o(null)},onRefresh:s}),devBoxNodeIds:l,devBoxStartNodeId:r,devBoxStartNodeIds:u,devBoxStartingNodeIds:C,openDevBox:o,startDevBox:g}}function dl(t){const[s,n]=a.useState(null),o=a.useCallback(i=>{t&&n(i)},[t]);return{nodeSettingsDialog:e.jsx(lr,{open:s!==null,onOpenChange:i=>{i||n(null)},initialSelectedNodeId:s??void 0,showTrigger:!1}),openNodeSettings:o}}function cl({activeTaskId:t,fetchActiveTask:s,setPendingMessages:n,setTask:o,setTasks:r}){const i=a.useCallback((w,p)=>{o(h=>h&&h.id===w?{...h,queuedMessages:p}:h),r(h=>h.map(l=>l.id===w?{...l,queuedMessages:p}:l))},[o,r]),f=a.useCallback(async w=>{if(!t)return!1;const p=`local-${Date.now()}-${Math.random().toString(16).slice(2)}`;n(h=>[...h,{id:p,content:w,timestamp:new Date().toISOString()}]);try{const h=await dr(t,w);return h.queued&&(n(l=>l.filter(u=>u.id!==p)),h.queuedMessages&&i(t,h.queuedMessages)),s(),!0}catch(h){return n(l=>l.filter(u=>u.id!==p)),oe.error(h instanceof Error?h.message:"Failed to send message"),!1}},[t,s,n,i]);return{cancelQueuedMessage:a.useCallback(async w=>{if(t)try{const p=await cr(t,w);i(t,p.queuedMessages),s()}catch(p){oe.error(p instanceof Error?p.message:"Failed to cancel queued message")}},[t,s,i]),queueFollowUpMessage:f}}function ul(){var ks,Ss,Cs,Ds,Es,Ts;const{id:t}=ur(),s=xr(),n=mr(),o=hr(),{cluster:r,systemInfo:i,events:f,sseConnected:j,subscribe:w,refresh:p,loading:h,error:l}=pr(),u=a.useMemo(()=>fr(s.state),[s.state]),[b,C]=a.useState(null),[g,M]=a.useState("active"),[m,y]=a.useState("all"),[_,F]=a.useState("all"),[L,q]=a.useState("all"),[E,O]=a.useState(""),U=a.useDeferredValue(E),{desktopTasksOpen:N,mobileTasksPanelOpen:T,mobileTasksPanelRef:W,operationsOpen:se,operationsPanelRef:H,setMobileTasksPanelOpen:G,setOperationsOpen:ie,toggleTasksPanel:ae}=Qi(),[Z,Q]=a.useState(()=>!!(u!=null&&u.draftNewTask)),[V,K]=a.useState(()=>(u==null?void 0:u.createMode)??"chat"),[J,de]=a.useState(()=>u!=null&&u.draftNewTask?{route:u.returnRoute??"/",taskId:u.returnTaskId??null}:null),[x,B]=a.useState(!1),[k,Y]=a.useState("transcript"),[c,A]=a.useState("all"),[I,re]=a.useState(!1),[v,P]=a.useState(null),[te,ge]=a.useState([]),[Ce,be]=a.useState([]),[Ke,Pe]=a.useState(!1),[ee,ue]=a.useState(null),[he,S]=a.useState(new Set),[we,X]=a.useState(!1),[Ae,Ie]=a.useState(!1),[lt,$e]=a.useState(null),ze=a.useRef(null),Le=a.useRef(null),De=((ks=r==null?void 0:r.self)==null?void 0:ks.role)==="leader",ve=(Ss=r==null?void 0:r.self)==null?void 0:Ss.id;el({cluster:r,subscribe:w});const{nodeSettingsDialog:Qe,openNodeSettings:ht}=dl(De),{devBoxDialog:Ee,devBoxNodeIds:je,devBoxStartNodeId:Ue,devBoxStartNodeIds:dt,devBoxStartingNodeIds:ps,openDevBox:fs,startDevBox:gs}=ll({cluster:r,refresh:p}),{fetchTasks:Re,setTasks:bs,tasks:We,tasksError:za,tasksLoading:St}=Xi({isLeader:De,selfId:ve,sseConnected:j,subscribe:w}),Ne=a.useMemo(()=>[...We].sort((d,D)=>D.updatedAt-d.updatedAt),[We]),Ua=a.useMemo(()=>{const d=new Map;for(const D of(r==null?void 0:r.nodes)??[]){const z=_o(Ne,D.id);z>0&&d.set(D.id,z)}return d},[r==null?void 0:r.nodes,Ne]),Ve=a.useMemo(()=>Ne.filter(d=>!gr(d,r==null?void 0:r.nodes,r==null?void 0:r.self)||!br(d,g)||m!=="all"&&d.agent!==m||!vr(d,L)||_==="unassigned"&&d.assignedTo||_!=="all"&&_!=="unassigned"&&jr(d.assignedTo,r==null?void 0:r.nodes,d.assignedNodeName)!==_?!1:U.trim()?Nr(d,U):!0),[Ne,r==null?void 0:r.nodes,r==null?void 0:r.self,g,m,L,_,U]);a.useEffect(()=>{S(d=>{const D=Po(d,Ve.map(z=>z.id));return D.size===d.size?d:D})},[Ve]),a.useEffect(()=>{De||S(new Set)},[De]);const Va=a.useMemo(()=>["all",...Array.from(new Set(Ne.map(d=>d.agent))).sort()],[Ne]),qa=a.useMemo(()=>{const D=Array.from(new Set(Ne.map(z=>z.assignedTo).filter(z=>!!z))).map(z=>{const fe=Ne.find(le=>le.assignedTo===z);return(r==null?void 0:r.nodes.find(le=>le.id===z))??{id:z,name:ia(z,r==null?void 0:r.nodes,fe==null?void 0:fe.assignedNodeName)}}).sort((z,fe)=>z.name.localeCompare(fe.name));return[{value:"all",label:"All nodes"},{value:"unassigned",label:"Unassigned"},...D.map(z=>({value:z.name.toLowerCase(),label:z.name}))]},[Ne,r==null?void 0:r.nodes]),vs=a.useMemo(()=>{const d=new Map;for(const D of(r==null?void 0:r.nodes)??[])d.set(D.id,D.name);for(const D of Ne)D.assignedTo&&D.assignedNodeName&&!d.has(D.assignedTo)&&d.set(D.assignedTo,D.assignedNodeName);return d},[r==null?void 0:r.nodes,Ne]),Ha=a.useMemo(()=>{const d=new Map;for(const D of(r==null?void 0:r.nodes)??[])d.set(D.id,D.status);return r!=null&&r.self&&d.set(r.self.id,r.self.status),d},[r]),js=a.useMemo(()=>{const d=new Map;for(const D of(r==null?void 0:r.nodes)??[])D.status!=="offline"&&d.set(D.id,D);return r!=null&&r.self&&r.self.status!=="offline"&&d.set(r.self.id,r.self),Array.from(d.values())},[r]),Ka=((Cs=r==null?void 0:r.self)==null?void 0:Cs.id)??((Ds=js[0])==null?void 0:Ds.id)??null,Ct=a.useMemo(()=>["all",...Array.from(new Set(f.map(d=>d.type))).sort()],[f]),Wa=a.useMemo(()=>c==="all"?f:f.filter(d=>d.type===c),[f,c]),Ga=Ve.length>0&&Ve.every(d=>he.has(d.id)),Qa=Ve.some(d=>he.has(d.id)),Ja=$o(Ve,he);a.useEffect(()=>{u!=null&&u.draftNewTask&&(Q(!0),de({route:u.returnRoute??"/",taskId:u.returnTaskId??null}))},[u]),a.useEffect(()=>{c!=="all"&&!Ct.includes(c)&&A("all")},[c,Ct]),a.useEffect(()=>{Fs(t,Z)&&!b&&Ne[0]&&C(Ne[0].id)},[t,Z,b,Ne]),a.useEffect(()=>{var d;Fs(t,Z)&&(b&&We.some(D=>D.id===b)||C(((d=Ne[0])==null?void 0:d.id)??null))},[t,Z,b,Ne,We]);const xe=Ao({routeTaskId:t,creatingTask:Z,internalSelectedTaskId:b,sortedTaskIds:Ne.map(d=>d.id)}),et=a.useMemo(()=>We.find(d=>d.id===xe)??null,[We,xe]);a.useEffect(()=>{Le.current=xe??null},[xe]);const pt=a.useCallback(()=>{P(null),ge([]),be([]),ue(null)},[]),Oe=a.useCallback(async()=>{const d=xe;if(d)try{const D=await wr(d);if(Le.current!==d)return;P(D),ue(null)}catch(D){if(Le.current!==d)return;P(null),ge([]),be([]),ue(D instanceof Error?D.message:"Failed to load task")}finally{Le.current===d&&Pe(!1)}},[xe]),ft=a.useCallback(async()=>{const d=xe;if(d)try{const D=await fa(d);if(Le.current!==d)return;ge(z=>Na(z,D.logs)),be(z=>wa(z,D.logs))}catch{}},[xe]);a.useEffect(()=>{if(!xe){P(null),ge([]),be([]),ue(null),Pe(!1);return}Y("transcript"),P(et),ge([]),be([]),ue(null),Pe(!0),Oe(),ft()},[xe,ft,Oe]),a.useEffect(()=>{var D;if(!xe||Z||St||We.some(z=>z.id===xe))return;const d=((D=Ne[0])==null?void 0:D.id)??null;C(d),pt(),a.startTransition(()=>{n(d?`/tasks/${d}`:"/",{state:null})})},[xe,pt,Z,n,Ne,We,St]),a.useEffect(()=>{et&&P(d=>!d||d.id!==et.id?d:{...d,...et})},[et]),a.useEffect(()=>{if(xe)return w("task",d=>{const D=d.data.taskId;if(!(typeof D!="string"||D!==xe)){if(d.type==="task.output"){const z=d.data.event;if(z){ge(le=>Pr(le,z));const fe=Rs(z);fe&&be(le=>$r(le,fe))}}d.type==="task.updated"&&Oe(),d.type==="task.status"&&(Oe(),ft())}})},[w,xe,Oe,ft]),a.useEffect(()=>{var d;k==="transcript"&&((d=ze.current)==null||d.scrollIntoView({behavior:"smooth"}))},[te,Ce,k]);const ne=v??et,Ya=ne!=null&&ne.assignedTo?(r==null?void 0:r.nodes.find(d=>d.id===ne.assignedTo))??null:null,Dt=Ce.length>0,Xa=ne?yr.has(ne.agent):!1,Et=(ne==null?void 0:ne.status)==="running",Za=ne?wt.has(ne.status):!1,en=ne?wt.has(ne.status)||kr.has(ne.status):!1,tn=!!(ne&&De&&ne.status==="failed"),Tt=a.useMemo(()=>Vi(ne,r,Dt,!!Et),[ne,r,Dt,Et]),_t=a.useMemo(()=>Rr([...te,...Ce.map(d=>Pt(d.content,d.timestamp))]),[te,Ce]),gt=a.useMemo(()=>{if(!ne||ne.conversationKind==="nativeSession")return null;const d=Or(ne);if(d.length>0)return Pt(d,new Date(ne.createdAt).toISOString());if(_t.length>0)return null;const D=Ir(ne.description||ne.title);return D.length>0?Pt(D,new Date(ne.createdAt).toISOString()):null},[ne,_t]),Mt=a.useMemo(()=>gt?Rs(gt):null,[gt]),sn=a.useMemo(()=>Mt?Fr(te,Mt):!1,[te,Mt]),At=a.useCallback((d="chat")=>{const D={route:t?`/tasks/${t}`:"/",taskId:xe};de(D),K(d),Q(!0),a.startTransition(()=>{n("/",{state:{draftNewTask:!0,returnRoute:D.route,returnTaskId:D.taskId,createMode:d}})})},[t,xe,n]),an=a.useCallback(()=>{var D;const d=(J==null?void 0:J.taskId)??((D=Ne[0])==null?void 0:D.id)??null;Q(!1),de(null),C(d),a.startTransition(()=>{n((J==null?void 0:J.route)??"/",{state:null})})},[J,Ne,n]),Ns=a.useCallback(d=>{Q(!1),de(null),C(d),a.startTransition(()=>{n(`/tasks/${d}`,{state:null})})},[n]),nn=a.useCallback(d=>{Le.current=d.id,Q(!1),de(null),bs(D=>Lo(D,d)),P(d),ge([]),be([]),ue(null),Pe(!1),Y("transcript"),C(d.id),sl({task:d,getActiveTaskId:()=>Le.current,setLogs:ge,setPendingMessages:be}),Re(),a.startTransition(()=>{n(`/tasks/${d.id}`,{state:null})})},[Re,n]),{cancelQueuedMessage:rn,queueFollowUpMessage:bt}=cl({activeTaskId:xe,fetchActiveTask:Oe,setPendingMessages:be,setTask:P,setTasks:bs}),on=a.useCallback(d=>{bt(d)},[bt]),ln=a.useCallback(d=>bt(d),[bt]),dn=a.useCallback(async()=>{if(ne)try{await Sr(ne.id),Oe(),Re()}catch(d){oe.error(d instanceof Error?d.message:"Failed to cancel task")}},[ne,Oe,Re]),{handleShareTask:cn,handleStopShareTask:un}=Ki(ne,Oe,Re),xn=a.useCallback(async()=>{if(ne)try{await Cr(ne.id),Oe(),Re()}catch(d){oe.error(d instanceof Error?d.message:"Failed to retry task")}},[ne,Oe,Re]),vt=a.useCallback((d,D=!1)=>{const z=Ro(Ve,d);return C(z),(D||!z)&&pt(),a.startTransition(()=>{n(z?`/tasks/${z}`:"/",{state:null})}),z},[pt,Ve,n]),mn=a.useCallback((d,D)=>{S(z=>{const fe=new Set(z);return D?fe.add(d):fe.delete(d),fe})},[]),hn=a.useCallback(d=>{if(!d){S(new Set);return}S(new Set(Ve.map(D=>D.id)))},[Ve]),pn=a.useCallback(async()=>{const d=Array.from(he);if(d.length!==0)try{const{results:D}=await Dr(d),z=D.filter(le=>!le.ok),fe=D.filter(le=>le.ok).map(le=>le.id);xe&&fe.includes(xe)&&vt(fe),z.length>0?oe.error(`Failed to archive ${z.length} task(s): ${z.map(le=>le.error??le.id).join(", ")}`):oe.success(`Archived ${fe.length} task(s)`),S(new Set(z.map(le=>le.id))),Re()}catch(D){oe.error(D instanceof Error?D.message:"Failed to archive tasks")}},[xe,Re,vt,he]),fn=a.useCallback(async()=>{const d=Array.from(he);if(d.length!==0)try{const{results:D}=await Er(d),z=D.filter(le=>!le.ok),fe=D.filter(le=>le.ok).map(le=>le.id);xe&&fe.includes(xe)&&vt(fe,!0),z.length>0?oe.error(`Failed to delete ${z.length} task(s): ${z.map(le=>le.error??le.id).join(", ")}`):oe.success(`Deleted ${fe.length} task(s)`),S(new Set(z.map(le=>le.id))),Re()}catch(D){oe.error(D instanceof Error?D.message:"Failed to delete tasks")}},[xe,Re,vt,he]),gn=a.useCallback(async()=>{X(!0);try{await Tr(),p()}catch(d){oe.error(d instanceof Error?d.message:"Failed to promote node")}finally{X(!1)}},[p]),bn=a.useCallback(async()=>{Ie(!0);try{await _r(),oe.success("This node left the remote cluster and is leading itself again."),Re(),Oe(),p()}catch(d){oe.error(d instanceof Error?d.message:"Failed to leave cluster")}finally{Ie(!1)}},[Oe,Re,p]),vn=a.useCallback(async d=>{var _s;const D=!us(d),z=d.id===((_s=r==null?void 0:r.self)==null?void 0:_s.id),fe=z?(i==null?void 0:i.transportType)??d.transportType:d.transportType,le=z&&!D&&it(fe);$e(d.id);try{le?await Mr("direct"):await Ar(d.id,D),oe.success(D?`Enabled remote access on ${d.name}`:`Disabled remote access on ${d.name}`),p()}catch(Ms){oe.error(Ms instanceof Error?Ms.message:"Failed to update remote access")}finally{$e(null)}},[(Es=r==null?void 0:r.self)==null?void 0:Es.id,p,i==null?void 0:i.transportType]),ws={toolbarTasks:Ve,activeTaskId:xe,tasksLoading:St,tasksError:za,isLeader:De,scope:g,agentFilter:m,nodeFilter:_,taskKindFilter:L,agentOptions:Va,nodeOptions:qa,nodeNameById:vs,nodeStatusById:Ha,leaderNodeId:((Ts=r==null?void 0:r.leader)==null?void 0:Ts.id)??null,searchQuery:E,devBoxNodeIds:je,devBoxStartNodeIds:dt,devBoxStartingNodeIds:ps,selectedTaskIds:he,allVisibleTasksSelected:Ga,someVisibleTasksSelected:Qa,canBatchArchive:Ja,onSearchChange:O,onScopeChange:M,onAgentFilterChange:y,onNodeFilterChange:F,onTaskKindFilterChange:q,onToggleTaskSelected:mn,onToggleAllVisibleTasks:hn,onBatchArchive:pn,onBatchDelete:fn,onCreateTask:At,onOpenNodeSettings:De?ht:void 0,onOpenDevBox:De?fs:void 0,onStartDevBox:De?gs:void 0,onSelectTask:Ns,onClose:ae},ys={cluster:r,systemInfo:i,nodeNameById:vs,nodeBlockingTaskCounts:Ua,eventTypeFilter:c,onEventTypeFilterChange:A,eventTypeOptions:Ct,filteredEvents:Wa,sseConnected:j,clusterLoading:h,clusterError:l,promotePending:we,onPromote:gn,onAddNode:()=>B(!0),leavePending:Ae,onLeaveCluster:bn,onToggleNodeDevTunnel:vn,devTunnelNodeId:lt,devBoxStartNodeId:Ue,devBoxStartingNodeIds:ps,onOpenNodeSettings:De?ht:void 0,onOpenDevBox:De?fs:void 0,onStartDevBox:De?gs:void 0,onClose:()=>ie(!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:$("hidden lg:block lg:shrink-0 lg:transition-all lg:duration-300",N?"lg:mr-3 lg:w-[24rem]":"lg:w-0 lg:overflow-hidden"),children:N&&e.jsx(Xs,{...ws})}),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(Si,{onToggleTasks:ae,desktopTasksOpen:N,mobileTasksPanelOpen:T,operationsOpen:se,onToggleOperations:()=>ie(d=>!d),cluster:r,sseConnected:j,activeTab:k,setActiveTab:Y,creatingTask:Z,createMode:V,activeTask:ne,assignedNode:Ya,taskLoading:Ke,taskError:ee,displayEvents:_t,initialPromptAlreadyInLogs:sn,initialPrompt:gt,supportsFollowUp:Xa,taskUnavailable:Tt.taskUnavailable,chatDisabled:Tt.chatDisabled,chatDisabledReason:Tt.chatDisabledReason,questionBypassEnabled:I,isRunning:!!Et,isStarting:Za,hasPendingFollowUp:Dt,canCancel:!!en,canRetry:!!tn,onRetry:xn,onCancel:dn,onShareTask:cn,onStopShareTask:un,onStartCreateTask:At,onCancelCreateTask:an,onCreateTask:nn,onSendMessage:on,onCancelQueuedMessage:rn,onQuestionBypassChange:re,onSubmitQuestionResponse:ln,messagesEndRef:ze})}),(o==null?void 0:o.terminalOpen)&&e.jsx($i,{nodes:js,defaultNodeId:Ka,onClose:()=>o==null?void 0:o.setTerminalOpen(!1)})]}),e.jsx("div",{className:$("hidden xl:block xl:shrink-0 xl:transition-all xl:duration-300",se?"xl:ml-3 xl:w-[26rem]":"xl:w-0 xl:overflow-hidden"),children:se&&e.jsx(Js,{...ys})})]}),se&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close operations panel",onClick:()=>ie(!1),className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm xl:hidden"}),e.jsx("div",{ref:H,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(Js,{...ys})})]}),T&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close task list",onClick:()=>G(!1),className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm lg:hidden"}),e.jsx("div",{ref:W,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(Xs,{...ws,onCreateTask:d=>{G(!1),At(d)},onSelectTask:d=>{G(!1),Ns(d)},onClose:()=>G(!1)})})]}),e.jsx(Ei,{open:x,onOpenChange:B,onAdded:p}),Qe,Ee]})}const fl=Object.freeze(Object.defineProperty({__proto__:null,DashboardPage:ul},Symbol.toStringTag,{value:"Module"}));export{fl as D,Os as G};
@@ -1,4 +1,4 @@
1
- import{c as ye,bb as jr,j as x,r as xe,B as gt,C as it,b as xt,X as Gi,q as Ki,E as Pr,bc as Qi,s as Zi,K as el}from"./index-BXsDi4nu.js";/**
1
+ import{c as ye,bb as jr,j as x,r as xe,B as gt,C as it,b as xt,X as Gi,l as Ki,E as Pr,bc as Qi,u as Zi,K as el}from"./index-cc0FQMdy.js";/**
2
2
  * @license lucide-react v1.7.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.