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.
- package/README.md +1 -1
- package/dashboard/assets/DashboardPage-BI_r0nXT.js +251 -0
- package/dashboard/assets/{DiffTab-BIU9YkOP.js → DiffTab-DDvHQmgo.js} +4 -4
- package/dashboard/assets/{FilesTab-DlIJQ12D.js → FilesTab-DVMAnAjC.js} +10 -10
- package/dashboard/assets/{PreviewTab-Czs-1ywX.js → PreviewTab-DYrIeJFR.js} +3 -3
- package/dashboard/assets/file-B6TrcVpl.js +6 -0
- package/dashboard/assets/index-CuMw5tL-.css +1 -0
- package/dashboard/assets/{index-vjxaNl7B.js → index-DduTnmHA.js} +3 -3
- package/dashboard/index.html +2 -2
- package/main.cjs +13158 -3851
- package/package.json +1 -1
- package/dashboard/assets/DashboardPage-9aRkE566.js +0 -210
- package/dashboard/assets/folder-D1IG8qWX.js +0 -11
- package/dashboard/assets/index-BzyFj1ix.css +0 -1
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-DlIJQ12D.js","assets/index-vjxaNl7B.js","assets/index-BzyFj1ix.css","assets/folder-D1IG8qWX.js","assets/PreviewTab-Czs-1ywX.js","assets/DiffTab-BIU9YkOP.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{c as ee,r as i,j as r,R as oo,a as zl,b as Nn,u as se,d as Hl,e as V,f as Kl,g as ql,h as Gl,B as je,i as K,k as it,l as ao,m as Yl,t as me,T as io,P as Xl,_ as Cr,n as Jl,N as lo,o as co,p as Zl,q as Ql,s as ec,v as tc,w as nc,x as rc,y as sc,z as oc,A as ac,C as ic,D as lc,E as cc,F as dc,G as uc,H as fc,I as mc,J as pc,K as hc}from"./index-vjxaNl7B.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 xc=[["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"}]],gc=ee("archive",xc);/**
|
|
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 vc=[["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"}]],kr=ee("bot",vc);/**
|
|
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 bc=[["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"}]],yc=ee("brain",bc);/**
|
|
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 wc=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Er=ee("check",wc);/**
|
|
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 Nc=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Ue=ee("chevron-down",Nc);/**
|
|
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 jc=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Bt=ee("chevron-right",jc);/**
|
|
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 Sc=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Tr=ee("chevron-up",Sc);/**
|
|
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 Cc=[["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"}]],kc=ee("circle-question-mark",Cc);/**
|
|
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 Ec=[["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"}]],uo=ee("circle-x",Ec);/**
|
|
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 Tc=[["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"}]],fo=ee("copy",Tc);/**
|
|
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 Ac=[["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"}]],mo=ee("external-link",Ac);/**
|
|
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 Rc=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],_c=ee("folder-open",Rc);/**
|
|
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 Pc=[["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"}]],Dc=ee("funnel",Pc);/**
|
|
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 Mc=[["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"}]],ar=ee("image-plus",Mc);/**
|
|
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 Ic=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ie=ee("loader-circle",Ic);/**
|
|
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 Oc=[["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"}]],po=ee("message-square-plus",Oc);/**
|
|
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 Lc=[["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"}]],ho=ee("panel-left-close",Lc);/**
|
|
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 $c=[["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"}]],Fc=ee("panel-left-open",$c);/**
|
|
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 Bc=[["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"}]],xo=ee("panel-right-close",Bc);/**
|
|
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 Uc=[["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"}]],Vc=ee("panel-right-open",Uc);/**
|
|
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 Wc=[["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"}]],zc=ee("pencil",Wc);/**
|
|
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 Hc=[["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"}]],Kc=ee("rotate-ccw",Hc);/**
|
|
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 qc=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],js=ee("search",qc);/**
|
|
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 Gc=[["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"}]],go=ee("send",Gc);/**
|
|
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 Yc=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Xc=ee("settings-2",Yc);/**
|
|
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 Jc=[["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"}]],Zc=ee("shield-check",Jc);/**
|
|
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 Qc=[["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"}]],ed=ee("trash-2",Qc);/**
|
|
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 td=[["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"}]],nd=ee("user",td);/**
|
|
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 rd=[["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"}]],sd=ee("wrench",rd);/**
|
|
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 od=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ar=ee("x",od);function Hn(e,t,n){const s=i.useRef(t);s.current=t,i.useEffect(()=>{let l=0,c=0;const d=m=>{const h=m.touches[0];h&&(l=h.clientX,c=h.clientY)},f=m=>{var p,v,b,y;const h=m.changedTouches[0];if(!h)return;const x=h.clientX-l;Math.abs(h.clientY-c)>100||Math.abs(x)<50||(x>0?(v=(p=s.current).onSwipeRight)==null||v.call(p):(y=(b=s.current).onSwipeLeft)==null||y.call(b))},u=(e==null?void 0:e.current)??document;return u.addEventListener("touchstart",d,{passive:!0}),u.addEventListener("touchend",f,{passive:!0}),()=>{u.removeEventListener("touchstart",d),u.removeEventListener("touchend",f)}},[e,n==null?void 0:n.threshold,n==null?void 0:n.maxVertical])}function Ss(e,t,n=30){const s=i.useRef(t);s.current=t,i.useEffect(()=>{let l=0,c=0,d=!1;const f=m=>{const h=m.touches[0];h&&(l=h.clientX,c=h.clientY,e==="left"?d=h.clientX<=n:d=h.clientX>=window.innerWidth-n)},u=m=>{if(!d)return;const h=m.changedTouches[0];if(!h)return;const x=h.clientX-l;Math.abs(h.clientY-c)>100||Math.abs(x)<50||(e==="left"&&x>0||e==="right"&&x<0)&&s.current()};return document.addEventListener("touchstart",f,{passive:!0}),document.addEventListener("touchend",u,{passive:!0}),()=>{document.removeEventListener("touchstart",f),document.removeEventListener("touchend",u)}},[e,n])}const ad=new Set(["assigned","running"]);function id(e,t){return e.reduce((n,s)=>s.assignedTo===t&&ad.has(s.status)?n+1:n,0)}function Et(e){return(e==null?void 0:e.toLowerCase())==="devtunnel"}function ld(e){return e?Et(e)?"DevTunnel":e.charAt(0).toUpperCase()+e.slice(1):"Direct"}function Rr(e,t){return Et(t??e.transportType)||!!e.devtunnelEndpoint}function vo(e,t){return!Et(t??e.transportType)}function bo(e,t){const n=t??e.transportType;return Et(n)?"DevTunnel":e.devtunnelEndpoint?"Direct + DevTunnel":ld(n)}function Cs(e,t){return!e&&!t}function cd({routeTaskId:e,creatingTask:t,internalSelectedTaskId:n,sortedTaskIds:s}){return e||(t?null:n??s[0]??null)}function dd(e,t){return[t,...e.filter(n=>n.id!==t.id)]}const ud=new Set(["completed","failed","cancelled","archived"]);function fd(e,t){const n=new Set(t);return new Set(Array.from(e).filter(s=>n.has(s)))}function md(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=>ud.has(o.status))}function pd(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 on(e){return typeof e=="object"&&e!==null}function hd(e){if(!on(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()}:{}}}return null}function xd(e){if(!on(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"||!on(e.source))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 It(e){if(typeof e=="string"){const t=e.trim();return t?[{type:"text",text:t}]:[]}return Array.isArray(e)?e.map(t=>hd(t)??xd(t)).filter(t=>t!==null):[]}function _r(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}:{type:"image",source:{type:"base64",media_type:t.mediaType,data:t.data}})}}function Kn(e,t=new Date().toISOString()){return{type:"user",message:gd(e),timestamp:t}}function Ut(e){if(e.type!=="user"||e.isSynthetic===!0)return null;if(typeof e.message=="string"){const t=It(e.message);return t.length>0?t:null}if(on(e.message)&&Array.isArray(e.message.content)){const t=It(e.message.content);return t.length>0?t:null}if(Array.isArray(e.content)){const t=It(e.content);return t.length>0?t:null}return null}function vd(e){return It(e.payload.initialMessage)}function Ot(e){return e.map(t=>{if(t.type==="text")return`t:${t.text}`;const n=t.data.slice(0,32),s=t.data.slice(-32);return`i:${t.mediaType}:${t.data.length}:${n}:${s}`}).join("|")}function bd(e){return e.filter(t=>t.type==="text").map(t=>t.text).join(`
|
|
153
|
-
`)}function Pr(e){return`data:${e.mediaType};base64,${e.data}`}function yd(e){var o,a;if(!e)return[];const t=[],n=e.items;if(n)for(const l of Array.from(n)){if((l==null?void 0:l.kind)!=="file"||!((o=l.type)!=null&&o.startsWith("image/")))continue;const c=(a=l.getAsFile)==null?void 0:a.call(l);c&&c.type.startsWith("image/")&&t.push(c)}if(t.length>0)return t;const s=e.files;return s?Array.from(s).filter(l=>l.type.startsWith("image/")):[]}function wd(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 ks(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 wd(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 Vt(e){return typeof e=="object"&&e!==null}function Nd(e){return Vt(e)&&typeof e.name=="string"&&e.name.toLowerCase()==="askuserquestion"}function jd(e){return!Vt(e)||typeof e.label!="string"||!e.label.trim()?null:{label:e.label.trim(),description:typeof e.description=="string"?e.description.trim():""}}function Sd(e){if(!Vt(e)||typeof e.question!="string"||!e.question.trim())return null;const t=Array.isArray(e.options)?e.options.map(jd).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 ir(e){if(!Vt(e)||!Array.isArray(e.questions))return null;const t=e.questions.map(Sd).filter(n=>n!==null);return t.length===0?null:{questions:t}}function Tt(e){return JSON.stringify(e)}function jn(e){const t=ir(e);if(t)return t;if(Nd(e)){const n=Vt(e.input)?e.input:void 0;return ir(n)}return null}function Cd(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 l=(o=a[1])==null?void 0:o.trim();l&&n.push(l)}return n}function Sn(e){for(const t of Cd(e))try{const n=JSON.parse(t),s=ir(n);if(s)return s}catch{}return null}function kd(e){return e.questions.map(t=>t.options.length>0?[0]:[])}function Ed(e,t){return e.questions.every((n,s)=>(t[s]??[]).length>0)}function Td(e,t){return e.questions.map((s,o)=>{const a=[...new Set(t[o]??[])].sort((l,c)=>l-c).filter(l=>s.options[l]!==void 0);return{header:s.header??null,question:s.question,multiSelect:s.multiSelect,selectedOptions:a.map(l=>s.options[l]).filter(l=>l!==void 0)}}).map(s=>{const o=s.header??s.question,a=s.selectedOptions.map(l=>l.label).join(s.multiSelect?", ":"");return`${o}: ${a}`}).join(`
|
|
154
|
-
`)}function yo(e){return Ut(e)!==null}function an(e){if(e.type==="user"){const t=Ut(e),n=typeof e.timestamp=="string"?e.timestamp:"";if(t)return`user:${n}:${Ot(t)}`}return JSON.stringify(e)}function lr(e){const t=jn(e);return t?Tt(t):null}function Es(e){if(!Array.isArray(e))return null;const t=new Set;for(const n of e){const s=lr(n);if(s){t.add(s);continue}if(typeof n=="object"&&n!==null&&n.type==="text"&&typeof n.text=="string"){const o=Sn(n.text);o&&t.add(Tt(o))}}return t.size===0?null:Array.from(t).sort().join("|")}function Ad(e){const t=lr(e);if(t)return t;if(typeof e.message=="string"){const n=Sn(e.message);return n?Tt(n):null}if(typeof e.message=="object"&&e.message!==null){const n=lr(e.message);return n||Es(e.message.content)}return Es(e.content)}function Rd(e,t,n){const s=typeof t.timestamp=="string"?t.timestamp:"";return`${e}-${s}-${n}`}function _d(e,t){const n=t.map(o=>({...o})),s=new Set(n.map(an));for(const o of e){const a=an(o);s.has(a)||(n.push(o),s.add(a))}return n}function Pd(e,t){const n=an(t);return e.some(s=>an(s)===n)?e:[...e,{...t}]}function Dd(e,t){const n=new Map;for(const s of t){const o=Ut(s);if(!o)continue;const a=Ot(o);n.set(a,(n.get(a)??0)+1)}return e.filter(s=>{const o=Ot(s.content),a=n.get(o)??0;return a<=0?!0:(n.set(o,a-1),!1)})}function Md(e,t){const n=Ot(t),s=e.findIndex(o=>Ot(o.content)===n);return s===-1?e:e.filter((o,a)=>a!==s)}function Id(e){return e.some(yo)}function Od(e){const t=[];let n=null;for(const s of e){if(yo(s)){n=null,t.push(s);continue}const o=Ad(s);o&&o===n||(t.push(s),o&&(n=o))}return t}function G(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 Ld(e,t){const n=i.createContext(t),s=a=>{const{children:l,...c}=a,d=i.useMemo(()=>c,Object.values(c));return r.jsx(n.Provider,{value:d,children:l})};s.displayName=e+"Provider";function o(a){const l=i.useContext(n);if(l)return l;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,l){const c=i.createContext(l),d=n.length;n=[...n,l];const f=m=>{var b;const{scope:h,children:x,...g}=m,p=((b=h==null?void 0:h[e])==null?void 0:b[d])||c,v=i.useMemo(()=>g,Object.values(g));return r.jsx(p.Provider,{value:v,children:x})};f.displayName=a+"Provider";function u(m,h){var p;const x=((p=h==null?void 0:h[e])==null?void 0:p[d])||c,g=i.useContext(x);if(g)return g;if(l!==void 0)return l;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[f,u]}const o=()=>{const a=n.map(l=>i.createContext(l));return function(c){const d=(c==null?void 0:c[e])||a;return i.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[s,$d(o,...t)]}function $d(...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 l=s.reduce((c,{useScope:d,scopeName:f})=>{const m=d(a)[`__scope${f}`];return{...c,...m}},{});return i.useMemo(()=>({[`__scope${t.scopeName}`]:l}),[l])}};return n.scopeName=t.scopeName,n}var ge=globalThis!=null&&globalThis.document?i.useLayoutEffect:()=>{},Fd=oo[" useId ".trim().toString()]||(()=>{}),Bd=0;function Xe(e){const[t,n]=i.useState(Fd());return ge(()=>{n(s=>s??String(Bd++))},[e]),e||(t?`radix-${t}`:"")}var Ud=oo[" useInsertionEffect ".trim().toString()]||ge;function Ct({prop:e,defaultProp:t,onChange:n=()=>{},caller:s}){const[o,a,l]=Vd({defaultProp:t,onChange:n}),c=e!==void 0,d=c?e:o;{const u=i.useRef(e!==void 0);i.useEffect(()=>{const m=u.current;m!==c&&console.warn(`${s} is changing from ${m?"controlled":"uncontrolled"} to ${c?"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.`),u.current=c},[c,s])}const f=i.useCallback(u=>{var m;if(c){const h=Wd(u)?u(e):u;h!==e&&((m=l.current)==null||m.call(l,h))}else a(u)},[c,e,a,l]);return[d,f]}function Vd({defaultProp:e,onChange:t}){const[n,s]=i.useState(e),o=i.useRef(n),a=i.useRef(t);return Ud(()=>{a.current=t},[t]),i.useEffect(()=>{var l;o.current!==n&&((l=a.current)==null||l.call(a,n),o.current=n)},[n,o]),[n,s,a]}function Wd(e){return typeof e=="function"}function Lt(e){const t=zd(e),n=i.forwardRef((s,o)=>{const{children:a,...l}=s,c=i.Children.toArray(a),d=c.find(Kd);if(d){const f=d.props.children,u=c.map(m=>m===d?i.Children.count(f)>1?i.Children.only(null):i.isValidElement(f)?f.props.children:null:m);return r.jsx(t,{...l,ref:o,children:i.isValidElement(f)?i.cloneElement(f,void 0,u):null})}return r.jsx(t,{...l,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function zd(e){const t=i.forwardRef((n,s)=>{const{children:o,...a}=n;if(i.isValidElement(o)){const l=Gd(o),c=qd(a,o.props);return o.type!==i.Fragment&&(c.ref=s?zl(s,l):l),i.cloneElement(o,c)}return i.Children.count(o)>1?i.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var wo=Symbol("radix.slottable");function Hd(e){const t=({children:n})=>r.jsx(r.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=wo,t}function Kd(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===wo}function qd(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]=(...c)=>{const d=a(...c);return o(...c),d}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function Gd(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 Yd=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],X=Yd.reduce((e,t)=>{const n=Lt(`Primitive.${t}`),s=i.forwardRef((o,a)=>{const{asChild:l,...c}=o,d=l?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function Xd(e,t){e&&Nn.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 Jd(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 Zd="DismissableLayer",cr="dismissableLayer.update",Qd="dismissableLayer.pointerDownOutside",eu="dismissableLayer.focusOutside",Ts,No=i.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Dr=i.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:l,onDismiss:c,...d}=e,f=i.useContext(No),[u,m]=i.useState(null),h=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,x]=i.useState({}),g=se(t,S=>m(S)),p=Array.from(f.layers),[v]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),b=p.indexOf(v),y=u?p.indexOf(u):-1,w=f.layersWithOutsidePointerEventsDisabled.size>0,j=y>=b,k=ru(S=>{const R=S.target,L=[...f.branches].some(B=>B.contains(R));!j||L||(o==null||o(S),l==null||l(S),S.defaultPrevented||c==null||c())},h),C=su(S=>{const R=S.target;[...f.branches].some(B=>B.contains(R))||(a==null||a(S),l==null||l(S),S.defaultPrevented||c==null||c())},h);return Jd(S=>{y===f.layers.size-1&&(s==null||s(S),!S.defaultPrevented&&c&&(S.preventDefault(),c()))},h),i.useEffect(()=>{if(u)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(Ts=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(u)),f.layers.add(u),As(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=Ts)}},[u,h,n,f]),i.useEffect(()=>()=>{u&&(f.layers.delete(u),f.layersWithOutsidePointerEventsDisabled.delete(u),As())},[u,f]),i.useEffect(()=>{const S=()=>x({});return document.addEventListener(cr,S),()=>document.removeEventListener(cr,S)},[]),r.jsx(X.div,{...d,ref:g,style:{pointerEvents:w?j?"auto":"none":void 0,...e.style},onFocusCapture:G(e.onFocusCapture,C.onFocusCapture),onBlurCapture:G(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:G(e.onPointerDownCapture,k.onPointerDownCapture)})});Dr.displayName=Zd;var tu="DismissableLayerBranch",nu=i.forwardRef((e,t)=>{const n=i.useContext(No),s=i.useRef(null),o=se(t,s);return i.useEffect(()=>{const a=s.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),r.jsx(X.div,{...e,ref:o})});nu.displayName=tu;function ru(e,t=globalThis==null?void 0:globalThis.document){const n=Qe(e),s=i.useRef(!1),o=i.useRef(()=>{});return i.useEffect(()=>{const a=c=>{if(c.target&&!s.current){let d=function(){jo(Qd,n,f,{discrete:!0})};const f={originalEvent:c};c.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=d,t.addEventListener("click",o.current,{once:!0})):d()}else t.removeEventListener("click",o.current);s.current=!1},l=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(l),t.removeEventListener("pointerdown",a),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>s.current=!0}}function su(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&&jo(eu,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 As(){const e=new CustomEvent(cr);document.dispatchEvent(e)}function jo(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?Xd(o,a):o.dispatchEvent(a)}var qn="focusScope.autoFocusOnMount",Gn="focusScope.autoFocusOnUnmount",Rs={bubbles:!1,cancelable:!0},ou="FocusScope",Mr=i.forwardRef((e,t)=>{const{loop:n=!1,trapped:s=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...l}=e,[c,d]=i.useState(null),f=Qe(o),u=Qe(a),m=i.useRef(null),h=se(t,p=>d(p)),x=i.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;i.useEffect(()=>{if(s){let p=function(w){if(x.paused||!c)return;const j=w.target;c.contains(j)?m.current=j:Ke(m.current,{select:!0})},v=function(w){if(x.paused||!c)return;const j=w.relatedTarget;j!==null&&(c.contains(j)||Ke(m.current,{select:!0}))},b=function(w){if(document.activeElement===document.body)for(const k of w)k.removedNodes.length>0&&Ke(c)};document.addEventListener("focusin",p),document.addEventListener("focusout",v);const y=new MutationObserver(b);return c&&y.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",v),y.disconnect()}}},[s,c,x.paused]),i.useEffect(()=>{if(c){Ps.add(x);const p=document.activeElement;if(!c.contains(p)){const b=new CustomEvent(qn,Rs);c.addEventListener(qn,f),c.dispatchEvent(b),b.defaultPrevented||(au(uu(So(c)),{select:!0}),document.activeElement===p&&Ke(c))}return()=>{c.removeEventListener(qn,f),setTimeout(()=>{const b=new CustomEvent(Gn,Rs);c.addEventListener(Gn,u),c.dispatchEvent(b),b.defaultPrevented||Ke(p??document.body,{select:!0}),c.removeEventListener(Gn,u),Ps.remove(x)},0)}}},[c,f,u,x]);const g=i.useCallback(p=>{if(!n&&!s||x.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]=iu(y);w&&j?!p.shiftKey&&b===j?(p.preventDefault(),n&&Ke(w,{select:!0})):p.shiftKey&&b===w&&(p.preventDefault(),n&&Ke(j,{select:!0})):b===y&&p.preventDefault()}},[n,s,x.paused]);return r.jsx(X.div,{tabIndex:-1,...l,ref:h,onKeyDown:g})});Mr.displayName=ou;function au(e,{select:t=!1}={}){const n=document.activeElement;for(const s of e)if(Ke(s,{select:t}),document.activeElement!==n)return}function iu(e){const t=So(e),n=_s(t,e),s=_s(t.reverse(),e);return[n,s]}function So(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 _s(e,t){for(const n of e)if(!lu(n,{upTo:t}))return n}function lu(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 cu(e){return e instanceof HTMLInputElement&&"select"in e}function Ke(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&cu(e)&&t&&e.select()}}var Ps=du();function du(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Ds(e,t),e.unshift(t)},remove(t){var n;e=Ds(e,t),(n=e[0])==null||n.resume()}}}function Ds(e,t){const n=[...e],s=n.indexOf(t);return s!==-1&&n.splice(s,1),n}function uu(e){return e.filter(t=>t.tagName!=="A")}var fu="Portal",Ir=i.forwardRef((e,t)=>{var c;const{container:n,...s}=e,[o,a]=i.useState(!1);ge(()=>a(!0),[]);const l=n||o&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return l?Hl.createPortal(r.jsx(X.div,{...s,ref:t}),l):null});Ir.displayName=fu;function mu(e,t){return i.useReducer((n,s)=>t[n][s]??n,e)}var At=e=>{const{present:t,children:n}=e,s=pu(t),o=typeof n=="function"?n({present:s.isPresent}):i.Children.only(n),a=se(s.ref,hu(o));return typeof n=="function"||s.isPresent?i.cloneElement(o,{ref:a}):null};At.displayName="Presence";function pu(e){const[t,n]=i.useState(),s=i.useRef(null),o=i.useRef(e),a=i.useRef("none"),l=e?"mounted":"unmounted",[c,d]=mu(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return i.useEffect(()=>{const f=Yt(s.current);a.current=c==="mounted"?f:"none"},[c]),ge(()=>{const f=s.current,u=o.current;if(u!==e){const h=a.current,x=Yt(f);e?d("MOUNT"):x==="none"||(f==null?void 0:f.display)==="none"?d("UNMOUNT"):d(u&&h!==x?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),ge(()=>{if(t){let f;const u=t.ownerDocument.defaultView??window,m=x=>{const p=Yt(s.current).includes(CSS.escape(x.animationName));if(x.target===t&&p&&(d("ANIMATION_END"),!o.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",f=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},h=x=>{x.target===t&&(a.current=Yt(s.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",m),t.addEventListener("animationend",m),()=>{u.clearTimeout(f),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",m),t.removeEventListener("animationend",m)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:i.useCallback(f=>{s.current=f?getComputedStyle(f):null,n(f)},[])}}function Yt(e){return(e==null?void 0:e.animationName)||"none"}function hu(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 Yn=0;function Co(){i.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Ms()),document.body.insertAdjacentElement("beforeend",e[1]??Ms()),Yn++,()=>{Yn===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Yn--}},[])}function Ms(){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 Me=function(){return Me=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},Me.apply(this,arguments)};function ko(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 xu(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 tn="right-scroll-bar-position",nn="width-before-scroll-bar",gu="with-scroll-bars-hidden",vu="--removed-body-scroll-bar-size";function Xn(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function bu(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 yu=typeof window<"u"?i.useLayoutEffect:i.useEffect,Is=new WeakMap;function wu(e,t){var n=bu(null,function(s){return e.forEach(function(o){return Xn(o,s)})});return yu(function(){var s=Is.get(n);if(s){var o=new Set(s),a=new Set(e),l=n.current;o.forEach(function(c){a.has(c)||Xn(c,null)}),a.forEach(function(c){o.has(c)||Xn(c,l)})}Is.set(n,e)},[e]),n}function Nu(e){return e}function ju(e,t){t===void 0&&(t=Nu);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 l=t(a,s);return n.push(l),function(){n=n.filter(function(c){return c!==l})}},assignSyncMedium:function(a){for(s=!0;n.length;){var l=n;n=[],l.forEach(a)}n={push:function(c){return a(c)},filter:function(){return n}}},assignMedium:function(a){s=!0;var l=[];if(n.length){var c=n;n=[],c.forEach(a),l=n}var d=function(){var u=l;l=[],u.forEach(a)},f=function(){return Promise.resolve().then(d)};f(),n={push:function(u){l.push(u),f()},filter:function(u){return l=l.filter(u),n}}}};return o}function Su(e){e===void 0&&(e={});var t=ju(null);return t.options=Me({async:!0,ssr:!1},e),t}var Eo=function(e){var t=e.sideCar,n=ko(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,Me({},n))};Eo.isSideCarExport=!0;function Cu(e,t){return e.useMedium(t),Eo}var To=Su(),Jn=function(){},Cn=i.forwardRef(function(e,t){var n=i.useRef(null),s=i.useState({onScrollCapture:Jn,onWheelCapture:Jn,onTouchMoveCapture:Jn}),o=s[0],a=s[1],l=e.forwardProps,c=e.children,d=e.className,f=e.removeScrollBar,u=e.enabled,m=e.shards,h=e.sideCar,x=e.noRelative,g=e.noIsolation,p=e.inert,v=e.allowPinchZoom,b=e.as,y=b===void 0?"div":b,w=e.gapMode,j=ko(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=h,C=wu([n,t]),S=Me(Me({},j),o);return i.createElement(i.Fragment,null,u&&i.createElement(k,{sideCar:To,removeScrollBar:f,shards:m,noRelative:x,noIsolation:g,inert:p,setCallbacks:a,allowPinchZoom:!!v,lockRef:n,gapMode:w}),l?i.cloneElement(i.Children.only(c),Me(Me({},S),{ref:C})):i.createElement(y,Me({},S,{className:d,ref:C}),c))});Cn.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Cn.classNames={fullWidth:nn,zeroRight:tn};var ku=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Eu(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=ku();return t&&e.setAttribute("nonce",t),e}function Tu(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Au(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Ru=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Eu())&&(Tu(t,n),Au(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},_u=function(){var e=Ru();return function(t,n){i.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Ao=function(){var e=_u(),t=function(n){var s=n.styles,o=n.dynamic;return e(s,o),null};return t},Pu={left:0,top:0,right:0,gap:0},Zn=function(e){return parseInt(e||"",10)||0},Du=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[Zn(n),Zn(s),Zn(o)]},Mu=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Pu;var t=Du(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])}},Iu=Ao(),Nt="data-scroll-locked",Ou=function(e,t,n,s){var o=e.left,a=e.top,l=e.right,c=e.gap;return n===void 0&&(n="margin"),`
|
|
155
|
-
.`.concat(gu,` {
|
|
156
|
-
overflow: hidden `).concat(s,`;
|
|
157
|
-
padding-right: `).concat(c,"px ").concat(s,`;
|
|
158
|
-
}
|
|
159
|
-
body[`).concat(Nt,`] {
|
|
160
|
-
overflow: hidden `).concat(s,`;
|
|
161
|
-
overscroll-behavior: contain;
|
|
162
|
-
`).concat([t&&"position: relative ".concat(s,";"),n==="margin"&&`
|
|
163
|
-
padding-left: `.concat(o,`px;
|
|
164
|
-
padding-top: `).concat(a,`px;
|
|
165
|
-
padding-right: `).concat(l,`px;
|
|
166
|
-
margin-left:0;
|
|
167
|
-
margin-top:0;
|
|
168
|
-
margin-right: `).concat(c,"px ").concat(s,`;
|
|
169
|
-
`),n==="padding"&&"padding-right: ".concat(c,"px ").concat(s,";")].filter(Boolean).join(""),`
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
.`).concat(tn,` {
|
|
173
|
-
right: `).concat(c,"px ").concat(s,`;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
.`).concat(nn,` {
|
|
177
|
-
margin-right: `).concat(c,"px ").concat(s,`;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
.`).concat(tn," .").concat(tn,` {
|
|
181
|
-
right: 0 `).concat(s,`;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
.`).concat(nn," .").concat(nn,` {
|
|
185
|
-
margin-right: 0 `).concat(s,`;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
body[`).concat(Nt,`] {
|
|
189
|
-
`).concat(vu,": ").concat(c,`px;
|
|
190
|
-
}
|
|
191
|
-
`)},Os=function(){var e=parseInt(document.body.getAttribute(Nt)||"0",10);return isFinite(e)?e:0},Lu=function(){i.useEffect(function(){return document.body.setAttribute(Nt,(Os()+1).toString()),function(){var e=Os()-1;e<=0?document.body.removeAttribute(Nt):document.body.setAttribute(Nt,e.toString())}},[])},$u=function(e){var t=e.noRelative,n=e.noImportant,s=e.gapMode,o=s===void 0?"margin":s;Lu();var a=i.useMemo(function(){return Mu(o)},[o]);return i.createElement(Iu,{styles:Ou(a,!t,o,n?"":"!important")})},dr=!1;if(typeof window<"u")try{var Xt=Object.defineProperty({},"passive",{get:function(){return dr=!0,!0}});window.addEventListener("test",Xt,Xt),window.removeEventListener("test",Xt,Xt)}catch{dr=!1}var vt=dr?{passive:!1}:!1,Fu=function(e){return e.tagName==="TEXTAREA"},Ro=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Fu(e)&&n[t]==="visible")},Bu=function(e){return Ro(e,"overflowY")},Uu=function(e){return Ro(e,"overflowX")},Ls=function(e,t){var n=t.ownerDocument,s=t;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var o=_o(e,s);if(o){var a=Po(e,s),l=a[1],c=a[2];if(l>c)return!0}s=s.parentNode}while(s&&s!==n.body);return!1},Vu=function(e){var t=e.scrollTop,n=e.scrollHeight,s=e.clientHeight;return[t,n,s]},Wu=function(e){var t=e.scrollLeft,n=e.scrollWidth,s=e.clientWidth;return[t,n,s]},_o=function(e,t){return e==="v"?Bu(t):Uu(t)},Po=function(e,t){return e==="v"?Vu(t):Wu(t)},zu=function(e,t){return e==="h"&&t==="rtl"?-1:1},Hu=function(e,t,n,s,o){var a=zu(e,window.getComputedStyle(t).direction),l=a*s,c=n.target,d=t.contains(c),f=!1,u=l>0,m=0,h=0;do{if(!c)break;var x=Po(e,c),g=x[0],p=x[1],v=x[2],b=p-v-a*g;(g||b)&&_o(e,c)&&(m+=b,h+=g);var y=c.parentNode;c=y&&y.nodeType===Node.DOCUMENT_FRAGMENT_NODE?y.host:y}while(!d&&c!==document.body||d&&(t.contains(c)||t===c));return(u&&Math.abs(m)<1||!u&&Math.abs(h)<1)&&(f=!0),f},Jt=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},$s=function(e){return[e.deltaX,e.deltaY]},Fs=function(e){return e&&"current"in e?e.current:e},Ku=function(e,t){return e[0]===t[0]&&e[1]===t[1]},qu=function(e){return`
|
|
192
|
-
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
193
|
-
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
194
|
-
`)},Gu=0,bt=[];function Yu(e){var t=i.useRef([]),n=i.useRef([0,0]),s=i.useRef(),o=i.useState(Gu++)[0],a=i.useState(Ao)[0],l=i.useRef(e);i.useEffect(function(){l.current=e},[e]),i.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var p=xu([e.lockRef.current],(e.shards||[]).map(Fs),!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 c=i.useCallback(function(p,v){if("touches"in p&&p.touches.length===2||p.type==="wheel"&&p.ctrlKey)return!l.current.allowPinchZoom;var b=Jt(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 R=window.getSelection(),L=R&&R.anchorNode,B=L?L===C||L.contains(C):!1;if(B)return!1;var O=Ls(S,C);if(!O)return!0;if(O?k=S:(k=S==="v"?"h":"v",O=Ls(S,C)),!O)return!1;if(!s.current&&"changedTouches"in p&&(w||j)&&(s.current=k),!k)return!0;var U=s.current||k;return Hu(U,v,p,U==="h"?w:j)},[]),d=i.useCallback(function(p){var v=p;if(!(!bt.length||bt[bt.length-1]!==a)){var b="deltaY"in v?$s(v):Jt(v),y=t.current.filter(function(k){return k.name===v.type&&(k.target===v.target||v.target===k.shadowParent)&&Ku(k.delta,b)})[0];if(y&&y.should){v.cancelable&&v.preventDefault();return}if(!y){var w=(l.current.shards||[]).map(Fs).filter(Boolean).filter(function(k){return k.contains(v.target)}),j=w.length>0?c(v,w[0]):!l.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:Xu(b)};t.current.push(w),setTimeout(function(){t.current=t.current.filter(function(j){return j!==w})},1)},[]),u=i.useCallback(function(p){n.current=Jt(p),s.current=void 0},[]),m=i.useCallback(function(p){f(p.type,$s(p),p.target,c(p,e.lockRef.current))},[]),h=i.useCallback(function(p){f(p.type,Jt(p),p.target,c(p,e.lockRef.current))},[]);i.useEffect(function(){return bt.push(a),e.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:h}),document.addEventListener("wheel",d,vt),document.addEventListener("touchmove",d,vt),document.addEventListener("touchstart",u,vt),function(){bt=bt.filter(function(p){return p!==a}),document.removeEventListener("wheel",d,vt),document.removeEventListener("touchmove",d,vt),document.removeEventListener("touchstart",u,vt)}},[]);var x=e.removeScrollBar,g=e.inert;return i.createElement(i.Fragment,null,g?i.createElement(a,{styles:qu(o)}):null,x?i.createElement($u,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Xu(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Ju=Cu(To,Yu);var Or=i.forwardRef(function(e,t){return i.createElement(Cn,Me({},e,{ref:t,sideCar:Ju}))});Or.classNames=Cn.classNames;var Zu=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},yt=new WeakMap,Zt=new WeakMap,Qt={},Qn=0,Do=function(e){return e&&(e.host||Do(e.parentNode))},Qu=function(e,t){return t.map(function(n){if(e.contains(n))return n;var s=Do(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})},ef=function(e,t,n,s){var o=Qu(t,Array.isArray(e)?e:[e]);Qt[n]||(Qt[n]=new WeakMap);var a=Qt[n],l=[],c=new Set,d=new Set(o),f=function(m){!m||c.has(m)||(c.add(m),f(m.parentNode))};o.forEach(f);var u=function(m){!m||d.has(m)||Array.prototype.forEach.call(m.children,function(h){if(c.has(h))u(h);else try{var x=h.getAttribute(s),g=x!==null&&x!=="false",p=(yt.get(h)||0)+1,v=(a.get(h)||0)+1;yt.set(h,p),a.set(h,v),l.push(h),p===1&&g&&Zt.set(h,!0),v===1&&h.setAttribute(n,"true"),g||h.setAttribute(s,"true")}catch(b){console.error("aria-hidden: cannot operate on ",h,b)}})};return u(t),c.clear(),Qn++,function(){l.forEach(function(m){var h=yt.get(m)-1,x=a.get(m)-1;yt.set(m,h),a.set(m,x),h||(Zt.has(m)||m.removeAttribute(s),Zt.delete(m)),x||m.removeAttribute(n)}),Qn--,Qn||(yt=new WeakMap,yt=new WeakMap,Zt=new WeakMap,Qt={})}},Mo=function(e,t,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(e)?e:[e]),o=Zu(e);return o?(s.push.apply(s,Array.from(o.querySelectorAll("[aria-live], script"))),ef(s,o,n,"aria-hidden")):function(){return null}},kn="Dialog",[Io,Oo]=nt(kn),[tf,De]=Io(kn),Lo=e=>{const{__scopeDialog:t,children:n,open:s,defaultOpen:o,onOpenChange:a,modal:l=!0}=e,c=i.useRef(null),d=i.useRef(null),[f,u]=Ct({prop:s,defaultProp:o??!1,onChange:a,caller:kn});return r.jsx(tf,{scope:t,triggerRef:c,contentRef:d,contentId:Xe(),titleId:Xe(),descriptionId:Xe(),open:f,onOpenChange:u,onOpenToggle:i.useCallback(()=>u(m=>!m),[u]),modal:l,children:n})};Lo.displayName=kn;var $o="DialogTrigger",Fo=i.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=De($o,n),a=se(t,o.triggerRef);return r.jsx(X.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Fr(o.open),...s,ref:a,onClick:G(e.onClick,o.onOpenToggle)})});Fo.displayName=$o;var Lr="DialogPortal",[nf,Bo]=Io(Lr,{forceMount:void 0}),Uo=e=>{const{__scopeDialog:t,forceMount:n,children:s,container:o}=e,a=De(Lr,t);return r.jsx(nf,{scope:t,forceMount:n,children:i.Children.map(s,l=>r.jsx(At,{present:n||a.open,children:r.jsx(Ir,{asChild:!0,container:o,children:l})}))})};Uo.displayName=Lr;var ln="DialogOverlay",Vo=i.forwardRef((e,t)=>{const n=Bo(ln,e.__scopeDialog),{forceMount:s=n.forceMount,...o}=e,a=De(ln,e.__scopeDialog);return a.modal?r.jsx(At,{present:s||a.open,children:r.jsx(sf,{...o,ref:t})}):null});Vo.displayName=ln;var rf=Lt("DialogOverlay.RemoveScroll"),sf=i.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=De(ln,n);return r.jsx(Or,{as:rf,allowPinchZoom:!0,shards:[o.contentRef],children:r.jsx(X.div,{"data-state":Fr(o.open),...s,ref:t,style:{pointerEvents:"auto",...s.style}})})}),ut="DialogContent",Wo=i.forwardRef((e,t)=>{const n=Bo(ut,e.__scopeDialog),{forceMount:s=n.forceMount,...o}=e,a=De(ut,e.__scopeDialog);return r.jsx(At,{present:s||a.open,children:a.modal?r.jsx(of,{...o,ref:t}):r.jsx(af,{...o,ref:t})})});Wo.displayName=ut;var of=i.forwardRef((e,t)=>{const n=De(ut,e.__scopeDialog),s=i.useRef(null),o=se(t,n.contentRef,s);return i.useEffect(()=>{const a=s.current;if(a)return Mo(a)},[]),r.jsx(zo,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:G(e.onCloseAutoFocus,a=>{var l;a.preventDefault(),(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:G(e.onPointerDownOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0;(l.button===2||c)&&a.preventDefault()}),onFocusOutside:G(e.onFocusOutside,a=>a.preventDefault())})}),af=i.forwardRef((e,t)=>{const n=De(ut,e.__scopeDialog),s=i.useRef(!1),o=i.useRef(!1);return r.jsx(zo,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var l,c;(l=e.onCloseAutoFocus)==null||l.call(e,a),a.defaultPrevented||(s.current||(c=n.triggerRef.current)==null||c.focus(),a.preventDefault()),s.current=!1,o.current=!1},onInteractOutside:a=>{var d,f;(d=e.onInteractOutside)==null||d.call(e,a),a.defaultPrevented||(s.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const l=a.target;((f=n.triggerRef.current)==null?void 0:f.contains(l))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),zo=i.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:a,...l}=e,c=De(ut,n),d=i.useRef(null),f=se(t,d);return Co(),r.jsxs(r.Fragment,{children:[r.jsx(Mr,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:o,onUnmountAutoFocus:a,children:r.jsx(Dr,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Fr(c.open),...l,ref:f,onDismiss:()=>c.onOpenChange(!1)})}),r.jsxs(r.Fragment,{children:[r.jsx(cf,{titleId:c.titleId}),r.jsx(uf,{contentRef:d,descriptionId:c.descriptionId})]})]})}),$r="DialogTitle",Ho=i.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=De($r,n);return r.jsx(X.h2,{id:o.titleId,...s,ref:t})});Ho.displayName=$r;var Ko="DialogDescription",qo=i.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=De(Ko,n);return r.jsx(X.p,{id:o.descriptionId,...s,ref:t})});qo.displayName=Ko;var Go="DialogClose",Yo=i.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=De(Go,n);return r.jsx(X.button,{type:"button",...s,ref:t,onClick:G(e.onClick,()=>o.onOpenChange(!1))})});Yo.displayName=Go;function Fr(e){return e?"open":"closed"}var Xo="DialogTitleWarning",[lf,Jo]=Ld(Xo,{contentName:ut,titleName:$r,docsSlug:"dialog"}),cf=({titleId:e})=>{const t=Jo(Xo),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
195
|
-
|
|
196
|
-
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
197
|
-
|
|
198
|
-
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},df="DialogDescriptionWarning",uf=({contentRef:e,descriptionId:t})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Jo(df).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},Zo=Lo,ff=Fo,Qo=Uo,Br=Vo,Ur=Wo,Vr=Ho,Wr=qo,En=Yo;const mf=Zo,pf=Qo,Mh=En,ea=i.forwardRef(({className:e,...t},n)=>r.jsx(Br,{ref:n,className:V("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}));ea.displayName=Br.displayName;const ta=i.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(pf,{children:[r.jsx(ea,{}),r.jsxs(Ur,{ref:s,className:V("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(En,{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(Ar,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ta.displayName=Ur.displayName;const na=({className:e,...t})=>r.jsx("div",{className:V("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});na.displayName="DialogHeader";const ra=({className:e,...t})=>r.jsx("div",{className:V("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});ra.displayName="DialogFooter";const sa=i.forwardRef(({className:e,...t},n)=>r.jsx(Vr,{ref:n,className:V("text-lg font-semibold leading-none tracking-tight",e),...t}));sa.displayName=Vr.displayName;const hf=i.forwardRef(({className:e,...t},n)=>r.jsx(Wr,{ref:n,className:V("text-sm text-muted-foreground",e),...t}));hf.displayName=Wr.displayName;const ct=i.forwardRef(({className:e,type:t,...n},s)=>r.jsx("input",{type:t,className:V("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 xf=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],gf=xf.reduce((e,t)=>{const n=Kl(`Primitive.${t}`),s=i.forwardRef((o,a)=>{const{asChild:l,...c}=o,d=l?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),vf="Label",oa=i.forwardRef((e,t)=>r.jsx(gf.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())}}));oa.displayName=vf;var aa=oa;const bf=ql("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),qe=i.forwardRef(({className:e,...t},n)=>r.jsx(aa,{ref:n,className:V(bf(),e),...t}));qe.displayName=aa.displayName;function yf({onAdded:e}){const[t,n]=i.useState(""),[s,o]=i.useState(!1),[a,l]=i.useState(null),c=i.useCallback(async d=>{if(d.preventDefault(),!!t.trim()){o(!0),l(null);try{await Gl({leaderEndpoint:t.trim(),transport:"devtunnel"}),e()}catch(f){l(f instanceof Error?f.message:"Failed to join node")}finally{o(!1)}}},[t,e]);return r.jsx(ta,{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(na,{className:"space-y-2 text-left",children:[r.jsx(sa,{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:c,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(qe,{htmlFor:"leader-endpoint",children:"Leader endpoint"}),r.jsx(je,{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:d=>n(d.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(ra,{className:"border-t border-border/60 pt-4",children:r.jsx(K,{type:"submit",disabled:!t.trim()||s,className:"rounded-2xl",children:s?"Joining...":"Join node"})})]})]})})}function ia(){const[e,t]=i.useState([]),[n,s]=i.useState(null),o=i.useRef(null),a=i.useCallback(()=>{var u;(u=o.current)==null||u.click()},[]),l=i.useCallback(async u=>{const m=Array.from(u.target.files??[]);if(m.length!==0)try{const h=await ks(m);t(x=>[...x,...h]),s(null)}catch(h){s(h instanceof Error?h.message:"Failed to attach image")}finally{u.target.value=""}},[]),c=i.useCallback(async u=>{const m=yd(u.clipboardData);if(m.length!==0){u.preventDefault();try{const h=await ks(m);t(x=>[...x,...h]),s(null)}catch(h){s(h instanceof Error?h.message:"Failed to attach image")}}},[]),d=i.useCallback(u=>{t(m=>m.filter((h,x)=>x!==u))},[]),f=i.useCallback(()=>{t([]),s(null)},[]);return{images:e,error:n,fileInputRef:o,pickImages:a,handleFileChange:l,handlePaste:c,removeImage:d,clearImages:f}}function wf({onSend:e,disabled:t,disabledReason:n="Chat is waiting on the agent.",placeholder:s="Send a follow-up message...",contextItems:o=[]}){const[a,l]=i.useState(""),c=i.useRef(null),{images:d,error:f,fileInputRef:u,pickImages:m,handleFileChange:h,handlePaste:x,removeImage:g,clearImages:p}=ia(),v=i.useCallback(()=>{c.current&&(c.current.style.height="auto")},[]),b=i.useCallback(()=>{const C=_r(a,d);C.length===0||t||(e(C),l(""),p(),v())},[a,d,t,e,p,v]),y=i.useCallback(C=>{C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),b())},[b]),w=i.useCallback(()=>{c.current&&(c.current.style.height="auto",c.current.style.height=`${Math.min(c.current.scrollHeight,220)}px`)},[]),j=!t&&(a.trim().length>0||d.length>0),k=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(C=>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:C.label}),r.jsx("span",{className:`truncate text-foreground/90 ${C.mono?"font-mono text-[11px]":""}`,children:C.value})]},`${C.label}:${C.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:u,type:"file",accept:"image/*",multiple:!0,onChange:h,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((C,S)=>r.jsxs("div",{className:"relative",children:[r.jsx("img",{src:Pr(C),alt:C.filename??`attachment ${S+1}`,className:"h-24 w-24 rounded-[22px] border border-border/70 object-cover"}),r.jsx("button",{type:"button",onClick:()=>g(S),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 ${C.filename??`image ${S+1}`}`,children:r.jsx(Ar,{className:"h-3.5 w-3.5"})})]},`${C.filename??"image"}-${S}`))})}),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:c,value:a,onChange:C=>l(C.target.value),onKeyDown:y,onPaste:x,onInput:w,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(K,{type:"button",variant:"ghost",onClick:m,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(ar,{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:k,children:r.jsx(K,{onClick:b,disabled:!j,size:"icon",className:"mb-0.5 h-9 w-9 shrink-0 rounded-full bg-primary/85 text-primary-foreground shadow-sm hover:bg-primary",children:r.jsx(go,{className:"h-4 w-4"})})})]}),f&&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:f})]})]})}function $t({payload:e,disabled:t=!1,bypassEnabled:n=!1,onBypassChange:s,onSubmit:o}){const[a,l]=i.useState(()=>n?kd(e):e.questions.map(()=>[])),[c,d]=i.useState(!1),[f,u]=i.useState(!1);i.useEffect(()=>{n&&l(g=>g.map((p,v)=>{var b;return p.length>0?p:(b=e.questions[v])!=null&&b.options.length?[0]:[]}))},[n,e]);const m=Ed(e,a)&&!t&&!c&&!f&&!!o,h=(g,p)=>{t||f||c||l(v=>v.map((b,y)=>{if(y!==g)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}))},x=async()=>{if(!m||!o)return;d(!0);const g=await o(Td(e,a));d(!1),g&&u(!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(kc,{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(K,{type:"button",variant:n?"secondary":"outline",size:"sm",onClick:()=>s==null?void 0:s(!n),className:"rounded-full",children:[r.jsx(Zc,{className:"h-4 w-4"}),n?"Bypass on":"Bypass future questions"]})]}),r.jsx("div",{className:"mt-4 space-y-4",children:e.questions.map((g,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:[g.header&&r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-muted-foreground",children:g.header}),r.jsx("div",{className:"mt-1 text-sm font-medium leading-6 text-foreground",children:g.question}),r.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:g.multiSelect?"Select one or more options.":"Select one option."})]}),r.jsx("div",{className:"space-y-2",children:g.options.map((b,y)=>{const w=v.includes(y);return r.jsxs("button",{type:"button",onClick:()=>h(p,y),disabled:t||c||f,"aria-pressed":w,className:V("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:V("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(Er,{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}`)})})]},`${g.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(K,{type:"button",onClick:()=>void x(),disabled:!m,className:"rounded-full px-5",children:f?"Sent":c?"Sending...":e.questions.length>1?"Send answers":"Send answer"})]})]})}function Bs({event:e,questionBypassEnabled:t=!1,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o=!1}){const a=e.type,l=jn(e);if(l)return r.jsx(ur,{children:r.jsx($t,{payload:l,bypassEnabled:t,onBypassChange:n,onSubmit:s,disabled:o})});if(a==="user"){const c=Ut(e);return c?r.jsx(Nf,{content:c}):null}return a==="assistant"?r.jsx(jf,{event:e,questionBypassEnabled:t,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o}):null}function Us(e){var n;const t=e.replace(/\r\n/g,`
|
|
199
|
-
`).split(`
|
|
200
|
-
`);for(;t.length>0&&((n=t[0])==null?void 0:n.trim())==="";)t.shift();return t.join(`
|
|
201
|
-
`)}function Nf({content:e}){const t=bd(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-sm leading-6 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:Pr(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(nd,{className:"h-4 w-4"})})]})})}function ur({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(kr,{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 jf({event:e,questionBypassEnabled:t,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o}){const a=e.message;if(!a)return null;const l=jn(a);if(l)return r.jsx(ur,{children:r.jsx($t,{payload:l,bypassEnabled:t,onBypassChange:n,onSubmit:s,disabled:o})});const c=a.content;if(!c||!Array.isArray(c))return null;const d=new Set,f=c.filter(g=>g.type==="text").map(g=>({...g,text:Us(String(g.text??"")),questionPayload:Sn(Us(String(g.text??"")))})).filter(g=>g.text.length>0||g.questionPayload),u=c.filter(g=>g.type==="thinking"),m=c.filter(g=>g.type==="tool_use"),h=c.filter(g=>g.type==="tool_result");return f.length>0||u.length>0||m.length>0||h.length>0?r.jsxs(ur,{children:[u.length>0&&r.jsx(Sf,{text:u.map(g=>String(g.thinking??"")).join(`
|
|
202
|
-
`)}),f.map((g,p)=>{if(g.questionPayload){const v=Tt(g.questionPayload);return d.has(v)?null:(d.add(v),r.jsx($t,{payload:g.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-sm leading-6 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:g.text})},p)}),m.map((g,p)=>r.jsx(Cf,{block:g,renderedQuestionSignatures:d,questionBypassEnabled:t,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o},p)),h.map((g,p)=>r.jsx(kf,{block:g,renderedQuestionSignatures:d,questionBypassEnabled:t,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o},p))]}):null}function Sf({text:e}){const[t,n]=i.useState(!1);return r.jsx("div",{className:"rounded-[22px] border border-border/60 bg-muted/35 px-4 py-3",children:r.jsxs("button",{type:"button",onClick:()=>n(s=>!s),className:"flex w-full items-start gap-2 text-left text-xs text-muted-foreground transition-colors hover:text-foreground",children:[r.jsx(yc,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-1 font-medium uppercase tracking-[0.18em]",children:[t?r.jsx(Ue,{className:"h-3 w-3"}):r.jsx(Bt,{className:"h-3 w-3"}),"Thinking"]}),t&&r.jsx("div",{className:"mt-2 whitespace-pre-wrap text-sm leading-6 text-muted-foreground/90",children:e})]})]})})}function Cf({block:e,renderedQuestionSignatures:t,questionBypassEnabled:n,onQuestionBypassChange:s,onSubmitQuestionResponse:o,questionResponseDisabled:a}){const[l,c]=i.useState(!1),d=String(e.name??"tool"),f=e.input,u=jn(e);if(u){const m=Tt(u);return t!=null&&t.has(m)?null:(t==null||t.add(m),r.jsx($t,{payload:u,bypassEnabled:n,onBypassChange:s,onSubmit:o,disabled:a}))}return r.jsxs("div",{className:"overflow-hidden rounded-[22px] border border-border/60 bg-muted/25",children:[r.jsxs("button",{type:"button",onClick:()=>c(m=>!m),className:"flex w-full items-center gap-2 px-4 py-3 text-left text-xs text-muted-foreground transition-colors hover:bg-muted/40 hover:text-foreground",children:[r.jsx(sd,{className:"h-3.5 w-3.5 shrink-0"}),r.jsx("span",{className:"font-mono text-[11px]",children:d}),l?r.jsx(Ue,{className:"ml-auto h-3.5 w-3.5"}):r.jsx(Bt,{className:"ml-auto h-3.5 w-3.5"})]}),l&&f&&r.jsx("div",{className:"border-t border-border/60 px-4 py-3",children:r.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap text-xs leading-5 text-muted-foreground",children:JSON.stringify(f,null,2)})})]})}function kf({block:e,renderedQuestionSignatures:t,questionBypassEnabled:n,onQuestionBypassChange:s,onSubmitQuestionResponse:o,questionResponseDisabled:a}){const[l,c]=i.useState(!1),d=e.content,f=typeof d=="string"?d:Array.isArray(d)?d.map(h=>String(h.text??"")).join(`
|
|
203
|
-
`):"";if(!f)return null;const u=Sn(f);if(u){const h=Tt(u);return t!=null&&t.has(h)?null:(t==null||t.add(h),r.jsx($t,{payload:u,bypassEnabled:n,onBypassChange:s,onSubmit:o,disabled:a}))}const m=f.length>132?`${f.slice(0,129)}...`:f;return r.jsxs("div",{className:"overflow-hidden rounded-[22px] border border-border/60 bg-background/65",children:[r.jsxs("button",{type:"button",onClick:()=>c(h=>!h),className:"flex w-full items-start gap-2 px-4 py-3 text-left text-xs text-muted-foreground transition-colors hover:bg-muted/35 hover:text-foreground",children:[r.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 font-medium uppercase tracking-[0.18em]",children:"Result"}),r.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[11px]",children:m}),l?r.jsx(Ue,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}):r.jsx(Bt,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"})]}),l&&r.jsx("div",{className:"border-t border-border/60 px-4 py-3",children:r.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap text-xs leading-5 text-muted-foreground",children:f})})]})}function la(e){const t=e+"CollectionProvider",[n,s]=nt(t),[o,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),l=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})};l.displayName=t;const c=e+"CollectionSlot",d=Lt(c),f=it.forwardRef((p,v)=>{const{scope:b,children:y}=p,w=a(c,b),j=se(v,w.collectionRef);return r.jsx(d,{ref:j,children:y})});f.displayName=c;const u=e+"CollectionItemSlot",m="data-radix-collection-item",h=Lt(u),x=it.forwardRef((p,v)=>{const{scope:b,children:y,...w}=p,j=it.useRef(null),k=se(v,j),C=a(u,b);return it.useEffect(()=>(C.itemMap.set(j,{ref:j,...w}),()=>void C.itemMap.delete(j))),r.jsx(h,{[m]:"",ref:k,children:y})});x.displayName=u;function g(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:l,Slot:f,ItemSlot:x},g,s]}var Ef=i.createContext(void 0);function zr(e){const t=i.useContext(Ef);return e||t||"ltr"}var er="rovingFocusGroup.onEntryFocus",Tf={bubbles:!1,cancelable:!0},Wt="RovingFocusGroup",[fr,ca,Af]=la(Wt),[Rf,da]=nt(Wt,[Af]),[_f,Pf]=Rf(Wt),ua=i.forwardRef((e,t)=>r.jsx(fr.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(fr.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Df,{...e,ref:t})})}));ua.displayName=Wt;var Df=i.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:o=!1,dir:a,currentTabStopId:l,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:f,preventScrollOnEntryFocus:u=!1,...m}=e,h=i.useRef(null),x=se(t,h),g=zr(a),[p,v]=Ct({prop:l,defaultProp:c??null,onChange:d,caller:Wt}),[b,y]=i.useState(!1),w=Qe(f),j=ca(n),k=i.useRef(!1),[C,S]=i.useState(0);return i.useEffect(()=>{const R=h.current;if(R)return R.addEventListener(er,w),()=>R.removeEventListener(er,w)},[w]),r.jsx(_f,{scope:n,orientation:s,dir:g,loop:o,currentTabStopId:p,onItemFocus:i.useCallback(R=>v(R),[v]),onItemShiftTab:i.useCallback(()=>y(!0),[]),onFocusableItemAdd:i.useCallback(()=>S(R=>R+1),[]),onFocusableItemRemove:i.useCallback(()=>S(R=>R-1),[]),children:r.jsx(X.div,{tabIndex:b||C===0?-1:0,"data-orientation":s,...m,ref:x,style:{outline:"none",...e.style},onMouseDown:G(e.onMouseDown,()=>{k.current=!0}),onFocus:G(e.onFocus,R=>{const L=!k.current;if(R.target===R.currentTarget&&L&&!b){const B=new CustomEvent(er,Tf);if(R.currentTarget.dispatchEvent(B),!B.defaultPrevented){const O=j().filter(P=>P.focusable),U=O.find(P=>P.active),$=O.find(P=>P.id===p),H=[U,$,...O].filter(Boolean).map(P=>P.ref.current);pa(H,u)}}k.current=!1}),onBlur:G(e.onBlur,()=>y(!1))})})}),fa="RovingFocusGroupItem",ma=i.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:o=!1,tabStopId:a,children:l,...c}=e,d=Xe(),f=a||d,u=Pf(fa,n),m=u.currentTabStopId===f,h=ca(n),{onFocusableItemAdd:x,onFocusableItemRemove:g,currentTabStopId:p}=u;return i.useEffect(()=>{if(s)return x(),()=>g()},[s,x,g]),r.jsx(fr.ItemSlot,{scope:n,id:f,focusable:s,active:o,children:r.jsx(X.span,{tabIndex:m?0:-1,"data-orientation":u.orientation,...c,ref:t,onMouseDown:G(e.onMouseDown,v=>{s?u.onItemFocus(f):v.preventDefault()}),onFocus:G(e.onFocus,()=>u.onItemFocus(f)),onKeyDown:G(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){u.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const b=Of(v,u.orientation,u.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=u.loop?Lf(w,j+1):w.slice(j+1)}setTimeout(()=>pa(w))}}),children:typeof l=="function"?l({isCurrentTabStop:m,hasTabStop:p!=null}):l})})});ma.displayName=fa;var Mf={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function If(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Of(e,t,n){const s=If(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return Mf[s]}function pa(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function Lf(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var $f=ua,Ff=ma,Tn="Tabs",[Bf]=nt(Tn,[da]),ha=da(),[Uf,Hr]=Bf(Tn),xa=i.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:o,defaultValue:a,orientation:l="horizontal",dir:c,activationMode:d="automatic",...f}=e,u=zr(c),[m,h]=Ct({prop:s,onChange:o,defaultProp:a??"",caller:Tn});return r.jsx(Uf,{scope:n,baseId:Xe(),value:m,onValueChange:h,orientation:l,dir:u,activationMode:d,children:r.jsx(X.div,{dir:u,"data-orientation":l,...f,ref:t})})});xa.displayName=Tn;var ga="TabsList",va=i.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...o}=e,a=Hr(ga,n),l=ha(n);return r.jsx($f,{asChild:!0,...l,orientation:a.orientation,dir:a.dir,loop:s,children:r.jsx(X.div,{role:"tablist","aria-orientation":a.orientation,...o,ref:t})})});va.displayName=ga;var ba="TabsTrigger",ya=i.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,disabled:o=!1,...a}=e,l=Hr(ba,n),c=ha(n),d=ja(l.baseId,s),f=Sa(l.baseId,s),u=s===l.value;return r.jsx(Ff,{asChild:!0,...c,focusable:!o,active:u,children:r.jsx(X.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":f,"data-state":u?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:d,...a,ref:t,onMouseDown:G(e.onMouseDown,m=>{!o&&m.button===0&&m.ctrlKey===!1?l.onValueChange(s):m.preventDefault()}),onKeyDown:G(e.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&l.onValueChange(s)}),onFocus:G(e.onFocus,()=>{const m=l.activationMode!=="manual";!u&&!o&&m&&l.onValueChange(s)})})})});ya.displayName=ba;var wa="TabsContent",Na=i.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,forceMount:o,children:a,...l}=e,c=Hr(wa,n),d=ja(c.baseId,s),f=Sa(c.baseId,s),u=s===c.value,m=i.useRef(u);return i.useEffect(()=>{const h=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(h)},[]),r.jsx(At,{present:o||u,children:({present:h})=>r.jsx(X.div,{"data-state":u?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":d,hidden:!h,id:f,tabIndex:0,...l,ref:t,style:{...e.style,animationDuration:m.current?"0s":void 0},children:h&&a})})});Na.displayName=wa;function ja(e,t){return`${e}-trigger-${t}`}function Sa(e,t){return`${e}-content-${t}`}var Vf=xa,Ca=va,ka=ya,Ea=Na;const Ta=Vf,Kr=i.forwardRef(({className:e,...t},n)=>r.jsx(Ca,{ref:n,className:V("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));Kr.displayName=Ca.displayName;const Ge=i.forwardRef(({className:e,...t},n)=>r.jsx(ka,{ref:n,className:V("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=ka.displayName;const Ye=i.forwardRef(({className:e,...t},n)=>r.jsx(Ea,{ref:n,className:V("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=Ea.displayName;var Aa="AlertDialog",[Wf]=nt(Aa,[Oo]),Ve=Oo(),Ra=e=>{const{__scopeAlertDialog:t,...n}=e,s=Ve(t);return r.jsx(Zo,{...s,...n,modal:!0})};Ra.displayName=Aa;var zf="AlertDialogTrigger",_a=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=Ve(n);return r.jsx(ff,{...o,...s,ref:t})});_a.displayName=zf;var Hf="AlertDialogPortal",Pa=e=>{const{__scopeAlertDialog:t,...n}=e,s=Ve(t);return r.jsx(Qo,{...s,...n})};Pa.displayName=Hf;var Kf="AlertDialogOverlay",Da=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=Ve(n);return r.jsx(Br,{...o,...s,ref:t})});Da.displayName=Kf;var jt="AlertDialogContent",[qf,Gf]=Wf(jt),Yf=Hd("AlertDialogContent"),Ma=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,children:s,...o}=e,a=Ve(n),l=i.useRef(null),c=se(t,l),d=i.useRef(null);return r.jsx(lf,{contentName:jt,titleName:Ia,docsSlug:"alert-dialog",children:r.jsx(qf,{scope:n,cancelRef:d,children:r.jsxs(Ur,{role:"alertdialog",...a,...o,ref:c,onOpenAutoFocus:G(o.onOpenAutoFocus,f=>{var u;f.preventDefault(),(u=d.current)==null||u.focus({preventScroll:!0})}),onPointerDownOutside:f=>f.preventDefault(),onInteractOutside:f=>f.preventDefault(),children:[r.jsx(Yf,{children:s}),r.jsx(Jf,{contentRef:l})]})})})});Ma.displayName=jt;var Ia="AlertDialogTitle",Oa=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=Ve(n);return r.jsx(Vr,{...o,...s,ref:t})});Oa.displayName=Ia;var La="AlertDialogDescription",$a=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=Ve(n);return r.jsx(Wr,{...o,...s,ref:t})});$a.displayName=La;var Xf="AlertDialogAction",Fa=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=Ve(n);return r.jsx(En,{...o,...s,ref:t})});Fa.displayName=Xf;var Ba="AlertDialogCancel",Ua=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,{cancelRef:o}=Gf(Ba,n),a=Ve(n),l=se(t,o);return r.jsx(En,{...a,...s,ref:l})});Ua.displayName=Ba;var Jf=({contentRef:e})=>{const t=`\`${jt}\` requires a description for the component to be accessible for screen reader users.
|
|
204
|
-
|
|
205
|
-
You can add a description to the \`${jt}\` by passing a \`${La}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
|
|
206
|
-
|
|
207
|
-
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.
|
|
208
|
-
|
|
209
|
-
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},Zf=Ra,Qf=_a,em=Pa,Va=Da,Wa=Ma,za=Fa,Ha=Ua,Ka=Oa,qa=$a;const mr=Zf,pr=Qf,tm=em,Ga=i.forwardRef(({className:e,...t},n)=>r.jsx(Va,{className:V("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}));Ga.displayName=Va.displayName;const cn=i.forwardRef(({className:e,...t},n)=>r.jsxs(tm,{children:[r.jsx(Ga,{}),r.jsx(Wa,{ref:n,className:V("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})]}));cn.displayName=Wa.displayName;const dn=({className:e,...t})=>r.jsx("div",{className:V("flex flex-col space-y-2 text-center sm:text-left",e),...t});dn.displayName="AlertDialogHeader";const un=({className:e,...t})=>r.jsx("div",{className:V("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});un.displayName="AlertDialogFooter";const fn=i.forwardRef(({className:e,...t},n)=>r.jsx(Ka,{ref:n,className:V("text-lg font-semibold",e),...t}));fn.displayName=Ka.displayName;const mn=i.forwardRef(({className:e,...t},n)=>r.jsx(qa,{ref:n,className:V("text-sm text-muted-foreground",e),...t}));mn.displayName=qa.displayName;const pn=i.forwardRef(({className:e,...t},n)=>r.jsx(za,{ref:n,className:V(ao(),e),...t}));pn.displayName=za.displayName;const hn=i.forwardRef(({className:e,...t},n)=>r.jsx(Ha,{ref:n,className:V(ao({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));hn.displayName=Ha.displayName;function Vs(e,[t,n]){return Math.min(n,Math.max(t,e))}const nm=["top","right","bottom","left"],et=Math.min,we=Math.max,xn=Math.round,en=Math.floor,Le=e=>({x:e,y:e}),rm={left:"right",right:"left",bottom:"top",top:"bottom"};function hr(e,t,n){return we(e,et(t,n))}function Fe(e,t){return typeof e=="function"?e(t):e}function Be(e){return e.split("-")[0]}function Rt(e){return e.split("-")[1]}function qr(e){return e==="x"?"y":"x"}function Gr(e){return e==="y"?"height":"width"}function Oe(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Yr(e){return qr(Oe(e))}function sm(e,t,n){n===void 0&&(n=!1);const s=Rt(e),o=Yr(e),a=Gr(o);let l=o==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(l=gn(l)),[l,gn(l)]}function om(e){const t=gn(e);return[xr(e),t,xr(t)]}function xr(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Ws=["left","right"],zs=["right","left"],am=["top","bottom"],im=["bottom","top"];function lm(e,t,n){switch(e){case"top":case"bottom":return n?t?zs:Ws:t?Ws:zs;case"left":case"right":return t?am:im;default:return[]}}function cm(e,t,n,s){const o=Rt(e);let a=lm(Be(e),n==="start",s);return o&&(a=a.map(l=>l+"-"+o),t&&(a=a.concat(a.map(xr)))),a}function gn(e){const t=Be(e);return rm[t]+e.slice(t.length)}function dm(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ya(e){return typeof e!="number"?dm(e):{top:e,right:e,bottom:e,left:e}}function vn(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 Hs(e,t,n){let{reference:s,floating:o}=e;const a=Oe(t),l=Yr(t),c=Gr(l),d=Be(t),f=a==="y",u=s.x+s.width/2-o.width/2,m=s.y+s.height/2-o.height/2,h=s[c]/2-o[c]/2;let x;switch(d){case"top":x={x:u,y:s.y-o.height};break;case"bottom":x={x:u,y:s.y+s.height};break;case"right":x={x:s.x+s.width,y:m};break;case"left":x={x:s.x-o.width,y:m};break;default:x={x:s.x,y:s.y}}switch(Rt(t)){case"start":x[l]-=h*(n&&f?-1:1);break;case"end":x[l]+=h*(n&&f?-1:1);break}return x}async function um(e,t){var n;t===void 0&&(t={});const{x:s,y:o,platform:a,rects:l,elements:c,strategy:d}=e,{boundary:f="clippingAncestors",rootBoundary:u="viewport",elementContext:m="floating",altBoundary:h=!1,padding:x=0}=Fe(t,e),g=Ya(x),v=c[h?m==="floating"?"reference":"floating":m],b=vn(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(c.floating)),boundary:f,rootBoundary:u,strategy:d})),y=m==="floating"?{x:s,y:o,width:l.floating.width,height:l.floating.height}:l.reference,w=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c.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=vn(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:y,offsetParent:w,strategy:d}):y);return{top:(b.top-k.top+g.top)/j.y,bottom:(k.bottom-b.bottom+g.bottom)/j.y,left:(b.left-k.left+g.left)/j.x,right:(k.right-b.right+g.right)/j.x}}const fm=50,mm=async(e,t,n)=>{const{placement:s="bottom",strategy:o="absolute",middleware:a=[],platform:l}=n,c=l.detectOverflow?l:{...l,detectOverflow:um},d=await(l.isRTL==null?void 0:l.isRTL(t));let f=await l.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:m}=Hs(f,s,d),h=s,x=0;const g={};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:u,y:m,initialPlacement:s,placement:h,strategy:o,middlewareData:g,rects:f,platform:c,elements:{reference:e,floating:t}});u=w??u,m=j??m,g[b]={...g[b],...k},C&&x<fm&&(x++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(f=C.rects===!0?await l.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:u,y:m}=Hs(f,h,d)),p=-1)}return{x:u,y:m,placement:h,strategy:o,middlewareData:g}},pm=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:o,rects:a,platform:l,elements:c,middlewareData:d}=t,{element:f,padding:u=0}=Fe(e,t)||{};if(f==null)return{};const m=Ya(u),h={x:n,y:s},x=Yr(o),g=Gr(x),p=await l.getDimensions(f),v=x==="y",b=v?"top":"left",y=v?"bottom":"right",w=v?"clientHeight":"clientWidth",j=a.reference[g]+a.reference[x]-h[x]-a.floating[g],k=h[x]-a.reference[x],C=await(l.getOffsetParent==null?void 0:l.getOffsetParent(f));let S=C?C[w]:0;(!S||!await(l.isElement==null?void 0:l.isElement(C)))&&(S=c.floating[w]||a.floating[g]);const R=j/2-k/2,L=S/2-p[g]/2-1,B=et(m[b],L),O=et(m[y],L),U=B,$=S-p[g]-O,F=S/2-p[g]/2+R,H=hr(U,F,$),P=!d.arrow&&Rt(o)!=null&&F!==H&&a.reference[g]/2-(F<U?B:O)-p[g]/2<0,_=P?F<U?F-U:F-$:0;return{[x]:h[x]+_,data:{[x]:H,centerOffset:F-H-_,...P&&{alignmentOffset:_}},reset:P}}}),hm=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:o,middlewareData:a,rects:l,initialPlacement:c,platform:d,elements:f}=t,{mainAxis:u=!0,crossAxis:m=!0,fallbackPlacements:h,fallbackStrategy:x="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:p=!0,...v}=Fe(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const b=Be(o),y=Oe(c),w=Be(c)===c,j=await(d.isRTL==null?void 0:d.isRTL(f.floating)),k=h||(w||!p?[gn(c)]:om(c)),C=g!=="none";!h&&C&&k.push(...cm(c,p,g,j));const S=[c,...k],R=await d.detectOverflow(t,v),L=[];let B=((s=a.flip)==null?void 0:s.overflows)||[];if(u&&L.push(R[b]),m){const F=sm(o,l,j);L.push(R[F[0]],R[F[1]])}if(B=[...B,{placement:o,overflows:L}],!L.every(F=>F<=0)){var O,U;const F=(((O=a.flip)==null?void 0:O.index)||0)+1,H=S[F];if(H&&(!(m==="alignment"?y!==Oe(H):!1)||B.every(D=>Oe(D.placement)===y?D.overflows[0]>0:!0)))return{data:{index:F,overflows:B},reset:{placement:H}};let P=(U=B.filter(_=>_.overflows[0]<=0).sort((_,D)=>_.overflows[1]-D.overflows[1])[0])==null?void 0:U.placement;if(!P)switch(x){case"bestFit":{var $;const _=($=B.filter(D=>{if(C){const E=Oe(D.placement);return E===y||E==="y"}return!0}).map(D=>[D.placement,D.overflows.filter(E=>E>0).reduce((E,Y)=>E+Y,0)]).sort((D,E)=>D[1]-E[1])[0])==null?void 0:$[0];_&&(P=_);break}case"initialPlacement":P=c;break}if(o!==P)return{reset:{placement:P}}}return{}}}};function Ks(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function qs(e){return nm.some(t=>e[t]>=0)}const xm=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:s}=t,{strategy:o="referenceHidden",...a}=Fe(e,t);switch(o){case"referenceHidden":{const l=await s.detectOverflow(t,{...a,elementContext:"reference"}),c=Ks(l,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:qs(c)}}}case"escaped":{const l=await s.detectOverflow(t,{...a,altBoundary:!0}),c=Ks(l,n.floating);return{data:{escapedOffsets:c,escaped:qs(c)}}}default:return{}}}}},Xa=new Set(["left","top"]);async function gm(e,t){const{placement:n,platform:s,elements:o}=e,a=await(s.isRTL==null?void 0:s.isRTL(o.floating)),l=Be(n),c=Rt(n),d=Oe(n)==="y",f=Xa.has(l)?-1:1,u=a&&d?-1:1,m=Fe(t,e);let{mainAxis:h,crossAxis:x,alignmentAxis:g}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return c&&typeof g=="number"&&(x=c==="end"?g*-1:g),d?{x:x*u,y:h*f}:{x:h*f,y:x*u}}const vm=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:o,y:a,placement:l,middlewareData:c}=t,d=await gm(t,e);return l===((n=c.offset)==null?void 0:n.placement)&&(s=c.arrow)!=null&&s.alignmentOffset?{}:{x:o+d.x,y:a+d.y,data:{...d,placement:l}}}}},bm=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:l=!0,crossAxis:c=!1,limiter:d={fn:b=>{let{x:y,y:w}=b;return{x:y,y:w}}},...f}=Fe(e,t),u={x:n,y:s},m=await a.detectOverflow(t,f),h=Oe(Be(o)),x=qr(h);let g=u[x],p=u[h];if(l){const b=x==="y"?"top":"left",y=x==="y"?"bottom":"right",w=g+m[b],j=g-m[y];g=hr(w,g,j)}if(c){const b=h==="y"?"top":"left",y=h==="y"?"bottom":"right",w=p+m[b],j=p-m[y];p=hr(w,p,j)}const v=d.fn({...t,[x]:g,[h]:p});return{...v,data:{x:v.x-n,y:v.y-s,enabled:{[x]:l,[h]:c}}}}}},ym=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:s,placement:o,rects:a,middlewareData:l}=t,{offset:c=0,mainAxis:d=!0,crossAxis:f=!0}=Fe(e,t),u={x:n,y:s},m=Oe(o),h=qr(m);let x=u[h],g=u[m];const p=Fe(c,t),v=typeof p=="number"?{mainAxis:p,crossAxis:0}:{mainAxis:0,crossAxis:0,...p};if(d){const w=h==="y"?"height":"width",j=a.reference[h]-a.floating[w]+v.mainAxis,k=a.reference[h]+a.reference[w]-v.mainAxis;x<j?x=j:x>k&&(x=k)}if(f){var b,y;const w=h==="y"?"width":"height",j=Xa.has(Be(o)),k=a.reference[m]-a.floating[w]+(j&&((b=l.offset)==null?void 0:b[m])||0)+(j?0:v.crossAxis),C=a.reference[m]+a.reference[w]+(j?0:((y=l.offset)==null?void 0:y[m])||0)-(j?v.crossAxis:0);g<k?g=k:g>C&&(g=C)}return{[h]:x,[m]:g}}}},wm=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,s;const{placement:o,rects:a,platform:l,elements:c}=t,{apply:d=()=>{},...f}=Fe(e,t),u=await l.detectOverflow(t,f),m=Be(o),h=Rt(o),x=Oe(o)==="y",{width:g,height:p}=a.floating;let v,b;m==="top"||m==="bottom"?(v=m,b=h===(await(l.isRTL==null?void 0:l.isRTL(c.floating))?"start":"end")?"left":"right"):(b=m,v=h==="end"?"top":"bottom");const y=p-u.top-u.bottom,w=g-u.left-u.right,j=et(p-u[v],y),k=et(g-u[b],w),C=!t.middlewareData.shift;let S=j,R=k;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(R=w),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(S=y),C&&!h){const B=we(u.left,0),O=we(u.right,0),U=we(u.top,0),$=we(u.bottom,0);x?R=g-2*(B!==0||O!==0?B+O:we(u.left,u.right)):S=p-2*(U!==0||$!==0?U+$:we(u.top,u.bottom))}await d({...t,availableWidth:R,availableHeight:S});const L=await l.getDimensions(c.floating);return g!==L.width||p!==L.height?{reset:{rects:!0}}:{}}}};function An(){return typeof window<"u"}function _t(e){return Ja(e)?(e.nodeName||"").toLowerCase():"#document"}function Se(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function $e(e){var t;return(t=(Ja(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Ja(e){return An()?e instanceof Node||e instanceof Se(e).Node:!1}function _e(e){return An()?e instanceof Element||e instanceof Se(e).Element:!1}function We(e){return An()?e instanceof HTMLElement||e instanceof Se(e).HTMLElement:!1}function Gs(e){return!An()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Se(e).ShadowRoot}function zt(e){const{overflow:t,overflowX:n,overflowY:s,display:o}=Pe(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&o!=="inline"&&o!=="contents"}function Nm(e){return/^(table|td|th)$/.test(_t(e))}function Rn(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const jm=/transform|translate|scale|rotate|perspective|filter/,Sm=/paint|layout|strict|content/,lt=e=>!!e&&e!=="none";let tr;function Xr(e){const t=_e(e)?Pe(e):e;return lt(t.transform)||lt(t.translate)||lt(t.scale)||lt(t.rotate)||lt(t.perspective)||!Jr()&&(lt(t.backdropFilter)||lt(t.filter))||jm.test(t.willChange||"")||Sm.test(t.contain||"")}function Cm(e){let t=tt(e);for(;We(t)&&!kt(t);){if(Xr(t))return t;if(Rn(t))return null;t=tt(t)}return null}function Jr(){return tr==null&&(tr=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),tr}function kt(e){return/^(html|body|#document)$/.test(_t(e))}function Pe(e){return Se(e).getComputedStyle(e)}function _n(e){return _e(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function tt(e){if(_t(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Gs(e)&&e.host||$e(e);return Gs(t)?t.host:t}function Za(e){const t=tt(e);return kt(t)?e.ownerDocument?e.ownerDocument.body:e.body:We(t)&&zt(t)?t:Za(t)}function Ft(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Za(e),a=o===((s=e.ownerDocument)==null?void 0:s.body),l=Se(o);if(a){const c=gr(l);return t.concat(l,l.visualViewport||[],zt(o)?o:[],c&&n?Ft(c):[])}else return t.concat(o,Ft(o,[],n))}function gr(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Qa(e){const t=Pe(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const o=We(e),a=o?e.offsetWidth:n,l=o?e.offsetHeight:s,c=xn(n)!==a||xn(s)!==l;return c&&(n=a,s=l),{width:n,height:s,$:c}}function Zr(e){return _e(e)?e:e.contextElement}function St(e){const t=Zr(e);if(!We(t))return Le(1);const n=t.getBoundingClientRect(),{width:s,height:o,$:a}=Qa(t);let l=(a?xn(n.width):n.width)/s,c=(a?xn(n.height):n.height)/o;return(!l||!Number.isFinite(l))&&(l=1),(!c||!Number.isFinite(c))&&(c=1),{x:l,y:c}}const km=Le(0);function ei(e){const t=Se(e);return!Jr()||!t.visualViewport?km:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Em(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Se(e)?!1:t}function ft(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),a=Zr(e);let l=Le(1);t&&(s?_e(s)&&(l=St(s)):l=St(e));const c=Em(a,n,s)?ei(a):Le(0);let d=(o.left+c.x)/l.x,f=(o.top+c.y)/l.y,u=o.width/l.x,m=o.height/l.y;if(a){const h=Se(a),x=s&&_e(s)?Se(s):s;let g=h,p=gr(g);for(;p&&s&&x!==g;){const v=St(p),b=p.getBoundingClientRect(),y=Pe(p),w=b.left+(p.clientLeft+parseFloat(y.paddingLeft))*v.x,j=b.top+(p.clientTop+parseFloat(y.paddingTop))*v.y;d*=v.x,f*=v.y,u*=v.x,m*=v.y,d+=w,f+=j,g=Se(p),p=gr(g)}}return vn({width:u,height:m,x:d,y:f})}function Pn(e,t){const n=_n(e).scrollLeft;return t?t.left+n:ft($e(e)).left+n}function ti(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-Pn(e,n),o=n.top+t.scrollTop;return{x:s,y:o}}function Tm(e){let{elements:t,rect:n,offsetParent:s,strategy:o}=e;const a=o==="fixed",l=$e(s),c=t?Rn(t.floating):!1;if(s===l||c&&a)return n;let d={scrollLeft:0,scrollTop:0},f=Le(1);const u=Le(0),m=We(s);if((m||!m&&!a)&&((_t(s)!=="body"||zt(l))&&(d=_n(s)),m)){const x=ft(s);f=St(s),u.x=x.x+s.clientLeft,u.y=x.y+s.clientTop}const h=l&&!m&&!a?ti(l,d):Le(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-d.scrollLeft*f.x+u.x+h.x,y:n.y*f.y-d.scrollTop*f.y+u.y+h.y}}function Am(e){return Array.from(e.getClientRects())}function Rm(e){const t=$e(e),n=_n(e),s=e.ownerDocument.body,o=we(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),a=we(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let l=-n.scrollLeft+Pn(e);const c=-n.scrollTop;return Pe(s).direction==="rtl"&&(l+=we(t.clientWidth,s.clientWidth)-o),{width:o,height:a,x:l,y:c}}const Ys=25;function _m(e,t){const n=Se(e),s=$e(e),o=n.visualViewport;let a=s.clientWidth,l=s.clientHeight,c=0,d=0;if(o){a=o.width,l=o.height;const u=Jr();(!u||u&&t==="fixed")&&(c=o.offsetLeft,d=o.offsetTop)}const f=Pn(s);if(f<=0){const u=s.ownerDocument,m=u.body,h=getComputedStyle(m),x=u.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,g=Math.abs(s.clientWidth-m.clientWidth-x);g<=Ys&&(a-=g)}else f<=Ys&&(a+=f);return{width:a,height:l,x:c,y:d}}function Pm(e,t){const n=ft(e,!0,t==="fixed"),s=n.top+e.clientTop,o=n.left+e.clientLeft,a=We(e)?St(e):Le(1),l=e.clientWidth*a.x,c=e.clientHeight*a.y,d=o*a.x,f=s*a.y;return{width:l,height:c,x:d,y:f}}function Xs(e,t,n){let s;if(t==="viewport")s=_m(e,n);else if(t==="document")s=Rm($e(e));else if(_e(t))s=Pm(t,n);else{const o=ei(e);s={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return vn(s)}function ni(e,t){const n=tt(e);return n===t||!_e(n)||kt(n)?!1:Pe(n).position==="fixed"||ni(n,t)}function Dm(e,t){const n=t.get(e);if(n)return n;let s=Ft(e,[],!1).filter(c=>_e(c)&&_t(c)!=="body"),o=null;const a=Pe(e).position==="fixed";let l=a?tt(e):e;for(;_e(l)&&!kt(l);){const c=Pe(l),d=Xr(l);!d&&c.position==="fixed"&&(o=null),(a?!d&&!o:!d&&c.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||zt(l)&&!d&&ni(e,l))?s=s.filter(u=>u!==l):o=c,l=tt(l)}return t.set(e,s),s}function Mm(e){let{element:t,boundary:n,rootBoundary:s,strategy:o}=e;const l=[...n==="clippingAncestors"?Rn(t)?[]:Dm(t,this._c):[].concat(n),s],c=Xs(t,l[0],o);let d=c.top,f=c.right,u=c.bottom,m=c.left;for(let h=1;h<l.length;h++){const x=Xs(t,l[h],o);d=we(x.top,d),f=et(x.right,f),u=et(x.bottom,u),m=we(x.left,m)}return{width:f-m,height:u-d,x:m,y:d}}function Im(e){const{width:t,height:n}=Qa(e);return{width:t,height:n}}function Om(e,t,n){const s=We(t),o=$e(t),a=n==="fixed",l=ft(e,!0,a,t);let c={scrollLeft:0,scrollTop:0};const d=Le(0);function f(){d.x=Pn(o)}if(s||!s&&!a)if((_t(t)!=="body"||zt(o))&&(c=_n(t)),s){const x=ft(t,!0,a,t);d.x=x.x+t.clientLeft,d.y=x.y+t.clientTop}else o&&f();a&&!s&&o&&f();const u=o&&!s&&!a?ti(o,c):Le(0),m=l.left+c.scrollLeft-d.x-u.x,h=l.top+c.scrollTop-d.y-u.y;return{x:m,y:h,width:l.width,height:l.height}}function nr(e){return Pe(e).position==="static"}function Js(e,t){if(!We(e)||Pe(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return $e(e)===n&&(n=n.ownerDocument.body),n}function ri(e,t){const n=Se(e);if(Rn(e))return n;if(!We(e)){let o=tt(e);for(;o&&!kt(o);){if(_e(o)&&!nr(o))return o;o=tt(o)}return n}let s=Js(e,t);for(;s&&Nm(s)&&nr(s);)s=Js(s,t);return s&&kt(s)&&nr(s)&&!Xr(s)?n:s||Cm(e)||n}const Lm=async function(e){const t=this.getOffsetParent||ri,n=this.getDimensions,s=await n(e.floating);return{reference:Om(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function $m(e){return Pe(e).direction==="rtl"}const Fm={convertOffsetParentRelativeRectToViewportRelativeRect:Tm,getDocumentElement:$e,getClippingRect:Mm,getOffsetParent:ri,getElementRects:Lm,getClientRects:Am,getDimensions:Im,getScale:St,isElement:_e,isRTL:$m};function si(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Bm(e,t){let n=null,s;const o=$e(e);function a(){var c;clearTimeout(s),(c=n)==null||c.disconnect(),n=null}function l(c,d){c===void 0&&(c=!1),d===void 0&&(d=1),a();const f=e.getBoundingClientRect(),{left:u,top:m,width:h,height:x}=f;if(c||t(),!h||!x)return;const g=en(m),p=en(o.clientWidth-(u+h)),v=en(o.clientHeight-(m+x)),b=en(u),w={rootMargin:-g+"px "+-p+"px "+-v+"px "+-b+"px",threshold:we(0,et(1,d))||1};let j=!0;function k(C){const S=C[0].intersectionRatio;if(S!==d){if(!j)return l();S?l(!1,S):s=setTimeout(()=>{l(!1,1e-7)},1e3)}S===1&&!si(f,e.getBoundingClientRect())&&l(),j=!1}try{n=new IntersectionObserver(k,{...w,root:o.ownerDocument})}catch{n=new IntersectionObserver(k,w)}n.observe(e)}return l(!0),a}function Um(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:d=!1}=s,f=Zr(e),u=o||a?[...f?Ft(f):[],...t?Ft(t):[]]:[];u.forEach(b=>{o&&b.addEventListener("scroll",n,{passive:!0}),a&&b.addEventListener("resize",n)});const m=f&&c?Bm(f,n):null;let h=-1,x=null;l&&(x=new ResizeObserver(b=>{let[y]=b;y&&y.target===f&&x&&t&&(x.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var w;(w=x)==null||w.observe(t)})),n()}),f&&!d&&x.observe(f),t&&x.observe(t));let g,p=d?ft(e):null;d&&v();function v(){const b=ft(e);p&&!si(p,b)&&n(),p=b,g=requestAnimationFrame(v)}return n(),()=>{var b;u.forEach(y=>{o&&y.removeEventListener("scroll",n),a&&y.removeEventListener("resize",n)}),m==null||m(),(b=x)==null||b.disconnect(),x=null,d&&cancelAnimationFrame(g)}}const Vm=vm,Wm=bm,zm=hm,Hm=wm,Km=xm,Zs=pm,qm=ym,Gm=(e,t,n)=>{const s=new Map,o={platform:Fm,...n},a={...o.platform,_c:s};return mm(e,t,{...o,platform:a})};var Ym=typeof document<"u",Xm=function(){},rn=Ym?i.useLayoutEffect:Xm;function bn(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(!bn(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)&&!bn(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function oi(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Qs(e,t){const n=oi(e);return Math.round(t*n)/n}function rr(e){const t=i.useRef(e);return rn(()=>{t.current=e}),t}function Jm(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:s=[],platform:o,elements:{reference:a,floating:l}={},transform:c=!0,whileElementsMounted:d,open:f}=e,[u,m]=i.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,x]=i.useState(s);bn(h,s)||x(s);const[g,p]=i.useState(null),[v,b]=i.useState(null),y=i.useCallback(D=>{D!==C.current&&(C.current=D,p(D))},[]),w=i.useCallback(D=>{D!==S.current&&(S.current=D,b(D))},[]),j=a||g,k=l||v,C=i.useRef(null),S=i.useRef(null),R=i.useRef(u),L=d!=null,B=rr(d),O=rr(o),U=rr(f),$=i.useCallback(()=>{if(!C.current||!S.current)return;const D={placement:t,strategy:n,middleware:h};O.current&&(D.platform=O.current),Gm(C.current,S.current,D).then(E=>{const Y={...E,isPositioned:U.current!==!1};F.current&&!bn(R.current,Y)&&(R.current=Y,Nn.flushSync(()=>{m(Y)}))})},[h,t,n,O,U]);rn(()=>{f===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,m(D=>({...D,isPositioned:!1})))},[f]);const F=i.useRef(!1);rn(()=>(F.current=!0,()=>{F.current=!1}),[]),rn(()=>{if(j&&(C.current=j),k&&(S.current=k),j&&k){if(B.current)return B.current(j,k,$);$()}},[j,k,$,B,L]);const H=i.useMemo(()=>({reference:C,floating:S,setReference:y,setFloating:w}),[y,w]),P=i.useMemo(()=>({reference:j,floating:k}),[j,k]),_=i.useMemo(()=>{const D={position:n,left:0,top:0};if(!P.floating)return D;const E=Qs(P.floating,u.x),Y=Qs(P.floating,u.y);return c?{...D,transform:"translate("+E+"px, "+Y+"px)",...oi(P.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:E,top:Y}},[n,c,P.floating,u.x,u.y]);return i.useMemo(()=>({...u,update:$,refs:H,elements:P,floatingStyles:_}),[u,$,H,P,_])}const Zm=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?Zs({element:s.current,padding:o}).fn(n):{}:s?Zs({element:s,padding:o}).fn(n):{}}}},Qm=(e,t)=>{const n=Vm(e);return{name:n.name,fn:n.fn,options:[e,t]}},ep=(e,t)=>{const n=Wm(e);return{name:n.name,fn:n.fn,options:[e,t]}},tp=(e,t)=>({fn:qm(e).fn,options:[e,t]}),np=(e,t)=>{const n=zm(e);return{name:n.name,fn:n.fn,options:[e,t]}},rp=(e,t)=>{const n=Hm(e);return{name:n.name,fn:n.fn,options:[e,t]}},sp=(e,t)=>{const n=Km(e);return{name:n.name,fn:n.fn,options:[e,t]}},op=(e,t)=>{const n=Zm(e);return{name:n.name,fn:n.fn,options:[e,t]}};var ap="Arrow",ai=i.forwardRef((e,t)=>{const{children:n,width:s=10,height:o=5,...a}=e;return r.jsx(X.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"})})});ai.displayName=ap;var ip=ai;function ii(e){const[t,n]=i.useState(void 0);return ge(()=>{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 l,c;if("borderBoxSize"in a){const d=a.borderBoxSize,f=Array.isArray(d)?d[0]:d;l=f.inlineSize,c=f.blockSize}else l=e.offsetWidth,c=e.offsetHeight;n({width:l,height:c})});return s.observe(e,{box:"border-box"}),()=>s.unobserve(e)}else n(void 0)},[e]),t}var Qr="Popper",[li,ci]=nt(Qr),[lp,di]=li(Qr),ui=e=>{const{__scopePopper:t,children:n}=e,[s,o]=i.useState(null);return r.jsx(lp,{scope:t,anchor:s,onAnchorChange:o,children:n})};ui.displayName=Qr;var fi="PopperAnchor",mi=i.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:s,...o}=e,a=di(fi,n),l=i.useRef(null),c=se(t,l),d=i.useRef(null);return i.useEffect(()=>{const f=d.current;d.current=(s==null?void 0:s.current)||l.current,f!==d.current&&a.onAnchorChange(d.current)}),s?null:r.jsx(X.div,{...o,ref:c})});mi.displayName=fi;var es="PopperContent",[cp,dp]=li(es),pi=i.forwardRef((e,t)=>{var M,J,ie,q,W,z;const{__scopePopper:n,side:s="bottom",sideOffset:o=0,align:a="center",alignOffset:l=0,arrowPadding:c=0,avoidCollisions:d=!0,collisionBoundary:f=[],collisionPadding:u=0,sticky:m="partial",hideWhenDetached:h=!1,updatePositionStrategy:x="optimized",onPlaced:g,...p}=e,v=di(es,n),[b,y]=i.useState(null),w=se(t,ce=>y(ce)),[j,k]=i.useState(null),C=ii(j),S=(C==null?void 0:C.width)??0,R=(C==null?void 0:C.height)??0,L=s+(a!=="center"?"-"+a:""),B=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},O=Array.isArray(f)?f:[f],U=O.length>0,$={padding:B,boundary:O.filter(fp),altBoundary:U},{refs:F,floatingStyles:H,placement:P,isPositioned:_,middlewareData:D}=Jm({strategy:"fixed",placement:L,whileElementsMounted:(...ce)=>Um(...ce,{animationFrame:x==="always"}),elements:{reference:v.anchor},middleware:[Qm({mainAxis:o+R,alignmentAxis:l}),d&&ep({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?tp():void 0,...$}),d&&np({...$}),rp({...$,apply:({elements:ce,rects:A,availableWidth:te,availableHeight:de})=>{const{width:Ce,height:ze}=A.reference,ht=ce.floating.style;ht.setProperty("--radix-popper-available-width",`${te}px`),ht.setProperty("--radix-popper-available-height",`${de}px`),ht.setProperty("--radix-popper-anchor-width",`${Ce}px`),ht.setProperty("--radix-popper-anchor-height",`${ze}px`)}}),j&&op({element:j,padding:c}),mp({arrowWidth:S,arrowHeight:R}),h&&sp({strategy:"referenceHidden",...$})]}),[E,Y]=gi(P),re=Qe(g);ge(()=>{_&&(re==null||re())},[_,re]);const le=(M=D.arrow)==null?void 0:M.x,pe=(J=D.arrow)==null?void 0:J.y,ue=((ie=D.arrow)==null?void 0:ie.centerOffset)!==0,[ve,xe]=i.useState();return ge(()=>{b&&xe(window.getComputedStyle(b).zIndex)},[b]),r.jsx("div",{ref:F.setFloating,"data-radix-popper-content-wrapper":"",style:{...H,transform:_?H.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ve,"--radix-popper-transform-origin":[(q=D.transformOrigin)==null?void 0:q.x,(W=D.transformOrigin)==null?void 0:W.y].join(" "),...((z=D.hide)==null?void 0:z.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:r.jsx(cp,{scope:n,placedSide:E,onArrowChange:k,arrowX:le,arrowY:pe,shouldHideArrow:ue,children:r.jsx(X.div,{"data-side":E,"data-align":Y,...p,ref:w,style:{...p.style,animation:_?void 0:"none"}})})})});pi.displayName=es;var hi="PopperArrow",up={top:"bottom",right:"left",bottom:"top",left:"right"},xi=i.forwardRef(function(t,n){const{__scopePopper:s,...o}=t,a=dp(hi,s),l=up[a.placedSide];return r.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[l]: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(ip,{...o,ref:n,style:{...o.style,display:"block"}})})});xi.displayName=hi;function fp(e){return e!==null}var mp=e=>({name:"transformOrigin",options:e,fn(t){var v,b,y;const{placement:n,rects:s,middlewareData:o}=t,l=((v=o.arrow)==null?void 0:v.centerOffset)!==0,c=l?0:e.arrowWidth,d=l?0:e.arrowHeight,[f,u]=gi(n),m={start:"0%",center:"50%",end:"100%"}[u],h=(((b=o.arrow)==null?void 0:b.x)??0)+c/2,x=(((y=o.arrow)==null?void 0:y.y)??0)+d/2;let g="",p="";return f==="bottom"?(g=l?m:`${h}px`,p=`${-d}px`):f==="top"?(g=l?m:`${h}px`,p=`${s.floating.height+d}px`):f==="right"?(g=`${-d}px`,p=l?m:`${x}px`):f==="left"&&(g=`${s.floating.width+d}px`,p=l?m:`${x}px`),{data:{x:g,y:p}}}});function gi(e){const[t,n="center"]=e.split("-");return[t,n]}var pp=ui,hp=mi,xp=pi,gp=xi;function vi(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 bi=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"}),vp="VisuallyHidden",bp=i.forwardRef((e,t)=>r.jsx(X.span,{...e,ref:t,style:{...bi,...e.style}}));bp.displayName=vp;var yp=[" ","Enter","ArrowUp","ArrowDown"],wp=[" ","Enter"],mt="Select",[Dn,Mn,Np]=la(mt),[Pt]=nt(mt,[Np,ci]),In=ci(),[jp,rt]=Pt(mt),[Sp,Cp]=Pt(mt),yi=e=>{const{__scopeSelect:t,children:n,open:s,defaultOpen:o,onOpenChange:a,value:l,defaultValue:c,onValueChange:d,dir:f,name:u,autoComplete:m,disabled:h,required:x,form:g}=e,p=In(t),[v,b]=i.useState(null),[y,w]=i.useState(null),[j,k]=i.useState(!1),C=zr(f),[S,R]=Ct({prop:s,defaultProp:o??!1,onChange:a,caller:mt}),[L,B]=Ct({prop:l,defaultProp:c,onChange:d,caller:mt}),O=i.useRef(null),U=v?g||!!v.closest("form"):!0,[$,F]=i.useState(new Set),H=Array.from($).map(P=>P.props.value).join(";");return r.jsx(pp,{...p,children:r.jsxs(jp,{required:x,scope:t,trigger:v,onTriggerChange:b,valueNode:y,onValueNodeChange:w,valueNodeHasChildren:j,onValueNodeHasChildrenChange:k,contentId:Xe(),value:L,onValueChange:B,open:S,onOpenChange:R,dir:C,triggerPointerDownPosRef:O,disabled:h,children:[r.jsx(Dn.Provider,{scope:t,children:r.jsx(Sp,{scope:e.__scopeSelect,onNativeOptionAdd:i.useCallback(P=>{F(_=>new Set(_).add(P))},[]),onNativeOptionRemove:i.useCallback(P=>{F(_=>{const D=new Set(_);return D.delete(P),D})},[]),children:n})}),U?r.jsxs(zi,{"aria-hidden":!0,required:x,tabIndex:-1,name:u,autoComplete:m,value:L,onChange:P=>B(P.target.value),disabled:h,form:g,children:[L===void 0?r.jsx("option",{value:""}):null,Array.from($)]},H):null]})})};yi.displayName=mt;var wi="SelectTrigger",Ni=i.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:s=!1,...o}=e,a=In(n),l=rt(wi,n),c=l.disabled||s,d=se(t,l.onTriggerChange),f=Mn(n),u=i.useRef("touch"),[m,h,x]=Ki(p=>{const v=f().filter(w=>!w.disabled),b=v.find(w=>w.value===l.value),y=qi(v,p,b);y!==void 0&&l.onValueChange(y.value)}),g=p=>{c||(l.onOpenChange(!0),x()),p&&(l.triggerPointerDownPosRef.current={x:Math.round(p.pageX),y:Math.round(p.pageY)})};return r.jsx(hp,{asChild:!0,...a,children:r.jsx(X.button,{type:"button",role:"combobox","aria-controls":l.contentId,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":Hi(l.value)?"":void 0,...o,ref:d,onClick:G(o.onClick,p=>{p.currentTarget.focus(),u.current!=="mouse"&&g(p)}),onPointerDown:G(o.onPointerDown,p=>{u.current=p.pointerType;const v=p.target;v.hasPointerCapture(p.pointerId)&&v.releasePointerCapture(p.pointerId),p.button===0&&p.ctrlKey===!1&&p.pointerType==="mouse"&&(g(p),p.preventDefault())}),onKeyDown:G(o.onKeyDown,p=>{const v=m.current!=="";!(p.ctrlKey||p.altKey||p.metaKey)&&p.key.length===1&&h(p.key),!(v&&p.key===" ")&&yp.includes(p.key)&&(g(),p.preventDefault())})})})});Ni.displayName=wi;var ji="SelectValue",Si=i.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:o,children:a,placeholder:l="",...c}=e,d=rt(ji,n),{onValueNodeHasChildrenChange:f}=d,u=a!==void 0,m=se(t,d.onValueNodeChange);return ge(()=>{f(u)},[f,u]),r.jsx(X.span,{...c,ref:m,style:{pointerEvents:"none"},children:Hi(d.value)?r.jsx(r.Fragment,{children:l}):a})});Si.displayName=ji;var kp="SelectIcon",Ci=i.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,...o}=e;return r.jsx(X.span,{"aria-hidden":!0,...o,ref:t,children:s||"▼"})});Ci.displayName=kp;var Ep="SelectPortal",ki=e=>r.jsx(Ir,{asChild:!0,...e});ki.displayName=Ep;var pt="SelectContent",Ei=i.forwardRef((e,t)=>{const n=rt(pt,e.__scopeSelect),[s,o]=i.useState();if(ge(()=>{o(new DocumentFragment)},[]),!n.open){const a=s;return a?Nn.createPortal(r.jsx(Ti,{scope:e.__scopeSelect,children:r.jsx(Dn.Slot,{scope:e.__scopeSelect,children:r.jsx("div",{children:e.children})})}),a):null}return r.jsx(Ai,{...e,ref:t})});Ei.displayName=pt;var Re=10,[Ti,st]=Pt(pt),Tp="SelectContentImpl",Ap=Lt("SelectContent.RemoveScroll"),Ai=i.forwardRef((e,t)=>{const{__scopeSelect:n,position:s="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:a,onPointerDownOutside:l,side:c,sideOffset:d,align:f,alignOffset:u,arrowPadding:m,collisionBoundary:h,collisionPadding:x,sticky:g,hideWhenDetached:p,avoidCollisions:v,...b}=e,y=rt(pt,n),[w,j]=i.useState(null),[k,C]=i.useState(null),S=se(t,M=>j(M)),[R,L]=i.useState(null),[B,O]=i.useState(null),U=Mn(n),[$,F]=i.useState(!1),H=i.useRef(!1);i.useEffect(()=>{if(w)return Mo(w)},[w]),Co();const P=i.useCallback(M=>{const[J,...ie]=U().map(z=>z.ref.current),[q]=ie.slice(-1),W=document.activeElement;for(const z of M)if(z===W||(z==null||z.scrollIntoView({block:"nearest"}),z===J&&k&&(k.scrollTop=0),z===q&&k&&(k.scrollTop=k.scrollHeight),z==null||z.focus(),document.activeElement!==W))return},[U,k]),_=i.useCallback(()=>P([R,w]),[P,R,w]);i.useEffect(()=>{$&&_()},[$,_]);const{onOpenChange:D,triggerPointerDownPosRef:E}=y;i.useEffect(()=>{if(w){let M={x:0,y:0};const J=q=>{var W,z;M={x:Math.abs(Math.round(q.pageX)-(((W=E.current)==null?void 0:W.x)??0)),y:Math.abs(Math.round(q.pageY)-(((z=E.current)==null?void 0:z.y)??0))}},ie=q=>{M.x<=10&&M.y<=10?q.preventDefault():w.contains(q.target)||D(!1),document.removeEventListener("pointermove",J),E.current=null};return E.current!==null&&(document.addEventListener("pointermove",J),document.addEventListener("pointerup",ie,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",J),document.removeEventListener("pointerup",ie,{capture:!0})}}},[w,D,E]),i.useEffect(()=>{const M=()=>D(!1);return window.addEventListener("blur",M),window.addEventListener("resize",M),()=>{window.removeEventListener("blur",M),window.removeEventListener("resize",M)}},[D]);const[Y,re]=Ki(M=>{const J=U().filter(W=>!W.disabled),ie=J.find(W=>W.ref.current===document.activeElement),q=qi(J,M,ie);q&&setTimeout(()=>q.ref.current.focus())}),le=i.useCallback((M,J,ie)=>{const q=!H.current&&!ie;(y.value!==void 0&&y.value===J||q)&&(L(M),q&&(H.current=!0))},[y.value]),pe=i.useCallback(()=>w==null?void 0:w.focus(),[w]),ue=i.useCallback((M,J,ie)=>{const q=!H.current&&!ie;(y.value!==void 0&&y.value===J||q)&&O(M)},[y.value]),ve=s==="popper"?vr:Ri,xe=ve===vr?{side:c,sideOffset:d,align:f,alignOffset:u,arrowPadding:m,collisionBoundary:h,collisionPadding:x,sticky:g,hideWhenDetached:p,avoidCollisions:v}:{};return r.jsx(Ti,{scope:n,content:w,viewport:k,onViewportChange:C,itemRefCallback:le,selectedItem:R,onItemLeave:pe,itemTextRefCallback:ue,focusSelectedItem:_,selectedItemText:B,position:s,isPositioned:$,searchRef:Y,children:r.jsx(Or,{as:Ap,allowPinchZoom:!0,children:r.jsx(Mr,{asChild:!0,trapped:y.open,onMountAutoFocus:M=>{M.preventDefault()},onUnmountAutoFocus:G(o,M=>{var J;(J=y.trigger)==null||J.focus({preventScroll:!0}),M.preventDefault()}),children:r.jsx(Dr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:M=>M.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:r.jsx(ve,{role:"listbox",id:y.contentId,"data-state":y.open?"open":"closed",dir:y.dir,onContextMenu:M=>M.preventDefault(),...b,...xe,onPlaced:()=>F(!0),ref:S,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:G(b.onKeyDown,M=>{const J=M.ctrlKey||M.altKey||M.metaKey;if(M.key==="Tab"&&M.preventDefault(),!J&&M.key.length===1&&re(M.key),["ArrowUp","ArrowDown","Home","End"].includes(M.key)){let q=U().filter(W=>!W.disabled).map(W=>W.ref.current);if(["ArrowUp","End"].includes(M.key)&&(q=q.slice().reverse()),["ArrowUp","ArrowDown"].includes(M.key)){const W=M.target,z=q.indexOf(W);q=q.slice(z+1)}setTimeout(()=>P(q)),M.preventDefault()}})})})})})})});Ai.displayName=Tp;var Rp="SelectItemAlignedPosition",Ri=i.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:s,...o}=e,a=rt(pt,n),l=st(pt,n),[c,d]=i.useState(null),[f,u]=i.useState(null),m=se(t,S=>u(S)),h=Mn(n),x=i.useRef(!1),g=i.useRef(!0),{viewport:p,selectedItem:v,selectedItemText:b,focusSelectedItem:y}=l,w=i.useCallback(()=>{if(a.trigger&&a.valueNode&&c&&f&&p&&v&&b){const S=a.trigger.getBoundingClientRect(),R=f.getBoundingClientRect(),L=a.valueNode.getBoundingClientRect(),B=b.getBoundingClientRect();if(a.dir!=="rtl"){const W=B.left-R.left,z=L.left-W,ce=S.left-z,A=S.width+ce,te=Math.max(A,R.width),de=window.innerWidth-Re,Ce=Vs(z,[Re,Math.max(Re,de-te)]);c.style.minWidth=A+"px",c.style.left=Ce+"px"}else{const W=R.right-B.right,z=window.innerWidth-L.right-W,ce=window.innerWidth-S.right-z,A=S.width+ce,te=Math.max(A,R.width),de=window.innerWidth-Re,Ce=Vs(z,[Re,Math.max(Re,de-te)]);c.style.minWidth=A+"px",c.style.right=Ce+"px"}const O=h(),U=window.innerHeight-Re*2,$=p.scrollHeight,F=window.getComputedStyle(f),H=parseInt(F.borderTopWidth,10),P=parseInt(F.paddingTop,10),_=parseInt(F.borderBottomWidth,10),D=parseInt(F.paddingBottom,10),E=H+P+$+D+_,Y=Math.min(v.offsetHeight*5,E),re=window.getComputedStyle(p),le=parseInt(re.paddingTop,10),pe=parseInt(re.paddingBottom,10),ue=S.top+S.height/2-Re,ve=U-ue,xe=v.offsetHeight/2,M=v.offsetTop+xe,J=H+P+M,ie=E-J;if(J<=ue){const W=O.length>0&&v===O[O.length-1].ref.current;c.style.bottom="0px";const z=f.clientHeight-p.offsetTop-p.offsetHeight,ce=Math.max(ve,xe+(W?pe:0)+z+_),A=J+ce;c.style.height=A+"px"}else{const W=O.length>0&&v===O[0].ref.current;c.style.top="0px";const ce=Math.max(ue,H+p.offsetTop+(W?le:0)+xe)+ie;c.style.height=ce+"px",p.scrollTop=J-ue+p.offsetTop}c.style.margin=`${Re}px 0`,c.style.minHeight=Y+"px",c.style.maxHeight=U+"px",s==null||s(),requestAnimationFrame(()=>x.current=!0)}},[h,a.trigger,a.valueNode,c,f,p,v,b,a.dir,s]);ge(()=>w(),[w]);const[j,k]=i.useState();ge(()=>{f&&k(window.getComputedStyle(f).zIndex)},[f]);const C=i.useCallback(S=>{S&&g.current===!0&&(w(),y==null||y(),g.current=!1)},[w,y]);return r.jsx(Pp,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:x,onScrollButtonChange:C,children:r.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:j},children:r.jsx(X.div,{...o,ref:m,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Ri.displayName=Rp;var _p="SelectPopperPosition",vr=i.forwardRef((e,t)=>{const{__scopeSelect:n,align:s="start",collisionPadding:o=Re,...a}=e,l=In(n);return r.jsx(xp,{...l,...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)"}})});vr.displayName=_p;var[Pp,ts]=Pt(pt,{}),br="SelectViewport",_i=i.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:s,...o}=e,a=st(br,n),l=ts(br,n),c=se(t,a.onViewportChange),d=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(Dn.Slot,{scope:n,children:r.jsx(X.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:G(o.onScroll,f=>{const u=f.currentTarget,{contentWrapper:m,shouldExpandOnScrollRef:h}=l;if(h!=null&&h.current&&m){const x=Math.abs(d.current-u.scrollTop);if(x>0){const g=window.innerHeight-Re*2,p=parseFloat(m.style.minHeight),v=parseFloat(m.style.height),b=Math.max(p,v);if(b<g){const y=b+x,w=Math.min(g,y),j=y-w;m.style.height=w+"px",m.style.bottom==="0px"&&(u.scrollTop=j>0?j:0,m.style.justifyContent="flex-end")}}}d.current=u.scrollTop})})})]})});_i.displayName=br;var Pi="SelectGroup",[Dp,Mp]=Pt(Pi),Ip=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=Xe();return r.jsx(Dp,{scope:n,id:o,children:r.jsx(X.div,{role:"group","aria-labelledby":o,...s,ref:t})})});Ip.displayName=Pi;var Di="SelectLabel",Mi=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=Mp(Di,n);return r.jsx(X.div,{id:o.id,...s,ref:t})});Mi.displayName=Di;var yn="SelectItem",[Op,Ii]=Pt(yn),Oi=i.forwardRef((e,t)=>{const{__scopeSelect:n,value:s,disabled:o=!1,textValue:a,...l}=e,c=rt(yn,n),d=st(yn,n),f=c.value===s,[u,m]=i.useState(a??""),[h,x]=i.useState(!1),g=se(t,y=>{var w;return(w=d.itemRefCallback)==null?void 0:w.call(d,y,s,o)}),p=Xe(),v=i.useRef("touch"),b=()=>{o||(c.onValueChange(s),c.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(Op,{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(Dn.ItemSlot,{scope:n,value:s,disabled:o,textValue:u,children:r.jsx(X.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,...l,ref:g,onFocus:G(l.onFocus,()=>x(!0)),onBlur:G(l.onBlur,()=>x(!1)),onClick:G(l.onClick,()=>{v.current!=="mouse"&&b()}),onPointerUp:G(l.onPointerUp,()=>{v.current==="mouse"&&b()}),onPointerDown:G(l.onPointerDown,y=>{v.current=y.pointerType}),onPointerMove:G(l.onPointerMove,y=>{var w;v.current=y.pointerType,o?(w=d.onItemLeave)==null||w.call(d):v.current==="mouse"&&y.currentTarget.focus({preventScroll:!0})}),onPointerLeave:G(l.onPointerLeave,y=>{var w;y.currentTarget===document.activeElement&&((w=d.onItemLeave)==null||w.call(d))}),onKeyDown:G(l.onKeyDown,y=>{var j;((j=d.searchRef)==null?void 0:j.current)!==""&&y.key===" "||(wp.includes(y.key)&&b(),y.key===" "&&y.preventDefault())})})})})});Oi.displayName=yn;var Mt="SelectItemText",Li=i.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:o,...a}=e,l=rt(Mt,n),c=st(Mt,n),d=Ii(Mt,n),f=Cp(Mt,n),[u,m]=i.useState(null),h=se(t,b=>m(b),d.onItemTextChange,b=>{var y;return(y=c.itemTextRefCallback)==null?void 0:y.call(c,b,d.value,d.disabled)}),x=u==null?void 0:u.textContent,g=i.useMemo(()=>r.jsx("option",{value:d.value,disabled:d.disabled,children:x},d.value),[d.disabled,d.value,x]),{onNativeOptionAdd:p,onNativeOptionRemove:v}=f;return ge(()=>(p(g),()=>v(g)),[p,v,g]),r.jsxs(r.Fragment,{children:[r.jsx(X.span,{id:d.textId,...a,ref:h}),d.isSelected&&l.valueNode&&!l.valueNodeHasChildren?Nn.createPortal(a.children,l.valueNode):null]})});Li.displayName=Mt;var $i="SelectItemIndicator",Fi=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return Ii($i,n).isSelected?r.jsx(X.span,{"aria-hidden":!0,...s,ref:t}):null});Fi.displayName=$i;var yr="SelectScrollUpButton",Bi=i.forwardRef((e,t)=>{const n=st(yr,e.__scopeSelect),s=ts(yr,e.__scopeSelect),[o,a]=i.useState(!1),l=se(t,s.onScrollButtonChange);return ge(()=>{if(n.viewport&&n.isPositioned){let c=function(){const f=d.scrollTop>0;a(f)};const d=n.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?r.jsx(Vi,{...e,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop-d.offsetHeight)}}):null});Bi.displayName=yr;var wr="SelectScrollDownButton",Ui=i.forwardRef((e,t)=>{const n=st(wr,e.__scopeSelect),s=ts(wr,e.__scopeSelect),[o,a]=i.useState(!1),l=se(t,s.onScrollButtonChange);return ge(()=>{if(n.viewport&&n.isPositioned){let c=function(){const f=d.scrollHeight-d.clientHeight,u=Math.ceil(d.scrollTop)<f;a(u)};const d=n.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?r.jsx(Vi,{...e,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop+d.offsetHeight)}}):null});Ui.displayName=wr;var Vi=i.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:s,...o}=e,a=st("SelectScrollButton",n),l=i.useRef(null),c=Mn(n),d=i.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return i.useEffect(()=>()=>d(),[d]),ge(()=>{var u;const f=c().find(m=>m.ref.current===document.activeElement);(u=f==null?void 0:f.ref.current)==null||u.scrollIntoView({block:"nearest"})},[c]),r.jsx(X.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:G(o.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(s,50))}),onPointerMove:G(o.onPointerMove,()=>{var f;(f=a.onItemLeave)==null||f.call(a),l.current===null&&(l.current=window.setInterval(s,50))}),onPointerLeave:G(o.onPointerLeave,()=>{d()})})}),Lp="SelectSeparator",Wi=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return r.jsx(X.div,{"aria-hidden":!0,...s,ref:t})});Wi.displayName=Lp;var Nr="SelectArrow",$p=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=In(n),a=rt(Nr,n),l=st(Nr,n);return a.open&&l.position==="popper"?r.jsx(gp,{...o,...s,ref:t}):null});$p.displayName=Nr;var Fp="SelectBubbleInput",zi=i.forwardRef(({__scopeSelect:e,value:t,...n},s)=>{const o=i.useRef(null),a=se(s,o),l=vi(t);return i.useEffect(()=>{const c=o.current;if(!c)return;const d=window.HTMLSelectElement.prototype,u=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==t&&u){const m=new Event("change",{bubbles:!0});u.call(c,t),c.dispatchEvent(m)}},[l,t]),r.jsx(X.select,{...n,style:{...bi,...n.style},ref:a,defaultValue:t})});zi.displayName=Fp;function Hi(e){return e===""||e===void 0}function Ki(e){const t=Qe(e),n=i.useRef(""),s=i.useRef(0),o=i.useCallback(l=>{const c=n.current+l;t(c),(function d(f){n.current=f,window.clearTimeout(s.current),f!==""&&(s.current=window.setTimeout(()=>d(""),1e3))})(c)},[t]),a=i.useCallback(()=>{n.current="",window.clearTimeout(s.current)},[]);return i.useEffect(()=>()=>window.clearTimeout(s.current),[]),[n,o,a]}function qi(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 l=Bp(e,Math.max(a,0));o.length===1&&(l=l.filter(f=>f!==n));const d=l.find(f=>f.textValue.toLowerCase().startsWith(o.toLowerCase()));return d!==n?d:void 0}function Bp(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Up=yi,Gi=Ni,Vp=Si,Wp=Ci,zp=ki,Yi=Ei,Hp=_i,Xi=Mi,Ji=Oi,Kp=Li,qp=Fi,Zi=Bi,Qi=Ui,el=Wi;const Ee=Up,Te=Vp,be=i.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(Gi,{ref:s,className:V("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(Wp,{asChild:!0,children:r.jsx(Ue,{className:"h-4 w-4 opacity-50"})})]}));be.displayName=Gi.displayName;const tl=i.forwardRef(({className:e,...t},n)=>r.jsx(Zi,{ref:n,className:V("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(Tr,{className:"h-4 w-4"})}));tl.displayName=Zi.displayName;const nl=i.forwardRef(({className:e,...t},n)=>r.jsx(Qi,{ref:n,className:V("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(Ue,{className:"h-4 w-4"})}));nl.displayName=Qi.displayName;const ye=i.forwardRef(({className:e,children:t,position:n="popper",...s},o)=>r.jsx(zp,{children:r.jsxs(Yi,{ref:o,className:V("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(tl,{}),r.jsx(Hp,{className:V("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),r.jsx(nl,{})]})}));ye.displayName=Yi.displayName;const Gp=i.forwardRef(({className:e,...t},n)=>r.jsx(Xi,{ref:n,className:V("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Gp.displayName=Xi.displayName;const ae=i.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(Ji,{ref:s,className:V("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(qp,{children:r.jsx(Er,{className:"h-4 w-4"})})}),r.jsx(Kp,{children:t})]}));ae.displayName=Ji.displayName;const Yp=i.forwardRef(({className:e,...t},n)=>r.jsx(el,{ref:n,className:V("-mx-1 my-1 h-px bg-muted",e),...t}));Yp.displayName=el.displayName;const rl=[{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"}],Xp=new Set(rl.filter(e=>e.supportsFollowUp).map(e=>e.value));function Jp(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 eo(){return rl.map(e=>r.jsx(ae,{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 to(e,t,n=!1){const s=e.trim();if(s)return s;const o=t.trim().split(`
|
|
210
|
-
`).map(a=>a.trim()).find(Boolean);return o?o.length>72?`${o.slice(0,69).trimEnd()}...`:o:n?"Image task":""}function Zp({nodes:e,currentNodeRole:t,leaderNodeId:n,onCreated:s,onCancel:o,className:a,footerClassName:l,submitLabel:c="Create chat",cancelLabel:d="Cancel",autoFocus:f=!1,layout:u="default"}){const[m,h]=i.useState(""),[x,g]=i.useState(""),[p,v]=i.useState("claudecode"),[b,y]=i.useState(""),[w,j]=i.useState("select"),[k,C]=i.useState("normal"),[S,R]=i.useState("auto"),[L,B]=i.useState(!1),[O,U]=i.useState(!1),{images:$,error:F,fileInputRef:H,pickImages:P,handleFileChange:_,handlePaste:D,removeImage:E}=ia(),Y=i.useMemo(()=>Jp(e,{currentNodeRole:t,leaderNodeId:n}),[e,t,n]);i.useEffect(()=>{S!=="auto"&&(Y.some(A=>A.id===S)||R("auto"))},[S,Y]);const re=i.useMemo(()=>{if(S!=="auto"){const te=e.find(de=>de.id===S);return(te==null?void 0:te.workDirFolders)??[]}const A=new Set;for(const te of Y)for(const de of te.workDirFolders??[])A.add(de);return[...A].sort()},[S,e,Y]),le=i.useCallback(async A=>{A.preventDefault();const te=to(m,x,$.length>0),de=x.trim()||te;if(!(!te||!de||!p)){B(!0);try{const Ce=_r(x,$),ze=await Yl({title:te,description:de,agent:p,project:b.trim()||null,payload:{initialMessage:Ce},priority:k,assignTo:S==="auto"?void 0:S});s(ze)}catch(Ce){me.error(Ce instanceof Error?Ce.message:"Failed to create task")}finally{B(!1)}}},[m,x,p,b,$,k,S,s]),pe=to(m,x,$.length>0),ue=!!(pe&&p&&(x.trim()||$.length>0)),ve=i.useCallback(A=>{var te;A.nativeEvent.isComposing||A.key==="Enter"&&A.shiftKey&&ue&&!L&&(A.preventDefault(),(te=A.currentTarget.form)==null||te.requestSubmit())},[ue,L]),xe=b||"__none__",M=re.length>0,J=$.length>0&&r.jsx("div",{className:"flex flex-wrap gap-3",children:$.map((A,te)=>r.jsxs("div",{className:"relative",children:[r.jsx("img",{src:Pr(A),alt:A.filename??`attachment ${te+1}`,className:"h-24 w-24 rounded-2xl border border-border/70 object-cover"}),r.jsx("button",{type:"button",onClick:()=>E(te),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 ${A.filename??`image ${te+1}`}`,children:r.jsx(Ar,{className:"h-3.5 w-3.5"})})]},`${A.filename??"image"}-${te}`))}),ie=r.jsxs("div",{className:"space-y-2",children:[r.jsx(qe,{className:"text-sm font-medium",children:"Assign to"}),r.jsxs(Ee,{value:S,onValueChange:R,children:[r.jsx(be,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:r.jsx(Te,{placeholder:"Auto-assign"})}),r.jsxs(ye,{children:[r.jsx(ae,{value:"auto",children:"Auto-assign"}),Y.map(A=>r.jsx(ae,{value:A.id,children:A.name},A.id))]})]})]}),q=r.jsxs("div",{className:"space-y-2",children:[r.jsx(qe,{className:"text-sm font-medium",children:"Agent"}),r.jsxs(Ee,{value:p,onValueChange:v,children:[r.jsx(be,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:r.jsx(Te,{placeholder:"Select agent"})}),r.jsx(ye,{children:eo()})]})]}),W=r.jsxs("div",{className:"space-y-2",children:[r.jsx(qe,{className:"text-sm font-medium",children:"Priority"}),r.jsxs(Ee,{value:k,onValueChange:C,children:[r.jsx(be,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:r.jsx(Te,{placeholder:"Select priority"})}),r.jsxs(ye,{children:[r.jsx(ae,{value:"low",children:"Low"}),r.jsx(ae,{value:"normal",children:"Normal"}),r.jsx(ae,{value:"high",children:"High"}),r.jsx(ae,{value:"critical",children:"Critical"})]})]})]}),z=r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:"Chat title"}),r.jsx(ct,{id:"task-title-composer",type:"text",value:m,onChange:A=>h(A.target.value),placeholder:"Optional. Leave blank to derive it from the prompt.",className:"h-10 rounded-2xl border-border/70 bg-background/60 px-3.5 shadow-none"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:pe?`Will appear as: ${pe}`:"A title will be generated from the first line of the prompt."})]}),ce=r.jsxs("div",{className:"space-y-2",children:[r.jsx(qe,{className:"text-sm font-medium",children:"Working directory"}),w==="select"&&M?r.jsxs(Ee,{value:xe,onValueChange:A=>{if(A==="__custom__"){j("custom"),y("");return}y(A==="__none__"?"":A)},children:[r.jsx(be,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:r.jsx(Te,{placeholder:"Select folder or use the node default"})}),r.jsxs(ye,{children:[r.jsx(ae,{value:"__none__",children:"Use node default"}),re.map(A=>r.jsx(ae,{value:A,children:A},A)),r.jsx(ae,{value:"__custom__",children:"Custom path..."})]})]}):r.jsxs("div",{className:"flex gap-2",children:[r.jsx(ct,{id:"task-project",type:"text",value:b,onChange:A=>y(A.target.value),placeholder:"Optional path (absolute or relative to node work dir)",className:"h-11 flex-1 rounded-2xl border-border/70 bg-background/70"}),M&&r.jsx(K,{type:"button",variant:"outline",onClick:()=>{j("select"),y("")},className:"h-11 rounded-2xl",children:"Browse"})]})]});return u==="composer"?r.jsxs("form",{onSubmit:le,className:V("space-y-4",a),children:[r.jsx("input",{ref:H,type:"file",accept:"image/*",multiple:!0,onChange:_,className:"hidden"}),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.jsx("textarea",{id:"task-description",value:x,onChange:A=>g(A.target.value),onKeyDown:ve,onPaste:D,placeholder:"Ask anything...",rows:4,autoFocus:f,"aria-label":"Opening prompt",className:"min-h-[140px] w-full resize-none rounded-[24px] bg-transparent px-5 pt-5 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-4 left-4 right-4 flex flex-wrap items-end justify-between gap-3",children:[r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[r.jsxs(K,{type:"button",variant:"ghost",size:"sm",onClick:P,className:"h-9 gap-1.5 rounded-full px-3 text-xs text-muted-foreground hover:text-foreground",children:[r.jsx(ar,{className:"h-3.5 w-3.5"}),"Images"]}),r.jsxs(Ee,{value:S,onValueChange:R,children:[r.jsx(be,{className:"h-9 w-auto gap-1.5 rounded-full border-border/70 bg-background/55 px-3.5 text-xs shadow-none",children:r.jsx(Te,{placeholder:"Auto-assign"})}),r.jsxs(ye,{children:[r.jsx(ae,{value:"auto",children:"Auto-assign"}),Y.map(A=>r.jsx(ae,{value:A.id,children:A.name},A.id))]})]}),r.jsxs(Ee,{value:p,onValueChange:v,children:[r.jsx(be,{className:"h-9 w-auto gap-1.5 rounded-full border-border/70 bg-background/55 px-3.5 text-xs shadow-none",children:r.jsx(Te,{placeholder:"Agent"})}),r.jsx(ye,{children:eo()})]}),r.jsxs(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>U(!O),"aria-controls":"task-composer-settings","aria-expanded":O,className:"h-9 gap-1.5 rounded-full px-3 text-xs text-muted-foreground hover:text-foreground",children:[r.jsx(Xc,{className:"h-3.5 w-3.5"}),O?r.jsx(Tr,{className:"h-3 w-3"}):r.jsx(Ue,{className:"h-3 w-3"})]})]}),r.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[o&&r.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:o,className:"h-9 rounded-full px-4 text-xs text-muted-foreground",children:d}),r.jsxs(K,{type:"submit",size:"icon",disabled:!ue||L,className:"h-10 w-10 rounded-full shadow-[0_8px_30px_-8px_hsl(var(--primary)/0.6)]",children:[L?r.jsx(Ie,{className:"h-4 w-4 animate-spin"}):r.jsx(go,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:L?"Creating chat":c})]})]})]})]}),(J||F)&&r.jsxs("div",{className:"space-y-3 rounded-[20px] border border-border/60 bg-background/45 p-4",children:[J,F&&r.jsx("div",{className:"text-xs text-destructive",children:F}),!F&&r.jsx("div",{className:"text-xs text-muted-foreground",children:"Shift+Enter starts the chat. Enter adds a new line. Paste screenshots directly into the prompt box or use the Images button."})]}),O&&r.jsxs("div",{id:"task-composer-settings",className:"grid gap-4 rounded-[20px] border border-border/60 bg-background/45 p-5 sm:grid-cols-2",children:[r.jsx("div",{className:"space-y-2 sm:col-span-2",children:z}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:[r.jsx(_c,{className:"h-3.5 w-3.5"}),"Working directory"]}),w==="select"&&M?r.jsxs(Ee,{value:xe,onValueChange:A=>{if(A==="__custom__"){j("custom"),y("");return}y(A==="__none__"?"":A)},children:[r.jsx(be,{className:"h-10 rounded-2xl border-border/70 bg-background/60 px-3.5 text-sm shadow-none",children:r.jsx(Te,{placeholder:"Use node default"})}),r.jsxs(ye,{children:[r.jsx(ae,{value:"__none__",children:"Use node default"}),re.map(A=>r.jsx(ae,{value:A,children:A},A)),r.jsx(ae,{value:"__custom__",children:"Custom path..."})]})]}):r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ct,{id:"task-project",type:"text",value:b,onChange:A=>y(A.target.value),placeholder:"Optional path",className:"h-10 rounded-2xl border-border/70 bg-background/60 px-3.5 shadow-none"}),M&&r.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>{j("select"),y("")},className:"h-9 shrink-0 rounded-2xl px-3",children:"Browse"})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:"Priority"}),r.jsxs(Ee,{value:k,onValueChange:C,children:[r.jsx(be,{className:"h-10 rounded-2xl border-border/70 bg-background/60 px-3.5 text-sm shadow-none",children:r.jsx(Te,{placeholder:"Select priority"})}),r.jsxs(ye,{children:[r.jsx(ae,{value:"low",children:"Low"}),r.jsx(ae,{value:"normal",children:"Normal"}),r.jsx(ae,{value:"high",children:"High"}),r.jsx(ae,{value:"critical",children:"Critical"})]})]})]})]})]}):r.jsxs("form",{onSubmit:le,className:V("space-y-5",a),children:[r.jsx("input",{ref:H,type:"file",accept:"image/*",multiple:!0,onChange:_,className:"hidden"}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(qe,{htmlFor:"task-description",className:"text-sm font-medium",children:"Opening prompt"}),r.jsx("textarea",{id:"task-description",value:x,onChange:A=>g(A.target.value),onKeyDown:ve,onPaste:D,placeholder:"Describe what the agent should do. This becomes the first message in the chat.",rows:6,autoFocus:f,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(K,{type:"button",variant:"outline",onClick:P,className:"rounded-2xl",children:[r.jsx(ar,{className:"h-4 w-4"}),"Add images"]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Shift+Enter starts the chat. Enter adds a new line. Upload or paste screenshots and reference images with the opening prompt."})]}),J,F&&r.jsx("p",{className:"text-xs text-destructive",children:F})]}),r.jsxs("div",{className:"grid gap-5 lg:grid-cols-[minmax(0,1fr)_220px]",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(qe,{htmlFor:"task-title",className:"text-sm font-medium",children:"Chat title"}),r.jsx(ct,{id:"task-title",type:"text",value:m,onChange:A=>h(A.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:pe?`Will appear as: ${pe}`:"A title will be generated from the first line of the prompt."})]}),q]}),ce,r.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[W,ie]}),r.jsxs("div",{className:V("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",l),children:[o&&r.jsx(K,{type:"button",variant:"ghost",onClick:o,className:"rounded-2xl",children:d}),r.jsx(K,{type:"submit",disabled:!ue||L,className:"rounded-2xl px-5",children:L?"Creating...":c})]})]})}const Qp=[{value:"active",label:"Active"},{value:"running",label:"Running"},{value:"waiting",label:"Waiting"},{value:"closed",label:"Closed"},{value:"archived",label:"Archived"}],wn=new Set(["pending","assigned"]),sl=new Set(["running"]),eh=new Set(["completed","failed","cancelled"]);function th(e,t){switch(t){case"running":return sl.has(e.status);case"waiting":return wn.has(e.status);case"closed":return eh.has(e.status);case"archived":return e.status==="archived";case"active":default:return e.status!=="archived"}}function nh(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 ns(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 rh(e,t,n){return ns(e,t,n).toLowerCase()}function sh(e,t){return[...e].sort((n,s)=>n.id===t?-1:s.id===t?1:n.name.localeCompare(s.name))}function oh(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 ah(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 ih(e){return e==="default workspace"?e:e.replace(/\\/g,"/").split("/").filter(Boolean).at(-1)??e}function lh(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 ch(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 dh(e){return new Date(e).toLocaleString()}function uh(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),me.success(t),!0;const a=globalThis.document,l=(o=a==null?void 0:a.execCommand)==null?void 0:o.bind(a);if(!(a!=null&&a.body)||typeof a.createElement!="function"||typeof l!="function")throw new Error("Clipboard access is unavailable");const c=a.createElement("textarea"),d=a.activeElement,f=d&&typeof d.focus=="function"?d:null;c.value=e,c.setAttribute("readonly","true"),c.style.position="fixed",c.style.opacity="0",c.style.pointerEvents="none",a.body.appendChild(c),c.select(),c.setSelectionRange(0,c.value.length);const u=l("copy");if(a.body.removeChild(c),f==null||f.focus(),!u)throw new Error("Clipboard access is unavailable");return me.success(t),!0}catch(a){return me.error(a instanceof Error?a.message:"Failed to copy"),!1}}function wt({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 sr({label:e}){return r.jsx("div",{className:"flex h-64 items-center justify-center text-sm text-muted-foreground",children:e})}function Ne({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:V("min-w-0 flex-1 break-all text-sm text-foreground",n&&"font-mono text-[11px] leading-5"),children:t}),s]})]})}function jr({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:V("mt-1 text-sm font-medium text-foreground",n&&"font-mono text-[11px]"),children:t})]})}function ol({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(je,{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 fh=i.lazy(async()=>({default:(await Cr(()=>import("./FilesTab-DlIJQ12D.js"),__vite__mapDeps([0,1,2,3]))).FilesTab})),mh=i.lazy(async()=>({default:(await Cr(()=>import("./PreviewTab-Czs-1ywX.js"),__vite__mapDeps([4,1,2]))).PreviewTab})),ph=i.lazy(async()=>({default:(await Cr(()=>import("./DiffTab-BIU9YkOP.js"),__vite__mapDeps([5,1,2,3]))).DiffTab}));function hh({onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:l,activeTab:c,setActiveTab:d,creatingTask:f,activeTask:u,assignedNode:m,taskLoading:h,taskError:x,displayEvents:g,hasUserMessageInLogs:p,initialPrompt:v,supportsFollowUp:b,taskUnavailable:y,chatDisabled:w,chatDisabledReason:j,questionBypassEnabled:k,isRunning:C,hasPendingFollowUp:S,canCancel:R,canRetry:L,onRetry:B,onCancel:O,onStartCreateTask:U,onCancelCreateTask:$,onCreateTask:F,onSendMessage:H,onQuestionBypassChange:P,onSubmitQuestionResponse:_,messagesEndRef:D}){const[E,Y]=i.useState(!1),[re,le]=i.useState(!1),pe=i.useRef(0),ue=i.useRef(!1),ve=i.useCallback(q=>{const W=q.currentTarget,z=pe.current;if(pe.current=W.scrollTop,ue.current)return;if(W.scrollHeight-W.scrollTop-W.clientHeight<30){le(!1),ue.current=!0,setTimeout(()=>{ue.current=!1},300);return}W.scrollTop<z&&z-W.scrollTop>10&&le(!0),W.scrollTop<=0&&le(!0)},[]),xe=(u==null?void 0:u.effectiveProjectPath)??(u==null?void 0:u.project)??"default workspace",M=u?(m==null?void 0:m.name)??ns(u.assignedTo,a==null?void 0:a.nodes,u.assignedNodeName):"unassigned",J=u?[{label:"Working dir",value:xe,mono:!0},{label:"Agent",value:u.agent,mono:!0},{label:"Node",value:M}]:[],ie=u!=null&&u.description&&u.description!==u.title?u.description:null;return f?r.jsx(xh,{onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:l,onCancel:$,onCreated:F}):!u&&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(sn,{onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:l})}),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(Ie,{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(Ie,{className:"h-4 w-4 animate-spin"}),"Fetching the selected chat thread..."]})]})]})})]}):u?r.jsxs(Ta,{value:c,onValueChange:d,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(sn,{onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:l})}),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:u.title,children:u.title}),r.jsx(io,{status:u.status}),r.jsx(Xl,{priority:u.priority}),r.jsx(K,{variant:"ghost",size:"icon",className:"ml-auto h-6 w-6 shrink-0 rounded-full text-muted-foreground",onClick:()=>Y(q=>!q),children:E?r.jsx(Tr,{className:"h-3.5 w-3.5"}):r.jsx(Ue,{className:"h-3.5 w-3.5"})})]}),E&&r.jsxs("div",{className:"mt-2 space-y-2",children:[ie&&r.jsx("p",{className:"max-w-3xl text-sm leading-5 text-muted-foreground",children:ie}),x&&r.jsx("div",{className:"w-fit rounded-full border border-destructive/25 bg-destructive/10 px-3 py-1 text-xs text-destructive",children:x}),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 ",dh(u.updatedAt)]}),r.jsx("span",{className:"font-mono",children:u.id.slice(0,8)})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[L&&r.jsxs(K,{variant:"outline",size:"sm",onClick:B,className:"shrink-0 rounded-full",children:[r.jsx(Kc,{className:"h-3.5 w-3.5"}),"Retry"]}),R&&r.jsxs(mr,{children:[r.jsx(pr,{asChild:!0,children:r.jsxs(K,{variant:"destructive",size:"sm",className:"shrink-0 rounded-full",children:[r.jsx(uo,{className:"h-3.5 w-3.5"}),"Cancel"]})}),r.jsxs(cn,{children:[r.jsxs(dn,{children:[r.jsx(fn,{children:"Cancel this task?"}),r.jsx(mn,{children:"The task will stop and move to a cancelled state."})]}),r.jsxs(un,{children:[r.jsx(hn,{children:"No"}),r.jsx(pn,{onClick:O,children:"Yes, cancel"})]})]})]})]})]})]}),r.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[r.jsxs(Kr,{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(je,{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(je,{variant:"outline",className:"hidden rounded-full border-primary/30 bg-primary/10 text-primary sm:inline-flex",children:"Queued"}),y&&r.jsx(je,{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:ve,children:r.jsxs("div",{className:"mx-auto flex max-w-4xl flex-col gap-5",children:[v&&!p&&r.jsx(Bs,{event:v,questionBypassEnabled:k,onQuestionBypassChange:P,onSubmitQuestionResponse:_,questionResponseDisabled:!b||w}),g.map((q,W)=>r.jsx(Bs,{event:q,questionBypassEnabled:k,onQuestionBypassChange:P,onSubmitQuestionResponse:_,questionResponseDisabled:!b||w},Rd("transcript",q,W))),g.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&&u.result||u.error)&&r.jsxs("div",{className:"space-y-3",children:[!b&&u.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(u.result,null,2)})]}),u.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:u.error})]})]}),(C||S)&&g.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(Ie,{className:"h-4 w-4 animate-spin"}),"The agent is still working on this conversation."]}),r.jsx("div",{ref:D})]})}),b?re?r.jsx(K,{size:"icon",onClick:()=>le(!1),className:"absolute bottom-4 right-4 z-10 h-12 w-12 rounded-full shadow-lg",children:r.jsx(zc,{className:"h-5 w-5"})}):r.jsx("div",{className:"shrink-0",children:r.jsx("div",{className:"mx-auto w-full max-w-4xl",children:r.jsx(wf,{onSend:H,disabled:w,disabledReason:j,contextItems:J,placeholder:w?j:"Continue the conversation..."})})}):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(sr,{label:"Loading files..."}),children:r.jsx(fh,{taskId:u.id})})}),r.jsx(Ye,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:r.jsx(i.Suspense,{fallback:r.jsx(sr,{label:"Loading preview..."}),children:r.jsx(mh,{taskId:u.id})})}),r.jsx(Ye,{value:"diff",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:r.jsx(i.Suspense,{fallback:r.jsx(sr,{label:"Loading diff..."}),children:r.jsx(ph,{taskId:u.id})})})]}):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(sn,{onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:l})}),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(kr,{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(K,{onClick:U,className:"mt-6 rounded-full px-5",children:[r.jsx(po,{className:"h-4 w-4"}),"Start new chat"]}),x&&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:x})]})})]})}function xh({onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:l,onCancel:c,onCreated:d}){var f,u;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(sn,{onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:l})}),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.jsxs("div",{className:"w-full max-w-2xl space-y-8",children:[r.jsxs("div",{className:"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(kr,{className:"h-7 w-7"})}),r.jsx("h2",{className:"mt-5 text-xl font-semibold tracking-tight text-foreground sm:text-3xl",children:"What should your agent do?"}),r.jsx("p",{className:"mx-auto mt-3 max-w-md text-sm leading-6 text-muted-foreground",children:"Describe what you want to build, fix, or explore. A new chat will open once the task is created."})]}),r.jsx(Zp,{nodes:(a==null?void 0:a.nodes)??[],currentNodeRole:(f=a==null?void 0:a.self)==null?void 0:f.role,leaderNodeId:((u=a==null?void 0:a.leader)==null?void 0:u.id)??null,onCreated:d,onCancel:c,submitLabel:"Start chat",autoFocus:!0,layout:"composer"})]})})]})}function sn({onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:l}){var c;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(gh,{desktopTasksOpen:t,mobileTasksPanelOpen:n,onToggleTasks:e}),r.jsx(je,{variant:"outline",className:"hidden rounded-full border-border/70 bg-background/60 sm:inline-flex",children:l?"Live":"Retrying"}),((c=a==null?void 0:a.leader)==null?void 0:c.name)&&r.jsxs(je,{variant:"outline",className:"hidden rounded-full border-border/70 bg-background/60 sm:inline-flex",children:["leader ",a.leader.name]})]}),r.jsxs(K,{variant:"outline",onClick:o,className:"shrink-0 rounded-full border-border/70 bg-background/60 px-3 sm:px-4",children:[s?r.jsx(xo,{className:"h-4 w-4"}):r.jsx(Vc,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline",children:s?"Hide cluster":"Show cluster"})]})]})}function gh({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(K,{variant:"outline",onClick:n,className:"rounded-full border-border/70 bg-background/60 px-3 sm:px-4",children:[s?r.jsx(ho,{className:"h-4 w-4"}):r.jsx(Fc,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline",children:s?"Hide tasks":"Show tasks"})]})}const vh={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 bh(e){return e.split(".")[0]??"unknown"}function yh(e){return new Date(e).toLocaleTimeString("en-US",{hour12:!1})}function or(e,t){return(t==null?void 0:t.get(e))??e}function wh(e,t){const n=e.data;switch(e.type){case"node.joined":return`${n.name} joined the cluster`;case"node.left":return`${or(n.nodeId,t)} left (${n.reason})`;case"node.status":return`${or(n.nodeId,t)} is now ${n.status}`;case"task.created":return`"${n.title}" created`;case"task.assigned":return`task assigned to ${or(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 Nh(e){return JSON.stringify(e,null,2)}function jh({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 l=bh(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:yh(a.timestamp)}),r.jsx(je,{variant:"outline",className:V("w-fit text-[10px] font-medium uppercase tracking-[0.16em]",vh[l]),children:a.type})]}),r.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-full text-muted-foreground",onClick:()=>void Je(Nh(a),"Event copied"),"aria-label":`Copy ${a.type} event`,title:"Copy event",children:r.jsx(fo,{className:"h-3.5 w-3.5"})})]}),r.jsx("div",{className:"text-sm leading-6 text-foreground/85",children:wh(a,o)})]})},a.id)})})})}function no({cluster:e,systemInfo:t,nodeNameById:n,nodeBlockingTaskCounts:s,eventTypeFilter:o,onEventTypeFilterChange:a,eventTypeOptions:l,filteredEvents:c,sseConnected:d,clusterLoading:f,clusterError:u,electionPending:m,onTriggerElection:h,promotePending:x,onPromote:g,onAddNode:p,leavePending:v,onLeaveCluster:b,onToggleNodeDevTunnel:y,devTunnelNodeId:w,onClose:j}){var U,$,F,H,P;const k=((U=e==null?void 0:e.self)==null?void 0:U.role)==="leader",C=(($=e==null?void 0:e.self)==null?void 0:$.role)==="follower"&&!(e!=null&&e.leader),S=(e==null?void 0:e.self)??null,L=sh((e==null?void 0:e.nodes)??[],S==null?void 0:S.id).filter(_=>_.id!==(S==null?void 0:S.id)),B=(S==null?void 0:S.role)==="leader"&&L.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(Ta,{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(K,{variant:"ghost",size:"icon",onClick:j,className:"rounded-full",children:r.jsx(xo,{className:"h-4 w-4"})})]}),r.jsxs(Kr,{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(ro,{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(je,{variant:"outline",className:"rounded-full border-border/70 bg-background/60",children:d?"Connected":"Reconnecting"})]}),f&&!e?r.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[r.jsx(Ie,{className:"h-4 w-4 animate-spin"}),"Loading cluster state..."]}):u&&!e?r.jsx("div",{className:"rounded-[22px] border border-destructive/20 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:u}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsx(wt,{label:"Term",value:String((e==null?void 0:e.term)??0)}),r.jsx(wt,{label:"Nodes",value:String((e==null?void 0:e.nodes.length)??0)}),r.jsx(wt,{label:"Pending",value:String((e==null?void 0:e.taskSummary.pending)??0)}),r.jsx(wt,{label:"Running",value:String((e==null?void 0:e.taskSummary.running)??0)}),r.jsx(wt,{label:"Completed",value:String((e==null?void 0:e.taskSummary.completed)??0)}),r.jsx(wt,{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(Ne,{label:"Leader",value:((F=e==null?void 0:e.leader)==null?void 0:F.name)??"None"}),r.jsx(Ne,{label:"Leader URL",value:((H=e==null?void 0:e.leader)==null?void 0:H.endpoint)??"Unavailable",mono:!0,action:(P=e==null?void 0:e.leader)!=null&&P.endpoint?r.jsx(dt,{label:"Copy leader URL",onClick:()=>{var _;return void Je(((_=e.leader)==null?void 0:_.endpoint)??"","Leader URL copied")}}):void 0}),r.jsx(Ne,{label:"Feed",value:d?"Receiving live updates":"Reconnecting to event stream"})]}),r.jsxs("div",{className:"flex flex-wrap gap-2",children:[k&&r.jsxs(K,{variant:"outline",size:"sm",onClick:h,disabled:m,className:"rounded-full",children:[m&&r.jsx(Ie,{className:"h-3.5 w-3.5 animate-spin"}),"Trigger election"]}),C&&r.jsxs(K,{variant:"outline",size:"sm",onClick:g,disabled:x,className:"rounded-full",children:[x&&r.jsx(Ie,{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"}),B?r.jsx(K,{variant:"outline",size:"sm",onClick:p,className:"rounded-full",children:"Join node"}):O?r.jsxs(K,{variant:"outline",size:"sm",onClick:b,disabled:v,className:"rounded-full",children:[v&&r.jsx(Ie,{className:"h-3.5 w-3.5 animate-spin"}),"Leave cluster"]}):null]}),S&&r.jsx(ro,{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 (",L.length,")"]}),L.length>0?r.jsx("div",{className:"space-y-3",children:L.map(_=>r.jsx(Sh,{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(Jl,{className:V("h-4 w-4",d?"text-emerald-500":"text-destructive")}),"Live events"]})}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs(Ee,{value:o,onValueChange:a,children:[r.jsx(be,{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(Te,{placeholder:"Event type"})}),r.jsx(ye,{children:l.map(_=>r.jsx(ae,{value:_,className:"text-[12px]",children:_==="all"?"All event types":_},_))})]}),r.jsx(je,{variant:"outline",className:"rounded-full border-border/70 bg-background/60",children:d?"Connected":"Reconnecting"})]})]}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(jh,{events:c,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 ro({node:e,systemInfo:t,blockingTaskCount:n,devTunnelNodeId:s,onToggleNodeDevTunnel:o,showActions:a=!0,defaultExpanded:l=!1}){const[c,d]=i.useState(l),f=(t==null?void 0:t.dashboardOrigin)??e.dashboardOrigin,u=e.devtunnelEndpoint??e.endpoint,m=f??e.endpoint,h=e.previewOrigin,x=(t==null?void 0:t.workDir)??e.workDir,g=bo(e,t==null?void 0:t.transportType),p=Rr(e,t==null?void 0:t.transportType),v=p&&Et((t==null?void 0:t.transportType)??e.transportType)?!0:vo(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:()=>d(y=>!y),className:"w-full px-4 py-3.5 text-left",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[c?r.jsx(Ue,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):r.jsx(Bt,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),r.jsx(lo,{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(mo,{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(co,{role:e.role}),r.jsx(je,{variant:"outline",className:"rounded-full border-primary/30 bg-background/60 text-[10px] capitalize",children:e.status})]})]}),c&&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(Ne,{label:"Node ID",value:e.id,mono:!0}),f&&r.jsx(Ne,{label:"Dashboard",value:f,mono:!0,action:r.jsx(dt,{label:"Copy dashboard URL",onClick:()=>void Je(f,"Dashboard URL copied")})}),r.jsx(Ne,{label:"Node URL",value:u,mono:!0,action:r.jsx(dt,{label:"Copy node URL",onClick:()=>void Je(u,"Node URL copied")})}),h&&r.jsx(Ne,{label:"Preview",value:h,mono:!0,action:r.jsx(dt,{label:"Copy preview endpoint",onClick:()=>void Je(h,"Preview endpoint copied")})}),x&&r.jsx(Ne,{label:"Workspace",value:x,mono:!0})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(jr,{label:"Transport",value:g}),t&&r.jsx(jr,{label:"Uptime",value:uh(t.uptime),mono:!0})]}),r.jsx(ol,{capabilities:e.capabilities,action:a&&v?r.jsxs(K,{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(Ie,{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 Sh({node:e,isLeader:t,blockingTaskCount:n,devTunnelNodeId:s,onToggleNodeDevTunnel:o}){const[a,l]=i.useState(!1),c=e.dashboardOrigin,d=e.devtunnelEndpoint??e.endpoint,f=c??e.endpoint,u=e.previewOrigin,m=bo(e),h=Rr(e),x=vo(e),g=n>0;return r.jsxs("div",{className:"rounded-[24px] border border-border/60 bg-background/45",children:[r.jsxs("button",{type:"button",onClick:()=>l(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(Ue,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):r.jsx(Bt,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),r.jsx(lo,{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(mo,{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(co,{role:e.role}),r.jsx(je,{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(Ne,{label:"Node ID",value:e.id,mono:!0}),c&&r.jsx(Ne,{label:"Dashboard",value:c,mono:!0,action:r.jsx(dt,{label:"Copy dashboard URL",onClick:()=>void Je(c,"Dashboard URL copied")})}),r.jsx(Ne,{label:"Node URL",value:d,mono:!0,action:r.jsx(dt,{label:"Copy node URL",onClick:()=>void Je(d,"Node URL copied")})}),u&&r.jsx(Ne,{label:"Preview",value:u,mono:!0,action:r.jsx(dt,{label:"Copy preview endpoint",onClick:()=>void Je(u,"Preview endpoint copied")})}),e.workDir&&r.jsx(Ne,{label:"Workspace",value:e.workDir,mono:!0}),r.jsx(jr,{label:"Transport",value:m})]}),r.jsx(ol,{capabilities:e.capabilities,action:t&&x?r.jsxs(K,{variant:"outline",size:"sm",onClick:()=>o(e),disabled:s===e.id||g,className:"rounded-full",title:g?"Finish assigned or running tasks before changing remote access":void 0,children:[s===e.id&&r.jsx(Ie,{className:"h-3.5 w-3.5 animate-spin"}),h?"Disable Remote Access":"Enable Remote Access"]}):void 0}),t&&x&&g&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function dt({label:e,onClick:t}){return r.jsx(K,{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(fo,{className:"h-3.5 w-3.5"})})}function Ch(e,t,n,s){var l;if(!e)return{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Select a task to continue the conversation."};const o=((l=t==null?void 0:t.self)==null?void 0:l.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..."}:wn.has(e.status)||e.status==="archived"?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:wn.has(e.status)?"Task has not started yet...":"Archived tasks are read-only."}:{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Continue the conversation..."}}var On="Checkbox",[kh]=nt(On),[Eh,rs]=kh(On);function Th(e){const{__scopeCheckbox:t,checked:n,children:s,defaultChecked:o,disabled:a,form:l,name:c,onCheckedChange:d,required:f,value:u="on",internal_do_not_use_render:m}=e,[h,x]=Ct({prop:n,defaultProp:o??!1,onChange:d,caller:On}),[g,p]=i.useState(null),[v,b]=i.useState(null),y=i.useRef(!1),w=g?!!l||!!g.closest("form"):!0,j={checked:h,disabled:a,setChecked:x,control:g,setControl:p,name:c,form:l,value:u,hasConsumerStoppedPropagationRef:y,required:f,defaultChecked:Ze(o)?!1:o,isFormControl:w,bubbleInput:v,setBubbleInput:b};return r.jsx(Eh,{scope:t,...j,children:Ah(m)?m(j):s})}var al="CheckboxTrigger",il=i.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...s},o)=>{const{control:a,value:l,disabled:c,checked:d,required:f,setControl:u,setChecked:m,hasConsumerStoppedPropagationRef:h,isFormControl:x,bubbleInput:g}=rs(al,e),p=se(o,u),v=i.useRef(d);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(X.button,{type:"button",role:"checkbox","aria-checked":Ze(d)?"mixed":d,"aria-required":f,"data-state":fl(d),"data-disabled":c?"":void 0,disabled:c,value:l,...s,ref:p,onKeyDown:G(t,b=>{b.key==="Enter"&&b.preventDefault()}),onClick:G(n,b=>{m(y=>Ze(y)?!0:!y),g&&x&&(h.current=b.isPropagationStopped(),h.current||b.stopPropagation())})})});il.displayName=al;var ss=i.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:s,checked:o,defaultChecked:a,required:l,disabled:c,value:d,onCheckedChange:f,form:u,...m}=e;return r.jsx(Th,{__scopeCheckbox:n,checked:o,defaultChecked:a,disabled:c,required:l,onCheckedChange:f,name:s,form:u,value:d,internal_do_not_use_render:({isFormControl:h})=>r.jsxs(r.Fragment,{children:[r.jsx(il,{...m,ref:t,__scopeCheckbox:n}),h&&r.jsx(ul,{__scopeCheckbox:n})]})})});ss.displayName=On;var ll="CheckboxIndicator",cl=i.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:s,...o}=e,a=rs(ll,n);return r.jsx(At,{present:s||Ze(a.checked)||a.checked===!0,children:r.jsx(X.span,{"data-state":fl(a.checked),"data-disabled":a.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});cl.displayName=ll;var dl="CheckboxBubbleInput",ul=i.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:s,hasConsumerStoppedPropagationRef:o,checked:a,defaultChecked:l,required:c,disabled:d,name:f,value:u,form:m,bubbleInput:h,setBubbleInput:x}=rs(dl,e),g=se(n,x),p=vi(a),v=ii(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(X.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??b.current,required:c,disabled:d,name:f,value:u,form:m,...t,tabIndex:-1,ref:g,style:{...t.style,...v,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});ul.displayName=dl;function Ah(e){return typeof e=="function"}function Ze(e){return e==="indeterminate"}function fl(e){return Ze(e)?"indeterminate":e?"checked":"unchecked"}const Sr=i.forwardRef(({className:e,...t},n)=>r.jsx(ss,{ref:n,className:V("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(cl,{className:V("flex items-center justify-center text-current"),children:r.jsx(Er,{className:"h-3.5 w-3.5"})})}));Sr.displayName=ss.displayName;function so({toolbarTasks:e,activeTaskId:t,tasksLoading:n,tasksError:s,isLeader:o,scope:a,agentFilter:l,nodeFilter:c,agentOptions:d,nodeOptions:f,nodeNameById:u,searchQuery:m,selectedTaskIds:h,allVisibleTasksSelected:x,someVisibleTasksSelected:g,canBatchArchive:p,onSearchChange:v,onScopeChange:b,onAgentFilterChange:y,onNodeFilterChange:w,onToggleTaskSelected:j,onToggleAllVisibleTasks:k,onBatchArchive:C,onBatchDelete:S,onCreateTask:R,onSelectTask:L,onClose:B}){const[O,U]=i.useState(!!m),[$,F]=i.useState(!1),H=i.useRef(null),P=i.useRef(null),_=h.size,D=a!=="active"||c!=="all"||l!=="all";return i.useEffect(()=>{m&&U(!0)},[m]),i.useEffect(()=>{var E;O&&((E=H.current)==null||E.focus())},[O]),i.useEffect(()=>{if(!O)return;const E=re=>{var pe;const le=re.target;le instanceof Node&&((pe=P.current)!=null&&pe.contains(le)||U(!1))},Y=re=>{re.key==="Escape"&&U(!1)};return document.addEventListener("mousedown",E),document.addEventListener("keydown",Y),()=>{document.removeEventListener("mousedown",E),document.removeEventListener("keydown",Y)}},[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(K,{variant:"ghost",size:"icon",onClick:B,className:"rounded-full",children:r.jsx(ho,{className:"h-4 w-4"})})]}),r.jsxs("div",{ref:P,className:"mt-4 flex items-center gap-2",children:[r.jsxs(K,{onClick:R,className:V("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(po,{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(js,{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:H,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(K,{variant:"outline",size:"icon",onClick:()=>U(!1),className:"rounded-full border-border/70 bg-background/60",children:r.jsx(uo,{className:"h-4 w-4"})})]}):r.jsxs(r.Fragment,{children:[r.jsxs(K,{variant:"outline",onClick:()=>U(!0),className:V("rounded-full border-border/70 bg-background/60 px-4 text-sm",m&&"border-primary/40 bg-primary/8 text-primary"),children:[r.jsx(js,{className:"h-4 w-4"}),"Search"]}),r.jsx(K,{variant:$||D?"secondary":"outline",size:"icon",onClick:()=>F(E=>!E),className:V("shrink-0 rounded-full border-border/70 bg-background/60",D&&"border-primary/40 bg-primary/8 text-primary"),title:"Filters",children:r.jsx(Dc,{className:"h-4 w-4"})})]})]}),($||D)&&r.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-2 sm:grid-cols-3",children:[r.jsxs(Ee,{value:a,onValueChange:E=>b(E),children:[r.jsx(be,{className:"h-9 rounded-full border-border/70 bg-background/55 text-[12px]",children:r.jsx(Te,{})}),r.jsx(ye,{children:Qp.map(E=>r.jsx(ae,{value:E.value,className:"text-[12px]",children:E.label},E.value))})]}),r.jsxs(Ee,{value:c,onValueChange:w,children:[r.jsx(be,{className:"h-9 rounded-full border-border/70 bg-background/55 text-[12px]",children:r.jsx(Te,{placeholder:"Node"})}),r.jsx(ye,{children:f.map(E=>r.jsx(ae,{value:E.value,className:"text-[12px]",children:E.label},E.value))})]}),r.jsxs(Ee,{value:l,onValueChange:y,children:[r.jsx(be,{className:"h-9 rounded-full border-border/70 bg-background/55 text-[12px]",children:r.jsx(Te,{placeholder:"Agent"})}),r.jsx(ye,{children:d.map(E=>r.jsx(ae,{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(Sr,{checked:g&&!x?"indeterminate":x,onCheckedChange:E=>k(E===!0),"aria-label":"Select all visible tasks"}),r.jsx("span",{children:"Select all"})]}),_>0&&r.jsx(K,{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:V("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:Y=>Y.stopPropagation(),children:r.jsx(Sr,{checked:h.has(E.id),onCheckedChange:Y=>j(E.id,Y===!0),"aria-label":`Select ${E.title}`})}),r.jsx("button",{type:"button",onClick:()=>L(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:V("mt-1 h-2.5 w-2.5 shrink-0 rounded-full",ah(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?u.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:ch(E.updatedAt)})]}),r.jsxs("div",{className:"mt-3 flex items-center gap-2 text-[11px] text-muted-foreground",children:[r.jsx(io,{status:E.status}),E.assignedNodeAvailable===!1&&r.jsx(je,{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:ih(E.effectiveProjectPath??E.project??"default workspace")})]}),r.jsx("div",{className:"mt-1 truncate font-mono text-[10px] text-muted-foreground/85",children:lh(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(mr,{children:[r.jsx(pr,{asChild:!0,children:r.jsxs(K,{variant:"outline",size:"sm",disabled:!p,className:"rounded-full",children:[r.jsx(gc,{className:"h-3.5 w-3.5"}),"Archive"]})}),r.jsxs(cn,{children:[r.jsxs(dn,{children:[r.jsxs(fn,{children:["Archive ",_," task",_!==1?"s":"","?"]}),r.jsx(mn,{children:"Archived tasks stay hidden from the default task view and can be reopened from the archived scope."})]}),r.jsxs(un,{children:[r.jsx(hn,{children:"Cancel"}),r.jsx(pn,{onClick:C,disabled:!p,children:"Archive"})]})]})]}),r.jsxs(mr,{children:[r.jsx(pr,{asChild:!0,children:r.jsxs(K,{variant:"destructive",size:"sm",className:"rounded-full",children:[r.jsx(ed,{className:"h-3.5 w-3.5"}),"Delete"]})}),r.jsxs(cn,{children:[r.jsxs(dn,{children:[r.jsxs(fn,{children:["Delete ",_," task",_!==1?"s":"","?"]}),r.jsx(mn,{children:"This removes the selected tasks and their saved logs."})]}),r.jsxs(un,{children:[r.jsx(hn,{children:"Cancel"}),r.jsx(pn,{onClick:S,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}):null]})}function Rh(e,t){return t.data.nodeId===e.self.id||t.data.name===e.self.name||t.data.endpoint===e.self.endpoint}function _h({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=Rh(e,s);s.type==="node.joined"&&!a&&me.success(`${o} joined the cluster`),s.type==="node.left"&&!a&&me.message(`${o} left the cluster`)})},[e,t])}function Ph(){var vs,bs,ys;const{id:e}=Zl(),t=Ql(),n=ec(),{cluster:s,systemInfo:o,events:a,sseConnected:l,subscribe:c,refresh:d,loading:f,error:u}=tc(),m=i.useMemo(()=>oh(t.state),[t.state]),[h,x]=i.useState([]),[g,p]=i.useState(!0),[v,b]=i.useState(null),[y,w]=i.useState(null),[j,k]=i.useState("active"),[C,S]=i.useState("all"),[R,L]=i.useState("all"),[B,O]=i.useState(""),U=i.useDeferredValue(B),[$,F]=i.useState(!0),[H,P]=i.useState(!1),[_,D]=i.useState(!1),[E,Y]=i.useState(()=>!!(m!=null&&m.draftNewTask)),[re,le]=i.useState(()=>m!=null&&m.draftNewTask?{route:m.returnRoute??"/",taskId:m.returnTaskId??null}:null),[pe,ue]=i.useState(!1),[ve,xe]=i.useState("transcript"),[M,J]=i.useState("all"),[ie,q]=i.useState(!1),[W,z]=i.useState(null),[ce,A]=i.useState([]),[te,de]=i.useState([]),[Ce,ze]=i.useState(!1),[ht,xt]=i.useState(null),[He,ot]=i.useState(new Set),[ml,os]=i.useState(!1),[pl,as]=i.useState(!1),[hl,is]=i.useState(!1),[xl,ls]=i.useState(null),cs=i.useRef(null),Dt=i.useRef(null),at=((vs=s==null?void 0:s.self)==null?void 0:vs.role)==="leader",Ln=(bs=s==null?void 0:s.self)==null?void 0:bs.id;_h({cluster:s,subscribe:c});const ds=i.useRef(null),us=i.useRef(null),fs=i.useRef(null),$n=()=>{var N,T;return!((T=(N=globalThis.window)==null?void 0:N.matchMedia("(min-width: 1024px)"))!=null&&T.matches)};Ss("left",()=>{$n()&&P(!0)}),Ss("right",()=>{$n()&&D(!0)}),Hn(ds,{onSwipeLeft:()=>P(!1)}),Hn(us,{onSwipeRight:()=>D(!1)}),Hn(fs,{onSwipeRight:()=>{$n()&&!H&&P(!0)},onSwipeLeft:()=>{_||D(!0)}});const he=i.useCallback(async()=>{try{const N=await nc({assignedTo:!at&&Ln?Ln:void 0,limit:100});x(N),b(null)}catch(N){b(N instanceof Error?N.message:"Failed to load tasks")}finally{p(!1)}},[at,Ln]);rc(he,1e4),i.useEffect(()=>{he()},[he]),i.useEffect(()=>c("task",he),[c,he]);const fe=i.useMemo(()=>[...h].sort((N,T)=>T.updatedAt-N.updatedAt),[h]),gl=i.useMemo(()=>{const N=new Map;for(const T of(s==null?void 0:s.nodes)??[]){const I=id(fe,T.id);I>0&&N.set(T.id,I)}return N},[s==null?void 0:s.nodes,fe]),Ae=i.useMemo(()=>fe.filter(N=>!th(N,j)||C!=="all"&&N.agent!==C||R==="unassigned"&&N.assignedTo||R!=="all"&&R!=="unassigned"&&rh(N.assignedTo,s==null?void 0:s.nodes,N.assignedNodeName)!==R?!1:U.trim()?nh(N,U):!0),[fe,j,C,R,U]);i.useEffect(()=>{ot(N=>{const T=fd(N,Ae.map(I=>I.id));return T.size===N.size?N:T})},[Ae]),i.useEffect(()=>{at||ot(new Set)},[at]);const vl=i.useMemo(()=>["all",...Array.from(new Set(fe.map(N=>N.agent))).sort()],[fe]),bl=i.useMemo(()=>{const T=Array.from(new Set(fe.map(I=>I.assignedTo).filter(I=>!!I))).map(I=>{const oe=fe.find(Z=>Z.assignedTo===I);return(s==null?void 0:s.nodes.find(Z=>Z.id===I))??{id:I,name:ns(I,s==null?void 0:s.nodes,oe==null?void 0:oe.assignedNodeName)}}).sort((I,oe)=>I.name.localeCompare(oe.name));return[{value:"all",label:"All nodes"},{value:"unassigned",label:"Unassigned"},...T.map(I=>({value:I.name.toLowerCase(),label:I.name}))]},[fe,s==null?void 0:s.nodes]),ms=i.useMemo(()=>{const N=new Map;for(const T of(s==null?void 0:s.nodes)??[])N.set(T.id,T.name);for(const T of fe)T.assignedTo&&T.assignedNodeName&&!N.has(T.assignedTo)&&N.set(T.assignedTo,T.assignedNodeName);return N},[s==null?void 0:s.nodes,fe]),Fn=i.useMemo(()=>["all",...Array.from(new Set(a.map(N=>N.type))).sort()],[a]),yl=i.useMemo(()=>M==="all"?a:a.filter(N=>N.type===M),[a,M]),wl=Ae.length>0&&Ae.every(N=>He.has(N.id)),Nl=Ae.some(N=>He.has(N.id)),jl=md(Ae,He);i.useEffect(()=>{m!=null&&m.draftNewTask&&(Y(!0),le({route:m.returnRoute??"/",taskId:m.returnTaskId??null}))},[m]),i.useEffect(()=>{M!=="all"&&!Fn.includes(M)&&J("all")},[M,Fn]),i.useEffect(()=>{Cs(e,E)&&!y&&fe[0]&&w(fe[0].id)},[e,E,y,fe]),i.useEffect(()=>{var N;Cs(e,E)&&(y&&h.some(T=>T.id===y)||w(((N=fe[0])==null?void 0:N.id)??null))},[e,E,y,fe,h]);const ne=cd({routeTaskId:e,creatingTask:E,internalSelectedTaskId:y,sortedTaskIds:fe.map(N=>N.id)}),gt=i.useMemo(()=>h.find(N=>N.id===ne)??null,[h,ne]);i.useEffect(()=>{Dt.current=ne??null},[ne]);const Ht=i.useCallback(()=>{z(null),A([]),de([]),xt(null)},[]),ke=i.useCallback(async()=>{const N=ne;if(N)try{const T=await sc(N);if(Dt.current!==N)return;z(T),xt(null)}catch(T){if(Dt.current!==N)return;z(null),A([]),de([]),xt(T instanceof Error?T.message:"Failed to load task")}finally{Dt.current===N&&ze(!1)}},[ne]),Kt=i.useCallback(async()=>{const N=ne;if(N)try{const T=await oc(N);if(Dt.current!==N)return;A(I=>_d(I,T.logs)),de(I=>Dd(I,T.logs))}catch{}},[ne]);i.useEffect(()=>{if(!ne){z(null),A([]),de([]),xt(null),ze(!1);return}xe("transcript"),z(gt),A([]),de([]),xt(null),ze(!0),ke(),Kt()},[ne,Kt,ke]),i.useEffect(()=>{var T;if(!ne||E||g||h.some(I=>I.id===ne))return;const N=((T=fe[0])==null?void 0:T.id)??null;w(N),Ht(),i.startTransition(()=>{n(N?`/tasks/${N}`:"/",{state:null})})},[ne,Ht,E,n,fe,h,g]),i.useEffect(()=>{gt&&z(N=>!N||N.id!==gt.id?N:{...N,...gt})},[gt]),i.useEffect(()=>{if(ne)return c("task",N=>{const T=N.data.taskId;if(!(typeof T!="string"||T!==ne)){if(N.type==="task.output"){const I=N.data.event;if(I){A(Z=>Pd(Z,I));const oe=Ut(I);oe&&de(Z=>Md(Z,oe))}}N.type==="task.status"&&(ke(),Kt())}})},[c,ne,ke,Kt]),i.useEffect(()=>{var N;ve==="transcript"&&((N=cs.current)==null||N.scrollIntoView({behavior:"smooth"}))},[ce,te,ve]);const Q=W??gt,Sl=Q!=null&&Q.assignedTo?(s==null?void 0:s.nodes.find(N=>N.id===Q.assignedTo))??null:null,Bn=te.length>0,Cl=Q?Xp.has(Q.agent):!1,Un=(Q==null?void 0:Q.status)==="running",kl=Q?at&&(wn.has(Q.status)||sl.has(Q.status)):!1,El=!!(Q&&at&&Q.status==="failed"),Vn=i.useMemo(()=>Ch(Q,s,Bn,!!Un),[Q,s,Bn,Un]),Tl=i.useMemo(()=>Id(ce),[ce]),Wn=i.useMemo(()=>Od([...ce,...te.map(N=>Kn(N.content,N.timestamp))]),[ce,te]),Al=i.useMemo(()=>{if(!Q)return null;const N=vd(Q);if(N.length>0)return Kn(N,new Date(Q.createdAt).toISOString());if(Wn.length>0)return null;const T=It(Q.description||Q.title);return T.length>0?Kn(T,new Date(Q.createdAt).toISOString()):null},[Q,Wn]),zn=i.useCallback(()=>{const N={route:e?`/tasks/${e}`:"/",taskId:ne};le(N),Y(!0),i.startTransition(()=>{n("/",{state:{draftNewTask:!0,returnRoute:N.route,returnTaskId:N.taskId}})})},[e,ne,n]),Rl=i.useCallback(()=>{var T;const N=(re==null?void 0:re.taskId)??((T=fe[0])==null?void 0:T.id)??null;Y(!1),le(null),w(N),i.startTransition(()=>{n((re==null?void 0:re.route)??"/",{state:null})})},[re,fe,n]),ps=i.useCallback(N=>{Y(!1),le(null),w(N),i.startTransition(()=>{n(`/tasks/${N}`,{state:null})})},[n]),_l=i.useCallback(N=>{Y(!1),le(null),x(T=>dd(T,N)),z(N),A([]),de([]),xt(null),ze(!1),xe("transcript"),w(N.id),he(),i.startTransition(()=>{n(`/tasks/${N.id}`,{state:null})})},[he,n]),qt=i.useCallback(async N=>{if(!ne)return!1;const T=`local-${Date.now()}-${Math.random().toString(16).slice(2)}`;de(I=>[...I,{id:T,content:N,timestamp:new Date().toISOString()}]);try{return await ac(ne,N),ke(),!0}catch(I){return de(oe=>oe.filter(Z=>Z.id!==T)),me.error(I instanceof Error?I.message:"Failed to send message"),!1}},[ne,ke]),Pl=i.useCallback(N=>{qt(N)},[qt]),Dl=i.useCallback(N=>qt(_r(N,[])),[qt]),Ml=i.useCallback(async()=>{if(Q)try{await ic(Q.id),ke(),he()}catch(N){me.error(N instanceof Error?N.message:"Failed to cancel task")}},[Q,ke,he]),Il=i.useCallback(async()=>{if(Q)try{await lc(Q.id),ke(),he()}catch(N){me.error(N instanceof Error?N.message:"Failed to retry task")}},[Q,ke,he]),Gt=i.useCallback((N,T=!1)=>{const I=pd(Ae,N);return w(I),(T||!I)&&Ht(),i.startTransition(()=>{n(I?`/tasks/${I}`:"/",{state:null})}),I},[Ht,Ae,n]),Ol=i.useCallback((N,T)=>{ot(I=>{const oe=new Set(I);return T?oe.add(N):oe.delete(N),oe})},[]),Ll=i.useCallback(N=>{if(!N){ot(new Set);return}ot(new Set(Ae.map(T=>T.id)))},[Ae]),$l=i.useCallback(async()=>{const N=Array.from(He);if(N.length!==0)try{const{results:T}=await cc(N),I=T.filter(Z=>!Z.ok),oe=T.filter(Z=>Z.ok).map(Z=>Z.id);ne&&oe.includes(ne)&&Gt(oe),I.length>0?me.error(`Failed to archive ${I.length} task(s): ${I.map(Z=>Z.error??Z.id).join(", ")}`):me.success(`Archived ${oe.length} task(s)`),ot(new Set(I.map(Z=>Z.id))),he()}catch(T){me.error(T instanceof Error?T.message:"Failed to archive tasks")}},[ne,he,Gt,He]),Fl=i.useCallback(async()=>{const N=Array.from(He);if(N.length!==0)try{const{results:T}=await dc(N),I=T.filter(Z=>!Z.ok),oe=T.filter(Z=>Z.ok).map(Z=>Z.id);ne&&oe.includes(ne)&&Gt(oe,!0),I.length>0?me.error(`Failed to delete ${I.length} task(s): ${I.map(Z=>Z.error??Z.id).join(", ")}`):me.success(`Deleted ${oe.length} task(s)`),ot(new Set(I.map(Z=>Z.id))),he()}catch(T){me.error(T instanceof Error?T.message:"Failed to delete tasks")}},[ne,he,Gt,He]),Bl=i.useCallback(async()=>{os(!0);try{await uc(),d()}catch(N){me.error(N instanceof Error?N.message:"Failed to trigger election")}finally{os(!1)}},[d]),Ul=i.useCallback(async()=>{as(!0);try{await fc(),d()}catch(N){me.error(N instanceof Error?N.message:"Failed to promote node")}finally{as(!1)}},[d]),Vl=i.useCallback(async()=>{is(!0);try{await mc(),me.success("This node left the remote cluster and is leading itself again."),he(),ke(),d()}catch(N){me.error(N instanceof Error?N.message:"Failed to leave cluster")}finally{is(!1)}},[ke,he,d]),Wl=i.useCallback(async N=>{var ws;const T=!Rr(N),I=N.id===((ws=s==null?void 0:s.self)==null?void 0:ws.id),oe=I?(o==null?void 0:o.transportType)??N.transportType:N.transportType,Z=I&&!T&&Et(oe);ls(N.id);try{Z?await pc("direct"):await hc(N.id,T),me.success(T?`Enabled remote access on ${N.name}`:`Disabled remote access on ${N.name}`),d()}catch(Ns){me.error(Ns instanceof Error?Ns.message:"Failed to update remote access")}finally{ls(null)}},[(ys=s==null?void 0:s.self)==null?void 0:ys.id,d,o==null?void 0:o.transportType]),hs=i.useCallback(()=>{var N,T;if((T=(N=globalThis.window)==null?void 0:N.matchMedia("(min-width: 1024px)"))!=null&&T.matches){F(I=>!I);return}P(I=>!I)},[]),xs={toolbarTasks:Ae,activeTaskId:ne,tasksLoading:g,tasksError:v,isLeader:at,scope:j,agentFilter:C,nodeFilter:R,agentOptions:vl,nodeOptions:bl,nodeNameById:ms,searchQuery:B,selectedTaskIds:He,allVisibleTasksSelected:wl,someVisibleTasksSelected:Nl,canBatchArchive:jl,onSearchChange:O,onScopeChange:k,onAgentFilterChange:S,onNodeFilterChange:L,onToggleTaskSelected:Ol,onToggleAllVisibleTasks:Ll,onBatchArchive:$l,onBatchDelete:Fl,onCreateTask:zn,onSelectTask:ps,onClose:hs},gs={cluster:s,systemInfo:o,nodeNameById:ms,nodeBlockingTaskCounts:gl,eventTypeFilter:M,onEventTypeFilterChange:J,eventTypeOptions:Fn,filteredEvents:yl,sseConnected:l,clusterLoading:f,clusterError:u,electionPending:ml,onTriggerElection:Bl,promotePending:pl,onPromote:Ul,onAddNode:()=>ue(!0),leavePending:hl,onLeaveCluster:Vl,onToggleNodeDevTunnel:Wl,devTunnelNodeId:xl,onClose:()=>D(!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:V("hidden lg:block lg:shrink-0 lg:transition-all lg:duration-300",$?"lg:mr-4 lg:w-[22rem]":"lg:w-0 lg:overflow-hidden"),children:$&&r.jsx(so,{...xs})}),r.jsx("section",{ref:fs,className:"min-h-0 min-w-0 flex-1",children:r.jsx(hh,{onToggleTasks:hs,desktopTasksOpen:$,mobileTasksPanelOpen:H,operationsOpen:_,onToggleOperations:()=>D(N=>!N),cluster:s,sseConnected:l,activeTab:ve,setActiveTab:xe,creatingTask:E,activeTask:Q,assignedNode:Sl,taskLoading:Ce,taskError:ht,displayEvents:Wn,hasUserMessageInLogs:Tl,initialPrompt:Al,supportsFollowUp:Cl,taskUnavailable:Vn.taskUnavailable,chatDisabled:Vn.chatDisabled,chatDisabledReason:Vn.chatDisabledReason,questionBypassEnabled:ie,isRunning:!!Un,hasPendingFollowUp:Bn,canCancel:!!kl,canRetry:!!El,onRetry:Il,onCancel:Ml,onStartCreateTask:zn,onCancelCreateTask:Rl,onCreateTask:_l,onSendMessage:Pl,onQuestionBypassChange:q,onSubmitQuestionResponse:Dl,messagesEndRef:cs})}),r.jsx("div",{className:V("hidden xl:block xl:shrink-0 xl:transition-all xl:duration-300",_?"xl:ml-4 xl:w-[24rem]":"xl:w-0 xl:overflow-hidden"),children:_&&r.jsx(no,{...gs})})]}),_&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Close operations panel",onClick:()=>D(!1),className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm xl:hidden"}),r.jsx("div",{ref:us,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(no,{...gs})})]}),H&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Close task list",onClick:()=>P(!1),className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm lg:hidden"}),r.jsx("div",{ref:ds,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(so,{...xs,onCreateTask:()=>{P(!1),zn()},onSelectTask:N=>{P(!1),ps(N)},onClose:()=>P(!1)})})]}),r.jsx(mf,{open:pe,onOpenChange:ue,children:r.jsx(yf,{onAdded:()=>{ue(!1),d()}})})]})}const Ih=Object.freeze(Object.defineProperty({__proto__:null,DashboardPage:Ph},Symbol.toStringTag,{value:"Module"}));export{Bt as C,mf as D,mo as E,ta as a,sa as b,Mh as c,Ue as d,Ih as e};
|