meshy-node 0.0.9 → 0.1.1
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-D5VZZBFL.js → DashboardPage-CspTw10d.js} +20 -20
- package/dashboard/assets/{DiffTab-DHa2twrY.js → DiffTab-DBsjdYWn.js} +4 -4
- package/dashboard/assets/FilesTab-Bi9oHsVg.js +34 -0
- package/dashboard/assets/PreviewTab-DUCCQm-Z.js +16 -0
- package/dashboard/assets/{folder-0eOoupgZ.js → folder-BemVlz-Z.js} +1 -1
- package/dashboard/assets/index-COGcvWLp.css +1 -0
- package/dashboard/assets/{index-CRdTxsjS.js → index-qpJbLw0n.js} +10 -10
- package/dashboard/index.html +2 -2
- package/main.cjs +912 -883
- package/package.json +1 -1
- package/dashboard/assets/FilesTab-DI35HxWK.js +0 -11
- package/dashboard/assets/PreviewTab-CAEInFgg.js +0 -6
- package/dashboard/assets/index-Bx5CT0VB.css +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-
|
|
2
|
-
import{c as re,r as i,j as r,R as
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-Bi9oHsVg.js","assets/index-qpJbLw0n.js","assets/index-COGcvWLp.css","assets/folder-BemVlz-Z.js","assets/PreviewTab-DUCCQm-Z.js","assets/DiffTab-DBsjdYWn.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as re,r as i,j as r,R as eo,a as Wl,b as Sn,u as se,d as zl,e as U,f as Hl,g as Kl,h as ql,B as je,i as G,k as lt,l as to,m as Gl,t as ce,T as no,P as Yl,_ as jr,n as Xl,N as ro,o as so,p as Jl,q as Zl,s as Ql,v as ec,w as tc,x as nc,y as rc,z as sc,A as oc,C as ac,D as ic,E as lc,F as cc,G as dc,H as uc,I as fc,J as mc,K as pc,L as hc,M as xc}from"./index-qpJbLw0n.js";/**
|
|
3
3
|
* @license lucide-react v1.7.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
6
6
|
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/const gc=[["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"}]],
|
|
7
|
+
*/const gc=[["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"}]],vs=re("archive",gc);/**
|
|
8
8
|
* @license lucide-react v1.7.0 - ISC
|
|
9
9
|
*
|
|
10
10
|
* This source code is licensed under the ISC license.
|
|
11
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"}]],
|
|
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"}]],Sr=re("bot",vc);/**
|
|
13
13
|
* @license lucide-react v1.7.0 - ISC
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the ISC license.
|
|
@@ -19,12 +19,12 @@ import{c as re,r as i,j as r,R as Qs,a as Wl,b as Sn,u as se,d as zl,e as U,f as
|
|
|
19
19
|
*
|
|
20
20
|
* This source code is licensed under the ISC license.
|
|
21
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"}]],
|
|
22
|
+
*/const wc=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Cr=re("check",wc);/**
|
|
23
23
|
* @license lucide-react v1.7.0 - ISC
|
|
24
24
|
*
|
|
25
25
|
* This source code is licensed under the ISC license.
|
|
26
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"}]],
|
|
27
|
+
*/const Nc=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Ve=re("chevron-down",Nc);/**
|
|
28
28
|
* @license lucide-react v1.7.0 - ISC
|
|
29
29
|
*
|
|
30
30
|
* This source code is licensed under the ISC license.
|
|
@@ -34,7 +34,7 @@ import{c as re,r as i,j as r,R as Qs,a as Wl,b as Sn,u as se,d as zl,e as U,f as
|
|
|
34
34
|
*
|
|
35
35
|
* This source code is licensed under the ISC license.
|
|
36
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"}]],
|
|
37
|
+
*/const Sc=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],kr=re("chevron-up",Sc);/**
|
|
38
38
|
* @license lucide-react v1.7.0 - ISC
|
|
39
39
|
*
|
|
40
40
|
* This source code is licensed under the ISC license.
|
|
@@ -64,7 +64,7 @@ import{c as re,r as i,j as r,R as Qs,a as Wl,b as Sn,u as se,d as zl,e as U,f as
|
|
|
64
64
|
*
|
|
65
65
|
* This source code is licensed under the ISC license.
|
|
66
66
|
* See the LICENSE file in the root directory of this source tree.
|
|
67
|
-
*/const Pc=[["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"}]],
|
|
67
|
+
*/const Pc=[["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=re("image-plus",Pc);/**
|
|
68
68
|
* @license lucide-react v1.7.0 - ISC
|
|
69
69
|
*
|
|
70
70
|
* This source code is licensed under the ISC license.
|
|
@@ -104,7 +104,7 @@ import{c as re,r as i,j as r,R as Qs,a as Wl,b as Sn,u as se,d as zl,e as U,f as
|
|
|
104
104
|
*
|
|
105
105
|
* This source code is licensed under the ISC license.
|
|
106
106
|
* See the LICENSE file in the root directory of this source tree.
|
|
107
|
-
*/const Wc=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],
|
|
107
|
+
*/const Wc=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],bs=re("search",Wc);/**
|
|
108
108
|
* @license lucide-react v1.7.0 - ISC
|
|
109
109
|
*
|
|
110
110
|
* This source code is licensed under the ISC license.
|
|
@@ -139,9 +139,9 @@ import{c as re,r as i,j as r,R as Qs,a as Wl,b as Sn,u as se,d as zl,e as U,f as
|
|
|
139
139
|
*
|
|
140
140
|
* This source code is licensed under the ISC license.
|
|
141
141
|
* See the LICENSE file in the root directory of this source tree.
|
|
142
|
-
*/const td=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],
|
|
143
|
-
`)}function
|
|
144
|
-
`)}function ho(e){return Yt(e)!==null}function xn(e){if(e.type==="user"){const t=Yt(e),n=typeof e.timestamp=="string"?e.timestamp:"";if(t)return`user:${n}:${zt(t)}`}return JSON.stringify(e)}function ir(e){const t=Cn(e);return t?Tt(t):null}function ws(e){if(!Array.isArray(e))return null;const t=new Set;for(const n of e){const s=ir(n);if(s){t.add(s);continue}if(typeof n=="object"&&n!==null&&n.type==="text"&&typeof n.text=="string"){const o=kn(n.text);o&&t.add(Tt(o))}}return t.size===0?null:Array.from(t).sort().join("|")}function Cd(e){const t=ir(e);if(t)return t;if(typeof e.message=="string"){const n=kn(e.message);return n?Tt(n):null}if(typeof e.message=="object"&&e.message!==null){const n=ir(e.message);return n||ws(e.message.content)}return ws(e.content)}function kd(e,t,n){const s=typeof t.timestamp=="string"?t.timestamp:"";return`${e}-${s}-${n}`}function Ed(e,t){const n=t.map(o=>({...o})),s=new Set(n.map(xn));for(const o of e){const a=xn(o);s.has(a)||(n.push(o),s.add(a))}return n}function Ad(e,t){const n=xn(t);return e.some(s=>xn(s)===n)?e:[...e,{...t}]}function Td(e,t){const n=new Map;for(const s of t){const o=Yt(s);if(!o)continue;const a=zt(o);n.set(a,(n.get(a)??0)+1)}return e.filter(s=>{const o=zt(s.content),a=n.get(o)??0;return a<=0?!0:(n.set(o,a-1),!1)})}function Rd(e,t){const n=zt(t),s=e.findIndex(o=>zt(o.content)===n);return s===-1?e:e.filter((o,a)=>a!==s)}function _d(e){return e.some(ho)}function Pd(e){const t=[];let n=null;for(const s of e){if(ho(s)){n=null,t.push(s);continue}const o=Cd(s);o&&o===n||(t.push(s),o&&(n=o))}return t}function Y(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Dd(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 st(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,Md(o,...t)]}function Md(...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:()=>{},Id=Qs[" useId ".trim().toString()]||(()=>{}),Od=0;function Je(e){const[t,n]=i.useState(Id());return ge(()=>{n(s=>s??String(Od++))},[e]),e||(t?`radix-${t}`:"")}var Ld=Qs[" useInsertionEffect ".trim().toString()]||ge;function kt({prop:e,defaultProp:t,onChange:n=()=>{},caller:s}){const[o,a,l]=$d({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=Fd(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 $d({defaultProp:e,onChange:t}){const[n,s]=i.useState(e),o=i.useRef(n),a=i.useRef(t);return Ld(()=>{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 Fd(e){return typeof e=="function"}function Ht(e){const t=Bd(e),n=i.forwardRef((s,o)=>{const{children:a,...l}=s,c=i.Children.toArray(a),d=c.find(Vd);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 Bd(e){const t=i.forwardRef((n,s)=>{const{children:o,...a}=n;if(i.isValidElement(o)){const l=zd(o),c=Wd(a,o.props);return o.type!==i.Fragment&&(c.ref=s?Wl(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 xo=Symbol("radix.slottable");function Ud(e){const t=({children:n})=>r.jsx(r.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=xo,t}function Vd(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===xo}function Wd(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 zd(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 Hd=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],X=Hd.reduce((e,t)=>{const n=Ht(`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 Kd(e,t){e&&Sn.flushSync(()=>e.dispatchEvent(t))}function et(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 qd(e,t=globalThis==null?void 0:globalThis.document){const n=et(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 Gd="DismissableLayer",lr="dismissableLayer.update",Yd="dismissableLayer.pointerDownOutside",Xd="dismissableLayer.focusOutside",Ns,go=i.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Tr=i.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:l,onDismiss:c,...d}=e,f=i.useContext(go),[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=Qd(S=>{const R=S.target,O=[...f.branches].some(F=>F.contains(R));!j||O||(o==null||o(S),l==null||l(S),S.defaultPrevented||c==null||c())},h),C=eu(S=>{const R=S.target;[...f.branches].some(F=>F.contains(R))||(a==null||a(S),l==null||l(S),S.defaultPrevented||c==null||c())},h);return qd(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&&(Ns=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(u)),f.layers.add(u),js(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=Ns)}},[u,h,n,f]),i.useEffect(()=>()=>{u&&(f.layers.delete(u),f.layersWithOutsidePointerEventsDisabled.delete(u),js())},[u,f]),i.useEffect(()=>{const S=()=>x({});return document.addEventListener(lr,S),()=>document.removeEventListener(lr,S)},[]),r.jsx(X.div,{...d,ref:g,style:{pointerEvents:w?j?"auto":"none":void 0,...e.style},onFocusCapture:Y(e.onFocusCapture,C.onFocusCapture),onBlurCapture:Y(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:Y(e.onPointerDownCapture,k.onPointerDownCapture)})});Tr.displayName=Gd;var Jd="DismissableLayerBranch",Zd=i.forwardRef((e,t)=>{const n=i.useContext(go),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})});Zd.displayName=Jd;function Qd(e,t=globalThis==null?void 0:globalThis.document){const n=et(e),s=i.useRef(!1),o=i.useRef(()=>{});return i.useEffect(()=>{const a=c=>{if(c.target&&!s.current){let d=function(){vo(Yd,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 eu(e,t=globalThis==null?void 0:globalThis.document){const n=et(e),s=i.useRef(!1);return i.useEffect(()=>{const o=a=>{a.target&&!s.current&&vo(Xd,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 js(){const e=new CustomEvent(lr);document.dispatchEvent(e)}function vo(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?Kd(o,a):o.dispatchEvent(a)}var Kn="focusScope.autoFocusOnMount",qn="focusScope.autoFocusOnUnmount",Ss={bubbles:!1,cancelable:!0},tu="FocusScope",Rr=i.forwardRef((e,t)=>{const{loop:n=!1,trapped:s=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...l}=e,[c,d]=i.useState(null),f=et(o),u=et(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:qe(m.current,{select:!0})},v=function(w){if(x.paused||!c)return;const j=w.relatedTarget;j!==null&&(c.contains(j)||qe(m.current,{select:!0}))},b=function(w){if(document.activeElement===document.body)for(const k of w)k.removedNodes.length>0&&qe(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){ks.add(x);const p=document.activeElement;if(!c.contains(p)){const b=new CustomEvent(Kn,Ss);c.addEventListener(Kn,f),c.dispatchEvent(b),b.defaultPrevented||(nu(iu(bo(c)),{select:!0}),document.activeElement===p&&qe(c))}return()=>{c.removeEventListener(Kn,f),setTimeout(()=>{const b=new CustomEvent(qn,Ss);c.addEventListener(qn,u),c.dispatchEvent(b),b.defaultPrevented||qe(p??document.body,{select:!0}),c.removeEventListener(qn,u),ks.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]=ru(y);w&&j?!p.shiftKey&&b===j?(p.preventDefault(),n&&qe(w,{select:!0})):p.shiftKey&&b===w&&(p.preventDefault(),n&&qe(j,{select:!0})):b===y&&p.preventDefault()}},[n,s,x.paused]);return r.jsx(X.div,{tabIndex:-1,...l,ref:h,onKeyDown:g})});Rr.displayName=tu;function nu(e,{select:t=!1}={}){const n=document.activeElement;for(const s of e)if(qe(s,{select:t}),document.activeElement!==n)return}function ru(e){const t=bo(e),n=Cs(t,e),s=Cs(t.reverse(),e);return[n,s]}function bo(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 Cs(e,t){for(const n of e)if(!su(n,{upTo:t}))return n}function su(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 ou(e){return e instanceof HTMLInputElement&&"select"in e}function qe(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&ou(e)&&t&&e.select()}}var ks=au();function au(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Es(e,t),e.unshift(t)},remove(t){var n;e=Es(e,t),(n=e[0])==null||n.resume()}}}function Es(e,t){const n=[...e],s=n.indexOf(t);return s!==-1&&n.splice(s,1),n}function iu(e){return e.filter(t=>t.tagName!=="A")}var lu="Portal",_r=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?zl.createPortal(r.jsx(X.div,{...s,ref:t}),l):null});_r.displayName=lu;function cu(e,t){return i.useReducer((n,s)=>t[n][s]??n,e)}var Rt=e=>{const{present:t,children:n}=e,s=du(t),o=typeof n=="function"?n({present:s.isPresent}):i.Children.only(n),a=se(s.ref,uu(o));return typeof n=="function"||s.isPresent?i.cloneElement(o,{ref:a}):null};Rt.displayName="Presence";function du(e){const[t,n]=i.useState(),s=i.useRef(null),o=i.useRef(e),a=i.useRef("none"),l=e?"mounted":"unmounted",[c,d]=cu(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return i.useEffect(()=>{const f=nn(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=nn(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=nn(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=nn(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 nn(e){return(e==null?void 0:e.animationName)||"none"}function uu(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 Gn=0;function yo(){i.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??As()),document.body.insertAdjacentElement("beforeend",e[1]??As()),Gn++,()=>{Gn===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Gn--}},[])}function As(){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 wo(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 fu(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 cn="right-scroll-bar-position",dn="width-before-scroll-bar",mu="with-scroll-bars-hidden",pu="--removed-body-scroll-bar-size";function Yn(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function hu(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 xu=typeof window<"u"?i.useLayoutEffect:i.useEffect,Ts=new WeakMap;function gu(e,t){var n=hu(null,function(s){return e.forEach(function(o){return Yn(o,s)})});return xu(function(){var s=Ts.get(n);if(s){var o=new Set(s),a=new Set(e),l=n.current;o.forEach(function(c){a.has(c)||Yn(c,null)}),a.forEach(function(c){o.has(c)||Yn(c,l)})}Ts.set(n,e)},[e]),n}function vu(e){return e}function bu(e,t){t===void 0&&(t=vu);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 yu(e){e===void 0&&(e={});var t=bu(null);return t.options=Me({async:!0,ssr:!1},e),t}var No=function(e){var t=e.sideCar,n=wo(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))};No.isSideCarExport=!0;function wu(e,t){return e.useMedium(t),No}var jo=yu(),Xn=function(){},En=i.forwardRef(function(e,t){var n=i.useRef(null),s=i.useState({onScrollCapture:Xn,onWheelCapture:Xn,onTouchMoveCapture:Xn}),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=wo(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=h,C=gu([n,t]),S=Me(Me({},j),o);return i.createElement(i.Fragment,null,u&&i.createElement(k,{sideCar:jo,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))});En.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};En.classNames={fullWidth:dn,zeroRight:cn};var Nu=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function ju(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Nu();return t&&e.setAttribute("nonce",t),e}function Su(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Cu(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var ku=function(){var e=0,t=null;return{add:function(n){e==0&&(t=ju())&&(Su(t,n),Cu(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Eu=function(){var e=ku();return function(t,n){i.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},So=function(){var e=Eu(),t=function(n){var s=n.styles,o=n.dynamic;return e(s,o),null};return t},Au={left:0,top:0,right:0,gap:0},Jn=function(e){return parseInt(e||"",10)||0},Tu=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[Jn(n),Jn(s),Jn(o)]},Ru=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Au;var t=Tu(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])}},_u=So(),jt="data-scroll-locked",Pu=function(e,t,n,s){var o=e.left,a=e.top,l=e.right,c=e.gap;return n===void 0&&(n="margin"),`
|
|
142
|
+
*/const td=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Er=re("x",td),nd=new Set(["assigned","running"]);function rd(e,t){return e.reduce((n,s)=>s.assignedTo===t&&nd.has(s.status)?n+1:n,0)}function At(e){return(e==null?void 0:e.toLowerCase())==="devtunnel"}function sd(e){return e?At(e)?"DevTunnel":e.charAt(0).toUpperCase()+e.slice(1):"Direct"}function Ar(e,t){return At(t??e.transportType)||!!e.devtunnelEndpoint}function mo(e,t){return!At(t??e.transportType)}function po(e,t){const n=t??e.transportType;return At(n)?"DevTunnel":e.devtunnelEndpoint?"Direct + DevTunnel":sd(n)}function ys(e,t){return!e&&!t}function od({routeTaskId:e,creatingTask:t,internalSelectedTaskId:n,sortedTaskIds:s}){return e||(t?null:n??s[0]??null)}function ad(e,t){return[t,...e.filter(n=>n.id!==t.id)]}const id=new Set(["completed","failed","cancelled","archived"]);function ld(e,t){const n=new Set(t);return new Set(Array.from(e).filter(s=>n.has(s)))}function cd(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=>id.has(o.status))}function dd(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 hn(e){return typeof e=="object"&&e!==null}function ud(e){if(!hn(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 fd(e){if(!hn(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"||!hn(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 Ot(e){if(typeof e=="string"){const t=e.trim();return t?[{type:"text",text:t}]:[]}return Array.isArray(e)?e.map(t=>ud(t)??fd(t)).filter(t=>t!==null):[]}function Tr(e,t){const n=e.trim();return[...n?[{type:"text",text:n}]:[],...t]}function md(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:md(e),timestamp:t}}function Yt(e){if(e.type!=="user"||e.isSynthetic===!0)return null;if(typeof e.message=="string"){const t=Ot(e.message);return t.length>0?t:null}if(hn(e.message)&&Array.isArray(e.message.content)){const t=Ot(e.message.content);return t.length>0?t:null}if(Array.isArray(e.content)){const t=Ot(e.content);return t.length>0?t:null}return null}function pd(e){return Ot(e.payload.initialMessage)}function zt(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 hd(e){return e.filter(t=>t.type==="text").map(t=>t.text).join(`
|
|
143
|
+
`)}function Rr(e){return`data:${e.mediaType};base64,${e.data}`}function xd(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 gd(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 ws(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 gd(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 Xt(e){return typeof e=="object"&&e!==null}function vd(e){return Xt(e)&&typeof e.name=="string"&&e.name.toLowerCase()==="askuserquestion"}function bd(e){return!Xt(e)||typeof e.label!="string"||!e.label.trim()?null:{label:e.label.trim(),description:typeof e.description=="string"?e.description.trim():""}}function yd(e){if(!Xt(e)||typeof e.question!="string"||!e.question.trim())return null;const t=Array.isArray(e.options)?e.options.map(bd).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(!Xt(e)||!Array.isArray(e.questions))return null;const t=e.questions.map(yd).filter(n=>n!==null);return t.length===0?null:{questions:t}}function Tt(e){return JSON.stringify(e)}function Cn(e){const t=ir(e);if(t)return t;if(vd(e)){const n=Xt(e.input)?e.input:void 0;return ir(n)}return null}function wd(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 kn(e){for(const t of wd(e))try{const n=JSON.parse(t),s=ir(n);if(s)return s}catch{}return null}function Nd(e){return e.questions.map(t=>t.options.length>0?[0]:[])}function jd(e,t){return e.questions.every((n,s)=>(t[s]??[]).length>0)}function Sd(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(`
|
|
144
|
+
`)}function ho(e){return Yt(e)!==null}function xn(e){if(e.type==="user"){const t=Yt(e),n=typeof e.timestamp=="string"?e.timestamp:"";if(t)return`user:${n}:${zt(t)}`}return JSON.stringify(e)}function lr(e){const t=Cn(e);return t?Tt(t):null}function Ns(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=kn(n.text);o&&t.add(Tt(o))}}return t.size===0?null:Array.from(t).sort().join("|")}function Cd(e){const t=lr(e);if(t)return t;if(typeof e.message=="string"){const n=kn(e.message);return n?Tt(n):null}if(typeof e.message=="object"&&e.message!==null){const n=lr(e.message);return n||Ns(e.message.content)}return Ns(e.content)}function kd(e,t,n){const s=typeof t.timestamp=="string"?t.timestamp:"";return`${e}-${s}-${n}`}function Ed(e,t){const n=t.map(o=>({...o})),s=new Set(n.map(xn));for(const o of e){const a=xn(o);s.has(a)||(n.push(o),s.add(a))}return n}function Ad(e,t){const n=xn(t);return e.some(s=>xn(s)===n)?e:[...e,{...t}]}function Td(e,t){const n=new Map;for(const s of t){const o=Yt(s);if(!o)continue;const a=zt(o);n.set(a,(n.get(a)??0)+1)}return e.filter(s=>{const o=zt(s.content),a=n.get(o)??0;return a<=0?!0:(n.set(o,a-1),!1)})}function Rd(e,t){const n=zt(t),s=e.findIndex(o=>zt(o.content)===n);return s===-1?e:e.filter((o,a)=>a!==s)}function _d(e){return e.some(ho)}function Pd(e){const t=[];let n=null;for(const s of e){if(ho(s)){n=null,t.push(s);continue}const o=Cd(s);o&&o===n||(t.push(s),o&&(n=o))}return t}function Y(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Dd(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 st(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,Md(o,...t)]}function Md(...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 ve=globalThis!=null&&globalThis.document?i.useLayoutEffect:()=>{},Id=eo[" useId ".trim().toString()]||(()=>{}),Od=0;function Ze(e){const[t,n]=i.useState(Id());return ve(()=>{n(s=>s??String(Od++))},[e]),e||(t?`radix-${t}`:"")}var Ld=eo[" useInsertionEffect ".trim().toString()]||ve;function kt({prop:e,defaultProp:t,onChange:n=()=>{},caller:s}){const[o,a,l]=$d({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=Fd(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 $d({defaultProp:e,onChange:t}){const[n,s]=i.useState(e),o=i.useRef(n),a=i.useRef(t);return Ld(()=>{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 Fd(e){return typeof e=="function"}function Ht(e){const t=Bd(e),n=i.forwardRef((s,o)=>{const{children:a,...l}=s,c=i.Children.toArray(a),d=c.find(Vd);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 Bd(e){const t=i.forwardRef((n,s)=>{const{children:o,...a}=n;if(i.isValidElement(o)){const l=zd(o),c=Wd(a,o.props);return o.type!==i.Fragment&&(c.ref=s?Wl(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 xo=Symbol("radix.slottable");function Ud(e){const t=({children:n})=>r.jsx(r.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=xo,t}function Vd(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===xo}function Wd(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 zd(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 Hd=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],X=Hd.reduce((e,t)=>{const n=Ht(`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 Kd(e,t){e&&Sn.flushSync(()=>e.dispatchEvent(t))}function tt(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 qd(e,t=globalThis==null?void 0:globalThis.document){const n=tt(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 Gd="DismissableLayer",cr="dismissableLayer.update",Yd="dismissableLayer.pointerDownOutside",Xd="dismissableLayer.focusOutside",js,go=i.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),_r=i.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:l,onDismiss:c,...d}=e,f=i.useContext(go),[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=Qd(S=>{const R=S.target,O=[...f.branches].some(F=>F.contains(R));!j||O||(o==null||o(S),l==null||l(S),S.defaultPrevented||c==null||c())},h),C=eu(S=>{const R=S.target;[...f.branches].some(F=>F.contains(R))||(a==null||a(S),l==null||l(S),S.defaultPrevented||c==null||c())},h);return qd(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&&(js=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(u)),f.layers.add(u),Ss(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=js)}},[u,h,n,f]),i.useEffect(()=>()=>{u&&(f.layers.delete(u),f.layersWithOutsidePointerEventsDisabled.delete(u),Ss())},[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:Y(e.onFocusCapture,C.onFocusCapture),onBlurCapture:Y(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:Y(e.onPointerDownCapture,k.onPointerDownCapture)})});_r.displayName=Gd;var Jd="DismissableLayerBranch",Zd=i.forwardRef((e,t)=>{const n=i.useContext(go),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})});Zd.displayName=Jd;function Qd(e,t=globalThis==null?void 0:globalThis.document){const n=tt(e),s=i.useRef(!1),o=i.useRef(()=>{});return i.useEffect(()=>{const a=c=>{if(c.target&&!s.current){let d=function(){vo(Yd,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 eu(e,t=globalThis==null?void 0:globalThis.document){const n=tt(e),s=i.useRef(!1);return i.useEffect(()=>{const o=a=>{a.target&&!s.current&&vo(Xd,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 Ss(){const e=new CustomEvent(cr);document.dispatchEvent(e)}function vo(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?Kd(o,a):o.dispatchEvent(a)}var qn="focusScope.autoFocusOnMount",Gn="focusScope.autoFocusOnUnmount",Cs={bubbles:!1,cancelable:!0},tu="FocusScope",Pr=i.forwardRef((e,t)=>{const{loop:n=!1,trapped:s=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...l}=e,[c,d]=i.useState(null),f=tt(o),u=tt(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:Ge(m.current,{select:!0})},v=function(w){if(x.paused||!c)return;const j=w.relatedTarget;j!==null&&(c.contains(j)||Ge(m.current,{select:!0}))},b=function(w){if(document.activeElement===document.body)for(const k of w)k.removedNodes.length>0&&Ge(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){Es.add(x);const p=document.activeElement;if(!c.contains(p)){const b=new CustomEvent(qn,Cs);c.addEventListener(qn,f),c.dispatchEvent(b),b.defaultPrevented||(nu(iu(bo(c)),{select:!0}),document.activeElement===p&&Ge(c))}return()=>{c.removeEventListener(qn,f),setTimeout(()=>{const b=new CustomEvent(Gn,Cs);c.addEventListener(Gn,u),c.dispatchEvent(b),b.defaultPrevented||Ge(p??document.body,{select:!0}),c.removeEventListener(Gn,u),Es.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]=ru(y);w&&j?!p.shiftKey&&b===j?(p.preventDefault(),n&&Ge(w,{select:!0})):p.shiftKey&&b===w&&(p.preventDefault(),n&&Ge(j,{select:!0})):b===y&&p.preventDefault()}},[n,s,x.paused]);return r.jsx(X.div,{tabIndex:-1,...l,ref:h,onKeyDown:g})});Pr.displayName=tu;function nu(e,{select:t=!1}={}){const n=document.activeElement;for(const s of e)if(Ge(s,{select:t}),document.activeElement!==n)return}function ru(e){const t=bo(e),n=ks(t,e),s=ks(t.reverse(),e);return[n,s]}function bo(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 ks(e,t){for(const n of e)if(!su(n,{upTo:t}))return n}function su(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 ou(e){return e instanceof HTMLInputElement&&"select"in e}function Ge(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&ou(e)&&t&&e.select()}}var Es=au();function au(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=As(e,t),e.unshift(t)},remove(t){var n;e=As(e,t),(n=e[0])==null||n.resume()}}}function As(e,t){const n=[...e],s=n.indexOf(t);return s!==-1&&n.splice(s,1),n}function iu(e){return e.filter(t=>t.tagName!=="A")}var lu="Portal",Dr=i.forwardRef((e,t)=>{var c;const{container:n,...s}=e,[o,a]=i.useState(!1);ve(()=>a(!0),[]);const l=n||o&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return l?zl.createPortal(r.jsx(X.div,{...s,ref:t}),l):null});Dr.displayName=lu;function cu(e,t){return i.useReducer((n,s)=>t[n][s]??n,e)}var Rt=e=>{const{present:t,children:n}=e,s=du(t),o=typeof n=="function"?n({present:s.isPresent}):i.Children.only(n),a=se(s.ref,uu(o));return typeof n=="function"||s.isPresent?i.cloneElement(o,{ref:a}):null};Rt.displayName="Presence";function du(e){const[t,n]=i.useState(),s=i.useRef(null),o=i.useRef(e),a=i.useRef("none"),l=e?"mounted":"unmounted",[c,d]=cu(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return i.useEffect(()=>{const f=nn(s.current);a.current=c==="mounted"?f:"none"},[c]),ve(()=>{const f=s.current,u=o.current;if(u!==e){const h=a.current,x=nn(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]),ve(()=>{if(t){let f;const u=t.ownerDocument.defaultView??window,m=x=>{const p=nn(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=nn(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 nn(e){return(e==null?void 0:e.animationName)||"none"}function uu(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 yo(){i.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Ts()),document.body.insertAdjacentElement("beforeend",e[1]??Ts()),Yn++,()=>{Yn===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Yn--}},[])}function Ts(){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 wo(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 fu(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 cn="right-scroll-bar-position",dn="width-before-scroll-bar",mu="with-scroll-bars-hidden",pu="--removed-body-scroll-bar-size";function Xn(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function hu(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 xu=typeof window<"u"?i.useLayoutEffect:i.useEffect,Rs=new WeakMap;function gu(e,t){var n=hu(null,function(s){return e.forEach(function(o){return Xn(o,s)})});return xu(function(){var s=Rs.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)})}Rs.set(n,e)},[e]),n}function vu(e){return e}function bu(e,t){t===void 0&&(t=vu);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 yu(e){e===void 0&&(e={});var t=bu(null);return t.options=Me({async:!0,ssr:!1},e),t}var No=function(e){var t=e.sideCar,n=wo(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))};No.isSideCarExport=!0;function wu(e,t){return e.useMedium(t),No}var jo=yu(),Jn=function(){},En=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=wo(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=h,C=gu([n,t]),S=Me(Me({},j),o);return i.createElement(i.Fragment,null,u&&i.createElement(k,{sideCar:jo,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))});En.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};En.classNames={fullWidth:dn,zeroRight:cn};var Nu=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function ju(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Nu();return t&&e.setAttribute("nonce",t),e}function Su(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Cu(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var ku=function(){var e=0,t=null;return{add:function(n){e==0&&(t=ju())&&(Su(t,n),Cu(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Eu=function(){var e=ku();return function(t,n){i.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},So=function(){var e=Eu(),t=function(n){var s=n.styles,o=n.dynamic;return e(s,o),null};return t},Au={left:0,top:0,right:0,gap:0},Zn=function(e){return parseInt(e||"",10)||0},Tu=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)]},Ru=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Au;var t=Tu(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])}},_u=So(),jt="data-scroll-locked",Pu=function(e,t,n,s){var o=e.left,a=e.top,l=e.right,c=e.gap;return n===void 0&&(n="margin"),`
|
|
145
145
|
.`.concat(mu,` {
|
|
146
146
|
overflow: hidden `).concat(s,`;
|
|
147
147
|
padding-right: `).concat(c,"px ").concat(s,`;
|
|
@@ -178,23 +178,23 @@ import{c as re,r as i,j as r,R as Qs,a as Wl,b as Sn,u as se,d as zl,e as U,f as
|
|
|
178
178
|
body[`).concat(jt,`] {
|
|
179
179
|
`).concat(pu,": ").concat(c,`px;
|
|
180
180
|
}
|
|
181
|
-
`)},
|
|
181
|
+
`)},_s=function(){var e=parseInt(document.body.getAttribute(jt)||"0",10);return isFinite(e)?e:0},Du=function(){i.useEffect(function(){return document.body.setAttribute(jt,(_s()+1).toString()),function(){var e=_s()-1;e<=0?document.body.removeAttribute(jt):document.body.setAttribute(jt,e.toString())}},[])},Mu=function(e){var t=e.noRelative,n=e.noImportant,s=e.gapMode,o=s===void 0?"margin":s;Du();var a=i.useMemo(function(){return Ru(o)},[o]);return i.createElement(_u,{styles:Pu(a,!t,o,n?"":"!important")})},dr=!1;if(typeof window<"u")try{var rn=Object.defineProperty({},"passive",{get:function(){return dr=!0,!0}});window.addEventListener("test",rn,rn),window.removeEventListener("test",rn,rn)}catch{dr=!1}var bt=dr?{passive:!1}:!1,Iu=function(e){return e.tagName==="TEXTAREA"},Co=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Iu(e)&&n[t]==="visible")},Ou=function(e){return Co(e,"overflowY")},Lu=function(e){return Co(e,"overflowX")},Ps=function(e,t){var n=t.ownerDocument,s=t;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var o=ko(e,s);if(o){var a=Eo(e,s),l=a[1],c=a[2];if(l>c)return!0}s=s.parentNode}while(s&&s!==n.body);return!1},$u=function(e){var t=e.scrollTop,n=e.scrollHeight,s=e.clientHeight;return[t,n,s]},Fu=function(e){var t=e.scrollLeft,n=e.scrollWidth,s=e.clientWidth;return[t,n,s]},ko=function(e,t){return e==="v"?Ou(t):Lu(t)},Eo=function(e,t){return e==="v"?$u(t):Fu(t)},Bu=function(e,t){return e==="h"&&t==="rtl"?-1:1},Uu=function(e,t,n,s,o){var a=Bu(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=Eo(e,c),g=x[0],p=x[1],v=x[2],b=p-v-a*g;(g||b)&&ko(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},sn=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Ds=function(e){return[e.deltaX,e.deltaY]},Ms=function(e){return e&&"current"in e?e.current:e},Vu=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Wu=function(e){return`
|
|
182
182
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
183
183
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
184
|
-
`)},zu=0,yt=[];function Hu(e){var t=i.useRef([]),n=i.useRef([0,0]),s=i.useRef(),o=i.useState(zu++)[0],a=i.useState(So)[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=fu([e.lockRef.current],(e.shards||[]).map(
|
|
184
|
+
`)},zu=0,yt=[];function Hu(e){var t=i.useRef([]),n=i.useRef([0,0]),s=i.useRef(),o=i.useState(zu++)[0],a=i.useState(So)[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=fu([e.lockRef.current],(e.shards||[]).map(Ms),!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=sn(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(),O=R&&R.anchorNode,F=O?O===C||O.contains(C):!1;if(F)return!1;var B=Ps(S,C);if(!B)return!0;if(B?k=S:(k=S==="v"?"h":"v",B=Ps(S,C)),!B)return!1;if(!s.current&&"changedTouches"in p&&(w||j)&&(s.current=k),!k)return!0;var V=s.current||k;return Uu(V,v,p,V==="h"?w:j)},[]),d=i.useCallback(function(p){var v=p;if(!(!yt.length||yt[yt.length-1]!==a)){var b="deltaY"in v?Ds(v):sn(v),y=t.current.filter(function(k){return k.name===v.type&&(k.target===v.target||v.target===k.shadowParent)&&Vu(k.delta,b)})[0];if(y&&y.should){v.cancelable&&v.preventDefault();return}if(!y){var w=(l.current.shards||[]).map(Ms).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:Ku(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=sn(p),s.current=void 0},[]),m=i.useCallback(function(p){f(p.type,Ds(p),p.target,c(p,e.lockRef.current))},[]),h=i.useCallback(function(p){f(p.type,sn(p),p.target,c(p,e.lockRef.current))},[]);i.useEffect(function(){return yt.push(a),e.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:h}),document.addEventListener("wheel",d,bt),document.addEventListener("touchmove",d,bt),document.addEventListener("touchstart",u,bt),function(){yt=yt.filter(function(p){return p!==a}),document.removeEventListener("wheel",d,bt),document.removeEventListener("touchmove",d,bt),document.removeEventListener("touchstart",u,bt)}},[]);var x=e.removeScrollBar,g=e.inert;return i.createElement(i.Fragment,null,g?i.createElement(a,{styles:Wu(o)}):null,x?i.createElement(Mu,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Ku(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const qu=wu(jo,Hu);var Mr=i.forwardRef(function(e,t){return i.createElement(En,Me({},e,{ref:t,sideCar:qu}))});Mr.classNames=En.classNames;var Gu=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},wt=new WeakMap,on=new WeakMap,an={},Qn=0,Ao=function(e){return e&&(e.host||Ao(e.parentNode))},Yu=function(e,t){return t.map(function(n){if(e.contains(n))return n;var s=Ao(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})},Xu=function(e,t,n,s){var o=Yu(t,Array.isArray(e)?e:[e]);an[n]||(an[n]=new WeakMap);var a=an[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=(wt.get(h)||0)+1,v=(a.get(h)||0)+1;wt.set(h,p),a.set(h,v),l.push(h),p===1&&g&&on.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=wt.get(m)-1,x=a.get(m)-1;wt.set(m,h),a.set(m,x),h||(on.has(m)||m.removeAttribute(s),on.delete(m)),x||m.removeAttribute(n)}),Qn--,Qn||(wt=new WeakMap,wt=new WeakMap,on=new WeakMap,an={})}},To=function(e,t,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(e)?e:[e]),o=Gu(e);return o?(s.push.apply(s,Array.from(o.querySelectorAll("[aria-live], script"))),Xu(s,o,n,"aria-hidden")):function(){return null}},An="Dialog",[Ro,_o]=st(An),[Ju,De]=Ro(An),Po=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]=kt({prop:s,defaultProp:o??!1,onChange:a,caller:An});return r.jsx(Ju,{scope:t,triggerRef:c,contentRef:d,contentId:Ze(),titleId:Ze(),descriptionId:Ze(),open:f,onOpenChange:u,onOpenToggle:i.useCallback(()=>u(m=>!m),[u]),modal:l,children:n})};Po.displayName=An;var Do="DialogTrigger",Mo=i.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=De(Do,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":Lr(o.open),...s,ref:a,onClick:Y(e.onClick,o.onOpenToggle)})});Mo.displayName=Do;var Ir="DialogPortal",[Zu,Io]=Ro(Ir,{forceMount:void 0}),Oo=e=>{const{__scopeDialog:t,forceMount:n,children:s,container:o}=e,a=De(Ir,t);return r.jsx(Zu,{scope:t,forceMount:n,children:i.Children.map(s,l=>r.jsx(Rt,{present:n||a.open,children:r.jsx(Dr,{asChild:!0,container:o,children:l})}))})};Oo.displayName=Ir;var gn="DialogOverlay",Lo=i.forwardRef((e,t)=>{const n=Io(gn,e.__scopeDialog),{forceMount:s=n.forceMount,...o}=e,a=De(gn,e.__scopeDialog);return a.modal?r.jsx(Rt,{present:s||a.open,children:r.jsx(ef,{...o,ref:t})}):null});Lo.displayName=gn;var Qu=Ht("DialogOverlay.RemoveScroll"),ef=i.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=De(gn,n);return r.jsx(Mr,{as:Qu,allowPinchZoom:!0,shards:[o.contentRef],children:r.jsx(X.div,{"data-state":Lr(o.open),...s,ref:t,style:{pointerEvents:"auto",...s.style}})})}),ft="DialogContent",$o=i.forwardRef((e,t)=>{const n=Io(ft,e.__scopeDialog),{forceMount:s=n.forceMount,...o}=e,a=De(ft,e.__scopeDialog);return r.jsx(Rt,{present:s||a.open,children:a.modal?r.jsx(tf,{...o,ref:t}):r.jsx(nf,{...o,ref:t})})});$o.displayName=ft;var tf=i.forwardRef((e,t)=>{const n=De(ft,e.__scopeDialog),s=i.useRef(null),o=se(t,n.contentRef,s);return i.useEffect(()=>{const a=s.current;if(a)return To(a)},[]),r.jsx(Fo,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Y(e.onCloseAutoFocus,a=>{var l;a.preventDefault(),(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Y(e.onPointerDownOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0;(l.button===2||c)&&a.preventDefault()}),onFocusOutside:Y(e.onFocusOutside,a=>a.preventDefault())})}),nf=i.forwardRef((e,t)=>{const n=De(ft,e.__scopeDialog),s=i.useRef(!1),o=i.useRef(!1);return r.jsx(Fo,{...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()}})}),Fo=i.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:a,...l}=e,c=De(ft,n),d=i.useRef(null),f=se(t,d);return yo(),r.jsxs(r.Fragment,{children:[r.jsx(Pr,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:o,onUnmountAutoFocus:a,children:r.jsx(_r,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Lr(c.open),...l,ref:f,onDismiss:()=>c.onOpenChange(!1)})}),r.jsxs(r.Fragment,{children:[r.jsx(sf,{titleId:c.titleId}),r.jsx(af,{contentRef:d,descriptionId:c.descriptionId})]})]})}),Or="DialogTitle",Bo=i.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=De(Or,n);return r.jsx(X.h2,{id:o.titleId,...s,ref:t})});Bo.displayName=Or;var Uo="DialogDescription",Vo=i.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=De(Uo,n);return r.jsx(X.p,{id:o.descriptionId,...s,ref:t})});Vo.displayName=Uo;var Wo="DialogClose",zo=i.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=De(Wo,n);return r.jsx(X.button,{type:"button",...s,ref:t,onClick:Y(e.onClick,()=>o.onOpenChange(!1))})});zo.displayName=Wo;function Lr(e){return e?"open":"closed"}var Ho="DialogTitleWarning",[rf,Ko]=Dd(Ho,{contentName:ft,titleName:Or,docsSlug:"dialog"}),sf=({titleId:e})=>{const t=Ko(Ho),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
185
185
|
|
|
186
186
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
187
187
|
|
|
188
|
-
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},of="DialogDescriptionWarning",af=({contentRef:e,descriptionId:t})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Ko(of).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},qo=Po,lf=Mo,Go=Oo,Or=Lo,Lr=$o,$r=Bo,Fr=Vo,Br=zo;const cf=qo,df=Go,Yo=i.forwardRef(({className:e,...t},n)=>r.jsx(Or,{ref:n,className:U("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Yo.displayName=Or.displayName;const Xo=i.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(df,{children:[r.jsx(Yo,{}),r.jsxs(Lr,{ref:s,className:U("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[t,r.jsxs(Br,{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(Cr,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Xo.displayName=Lr.displayName;const Jo=({className:e,...t})=>r.jsx("div",{className:U("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Jo.displayName="DialogHeader";const Zo=({className:e,...t})=>r.jsx("div",{className:U("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Zo.displayName="DialogFooter";const Qo=i.forwardRef(({className:e,...t},n)=>r.jsx($r,{ref:n,className:U("text-lg font-semibold leading-none tracking-tight",e),...t}));Qo.displayName=$r.displayName;const uf=i.forwardRef(({className:e,...t},n)=>r.jsx(Fr,{ref:n,className:U("text-sm text-muted-foreground",e),...t}));uf.displayName=Fr.displayName;const dt=i.forwardRef(({className:e,type:t,...n},s)=>r.jsx("input",{type:t,className:U("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:s,...n}));dt.displayName="Input";var ff=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],mf=ff.reduce((e,t)=>{const n=Hl(`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}},{}),pf="Label",ea=i.forwardRef((e,t)=>r.jsx(mf.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())}}));ea.displayName=pf;var ta=ea;const hf=Kl("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ge=i.forwardRef(({className:e,...t},n)=>r.jsx(ta,{ref:n,className:U(hf(),e),...t}));Ge.displayName=ta.displayName;function xf({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 ql({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(Xo,{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(Jo,{className:"space-y-2 text-left",children:[r.jsx(Qo,{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(Ge,{htmlFor:"leader-endpoint",children:"Leader endpoint"}),r.jsx(be,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 text-[10px] uppercase tracking-[0.16em]",children:"DevTunnel only"})]}),r.jsx(dt,{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(Zo,{className:"border-t border-border/60 pt-4",children:r.jsx(G,{type:"submit",disabled:!t.trim()||s,className:"rounded-2xl",children:s?"Joining...":"Join node"})})]})]})})}function na(){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 ys(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=xd(u.clipboardData);if(m.length!==0){u.preventDefault();try{const h=await ys(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 gf({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}=na(),v=i.useCallback(()=>{c.current&&(c.current.style.height="auto")},[]),b=i.useCallback(()=>{const C=Er(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-3 backdrop-blur-xl sm:px-4 sm:py-4",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:Ar(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(Cr,{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(G,{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(or,{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(G,{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(fo,{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 Kt({payload:e,disabled:t=!1,bypassEnabled:n=!1,onBypassChange:s,onSubmit:o}){const[a,l]=i.useState(()=>n?Nd(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=jd(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(Sd(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(G,{type:"button",variant:n?"secondary":"outline",size:"sm",onClick:()=>s==null?void 0:s(!n),className:"rounded-full",children:[r.jsx(Gc,{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:U("flex w-full items-start gap-3 rounded-[18px] border px-4 py-3 text-left transition-colors",w?"border-primary/50 bg-primary/10 text-foreground":"border-border/60 bg-background/80 text-foreground hover:border-primary/30 hover:bg-primary/5"),children:[r.jsx("span",{className:U("mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border",w?"border-primary bg-primary text-primary-foreground":"border-border/70 bg-background text-transparent"),children:r.jsx(Sr,{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(G,{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 Ms({event:e,questionBypassEnabled:t=!1,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o=!1}){const a=e.type,l=Cn(e);if(l)return r.jsx(dr,{children:r.jsx(Kt,{payload:l,bypassEnabled:t,onBypassChange:n,onSubmit:s,disabled:o})});if(a==="user"){const c=Yt(e);return c?r.jsx(vf,{content:c}):null}return a==="assistant"?r.jsx(bf,{event:e,questionBypassEnabled:t,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o}):null}function Is(e){var n;const t=e.replace(/\r\n/g,`
|
|
188
|
+
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},of="DialogDescriptionWarning",af=({contentRef:e,descriptionId:t})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Ko(of).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},qo=Po,lf=Mo,Go=Oo,$r=Lo,Fr=$o,Br=Bo,Ur=Vo,Tn=zo;const cf=qo,df=Go,_h=Tn,Yo=i.forwardRef(({className:e,...t},n)=>r.jsx($r,{ref:n,className:U("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Yo.displayName=$r.displayName;const Xo=i.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(df,{children:[r.jsx(Yo,{}),r.jsxs(Fr,{ref:s,className:U("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[t,r.jsxs(Tn,{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(Er,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Xo.displayName=Fr.displayName;const Jo=({className:e,...t})=>r.jsx("div",{className:U("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Jo.displayName="DialogHeader";const Zo=({className:e,...t})=>r.jsx("div",{className:U("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Zo.displayName="DialogFooter";const Qo=i.forwardRef(({className:e,...t},n)=>r.jsx(Br,{ref:n,className:U("text-lg font-semibold leading-none tracking-tight",e),...t}));Qo.displayName=Br.displayName;const uf=i.forwardRef(({className:e,...t},n)=>r.jsx(Ur,{ref:n,className:U("text-sm text-muted-foreground",e),...t}));uf.displayName=Ur.displayName;const dt=i.forwardRef(({className:e,type:t,...n},s)=>r.jsx("input",{type:t,className:U("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:s,...n}));dt.displayName="Input";var ff=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],mf=ff.reduce((e,t)=>{const n=Hl(`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}},{}),pf="Label",ea=i.forwardRef((e,t)=>r.jsx(mf.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())}}));ea.displayName=pf;var ta=ea;const hf=Kl("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ye=i.forwardRef(({className:e,...t},n)=>r.jsx(ta,{ref:n,className:U(hf(),e),...t}));Ye.displayName=ta.displayName;function xf({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 ql({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(Xo,{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(Jo,{className:"space-y-2 text-left",children:[r.jsx(Qo,{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(Ye,{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(dt,{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(Zo,{className:"border-t border-border/60 pt-4",children:r.jsx(G,{type:"submit",disabled:!t.trim()||s,className:"rounded-2xl",children:s?"Joining...":"Join node"})})]})]})})}function na(){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 ws(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=xd(u.clipboardData);if(m.length!==0){u.preventDefault();try{const h=await ws(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 gf({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}=na(),v=i.useCallback(()=>{c.current&&(c.current.style.height="auto")},[]),b=i.useCallback(()=>{const C=Tr(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-3 backdrop-blur-xl sm:px-4 sm:py-4",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:Rr(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(Er,{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(G,{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(G,{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(fo,{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 Kt({payload:e,disabled:t=!1,bypassEnabled:n=!1,onBypassChange:s,onSubmit:o}){const[a,l]=i.useState(()=>n?Nd(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=jd(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(Sd(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(G,{type:"button",variant:n?"secondary":"outline",size:"sm",onClick:()=>s==null?void 0:s(!n),className:"rounded-full",children:[r.jsx(Gc,{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:U("flex w-full items-start gap-3 rounded-[18px] border px-4 py-3 text-left transition-colors",w?"border-primary/50 bg-primary/10 text-foreground":"border-border/60 bg-background/80 text-foreground hover:border-primary/30 hover:bg-primary/5"),children:[r.jsx("span",{className:U("mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border",w?"border-primary bg-primary text-primary-foreground":"border-border/70 bg-background text-transparent"),children:r.jsx(Cr,{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(G,{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 Is({event:e,questionBypassEnabled:t=!1,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o=!1}){const a=e.type,l=Cn(e);if(l)return r.jsx(ur,{children:r.jsx(Kt,{payload:l,bypassEnabled:t,onBypassChange:n,onSubmit:s,disabled:o})});if(a==="user"){const c=Yt(e);return c?r.jsx(vf,{content:c}):null}return a==="assistant"?r.jsx(bf,{event:e,questionBypassEnabled:t,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o}):null}function Os(e){var n;const t=e.replace(/\r\n/g,`
|
|
189
189
|
`).split(`
|
|
190
190
|
`);for(;t.length>0&&((n=t[0])==null?void 0:n.trim())==="";)t.shift();return t.join(`
|
|
191
|
-
`)}function vf({content:e}){const t=hd(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:
|
|
192
|
-
`)}),f.map((g,p)=>{if(g.questionPayload){const v=Tt(g.questionPayload);return d.has(v)?null:(d.add(v),r.jsx(Kt,{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(wf,{block:g,renderedQuestionSignatures:d,questionBypassEnabled:t,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o},p)),h.map((g,p)=>r.jsx(Nf,{block:g,renderedQuestionSignatures:d,questionBypassEnabled:t,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o},p))]}):null}function yf({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(
|
|
193
|
-
`):"";if(!f)return null;const u=kn(f);if(u){const h=Tt(u);return t!=null&&t.has(h)?null:(t==null||t.add(h),r.jsx(Kt,{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(rt,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}):r.jsx(Gt,{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 ra(e){const t=e+"CollectionProvider",[n,s]=st(t),[o,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),l=p=>{const{scope:v,children:b}=p,y=lt.useRef(null),w=lt.useRef(new Map).current;return r.jsx(o,{scope:v,itemMap:w,collectionRef:y,children:b})};l.displayName=t;const c=e+"CollectionSlot",d=Ht(c),f=lt.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=Ht(u),x=lt.forwardRef((p,v)=>{const{scope:b,children:y,...w}=p,j=lt.useRef(null),k=se(v,j),C=a(u,b);return lt.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 lt.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 jf=i.createContext(void 0);function Ur(e){const t=i.useContext(jf);return e||t||"ltr"}var Qn="rovingFocusGroup.onEntryFocus",Sf={bubbles:!1,cancelable:!0},Jt="RovingFocusGroup",[ur,sa,Cf]=ra(Jt),[kf,oa]=st(Jt,[Cf]),[Ef,Af]=kf(Jt),aa=i.forwardRef((e,t)=>r.jsx(ur.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(ur.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Tf,{...e,ref:t})})}));aa.displayName=Jt;var Tf=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=Ur(a),[p,v]=kt({prop:l,defaultProp:c??null,onChange:d,caller:Jt}),[b,y]=i.useState(!1),w=et(f),j=sa(n),k=i.useRef(!1),[C,S]=i.useState(0);return i.useEffect(()=>{const R=h.current;if(R)return R.addEventListener(Qn,w),()=>R.removeEventListener(Qn,w)},[w]),r.jsx(Ef,{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:Y(e.onMouseDown,()=>{k.current=!0}),onFocus:Y(e.onFocus,R=>{const O=!k.current;if(R.target===R.currentTarget&&O&&!b){const F=new CustomEvent(Qn,Sf);if(R.currentTarget.dispatchEvent(F),!F.defaultPrevented){const B=j().filter(_=>_.focusable),V=B.find(_=>_.active),L=B.find(_=>_.id===p),H=[V,L,...B].filter(Boolean).map(_=>_.ref.current);ca(H,u)}}k.current=!1}),onBlur:Y(e.onBlur,()=>y(!1))})})}),ia="RovingFocusGroupItem",la=i.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:o=!1,tabStopId:a,children:l,...c}=e,d=Je(),f=a||d,u=Af(ia,n),m=u.currentTabStopId===f,h=sa(n),{onFocusableItemAdd:x,onFocusableItemRemove:g,currentTabStopId:p}=u;return i.useEffect(()=>{if(s)return x(),()=>g()},[s,x,g]),r.jsx(ur.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:Y(e.onMouseDown,v=>{s?u.onItemFocus(f):v.preventDefault()}),onFocus:Y(e.onFocus,()=>u.onItemFocus(f)),onKeyDown:Y(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){u.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const b=Pf(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?Df(w,j+1):w.slice(j+1)}setTimeout(()=>ca(w))}}),children:typeof l=="function"?l({isCurrentTabStop:m,hasTabStop:p!=null}):l})})});la.displayName=ia;var Rf={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function _f(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Pf(e,t,n){const s=_f(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return Rf[s]}function ca(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function Df(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Mf=aa,If=la,Tn="Tabs",[Of]=st(Tn,[oa]),da=oa(),[Lf,Vr]=Of(Tn),ua=i.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:o,defaultValue:a,orientation:l="horizontal",dir:c,activationMode:d="automatic",...f}=e,u=Ur(c),[m,h]=kt({prop:s,onChange:o,defaultProp:a??"",caller:Tn});return r.jsx(Lf,{scope:n,baseId:Je(),value:m,onValueChange:h,orientation:l,dir:u,activationMode:d,children:r.jsx(X.div,{dir:u,"data-orientation":l,...f,ref:t})})});ua.displayName=Tn;var fa="TabsList",ma=i.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...o}=e,a=Vr(fa,n),l=da(n);return r.jsx(Mf,{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})})});ma.displayName=fa;var pa="TabsTrigger",ha=i.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,disabled:o=!1,...a}=e,l=Vr(pa,n),c=da(n),d=va(l.baseId,s),f=ba(l.baseId,s),u=s===l.value;return r.jsx(If,{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:Y(e.onMouseDown,m=>{!o&&m.button===0&&m.ctrlKey===!1?l.onValueChange(s):m.preventDefault()}),onKeyDown:Y(e.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&l.onValueChange(s)}),onFocus:Y(e.onFocus,()=>{const m=l.activationMode!=="manual";!u&&!o&&m&&l.onValueChange(s)})})})});ha.displayName=pa;var xa="TabsContent",ga=i.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,forceMount:o,children:a,...l}=e,c=Vr(xa,n),d=va(c.baseId,s),f=ba(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(Rt,{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})})});ga.displayName=xa;function va(e,t){return`${e}-trigger-${t}`}function ba(e,t){return`${e}-content-${t}`}var $f=ua,ya=ma,wa=ha,Na=ga;const ja=$f,Wr=i.forwardRef(({className:e,...t},n)=>r.jsx(ya,{ref:n,className:U("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));Wr.displayName=ya.displayName;const Ye=i.forwardRef(({className:e,...t},n)=>r.jsx(wa,{ref:n,className:U("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...t}));Ye.displayName=wa.displayName;const Xe=i.forwardRef(({className:e,...t},n)=>r.jsx(Na,{ref:n,className:U("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Xe.displayName=Na.displayName;var Sa="AlertDialog",[Ff]=st(Sa,[_o]),Ve=_o(),Ca=e=>{const{__scopeAlertDialog:t,...n}=e,s=Ve(t);return r.jsx(qo,{...s,...n,modal:!0})};Ca.displayName=Sa;var Bf="AlertDialogTrigger",ka=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=Ve(n);return r.jsx(lf,{...o,...s,ref:t})});ka.displayName=Bf;var Uf="AlertDialogPortal",Ea=e=>{const{__scopeAlertDialog:t,...n}=e,s=Ve(t);return r.jsx(Go,{...s,...n})};Ea.displayName=Uf;var Vf="AlertDialogOverlay",Aa=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=Ve(n);return r.jsx(Or,{...o,...s,ref:t})});Aa.displayName=Vf;var St="AlertDialogContent",[Wf,zf]=Ff(St),Hf=Ud("AlertDialogContent"),Ta=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(rf,{contentName:St,titleName:Ra,docsSlug:"alert-dialog",children:r.jsx(Wf,{scope:n,cancelRef:d,children:r.jsxs(Lr,{role:"alertdialog",...a,...o,ref:c,onOpenAutoFocus:Y(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(Hf,{children:s}),r.jsx(qf,{contentRef:l})]})})})});Ta.displayName=St;var Ra="AlertDialogTitle",_a=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=Ve(n);return r.jsx($r,{...o,...s,ref:t})});_a.displayName=Ra;var Pa="AlertDialogDescription",Da=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=Ve(n);return r.jsx(Fr,{...o,...s,ref:t})});Da.displayName=Pa;var Kf="AlertDialogAction",Ma=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=Ve(n);return r.jsx(Br,{...o,...s,ref:t})});Ma.displayName=Kf;var Ia="AlertDialogCancel",Oa=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,{cancelRef:o}=zf(Ia,n),a=Ve(n),l=se(t,o);return r.jsx(Br,{...a,...s,ref:l})});Oa.displayName=Ia;var qf=({contentRef:e})=>{const t=`\`${St}\` requires a description for the component to be accessible for screen reader users.
|
|
191
|
+
`)}function vf({content:e}){const t=hd(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:Rr(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(Zc,{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(Sr,{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 bf({event:e,questionBypassEnabled:t,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o}){const a=e.message;if(!a)return null;const l=Cn(a);if(l)return r.jsx(ur,{children:r.jsx(Kt,{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:Os(String(g.text??"")),questionPayload:kn(Os(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(yf,{text:u.map(g=>String(g.thinking??"")).join(`
|
|
192
|
+
`)}),f.map((g,p)=>{if(g.questionPayload){const v=Tt(g.questionPayload);return d.has(v)?null:(d.add(v),r.jsx(Kt,{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(wf,{block:g,renderedQuestionSignatures:d,questionBypassEnabled:t,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o},p)),h.map((g,p)=>r.jsx(Nf,{block:g,renderedQuestionSignatures:d,questionBypassEnabled:t,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o},p))]}):null}function yf({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(Ve,{className:"h-3 w-3"}):r.jsx(Gt,{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 wf({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=Cn(e);if(u){const m=Tt(u);return t!=null&&t.has(m)?null:(t==null||t.add(m),r.jsx(Kt,{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(ed,{className:"h-3.5 w-3.5 shrink-0"}),r.jsx("span",{className:"font-mono text-[11px]",children:d}),l?r.jsx(Ve,{className:"ml-auto h-3.5 w-3.5"}):r.jsx(Gt,{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 Nf({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(`
|
|
193
|
+
`):"";if(!f)return null;const u=kn(f);if(u){const h=Tt(u);return t!=null&&t.has(h)?null:(t==null||t.add(h),r.jsx(Kt,{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(Ve,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}):r.jsx(Gt,{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 ra(e){const t=e+"CollectionProvider",[n,s]=st(t),[o,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),l=p=>{const{scope:v,children:b}=p,y=lt.useRef(null),w=lt.useRef(new Map).current;return r.jsx(o,{scope:v,itemMap:w,collectionRef:y,children:b})};l.displayName=t;const c=e+"CollectionSlot",d=Ht(c),f=lt.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=Ht(u),x=lt.forwardRef((p,v)=>{const{scope:b,children:y,...w}=p,j=lt.useRef(null),k=se(v,j),C=a(u,b);return lt.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 lt.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 jf=i.createContext(void 0);function Vr(e){const t=i.useContext(jf);return e||t||"ltr"}var er="rovingFocusGroup.onEntryFocus",Sf={bubbles:!1,cancelable:!0},Jt="RovingFocusGroup",[fr,sa,Cf]=ra(Jt),[kf,oa]=st(Jt,[Cf]),[Ef,Af]=kf(Jt),aa=i.forwardRef((e,t)=>r.jsx(fr.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(fr.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Tf,{...e,ref:t})})}));aa.displayName=Jt;var Tf=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=Vr(a),[p,v]=kt({prop:l,defaultProp:c??null,onChange:d,caller:Jt}),[b,y]=i.useState(!1),w=tt(f),j=sa(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(Ef,{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:Y(e.onMouseDown,()=>{k.current=!0}),onFocus:Y(e.onFocus,R=>{const O=!k.current;if(R.target===R.currentTarget&&O&&!b){const F=new CustomEvent(er,Sf);if(R.currentTarget.dispatchEvent(F),!F.defaultPrevented){const B=j().filter(_=>_.focusable),V=B.find(_=>_.active),L=B.find(_=>_.id===p),H=[V,L,...B].filter(Boolean).map(_=>_.ref.current);ca(H,u)}}k.current=!1}),onBlur:Y(e.onBlur,()=>y(!1))})})}),ia="RovingFocusGroupItem",la=i.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:o=!1,tabStopId:a,children:l,...c}=e,d=Ze(),f=a||d,u=Af(ia,n),m=u.currentTabStopId===f,h=sa(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:Y(e.onMouseDown,v=>{s?u.onItemFocus(f):v.preventDefault()}),onFocus:Y(e.onFocus,()=>u.onItemFocus(f)),onKeyDown:Y(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){u.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const b=Pf(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?Df(w,j+1):w.slice(j+1)}setTimeout(()=>ca(w))}}),children:typeof l=="function"?l({isCurrentTabStop:m,hasTabStop:p!=null}):l})})});la.displayName=ia;var Rf={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function _f(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Pf(e,t,n){const s=_f(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return Rf[s]}function ca(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function Df(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Mf=aa,If=la,Rn="Tabs",[Of]=st(Rn,[oa]),da=oa(),[Lf,Wr]=Of(Rn),ua=i.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:o,defaultValue:a,orientation:l="horizontal",dir:c,activationMode:d="automatic",...f}=e,u=Vr(c),[m,h]=kt({prop:s,onChange:o,defaultProp:a??"",caller:Rn});return r.jsx(Lf,{scope:n,baseId:Ze(),value:m,onValueChange:h,orientation:l,dir:u,activationMode:d,children:r.jsx(X.div,{dir:u,"data-orientation":l,...f,ref:t})})});ua.displayName=Rn;var fa="TabsList",ma=i.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...o}=e,a=Wr(fa,n),l=da(n);return r.jsx(Mf,{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})})});ma.displayName=fa;var pa="TabsTrigger",ha=i.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,disabled:o=!1,...a}=e,l=Wr(pa,n),c=da(n),d=va(l.baseId,s),f=ba(l.baseId,s),u=s===l.value;return r.jsx(If,{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:Y(e.onMouseDown,m=>{!o&&m.button===0&&m.ctrlKey===!1?l.onValueChange(s):m.preventDefault()}),onKeyDown:Y(e.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&l.onValueChange(s)}),onFocus:Y(e.onFocus,()=>{const m=l.activationMode!=="manual";!u&&!o&&m&&l.onValueChange(s)})})})});ha.displayName=pa;var xa="TabsContent",ga=i.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,forceMount:o,children:a,...l}=e,c=Wr(xa,n),d=va(c.baseId,s),f=ba(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(Rt,{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})})});ga.displayName=xa;function va(e,t){return`${e}-trigger-${t}`}function ba(e,t){return`${e}-content-${t}`}var $f=ua,ya=ma,wa=ha,Na=ga;const ja=$f,zr=i.forwardRef(({className:e,...t},n)=>r.jsx(ya,{ref:n,className:U("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));zr.displayName=ya.displayName;const Xe=i.forwardRef(({className:e,...t},n)=>r.jsx(wa,{ref:n,className:U("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...t}));Xe.displayName=wa.displayName;const Je=i.forwardRef(({className:e,...t},n)=>r.jsx(Na,{ref:n,className:U("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Je.displayName=Na.displayName;var Sa="AlertDialog",[Ff]=st(Sa,[_o]),We=_o(),Ca=e=>{const{__scopeAlertDialog:t,...n}=e,s=We(t);return r.jsx(qo,{...s,...n,modal:!0})};Ca.displayName=Sa;var Bf="AlertDialogTrigger",ka=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=We(n);return r.jsx(lf,{...o,...s,ref:t})});ka.displayName=Bf;var Uf="AlertDialogPortal",Ea=e=>{const{__scopeAlertDialog:t,...n}=e,s=We(t);return r.jsx(Go,{...s,...n})};Ea.displayName=Uf;var Vf="AlertDialogOverlay",Aa=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=We(n);return r.jsx($r,{...o,...s,ref:t})});Aa.displayName=Vf;var St="AlertDialogContent",[Wf,zf]=Ff(St),Hf=Ud("AlertDialogContent"),Ta=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,children:s,...o}=e,a=We(n),l=i.useRef(null),c=se(t,l),d=i.useRef(null);return r.jsx(rf,{contentName:St,titleName:Ra,docsSlug:"alert-dialog",children:r.jsx(Wf,{scope:n,cancelRef:d,children:r.jsxs(Fr,{role:"alertdialog",...a,...o,ref:c,onOpenAutoFocus:Y(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(Hf,{children:s}),r.jsx(qf,{contentRef:l})]})})})});Ta.displayName=St;var Ra="AlertDialogTitle",_a=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=We(n);return r.jsx(Br,{...o,...s,ref:t})});_a.displayName=Ra;var Pa="AlertDialogDescription",Da=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=We(n);return r.jsx(Ur,{...o,...s,ref:t})});Da.displayName=Pa;var Kf="AlertDialogAction",Ma=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=We(n);return r.jsx(Tn,{...o,...s,ref:t})});Ma.displayName=Kf;var Ia="AlertDialogCancel",Oa=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,{cancelRef:o}=zf(Ia,n),a=We(n),l=se(t,o);return r.jsx(Tn,{...a,...s,ref:l})});Oa.displayName=Ia;var qf=({contentRef:e})=>{const t=`\`${St}\` requires a description for the component to be accessible for screen reader users.
|
|
194
194
|
|
|
195
195
|
You can add a description to the \`${St}\` by passing a \`${Pa}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
|
|
196
196
|
|
|
197
197
|
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 \`${St}\`. 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.
|
|
198
198
|
|
|
199
|
-
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},Gf=Ca,Yf=ka,Xf=Ea,La=Aa,$a=Ta,Fa=Ma,Ba=Oa,Ua=_a,Va=Da;const un=Gf,fn=Yf,Jf=Xf,Wa=i.forwardRef(({className:e,...t},n)=>r.jsx(La,{className:U("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));Wa.displayName=La.displayName;const Lt=i.forwardRef(({className:e,...t},n)=>r.jsxs(Jf,{children:[r.jsx(Wa,{}),r.jsx($a,{ref:n,className:U("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]}));Lt.displayName=$a.displayName;const $t=({className:e,...t})=>r.jsx("div",{className:U("flex flex-col space-y-2 text-center sm:text-left",e),...t});$t.displayName="AlertDialogHeader";const Ft=({className:e,...t})=>r.jsx("div",{className:U("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Ft.displayName="AlertDialogFooter";const Bt=i.forwardRef(({className:e,...t},n)=>r.jsx(Ua,{ref:n,className:U("text-lg font-semibold",e),...t}));Bt.displayName=Ua.displayName;const Ut=i.forwardRef(({className:e,...t},n)=>r.jsx(Va,{ref:n,className:U("text-sm text-muted-foreground",e),...t}));Ut.displayName=Va.displayName;const Vt=i.forwardRef(({className:e,...t},n)=>r.jsx(Fa,{ref:n,className:U(eo(),e),...t}));Vt.displayName=Fa.displayName;const Wt=i.forwardRef(({className:e,...t},n)=>r.jsx(Ba,{ref:n,className:U(eo({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));Wt.displayName=Ba.displayName;function Os(e,[t,n]){return Math.min(n,Math.max(t,e))}const Zf=["top","right","bottom","left"],tt=Math.min,Ne=Math.max,vn=Math.round,ln=Math.floor,Le=e=>({x:e,y:e}),Qf={left:"right",right:"left",bottom:"top",top:"bottom"};function fr(e,t,n){return Ne(e,tt(t,n))}function Be(e,t){return typeof e=="function"?e(t):e}function Ue(e){return e.split("-")[0]}function _t(e){return e.split("-")[1]}function zr(e){return e==="x"?"y":"x"}function Hr(e){return e==="y"?"height":"width"}function Oe(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Kr(e){return zr(Oe(e))}function em(e,t,n){n===void 0&&(n=!1);const s=_t(e),o=Kr(e),a=Hr(o);let l=o==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(l=bn(l)),[l,bn(l)]}function tm(e){const t=bn(e);return[mr(e),t,mr(t)]}function mr(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Ls=["left","right"],$s=["right","left"],nm=["top","bottom"],rm=["bottom","top"];function sm(e,t,n){switch(e){case"top":case"bottom":return n?t?$s:Ls:t?Ls:$s;case"left":case"right":return t?nm:rm;default:return[]}}function om(e,t,n,s){const o=_t(e);let a=sm(Ue(e),n==="start",s);return o&&(a=a.map(l=>l+"-"+o),t&&(a=a.concat(a.map(mr)))),a}function bn(e){const t=Ue(e);return Qf[t]+e.slice(t.length)}function am(e){return{top:0,right:0,bottom:0,left:0,...e}}function za(e){return typeof e!="number"?am(e):{top:e,right:e,bottom:e,left:e}}function yn(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 Fs(e,t,n){let{reference:s,floating:o}=e;const a=Oe(t),l=Kr(t),c=Hr(l),d=Ue(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(_t(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 im(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}=Be(t,e),g=za(x),v=c[h?m==="floating"?"reference":"floating":m],b=yn(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=yn(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 lm=50,cm=async(e,t,n)=>{const{placement:s="bottom",strategy:o="absolute",middleware:a=[],platform:l}=n,c=l.detectOverflow?l:{...l,detectOverflow:im},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}=Fs(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<lm&&(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}=Fs(f,h,d)),p=-1)}return{x:u,y:m,placement:h,strategy:o,middlewareData:g}},dm=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}=Be(e,t)||{};if(f==null)return{};const m=za(u),h={x:n,y:s},x=Kr(o),g=Hr(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,O=S/2-p[g]/2-1,F=tt(m[b],O),B=tt(m[y],O),V=F,L=S-p[g]-B,$=S/2-p[g]/2+R,H=fr(V,$,L),_=!d.arrow&&_t(o)!=null&&$!==H&&a.reference[g]/2-($<V?F:B)-p[g]/2<0,P=_?$<V?$-V:$-L:0;return{[x]:h[x]+P,data:{[x]:H,centerOffset:$-H-P,..._&&{alignmentOffset:P}},reset:_}}}),um=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}=Be(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const b=Ue(o),y=Oe(c),w=Ue(c)===c,j=await(d.isRTL==null?void 0:d.isRTL(f.floating)),k=h||(w||!p?[bn(c)]:tm(c)),C=g!=="none";!h&&C&&k.push(...om(c,p,g,j));const S=[c,...k],R=await d.detectOverflow(t,v),O=[];let F=((s=a.flip)==null?void 0:s.overflows)||[];if(u&&O.push(R[b]),m){const $=em(o,l,j);O.push(R[$[0]],R[$[1]])}if(F=[...F,{placement:o,overflows:O}],!O.every($=>$<=0)){var B,V;const $=(((B=a.flip)==null?void 0:B.index)||0)+1,H=S[$];if(H&&(!(m==="alignment"?y!==Oe(H):!1)||F.every(I=>Oe(I.placement)===y?I.overflows[0]>0:!0)))return{data:{index:$,overflows:F},reset:{placement:H}};let _=(V=F.filter(P=>P.overflows[0]<=0).sort((P,I)=>P.overflows[1]-I.overflows[1])[0])==null?void 0:V.placement;if(!_)switch(x){case"bestFit":{var L;const P=(L=F.filter(I=>{if(C){const z=Oe(I.placement);return z===y||z==="y"}return!0}).map(I=>[I.placement,I.overflows.filter(z=>z>0).reduce((z,K)=>z+K,0)]).sort((I,z)=>I[1]-z[1])[0])==null?void 0:L[0];P&&(_=P);break}case"initialPlacement":_=c;break}if(o!==_)return{reset:{placement:_}}}return{}}}};function Bs(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Us(e){return Zf.some(t=>e[t]>=0)}const fm=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:s}=t,{strategy:o="referenceHidden",...a}=Be(e,t);switch(o){case"referenceHidden":{const l=await s.detectOverflow(t,{...a,elementContext:"reference"}),c=Bs(l,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:Us(c)}}}case"escaped":{const l=await s.detectOverflow(t,{...a,altBoundary:!0}),c=Bs(l,n.floating);return{data:{escapedOffsets:c,escaped:Us(c)}}}default:return{}}}}},Ha=new Set(["left","top"]);async function mm(e,t){const{placement:n,platform:s,elements:o}=e,a=await(s.isRTL==null?void 0:s.isRTL(o.floating)),l=Ue(n),c=_t(n),d=Oe(n)==="y",f=Ha.has(l)?-1:1,u=a&&d?-1:1,m=Be(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 pm=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 mm(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}}}}},hm=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}=Be(e,t),u={x:n,y:s},m=await a.detectOverflow(t,f),h=Oe(Ue(o)),x=zr(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=fr(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=fr(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}}}}}},xm=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}=Be(e,t),u={x:n,y:s},m=Oe(o),h=zr(m);let x=u[h],g=u[m];const p=Be(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=Ha.has(Ue(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}}}},gm=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}=Be(e,t),u=await l.detectOverflow(t,f),m=Ue(o),h=_t(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=tt(p-u[v],y),k=tt(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 F=Ne(u.left,0),B=Ne(u.right,0),V=Ne(u.top,0),L=Ne(u.bottom,0);x?R=g-2*(F!==0||B!==0?F+B:Ne(u.left,u.right)):S=p-2*(V!==0||L!==0?V+L:Ne(u.top,u.bottom))}await d({...t,availableWidth:R,availableHeight:S});const O=await l.getDimensions(c.floating);return g!==O.width||p!==O.height?{reset:{rects:!0}}:{}}}};function Rn(){return typeof window<"u"}function Pt(e){return Ka(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=(Ka(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Ka(e){return Rn()?e instanceof Node||e instanceof Se(e).Node:!1}function _e(e){return Rn()?e instanceof Element||e instanceof Se(e).Element:!1}function We(e){return Rn()?e instanceof HTMLElement||e instanceof Se(e).HTMLElement:!1}function Vs(e){return!Rn()||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 vm(e){return/^(table|td|th)$/.test(Pt(e))}function _n(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const bm=/transform|translate|scale|rotate|perspective|filter/,ym=/paint|layout|strict|content/,ct=e=>!!e&&e!=="none";let er;function qr(e){const t=_e(e)?Pe(e):e;return ct(t.transform)||ct(t.translate)||ct(t.scale)||ct(t.rotate)||ct(t.perspective)||!Gr()&&(ct(t.backdropFilter)||ct(t.filter))||bm.test(t.willChange||"")||ym.test(t.contain||"")}function wm(e){let t=nt(e);for(;We(t)&&!Et(t);){if(qr(t))return t;if(_n(t))return null;t=nt(t)}return null}function Gr(){return er==null&&(er=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),er}function Et(e){return/^(html|body|#document)$/.test(Pt(e))}function Pe(e){return Se(e).getComputedStyle(e)}function Pn(e){return _e(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function nt(e){if(Pt(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Vs(e)&&e.host||$e(e);return Vs(t)?t.host:t}function qa(e){const t=nt(e);return Et(t)?e.ownerDocument?e.ownerDocument.body:e.body:We(t)&&Zt(t)?t:qa(t)}function qt(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=qa(e),a=o===((s=e.ownerDocument)==null?void 0:s.body),l=Se(o);if(a){const c=pr(l);return t.concat(l,l.visualViewport||[],Zt(o)?o:[],c&&n?qt(c):[])}else return t.concat(o,qt(o,[],n))}function pr(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Ga(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=vn(n)!==a||vn(s)!==l;return c&&(n=a,s=l),{width:n,height:s,$:c}}function Yr(e){return _e(e)?e:e.contextElement}function Ct(e){const t=Yr(e);if(!We(t))return Le(1);const n=t.getBoundingClientRect(),{width:s,height:o,$:a}=Ga(t);let l=(a?vn(n.width):n.width)/s,c=(a?vn(n.height):n.height)/o;return(!l||!Number.isFinite(l))&&(l=1),(!c||!Number.isFinite(c))&&(c=1),{x:l,y:c}}const Nm=Le(0);function Ya(e){const t=Se(e);return!Gr()||!t.visualViewport?Nm:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function jm(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Se(e)?!1:t}function mt(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),a=Yr(e);let l=Le(1);t&&(s?_e(s)&&(l=Ct(s)):l=Ct(e));const c=jm(a,n,s)?Ya(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=pr(g);for(;p&&s&&x!==g;){const v=Ct(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=pr(g)}}return yn({width:u,height:m,x:d,y:f})}function Dn(e,t){const n=Pn(e).scrollLeft;return t?t.left+n:mt($e(e)).left+n}function Xa(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-Dn(e,n),o=n.top+t.scrollTop;return{x:s,y:o}}function Sm(e){let{elements:t,rect:n,offsetParent:s,strategy:o}=e;const a=o==="fixed",l=$e(s),c=t?_n(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)&&((Pt(s)!=="body"||Zt(l))&&(d=Pn(s)),m)){const x=mt(s);f=Ct(s),u.x=x.x+s.clientLeft,u.y=x.y+s.clientTop}const h=l&&!m&&!a?Xa(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 Cm(e){return Array.from(e.getClientRects())}function km(e){const t=$e(e),n=Pn(e),s=e.ownerDocument.body,o=Ne(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),a=Ne(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let l=-n.scrollLeft+Dn(e);const c=-n.scrollTop;return Pe(s).direction==="rtl"&&(l+=Ne(t.clientWidth,s.clientWidth)-o),{width:o,height:a,x:l,y:c}}const Ws=25;function Em(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=Gr();(!u||u&&t==="fixed")&&(c=o.offsetLeft,d=o.offsetTop)}const f=Dn(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<=Ws&&(a-=g)}else f<=Ws&&(a+=f);return{width:a,height:l,x:c,y:d}}function Am(e,t){const n=mt(e,!0,t==="fixed"),s=n.top+e.clientTop,o=n.left+e.clientLeft,a=We(e)?Ct(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 zs(e,t,n){let s;if(t==="viewport")s=Em(e,n);else if(t==="document")s=km($e(e));else if(_e(t))s=Am(t,n);else{const o=Ya(e);s={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return yn(s)}function Ja(e,t){const n=nt(e);return n===t||!_e(n)||Et(n)?!1:Pe(n).position==="fixed"||Ja(n,t)}function Tm(e,t){const n=t.get(e);if(n)return n;let s=qt(e,[],!1).filter(c=>_e(c)&&Pt(c)!=="body"),o=null;const a=Pe(e).position==="fixed";let l=a?nt(e):e;for(;_e(l)&&!Et(l);){const c=Pe(l),d=qr(l);!d&&c.position==="fixed"&&(o=null),(a?!d&&!o:!d&&c.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Zt(l)&&!d&&Ja(e,l))?s=s.filter(u=>u!==l):o=c,l=nt(l)}return t.set(e,s),s}function Rm(e){let{element:t,boundary:n,rootBoundary:s,strategy:o}=e;const l=[...n==="clippingAncestors"?_n(t)?[]:Tm(t,this._c):[].concat(n),s],c=zs(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=zs(t,l[h],o);d=Ne(x.top,d),f=tt(x.right,f),u=tt(x.bottom,u),m=Ne(x.left,m)}return{width:f-m,height:u-d,x:m,y:d}}function _m(e){const{width:t,height:n}=Ga(e);return{width:t,height:n}}function Pm(e,t,n){const s=We(t),o=$e(t),a=n==="fixed",l=mt(e,!0,a,t);let c={scrollLeft:0,scrollTop:0};const d=Le(0);function f(){d.x=Dn(o)}if(s||!s&&!a)if((Pt(t)!=="body"||Zt(o))&&(c=Pn(t)),s){const x=mt(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?Xa(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 tr(e){return Pe(e).position==="static"}function Hs(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 Za(e,t){const n=Se(e);if(_n(e))return n;if(!We(e)){let o=nt(e);for(;o&&!Et(o);){if(_e(o)&&!tr(o))return o;o=nt(o)}return n}let s=Hs(e,t);for(;s&&vm(s)&&tr(s);)s=Hs(s,t);return s&&Et(s)&&tr(s)&&!qr(s)?n:s||wm(e)||n}const Dm=async function(e){const t=this.getOffsetParent||Za,n=this.getDimensions,s=await n(e.floating);return{reference:Pm(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function Mm(e){return Pe(e).direction==="rtl"}const Im={convertOffsetParentRelativeRectToViewportRelativeRect:Sm,getDocumentElement:$e,getClippingRect:Rm,getOffsetParent:Za,getElementRects:Dm,getClientRects:Cm,getDimensions:_m,getScale:Ct,isElement:_e,isRTL:Mm};function Qa(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Om(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=ln(m),p=ln(o.clientWidth-(u+h)),v=ln(o.clientHeight-(m+x)),b=ln(u),w={rootMargin:-g+"px "+-p+"px "+-v+"px "+-b+"px",threshold:Ne(0,tt(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&&!Qa(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 Lm(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=Yr(e),u=o||a?[...f?qt(f):[],...t?qt(t):[]]:[];u.forEach(b=>{o&&b.addEventListener("scroll",n,{passive:!0}),a&&b.addEventListener("resize",n)});const m=f&&c?Om(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?mt(e):null;d&&v();function v(){const b=mt(e);p&&!Qa(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 $m=pm,Fm=hm,Bm=um,Um=gm,Vm=fm,Ks=dm,Wm=xm,zm=(e,t,n)=>{const s=new Map,o={platform:Im,...n},a={...o.platform,_c:s};return cm(e,t,{...o,platform:a})};var Hm=typeof document<"u",Km=function(){},mn=Hm?i.useLayoutEffect:Km;function wn(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(!wn(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)&&!wn(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function ei(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function qs(e,t){const n=ei(e);return Math.round(t*n)/n}function nr(e){const t=i.useRef(e);return mn(()=>{t.current=e}),t}function qm(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);wn(h,s)||x(s);const[g,p]=i.useState(null),[v,b]=i.useState(null),y=i.useCallback(I=>{I!==C.current&&(C.current=I,p(I))},[]),w=i.useCallback(I=>{I!==S.current&&(S.current=I,b(I))},[]),j=a||g,k=l||v,C=i.useRef(null),S=i.useRef(null),R=i.useRef(u),O=d!=null,F=nr(d),B=nr(o),V=nr(f),L=i.useCallback(()=>{if(!C.current||!S.current)return;const I={placement:t,strategy:n,middleware:h};B.current&&(I.platform=B.current),zm(C.current,S.current,I).then(z=>{const K={...z,isPositioned:V.current!==!1};$.current&&!wn(R.current,K)&&(R.current=K,Sn.flushSync(()=>{m(K)}))})},[h,t,n,B,V]);mn(()=>{f===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,m(I=>({...I,isPositioned:!1})))},[f]);const $=i.useRef(!1);mn(()=>($.current=!0,()=>{$.current=!1}),[]),mn(()=>{if(j&&(C.current=j),k&&(S.current=k),j&&k){if(F.current)return F.current(j,k,L);L()}},[j,k,L,F,O]);const H=i.useMemo(()=>({reference:C,floating:S,setReference:y,setFloating:w}),[y,w]),_=i.useMemo(()=>({reference:j,floating:k}),[j,k]),P=i.useMemo(()=>{const I={position:n,left:0,top:0};if(!_.floating)return I;const z=qs(_.floating,u.x),K=qs(_.floating,u.y);return c?{...I,transform:"translate("+z+"px, "+K+"px)",...ei(_.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:z,top:K}},[n,c,_.floating,u.x,u.y]);return i.useMemo(()=>({...u,update:L,refs:H,elements:_,floatingStyles:P}),[u,L,H,_,P])}const Gm=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?Ks({element:s.current,padding:o}).fn(n):{}:s?Ks({element:s,padding:o}).fn(n):{}}}},Ym=(e,t)=>{const n=$m(e);return{name:n.name,fn:n.fn,options:[e,t]}},Xm=(e,t)=>{const n=Fm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Jm=(e,t)=>({fn:Wm(e).fn,options:[e,t]}),Zm=(e,t)=>{const n=Bm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Qm=(e,t)=>{const n=Um(e);return{name:n.name,fn:n.fn,options:[e,t]}},ep=(e,t)=>{const n=Vm(e);return{name:n.name,fn:n.fn,options:[e,t]}},tp=(e,t)=>{const n=Gm(e);return{name:n.name,fn:n.fn,options:[e,t]}};var np="Arrow",ti=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"})})});ti.displayName=np;var rp=ti;function ni(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 Xr="Popper",[ri,si]=st(Xr),[sp,oi]=ri(Xr),ai=e=>{const{__scopePopper:t,children:n}=e,[s,o]=i.useState(null);return r.jsx(sp,{scope:t,anchor:s,onAnchorChange:o,children:n})};ai.displayName=Xr;var ii="PopperAnchor",li=i.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:s,...o}=e,a=oi(ii,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})});li.displayName=ii;var Jr="PopperContent",[op,ap]=ri(Jr),ci=i.forwardRef((e,t)=>{var M,Z,he,ee,Q,q;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=oi(Jr,n),[b,y]=i.useState(null),w=se(t,ue=>y(ue)),[j,k]=i.useState(null),C=ni(j),S=(C==null?void 0:C.width)??0,R=(C==null?void 0:C.height)??0,O=s+(a!=="center"?"-"+a:""),F=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},B=Array.isArray(f)?f:[f],V=B.length>0,L={padding:F,boundary:B.filter(lp),altBoundary:V},{refs:$,floatingStyles:H,placement:_,isPositioned:P,middlewareData:I}=qm({strategy:"fixed",placement:O,whileElementsMounted:(...ue)=>Lm(...ue,{animationFrame:x==="always"}),elements:{reference:v.anchor},middleware:[Ym({mainAxis:o+R,alignmentAxis:l}),d&&Xm({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?Jm():void 0,...L}),d&&Zm({...L}),Qm({...L,apply:({elements:ue,rects:E,availableWidth:te,availableHeight:de})=>{const{width:Ce,height:ze}=E.reference,xt=ue.floating.style;xt.setProperty("--radix-popper-available-width",`${te}px`),xt.setProperty("--radix-popper-available-height",`${de}px`),xt.setProperty("--radix-popper-anchor-width",`${Ce}px`),xt.setProperty("--radix-popper-anchor-height",`${ze}px`)}}),j&&tp({element:j,padding:c}),cp({arrowWidth:S,arrowHeight:R}),h&&ep({strategy:"referenceHidden",...L})]}),[z,K]=fi(_),T=et(g);ge(()=>{P&&(T==null||T())},[P,T]);const oe=(M=I.arrow)==null?void 0:M.x,pe=(Z=I.arrow)==null?void 0:Z.y,ce=((he=I.arrow)==null?void 0:he.centerOffset)!==0,[xe,ve]=i.useState();return ge(()=>{b&&ve(window.getComputedStyle(b).zIndex)},[b]),r.jsx("div",{ref:$.setFloating,"data-radix-popper-content-wrapper":"",style:{...H,transform:P?H.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:xe,"--radix-popper-transform-origin":[(ee=I.transformOrigin)==null?void 0:ee.x,(Q=I.transformOrigin)==null?void 0:Q.y].join(" "),...((q=I.hide)==null?void 0:q.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:r.jsx(op,{scope:n,placedSide:z,onArrowChange:k,arrowX:oe,arrowY:pe,shouldHideArrow:ce,children:r.jsx(X.div,{"data-side":z,"data-align":K,...p,ref:w,style:{...p.style,animation:P?void 0:"none"}})})})});ci.displayName=Jr;var di="PopperArrow",ip={top:"bottom",right:"left",bottom:"top",left:"right"},ui=i.forwardRef(function(t,n){const{__scopePopper:s,...o}=t,a=ap(di,s),l=ip[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(rp,{...o,ref:n,style:{...o.style,display:"block"}})})});ui.displayName=di;function lp(e){return e!==null}var cp=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]=fi(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 fi(e){const[t,n="center"]=e.split("-");return[t,n]}var dp=ai,up=li,fp=ci,mp=ui;function mi(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 pi=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"}),pp="VisuallyHidden",hp=i.forwardRef((e,t)=>r.jsx(X.span,{...e,ref:t,style:{...pi,...e.style}}));hp.displayName=pp;var xp=[" ","Enter","ArrowUp","ArrowDown"],gp=[" ","Enter"],pt="Select",[Mn,In,vp]=ra(pt),[Dt]=st(pt,[vp,si]),On=si(),[bp,ot]=Dt(pt),[yp,wp]=Dt(pt),hi=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=On(t),[v,b]=i.useState(null),[y,w]=i.useState(null),[j,k]=i.useState(!1),C=Ur(f),[S,R]=kt({prop:s,defaultProp:o??!1,onChange:a,caller:pt}),[O,F]=kt({prop:l,defaultProp:c,onChange:d,caller:pt}),B=i.useRef(null),V=v?g||!!v.closest("form"):!0,[L,$]=i.useState(new Set),H=Array.from(L).map(_=>_.props.value).join(";");return r.jsx(dp,{...p,children:r.jsxs(bp,{required:x,scope:t,trigger:v,onTriggerChange:b,valueNode:y,onValueNodeChange:w,valueNodeHasChildren:j,onValueNodeHasChildrenChange:k,contentId:Je(),value:O,onValueChange:F,open:S,onOpenChange:R,dir:C,triggerPointerDownPosRef:B,disabled:h,children:[r.jsx(Mn.Provider,{scope:t,children:r.jsx(yp,{scope:e.__scopeSelect,onNativeOptionAdd:i.useCallback(_=>{$(P=>new Set(P).add(_))},[]),onNativeOptionRemove:i.useCallback(_=>{$(P=>{const I=new Set(P);return I.delete(_),I})},[]),children:n})}),V?r.jsxs(Fi,{"aria-hidden":!0,required:x,tabIndex:-1,name:u,autoComplete:m,value:O,onChange:_=>F(_.target.value),disabled:h,form:g,children:[O===void 0?r.jsx("option",{value:""}):null,Array.from(L)]},H):null]})})};hi.displayName=pt;var xi="SelectTrigger",gi=i.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:s=!1,...o}=e,a=On(n),l=ot(xi,n),c=l.disabled||s,d=se(t,l.onTriggerChange),f=In(n),u=i.useRef("touch"),[m,h,x]=Ui(p=>{const v=f().filter(w=>!w.disabled),b=v.find(w=>w.value===l.value),y=Vi(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(up,{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":Bi(l.value)?"":void 0,...o,ref:d,onClick:Y(o.onClick,p=>{p.currentTarget.focus(),u.current!=="mouse"&&g(p)}),onPointerDown:Y(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:Y(o.onKeyDown,p=>{const v=m.current!=="";!(p.ctrlKey||p.altKey||p.metaKey)&&p.key.length===1&&h(p.key),!(v&&p.key===" ")&&xp.includes(p.key)&&(g(),p.preventDefault())})})})});gi.displayName=xi;var vi="SelectValue",bi=i.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:o,children:a,placeholder:l="",...c}=e,d=ot(vi,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:Bi(d.value)?r.jsx(r.Fragment,{children:l}):a})});bi.displayName=vi;var Np="SelectIcon",yi=i.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,...o}=e;return r.jsx(X.span,{"aria-hidden":!0,...o,ref:t,children:s||"▼"})});yi.displayName=Np;var jp="SelectPortal",wi=e=>r.jsx(_r,{asChild:!0,...e});wi.displayName=jp;var ht="SelectContent",Ni=i.forwardRef((e,t)=>{const n=ot(ht,e.__scopeSelect),[s,o]=i.useState();if(ge(()=>{o(new DocumentFragment)},[]),!n.open){const a=s;return a?Sn.createPortal(r.jsx(ji,{scope:e.__scopeSelect,children:r.jsx(Mn.Slot,{scope:e.__scopeSelect,children:r.jsx("div",{children:e.children})})}),a):null}return r.jsx(Si,{...e,ref:t})});Ni.displayName=ht;var Re=10,[ji,at]=Dt(ht),Sp="SelectContentImpl",Cp=Ht("SelectContent.RemoveScroll"),Si=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=ot(ht,n),[w,j]=i.useState(null),[k,C]=i.useState(null),S=se(t,M=>j(M)),[R,O]=i.useState(null),[F,B]=i.useState(null),V=In(n),[L,$]=i.useState(!1),H=i.useRef(!1);i.useEffect(()=>{if(w)return To(w)},[w]),yo();const _=i.useCallback(M=>{const[Z,...he]=V().map(q=>q.ref.current),[ee]=he.slice(-1),Q=document.activeElement;for(const q of M)if(q===Q||(q==null||q.scrollIntoView({block:"nearest"}),q===Z&&k&&(k.scrollTop=0),q===ee&&k&&(k.scrollTop=k.scrollHeight),q==null||q.focus(),document.activeElement!==Q))return},[V,k]),P=i.useCallback(()=>_([R,w]),[_,R,w]);i.useEffect(()=>{L&&P()},[L,P]);const{onOpenChange:I,triggerPointerDownPosRef:z}=y;i.useEffect(()=>{if(w){let M={x:0,y:0};const Z=ee=>{var Q,q;M={x:Math.abs(Math.round(ee.pageX)-(((Q=z.current)==null?void 0:Q.x)??0)),y:Math.abs(Math.round(ee.pageY)-(((q=z.current)==null?void 0:q.y)??0))}},he=ee=>{M.x<=10&&M.y<=10?ee.preventDefault():w.contains(ee.target)||I(!1),document.removeEventListener("pointermove",Z),z.current=null};return z.current!==null&&(document.addEventListener("pointermove",Z),document.addEventListener("pointerup",he,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Z),document.removeEventListener("pointerup",he,{capture:!0})}}},[w,I,z]),i.useEffect(()=>{const M=()=>I(!1);return window.addEventListener("blur",M),window.addEventListener("resize",M),()=>{window.removeEventListener("blur",M),window.removeEventListener("resize",M)}},[I]);const[K,T]=Ui(M=>{const Z=V().filter(Q=>!Q.disabled),he=Z.find(Q=>Q.ref.current===document.activeElement),ee=Vi(Z,M,he);ee&&setTimeout(()=>ee.ref.current.focus())}),oe=i.useCallback((M,Z,he)=>{const ee=!H.current&&!he;(y.value!==void 0&&y.value===Z||ee)&&(O(M),ee&&(H.current=!0))},[y.value]),pe=i.useCallback(()=>w==null?void 0:w.focus(),[w]),ce=i.useCallback((M,Z,he)=>{const ee=!H.current&&!he;(y.value!==void 0&&y.value===Z||ee)&&B(M)},[y.value]),xe=s==="popper"?hr:Ci,ve=xe===hr?{side:c,sideOffset:d,align:f,alignOffset:u,arrowPadding:m,collisionBoundary:h,collisionPadding:x,sticky:g,hideWhenDetached:p,avoidCollisions:v}:{};return r.jsx(ji,{scope:n,content:w,viewport:k,onViewportChange:C,itemRefCallback:oe,selectedItem:R,onItemLeave:pe,itemTextRefCallback:ce,focusSelectedItem:P,selectedItemText:F,position:s,isPositioned:L,searchRef:K,children:r.jsx(Pr,{as:Cp,allowPinchZoom:!0,children:r.jsx(Rr,{asChild:!0,trapped:y.open,onMountAutoFocus:M=>{M.preventDefault()},onUnmountAutoFocus:Y(o,M=>{var Z;(Z=y.trigger)==null||Z.focus({preventScroll:!0}),M.preventDefault()}),children:r.jsx(Tr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:M=>M.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:r.jsx(xe,{role:"listbox",id:y.contentId,"data-state":y.open?"open":"closed",dir:y.dir,onContextMenu:M=>M.preventDefault(),...b,...ve,onPlaced:()=>$(!0),ref:S,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:Y(b.onKeyDown,M=>{const Z=M.ctrlKey||M.altKey||M.metaKey;if(M.key==="Tab"&&M.preventDefault(),!Z&&M.key.length===1&&T(M.key),["ArrowUp","ArrowDown","Home","End"].includes(M.key)){let ee=V().filter(Q=>!Q.disabled).map(Q=>Q.ref.current);if(["ArrowUp","End"].includes(M.key)&&(ee=ee.slice().reverse()),["ArrowUp","ArrowDown"].includes(M.key)){const Q=M.target,q=ee.indexOf(Q);ee=ee.slice(q+1)}setTimeout(()=>_(ee)),M.preventDefault()}})})})})})})});Si.displayName=Sp;var kp="SelectItemAlignedPosition",Ci=i.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:s,...o}=e,a=ot(ht,n),l=at(ht,n),[c,d]=i.useState(null),[f,u]=i.useState(null),m=se(t,S=>u(S)),h=In(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(),O=a.valueNode.getBoundingClientRect(),F=b.getBoundingClientRect();if(a.dir!=="rtl"){const Q=F.left-R.left,q=O.left-Q,ue=S.left-q,E=S.width+ue,te=Math.max(E,R.width),de=window.innerWidth-Re,Ce=Os(q,[Re,Math.max(Re,de-te)]);c.style.minWidth=E+"px",c.style.left=Ce+"px"}else{const Q=R.right-F.right,q=window.innerWidth-O.right-Q,ue=window.innerWidth-S.right-q,E=S.width+ue,te=Math.max(E,R.width),de=window.innerWidth-Re,Ce=Os(q,[Re,Math.max(Re,de-te)]);c.style.minWidth=E+"px",c.style.right=Ce+"px"}const B=h(),V=window.innerHeight-Re*2,L=p.scrollHeight,$=window.getComputedStyle(f),H=parseInt($.borderTopWidth,10),_=parseInt($.paddingTop,10),P=parseInt($.borderBottomWidth,10),I=parseInt($.paddingBottom,10),z=H+_+L+I+P,K=Math.min(v.offsetHeight*5,z),T=window.getComputedStyle(p),oe=parseInt(T.paddingTop,10),pe=parseInt(T.paddingBottom,10),ce=S.top+S.height/2-Re,xe=V-ce,ve=v.offsetHeight/2,M=v.offsetTop+ve,Z=H+_+M,he=z-Z;if(Z<=ce){const Q=B.length>0&&v===B[B.length-1].ref.current;c.style.bottom="0px";const q=f.clientHeight-p.offsetTop-p.offsetHeight,ue=Math.max(xe,ve+(Q?pe:0)+q+P),E=Z+ue;c.style.height=E+"px"}else{const Q=B.length>0&&v===B[0].ref.current;c.style.top="0px";const ue=Math.max(ce,H+p.offsetTop+(Q?oe:0)+ve)+he;c.style.height=ue+"px",p.scrollTop=Z-ce+p.offsetTop}c.style.margin=`${Re}px 0`,c.style.minHeight=K+"px",c.style.maxHeight=V+"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(Ap,{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}})})})});Ci.displayName=kp;var Ep="SelectPopperPosition",hr=i.forwardRef((e,t)=>{const{__scopeSelect:n,align:s="start",collisionPadding:o=Re,...a}=e,l=On(n);return r.jsx(fp,{...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)"}})});hr.displayName=Ep;var[Ap,Zr]=Dt(ht,{}),xr="SelectViewport",ki=i.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:s,...o}=e,a=at(xr,n),l=Zr(xr,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(Mn.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:Y(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})})})]})});ki.displayName=xr;var Ei="SelectGroup",[Tp,Rp]=Dt(Ei),_p=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=Je();return r.jsx(Tp,{scope:n,id:o,children:r.jsx(X.div,{role:"group","aria-labelledby":o,...s,ref:t})})});_p.displayName=Ei;var Ai="SelectLabel",Ti=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=Rp(Ai,n);return r.jsx(X.div,{id:o.id,...s,ref:t})});Ti.displayName=Ai;var Nn="SelectItem",[Pp,Ri]=Dt(Nn),_i=i.forwardRef((e,t)=>{const{__scopeSelect:n,value:s,disabled:o=!1,textValue:a,...l}=e,c=ot(Nn,n),d=at(Nn,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=Je(),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(Pp,{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(Mn.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:Y(l.onFocus,()=>x(!0)),onBlur:Y(l.onBlur,()=>x(!1)),onClick:Y(l.onClick,()=>{v.current!=="mouse"&&b()}),onPointerUp:Y(l.onPointerUp,()=>{v.current==="mouse"&&b()}),onPointerDown:Y(l.onPointerDown,y=>{v.current=y.pointerType}),onPointerMove:Y(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:Y(l.onPointerLeave,y=>{var w;y.currentTarget===document.activeElement&&((w=d.onItemLeave)==null||w.call(d))}),onKeyDown:Y(l.onKeyDown,y=>{var j;((j=d.searchRef)==null?void 0:j.current)!==""&&y.key===" "||(gp.includes(y.key)&&b(),y.key===" "&&y.preventDefault())})})})})});_i.displayName=Nn;var It="SelectItemText",Pi=i.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:o,...a}=e,l=ot(It,n),c=at(It,n),d=Ri(It,n),f=wp(It,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?Sn.createPortal(a.children,l.valueNode):null]})});Pi.displayName=It;var Di="SelectItemIndicator",Mi=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return Ri(Di,n).isSelected?r.jsx(X.span,{"aria-hidden":!0,...s,ref:t}):null});Mi.displayName=Di;var gr="SelectScrollUpButton",Ii=i.forwardRef((e,t)=>{const n=at(gr,e.__scopeSelect),s=Zr(gr,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(Li,{...e,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop-d.offsetHeight)}}):null});Ii.displayName=gr;var vr="SelectScrollDownButton",Oi=i.forwardRef((e,t)=>{const n=at(vr,e.__scopeSelect),s=Zr(vr,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(Li,{...e,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop+d.offsetHeight)}}):null});Oi.displayName=vr;var Li=i.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:s,...o}=e,a=at("SelectScrollButton",n),l=i.useRef(null),c=In(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:Y(o.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(s,50))}),onPointerMove:Y(o.onPointerMove,()=>{var f;(f=a.onItemLeave)==null||f.call(a),l.current===null&&(l.current=window.setInterval(s,50))}),onPointerLeave:Y(o.onPointerLeave,()=>{d()})})}),Dp="SelectSeparator",$i=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return r.jsx(X.div,{"aria-hidden":!0,...s,ref:t})});$i.displayName=Dp;var br="SelectArrow",Mp=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=On(n),a=ot(br,n),l=at(br,n);return a.open&&l.position==="popper"?r.jsx(mp,{...o,...s,ref:t}):null});Mp.displayName=br;var Ip="SelectBubbleInput",Fi=i.forwardRef(({__scopeSelect:e,value:t,...n},s)=>{const o=i.useRef(null),a=se(s,o),l=mi(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:{...pi,...n.style},ref:a,defaultValue:t})});Fi.displayName=Ip;function Bi(e){return e===""||e===void 0}function Ui(e){const t=et(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 Vi(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=Op(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 Op(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Lp=hi,Wi=gi,$p=bi,Fp=yi,Bp=wi,zi=Ni,Up=ki,Hi=Ti,Ki=_i,Vp=Pi,Wp=Mi,qi=Ii,Gi=Oi,Yi=$i;const Ee=Lp,Ae=$p,ye=i.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(Wi,{ref:s,className:U("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,r.jsx(Fp,{asChild:!0,children:r.jsx(rt,{className:"h-4 w-4 opacity-50"})})]}));ye.displayName=Wi.displayName;const Xi=i.forwardRef(({className:e,...t},n)=>r.jsx(qi,{ref:n,className:U("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(so,{className:"h-4 w-4"})}));Xi.displayName=qi.displayName;const Ji=i.forwardRef(({className:e,...t},n)=>r.jsx(Gi,{ref:n,className:U("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(rt,{className:"h-4 w-4"})}));Ji.displayName=Gi.displayName;const we=i.forwardRef(({className:e,children:t,position:n="popper",...s},o)=>r.jsx(Bp,{children:r.jsxs(zi,{ref:o,className:U("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...s,children:[r.jsx(Xi,{}),r.jsx(Up,{className:U("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),r.jsx(Ji,{})]})}));we.displayName=zi.displayName;const zp=i.forwardRef(({className:e,...t},n)=>r.jsx(Hi,{ref:n,className:U("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));zp.displayName=Hi.displayName;const ie=i.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(Ki,{ref:s,className:U("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[r.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsx(Wp,{children:r.jsx(Sr,{className:"h-4 w-4"})})}),r.jsx(Vp,{children:t})]}));ie.displayName=Ki.displayName;const Hp=i.forwardRef(({className:e,...t},n)=>r.jsx(Yi,{ref:n,className:U("-mx-1 my-1 h-px bg-muted",e),...t}));Hp.displayName=Yi.displayName;const Zi=[{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"}],Kp=new Set(Zi.filter(e=>e.supportsFollowUp).map(e=>e.value));function qp(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 Gs(){return Zi.map(e=>r.jsx(ie,{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 Ys(e,t,n=!1){const s=e.trim();if(s)return s;const o=t.trim().split(`
|
|
200
|
-
`).map(a=>a.trim()).find(Boolean);return o?o.length>72?`${o.slice(0,69).trimEnd()}...`:o:n?"Image task":""}function Gp({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"),[O,F]=i.useState(!1),[B,V]=i.useState(!1),{images:L,error:$,fileInputRef:H,pickImages:_,handleFileChange:P,handlePaste:I,removeImage:z}=na(),K=i.useMemo(()=>qp(e,{currentNodeRole:t,leaderNodeId:n}),[e,t,n]);i.useEffect(()=>{S!=="auto"&&(K.some(E=>E.id===S)||R("auto"))},[S,K]);const T=i.useMemo(()=>{if(S!=="auto"){const te=e.find(de=>de.id===S);return(te==null?void 0:te.workDirFolders)??[]}const E=new Set;for(const te of K)for(const de of te.workDirFolders??[])E.add(de);return[...E].sort()},[S,e,K]),oe=i.useCallback(async E=>{E.preventDefault();const te=Ys(m,x,L.length>0),de=x.trim()||te;if(!(!te||!de||!p)){F(!0);try{const Ce=Er(x,L),ze=await Gl({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){le.error(Ce instanceof Error?Ce.message:"Failed to create task")}finally{F(!1)}}},[m,x,p,b,L,k,S,s]),pe=Ys(m,x,L.length>0),ce=!!(pe&&p&&(x.trim()||L.length>0)),xe=i.useCallback(E=>{var te;E.nativeEvent.isComposing||E.key==="Enter"&&E.shiftKey&&ce&&!O&&(E.preventDefault(),(te=E.currentTarget.form)==null||te.requestSubmit())},[ce,O]),ve=b||"__none__",M=T.length>0,Z=L.length>0&&r.jsx("div",{className:"flex flex-wrap gap-3",children:L.map((E,te)=>r.jsxs("div",{className:"relative",children:[r.jsx("img",{src:Ar(E),alt:E.filename??`attachment ${te+1}`,className:"h-24 w-24 rounded-2xl border border-border/70 object-cover"}),r.jsx("button",{type:"button",onClick:()=>z(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 ${E.filename??`image ${te+1}`}`,children:r.jsx(Cr,{className:"h-3.5 w-3.5"})})]},`${E.filename??"image"}-${te}`))}),he=r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ge,{className:"text-sm font-medium",children:"Assign to"}),r.jsxs(Ee,{value:S,onValueChange:R,children:[r.jsx(ye,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:r.jsx(Ae,{placeholder:"Auto-assign"})}),r.jsxs(we,{children:[r.jsx(ie,{value:"auto",children:"Auto-assign"}),K.map(E=>r.jsx(ie,{value:E.id,children:E.name},E.id))]})]})]}),ee=r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ge,{className:"text-sm font-medium",children:"Agent"}),r.jsxs(Ee,{value:p,onValueChange:v,children:[r.jsx(ye,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:r.jsx(Ae,{placeholder:"Select agent"})}),r.jsx(we,{children:Gs()})]})]}),Q=r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ge,{className:"text-sm font-medium",children:"Priority"}),r.jsxs(Ee,{value:k,onValueChange:C,children:[r.jsx(ye,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:r.jsx(Ae,{placeholder:"Select priority"})}),r.jsxs(we,{children:[r.jsx(ie,{value:"low",children:"Low"}),r.jsx(ie,{value:"normal",children:"Normal"}),r.jsx(ie,{value:"high",children:"High"}),r.jsx(ie,{value:"critical",children:"Critical"})]})]})]}),q=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(dt,{id:"task-title-composer",type:"text",value:m,onChange:E=>h(E.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."})]}),ue=r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ge,{className:"text-sm font-medium",children:"Working directory"}),w==="select"&&M?r.jsxs(Ee,{value:ve,onValueChange:E=>{if(E==="__custom__"){j("custom"),y("");return}y(E==="__none__"?"":E)},children:[r.jsx(ye,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:r.jsx(Ae,{placeholder:"Select folder or use the node default"})}),r.jsxs(we,{children:[r.jsx(ie,{value:"__none__",children:"Use node default"}),T.map(E=>r.jsx(ie,{value:E,children:E},E)),r.jsx(ie,{value:"__custom__",children:"Custom path..."})]})]}):r.jsxs("div",{className:"flex gap-2",children:[r.jsx(dt,{id:"task-project",type:"text",value:b,onChange:E=>y(E.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(G,{type:"button",variant:"outline",onClick:()=>{j("select"),y("")},className:"h-11 rounded-2xl",children:"Browse"})]})]});return u==="composer"?r.jsxs("form",{onSubmit:oe,className:U("space-y-4",a),children:[r.jsx("input",{ref:H,type:"file",accept:"image/*",multiple:!0,onChange:P,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:E=>g(E.target.value),onKeyDown:xe,onPaste:I,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(G,{type:"button",variant:"ghost",size:"sm",onClick:_,className:"h-9 gap-1.5 rounded-full px-3 text-xs text-muted-foreground hover:text-foreground",children:[r.jsx(or,{className:"h-3.5 w-3.5"}),"Images"]}),r.jsxs(Ee,{value:S,onValueChange:R,children:[r.jsx(ye,{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(Ae,{placeholder:"Auto-assign"})}),r.jsxs(we,{children:[r.jsx(ie,{value:"auto",children:"Auto-assign"}),K.map(E=>r.jsx(ie,{value:E.id,children:E.name},E.id))]})]}),r.jsxs(Ee,{value:p,onValueChange:v,children:[r.jsx(ye,{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(Ae,{placeholder:"Agent"})}),r.jsx(we,{children:Gs()})]}),r.jsxs(G,{type:"button",variant:"ghost",size:"sm",onClick:()=>V(!B),"aria-controls":"task-composer-settings","aria-expanded":B,className:"h-9 gap-1.5 rounded-full px-3 text-xs text-muted-foreground hover:text-foreground",children:[r.jsx(Kc,{className:"h-3.5 w-3.5"}),B?r.jsx(so,{className:"h-3 w-3"}):r.jsx(rt,{className:"h-3 w-3"})]})]}),r.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[o&&r.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:o,className:"h-9 rounded-full px-4 text-xs text-muted-foreground",children:d}),r.jsxs(G,{type:"submit",size:"icon",disabled:!ce||O,className:"h-10 w-10 rounded-full shadow-[0_8px_30px_-8px_hsl(var(--primary)/0.6)]",children:[O?r.jsx(Ie,{className:"h-4 w-4 animate-spin"}):r.jsx(fo,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:O?"Creating chat":c})]})]})]})]}),(Z||$)&&r.jsxs("div",{className:"space-y-3 rounded-[20px] border border-border/60 bg-background/45 p-4",children:[Z,$&&r.jsx("div",{className:"text-xs text-destructive",children:$}),!$&&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."})]}),B&&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:q}),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:ve,onValueChange:E=>{if(E==="__custom__"){j("custom"),y("");return}y(E==="__none__"?"":E)},children:[r.jsx(ye,{className:"h-10 rounded-2xl border-border/70 bg-background/60 px-3.5 text-sm shadow-none",children:r.jsx(Ae,{placeholder:"Use node default"})}),r.jsxs(we,{children:[r.jsx(ie,{value:"__none__",children:"Use node default"}),T.map(E=>r.jsx(ie,{value:E,children:E},E)),r.jsx(ie,{value:"__custom__",children:"Custom path..."})]})]}):r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(dt,{id:"task-project",type:"text",value:b,onChange:E=>y(E.target.value),placeholder:"Optional path",className:"h-10 rounded-2xl border-border/70 bg-background/60 px-3.5 shadow-none"}),M&&r.jsx(G,{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(ye,{className:"h-10 rounded-2xl border-border/70 bg-background/60 px-3.5 text-sm shadow-none",children:r.jsx(Ae,{placeholder:"Select priority"})}),r.jsxs(we,{children:[r.jsx(ie,{value:"low",children:"Low"}),r.jsx(ie,{value:"normal",children:"Normal"}),r.jsx(ie,{value:"high",children:"High"}),r.jsx(ie,{value:"critical",children:"Critical"})]})]})]})]})]}):r.jsxs("form",{onSubmit:oe,className:U("space-y-5",a),children:[r.jsx("input",{ref:H,type:"file",accept:"image/*",multiple:!0,onChange:P,className:"hidden"}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ge,{htmlFor:"task-description",className:"text-sm font-medium",children:"Opening prompt"}),r.jsx("textarea",{id:"task-description",value:x,onChange:E=>g(E.target.value),onKeyDown:xe,onPaste:I,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(G,{type:"button",variant:"outline",onClick:_,className:"rounded-2xl",children:[r.jsx(or,{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."})]}),Z,$&&r.jsx("p",{className:"text-xs text-destructive",children:$})]}),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(Ge,{htmlFor:"task-title",className:"text-sm font-medium",children:"Chat title"}),r.jsx(dt,{id:"task-title",type:"text",value:m,onChange:E=>h(E.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."})]}),ee]}),ue,r.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[Q,he]}),r.jsxs("div",{className:U("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",l),children:[o&&r.jsx(G,{type:"button",variant:"ghost",onClick:o,className:"rounded-2xl",children:d}),r.jsx(G,{type:"submit",disabled:!ce||O,className:"rounded-2xl px-5",children:O?"Creating...":c})]})]})}const Yp=[{value:"active",label:"Active"},{value:"running",label:"Running"},{value:"waiting",label:"Waiting"},{value:"closed",label:"Closed"},{value:"archived",label:"Archived"}],jn=new Set(["pending","assigned"]),Qi=new Set(["running"]),Xp=new Set(["completed","failed","cancelled"]),Jp=new Set(["completed","failed","cancelled"]);function Zp(e,t){switch(t){case"running":return Qi.has(e.status);case"waiting":return jn.has(e.status);case"closed":return Xp.has(e.status);case"archived":return e.status==="archived";case"active":default:return e.status!=="archived"}}function Qp(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 Qr(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 eh(e,t,n){return Qr(e,t,n).toLowerCase()}function th(e,t){return[...e].sort((n,s)=>n.id===t?-1:s.id===t?1:n.name.localeCompare(s.name))}function nh(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 rh(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 sh(e){return e==="default workspace"?e:e.replace(/\\/g,"/").split("/").filter(Boolean).at(-1)??e}function oh(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 ah(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 ih(e){return new Date(e).toLocaleString()}function lh(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 Ze(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),le.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 le.success(t),!0}catch(a){return le.error(a instanceof Error?a.message:"Failed to copy"),!1}}function Nt({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 rr({label:e}){return r.jsx("div",{className:"flex h-64 items-center justify-center text-sm text-muted-foreground",children:e})}function je({label:e,value:t,mono:n,action:s}){return r.jsxs("div",{className:"grid grid-cols-[5.25rem,minmax(0,1fr)] items-start gap-3",children:[r.jsx("span",{className:"pt-0.5 text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:e}),r.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[r.jsx("span",{className:U("min-w-0 flex-1 break-all text-sm text-foreground",n&&"font-mono text-[11px] leading-5"),children:t}),s]})]})}function yr({label:e,value:t,mono:n}){return r.jsxs("div",{className:"rounded-[18px] border border-border/60 bg-background/60 px-3 py-3",children:[r.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:e}),r.jsx("div",{className:U("mt-1 text-sm font-medium text-foreground",n&&"font-mono text-[11px]"),children:t})]})}function el({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(be,{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 ch=i.lazy(async()=>({default:(await Nr(()=>import("./FilesTab-DI35HxWK.js"),__vite__mapDeps([0,1,2,3]))).FilesTab})),dh=i.lazy(async()=>({default:(await Nr(()=>import("./PreviewTab-CAEInFgg.js"),__vite__mapDeps([4,1,2]))).PreviewTab})),uh=i.lazy(async()=>({default:(await Nr(()=>import("./DiffTab-DHa2twrY.js"),__vite__mapDeps([5,1,2,3]))).DiffTab}));function fh({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:O,onRetry:F,onCancel:B,onStartCreateTask:V,onCancelCreateTask:L,onCreateTask:$,onSendMessage:H,onQuestionBypassChange:_,onSubmitQuestionResponse:P,messagesEndRef:I}){const z=(u==null?void 0:u.effectiveProjectPath)??(u==null?void 0:u.project)??"default workspace",K=u?(m==null?void 0:m.name)??Qr(u.assignedTo,a==null?void 0:a.nodes,u.assignedNodeName):"unassigned",T=u?[{label:"Working dir",value:z,mono:!0},{label:"Agent",value:u.agent,mono:!0},{label:"Node",value:K}]:[],oe=u!=null&&u.description&&u.description!==u.title?u.description:null;return f?r.jsx(mh,{onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:l,onCancel:L,onCreated:$}):!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(pn,{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(ja,{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-4 sm:px-5",children:[r.jsx("div",{className:"flex items-center justify-between gap-3 border-b border-border/60 pb-4",children:r.jsx(pn,{onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:l})}),r.jsxs("div",{className:"flex flex-col gap-4 xl:flex-row xl:items-start xl:justify-between",children:[r.jsxs("div",{className:"min-w-0 space-y-3",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsx("h2",{className:"truncate text-lg font-semibold tracking-tight text-foreground sm:text-2xl",children:u.title}),r.jsx(to,{status:u.status}),r.jsx(Yl,{priority:u.priority})]}),oe&&r.jsx("p",{className:"max-w-3xl text-sm leading-6 text-muted-foreground",children:oe}),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 flex-col gap-3 xl:min-w-[14rem] xl:items-end",children:[r.jsxs("div",{className:"flex max-w-full flex-nowrap items-center gap-2 overflow-x-auto pt-2 pb-1 xl:justify-end",children:[O&&r.jsxs(G,{variant:"outline",size:"sm",onClick:F,className:"shrink-0 rounded-full",children:[r.jsx(Vc,{className:"h-3.5 w-3.5"}),"Retry"]}),R&&r.jsxs(un,{children:[r.jsx(fn,{asChild:!0,children:r.jsxs(G,{variant:"destructive",size:"sm",className:"shrink-0 rounded-full",children:[r.jsx(oo,{className:"h-3.5 w-3.5"}),"Cancel"]})}),r.jsxs(Lt,{children:[r.jsxs($t,{children:[r.jsx(Bt,{children:"Cancel this task?"}),r.jsx(Ut,{children:"The task will stop and move to a cancelled state."})]}),r.jsxs(Ft,{children:[r.jsx(Wt,{children:"No"}),r.jsx(Vt,{onClick:B,children:"Yes, cancel"})]})]})]})]}),r.jsxs("div",{className:"flex flex-col text-xs text-muted-foreground xl:items-end",children:[r.jsxs("span",{children:["updated ",ih(u.updatedAt)]}),r.jsx("span",{className:"font-mono",children:u.id.slice(0,8)})]})]})]}),r.jsx("div",{className:"mt-3 flex flex-col gap-3 xl:flex-row xl:items-center xl:justify-between",children:r.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[r.jsxs(Wr,{className:"h-auto max-w-full overflow-x-auto rounded-full bg-muted/70 p-1",children:[r.jsx(Ye,{value:"transcript",className:"rounded-full px-2.5 sm:px-4",children:"Transcript"}),r.jsx(Ye,{value:"files",className:"rounded-full px-2.5 sm:px-4",children:"Files"}),r.jsx(Ye,{value:"preview",className:"rounded-full px-2.5 sm:px-4",children:"Preview"}),r.jsx(Ye,{value:"diff",className:"rounded-full px-2.5 sm:px-4",children:"Diff"})]}),C&&r.jsx(be,{variant:"outline",className:"rounded-full border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300",children:"Agent is working"}),S&&r.jsx(be,{variant:"outline",className:"rounded-full border-primary/30 bg-primary/10 text-primary",children:"Message queued"}),!b&&r.jsx(be,{variant:"outline",className:"rounded-full border-border/70 bg-background/60",children:"Read-only transcript"}),y&&r.jsx(be,{variant:"outline",className:"rounded-full border-destructive/25 bg-destructive/10 text-destructive",children:"Node unavailable"})]})})]}),r.jsx(Xe,{value:"transcript",className:"mt-0 min-h-0 flex-1",children:r.jsxs("div",{className:"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",children:r.jsxs("div",{className:"mx-auto flex max-w-4xl flex-col gap-5",children:[v&&!p&&r.jsx(Ms,{event:v,questionBypassEnabled:k,onQuestionBypassChange:_,onSubmitQuestionResponse:P,questionResponseDisabled:!b||w}),g.map((pe,ce)=>r.jsx(Ms,{event:pe,questionBypassEnabled:k,onQuestionBypassChange:_,onSubmitQuestionResponse:P,questionResponseDisabled:!b||w},kd("transcript",pe,ce))),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:I})]})}),b?r.jsx("div",{className:"shrink-0",children:r.jsx("div",{className:"mx-auto w-full max-w-4xl",children:r.jsx(gf,{onSend:H,disabled:w,disabledReason:j,contextItems:T,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(Xe,{value:"files",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:r.jsx(i.Suspense,{fallback:r.jsx(rr,{label:"Loading files..."}),children:r.jsx(ch,{taskId:u.id})})}),r.jsx(Xe,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:r.jsx(i.Suspense,{fallback:r.jsx(rr,{label:"Loading preview..."}),children:r.jsx(dh,{taskId:u.id})})}),r.jsx(Xe,{value:"diff",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:r.jsx(i.Suspense,{fallback:r.jsx(rr,{label:"Loading diff..."}),children:r.jsx(uh,{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(pn,{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(jr,{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(G,{onClick:V,className:"mt-6 rounded-full px-5",children:[r.jsx(lo,{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 mh({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(pn,{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(jr,{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(Gp,{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 pn({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(ph,{desktopTasksOpen:t,mobileTasksPanelOpen:n,onToggleTasks:e}),r.jsx(be,{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(be,{variant:"outline",className:"hidden rounded-full border-border/70 bg-background/60 sm:inline-flex",children:["leader ",a.leader.name]})]}),r.jsxs(G,{variant:"outline",onClick:o,className:"shrink-0 rounded-full border-border/70 bg-background/60 px-3 sm:px-4",children:[s?r.jsx(uo,{className:"h-4 w-4"}):r.jsx(Bc,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline",children:s?"Hide cluster":"Show cluster"})]})]})}function ph({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(G,{variant:"outline",onClick:n,className:"rounded-full border-border/70 bg-background/60 px-3 sm:px-4",children:[s?r.jsx(co,{className:"h-4 w-4"}):r.jsx(Lc,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline",children:s?"Hide tasks":"Show tasks"})]})}const hh={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 xh(e){return e.split(".")[0]??"unknown"}function gh(e){return new Date(e).toLocaleTimeString("en-US",{hour12:!1})}function sr(e,t){return(t==null?void 0:t.get(e))??e}function vh(e,t){const n=e.data;switch(e.type){case"node.joined":return`${n.name} joined the cluster`;case"node.left":return`${sr(n.nodeId,t)} left (${n.reason})`;case"node.status":return`${sr(n.nodeId,t)} is now ${n.status}`;case"task.created":return`"${n.title}" created`;case"task.assigned":return`task assigned to ${sr(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 bh(e){return JSON.stringify(e,null,2)}function yh({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=xh(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:gh(a.timestamp)}),r.jsx(be,{variant:"outline",className:U("w-fit text-[10px] font-medium uppercase tracking-[0.16em]",hh[l]),children:a.type})]}),r.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-full text-muted-foreground",onClick:()=>void Ze(bh(a),"Event copied"),"aria-label":`Copy ${a.type} event`,title:"Copy event",children:r.jsx(ao,{className:"h-3.5 w-3.5"})})]}),r.jsx("div",{className:"text-sm leading-6 text-foreground/85",children:vh(a,o)})]})},a.id)})})})}function Xs({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 V,L,$,H,_;const k=((V=e==null?void 0:e.self)==null?void 0:V.role)==="leader",C=((L=e==null?void 0:e.self)==null?void 0:L.role)==="follower"&&!(e!=null&&e.leader),S=(e==null?void 0:e.self)??null,O=th((e==null?void 0:e.nodes)??[],S==null?void 0:S.id).filter(P=>P.id!==(S==null?void 0:S.id)),F=(S==null?void 0:S.role)==="leader"&&O.length===0,B=(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(ja,{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(G,{variant:"ghost",size:"icon",onClick:j,className:"rounded-full",children:r.jsx(uo,{className:"h-4 w-4"})})]}),r.jsxs(Wr,{className:"mt-4 grid h-auto w-full grid-cols-3 rounded-full bg-muted/70 p-1",children:[r.jsx(Ye,{value:"overview",className:"rounded-full px-3 text-xs",children:"Overview"}),r.jsx(Ye,{value:"nodes",className:"rounded-full px-3 text-xs",children:"Nodes"}),r.jsx(Ye,{value:"events",className:"rounded-full px-3 text-xs",children:"Live events"})]})]}),r.jsx(Xe,{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(Js,{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(be,{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(Nt,{label:"Term",value:String((e==null?void 0:e.term)??0)}),r.jsx(Nt,{label:"Nodes",value:String((e==null?void 0:e.nodes.length)??0)}),r.jsx(Nt,{label:"Pending",value:String((e==null?void 0:e.taskSummary.pending)??0)}),r.jsx(Nt,{label:"Running",value:String((e==null?void 0:e.taskSummary.running)??0)}),r.jsx(Nt,{label:"Completed",value:String((e==null?void 0:e.taskSummary.completed)??0)}),r.jsx(Nt,{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(je,{label:"Leader",value:(($=e==null?void 0:e.leader)==null?void 0:$.name)??"None"}),r.jsx(je,{label:"Leader URL",value:((H=e==null?void 0:e.leader)==null?void 0:H.endpoint)??"Unavailable",mono:!0,action:(_=e==null?void 0:e.leader)!=null&&_.endpoint?r.jsx(ut,{label:"Copy leader URL",onClick:()=>{var P;return void Ze(((P=e.leader)==null?void 0:P.endpoint)??"","Leader URL copied")}}):void 0}),r.jsx(je,{label:"Feed",value:d?"Receiving live updates":"Reconnecting to event stream"})]}),r.jsxs("div",{className:"flex flex-wrap gap-2",children:[k&&r.jsxs(G,{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(G,{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(Xe,{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"}),F?r.jsx(G,{variant:"outline",size:"sm",onClick:p,className:"rounded-full",children:"Join node"}):B?r.jsxs(G,{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(Js,{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 (",O.length,")"]}),O.length>0?r.jsx("div",{className:"space-y-3",children:O.map(P=>r.jsx(wh,{node:P,isLeader:!!k,blockingTaskCount:s.get(P.id)??0,devTunnelNodeId:w,onToggleNodeDevTunnel:y},P.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(Xe,{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(Xl,{className:U("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(ye,{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(Ae,{placeholder:"Event type"})}),r.jsx(we,{children:l.map(P=>r.jsx(ie,{value:P,className:"text-[12px]",children:P==="all"?"All event types":P},P))})]}),r.jsx(be,{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(yh,{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 Js({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=po(e,t==null?void 0:t.transportType),p=kr(e,t==null?void 0:t.transportType),v=p&&At((t==null?void 0:t.transportType)??e.transportType)?!0:mo(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(rt,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):r.jsx(Gt,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),r.jsx(no,{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(io,{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(ro,{role:e.role}),r.jsx(be,{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(je,{label:"Node ID",value:e.id,mono:!0}),f&&r.jsx(je,{label:"Dashboard",value:f,mono:!0,action:r.jsx(ut,{label:"Copy dashboard URL",onClick:()=>void Ze(f,"Dashboard URL copied")})}),r.jsx(je,{label:"Node URL",value:u,mono:!0,action:r.jsx(ut,{label:"Copy node URL",onClick:()=>void Ze(u,"Node URL copied")})}),h&&r.jsx(je,{label:"Preview",value:h,mono:!0,action:r.jsx(ut,{label:"Copy preview endpoint",onClick:()=>void Ze(h,"Preview endpoint copied")})}),x&&r.jsx(je,{label:"Workspace",value:x,mono:!0})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(yr,{label:"Transport",value:g}),t&&r.jsx(yr,{label:"Uptime",value:lh(t.uptime),mono:!0})]}),r.jsx(el,{capabilities:e.capabilities,action:a&&v?r.jsxs(G,{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 wh({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=po(e),h=kr(e),x=mo(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(rt,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):r.jsx(Gt,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),r.jsx(no,{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(io,{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(ro,{role:e.role}),r.jsx(be,{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(je,{label:"Node ID",value:e.id,mono:!0}),c&&r.jsx(je,{label:"Dashboard",value:c,mono:!0,action:r.jsx(ut,{label:"Copy dashboard URL",onClick:()=>void Ze(c,"Dashboard URL copied")})}),r.jsx(je,{label:"Node URL",value:d,mono:!0,action:r.jsx(ut,{label:"Copy node URL",onClick:()=>void Ze(d,"Node URL copied")})}),u&&r.jsx(je,{label:"Preview",value:u,mono:!0,action:r.jsx(ut,{label:"Copy preview endpoint",onClick:()=>void Ze(u,"Preview endpoint copied")})}),e.workDir&&r.jsx(je,{label:"Workspace",value:e.workDir,mono:!0}),r.jsx(yr,{label:"Transport",value:m})]}),r.jsx(el,{capabilities:e.capabilities,action:t&&x?r.jsxs(G,{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 ut({label:e,onClick:t}){return r.jsx(G,{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(ao,{className:"h-3.5 w-3.5"})})}function Nh(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..."}:jn.has(e.status)||e.status==="archived"?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:jn.has(e.status)?"Task has not started yet...":"Archived tasks are read-only."}:{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Continue the conversation..."}}var Ln="Checkbox",[jh]=st(Ln),[Sh,es]=jh(Ln);function Ch(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]=kt({prop:n,defaultProp:o??!1,onChange:d,caller:Ln}),[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:Qe(o)?!1:o,isFormControl:w,bubbleInput:v,setBubbleInput:b};return r.jsx(Sh,{scope:t,...j,children:kh(m)?m(j):s})}var tl="CheckboxTrigger",nl=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}=es(tl,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":Qe(d)?"mixed":d,"aria-required":f,"data-state":il(d),"data-disabled":c?"":void 0,disabled:c,value:l,...s,ref:p,onKeyDown:Y(t,b=>{b.key==="Enter"&&b.preventDefault()}),onClick:Y(n,b=>{m(y=>Qe(y)?!0:!y),g&&x&&(h.current=b.isPropagationStopped(),h.current||b.stopPropagation())})})});nl.displayName=tl;var ts=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(Ch,{__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(nl,{...m,ref:t,__scopeCheckbox:n}),h&&r.jsx(al,{__scopeCheckbox:n})]})})});ts.displayName=Ln;var rl="CheckboxIndicator",sl=i.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:s,...o}=e,a=es(rl,n);return r.jsx(Rt,{present:s||Qe(a.checked)||a.checked===!0,children:r.jsx(X.span,{"data-state":il(a.checked),"data-disabled":a.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});sl.displayName=rl;var ol="CheckboxBubbleInput",al=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}=es(ol,e),g=se(n,x),p=mi(a),v=ni(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=Qe(a),k.call(y,Qe(a)?!1:a),y.dispatchEvent(S)}},[h,p,a,o]);const b=i.useRef(Qe(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%)"}})});al.displayName=ol;function kh(e){return typeof e=="function"}function Qe(e){return e==="indeterminate"}function il(e){return Qe(e)?"indeterminate":e?"checked":"unchecked"}const wr=i.forwardRef(({className:e,...t},n)=>r.jsx(ts,{ref:n,className:U("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:r.jsx(sl,{className:U("flex items-center justify-center text-current"),children:r.jsx(Sr,{className:"h-3.5 w-3.5"})})}));wr.displayName=ts.displayName;function Zs({toolbarTasks:e,activeTaskId:t,activeTask:n,tasksLoading:s,tasksError:o,isLeader:a,scope:l,agentFilter:c,nodeFilter:d,agentOptions:f,nodeOptions:u,nodeNameById:m,searchQuery:h,selectedTaskIds:x,allVisibleTasksSelected:g,someVisibleTasksSelected:p,canBatchArchive:v,onSearchChange:b,onScopeChange:y,onAgentFilterChange:w,onNodeFilterChange:j,onToggleTaskSelected:k,onToggleAllVisibleTasks:C,canArchive:S,canDelete:R,onArchive:O,onDelete:F,onBatchArchive:B,onBatchDelete:V,onCreateTask:L,onSelectTask:$,onClose:H}){const[_,P]=i.useState(!!h),I=i.useRef(null),z=i.useRef(null),K=x.size;return i.useEffect(()=>{h&&P(!0)},[h]),i.useEffect(()=>{var T;_&&((T=I.current)==null||T.focus())},[_]),i.useEffect(()=>{if(!_)return;const T=pe=>{var xe;const ce=pe.target;ce instanceof Node&&((xe=z.current)!=null&&xe.contains(ce)||P(!1))},oe=pe=>{pe.key==="Escape"&&P(!1)};return document.addEventListener("mousedown",T),document.addEventListener("keydown",oe),()=>{document.removeEventListener("mousedown",T),document.removeEventListener("keydown",oe)}},[_]),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(G,{variant:"ghost",size:"icon",onClick:H,className:"rounded-full",children:r.jsx(co,{className:"h-4 w-4"})})]}),r.jsxs("div",{ref:z,className:"mt-4 flex items-center gap-2",children:[r.jsxs(G,{onClick:L,className:U("justify-start rounded-[22px] px-4 py-6 text-left shadow-[0_24px_60px_-32px_hsl(var(--primary)/0.95)] transition-[flex] duration-200",_?"flex-[2]":"flex-1"),children:[r.jsx(lo,{className:"h-4 w-4"}),"New chat"]}),_?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(vs,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),r.jsx(dt,{ref:I,value:h,onChange:T=>b(T.target.value),placeholder:"Search tasks",className:"h-11 rounded-full border-border/70 bg-background/60 pl-11 text-sm"})]}),r.jsx(G,{variant:"outline",size:"icon",onClick:()=>P(!1),className:"rounded-full border-border/70 bg-background/60",children:r.jsx(oo,{className:"h-4 w-4"})})]}):r.jsxs(G,{variant:"outline",onClick:()=>P(!0),className:U("rounded-full border-border/70 bg-background/60 px-4 text-sm",h&&"border-primary/40 bg-primary/8 text-primary"),children:[r.jsx(vs,{className:"h-4 w-4"}),"Search"]})]}),r.jsxs("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:grid-cols-3",children:[r.jsxs(Ee,{value:l,onValueChange:T=>y(T),children:[r.jsx(ye,{className:"h-9 rounded-full border-border/70 bg-background/55 text-[12px]",children:r.jsx(Ae,{})}),r.jsx(we,{children:Yp.map(T=>r.jsx(ie,{value:T.value,className:"text-[12px]",children:T.label},T.value))})]}),r.jsxs(Ee,{value:d,onValueChange:j,children:[r.jsx(ye,{className:"h-9 rounded-full border-border/70 bg-background/55 text-[12px]",children:r.jsx(Ae,{placeholder:"Node"})}),r.jsx(we,{children:u.map(T=>r.jsx(ie,{value:T.value,className:"text-[12px]",children:T.label},T.value))})]}),r.jsxs(Ee,{value:c,onValueChange:w,children:[r.jsx(ye,{className:"h-9 rounded-full border-border/70 bg-background/55 text-[12px]",children:r.jsx(Ae,{placeholder:"Agent"})}),r.jsx(we,{children:f.map(T=>r.jsx(ie,{value:T,className:"text-[12px]",children:T==="all"?"All agents":T},T))})]})]})]}),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:[a&&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(wr,{checked:p&&!g?"indeterminate":g,onCheckedChange:T=>C(T===!0),"aria-label":"Select all visible tasks"}),r.jsx("span",{children:"Select all"})]}),K>0&&r.jsx(G,{variant:"ghost",size:"sm",onClick:()=>C(!1),className:"h-7 rounded-full px-3 text-xs",children:"Clear"})]}),e.map(T=>r.jsxs("div",{className:U("flex items-start gap-3 rounded-[24px] border px-3 py-3 transition-all",T.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:[a&&r.jsx("div",{className:"flex shrink-0 pt-1",onClick:oe=>oe.stopPropagation(),children:r.jsx(wr,{checked:x.has(T.id),onCheckedChange:oe=>k(T.id,oe===!0),"aria-label":`Select ${T.title}`})}),r.jsx("button",{type:"button",onClick:()=>$(T.id),className:"min-w-0 flex-1 text-left",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("span",{className:U("mt-1 h-2.5 w-2.5 shrink-0 rounded-full",rh(T.status))}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:T.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:T.agent}),r.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),r.jsx("span",{children:T.assignedTo?m.get(T.assignedTo)??T.assignedTo.slice(0,8):"unassigned"}),r.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),r.jsx("span",{children:ah(T.updatedAt)})]}),r.jsxs("div",{className:"mt-3 flex items-center gap-2 text-[11px] text-muted-foreground",children:[r.jsx(to,{status:T.status}),T.assignedNodeAvailable===!1&&r.jsx(be,{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:sh(T.effectiveProjectPath??T.project??"default workspace")})]}),r.jsx("div",{className:"mt-1 truncate font-mono text-[10px] text-muted-foreground/85",children:oh(T.effectiveProjectPath??T.project??"default workspace")})]})]})})]},T.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:s?"Loading tasks...":o||"No tasks match this view."})}),a&&K>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:[K," task",K!==1?"s":""," selected"]}),!v&&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(un,{children:[r.jsx(fn,{asChild:!0,children:r.jsxs(G,{variant:"outline",size:"sm",disabled:!v,className:"rounded-full",children:[r.jsx(gs,{className:"h-3.5 w-3.5"}),"Archive"]})}),r.jsxs(Lt,{children:[r.jsxs($t,{children:[r.jsxs(Bt,{children:["Archive ",K," task",K!==1?"s":"","?"]}),r.jsx(Ut,{children:"Archived tasks stay hidden from the default task view and can be reopened from the archived scope."})]}),r.jsxs(Ft,{children:[r.jsx(Wt,{children:"Cancel"}),r.jsx(Vt,{onClick:B,disabled:!v,children:"Archive"})]})]})]}),r.jsxs(un,{children:[r.jsx(fn,{asChild:!0,children:r.jsxs(G,{variant:"destructive",size:"sm",className:"rounded-full",children:[r.jsx(Xc,{className:"h-3.5 w-3.5"}),"Delete"]})}),r.jsxs(Lt,{children:[r.jsxs($t,{children:[r.jsxs(Bt,{children:["Delete ",K," task",K!==1?"s":"","?"]}),r.jsx(Ut,{children:"This removes the selected tasks and their saved logs."})]}),r.jsxs(Ft,{children:[r.jsx(Wt,{children:"Cancel"}),r.jsx(Vt,{onClick:V,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}):n?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:"Selected task"}),r.jsx("div",{className:"mt-2 truncate text-sm font-semibold text-foreground",children:n.title}),r.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[S&&r.jsxs(G,{variant:"outline",size:"sm",onClick:O,className:"rounded-full",children:[r.jsx(gs,{className:"h-3.5 w-3.5"}),"Archive"]}),R&&r.jsxs(un,{children:[r.jsx(fn,{asChild:!0,children:r.jsx(G,{variant:"destructive",size:"sm",className:"rounded-full",children:"Delete"})}),r.jsxs(Lt,{children:[r.jsxs($t,{children:[r.jsx(Bt,{children:"Permanently delete this task?"}),r.jsx(Ut,{children:"This removes the task record and its saved logs."})]}),r.jsxs(Ft,{children:[r.jsx(Wt,{children:"No"}),r.jsx(Vt,{onClick:F,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}):null]})}function Eh(e,t){return t.data.nodeId===e.self.id||t.data.name===e.self.name||t.data.endpoint===e.self.endpoint}function Ah({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=Eh(e,s);s.type==="node.joined"&&!a&&le.success(`${o} joined the cluster`),s.type==="node.left"&&!a&&le.message(`${o} left the cluster`)})},[e,t])}function Th(){var fs,ms,ps;const{id:e}=Jl(),t=Zl(),n=Ql(),{cluster:s,systemInfo:o,events:a,sseConnected:l,subscribe:c,refresh:d,loading:f,error:u}=ec(),m=i.useMemo(()=>nh(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,O]=i.useState("all"),[F,B]=i.useState(""),V=i.useDeferredValue(F),[L,$]=i.useState(!0),[H,_]=i.useState(!1),[P,I]=i.useState(!1),[z,K]=i.useState(()=>!!(m!=null&&m.draftNewTask)),[T,oe]=i.useState(()=>m!=null&&m.draftNewTask?{route:m.returnRoute??"/",taskId:m.returnTaskId??null}:null),[pe,ce]=i.useState(!1),[xe,ve]=i.useState("transcript"),[M,Z]=i.useState("all"),[he,ee]=i.useState(!1),[Q,q]=i.useState(null),[ue,E]=i.useState([]),[te,de]=i.useState([]),[Ce,ze]=i.useState(!1),[xt,gt]=i.useState(null),[He,it]=i.useState(new Set),[ll,ns]=i.useState(!1),[cl,rs]=i.useState(!1),[dl,ss]=i.useState(!1),[ul,os]=i.useState(null),as=i.useRef(null),Mt=i.useRef(null),Fe=((fs=s==null?void 0:s.self)==null?void 0:fs.role)==="leader",$n=(ms=s==null?void 0:s.self)==null?void 0:ms.id;Ah({cluster:s,subscribe:c});const fe=i.useCallback(async()=>{try{const N=await tc({assignedTo:!Fe&&$n?$n:void 0,limit:100});x(N),b(null)}catch(N){b(N instanceof Error?N.message:"Failed to load tasks")}finally{p(!1)}},[Fe,$n]);nc(fe,1e4),i.useEffect(()=>{fe()},[fe]),i.useEffect(()=>c("task",fe),[c,fe]);const me=i.useMemo(()=>[...h].sort((N,A)=>A.updatedAt-N.updatedAt),[h]),fl=i.useMemo(()=>{const N=new Map;for(const A of(s==null?void 0:s.nodes)??[]){const D=rd(me,A.id);D>0&&N.set(A.id,D)}return N},[s==null?void 0:s.nodes,me]),Te=i.useMemo(()=>me.filter(N=>!Zp(N,j)||C!=="all"&&N.agent!==C||R==="unassigned"&&N.assignedTo||R!=="all"&&R!=="unassigned"&&eh(N.assignedTo,s==null?void 0:s.nodes,N.assignedNodeName)!==R?!1:V.trim()?Qp(N,V):!0),[me,j,C,R,V]);i.useEffect(()=>{it(N=>{const A=ld(N,Te.map(D=>D.id));return A.size===N.size?N:A})},[Te]),i.useEffect(()=>{Fe||it(new Set)},[Fe]);const ml=i.useMemo(()=>["all",...Array.from(new Set(me.map(N=>N.agent))).sort()],[me]),pl=i.useMemo(()=>{const A=Array.from(new Set(me.map(D=>D.assignedTo).filter(D=>!!D))).map(D=>{const ae=me.find(J=>J.assignedTo===D);return(s==null?void 0:s.nodes.find(J=>J.id===D))??{id:D,name:Qr(D,s==null?void 0:s.nodes,ae==null?void 0:ae.assignedNodeName)}}).sort((D,ae)=>D.name.localeCompare(ae.name));return[{value:"all",label:"All nodes"},{value:"unassigned",label:"Unassigned"},...A.map(D=>({value:D.name.toLowerCase(),label:D.name}))]},[me,s==null?void 0:s.nodes]),is=i.useMemo(()=>{const N=new Map;for(const A of(s==null?void 0:s.nodes)??[])N.set(A.id,A.name);for(const A of me)A.assignedTo&&A.assignedNodeName&&!N.has(A.assignedTo)&&N.set(A.assignedTo,A.assignedNodeName);return N},[s==null?void 0:s.nodes,me]),Fn=i.useMemo(()=>["all",...Array.from(new Set(a.map(N=>N.type))).sort()],[a]),hl=i.useMemo(()=>M==="all"?a:a.filter(N=>N.type===M),[a,M]),xl=Te.length>0&&Te.every(N=>He.has(N.id)),gl=Te.some(N=>He.has(N.id)),vl=cd(Te,He);i.useEffect(()=>{m!=null&&m.draftNewTask&&(K(!0),oe({route:m.returnRoute??"/",taskId:m.returnTaskId??null}))},[m]),i.useEffect(()=>{M!=="all"&&!Fn.includes(M)&&Z("all")},[M,Fn]),i.useEffect(()=>{bs(e,z)&&!y&&me[0]&&w(me[0].id)},[e,z,y,me]),i.useEffect(()=>{var N;bs(e,z)&&(y&&h.some(A=>A.id===y)||w(((N=me[0])==null?void 0:N.id)??null))},[e,z,y,me,h]);const ne=od({routeTaskId:e,creatingTask:z,internalSelectedTaskId:y,sortedTaskIds:me.map(N=>N.id)}),vt=i.useMemo(()=>h.find(N=>N.id===ne)??null,[h,ne]);i.useEffect(()=>{Mt.current=ne??null},[ne]);const Qt=i.useCallback(()=>{q(null),E([]),de([]),gt(null)},[]),ke=i.useCallback(async()=>{const N=ne;if(N)try{const A=await rc(N);if(Mt.current!==N)return;q(A),gt(null)}catch(A){if(Mt.current!==N)return;q(null),E([]),de([]),gt(A instanceof Error?A.message:"Failed to load task")}finally{Mt.current===N&&ze(!1)}},[ne]),en=i.useCallback(async()=>{const N=ne;if(N)try{const A=await sc(N);if(Mt.current!==N)return;E(D=>Ed(D,A.logs)),de(D=>Td(D,A.logs))}catch{}},[ne]);i.useEffect(()=>{if(!ne){q(null),E([]),de([]),gt(null),ze(!1);return}ve("transcript"),q(vt),E([]),de([]),gt(null),ze(!0),ke(),en()},[ne,en,ke]),i.useEffect(()=>{var A;if(!ne||z||g||h.some(D=>D.id===ne))return;const N=((A=me[0])==null?void 0:A.id)??null;w(N),Qt(),i.startTransition(()=>{n(N?`/tasks/${N}`:"/",{state:null})})},[ne,Qt,z,n,me,h,g]),i.useEffect(()=>{vt&&q(N=>!N||N.id!==vt.id?N:{...N,...vt})},[vt]),i.useEffect(()=>{if(ne)return c("task",N=>{const A=N.data.taskId;if(!(typeof A!="string"||A!==ne)){if(N.type==="task.output"){const D=N.data.event;if(D){E(J=>Ad(J,D));const ae=Yt(D);ae&&de(J=>Rd(J,ae))}}N.type==="task.status"&&(ke(),en())}})},[c,ne,ke,en]),i.useEffect(()=>{var N;xe==="transcript"&&((N=as.current)==null||N.scrollIntoView({behavior:"smooth"}))},[ue,te,xe]);const W=Q??vt,bl=W!=null&&W.assignedTo?(s==null?void 0:s.nodes.find(N=>N.id===W.assignedTo))??null:null,Bn=te.length>0,yl=W?Kp.has(W.agent):!1,Un=(W==null?void 0:W.status)==="running",wl=W?Fe&&(jn.has(W.status)||Qi.has(W.status)):!1,Nl=!!(W&&Fe&&W.status==="failed"),jl=W?Fe&&Jp.has(W.status):!1,Sl=!!(W&&Fe),Vn=i.useMemo(()=>Nh(W,s,Bn,!!Un),[W,s,Bn,Un]),Cl=i.useMemo(()=>_d(ue),[ue]),Wn=i.useMemo(()=>Pd([...ue,...te.map(N=>Hn(N.content,N.timestamp))]),[ue,te]),kl=i.useMemo(()=>{if(!W)return null;const N=pd(W);if(N.length>0)return Hn(N,new Date(W.createdAt).toISOString());if(Wn.length>0)return null;const A=Ot(W.description||W.title);return A.length>0?Hn(A,new Date(W.createdAt).toISOString()):null},[W,Wn]),zn=i.useCallback(()=>{const N={route:e?`/tasks/${e}`:"/",taskId:ne};oe(N),K(!0),i.startTransition(()=>{n("/",{state:{draftNewTask:!0,returnRoute:N.route,returnTaskId:N.taskId}})})},[e,ne,n]),El=i.useCallback(()=>{var A;const N=(T==null?void 0:T.taskId)??((A=me[0])==null?void 0:A.id)??null;K(!1),oe(null),w(N),i.startTransition(()=>{n((T==null?void 0:T.route)??"/",{state:null})})},[T,me,n]),ls=i.useCallback(N=>{K(!1),oe(null),w(N),i.startTransition(()=>{n(`/tasks/${N}`,{state:null})})},[n]),Al=i.useCallback(N=>{K(!1),oe(null),x(A=>ad(A,N)),q(N),E([]),de([]),gt(null),ze(!1),ve("transcript"),w(N.id),fe(),i.startTransition(()=>{n(`/tasks/${N.id}`,{state:null})})},[fe,n]),tn=i.useCallback(async N=>{if(!ne)return!1;const A=`local-${Date.now()}-${Math.random().toString(16).slice(2)}`;de(D=>[...D,{id:A,content:N,timestamp:new Date().toISOString()}]);try{return await oc(ne,N),ke(),!0}catch(D){return de(ae=>ae.filter(J=>J.id!==A)),le.error(D instanceof Error?D.message:"Failed to send message"),!1}},[ne,ke]),Tl=i.useCallback(N=>{tn(N)},[tn]),Rl=i.useCallback(N=>tn(Er(N,[])),[tn]),_l=i.useCallback(async()=>{if(W)try{await ac(W.id),ke(),fe()}catch(N){le.error(N instanceof Error?N.message:"Failed to cancel task")}},[W,ke,fe]),Pl=i.useCallback(async()=>{if(W)try{await ic(W.id),ke(),fe()}catch(N){le.error(N instanceof Error?N.message:"Failed to retry task")}},[W,ke,fe]),Ke=i.useCallback((N,A=!1)=>{const D=dd(Te,N);return w(D),(A||!D)&&Qt(),i.startTransition(()=>{n(D?`/tasks/${D}`:"/",{state:null})}),D},[Qt,Te,n]),Dl=i.useCallback(async()=>{if(W)try{await lc(W.id),Ke([W.id]),fe()}catch(N){le.error(N instanceof Error?N.message:"Failed to archive task")}},[W,fe,Ke]),Ml=i.useCallback(async()=>{if(W)try{await cc(W.id),Ke([W.id],!0),fe()}catch(N){le.error(N instanceof Error?N.message:"Failed to delete task")}},[W,fe,Ke]),Il=i.useCallback((N,A)=>{it(D=>{const ae=new Set(D);return A?ae.add(N):ae.delete(N),ae})},[]),Ol=i.useCallback(N=>{if(!N){it(new Set);return}it(new Set(Te.map(A=>A.id)))},[Te]),Ll=i.useCallback(async()=>{const N=Array.from(He);if(N.length!==0)try{const{results:A}=await dc(N),D=A.filter(J=>!J.ok),ae=A.filter(J=>J.ok).map(J=>J.id);ne&&ae.includes(ne)&&Ke(ae),D.length>0?le.error(`Failed to archive ${D.length} task(s): ${D.map(J=>J.error??J.id).join(", ")}`):le.success(`Archived ${ae.length} task(s)`),it(new Set(D.map(J=>J.id))),fe()}catch(A){le.error(A instanceof Error?A.message:"Failed to archive tasks")}},[ne,fe,Ke,He]),$l=i.useCallback(async()=>{const N=Array.from(He);if(N.length!==0)try{const{results:A}=await uc(N),D=A.filter(J=>!J.ok),ae=A.filter(J=>J.ok).map(J=>J.id);ne&&ae.includes(ne)&&Ke(ae,!0),D.length>0?le.error(`Failed to delete ${D.length} task(s): ${D.map(J=>J.error??J.id).join(", ")}`):le.success(`Deleted ${ae.length} task(s)`),it(new Set(D.map(J=>J.id))),fe()}catch(A){le.error(A instanceof Error?A.message:"Failed to delete tasks")}},[ne,fe,Ke,He]),Fl=i.useCallback(async()=>{ns(!0);try{await fc(),d()}catch(N){le.error(N instanceof Error?N.message:"Failed to trigger election")}finally{ns(!1)}},[d]),Bl=i.useCallback(async()=>{rs(!0);try{await mc(),d()}catch(N){le.error(N instanceof Error?N.message:"Failed to promote node")}finally{rs(!1)}},[d]),Ul=i.useCallback(async()=>{ss(!0);try{await pc(),le.success("This node left the remote cluster and is leading itself again."),fe(),ke(),d()}catch(N){le.error(N instanceof Error?N.message:"Failed to leave cluster")}finally{ss(!1)}},[ke,fe,d]),Vl=i.useCallback(async N=>{var hs;const A=!kr(N),D=N.id===((hs=s==null?void 0:s.self)==null?void 0:hs.id),ae=D?(o==null?void 0:o.transportType)??N.transportType:N.transportType,J=D&&!A&&At(ae);os(N.id);try{J?await hc("direct"):await xc(N.id,A),le.success(A?`Enabled remote access on ${N.name}`:`Disabled remote access on ${N.name}`),d()}catch(xs){le.error(xs instanceof Error?xs.message:"Failed to update remote access")}finally{os(null)}},[(ps=s==null?void 0:s.self)==null?void 0:ps.id,d,o==null?void 0:o.transportType]),cs=i.useCallback(()=>{var N,A;if((A=(N=globalThis.window)==null?void 0:N.matchMedia("(min-width: 1024px)"))!=null&&A.matches){$(D=>!D);return}_(D=>!D)},[]),ds={toolbarTasks:Te,activeTaskId:ne,activeTask:W,tasksLoading:g,tasksError:v,isLeader:Fe,scope:j,agentFilter:C,nodeFilter:R,agentOptions:ml,nodeOptions:pl,nodeNameById:is,searchQuery:F,selectedTaskIds:He,allVisibleTasksSelected:xl,someVisibleTasksSelected:gl,canBatchArchive:vl,onSearchChange:B,onScopeChange:k,onAgentFilterChange:S,onNodeFilterChange:O,onToggleTaskSelected:Il,onToggleAllVisibleTasks:Ol,canArchive:jl,canDelete:Sl,onArchive:Dl,onDelete:Ml,onBatchArchive:Ll,onBatchDelete:$l,onCreateTask:zn,onSelectTask:ls,onClose:cs},us={cluster:s,systemInfo:o,nodeNameById:is,nodeBlockingTaskCounts:fl,eventTypeFilter:M,onEventTypeFilterChange:Z,eventTypeOptions:Fn,filteredEvents:hl,sseConnected:l,clusterLoading:f,clusterError:u,electionPending:ll,onTriggerElection:Fl,promotePending:cl,onPromote:Bl,onAddNode:()=>ce(!0),leavePending:dl,onLeaveCluster:Ul,onToggleNodeDevTunnel:Vl,devTunnelNodeId:ul,onClose:()=>I(!1)};return r.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden pb-2",children:[r.jsxs("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[r.jsx("div",{className:U("hidden lg:block lg:shrink-0 lg:transition-all lg:duration-300",L?"lg:mr-4 lg:w-[22rem]":"lg:w-0 lg:overflow-hidden"),children:L&&r.jsx(Zs,{...ds})}),r.jsx("section",{className:"min-h-0 min-w-0 flex-1",children:r.jsx(fh,{onToggleTasks:cs,desktopTasksOpen:L,mobileTasksPanelOpen:H,operationsOpen:P,onToggleOperations:()=>I(N=>!N),cluster:s,sseConnected:l,activeTab:xe,setActiveTab:ve,creatingTask:z,activeTask:W,assignedNode:bl,taskLoading:Ce,taskError:xt,displayEvents:Wn,hasUserMessageInLogs:Cl,initialPrompt:kl,supportsFollowUp:yl,taskUnavailable:Vn.taskUnavailable,chatDisabled:Vn.chatDisabled,chatDisabledReason:Vn.chatDisabledReason,questionBypassEnabled:he,isRunning:!!Un,hasPendingFollowUp:Bn,canCancel:!!wl,canRetry:!!Nl,onRetry:Pl,onCancel:_l,onStartCreateTask:zn,onCancelCreateTask:El,onCreateTask:Al,onSendMessage:Tl,onQuestionBypassChange:ee,onSubmitQuestionResponse:Rl,messagesEndRef:as})}),r.jsx("div",{className:U("hidden xl:block xl:shrink-0 xl:transition-all xl:duration-300",P?"xl:ml-4 xl:w-[24rem]":"xl:w-0 xl:overflow-hidden"),children:P&&r.jsx(Xs,{...us})})]}),P&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Close operations panel",onClick:()=>I(!1),className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm xl:hidden"}),r.jsx("div",{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(Xs,{...us})})]}),H&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Close task list",onClick:()=>_(!1),className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm lg:hidden"}),r.jsx("div",{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(Zs,{...ds,onCreateTask:()=>{_(!1),zn()},onSelectTask:N=>{_(!1),ls(N)},onClose:()=>_(!1)})})]}),r.jsx(cf,{open:pe,onOpenChange:ce,children:r.jsx(xf,{onAdded:()=>{ce(!1),d()}})})]})}const _h=Object.freeze(Object.defineProperty({__proto__:null,DashboardPage:Th},Symbol.toStringTag,{value:"Module"}));export{Gt as C,_h as D,io as E,rt as a};
|
|
199
|
+
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},Gf=Ca,Yf=ka,Xf=Ea,La=Aa,$a=Ta,Fa=Ma,Ba=Oa,Ua=_a,Va=Da;const un=Gf,fn=Yf,Jf=Xf,Wa=i.forwardRef(({className:e,...t},n)=>r.jsx(La,{className:U("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));Wa.displayName=La.displayName;const Lt=i.forwardRef(({className:e,...t},n)=>r.jsxs(Jf,{children:[r.jsx(Wa,{}),r.jsx($a,{ref:n,className:U("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]}));Lt.displayName=$a.displayName;const $t=({className:e,...t})=>r.jsx("div",{className:U("flex flex-col space-y-2 text-center sm:text-left",e),...t});$t.displayName="AlertDialogHeader";const Ft=({className:e,...t})=>r.jsx("div",{className:U("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Ft.displayName="AlertDialogFooter";const Bt=i.forwardRef(({className:e,...t},n)=>r.jsx(Ua,{ref:n,className:U("text-lg font-semibold",e),...t}));Bt.displayName=Ua.displayName;const Ut=i.forwardRef(({className:e,...t},n)=>r.jsx(Va,{ref:n,className:U("text-sm text-muted-foreground",e),...t}));Ut.displayName=Va.displayName;const Vt=i.forwardRef(({className:e,...t},n)=>r.jsx(Fa,{ref:n,className:U(to(),e),...t}));Vt.displayName=Fa.displayName;const Wt=i.forwardRef(({className:e,...t},n)=>r.jsx(Ba,{ref:n,className:U(to({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));Wt.displayName=Ba.displayName;function Ls(e,[t,n]){return Math.min(n,Math.max(t,e))}const Zf=["top","right","bottom","left"],nt=Math.min,we=Math.max,vn=Math.round,ln=Math.floor,Le=e=>({x:e,y:e}),Qf={left:"right",right:"left",bottom:"top",top:"bottom"};function mr(e,t,n){return we(e,nt(t,n))}function Be(e,t){return typeof e=="function"?e(t):e}function Ue(e){return e.split("-")[0]}function _t(e){return e.split("-")[1]}function Hr(e){return e==="x"?"y":"x"}function Kr(e){return e==="y"?"height":"width"}function Oe(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function qr(e){return Hr(Oe(e))}function em(e,t,n){n===void 0&&(n=!1);const s=_t(e),o=qr(e),a=Kr(o);let l=o==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(l=bn(l)),[l,bn(l)]}function tm(e){const t=bn(e);return[pr(e),t,pr(t)]}function pr(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const $s=["left","right"],Fs=["right","left"],nm=["top","bottom"],rm=["bottom","top"];function sm(e,t,n){switch(e){case"top":case"bottom":return n?t?Fs:$s:t?$s:Fs;case"left":case"right":return t?nm:rm;default:return[]}}function om(e,t,n,s){const o=_t(e);let a=sm(Ue(e),n==="start",s);return o&&(a=a.map(l=>l+"-"+o),t&&(a=a.concat(a.map(pr)))),a}function bn(e){const t=Ue(e);return Qf[t]+e.slice(t.length)}function am(e){return{top:0,right:0,bottom:0,left:0,...e}}function za(e){return typeof e!="number"?am(e):{top:e,right:e,bottom:e,left:e}}function yn(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 Bs(e,t,n){let{reference:s,floating:o}=e;const a=Oe(t),l=qr(t),c=Kr(l),d=Ue(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(_t(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 im(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}=Be(t,e),g=za(x),v=c[h?m==="floating"?"reference":"floating":m],b=yn(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=yn(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 lm=50,cm=async(e,t,n)=>{const{placement:s="bottom",strategy:o="absolute",middleware:a=[],platform:l}=n,c=l.detectOverflow?l:{...l,detectOverflow:im},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}=Bs(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<lm&&(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}=Bs(f,h,d)),p=-1)}return{x:u,y:m,placement:h,strategy:o,middlewareData:g}},dm=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}=Be(e,t)||{};if(f==null)return{};const m=za(u),h={x:n,y:s},x=qr(o),g=Kr(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,O=S/2-p[g]/2-1,F=nt(m[b],O),B=nt(m[y],O),V=F,L=S-p[g]-B,$=S/2-p[g]/2+R,H=mr(V,$,L),_=!d.arrow&&_t(o)!=null&&$!==H&&a.reference[g]/2-($<V?F:B)-p[g]/2<0,P=_?$<V?$-V:$-L:0;return{[x]:h[x]+P,data:{[x]:H,centerOffset:$-H-P,..._&&{alignmentOffset:P}},reset:_}}}),um=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}=Be(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const b=Ue(o),y=Oe(c),w=Ue(c)===c,j=await(d.isRTL==null?void 0:d.isRTL(f.floating)),k=h||(w||!p?[bn(c)]:tm(c)),C=g!=="none";!h&&C&&k.push(...om(c,p,g,j));const S=[c,...k],R=await d.detectOverflow(t,v),O=[];let F=((s=a.flip)==null?void 0:s.overflows)||[];if(u&&O.push(R[b]),m){const $=em(o,l,j);O.push(R[$[0]],R[$[1]])}if(F=[...F,{placement:o,overflows:O}],!O.every($=>$<=0)){var B,V;const $=(((B=a.flip)==null?void 0:B.index)||0)+1,H=S[$];if(H&&(!(m==="alignment"?y!==Oe(H):!1)||F.every(I=>Oe(I.placement)===y?I.overflows[0]>0:!0)))return{data:{index:$,overflows:F},reset:{placement:H}};let _=(V=F.filter(P=>P.overflows[0]<=0).sort((P,I)=>P.overflows[1]-I.overflows[1])[0])==null?void 0:V.placement;if(!_)switch(x){case"bestFit":{var L;const P=(L=F.filter(I=>{if(C){const W=Oe(I.placement);return W===y||W==="y"}return!0}).map(I=>[I.placement,I.overflows.filter(W=>W>0).reduce((W,K)=>W+K,0)]).sort((I,W)=>I[1]-W[1])[0])==null?void 0:L[0];P&&(_=P);break}case"initialPlacement":_=c;break}if(o!==_)return{reset:{placement:_}}}return{}}}};function Us(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Vs(e){return Zf.some(t=>e[t]>=0)}const fm=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:s}=t,{strategy:o="referenceHidden",...a}=Be(e,t);switch(o){case"referenceHidden":{const l=await s.detectOverflow(t,{...a,elementContext:"reference"}),c=Us(l,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:Vs(c)}}}case"escaped":{const l=await s.detectOverflow(t,{...a,altBoundary:!0}),c=Us(l,n.floating);return{data:{escapedOffsets:c,escaped:Vs(c)}}}default:return{}}}}},Ha=new Set(["left","top"]);async function mm(e,t){const{placement:n,platform:s,elements:o}=e,a=await(s.isRTL==null?void 0:s.isRTL(o.floating)),l=Ue(n),c=_t(n),d=Oe(n)==="y",f=Ha.has(l)?-1:1,u=a&&d?-1:1,m=Be(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 pm=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 mm(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}}}}},hm=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}=Be(e,t),u={x:n,y:s},m=await a.detectOverflow(t,f),h=Oe(Ue(o)),x=Hr(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=mr(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=mr(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}}}}}},xm=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}=Be(e,t),u={x:n,y:s},m=Oe(o),h=Hr(m);let x=u[h],g=u[m];const p=Be(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=Ha.has(Ue(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}}}},gm=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}=Be(e,t),u=await l.detectOverflow(t,f),m=Ue(o),h=_t(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=nt(p-u[v],y),k=nt(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 F=we(u.left,0),B=we(u.right,0),V=we(u.top,0),L=we(u.bottom,0);x?R=g-2*(F!==0||B!==0?F+B:we(u.left,u.right)):S=p-2*(V!==0||L!==0?V+L:we(u.top,u.bottom))}await d({...t,availableWidth:R,availableHeight:S});const O=await l.getDimensions(c.floating);return g!==O.width||p!==O.height?{reset:{rects:!0}}:{}}}};function _n(){return typeof window<"u"}function Pt(e){return Ka(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=(Ka(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Ka(e){return _n()?e instanceof Node||e instanceof Se(e).Node:!1}function _e(e){return _n()?e instanceof Element||e instanceof Se(e).Element:!1}function ze(e){return _n()?e instanceof HTMLElement||e instanceof Se(e).HTMLElement:!1}function Ws(e){return!_n()||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 vm(e){return/^(table|td|th)$/.test(Pt(e))}function Pn(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const bm=/transform|translate|scale|rotate|perspective|filter/,ym=/paint|layout|strict|content/,ct=e=>!!e&&e!=="none";let tr;function Gr(e){const t=_e(e)?Pe(e):e;return ct(t.transform)||ct(t.translate)||ct(t.scale)||ct(t.rotate)||ct(t.perspective)||!Yr()&&(ct(t.backdropFilter)||ct(t.filter))||bm.test(t.willChange||"")||ym.test(t.contain||"")}function wm(e){let t=rt(e);for(;ze(t)&&!Et(t);){if(Gr(t))return t;if(Pn(t))return null;t=rt(t)}return null}function Yr(){return tr==null&&(tr=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),tr}function Et(e){return/^(html|body|#document)$/.test(Pt(e))}function Pe(e){return Se(e).getComputedStyle(e)}function Dn(e){return _e(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function rt(e){if(Pt(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Ws(e)&&e.host||$e(e);return Ws(t)?t.host:t}function qa(e){const t=rt(e);return Et(t)?e.ownerDocument?e.ownerDocument.body:e.body:ze(t)&&Zt(t)?t:qa(t)}function qt(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=qa(e),a=o===((s=e.ownerDocument)==null?void 0:s.body),l=Se(o);if(a){const c=hr(l);return t.concat(l,l.visualViewport||[],Zt(o)?o:[],c&&n?qt(c):[])}else return t.concat(o,qt(o,[],n))}function hr(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Ga(e){const t=Pe(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const o=ze(e),a=o?e.offsetWidth:n,l=o?e.offsetHeight:s,c=vn(n)!==a||vn(s)!==l;return c&&(n=a,s=l),{width:n,height:s,$:c}}function Xr(e){return _e(e)?e:e.contextElement}function Ct(e){const t=Xr(e);if(!ze(t))return Le(1);const n=t.getBoundingClientRect(),{width:s,height:o,$:a}=Ga(t);let l=(a?vn(n.width):n.width)/s,c=(a?vn(n.height):n.height)/o;return(!l||!Number.isFinite(l))&&(l=1),(!c||!Number.isFinite(c))&&(c=1),{x:l,y:c}}const Nm=Le(0);function Ya(e){const t=Se(e);return!Yr()||!t.visualViewport?Nm:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function jm(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Se(e)?!1:t}function mt(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),a=Xr(e);let l=Le(1);t&&(s?_e(s)&&(l=Ct(s)):l=Ct(e));const c=jm(a,n,s)?Ya(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=hr(g);for(;p&&s&&x!==g;){const v=Ct(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=hr(g)}}return yn({width:u,height:m,x:d,y:f})}function Mn(e,t){const n=Dn(e).scrollLeft;return t?t.left+n:mt($e(e)).left+n}function Xa(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-Mn(e,n),o=n.top+t.scrollTop;return{x:s,y:o}}function Sm(e){let{elements:t,rect:n,offsetParent:s,strategy:o}=e;const a=o==="fixed",l=$e(s),c=t?Pn(t.floating):!1;if(s===l||c&&a)return n;let d={scrollLeft:0,scrollTop:0},f=Le(1);const u=Le(0),m=ze(s);if((m||!m&&!a)&&((Pt(s)!=="body"||Zt(l))&&(d=Dn(s)),m)){const x=mt(s);f=Ct(s),u.x=x.x+s.clientLeft,u.y=x.y+s.clientTop}const h=l&&!m&&!a?Xa(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 Cm(e){return Array.from(e.getClientRects())}function km(e){const t=$e(e),n=Dn(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+Mn(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 zs=25;function Em(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=Yr();(!u||u&&t==="fixed")&&(c=o.offsetLeft,d=o.offsetTop)}const f=Mn(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<=zs&&(a-=g)}else f<=zs&&(a+=f);return{width:a,height:l,x:c,y:d}}function Am(e,t){const n=mt(e,!0,t==="fixed"),s=n.top+e.clientTop,o=n.left+e.clientLeft,a=ze(e)?Ct(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 Hs(e,t,n){let s;if(t==="viewport")s=Em(e,n);else if(t==="document")s=km($e(e));else if(_e(t))s=Am(t,n);else{const o=Ya(e);s={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return yn(s)}function Ja(e,t){const n=rt(e);return n===t||!_e(n)||Et(n)?!1:Pe(n).position==="fixed"||Ja(n,t)}function Tm(e,t){const n=t.get(e);if(n)return n;let s=qt(e,[],!1).filter(c=>_e(c)&&Pt(c)!=="body"),o=null;const a=Pe(e).position==="fixed";let l=a?rt(e):e;for(;_e(l)&&!Et(l);){const c=Pe(l),d=Gr(l);!d&&c.position==="fixed"&&(o=null),(a?!d&&!o:!d&&c.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Zt(l)&&!d&&Ja(e,l))?s=s.filter(u=>u!==l):o=c,l=rt(l)}return t.set(e,s),s}function Rm(e){let{element:t,boundary:n,rootBoundary:s,strategy:o}=e;const l=[...n==="clippingAncestors"?Pn(t)?[]:Tm(t,this._c):[].concat(n),s],c=Hs(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=Hs(t,l[h],o);d=we(x.top,d),f=nt(x.right,f),u=nt(x.bottom,u),m=we(x.left,m)}return{width:f-m,height:u-d,x:m,y:d}}function _m(e){const{width:t,height:n}=Ga(e);return{width:t,height:n}}function Pm(e,t,n){const s=ze(t),o=$e(t),a=n==="fixed",l=mt(e,!0,a,t);let c={scrollLeft:0,scrollTop:0};const d=Le(0);function f(){d.x=Mn(o)}if(s||!s&&!a)if((Pt(t)!=="body"||Zt(o))&&(c=Dn(t)),s){const x=mt(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?Xa(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 Ks(e,t){if(!ze(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 Za(e,t){const n=Se(e);if(Pn(e))return n;if(!ze(e)){let o=rt(e);for(;o&&!Et(o);){if(_e(o)&&!nr(o))return o;o=rt(o)}return n}let s=Ks(e,t);for(;s&&vm(s)&&nr(s);)s=Ks(s,t);return s&&Et(s)&&nr(s)&&!Gr(s)?n:s||wm(e)||n}const Dm=async function(e){const t=this.getOffsetParent||Za,n=this.getDimensions,s=await n(e.floating);return{reference:Pm(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function Mm(e){return Pe(e).direction==="rtl"}const Im={convertOffsetParentRelativeRectToViewportRelativeRect:Sm,getDocumentElement:$e,getClippingRect:Rm,getOffsetParent:Za,getElementRects:Dm,getClientRects:Cm,getDimensions:_m,getScale:Ct,isElement:_e,isRTL:Mm};function Qa(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Om(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=ln(m),p=ln(o.clientWidth-(u+h)),v=ln(o.clientHeight-(m+x)),b=ln(u),w={rootMargin:-g+"px "+-p+"px "+-v+"px "+-b+"px",threshold:we(0,nt(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&&!Qa(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 Lm(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=Xr(e),u=o||a?[...f?qt(f):[],...t?qt(t):[]]:[];u.forEach(b=>{o&&b.addEventListener("scroll",n,{passive:!0}),a&&b.addEventListener("resize",n)});const m=f&&c?Om(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?mt(e):null;d&&v();function v(){const b=mt(e);p&&!Qa(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 $m=pm,Fm=hm,Bm=um,Um=gm,Vm=fm,qs=dm,Wm=xm,zm=(e,t,n)=>{const s=new Map,o={platform:Im,...n},a={...o.platform,_c:s};return cm(e,t,{...o,platform:a})};var Hm=typeof document<"u",Km=function(){},mn=Hm?i.useLayoutEffect:Km;function wn(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(!wn(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)&&!wn(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function ei(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Gs(e,t){const n=ei(e);return Math.round(t*n)/n}function rr(e){const t=i.useRef(e);return mn(()=>{t.current=e}),t}function qm(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);wn(h,s)||x(s);const[g,p]=i.useState(null),[v,b]=i.useState(null),y=i.useCallback(I=>{I!==C.current&&(C.current=I,p(I))},[]),w=i.useCallback(I=>{I!==S.current&&(S.current=I,b(I))},[]),j=a||g,k=l||v,C=i.useRef(null),S=i.useRef(null),R=i.useRef(u),O=d!=null,F=rr(d),B=rr(o),V=rr(f),L=i.useCallback(()=>{if(!C.current||!S.current)return;const I={placement:t,strategy:n,middleware:h};B.current&&(I.platform=B.current),zm(C.current,S.current,I).then(W=>{const K={...W,isPositioned:V.current!==!1};$.current&&!wn(R.current,K)&&(R.current=K,Sn.flushSync(()=>{m(K)}))})},[h,t,n,B,V]);mn(()=>{f===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,m(I=>({...I,isPositioned:!1})))},[f]);const $=i.useRef(!1);mn(()=>($.current=!0,()=>{$.current=!1}),[]),mn(()=>{if(j&&(C.current=j),k&&(S.current=k),j&&k){if(F.current)return F.current(j,k,L);L()}},[j,k,L,F,O]);const H=i.useMemo(()=>({reference:C,floating:S,setReference:y,setFloating:w}),[y,w]),_=i.useMemo(()=>({reference:j,floating:k}),[j,k]),P=i.useMemo(()=>{const I={position:n,left:0,top:0};if(!_.floating)return I;const W=Gs(_.floating,u.x),K=Gs(_.floating,u.y);return c?{...I,transform:"translate("+W+"px, "+K+"px)",...ei(_.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:W,top:K}},[n,c,_.floating,u.x,u.y]);return i.useMemo(()=>({...u,update:L,refs:H,elements:_,floatingStyles:P}),[u,L,H,_,P])}const Gm=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?qs({element:s.current,padding:o}).fn(n):{}:s?qs({element:s,padding:o}).fn(n):{}}}},Ym=(e,t)=>{const n=$m(e);return{name:n.name,fn:n.fn,options:[e,t]}},Xm=(e,t)=>{const n=Fm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Jm=(e,t)=>({fn:Wm(e).fn,options:[e,t]}),Zm=(e,t)=>{const n=Bm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Qm=(e,t)=>{const n=Um(e);return{name:n.name,fn:n.fn,options:[e,t]}},ep=(e,t)=>{const n=Vm(e);return{name:n.name,fn:n.fn,options:[e,t]}},tp=(e,t)=>{const n=Gm(e);return{name:n.name,fn:n.fn,options:[e,t]}};var np="Arrow",ti=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"})})});ti.displayName=np;var rp=ti;function ni(e){const[t,n]=i.useState(void 0);return ve(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const s=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const a=o[0];let 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 Jr="Popper",[ri,si]=st(Jr),[sp,oi]=ri(Jr),ai=e=>{const{__scopePopper:t,children:n}=e,[s,o]=i.useState(null);return r.jsx(sp,{scope:t,anchor:s,onAnchorChange:o,children:n})};ai.displayName=Jr;var ii="PopperAnchor",li=i.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:s,...o}=e,a=oi(ii,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})});li.displayName=ii;var Zr="PopperContent",[op,ap]=ri(Zr),ci=i.forwardRef((e,t)=>{var M,Z,he,ee,Q,q;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=oi(Zr,n),[b,y]=i.useState(null),w=se(t,fe=>y(fe)),[j,k]=i.useState(null),C=ni(j),S=(C==null?void 0:C.width)??0,R=(C==null?void 0:C.height)??0,O=s+(a!=="center"?"-"+a:""),F=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},B=Array.isArray(f)?f:[f],V=B.length>0,L={padding:F,boundary:B.filter(lp),altBoundary:V},{refs:$,floatingStyles:H,placement:_,isPositioned:P,middlewareData:I}=qm({strategy:"fixed",placement:O,whileElementsMounted:(...fe)=>Lm(...fe,{animationFrame:x==="always"}),elements:{reference:v.anchor},middleware:[Ym({mainAxis:o+R,alignmentAxis:l}),d&&Xm({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?Jm():void 0,...L}),d&&Zm({...L}),Qm({...L,apply:({elements:fe,rects:E,availableWidth:te,availableHeight:de})=>{const{width:Ce,height:He}=E.reference,xt=fe.floating.style;xt.setProperty("--radix-popper-available-width",`${te}px`),xt.setProperty("--radix-popper-available-height",`${de}px`),xt.setProperty("--radix-popper-anchor-width",`${Ce}px`),xt.setProperty("--radix-popper-anchor-height",`${He}px`)}}),j&&tp({element:j,padding:c}),cp({arrowWidth:S,arrowHeight:R}),h&&ep({strategy:"referenceHidden",...L})]}),[W,K]=fi(_),T=tt(g);ve(()=>{P&&(T==null||T())},[P,T]);const ie=(M=I.arrow)==null?void 0:M.x,xe=(Z=I.arrow)==null?void 0:Z.y,le=((he=I.arrow)==null?void 0:he.centerOffset)!==0,[ue,ge]=i.useState();return ve(()=>{b&&ge(window.getComputedStyle(b).zIndex)},[b]),r.jsx("div",{ref:$.setFloating,"data-radix-popper-content-wrapper":"",style:{...H,transform:P?H.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ue,"--radix-popper-transform-origin":[(ee=I.transformOrigin)==null?void 0:ee.x,(Q=I.transformOrigin)==null?void 0:Q.y].join(" "),...((q=I.hide)==null?void 0:q.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:r.jsx(op,{scope:n,placedSide:W,onArrowChange:k,arrowX:ie,arrowY:xe,shouldHideArrow:le,children:r.jsx(X.div,{"data-side":W,"data-align":K,...p,ref:w,style:{...p.style,animation:P?void 0:"none"}})})})});ci.displayName=Zr;var di="PopperArrow",ip={top:"bottom",right:"left",bottom:"top",left:"right"},ui=i.forwardRef(function(t,n){const{__scopePopper:s,...o}=t,a=ap(di,s),l=ip[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(rp,{...o,ref:n,style:{...o.style,display:"block"}})})});ui.displayName=di;function lp(e){return e!==null}var cp=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]=fi(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 fi(e){const[t,n="center"]=e.split("-");return[t,n]}var dp=ai,up=li,fp=ci,mp=ui;function mi(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 pi=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"}),pp="VisuallyHidden",hp=i.forwardRef((e,t)=>r.jsx(X.span,{...e,ref:t,style:{...pi,...e.style}}));hp.displayName=pp;var xp=[" ","Enter","ArrowUp","ArrowDown"],gp=[" ","Enter"],pt="Select",[In,On,vp]=ra(pt),[Dt]=st(pt,[vp,si]),Ln=si(),[bp,ot]=Dt(pt),[yp,wp]=Dt(pt),hi=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=Ln(t),[v,b]=i.useState(null),[y,w]=i.useState(null),[j,k]=i.useState(!1),C=Vr(f),[S,R]=kt({prop:s,defaultProp:o??!1,onChange:a,caller:pt}),[O,F]=kt({prop:l,defaultProp:c,onChange:d,caller:pt}),B=i.useRef(null),V=v?g||!!v.closest("form"):!0,[L,$]=i.useState(new Set),H=Array.from(L).map(_=>_.props.value).join(";");return r.jsx(dp,{...p,children:r.jsxs(bp,{required:x,scope:t,trigger:v,onTriggerChange:b,valueNode:y,onValueNodeChange:w,valueNodeHasChildren:j,onValueNodeHasChildrenChange:k,contentId:Ze(),value:O,onValueChange:F,open:S,onOpenChange:R,dir:C,triggerPointerDownPosRef:B,disabled:h,children:[r.jsx(In.Provider,{scope:t,children:r.jsx(yp,{scope:e.__scopeSelect,onNativeOptionAdd:i.useCallback(_=>{$(P=>new Set(P).add(_))},[]),onNativeOptionRemove:i.useCallback(_=>{$(P=>{const I=new Set(P);return I.delete(_),I})},[]),children:n})}),V?r.jsxs(Fi,{"aria-hidden":!0,required:x,tabIndex:-1,name:u,autoComplete:m,value:O,onChange:_=>F(_.target.value),disabled:h,form:g,children:[O===void 0?r.jsx("option",{value:""}):null,Array.from(L)]},H):null]})})};hi.displayName=pt;var xi="SelectTrigger",gi=i.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:s=!1,...o}=e,a=Ln(n),l=ot(xi,n),c=l.disabled||s,d=se(t,l.onTriggerChange),f=On(n),u=i.useRef("touch"),[m,h,x]=Ui(p=>{const v=f().filter(w=>!w.disabled),b=v.find(w=>w.value===l.value),y=Vi(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(up,{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":Bi(l.value)?"":void 0,...o,ref:d,onClick:Y(o.onClick,p=>{p.currentTarget.focus(),u.current!=="mouse"&&g(p)}),onPointerDown:Y(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:Y(o.onKeyDown,p=>{const v=m.current!=="";!(p.ctrlKey||p.altKey||p.metaKey)&&p.key.length===1&&h(p.key),!(v&&p.key===" ")&&xp.includes(p.key)&&(g(),p.preventDefault())})})})});gi.displayName=xi;var vi="SelectValue",bi=i.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:o,children:a,placeholder:l="",...c}=e,d=ot(vi,n),{onValueNodeHasChildrenChange:f}=d,u=a!==void 0,m=se(t,d.onValueNodeChange);return ve(()=>{f(u)},[f,u]),r.jsx(X.span,{...c,ref:m,style:{pointerEvents:"none"},children:Bi(d.value)?r.jsx(r.Fragment,{children:l}):a})});bi.displayName=vi;var Np="SelectIcon",yi=i.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,...o}=e;return r.jsx(X.span,{"aria-hidden":!0,...o,ref:t,children:s||"▼"})});yi.displayName=Np;var jp="SelectPortal",wi=e=>r.jsx(Dr,{asChild:!0,...e});wi.displayName=jp;var ht="SelectContent",Ni=i.forwardRef((e,t)=>{const n=ot(ht,e.__scopeSelect),[s,o]=i.useState();if(ve(()=>{o(new DocumentFragment)},[]),!n.open){const a=s;return a?Sn.createPortal(r.jsx(ji,{scope:e.__scopeSelect,children:r.jsx(In.Slot,{scope:e.__scopeSelect,children:r.jsx("div",{children:e.children})})}),a):null}return r.jsx(Si,{...e,ref:t})});Ni.displayName=ht;var Re=10,[ji,at]=Dt(ht),Sp="SelectContentImpl",Cp=Ht("SelectContent.RemoveScroll"),Si=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=ot(ht,n),[w,j]=i.useState(null),[k,C]=i.useState(null),S=se(t,M=>j(M)),[R,O]=i.useState(null),[F,B]=i.useState(null),V=On(n),[L,$]=i.useState(!1),H=i.useRef(!1);i.useEffect(()=>{if(w)return To(w)},[w]),yo();const _=i.useCallback(M=>{const[Z,...he]=V().map(q=>q.ref.current),[ee]=he.slice(-1),Q=document.activeElement;for(const q of M)if(q===Q||(q==null||q.scrollIntoView({block:"nearest"}),q===Z&&k&&(k.scrollTop=0),q===ee&&k&&(k.scrollTop=k.scrollHeight),q==null||q.focus(),document.activeElement!==Q))return},[V,k]),P=i.useCallback(()=>_([R,w]),[_,R,w]);i.useEffect(()=>{L&&P()},[L,P]);const{onOpenChange:I,triggerPointerDownPosRef:W}=y;i.useEffect(()=>{if(w){let M={x:0,y:0};const Z=ee=>{var Q,q;M={x:Math.abs(Math.round(ee.pageX)-(((Q=W.current)==null?void 0:Q.x)??0)),y:Math.abs(Math.round(ee.pageY)-(((q=W.current)==null?void 0:q.y)??0))}},he=ee=>{M.x<=10&&M.y<=10?ee.preventDefault():w.contains(ee.target)||I(!1),document.removeEventListener("pointermove",Z),W.current=null};return W.current!==null&&(document.addEventListener("pointermove",Z),document.addEventListener("pointerup",he,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Z),document.removeEventListener("pointerup",he,{capture:!0})}}},[w,I,W]),i.useEffect(()=>{const M=()=>I(!1);return window.addEventListener("blur",M),window.addEventListener("resize",M),()=>{window.removeEventListener("blur",M),window.removeEventListener("resize",M)}},[I]);const[K,T]=Ui(M=>{const Z=V().filter(Q=>!Q.disabled),he=Z.find(Q=>Q.ref.current===document.activeElement),ee=Vi(Z,M,he);ee&&setTimeout(()=>ee.ref.current.focus())}),ie=i.useCallback((M,Z,he)=>{const ee=!H.current&&!he;(y.value!==void 0&&y.value===Z||ee)&&(O(M),ee&&(H.current=!0))},[y.value]),xe=i.useCallback(()=>w==null?void 0:w.focus(),[w]),le=i.useCallback((M,Z,he)=>{const ee=!H.current&&!he;(y.value!==void 0&&y.value===Z||ee)&&B(M)},[y.value]),ue=s==="popper"?xr:Ci,ge=ue===xr?{side:c,sideOffset:d,align:f,alignOffset:u,arrowPadding:m,collisionBoundary:h,collisionPadding:x,sticky:g,hideWhenDetached:p,avoidCollisions:v}:{};return r.jsx(ji,{scope:n,content:w,viewport:k,onViewportChange:C,itemRefCallback:ie,selectedItem:R,onItemLeave:xe,itemTextRefCallback:le,focusSelectedItem:P,selectedItemText:F,position:s,isPositioned:L,searchRef:K,children:r.jsx(Mr,{as:Cp,allowPinchZoom:!0,children:r.jsx(Pr,{asChild:!0,trapped:y.open,onMountAutoFocus:M=>{M.preventDefault()},onUnmountAutoFocus:Y(o,M=>{var Z;(Z=y.trigger)==null||Z.focus({preventScroll:!0}),M.preventDefault()}),children:r.jsx(_r,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:M=>M.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:r.jsx(ue,{role:"listbox",id:y.contentId,"data-state":y.open?"open":"closed",dir:y.dir,onContextMenu:M=>M.preventDefault(),...b,...ge,onPlaced:()=>$(!0),ref:S,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:Y(b.onKeyDown,M=>{const Z=M.ctrlKey||M.altKey||M.metaKey;if(M.key==="Tab"&&M.preventDefault(),!Z&&M.key.length===1&&T(M.key),["ArrowUp","ArrowDown","Home","End"].includes(M.key)){let ee=V().filter(Q=>!Q.disabled).map(Q=>Q.ref.current);if(["ArrowUp","End"].includes(M.key)&&(ee=ee.slice().reverse()),["ArrowUp","ArrowDown"].includes(M.key)){const Q=M.target,q=ee.indexOf(Q);ee=ee.slice(q+1)}setTimeout(()=>_(ee)),M.preventDefault()}})})})})})})});Si.displayName=Sp;var kp="SelectItemAlignedPosition",Ci=i.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:s,...o}=e,a=ot(ht,n),l=at(ht,n),[c,d]=i.useState(null),[f,u]=i.useState(null),m=se(t,S=>u(S)),h=On(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(),O=a.valueNode.getBoundingClientRect(),F=b.getBoundingClientRect();if(a.dir!=="rtl"){const Q=F.left-R.left,q=O.left-Q,fe=S.left-q,E=S.width+fe,te=Math.max(E,R.width),de=window.innerWidth-Re,Ce=Ls(q,[Re,Math.max(Re,de-te)]);c.style.minWidth=E+"px",c.style.left=Ce+"px"}else{const Q=R.right-F.right,q=window.innerWidth-O.right-Q,fe=window.innerWidth-S.right-q,E=S.width+fe,te=Math.max(E,R.width),de=window.innerWidth-Re,Ce=Ls(q,[Re,Math.max(Re,de-te)]);c.style.minWidth=E+"px",c.style.right=Ce+"px"}const B=h(),V=window.innerHeight-Re*2,L=p.scrollHeight,$=window.getComputedStyle(f),H=parseInt($.borderTopWidth,10),_=parseInt($.paddingTop,10),P=parseInt($.borderBottomWidth,10),I=parseInt($.paddingBottom,10),W=H+_+L+I+P,K=Math.min(v.offsetHeight*5,W),T=window.getComputedStyle(p),ie=parseInt(T.paddingTop,10),xe=parseInt(T.paddingBottom,10),le=S.top+S.height/2-Re,ue=V-le,ge=v.offsetHeight/2,M=v.offsetTop+ge,Z=H+_+M,he=W-Z;if(Z<=le){const Q=B.length>0&&v===B[B.length-1].ref.current;c.style.bottom="0px";const q=f.clientHeight-p.offsetTop-p.offsetHeight,fe=Math.max(ue,ge+(Q?xe:0)+q+P),E=Z+fe;c.style.height=E+"px"}else{const Q=B.length>0&&v===B[0].ref.current;c.style.top="0px";const fe=Math.max(le,H+p.offsetTop+(Q?ie:0)+ge)+he;c.style.height=fe+"px",p.scrollTop=Z-le+p.offsetTop}c.style.margin=`${Re}px 0`,c.style.minHeight=K+"px",c.style.maxHeight=V+"px",s==null||s(),requestAnimationFrame(()=>x.current=!0)}},[h,a.trigger,a.valueNode,c,f,p,v,b,a.dir,s]);ve(()=>w(),[w]);const[j,k]=i.useState();ve(()=>{f&&k(window.getComputedStyle(f).zIndex)},[f]);const C=i.useCallback(S=>{S&&g.current===!0&&(w(),y==null||y(),g.current=!1)},[w,y]);return r.jsx(Ap,{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}})})})});Ci.displayName=kp;var Ep="SelectPopperPosition",xr=i.forwardRef((e,t)=>{const{__scopeSelect:n,align:s="start",collisionPadding:o=Re,...a}=e,l=Ln(n);return r.jsx(fp,{...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)"}})});xr.displayName=Ep;var[Ap,Qr]=Dt(ht,{}),gr="SelectViewport",ki=i.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:s,...o}=e,a=at(gr,n),l=Qr(gr,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(In.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:Y(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})})})]})});ki.displayName=gr;var Ei="SelectGroup",[Tp,Rp]=Dt(Ei),_p=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=Ze();return r.jsx(Tp,{scope:n,id:o,children:r.jsx(X.div,{role:"group","aria-labelledby":o,...s,ref:t})})});_p.displayName=Ei;var Ai="SelectLabel",Ti=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=Rp(Ai,n);return r.jsx(X.div,{id:o.id,...s,ref:t})});Ti.displayName=Ai;var Nn="SelectItem",[Pp,Ri]=Dt(Nn),_i=i.forwardRef((e,t)=>{const{__scopeSelect:n,value:s,disabled:o=!1,textValue:a,...l}=e,c=ot(Nn,n),d=at(Nn,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=Ze(),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(Pp,{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(In.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:Y(l.onFocus,()=>x(!0)),onBlur:Y(l.onBlur,()=>x(!1)),onClick:Y(l.onClick,()=>{v.current!=="mouse"&&b()}),onPointerUp:Y(l.onPointerUp,()=>{v.current==="mouse"&&b()}),onPointerDown:Y(l.onPointerDown,y=>{v.current=y.pointerType}),onPointerMove:Y(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:Y(l.onPointerLeave,y=>{var w;y.currentTarget===document.activeElement&&((w=d.onItemLeave)==null||w.call(d))}),onKeyDown:Y(l.onKeyDown,y=>{var j;((j=d.searchRef)==null?void 0:j.current)!==""&&y.key===" "||(gp.includes(y.key)&&b(),y.key===" "&&y.preventDefault())})})})})});_i.displayName=Nn;var It="SelectItemText",Pi=i.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:o,...a}=e,l=ot(It,n),c=at(It,n),d=Ri(It,n),f=wp(It,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 ve(()=>(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?Sn.createPortal(a.children,l.valueNode):null]})});Pi.displayName=It;var Di="SelectItemIndicator",Mi=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return Ri(Di,n).isSelected?r.jsx(X.span,{"aria-hidden":!0,...s,ref:t}):null});Mi.displayName=Di;var vr="SelectScrollUpButton",Ii=i.forwardRef((e,t)=>{const n=at(vr,e.__scopeSelect),s=Qr(vr,e.__scopeSelect),[o,a]=i.useState(!1),l=se(t,s.onScrollButtonChange);return ve(()=>{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(Li,{...e,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop-d.offsetHeight)}}):null});Ii.displayName=vr;var br="SelectScrollDownButton",Oi=i.forwardRef((e,t)=>{const n=at(br,e.__scopeSelect),s=Qr(br,e.__scopeSelect),[o,a]=i.useState(!1),l=se(t,s.onScrollButtonChange);return ve(()=>{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(Li,{...e,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop+d.offsetHeight)}}):null});Oi.displayName=br;var Li=i.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:s,...o}=e,a=at("SelectScrollButton",n),l=i.useRef(null),c=On(n),d=i.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return i.useEffect(()=>()=>d(),[d]),ve(()=>{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:Y(o.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(s,50))}),onPointerMove:Y(o.onPointerMove,()=>{var f;(f=a.onItemLeave)==null||f.call(a),l.current===null&&(l.current=window.setInterval(s,50))}),onPointerLeave:Y(o.onPointerLeave,()=>{d()})})}),Dp="SelectSeparator",$i=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return r.jsx(X.div,{"aria-hidden":!0,...s,ref:t})});$i.displayName=Dp;var yr="SelectArrow",Mp=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=Ln(n),a=ot(yr,n),l=at(yr,n);return a.open&&l.position==="popper"?r.jsx(mp,{...o,...s,ref:t}):null});Mp.displayName=yr;var Ip="SelectBubbleInput",Fi=i.forwardRef(({__scopeSelect:e,value:t,...n},s)=>{const o=i.useRef(null),a=se(s,o),l=mi(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:{...pi,...n.style},ref:a,defaultValue:t})});Fi.displayName=Ip;function Bi(e){return e===""||e===void 0}function Ui(e){const t=tt(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 Vi(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=Op(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 Op(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Lp=hi,Wi=gi,$p=bi,Fp=yi,Bp=wi,zi=Ni,Up=ki,Hi=Ti,Ki=_i,Vp=Pi,Wp=Mi,qi=Ii,Gi=Oi,Yi=$i;const Ee=Lp,Ae=$p,be=i.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(Wi,{ref:s,className:U("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,r.jsx(Fp,{asChild:!0,children:r.jsx(Ve,{className:"h-4 w-4 opacity-50"})})]}));be.displayName=Wi.displayName;const Xi=i.forwardRef(({className:e,...t},n)=>r.jsx(qi,{ref:n,className:U("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(kr,{className:"h-4 w-4"})}));Xi.displayName=qi.displayName;const Ji=i.forwardRef(({className:e,...t},n)=>r.jsx(Gi,{ref:n,className:U("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(Ve,{className:"h-4 w-4"})}));Ji.displayName=Gi.displayName;const ye=i.forwardRef(({className:e,children:t,position:n="popper",...s},o)=>r.jsx(Bp,{children:r.jsxs(zi,{ref:o,className:U("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...s,children:[r.jsx(Xi,{}),r.jsx(Up,{className:U("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),r.jsx(Ji,{})]})}));ye.displayName=zi.displayName;const zp=i.forwardRef(({className:e,...t},n)=>r.jsx(Hi,{ref:n,className:U("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));zp.displayName=Hi.displayName;const ae=i.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(Ki,{ref:s,className:U("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[r.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsx(Wp,{children:r.jsx(Cr,{className:"h-4 w-4"})})}),r.jsx(Vp,{children:t})]}));ae.displayName=Ki.displayName;const Hp=i.forwardRef(({className:e,...t},n)=>r.jsx(Yi,{ref:n,className:U("-mx-1 my-1 h-px bg-muted",e),...t}));Hp.displayName=Yi.displayName;const Zi=[{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"}],Kp=new Set(Zi.filter(e=>e.supportsFollowUp).map(e=>e.value));function qp(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 Ys(){return Zi.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 Xs(e,t,n=!1){const s=e.trim();if(s)return s;const o=t.trim().split(`
|
|
200
|
+
`).map(a=>a.trim()).find(Boolean);return o?o.length>72?`${o.slice(0,69).trimEnd()}...`:o:n?"Image task":""}function Gp({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"),[O,F]=i.useState(!1),[B,V]=i.useState(!1),{images:L,error:$,fileInputRef:H,pickImages:_,handleFileChange:P,handlePaste:I,removeImage:W}=na(),K=i.useMemo(()=>qp(e,{currentNodeRole:t,leaderNodeId:n}),[e,t,n]);i.useEffect(()=>{S!=="auto"&&(K.some(E=>E.id===S)||R("auto"))},[S,K]);const T=i.useMemo(()=>{if(S!=="auto"){const te=e.find(de=>de.id===S);return(te==null?void 0:te.workDirFolders)??[]}const E=new Set;for(const te of K)for(const de of te.workDirFolders??[])E.add(de);return[...E].sort()},[S,e,K]),ie=i.useCallback(async E=>{E.preventDefault();const te=Xs(m,x,L.length>0),de=x.trim()||te;if(!(!te||!de||!p)){F(!0);try{const Ce=Tr(x,L),He=await Gl({title:te,description:de,agent:p,project:b.trim()||null,payload:{initialMessage:Ce},priority:k,assignTo:S==="auto"?void 0:S});s(He)}catch(Ce){ce.error(Ce instanceof Error?Ce.message:"Failed to create task")}finally{F(!1)}}},[m,x,p,b,L,k,S,s]),xe=Xs(m,x,L.length>0),le=!!(xe&&p&&(x.trim()||L.length>0)),ue=i.useCallback(E=>{var te;E.nativeEvent.isComposing||E.key==="Enter"&&E.shiftKey&&le&&!O&&(E.preventDefault(),(te=E.currentTarget.form)==null||te.requestSubmit())},[le,O]),ge=b||"__none__",M=T.length>0,Z=L.length>0&&r.jsx("div",{className:"flex flex-wrap gap-3",children:L.map((E,te)=>r.jsxs("div",{className:"relative",children:[r.jsx("img",{src:Rr(E),alt:E.filename??`attachment ${te+1}`,className:"h-24 w-24 rounded-2xl border border-border/70 object-cover"}),r.jsx("button",{type:"button",onClick:()=>W(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 ${E.filename??`image ${te+1}`}`,children:r.jsx(Er,{className:"h-3.5 w-3.5"})})]},`${E.filename??"image"}-${te}`))}),he=r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ye,{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(Ae,{placeholder:"Auto-assign"})}),r.jsxs(ye,{children:[r.jsx(ae,{value:"auto",children:"Auto-assign"}),K.map(E=>r.jsx(ae,{value:E.id,children:E.name},E.id))]})]})]}),ee=r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ye,{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(Ae,{placeholder:"Select agent"})}),r.jsx(ye,{children:Ys()})]})]}),Q=r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ye,{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(Ae,{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"})]})]})]}),q=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(dt,{id:"task-title-composer",type:"text",value:m,onChange:E=>h(E.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:xe?`Will appear as: ${xe}`:"A title will be generated from the first line of the prompt."})]}),fe=r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ye,{className:"text-sm font-medium",children:"Working directory"}),w==="select"&&M?r.jsxs(Ee,{value:ge,onValueChange:E=>{if(E==="__custom__"){j("custom"),y("");return}y(E==="__none__"?"":E)},children:[r.jsx(be,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:r.jsx(Ae,{placeholder:"Select folder or use the node default"})}),r.jsxs(ye,{children:[r.jsx(ae,{value:"__none__",children:"Use node default"}),T.map(E=>r.jsx(ae,{value:E,children:E},E)),r.jsx(ae,{value:"__custom__",children:"Custom path..."})]})]}):r.jsxs("div",{className:"flex gap-2",children:[r.jsx(dt,{id:"task-project",type:"text",value:b,onChange:E=>y(E.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(G,{type:"button",variant:"outline",onClick:()=>{j("select"),y("")},className:"h-11 rounded-2xl",children:"Browse"})]})]});return u==="composer"?r.jsxs("form",{onSubmit:ie,className:U("space-y-4",a),children:[r.jsx("input",{ref:H,type:"file",accept:"image/*",multiple:!0,onChange:P,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:E=>g(E.target.value),onKeyDown:ue,onPaste:I,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(G,{type:"button",variant:"ghost",size:"sm",onClick:_,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(Ae,{placeholder:"Auto-assign"})}),r.jsxs(ye,{children:[r.jsx(ae,{value:"auto",children:"Auto-assign"}),K.map(E=>r.jsx(ae,{value:E.id,children:E.name},E.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(Ae,{placeholder:"Agent"})}),r.jsx(ye,{children:Ys()})]}),r.jsxs(G,{type:"button",variant:"ghost",size:"sm",onClick:()=>V(!B),"aria-controls":"task-composer-settings","aria-expanded":B,className:"h-9 gap-1.5 rounded-full px-3 text-xs text-muted-foreground hover:text-foreground",children:[r.jsx(Kc,{className:"h-3.5 w-3.5"}),B?r.jsx(kr,{className:"h-3 w-3"}):r.jsx(Ve,{className:"h-3 w-3"})]})]}),r.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[o&&r.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:o,className:"h-9 rounded-full px-4 text-xs text-muted-foreground",children:d}),r.jsxs(G,{type:"submit",size:"icon",disabled:!le||O,className:"h-10 w-10 rounded-full shadow-[0_8px_30px_-8px_hsl(var(--primary)/0.6)]",children:[O?r.jsx(Ie,{className:"h-4 w-4 animate-spin"}):r.jsx(fo,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:O?"Creating chat":c})]})]})]})]}),(Z||$)&&r.jsxs("div",{className:"space-y-3 rounded-[20px] border border-border/60 bg-background/45 p-4",children:[Z,$&&r.jsx("div",{className:"text-xs text-destructive",children:$}),!$&&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."})]}),B&&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:q}),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:ge,onValueChange:E=>{if(E==="__custom__"){j("custom"),y("");return}y(E==="__none__"?"":E)},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(Ae,{placeholder:"Use node default"})}),r.jsxs(ye,{children:[r.jsx(ae,{value:"__none__",children:"Use node default"}),T.map(E=>r.jsx(ae,{value:E,children:E},E)),r.jsx(ae,{value:"__custom__",children:"Custom path..."})]})]}):r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(dt,{id:"task-project",type:"text",value:b,onChange:E=>y(E.target.value),placeholder:"Optional path",className:"h-10 rounded-2xl border-border/70 bg-background/60 px-3.5 shadow-none"}),M&&r.jsx(G,{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(Ae,{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:ie,className:U("space-y-5",a),children:[r.jsx("input",{ref:H,type:"file",accept:"image/*",multiple:!0,onChange:P,className:"hidden"}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ye,{htmlFor:"task-description",className:"text-sm font-medium",children:"Opening prompt"}),r.jsx("textarea",{id:"task-description",value:x,onChange:E=>g(E.target.value),onKeyDown:ue,onPaste:I,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(G,{type:"button",variant:"outline",onClick:_,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."})]}),Z,$&&r.jsx("p",{className:"text-xs text-destructive",children:$})]}),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(Ye,{htmlFor:"task-title",className:"text-sm font-medium",children:"Chat title"}),r.jsx(dt,{id:"task-title",type:"text",value:m,onChange:E=>h(E.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:xe?`Will appear as: ${xe}`:"A title will be generated from the first line of the prompt."})]}),ee]}),fe,r.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[Q,he]}),r.jsxs("div",{className:U("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",l),children:[o&&r.jsx(G,{type:"button",variant:"ghost",onClick:o,className:"rounded-2xl",children:d}),r.jsx(G,{type:"submit",disabled:!le||O,className:"rounded-2xl px-5",children:O?"Creating...":c})]})]})}const Yp=[{value:"active",label:"Active"},{value:"running",label:"Running"},{value:"waiting",label:"Waiting"},{value:"closed",label:"Closed"},{value:"archived",label:"Archived"}],jn=new Set(["pending","assigned"]),Qi=new Set(["running"]),Xp=new Set(["completed","failed","cancelled"]),Jp=new Set(["completed","failed","cancelled"]);function Zp(e,t){switch(t){case"running":return Qi.has(e.status);case"waiting":return jn.has(e.status);case"closed":return Xp.has(e.status);case"archived":return e.status==="archived";case"active":default:return e.status!=="archived"}}function Qp(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 es(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 eh(e,t,n){return es(e,t,n).toLowerCase()}function th(e,t){return[...e].sort((n,s)=>n.id===t?-1:s.id===t?1:n.name.localeCompare(s.name))}function nh(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 rh(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 sh(e){return e==="default workspace"?e:e.replace(/\\/g,"/").split("/").filter(Boolean).at(-1)??e}function oh(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 ah(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 ih(e){return new Date(e).toLocaleString()}function lh(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 Qe(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),ce.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 ce.success(t),!0}catch(a){return ce.error(a instanceof Error?a.message:"Failed to copy"),!1}}function Nt({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:U("min-w-0 flex-1 break-all text-sm text-foreground",n&&"font-mono text-[11px] leading-5"),children:t}),s]})]})}function wr({label:e,value:t,mono:n}){return r.jsxs("div",{className:"rounded-[18px] border border-border/60 bg-background/60 px-3 py-3",children:[r.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:e}),r.jsx("div",{className:U("mt-1 text-sm font-medium text-foreground",n&&"font-mono text-[11px]"),children:t})]})}function el({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 ch=i.lazy(async()=>({default:(await jr(()=>import("./FilesTab-Bi9oHsVg.js"),__vite__mapDeps([0,1,2,3]))).FilesTab})),dh=i.lazy(async()=>({default:(await jr(()=>import("./PreviewTab-DUCCQm-Z.js"),__vite__mapDeps([4,1,2]))).PreviewTab})),uh=i.lazy(async()=>({default:(await jr(()=>import("./DiffTab-DBsjdYWn.js"),__vite__mapDeps([5,1,2,3]))).DiffTab}));function fh({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:O,onRetry:F,onCancel:B,onStartCreateTask:V,onCancelCreateTask:L,onCreateTask:$,onSendMessage:H,onQuestionBypassChange:_,onSubmitQuestionResponse:P,messagesEndRef:I}){const[W,K]=i.useState(!1),T=(u==null?void 0:u.effectiveProjectPath)??(u==null?void 0:u.project)??"default workspace",ie=u?(m==null?void 0:m.name)??es(u.assignedTo,a==null?void 0:a.nodes,u.assignedNodeName):"unassigned",xe=u?[{label:"Working dir",value:T,mono:!0},{label:"Agent",value:u.agent,mono:!0},{label:"Node",value:ie}]:[],le=u!=null&&u.description&&u.description!==u.title?u.description:null;return f?r.jsx(mh,{onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:l,onCancel:L,onCreated:$}):!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(pn,{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(ja,{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(pn,{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(no,{status:u.status}),r.jsx(Yl,{priority:u.priority}),r.jsx(G,{variant:"ghost",size:"icon",className:"ml-auto h-6 w-6 shrink-0 rounded-full text-muted-foreground",onClick:()=>K(ue=>!ue),children:W?r.jsx(kr,{className:"h-3.5 w-3.5"}):r.jsx(Ve,{className:"h-3.5 w-3.5"})})]}),W&&r.jsxs("div",{className:"mt-2 space-y-2",children:[le&&r.jsx("p",{className:"max-w-3xl text-sm leading-5 text-muted-foreground",children:le}),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 ",ih(u.updatedAt)]}),r.jsx("span",{className:"font-mono",children:u.id.slice(0,8)})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[O&&r.jsxs(G,{variant:"outline",size:"sm",onClick:F,className:"shrink-0 rounded-full",children:[r.jsx(Vc,{className:"h-3.5 w-3.5"}),"Retry"]}),R&&r.jsxs(un,{children:[r.jsx(fn,{asChild:!0,children:r.jsxs(G,{variant:"destructive",size:"sm",className:"shrink-0 rounded-full",children:[r.jsx(oo,{className:"h-3.5 w-3.5"}),"Cancel"]})}),r.jsxs(Lt,{children:[r.jsxs($t,{children:[r.jsx(Bt,{children:"Cancel this task?"}),r.jsx(Ut,{children:"The task will stop and move to a cancelled state."})]}),r.jsxs(Ft,{children:[r.jsx(Wt,{children:"No"}),r.jsx(Vt,{onClick:B,children:"Yes, cancel"})]})]})]})]})]})]}),r.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[r.jsxs(zr,{className:"h-auto max-w-full overflow-x-auto rounded-full bg-muted/70 p-1",children:[r.jsx(Xe,{value:"transcript",className:"rounded-full px-2.5 sm:px-4",children:"Transcript"}),r.jsx(Xe,{value:"files",className:"rounded-full px-2.5 sm:px-4",children:"Files"}),r.jsx(Xe,{value:"preview",className:"rounded-full px-2.5 sm:px-4",children:"Preview"}),r.jsx(Xe,{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(Je,{value:"transcript",className:"mt-0 min-h-0 flex-1",children:r.jsxs("div",{className:"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",children:r.jsxs("div",{className:"mx-auto flex max-w-4xl flex-col gap-5",children:[v&&!p&&r.jsx(Is,{event:v,questionBypassEnabled:k,onQuestionBypassChange:_,onSubmitQuestionResponse:P,questionResponseDisabled:!b||w}),g.map((ue,ge)=>r.jsx(Is,{event:ue,questionBypassEnabled:k,onQuestionBypassChange:_,onSubmitQuestionResponse:P,questionResponseDisabled:!b||w},kd("transcript",ue,ge))),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:I})]})}),b?r.jsx("div",{className:"shrink-0",children:r.jsx("div",{className:"mx-auto w-full max-w-4xl",children:r.jsx(gf,{onSend:H,disabled:w,disabledReason:j,contextItems:xe,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(Je,{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(ch,{taskId:u.id})})}),r.jsx(Je,{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(dh,{taskId:u.id})})}),r.jsx(Je,{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(uh,{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(pn,{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(Sr,{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(G,{onClick:V,className:"mt-6 rounded-full px-5",children:[r.jsx(lo,{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 mh({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(pn,{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(Sr,{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(Gp,{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 pn({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(ph,{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(G,{variant:"outline",onClick:o,className:"shrink-0 rounded-full border-border/70 bg-background/60 px-3 sm:px-4",children:[s?r.jsx(uo,{className:"h-4 w-4"}):r.jsx(Bc,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline",children:s?"Hide cluster":"Show cluster"})]})]})}function ph({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(G,{variant:"outline",onClick:n,className:"rounded-full border-border/70 bg-background/60 px-3 sm:px-4",children:[s?r.jsx(co,{className:"h-4 w-4"}):r.jsx(Lc,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline",children:s?"Hide tasks":"Show tasks"})]})}const hh={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 xh(e){return e.split(".")[0]??"unknown"}function gh(e){return new Date(e).toLocaleTimeString("en-US",{hour12:!1})}function or(e,t){return(t==null?void 0:t.get(e))??e}function vh(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 bh(e){return JSON.stringify(e,null,2)}function yh({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=xh(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:gh(a.timestamp)}),r.jsx(je,{variant:"outline",className:U("w-fit text-[10px] font-medium uppercase tracking-[0.16em]",hh[l]),children:a.type})]}),r.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-full text-muted-foreground",onClick:()=>void Qe(bh(a),"Event copied"),"aria-label":`Copy ${a.type} event`,title:"Copy event",children:r.jsx(ao,{className:"h-3.5 w-3.5"})})]}),r.jsx("div",{className:"text-sm leading-6 text-foreground/85",children:vh(a,o)})]})},a.id)})})})}function Js({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 V,L,$,H,_;const k=((V=e==null?void 0:e.self)==null?void 0:V.role)==="leader",C=((L=e==null?void 0:e.self)==null?void 0:L.role)==="follower"&&!(e!=null&&e.leader),S=(e==null?void 0:e.self)??null,O=th((e==null?void 0:e.nodes)??[],S==null?void 0:S.id).filter(P=>P.id!==(S==null?void 0:S.id)),F=(S==null?void 0:S.role)==="leader"&&O.length===0,B=(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(ja,{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(G,{variant:"ghost",size:"icon",onClick:j,className:"rounded-full",children:r.jsx(uo,{className:"h-4 w-4"})})]}),r.jsxs(zr,{className:"mt-4 grid h-auto w-full grid-cols-3 rounded-full bg-muted/70 p-1",children:[r.jsx(Xe,{value:"overview",className:"rounded-full px-3 text-xs",children:"Overview"}),r.jsx(Xe,{value:"nodes",className:"rounded-full px-3 text-xs",children:"Nodes"}),r.jsx(Xe,{value:"events",className:"rounded-full px-3 text-xs",children:"Live events"})]})]}),r.jsx(Je,{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(Zs,{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(Nt,{label:"Term",value:String((e==null?void 0:e.term)??0)}),r.jsx(Nt,{label:"Nodes",value:String((e==null?void 0:e.nodes.length)??0)}),r.jsx(Nt,{label:"Pending",value:String((e==null?void 0:e.taskSummary.pending)??0)}),r.jsx(Nt,{label:"Running",value:String((e==null?void 0:e.taskSummary.running)??0)}),r.jsx(Nt,{label:"Completed",value:String((e==null?void 0:e.taskSummary.completed)??0)}),r.jsx(Nt,{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:(($=e==null?void 0:e.leader)==null?void 0:$.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:(_=e==null?void 0:e.leader)!=null&&_.endpoint?r.jsx(ut,{label:"Copy leader URL",onClick:()=>{var P;return void Qe(((P=e.leader)==null?void 0:P.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(G,{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(G,{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(Je,{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"}),F?r.jsx(G,{variant:"outline",size:"sm",onClick:p,className:"rounded-full",children:"Join node"}):B?r.jsxs(G,{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(Zs,{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 (",O.length,")"]}),O.length>0?r.jsx("div",{className:"space-y-3",children:O.map(P=>r.jsx(wh,{node:P,isLeader:!!k,blockingTaskCount:s.get(P.id)??0,devTunnelNodeId:w,onToggleNodeDevTunnel:y},P.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(Je,{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(Xl,{className:U("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(Ae,{placeholder:"Event type"})}),r.jsx(ye,{children:l.map(P=>r.jsx(ae,{value:P,className:"text-[12px]",children:P==="all"?"All event types":P},P))})]}),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(yh,{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 Zs({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=po(e,t==null?void 0:t.transportType),p=Ar(e,t==null?void 0:t.transportType),v=p&&At((t==null?void 0:t.transportType)??e.transportType)?!0:mo(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(Ve,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):r.jsx(Gt,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),r.jsx(ro,{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(io,{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(so,{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(ut,{label:"Copy dashboard URL",onClick:()=>void Qe(f,"Dashboard URL copied")})}),r.jsx(Ne,{label:"Node URL",value:u,mono:!0,action:r.jsx(ut,{label:"Copy node URL",onClick:()=>void Qe(u,"Node URL copied")})}),h&&r.jsx(Ne,{label:"Preview",value:h,mono:!0,action:r.jsx(ut,{label:"Copy preview endpoint",onClick:()=>void Qe(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(wr,{label:"Transport",value:g}),t&&r.jsx(wr,{label:"Uptime",value:lh(t.uptime),mono:!0})]}),r.jsx(el,{capabilities:e.capabilities,action:a&&v?r.jsxs(G,{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 wh({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=po(e),h=Ar(e),x=mo(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(Ve,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):r.jsx(Gt,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),r.jsx(ro,{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(io,{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(so,{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(ut,{label:"Copy dashboard URL",onClick:()=>void Qe(c,"Dashboard URL copied")})}),r.jsx(Ne,{label:"Node URL",value:d,mono:!0,action:r.jsx(ut,{label:"Copy node URL",onClick:()=>void Qe(d,"Node URL copied")})}),u&&r.jsx(Ne,{label:"Preview",value:u,mono:!0,action:r.jsx(ut,{label:"Copy preview endpoint",onClick:()=>void Qe(u,"Preview endpoint copied")})}),e.workDir&&r.jsx(Ne,{label:"Workspace",value:e.workDir,mono:!0}),r.jsx(wr,{label:"Transport",value:m})]}),r.jsx(el,{capabilities:e.capabilities,action:t&&x?r.jsxs(G,{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 ut({label:e,onClick:t}){return r.jsx(G,{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(ao,{className:"h-3.5 w-3.5"})})}function Nh(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..."}:jn.has(e.status)||e.status==="archived"?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:jn.has(e.status)?"Task has not started yet...":"Archived tasks are read-only."}:{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Continue the conversation..."}}var $n="Checkbox",[jh]=st($n),[Sh,ts]=jh($n);function Ch(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]=kt({prop:n,defaultProp:o??!1,onChange:d,caller:$n}),[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:et(o)?!1:o,isFormControl:w,bubbleInput:v,setBubbleInput:b};return r.jsx(Sh,{scope:t,...j,children:kh(m)?m(j):s})}var tl="CheckboxTrigger",nl=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}=ts(tl,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":et(d)?"mixed":d,"aria-required":f,"data-state":il(d),"data-disabled":c?"":void 0,disabled:c,value:l,...s,ref:p,onKeyDown:Y(t,b=>{b.key==="Enter"&&b.preventDefault()}),onClick:Y(n,b=>{m(y=>et(y)?!0:!y),g&&x&&(h.current=b.isPropagationStopped(),h.current||b.stopPropagation())})})});nl.displayName=tl;var ns=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(Ch,{__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(nl,{...m,ref:t,__scopeCheckbox:n}),h&&r.jsx(al,{__scopeCheckbox:n})]})})});ns.displayName=$n;var rl="CheckboxIndicator",sl=i.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:s,...o}=e,a=ts(rl,n);return r.jsx(Rt,{present:s||et(a.checked)||a.checked===!0,children:r.jsx(X.span,{"data-state":il(a.checked),"data-disabled":a.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});sl.displayName=rl;var ol="CheckboxBubbleInput",al=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}=ts(ol,e),g=se(n,x),p=mi(a),v=ni(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=et(a),k.call(y,et(a)?!1:a),y.dispatchEvent(S)}},[h,p,a,o]);const b=i.useRef(et(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%)"}})});al.displayName=ol;function kh(e){return typeof e=="function"}function et(e){return e==="indeterminate"}function il(e){return et(e)?"indeterminate":e?"checked":"unchecked"}const Nr=i.forwardRef(({className:e,...t},n)=>r.jsx(ns,{ref:n,className:U("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:r.jsx(sl,{className:U("flex items-center justify-center text-current"),children:r.jsx(Cr,{className:"h-3.5 w-3.5"})})}));Nr.displayName=ns.displayName;function Qs({toolbarTasks:e,activeTaskId:t,activeTask:n,tasksLoading:s,tasksError:o,isLeader:a,scope:l,agentFilter:c,nodeFilter:d,agentOptions:f,nodeOptions:u,nodeNameById:m,searchQuery:h,selectedTaskIds:x,allVisibleTasksSelected:g,someVisibleTasksSelected:p,canBatchArchive:v,onSearchChange:b,onScopeChange:y,onAgentFilterChange:w,onNodeFilterChange:j,onToggleTaskSelected:k,onToggleAllVisibleTasks:C,canArchive:S,canDelete:R,onArchive:O,onDelete:F,onBatchArchive:B,onBatchDelete:V,onCreateTask:L,onSelectTask:$,onClose:H}){const[_,P]=i.useState(!!h),I=i.useRef(null),W=i.useRef(null),K=x.size;return i.useEffect(()=>{h&&P(!0)},[h]),i.useEffect(()=>{var T;_&&((T=I.current)==null||T.focus())},[_]),i.useEffect(()=>{if(!_)return;const T=xe=>{var ue;const le=xe.target;le instanceof Node&&((ue=W.current)!=null&&ue.contains(le)||P(!1))},ie=xe=>{xe.key==="Escape"&&P(!1)};return document.addEventListener("mousedown",T),document.addEventListener("keydown",ie),()=>{document.removeEventListener("mousedown",T),document.removeEventListener("keydown",ie)}},[_]),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(G,{variant:"ghost",size:"icon",onClick:H,className:"rounded-full",children:r.jsx(co,{className:"h-4 w-4"})})]}),r.jsxs("div",{ref:W,className:"mt-4 flex items-center gap-2",children:[r.jsxs(G,{onClick:L,className:U("justify-start rounded-[22px] px-4 py-6 text-left shadow-[0_24px_60px_-32px_hsl(var(--primary)/0.95)] transition-[flex] duration-200",_?"flex-[2]":"flex-1"),children:[r.jsx(lo,{className:"h-4 w-4"}),"New chat"]}),_?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(bs,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),r.jsx(dt,{ref:I,value:h,onChange:T=>b(T.target.value),placeholder:"Search tasks",className:"h-11 rounded-full border-border/70 bg-background/60 pl-11 text-sm"})]}),r.jsx(G,{variant:"outline",size:"icon",onClick:()=>P(!1),className:"rounded-full border-border/70 bg-background/60",children:r.jsx(oo,{className:"h-4 w-4"})})]}):r.jsxs(G,{variant:"outline",onClick:()=>P(!0),className:U("rounded-full border-border/70 bg-background/60 px-4 text-sm",h&&"border-primary/40 bg-primary/8 text-primary"),children:[r.jsx(bs,{className:"h-4 w-4"}),"Search"]})]}),r.jsxs("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:grid-cols-3",children:[r.jsxs(Ee,{value:l,onValueChange:T=>y(T),children:[r.jsx(be,{className:"h-9 rounded-full border-border/70 bg-background/55 text-[12px]",children:r.jsx(Ae,{})}),r.jsx(ye,{children:Yp.map(T=>r.jsx(ae,{value:T.value,className:"text-[12px]",children:T.label},T.value))})]}),r.jsxs(Ee,{value:d,onValueChange:j,children:[r.jsx(be,{className:"h-9 rounded-full border-border/70 bg-background/55 text-[12px]",children:r.jsx(Ae,{placeholder:"Node"})}),r.jsx(ye,{children:u.map(T=>r.jsx(ae,{value:T.value,className:"text-[12px]",children:T.label},T.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(Ae,{placeholder:"Agent"})}),r.jsx(ye,{children:f.map(T=>r.jsx(ae,{value:T,className:"text-[12px]",children:T==="all"?"All agents":T},T))})]})]})]}),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:[a&&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(Nr,{checked:p&&!g?"indeterminate":g,onCheckedChange:T=>C(T===!0),"aria-label":"Select all visible tasks"}),r.jsx("span",{children:"Select all"})]}),K>0&&r.jsx(G,{variant:"ghost",size:"sm",onClick:()=>C(!1),className:"h-7 rounded-full px-3 text-xs",children:"Clear"})]}),e.map(T=>r.jsxs("div",{className:U("flex items-start gap-3 rounded-[24px] border px-3 py-3 transition-all",T.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:[a&&r.jsx("div",{className:"flex shrink-0 pt-1",onClick:ie=>ie.stopPropagation(),children:r.jsx(Nr,{checked:x.has(T.id),onCheckedChange:ie=>k(T.id,ie===!0),"aria-label":`Select ${T.title}`})}),r.jsx("button",{type:"button",onClick:()=>$(T.id),className:"min-w-0 flex-1 text-left",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("span",{className:U("mt-1 h-2.5 w-2.5 shrink-0 rounded-full",rh(T.status))}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:T.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:T.agent}),r.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),r.jsx("span",{children:T.assignedTo?m.get(T.assignedTo)??T.assignedTo.slice(0,8):"unassigned"}),r.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),r.jsx("span",{children:ah(T.updatedAt)})]}),r.jsxs("div",{className:"mt-3 flex items-center gap-2 text-[11px] text-muted-foreground",children:[r.jsx(no,{status:T.status}),T.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:sh(T.effectiveProjectPath??T.project??"default workspace")})]}),r.jsx("div",{className:"mt-1 truncate font-mono text-[10px] text-muted-foreground/85",children:oh(T.effectiveProjectPath??T.project??"default workspace")})]})]})})]},T.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:s?"Loading tasks...":o||"No tasks match this view."})}),a&&K>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:[K," task",K!==1?"s":""," selected"]}),!v&&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(un,{children:[r.jsx(fn,{asChild:!0,children:r.jsxs(G,{variant:"outline",size:"sm",disabled:!v,className:"rounded-full",children:[r.jsx(vs,{className:"h-3.5 w-3.5"}),"Archive"]})}),r.jsxs(Lt,{children:[r.jsxs($t,{children:[r.jsxs(Bt,{children:["Archive ",K," task",K!==1?"s":"","?"]}),r.jsx(Ut,{children:"Archived tasks stay hidden from the default task view and can be reopened from the archived scope."})]}),r.jsxs(Ft,{children:[r.jsx(Wt,{children:"Cancel"}),r.jsx(Vt,{onClick:B,disabled:!v,children:"Archive"})]})]})]}),r.jsxs(un,{children:[r.jsx(fn,{asChild:!0,children:r.jsxs(G,{variant:"destructive",size:"sm",className:"rounded-full",children:[r.jsx(Xc,{className:"h-3.5 w-3.5"}),"Delete"]})}),r.jsxs(Lt,{children:[r.jsxs($t,{children:[r.jsxs(Bt,{children:["Delete ",K," task",K!==1?"s":"","?"]}),r.jsx(Ut,{children:"This removes the selected tasks and their saved logs."})]}),r.jsxs(Ft,{children:[r.jsx(Wt,{children:"Cancel"}),r.jsx(Vt,{onClick:V,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}):n?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:"Selected task"}),r.jsx("div",{className:"mt-2 truncate text-sm font-semibold text-foreground",children:n.title}),r.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[S&&r.jsxs(G,{variant:"outline",size:"sm",onClick:O,className:"rounded-full",children:[r.jsx(vs,{className:"h-3.5 w-3.5"}),"Archive"]}),R&&r.jsxs(un,{children:[r.jsx(fn,{asChild:!0,children:r.jsx(G,{variant:"destructive",size:"sm",className:"rounded-full",children:"Delete"})}),r.jsxs(Lt,{children:[r.jsxs($t,{children:[r.jsx(Bt,{children:"Permanently delete this task?"}),r.jsx(Ut,{children:"This removes the task record and its saved logs."})]}),r.jsxs(Ft,{children:[r.jsx(Wt,{children:"No"}),r.jsx(Vt,{onClick:F,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}):null]})}function Eh(e,t){return t.data.nodeId===e.self.id||t.data.name===e.self.name||t.data.endpoint===e.self.endpoint}function Ah({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=Eh(e,s);s.type==="node.joined"&&!a&&ce.success(`${o} joined the cluster`),s.type==="node.left"&&!a&&ce.message(`${o} left the cluster`)})},[e,t])}function Th(){var ms,ps,hs;const{id:e}=Jl(),t=Zl(),n=Ql(),{cluster:s,systemInfo:o,events:a,sseConnected:l,subscribe:c,refresh:d,loading:f,error:u}=ec(),m=i.useMemo(()=>nh(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,O]=i.useState("all"),[F,B]=i.useState(""),V=i.useDeferredValue(F),[L,$]=i.useState(!0),[H,_]=i.useState(!1),[P,I]=i.useState(!1),[W,K]=i.useState(()=>!!(m!=null&&m.draftNewTask)),[T,ie]=i.useState(()=>m!=null&&m.draftNewTask?{route:m.returnRoute??"/",taskId:m.returnTaskId??null}:null),[xe,le]=i.useState(!1),[ue,ge]=i.useState("transcript"),[M,Z]=i.useState("all"),[he,ee]=i.useState(!1),[Q,q]=i.useState(null),[fe,E]=i.useState([]),[te,de]=i.useState([]),[Ce,He]=i.useState(!1),[xt,gt]=i.useState(null),[Ke,it]=i.useState(new Set),[ll,rs]=i.useState(!1),[cl,ss]=i.useState(!1),[dl,os]=i.useState(!1),[ul,as]=i.useState(null),is=i.useRef(null),Mt=i.useRef(null),Fe=((ms=s==null?void 0:s.self)==null?void 0:ms.role)==="leader",Fn=(ps=s==null?void 0:s.self)==null?void 0:ps.id;Ah({cluster:s,subscribe:c});const me=i.useCallback(async()=>{try{const N=await tc({assignedTo:!Fe&&Fn?Fn:void 0,limit:100});x(N),b(null)}catch(N){b(N instanceof Error?N.message:"Failed to load tasks")}finally{p(!1)}},[Fe,Fn]);nc(me,1e4),i.useEffect(()=>{me()},[me]),i.useEffect(()=>c("task",me),[c,me]);const pe=i.useMemo(()=>[...h].sort((N,A)=>A.updatedAt-N.updatedAt),[h]),fl=i.useMemo(()=>{const N=new Map;for(const A of(s==null?void 0:s.nodes)??[]){const D=rd(pe,A.id);D>0&&N.set(A.id,D)}return N},[s==null?void 0:s.nodes,pe]),Te=i.useMemo(()=>pe.filter(N=>!Zp(N,j)||C!=="all"&&N.agent!==C||R==="unassigned"&&N.assignedTo||R!=="all"&&R!=="unassigned"&&eh(N.assignedTo,s==null?void 0:s.nodes,N.assignedNodeName)!==R?!1:V.trim()?Qp(N,V):!0),[pe,j,C,R,V]);i.useEffect(()=>{it(N=>{const A=ld(N,Te.map(D=>D.id));return A.size===N.size?N:A})},[Te]),i.useEffect(()=>{Fe||it(new Set)},[Fe]);const ml=i.useMemo(()=>["all",...Array.from(new Set(pe.map(N=>N.agent))).sort()],[pe]),pl=i.useMemo(()=>{const A=Array.from(new Set(pe.map(D=>D.assignedTo).filter(D=>!!D))).map(D=>{const oe=pe.find(J=>J.assignedTo===D);return(s==null?void 0:s.nodes.find(J=>J.id===D))??{id:D,name:es(D,s==null?void 0:s.nodes,oe==null?void 0:oe.assignedNodeName)}}).sort((D,oe)=>D.name.localeCompare(oe.name));return[{value:"all",label:"All nodes"},{value:"unassigned",label:"Unassigned"},...A.map(D=>({value:D.name.toLowerCase(),label:D.name}))]},[pe,s==null?void 0:s.nodes]),ls=i.useMemo(()=>{const N=new Map;for(const A of(s==null?void 0:s.nodes)??[])N.set(A.id,A.name);for(const A of pe)A.assignedTo&&A.assignedNodeName&&!N.has(A.assignedTo)&&N.set(A.assignedTo,A.assignedNodeName);return N},[s==null?void 0:s.nodes,pe]),Bn=i.useMemo(()=>["all",...Array.from(new Set(a.map(N=>N.type))).sort()],[a]),hl=i.useMemo(()=>M==="all"?a:a.filter(N=>N.type===M),[a,M]),xl=Te.length>0&&Te.every(N=>Ke.has(N.id)),gl=Te.some(N=>Ke.has(N.id)),vl=cd(Te,Ke);i.useEffect(()=>{m!=null&&m.draftNewTask&&(K(!0),ie({route:m.returnRoute??"/",taskId:m.returnTaskId??null}))},[m]),i.useEffect(()=>{M!=="all"&&!Bn.includes(M)&&Z("all")},[M,Bn]),i.useEffect(()=>{ys(e,W)&&!y&&pe[0]&&w(pe[0].id)},[e,W,y,pe]),i.useEffect(()=>{var N;ys(e,W)&&(y&&h.some(A=>A.id===y)||w(((N=pe[0])==null?void 0:N.id)??null))},[e,W,y,pe,h]);const ne=od({routeTaskId:e,creatingTask:W,internalSelectedTaskId:y,sortedTaskIds:pe.map(N=>N.id)}),vt=i.useMemo(()=>h.find(N=>N.id===ne)??null,[h,ne]);i.useEffect(()=>{Mt.current=ne??null},[ne]);const Qt=i.useCallback(()=>{q(null),E([]),de([]),gt(null)},[]),ke=i.useCallback(async()=>{const N=ne;if(N)try{const A=await rc(N);if(Mt.current!==N)return;q(A),gt(null)}catch(A){if(Mt.current!==N)return;q(null),E([]),de([]),gt(A instanceof Error?A.message:"Failed to load task")}finally{Mt.current===N&&He(!1)}},[ne]),en=i.useCallback(async()=>{const N=ne;if(N)try{const A=await sc(N);if(Mt.current!==N)return;E(D=>Ed(D,A.logs)),de(D=>Td(D,A.logs))}catch{}},[ne]);i.useEffect(()=>{if(!ne){q(null),E([]),de([]),gt(null),He(!1);return}ge("transcript"),q(vt),E([]),de([]),gt(null),He(!0),ke(),en()},[ne,en,ke]),i.useEffect(()=>{var A;if(!ne||W||g||h.some(D=>D.id===ne))return;const N=((A=pe[0])==null?void 0:A.id)??null;w(N),Qt(),i.startTransition(()=>{n(N?`/tasks/${N}`:"/",{state:null})})},[ne,Qt,W,n,pe,h,g]),i.useEffect(()=>{vt&&q(N=>!N||N.id!==vt.id?N:{...N,...vt})},[vt]),i.useEffect(()=>{if(ne)return c("task",N=>{const A=N.data.taskId;if(!(typeof A!="string"||A!==ne)){if(N.type==="task.output"){const D=N.data.event;if(D){E(J=>Ad(J,D));const oe=Yt(D);oe&&de(J=>Rd(J,oe))}}N.type==="task.status"&&(ke(),en())}})},[c,ne,ke,en]),i.useEffect(()=>{var N;ue==="transcript"&&((N=is.current)==null||N.scrollIntoView({behavior:"smooth"}))},[fe,te,ue]);const z=Q??vt,bl=z!=null&&z.assignedTo?(s==null?void 0:s.nodes.find(N=>N.id===z.assignedTo))??null:null,Un=te.length>0,yl=z?Kp.has(z.agent):!1,Vn=(z==null?void 0:z.status)==="running",wl=z?Fe&&(jn.has(z.status)||Qi.has(z.status)):!1,Nl=!!(z&&Fe&&z.status==="failed"),jl=z?Fe&&Jp.has(z.status):!1,Sl=!!(z&&Fe),Wn=i.useMemo(()=>Nh(z,s,Un,!!Vn),[z,s,Un,Vn]),Cl=i.useMemo(()=>_d(fe),[fe]),zn=i.useMemo(()=>Pd([...fe,...te.map(N=>Kn(N.content,N.timestamp))]),[fe,te]),kl=i.useMemo(()=>{if(!z)return null;const N=pd(z);if(N.length>0)return Kn(N,new Date(z.createdAt).toISOString());if(zn.length>0)return null;const A=Ot(z.description||z.title);return A.length>0?Kn(A,new Date(z.createdAt).toISOString()):null},[z,zn]),Hn=i.useCallback(()=>{const N={route:e?`/tasks/${e}`:"/",taskId:ne};ie(N),K(!0),i.startTransition(()=>{n("/",{state:{draftNewTask:!0,returnRoute:N.route,returnTaskId:N.taskId}})})},[e,ne,n]),El=i.useCallback(()=>{var A;const N=(T==null?void 0:T.taskId)??((A=pe[0])==null?void 0:A.id)??null;K(!1),ie(null),w(N),i.startTransition(()=>{n((T==null?void 0:T.route)??"/",{state:null})})},[T,pe,n]),cs=i.useCallback(N=>{K(!1),ie(null),w(N),i.startTransition(()=>{n(`/tasks/${N}`,{state:null})})},[n]),Al=i.useCallback(N=>{K(!1),ie(null),x(A=>ad(A,N)),q(N),E([]),de([]),gt(null),He(!1),ge("transcript"),w(N.id),me(),i.startTransition(()=>{n(`/tasks/${N.id}`,{state:null})})},[me,n]),tn=i.useCallback(async N=>{if(!ne)return!1;const A=`local-${Date.now()}-${Math.random().toString(16).slice(2)}`;de(D=>[...D,{id:A,content:N,timestamp:new Date().toISOString()}]);try{return await oc(ne,N),ke(),!0}catch(D){return de(oe=>oe.filter(J=>J.id!==A)),ce.error(D instanceof Error?D.message:"Failed to send message"),!1}},[ne,ke]),Tl=i.useCallback(N=>{tn(N)},[tn]),Rl=i.useCallback(N=>tn(Tr(N,[])),[tn]),_l=i.useCallback(async()=>{if(z)try{await ac(z.id),ke(),me()}catch(N){ce.error(N instanceof Error?N.message:"Failed to cancel task")}},[z,ke,me]),Pl=i.useCallback(async()=>{if(z)try{await ic(z.id),ke(),me()}catch(N){ce.error(N instanceof Error?N.message:"Failed to retry task")}},[z,ke,me]),qe=i.useCallback((N,A=!1)=>{const D=dd(Te,N);return w(D),(A||!D)&&Qt(),i.startTransition(()=>{n(D?`/tasks/${D}`:"/",{state:null})}),D},[Qt,Te,n]),Dl=i.useCallback(async()=>{if(z)try{await lc(z.id),qe([z.id]),me()}catch(N){ce.error(N instanceof Error?N.message:"Failed to archive task")}},[z,me,qe]),Ml=i.useCallback(async()=>{if(z)try{await cc(z.id),qe([z.id],!0),me()}catch(N){ce.error(N instanceof Error?N.message:"Failed to delete task")}},[z,me,qe]),Il=i.useCallback((N,A)=>{it(D=>{const oe=new Set(D);return A?oe.add(N):oe.delete(N),oe})},[]),Ol=i.useCallback(N=>{if(!N){it(new Set);return}it(new Set(Te.map(A=>A.id)))},[Te]),Ll=i.useCallback(async()=>{const N=Array.from(Ke);if(N.length!==0)try{const{results:A}=await dc(N),D=A.filter(J=>!J.ok),oe=A.filter(J=>J.ok).map(J=>J.id);ne&&oe.includes(ne)&&qe(oe),D.length>0?ce.error(`Failed to archive ${D.length} task(s): ${D.map(J=>J.error??J.id).join(", ")}`):ce.success(`Archived ${oe.length} task(s)`),it(new Set(D.map(J=>J.id))),me()}catch(A){ce.error(A instanceof Error?A.message:"Failed to archive tasks")}},[ne,me,qe,Ke]),$l=i.useCallback(async()=>{const N=Array.from(Ke);if(N.length!==0)try{const{results:A}=await uc(N),D=A.filter(J=>!J.ok),oe=A.filter(J=>J.ok).map(J=>J.id);ne&&oe.includes(ne)&&qe(oe,!0),D.length>0?ce.error(`Failed to delete ${D.length} task(s): ${D.map(J=>J.error??J.id).join(", ")}`):ce.success(`Deleted ${oe.length} task(s)`),it(new Set(D.map(J=>J.id))),me()}catch(A){ce.error(A instanceof Error?A.message:"Failed to delete tasks")}},[ne,me,qe,Ke]),Fl=i.useCallback(async()=>{rs(!0);try{await fc(),d()}catch(N){ce.error(N instanceof Error?N.message:"Failed to trigger election")}finally{rs(!1)}},[d]),Bl=i.useCallback(async()=>{ss(!0);try{await mc(),d()}catch(N){ce.error(N instanceof Error?N.message:"Failed to promote node")}finally{ss(!1)}},[d]),Ul=i.useCallback(async()=>{os(!0);try{await pc(),ce.success("This node left the remote cluster and is leading itself again."),me(),ke(),d()}catch(N){ce.error(N instanceof Error?N.message:"Failed to leave cluster")}finally{os(!1)}},[ke,me,d]),Vl=i.useCallback(async N=>{var xs;const A=!Ar(N),D=N.id===((xs=s==null?void 0:s.self)==null?void 0:xs.id),oe=D?(o==null?void 0:o.transportType)??N.transportType:N.transportType,J=D&&!A&&At(oe);as(N.id);try{J?await hc("direct"):await xc(N.id,A),ce.success(A?`Enabled remote access on ${N.name}`:`Disabled remote access on ${N.name}`),d()}catch(gs){ce.error(gs instanceof Error?gs.message:"Failed to update remote access")}finally{as(null)}},[(hs=s==null?void 0:s.self)==null?void 0:hs.id,d,o==null?void 0:o.transportType]),ds=i.useCallback(()=>{var N,A;if((A=(N=globalThis.window)==null?void 0:N.matchMedia("(min-width: 1024px)"))!=null&&A.matches){$(D=>!D);return}_(D=>!D)},[]),us={toolbarTasks:Te,activeTaskId:ne,activeTask:z,tasksLoading:g,tasksError:v,isLeader:Fe,scope:j,agentFilter:C,nodeFilter:R,agentOptions:ml,nodeOptions:pl,nodeNameById:ls,searchQuery:F,selectedTaskIds:Ke,allVisibleTasksSelected:xl,someVisibleTasksSelected:gl,canBatchArchive:vl,onSearchChange:B,onScopeChange:k,onAgentFilterChange:S,onNodeFilterChange:O,onToggleTaskSelected:Il,onToggleAllVisibleTasks:Ol,canArchive:jl,canDelete:Sl,onArchive:Dl,onDelete:Ml,onBatchArchive:Ll,onBatchDelete:$l,onCreateTask:Hn,onSelectTask:cs,onClose:ds},fs={cluster:s,systemInfo:o,nodeNameById:ls,nodeBlockingTaskCounts:fl,eventTypeFilter:M,onEventTypeFilterChange:Z,eventTypeOptions:Bn,filteredEvents:hl,sseConnected:l,clusterLoading:f,clusterError:u,electionPending:ll,onTriggerElection:Fl,promotePending:cl,onPromote:Bl,onAddNode:()=>le(!0),leavePending:dl,onLeaveCluster:Ul,onToggleNodeDevTunnel:Vl,devTunnelNodeId:ul,onClose:()=>I(!1)};return r.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden pb-2",children:[r.jsxs("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[r.jsx("div",{className:U("hidden lg:block lg:shrink-0 lg:transition-all lg:duration-300",L?"lg:mr-4 lg:w-[22rem]":"lg:w-0 lg:overflow-hidden"),children:L&&r.jsx(Qs,{...us})}),r.jsx("section",{className:"min-h-0 min-w-0 flex-1",children:r.jsx(fh,{onToggleTasks:ds,desktopTasksOpen:L,mobileTasksPanelOpen:H,operationsOpen:P,onToggleOperations:()=>I(N=>!N),cluster:s,sseConnected:l,activeTab:ue,setActiveTab:ge,creatingTask:W,activeTask:z,assignedNode:bl,taskLoading:Ce,taskError:xt,displayEvents:zn,hasUserMessageInLogs:Cl,initialPrompt:kl,supportsFollowUp:yl,taskUnavailable:Wn.taskUnavailable,chatDisabled:Wn.chatDisabled,chatDisabledReason:Wn.chatDisabledReason,questionBypassEnabled:he,isRunning:!!Vn,hasPendingFollowUp:Un,canCancel:!!wl,canRetry:!!Nl,onRetry:Pl,onCancel:_l,onStartCreateTask:Hn,onCancelCreateTask:El,onCreateTask:Al,onSendMessage:Tl,onQuestionBypassChange:ee,onSubmitQuestionResponse:Rl,messagesEndRef:is})}),r.jsx("div",{className:U("hidden xl:block xl:shrink-0 xl:transition-all xl:duration-300",P?"xl:ml-4 xl:w-[24rem]":"xl:w-0 xl:overflow-hidden"),children:P&&r.jsx(Js,{...fs})})]}),P&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Close operations panel",onClick:()=>I(!1),className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm xl:hidden"}),r.jsx("div",{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(Js,{...fs})})]}),H&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Close task list",onClick:()=>_(!1),className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm lg:hidden"}),r.jsx("div",{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(Qs,{...us,onCreateTask:()=>{_(!1),Hn()},onSelectTask:N=>{_(!1),cs(N)},onClose:()=>_(!1)})})]}),r.jsx(cf,{open:xe,onOpenChange:le,children:r.jsx(xf,{onAdded:()=>{le(!1),d()}})})]})}const Ph=Object.freeze(Object.defineProperty({__proto__:null,DashboardPage:Th},Symbol.toStringTag,{value:"Module"}));export{Gt as C,cf as D,io as E,Xo as a,Qo as b,_h as c,Ve as d,Ph as e};
|