meshy-node 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,251 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-DVMAnAjC.js","assets/index-DduTnmHA.js","assets/index-CuMw5tL-.css","assets/file-B6TrcVpl.js","assets/PreviewTab-DYrIeJFR.js","assets/DiffTab-DDvHQmgo.js"])))=>i.map(i=>d[i]);
2
+ import{c as G,r as i,j as r,R as ho,a as oc,b as En,u as le,d as ac,e as U,f as ic,g as lc,h as cc,B as Ce,i as H,k as it,l as xo,m as dc,n as uc,t as he,T as go,P as fc,_ as Dr,o as mc,N as vo,p as bo,q as pc,s as hc,v as xc,w as gc,x as vc,y as bc,z as yc,A as wc,C as Nc,D as jc,E as Sc,F as kc,G as Cc,H as Ec,I as Tc,J as Ac,K as Rc,L as _c}from"./index-DduTnmHA.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 Pc=[["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"}]],Dc=G("archive",Pc);/**
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 Mc=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Oc=G("arrow-up",Mc);/**
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 Ic=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],yo=G("bot",Ic);/**
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 Lc=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],$c=G("brain",Lc);/**
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 Fc=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],pt=G("check",Fc);/**
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 Bc=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Tt=G("chevron-down",Bc);/**
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 Uc=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Mr=G("chevron-right",Uc);/**
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 Vc=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Or=G("chevron-up",Vc);/**
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 Wc=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],zc=G("circle-question-mark",Wc);/**
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 Hc=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Kc=G("circle-x",Hc);/**
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 qc=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Gc=G("circle",qc);/**
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 Yc=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],wo=G("copy",Yc);/**
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 Xc=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],No=G("external-link",Xc);/**
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 Jc=[["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"}]],Zc=G("flag",Jc);/**
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 Qc=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],ed=G("folder-tree",Qc);/**
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 td=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],nd=G("folder",td);/**
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 rd=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],sd=G("funnel",rd);/**
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 od=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],ad=G("globe",od);/**
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 id=[["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"}]],ld=G("history",id);/**
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 cd=[["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"}]],fr=G("image-plus",cd);/**
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 dd=[["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"}]],ud=G("laptop",dd);/**
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 fd=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]],md=G("list-checks",fd);/**
113
+ * @license lucide-react v1.7.0 - ISC
114
+ *
115
+ * This source code is licensed under the ISC license.
116
+ * See the LICENSE file in the root directory of this source tree.
117
+ */const pd=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],ye=G("loader-circle",pd);/**
118
+ * @license lucide-react v1.7.0 - ISC
119
+ *
120
+ * This source code is licensed under the ISC license.
121
+ * See the LICENSE file in the root directory of this source tree.
122
+ */const hd=[["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"}]],jo=G("message-square-plus",hd);/**
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 xd=[["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"}]],So=G("panel-left-close",xd);/**
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 gd=[["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"}]],vd=G("panel-left-open",gd);/**
133
+ * @license lucide-react v1.7.0 - ISC
134
+ *
135
+ * This source code is licensed under the ISC license.
136
+ * See the LICENSE file in the root directory of this source tree.
137
+ */const bd=[["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"}]],ko=G("panel-right-close",bd);/**
138
+ * @license lucide-react v1.7.0 - ISC
139
+ *
140
+ * This source code is licensed under the ISC license.
141
+ * See the LICENSE file in the root directory of this source tree.
142
+ */const yd=[["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"}]],wd=G("panel-right-open",yd);/**
143
+ * @license lucide-react v1.7.0 - ISC
144
+ *
145
+ * This source code is licensed under the ISC license.
146
+ * See the LICENSE file in the root directory of this source tree.
147
+ */const Nd=[["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"}]],Ir=G("pencil",Nd);/**
148
+ * @license lucide-react v1.7.0 - ISC
149
+ *
150
+ * This source code is licensed under the ISC license.
151
+ * See the LICENSE file in the root directory of this source tree.
152
+ */const jd=[["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"}]],Sd=G("rotate-ccw",jd);/**
153
+ * @license lucide-react v1.7.0 - ISC
154
+ *
155
+ * This source code is licensed under the ISC license.
156
+ * See the LICENSE file in the root directory of this source tree.
157
+ */const kd=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Es=G("search",kd);/**
158
+ * @license lucide-react v1.7.0 - ISC
159
+ *
160
+ * This source code is licensed under the ISC license.
161
+ * See the LICENSE file in the root directory of this source tree.
162
+ */const Cd=[["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"}]],Co=G("send",Cd);/**
163
+ * @license lucide-react v1.7.0 - ISC
164
+ *
165
+ * This source code is licensed under the ISC license.
166
+ * See the LICENSE file in the root directory of this source tree.
167
+ */const Ed=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],Td=G("shield-alert",Ed);/**
168
+ * @license lucide-react v1.7.0 - ISC
169
+ *
170
+ * This source code is licensed under the ISC license.
171
+ * See the LICENSE file in the root directory of this source tree.
172
+ */const Ad=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Rd=G("shield-check",Ad);/**
173
+ * @license lucide-react v1.7.0 - ISC
174
+ *
175
+ * This source code is licensed under the ISC license.
176
+ * See the LICENSE file in the root directory of this source tree.
177
+ */const _d=[["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"}]],Pd=G("trash-2",_d);/**
178
+ * @license lucide-react v1.7.0 - ISC
179
+ *
180
+ * This source code is licensed under the ISC license.
181
+ * See the LICENSE file in the root directory of this source tree.
182
+ */const Dd=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Md=G("user",Dd);/**
183
+ * @license lucide-react v1.7.0 - ISC
184
+ *
185
+ * This source code is licensed under the ISC license.
186
+ * See the LICENSE file in the root directory of this source tree.
187
+ */const Od=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],Eo=G("wrench",Od);/**
188
+ * @license lucide-react v1.7.0 - ISC
189
+ *
190
+ * This source code is licensed under the ISC license.
191
+ * See the LICENSE file in the root directory of this source tree.
192
+ */const Id=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],zt=G("x",Id),Ld=new Set(["assigned","running"]);function $d(e,t){return e.reduce((n,s)=>s.assignedTo===t&&Ld.has(s.status)?n+1:n,0)}function At(e){return(e==null?void 0:e.toLowerCase())==="devtunnel"}function Fd(e){return e?At(e)?"DevTunnel":e.charAt(0).toUpperCase()+e.slice(1):"Direct"}function Lr(e,t){return At(t??e.transportType)||!!e.devtunnelEndpoint}function To(e,t){return!At(t??e.transportType)}function Ao(e,t){const n=t??e.transportType;return At(n)?"DevTunnel":e.devtunnelEndpoint?"Direct + DevTunnel":Fd(n)}function Ts(e,t){return!e&&!t}function Bd({routeTaskId:e,creatingTask:t,internalSelectedTaskId:n,sortedTaskIds:s}){return e||(t?null:n??s[0]??null)}function Ud(e,t){return[t,...e.filter(n=>n.id!==t.id)]}const Vd=new Set(["completed","failed","cancelled","archived"]);function Wd(e,t){const n=new Set(t);return new Set(Array.from(e).filter(s=>n.has(s)))}function zd(e,t){const n=new Set(t);if(n.size===0)return!1;const s=e.filter(o=>n.has(o.id));return s.length===n.size&&s.every(o=>Vd.has(o.status))}function Hd(e,t){var s;const n=new Set(t);return((s=e.find(o=>!n.has(o.id)))==null?void 0:s.id)??null}function un(e){return typeof e=="object"&&e!==null}function Kd(e){if(!un(e))return null;if(e.type==="text"&&typeof e.text=="string"){const t=e.text.trim();return t?{type:"text",text:t}:null}if(e.type==="image"&&typeof e.mediaType=="string"&&typeof e.data=="string"){const t=e.mediaType.trim(),n=e.data;return!t||!n?null:{type:"image",mediaType:t,data:n,...typeof e.filename=="string"&&e.filename.trim()?{filename:e.filename.trim()}:{}}}if(e.type==="tool_result"&&typeof e.toolUseId=="string"&&typeof e.content=="string"){const t=e.toolUseId.trim(),n=e.content.trim();return!t||!n?null:{type:"tool_result",toolUseId:t,content:n,...typeof e.isError=="boolean"?{isError:e.isError}:{}}}return null}function qd(e){if(!un(e))return null;if(e.type==="text"&&typeof e.text=="string"){const s=e.text.trim();return s?{type:"text",text:s}:null}if(e.type!=="image"||!un(e.source)){if(e.type==="tool_result"&&typeof e.tool_use_id=="string"&&typeof e.content=="string"){const s=e.tool_use_id.trim(),o=e.content.trim();return!s||!o?null:{type:"tool_result",toolUseId:s,content:o,...typeof e.is_error=="boolean"?{isError:e.is_error}:{}}}return null}const t=typeof e.source.media_type=="string"?e.source.media_type.trim():"",n=typeof e.source.data=="string"?e.source.data:"";return!t||!n?null:{type:"image",mediaType:t,data:n}}function Lt(e){if(typeof e=="string"){const t=e.trim();return t?[{type:"text",text:t}]:[]}return Array.isArray(e)?e.map(t=>Kd(t)??qd(t)).filter(t=>t!==null):[]}function Ro(e,t){const n=e.trim();return[...n?[{type:"text",text:n}]:[],...t]}function Gd(e){return{role:"user",content:e.map(t=>t.type==="text"?{type:"text",text:t.text}:t.type==="tool_result"?{type:"tool_result",tool_use_id:t.toolUseId,content:t.content,...typeof t.isError=="boolean"?{is_error:t.isError}:{}}:{type:"image",source:{type:"base64",media_type:t.mediaType,data:t.data}})}}function Yn(e,t=new Date().toISOString()){return{type:"user",message:Gd(e),timestamp:t}}function Ht(e){if(e.type!=="user"||e.isSynthetic===!0)return null;if(typeof e.message=="string"){const t=Lt(e.message);return t.length>0?t:null}if(un(e.message)&&Array.isArray(e.message.content)){const t=Lt(e.message.content);return t.length>0?t:null}if(Array.isArray(e.content)){const t=Lt(e.content);return t.length>0?t:null}return null}function Yd(e){return Lt(e.payload.initialMessage)}function Ft(e){return e.map(t=>{if(t.type==="text")return`t:${t.text}`;if(t.type==="tool_result")return`r:${t.toolUseId}:${t.isError===!0?"1":"0"}:${t.content}`;const n=t.data.slice(0,32),s=t.data.slice(-32);return`i:${t.mediaType}:${t.data.length}:${n}:${s}`}).join("|")}function Xd(e){return e.map(t=>t.type==="text"?t.text:t.type==="tool_result"?t.content:"").filter(Boolean).join(`
193
+ `)}function $r(e){return`data:${e.mediaType};base64,${e.data}`}function Jd(e){var o,a;if(!e)return[];const t=[],n=e.items;if(n)for(const c of Array.from(n)){if((c==null?void 0:c.kind)!=="file"||!((o=c.type)!=null&&o.startsWith("image/")))continue;const l=(a=c.getAsFile)==null?void 0:a.call(c);l&&l.type.startsWith("image/")&&t.push(l)}if(t.length>0)return t;const s=e.files;return s?Array.from(s).filter(c=>c.type.startsWith("image/")):[]}function Zd(e){return new Promise((t,n)=>{const s=new FileReader;s.onload=()=>{if(typeof s.result!="string"){n(new Error(`Failed to read ${e.name}`));return}t(s.result)},s.onerror=()=>n(s.error??new Error(`Failed to read ${e.name}`)),s.readAsDataURL(e)})}async function As(e){return Promise.all(Array.from(e).map(async t=>{if(!t.type.startsWith("image/"))throw new Error(`${t.name} is not an image`);const n=await Zd(t),s=n.indexOf(",");if(s===-1)throw new Error(`Failed to parse ${t.name}`);return{type:"image",mediaType:t.type||"image/png",data:n.slice(s+1),filename:t.name}}))}function Kt(e){return typeof e=="object"&&e!==null}function Qd(e){return Kt(e)&&typeof e.name=="string"&&e.name.toLowerCase()==="askuserquestion"}function eu(e){return!Kt(e)||typeof e.label!="string"||!e.label.trim()?null:{label:e.label.trim(),description:typeof e.description=="string"?e.description.trim():""}}function tu(e){if(!Kt(e)||typeof e.question!="string"||!e.question.trim())return null;const t=Array.isArray(e.options)?e.options.map(eu).filter(n=>n!==null):[];return t.length===0?null:{header:typeof e.header=="string"&&e.header.trim()?e.header.trim():void 0,question:e.question.trim(),multiSelect:e.multiSelect===!0,options:t}}function mr(e){if(!Kt(e)||!Array.isArray(e.questions))return null;const t=e.questions.map(tu).filter(n=>n!==null);return t.length===0?null:{questions:t}}function Rt(e){return JSON.stringify({questions:e.questions})}function Tn(e){const t=mr(e);if(t)return t;if(Qd(e)){const n=Kt(e.input)?e.input:void 0,s=mr(n);return s?{...s,...typeof e.id=="string"&&e.id.trim()?{toolUseId:e.id.trim()}:{}}:null}return null}function nu(e){var o;const t=e.trim();if(!t)return[];const n=[t],s=t.matchAll(/```(?:json)?\s*([\s\S]*?)```/gi);for(const a of s){const c=(o=a[1])==null?void 0:o.trim();c&&n.push(c)}return n}function An(e){for(const t of nu(e))try{const n=JSON.parse(t),s=mr(n);if(s)return s}catch{}return null}function ru(e){return e.questions.map(t=>t.options.length>0?[0]:[])}function su(e,t){return e.questions.every((n,s)=>(t[s]??[]).length>0)}function ou(e,t){const s=e.questions.map((o,a)=>{const c=[...new Set(t[a]??[])].sort((l,u)=>l-u).filter(l=>o.options[l]!==void 0);return{header:o.header??null,question:o.question,multiSelect:o.multiSelect,selectedOptions:c.map(l=>o.options[l]).filter(l=>l!==void 0)}}).map(o=>{const a=o.header??o.question,c=o.selectedOptions.map(l=>l.label).join(o.multiSelect?", ":"");return`${a}: ${c}`}).join(`
194
+ `);return e.toolUseId?[{type:"tool_result",toolUseId:e.toolUseId,content:s,isError:!1}]:[{type:"text",text:s}]}function Bt(e){return typeof e=="object"&&e!==null}function au(e){if(!e)return;const t=["file_path","path","command"].map(n=>e[n]).find(n=>typeof n=="string"&&n.trim().length>0);return t==null?void 0:t.trim()}function iu(e){const t=e.toLowerCase();return t.includes(" permission to write ")?"Write":t.includes(" permission to edit ")?"Edit":t.includes(" permission to run ")||t.includes(" permission to execute ")?"Bash":"Action"}function pr(e){const t=e.trim();if(!t.startsWith("Awaiting your permission to "))return null;const n=t.match(/`([^`]+)`/);return{requests:[{toolName:iu(t),target:n==null?void 0:n[1],summary:t}]}}function lu(e){if(!Array.isArray(e.permission_denials))return null;const t=[];for(const n of e.permission_denials){if(!Bt(n)||typeof n.tool_name!="string")continue;const s=Bt(n.tool_input)?n.tool_input:void 0,o=au(s),a=typeof e.result=="string"&&e.result.trim().length>0?e.result.trim():`Awaiting your permission to use ${n.tool_name}${o?` on \`${o}\``:""}.`;t.push({toolName:n.tool_name,...typeof n.tool_use_id=="string"?{toolUseId:n.tool_use_id}:{},...o?{target:o}:{},summary:a})}return t.length>0?{requests:t}:null}function Rs(e){if(!Array.isArray(e))return null;for(const t of e){if(!Bt(t)||t.type!=="text"||typeof t.text!="string")continue;const n=pr(t.text);if(n)return n}return null}function Fr(e){if(!Bt(e))return null;const t=lu(e);if(t)return t;if(typeof e.result=="string"){const s=pr(e.result);if(s)return s}if(typeof e.message=="string"){const s=pr(e.message);if(s)return s}if(Bt(e.message)){const s=Fr(e.message);if(s)return s;const o=Rs(e.message.content);if(o)return o}const n=Rs(e.content);return n||null}function cu(e){return JSON.stringify(e.requests.map(t=>({toolName:t.toolName,target:t.target??null,summary:t.summary})))}function du(e,t){return e.requests.map(n=>{const s=n.target?` for \`${n.target}\``:"",o=t==="approve"?`Approved. Proceed with the requested ${n.toolName} action${s}.`:`Denied. Do not proceed with the requested ${n.toolName} action${s}. Ask for another approach if needed.`;return n.toolUseId?{type:"tool_result",toolUseId:n.toolUseId,content:o,isError:t==="deny"}:t==="approve"?{type:"text",text:o}:{type:"text",text:o}})}function _o(e){return Ht(e)!==null}function fn(e){if(e.type==="user"){const t=Ht(e),n=typeof e.timestamp=="string"?e.timestamp:"";if(t)return`user:${n}:${Ft(t)}`}return JSON.stringify(e)}function hr(e){const t=Tn(e);return t?`question:${Rt(t)}`:null}function uu(e){const t=Fr(e);return t?`permission:${cu(t)}`:null}function _s(e){if(!Array.isArray(e))return null;const t=new Set;for(const n of e){const s=hr(n);if(s){t.add(s);continue}if(typeof n=="object"&&n!==null&&n.type==="text"&&typeof n.text=="string"){const o=An(n.text);o&&t.add(Rt(o))}}return t.size===0?null:Array.from(t).sort().join("|")}function fu(e){const t=hr(e);if(t)return t;if(typeof e.message=="string"){const n=An(e.message);return n?Rt(n):null}if(typeof e.message=="object"&&e.message!==null){const n=hr(e.message);return n||_s(e.message.content)}return _s(e.content)}function mu(e){return uu(e)}function pu(e,t,n){const s=typeof t.timestamp=="string"?t.timestamp:"";return`${e}-${s}-${n}`}function hu(e,t){const n=t.map(o=>({...o})),s=new Set(n.map(fn));for(const o of e){const a=fn(o);s.has(a)||(n.push(o),s.add(a))}return n}function xu(e,t){const n=fn(t);return e.some(s=>fn(s)===n)?e:[...e,{...t}]}function gu(e,t){const n=new Map;for(const s of t){const o=Ht(s);if(!o)continue;const a=Ft(o);n.set(a,(n.get(a)??0)+1)}return e.filter(s=>{const o=Ft(s.content),a=n.get(o)??0;return a<=0?!0:(n.set(o,a-1),!1)})}function vu(e,t){const n=Ft(t),s=e.findIndex(o=>Ft(o.content)===n);return s===-1?e:e.filter((o,a)=>a!==s)}function bu(e){return e.some(_o)}function yu(e){const t=[];let n=null;for(const s of e){if(_o(s)){n=null,t.push(s);continue}const o=mu(s)??fu(s);o&&o===n||(t.push(s),o&&(n=o))}return t}function Y(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function wu(e,t){const n=i.createContext(t),s=a=>{const{children:c,...l}=a,u=i.useMemo(()=>l,Object.values(l));return r.jsx(n.Provider,{value:u,children:c})};s.displayName=e+"Provider";function o(a){const c=i.useContext(n);if(c)return c;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[s,o]}function nt(e,t=[]){let n=[];function s(a,c){const l=i.createContext(c),u=n.length;n=[...n,c];const f=m=>{var b;const{scope:h,children:g,...x}=m,p=((b=h==null?void 0:h[e])==null?void 0:b[u])||l,v=i.useMemo(()=>x,Object.values(x));return r.jsx(p.Provider,{value:v,children:g})};f.displayName=a+"Provider";function d(m,h){var p;const g=((p=h==null?void 0:h[e])==null?void 0:p[u])||l,x=i.useContext(g);if(x)return x;if(c!==void 0)return c;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[f,d]}const o=()=>{const a=n.map(c=>i.createContext(c));return function(l){const u=(l==null?void 0:l[e])||a;return i.useMemo(()=>({[`__scope${e}`]:{...l,[e]:u}}),[l,u])}};return o.scopeName=e,[s,Nu(o,...t)]}function Nu(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const c=s.reduce((l,{useScope:u,scopeName:f})=>{const m=u(a)[`__scope${f}`];return{...l,...m}},{});return i.useMemo(()=>({[`__scope${t.scopeName}`]:c}),[c])}};return n.scopeName=t.scopeName,n}var ve=globalThis!=null&&globalThis.document?i.useLayoutEffect:()=>{},ju=ho[" useId ".trim().toString()]||(()=>{}),Su=0;function Xe(e){const[t,n]=i.useState(ju());return ve(()=>{n(s=>s??String(Su++))},[e]),e||(t?`radix-${t}`:"")}var ku=ho[" useInsertionEffect ".trim().toString()]||ve;function kt({prop:e,defaultProp:t,onChange:n=()=>{},caller:s}){const[o,a,c]=Cu({defaultProp:t,onChange:n}),l=e!==void 0,u=l?e:o;{const d=i.useRef(e!==void 0);i.useEffect(()=>{const m=d.current;m!==l&&console.warn(`${s} is changing from ${m?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=l},[l,s])}const f=i.useCallback(d=>{var m;if(l){const h=Eu(d)?d(e):d;h!==e&&((m=c.current)==null||m.call(c,h))}else a(d)},[l,e,a,c]);return[u,f]}function Cu({defaultProp:e,onChange:t}){const[n,s]=i.useState(e),o=i.useRef(n),a=i.useRef(t);return ku(()=>{a.current=t},[t]),i.useEffect(()=>{var c;o.current!==n&&((c=a.current)==null||c.call(a,n),o.current=n)},[n,o]),[n,s,a]}function Eu(e){return typeof e=="function"}function Ut(e){const t=Tu(e),n=i.forwardRef((s,o)=>{const{children:a,...c}=s,l=i.Children.toArray(a),u=l.find(Ru);if(u){const f=u.props.children,d=l.map(m=>m===u?i.Children.count(f)>1?i.Children.only(null):i.isValidElement(f)?f.props.children:null:m);return r.jsx(t,{...c,ref:o,children:i.isValidElement(f)?i.cloneElement(f,void 0,d):null})}return r.jsx(t,{...c,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function Tu(e){const t=i.forwardRef((n,s)=>{const{children:o,...a}=n;if(i.isValidElement(o)){const c=Pu(o),l=_u(a,o.props);return o.type!==i.Fragment&&(l.ref=s?oc(s,c):c),i.cloneElement(o,l)}return i.Children.count(o)>1?i.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Po=Symbol("radix.slottable");function Au(e){const t=({children:n})=>r.jsx(r.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=Po,t}function Ru(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Po}function _u(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...l)=>{const u=a(...l);return o(...l),u}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function Pu(e){var s,o;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Du=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Z=Du.reduce((e,t)=>{const n=Ut(`Primitive.${t}`),s=i.forwardRef((o,a)=>{const{asChild:c,...l}=o,u=c?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(u,{...l,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function Mu(e,t){e&&En.flushSync(()=>e.dispatchEvent(t))}function Qe(e){const t=i.useRef(e);return i.useEffect(()=>{t.current=e}),i.useMemo(()=>(...n)=>{var s;return(s=t.current)==null?void 0:s.call(t,...n)},[])}function Ou(e,t=globalThis==null?void 0:globalThis.document){const n=Qe(e);i.useEffect(()=>{const s=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",s,{capture:!0}),()=>t.removeEventListener("keydown",s,{capture:!0})},[n,t])}var Iu="DismissableLayer",xr="dismissableLayer.update",Lu="dismissableLayer.pointerDownOutside",$u="dismissableLayer.focusOutside",Ps,Do=i.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Br=i.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:c,onDismiss:l,...u}=e,f=i.useContext(Do),[d,m]=i.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,g]=i.useState({}),x=le(t,S=>m(S)),p=Array.from(f.layers),[v]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),b=p.indexOf(v),y=d?p.indexOf(d):-1,w=f.layersWithOutsidePointerEventsDisabled.size>0,j=y>=b,k=Uu(S=>{const T=S.target,R=[...f.branches].some(A=>A.contains(T));!j||R||(o==null||o(S),c==null||c(S),S.defaultPrevented||l==null||l())},h),C=Vu(S=>{const T=S.target;[...f.branches].some(A=>A.contains(T))||(a==null||a(S),c==null||c(S),S.defaultPrevented||l==null||l())},h);return Ou(S=>{y===f.layers.size-1&&(s==null||s(S),!S.defaultPrevented&&l&&(S.preventDefault(),l()))},h),i.useEffect(()=>{if(d)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(Ps=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(d)),f.layers.add(d),Ds(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=Ps)}},[d,h,n,f]),i.useEffect(()=>()=>{d&&(f.layers.delete(d),f.layersWithOutsidePointerEventsDisabled.delete(d),Ds())},[d,f]),i.useEffect(()=>{const S=()=>g({});return document.addEventListener(xr,S),()=>document.removeEventListener(xr,S)},[]),r.jsx(Z.div,{...u,ref:x,style:{pointerEvents:w?j?"auto":"none":void 0,...e.style},onFocusCapture:Y(e.onFocusCapture,C.onFocusCapture),onBlurCapture:Y(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:Y(e.onPointerDownCapture,k.onPointerDownCapture)})});Br.displayName=Iu;var Fu="DismissableLayerBranch",Bu=i.forwardRef((e,t)=>{const n=i.useContext(Do),s=i.useRef(null),o=le(t,s);return i.useEffect(()=>{const a=s.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),r.jsx(Z.div,{...e,ref:o})});Bu.displayName=Fu;function Uu(e,t=globalThis==null?void 0:globalThis.document){const n=Qe(e),s=i.useRef(!1),o=i.useRef(()=>{});return i.useEffect(()=>{const a=l=>{if(l.target&&!s.current){let u=function(){Mo(Lu,n,f,{discrete:!0})};const f={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=u,t.addEventListener("click",o.current,{once:!0})):u()}else t.removeEventListener("click",o.current);s.current=!1},c=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(c),t.removeEventListener("pointerdown",a),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>s.current=!0}}function Vu(e,t=globalThis==null?void 0:globalThis.document){const n=Qe(e),s=i.useRef(!1);return i.useEffect(()=>{const o=a=>{a.target&&!s.current&&Mo($u,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}function Ds(){const e=new CustomEvent(xr);document.dispatchEvent(e)}function Mo(e,t,n,{discrete:s}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),s?Mu(o,a):o.dispatchEvent(a)}var Xn="focusScope.autoFocusOnMount",Jn="focusScope.autoFocusOnUnmount",Ms={bubbles:!1,cancelable:!0},Wu="FocusScope",Ur=i.forwardRef((e,t)=>{const{loop:n=!1,trapped:s=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...c}=e,[l,u]=i.useState(null),f=Qe(o),d=Qe(a),m=i.useRef(null),h=le(t,p=>u(p)),g=i.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;i.useEffect(()=>{if(s){let p=function(w){if(g.paused||!l)return;const j=w.target;l.contains(j)?m.current=j:qe(m.current,{select:!0})},v=function(w){if(g.paused||!l)return;const j=w.relatedTarget;j!==null&&(l.contains(j)||qe(m.current,{select:!0}))},b=function(w){if(document.activeElement===document.body)for(const k of w)k.removedNodes.length>0&&qe(l)};document.addEventListener("focusin",p),document.addEventListener("focusout",v);const y=new MutationObserver(b);return l&&y.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",v),y.disconnect()}}},[s,l,g.paused]),i.useEffect(()=>{if(l){Is.add(g);const p=document.activeElement;if(!l.contains(p)){const b=new CustomEvent(Xn,Ms);l.addEventListener(Xn,f),l.dispatchEvent(b),b.defaultPrevented||(zu(Yu(Oo(l)),{select:!0}),document.activeElement===p&&qe(l))}return()=>{l.removeEventListener(Xn,f),setTimeout(()=>{const b=new CustomEvent(Jn,Ms);l.addEventListener(Jn,d),l.dispatchEvent(b),b.defaultPrevented||qe(p??document.body,{select:!0}),l.removeEventListener(Jn,d),Is.remove(g)},0)}}},[l,f,d,g]);const x=i.useCallback(p=>{if(!n&&!s||g.paused)return;const v=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,b=document.activeElement;if(v&&b){const y=p.currentTarget,[w,j]=Hu(y);w&&j?!p.shiftKey&&b===j?(p.preventDefault(),n&&qe(w,{select:!0})):p.shiftKey&&b===w&&(p.preventDefault(),n&&qe(j,{select:!0})):b===y&&p.preventDefault()}},[n,s,g.paused]);return r.jsx(Z.div,{tabIndex:-1,...c,ref:h,onKeyDown:x})});Ur.displayName=Wu;function zu(e,{select:t=!1}={}){const n=document.activeElement;for(const s of e)if(qe(s,{select:t}),document.activeElement!==n)return}function Hu(e){const t=Oo(e),n=Os(t,e),s=Os(t.reverse(),e);return[n,s]}function Oo(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const o=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||o?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Os(e,t){for(const n of e)if(!Ku(n,{upTo:t}))return n}function Ku(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function qu(e){return e instanceof HTMLInputElement&&"select"in e}function qe(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&qu(e)&&t&&e.select()}}var Is=Gu();function Gu(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Ls(e,t),e.unshift(t)},remove(t){var n;e=Ls(e,t),(n=e[0])==null||n.resume()}}}function Ls(e,t){const n=[...e],s=n.indexOf(t);return s!==-1&&n.splice(s,1),n}function Yu(e){return e.filter(t=>t.tagName!=="A")}var Xu="Portal",Vr=i.forwardRef((e,t)=>{var l;const{container:n,...s}=e,[o,a]=i.useState(!1);ve(()=>a(!0),[]);const c=n||o&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return c?ac.createPortal(r.jsx(Z.div,{...s,ref:t}),c):null});Vr.displayName=Xu;function Ju(e,t){return i.useReducer((n,s)=>t[n][s]??n,e)}var _t=e=>{const{present:t,children:n}=e,s=Zu(t),o=typeof n=="function"?n({present:s.isPresent}):i.Children.only(n),a=le(s.ref,Qu(o));return typeof n=="function"||s.isPresent?i.cloneElement(o,{ref:a}):null};_t.displayName="Presence";function Zu(e){const[t,n]=i.useState(),s=i.useRef(null),o=i.useRef(e),a=i.useRef("none"),c=e?"mounted":"unmounted",[l,u]=Ju(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return i.useEffect(()=>{const f=en(s.current);a.current=l==="mounted"?f:"none"},[l]),ve(()=>{const f=s.current,d=o.current;if(d!==e){const h=a.current,g=en(f);e?u("MOUNT"):g==="none"||(f==null?void 0:f.display)==="none"?u("UNMOUNT"):u(d&&h!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,u]),ve(()=>{if(t){let f;const d=t.ownerDocument.defaultView??window,m=g=>{const p=en(s.current).includes(CSS.escape(g.animationName));if(g.target===t&&p&&(u("ANIMATION_END"),!o.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",f=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},h=g=>{g.target===t&&(a.current=en(s.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",m),t.addEventListener("animationend",m),()=>{d.clearTimeout(f),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",m),t.removeEventListener("animationend",m)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:i.useCallback(f=>{s.current=f?getComputedStyle(f):null,n(f)},[])}}function en(e){return(e==null?void 0:e.animationName)||"none"}function Qu(e){var s,o;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Zn=0;function Io(){i.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??$s()),document.body.insertAdjacentElement("beforeend",e[1]??$s()),Zn++,()=>{Zn===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Zn--}},[])}function $s(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Ie=function(){return Ie=Object.assign||function(t){for(var n,s=1,o=arguments.length;s<o;s++){n=arguments[s];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Ie.apply(this,arguments)};function Lo(e,t){var n={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,s=Object.getOwnPropertySymbols(e);o<s.length;o++)t.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(e,s[o])&&(n[s[o]]=e[s[o]]);return n}function ef(e,t,n){if(n||arguments.length===2)for(var s=0,o=t.length,a;s<o;s++)(a||!(s in t))&&(a||(a=Array.prototype.slice.call(t,0,s)),a[s]=t[s]);return e.concat(a||Array.prototype.slice.call(t))}var an="right-scroll-bar-position",ln="width-before-scroll-bar",tf="with-scroll-bars-hidden",nf="--removed-body-scroll-bar-size";function Qn(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function rf(e,t){var n=i.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(s){var o=n.value;o!==s&&(n.value=s,n.callback(s,o))}}}})[0];return n.callback=t,n.facade}var sf=typeof window<"u"?i.useLayoutEffect:i.useEffect,Fs=new WeakMap;function of(e,t){var n=rf(null,function(s){return e.forEach(function(o){return Qn(o,s)})});return sf(function(){var s=Fs.get(n);if(s){var o=new Set(s),a=new Set(e),c=n.current;o.forEach(function(l){a.has(l)||Qn(l,null)}),a.forEach(function(l){o.has(l)||Qn(l,c)})}Fs.set(n,e)},[e]),n}function af(e){return e}function lf(e,t){t===void 0&&(t=af);var n=[],s=!1,o={read:function(){if(s)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var c=t(a,s);return n.push(c),function(){n=n.filter(function(l){return l!==c})}},assignSyncMedium:function(a){for(s=!0;n.length;){var c=n;n=[],c.forEach(a)}n={push:function(l){return a(l)},filter:function(){return n}}},assignMedium:function(a){s=!0;var c=[];if(n.length){var l=n;n=[],l.forEach(a),c=n}var u=function(){var d=c;c=[],d.forEach(a)},f=function(){return Promise.resolve().then(u)};f(),n={push:function(d){c.push(d),f()},filter:function(d){return c=c.filter(d),n}}}};return o}function cf(e){e===void 0&&(e={});var t=lf(null);return t.options=Ie({async:!0,ssr:!1},e),t}var $o=function(e){var t=e.sideCar,n=Lo(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var s=t.read();if(!s)throw new Error("Sidecar medium not found");return i.createElement(s,Ie({},n))};$o.isSideCarExport=!0;function df(e,t){return e.useMedium(t),$o}var Fo=cf(),er=function(){},Rn=i.forwardRef(function(e,t){var n=i.useRef(null),s=i.useState({onScrollCapture:er,onWheelCapture:er,onTouchMoveCapture:er}),o=s[0],a=s[1],c=e.forwardProps,l=e.children,u=e.className,f=e.removeScrollBar,d=e.enabled,m=e.shards,h=e.sideCar,g=e.noRelative,x=e.noIsolation,p=e.inert,v=e.allowPinchZoom,b=e.as,y=b===void 0?"div":b,w=e.gapMode,j=Lo(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=h,C=of([n,t]),S=Ie(Ie({},j),o);return i.createElement(i.Fragment,null,d&&i.createElement(k,{sideCar:Fo,removeScrollBar:f,shards:m,noRelative:g,noIsolation:x,inert:p,setCallbacks:a,allowPinchZoom:!!v,lockRef:n,gapMode:w}),c?i.cloneElement(i.Children.only(l),Ie(Ie({},S),{ref:C})):i.createElement(y,Ie({},S,{className:u,ref:C}),l))});Rn.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Rn.classNames={fullWidth:ln,zeroRight:an};var uf=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function ff(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=uf();return t&&e.setAttribute("nonce",t),e}function mf(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function pf(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var hf=function(){var e=0,t=null;return{add:function(n){e==0&&(t=ff())&&(mf(t,n),pf(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},xf=function(){var e=hf();return function(t,n){i.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Bo=function(){var e=xf(),t=function(n){var s=n.styles,o=n.dynamic;return e(s,o),null};return t},gf={left:0,top:0,right:0,gap:0},tr=function(e){return parseInt(e||"",10)||0},vf=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],s=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[tr(n),tr(s),tr(o)]},bf=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return gf;var t=vf(e),n=document.documentElement.clientWidth,s=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,s-n+t[2]-t[0])}},yf=Bo(),wt="data-scroll-locked",wf=function(e,t,n,s){var o=e.left,a=e.top,c=e.right,l=e.gap;return n===void 0&&(n="margin"),`
195
+ .`.concat(tf,` {
196
+ overflow: hidden `).concat(s,`;
197
+ padding-right: `).concat(l,"px ").concat(s,`;
198
+ }
199
+ body[`).concat(wt,`] {
200
+ overflow: hidden `).concat(s,`;
201
+ overscroll-behavior: contain;
202
+ `).concat([t&&"position: relative ".concat(s,";"),n==="margin"&&`
203
+ padding-left: `.concat(o,`px;
204
+ padding-top: `).concat(a,`px;
205
+ padding-right: `).concat(c,`px;
206
+ margin-left:0;
207
+ margin-top:0;
208
+ margin-right: `).concat(l,"px ").concat(s,`;
209
+ `),n==="padding"&&"padding-right: ".concat(l,"px ").concat(s,";")].filter(Boolean).join(""),`
210
+ }
211
+
212
+ .`).concat(an,` {
213
+ right: `).concat(l,"px ").concat(s,`;
214
+ }
215
+
216
+ .`).concat(ln,` {
217
+ margin-right: `).concat(l,"px ").concat(s,`;
218
+ }
219
+
220
+ .`).concat(an," .").concat(an,` {
221
+ right: 0 `).concat(s,`;
222
+ }
223
+
224
+ .`).concat(ln," .").concat(ln,` {
225
+ margin-right: 0 `).concat(s,`;
226
+ }
227
+
228
+ body[`).concat(wt,`] {
229
+ `).concat(nf,": ").concat(l,`px;
230
+ }
231
+ `)},Bs=function(){var e=parseInt(document.body.getAttribute(wt)||"0",10);return isFinite(e)?e:0},Nf=function(){i.useEffect(function(){return document.body.setAttribute(wt,(Bs()+1).toString()),function(){var e=Bs()-1;e<=0?document.body.removeAttribute(wt):document.body.setAttribute(wt,e.toString())}},[])},jf=function(e){var t=e.noRelative,n=e.noImportant,s=e.gapMode,o=s===void 0?"margin":s;Nf();var a=i.useMemo(function(){return bf(o)},[o]);return i.createElement(yf,{styles:wf(a,!t,o,n?"":"!important")})},gr=!1;if(typeof window<"u")try{var tn=Object.defineProperty({},"passive",{get:function(){return gr=!0,!0}});window.addEventListener("test",tn,tn),window.removeEventListener("test",tn,tn)}catch{gr=!1}var gt=gr?{passive:!1}:!1,Sf=function(e){return e.tagName==="TEXTAREA"},Uo=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Sf(e)&&n[t]==="visible")},kf=function(e){return Uo(e,"overflowY")},Cf=function(e){return Uo(e,"overflowX")},Us=function(e,t){var n=t.ownerDocument,s=t;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var o=Vo(e,s);if(o){var a=Wo(e,s),c=a[1],l=a[2];if(c>l)return!0}s=s.parentNode}while(s&&s!==n.body);return!1},Ef=function(e){var t=e.scrollTop,n=e.scrollHeight,s=e.clientHeight;return[t,n,s]},Tf=function(e){var t=e.scrollLeft,n=e.scrollWidth,s=e.clientWidth;return[t,n,s]},Vo=function(e,t){return e==="v"?kf(t):Cf(t)},Wo=function(e,t){return e==="v"?Ef(t):Tf(t)},Af=function(e,t){return e==="h"&&t==="rtl"?-1:1},Rf=function(e,t,n,s,o){var a=Af(e,window.getComputedStyle(t).direction),c=a*s,l=n.target,u=t.contains(l),f=!1,d=c>0,m=0,h=0;do{if(!l)break;var g=Wo(e,l),x=g[0],p=g[1],v=g[2],b=p-v-a*x;(x||b)&&Vo(e,l)&&(m+=b,h+=x);var y=l.parentNode;l=y&&y.nodeType===Node.DOCUMENT_FRAGMENT_NODE?y.host:y}while(!u&&l!==document.body||u&&(t.contains(l)||t===l));return(d&&Math.abs(m)<1||!d&&Math.abs(h)<1)&&(f=!0),f},nn=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Vs=function(e){return[e.deltaX,e.deltaY]},Ws=function(e){return e&&"current"in e?e.current:e},_f=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Pf=function(e){return`
232
+ .block-interactivity-`.concat(e,` {pointer-events: none;}
233
+ .allow-interactivity-`).concat(e,` {pointer-events: all;}
234
+ `)},Df=0,vt=[];function Mf(e){var t=i.useRef([]),n=i.useRef([0,0]),s=i.useRef(),o=i.useState(Df++)[0],a=i.useState(Bo)[0],c=i.useRef(e);i.useEffect(function(){c.current=e},[e]),i.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var p=ef([e.lockRef.current],(e.shards||[]).map(Ws),!0).filter(Boolean);return p.forEach(function(v){return v.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),p.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var l=i.useCallback(function(p,v){if("touches"in p&&p.touches.length===2||p.type==="wheel"&&p.ctrlKey)return!c.current.allowPinchZoom;var b=nn(p),y=n.current,w="deltaX"in p?p.deltaX:y[0]-b[0],j="deltaY"in p?p.deltaY:y[1]-b[1],k,C=p.target,S=Math.abs(w)>Math.abs(j)?"h":"v";if("touches"in p&&S==="h"&&C.type==="range")return!1;var T=window.getSelection(),R=T&&T.anchorNode,A=R?R===C||R.contains(C):!1;if(A)return!1;var O=Us(S,C);if(!O)return!0;if(O?k=S:(k=S==="v"?"h":"v",O=Us(S,C)),!O)return!1;if(!s.current&&"changedTouches"in p&&(w||j)&&(s.current=k),!k)return!0;var $=s.current||k;return Rf($,v,p,$==="h"?w:j)},[]),u=i.useCallback(function(p){var v=p;if(!(!vt.length||vt[vt.length-1]!==a)){var b="deltaY"in v?Vs(v):nn(v),y=t.current.filter(function(k){return k.name===v.type&&(k.target===v.target||v.target===k.shadowParent)&&_f(k.delta,b)})[0];if(y&&y.should){v.cancelable&&v.preventDefault();return}if(!y){var w=(c.current.shards||[]).map(Ws).filter(Boolean).filter(function(k){return k.contains(v.target)}),j=w.length>0?l(v,w[0]):!c.current.noIsolation;j&&v.cancelable&&v.preventDefault()}}},[]),f=i.useCallback(function(p,v,b,y){var w={name:p,delta:v,target:b,should:y,shadowParent:Of(b)};t.current.push(w),setTimeout(function(){t.current=t.current.filter(function(j){return j!==w})},1)},[]),d=i.useCallback(function(p){n.current=nn(p),s.current=void 0},[]),m=i.useCallback(function(p){f(p.type,Vs(p),p.target,l(p,e.lockRef.current))},[]),h=i.useCallback(function(p){f(p.type,nn(p),p.target,l(p,e.lockRef.current))},[]);i.useEffect(function(){return vt.push(a),e.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:h}),document.addEventListener("wheel",u,gt),document.addEventListener("touchmove",u,gt),document.addEventListener("touchstart",d,gt),function(){vt=vt.filter(function(p){return p!==a}),document.removeEventListener("wheel",u,gt),document.removeEventListener("touchmove",u,gt),document.removeEventListener("touchstart",d,gt)}},[]);var g=e.removeScrollBar,x=e.inert;return i.createElement(i.Fragment,null,x?i.createElement(a,{styles:Pf(o)}):null,g?i.createElement(jf,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Of(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const If=df(Fo,Mf);var Wr=i.forwardRef(function(e,t){return i.createElement(Rn,Ie({},e,{ref:t,sideCar:If}))});Wr.classNames=Rn.classNames;var Lf=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},bt=new WeakMap,rn=new WeakMap,sn={},nr=0,zo=function(e){return e&&(e.host||zo(e.parentNode))},$f=function(e,t){return t.map(function(n){if(e.contains(n))return n;var s=zo(n);return s&&e.contains(s)?s:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Ff=function(e,t,n,s){var o=$f(t,Array.isArray(e)?e:[e]);sn[n]||(sn[n]=new WeakMap);var a=sn[n],c=[],l=new Set,u=new Set(o),f=function(m){!m||l.has(m)||(l.add(m),f(m.parentNode))};o.forEach(f);var d=function(m){!m||u.has(m)||Array.prototype.forEach.call(m.children,function(h){if(l.has(h))d(h);else try{var g=h.getAttribute(s),x=g!==null&&g!=="false",p=(bt.get(h)||0)+1,v=(a.get(h)||0)+1;bt.set(h,p),a.set(h,v),c.push(h),p===1&&x&&rn.set(h,!0),v===1&&h.setAttribute(n,"true"),x||h.setAttribute(s,"true")}catch(b){console.error("aria-hidden: cannot operate on ",h,b)}})};return d(t),l.clear(),nr++,function(){c.forEach(function(m){var h=bt.get(m)-1,g=a.get(m)-1;bt.set(m,h),a.set(m,g),h||(rn.has(m)||m.removeAttribute(s),rn.delete(m)),g||m.removeAttribute(n)}),nr--,nr||(bt=new WeakMap,bt=new WeakMap,rn=new WeakMap,sn={})}},Ho=function(e,t,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(e)?e:[e]),o=Lf(e);return o?(s.push.apply(s,Array.from(o.querySelectorAll("[aria-live], script"))),Ff(s,o,n,"aria-hidden")):function(){return null}},_n="Dialog",[Ko,qo]=nt(_n),[Bf,Oe]=Ko(_n),Go=e=>{const{__scopeDialog:t,children:n,open:s,defaultOpen:o,onOpenChange:a,modal:c=!0}=e,l=i.useRef(null),u=i.useRef(null),[f,d]=kt({prop:s,defaultProp:o??!1,onChange:a,caller:_n});return r.jsx(Bf,{scope:t,triggerRef:l,contentRef:u,contentId:Xe(),titleId:Xe(),descriptionId:Xe(),open:f,onOpenChange:d,onOpenToggle:i.useCallback(()=>d(m=>!m),[d]),modal:c,children:n})};Go.displayName=_n;var Yo="DialogTrigger",Xo=i.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Oe(Yo,n),a=le(t,o.triggerRef);return r.jsx(Z.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Kr(o.open),...s,ref:a,onClick:Y(e.onClick,o.onOpenToggle)})});Xo.displayName=Yo;var zr="DialogPortal",[Uf,Jo]=Ko(zr,{forceMount:void 0}),Zo=e=>{const{__scopeDialog:t,forceMount:n,children:s,container:o}=e,a=Oe(zr,t);return r.jsx(Uf,{scope:t,forceMount:n,children:i.Children.map(s,c=>r.jsx(_t,{present:n||a.open,children:r.jsx(Vr,{asChild:!0,container:o,children:c})}))})};Zo.displayName=zr;var mn="DialogOverlay",Qo=i.forwardRef((e,t)=>{const n=Jo(mn,e.__scopeDialog),{forceMount:s=n.forceMount,...o}=e,a=Oe(mn,e.__scopeDialog);return a.modal?r.jsx(_t,{present:s||a.open,children:r.jsx(Wf,{...o,ref:t})}):null});Qo.displayName=mn;var Vf=Ut("DialogOverlay.RemoveScroll"),Wf=i.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Oe(mn,n);return r.jsx(Wr,{as:Vf,allowPinchZoom:!0,shards:[o.contentRef],children:r.jsx(Z.div,{"data-state":Kr(o.open),...s,ref:t,style:{pointerEvents:"auto",...s.style}})})}),dt="DialogContent",ea=i.forwardRef((e,t)=>{const n=Jo(dt,e.__scopeDialog),{forceMount:s=n.forceMount,...o}=e,a=Oe(dt,e.__scopeDialog);return r.jsx(_t,{present:s||a.open,children:a.modal?r.jsx(zf,{...o,ref:t}):r.jsx(Hf,{...o,ref:t})})});ea.displayName=dt;var zf=i.forwardRef((e,t)=>{const n=Oe(dt,e.__scopeDialog),s=i.useRef(null),o=le(t,n.contentRef,s);return i.useEffect(()=>{const a=s.current;if(a)return Ho(a)},[]),r.jsx(ta,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Y(e.onCloseAutoFocus,a=>{var c;a.preventDefault(),(c=n.triggerRef.current)==null||c.focus()}),onPointerDownOutside:Y(e.onPointerDownOutside,a=>{const c=a.detail.originalEvent,l=c.button===0&&c.ctrlKey===!0;(c.button===2||l)&&a.preventDefault()}),onFocusOutside:Y(e.onFocusOutside,a=>a.preventDefault())})}),Hf=i.forwardRef((e,t)=>{const n=Oe(dt,e.__scopeDialog),s=i.useRef(!1),o=i.useRef(!1);return r.jsx(ta,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var c,l;(c=e.onCloseAutoFocus)==null||c.call(e,a),a.defaultPrevented||(s.current||(l=n.triggerRef.current)==null||l.focus(),a.preventDefault()),s.current=!1,o.current=!1},onInteractOutside:a=>{var u,f;(u=e.onInteractOutside)==null||u.call(e,a),a.defaultPrevented||(s.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const c=a.target;((f=n.triggerRef.current)==null?void 0:f.contains(c))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),ta=i.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:a,...c}=e,l=Oe(dt,n),u=i.useRef(null),f=le(t,u);return Io(),r.jsxs(r.Fragment,{children:[r.jsx(Ur,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:o,onUnmountAutoFocus:a,children:r.jsx(Br,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":Kr(l.open),...c,ref:f,onDismiss:()=>l.onOpenChange(!1)})}),r.jsxs(r.Fragment,{children:[r.jsx(qf,{titleId:l.titleId}),r.jsx(Yf,{contentRef:u,descriptionId:l.descriptionId})]})]})}),Hr="DialogTitle",na=i.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Oe(Hr,n);return r.jsx(Z.h2,{id:o.titleId,...s,ref:t})});na.displayName=Hr;var ra="DialogDescription",sa=i.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Oe(ra,n);return r.jsx(Z.p,{id:o.descriptionId,...s,ref:t})});sa.displayName=ra;var oa="DialogClose",aa=i.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Oe(oa,n);return r.jsx(Z.button,{type:"button",...s,ref:t,onClick:Y(e.onClick,()=>o.onOpenChange(!1))})});aa.displayName=oa;function Kr(e){return e?"open":"closed"}var ia="DialogTitleWarning",[Kf,la]=wu(ia,{contentName:dt,titleName:Hr,docsSlug:"dialog"}),qf=({titleId:e})=>{const t=la(ia),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
235
+
236
+ If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
237
+
238
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return i.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Gf="DialogDescriptionWarning",Yf=({contentRef:e,descriptionId:t})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${la(Gf).contentName}}.`;return i.useEffect(()=>{var a;const o=(a=e.current)==null?void 0:a.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(s))},[s,e,t]),null},ca=Go,Xf=Xo,da=Zo,qr=Qo,Gr=ea,Yr=na,Xr=sa,Pn=aa;const Jf=ca,Zf=da,Bx=Pn,ua=i.forwardRef(({className:e,...t},n)=>r.jsx(qr,{ref:n,className:U("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));ua.displayName=qr.displayName;const fa=i.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(Zf,{children:[r.jsx(ua,{}),r.jsxs(Gr,{ref:s,className:U("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[t,r.jsxs(Pn,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[r.jsx(zt,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));fa.displayName=Gr.displayName;const ma=({className:e,...t})=>r.jsx("div",{className:U("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});ma.displayName="DialogHeader";const pa=({className:e,...t})=>r.jsx("div",{className:U("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});pa.displayName="DialogFooter";const ha=i.forwardRef(({className:e,...t},n)=>r.jsx(Yr,{ref:n,className:U("text-lg font-semibold leading-none tracking-tight",e),...t}));ha.displayName=Yr.displayName;const Qf=i.forwardRef(({className:e,...t},n)=>r.jsx(Xr,{ref:n,className:U("text-sm text-muted-foreground",e),...t}));Qf.displayName=Xr.displayName;const Ct=i.forwardRef(({className:e,type:t,...n},s)=>r.jsx("input",{type:t,className:U("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:s,...n}));Ct.displayName="Input";var em=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],tm=em.reduce((e,t)=>{const n=ic(`Primitive.${t}`),s=i.forwardRef((o,a)=>{const{asChild:c,...l}=o,u=c?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(u,{...l,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),nm="Label",xa=i.forwardRef((e,t)=>r.jsx(tm.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));xa.displayName=nm;var ga=xa;const rm=lc("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ue=i.forwardRef(({className:e,...t},n)=>r.jsx(ga,{ref:n,className:U(rm(),e),...t}));Ue.displayName=ga.displayName;function sm({onAdded:e}){const[t,n]=i.useState(""),[s,o]=i.useState(!1),[a,c]=i.useState(null),l=i.useCallback(async u=>{if(u.preventDefault(),!!t.trim()){o(!0),c(null);try{await cc({leaderEndpoint:t.trim(),transport:"devtunnel"}),e()}catch(f){c(f instanceof Error?f.message:"Failed to join node")}finally{o(!1)}}},[t,e]);return r.jsx(fa,{className:"overflow-hidden border-border/60 bg-transparent p-0 shadow-none sm:max-w-xl",children:r.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:[r.jsx("div",{className:"border-b border-border/60 px-6 py-5",children:r.jsxs(ma,{className:"space-y-2 text-left",children:[r.jsx(ha,{className:"text-2xl tracking-tight",children:"Join node"}),r.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."})]})}),r.jsxs("form",{onSubmit:l,className:"space-y-4 px-6 py-5",children:[a&&r.jsx("div",{className:"rounded-[20px] border border-destructive/20 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:a}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx(Ue,{htmlFor:"leader-endpoint",children:"Leader endpoint"}),r.jsx(Ce,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 text-[10px] uppercase tracking-[0.16em]",children:"DevTunnel only"})]}),r.jsx(Ct,{id:"leader-endpoint",type:"url",value:t,onChange:u=>n(u.target.value),placeholder:"https://your-leader.devtunnels.ms",className:"h-11 rounded-2xl border-border/70 bg-background/70"})]}),r.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."}),r.jsx(pa,{className:"border-t border-border/60 pt-4",children:r.jsx(H,{type:"submit",disabled:!t.trim()||s,className:"rounded-2xl",children:s?"Joining...":"Join node"})})]})]})})}function va(){const[e,t]=i.useState([]),[n,s]=i.useState(null),o=i.useRef(null),a=i.useCallback(()=>{var d;(d=o.current)==null||d.click()},[]),c=i.useCallback(async d=>{const m=Array.from(d.target.files??[]);if(m.length!==0)try{const h=await As(m);t(g=>[...g,...h]),s(null)}catch(h){s(h instanceof Error?h.message:"Failed to attach image")}finally{d.target.value=""}},[]),l=i.useCallback(async d=>{const m=Jd(d.clipboardData);if(m.length!==0){d.preventDefault();try{const h=await As(m);t(g=>[...g,...h]),s(null)}catch(h){s(h instanceof Error?h.message:"Failed to attach image")}}},[]),u=i.useCallback(d=>{t(m=>m.filter((h,g)=>g!==d))},[]),f=i.useCallback(()=>{t([]),s(null)},[]);return{images:e,error:n,fileInputRef:o,pickImages:a,handleFileChange:c,handlePaste:l,removeImage:u,clearImages:f}}function om({onSend:e,disabled:t,disabledReason:n="Chat is waiting on the agent.",placeholder:s="Send a follow-up message...",contextItems:o=[],running:a=!1,onStop:c}){const[l,u]=i.useState(""),f=i.useRef(null),{images:d,error:m,fileInputRef:h,pickImages:g,handleFileChange:x,handlePaste:p,removeImage:v,clearImages:b}=va(),y=i.useCallback(()=>{f.current&&(f.current.style.height="auto")},[]),w=i.useCallback(()=>{const R=Ro(l,d);R.length===0||t||(e(R),u(""),b(),y())},[l,d,t,e,b,y]),j=i.useCallback(R=>{R.key==="Enter"&&!R.shiftKey&&(R.preventDefault(),w())},[w]),k=i.useCallback(()=>{f.current&&(f.current.style.height="auto",f.current.style.height=`${Math.min(f.current.scrollHeight,220)}px`)},[]),C=!t&&!a&&(l.trim().length>0||d.length>0),S=a&&!!c,T=a?c?"Task is running — click to stop":"Task is running...":t?n:"Enter sends, Shift+Enter adds a line";return r.jsxs("div",{className:"border-t border-border/60 bg-background/55 px-2 py-1.5 backdrop-blur-xl sm:px-4 sm:py-2",children:[o.length>0&&r.jsx("div",{className:"flex flex-wrap items-center gap-2 px-3 pb-2.5",children:o.map(R=>r.jsxs("div",{className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-border/60 bg-muted/40 px-3 py-1 text-xs",children:[r.jsx("span",{className:"shrink-0 text-[9px] font-medium uppercase tracking-[0.12em] text-muted-foreground/80",children:R.label}),r.jsx("span",{className:`truncate text-foreground/90 ${R.mono?"font-mono text-[11px]":""}`,children:R.value})]},`${R.label}:${R.value}`))}),r.jsxs("div",{className:"overflow-hidden rounded-3xl border border-border/65 bg-card/85 shadow-[0_28px_90px_-62px_rgba(0,0,0,var(--panel-shadow-alpha))] sm:rounded-[40px]",children:[r.jsx("input",{ref:h,type:"file",accept:"image/*",multiple:!0,onChange:x,className:"hidden"}),d.length>0&&r.jsx("div",{className:"px-3 pt-3 sm:px-6 sm:pt-6",children:r.jsx("div",{className:"flex flex-wrap gap-3",children:d.map((R,A)=>r.jsxs("div",{className:"relative",children:[r.jsx("img",{src:$r(R),alt:R.filename??`attachment ${A+1}`,className:"h-24 w-24 rounded-[22px] border border-border/70 object-cover"}),r.jsx("button",{type:"button",onClick:()=>v(A),className:"absolute -top-2 -right-2 flex h-7 w-7 items-center justify-center rounded-full border border-border/70 bg-background text-muted-foreground transition-colors hover:text-foreground","aria-label":`Remove ${R.filename??`image ${A+1}`}`,children:r.jsx(zt,{className:"h-3.5 w-3.5"})})]},`${R.filename??"image"}-${A}`))})}),r.jsxs("div",{className:"flex items-end gap-2 px-3 pt-3 pb-3 sm:px-6 sm:pt-4 sm:pb-4",children:[r.jsx("textarea",{ref:f,value:l,onChange:R=>u(R.target.value),onKeyDown:j,onPaste:p,onInput:k,placeholder:s,disabled:t,rows:1,className:"min-h-[2.5rem] flex-1 resize-none bg-transparent px-0 py-1 text-sm leading-7 text-foreground placeholder:text-muted-foreground/70 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),r.jsxs(H,{type:"button",variant:"ghost",onClick:g,disabled:t,className:"mb-0.5 h-9 shrink-0 gap-1.5 rounded-full px-2 text-xs text-muted-foreground hover:text-foreground sm:px-3",title:"Attach images",children:[r.jsx(fr,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"}),r.jsx("span",{className:"hidden sm:inline",children:"Images"})]}),r.jsx("span",{title:T,children:r.jsx(H,{onClick:a?c:w,disabled:a?!S:!C,size:"icon","aria-label":a?"Stop running task":"Send message",className:"mb-0.5 h-9 w-9 shrink-0 rounded-full bg-primary/85 text-primary-foreground shadow-sm hover:bg-primary",children:a?r.jsx(ye,{className:"h-4 w-4 animate-spin"}):r.jsx(Co,{className:"h-4 w-4"})})})]}),m&&r.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive sm:px-6 sm:py-3",children:m})]})]})}function Vt({payload:e,disabled:t=!1,bypassEnabled:n=!1,onBypassChange:s,onSubmit:o}){const[a,c]=i.useState(()=>n?ru(e):e.questions.map(()=>[])),[l,u]=i.useState(!1),[f,d]=i.useState(!1);i.useEffect(()=>{n&&c(x=>x.map((p,v)=>{var b;return p.length>0?p:(b=e.questions[v])!=null&&b.options.length?[0]:[]}))},[n,e]);const m=su(e,a)&&!t&&!l&&!f&&!!o,h=(x,p)=>{t||f||l||c(v=>v.map((b,y)=>{if(y!==x)return b;const w=e.questions[y];return w?w.multiSelect?b.includes(p)?b.filter(j=>j!==p):[...b,p].sort((j,k)=>j-k):[p]:b}))},g=async()=>{if(!m||!o)return;u(!0);const x=await o(ou(e,a));u(!1),x&&d(!0)};return r.jsxs("div",{className:"rounded-[24px] border border-primary/20 bg-primary/5 p-4 shadow-[0_24px_80px_-60px_hsl(var(--primary)/0.9)]",children:[r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-primary/20 bg-primary/10 text-primary",children:r.jsx(zc,{className:"h-4 w-4"})}),r.jsxs("div",{children:[r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.22em] text-primary/80",children:"Ask User Question"}),r.jsx("div",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:"Select the answer you want to send back to the agent."})]})]}),r.jsxs(H,{type:"button",variant:n?"secondary":"outline",size:"sm",onClick:()=>s==null?void 0:s(!n),className:"rounded-full",children:[r.jsx(Rd,{className:"h-4 w-4"}),n?"Bypass on":"Bypass future questions"]})]}),r.jsx("div",{className:"mt-4 space-y-4",children:e.questions.map((x,p)=>{const v=a[p]??[];return r.jsxs("div",{className:"space-y-3 rounded-[20px] border border-border/60 bg-background/75 p-4",children:[r.jsxs("div",{children:[x.header&&r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-muted-foreground",children:x.header}),r.jsx("div",{className:"mt-1 text-sm font-medium leading-6 text-foreground",children:x.question}),r.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:x.multiSelect?"Select one or more options.":"Select one option."})]}),r.jsx("div",{className:"space-y-2",children:x.options.map((b,y)=>{const w=v.includes(y);return r.jsxs("button",{type:"button",onClick:()=>h(p,y),disabled:t||l||f,"aria-pressed":w,className:U("flex w-full items-start gap-3 rounded-[18px] border px-4 py-3 text-left transition-colors",w?"border-primary/50 bg-primary/10 text-foreground":"border-border/60 bg-background/80 text-foreground hover:border-primary/30 hover:bg-primary/5"),children:[r.jsx("span",{className:U("mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border",w?"border-primary bg-primary text-primary-foreground":"border-border/70 bg-background text-transparent"),children:r.jsx(pt,{className:"h-3.5 w-3.5"})}),r.jsxs("span",{className:"min-w-0",children:[r.jsx("span",{className:"block text-sm font-medium leading-5",children:b.label}),b.description&&r.jsx("span",{className:"mt-1 block text-xs leading-5 text-muted-foreground",children:b.description})]})]},`${b.label}-${y}`)})})]},`${x.header??"question"}-${p}`)})}),r.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-3",children:[r.jsx("div",{className:"text-xs text-muted-foreground",children:n?"Bypass is enabled. New question cards will default to the first option.":"Enable bypass if you want future question cards to preselect the first option."}),r.jsx(H,{type:"button",onClick:()=>void g(),disabled:!m,className:"rounded-full px-5",children:f?"Sent":l?"Sending...":e.questions.length>1?"Send answers":"Send answer"})]})]})}function am({payload:e,disabled:t=!1,onSubmit:n}){const[s,o]=i.useState(null),[a,c]=i.useState(!1),l=!t&&!a&&!!n,u=async f=>{if(!l||!n)return;o(f);const d=await n(du(e,f));o(null),d&&c(!0)};return r.jsxs("div",{className:"rounded-[24px] border border-amber-500/25 bg-amber-500/5 p-4 shadow-[0_24px_80px_-60px_rgba(245,158,11,0.8)]",children:[r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-amber-500/25 bg-amber-500/10 text-amber-600 dark:text-amber-400",children:r.jsx(Td,{className:"h-4 w-4"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.22em] text-amber-700/80 dark:text-amber-300/80",children:"Permission Request"}),r.jsx("div",{className:"mt-1 space-y-3",children:e.requests.map((f,d)=>r.jsxs("div",{className:"rounded-[18px] border border-border/60 bg-background/75 px-4 py-3",children:[r.jsx("div",{className:"text-sm font-medium leading-6 text-foreground",children:f.summary}),(f.toolName||f.target)&&r.jsxs("div",{className:"mt-2 flex flex-wrap gap-2 text-[11px] uppercase tracking-[0.18em] text-muted-foreground",children:[r.jsx("span",{children:f.toolName}),f.target&&r.jsx("span",{className:"font-mono normal-case tracking-normal",children:f.target})]})]},`${f.toolUseId??f.toolName}-${d}`))})]})]}),r.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-end gap-2",children:[r.jsxs(H,{type:"button",variant:"outline",onClick:()=>void u("deny"),disabled:!l||s!==null,className:"rounded-full",children:[r.jsx(zt,{className:"h-4 w-4"}),a?"Sent":s==="deny"?"Sending...":"Deny"]}),r.jsxs(H,{type:"button",onClick:()=>void u("approve"),disabled:!l||s!==null,className:"rounded-full",children:[r.jsx(pt,{className:"h-4 w-4"}),a?"Sent":s==="approve"?"Sending...":"Approve"]})]})]})}function zs({event:e,questionBypassEnabled:t=!1,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o=!1}){const a=e.type,c=Fr(e),l=Tn(e);if(c)return r.jsx($t,{children:r.jsx(am,{payload:c,onSubmit:s,disabled:o})});if(l)return r.jsx($t,{children:r.jsx(Vt,{payload:l,bypassEnabled:t,onBypassChange:n,onSubmit:s,disabled:o})});if(a==="user"){const u=im(e),f=u.filter(m=>m.type==="tool_result");if(f.length>0&&u.every(m=>m.type==="tool_result"))return r.jsx($t,{children:f.map((m,h)=>r.jsx(ba,{block:m,questionBypassEnabled:t,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o},h))});const d=Ht(e);return d?r.jsx(lm,{content:d}):null}return a==="assistant"?r.jsx(cm,{event:e,questionBypassEnabled:t,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o}):null}function im(e){const t=e.message,n=t==null?void 0:t.content;if(Array.isArray(n))return n.filter(o=>typeof o=="object"&&o!==null);const s=e.content;return Array.isArray(s)?s.filter(o=>typeof o=="object"&&o!==null):[]}function rr(e){var n;const t=e.replace(/\r\n/g,`
239
+ `).split(`
240
+ `);for(;t.length>0&&((n=t[0])==null?void 0:n.trim())==="";)t.shift();return t.join(`
241
+ `)}function lm({content:e}){const t=Xd(e),n=e.filter(s=>s.type==="image");return r.jsx("div",{className:"animate-message-rise flex justify-end",children:r.jsxs("div",{className:"flex max-w-[88%] items-start gap-3",children:[r.jsxs("div",{className:"space-y-1 rounded-[26px] rounded-tr-md border border-primary/25 bg-primary px-4 py-3 text-[13px] leading-5 text-primary-foreground shadow-[0_20px_70px_-42px_hsl(var(--primary)/0.95)]",children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.28em] text-primary-foreground/75",children:"You"}),t&&r.jsx("div",{className:"whitespace-pre-wrap",children:t}),n.length>0&&r.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:n.map((s,o)=>r.jsx("img",{src:$r(s),alt:s.filename??`attachment ${o+1}`,className:"max-h-72 rounded-2xl border border-primary-foreground/15 object-cover"},`${s.filename??"image"}-${o}`))})]}),r.jsx("div",{className:"mt-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-primary/20 bg-primary/10 text-primary",children:r.jsx(Md,{className:"h-4 w-4"})})]})})}function $t({children:e}){return r.jsx("div",{className:"animate-message-rise flex justify-start",children:r.jsxs("div",{className:"flex max-w-[92%] items-start gap-3",children:[r.jsx("div",{className:"mt-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-border/70 bg-muted/70 text-muted-foreground",children:r.jsx(yo,{className:"h-4 w-4"})}),r.jsxs("div",{className:"min-w-0 space-y-3",children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.28em] text-muted-foreground",children:"Agent"}),e]})]})})}function cm({event:e,questionBypassEnabled:t,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o}){const a=e.message;if(!a)return null;const c=Tn(a);if(c)return r.jsx($t,{children:r.jsx(Vt,{payload:c,bypassEnabled:t,onBypassChange:n,onSubmit:s,disabled:o})});const l=a.content;if(!l||!Array.isArray(l))return null;const u=new Set,f=l.filter(x=>x.type==="text").map(x=>({...x,text:rr(String(x.text??"")),questionPayload:An(rr(String(x.text??"")))})).filter(x=>x.text.length>0||x.questionPayload),d=l.filter(x=>x.type==="thinking").map(x=>rr(String(x.thinking??""))).filter(Boolean).join(`
242
+
243
+ `),m=l.filter(x=>x.type==="tool_use"),h=l.filter(x=>x.type==="tool_result");return f.length>0||d.length>0||m.length>0||h.length>0?r.jsxs($t,{children:[d.length>0&&r.jsx(mm,{text:d}),f.map((x,p)=>{if(x.questionPayload){const v=Rt(x.questionPayload);return u.has(v)?null:(u.add(v),r.jsx(Vt,{payload:x.questionPayload,bypassEnabled:t,onBypassChange:n,onSubmit:s,disabled:o},p))}return r.jsx("div",{className:"rounded-[26px] rounded-tl-md border border-border/70 bg-card/80 px-4 py-3 text-[13px] leading-5 text-foreground shadow-[0_20px_70px_-58px_rgba(0,0,0,0.9)] backdrop-blur-sm",children:r.jsx("div",{className:"whitespace-pre-wrap",children:x.text})},p)}),m.map((x,p)=>r.jsx(pm,{block:x,renderedQuestionSignatures:u,questionBypassEnabled:t,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o},p)),h.map((x,p)=>r.jsx(ba,{block:x,renderedQuestionSignatures:u,questionBypassEnabled:t,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o},p))]}):null}function dm(e){return e.replace(/\s+/g," ").trim()}function Nt(e,t=132){const n=dm(e);return n?n.length>t?`${n.slice(0,t-3)}...`:n:""}function vr(e,t=84){if(typeof e=="string")return Nt(e,t);if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e)){const n=e.slice(0,3).map(s=>vr(s,28)).filter(Boolean).join(", ");return Nt(n||JSON.stringify(e),t)}if(typeof e=="object"&&e!==null){const n=Object.entries(e).slice(0,3).map(([s,o])=>`${s}: ${vr(o,32)}`).join(" · ");return Nt(n||JSON.stringify(e),t)}return""}function um(e){if(!e)return"No input";const t=Object.entries(e).slice(0,4).map(([n,s])=>`${n}: ${vr(s,40)}`).filter(n=>n.trim().length>0).join(" · ");return Nt(t||JSON.stringify(e),156)||"No input"}function fm({expanded:e}){return r.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full border border-border/60 bg-background/70 px-2 py-1 text-[10px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:[e?"Less":"More",e?r.jsx(Or,{className:"h-3 w-3"}):r.jsx(Tt,{className:"h-3 w-3"})]})}function Jr({title:e,preview:t,icon:n,children:s,accentClassName:o,previewClassName:a="font-mono text-[11px] text-muted-foreground/90"}){const[c,l]=i.useState(!1);return r.jsxs("div",{className:`overflow-hidden rounded-[22px] border border-border/60 ${o}`,children:[r.jsxs("button",{type:"button",onClick:()=>l(u=>!u),className:"flex w-full items-start gap-3 px-4 py-3 text-left transition-colors hover:bg-background/30",children:[r.jsx("div",{className:"mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-full border border-border/60 bg-background/70 text-muted-foreground",children:n}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"flex flex-wrap items-center gap-2",children:r.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.22em] text-muted-foreground",children:e})}),r.jsx("div",{className:`mt-1 whitespace-pre-wrap break-words text-[12px] leading-5 ${a}`,children:t})]}),r.jsx(fm,{expanded:c})]}),c&&r.jsx("div",{className:"border-t border-border/60 px-4 py-3",children:s})]})}function mm({text:e}){const t=Nt(e,156);return r.jsx(Jr,{title:"Thinking",preview:t,icon:r.jsx($c,{className:"h-3.5 w-3.5"}),accentClassName:"bg-muted/35",previewClassName:"text-[12px] leading-5 text-muted-foreground/90",children:r.jsx("div",{className:"whitespace-pre-wrap text-[13px] leading-5 text-muted-foreground/90",children:e})})}function pm({block:e,renderedQuestionSignatures:t,questionBypassEnabled:n,onQuestionBypassChange:s,onSubmitQuestionResponse:o,questionResponseDisabled:a}){const c=String(e.name??"tool"),l=e.input,u=Tn(e);if(u){const d=Rt(u);return t!=null&&t.has(d)?null:(t==null||t.add(d),r.jsx(Vt,{payload:u,bypassEnabled:n,onBypassChange:s,onSubmit:o,disabled:a}))}const f=um(l);if(c==="TodoWrite"){const d=hm(l==null?void 0:l.todos);if(d.length>0)return r.jsx(xm,{todos:d})}return r.jsx(Jr,{title:`Tool: ${c}`,preview:f,icon:r.jsx(Eo,{className:"h-3.5 w-3.5"}),accentClassName:"bg-muted/25",children:r.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap text-xs leading-5 text-muted-foreground",children:JSON.stringify(l??{},null,2)})})}function ba({block:e,renderedQuestionSignatures:t,questionBypassEnabled:n,onQuestionBypassChange:s,onSubmitQuestionResponse:o,questionResponseDisabled:a}){const c=e.content,l=typeof c=="string"?c:Array.isArray(c)?c.map(d=>String(d.text??"")).join(`
244
+ `):"";if(!l)return null;const u=An(l);if(u){const d=Rt(u);return t!=null&&t.has(d)?null:(t==null||t.add(d),r.jsx(Vt,{payload:u,bypassEnabled:n,onBypassChange:s,onSubmit:o,disabled:a}))}const f=Nt(l,156);return r.jsx(Jr,{title:"Result",preview:f,icon:r.jsx(Eo,{className:"h-3.5 w-3.5"}),accentClassName:"bg-background/65",children:r.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap text-xs leading-5 text-muted-foreground",children:l})})}function hm(e){return Array.isArray(e)?e.map(t=>{if(typeof t!="object"||t===null)return null;const n=t,s=typeof n.content=="string"?n.content:"";if(!s)return null;const o=typeof n.activeForm=="string"?n.activeForm:s,a=typeof n.status=="string"?n.status:"pending";return{content:s,activeForm:o,status:a==="completed"||a==="in_progress"?a:"pending"}}).filter(t=>t!==null):[]}function xm({todos:e}){const t=e.filter(o=>o.status==="completed").length,n=e.length,s=e.find(o=>o.status==="in_progress");return r.jsxs("div",{className:"overflow-hidden rounded-[22px] border border-border/60 bg-muted/20",children:[r.jsxs("div",{className:"flex items-center gap-3 border-b border-border/50 px-4 py-3",children:[r.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full border border-border/60 bg-background/70 text-muted-foreground",children:r.jsx(md,{className:"h-3.5 w-3.5"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.22em] text-muted-foreground",children:"Todos"}),r.jsx("div",{className:"mt-0.5 truncate text-[12px] leading-5 text-muted-foreground/90",children:s?s.activeForm:n===0?"No items":t===n?"All complete":"Up next"})]}),r.jsxs("div",{className:"shrink-0 rounded-full border border-border/60 bg-background/70 px-2 py-0.5 font-mono text-[10px] tracking-wide text-muted-foreground",children:[t,"/",n]})]}),r.jsx("ul",{className:"divide-y divide-border/40",children:e.map((o,a)=>r.jsxs("li",{className:"flex items-start gap-3 px-4 py-2.5",children:[r.jsx(gm,{status:o.status}),r.jsx("span",{className:o.status==="completed"?"text-[13px] leading-5 text-muted-foreground line-through decoration-muted-foreground/60":o.status==="in_progress"?"text-[13px] font-medium leading-5 text-foreground":"text-[13px] leading-5 text-foreground/85",children:o.status==="in_progress"?o.activeForm:o.content})]},`${a}-${o.content}`))})]})}function gm({status:e}){return e==="completed"?r.jsx("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-emerald-500/15 text-emerald-500 dark:text-emerald-400",children:r.jsx(pt,{className:"h-3 w-3"})}):e==="in_progress"?r.jsx("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center text-primary",children:r.jsx(ye,{className:"h-3.5 w-3.5 animate-spin"})}):r.jsx("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground/60",children:r.jsx(Gc,{className:"h-3 w-3"})})}function ya(e){const t=e+"CollectionProvider",[n,s]=nt(t),[o,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),c=p=>{const{scope:v,children:b}=p,y=it.useRef(null),w=it.useRef(new Map).current;return r.jsx(o,{scope:v,itemMap:w,collectionRef:y,children:b})};c.displayName=t;const l=e+"CollectionSlot",u=Ut(l),f=it.forwardRef((p,v)=>{const{scope:b,children:y}=p,w=a(l,b),j=le(v,w.collectionRef);return r.jsx(u,{ref:j,children:y})});f.displayName=l;const d=e+"CollectionItemSlot",m="data-radix-collection-item",h=Ut(d),g=it.forwardRef((p,v)=>{const{scope:b,children:y,...w}=p,j=it.useRef(null),k=le(v,j),C=a(d,b);return it.useEffect(()=>(C.itemMap.set(j,{ref:j,...w}),()=>void C.itemMap.delete(j))),r.jsx(h,{[m]:"",ref:k,children:y})});g.displayName=d;function x(p){const v=a(e+"CollectionConsumer",p);return it.useCallback(()=>{const y=v.collectionRef.current;if(!y)return[];const w=Array.from(y.querySelectorAll(`[${m}]`));return Array.from(v.itemMap.values()).sort((C,S)=>w.indexOf(C.ref.current)-w.indexOf(S.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:c,Slot:f,ItemSlot:g},x,s]}var vm=i.createContext(void 0);function Zr(e){const t=i.useContext(vm);return e||t||"ltr"}var sr="rovingFocusGroup.onEntryFocus",bm={bubbles:!1,cancelable:!0},qt="RovingFocusGroup",[br,wa,ym]=ya(qt),[wm,Na]=nt(qt,[ym]),[Nm,jm]=wm(qt),ja=i.forwardRef((e,t)=>r.jsx(br.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(br.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Sm,{...e,ref:t})})}));ja.displayName=qt;var Sm=i.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:o=!1,dir:a,currentTabStopId:c,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:u,onEntryFocus:f,preventScrollOnEntryFocus:d=!1,...m}=e,h=i.useRef(null),g=le(t,h),x=Zr(a),[p,v]=kt({prop:c,defaultProp:l??null,onChange:u,caller:qt}),[b,y]=i.useState(!1),w=Qe(f),j=wa(n),k=i.useRef(!1),[C,S]=i.useState(0);return i.useEffect(()=>{const T=h.current;if(T)return T.addEventListener(sr,w),()=>T.removeEventListener(sr,w)},[w]),r.jsx(Nm,{scope:n,orientation:s,dir:x,loop:o,currentTabStopId:p,onItemFocus:i.useCallback(T=>v(T),[v]),onItemShiftTab:i.useCallback(()=>y(!0),[]),onFocusableItemAdd:i.useCallback(()=>S(T=>T+1),[]),onFocusableItemRemove:i.useCallback(()=>S(T=>T-1),[]),children:r.jsx(Z.div,{tabIndex:b||C===0?-1:0,"data-orientation":s,...m,ref:g,style:{outline:"none",...e.style},onMouseDown:Y(e.onMouseDown,()=>{k.current=!0}),onFocus:Y(e.onFocus,T=>{const R=!k.current;if(T.target===T.currentTarget&&R&&!b){const A=new CustomEvent(sr,bm);if(T.currentTarget.dispatchEvent(A),!A.defaultPrevented){const O=j().filter(P=>P.focusable),$=O.find(P=>P.active),V=O.find(P=>P.id===p),z=[$,V,...O].filter(Boolean).map(P=>P.ref.current);Ca(z,d)}}k.current=!1}),onBlur:Y(e.onBlur,()=>y(!1))})})}),Sa="RovingFocusGroupItem",ka=i.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:o=!1,tabStopId:a,children:c,...l}=e,u=Xe(),f=a||u,d=jm(Sa,n),m=d.currentTabStopId===f,h=wa(n),{onFocusableItemAdd:g,onFocusableItemRemove:x,currentTabStopId:p}=d;return i.useEffect(()=>{if(s)return g(),()=>x()},[s,g,x]),r.jsx(br.ItemSlot,{scope:n,id:f,focusable:s,active:o,children:r.jsx(Z.span,{tabIndex:m?0:-1,"data-orientation":d.orientation,...l,ref:t,onMouseDown:Y(e.onMouseDown,v=>{s?d.onItemFocus(f):v.preventDefault()}),onFocus:Y(e.onFocus,()=>d.onItemFocus(f)),onKeyDown:Y(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){d.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const b=Em(v,d.orientation,d.dir);if(b!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let w=h().filter(j=>j.focusable).map(j=>j.ref.current);if(b==="last")w.reverse();else if(b==="prev"||b==="next"){b==="prev"&&w.reverse();const j=w.indexOf(v.currentTarget);w=d.loop?Tm(w,j+1):w.slice(j+1)}setTimeout(()=>Ca(w))}}),children:typeof c=="function"?c({isCurrentTabStop:m,hasTabStop:p!=null}):c})})});ka.displayName=Sa;var km={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Cm(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Em(e,t,n){const s=Cm(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return km[s]}function Ca(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function Tm(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Am=ja,Rm=ka,Dn="Tabs",[_m]=nt(Dn,[Na]),Ea=Na(),[Pm,Qr]=_m(Dn),Ta=i.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:o,defaultValue:a,orientation:c="horizontal",dir:l,activationMode:u="automatic",...f}=e,d=Zr(l),[m,h]=kt({prop:s,onChange:o,defaultProp:a??"",caller:Dn});return r.jsx(Pm,{scope:n,baseId:Xe(),value:m,onValueChange:h,orientation:c,dir:d,activationMode:u,children:r.jsx(Z.div,{dir:d,"data-orientation":c,...f,ref:t})})});Ta.displayName=Dn;var Aa="TabsList",Ra=i.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...o}=e,a=Qr(Aa,n),c=Ea(n);return r.jsx(Am,{asChild:!0,...c,orientation:a.orientation,dir:a.dir,loop:s,children:r.jsx(Z.div,{role:"tablist","aria-orientation":a.orientation,...o,ref:t})})});Ra.displayName=Aa;var _a="TabsTrigger",Pa=i.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,disabled:o=!1,...a}=e,c=Qr(_a,n),l=Ea(n),u=Oa(c.baseId,s),f=Ia(c.baseId,s),d=s===c.value;return r.jsx(Rm,{asChild:!0,...l,focusable:!o,active:d,children:r.jsx(Z.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":f,"data-state":d?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:u,...a,ref:t,onMouseDown:Y(e.onMouseDown,m=>{!o&&m.button===0&&m.ctrlKey===!1?c.onValueChange(s):m.preventDefault()}),onKeyDown:Y(e.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&c.onValueChange(s)}),onFocus:Y(e.onFocus,()=>{const m=c.activationMode!=="manual";!d&&!o&&m&&c.onValueChange(s)})})})});Pa.displayName=_a;var Da="TabsContent",Ma=i.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,forceMount:o,children:a,...c}=e,l=Qr(Da,n),u=Oa(l.baseId,s),f=Ia(l.baseId,s),d=s===l.value,m=i.useRef(d);return i.useEffect(()=>{const h=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(h)},[]),r.jsx(_t,{present:o||d,children:({present:h})=>r.jsx(Z.div,{"data-state":d?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":u,hidden:!h,id:f,tabIndex:0,...c,ref:t,style:{...e.style,animationDuration:m.current?"0s":void 0},children:h&&a})})});Ma.displayName=Da;function Oa(e,t){return`${e}-trigger-${t}`}function Ia(e,t){return`${e}-content-${t}`}var Dm=Ta,La=Ra,$a=Pa,Fa=Ma;const Ba=Dm,es=i.forwardRef(({className:e,...t},n)=>r.jsx(La,{ref:n,className:U("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));es.displayName=La.displayName;const Ge=i.forwardRef(({className:e,...t},n)=>r.jsx($a,{ref:n,className:U("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...t}));Ge.displayName=$a.displayName;const Ye=i.forwardRef(({className:e,...t},n)=>r.jsx(Fa,{ref:n,className:U("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Ye.displayName=Fa.displayName;var Ua="AlertDialog",[Mm]=nt(Ua,[qo]),ze=qo(),Va=e=>{const{__scopeAlertDialog:t,...n}=e,s=ze(t);return r.jsx(ca,{...s,...n,modal:!0})};Va.displayName=Ua;var Om="AlertDialogTrigger",Wa=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=ze(n);return r.jsx(Xf,{...o,...s,ref:t})});Wa.displayName=Om;var Im="AlertDialogPortal",za=e=>{const{__scopeAlertDialog:t,...n}=e,s=ze(t);return r.jsx(da,{...s,...n})};za.displayName=Im;var Lm="AlertDialogOverlay",Ha=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=ze(n);return r.jsx(qr,{...o,...s,ref:t})});Ha.displayName=Lm;var jt="AlertDialogContent",[$m,Fm]=Mm(jt),Bm=Au("AlertDialogContent"),Ka=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,children:s,...o}=e,a=ze(n),c=i.useRef(null),l=le(t,c),u=i.useRef(null);return r.jsx(Kf,{contentName:jt,titleName:qa,docsSlug:"alert-dialog",children:r.jsx($m,{scope:n,cancelRef:u,children:r.jsxs(Gr,{role:"alertdialog",...a,...o,ref:l,onOpenAutoFocus:Y(o.onOpenAutoFocus,f=>{var d;f.preventDefault(),(d=u.current)==null||d.focus({preventScroll:!0})}),onPointerDownOutside:f=>f.preventDefault(),onInteractOutside:f=>f.preventDefault(),children:[r.jsx(Bm,{children:s}),r.jsx(Vm,{contentRef:c})]})})})});Ka.displayName=jt;var qa="AlertDialogTitle",Ga=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=ze(n);return r.jsx(Yr,{...o,...s,ref:t})});Ga.displayName=qa;var Ya="AlertDialogDescription",Xa=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=ze(n);return r.jsx(Xr,{...o,...s,ref:t})});Xa.displayName=Ya;var Um="AlertDialogAction",Ja=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=ze(n);return r.jsx(Pn,{...o,...s,ref:t})});Ja.displayName=Um;var Za="AlertDialogCancel",Qa=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,{cancelRef:o}=Fm(Za,n),a=ze(n),c=le(t,o);return r.jsx(Pn,{...a,...s,ref:c})});Qa.displayName=Za;var Vm=({contentRef:e})=>{const t=`\`${jt}\` requires a description for the component to be accessible for screen reader users.
245
+
246
+ You can add a description to the \`${jt}\` by passing a \`${Ya}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
247
+
248
+ Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${jt}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
249
+
250
+ For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return i.useEffect(()=>{var s;document.getElementById((s=e.current)==null?void 0:s.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},Wm=Va,zm=Wa,Hm=za,ei=Ha,ti=Ka,ni=Ja,ri=Qa,si=Ga,oi=Xa;const yr=Wm,Hs=zm,Km=Hm,ai=i.forwardRef(({className:e,...t},n)=>r.jsx(ei,{className:U("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));ai.displayName=ei.displayName;const pn=i.forwardRef(({className:e,...t},n)=>r.jsxs(Km,{children:[r.jsx(ai,{}),r.jsx(ti,{ref:n,className:U("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]}));pn.displayName=ti.displayName;const hn=({className:e,...t})=>r.jsx("div",{className:U("flex flex-col space-y-2 text-center sm:text-left",e),...t});hn.displayName="AlertDialogHeader";const xn=({className:e,...t})=>r.jsx("div",{className:U("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});xn.displayName="AlertDialogFooter";const gn=i.forwardRef(({className:e,...t},n)=>r.jsx(si,{ref:n,className:U("text-lg font-semibold",e),...t}));gn.displayName=si.displayName;const vn=i.forwardRef(({className:e,...t},n)=>r.jsx(oi,{ref:n,className:U("text-sm text-muted-foreground",e),...t}));vn.displayName=oi.displayName;const bn=i.forwardRef(({className:e,...t},n)=>r.jsx(ni,{ref:n,className:U(xo(),e),...t}));bn.displayName=ni.displayName;const yn=i.forwardRef(({className:e,...t},n)=>r.jsx(ri,{ref:n,className:U(xo({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));yn.displayName=ri.displayName;function Ks(e,[t,n]){return Math.min(n,Math.max(t,e))}const qm=["top","right","bottom","left"],et=Math.min,Se=Math.max,wn=Math.round,on=Math.floor,$e=e=>({x:e,y:e}),Gm={left:"right",right:"left",bottom:"top",top:"bottom"};function wr(e,t,n){return Se(e,et(t,n))}function Ve(e,t){return typeof e=="function"?e(t):e}function We(e){return e.split("-")[0]}function Pt(e){return e.split("-")[1]}function ts(e){return e==="x"?"y":"x"}function ns(e){return e==="y"?"height":"width"}function Le(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function rs(e){return ts(Le(e))}function Ym(e,t,n){n===void 0&&(n=!1);const s=Pt(e),o=rs(e),a=ns(o);let c=o==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(c=Nn(c)),[c,Nn(c)]}function Xm(e){const t=Nn(e);return[Nr(e),t,Nr(t)]}function Nr(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const qs=["left","right"],Gs=["right","left"],Jm=["top","bottom"],Zm=["bottom","top"];function Qm(e,t,n){switch(e){case"top":case"bottom":return n?t?Gs:qs:t?qs:Gs;case"left":case"right":return t?Jm:Zm;default:return[]}}function ep(e,t,n,s){const o=Pt(e);let a=Qm(We(e),n==="start",s);return o&&(a=a.map(c=>c+"-"+o),t&&(a=a.concat(a.map(Nr)))),a}function Nn(e){const t=We(e);return Gm[t]+e.slice(t.length)}function tp(e){return{top:0,right:0,bottom:0,left:0,...e}}function ii(e){return typeof e!="number"?tp(e):{top:e,right:e,bottom:e,left:e}}function jn(e){const{x:t,y:n,width:s,height:o}=e;return{width:s,height:o,top:n,left:t,right:t+s,bottom:n+o,x:t,y:n}}function Ys(e,t,n){let{reference:s,floating:o}=e;const a=Le(t),c=rs(t),l=ns(c),u=We(t),f=a==="y",d=s.x+s.width/2-o.width/2,m=s.y+s.height/2-o.height/2,h=s[l]/2-o[l]/2;let g;switch(u){case"top":g={x:d,y:s.y-o.height};break;case"bottom":g={x:d,y:s.y+s.height};break;case"right":g={x:s.x+s.width,y:m};break;case"left":g={x:s.x-o.width,y:m};break;default:g={x:s.x,y:s.y}}switch(Pt(t)){case"start":g[c]-=h*(n&&f?-1:1);break;case"end":g[c]+=h*(n&&f?-1:1);break}return g}async function np(e,t){var n;t===void 0&&(t={});const{x:s,y:o,platform:a,rects:c,elements:l,strategy:u}=e,{boundary:f="clippingAncestors",rootBoundary:d="viewport",elementContext:m="floating",altBoundary:h=!1,padding:g=0}=Ve(t,e),x=ii(g),v=l[h?m==="floating"?"reference":"floating":m],b=jn(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(v)))==null||n?v:v.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(l.floating)),boundary:f,rootBoundary:d,strategy:u})),y=m==="floating"?{x:s,y:o,width:c.floating.width,height:c.floating.height}:c.reference,w=await(a.getOffsetParent==null?void 0:a.getOffsetParent(l.floating)),j=await(a.isElement==null?void 0:a.isElement(w))?await(a.getScale==null?void 0:a.getScale(w))||{x:1,y:1}:{x:1,y:1},k=jn(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:y,offsetParent:w,strategy:u}):y);return{top:(b.top-k.top+x.top)/j.y,bottom:(k.bottom-b.bottom+x.bottom)/j.y,left:(b.left-k.left+x.left)/j.x,right:(k.right-b.right+x.right)/j.x}}const rp=50,sp=async(e,t,n)=>{const{placement:s="bottom",strategy:o="absolute",middleware:a=[],platform:c}=n,l=c.detectOverflow?c:{...c,detectOverflow:np},u=await(c.isRTL==null?void 0:c.isRTL(t));let f=await c.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:m}=Ys(f,s,u),h=s,g=0;const x={};for(let p=0;p<a.length;p++){const v=a[p];if(!v)continue;const{name:b,fn:y}=v,{x:w,y:j,data:k,reset:C}=await y({x:d,y:m,initialPlacement:s,placement:h,strategy:o,middlewareData:x,rects:f,platform:l,elements:{reference:e,floating:t}});d=w??d,m=j??m,x[b]={...x[b],...k},C&&g<rp&&(g++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(f=C.rects===!0?await c.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:m}=Ys(f,h,u)),p=-1)}return{x:d,y:m,placement:h,strategy:o,middlewareData:x}},op=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:o,rects:a,platform:c,elements:l,middlewareData:u}=t,{element:f,padding:d=0}=Ve(e,t)||{};if(f==null)return{};const m=ii(d),h={x:n,y:s},g=rs(o),x=ns(g),p=await c.getDimensions(f),v=g==="y",b=v?"top":"left",y=v?"bottom":"right",w=v?"clientHeight":"clientWidth",j=a.reference[x]+a.reference[g]-h[g]-a.floating[x],k=h[g]-a.reference[g],C=await(c.getOffsetParent==null?void 0:c.getOffsetParent(f));let S=C?C[w]:0;(!S||!await(c.isElement==null?void 0:c.isElement(C)))&&(S=l.floating[w]||a.floating[x]);const T=j/2-k/2,R=S/2-p[x]/2-1,A=et(m[b],R),O=et(m[y],R),$=A,V=S-p[x]-O,W=S/2-p[x]/2+T,z=wr($,W,V),P=!u.arrow&&Pt(o)!=null&&W!==z&&a.reference[x]/2-(W<$?A:O)-p[x]/2<0,_=P?W<$?W-$:W-V:0;return{[g]:h[g]+_,data:{[g]:z,centerOffset:W-z-_,...P&&{alignmentOffset:_}},reset:P}}}),ap=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:o,middlewareData:a,rects:c,initialPlacement:l,platform:u,elements:f}=t,{mainAxis:d=!0,crossAxis:m=!0,fallbackPlacements:h,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:p=!0,...v}=Ve(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const b=We(o),y=Le(l),w=We(l)===l,j=await(u.isRTL==null?void 0:u.isRTL(f.floating)),k=h||(w||!p?[Nn(l)]:Xm(l)),C=x!=="none";!h&&C&&k.push(...ep(l,p,x,j));const S=[l,...k],T=await u.detectOverflow(t,v),R=[];let A=((s=a.flip)==null?void 0:s.overflows)||[];if(d&&R.push(T[b]),m){const W=Ym(o,c,j);R.push(T[W[0]],T[W[1]])}if(A=[...A,{placement:o,overflows:R}],!R.every(W=>W<=0)){var O,$;const W=(((O=a.flip)==null?void 0:O.index)||0)+1,z=S[W];if(z&&(!(m==="alignment"?y!==Le(z):!1)||A.every(L=>Le(L.placement)===y?L.overflows[0]>0:!0)))return{data:{index:W,overflows:A},reset:{placement:z}};let P=($=A.filter(_=>_.overflows[0]<=0).sort((_,L)=>_.overflows[1]-L.overflows[1])[0])==null?void 0:$.placement;if(!P)switch(g){case"bestFit":{var V;const _=(V=A.filter(L=>{if(C){const E=Le(L.placement);return E===y||E==="y"}return!0}).map(L=>[L.placement,L.overflows.filter(E=>E>0).reduce((E,te)=>E+te,0)]).sort((L,E)=>L[1]-E[1])[0])==null?void 0:V[0];_&&(P=_);break}case"initialPlacement":P=l;break}if(o!==P)return{reset:{placement:P}}}return{}}}};function Xs(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Js(e){return qm.some(t=>e[t]>=0)}const ip=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:s}=t,{strategy:o="referenceHidden",...a}=Ve(e,t);switch(o){case"referenceHidden":{const c=await s.detectOverflow(t,{...a,elementContext:"reference"}),l=Xs(c,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:Js(l)}}}case"escaped":{const c=await s.detectOverflow(t,{...a,altBoundary:!0}),l=Xs(c,n.floating);return{data:{escapedOffsets:l,escaped:Js(l)}}}default:return{}}}}},li=new Set(["left","top"]);async function lp(e,t){const{placement:n,platform:s,elements:o}=e,a=await(s.isRTL==null?void 0:s.isRTL(o.floating)),c=We(n),l=Pt(n),u=Le(n)==="y",f=li.has(c)?-1:1,d=a&&u?-1:1,m=Ve(t,e);let{mainAxis:h,crossAxis:g,alignmentAxis:x}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return l&&typeof x=="number"&&(g=l==="end"?x*-1:x),u?{x:g*d,y:h*f}:{x:h*f,y:g*d}}const cp=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:o,y:a,placement:c,middlewareData:l}=t,u=await lp(t,e);return c===((n=l.offset)==null?void 0:n.placement)&&(s=l.arrow)!=null&&s.alignmentOffset?{}:{x:o+u.x,y:a+u.y,data:{...u,placement:c}}}}},dp=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:o,platform:a}=t,{mainAxis:c=!0,crossAxis:l=!1,limiter:u={fn:b=>{let{x:y,y:w}=b;return{x:y,y:w}}},...f}=Ve(e,t),d={x:n,y:s},m=await a.detectOverflow(t,f),h=Le(We(o)),g=ts(h);let x=d[g],p=d[h];if(c){const b=g==="y"?"top":"left",y=g==="y"?"bottom":"right",w=x+m[b],j=x-m[y];x=wr(w,x,j)}if(l){const b=h==="y"?"top":"left",y=h==="y"?"bottom":"right",w=p+m[b],j=p-m[y];p=wr(w,p,j)}const v=u.fn({...t,[g]:x,[h]:p});return{...v,data:{x:v.x-n,y:v.y-s,enabled:{[g]:c,[h]:l}}}}}},up=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:s,placement:o,rects:a,middlewareData:c}=t,{offset:l=0,mainAxis:u=!0,crossAxis:f=!0}=Ve(e,t),d={x:n,y:s},m=Le(o),h=ts(m);let g=d[h],x=d[m];const p=Ve(l,t),v=typeof p=="number"?{mainAxis:p,crossAxis:0}:{mainAxis:0,crossAxis:0,...p};if(u){const w=h==="y"?"height":"width",j=a.reference[h]-a.floating[w]+v.mainAxis,k=a.reference[h]+a.reference[w]-v.mainAxis;g<j?g=j:g>k&&(g=k)}if(f){var b,y;const w=h==="y"?"width":"height",j=li.has(We(o)),k=a.reference[m]-a.floating[w]+(j&&((b=c.offset)==null?void 0:b[m])||0)+(j?0:v.crossAxis),C=a.reference[m]+a.reference[w]+(j?0:((y=c.offset)==null?void 0:y[m])||0)-(j?v.crossAxis:0);x<k?x=k:x>C&&(x=C)}return{[h]:g,[m]:x}}}},fp=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,s;const{placement:o,rects:a,platform:c,elements:l}=t,{apply:u=()=>{},...f}=Ve(e,t),d=await c.detectOverflow(t,f),m=We(o),h=Pt(o),g=Le(o)==="y",{width:x,height:p}=a.floating;let v,b;m==="top"||m==="bottom"?(v=m,b=h===(await(c.isRTL==null?void 0:c.isRTL(l.floating))?"start":"end")?"left":"right"):(b=m,v=h==="end"?"top":"bottom");const y=p-d.top-d.bottom,w=x-d.left-d.right,j=et(p-d[v],y),k=et(x-d[b],w),C=!t.middlewareData.shift;let S=j,T=k;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(T=w),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(S=y),C&&!h){const A=Se(d.left,0),O=Se(d.right,0),$=Se(d.top,0),V=Se(d.bottom,0);g?T=x-2*(A!==0||O!==0?A+O:Se(d.left,d.right)):S=p-2*($!==0||V!==0?$+V:Se(d.top,d.bottom))}await u({...t,availableWidth:T,availableHeight:S});const R=await c.getDimensions(l.floating);return x!==R.width||p!==R.height?{reset:{rects:!0}}:{}}}};function Mn(){return typeof window<"u"}function Dt(e){return ci(e)?(e.nodeName||"").toLowerCase():"#document"}function Ee(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Fe(e){var t;return(t=(ci(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function ci(e){return Mn()?e instanceof Node||e instanceof Ee(e).Node:!1}function De(e){return Mn()?e instanceof Element||e instanceof Ee(e).Element:!1}function He(e){return Mn()?e instanceof HTMLElement||e instanceof Ee(e).HTMLElement:!1}function Zs(e){return!Mn()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ee(e).ShadowRoot}function Gt(e){const{overflow:t,overflowX:n,overflowY:s,display:o}=Me(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&o!=="inline"&&o!=="contents"}function mp(e){return/^(table|td|th)$/.test(Dt(e))}function On(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const pp=/transform|translate|scale|rotate|perspective|filter/,hp=/paint|layout|strict|content/,lt=e=>!!e&&e!=="none";let or;function ss(e){const t=De(e)?Me(e):e;return lt(t.transform)||lt(t.translate)||lt(t.scale)||lt(t.rotate)||lt(t.perspective)||!os()&&(lt(t.backdropFilter)||lt(t.filter))||pp.test(t.willChange||"")||hp.test(t.contain||"")}function xp(e){let t=tt(e);for(;He(t)&&!Et(t);){if(ss(t))return t;if(On(t))return null;t=tt(t)}return null}function os(){return or==null&&(or=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),or}function Et(e){return/^(html|body|#document)$/.test(Dt(e))}function Me(e){return Ee(e).getComputedStyle(e)}function In(e){return De(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function tt(e){if(Dt(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Zs(e)&&e.host||Fe(e);return Zs(t)?t.host:t}function di(e){const t=tt(e);return Et(t)?e.ownerDocument?e.ownerDocument.body:e.body:He(t)&&Gt(t)?t:di(t)}function Wt(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=di(e),a=o===((s=e.ownerDocument)==null?void 0:s.body),c=Ee(o);if(a){const l=jr(c);return t.concat(c,c.visualViewport||[],Gt(o)?o:[],l&&n?Wt(l):[])}else return t.concat(o,Wt(o,[],n))}function jr(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ui(e){const t=Me(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const o=He(e),a=o?e.offsetWidth:n,c=o?e.offsetHeight:s,l=wn(n)!==a||wn(s)!==c;return l&&(n=a,s=c),{width:n,height:s,$:l}}function as(e){return De(e)?e:e.contextElement}function St(e){const t=as(e);if(!He(t))return $e(1);const n=t.getBoundingClientRect(),{width:s,height:o,$:a}=ui(t);let c=(a?wn(n.width):n.width)/s,l=(a?wn(n.height):n.height)/o;return(!c||!Number.isFinite(c))&&(c=1),(!l||!Number.isFinite(l))&&(l=1),{x:c,y:l}}const gp=$e(0);function fi(e){const t=Ee(e);return!os()||!t.visualViewport?gp:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function vp(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ee(e)?!1:t}function ut(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),a=as(e);let c=$e(1);t&&(s?De(s)&&(c=St(s)):c=St(e));const l=vp(a,n,s)?fi(a):$e(0);let u=(o.left+l.x)/c.x,f=(o.top+l.y)/c.y,d=o.width/c.x,m=o.height/c.y;if(a){const h=Ee(a),g=s&&De(s)?Ee(s):s;let x=h,p=jr(x);for(;p&&s&&g!==x;){const v=St(p),b=p.getBoundingClientRect(),y=Me(p),w=b.left+(p.clientLeft+parseFloat(y.paddingLeft))*v.x,j=b.top+(p.clientTop+parseFloat(y.paddingTop))*v.y;u*=v.x,f*=v.y,d*=v.x,m*=v.y,u+=w,f+=j,x=Ee(p),p=jr(x)}}return jn({width:d,height:m,x:u,y:f})}function Ln(e,t){const n=In(e).scrollLeft;return t?t.left+n:ut(Fe(e)).left+n}function mi(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-Ln(e,n),o=n.top+t.scrollTop;return{x:s,y:o}}function bp(e){let{elements:t,rect:n,offsetParent:s,strategy:o}=e;const a=o==="fixed",c=Fe(s),l=t?On(t.floating):!1;if(s===c||l&&a)return n;let u={scrollLeft:0,scrollTop:0},f=$e(1);const d=$e(0),m=He(s);if((m||!m&&!a)&&((Dt(s)!=="body"||Gt(c))&&(u=In(s)),m)){const g=ut(s);f=St(s),d.x=g.x+s.clientLeft,d.y=g.y+s.clientTop}const h=c&&!m&&!a?mi(c,u):$e(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-u.scrollLeft*f.x+d.x+h.x,y:n.y*f.y-u.scrollTop*f.y+d.y+h.y}}function yp(e){return Array.from(e.getClientRects())}function wp(e){const t=Fe(e),n=In(e),s=e.ownerDocument.body,o=Se(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),a=Se(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let c=-n.scrollLeft+Ln(e);const l=-n.scrollTop;return Me(s).direction==="rtl"&&(c+=Se(t.clientWidth,s.clientWidth)-o),{width:o,height:a,x:c,y:l}}const Qs=25;function Np(e,t){const n=Ee(e),s=Fe(e),o=n.visualViewport;let a=s.clientWidth,c=s.clientHeight,l=0,u=0;if(o){a=o.width,c=o.height;const d=os();(!d||d&&t==="fixed")&&(l=o.offsetLeft,u=o.offsetTop)}const f=Ln(s);if(f<=0){const d=s.ownerDocument,m=d.body,h=getComputedStyle(m),g=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,x=Math.abs(s.clientWidth-m.clientWidth-g);x<=Qs&&(a-=x)}else f<=Qs&&(a+=f);return{width:a,height:c,x:l,y:u}}function jp(e,t){const n=ut(e,!0,t==="fixed"),s=n.top+e.clientTop,o=n.left+e.clientLeft,a=He(e)?St(e):$e(1),c=e.clientWidth*a.x,l=e.clientHeight*a.y,u=o*a.x,f=s*a.y;return{width:c,height:l,x:u,y:f}}function eo(e,t,n){let s;if(t==="viewport")s=Np(e,n);else if(t==="document")s=wp(Fe(e));else if(De(t))s=jp(t,n);else{const o=fi(e);s={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return jn(s)}function pi(e,t){const n=tt(e);return n===t||!De(n)||Et(n)?!1:Me(n).position==="fixed"||pi(n,t)}function Sp(e,t){const n=t.get(e);if(n)return n;let s=Wt(e,[],!1).filter(l=>De(l)&&Dt(l)!=="body"),o=null;const a=Me(e).position==="fixed";let c=a?tt(e):e;for(;De(c)&&!Et(c);){const l=Me(c),u=ss(c);!u&&l.position==="fixed"&&(o=null),(a?!u&&!o:!u&&l.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Gt(c)&&!u&&pi(e,c))?s=s.filter(d=>d!==c):o=l,c=tt(c)}return t.set(e,s),s}function kp(e){let{element:t,boundary:n,rootBoundary:s,strategy:o}=e;const c=[...n==="clippingAncestors"?On(t)?[]:Sp(t,this._c):[].concat(n),s],l=eo(t,c[0],o);let u=l.top,f=l.right,d=l.bottom,m=l.left;for(let h=1;h<c.length;h++){const g=eo(t,c[h],o);u=Se(g.top,u),f=et(g.right,f),d=et(g.bottom,d),m=Se(g.left,m)}return{width:f-m,height:d-u,x:m,y:u}}function Cp(e){const{width:t,height:n}=ui(e);return{width:t,height:n}}function Ep(e,t,n){const s=He(t),o=Fe(t),a=n==="fixed",c=ut(e,!0,a,t);let l={scrollLeft:0,scrollTop:0};const u=$e(0);function f(){u.x=Ln(o)}if(s||!s&&!a)if((Dt(t)!=="body"||Gt(o))&&(l=In(t)),s){const g=ut(t,!0,a,t);u.x=g.x+t.clientLeft,u.y=g.y+t.clientTop}else o&&f();a&&!s&&o&&f();const d=o&&!s&&!a?mi(o,l):$e(0),m=c.left+l.scrollLeft-u.x-d.x,h=c.top+l.scrollTop-u.y-d.y;return{x:m,y:h,width:c.width,height:c.height}}function ar(e){return Me(e).position==="static"}function to(e,t){if(!He(e)||Me(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Fe(e)===n&&(n=n.ownerDocument.body),n}function hi(e,t){const n=Ee(e);if(On(e))return n;if(!He(e)){let o=tt(e);for(;o&&!Et(o);){if(De(o)&&!ar(o))return o;o=tt(o)}return n}let s=to(e,t);for(;s&&mp(s)&&ar(s);)s=to(s,t);return s&&Et(s)&&ar(s)&&!ss(s)?n:s||xp(e)||n}const Tp=async function(e){const t=this.getOffsetParent||hi,n=this.getDimensions,s=await n(e.floating);return{reference:Ep(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function Ap(e){return Me(e).direction==="rtl"}const Rp={convertOffsetParentRelativeRectToViewportRelativeRect:bp,getDocumentElement:Fe,getClippingRect:kp,getOffsetParent:hi,getElementRects:Tp,getClientRects:yp,getDimensions:Cp,getScale:St,isElement:De,isRTL:Ap};function xi(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function _p(e,t){let n=null,s;const o=Fe(e);function a(){var l;clearTimeout(s),(l=n)==null||l.disconnect(),n=null}function c(l,u){l===void 0&&(l=!1),u===void 0&&(u=1),a();const f=e.getBoundingClientRect(),{left:d,top:m,width:h,height:g}=f;if(l||t(),!h||!g)return;const x=on(m),p=on(o.clientWidth-(d+h)),v=on(o.clientHeight-(m+g)),b=on(d),w={rootMargin:-x+"px "+-p+"px "+-v+"px "+-b+"px",threshold:Se(0,et(1,u))||1};let j=!0;function k(C){const S=C[0].intersectionRatio;if(S!==u){if(!j)return c();S?c(!1,S):s=setTimeout(()=>{c(!1,1e-7)},1e3)}S===1&&!xi(f,e.getBoundingClientRect())&&c(),j=!1}try{n=new IntersectionObserver(k,{...w,root:o.ownerDocument})}catch{n=new IntersectionObserver(k,w)}n.observe(e)}return c(!0),a}function Pp(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=s,f=as(e),d=o||a?[...f?Wt(f):[],...t?Wt(t):[]]:[];d.forEach(b=>{o&&b.addEventListener("scroll",n,{passive:!0}),a&&b.addEventListener("resize",n)});const m=f&&l?_p(f,n):null;let h=-1,g=null;c&&(g=new ResizeObserver(b=>{let[y]=b;y&&y.target===f&&g&&t&&(g.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var w;(w=g)==null||w.observe(t)})),n()}),f&&!u&&g.observe(f),t&&g.observe(t));let x,p=u?ut(e):null;u&&v();function v(){const b=ut(e);p&&!xi(p,b)&&n(),p=b,x=requestAnimationFrame(v)}return n(),()=>{var b;d.forEach(y=>{o&&y.removeEventListener("scroll",n),a&&y.removeEventListener("resize",n)}),m==null||m(),(b=g)==null||b.disconnect(),g=null,u&&cancelAnimationFrame(x)}}const Dp=cp,Mp=dp,Op=ap,Ip=fp,Lp=ip,no=op,$p=up,Fp=(e,t,n)=>{const s=new Map,o={platform:Rp,...n},a={...o.platform,_c:s};return sp(e,t,{...o,platform:a})};var Bp=typeof document<"u",Up=function(){},cn=Bp?i.useLayoutEffect:Up;function Sn(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,s,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(s=n;s--!==0;)if(!Sn(e[s],t[s]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(t,o[s]))return!1;for(s=n;s--!==0;){const a=o[s];if(!(a==="_owner"&&e.$$typeof)&&!Sn(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function gi(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function ro(e,t){const n=gi(e);return Math.round(t*n)/n}function ir(e){const t=i.useRef(e);return cn(()=>{t.current=e}),t}function Vp(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:s=[],platform:o,elements:{reference:a,floating:c}={},transform:l=!0,whileElementsMounted:u,open:f}=e,[d,m]=i.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,g]=i.useState(s);Sn(h,s)||g(s);const[x,p]=i.useState(null),[v,b]=i.useState(null),y=i.useCallback(L=>{L!==C.current&&(C.current=L,p(L))},[]),w=i.useCallback(L=>{L!==S.current&&(S.current=L,b(L))},[]),j=a||x,k=c||v,C=i.useRef(null),S=i.useRef(null),T=i.useRef(d),R=u!=null,A=ir(u),O=ir(o),$=ir(f),V=i.useCallback(()=>{if(!C.current||!S.current)return;const L={placement:t,strategy:n,middleware:h};O.current&&(L.platform=O.current),Fp(C.current,S.current,L).then(E=>{const te={...E,isPositioned:$.current!==!1};W.current&&!Sn(T.current,te)&&(T.current=te,En.flushSync(()=>{m(te)}))})},[h,t,n,O,$]);cn(()=>{f===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,m(L=>({...L,isPositioned:!1})))},[f]);const W=i.useRef(!1);cn(()=>(W.current=!0,()=>{W.current=!1}),[]),cn(()=>{if(j&&(C.current=j),k&&(S.current=k),j&&k){if(A.current)return A.current(j,k,V);V()}},[j,k,V,A,R]);const z=i.useMemo(()=>({reference:C,floating:S,setReference:y,setFloating:w}),[y,w]),P=i.useMemo(()=>({reference:j,floating:k}),[j,k]),_=i.useMemo(()=>{const L={position:n,left:0,top:0};if(!P.floating)return L;const E=ro(P.floating,d.x),te=ro(P.floating,d.y);return l?{...L,transform:"translate("+E+"px, "+te+"px)",...gi(P.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:E,top:te}},[n,l,P.floating,d.x,d.y]);return i.useMemo(()=>({...d,update:V,refs:z,elements:P,floatingStyles:_}),[d,V,z,P,_])}const Wp=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:s,padding:o}=typeof e=="function"?e(n):e;return s&&t(s)?s.current!=null?no({element:s.current,padding:o}).fn(n):{}:s?no({element:s,padding:o}).fn(n):{}}}},zp=(e,t)=>{const n=Dp(e);return{name:n.name,fn:n.fn,options:[e,t]}},Hp=(e,t)=>{const n=Mp(e);return{name:n.name,fn:n.fn,options:[e,t]}},Kp=(e,t)=>({fn:$p(e).fn,options:[e,t]}),qp=(e,t)=>{const n=Op(e);return{name:n.name,fn:n.fn,options:[e,t]}},Gp=(e,t)=>{const n=Ip(e);return{name:n.name,fn:n.fn,options:[e,t]}},Yp=(e,t)=>{const n=Lp(e);return{name:n.name,fn:n.fn,options:[e,t]}},Xp=(e,t)=>{const n=Wp(e);return{name:n.name,fn:n.fn,options:[e,t]}};var Jp="Arrow",vi=i.forwardRef((e,t)=>{const{children:n,width:s=10,height:o=5,...a}=e;return r.jsx(Z.svg,{...a,ref:t,width:s,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:r.jsx("polygon",{points:"0,0 30,0 15,10"})})});vi.displayName=Jp;var Zp=vi;function bi(e){const[t,n]=i.useState(void 0);return ve(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const s=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const a=o[0];let c,l;if("borderBoxSize"in a){const u=a.borderBoxSize,f=Array.isArray(u)?u[0]:u;c=f.inlineSize,l=f.blockSize}else c=e.offsetWidth,l=e.offsetHeight;n({width:c,height:l})});return s.observe(e,{box:"border-box"}),()=>s.unobserve(e)}else n(void 0)},[e]),t}var is="Popper",[yi,wi]=nt(is),[Qp,Ni]=yi(is),ji=e=>{const{__scopePopper:t,children:n}=e,[s,o]=i.useState(null);return r.jsx(Qp,{scope:t,anchor:s,onAnchorChange:o,children:n})};ji.displayName=is;var Si="PopperAnchor",ki=i.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:s,...o}=e,a=Ni(Si,n),c=i.useRef(null),l=le(t,c),u=i.useRef(null);return i.useEffect(()=>{const f=u.current;u.current=(s==null?void 0:s.current)||c.current,f!==u.current&&a.onAnchorChange(u.current)}),s?null:r.jsx(Z.div,{...o,ref:l})});ki.displayName=Si;var ls="PopperContent",[eh,th]=yi(ls),Ci=i.forwardRef((e,t)=>{var I,X,de,q,J,K;const{__scopePopper:n,side:s="bottom",sideOffset:o=0,align:a="center",alignOffset:c=0,arrowPadding:l=0,avoidCollisions:u=!0,collisionBoundary:f=[],collisionPadding:d=0,sticky:m="partial",hideWhenDetached:h=!1,updatePositionStrategy:g="optimized",onPlaced:x,...p}=e,v=Ni(ls,n),[b,y]=i.useState(null),w=le(t,F=>y(F)),[j,k]=i.useState(null),C=bi(j),S=(C==null?void 0:C.width)??0,T=(C==null?void 0:C.height)??0,R=s+(a!=="center"?"-"+a:""),A=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},O=Array.isArray(f)?f:[f],$=O.length>0,V={padding:A,boundary:O.filter(rh),altBoundary:$},{refs:W,floatingStyles:z,placement:P,isPositioned:_,middlewareData:L}=Vp({strategy:"fixed",placement:R,whileElementsMounted:(...F)=>Pp(...F,{animationFrame:g==="always"}),elements:{reference:v.anchor},middleware:[zp({mainAxis:o+T,alignmentAxis:c}),u&&Hp({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?Kp():void 0,...V}),u&&qp({...V}),Gp({...V,apply:({elements:F,rects:re,availableWidth:ue,availableHeight:we})=>{const{width:be,height:Be}=re.reference,ie=F.floating.style;ie.setProperty("--radix-popper-available-width",`${ue}px`),ie.setProperty("--radix-popper-available-height",`${we}px`),ie.setProperty("--radix-popper-anchor-width",`${be}px`),ie.setProperty("--radix-popper-anchor-height",`${Be}px`)}}),j&&Xp({element:j,padding:l}),sh({arrowWidth:S,arrowHeight:T}),h&&Yp({strategy:"referenceHidden",...V})]}),[E,te]=Ai(P),ce=Qe(x);ve(()=>{_&&(ce==null||ce())},[_,ce]);const ae=(I=L.arrow)==null?void 0:I.x,me=(X=L.arrow)==null?void 0:X.y,M=((de=L.arrow)==null?void 0:de.centerOffset)!==0,[Q,ne]=i.useState();return ve(()=>{b&&ne(window.getComputedStyle(b).zIndex)},[b]),r.jsx("div",{ref:W.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:_?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Q,"--radix-popper-transform-origin":[(q=L.transformOrigin)==null?void 0:q.x,(J=L.transformOrigin)==null?void 0:J.y].join(" "),...((K=L.hide)==null?void 0:K.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:r.jsx(eh,{scope:n,placedSide:E,onArrowChange:k,arrowX:ae,arrowY:me,shouldHideArrow:M,children:r.jsx(Z.div,{"data-side":E,"data-align":te,...p,ref:w,style:{...p.style,animation:_?void 0:"none"}})})})});Ci.displayName=ls;var Ei="PopperArrow",nh={top:"bottom",right:"left",bottom:"top",left:"right"},Ti=i.forwardRef(function(t,n){const{__scopePopper:s,...o}=t,a=th(Ei,s),c=nh[a.placedSide];return r.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[c]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:r.jsx(Zp,{...o,ref:n,style:{...o.style,display:"block"}})})});Ti.displayName=Ei;function rh(e){return e!==null}var sh=e=>({name:"transformOrigin",options:e,fn(t){var v,b,y;const{placement:n,rects:s,middlewareData:o}=t,c=((v=o.arrow)==null?void 0:v.centerOffset)!==0,l=c?0:e.arrowWidth,u=c?0:e.arrowHeight,[f,d]=Ai(n),m={start:"0%",center:"50%",end:"100%"}[d],h=(((b=o.arrow)==null?void 0:b.x)??0)+l/2,g=(((y=o.arrow)==null?void 0:y.y)??0)+u/2;let x="",p="";return f==="bottom"?(x=c?m:`${h}px`,p=`${-u}px`):f==="top"?(x=c?m:`${h}px`,p=`${s.floating.height+u}px`):f==="right"?(x=`${-u}px`,p=c?m:`${g}px`):f==="left"&&(x=`${s.floating.width+u}px`,p=c?m:`${g}px`),{data:{x,y:p}}}});function Ai(e){const[t,n="center"]=e.split("-");return[t,n]}var oh=ji,ah=ki,ih=Ci,lh=Ti;function Ri(e){const t=i.useRef({value:e,previous:e});return i.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var _i=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),ch="VisuallyHidden",dh=i.forwardRef((e,t)=>r.jsx(Z.span,{...e,ref:t,style:{..._i,...e.style}}));dh.displayName=ch;var uh=[" ","Enter","ArrowUp","ArrowDown"],fh=[" ","Enter"],ft="Select",[$n,Fn,mh]=ya(ft),[Mt]=nt(ft,[mh,wi]),Bn=wi(),[ph,rt]=Mt(ft),[hh,xh]=Mt(ft),Pi=e=>{const{__scopeSelect:t,children:n,open:s,defaultOpen:o,onOpenChange:a,value:c,defaultValue:l,onValueChange:u,dir:f,name:d,autoComplete:m,disabled:h,required:g,form:x}=e,p=Bn(t),[v,b]=i.useState(null),[y,w]=i.useState(null),[j,k]=i.useState(!1),C=Zr(f),[S,T]=kt({prop:s,defaultProp:o??!1,onChange:a,caller:ft}),[R,A]=kt({prop:c,defaultProp:l,onChange:u,caller:ft}),O=i.useRef(null),$=v?x||!!v.closest("form"):!0,[V,W]=i.useState(new Set),z=Array.from(V).map(P=>P.props.value).join(";");return r.jsx(oh,{...p,children:r.jsxs(ph,{required:g,scope:t,trigger:v,onTriggerChange:b,valueNode:y,onValueNodeChange:w,valueNodeHasChildren:j,onValueNodeHasChildrenChange:k,contentId:Xe(),value:R,onValueChange:A,open:S,onOpenChange:T,dir:C,triggerPointerDownPosRef:O,disabled:h,children:[r.jsx($n.Provider,{scope:t,children:r.jsx(hh,{scope:e.__scopeSelect,onNativeOptionAdd:i.useCallback(P=>{W(_=>new Set(_).add(P))},[]),onNativeOptionRemove:i.useCallback(P=>{W(_=>{const L=new Set(_);return L.delete(P),L})},[]),children:n})}),$?r.jsxs(nl,{"aria-hidden":!0,required:g,tabIndex:-1,name:d,autoComplete:m,value:R,onChange:P=>A(P.target.value),disabled:h,form:x,children:[R===void 0?r.jsx("option",{value:""}):null,Array.from(V)]},z):null]})})};Pi.displayName=ft;var Di="SelectTrigger",Mi=i.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:s=!1,...o}=e,a=Bn(n),c=rt(Di,n),l=c.disabled||s,u=le(t,c.onTriggerChange),f=Fn(n),d=i.useRef("touch"),[m,h,g]=sl(p=>{const v=f().filter(w=>!w.disabled),b=v.find(w=>w.value===c.value),y=ol(v,p,b);y!==void 0&&c.onValueChange(y.value)}),x=p=>{l||(c.onOpenChange(!0),g()),p&&(c.triggerPointerDownPosRef.current={x:Math.round(p.pageX),y:Math.round(p.pageY)})};return r.jsx(ah,{asChild:!0,...a,children:r.jsx(Z.button,{type:"button",role:"combobox","aria-controls":c.contentId,"aria-expanded":c.open,"aria-required":c.required,"aria-autocomplete":"none",dir:c.dir,"data-state":c.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":rl(c.value)?"":void 0,...o,ref:u,onClick:Y(o.onClick,p=>{p.currentTarget.focus(),d.current!=="mouse"&&x(p)}),onPointerDown:Y(o.onPointerDown,p=>{d.current=p.pointerType;const v=p.target;v.hasPointerCapture(p.pointerId)&&v.releasePointerCapture(p.pointerId),p.button===0&&p.ctrlKey===!1&&p.pointerType==="mouse"&&(x(p),p.preventDefault())}),onKeyDown:Y(o.onKeyDown,p=>{const v=m.current!=="";!(p.ctrlKey||p.altKey||p.metaKey)&&p.key.length===1&&h(p.key),!(v&&p.key===" ")&&uh.includes(p.key)&&(x(),p.preventDefault())})})})});Mi.displayName=Di;var Oi="SelectValue",Ii=i.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:o,children:a,placeholder:c="",...l}=e,u=rt(Oi,n),{onValueNodeHasChildrenChange:f}=u,d=a!==void 0,m=le(t,u.onValueNodeChange);return ve(()=>{f(d)},[f,d]),r.jsx(Z.span,{...l,ref:m,style:{pointerEvents:"none"},children:rl(u.value)?r.jsx(r.Fragment,{children:c}):a})});Ii.displayName=Oi;var gh="SelectIcon",Li=i.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,...o}=e;return r.jsx(Z.span,{"aria-hidden":!0,...o,ref:t,children:s||"▼"})});Li.displayName=gh;var vh="SelectPortal",$i=e=>r.jsx(Vr,{asChild:!0,...e});$i.displayName=vh;var mt="SelectContent",Fi=i.forwardRef((e,t)=>{const n=rt(mt,e.__scopeSelect),[s,o]=i.useState();if(ve(()=>{o(new DocumentFragment)},[]),!n.open){const a=s;return a?En.createPortal(r.jsx(Bi,{scope:e.__scopeSelect,children:r.jsx($n.Slot,{scope:e.__scopeSelect,children:r.jsx("div",{children:e.children})})}),a):null}return r.jsx(Ui,{...e,ref:t})});Fi.displayName=mt;var _e=10,[Bi,st]=Mt(mt),bh="SelectContentImpl",yh=Ut("SelectContent.RemoveScroll"),Ui=i.forwardRef((e,t)=>{const{__scopeSelect:n,position:s="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:a,onPointerDownOutside:c,side:l,sideOffset:u,align:f,alignOffset:d,arrowPadding:m,collisionBoundary:h,collisionPadding:g,sticky:x,hideWhenDetached:p,avoidCollisions:v,...b}=e,y=rt(mt,n),[w,j]=i.useState(null),[k,C]=i.useState(null),S=le(t,I=>j(I)),[T,R]=i.useState(null),[A,O]=i.useState(null),$=Fn(n),[V,W]=i.useState(!1),z=i.useRef(!1);i.useEffect(()=>{if(w)return Ho(w)},[w]),Io();const P=i.useCallback(I=>{const[X,...de]=$().map(K=>K.ref.current),[q]=de.slice(-1),J=document.activeElement;for(const K of I)if(K===J||(K==null||K.scrollIntoView({block:"nearest"}),K===X&&k&&(k.scrollTop=0),K===q&&k&&(k.scrollTop=k.scrollHeight),K==null||K.focus(),document.activeElement!==J))return},[$,k]),_=i.useCallback(()=>P([T,w]),[P,T,w]);i.useEffect(()=>{V&&_()},[V,_]);const{onOpenChange:L,triggerPointerDownPosRef:E}=y;i.useEffect(()=>{if(w){let I={x:0,y:0};const X=q=>{var J,K;I={x:Math.abs(Math.round(q.pageX)-(((J=E.current)==null?void 0:J.x)??0)),y:Math.abs(Math.round(q.pageY)-(((K=E.current)==null?void 0:K.y)??0))}},de=q=>{I.x<=10&&I.y<=10?q.preventDefault():w.contains(q.target)||L(!1),document.removeEventListener("pointermove",X),E.current=null};return E.current!==null&&(document.addEventListener("pointermove",X),document.addEventListener("pointerup",de,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",X),document.removeEventListener("pointerup",de,{capture:!0})}}},[w,L,E]),i.useEffect(()=>{const I=()=>L(!1);return window.addEventListener("blur",I),window.addEventListener("resize",I),()=>{window.removeEventListener("blur",I),window.removeEventListener("resize",I)}},[L]);const[te,ce]=sl(I=>{const X=$().filter(J=>!J.disabled),de=X.find(J=>J.ref.current===document.activeElement),q=ol(X,I,de);q&&setTimeout(()=>q.ref.current.focus())}),ae=i.useCallback((I,X,de)=>{const q=!z.current&&!de;(y.value!==void 0&&y.value===X||q)&&(R(I),q&&(z.current=!0))},[y.value]),me=i.useCallback(()=>w==null?void 0:w.focus(),[w]),M=i.useCallback((I,X,de)=>{const q=!z.current&&!de;(y.value!==void 0&&y.value===X||q)&&O(I)},[y.value]),Q=s==="popper"?Sr:Vi,ne=Q===Sr?{side:l,sideOffset:u,align:f,alignOffset:d,arrowPadding:m,collisionBoundary:h,collisionPadding:g,sticky:x,hideWhenDetached:p,avoidCollisions:v}:{};return r.jsx(Bi,{scope:n,content:w,viewport:k,onViewportChange:C,itemRefCallback:ae,selectedItem:T,onItemLeave:me,itemTextRefCallback:M,focusSelectedItem:_,selectedItemText:A,position:s,isPositioned:V,searchRef:te,children:r.jsx(Wr,{as:yh,allowPinchZoom:!0,children:r.jsx(Ur,{asChild:!0,trapped:y.open,onMountAutoFocus:I=>{I.preventDefault()},onUnmountAutoFocus:Y(o,I=>{var X;(X=y.trigger)==null||X.focus({preventScroll:!0}),I.preventDefault()}),children:r.jsx(Br,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:c,onFocusOutside:I=>I.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:r.jsx(Q,{role:"listbox",id:y.contentId,"data-state":y.open?"open":"closed",dir:y.dir,onContextMenu:I=>I.preventDefault(),...b,...ne,onPlaced:()=>W(!0),ref:S,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:Y(b.onKeyDown,I=>{const X=I.ctrlKey||I.altKey||I.metaKey;if(I.key==="Tab"&&I.preventDefault(),!X&&I.key.length===1&&ce(I.key),["ArrowUp","ArrowDown","Home","End"].includes(I.key)){let q=$().filter(J=>!J.disabled).map(J=>J.ref.current);if(["ArrowUp","End"].includes(I.key)&&(q=q.slice().reverse()),["ArrowUp","ArrowDown"].includes(I.key)){const J=I.target,K=q.indexOf(J);q=q.slice(K+1)}setTimeout(()=>P(q)),I.preventDefault()}})})})})})})});Ui.displayName=bh;var wh="SelectItemAlignedPosition",Vi=i.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:s,...o}=e,a=rt(mt,n),c=st(mt,n),[l,u]=i.useState(null),[f,d]=i.useState(null),m=le(t,S=>d(S)),h=Fn(n),g=i.useRef(!1),x=i.useRef(!0),{viewport:p,selectedItem:v,selectedItemText:b,focusSelectedItem:y}=c,w=i.useCallback(()=>{if(a.trigger&&a.valueNode&&l&&f&&p&&v&&b){const S=a.trigger.getBoundingClientRect(),T=f.getBoundingClientRect(),R=a.valueNode.getBoundingClientRect(),A=b.getBoundingClientRect();if(a.dir!=="rtl"){const J=A.left-T.left,K=R.left-J,F=S.left-K,re=S.width+F,ue=Math.max(re,T.width),we=window.innerWidth-_e,be=Ks(K,[_e,Math.max(_e,we-ue)]);l.style.minWidth=re+"px",l.style.left=be+"px"}else{const J=T.right-A.right,K=window.innerWidth-R.right-J,F=window.innerWidth-S.right-K,re=S.width+F,ue=Math.max(re,T.width),we=window.innerWidth-_e,be=Ks(K,[_e,Math.max(_e,we-ue)]);l.style.minWidth=re+"px",l.style.right=be+"px"}const O=h(),$=window.innerHeight-_e*2,V=p.scrollHeight,W=window.getComputedStyle(f),z=parseInt(W.borderTopWidth,10),P=parseInt(W.paddingTop,10),_=parseInt(W.borderBottomWidth,10),L=parseInt(W.paddingBottom,10),E=z+P+V+L+_,te=Math.min(v.offsetHeight*5,E),ce=window.getComputedStyle(p),ae=parseInt(ce.paddingTop,10),me=parseInt(ce.paddingBottom,10),M=S.top+S.height/2-_e,Q=$-M,ne=v.offsetHeight/2,I=v.offsetTop+ne,X=z+P+I,de=E-X;if(X<=M){const J=O.length>0&&v===O[O.length-1].ref.current;l.style.bottom="0px";const K=f.clientHeight-p.offsetTop-p.offsetHeight,F=Math.max(Q,ne+(J?me:0)+K+_),re=X+F;l.style.height=re+"px"}else{const J=O.length>0&&v===O[0].ref.current;l.style.top="0px";const F=Math.max(M,z+p.offsetTop+(J?ae:0)+ne)+de;l.style.height=F+"px",p.scrollTop=X-M+p.offsetTop}l.style.margin=`${_e}px 0`,l.style.minHeight=te+"px",l.style.maxHeight=$+"px",s==null||s(),requestAnimationFrame(()=>g.current=!0)}},[h,a.trigger,a.valueNode,l,f,p,v,b,a.dir,s]);ve(()=>w(),[w]);const[j,k]=i.useState();ve(()=>{f&&k(window.getComputedStyle(f).zIndex)},[f]);const C=i.useCallback(S=>{S&&x.current===!0&&(w(),y==null||y(),x.current=!1)},[w,y]);return r.jsx(jh,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:g,onScrollButtonChange:C,children:r.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:j},children:r.jsx(Z.div,{...o,ref:m,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Vi.displayName=wh;var Nh="SelectPopperPosition",Sr=i.forwardRef((e,t)=>{const{__scopeSelect:n,align:s="start",collisionPadding:o=_e,...a}=e,c=Bn(n);return r.jsx(ih,{...c,...a,ref:t,align:s,collisionPadding:o,style:{boxSizing:"border-box",...a.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Sr.displayName=Nh;var[jh,cs]=Mt(mt,{}),kr="SelectViewport",Wi=i.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:s,...o}=e,a=st(kr,n),c=cs(kr,n),l=le(t,a.onViewportChange),u=i.useRef(0);return r.jsxs(r.Fragment,{children:[r.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),r.jsx($n.Slot,{scope:n,children:r.jsx(Z.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Y(o.onScroll,f=>{const d=f.currentTarget,{contentWrapper:m,shouldExpandOnScrollRef:h}=c;if(h!=null&&h.current&&m){const g=Math.abs(u.current-d.scrollTop);if(g>0){const x=window.innerHeight-_e*2,p=parseFloat(m.style.minHeight),v=parseFloat(m.style.height),b=Math.max(p,v);if(b<x){const y=b+g,w=Math.min(x,y),j=y-w;m.style.height=w+"px",m.style.bottom==="0px"&&(d.scrollTop=j>0?j:0,m.style.justifyContent="flex-end")}}}u.current=d.scrollTop})})})]})});Wi.displayName=kr;var zi="SelectGroup",[Sh,kh]=Mt(zi),Ch=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=Xe();return r.jsx(Sh,{scope:n,id:o,children:r.jsx(Z.div,{role:"group","aria-labelledby":o,...s,ref:t})})});Ch.displayName=zi;var Hi="SelectLabel",Ki=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=kh(Hi,n);return r.jsx(Z.div,{id:o.id,...s,ref:t})});Ki.displayName=Hi;var kn="SelectItem",[Eh,qi]=Mt(kn),Gi=i.forwardRef((e,t)=>{const{__scopeSelect:n,value:s,disabled:o=!1,textValue:a,...c}=e,l=rt(kn,n),u=st(kn,n),f=l.value===s,[d,m]=i.useState(a??""),[h,g]=i.useState(!1),x=le(t,y=>{var w;return(w=u.itemRefCallback)==null?void 0:w.call(u,y,s,o)}),p=Xe(),v=i.useRef("touch"),b=()=>{o||(l.onValueChange(s),l.onOpenChange(!1))};if(s==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return r.jsx(Eh,{scope:n,value:s,disabled:o,textId:p,isSelected:f,onItemTextChange:i.useCallback(y=>{m(w=>w||((y==null?void 0:y.textContent)??"").trim())},[]),children:r.jsx($n.ItemSlot,{scope:n,value:s,disabled:o,textValue:d,children:r.jsx(Z.div,{role:"option","aria-labelledby":p,"data-highlighted":h?"":void 0,"aria-selected":f&&h,"data-state":f?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...c,ref:x,onFocus:Y(c.onFocus,()=>g(!0)),onBlur:Y(c.onBlur,()=>g(!1)),onClick:Y(c.onClick,()=>{v.current!=="mouse"&&b()}),onPointerUp:Y(c.onPointerUp,()=>{v.current==="mouse"&&b()}),onPointerDown:Y(c.onPointerDown,y=>{v.current=y.pointerType}),onPointerMove:Y(c.onPointerMove,y=>{var w;v.current=y.pointerType,o?(w=u.onItemLeave)==null||w.call(u):v.current==="mouse"&&y.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Y(c.onPointerLeave,y=>{var w;y.currentTarget===document.activeElement&&((w=u.onItemLeave)==null||w.call(u))}),onKeyDown:Y(c.onKeyDown,y=>{var j;((j=u.searchRef)==null?void 0:j.current)!==""&&y.key===" "||(fh.includes(y.key)&&b(),y.key===" "&&y.preventDefault())})})})})});Gi.displayName=kn;var It="SelectItemText",Yi=i.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:o,...a}=e,c=rt(It,n),l=st(It,n),u=qi(It,n),f=xh(It,n),[d,m]=i.useState(null),h=le(t,b=>m(b),u.onItemTextChange,b=>{var y;return(y=l.itemTextRefCallback)==null?void 0:y.call(l,b,u.value,u.disabled)}),g=d==null?void 0:d.textContent,x=i.useMemo(()=>r.jsx("option",{value:u.value,disabled:u.disabled,children:g},u.value),[u.disabled,u.value,g]),{onNativeOptionAdd:p,onNativeOptionRemove:v}=f;return ve(()=>(p(x),()=>v(x)),[p,v,x]),r.jsxs(r.Fragment,{children:[r.jsx(Z.span,{id:u.textId,...a,ref:h}),u.isSelected&&c.valueNode&&!c.valueNodeHasChildren?En.createPortal(a.children,c.valueNode):null]})});Yi.displayName=It;var Xi="SelectItemIndicator",Ji=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return qi(Xi,n).isSelected?r.jsx(Z.span,{"aria-hidden":!0,...s,ref:t}):null});Ji.displayName=Xi;var Cr="SelectScrollUpButton",Zi=i.forwardRef((e,t)=>{const n=st(Cr,e.__scopeSelect),s=cs(Cr,e.__scopeSelect),[o,a]=i.useState(!1),c=le(t,s.onScrollButtonChange);return ve(()=>{if(n.viewport&&n.isPositioned){let l=function(){const f=u.scrollTop>0;a(f)};const u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?r.jsx(el,{...e,ref:c,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop-u.offsetHeight)}}):null});Zi.displayName=Cr;var Er="SelectScrollDownButton",Qi=i.forwardRef((e,t)=>{const n=st(Er,e.__scopeSelect),s=cs(Er,e.__scopeSelect),[o,a]=i.useState(!1),c=le(t,s.onScrollButtonChange);return ve(()=>{if(n.viewport&&n.isPositioned){let l=function(){const f=u.scrollHeight-u.clientHeight,d=Math.ceil(u.scrollTop)<f;a(d)};const u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?r.jsx(el,{...e,ref:c,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop+u.offsetHeight)}}):null});Qi.displayName=Er;var el=i.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:s,...o}=e,a=st("SelectScrollButton",n),c=i.useRef(null),l=Fn(n),u=i.useCallback(()=>{c.current!==null&&(window.clearInterval(c.current),c.current=null)},[]);return i.useEffect(()=>()=>u(),[u]),ve(()=>{var d;const f=l().find(m=>m.ref.current===document.activeElement);(d=f==null?void 0:f.ref.current)==null||d.scrollIntoView({block:"nearest"})},[l]),r.jsx(Z.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:Y(o.onPointerDown,()=>{c.current===null&&(c.current=window.setInterval(s,50))}),onPointerMove:Y(o.onPointerMove,()=>{var f;(f=a.onItemLeave)==null||f.call(a),c.current===null&&(c.current=window.setInterval(s,50))}),onPointerLeave:Y(o.onPointerLeave,()=>{u()})})}),Th="SelectSeparator",tl=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return r.jsx(Z.div,{"aria-hidden":!0,...s,ref:t})});tl.displayName=Th;var Tr="SelectArrow",Ah=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=Bn(n),a=rt(Tr,n),c=st(Tr,n);return a.open&&c.position==="popper"?r.jsx(lh,{...o,...s,ref:t}):null});Ah.displayName=Tr;var Rh="SelectBubbleInput",nl=i.forwardRef(({__scopeSelect:e,value:t,...n},s)=>{const o=i.useRef(null),a=le(s,o),c=Ri(t);return i.useEffect(()=>{const l=o.current;if(!l)return;const u=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(u,"value").set;if(c!==t&&d){const m=new Event("change",{bubbles:!0});d.call(l,t),l.dispatchEvent(m)}},[c,t]),r.jsx(Z.select,{...n,style:{..._i,...n.style},ref:a,defaultValue:t})});nl.displayName=Rh;function rl(e){return e===""||e===void 0}function sl(e){const t=Qe(e),n=i.useRef(""),s=i.useRef(0),o=i.useCallback(c=>{const l=n.current+c;t(l),(function u(f){n.current=f,window.clearTimeout(s.current),f!==""&&(s.current=window.setTimeout(()=>u(""),1e3))})(l)},[t]),a=i.useCallback(()=>{n.current="",window.clearTimeout(s.current)},[]);return i.useEffect(()=>()=>window.clearTimeout(s.current),[]),[n,o,a]}function ol(e,t,n){const o=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let c=_h(e,Math.max(a,0));o.length===1&&(c=c.filter(f=>f!==n));const u=c.find(f=>f.textValue.toLowerCase().startsWith(o.toLowerCase()));return u!==n?u:void 0}function _h(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Ph=Pi,al=Mi,Dh=Ii,Mh=Li,Oh=$i,il=Fi,Ih=Wi,ll=Ki,cl=Gi,Lh=Yi,$h=Ji,dl=Zi,ul=Qi,fl=tl;const Ae=Ph,Pe=Dh,Ne=i.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(al,{ref:s,className:U("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,r.jsx(Mh,{asChild:!0,children:r.jsx(Tt,{className:"h-4 w-4 opacity-50"})})]}));Ne.displayName=al.displayName;const ml=i.forwardRef(({className:e,...t},n)=>r.jsx(dl,{ref:n,className:U("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(Or,{className:"h-4 w-4"})}));ml.displayName=dl.displayName;const pl=i.forwardRef(({className:e,...t},n)=>r.jsx(ul,{ref:n,className:U("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(Tt,{className:"h-4 w-4"})}));pl.displayName=ul.displayName;const je=i.forwardRef(({className:e,children:t,position:n="popper",...s},o)=>r.jsx(Oh,{children:r.jsxs(il,{ref:o,className:U("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...s,children:[r.jsx(ml,{}),r.jsx(Ih,{className:U("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),r.jsx(pl,{})]})}));je.displayName=il.displayName;const Fh=i.forwardRef(({className:e,...t},n)=>r.jsx(ll,{ref:n,className:U("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Fh.displayName=ll.displayName;const ge=i.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(cl,{ref:s,className:U("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[r.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsx($h,{children:r.jsx(pt,{className:"h-4 w-4"})})}),r.jsx(Lh,{children:t})]}));ge.displayName=cl.displayName;const Bh=i.forwardRef(({className:e,...t},n)=>r.jsx(fl,{ref:n,className:U("-mx-1 my-1 h-px bg-muted",e),...t}));Bh.displayName=fl.displayName;const Ar="bypass",hl=[{value:"claudecode",label:"claudecode",supportsFollowUp:!0},{value:"codex",label:"codex",supportsFollowUp:!0},{value:"mars",label:"mars",disabled:!0,description:"coming soon"},{value:"eureka",label:"eureka",disabled:!0,description:"coming soon"}],Uh=[{value:"bypass",label:"Bypass"},{value:"plan",label:"Plan"},{value:"edit",label:"Edit"},{value:"dangerous",label:"Dangerous"}],Vh=new Set(hl.filter(e=>e.supportsFollowUp).map(e=>e.value)),Wh=20,zh=3,so="meshy-working-dir-recents-by-node";function Hh(e){return e.startsWith("/")||e.startsWith("\\\\")||/^[A-Za-z]:[\\/]/.test(e)}function Kh(e){const t=e.trim();return t||"."}function Rr(e){const t=[],n=new Set;for(const s of e){const o=s.trim();if(!(!o||n.has(o))&&(n.add(o),t.push(o),t.length===zh))break}return t}function qh(e,t){const n=t.trim();return Rr(n?[n,...e]:e)}function Gh(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[n,s]of Object.entries(e)){if(!n||!Array.isArray(s))continue;const o=s.filter(c=>typeof c=="string"),a=Rr(o);a.length>0&&(t[n]=a)}return t}function Yh(e,t,n){if(!t)return e;const s=e[t]??[],o=qh(s,n);if(o.length===0){if(!(t in e))return e;const{[t]:a,...c}=e;return c}return{...e,[t]:o}}function Xh(e,t,n){return e!=="auto"?t.find(s=>s.id===e)??null:n.length===1?n[0]??null:null}function Jh(e,t){const n=t.trim();return n?Hh(n)||!e?n:`${e.replace(/[/\\]+$/,"")}/${n}`:""}function Zh(e,t){return e?e.isAbsolute?e.currentPath:e.currentPath==="."||e.currentPath===""?e.rootPath||(t==null?void 0:t.workDir)||"Node root":e.currentPath:(t==null?void 0:t.workDir)??"Node root"}function oo({value:e,onChange:t,assignTo:n,nodes:s,assignableNodes:o,layout:a="default",chipClassName:c,chipActiveClassName:l,chipInactiveClassName:u}){const[f,d]=i.useState(!1),[m,h]=i.useState(null),[g,x]=i.useState(!1),[p,v]=i.useState(!1),[b,y]=i.useState(null),[w,j]=i.useState(""),[k,C]=i.useState(!1),[S,T]=i.useState({}),R=i.useRef(null),A=i.useMemo(()=>Xh(n,s,o),[n,s,o]),O=A==null?void 0:A.id,$=i.useMemo(()=>O?S[O]??[]:[],[S,O]),V=i.useMemo(()=>e.trim()?Jh(A==null?void 0:A.workDir,e):"Use node default",[e,A==null?void 0:A.workDir]);i.useEffect(()=>{if(!(typeof window>"u"))try{const M=window.localStorage.getItem(so);if(!M)return;const Q=JSON.parse(M);T(Gh(Q))}catch{}},[]);const W=i.useCallback(M=>{O&&T(Q=>{const ne=Yh(Q,O,M);if(ne===Q)return Q;if(typeof window<"u")try{window.localStorage.setItem(so,JSON.stringify(ne))}catch{}return ne})},[O]),z=i.useCallback((M,Q=!0)=>{const ne=M.trim();t(ne),Q&&ne&&W(ne),d(!1)},[t,W]),P=i.useCallback(async(M,Q=0,ne=!1)=>{if(O){y(null),ne?v(!0):x(!0);try{const I=await dc(O,{path:M,limit:Wh,offset:Q,directoriesOnly:!0,allowAbsolute:!0});h(X=>ne&&X?{...I,entries:[...X.entries,...I.entries]}:I)}catch(I){y(I instanceof Error?I.message:"Failed to browse directories"),ne||h(null)}finally{x(!1),v(!1)}}},[O]),_=i.useRef(e);_.current=e;const L=i.useRef(P);L.current=P,i.useEffect(()=>{if(!f)return;const M=_.current;j(M),C(!1),h(null),y(null),O&&L.current(Kh(M))},[f,O]),i.useEffect(()=>{if(!f)return;const M=ne=>{R.current&&(R.current.contains(ne.target)||d(!1))},Q=ne=>{ne.key==="Escape"&&d(!1)};return document.addEventListener("mousedown",M),document.addEventListener("keydown",Q),()=>{document.removeEventListener("mousedown",M),document.removeEventListener("keydown",Q)}},[f]);const E=i.useCallback(M=>{P(M)},[P]),te=i.useCallback(()=>{m&&P(m.currentPath,m.entries.length,!0)},[m,P]),ce=a==="composer"?r.jsxs(H,{type:"button",variant:"ghost",onClick:()=>d(M=>!M),title:V,className:U(c,"min-w-0 max-w-full",e.trim()?l:u),children:[r.jsx(ed,{className:"h-3.5 w-3.5 shrink-0"}),r.jsx("span",{className:"min-w-0 truncate",children:V})]}):r.jsxs(H,{type:"button",variant:"outline",onClick:()=>d(M=>!M),className:"h-11 w-full justify-between rounded-2xl border-border/70 bg-background/70 px-4",title:V,children:[r.jsx("span",{className:U("truncate",e.trim()?"font-mono text-foreground":"text-muted-foreground"),children:V}),r.jsx("span",{className:"ml-3 shrink-0 text-xs text-muted-foreground",children:A?A.name:"Manual"})]}),ae=Zh(m,A),me=!!(m!=null&&m.parentPath);return r.jsxs("div",{className:U("relative inline-block",a==="composer"?"min-w-0 flex-1":"w-full"),ref:R,children:[a==="default"?r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ue,{className:"text-sm font-medium",children:"Working directory"}),ce]}):ce,f&&r.jsxs("div",{className:U("absolute z-50 mt-2 w-[360px] overflow-hidden rounded-2xl border border-border/60 bg-background/95 shadow-lg backdrop-blur",a==="composer"?"left-0":"left-0 right-0 w-auto min-w-[320px]"),children:[$.length>0&&r.jsxs("div",{className:"border-b border-border/60 px-3 py-2.5",children:[r.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:[r.jsx(ld,{className:"h-3 w-3"}),"Recent"]}),r.jsx("div",{className:"flex flex-col gap-1",children:$.map(M=>r.jsx("button",{type:"button",onClick:()=>z(M,!1),className:"truncate rounded-md px-2 py-1 text-left font-mono text-xs text-foreground hover:bg-background/60",title:M,children:M},M))})]}),r.jsxs("div",{className:"flex items-center gap-2 border-b border-border/60 px-3 py-2",children:[r.jsx("button",{type:"button",onClick:()=>(m==null?void 0:m.parentPath)&&E(m.parentPath),disabled:!me||g,className:"flex h-7 w-7 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:r.jsx(Oc,{className:"h-3.5 w-3.5"})}),r.jsx("div",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground",title:ae,children:ae}),m&&r.jsx("button",{type:"button",onClick:()=>z(m.isAbsolute?m.currentPath:m.currentPath==="."?"":m.currentPath),className:"shrink-0 rounded-md px-2 py-1 text-[11px] font-medium text-foreground hover:bg-background/60",title:"Use this folder",children:"Use"})]}),r.jsxs("div",{className:"max-h-72 overflow-y-auto",children:[A?g?r.jsxs("div",{className:"flex items-center justify-center px-3 py-6 text-xs text-muted-foreground",children:[r.jsx(ye,{className:"mr-2 h-3.5 w-3.5 animate-spin"}),"Loading..."]}):m&&m.entries.length>0?r.jsxs(r.Fragment,{children:[m.entries.map(M=>r.jsxs("div",{className:"group flex items-stretch border-b border-border/40 last:border-b-0",children:[r.jsxs("button",{type:"button",onClick:()=>z(M.path),className:"flex min-w-0 flex-1 items-center gap-2 px-3 py-2 text-left hover:bg-background/55",title:`Use ${M.path}`,children:[r.jsx(nd,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"truncate text-sm text-foreground",children:M.name})]}),r.jsx("button",{type:"button",onClick:()=>E(M.path),className:"flex w-16 shrink-0 items-center justify-center border-l border-border/30 text-muted-foreground hover:bg-background/70 hover:text-foreground",title:"Open subfolder","aria-label":`Open ${M.name}`,children:r.jsx(Mr,{className:"h-4 w-4"})})]},M.path)),m.hasMore&&r.jsx("div",{className:"border-t border-border/60 p-2",children:r.jsxs(H,{type:"button",variant:"outline",size:"sm",onClick:te,disabled:p,className:"h-8 w-full rounded-md text-xs",children:[p?r.jsx(ye,{className:"mr-1.5 h-3 w-3 animate-spin"}):null,"Load more"]})})]}):r.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:b??"No subfolders."}):r.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"Select a specific node to browse folders."}),b&&m&&m.entries.length>0&&r.jsx("div",{className:"border-t border-border/60 px-3 py-2 text-xs text-destructive",children:b})]}),r.jsx("div",{className:"flex items-center gap-1.5 border-t border-border/60 bg-background/40 px-3 py-2",children:k?r.jsxs(r.Fragment,{children:[r.jsx(Ct,{value:w,onChange:M=>j(M.target.value),onKeyDown:M=>{M.key==="Enter"&&w.trim()?(M.preventDefault(),z(w)):M.key==="Escape"&&(M.preventDefault(),C(!1),j(e))},autoFocus:!0,placeholder:"Path (relative or absolute)",className:"h-8 flex-1 rounded-md border-border/60 bg-background/70 font-mono text-xs"}),r.jsx("button",{type:"button",onClick:()=>z(w),disabled:!w.trim(),className:"flex h-8 w-8 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:r.jsx(pt,{className:"h-4 w-4"})}),r.jsx("button",{type:"button",onClick:()=>{C(!1),j(e)},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","aria-label":"Cancel manual path",children:r.jsx(zt,{className:"h-4 w-4"})})]}):r.jsxs("button",{type:"button",onClick:()=>{j(e),C(!0)},className:"flex h-8 flex-1 items-center justify-between rounded-md px-2 text-xs text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Enter a manual path",children:[r.jsx("span",{children:"Manual input"}),r.jsx(Ir,{className:"h-3.5 w-3.5"})]})})]})]})}function Qh(e,t={}){const n=e.filter(s=>s.status==="online");return t.currentNodeRole!=="follower"||!t.leaderNodeId?n:n.filter(s=>s.id!==t.leaderNodeId)}function ao(){return hl.map(e=>r.jsx(ge,{value:e.value,disabled:e.disabled,children:r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("span",{children:e.label}),e.description&&r.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:e.description})]})},e.value))}function io(){return Uh.map(e=>r.jsx(ge,{value:e.value,children:r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("span",{children:e.label}),e.description&&r.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:e.description})]})},e.value))}function ex({isCurrent:e}){return e?r.jsx(ud,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500 dark:text-emerald-400","aria-label":"current node"}):r.jsx(ad,{className:"h-3.5 w-3.5 shrink-0 text-sky-500 dark:text-sky-400","aria-label":"remote follower node"})}function lo(e,t){return e.map(n=>{const s=!!t&&n.id===t;return r.jsx(ge,{value:n.id,children:r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx(ex,{isCurrent:s}),r.jsx("span",{className:"truncate",children:n.name}),r.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:s?"current":"remote"})]})},n.id)})}function xl(e,t,n=!1){const s=e.trim();if(s)return s;const o=t.trim().split(`
251
+ `).map(a=>a.trim()).find(Boolean);return o?o.length>72?`${o.slice(0,69).trimEnd()}...`:o:n?"Image task":""}function tx(e){const t=xl(e.title,e.description,e.images.length>0),n=e.description.trim()||t,s=e.mode??Ar,o=Ro(e.description,e.images);return!t||!n||!e.agent?null:{title:t,description:n,agent:e.agent,project:e.project.trim()||null,payload:{initialMessage:o,mode:s},priority:e.priority,assignTo:e.assignTo==="auto"?void 0:e.assignTo}}function nx({nodes:e,currentNodeRole:t,currentNodeId:n,leaderNodeId:s,onCreated:o,onCancel:a,className:c,footerClassName:l,submitLabel:u="Create chat",cancelLabel:f="Cancel",autoFocus:d=!1,layout:m="default"}){const[h,g]=i.useState(""),[x,p]=i.useState(""),[v,b]=i.useState("claudecode"),[y,w]=i.useState(Ar),[j,k]=i.useState(""),[C,S]=i.useState("normal"),T=i.useMemo(()=>Qh(e,{currentNodeRole:t,leaderNodeId:s}),[e,t,s]),R=i.useMemo(()=>{var F;return n&&T.some(re=>re.id===n)?n:((F=T[0])==null?void 0:F.id)??""},[T,n]),[A,O]=i.useState(R),[$,V]=i.useState(!1),[W,z]=i.useState(!1),{images:P,error:_,fileInputRef:L,pickImages:E,handleFileChange:te,handlePaste:ce,removeImage:ae}=va();i.useEffect(()=>{A&&T.some(F=>F.id===A)||O(R)},[A,T,R]),i.useEffect(()=>{k("")},[A]);const me=i.useCallback(async F=>{F.preventDefault();const re=tx({title:h,description:x,agent:v,project:j,priority:C,assignTo:A,mode:y,images:P});if(re){V(!0);try{const ue=await uc(re);o(ue)}catch(ue){he.error(ue instanceof Error?ue.message:"Failed to create task")}finally{V(!1)}}},[h,x,v,j,C,A,y,P,o]),M=xl(h,x,P.length>0),Q=!!(M&&v&&A&&(x.trim()||P.length>0)),ne=i.useCallback(F=>{var re;F.nativeEvent.isComposing||F.key==="Enter"&&(F.ctrlKey||F.metaKey)&&Q&&!$&&(F.preventDefault(),(re=F.currentTarget.form)==null||re.requestSubmit())},[Q,$]),I=P.length>0&&r.jsx("div",{className:"flex flex-wrap gap-3",children:P.map((F,re)=>r.jsxs("div",{className:"relative",children:[r.jsx("img",{src:$r(F),alt:F.filename??`attachment ${re+1}`,className:"h-24 w-24 rounded-2xl border border-border/70 object-cover"}),r.jsx("button",{type:"button",onClick:()=>ae(re),className:"absolute -top-2 -right-2 flex h-6 w-6 items-center justify-center rounded-full border border-border/70 bg-background text-muted-foreground transition-colors hover:text-foreground","aria-label":`Remove ${F.filename??`image ${re+1}`}`,children:r.jsx(zt,{className:"h-3.5 w-3.5"})})]},`${F.filename??"image"}-${re}`))}),X=r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ue,{className:"text-sm font-medium",children:"Assign to"}),r.jsxs(Ae,{value:A,onValueChange:O,children:[r.jsx(Ne,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:r.jsx(Pe,{placeholder:"Select node"})}),r.jsx(je,{children:lo(T,n)})]})]}),de=r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ue,{className:"text-sm font-medium",children:"Agent"}),r.jsxs(Ae,{value:v,onValueChange:b,children:[r.jsx(Ne,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:r.jsx(Pe,{placeholder:"Select agent"})}),r.jsx(je,{children:ao()})]})]}),q=r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ue,{className:"text-sm font-medium",children:"Mode"}),r.jsxs(Ae,{value:y,onValueChange:F=>w(F),children:[r.jsx(Ne,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:r.jsx(Pe,{placeholder:"Select mode"})}),r.jsx(je,{children:io()})]})]}),J=r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ue,{className:"text-sm font-medium",children:"Priority"}),r.jsxs(Ae,{value:C,onValueChange:S,children:[r.jsx(Ne,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:r.jsx(Pe,{placeholder:"Select priority"})}),r.jsxs(je,{children:[r.jsx(ge,{value:"low",children:"Low"}),r.jsx(ge,{value:"normal",children:"Normal"}),r.jsx(ge,{value:"high",children:"High"}),r.jsx(ge,{value:"critical",children:"Critical"})]})]})]}),K=r.jsx(oo,{value:j,onChange:k,assignTo:A,nodes:e,assignableNodes:T});return m==="composer"?r.jsxs("form",{onSubmit:me,className:U("space-y-4",c),children:[r.jsx("input",{ref:L,type:"file",accept:"image/*",multiple:!0,onChange:te,className:"hidden"}),(()=>{var Be;const F="h-9 w-auto gap-1.5 rounded-full px-3.5 text-xs shadow-none transition-colors",re="border-transparent bg-transparent text-muted-foreground hover:bg-background/40 hover:text-foreground",ue="border-border/70 bg-background/55 text-foreground",we=v==="claudecode",be=y===Ar;return r.jsxs("div",{className:"relative rounded-[24px] border border-border/60 bg-background/45 shadow-[0_20px_80px_-40px_rgba(0,0,0,0.6)]",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 pt-3",children:[r.jsxs(Ae,{value:A,onValueChange:O,children:[r.jsx(Ne,{className:U(F,ue,"border-transparent bg-transparent hover:bg-background/40"),title:`Assigned node: ${((Be=T.find(ie=>ie.id===A))==null?void 0:Be.name)??"unassigned"}`,children:r.jsx(Pe,{placeholder:"Select node"})}),r.jsx(je,{children:lo(T,n)})]}),W?r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(Ct,{id:"task-title-composer",type:"text",value:h,onChange:ie=>g(ie.target.value),onKeyDown:ie=>{(ie.key==="Enter"||ie.key==="Escape")&&(ie.preventDefault(),z(!1))},autoFocus:!0,placeholder:"Chat title",className:"h-8 w-48 min-w-0 rounded-full border-border/70 bg-background/55 px-3 text-xs shadow-none"}),r.jsx(H,{type:"button",variant:"ghost",size:"icon",onClick:()=>z(!1),"aria-label":"Save title",className:"h-8 w-8 shrink-0 rounded-full text-muted-foreground hover:text-foreground",children:r.jsx(pt,{className:"h-3.5 w-3.5"})})]}):r.jsxs("button",{type:"button",onClick:()=>z(!0),className:"flex min-w-0 items-center gap-1.5 rounded-full px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-background/55 hover:text-foreground",title:M||"Title",children:[r.jsx("span",{className:"max-w-[220px] truncate",children:M||"Title"}),r.jsx(Ir,{className:"h-3 w-3 shrink-0"})]})]}),r.jsx("textarea",{id:"task-description",value:x,onChange:ie=>p(ie.target.value),onKeyDown:ne,onPaste:ce,placeholder:"Ask anything...",rows:4,autoFocus:d,"aria-label":"Opening prompt",className:"min-h-[140px] w-full resize-none rounded-[24px] bg-transparent px-5 pt-2 pb-16 text-[15px] leading-7 text-foreground ring-offset-background placeholder:text-muted-foreground/70 focus-visible:outline-none"}),r.jsxs("div",{className:"absolute bottom-3 left-3 right-3 flex flex-nowrap items-center gap-2",children:[r.jsx(H,{type:"button",variant:"ghost",size:"icon",onClick:E,"aria-label":"Add images",className:"h-9 w-9 shrink-0 rounded-full text-muted-foreground hover:text-foreground",children:r.jsx(fr,{className:"h-4 w-4"})}),r.jsx("span",{className:"mx-0.5 h-5 w-px bg-border/60","aria-hidden":!0}),r.jsx(oo,{value:j,onChange:k,assignTo:A,nodes:e,assignableNodes:T,layout:"composer",chipClassName:F,chipActiveClassName:ue,chipInactiveClassName:re}),r.jsxs(Ae,{value:v,onValueChange:b,children:[r.jsx(Ne,{className:U(F,we?re:ue),children:r.jsx(Pe,{placeholder:"Agent"})}),r.jsx(je,{children:ao()})]}),r.jsxs(Ae,{value:y,onValueChange:ie=>w(ie),children:[r.jsx(Ne,{className:U(F,be?re:ue),children:r.jsx(Pe,{placeholder:"Mode"})}),r.jsx(je,{children:io()})]}),r.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[r.jsxs(Ae,{value:C,onValueChange:S,children:[r.jsx(Ne,{"aria-label":`Priority: ${C}`,title:`Priority: ${C}`,className:U("h-9 w-9 justify-center gap-0 rounded-full p-0 text-xs shadow-none [&>svg:last-child]:hidden",C==="normal"?"border-transparent bg-transparent text-muted-foreground hover:bg-background/40":"border-border/70 bg-background/55",C==="critical"&&"text-destructive",C==="high"&&"text-amber-600 dark:text-amber-400",C==="low"&&"text-muted-foreground"),children:r.jsx(Zc,{className:U("h-4 w-4",C==="critical"&&"fill-destructive/20")})}),r.jsxs(je,{children:[r.jsx(ge,{value:"low",children:"Low"}),r.jsx(ge,{value:"normal",children:"Normal"}),r.jsx(ge,{value:"high",children:"High"}),r.jsx(ge,{value:"critical",children:"Critical"})]})]}),a&&r.jsx(H,{type:"button",variant:"ghost",size:"sm",onClick:a,className:"h-9 rounded-full px-4 text-xs text-muted-foreground",children:f}),r.jsxs(H,{type:"submit",size:"icon",disabled:!Q||$,className:"h-10 w-10 rounded-full shadow-[0_8px_30px_-8px_hsl(var(--primary)/0.6)]",children:[$?r.jsx(ye,{className:"h-4 w-4 animate-spin"}):r.jsx(Co,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:$?"Creating chat":u})]})]})]})]})})(),(I||_)&&r.jsxs("div",{className:"space-y-3 rounded-[20px] border border-border/60 bg-background/45 p-4",children:[I,_&&r.jsx("div",{className:"text-xs text-destructive",children:_}),!_&&r.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."})]})]}):r.jsxs("form",{onSubmit:me,className:U("space-y-5",c),children:[r.jsx("input",{ref:L,type:"file",accept:"image/*",multiple:!0,onChange:te,className:"hidden"}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ue,{htmlFor:"task-description",className:"text-sm font-medium",children:"Opening prompt"}),r.jsx("textarea",{id:"task-description",value:x,onChange:F=>p(F.target.value),onKeyDown:ne,onPaste:ce,placeholder:"Describe what the agent should do. This becomes the first message in the chat.",rows:6,autoFocus:d,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"}),r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsxs(H,{type:"button",variant:"outline",onClick:E,className:"rounded-2xl",children:[r.jsx(fr,{className:"h-4 w-4"}),"Add images"]}),r.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."})]}),I,_&&r.jsx("p",{className:"text-xs text-destructive",children:_})]}),r.jsxs("div",{className:"grid gap-5 lg:grid-cols-[minmax(0,1fr)_220px_220px]",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ue,{htmlFor:"task-title",className:"text-sm font-medium",children:"Chat title"}),r.jsx(Ct,{id:"task-title",type:"text",value:h,onChange:F=>g(F.target.value),placeholder:"Optional. Leave blank to derive it from the prompt.",className:"h-11 rounded-2xl border-border/70 bg-background/70"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:M?`Will appear as: ${M}`:"A title will be generated from the first line of the prompt."})]}),de,q]}),K,r.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[J,X]}),r.jsxs("div",{className:U("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",l),children:[a&&r.jsx(H,{type:"button",variant:"ghost",onClick:a,className:"rounded-2xl",children:f}),r.jsx(H,{type:"submit",disabled:!Q||$,className:"rounded-2xl px-5",children:$?"Creating...":u})]})]})}const rx=[{value:"active",label:"Active"},{value:"running",label:"Running"},{value:"waiting",label:"Waiting"},{value:"closed",label:"Closed"},{value:"archived",label:"Archived"}],Cn=new Set(["pending","assigned"]),gl=new Set(["running"]),sx=new Set(["completed","failed","cancelled"]);function ox(e,t){switch(t){case"running":return gl.has(e.status);case"waiting":return Cn.has(e.status);case"closed":return sx.has(e.status);case"archived":return e.status==="archived";case"active":default:return e.status!=="archived"}}function ax(e,t){const n=t.trim().toLowerCase();return n?[e.title,e.description,e.id,e.agent,e.assignedTo??"",e.assignedNodeName??"",e.project??"",e.effectiveProjectPath??""].some(s=>s.toLowerCase().includes(n)):!0}function ds(e,t,n){if(!e)return"unassigned";const s=t==null?void 0:t.find(o=>o.id===e);return(s==null?void 0:s.name)??n??e.slice(0,8)}function ix(e,t,n){return ds(e,t,n).toLowerCase()}function lx(e,t){return[...e].sort((n,s)=>n.id===t?-1:s.id===t?1:n.name.localeCompare(s.name))}function cx(e){if(!e||typeof e!="object")return null;const t=e;return{draftNewTask:t.draftNewTask===!0,returnRoute:typeof t.returnRoute=="string"?t.returnRoute:void 0,returnTaskId:typeof t.returnTaskId=="string"||t.returnTaskId===null?t.returnTaskId:void 0}}function dx(e){switch(e){case"running":return"bg-amber-500";case"completed":return"bg-emerald-500";case"failed":return"bg-destructive";case"cancelled":case"archived":return"bg-slate-400";case"assigned":return"bg-teal-500";case"pending":default:return"bg-muted-foreground"}}function ux(e){return e==="default workspace"?e:e.replace(/\\/g,"/").split("/").filter(Boolean).at(-1)??e}function fx(e){if(e==="default workspace")return"Uses the node default workspace";const t=e.replace(/\\/g,"/"),n=t.split("/").filter(Boolean);return n.length<=3?t:`.../${n.slice(-3).join("/")}`}function mx(e){const t=Date.now()-e;return t<6e4?"just now":t<36e5?`${Math.floor(t/6e4)}m`:t<864e5?`${Math.floor(t/36e5)}h`:`${Math.floor(t/864e5)}d`}function px(e){return new Date(e).toLocaleString()}function hx(e){const t=Math.floor(e/1e3),n=Math.floor(t/3600),s=Math.floor(t%3600/60),o=t%60;return`${String(n).padStart(2,"0")}:${String(s).padStart(2,"0")}:${String(o).padStart(2,"0")}`}async function Je(e,t="Copied to clipboard"){var n,s,o;try{if((s=(n=globalThis.navigator)==null?void 0:n.clipboard)!=null&&s.writeText)return await globalThis.navigator.clipboard.writeText(e),he.success(t),!0;const a=globalThis.document,c=(o=a==null?void 0:a.execCommand)==null?void 0:o.bind(a);if(!(a!=null&&a.body)||typeof a.createElement!="function"||typeof c!="function")throw new Error("Clipboard access is unavailable");const l=a.createElement("textarea"),u=a.activeElement,f=u&&typeof u.focus=="function"?u:null;l.value=e,l.setAttribute("readonly","true"),l.style.position="fixed",l.style.opacity="0",l.style.pointerEvents="none",a.body.appendChild(l),l.select(),l.setSelectionRange(0,l.value.length);const d=c("copy");if(a.body.removeChild(l),f==null||f.focus(),!d)throw new Error("Clipboard access is unavailable");return he.success(t),!0}catch(a){return he.error(a instanceof Error?a.message:"Failed to copy"),!1}}function yt({label:e,value:t}){return r.jsxs("div",{className:"min-w-[7.25rem] flex-1 rounded-[20px] border border-border/60 bg-background/45 px-3 py-3",children:[r.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:e}),r.jsx("div",{className:"mt-1 text-lg font-semibold tracking-tight text-foreground",children:t})]})}function lr({label:e}){return r.jsx("div",{className:"flex h-64 items-center justify-center text-sm text-muted-foreground",children:e})}function ke({label:e,value:t,mono:n,action:s}){return r.jsxs("div",{className:"grid grid-cols-[5.25rem,minmax(0,1fr)] items-start gap-3",children:[r.jsx("span",{className:"pt-0.5 text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:e}),r.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[r.jsx("span",{className:U("min-w-0 flex-1 break-all text-sm text-foreground",n&&"font-mono text-[11px] leading-5"),children:t}),s]})]})}function _r({label:e,value:t,mono:n}){return r.jsxs("div",{className:"rounded-[18px] border border-border/60 bg-background/60 px-3 py-3",children:[r.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:e}),r.jsx("div",{className:U("mt-1 text-sm font-medium text-foreground",n&&"font-mono text-[11px]"),children:t})]})}function vl({capabilities:e,action:t}){return r.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between sm:gap-4",children:[r.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[r.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:"Capabilities"}),r.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:e.length>0?e.map(n=>r.jsx(Ce,{variant:"secondary",className:"rounded-full",children:n},n)):r.jsx("span",{className:"text-sm text-muted-foreground",children:"None declared"})})]}),t&&r.jsx("div",{className:"shrink-0 self-start",children:t})]})}const xx=i.lazy(async()=>({default:(await Dr(()=>import("./FilesTab-DVMAnAjC.js"),__vite__mapDeps([0,1,2,3]))).FilesTab})),gx=i.lazy(async()=>({default:(await Dr(()=>import("./PreviewTab-DYrIeJFR.js"),__vite__mapDeps([4,1,2]))).PreviewTab})),vx=i.lazy(async()=>({default:(await Dr(()=>import("./DiffTab-DDvHQmgo.js"),__vite__mapDeps([5,1,2,3]))).DiffTab}));function bx({onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:c,activeTab:l,setActiveTab:u,creatingTask:f,activeTask:d,assignedNode:m,taskLoading:h,taskError:g,displayEvents:x,hasUserMessageInLogs:p,initialPrompt:v,supportsFollowUp:b,taskUnavailable:y,chatDisabled:w,chatDisabledReason:j,questionBypassEnabled:k,isRunning:C,hasPendingFollowUp:S,canCancel:T,canRetry:R,onRetry:A,onCancel:O,onStartCreateTask:$,onCancelCreateTask:V,onCreateTask:W,onSendMessage:z,onQuestionBypassChange:P,onSubmitQuestionResponse:_,messagesEndRef:L}){const[E,te]=i.useState(!1),[ce,ae]=i.useState(!1),[me,M]=i.useState(!1),Q=i.useRef(0),ne=i.useRef(!1),I=i.useCallback(K=>{const F=K.currentTarget,re=Q.current;if(Q.current=F.scrollTop,ne.current)return;if(F.scrollHeight-F.scrollTop-F.clientHeight<30){ae(!1),ne.current=!0,setTimeout(()=>{ne.current=!1},300);return}F.scrollTop<re&&re-F.scrollTop>10&&ae(!0),F.scrollTop<=0&&ae(!0)},[]),X=(d==null?void 0:d.effectiveProjectPath)??(d==null?void 0:d.project)??"default workspace",de=d?(m==null?void 0:m.name)??ds(d.assignedTo,a==null?void 0:a.nodes,d.assignedNodeName):"unassigned",q=d?[{label:"Working dir",value:X,mono:!0},{label:"Agent",value:d.agent,mono:!0},{label:"Node",value:de}]:[],J=d!=null&&d.description&&d.description!==d.title?d.description:null;return f?r.jsx(yx,{onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:c,onCancel:V,onCreated:W}):!d&&h?r.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden rounded-2xl sm:rounded-[32px] border border-border/60 bg-background/78 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:[r.jsx("div",{className:"shrink-0 border-b border-border/60 px-4 py-4 sm:px-5",children:r.jsx(dn,{onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:c})}),r.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-6 py-10 sm:px-8",children:r.jsxs("div",{className:"space-y-4 text-center",children:[r.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-full border border-primary/20 bg-primary/10 text-primary",children:r.jsx(ye,{className:"h-7 w-7 animate-spin"})}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h2",{className:"text-2xl font-semibold tracking-tight text-foreground",children:"Loading conversation"}),r.jsxs("div",{className:"flex items-center justify-center gap-3 text-sm text-muted-foreground",children:[r.jsx(ye,{className:"h-4 w-4 animate-spin"}),"Fetching the selected chat thread..."]})]})]})})]}):d?r.jsxs(Ba,{value:l,onValueChange:u,className:"flex h-full min-h-0 flex-col overflow-hidden rounded-2xl sm:rounded-[32px] border border-border/60 bg-background/78 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:[r.jsxs("div",{className:"shrink-0 border-b border-border/60 px-4 py-2.5 sm:px-5",children:[r.jsx("div",{className:"flex items-center gap-3",children:r.jsx(dn,{onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:c})}),r.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[r.jsx("h2",{className:"min-w-0 truncate text-base font-semibold tracking-tight text-foreground sm:text-lg",title:d.title,children:d.title}),r.jsx(go,{status:d.status}),r.jsx(fc,{priority:d.priority}),r.jsx(H,{variant:"ghost",size:"icon",className:"ml-auto h-6 w-6 shrink-0 rounded-full text-muted-foreground",onClick:()=>te(K=>!K),children:E?r.jsx(Or,{className:"h-3.5 w-3.5"}):r.jsx(Tt,{className:"h-3.5 w-3.5"})})]}),E&&r.jsxs("div",{className:"mt-2 space-y-2",children:[J&&r.jsx("p",{className:"max-w-3xl text-sm leading-5 text-muted-foreground",children:J}),g&&r.jsx("div",{className:"w-fit rounded-full border border-destructive/25 bg-destructive/10 px-3 py-1 text-xs text-destructive",children:g}),r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsxs("div",{className:"flex flex-col text-xs text-muted-foreground",children:[r.jsxs("span",{children:["updated ",px(d.updatedAt)]}),r.jsx("span",{className:"font-mono",children:d.id.slice(0,8)})]}),r.jsx("div",{className:"flex items-center gap-2",children:R&&r.jsxs(H,{variant:"outline",size:"sm",onClick:A,className:"shrink-0 rounded-full",children:[r.jsx(Sd,{className:"h-3.5 w-3.5"}),"Retry"]})})]})]}),r.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[r.jsxs(es,{className:"h-auto max-w-full overflow-x-auto rounded-full bg-muted/70 p-1",children:[r.jsx(Ge,{value:"transcript",className:"rounded-full px-2.5 sm:px-4",children:"Transcript"}),r.jsx(Ge,{value:"files",className:"rounded-full px-2.5 sm:px-4",children:"Files"}),r.jsx(Ge,{value:"preview",className:"rounded-full px-2.5 sm:px-4",children:"Preview"}),r.jsx(Ge,{value:"diff",className:"rounded-full px-2.5 sm:px-4",children:"Diff"})]}),C&&r.jsx(Ce,{variant:"outline",className:"hidden rounded-full border-amber-500/30 bg-amber-500/10 text-amber-700 sm:inline-flex dark:text-amber-300",children:"Working"}),S&&r.jsx(Ce,{variant:"outline",className:"hidden rounded-full border-primary/30 bg-primary/10 text-primary sm:inline-flex",children:"Queued"}),y&&r.jsx(Ce,{variant:"outline",className:"hidden rounded-full border-destructive/25 bg-destructive/10 text-destructive sm:inline-flex",children:"Unavailable"})]})]}),r.jsx(Ye,{value:"transcript",className:"mt-0 min-h-0 flex-1",children:r.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[r.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-5 sm:px-5",onScroll:I,children:r.jsxs("div",{className:"mx-auto flex max-w-[72rem] flex-col gap-5",children:[v&&!p&&r.jsx(zs,{event:v,questionBypassEnabled:k,onQuestionBypassChange:P,onSubmitQuestionResponse:_,questionResponseDisabled:!b||w}),x.map((K,F)=>r.jsx(zs,{event:K,questionBypassEnabled:k,onQuestionBypassChange:P,onSubmitQuestionResponse:_,questionResponseDisabled:!b||w},pu("transcript",K,F))),x.length===0&&r.jsxs("div",{className:"rounded-[28px] border border-dashed border-border/70 bg-background/35 px-5 py-8 text-center",children:[r.jsx("div",{className:"text-sm font-medium text-foreground",children:"Transcript is warming up"}),r.jsx("div",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:h?"Fetching task output...":"The opening prompt has been stored, but the agent has not emitted conversation output yet."})]}),(!b&&d.result||d.error)&&r.jsxs("div",{className:"space-y-3",children:[!b&&d.result&&r.jsxs("div",{className:"rounded-[26px] border border-border/70 bg-card/80 px-4 py-4",children:[r.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:"Stored result"}),r.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-xs leading-5 text-muted-foreground",children:JSON.stringify(d.result,null,2)})]}),d.error&&r.jsxs("div",{className:"rounded-[26px] border border-destructive/20 bg-destructive/10 px-4 py-4 text-destructive",children:[r.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em]",children:"Stored error"}),r.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-xs leading-5",children:d.error})]})]}),(C||S)&&x.length>0&&r.jsxs("div",{className:"flex items-center gap-3 rounded-[24px] border border-border/60 bg-background/45 px-4 py-3 text-sm text-muted-foreground",children:[r.jsx(ye,{className:"h-4 w-4 animate-spin"}),"The agent is still working on this conversation."]}),r.jsx("div",{ref:L})]})}),b?ce?r.jsx(H,{size:"icon",onClick:()=>ae(!1),className:"absolute bottom-4 right-4 z-10 h-12 w-12 rounded-full shadow-lg",children:r.jsx(Ir,{className:"h-5 w-5"})}):r.jsx("div",{className:"shrink-0",children:r.jsx("div",{className:"mx-auto w-full max-w-[72rem]",children:r.jsx(om,{onSend:z,disabled:w,disabledReason:j,contextItems:q,placeholder:w?j:"Continue the conversation...",running:C||S,onStop:T?()=>M(!0):void 0})})}):r.jsx("div",{className:"shrink-0 border-t border-border/60 px-4 py-4 text-sm 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."})]})}),r.jsx(Ye,{value:"files",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:r.jsx(i.Suspense,{fallback:r.jsx(lr,{label:"Loading files..."}),children:r.jsx(xx,{taskId:d.id})})}),r.jsx(Ye,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:r.jsx(i.Suspense,{fallback:r.jsx(lr,{label:"Loading preview..."}),children:r.jsx(gx,{taskId:d.id})})}),r.jsx(Ye,{value:"diff",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:r.jsx(i.Suspense,{fallback:r.jsx(lr,{label:"Loading diff..."}),children:r.jsx(vx,{taskId:d.id})})}),r.jsx(yr,{open:me,onOpenChange:M,children:r.jsxs(pn,{children:[r.jsxs(hn,{children:[r.jsx(gn,{children:"Stop this task?"}),r.jsx(vn,{children:"The task will stop and move to a cancelled state."})]}),r.jsxs(xn,{children:[r.jsx(yn,{children:"Keep running"}),r.jsx(bn,{onClick:O,children:"Stop task"})]})]})})]}):r.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden rounded-2xl sm:rounded-[32px] border border-border/60 bg-background/78 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:[r.jsx("div",{className:"shrink-0 border-b border-border/60 px-4 py-4 sm:px-5",children:r.jsx(dn,{onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:c})}),r.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-6 py-10 sm:px-8",children:r.jsxs("div",{className:"w-full max-w-2xl text-center",children:[r.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-full border border-primary/20 bg-primary/10 text-primary",children:r.jsx(yo,{className:"h-7 w-7"})}),r.jsx("h2",{className:"mt-5 text-xl font-semibold tracking-tight text-foreground sm:text-3xl",children:"No chat selected"}),r.jsx("p",{className:"mx-auto mt-3 max-w-xl text-sm leading-6 text-muted-foreground",children:"Open a task from the left sidebar to continue the conversation, or start a new task to create a fresh chat thread."}),r.jsxs(H,{onClick:$,className:"mt-6 rounded-full px-5",children:[r.jsx(jo,{className:"h-4 w-4"}),"Start new chat"]}),g&&r.jsx("div",{className:"mx-auto mt-4 max-w-lg rounded-[20px] border border-destructive/20 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:g})]})})]})}function yx({onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:c,onCancel:l,onCreated:u}){var f,d,m;return r.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden rounded-2xl sm:rounded-[32px] border border-border/60 bg-background/78 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:[r.jsx("div",{className:"shrink-0 border-b border-border/60 px-4 py-4 sm:px-5",children:r.jsx(dn,{onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:c})}),r.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:r.jsx("div",{className:"w-full max-w-2xl",children:r.jsx(nx,{nodes:(a==null?void 0:a.nodes)??[],currentNodeRole:(f=a==null?void 0:a.self)==null?void 0:f.role,currentNodeId:((d=a==null?void 0:a.self)==null?void 0:d.id)??null,leaderNodeId:((m=a==null?void 0:a.leader)==null?void 0:m.id)??null,onCreated:u,onCancel:l,submitLabel:"Start chat",autoFocus:!0,layout:"composer"})})})]})}function dn({onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:c}){var l;return r.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[r.jsx(wx,{desktopTasksOpen:t,mobileTasksPanelOpen:n,onToggleTasks:e}),r.jsx(Ce,{variant:"outline",className:"hidden rounded-full border-border/70 bg-background/60 sm:inline-flex",children:c?"Live":"Retrying"}),((l=a==null?void 0:a.leader)==null?void 0:l.name)&&r.jsxs(Ce,{variant:"outline",className:"hidden rounded-full border-border/70 bg-background/60 sm:inline-flex",children:["leader ",a.leader.name]})]}),r.jsxs(H,{variant:"outline",onClick:o,className:"shrink-0 rounded-full border-border/70 bg-background/60 px-3 sm:px-4",children:[s?r.jsx(ko,{className:"h-4 w-4"}):r.jsx(wd,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline",children:s?"Hide cluster":"Show cluster"})]})]})}function wx({desktopTasksOpen:e,mobileTasksPanelOpen:t,onToggleTasks:n}){var o,a;const s=(a=(o=globalThis.window)==null?void 0:o.matchMedia("(min-width: 1024px)"))!=null&&a.matches?e:t;return r.jsxs(H,{variant:"outline",onClick:n,className:"rounded-full border-border/70 bg-background/60 px-3 sm:px-4",children:[s?r.jsx(So,{className:"h-4 w-4"}):r.jsx(vd,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline",children:s?"Hide tasks":"Show tasks"})]})}const Nx={node:"border-teal-500/30 bg-teal-500/10 text-teal-700 dark:text-teal-300",task:"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300",election:"border-indigo-500/30 bg-indigo-500/10 text-indigo-700 dark:text-indigo-300",cluster:"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300"};function jx(e){return e.split(".")[0]??"unknown"}function Sx(e){return new Date(e).toLocaleTimeString("en-US",{hour12:!1})}function cr(e,t){return(t==null?void 0:t.get(e))??e}function kx(e,t){const n=e.data;switch(e.type){case"node.joined":return`${n.name} joined the cluster`;case"node.left":return`${cr(n.nodeId,t)} left (${n.reason})`;case"node.status":return`${cr(n.nodeId,t)} is now ${n.status}`;case"task.created":return`"${n.title}" created`;case"task.assigned":return`task assigned to ${cr(n.nodeId,t)}`;case"task.status":return`task ${n.taskId.slice(0,8)} -> ${n.status}`;case"election.started":return`candidate ${n.candidateId.slice(0,8)} term ${n.term}`;case"election.complete":return`leader elected, term ${n.term}`;case"cluster.state":return`${n.nodeCount} nodes, term ${n.term}`;default:return JSON.stringify(n)}}function Cx(e){return JSON.stringify(e,null,2)}function Ex({events:e,maxHeight:t="400px",emptyTitle:n="No live events yet",emptyDescription:s="Cluster activity appears here as it happens.",nodeNameById:o}){return e.length===0?r.jsx("div",{className:"flex h-28 items-center justify-center rounded-[20px] border border-dashed border-border/70 bg-background/40 text-center",children:r.jsxs("div",{children:[r.jsx("div",{className:"text-sm text-muted-foreground",children:n}),r.jsx("div",{className:"mt-1 text-xs text-muted-foreground/70",children:s})]})}):r.jsx("div",{className:"overflow-y-auto pr-1",style:{maxHeight:t},children:r.jsx("div",{className:"space-y-2",children:e.map(a=>{const c=jx(a.type);return r.jsx("div",{className:"rounded-[20px] border border-border/60 bg-background/45 px-4 py-3 transition-colors hover:border-border hover:bg-background/65",children:r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsx("div",{className:"font-mono text-[11px] text-muted-foreground",children:Sx(a.timestamp)}),r.jsx(Ce,{variant:"outline",className:U("w-fit text-[10px] font-medium uppercase tracking-[0.16em]",Nx[c]),children:a.type})]}),r.jsx(H,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-full text-muted-foreground",onClick:()=>void Je(Cx(a),"Event copied"),"aria-label":`Copy ${a.type} event`,title:"Copy event",children:r.jsx(wo,{className:"h-3.5 w-3.5"})})]}),r.jsx("div",{className:"text-sm leading-6 text-foreground/85",children:kx(a,o)})]})},a.id)})})})}function co({cluster:e,systemInfo:t,nodeNameById:n,nodeBlockingTaskCounts:s,eventTypeFilter:o,onEventTypeFilterChange:a,eventTypeOptions:c,filteredEvents:l,sseConnected:u,clusterLoading:f,clusterError:d,electionPending:m,onTriggerElection:h,promotePending:g,onPromote:x,onAddNode:p,leavePending:v,onLeaveCluster:b,onToggleNodeDevTunnel:y,devTunnelNodeId:w,onClose:j}){var $,V,W,z,P;const k=(($=e==null?void 0:e.self)==null?void 0:$.role)==="leader",C=((V=e==null?void 0:e.self)==null?void 0:V.role)==="follower"&&!(e!=null&&e.leader),S=(e==null?void 0:e.self)??null,R=lx((e==null?void 0:e.nodes)??[],S==null?void 0:S.id).filter(_=>_.id!==(S==null?void 0:S.id)),A=(S==null?void 0:S.role)==="leader"&&R.length===0,O=(S==null?void 0:S.role)==="follower"&&!!(e!=null&&e.leader);return r.jsx("aside",{className:"flex h-full min-h-0 flex-col overflow-hidden rounded-[32px] border border-border/60 bg-background/84 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:r.jsxs(Ba,{defaultValue:"overview",className:"flex h-full min-h-0 flex-col",children:[r.jsxs("div",{className:"shrink-0 border-b border-border/60 px-4 py-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-lg font-semibold tracking-tight",children:"Operations"}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Node, cluster, and live events."})]}),r.jsx(H,{variant:"ghost",size:"icon",onClick:j,className:"rounded-full",children:r.jsx(ko,{className:"h-4 w-4"})})]}),r.jsxs(es,{className:"mt-4 grid h-auto w-full grid-cols-3 rounded-full bg-muted/70 p-1",children:[r.jsx(Ge,{value:"overview",className:"rounded-full px-3 text-xs",children:"Overview"}),r.jsx(Ge,{value:"nodes",className:"rounded-full px-3 text-xs",children:"Nodes"}),r.jsx(Ge,{value:"events",className:"rounded-full px-3 text-xs",children:"Live events"})]})]}),r.jsx(Ye,{value:"overview",className:"mt-0 min-h-0 flex-1",children:r.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-y-auto px-4 py-5",children:r.jsxs("div",{className:"space-y-7",children:[S&&r.jsx(uo,{node:S,systemInfo:t,blockingTaskCount:s.get(S.id)??0,devTunnelNodeId:w,onToggleNodeDevTunnel:y,showActions:!1,defaultExpanded:!1}),r.jsxs("section",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx("div",{className:"text-sm font-medium text-foreground",children:"Cluster snapshot"}),r.jsx(Ce,{variant:"outline",className:"rounded-full border-border/70 bg-background/60",children:u?"Connected":"Reconnecting"})]}),f&&!e?r.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[r.jsx(ye,{className:"h-4 w-4 animate-spin"}),"Loading cluster state..."]}):d&&!e?r.jsx("div",{className:"rounded-[22px] border border-destructive/20 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:d}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsx(yt,{label:"Term",value:String((e==null?void 0:e.term)??0)}),r.jsx(yt,{label:"Nodes",value:String((e==null?void 0:e.nodes.length)??0)}),r.jsx(yt,{label:"Pending",value:String((e==null?void 0:e.taskSummary.pending)??0)}),r.jsx(yt,{label:"Running",value:String((e==null?void 0:e.taskSummary.running)??0)}),r.jsx(yt,{label:"Completed",value:String((e==null?void 0:e.taskSummary.completed)??0)}),r.jsx(yt,{label:"Failed",value:String((e==null?void 0:e.taskSummary.failed)??0)})]}),r.jsxs("div",{className:"space-y-3 rounded-[24px] border border-border/60 bg-background/45 px-4 py-4",children:[r.jsx(ke,{label:"Leader",value:((W=e==null?void 0:e.leader)==null?void 0:W.name)??"None"}),r.jsx(ke,{label:"Leader URL",value:((z=e==null?void 0:e.leader)==null?void 0:z.endpoint)??"Unavailable",mono:!0,action:(P=e==null?void 0:e.leader)!=null&&P.endpoint?r.jsx(ct,{label:"Copy leader URL",onClick:()=>{var _;return void Je(((_=e.leader)==null?void 0:_.endpoint)??"","Leader URL copied")}}):void 0}),r.jsx(ke,{label:"Feed",value:u?"Receiving live updates":"Reconnecting to event stream"})]}),r.jsxs("div",{className:"flex flex-wrap gap-2",children:[k&&r.jsxs(H,{variant:"outline",size:"sm",onClick:h,disabled:m,className:"rounded-full",children:[m&&r.jsx(ye,{className:"h-3.5 w-3.5 animate-spin"}),"Trigger election"]}),C&&r.jsxs(H,{variant:"outline",size:"sm",onClick:x,disabled:g,className:"rounded-full",children:[g&&r.jsx(ye,{className:"h-3.5 w-3.5 animate-spin"}),"Promote self"]})]})]})]})]})})}),r.jsx(Ye,{value:"nodes",className:"mt-0 min-h-0 flex-1",children:r.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-y-auto px-4 py-5",children:r.jsxs("div",{className:"space-y-7",children:[r.jsxs("section",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx("div",{className:"text-sm font-medium text-foreground",children:"This node"}),A?r.jsx(H,{variant:"outline",size:"sm",onClick:p,className:"rounded-full",children:"Join node"}):O?r.jsxs(H,{variant:"outline",size:"sm",onClick:b,disabled:v,className:"rounded-full",children:[v&&r.jsx(ye,{className:"h-3.5 w-3.5 animate-spin"}),"Leave cluster"]}):null]}),S&&r.jsx(uo,{node:S,systemInfo:t,blockingTaskCount:s.get(S.id)??0,devTunnelNodeId:w,onToggleNodeDevTunnel:y,showActions:!0,defaultExpanded:!0})]}),r.jsxs("section",{className:"space-y-4",children:[r.jsxs("div",{className:"text-sm font-medium text-foreground",children:["Peer nodes (",R.length,")"]}),R.length>0?r.jsx("div",{className:"space-y-3",children:R.map(_=>r.jsx(Tx,{node:_,isLeader:!!k,blockingTaskCount:s.get(_.id)??0,devTunnelNodeId:w,onToggleNodeDevTunnel:y},_.id))}):r.jsx("div",{className:"rounded-[24px] border border-dashed border-border/70 bg-background/35 px-4 py-5 text-sm text-muted-foreground",children:"No peer nodes are connected yet."})]})]})})}),r.jsx(Ye,{value:"events",className:"mt-0 min-h-0 flex-1",children:r.jsxs("div",{className:"flex h-full min-h-0 flex-col px-4 py-5",children:[r.jsxs("div",{className:"mb-4 space-y-3",children:[r.jsx("div",{children:r.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[r.jsx(mc,{className:U("h-4 w-4",u?"text-emerald-500":"text-destructive")}),"Live events"]})}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs(Ae,{value:o,onValueChange:a,children:[r.jsx(Ne,{className:"h-9 min-w-[11rem] flex-1 rounded-full border-border/70 bg-background/55 text-[12px] sm:max-w-[15rem]",children:r.jsx(Pe,{placeholder:"Event type"})}),r.jsx(je,{children:c.map(_=>r.jsx(ge,{value:_,className:"text-[12px]",children:_==="all"?"All event types":_},_))})]}),r.jsx(Ce,{variant:"outline",className:"rounded-full border-border/70 bg-background/60",children:u?"Connected":"Reconnecting"})]})]}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(Ex,{events:l,maxHeight:"100%",emptyTitle:o==="all"?"No live events yet":"No matching events",emptyDescription:o==="all"?"Cluster activity appears here as it happens.":`No "${o}" events are in the current stream.`,nodeNameById:n})})]})})]})})}function uo({node:e,systemInfo:t,blockingTaskCount:n,devTunnelNodeId:s,onToggleNodeDevTunnel:o,showActions:a=!0,defaultExpanded:c=!1}){const[l,u]=i.useState(c),f=(t==null?void 0:t.dashboardOrigin)??e.dashboardOrigin,d=e.devtunnelEndpoint??e.endpoint,m=f??e.endpoint,h=e.previewOrigin,g=(t==null?void 0:t.workDir)??e.workDir,x=Ao(e,t==null?void 0:t.transportType),p=Lr(e,t==null?void 0:t.transportType),v=p&&At((t==null?void 0:t.transportType)??e.transportType)?!0:To(e,t==null?void 0:t.transportType),b=n>0;return r.jsxs("section",{className:"rounded-[28px] border border-primary/20 bg-primary/8 shadow-[0_24px_80px_-60px_hsl(var(--primary)/0.9)]",children:[r.jsxs("button",{type:"button",onClick:()=>u(y=>!y),className:"w-full px-4 py-3.5 text-left",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[l?r.jsx(Tt,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):r.jsx(Mr,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),r.jsx(vo,{status:e.status}),r.jsx("span",{className:"text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:"Current node"}),r.jsx("a",{href:m,target:"_blank",rel:"noreferrer",onClick:y=>y.stopPropagation(),className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:r.jsx(No,{className:"h-3.5 w-3.5"})})]}),r.jsxs("div",{className:"mt-1.5 flex items-center gap-2 pl-6",children:[r.jsx("span",{className:"text-sm font-semibold tracking-tight text-foreground",children:e.name}),r.jsx(bo,{role:e.role}),r.jsx(Ce,{variant:"outline",className:"rounded-full border-primary/30 bg-background/60 text-[10px] capitalize",children:e.status})]})]}),l&&r.jsxs("div",{className:"space-y-4 border-t border-primary/15 px-4 pb-4 pt-3",children:[r.jsxs("div",{className:"space-y-3 rounded-[20px] border border-primary/20 bg-background/72 px-3.5 py-3.5",children:[r.jsx(ke,{label:"Node ID",value:e.id,mono:!0}),f&&r.jsx(ke,{label:"Dashboard",value:f,mono:!0,action:r.jsx(ct,{label:"Copy dashboard URL",onClick:()=>void Je(f,"Dashboard URL copied")})}),r.jsx(ke,{label:"Node URL",value:d,mono:!0,action:r.jsx(ct,{label:"Copy node URL",onClick:()=>void Je(d,"Node URL copied")})}),h&&r.jsx(ke,{label:"Preview",value:h,mono:!0,action:r.jsx(ct,{label:"Copy preview endpoint",onClick:()=>void Je(h,"Preview endpoint copied")})}),g&&r.jsx(ke,{label:"Workspace",value:g,mono:!0})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(_r,{label:"Transport",value:x}),t&&r.jsx(_r,{label:"Uptime",value:hx(t.uptime),mono:!0})]}),r.jsx(vl,{capabilities:e.capabilities,action:a&&v?r.jsxs(H,{variant:"outline",size:"sm",onClick:()=>o(e),disabled:s===e.id||b,className:"rounded-full",title:b?"Finish assigned or running tasks before changing remote access":void 0,children:[s===e.id&&r.jsx(ye,{className:"h-3.5 w-3.5 animate-spin"}),p?"Disable Remote Access":"Enable Remote Access"]}):void 0}),a&&v&&b&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function Tx({node:e,isLeader:t,blockingTaskCount:n,devTunnelNodeId:s,onToggleNodeDevTunnel:o}){const[a,c]=i.useState(!1),l=e.dashboardOrigin,u=e.devtunnelEndpoint??e.endpoint,f=l??e.endpoint,d=e.previewOrigin,m=Ao(e),h=Lr(e),g=To(e),x=n>0;return r.jsxs("div",{className:"rounded-[24px] border border-border/60 bg-background/45",children:[r.jsxs("button",{type:"button",onClick:()=>c(p=>!p),className:"w-full px-4 py-3 text-left",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[a?r.jsx(Tt,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):r.jsx(Mr,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),r.jsx(vo,{status:e.status}),r.jsx("span",{className:"text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:"Peer node"}),r.jsx("a",{href:f,target:"_blank",rel:"noreferrer",onClick:p=>p.stopPropagation(),className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:r.jsx(No,{className:"h-3.5 w-3.5"})})]}),r.jsxs("div",{className:"mt-1.5 flex items-center gap-2 pl-6",children:[r.jsx("span",{className:"text-sm font-semibold text-foreground",children:e.name}),r.jsx(bo,{role:e.role}),r.jsx(Ce,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 text-[10px] capitalize",children:e.status})]})]}),a&&r.jsxs("div",{className:"space-y-4 border-t border-border/50 px-4 pb-4 pt-3",children:[r.jsxs("div",{className:"space-y-3",children:[r.jsx(ke,{label:"Node ID",value:e.id,mono:!0}),l&&r.jsx(ke,{label:"Dashboard",value:l,mono:!0,action:r.jsx(ct,{label:"Copy dashboard URL",onClick:()=>void Je(l,"Dashboard URL copied")})}),r.jsx(ke,{label:"Node URL",value:u,mono:!0,action:r.jsx(ct,{label:"Copy node URL",onClick:()=>void Je(u,"Node URL copied")})}),d&&r.jsx(ke,{label:"Preview",value:d,mono:!0,action:r.jsx(ct,{label:"Copy preview endpoint",onClick:()=>void Je(d,"Preview endpoint copied")})}),e.workDir&&r.jsx(ke,{label:"Workspace",value:e.workDir,mono:!0}),r.jsx(_r,{label:"Transport",value:m})]}),r.jsx(vl,{capabilities:e.capabilities,action:t&&g?r.jsxs(H,{variant:"outline",size:"sm",onClick:()=>o(e),disabled:s===e.id||x,className:"rounded-full",title:x?"Finish assigned or running tasks before changing remote access":void 0,children:[s===e.id&&r.jsx(ye,{className:"h-3.5 w-3.5 animate-spin"}),h?"Disable Remote Access":"Enable Remote Access"]}):void 0}),t&&g&&x&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function ct({label:e,onClick:t}){return r.jsx(H,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-full text-muted-foreground",onClick:t,"aria-label":e,title:e,children:r.jsx(wo,{className:"h-3.5 w-3.5"})})}function Ax(e,t,n,s){var c;if(!e)return{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Select a task to continue the conversation."};const o=((c=t==null?void 0:t.self)==null?void 0:c.role)==="follower";return e.assignedTo!==null&&e.assignedNodeAvailable===!1?{taskUnavailable:!0,chatDisabled:!0,chatDisabledReason:`${e.assignedNodeName??"Assigned node"} is unavailable. Leave the cluster on that node or re-run the task elsewhere.`}:o?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Follower nodes are read-only. Use the leader dashboard to manage chat, or leave the cluster first."}:n||s?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Waiting for the current turn to finish..."}:Cn.has(e.status)||e.status==="archived"?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:Cn.has(e.status)?"Task has not started yet...":"Archived tasks are read-only."}:{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Continue the conversation..."}}var Un="Checkbox",[Rx]=nt(Un),[_x,us]=Rx(Un);function Px(e){const{__scopeCheckbox:t,checked:n,children:s,defaultChecked:o,disabled:a,form:c,name:l,onCheckedChange:u,required:f,value:d="on",internal_do_not_use_render:m}=e,[h,g]=kt({prop:n,defaultProp:o??!1,onChange:u,caller:Un}),[x,p]=i.useState(null),[v,b]=i.useState(null),y=i.useRef(!1),w=x?!!c||!!x.closest("form"):!0,j={checked:h,disabled:a,setChecked:g,control:x,setControl:p,name:l,form:c,value:d,hasConsumerStoppedPropagationRef:y,required:f,defaultChecked:Ze(o)?!1:o,isFormControl:w,bubbleInput:v,setBubbleInput:b};return r.jsx(_x,{scope:t,...j,children:Dx(m)?m(j):s})}var bl="CheckboxTrigger",yl=i.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...s},o)=>{const{control:a,value:c,disabled:l,checked:u,required:f,setControl:d,setChecked:m,hasConsumerStoppedPropagationRef:h,isFormControl:g,bubbleInput:x}=us(bl,e),p=le(o,d),v=i.useRef(u);return i.useEffect(()=>{const b=a==null?void 0:a.form;if(b){const y=()=>m(v.current);return b.addEventListener("reset",y),()=>b.removeEventListener("reset",y)}},[a,m]),r.jsx(Z.button,{type:"button",role:"checkbox","aria-checked":Ze(u)?"mixed":u,"aria-required":f,"data-state":kl(u),"data-disabled":l?"":void 0,disabled:l,value:c,...s,ref:p,onKeyDown:Y(t,b=>{b.key==="Enter"&&b.preventDefault()}),onClick:Y(n,b=>{m(y=>Ze(y)?!0:!y),x&&g&&(h.current=b.isPropagationStopped(),h.current||b.stopPropagation())})})});yl.displayName=bl;var fs=i.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:s,checked:o,defaultChecked:a,required:c,disabled:l,value:u,onCheckedChange:f,form:d,...m}=e;return r.jsx(Px,{__scopeCheckbox:n,checked:o,defaultChecked:a,disabled:l,required:c,onCheckedChange:f,name:s,form:d,value:u,internal_do_not_use_render:({isFormControl:h})=>r.jsxs(r.Fragment,{children:[r.jsx(yl,{...m,ref:t,__scopeCheckbox:n}),h&&r.jsx(Sl,{__scopeCheckbox:n})]})})});fs.displayName=Un;var wl="CheckboxIndicator",Nl=i.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:s,...o}=e,a=us(wl,n);return r.jsx(_t,{present:s||Ze(a.checked)||a.checked===!0,children:r.jsx(Z.span,{"data-state":kl(a.checked),"data-disabled":a.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});Nl.displayName=wl;var jl="CheckboxBubbleInput",Sl=i.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:s,hasConsumerStoppedPropagationRef:o,checked:a,defaultChecked:c,required:l,disabled:u,name:f,value:d,form:m,bubbleInput:h,setBubbleInput:g}=us(jl,e),x=le(n,g),p=Ri(a),v=bi(s);i.useEffect(()=>{const y=h;if(!y)return;const w=window.HTMLInputElement.prototype,k=Object.getOwnPropertyDescriptor(w,"checked").set,C=!o.current;if(p!==a&&k){const S=new Event("click",{bubbles:C});y.indeterminate=Ze(a),k.call(y,Ze(a)?!1:a),y.dispatchEvent(S)}},[h,p,a,o]);const b=i.useRef(Ze(a)?!1:a);return r.jsx(Z.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??b.current,required:l,disabled:u,name:f,value:d,form:m,...t,tabIndex:-1,ref:x,style:{...t.style,...v,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Sl.displayName=jl;function Dx(e){return typeof e=="function"}function Ze(e){return e==="indeterminate"}function kl(e){return Ze(e)?"indeterminate":e?"checked":"unchecked"}const Pr=i.forwardRef(({className:e,...t},n)=>r.jsx(fs,{ref:n,className:U("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:r.jsx(Nl,{className:U("flex items-center justify-center text-current"),children:r.jsx(pt,{className:"h-3.5 w-3.5"})})}));Pr.displayName=fs.displayName;function fo({toolbarTasks:e,activeTaskId:t,tasksLoading:n,tasksError:s,isLeader:o,scope:a,agentFilter:c,nodeFilter:l,agentOptions:u,nodeOptions:f,nodeNameById:d,searchQuery:m,selectedTaskIds:h,allVisibleTasksSelected:g,someVisibleTasksSelected:x,canBatchArchive:p,onSearchChange:v,onScopeChange:b,onAgentFilterChange:y,onNodeFilterChange:w,onToggleTaskSelected:j,onToggleAllVisibleTasks:k,onBatchArchive:C,onBatchDelete:S,onCreateTask:T,onSelectTask:R,onClose:A}){const[O,$]=i.useState(!!m),[V,W]=i.useState(!1),z=i.useRef(null),P=i.useRef(null),_=h.size,L=a!=="active"||l!=="all"||c!=="all";return i.useEffect(()=>{m&&$(!0)},[m]),i.useEffect(()=>{var E;O&&((E=z.current)==null||E.focus())},[O]),i.useEffect(()=>{if(!O)return;const E=ce=>{var me;const ae=ce.target;ae instanceof Node&&((me=P.current)!=null&&me.contains(ae)||$(!1))},te=ce=>{ce.key==="Escape"&&$(!1)};return document.addEventListener("mousedown",E),document.addEventListener("keydown",te),()=>{document.removeEventListener("mousedown",E),document.removeEventListener("keydown",te)}},[O]),r.jsxs("aside",{className:"flex h-full min-h-0 flex-col overflow-hidden rounded-[32px] border border-border/60 bg-background/80 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:[r.jsxs("div",{className:"shrink-0 border-b border-border/60 px-4 py-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx("div",{className:"text-lg font-semibold tracking-tight text-foreground",children:"Tasks"}),r.jsx(H,{variant:"ghost",size:"icon",onClick:A,className:"rounded-full",children:r.jsx(So,{className:"h-4 w-4"})})]}),r.jsxs("div",{ref:P,className:"mt-4 flex items-center gap-2",children:[r.jsxs(H,{onClick:T,className:U("justify-start rounded-[22px] px-4 py-6 text-left shadow-[0_24px_60px_-32px_hsl(var(--primary)/0.95)] transition-[flex] duration-200",O?"flex-[2]":"flex-1"),children:[r.jsx(jo,{className:"h-4 w-4"}),"New chat"]}),O?r.jsxs("div",{className:"flex min-w-0 flex-[3] items-center gap-2",children:[r.jsxs("div",{className:"relative min-w-0 flex-1",children:[r.jsx(Es,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),r.jsx(Ct,{ref:z,value:m,onChange:E=>v(E.target.value),placeholder:"Search tasks",className:"h-11 rounded-full border-border/70 bg-background/60 pl-11 text-sm"})]}),r.jsx(H,{variant:"outline",size:"icon",onClick:()=>$(!1),className:"rounded-full border-border/70 bg-background/60",children:r.jsx(Kc,{className:"h-4 w-4"})})]}):r.jsxs(r.Fragment,{children:[r.jsxs(H,{variant:"outline",onClick:()=>$(!0),className:U("rounded-full border-border/70 bg-background/60 px-4 text-sm",m&&"border-primary/40 bg-primary/8 text-primary"),children:[r.jsx(Es,{className:"h-4 w-4"}),"Search"]}),r.jsx(H,{variant:V||L?"secondary":"outline",size:"icon",onClick:()=>W(E=>!E),className:U("shrink-0 rounded-full border-border/70 bg-background/60",L&&"border-primary/40 bg-primary/8 text-primary"),title:"Filters",children:r.jsx(sd,{className:"h-4 w-4"})})]})]}),(V||L)&&r.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-2 sm:grid-cols-3",children:[r.jsxs(Ae,{value:a,onValueChange:E=>b(E),children:[r.jsx(Ne,{className:"h-9 rounded-full border-border/70 bg-background/55 text-[12px]",children:r.jsx(Pe,{})}),r.jsx(je,{children:rx.map(E=>r.jsx(ge,{value:E.value,className:"text-[12px]",children:E.label},E.value))})]}),r.jsxs(Ae,{value:l,onValueChange:w,children:[r.jsx(Ne,{className:"h-9 rounded-full border-border/70 bg-background/55 text-[12px]",children:r.jsx(Pe,{placeholder:"Node"})}),r.jsx(je,{children:f.map(E=>r.jsx(ge,{value:E.value,className:"text-[12px]",children:E.label},E.value))})]}),r.jsxs(Ae,{value:c,onValueChange:y,children:[r.jsx(Ne,{className:"h-9 rounded-full border-border/70 bg-background/55 text-[12px]",children:r.jsx(Pe,{placeholder:"Agent"})}),r.jsx(je,{children:u.map(E=>r.jsx(ge,{value:E,className:"text-[12px]",children:E==="all"?"All agents":E},E))})]})]})]}),r.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 py-3",children:e.length>0?r.jsxs("div",{className:"space-y-2",children:[o&&r.jsxs("div",{className:"mb-1 flex items-center justify-between px-1 py-1",children:[r.jsxs("label",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:[r.jsx(Pr,{checked:x&&!g?"indeterminate":g,onCheckedChange:E=>k(E===!0),"aria-label":"Select all visible tasks"}),r.jsx("span",{children:"Select all"})]}),_>0&&r.jsx(H,{variant:"ghost",size:"sm",onClick:()=>k(!1),className:"h-7 rounded-full px-3 text-xs",children:"Clear"})]}),e.map(E=>r.jsxs("div",{className:U("flex items-start gap-3 rounded-[24px] border px-3 py-3 transition-all",E.id===t?"border-primary/45 bg-primary/9 shadow-[0_24px_80px_-54px_hsl(var(--primary)/0.95)]":"border-border/60 bg-background/40 hover:border-border hover:bg-background/60"),children:[o&&r.jsx("div",{className:"flex shrink-0 pt-1",onClick:te=>te.stopPropagation(),children:r.jsx(Pr,{checked:h.has(E.id),onCheckedChange:te=>j(E.id,te===!0),"aria-label":`Select ${E.title}`})}),r.jsx("button",{type:"button",onClick:()=>R(E.id),className:"min-w-0 flex-1 text-left",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("span",{className:U("mt-1 h-2.5 w-2.5 shrink-0 rounded-full",dx(E.status))}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:E.title}),r.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",children:[r.jsx("span",{className:"font-mono",children:E.agent}),r.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),r.jsx("span",{children:E.assignedTo?d.get(E.assignedTo)??E.assignedTo.slice(0,8):"unassigned"}),r.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),r.jsx("span",{children:mx(E.updatedAt)})]}),r.jsxs("div",{className:"mt-3 flex items-center gap-2 text-[11px] text-muted-foreground",children:[r.jsx(go,{status:E.status}),E.assignedNodeAvailable===!1&&r.jsx(Ce,{variant:"outline",className:"border-destructive/25 bg-destructive/10 text-[10px] text-destructive",children:"unavailable"}),r.jsx("span",{className:"truncate font-medium text-foreground/85",children:ux(E.effectiveProjectPath??E.project??"default workspace")})]}),r.jsx("div",{className:"mt-1 truncate font-mono text-[10px] text-muted-foreground/85",children:fx(E.effectiveProjectPath??E.project??"default workspace")})]})]})})]},E.id))]}):r.jsx("div",{className:"rounded-[24px] border border-dashed border-border/70 bg-background/35 px-4 py-5 text-sm text-muted-foreground",children:n?"Loading tasks...":s||"No tasks match this view."})}),o&&_>0?r.jsxs("div",{className:"shrink-0 border-t border-border/60 px-4 py-4",children:[r.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:"Batch actions"}),r.jsxs("div",{className:"mt-2 text-sm font-semibold text-foreground",children:[_," task",_!==1?"s":""," selected"]}),!p&&r.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:"Only completed, failed, cancelled, or archived tasks can be archived."}),r.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[r.jsxs(yr,{children:[r.jsx(Hs,{asChild:!0,children:r.jsxs(H,{variant:"outline",size:"sm",disabled:!p,className:"rounded-full",children:[r.jsx(Dc,{className:"h-3.5 w-3.5"}),"Archive"]})}),r.jsxs(pn,{children:[r.jsxs(hn,{children:[r.jsxs(gn,{children:["Archive ",_," task",_!==1?"s":"","?"]}),r.jsx(vn,{children:"Archived tasks stay hidden from the default task view and can be reopened from the archived scope."})]}),r.jsxs(xn,{children:[r.jsx(yn,{children:"Cancel"}),r.jsx(bn,{onClick:C,disabled:!p,children:"Archive"})]})]})]}),r.jsxs(yr,{children:[r.jsx(Hs,{asChild:!0,children:r.jsxs(H,{variant:"destructive",size:"sm",className:"rounded-full",children:[r.jsx(Pd,{className:"h-3.5 w-3.5"}),"Delete"]})}),r.jsxs(pn,{children:[r.jsxs(hn,{children:[r.jsxs(gn,{children:["Delete ",_," task",_!==1?"s":"","?"]}),r.jsx(vn,{children:"This removes the selected tasks and their saved logs."})]}),r.jsxs(xn,{children:[r.jsx(yn,{children:"Cancel"}),r.jsx(bn,{onClick:S,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}):null]})}function dr(e,t,n){const s=i.useRef(t);s.current=t,i.useEffect(()=>{let c=0,l=0;const u=m=>{const h=m.touches[0];h&&(c=h.clientX,l=h.clientY)},f=m=>{var p,v,b,y;const h=m.changedTouches[0];if(!h)return;const g=h.clientX-c;Math.abs(h.clientY-l)>100||Math.abs(g)<50||(g>0?(v=(p=s.current).onSwipeRight)==null||v.call(p):(y=(b=s.current).onSwipeLeft)==null||y.call(b))},d=(e==null?void 0:e.current)??document;return d.addEventListener("touchstart",u,{passive:!0}),d.addEventListener("touchend",f,{passive:!0}),()=>{d.removeEventListener("touchstart",u),d.removeEventListener("touchend",f)}},[e,n==null?void 0:n.threshold,n==null?void 0:n.maxVertical])}function mo(e,t,n=30){const s=i.useRef(t);s.current=t,i.useEffect(()=>{let c=0,l=0,u=!1;const f=m=>{const h=m.touches[0];h&&(c=h.clientX,l=h.clientY,e==="left"?u=h.clientX<=n:u=h.clientX>=window.innerWidth-n)},d=m=>{if(!u)return;const h=m.changedTouches[0];if(!h)return;const g=h.clientX-c;Math.abs(h.clientY-l)>100||Math.abs(g)<50||(e==="left"&&g>0||e==="right"&&g<0)&&s.current()};return document.addEventListener("touchstart",f,{passive:!0}),document.addEventListener("touchend",d,{passive:!0}),()=>{document.removeEventListener("touchstart",f),document.removeEventListener("touchend",d)}},[e,n])}const po="(min-width: 1024px)",Mx="(min-width: 1280px)";function ur(e){var t,n,s;return((s=(n=(t=globalThis.window)==null?void 0:t.matchMedia)==null?void 0:n.call(t,e))==null?void 0:s.matches)??!1}function Ox(){const[e,t]=i.useState(!0),[n,s]=i.useState(!1),[o,a]=i.useState(()=>ur(Mx)),c=i.useRef(null),l=i.useRef(null),u=i.useRef(null),f=i.useCallback(()=>!ur(po),[]);mo("left",()=>{f()&&s(!0)}),mo("right",()=>{f()&&a(!0)}),dr(c,{onSwipeLeft:()=>s(!1)}),dr(l,{onSwipeRight:()=>a(!1)}),dr(u,{onSwipeRight:()=>{f()&&!n&&s(!0)},onSwipeLeft:()=>{o||a(!0)}});const d=i.useCallback(()=>{if(ur(po)){t(m=>!m);return}s(m=>!m)},[]);return{conversationRef:u,desktopTasksOpen:e,mobileTasksPanelOpen:n,mobileTasksPanelRef:c,operationsOpen:o,operationsPanelRef:l,setMobileTasksPanelOpen:s,setOperationsOpen:a,toggleTasksPanel:d}}function Ix(e,t){return t.data.nodeId===e.self.id||t.data.name===e.self.name||t.data.endpoint===e.self.endpoint}function Lx({cluster:e,subscribe:t}){i.useEffect(()=>{var n;if(((n=e==null?void 0:e.self)==null?void 0:n.role)==="leader")return t("node",s=>{const o=String(s.data.name??s.data.nodeId??"node"),a=Ix(e,s);s.type==="node.joined"&&!a&&he.success(`${o} joined the cluster`),s.type==="node.left"&&!a&&he.message(`${o} left the cluster`)})},[e,t])}function $x(){var Ns,js,Ss;const{id:e}=pc(),t=hc(),n=xc(),{cluster:s,systemInfo:o,events:a,sseConnected:c,subscribe:l,refresh:u,loading:f,error:d}=gc(),m=i.useMemo(()=>cx(t.state),[t.state]),[h,g]=i.useState([]),[x,p]=i.useState(!0),[v,b]=i.useState(null),[y,w]=i.useState(null),[j,k]=i.useState("active"),[C,S]=i.useState("all"),[T,R]=i.useState("all"),[A,O]=i.useState(""),$=i.useDeferredValue(A),{conversationRef:V,desktopTasksOpen:W,mobileTasksPanelOpen:z,mobileTasksPanelRef:P,operationsOpen:_,operationsPanelRef:L,setMobileTasksPanelOpen:E,setOperationsOpen:te,toggleTasksPanel:ce}=Ox(),[ae,me]=i.useState(()=>!!(m!=null&&m.draftNewTask)),[M,Q]=i.useState(()=>m!=null&&m.draftNewTask?{route:m.returnRoute??"/",taskId:m.returnTaskId??null}:null),[ne,I]=i.useState(!1),[X,de]=i.useState("transcript"),[q,J]=i.useState("all"),[K,F]=i.useState(!1),[re,ue]=i.useState(null),[we,be]=i.useState([]),[Be,ie]=i.useState([]),[Cl,Yt]=i.useState(!1),[El,ht]=i.useState(null),[Ke,ot]=i.useState(new Set),[Tl,ms]=i.useState(!1),[Al,ps]=i.useState(!1),[Rl,hs]=i.useState(!1),[_l,xs]=i.useState(null),gs=i.useRef(null),Ot=i.useRef(null),at=((Ns=s==null?void 0:s.self)==null?void 0:Ns.role)==="leader",Vn=(js=s==null?void 0:s.self)==null?void 0:js.id;Lx({cluster:s,subscribe:l});const xe=i.useCallback(async()=>{try{const N=await vc({assignedTo:!at&&Vn?Vn:void 0,limit:100});g(N),b(null)}catch(N){b(N instanceof Error?N.message:"Failed to load tasks")}finally{p(!1)}},[at,Vn]);bc(xe,1e4),i.useEffect(()=>{xe()},[xe]),i.useEffect(()=>l("task",xe),[l,xe]);const pe=i.useMemo(()=>[...h].sort((N,D)=>D.updatedAt-N.updatedAt),[h]),Pl=i.useMemo(()=>{const N=new Map;for(const D of(s==null?void 0:s.nodes)??[]){const B=$d(pe,D.id);B>0&&N.set(D.id,B)}return N},[s==null?void 0:s.nodes,pe]),Re=i.useMemo(()=>pe.filter(N=>!ox(N,j)||C!=="all"&&N.agent!==C||T==="unassigned"&&N.assignedTo||T!=="all"&&T!=="unassigned"&&ix(N.assignedTo,s==null?void 0:s.nodes,N.assignedNodeName)!==T?!1:$.trim()?ax(N,$):!0),[pe,j,C,T,$]);i.useEffect(()=>{ot(N=>{const D=Wd(N,Re.map(B=>B.id));return D.size===N.size?N:D})},[Re]),i.useEffect(()=>{at||ot(new Set)},[at]);const Dl=i.useMemo(()=>["all",...Array.from(new Set(pe.map(N=>N.agent))).sort()],[pe]),Ml=i.useMemo(()=>{const D=Array.from(new Set(pe.map(B=>B.assignedTo).filter(B=>!!B))).map(B=>{const fe=pe.find(ee=>ee.assignedTo===B);return(s==null?void 0:s.nodes.find(ee=>ee.id===B))??{id:B,name:ds(B,s==null?void 0:s.nodes,fe==null?void 0:fe.assignedNodeName)}}).sort((B,fe)=>B.name.localeCompare(fe.name));return[{value:"all",label:"All nodes"},{value:"unassigned",label:"Unassigned"},...D.map(B=>({value:B.name.toLowerCase(),label:B.name}))]},[pe,s==null?void 0:s.nodes]),vs=i.useMemo(()=>{const N=new Map;for(const D of(s==null?void 0:s.nodes)??[])N.set(D.id,D.name);for(const D of pe)D.assignedTo&&D.assignedNodeName&&!N.has(D.assignedTo)&&N.set(D.assignedTo,D.assignedNodeName);return N},[s==null?void 0:s.nodes,pe]),Wn=i.useMemo(()=>["all",...Array.from(new Set(a.map(N=>N.type))).sort()],[a]),Ol=i.useMemo(()=>q==="all"?a:a.filter(N=>N.type===q),[a,q]),Il=Re.length>0&&Re.every(N=>Ke.has(N.id)),Ll=Re.some(N=>Ke.has(N.id)),$l=zd(Re,Ke);i.useEffect(()=>{m!=null&&m.draftNewTask&&(me(!0),Q({route:m.returnRoute??"/",taskId:m.returnTaskId??null}))},[m]),i.useEffect(()=>{q!=="all"&&!Wn.includes(q)&&J("all")},[q,Wn]),i.useEffect(()=>{Ts(e,ae)&&!y&&pe[0]&&w(pe[0].id)},[e,ae,y,pe]),i.useEffect(()=>{var N;Ts(e,ae)&&(y&&h.some(D=>D.id===y)||w(((N=pe[0])==null?void 0:N.id)??null))},[e,ae,y,pe,h]);const oe=Bd({routeTaskId:e,creatingTask:ae,internalSelectedTaskId:y,sortedTaskIds:pe.map(N=>N.id)}),xt=i.useMemo(()=>h.find(N=>N.id===oe)??null,[h,oe]);i.useEffect(()=>{Ot.current=oe??null},[oe]);const Xt=i.useCallback(()=>{ue(null),be([]),ie([]),ht(null)},[]),Te=i.useCallback(async()=>{const N=oe;if(N)try{const D=await yc(N);if(Ot.current!==N)return;ue(D),ht(null)}catch(D){if(Ot.current!==N)return;ue(null),be([]),ie([]),ht(D instanceof Error?D.message:"Failed to load task")}finally{Ot.current===N&&Yt(!1)}},[oe]),Jt=i.useCallback(async()=>{const N=oe;if(N)try{const D=await wc(N);if(Ot.current!==N)return;be(B=>hu(B,D.logs)),ie(B=>gu(B,D.logs))}catch{}},[oe]);i.useEffect(()=>{if(!oe){ue(null),be([]),ie([]),ht(null),Yt(!1);return}de("transcript"),ue(xt),be([]),ie([]),ht(null),Yt(!0),Te(),Jt()},[oe,Jt,Te]),i.useEffect(()=>{var D;if(!oe||ae||x||h.some(B=>B.id===oe))return;const N=((D=pe[0])==null?void 0:D.id)??null;w(N),Xt(),i.startTransition(()=>{n(N?`/tasks/${N}`:"/",{state:null})})},[oe,Xt,ae,n,pe,h,x]),i.useEffect(()=>{xt&&ue(N=>!N||N.id!==xt.id?N:{...N,...xt})},[xt]),i.useEffect(()=>{if(oe)return l("task",N=>{const D=N.data.taskId;if(!(typeof D!="string"||D!==oe)){if(N.type==="task.output"){const B=N.data.event;if(B){be(ee=>xu(ee,B));const fe=Ht(B);fe&&ie(ee=>vu(ee,fe))}}N.type==="task.status"&&(Te(),Jt())}})},[l,oe,Te,Jt]),i.useEffect(()=>{var N;X==="transcript"&&((N=gs.current)==null||N.scrollIntoView({behavior:"smooth"}))},[we,Be,X]);const se=re??xt,Fl=se!=null&&se.assignedTo?(s==null?void 0:s.nodes.find(N=>N.id===se.assignedTo))??null:null,zn=Be.length>0,Bl=se?Vh.has(se.agent):!1,Hn=(se==null?void 0:se.status)==="running",Ul=se?at&&(Cn.has(se.status)||gl.has(se.status)):!1,Vl=!!(se&&at&&se.status==="failed"),Kn=i.useMemo(()=>Ax(se,s,zn,!!Hn),[se,s,zn,Hn]),Wl=i.useMemo(()=>bu(we),[we]),qn=i.useMemo(()=>yu([...we,...Be.map(N=>Yn(N.content,N.timestamp))]),[we,Be]),zl=i.useMemo(()=>{if(!se)return null;const N=Yd(se);if(N.length>0)return Yn(N,new Date(se.createdAt).toISOString());if(qn.length>0)return null;const D=Lt(se.description||se.title);return D.length>0?Yn(D,new Date(se.createdAt).toISOString()):null},[se,qn]),Gn=i.useCallback(()=>{const N={route:e?`/tasks/${e}`:"/",taskId:oe};Q(N),me(!0),i.startTransition(()=>{n("/",{state:{draftNewTask:!0,returnRoute:N.route,returnTaskId:N.taskId}})})},[e,oe,n]),Hl=i.useCallback(()=>{var D;const N=(M==null?void 0:M.taskId)??((D=pe[0])==null?void 0:D.id)??null;me(!1),Q(null),w(N),i.startTransition(()=>{n((M==null?void 0:M.route)??"/",{state:null})})},[M,pe,n]),bs=i.useCallback(N=>{me(!1),Q(null),w(N),i.startTransition(()=>{n(`/tasks/${N}`,{state:null})})},[n]),Kl=i.useCallback(N=>{me(!1),Q(null),g(D=>Ud(D,N)),ue(N),be([]),ie([]),ht(null),Yt(!1),de("transcript"),w(N.id),xe(),i.startTransition(()=>{n(`/tasks/${N.id}`,{state:null})})},[xe,n]),Zt=i.useCallback(async N=>{if(!oe)return!1;const D=`local-${Date.now()}-${Math.random().toString(16).slice(2)}`;ie(B=>[...B,{id:D,content:N,timestamp:new Date().toISOString()}]);try{return await Nc(oe,N),Te(),!0}catch(B){return ie(fe=>fe.filter(ee=>ee.id!==D)),he.error(B instanceof Error?B.message:"Failed to send message"),!1}},[oe,Te]),ql=i.useCallback(N=>{Zt(N)},[Zt]),Gl=i.useCallback(N=>Zt(N),[Zt]),Yl=i.useCallback(async()=>{if(se)try{await jc(se.id),Te(),xe()}catch(N){he.error(N instanceof Error?N.message:"Failed to cancel task")}},[se,Te,xe]),Xl=i.useCallback(async()=>{if(se)try{await Sc(se.id),Te(),xe()}catch(N){he.error(N instanceof Error?N.message:"Failed to retry task")}},[se,Te,xe]),Qt=i.useCallback((N,D=!1)=>{const B=Hd(Re,N);return w(B),(D||!B)&&Xt(),i.startTransition(()=>{n(B?`/tasks/${B}`:"/",{state:null})}),B},[Xt,Re,n]),Jl=i.useCallback((N,D)=>{ot(B=>{const fe=new Set(B);return D?fe.add(N):fe.delete(N),fe})},[]),Zl=i.useCallback(N=>{if(!N){ot(new Set);return}ot(new Set(Re.map(D=>D.id)))},[Re]),Ql=i.useCallback(async()=>{const N=Array.from(Ke);if(N.length!==0)try{const{results:D}=await kc(N),B=D.filter(ee=>!ee.ok),fe=D.filter(ee=>ee.ok).map(ee=>ee.id);oe&&fe.includes(oe)&&Qt(fe),B.length>0?he.error(`Failed to archive ${B.length} task(s): ${B.map(ee=>ee.error??ee.id).join(", ")}`):he.success(`Archived ${fe.length} task(s)`),ot(new Set(B.map(ee=>ee.id))),xe()}catch(D){he.error(D instanceof Error?D.message:"Failed to archive tasks")}},[oe,xe,Qt,Ke]),ec=i.useCallback(async()=>{const N=Array.from(Ke);if(N.length!==0)try{const{results:D}=await Cc(N),B=D.filter(ee=>!ee.ok),fe=D.filter(ee=>ee.ok).map(ee=>ee.id);oe&&fe.includes(oe)&&Qt(fe,!0),B.length>0?he.error(`Failed to delete ${B.length} task(s): ${B.map(ee=>ee.error??ee.id).join(", ")}`):he.success(`Deleted ${fe.length} task(s)`),ot(new Set(B.map(ee=>ee.id))),xe()}catch(D){he.error(D instanceof Error?D.message:"Failed to delete tasks")}},[oe,xe,Qt,Ke]),tc=i.useCallback(async()=>{ms(!0);try{await Ec(),u()}catch(N){he.error(N instanceof Error?N.message:"Failed to trigger election")}finally{ms(!1)}},[u]),nc=i.useCallback(async()=>{ps(!0);try{await Tc(),u()}catch(N){he.error(N instanceof Error?N.message:"Failed to promote node")}finally{ps(!1)}},[u]),rc=i.useCallback(async()=>{hs(!0);try{await Ac(),he.success("This node left the remote cluster and is leading itself again."),xe(),Te(),u()}catch(N){he.error(N instanceof Error?N.message:"Failed to leave cluster")}finally{hs(!1)}},[Te,xe,u]),sc=i.useCallback(async N=>{var ks;const D=!Lr(N),B=N.id===((ks=s==null?void 0:s.self)==null?void 0:ks.id),fe=B?(o==null?void 0:o.transportType)??N.transportType:N.transportType,ee=B&&!D&&At(fe);xs(N.id);try{ee?await Rc("direct"):await _c(N.id,D),he.success(D?`Enabled remote access on ${N.name}`:`Disabled remote access on ${N.name}`),u()}catch(Cs){he.error(Cs instanceof Error?Cs.message:"Failed to update remote access")}finally{xs(null)}},[(Ss=s==null?void 0:s.self)==null?void 0:Ss.id,u,o==null?void 0:o.transportType]),ys={toolbarTasks:Re,activeTaskId:oe,tasksLoading:x,tasksError:v,isLeader:at,scope:j,agentFilter:C,nodeFilter:T,agentOptions:Dl,nodeOptions:Ml,nodeNameById:vs,searchQuery:A,selectedTaskIds:Ke,allVisibleTasksSelected:Il,someVisibleTasksSelected:Ll,canBatchArchive:$l,onSearchChange:O,onScopeChange:k,onAgentFilterChange:S,onNodeFilterChange:R,onToggleTaskSelected:Jl,onToggleAllVisibleTasks:Zl,onBatchArchive:Ql,onBatchDelete:ec,onCreateTask:Gn,onSelectTask:bs,onClose:ce},ws={cluster:s,systemInfo:o,nodeNameById:vs,nodeBlockingTaskCounts:Pl,eventTypeFilter:q,onEventTypeFilterChange:J,eventTypeOptions:Wn,filteredEvents:Ol,sseConnected:c,clusterLoading:f,clusterError:d,electionPending:Tl,onTriggerElection:tc,promotePending:Al,onPromote:nc,onAddNode:()=>I(!0),leavePending:Rl,onLeaveCluster:rc,onToggleNodeDevTunnel:sc,devTunnelNodeId:_l,onClose:()=>te(!1)};return r.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden pb-2",children:[r.jsxs("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[r.jsx("div",{className:U("hidden lg:block lg:shrink-0 lg:transition-all lg:duration-300",W?"lg:mr-3 lg:w-[24rem]":"lg:w-0 lg:overflow-hidden"),children:W&&r.jsx(fo,{...ys})}),r.jsx("section",{ref:V,className:"min-h-0 min-w-0 flex-1",children:r.jsx(bx,{onToggleTasks:ce,desktopTasksOpen:W,mobileTasksPanelOpen:z,operationsOpen:_,onToggleOperations:()=>te(N=>!N),cluster:s,sseConnected:c,activeTab:X,setActiveTab:de,creatingTask:ae,activeTask:se,assignedNode:Fl,taskLoading:Cl,taskError:El,displayEvents:qn,hasUserMessageInLogs:Wl,initialPrompt:zl,supportsFollowUp:Bl,taskUnavailable:Kn.taskUnavailable,chatDisabled:Kn.chatDisabled,chatDisabledReason:Kn.chatDisabledReason,questionBypassEnabled:K,isRunning:!!Hn,hasPendingFollowUp:zn,canCancel:!!Ul,canRetry:!!Vl,onRetry:Xl,onCancel:Yl,onStartCreateTask:Gn,onCancelCreateTask:Hl,onCreateTask:Kl,onSendMessage:ql,onQuestionBypassChange:F,onSubmitQuestionResponse:Gl,messagesEndRef:gs})}),r.jsx("div",{className:U("hidden xl:block xl:shrink-0 xl:transition-all xl:duration-300",_?"xl:ml-3 xl:w-[26rem]":"xl:w-0 xl:overflow-hidden"),children:_&&r.jsx(co,{...ws})})]}),_&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Close operations panel",onClick:()=>te(!1),className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm xl:hidden"}),r.jsx("div",{ref:L,className:"fixed inset-y-0 right-0 z-40 w-full p-2 sm:max-w-sm sm:p-3 xl:hidden",children:r.jsx(co,{...ws})})]}),z&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Close task list",onClick:()=>E(!1),className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm lg:hidden"}),r.jsx("div",{ref:P,className:"fixed inset-y-0 left-0 z-40 w-full p-2 sm:max-w-sm sm:p-3 lg:hidden",children:r.jsx(fo,{...ys,onCreateTask:()=>{E(!1),Gn()},onSelectTask:N=>{E(!1),bs(N)},onClose:()=>E(!1)})})]}),r.jsx(Jf,{open:ne,onOpenChange:I,children:r.jsx(sm,{onAdded:()=>{I(!1),u()}})})]})}const Ux=Object.freeze(Object.defineProperty({__proto__:null,DashboardPage:$x},Symbol.toStringTag,{value:"Module"}));export{Mr as C,Jf as D,No as E,nd as F,fa as a,ha as b,Bx as c,Tt as d,Ux as e};