@damn-dev/cli 0.9.13 → 0.9.15
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/package.json +1 -1
- package/runtime/apps/backend/dist/server.cjs +149 -6
- package/runtime/apps/frontend/dist/assets/index-BsJnJU_r.css +1 -0
- package/runtime/apps/frontend/dist/assets/{index-B5J-qv0E.js → index-C6ACsiE5.js} +5 -5
- package/runtime/apps/frontend/dist/index.html +2 -2
- package/runtime/apps/frontend/dist/sw.js +1 -1
- package/runtime/apps/frontend/dist/assets/index-CRgB-eIU.css +0 -1
|
@@ -57,7 +57,7 @@ Please change the parent <Route path="${w}"> to <Route path="${w==="/"?"*":`${w}
|
|
|
57
57
|
`)},KF=function(){var e=parseInt(document.body.getAttribute(Md)||"0",10);return isFinite(e)?e:0},$oe=function(){y.useEffect(function(){return document.body.setAttribute(Md,(KF()+1).toString()),function(){var e=KF()-1;e<=0?document.body.removeAttribute(Md):document.body.setAttribute(Md,e.toString())}},[])},Voe=function(e){var t=e.noRelative,n=e.noImportant,s=e.gapMode,i=s===void 0?"margin":s;$oe();var a=y.useMemo(function(){return Loe(i)},[i]);return y.createElement(Boe,{styles:zoe(a,!t,i,n?"":"!important")})},W2=!1;if(typeof window<"u")try{var Ag=Object.defineProperty({},"passive",{get:function(){return W2=!0,!0}});window.addEventListener("test",Ag,Ag),window.removeEventListener("test",Ag,Ag)}catch{W2=!1}var ld=W2?{passive:!1}:!1,Uoe=function(e){return e.tagName==="TEXTAREA"},GL=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Uoe(e)&&n[t]==="visible")},Hoe=function(e){return GL(e,"overflowY")},Woe=function(e){return GL(e,"overflowX")},YF=function(e,t){var n=t.ownerDocument,s=t;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var i=KL(e,s);if(i){var a=YL(e,s),o=a[1],l=a[2];if(o>l)return!0}s=s.parentNode}while(s&&s!==n.body);return!1},qoe=function(e){var t=e.scrollTop,n=e.scrollHeight,s=e.clientHeight;return[t,n,s]},Goe=function(e){var t=e.scrollLeft,n=e.scrollWidth,s=e.clientWidth;return[t,n,s]},KL=function(e,t){return e==="v"?Hoe(t):Woe(t)},YL=function(e,t){return e==="v"?qoe(t):Goe(t)},Koe=function(e,t){return e==="h"&&t==="rtl"?-1:1},Yoe=function(e,t,n,s,i){var a=Koe(e,window.getComputedStyle(t).direction),o=a*s,l=n.target,c=t.contains(l),d=!1,f=o>0,p=0,m=0;do{if(!l)break;var g=YL(e,l),b=g[0],_=g[1],w=g[2],A=_-w-a*b;(b||A)&&KL(e,l)&&(p+=A,m+=b);var S=l.parentNode;l=S&&S.nodeType===Node.DOCUMENT_FRAGMENT_NODE?S.host:S}while(!c&&l!==document.body||c&&(t.contains(l)||t===l));return(f&&Math.abs(p)<1||!f&&Math.abs(m)<1)&&(d=!0),d},Sg=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},QF=function(e){return[e.deltaX,e.deltaY]},XF=function(e){return e&&"current"in e?e.current:e},Qoe=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Xoe=function(e){return`
|
|
58
58
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
59
59
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
60
|
-
`)},Joe=0,cd=[];function Zoe(e){var t=y.useRef([]),n=y.useRef([0,0]),s=y.useRef(),i=y.useState(Joe++)[0],a=y.useState(qL)[0],o=y.useRef(e);y.useEffect(function(){o.current=e},[e]),y.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var _=yoe([e.lockRef.current],(e.shards||[]).map(XF),!0).filter(Boolean);return _.forEach(function(w){return w.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),_.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var l=y.useCallback(function(_,w){if("touches"in _&&_.touches.length===2||_.type==="wheel"&&_.ctrlKey)return!o.current.allowPinchZoom;var A=Sg(_),S=n.current,C="deltaX"in _?_.deltaX:S[0]-A[0],E="deltaY"in _?_.deltaY:S[1]-A[1],k,T=_.target,F=Math.abs(C)>Math.abs(E)?"h":"v";if("touches"in _&&F==="h"&&T.type==="range")return!1;var M=window.getSelection(),I=M&&M.anchorNode,R=I?I===T||I.contains(T):!1;if(R)return!1;var H=YF(F,T);if(!H)return!0;if(H?k=F:(k=F==="v"?"h":"v",H=YF(F,T)),!H)return!1;if(!s.current&&"changedTouches"in _&&(C||E)&&(s.current=k),!k)return!0;var V=s.current||k;return Yoe(V,w,_,V==="h"?C:E)},[]),c=y.useCallback(function(_){var w=_;if(!(!cd.length||cd[cd.length-1]!==a)){var A="deltaY"in w?QF(w):Sg(w),S=t.current.filter(function(k){return k.name===w.type&&(k.target===w.target||w.target===k.shadowParent)&&Qoe(k.delta,A)})[0];if(S&&S.should){w.cancelable&&w.preventDefault();return}if(!S){var C=(o.current.shards||[]).map(XF).filter(Boolean).filter(function(k){return k.contains(w.target)}),E=C.length>0?l(w,C[0]):!o.current.noIsolation;E&&w.cancelable&&w.preventDefault()}}},[]),d=y.useCallback(function(_,w,A,S){var C={name:_,delta:w,target:A,should:S,shadowParent:ele(A)};t.current.push(C),setTimeout(function(){t.current=t.current.filter(function(E){return E!==C})},1)},[]),f=y.useCallback(function(_){n.current=Sg(_),s.current=void 0},[]),p=y.useCallback(function(_){d(_.type,QF(_),_.target,l(_,e.lockRef.current))},[]),m=y.useCallback(function(_){d(_.type,Sg(_),_.target,l(_,e.lockRef.current))},[]);y.useEffect(function(){return cd.push(a),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",c,ld),document.addEventListener("touchmove",c,ld),document.addEventListener("touchstart",f,ld),function(){cd=cd.filter(function(_){return _!==a}),document.removeEventListener("wheel",c,ld),document.removeEventListener("touchmove",c,ld),document.removeEventListener("touchstart",f,ld)}},[]);var g=e.removeScrollBar,b=e.inert;return y.createElement(y.Fragment,null,b?y.createElement(a,{styles:Xoe(i)}):null,g?y.createElement(Voe,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ele(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const tle=Eoe(WL,Zoe);var Sm=y.forwardRef(function(e,t){return y.createElement(wv,Fa({},e,{ref:t,sideCar:tle}))});Sm.classNames=wv.classNames;var nle=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},ud=new WeakMap,Cg=new WeakMap,jg={},Nw=0,QL=function(e){return e&&(e.host||QL(e.parentNode))},sle=function(e,t){return t.map(function(n){if(e.contains(n))return n;var s=QL(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})},ile=function(e,t,n,s){var i=sle(t,Array.isArray(e)?e:[e]);jg[n]||(jg[n]=new WeakMap);var a=jg[n],o=[],l=new Set,c=new Set(i),d=function(p){!p||l.has(p)||(l.add(p),d(p.parentNode))};i.forEach(d);var f=function(p){!p||c.has(p)||Array.prototype.forEach.call(p.children,function(m){if(l.has(m))f(m);else try{var g=m.getAttribute(s),b=g!==null&&g!=="false",_=(ud.get(m)||0)+1,w=(a.get(m)||0)+1;ud.set(m,_),a.set(m,w),o.push(m),_===1&&b&&Cg.set(m,!0),w===1&&m.setAttribute(n,"true"),b||m.setAttribute(s,"true")}catch(A){console.error("aria-hidden: cannot operate on ",m,A)}})};return f(t),l.clear(),Nw++,function(){o.forEach(function(p){var m=ud.get(p)-1,g=a.get(p)-1;ud.set(p,m),a.set(p,g),m||(Cg.has(p)||p.removeAttribute(s),Cg.delete(p)),g||p.removeAttribute(n)}),Nw--,Nw||(ud=new WeakMap,ud=new WeakMap,Cg=new WeakMap,jg={})}},Av=function(e,t,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(e)?e:[e]),i=nle(e);return i?(s.push.apply(s,Array.from(i.querySelectorAll("[aria-live], script"))),ile(s,i,n,"aria-hidden")):function(){return null}},Sv="Dialog",[XL]=Wa(Sv),[rle,ha]=XL(Sv),JL=e=>{const{__scopeDialog:t,children:n,open:s,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,l=y.useRef(null),c=y.useRef(null),[d,f]=Fo({prop:s,defaultProp:i??!1,onChange:a,caller:Sv});return r.jsx(rle,{scope:t,triggerRef:l,contentRef:c,contentId:Zi(),titleId:Zi(),descriptionId:Zi(),open:d,onOpenChange:f,onOpenToggle:y.useCallback(()=>f(p=>!p),[f]),modal:o,children:n})};JL.displayName=Sv;var ZL="DialogTrigger",e9=y.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,i=ha(ZL,n),a=At(t,i.triggerRef);return r.jsx(lt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":W5(i.open),...s,ref:a,onClick:Oe(e.onClick,i.onOpenToggle)})});e9.displayName=ZL;var U5="DialogPortal",[ale,t9]=XL(U5,{forceMount:void 0}),n9=e=>{const{__scopeDialog:t,forceMount:n,children:s,container:i}=e,a=ha(U5,t);return r.jsx(ale,{scope:t,forceMount:n,children:y.Children.map(s,o=>r.jsx(zr,{present:n||a.open,children:r.jsx(hh,{asChild:!0,container:i,children:o})}))})};n9.displayName=U5;var l0="DialogOverlay",s9=y.forwardRef((e,t)=>{const n=t9(l0,e.__scopeDialog),{forceMount:s=n.forceMount,...i}=e,a=ha(l0,e.__scopeDialog);return a.modal?r.jsx(zr,{present:s||a.open,children:r.jsx(lle,{...i,ref:t})}):null});s9.displayName=l0;var ole=iu("DialogOverlay.RemoveScroll"),lle=y.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,i=ha(l0,n);return r.jsx(Sm,{as:ole,allowPinchZoom:!0,shards:[i.contentRef],children:r.jsx(lt.div,{"data-state":W5(i.open),...s,ref:t,style:{pointerEvents:"auto",...s.style}})})}),ru="DialogContent",i9=y.forwardRef((e,t)=>{const n=t9(ru,e.__scopeDialog),{forceMount:s=n.forceMount,...i}=e,a=ha(ru,e.__scopeDialog);return r.jsx(zr,{present:s||a.open,children:a.modal?r.jsx(cle,{...i,ref:t}):r.jsx(ule,{...i,ref:t})})});i9.displayName=ru;var cle=y.forwardRef((e,t)=>{const n=ha(ru,e.__scopeDialog),s=y.useRef(null),i=At(t,n.contentRef,s);return y.useEffect(()=>{const a=s.current;if(a)return Av(a)},[]),r.jsx(r9,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Oe(e.onCloseAutoFocus,a=>{a.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Oe(e.onPointerDownOutside,a=>{const o=a.detail.originalEvent,l=o.button===0&&o.ctrlKey===!0;(o.button===2||l)&&a.preventDefault()}),onFocusOutside:Oe(e.onFocusOutside,a=>a.preventDefault())})}),ule=y.forwardRef((e,t)=>{const n=ha(ru,e.__scopeDialog),s=y.useRef(!1),i=y.useRef(!1);return r.jsx(r9,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{e.onCloseAutoFocus?.(a),a.defaultPrevented||(s.current||n.triggerRef.current?.focus(),a.preventDefault()),s.current=!1,i.current=!1},onInteractOutside:a=>{e.onInteractOutside?.(a),a.defaultPrevented||(s.current=!0,a.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=a.target;n.triggerRef.current?.contains(o)&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&i.current&&a.preventDefault()}})}),r9=y.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:s,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,l=ha(ru,n),c=y.useRef(null),d=At(t,c);return _v(),r.jsxs(r.Fragment,{children:[r.jsx(Am,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:i,onUnmountAutoFocus:a,children:r.jsx(dh,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":W5(l.open),...o,ref:d,onDismiss:()=>l.onOpenChange(!1)})}),r.jsxs(r.Fragment,{children:[r.jsx(hle,{titleId:l.titleId}),r.jsx(ple,{contentRef:c,descriptionId:l.descriptionId})]})]})}),H5="DialogTitle",a9=y.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,i=ha(H5,n);return r.jsx(lt.h2,{id:i.titleId,...s,ref:t})});a9.displayName=H5;var o9="DialogDescription",dle=y.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,i=ha(o9,n);return r.jsx(lt.p,{id:i.descriptionId,...s,ref:t})});dle.displayName=o9;var l9="DialogClose",c9=y.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,i=ha(l9,n);return r.jsx(lt.button,{type:"button",...s,ref:t,onClick:Oe(e.onClick,()=>i.onOpenChange(!1))})});c9.displayName=l9;function W5(e){return e?"open":"closed"}var u9="DialogTitleWarning",[
|
|
60
|
+
`)},Joe=0,cd=[];function Zoe(e){var t=y.useRef([]),n=y.useRef([0,0]),s=y.useRef(),i=y.useState(Joe++)[0],a=y.useState(qL)[0],o=y.useRef(e);y.useEffect(function(){o.current=e},[e]),y.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var _=yoe([e.lockRef.current],(e.shards||[]).map(XF),!0).filter(Boolean);return _.forEach(function(w){return w.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),_.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var l=y.useCallback(function(_,w){if("touches"in _&&_.touches.length===2||_.type==="wheel"&&_.ctrlKey)return!o.current.allowPinchZoom;var A=Sg(_),S=n.current,C="deltaX"in _?_.deltaX:S[0]-A[0],E="deltaY"in _?_.deltaY:S[1]-A[1],k,T=_.target,F=Math.abs(C)>Math.abs(E)?"h":"v";if("touches"in _&&F==="h"&&T.type==="range")return!1;var M=window.getSelection(),I=M&&M.anchorNode,R=I?I===T||I.contains(T):!1;if(R)return!1;var H=YF(F,T);if(!H)return!0;if(H?k=F:(k=F==="v"?"h":"v",H=YF(F,T)),!H)return!1;if(!s.current&&"changedTouches"in _&&(C||E)&&(s.current=k),!k)return!0;var V=s.current||k;return Yoe(V,w,_,V==="h"?C:E)},[]),c=y.useCallback(function(_){var w=_;if(!(!cd.length||cd[cd.length-1]!==a)){var A="deltaY"in w?QF(w):Sg(w),S=t.current.filter(function(k){return k.name===w.type&&(k.target===w.target||w.target===k.shadowParent)&&Qoe(k.delta,A)})[0];if(S&&S.should){w.cancelable&&w.preventDefault();return}if(!S){var C=(o.current.shards||[]).map(XF).filter(Boolean).filter(function(k){return k.contains(w.target)}),E=C.length>0?l(w,C[0]):!o.current.noIsolation;E&&w.cancelable&&w.preventDefault()}}},[]),d=y.useCallback(function(_,w,A,S){var C={name:_,delta:w,target:A,should:S,shadowParent:ele(A)};t.current.push(C),setTimeout(function(){t.current=t.current.filter(function(E){return E!==C})},1)},[]),f=y.useCallback(function(_){n.current=Sg(_),s.current=void 0},[]),p=y.useCallback(function(_){d(_.type,QF(_),_.target,l(_,e.lockRef.current))},[]),m=y.useCallback(function(_){d(_.type,Sg(_),_.target,l(_,e.lockRef.current))},[]);y.useEffect(function(){return cd.push(a),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",c,ld),document.addEventListener("touchmove",c,ld),document.addEventListener("touchstart",f,ld),function(){cd=cd.filter(function(_){return _!==a}),document.removeEventListener("wheel",c,ld),document.removeEventListener("touchmove",c,ld),document.removeEventListener("touchstart",f,ld)}},[]);var g=e.removeScrollBar,b=e.inert;return y.createElement(y.Fragment,null,b?y.createElement(a,{styles:Xoe(i)}):null,g?y.createElement(Voe,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ele(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const tle=Eoe(WL,Zoe);var Sm=y.forwardRef(function(e,t){return y.createElement(wv,Fa({},e,{ref:t,sideCar:tle}))});Sm.classNames=wv.classNames;var nle=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},ud=new WeakMap,Cg=new WeakMap,jg={},Nw=0,QL=function(e){return e&&(e.host||QL(e.parentNode))},sle=function(e,t){return t.map(function(n){if(e.contains(n))return n;var s=QL(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})},ile=function(e,t,n,s){var i=sle(t,Array.isArray(e)?e:[e]);jg[n]||(jg[n]=new WeakMap);var a=jg[n],o=[],l=new Set,c=new Set(i),d=function(p){!p||l.has(p)||(l.add(p),d(p.parentNode))};i.forEach(d);var f=function(p){!p||c.has(p)||Array.prototype.forEach.call(p.children,function(m){if(l.has(m))f(m);else try{var g=m.getAttribute(s),b=g!==null&&g!=="false",_=(ud.get(m)||0)+1,w=(a.get(m)||0)+1;ud.set(m,_),a.set(m,w),o.push(m),_===1&&b&&Cg.set(m,!0),w===1&&m.setAttribute(n,"true"),b||m.setAttribute(s,"true")}catch(A){console.error("aria-hidden: cannot operate on ",m,A)}})};return f(t),l.clear(),Nw++,function(){o.forEach(function(p){var m=ud.get(p)-1,g=a.get(p)-1;ud.set(p,m),a.set(p,g),m||(Cg.has(p)||p.removeAttribute(s),Cg.delete(p)),g||p.removeAttribute(n)}),Nw--,Nw||(ud=new WeakMap,ud=new WeakMap,Cg=new WeakMap,jg={})}},Av=function(e,t,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(e)?e:[e]),i=nle(e);return i?(s.push.apply(s,Array.from(i.querySelectorAll("[aria-live], script"))),ile(s,i,n,"aria-hidden")):function(){return null}},Sv="Dialog",[XL]=Wa(Sv),[rle,ha]=XL(Sv),JL=e=>{const{__scopeDialog:t,children:n,open:s,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,l=y.useRef(null),c=y.useRef(null),[d,f]=Fo({prop:s,defaultProp:i??!1,onChange:a,caller:Sv});return r.jsx(rle,{scope:t,triggerRef:l,contentRef:c,contentId:Zi(),titleId:Zi(),descriptionId:Zi(),open:d,onOpenChange:f,onOpenToggle:y.useCallback(()=>f(p=>!p),[f]),modal:o,children:n})};JL.displayName=Sv;var ZL="DialogTrigger",e9=y.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,i=ha(ZL,n),a=At(t,i.triggerRef);return r.jsx(lt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":W5(i.open),...s,ref:a,onClick:Oe(e.onClick,i.onOpenToggle)})});e9.displayName=ZL;var U5="DialogPortal",[ale,t9]=XL(U5,{forceMount:void 0}),n9=e=>{const{__scopeDialog:t,forceMount:n,children:s,container:i}=e,a=ha(U5,t);return r.jsx(ale,{scope:t,forceMount:n,children:y.Children.map(s,o=>r.jsx(zr,{present:n||a.open,children:r.jsx(hh,{asChild:!0,container:i,children:o})}))})};n9.displayName=U5;var l0="DialogOverlay",s9=y.forwardRef((e,t)=>{const n=t9(l0,e.__scopeDialog),{forceMount:s=n.forceMount,...i}=e,a=ha(l0,e.__scopeDialog);return a.modal?r.jsx(zr,{present:s||a.open,children:r.jsx(lle,{...i,ref:t})}):null});s9.displayName=l0;var ole=iu("DialogOverlay.RemoveScroll"),lle=y.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,i=ha(l0,n);return r.jsx(Sm,{as:ole,allowPinchZoom:!0,shards:[i.contentRef],children:r.jsx(lt.div,{"data-state":W5(i.open),...s,ref:t,style:{pointerEvents:"auto",...s.style}})})}),ru="DialogContent",i9=y.forwardRef((e,t)=>{const n=t9(ru,e.__scopeDialog),{forceMount:s=n.forceMount,...i}=e,a=ha(ru,e.__scopeDialog);return r.jsx(zr,{present:s||a.open,children:a.modal?r.jsx(cle,{...i,ref:t}):r.jsx(ule,{...i,ref:t})})});i9.displayName=ru;var cle=y.forwardRef((e,t)=>{const n=ha(ru,e.__scopeDialog),s=y.useRef(null),i=At(t,n.contentRef,s);return y.useEffect(()=>{const a=s.current;if(a)return Av(a)},[]),r.jsx(r9,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Oe(e.onCloseAutoFocus,a=>{a.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Oe(e.onPointerDownOutside,a=>{const o=a.detail.originalEvent,l=o.button===0&&o.ctrlKey===!0;(o.button===2||l)&&a.preventDefault()}),onFocusOutside:Oe(e.onFocusOutside,a=>a.preventDefault())})}),ule=y.forwardRef((e,t)=>{const n=ha(ru,e.__scopeDialog),s=y.useRef(!1),i=y.useRef(!1);return r.jsx(r9,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{e.onCloseAutoFocus?.(a),a.defaultPrevented||(s.current||n.triggerRef.current?.focus(),a.preventDefault()),s.current=!1,i.current=!1},onInteractOutside:a=>{e.onInteractOutside?.(a),a.defaultPrevented||(s.current=!0,a.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=a.target;n.triggerRef.current?.contains(o)&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&i.current&&a.preventDefault()}})}),r9=y.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:s,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,l=ha(ru,n),c=y.useRef(null),d=At(t,c);return _v(),r.jsxs(r.Fragment,{children:[r.jsx(Am,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:i,onUnmountAutoFocus:a,children:r.jsx(dh,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":W5(l.open),...o,ref:d,onDismiss:()=>l.onOpenChange(!1)})}),r.jsxs(r.Fragment,{children:[r.jsx(hle,{titleId:l.titleId}),r.jsx(ple,{contentRef:c,descriptionId:l.descriptionId})]})]})}),H5="DialogTitle",a9=y.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,i=ha(H5,n);return r.jsx(lt.h2,{id:i.titleId,...s,ref:t})});a9.displayName=H5;var o9="DialogDescription",dle=y.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,i=ha(o9,n);return r.jsx(lt.p,{id:i.descriptionId,...s,ref:t})});dle.displayName=o9;var l9="DialogClose",c9=y.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,i=ha(l9,n);return r.jsx(lt.button,{type:"button",...s,ref:t,onClick:Oe(e.onClick,()=>i.onOpenChange(!1))})});c9.displayName=l9;function W5(e){return e?"open":"closed"}var u9="DialogTitleWarning",[L8e,d9]=Vae(u9,{contentName:ru,titleName:H5,docsSlug:"dialog"}),hle=({titleId:e})=>{const t=d9(u9),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
61
61
|
|
|
62
62
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
63
63
|
|
|
@@ -128,7 +128,7 @@ Your target audience...
|
|
|
128
128
|
`))+1))}const o="#".repeat(i),l=n.enter("headingAtx"),c=n.enter("phrasing");a.move(o+" ");let d=n.containerPhrasing(e,{before:"# ",after:`
|
|
129
129
|
`,...a.current()});return/^[\t ]/.test(d)&&(d=Bp(d.charCodeAt(0))+d.slice(1)),d=d?o+" "+d:o,n.options.closeAtx&&(d+=" "+o),c(),l(),d}n$.peek=bve;function n$(e){return e.value||""}function bve(){return"<"}s$.peek=vve;function s$(e,t,n,s){const i=Rj(n),a=i==='"'?"Quote":"Apostrophe",o=n.enter("image");let l=n.enter("label");const c=n.createTracker(s);let d=c.move("![");return d+=c.move(n.safe(e.alt,{before:d,after:"]",...c.current()})),d+=c.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),d+=c.move("<"),d+=c.move(n.safe(e.url,{before:d,after:">",...c.current()})),d+=c.move(">")):(l=n.enter("destinationRaw"),d+=c.move(n.safe(e.url,{before:d,after:e.title?" ":")",...c.current()}))),l(),e.title&&(l=n.enter(`title${a}`),d+=c.move(" "+i),d+=c.move(n.safe(e.title,{before:d,after:i,...c.current()})),d+=c.move(i),l()),d+=c.move(")"),o(),d}function vve(){return"!"}i$.peek=yve;function i$(e,t,n,s){const i=e.referenceType,a=n.enter("imageReference");let o=n.enter("label");const l=n.createTracker(s);let c=l.move("![");const d=n.safe(e.alt,{before:c,after:"]",...l.current()});c+=l.move(d+"]["),o();const f=n.stack;n.stack=[],o=n.enter("reference");const p=n.safe(n.associationId(e),{before:c,after:"]",...l.current()});return o(),n.stack=f,a(),i==="full"||!d||d!==p?c+=l.move(p+"]"):i==="shortcut"?c=c.slice(0,-1):c+=l.move("]"),c}function yve(){return"!"}r$.peek=_ve;function r$(e,t,n){let s=e.value||"",i="`",a=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(s);)i+="`";for(/[^ \r\n]/.test(s)&&(/^[ \r\n]/.test(s)&&/[ \r\n]$/.test(s)||/^`|`$/.test(s))&&(s=" "+s+" ");++a<n.unsafe.length;){const o=n.unsafe[a],l=n.compilePattern(o);let c;if(o.atBreak)for(;c=l.exec(s);){let d=c.index;s.charCodeAt(d)===10&&s.charCodeAt(d-1)===13&&d--,s=s.slice(0,d)+" "+s.slice(c.index+1)}}return i+s+i}function _ve(){return"`"}function a$(e,t){const n=Sj(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}o$.peek=wve;function o$(e,t,n,s){const i=Rj(n),a=i==='"'?"Quote":"Apostrophe",o=n.createTracker(s);let l,c;if(a$(e,n)){const f=n.stack;n.stack=[],l=n.enter("autolink");let p=o.move("<");return p+=o.move(n.containerPhrasing(e,{before:p,after:">",...o.current()})),p+=o.move(">"),l(),n.stack=f,p}l=n.enter("link"),c=n.enter("label");let d=o.move("[");return d+=o.move(n.containerPhrasing(e,{before:d,after:"](",...o.current()})),d+=o.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),d+=o.move("<"),d+=o.move(n.safe(e.url,{before:d,after:">",...o.current()})),d+=o.move(">")):(c=n.enter("destinationRaw"),d+=o.move(n.safe(e.url,{before:d,after:e.title?" ":")",...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),d+=o.move(" "+i),d+=o.move(n.safe(e.title,{before:d,after:i,...o.current()})),d+=o.move(i),c()),d+=o.move(")"),l(),d}function wve(e,t,n){return a$(e,n)?"<":"["}l$.peek=Ave;function l$(e,t,n,s){const i=e.referenceType,a=n.enter("linkReference");let o=n.enter("label");const l=n.createTracker(s);let c=l.move("[");const d=n.containerPhrasing(e,{before:c,after:"]",...l.current()});c+=l.move(d+"]["),o();const f=n.stack;n.stack=[],o=n.enter("reference");const p=n.safe(n.associationId(e),{before:c,after:"]",...l.current()});return o(),n.stack=f,a(),i==="full"||!d||d!==p?c+=l.move(p+"]"):i==="shortcut"?c=c.slice(0,-1):c+=l.move("]"),c}function Ave(){return"["}function Dj(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Sve(e){const t=Dj(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Cve(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function c$(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function jve(e,t,n,s){const i=n.enter("list"),a=n.bulletCurrent;let o=e.ordered?Cve(n):Dj(n);const l=e.ordered?o==="."?")":".":Sve(n);let c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){const f=e.children?e.children[0]:void 0;if((o==="*"||o==="-")&&f&&(!f.children||!f.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),c$(n)===o&&f){let p=-1;for(;++p<e.children.length;){const m=e.children[p];if(m&&m.type==="listItem"&&m.children&&m.children[0]&&m.children[0].type==="thematicBreak"){c=!0;break}}}}c&&(o=l),n.bulletCurrent=o;const d=n.containerFlow(e,s);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),d}function Nve(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function kve(e,t,n,s){const i=Nve(n);let a=n.bulletCurrent||Dj(n);t&&t.type==="list"&&t.ordered&&(a=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);const l=n.createTracker(s);l.move(a+" ".repeat(o-a.length)),l.shift(o);const c=n.enter("listItem"),d=n.indentLines(n.containerFlow(e,l.current()),f);return c(),d;function f(p,m,g){return m?(g?"":" ".repeat(o))+p:(g?a:a+" ".repeat(o-a.length))+p}}function Eve(e,t,n,s){const i=n.enter("paragraph"),a=n.enter("phrasing"),o=n.containerPhrasing(e,s);return a(),i(),o}const Fve=Wv(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Tve(e,t,n,s){return(e.children.some(function(o){return Fve(o)})?n.containerPhrasing:n.containerFlow).call(n,e,s)}function Mve(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}u$.peek=Rve;function u$(e,t,n,s){const i=Mve(n),a=n.enter("strong"),o=n.createTracker(s),l=o.move(i+i);let c=o.move(n.containerPhrasing(e,{after:i,before:l,...o.current()}));const d=c.charCodeAt(0),f=C0(s.before.charCodeAt(s.before.length-1),d,i);f.inside&&(c=Bp(d)+c.slice(1));const p=c.charCodeAt(c.length-1),m=C0(s.after.charCodeAt(0),p,i);m.inside&&(c=c.slice(0,-1)+Bp(p));const g=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:m.outside,before:f.outside},l+c+g}function Rve(e,t,n){return n.options.strong||"*"}function Dve(e,t,n,s){return n.safe(e.value,s)}function Ove(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function Pve(e,t,n){const s=(c$(n)+(n.options.ruleSpaces?" ":"")).repeat(Ove(n));return n.options.ruleSpaces?s.slice(0,-1):s}const d$={blockquote:rve,break:sR,code:dve,definition:fve,emphasis:t$,hardBreak:sR,heading:gve,html:n$,image:s$,imageReference:i$,inlineCode:r$,link:o$,linkReference:l$,list:jve,listItem:kve,paragraph:Eve,root:Tve,strong:u$,text:Dve,thematicBreak:Pve};function Ive(){return{enter:{table:Lve,tableData:iR,tableHeader:iR,tableRow:zve},exit:{codeText:$ve,table:Bve,tableData:xA,tableHeader:xA,tableRow:xA}}}function Lve(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function Bve(e){this.exit(e),this.data.inTable=void 0}function zve(e){this.enter({type:"tableRow",children:[]},e)}function xA(e){this.exit(e)}function iR(e){this.enter({type:"tableCell",children:[]},e)}function $ve(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Vve));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Vve(e,t){return t==="|"?t:e}function Uve(e){const t=e||{},n=t.tableCellPadding,s=t.tablePipeAlign,i=t.stringLength,a=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
130
130
|
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:m,table:o,tableCell:c,tableRow:l}};function o(g,b,_,w){return d(f(g,_,w),g.align)}function l(g,b,_,w){const A=p(g,_,w),S=d([A]);return S.slice(0,S.indexOf(`
|
|
131
|
-
`))}function c(g,b,_,w){const A=_.enter("tableCell"),S=_.enter("phrasing"),C=_.containerPhrasing(g,{...w,before:a,after:a});return S(),A(),C}function d(g,b){return nve(g,{align:b,alignDelimiters:s,padding:n,stringLength:i})}function f(g,b,_){const w=g.children;let A=-1;const S=[],C=b.enter("table");for(;++A<w.length;)S[A]=p(w[A],b,_);return C(),S}function p(g,b,_){const w=g.children;let A=-1;const S=[],C=b.enter("tableRow");for(;++A<w.length;)S[A]=c(w[A],g,b,_);return C(),S}function m(g,b,_){let w=d$.inlineCode(g,b,_);return _.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function Hve(){return{exit:{taskListCheckValueChecked:rR,taskListCheckValueUnchecked:rR,paragraph:qve}}}function Wve(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Gve}}}function rR(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function qve(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const s=n.children[0];if(s&&s.type==="text"){const i=t.children;let a=-1,o;for(;++a<i.length;){const l=i[a];if(l.type==="paragraph"){o=l;break}}o===n&&(s.value=s.value.slice(1),s.value.length===0?n.children.shift():n.position&&s.position&&typeof s.position.start.offset=="number"&&(s.position.start.column++,s.position.start.offset++,n.position.start=Object.assign({},s.position.start)))}}this.exit(e)}function Gve(e,t,n,s){const i=e.children[0],a=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",l=n.createTracker(s);a&&l.move(o);let c=d$.listItem(e,t,n,{...s,...l.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,d)),c;function d(f){return f+o}}function Kve(){return[C0e(),q0e(),Q0e(),Ive(),Hve()]}function Yve(e){return{extensions:[j0e(),G0e(e),X0e(),Uve(e),Wve()]}}const Qve={tokenize:nye,partial:!0},h$={tokenize:sye,partial:!0},f$={tokenize:iye,partial:!0},p$={tokenize:rye,partial:!0},Xve={tokenize:aye,partial:!0},m$={name:"wwwAutolink",tokenize:eye,previous:g$},x$={name:"protocolAutolink",tokenize:tye,previous:b$},Ho={name:"emailAutolink",tokenize:Zve,previous:v$},Ga={};function Jve(){return{text:Ga}}let Ec=48;for(;Ec<123;)Ga[Ec]=Ho,Ec++,Ec===58?Ec=65:Ec===91&&(Ec=97);Ga[43]=Ho;Ga[45]=Ho;Ga[46]=Ho;Ga[95]=Ho;Ga[72]=[Ho,x$];Ga[104]=[Ho,x$];Ga[87]=[Ho,m$];Ga[119]=[Ho,m$];function Zve(e,t,n){const s=this;let i,a;return o;function o(p){return!XS(p)||!v$.call(s,s.previous)||Oj(s.events)?n(p):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),l(p))}function l(p){return XS(p)?(e.consume(p),l):p===64?(e.consume(p),c):n(p)}function c(p){return p===46?e.check(Xve,f,d)(p):p===45||p===95||Hs(p)?(a=!0,e.consume(p),c):f(p)}function d(p){return e.consume(p),i=!0,c}function f(p){return a&&i&&ii(s.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(p)):n(p)}}function eye(e,t,n){const s=this;return i;function i(o){return o!==87&&o!==119||!g$.call(s,s.previous)||Oj(s.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(Qve,e.attempt(h$,e.attempt(f$,a),n),n)(o))}function a(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function tye(e,t,n){const s=this;let i="",a=!1;return o;function o(p){return(p===72||p===104)&&b$.call(s,s.previous)&&!Oj(s.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(p),e.consume(p),l):n(p)}function l(p){if(ii(p)&&i.length<5)return i+=String.fromCodePoint(p),e.consume(p),l;if(p===58){const m=i.toLowerCase();if(m==="http"||m==="https")return e.consume(p),c}return n(p)}function c(p){return p===47?(e.consume(p),a?d:(a=!0,c)):n(p)}function d(p){return p===null||_0(p)||Wt(p)||cu(p)||Vv(p)?n(p):e.attempt(h$,e.attempt(f$,f),n)(p)}function f(p){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(p)}}function nye(e,t,n){let s=0;return i;function i(o){return(o===87||o===119)&&s<3?(s++,e.consume(o),i):o===46&&s===3?(e.consume(o),a):n(o)}function a(o){return o===null?n(o):t(o)}}function sye(e,t,n){let s,i,a;return o;function o(d){return d===46||d===95?e.check(p$,c,l)(d):d===null||Wt(d)||cu(d)||d!==45&&Vv(d)?c(d):(a=!0,e.consume(d),o)}function l(d){return d===95?s=!0:(i=s,s=void 0),e.consume(d),o}function c(d){return i||s||!a?n(d):t(d)}}function iye(e,t){let n=0,s=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&s<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(p$,t,a)(o):o===null||Wt(o)||cu(o)?t(o):(e.consume(o),i)}function a(o){return o===41&&s++,e.consume(o),i}}function rye(e,t,n){return s;function s(l){return l===33||l===34||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===63||l===95||l===126?(e.consume(l),s):l===38?(e.consume(l),a):l===93?(e.consume(l),i):l===60||l===null||Wt(l)||cu(l)?t(l):n(l)}function i(l){return l===null||l===40||l===91||Wt(l)||cu(l)?t(l):s(l)}function a(l){return ii(l)?o(l):n(l)}function o(l){return l===59?(e.consume(l),s):ii(l)?(e.consume(l),o):n(l)}}function aye(e,t,n){return s;function s(a){return e.consume(a),i}function i(a){return Hs(a)?n(a):t(a)}}function g$(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Wt(e)}function b$(e){return!ii(e)}function v$(e){return!(e===47||XS(e))}function XS(e){return e===43||e===45||e===46||e===95||Hs(e)}function Oj(e){let t=e.length,n=!1;for(;t--;){const s=e[t][1];if((s.type==="labelLink"||s.type==="labelImage")&&!s._balanced){n=!0;break}if(s._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const oye={tokenize:mye,partial:!0};function lye(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:hye,continuation:{tokenize:fye},exit:pye}},text:{91:{name:"gfmFootnoteCall",tokenize:dye},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:cye,resolveTo:uye}}}}function cye(e,t,n){const s=this;let i=s.events.length;const a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o;for(;i--;){const c=s.events[i][1];if(c.type==="labelImage"){o=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return l;function l(c){if(!o||!o._balanced)return n(c);const d=ea(s.sliceSerialize({start:o.end,end:s.now()}));return d.codePointAt(0)!==94||!a.includes(d.slice(1))?n(c):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),t(c))}}function uye(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const s={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const a={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},l=[e[n+1],e[n+2],["enter",s,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t],e[e.length-2],e[e.length-1],["exit",s,t]];return e.splice(n,e.length-n+1,...l),e}function dye(e,t,n){const s=this,i=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let a=0,o;return l;function l(p){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),c}function c(p){return p!==94?n(p):(e.enter("gfmFootnoteCallMarker"),e.consume(p),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",d)}function d(p){if(a>999||p===93&&!o||p===null||p===91||Wt(p))return n(p);if(p===93){e.exit("chunkString");const m=e.exit("gfmFootnoteCallString");return i.includes(ea(s.sliceSerialize(m)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(p)}return Wt(p)||(o=!0),a++,e.consume(p),p===92?f:d}function f(p){return p===91||p===92||p===93?(e.consume(p),a++,d):d(p)}}function hye(e,t,n){const s=this,i=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let a,o=0,l;return c;function c(b){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionLabelMarker"),d}function d(b){return b===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",f):n(b)}function f(b){if(o>999||b===93&&!l||b===null||b===91||Wt(b))return n(b);if(b===93){e.exit("chunkString");const _=e.exit("gfmFootnoteDefinitionLabelString");return a=ea(s.sliceSerialize(_)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),m}return Wt(b)||(l=!0),o++,e.consume(b),b===92?p:f}function p(b){return b===91||b===92||b===93?(e.consume(b),o++,f):f(b)}function m(b){return b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),i.includes(a)||i.push(a),vt(e,g,"gfmFootnoteDefinitionWhitespace")):n(b)}function g(b){return t(b)}}function fye(e,t,n){return e.check(Pm,t,e.attempt(oye,t,n))}function pye(e){e.exit("gfmFootnoteDefinition")}function mye(e,t,n){const s=this;return vt(e,i,"gfmFootnoteDefinitionIndent",5);function i(a){const o=s.events[s.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(a):n(a)}}function xye(e){let n=(e||{}).singleTilde;const s={name:"strikethrough",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:s},insideSpan:{null:[s]},attentionMarkers:{null:[126]}};function i(o,l){let c=-1;for(;++c<o.length;)if(o[c][0]==="enter"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._close){let d=c;for(;d--;)if(o[d][0]==="exit"&&o[d][1].type==="strikethroughSequenceTemporary"&&o[d][1]._open&&o[c][1].end.offset-o[c][1].start.offset===o[d][1].end.offset-o[d][1].start.offset){o[c][1].type="strikethroughSequence",o[d][1].type="strikethroughSequence";const f={type:"strikethrough",start:Object.assign({},o[d][1].start),end:Object.assign({},o[c][1].end)},p={type:"strikethroughText",start:Object.assign({},o[d][1].end),end:Object.assign({},o[c][1].start)},m=[["enter",f,l],["enter",o[d][1],l],["exit",o[d][1],l],["enter",p,l]],g=l.parser.constructs.insideSpan.null;g&&tr(m,m.length,0,Uv(g,o.slice(d+1,c),l)),tr(m,m.length,0,[["exit",p,l],["enter",o[c][1],l],["exit",o[c][1],l],["exit",f,l]]),tr(o,d-1,c-d+3,m),c=d+m.length-2;break}}for(c=-1;++c<o.length;)o[c][1].type==="strikethroughSequenceTemporary"&&(o[c][1].type="data");return o}function a(o,l,c){const d=this.previous,f=this.events;let p=0;return m;function m(b){return d===126&&f[f.length-1][1].type!=="characterEscape"?c(b):(o.enter("strikethroughSequenceTemporary"),g(b))}function g(b){const _=Yd(d);if(b===126)return p>1?c(b):(o.consume(b),p++,g);if(p<2&&!n)return c(b);const w=o.exit("strikethroughSequenceTemporary"),A=Yd(b);return w._open=!A||A===2&&!!_,w._close=!_||_===2&&!!A,l(b)}}}class gye{constructor(){this.map=[]}add(t,n,s){bye(this,t,n,s)}consume(t){if(this.map.sort(function(a,o){return a[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const s=[];for(;n>0;)n-=1,s.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];s.push(t.slice()),t.length=0;let i=s.pop();for(;i;){for(const a of i)t.push(a);i=s.pop()}this.map.length=0}}function bye(e,t,n,s){let i=0;if(!(n===0&&s.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...s);return}i+=1}e.map.push([t,n,s])}}function vye(e,t){let n=!1;const s=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&s.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const a=s.length-1;s[a]=s[a]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return s}function yye(){return{flow:{null:{name:"table",tokenize:_ye,resolveAll:wye}}}}function _ye(e,t,n){const s=this;let i=0,a=0,o;return l;function l(R){let H=s.events.length-1;for(;H>-1;){const q=s.events[H][1].type;if(q==="lineEnding"||q==="linePrefix")H--;else break}const V=H>-1?s.events[H][1].type:null,K=V==="tableHead"||V==="tableRow"?T:c;return K===T&&s.parser.lazy[s.now().line]?n(R):K(R)}function c(R){return e.enter("tableHead"),e.enter("tableRow"),d(R)}function d(R){return R===124||(o=!0,a+=1),f(R)}function f(R){return R===null?n(R):qe(R)?a>1?(a=0,s.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),g):n(R):ht(R)?vt(e,f,"whitespace")(R):(a+=1,o&&(o=!1,i+=1),R===124?(e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),o=!0,f):(e.enter("data"),p(R)))}function p(R){return R===null||R===124||Wt(R)?(e.exit("data"),f(R)):(e.consume(R),R===92?m:p)}function m(R){return R===92||R===124?(e.consume(R),p):p(R)}function g(R){return s.interrupt=!1,s.parser.lazy[s.now().line]?n(R):(e.enter("tableDelimiterRow"),o=!1,ht(R)?vt(e,b,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):b(R))}function b(R){return R===45||R===58?w(R):R===124?(o=!0,e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),_):k(R)}function _(R){return ht(R)?vt(e,w,"whitespace")(R):w(R)}function w(R){return R===58?(a+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(R),e.exit("tableDelimiterMarker"),A):R===45?(a+=1,A(R)):R===null||qe(R)?E(R):k(R)}function A(R){return R===45?(e.enter("tableDelimiterFiller"),S(R)):k(R)}function S(R){return R===45?(e.consume(R),S):R===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(R),e.exit("tableDelimiterMarker"),C):(e.exit("tableDelimiterFiller"),C(R))}function C(R){return ht(R)?vt(e,E,"whitespace")(R):E(R)}function E(R){return R===124?b(R):R===null||qe(R)?!o||i!==a?k(R):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(R)):k(R)}function k(R){return n(R)}function T(R){return e.enter("tableRow"),F(R)}function F(R){return R===124?(e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),F):R===null||qe(R)?(e.exit("tableRow"),t(R)):ht(R)?vt(e,F,"whitespace")(R):(e.enter("data"),M(R))}function M(R){return R===null||R===124||Wt(R)?(e.exit("data"),F(R)):(e.consume(R),R===92?I:M)}function I(R){return R===92||R===124?(e.consume(R),M):M(R)}}function wye(e,t){let n=-1,s=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],l=!1,c=0,d,f,p;const m=new gye;for(;++n<e.length;){const g=e[n],b=g[1];g[0]==="enter"?b.type==="tableHead"?(l=!1,c!==0&&(aR(m,t,c,d,f),f=void 0,c=0),d={type:"table",start:Object.assign({},b.start),end:Object.assign({},b.end)},m.add(n,0,[["enter",d,t]])):b.type==="tableRow"||b.type==="tableDelimiterRow"?(s=!0,p=void 0,a=[0,0,0,0],o=[0,n+1,0,0],l&&(l=!1,f={type:"tableBody",start:Object.assign({},b.start),end:Object.assign({},b.end)},m.add(n,0,[["enter",f,t]])),i=b.type==="tableDelimiterRow"?2:f?3:1):i&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")?(s=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],p=zg(m,t,a,i,void 0,p),a=[0,0,0,0]),o[2]=n)):b.type==="tableCellDivider"&&(s?s=!1:(a[1]!==0&&(o[0]=o[1],p=zg(m,t,a,i,void 0,p)),a=o,o=[a[1],n,0,0])):b.type==="tableHead"?(l=!0,c=n):b.type==="tableRow"||b.type==="tableDelimiterRow"?(c=n,a[1]!==0?(o[0]=o[1],p=zg(m,t,a,i,n,p)):o[1]!==0&&(p=zg(m,t,o,i,n,p)),i=0):i&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")&&(o[3]=n)}for(c!==0&&aR(m,t,c,d,f),m.consume(t.events),n=-1;++n<t.events.length;){const g=t.events[n];g[0]==="enter"&&g[1].type==="table"&&(g[1]._align=vye(t.events,n))}return e}function zg(e,t,n,s,i,a){const o=s===1?"tableHeader":s===2?"tableDelimiter":"tableData",l="tableContent";n[0]!==0&&(a.end=Object.assign({},_d(t.events,n[0])),e.add(n[0],0,[["exit",a,t]]));const c=_d(t.events,n[1]);if(a={type:o,start:Object.assign({},c),end:Object.assign({},c)},e.add(n[1],0,[["enter",a,t]]),n[2]!==0){const d=_d(t.events,n[2]),f=_d(t.events,n[3]),p={type:l,start:Object.assign({},d),end:Object.assign({},f)};if(e.add(n[2],0,[["enter",p,t]]),s!==2){const m=t.events[n[2]],g=t.events[n[3]];if(m[1].end=Object.assign({},g[1].end),m[1].type="chunkText",m[1].contentType="text",n[3]>n[2]+1){const b=n[2]+1,_=n[3]-n[2]-1;e.add(b,_,[])}}e.add(n[3]+1,0,[["exit",p,t]])}return i!==void 0&&(a.end=Object.assign({},_d(t.events,i)),e.add(i,0,[["exit",a,t]]),a=void 0),a}function aR(e,t,n,s,i){const a=[],o=_d(t.events,n);i&&(i.end=Object.assign({},o),a.push(["exit",i,t])),s.end=Object.assign({},o),a.push(["exit",s,t]),e.add(n+1,0,a)}function _d(e,t){const n=e[t],s=n[0]==="enter"?"start":"end";return n[1][s]}const Aye={name:"tasklistCheck",tokenize:Cye};function Sye(){return{text:{91:Aye}}}function Cye(e,t,n){const s=this;return i;function i(c){return s.previous!==null||!s._gfmTasklistFirstContentOfListItem?n(c):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),a)}function a(c){return Wt(c)?(e.enter("taskListCheckValueUnchecked"),e.consume(c),e.exit("taskListCheckValueUnchecked"),o):c===88||c===120?(e.enter("taskListCheckValueChecked"),e.consume(c),e.exit("taskListCheckValueChecked"),o):n(c)}function o(c){return c===93?(e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),l):n(c)}function l(c){return qe(c)?t(c):ht(c)?e.check({tokenize:jye},t,n)(c):n(c)}}function jye(e,t,n){return vt(e,s,"whitespace");function s(i){return i===null?n(i):t(i)}}function Nye(e){return Fz([Jve(),lye(),xye(e),yye(),Sye()])}const kye={};function Fi(e){const t=this,n=e||kye,s=t.data(),i=s.micromarkExtensions||(s.micromarkExtensions=[]),a=s.fromMarkdownExtensions||(s.fromMarkdownExtensions=[]),o=s.toMarkdownExtensions||(s.toMarkdownExtensions=[]);i.push(Nye(n)),a.push(Kve()),o.push(Yve(n))}const Eye={"MEMORY.md":"Written by the agent. Edits may be overwritten.","KNOWLEDGE.md":"Distilled learning. Edits may be overwritten by reflection.","REFLEXION.md":"Earned constraints from failures. Edits may be overwritten.","HEARTBEAT.md":"Controls periodic agent behavior.","TOOLS.md":"Your local environment notes.","USER.md":"What the agent knows about you."},Fye={"CONTEXT.md":"Injected into every agent call in this channel.","NOTES.md":"Your notes. Not shared with agents."};function Tye({agentId:e,filename:t,onClose:n}){const{data:s}=pj(e),i=L.useUtils(),{data:a,isLoading:o,error:l}=L.agents.getFile.useQuery({agentId:e,filename:t},{retry:!1}),[c,d]=y.useState(!1),[f,p]=y.useState(""),[m,g]=y.useState(!1),[b,_]=y.useState(!1),[w,A]=y.useState(!1),S=y.useRef(null);y.useEffect(()=>{a&&a.content===""&&(p(""),d(!0))},[a]);const C=L.agents.setFile.useMutation({onSuccess:()=>{_(!0),setTimeout(()=>_(!1),1500),i.agents.getFile.invalidate({agentId:e,filename:t}),i.agents.listFiles.invalidate({agentId:e}),d(!1)}}),E=L.agents.resetFile.useMutation({onSuccess:V=>{i.agents.getFile.invalidate({agentId:e,filename:t}),A(!0),g(!1),setTimeout(()=>A(!1),1500),p(V.content),d(!1)}});function k(){p(a?.content??""),d(!0),setTimeout(()=>S.current?.focus(),50)}function T(){C.mutate({agentId:e,filename:t,content:f})}function F(){d(!1),p("")}function M(){if(!m){g(!0);return}E.mutate({agentId:e,filename:t})}const I=Eye[t],R=a?.hasDefault??!1,H=a?.content??"";return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"px-4 py-3 border-b border-[#2A2A35] flex-shrink-0",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s&&r.jsx("span",{className:"text-base flex-shrink-0",children:s.emoji}),r.jsxs("span",{className:"text-[13px] font-semibold text-[#F0F0F5] truncate",children:[s?.name??e," — ",t]})]}),r.jsx("button",{onClick:n,className:"w-6 h-6 flex items-center justify-center rounded text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/10 transition-colors flex-shrink-0 ml-2",children:r.jsx(Te,{className:"w-3.5 h-3.5"})})]}),I&&r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mt-1",children:I})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0",children:[o&&r.jsxs("div",{className:"flex items-center gap-1.5 px-4 py-4 text-[#5A5A6E]",children:[r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#5A5A6E] animate-pulse"}),r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#5A5A6E] animate-pulse [animation-delay:0.2s]"}),r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#5A5A6E] animate-pulse [animation-delay:0.4s]"})]}),l&&r.jsx("p",{className:"px-4 py-4 text-[13px] text-[#EF4444] italic",children:"Failed to load file."}),!o&&!l&&!c&&r.jsx("div",{className:"px-4 py-4 prose-message text-[13px]",children:H?r.jsx(Ei,{remarkPlugins:[Fi],children:H}):r.jsx("p",{className:"text-[#5A5A6E] italic",children:"Empty file."})}),!o&&!l&&c&&r.jsx("textarea",{ref:S,value:f,onChange:V=>p(V.target.value),onKeyDown:V=>{V.key==="Enter"&&V.metaKey&&(V.preventDefault(),T())},className:"w-full h-full min-h-[300px] bg-[#13131A] text-[#F0F0F5] text-[13px] font-mono px-4 py-4 resize-none outline-none border-none",spellCheck:!1})]}),r.jsxs("div",{className:"px-4 py-3 border-t border-[#2A2A35] flex items-center justify-between flex-shrink-0",children:[r.jsx("div",{className:"flex items-center gap-2",children:r.jsxs(Me,{mode:"wait",children:[b&&r.jsxs(ne.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"text-[12px] text-[#10B981] flex items-center gap-1",children:[r.jsx(Fe,{className:"w-3 h-3"})," Saved"]},"saved"),w&&r.jsx(ne.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"text-[12px] text-[#F59E0B]",children:"Reset"},"reset")]})}),r.jsxs("div",{className:"flex items-center gap-2",children:[!c&&R&&!m&&r.jsxs("button",{onClick:M,disabled:E.isPending,className:"flex items-center gap-1 px-2.5 py-1.5 rounded text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/5 transition-colors disabled:opacity-40",children:[r.jsx(lh,{className:"w-3 h-3"}),"Reset"]}),m&&r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"text-[11px] text-[#8A8A99]",children:["Reset ",t,"?"]}),r.jsx("button",{onClick:M,disabled:E.isPending,className:"px-2.5 py-1.5 rounded text-[12px] text-[#EF4444] hover:bg-[#EF4444]/10 transition-colors disabled:opacity-40",children:"Confirm"}),r.jsx("button",{onClick:()=>g(!1),className:"px-2.5 py-1.5 rounded text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/5 transition-colors",children:"Cancel"})]}),!c&&!m&&r.jsxs("button",{onClick:k,className:"flex items-center gap-1 px-2.5 py-1.5 rounded text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/5 transition-colors",children:[r.jsx(oh,{className:"w-3 h-3"}),"Edit"]}),c&&r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:F,className:"px-2.5 py-1.5 rounded text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/5 transition-colors",children:"Cancel"}),r.jsx("button",{onClick:T,disabled:C.isPending,className:"px-3 py-1.5 rounded text-[12px] font-medium bg-[#6366F1] text-white hover:bg-[#5558E8] transition-colors disabled:opacity-40",children:C.isPending?"Saving...":"Save"}),r.jsx("kbd",{className:"text-[10px] bg-white/5 border border-[#2A2A35] px-1.5 py-0.5 rounded text-[#5A5A6E]",children:"⌘↵"})]})]})]})]})}function Mye({channelId:e,filename:t,onClose:n}){const{data:s}=ez(e),i=L.useUtils(),{data:a,isLoading:o,error:l}=L.channels.getFile.useQuery({channelId:e,filename:t},{retry:!1}),[c,d]=y.useState(!1),[f,p]=y.useState(""),[m,g]=y.useState(!1),b=y.useRef(null);y.useEffect(()=>{a!==void 0&&a.content===""&&(p(""),d(!0))},[a]);const _=L.channels.setFile.useMutation({onSuccess:()=>{g(!0),setTimeout(()=>g(!1),1500),i.channels.getFile.invalidate({channelId:e,filename:t}),i.channels.listFiles.invalidate({channelId:e}),d(!1)}});function w(){p(a?.content??""),d(!0),setTimeout(()=>b.current?.focus(),50)}function A(){_.mutate({channelId:e,filename:t,content:f})}function S(){d(!1),p("")}const C=Fye[t],E=a?.content??"";return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"px-4 py-3 border-b border-[#2A2A35] flex-shrink-0",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx(Tp,{className:"w-3.5 h-3.5 text-[#8A8A99] flex-shrink-0"}),r.jsxs("span",{className:"text-[13px] font-semibold text-[#F0F0F5] truncate",children:[s?.name??e," — ",t]})]}),r.jsx("button",{onClick:n,className:"w-6 h-6 flex items-center justify-center rounded text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/10 transition-colors flex-shrink-0 ml-2",children:r.jsx(Te,{className:"w-3.5 h-3.5"})})]}),C&&r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mt-1",children:C})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0",children:[o&&r.jsxs("div",{className:"flex items-center gap-1.5 px-4 py-4 text-[#5A5A6E]",children:[r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#5A5A6E] animate-pulse"}),r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#5A5A6E] animate-pulse [animation-delay:0.2s]"}),r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#5A5A6E] animate-pulse [animation-delay:0.4s]"})]}),l&&r.jsx("p",{className:"px-4 py-4 text-[13px] text-[#EF4444] italic",children:"Failed to load file."}),!o&&!l&&!c&&r.jsx("div",{className:"px-4 py-4 prose-message text-[13px]",children:E?r.jsx(Ei,{remarkPlugins:[Fi],children:E}):r.jsx("p",{className:"text-[#5A5A6E] italic",children:"Empty file."})}),!o&&!l&&c&&r.jsx("textarea",{ref:b,value:f,onChange:k=>p(k.target.value),onKeyDown:k=>{k.key==="Enter"&&k.metaKey&&(k.preventDefault(),A())},className:"w-full h-full min-h-[300px] bg-[#13131A] text-[#F0F0F5] text-[13px] font-mono px-4 py-4 resize-none outline-none border-none",spellCheck:!1})]}),r.jsxs("div",{className:"px-4 py-3 border-t border-[#2A2A35] flex items-center justify-end flex-shrink-0 gap-2",children:[r.jsx(Me,{mode:"wait",children:m&&r.jsxs(ne.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"text-[12px] text-[#10B981] flex items-center gap-1 mr-auto",children:[r.jsx(Fe,{className:"w-3 h-3"})," Saved"]},"saved")}),!c&&r.jsxs("button",{onClick:w,className:"flex items-center gap-1 px-2.5 py-1.5 rounded text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/5 transition-colors",children:[r.jsx(oh,{className:"w-3 h-3"}),"Edit"]}),c&&r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:S,className:"px-2.5 py-1.5 rounded text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/5 transition-colors",children:"Cancel"}),r.jsx("button",{onClick:A,disabled:_.isPending,className:"px-3 py-1.5 rounded text-[12px] font-medium bg-[#6366F1] text-white hover:bg-[#5558E8] transition-colors disabled:opacity-40",children:_.isPending?"Saving...":"Save"}),r.jsx("kbd",{className:"text-[10px] bg-white/5 border border-[#2A2A35] px-1.5 py-0.5 rounded text-[#5A5A6E]",children:"⌘↵"})]})]})]})}function Rye(){const{agentId:e,channelId:t,entityType:n,filename:s,close:i}=y0(),a=!!s&&!!n;return y.useEffect(()=>{if(!a)return;function o(l){l.key==="Escape"&&i()}return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[a,i]),r.jsx(Me,{children:a&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"fixed inset-0 z-[55]",onClick:i}),r.jsxs(ne.div,{initial:{x:-380},animate:{x:0},exit:{x:-380},transition:{duration:.15,ease:"easeOut"},className:"fixed top-0 h-screen w-[380px] bg-[#1C1C24] border-r border-[#2A2A35] flex flex-col z-[55] shadow-xl",style:{left:240},onClick:o=>o.stopPropagation(),children:[n==="agent"&&e&&s&&r.jsx(Tye,{agentId:e,filename:s,onClose:i}),n==="channel"&&t&&s&&r.jsx(Mye,{channelId:t,filename:s,onClose:i})]})]})})}const Dye={high:"#EF4444",normal:"#F59E0B",low:"#6366F1"},Oye={shell_exec:Ti,trust_config:Wl,skill_install:vL,file_edit:li,delegation_rule:Wl,generic:yL};function Pye({priority:e}){return r.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:Dye[e]??"#5A5A6E"}})}function Iye({expiresAt:e}){if(!e)return null;const t=new Date(e).getTime()-Date.now();if(t<=0)return r.jsx("span",{className:"text-[10px] text-[#EF4444]",children:"Expired"});const n=Math.floor(t/36e5),s=Math.floor(t%36e5/6e4),i=n>0?`${n}h ${s}m`:`${s}m`;return r.jsxs("span",{className:"flex items-center gap-0.5 text-[10px] text-[#5A5A6E]",children:[r.jsx(bm,{className:"w-2.5 h-2.5"}),i]})}const Pj={pending:"#F59E0B",working:"#6366F1",input_needed:"#8B5CF6",completed:"#10B981",failed:"#EF4444",cancelled:"#5A5A6E"},y$={pending:"○",working:"⏳",input_needed:"❓",completed:"✅",failed:"⚠️",cancelled:"🛑",blocked:"🚫"};function Lye(e,t){const n=e??t,s=Date.now()-new Date(n).getTime(),i=Math.floor(s/1e3);if(i<60)return`${i}s`;const a=Math.floor(i/60);return a<60?`${a}m`:`${Math.floor(a/60)}h ${a%60}m`}function _$(e){const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${n%60}m`}function w$({node:e,navigate:t,depth:n=0}){const s=e.children.length>1,i=Pj[e.status]??"#5A5A6E";return r.jsxs("div",{className:n>0?"ml-4 border-l border-[#2A2A35] pl-3":"",children:[r.jsxs("div",{className:"flex items-center gap-2 py-1.5 group",children:[r.jsx("span",{className:"text-[12px]",children:y$[e.status]??"•"}),r.jsxs("div",{className:"flex items-center gap-1",children:[e.toAgent&&r.jsx("span",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[10px] flex-shrink-0",style:{backgroundColor:`${e.toAgent.color}26`},children:e.toAgent.emoji}),r.jsx("span",{className:"text-[11px] font-medium text-[#F0F0F5]",children:e.toAgent?.name??e.toAgentId})]}),r.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:i}}),e.crossInstance&&r.jsx(Xt,{className:"w-2.5 h-2.5 text-[#A78BFA] flex-shrink-0"}),r.jsx("span",{className:"text-[10px] text-[#5A5A6E]",children:e.status.replace("_"," ")}),e.targetChannelId&&r.jsx("button",{onClick:()=>t(`/channels/${e.targetChannelId}`),className:"opacity-0 group-hover:opacity-100 transition-opacity text-[#5A5A6E] hover:text-[#8A8A99]",children:r.jsx(cs,{className:"w-2.5 h-2.5"})})]}),r.jsx("p",{className:"text-[10px] text-[#8A8A99] line-clamp-1 ml-6 mb-1",children:e.task}),e.crossInstance&&e.status==="failed"&&e.task.includes("cross-instance")&&r.jsx("p",{className:"text-[10px] text-[#A78BFA] ml-6 mb-1",children:"(cross-instance disabled)"}),s&&r.jsx("div",{className:"ml-6 mb-1",children:r.jsx("span",{className:"text-[9px] text-[#5A5A6E] uppercase tracking-wider",children:"parallel"})}),e.children.map(a=>r.jsx(w$,{node:a,navigate:t,depth:n+1},a.id))]})}function A$({taskId:e,navigate:t}){const{data:n,isLoading:s}=L.agentTasks.getChain.useQuery({taskId:e});return s?r.jsx("div",{className:"py-2 text-[11px] text-[#5A5A6E]",children:"Loading chain..."}):n?r.jsxs("div",{className:"py-2 px-1",children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[r.jsx(Zl,{className:"w-3 h-3 text-[#6366F1]"}),r.jsx("span",{className:"text-[11px] font-semibold text-[#8A8A99]",children:"Task Chain"})]}),r.jsx(w$,{node:n,navigate:t})]}):r.jsx("div",{className:"py-2 text-[11px] text-[#5A5A6E]",children:"Chain not found"})}function Bye(){const{data:e}=L.agentTasks.stats.useQuery(void 0,{staleTime:3e4});return!e||e.totalTasks===0?null:r.jsxs("div",{className:"px-5 py-3 border-b border-[#2A2A35]",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(M5,{className:"w-3.5 h-3.5 text-[#8A8A99]"}),r.jsx("span",{className:"text-[11px] font-semibold text-[#8A8A99] uppercase tracking-widest",children:"Delegation Stats"})]}),r.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[r.jsxs("div",{className:"bg-[#1C1C24] rounded-lg px-2.5 py-2 border border-[#2A2A35]",children:[r.jsx("p",{className:"text-[16px] font-semibold text-[#F0F0F5]",children:e.totalTasks}),r.jsx("p",{className:"text-[9px] text-[#5A5A6E] uppercase",children:"Total"})]}),r.jsxs("div",{className:"bg-[#1C1C24] rounded-lg px-2.5 py-2 border border-[#2A2A35]",children:[r.jsx("p",{className:"text-[16px] font-semibold text-[#6366F1]",children:e.activeTasks}),r.jsx("p",{className:"text-[9px] text-[#5A5A6E] uppercase",children:"Active"})]}),r.jsxs("div",{className:"bg-[#1C1C24] rounded-lg px-2.5 py-2 border border-[#2A2A35]",children:[r.jsx("p",{className:"text-[16px] font-semibold text-[#10B981]",children:e.completedTasks}),r.jsx("p",{className:"text-[9px] text-[#5A5A6E] uppercase",children:"Done"})]}),r.jsxs("div",{className:"bg-[#1C1C24] rounded-lg px-2.5 py-2 border border-[#2A2A35]",children:[r.jsx("p",{className:"text-[16px] font-semibold text-[#EF4444]",children:e.failedTasks}),r.jsx("p",{className:"text-[9px] text-[#5A5A6E] uppercase",children:"Failed"})]})]}),r.jsxs("div",{className:"flex items-center gap-3 mt-2 text-[10px] text-[#5A5A6E]",children:[e.avgDurationMs!=null&&r.jsxs("span",{children:["Avg: ",_$(e.avgDurationMs)]}),e.totalTokensUsed>0&&r.jsxs("span",{children:[e.totalTokensUsed.toLocaleString()," tokens"]}),e.crossInstanceTasks.total>0&&r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx(Xt,{className:"w-2.5 h-2.5"}),e.crossInstanceTasks.total," cross-instance"]})]})]})}function zye({navigate:e}){const{data:t=[],isLoading:n}=L.agentTasks.active.useQuery(void 0,{refetchInterval:5e3}),s=L.agentTasks.cancel.useMutation(),[i,a]=y.useState(new Set);if(n||t.length===0)return null;function o(l){a(c=>{const d=new Set(c);return d.has(l)?d.delete(l):d.add(l),d})}return r.jsxs("div",{className:"border-b border-[#2A2A35]",children:[r.jsxs("div",{className:"px-5 py-3 flex items-center gap-2",children:[r.jsx(cse,{className:"w-3.5 h-3.5 text-[#6366F1]"}),r.jsx("span",{className:"text-[12px] font-semibold text-[#F0F0F5]",children:"Active Tasks"}),r.jsx("span",{className:"bg-[#6366F1] text-white text-[10px] font-bold rounded-full min-w-[18px] h-[18px] flex items-center justify-center px-1 leading-none",children:t.length})]}),t.map(l=>r.jsxs("div",{className:"px-5 py-2.5 hover:bg-white/[0.02] transition-colors border-t border-[#2A2A35]/30",children:[r.jsxs("div",{className:"flex items-start gap-2.5",children:[r.jsxs("div",{className:"flex -space-x-1.5 flex-shrink-0 mt-0.5",children:[l.fromAgent&&r.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-[11px] border border-[#13131A]",style:{backgroundColor:`${l.fromAgent.color}26`},title:l.fromAgent.name,children:l.fromAgent.emoji}),l.toAgent&&r.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-[11px] border border-[#13131A]",style:{backgroundColor:`${l.toAgent.color}26`},title:l.toAgent.name,children:l.toAgent.emoji})]}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[r.jsxs("span",{className:"text-[11px] font-medium text-[#F0F0F5] truncate",children:[l.fromAgent?.name??l.fromAgentId," → ",l.toAgent?.name??l.toAgentId]}),r.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:Pj[l.status]??"#5A5A6E"}}),l.crossInstance&&r.jsx(Xt,{className:"w-2.5 h-2.5 text-[#A78BFA] flex-shrink-0"})]}),r.jsx("p",{className:"text-[11px] text-[#8A8A99] line-clamp-1",children:l.task}),r.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[r.jsxs("span",{className:"text-[10px] text-[#5A5A6E]",children:[Lye(l.startedAt,l.createdAt)," · depth ",l.depth," · ",l.status.replace("_"," ")]}),l.parentTaskId&&r.jsxs("button",{onClick:c=>{c.stopPropagation(),o(l.id)},className:"flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] text-[#6366F1] hover:bg-[#6366F1]/10 transition-colors",children:[r.jsx(Zl,{className:"w-2.5 h-2.5"}),"Chain"]}),r.jsxs("button",{onClick:c=>{c.stopPropagation(),s.mutate({taskId:l.id})},disabled:s.isPending,className:"flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] text-[#EF4444] hover:bg-[#EF4444]/10 transition-colors disabled:opacity-40 ml-auto",children:[r.jsx(L5,{className:"w-2.5 h-2.5"}),"Cancel"]}),l.channelId&&r.jsx("button",{onClick:()=>e(`/channels/${l.channelId}`),className:"flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] text-[#5A5A6E] hover:text-[#8A8A99] hover:bg-white/[0.04] transition-colors",children:r.jsx(cs,{className:"w-2.5 h-2.5"})})]})]})]}),r.jsx(Me,{children:i.has(l.id)&&r.jsx(ne.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden ml-8 mt-1 border-l border-[#2A2A35] pl-3",children:r.jsx(A$,{taskId:l.id,navigate:e})})})]},l.id))]})}function $ye({navigate:e}){const[t,n]=y.useState(!1),[s,i]=y.useState(new Set),{data:a}=L.agentTasks.list.useQuery({status:"completed",limit:10},{staleTime:3e4}),{data:o}=L.agentTasks.list.useQuery({status:"failed",limit:10},{staleTime:3e4}),l=a?.items??[],d=[...o?.items??[],...l].sort((p,m)=>m.createdAt.localeCompare(p.createdAt)).slice(0,10);if(d.length===0)return null;function f(p){i(m=>{const g=new Set(m);return g.has(p)?g.delete(p):g.add(p),g})}return r.jsxs("div",{className:"border-b border-[#2A2A35]",children:[r.jsxs("button",{onClick:()=>n(p=>!p),className:"w-full px-5 py-2.5 flex items-center gap-2 hover:bg-white/[0.02] transition-colors",children:[t?r.jsx(ah,{className:"w-3 h-3 text-[#5A5A6E]"}):r.jsx(ft,{className:"w-3 h-3 text-[#5A5A6E]"}),r.jsx("span",{className:"text-[11px] font-semibold text-[#5A5A6E] uppercase tracking-widest",children:"Recent Completed/Failed"}),r.jsx("span",{className:"text-[10px] text-[#5A5A6E]",children:d.length})]}),r.jsx(Me,{children:t&&r.jsx(ne.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:d.map(p=>r.jsxs("div",{className:"px-5 py-2 hover:bg-white/[0.02] transition-colors border-t border-[#2A2A35]/30",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[10px]",children:y$[p.status]??"•"}),r.jsxs("div",{className:"flex -space-x-1.5 flex-shrink-0",children:[p.fromAgent&&r.jsx("span",{className:"text-[10px]",children:p.fromAgent.emoji}),r.jsx("span",{className:"text-[9px] text-[#5A5A6E] mx-0.5",children:"→"}),p.toAgent&&r.jsx("span",{className:"text-[10px]",children:p.toAgent.emoji})]}),r.jsx("span",{className:"text-[11px] text-[#8A8A99] flex-1 truncate",children:p.task}),p.crossInstance&&r.jsx(Xt,{className:"w-2.5 h-2.5 text-[#A78BFA] flex-shrink-0"}),p.completedAt&&p.startedAt&&r.jsx("span",{className:"text-[10px] text-[#5A5A6E]",children:_$(new Date(p.completedAt).getTime()-new Date(p.startedAt).getTime())}),p.parentTaskId&&r.jsx("button",{onClick:m=>{m.stopPropagation(),f(p.id)},className:"text-[#6366F1] hover:bg-[#6366F1]/10 rounded p-0.5 transition-colors",children:r.jsx(Zl,{className:"w-2.5 h-2.5"})}),p.channelId&&r.jsx("button",{onClick:()=>e(`/channels/${p.channelId}`),className:"text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:r.jsx(cs,{className:"w-2.5 h-2.5"})})]}),r.jsx(Me,{children:s.has(p.id)&&r.jsx(ne.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden ml-6 mt-1",children:r.jsx(A$,{taskId:p.id,navigate:e})})})]},p.id))})})]})}function Vye(){const[e,t]=y.useState(!1),[n,s]=y.useState("all"),{data:i=[]}=L.agentTasks.crossInstanceAudit.useQuery({limit:50,decision:n==="all"?void 0:n},{staleTime:3e4});return i.length===0&&n==="all"?null:r.jsxs("div",{className:"border-b border-[#2A2A35]",children:[r.jsxs("button",{onClick:()=>t(a=>!a),className:"w-full px-5 py-2.5 flex items-center gap-2 hover:bg-white/[0.02] transition-colors",children:[e?r.jsx(ah,{className:"w-3 h-3 text-[#A78BFA]"}):r.jsx(ft,{className:"w-3 h-3 text-[#A78BFA]"}),r.jsx(Xt,{className:"w-3 h-3 text-[#A78BFA]"}),r.jsx("span",{className:"text-[11px] font-semibold text-[#A78BFA] uppercase tracking-widest",children:"Cross-Instance Audit"}),r.jsx("span",{className:"text-[10px] text-[#5A5A6E]",children:i.length})]}),r.jsx(Me,{children:e&&r.jsxs(ne.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:[r.jsx("div",{className:"flex gap-1 px-5 py-1.5",children:["all","allowed","blocked"].map(a=>r.jsx("button",{onClick:()=>s(a),className:`px-2 py-0.5 rounded-full text-[10px] font-medium transition-colors ${n===a?"bg-[#A78BFA] text-white":"bg-white/5 text-[#8A8A99] hover:text-[#C8C8D4]"}`,children:a},a))}),i.map(a=>r.jsxs("div",{className:"px-5 py-2 hover:bg-white/[0.02] transition-colors border-t border-[#2A2A35]/30",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:`px-1.5 py-0.5 rounded text-[9px] font-medium ${a.decision==="allowed"?"bg-[#10B981]/10 text-[#10B981]":"bg-[#EF4444]/10 text-[#EF4444]"}`,children:a.decision}),r.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[a.fromAgent&&r.jsx("span",{className:"text-[10px]",children:a.fromAgent.emoji}),r.jsx("span",{className:"text-[9px] text-[#5A5A6E]",children:"→"}),a.toAgent&&r.jsx("span",{className:"text-[10px]",children:a.toAgent.emoji})]}),r.jsx("span",{className:"text-[11px] text-[#8A8A99] flex-1 truncate",children:a.taskSummary}),r.jsx("span",{className:"text-[10px] text-[#5A5A6E] flex-shrink-0",children:Ir(a.timestamp)}),a.status!=="blocked"&&r.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:Pj[a.status]??"#5A5A6E"}})]}),r.jsxs("div",{className:"flex items-center gap-1 mt-0.5 ml-14",children:[r.jsx("span",{className:"text-[10px] text-[#5A5A6E]",children:a.fromAgent?.name??a.fromAgentId}),r.jsx("span",{className:"text-[9px] text-[#5A5A6E]",children:"→"}),r.jsx("span",{className:"text-[10px] text-[#5A5A6E]",children:a.toAgent?.name??a.toAgentId})]})]},a.id)),i.length===0&&r.jsx("p",{className:"px-5 py-3 text-[11px] text-[#5A5A6E] italic",children:"No cross-instance delegations found."})]})})]})}function Uye({onClose:e}){const t=an(),n=L.useUtils(),[s,i]=y.useState(new Set),[a,o]=y.useState(null),[l,c]=y.useState(""),[d,f]=y.useState(!1),[p,m]=y.useState(""),[g,b]=y.useState(new Set),{data:_,isLoading:w}=L.approvals.list.useQuery({status:"pending"},{refetchInterval:1e4}),A=L.approvals.decide.useMutation({onSuccess:()=>{n.approvals.list.invalidate(),n.approvals.pendingCount.invalidate()}}),S=L.approvals.batchApprove.useMutation({onSuccess:()=>{i(new Set),n.approvals.list.invalidate(),n.approvals.pendingCount.invalidate()}}),C=L.approvals.batchReject.useMutation({onSuccess:()=>{i(new Set),f(!1),m(""),n.approvals.list.invalidate(),n.approvals.pendingCount.invalidate()}}),E=[..._?.items??[]].sort(($,B)=>B.createdAt.localeCompare($.createdAt)),k=E.filter($=>$.messageId).map($=>$.messageId),T=[...s].filter($=>k.includes($));function F($){i(B=>{const Y=new Set(B);return Y.has($)?Y.delete($):Y.add($),Y})}function M(){s.size===k.length?i(new Set):i(new Set(k))}function I($){A.mutate({messageId:$,decision:"approved"})}function R($){A.mutate({messageId:$,decision:"rejected",rejectionNote:l||void 0}),o(null),c("")}function H(){T.length!==0&&S.mutate({messageIds:T})}function V(){T.length!==0&&C.mutate({messageIds:T,rejectionNote:p||void 0})}function K($){b(B=>{const Y=new Set(B);return Y.has($)?Y.delete($):Y.add($),Y})}function q($){t(`/channels/${$}`),e()}return r.jsxs(r.Fragment,{children:[r.jsx(ne.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-40",style:{backdropFilter:"blur(2px)",backgroundColor:"rgba(0,0,0,0.25)"},onClick:e}),r.jsxs(ne.div,{initial:{x:"100%",opacity:0},animate:{x:0,opacity:1},exit:{x:"100%",opacity:0},transition:{duration:.3,ease:[.16,1,.3,1]},className:"fixed right-0 top-0 h-screen w-[420px] bg-[#13131A] border-l border-[#2A2A35] flex flex-col z-50 shadow-2xl",children:[r.jsxs("div",{className:"px-5 py-4 border-b border-[#2A2A35] flex items-center justify-between flex-shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-2.5",children:[r.jsx("h2",{className:"text-[15px] font-semibold text-[#F0F0F5]",children:"Pending Approvals"}),E.length>0&&r.jsx("span",{className:"bg-[#EF4444] text-white text-[10px] font-bold rounded-full min-w-[18px] h-[18px] flex items-center justify-center px-1 leading-none",children:E.length})]}),r.jsx("button",{onClick:e,className:"w-7 h-7 flex items-center justify-center rounded-md text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/10 transition-colors",children:r.jsx(Te,{className:"w-4 h-4"})})]}),T.length>0&&r.jsx("div",{className:"px-5 py-3 border-b border-[#2A2A35]/50 flex flex-col gap-2 flex-shrink-0",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("span",{className:"text-[12px] text-[#8A8A99]",children:[T.length," selected"]}),r.jsxs("button",{onClick:H,disabled:S.isPending,className:"flex items-center gap-1 px-2.5 py-1 rounded-md bg-[#10B981]/15 text-[#10B981] text-[11px] font-medium hover:bg-[#10B981]/25 transition-colors disabled:opacity-40",children:[r.jsx(Fe,{className:"w-3 h-3"}),"Approve ",T.length]}),d?r.jsxs("div",{className:"flex items-center gap-1.5 flex-1",children:[r.jsx("input",{value:p,onChange:$=>m($.target.value),placeholder:"Reason (optional)",className:"flex-1 bg-[#0F0F11] border border-[#2A2A35] rounded-md px-2 py-1 text-[11px] text-[#F0F0F5] placeholder-[#5A5A6E] outline-none focus:border-[#EF4444]/40",onKeyDown:$=>{$.key==="Enter"&&V()},autoFocus:!0}),r.jsx("button",{onClick:V,disabled:C.isPending,className:"px-2 py-1 rounded-md bg-[#EF4444]/15 text-[#EF4444] text-[11px] font-medium hover:bg-[#EF4444]/25 transition-colors disabled:opacity-40",children:"Reject"}),r.jsx("button",{onClick:()=>{f(!1),m("")},className:"text-[11px] text-[#5A5A6E] hover:text-[#8A8A99]",children:"Cancel"})]}):r.jsxs("button",{onClick:()=>f(!0),className:"flex items-center gap-1 px-2.5 py-1 rounded-md bg-[#EF4444]/15 text-[#EF4444] text-[11px] font-medium hover:bg-[#EF4444]/25 transition-colors",children:[r.jsx(Te,{className:"w-3 h-3"}),"Reject ",T.length]})]})}),r.jsxs("div",{className:"flex-1 overflow-y-auto",children:[r.jsx(Bye,{}),r.jsx(zye,{navigate:t}),r.jsx($ye,{navigate:t}),r.jsx(Vye,{}),w?r.jsx("div",{className:"flex items-center justify-center py-16",children:r.jsx("div",{className:"w-5 h-5 border-2 border-[#6366F1]/30 border-t-[#6366F1] rounded-full animate-spin"})}):E.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[r.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/[0.03] border border-[#2A2A35] flex items-center justify-center mb-3",children:r.jsx(Fe,{className:"w-4 h-4 text-[#5A5A6E]"})}),r.jsx("p",{className:"text-[13px] text-[#5A5A6E]",children:"No pending approvals"})]}):r.jsxs(r.Fragment,{children:[k.length>1&&r.jsx("div",{className:"px-5 py-2 sticky top-0 z-10 bg-[#13131A]",children:r.jsxs("label",{className:"flex items-center gap-2 text-[11px] text-[#5A5A6E] cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:s.size>0&&s.size===k.length,onChange:M,className:"accent-[#6366F1] w-3.5 h-3.5"}),"Select all"]})}),r.jsx(Me,{initial:!1,children:E.map($=>{const B=Oye[$.type]??yL,Y=a===($.messageId??$.id),U=g.has($.id);return r.jsx(ne.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.15},className:"border-b border-[#2A2A35]/40",children:r.jsx("div",{className:"px-5 py-3 hover:bg-white/[0.02] transition-colors",children:r.jsxs("div",{className:"flex items-start gap-2.5",children:[$.messageId&&r.jsx("input",{type:"checkbox",checked:s.has($.messageId),onChange:()=>F($.messageId),className:"accent-[#6366F1] w-3.5 h-3.5 mt-1 flex-shrink-0"}),r.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center flex-shrink-0",style:{backgroundColor:$.agentColor?`${$.agentColor}15`:"rgba(99, 102, 241, 0.1)"},children:$.agentEmoji?r.jsx("span",{className:"text-xs",children:$.agentEmoji}):r.jsx(B,{className:"w-3.5 h-3.5 text-[#8A8A99]"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[r.jsx("span",{className:"text-[12px] font-medium text-[#F0F0F5] truncate",children:$.agentName??"Agent"}),r.jsx(Pye,{priority:$.priority}),r.jsx(Iye,{expiresAt:$.expiresAt}),r.jsx("span",{className:"text-[10px] text-[#5A5A6E] ml-auto flex-shrink-0",children:Ir($.createdAt)})]}),$.type==="delegation_rule"&&$.payload?(()=>{try{const W=JSON.parse($.payload);return r.jsxs("div",{className:"mb-1.5",children:[r.jsxs("p",{className:"text-[12px] text-[#C8C8D4] leading-relaxed mb-1",children:["COO wants to create a delegation rule: Auto-approve ",r.jsx("code",{className:"text-[#6366F1] bg-[#6366F1]/10 px-1 rounded text-[11px]",children:W.pattern})," for ",r.jsx("span",{className:"text-[#F0F0F5] font-medium",children:W.agentId})]}),r.jsx("p",{className:"text-[11px] text-[#8A8A99] italic mb-1",children:W.reason}),r.jsxs("p",{className:"text-[10px] text-[#5A5A6E] leading-relaxed",children:["Future ",r.jsx("code",{className:"text-[#5A5A6E]",children:W.pattern})," actions from ",W.agentId," will be automatically approved without your review."]})]})}catch{return null}})():r.jsxs(r.Fragment,{children:[r.jsx("p",{className:`text-[12px] text-[#C8C8D4] leading-relaxed mb-1 whitespace-pre-wrap ${U?"":"line-clamp-2"}`,children:$.content}),$.content.length>100&&r.jsxs("button",{onClick:()=>K($.id),className:"flex items-center gap-0.5 text-[10px] text-[#5A5A6E] hover:text-[#8A8A99] transition-colors mb-1.5",children:[U?r.jsx(ah,{className:"w-2.5 h-2.5"}):r.jsx(ft,{className:"w-2.5 h-2.5"}),U?"Less":"More"]})]}),Y?r.jsxs(ne.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},className:"flex items-center gap-1.5 mb-1",children:[r.jsx("input",{value:l,onChange:W=>c(W.target.value),placeholder:"Reason (optional)",className:"flex-1 bg-[#0F0F11] border border-[#2A2A35] rounded-md px-2 py-1 text-[11px] text-[#F0F0F5] placeholder-[#5A5A6E] outline-none focus:border-[#EF4444]/40",onKeyDown:W=>{W.key==="Enter"&&R($.messageId)},autoFocus:!0}),r.jsx("button",{onClick:()=>R($.messageId),className:"px-2 py-1 rounded-md bg-[#EF4444]/15 text-[#EF4444] text-[11px] font-medium hover:bg-[#EF4444]/25 transition-colors",children:"Reject"}),r.jsx("button",{onClick:()=>{o(null),c("")},className:"text-[11px] text-[#5A5A6E] hover:text-[#8A8A99]",children:"Cancel"})]}):r.jsxs("div",{className:"flex items-center gap-1.5",children:[$.messageId&&r.jsxs(r.Fragment,{children:[r.jsxs("button",{onClick:()=>I($.messageId),disabled:A.isPending,className:"flex items-center gap-1 px-2 py-0.5 rounded-md bg-[#10B981]/12 text-[#10B981] text-[11px] font-medium hover:bg-[#10B981]/22 transition-colors disabled:opacity-40",children:[r.jsx(Fe,{className:"w-3 h-3"}),"Approve"]}),r.jsxs("button",{onClick:()=>o($.messageId),className:"flex items-center gap-1 px-2 py-0.5 rounded-md bg-[#EF4444]/12 text-[#EF4444] text-[11px] font-medium hover:bg-[#EF4444]/22 transition-colors",children:[r.jsx(Te,{className:"w-3 h-3"}),"Reject"]})]}),r.jsxs("button",{onClick:()=>q($.channelId),className:"flex items-center gap-0.5 ml-auto px-1.5 py-0.5 rounded text-[10px] text-[#5A5A6E] hover:text-[#8A8A99] hover:bg-white/[0.04] transition-colors",children:[r.jsx(cs,{className:"w-2.5 h-2.5"}),"View"]})]})]})]})})},$.id)})})]})]})]})]})}function Hye(){const e=an(),{data:t}=L.onboarding.getState.useQuery(void 0,{refetchOnWindowFocus:!1}),{data:n}=L.onboarding.pollOpenClaw.useQuery(void 0,{refetchInterval:1e4,refetchOnWindowFocus:!1}),s=L.onboarding.skipOpenClaw.useMutation(),i=L.useUtils();if(!t?.skippedOpenClaw||n?.running)return null;async function a(){await s.mutateAsync(),i.onboarding.getState.invalidate()}return r.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-[#1C1410] border-b border-[#F59E0B]/20 text-[12px] flex-shrink-0",children:[r.jsxs("span",{className:"text-[#F59E0B]",children:["OpenClaw not connected —"," ",r.jsx("button",{onClick:()=>e("/onboarding"),className:"underline underline-offset-2 hover:text-[#FBBF24] transition-colors",children:"set up now"})]}),r.jsx("button",{onClick:a,className:"text-[#F59E0B]/60 hover:text-[#F59E0B] transition-colors ml-4",children:r.jsx(Te,{className:"w-3.5 h-3.5"})})]})}function Wye(){const{data:e}=L.settings.getTestMode.useQuery(void 0,{refetchOnWindowFocus:!1,refetchInterval:15e3}),t=L.useUtils(),n=L.settings.setTestMode.useMutation({onSuccess:()=>{t.settings.getTestMode.invalidate()}});return e?.enabled?r.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-[#1C1A0F] border-b border-[#F59E0B]/30 text-[12px] flex-shrink-0",children:[r.jsxs("span",{className:"flex items-center gap-2 text-[#FBBF24]",children:[r.jsx(oL,{className:"w-3.5 h-3.5"}),"Test mode active — no memory, knowledge, or reflection will be recorded."]}),r.jsx("button",{onClick:()=>n.mutate({enabled:!1}),disabled:n.isPending,className:"text-[#FBBF24]/80 hover:text-[#FBBF24] underline underline-offset-2 transition-colors ml-4 disabled:opacity-50",children:"disable"})]}):null}function qye({children:e}){const[t,n]=y.useState(!1);return r.jsxs("div",{className:"flex h-screen w-screen overflow-hidden bg-[#0F0F11] flex-col",children:[r.jsx(Hye,{}),r.jsx(Wye,{}),r.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[r.jsx(lme,{onOpenApprovals:()=>n(s=>!s)}),r.jsxs("main",{className:"flex flex-1 overflow-hidden relative",children:[e,r.jsx(Afe,{})]}),r.jsx(Rye,{})]}),r.jsx(Me,{children:t&&r.jsx(Uye,{onClose:()=>n(!1)})})]})}function Gye({label:e,emoji:t,color:n,typeBadge:s,onRemove:i}){return r.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-md group",children:[r.jsx("span",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs flex-shrink-0",style:{backgroundColor:`${n}26`},children:t??e[0]?.toUpperCase()}),r.jsx("span",{className:"text-[13px] text-[#C8C8D4] flex-1 truncate",children:e}),r.jsx("span",{className:"text-[10px] text-[#5A5A6E] bg-white/5 px-1.5 py-0.5 rounded",children:s}),i&&r.jsx("button",{onClick:i,className:"w-5 h-5 flex items-center justify-center rounded text-[#5A5A6E] opacity-0 group-hover:opacity-100 hover:text-[#EF4444] hover:bg-[#EF4444]/10 transition-all",children:r.jsx(Te,{className:"w-3 h-3"})})]})}function Kye({channelId:e,existingIds:t,agents:n,workspaceMembers:s}){const[i,a]=y.useState(!1),[o,l]=y.useState(""),c=L.useUtils(),d=L.channels.addParticipant.useMutation({onSuccess:()=>{c.channels.list.invalidate(),l(""),a(!1)}}),f=n.filter(_=>!t.has(_.id)),p=s.filter(_=>!t.has(_.userId)),m=o.toLowerCase(),g=m?f.filter(_=>_.name.toLowerCase().includes(m)):f,b=m?p.filter(_=>_.name.toLowerCase().includes(m)):p;return i?r.jsxs("div",{className:"px-1",children:[r.jsx("input",{autoFocus:!0,value:o,onChange:_=>l(_.target.value),placeholder:"Search people and agents...",className:"w-full bg-[#13131A] border border-[#2A2A35] rounded-md px-2 py-1.5 text-[12px] text-[#F0F0F5] placeholder-[#5A5A6E] outline-none focus:border-[#6366F1]/60 transition-colors mb-1",onKeyDown:_=>{_.key==="Escape"&&(a(!1),l(""))}}),r.jsxs("div",{className:"max-h-[180px] overflow-y-auto",children:[g.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-[10px] text-[#5A5A6E] px-2 py-1 uppercase tracking-widest font-semibold",children:"Agents"}),g.map(_=>r.jsxs("button",{onClick:()=>d.mutate({channelId:e,participantId:_.id,participantType:"agent"}),disabled:d.isPending,className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-[12px] text-[#C8C8D4] hover:bg-white/5 transition-colors",children:[r.jsx("span",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[11px] flex-shrink-0",style:{backgroundColor:`${_.color}26`},children:_.emoji}),r.jsx("span",{className:"flex-1 text-left truncate",children:_.name}),r.jsx("span",{className:"text-[10px] text-[#5A5A6E]",children:_.role})]},_.id))]}),b.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-[10px] text-[#5A5A6E] px-2 py-1 uppercase tracking-widest font-semibold",children:"People"}),b.map(_=>{const w=_.name.split(" ").map(A=>A[0]).join("").slice(0,2).toUpperCase();return r.jsxs("button",{onClick:()=>d.mutate({channelId:e,participantId:_.userId,participantType:"human"}),disabled:d.isPending,className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-[12px] text-[#C8C8D4] hover:bg-white/5 transition-colors",children:[_.image?r.jsx("img",{src:_.image,className:"w-5 h-5 rounded-full flex-shrink-0",alt:""}):r.jsx("span",{className:"w-5 h-5 rounded-full bg-gradient-to-br from-[#6366F1] to-[#8B5CF6] flex items-center justify-center text-[9px] font-semibold text-white flex-shrink-0",children:w}),r.jsx("span",{className:"flex-1 text-left truncate",children:_.name})]},_.userId)})]}),g.length===0&&b.length===0&&r.jsx("p",{className:"text-[11px] text-[#5A5A6E] px-2 py-1.5",children:"No participants available"})]})]}):r.jsxs("button",{onClick:()=>a(!0),className:"flex items-center gap-1.5 px-2 py-1.5 rounded-md text-[12px] text-[#5A5A6E] hover:text-[#8A8A99] hover:bg-white/5 transition-colors w-full",children:[r.jsx(wt,{className:"w-3.5 h-3.5"}),r.jsx("span",{children:"Add participant"})]})}function S$({channel:e}){const{data:t=[]}=Vo(),{data:n}=Mi(),{data:s=[]}=L.workspace.listMembers.useQuery(void 0,{staleTime:3e4}),i=L.useUtils(),a=L.channels.removeParticipant.useMutation({onSuccess:()=>{i.channels.list.invalidate()}}),o=new Set(e.participants.map(c=>c.participantId)),l=e.participants.length;return r.jsxs(Ys,{children:[r.jsx(ci,{asChild:!0,children:r.jsxs("button",{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/10 transition-colors border border-transparent hover:border-[#2A2A35]",children:[r.jsx(wm,{className:"w-3.5 h-3.5"}),r.jsx("span",{children:l})]})}),r.jsx(Qs,{children:r.jsxs(Xs,{align:"end",sideOffset:6,className:"bg-[#1C1C24] border border-[#2A2A35] rounded-lg shadow-xl w-[260px] z-50",children:[r.jsx("div",{className:"px-3 py-2 border-b border-[#2A2A35]",children:r.jsx("span",{className:"text-[11px] font-semibold text-[#8A8A99] uppercase tracking-widest",children:"Members"})}),r.jsx("div",{className:"py-1 px-1 max-h-[200px] overflow-y-auto",children:e.participants.map(c=>{const d=t.find(A=>A.id===c.participantId),f=c.participantType==="human",m=(f?s.find(A=>A.userId===c.participantId):void 0)?.name??n?.user?.name??n?.user?.email??"User",g=f?m:d?.name??c.participantId,b=f?void 0:d?.emoji,_=f?"#6366F1":d?.color??"#8A8A99",w=e.participants.length>1;return r.jsx(Gye,{label:g,emoji:b,color:_,typeBadge:f?"Human":"Agent",onRemove:w?()=>a.mutate({channelId:e.id,participantId:c.participantId}):void 0},c.id)})}),r.jsx("div",{className:"border-t border-[#2A2A35] py-1.5 px-1",children:r.jsx(Kye,{channelId:e.id,existingIds:o,agents:t,workspaceMembers:s})}),r.jsx(oa,{className:"fill-[#2A2A35]"})]})})]})}function Ij(e){const t=e+"CollectionProvider",[n,s]=Wa(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=_=>{const{scope:w,children:A}=_,S=be.useRef(null),C=be.useRef(new Map).current;return r.jsx(i,{scope:w,itemMap:C,collectionRef:S,children:A})};o.displayName=t;const l=e+"CollectionSlot",c=iu(l),d=be.forwardRef((_,w)=>{const{scope:A,children:S}=_,C=a(l,A),E=At(w,C.collectionRef);return r.jsx(c,{ref:E,children:S})});d.displayName=l;const f=e+"CollectionItemSlot",p="data-radix-collection-item",m=iu(f),g=be.forwardRef((_,w)=>{const{scope:A,children:S,...C}=_,E=be.useRef(null),k=At(w,E),T=a(f,A);return be.useEffect(()=>(T.itemMap.set(E,{ref:E,...C}),()=>{T.itemMap.delete(E)})),r.jsx(m,{[p]:"",ref:k,children:S})});g.displayName=f;function b(_){const w=a(e+"CollectionConsumer",_);return be.useCallback(()=>{const S=w.collectionRef.current;if(!S)return[];const C=Array.from(S.querySelectorAll(`[${p}]`));return Array.from(w.itemMap.values()).sort((T,F)=>C.indexOf(T.ref.current)-C.indexOf(F.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:o,Slot:d,ItemSlot:g},b,s]}var Yye=y.createContext(void 0);function Lj(e){const t=y.useContext(Yye);return e||t||"ltr"}var gA="rovingFocusGroup.onEntryFocus",Qye={bubbles:!1,cancelable:!0},Lm="RovingFocusGroup",[JS,C$,Xye]=Ij(Lm),[Jye,j$]=Wa(Lm,[Xye]),[Zye,e1e]=Jye(Lm),N$=y.forwardRef((e,t)=>r.jsx(JS.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(JS.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(t1e,{...e,ref:t})})}));N$.displayName=Lm;var t1e=y.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:f=!1,...p}=e,m=y.useRef(null),g=At(t,m),b=Lj(a),[_,w]=Fo({prop:o,defaultProp:l??null,onChange:c,caller:Lm}),[A,S]=y.useState(!1),C=ia(d),E=C$(n),k=y.useRef(!1),[T,F]=y.useState(0);return y.useEffect(()=>{const M=m.current;if(M)return M.addEventListener(gA,C),()=>M.removeEventListener(gA,C)},[C]),r.jsx(Zye,{scope:n,orientation:s,dir:b,loop:i,currentTabStopId:_,onItemFocus:y.useCallback(M=>w(M),[w]),onItemShiftTab:y.useCallback(()=>S(!0),[]),onFocusableItemAdd:y.useCallback(()=>F(M=>M+1),[]),onFocusableItemRemove:y.useCallback(()=>F(M=>M-1),[]),children:r.jsx(lt.div,{tabIndex:A||T===0?-1:0,"data-orientation":s,...p,ref:g,style:{outline:"none",...e.style},onMouseDown:Oe(e.onMouseDown,()=>{k.current=!0}),onFocus:Oe(e.onFocus,M=>{const I=!k.current;if(M.target===M.currentTarget&&I&&!A){const R=new CustomEvent(gA,Qye);if(M.currentTarget.dispatchEvent(R),!R.defaultPrevented){const H=E().filter(B=>B.focusable),V=H.find(B=>B.active),K=H.find(B=>B.id===_),$=[V,K,...H].filter(Boolean).map(B=>B.ref.current);F$($,f)}}k.current=!1}),onBlur:Oe(e.onBlur,()=>S(!1))})})}),k$="RovingFocusGroupItem",E$=y.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:i=!1,tabStopId:a,children:o,...l}=e,c=Zi(),d=a||c,f=e1e(k$,n),p=f.currentTabStopId===d,m=C$(n),{onFocusableItemAdd:g,onFocusableItemRemove:b,currentTabStopId:_}=f;return y.useEffect(()=>{if(s)return g(),()=>b()},[s,g,b]),r.jsx(JS.ItemSlot,{scope:n,id:d,focusable:s,active:i,children:r.jsx(lt.span,{tabIndex:p?0:-1,"data-orientation":f.orientation,...l,ref:t,onMouseDown:Oe(e.onMouseDown,w=>{s?f.onItemFocus(d):w.preventDefault()}),onFocus:Oe(e.onFocus,()=>f.onItemFocus(d)),onKeyDown:Oe(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){f.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const A=i1e(w,f.orientation,f.dir);if(A!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let C=m().filter(E=>E.focusable).map(E=>E.ref.current);if(A==="last")C.reverse();else if(A==="prev"||A==="next"){A==="prev"&&C.reverse();const E=C.indexOf(w.currentTarget);C=f.loop?r1e(C,E+1):C.slice(E+1)}setTimeout(()=>F$(C))}}),children:typeof o=="function"?o({isCurrentTabStop:p,hasTabStop:_!=null}):o})})});E$.displayName=k$;var n1e={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function s1e(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function i1e(e,t,n){const s=s1e(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return n1e[s]}function F$(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function r1e(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var a1e=N$,o1e=E$,ZS=["Enter"," "],l1e=["ArrowDown","PageUp","Home"],T$=["ArrowUp","PageDown","End"],c1e=[...l1e,...T$],u1e={ltr:[...ZS,"ArrowRight"],rtl:[...ZS,"ArrowLeft"]},d1e={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Bm="Menu",[zp,h1e,f1e]=Ij(Bm),[_u,M$]=Wa(Bm,[f1e,tc,j$]),zm=tc(),R$=j$(),[D$,ic]=_u(Bm),[p1e,$m]=_u(Bm),O$=e=>{const{__scopeMenu:t,open:n=!1,children:s,dir:i,onOpenChange:a,modal:o=!0}=e,l=zm(t),[c,d]=y.useState(null),f=y.useRef(!1),p=ia(a),m=Lj(i);return y.useEffect(()=>{const g=()=>{f.current=!0,document.addEventListener("pointerdown",b,{capture:!0,once:!0}),document.addEventListener("pointermove",b,{capture:!0,once:!0})},b=()=>f.current=!1;return document.addEventListener("keydown",g,{capture:!0}),()=>{document.removeEventListener("keydown",g,{capture:!0}),document.removeEventListener("pointerdown",b,{capture:!0}),document.removeEventListener("pointermove",b,{capture:!0})}},[]),r.jsx(jm,{...l,children:r.jsx(D$,{scope:t,open:n,onOpenChange:p,content:c,onContentChange:d,children:r.jsx(p1e,{scope:t,onClose:y.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:f,dir:m,modal:o,children:s})})})};O$.displayName=Bm;var m1e="MenuAnchor",Bj=y.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e,i=zm(n);return r.jsx(Nm,{...i,...s,ref:t})});Bj.displayName=m1e;var zj="MenuPortal",[x1e,P$]=_u(zj,{forceMount:void 0}),I$=e=>{const{__scopeMenu:t,forceMount:n,children:s,container:i}=e,a=ic(zj,t);return r.jsx(x1e,{scope:t,forceMount:n,children:r.jsx(zr,{present:n||a.open,children:r.jsx(hh,{asChild:!0,container:i,children:s})})})};I$.displayName=zj;var Or="MenuContent",[g1e,$j]=_u(Or),L$=y.forwardRef((e,t)=>{const n=P$(Or,e.__scopeMenu),{forceMount:s=n.forceMount,...i}=e,a=ic(Or,e.__scopeMenu),o=$m(Or,e.__scopeMenu);return r.jsx(zp.Provider,{scope:e.__scopeMenu,children:r.jsx(zr,{present:s||a.open,children:r.jsx(zp.Slot,{scope:e.__scopeMenu,children:o.modal?r.jsx(b1e,{...i,ref:t}):r.jsx(v1e,{...i,ref:t})})})})}),b1e=y.forwardRef((e,t)=>{const n=ic(Or,e.__scopeMenu),s=y.useRef(null),i=At(t,s);return y.useEffect(()=>{const a=s.current;if(a)return Av(a)},[]),r.jsx(Vj,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Oe(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),v1e=y.forwardRef((e,t)=>{const n=ic(Or,e.__scopeMenu);return r.jsx(Vj,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),y1e=iu("MenuContent.ScrollLock"),Vj=y.forwardRef((e,t)=>{const{__scopeMenu:n,loop:s=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEntryFocus:c,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:p,onInteractOutside:m,onDismiss:g,disableOutsideScroll:b,..._}=e,w=ic(Or,n),A=$m(Or,n),S=zm(n),C=R$(n),E=h1e(n),[k,T]=y.useState(null),F=y.useRef(null),M=At(t,F,w.onContentChange),I=y.useRef(0),R=y.useRef(""),H=y.useRef(0),V=y.useRef(null),K=y.useRef("right"),q=y.useRef(0),$=b?Sm:y.Fragment,B=b?{as:y1e,allowPinchZoom:!0}:void 0,Y=W=>{const O=R.current+W,D=E().filter(oe=>!oe.disabled),Q=document.activeElement,z=D.find(oe=>oe.ref.current===Q)?.textValue,J=D.map(oe=>oe.textValue),ee=M1e(J,O,z),re=D.find(oe=>oe.textValue===ee)?.ref.current;(function oe(se){R.current=se,window.clearTimeout(I.current),se!==""&&(I.current=window.setTimeout(()=>oe(""),1e3))})(O),re&&setTimeout(()=>re.focus())};y.useEffect(()=>()=>window.clearTimeout(I.current),[]),_v();const U=y.useCallback(W=>K.current===V.current?.side&&D1e(W,V.current?.area),[]);return r.jsx(g1e,{scope:n,searchRef:R,onItemEnter:y.useCallback(W=>{U(W)&&W.preventDefault()},[U]),onItemLeave:y.useCallback(W=>{U(W)||(F.current?.focus(),T(null))},[U]),onTriggerLeave:y.useCallback(W=>{U(W)&&W.preventDefault()},[U]),pointerGraceTimerRef:H,onPointerGraceIntentChange:y.useCallback(W=>{V.current=W},[]),children:r.jsx($,{...B,children:r.jsx(Am,{asChild:!0,trapped:i,onMountAutoFocus:Oe(a,W=>{W.preventDefault(),F.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:r.jsx(dh,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:p,onInteractOutside:m,onDismiss:g,children:r.jsx(a1e,{asChild:!0,...C,dir:A.dir,orientation:"vertical",loop:s,currentTabStopId:k,onCurrentTabStopIdChange:T,onEntryFocus:Oe(c,W=>{A.isUsingKeyboardRef.current||W.preventDefault()}),preventScrollOnEntryFocus:!0,children:r.jsx(Fv,{role:"menu","aria-orientation":"vertical","data-state":t7(w.open),"data-radix-menu-content":"",dir:A.dir,...S,..._,ref:M,style:{outline:"none",..._.style},onKeyDown:Oe(_.onKeyDown,W=>{const D=W.target.closest("[data-radix-menu-content]")===W.currentTarget,Q=W.ctrlKey||W.altKey||W.metaKey,z=W.key.length===1;D&&(W.key==="Tab"&&W.preventDefault(),!Q&&z&&Y(W.key));const J=F.current;if(W.target!==J||!c1e.includes(W.key))return;W.preventDefault();const re=E().filter(oe=>!oe.disabled).map(oe=>oe.ref.current);T$.includes(W.key)&&re.reverse(),F1e(re)}),onBlur:Oe(e.onBlur,W=>{W.currentTarget.contains(W.target)||(window.clearTimeout(I.current),R.current="")}),onPointerMove:Oe(e.onPointerMove,$p(W=>{const O=W.target,D=q.current!==W.clientX;if(W.currentTarget.contains(O)&&D){const Q=W.clientX>q.current?"right":"left";K.current=Q,q.current=W.clientX}}))})})})})})})});L$.displayName=Or;var _1e="MenuGroup",Uj=y.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(lt.div,{role:"group",...s,ref:t})});Uj.displayName=_1e;var w1e="MenuLabel",B$=y.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(lt.div,{...s,ref:t})});B$.displayName=w1e;var j0="MenuItem",oR="menu.itemSelect",Gv=y.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:s,...i}=e,a=y.useRef(null),o=$m(j0,e.__scopeMenu),l=$j(j0,e.__scopeMenu),c=At(t,a),d=y.useRef(!1),f=()=>{const p=a.current;if(!n&&p){const m=new CustomEvent(oR,{bubbles:!0,cancelable:!0});p.addEventListener(oR,g=>s?.(g),{once:!0}),BL(p,m),m.defaultPrevented?d.current=!1:o.onClose()}};return r.jsx(z$,{...i,ref:c,disabled:n,onClick:Oe(e.onClick,f),onPointerDown:p=>{e.onPointerDown?.(p),d.current=!0},onPointerUp:Oe(e.onPointerUp,p=>{d.current||p.currentTarget?.click()}),onKeyDown:Oe(e.onKeyDown,p=>{const m=l.searchRef.current!=="";n||m&&p.key===" "||ZS.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});Gv.displayName=j0;var z$=y.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:s=!1,textValue:i,...a}=e,o=$j(j0,n),l=R$(n),c=y.useRef(null),d=At(t,c),[f,p]=y.useState(!1),[m,g]=y.useState("");return y.useEffect(()=>{const b=c.current;b&&g((b.textContent??"").trim())},[a.children]),r.jsx(zp.ItemSlot,{scope:n,disabled:s,textValue:i??m,children:r.jsx(o1e,{asChild:!0,...l,focusable:!s,children:r.jsx(lt.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":s||void 0,"data-disabled":s?"":void 0,...a,ref:d,onPointerMove:Oe(e.onPointerMove,$p(b=>{s?o.onItemLeave(b):(o.onItemEnter(b),b.defaultPrevented||b.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Oe(e.onPointerLeave,$p(b=>o.onItemLeave(b))),onFocus:Oe(e.onFocus,()=>p(!0)),onBlur:Oe(e.onBlur,()=>p(!1))})})})}),A1e="MenuCheckboxItem",$$=y.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:s,...i}=e;return r.jsx(q$,{scope:e.__scopeMenu,checked:n,children:r.jsx(Gv,{role:"menuitemcheckbox","aria-checked":N0(n)?"mixed":n,...i,ref:t,"data-state":qj(n),onSelect:Oe(i.onSelect,()=>s?.(N0(n)?!0:!n),{checkForDefaultPrevented:!1})})})});$$.displayName=A1e;var V$="MenuRadioGroup",[S1e,C1e]=_u(V$,{value:void 0,onValueChange:()=>{}}),U$=y.forwardRef((e,t)=>{const{value:n,onValueChange:s,...i}=e,a=ia(s);return r.jsx(S1e,{scope:e.__scopeMenu,value:n,onValueChange:a,children:r.jsx(Uj,{...i,ref:t})})});U$.displayName=V$;var H$="MenuRadioItem",W$=y.forwardRef((e,t)=>{const{value:n,...s}=e,i=C1e(H$,e.__scopeMenu),a=n===i.value;return r.jsx(q$,{scope:e.__scopeMenu,checked:a,children:r.jsx(Gv,{role:"menuitemradio","aria-checked":a,...s,ref:t,"data-state":qj(a),onSelect:Oe(s.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});W$.displayName=H$;var Hj="MenuItemIndicator",[q$,j1e]=_u(Hj,{checked:!1}),G$=y.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:s,...i}=e,a=j1e(Hj,n);return r.jsx(zr,{present:s||N0(a.checked)||a.checked===!0,children:r.jsx(lt.span,{...i,ref:t,"data-state":qj(a.checked)})})});G$.displayName=Hj;var N1e="MenuSeparator",K$=y.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(lt.div,{role:"separator","aria-orientation":"horizontal",...s,ref:t})});K$.displayName=N1e;var k1e="MenuArrow",Y$=y.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e,i=zm(n);return r.jsx(Tv,{...i,...s,ref:t})});Y$.displayName=k1e;var Wj="MenuSub",[E1e,Q$]=_u(Wj),X$=e=>{const{__scopeMenu:t,children:n,open:s=!1,onOpenChange:i}=e,a=ic(Wj,t),o=zm(t),[l,c]=y.useState(null),[d,f]=y.useState(null),p=ia(i);return y.useEffect(()=>(a.open===!1&&p(!1),()=>p(!1)),[a.open,p]),r.jsx(jm,{...o,children:r.jsx(D$,{scope:t,open:s,onOpenChange:p,content:d,onContentChange:f,children:r.jsx(E1e,{scope:t,contentId:Zi(),triggerId:Zi(),trigger:l,onTriggerChange:c,children:n})})})};X$.displayName=Wj;var Xf="MenuSubTrigger",J$=y.forwardRef((e,t)=>{const n=ic(Xf,e.__scopeMenu),s=$m(Xf,e.__scopeMenu),i=Q$(Xf,e.__scopeMenu),a=$j(Xf,e.__scopeMenu),o=y.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:c}=a,d={__scopeMenu:e.__scopeMenu},f=y.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return y.useEffect(()=>f,[f]),y.useEffect(()=>{const p=l.current;return()=>{window.clearTimeout(p),c(null)}},[l,c]),r.jsx(Bj,{asChild:!0,...d,children:r.jsx(z$,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":t7(n.open),...e,ref:yv(t,i.onTriggerChange),onClick:p=>{e.onClick?.(p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Oe(e.onPointerMove,$p(p=>{a.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),f()},100))})),onPointerLeave:Oe(e.onPointerLeave,$p(p=>{f();const m=n.content?.getBoundingClientRect();if(m){const g=n.content?.dataset.side,b=g==="right",_=b?-5:5,w=m[b?"left":"right"],A=m[b?"right":"left"];a.onPointerGraceIntentChange({area:[{x:p.clientX+_,y:p.clientY},{x:w,y:m.top},{x:A,y:m.top},{x:A,y:m.bottom},{x:w,y:m.bottom}],side:g}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(p),p.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:Oe(e.onKeyDown,p=>{const m=a.searchRef.current!=="";e.disabled||m&&p.key===" "||u1e[s.dir].includes(p.key)&&(n.onOpenChange(!0),n.content?.focus(),p.preventDefault())})})})});J$.displayName=Xf;var Z$="MenuSubContent",e7=y.forwardRef((e,t)=>{const n=P$(Or,e.__scopeMenu),{forceMount:s=n.forceMount,...i}=e,a=ic(Or,e.__scopeMenu),o=$m(Or,e.__scopeMenu),l=Q$(Z$,e.__scopeMenu),c=y.useRef(null),d=At(t,c);return r.jsx(zp.Provider,{scope:e.__scopeMenu,children:r.jsx(zr,{present:s||a.open,children:r.jsx(zp.Slot,{scope:e.__scopeMenu,children:r.jsx(Vj,{id:l.contentId,"aria-labelledby":l.triggerId,...i,ref:d,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:f=>{o.isUsingKeyboardRef.current&&c.current?.focus(),f.preventDefault()},onCloseAutoFocus:f=>f.preventDefault(),onFocusOutside:Oe(e.onFocusOutside,f=>{f.target!==l.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:Oe(e.onEscapeKeyDown,f=>{o.onClose(),f.preventDefault()}),onKeyDown:Oe(e.onKeyDown,f=>{const p=f.currentTarget.contains(f.target),m=d1e[o.dir].includes(f.key);p&&m&&(a.onOpenChange(!1),l.trigger?.focus(),f.preventDefault())})})})})})});e7.displayName=Z$;function t7(e){return e?"open":"closed"}function N0(e){return e==="indeterminate"}function qj(e){return N0(e)?"indeterminate":e?"checked":"unchecked"}function F1e(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function T1e(e,t){return e.map((n,s)=>e[(t+s)%e.length])}function M1e(e,t,n){const i=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let o=T1e(e,Math.max(a,0));i.length===1&&(o=o.filter(d=>d!==n));const c=o.find(d=>d.toLowerCase().startsWith(i.toLowerCase()));return c!==n?c:void 0}function R1e(e,t){const{x:n,y:s}=e;let i=!1;for(let a=0,o=t.length-1;a<t.length;o=a++){const l=t[a],c=t[o],d=l.x,f=l.y,p=c.x,m=c.y;f>s!=m>s&&n<(p-d)*(s-f)/(m-f)+d&&(i=!i)}return i}function D1e(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return R1e(n,t)}function $p(e){return t=>t.pointerType==="mouse"?e(t):void 0}var O1e=O$,P1e=Bj,I1e=I$,L1e=L$,B1e=Uj,z1e=B$,$1e=Gv,V1e=$$,U1e=U$,H1e=W$,W1e=G$,q1e=K$,G1e=Y$,K1e=X$,Y1e=J$,Q1e=e7,Kv="DropdownMenu",[X1e]=Wa(Kv,[M$]),ei=M$(),[J1e,n7]=X1e(Kv),s7=e=>{const{__scopeDropdownMenu:t,children:n,dir:s,open:i,defaultOpen:a,onOpenChange:o,modal:l=!0}=e,c=ei(t),d=y.useRef(null),[f,p]=Fo({prop:i,defaultProp:a??!1,onChange:o,caller:Kv});return r.jsx(J1e,{scope:t,triggerId:Zi(),triggerRef:d,contentId:Zi(),open:f,onOpenChange:p,onOpenToggle:y.useCallback(()=>p(m=>!m),[p]),modal:l,children:r.jsx(O1e,{...c,open:f,onOpenChange:p,dir:s,modal:l,children:n})})};s7.displayName=Kv;var i7="DropdownMenuTrigger",r7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:s=!1,...i}=e,a=n7(i7,n),o=ei(n);return r.jsx(P1e,{asChild:!0,...o,children:r.jsx(lt.button,{type:"button",id:a.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed","data-disabled":s?"":void 0,disabled:s,...i,ref:yv(t,a.triggerRef),onPointerDown:Oe(e.onPointerDown,l=>{!s&&l.button===0&&l.ctrlKey===!1&&(a.onOpenToggle(),a.open||l.preventDefault())}),onKeyDown:Oe(e.onKeyDown,l=>{s||(["Enter"," "].includes(l.key)&&a.onOpenToggle(),l.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});r7.displayName=i7;var Z1e="DropdownMenuPortal",a7=e=>{const{__scopeDropdownMenu:t,...n}=e,s=ei(t);return r.jsx(I1e,{...s,...n})};a7.displayName=Z1e;var o7="DropdownMenuContent",l7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=n7(o7,n),a=ei(n),o=y.useRef(!1);return r.jsx(L1e,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...s,ref:t,onCloseAutoFocus:Oe(e.onCloseAutoFocus,l=>{o.current||i.triggerRef.current?.focus(),o.current=!1,l.preventDefault()}),onInteractOutside:Oe(e.onInteractOutside,l=>{const c=l.detail.originalEvent,d=c.button===0&&c.ctrlKey===!0,f=c.button===2||d;(!i.modal||f)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});l7.displayName=o7;var e_e="DropdownMenuGroup",c7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=ei(n);return r.jsx(B1e,{...i,...s,ref:t})});c7.displayName=e_e;var t_e="DropdownMenuLabel",u7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=ei(n);return r.jsx(z1e,{...i,...s,ref:t})});u7.displayName=t_e;var n_e="DropdownMenuItem",d7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=ei(n);return r.jsx($1e,{...i,...s,ref:t})});d7.displayName=n_e;var s_e="DropdownMenuCheckboxItem",i_e=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=ei(n);return r.jsx(V1e,{...i,...s,ref:t})});i_e.displayName=s_e;var r_e="DropdownMenuRadioGroup",a_e=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=ei(n);return r.jsx(U1e,{...i,...s,ref:t})});a_e.displayName=r_e;var o_e="DropdownMenuRadioItem",l_e=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=ei(n);return r.jsx(H1e,{...i,...s,ref:t})});l_e.displayName=o_e;var c_e="DropdownMenuItemIndicator",u_e=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=ei(n);return r.jsx(W1e,{...i,...s,ref:t})});u_e.displayName=c_e;var d_e="DropdownMenuSeparator",h7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=ei(n);return r.jsx(q1e,{...i,...s,ref:t})});h7.displayName=d_e;var h_e="DropdownMenuArrow",f_e=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=ei(n);return r.jsx(G1e,{...i,...s,ref:t})});f_e.displayName=h_e;var p_e=e=>{const{__scopeDropdownMenu:t,children:n,open:s,onOpenChange:i,defaultOpen:a}=e,o=ei(t),[l,c]=Fo({prop:s,defaultProp:a??!1,onChange:i,caller:"DropdownMenuSub"});return r.jsx(K1e,{...o,open:l,onOpenChange:c,children:n})},m_e="DropdownMenuSubTrigger",f7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=ei(n);return r.jsx(Y1e,{...i,...s,ref:t})});f7.displayName=m_e;var x_e="DropdownMenuSubContent",p7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=ei(n);return r.jsx(Q1e,{...i,...s,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});p7.displayName=x_e;var Yv=s7,Qv=r7,Od=a7,Xv=l7,g_e=c7,b_e=u7,Bl=d7,v_e=h7,lR=p_e,cR=f7,uR=p7;function dR(e,[t,n]){return Math.min(n,Math.max(t,e))}function m7(e){const t=y.useRef({value:e,previous:e});return y.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var y_e=[" ","Enter","ArrowUp","ArrowDown"],__e=[" ","Enter"],uu="Select",[Jv,Zv,w_e]=Ij(uu),[vh]=Wa(uu,[w_e,tc]),ey=tc(),[A_e,rc]=vh(uu),[S_e,C_e]=vh(uu),x7=e=>{const{__scopeSelect:t,children:n,open:s,defaultOpen:i,onOpenChange:a,value:o,defaultValue:l,onValueChange:c,dir:d,name:f,autoComplete:p,disabled:m,required:g,form:b}=e,_=ey(t),[w,A]=y.useState(null),[S,C]=y.useState(null),[E,k]=y.useState(!1),T=Lj(d),[F,M]=Fo({prop:s,defaultProp:i??!1,onChange:a,caller:uu}),[I,R]=Fo({prop:o,defaultProp:l,onChange:c,caller:uu}),H=y.useRef(null),V=w?b||!!w.closest("form"):!0,[K,q]=y.useState(new Set),$=Array.from(K).map(B=>B.props.value).join(";");return r.jsx(jm,{..._,children:r.jsxs(A_e,{required:g,scope:t,trigger:w,onTriggerChange:A,valueNode:S,onValueNodeChange:C,valueNodeHasChildren:E,onValueNodeHasChildrenChange:k,contentId:Zi(),value:I,onValueChange:R,open:F,onOpenChange:M,dir:T,triggerPointerDownPosRef:H,disabled:m,children:[r.jsx(Jv.Provider,{scope:t,children:r.jsx(S_e,{scope:e.__scopeSelect,onNativeOptionAdd:y.useCallback(B=>{q(Y=>new Set(Y).add(B))},[]),onNativeOptionRemove:y.useCallback(B=>{q(Y=>{const U=new Set(Y);return U.delete(B),U})},[]),children:n})}),V?r.jsxs(L7,{"aria-hidden":!0,required:g,tabIndex:-1,name:f,autoComplete:p,value:I,onChange:B=>R(B.target.value),disabled:m,form:b,children:[I===void 0?r.jsx("option",{value:""}):null,Array.from(K)]},$):null]})})};x7.displayName=uu;var g7="SelectTrigger",b7=y.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:s=!1,...i}=e,a=ey(n),o=rc(g7,n),l=o.disabled||s,c=At(t,o.onTriggerChange),d=Zv(n),f=y.useRef("touch"),[p,m,g]=z7(_=>{const w=d().filter(C=>!C.disabled),A=w.find(C=>C.value===o.value),S=$7(w,_,A);S!==void 0&&o.onValueChange(S.value)}),b=_=>{l||(o.onOpenChange(!0),g()),_&&(o.triggerPointerDownPosRef.current={x:Math.round(_.pageX),y:Math.round(_.pageY)})};return r.jsx(Nm,{asChild:!0,...a,children:r.jsx(lt.button,{type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":B7(o.value)?"":void 0,...i,ref:c,onClick:Oe(i.onClick,_=>{_.currentTarget.focus(),f.current!=="mouse"&&b(_)}),onPointerDown:Oe(i.onPointerDown,_=>{f.current=_.pointerType;const w=_.target;w.hasPointerCapture(_.pointerId)&&w.releasePointerCapture(_.pointerId),_.button===0&&_.ctrlKey===!1&&_.pointerType==="mouse"&&(b(_),_.preventDefault())}),onKeyDown:Oe(i.onKeyDown,_=>{const w=p.current!=="";!(_.ctrlKey||_.altKey||_.metaKey)&&_.key.length===1&&m(_.key),!(w&&_.key===" ")&&y_e.includes(_.key)&&(b(),_.preventDefault())})})})});b7.displayName=g7;var v7="SelectValue",y7=y.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:i,children:a,placeholder:o="",...l}=e,c=rc(v7,n),{onValueNodeHasChildrenChange:d}=c,f=a!==void 0,p=At(t,c.onValueNodeChange);return Ks(()=>{d(f)},[d,f]),r.jsx(lt.span,{...l,ref:p,style:{pointerEvents:"none"},children:B7(c.value)?r.jsx(r.Fragment,{children:o}):a})});y7.displayName=v7;var j_e="SelectIcon",_7=y.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,...i}=e;return r.jsx(lt.span,{"aria-hidden":!0,...i,ref:t,children:s||"▼"})});_7.displayName=j_e;var N_e="SelectPortal",w7=e=>r.jsx(hh,{asChild:!0,...e});w7.displayName=N_e;var du="SelectContent",A7=y.forwardRef((e,t)=>{const n=rc(du,e.__scopeSelect),[s,i]=y.useState();if(Ks(()=>{i(new DocumentFragment)},[]),!n.open){const a=s;return a?Xr.createPortal(r.jsx(S7,{scope:e.__scopeSelect,children:r.jsx(Jv.Slot,{scope:e.__scopeSelect,children:r.jsx("div",{children:e.children})})}),a):null}return r.jsx(C7,{...e,ref:t})});A7.displayName=du;var Kr=10,[S7,ac]=vh(du),k_e="SelectContentImpl",E_e=iu("SelectContent.RemoveScroll"),C7=y.forwardRef((e,t)=>{const{__scopeSelect:n,position:s="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:l,sideOffset:c,align:d,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:g,sticky:b,hideWhenDetached:_,avoidCollisions:w,...A}=e,S=rc(du,n),[C,E]=y.useState(null),[k,T]=y.useState(null),F=At(t,oe=>E(oe)),[M,I]=y.useState(null),[R,H]=y.useState(null),V=Zv(n),[K,q]=y.useState(!1),$=y.useRef(!1);y.useEffect(()=>{if(C)return Av(C)},[C]),_v();const B=y.useCallback(oe=>{const[se,...ae]=V().map(je=>je.ref.current),[le]=ae.slice(-1),ge=document.activeElement;for(const je of oe)if(je===ge||(je?.scrollIntoView({block:"nearest"}),je===se&&k&&(k.scrollTop=0),je===le&&k&&(k.scrollTop=k.scrollHeight),je?.focus(),document.activeElement!==ge))return},[V,k]),Y=y.useCallback(()=>B([M,C]),[B,M,C]);y.useEffect(()=>{K&&Y()},[K,Y]);const{onOpenChange:U,triggerPointerDownPosRef:W}=S;y.useEffect(()=>{if(C){let oe={x:0,y:0};const se=le=>{oe={x:Math.abs(Math.round(le.pageX)-(W.current?.x??0)),y:Math.abs(Math.round(le.pageY)-(W.current?.y??0))}},ae=le=>{oe.x<=10&&oe.y<=10?le.preventDefault():C.contains(le.target)||U(!1),document.removeEventListener("pointermove",se),W.current=null};return W.current!==null&&(document.addEventListener("pointermove",se),document.addEventListener("pointerup",ae,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",se),document.removeEventListener("pointerup",ae,{capture:!0})}}},[C,U,W]),y.useEffect(()=>{const oe=()=>U(!1);return window.addEventListener("blur",oe),window.addEventListener("resize",oe),()=>{window.removeEventListener("blur",oe),window.removeEventListener("resize",oe)}},[U]);const[O,D]=z7(oe=>{const se=V().filter(ge=>!ge.disabled),ae=se.find(ge=>ge.ref.current===document.activeElement),le=$7(se,oe,ae);le&&setTimeout(()=>le.ref.current.focus())}),Q=y.useCallback((oe,se,ae)=>{const le=!$.current&&!ae;(S.value!==void 0&&S.value===se||le)&&(I(oe),le&&($.current=!0))},[S.value]),z=y.useCallback(()=>C?.focus(),[C]),J=y.useCallback((oe,se,ae)=>{const le=!$.current&&!ae;(S.value!==void 0&&S.value===se||le)&&H(oe)},[S.value]),ee=s==="popper"?eC:j7,re=ee===eC?{side:l,sideOffset:c,align:d,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:g,sticky:b,hideWhenDetached:_,avoidCollisions:w}:{};return r.jsx(S7,{scope:n,content:C,viewport:k,onViewportChange:T,itemRefCallback:Q,selectedItem:M,onItemLeave:z,itemTextRefCallback:J,focusSelectedItem:Y,selectedItemText:R,position:s,isPositioned:K,searchRef:O,children:r.jsx(Sm,{as:E_e,allowPinchZoom:!0,children:r.jsx(Am,{asChild:!0,trapped:S.open,onMountAutoFocus:oe=>{oe.preventDefault()},onUnmountAutoFocus:Oe(i,oe=>{S.trigger?.focus({preventScroll:!0}),oe.preventDefault()}),children:r.jsx(dh,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:oe=>oe.preventDefault(),onDismiss:()=>S.onOpenChange(!1),children:r.jsx(ee,{role:"listbox",id:S.contentId,"data-state":S.open?"open":"closed",dir:S.dir,onContextMenu:oe=>oe.preventDefault(),...A,...re,onPlaced:()=>q(!0),ref:F,style:{display:"flex",flexDirection:"column",outline:"none",...A.style},onKeyDown:Oe(A.onKeyDown,oe=>{const se=oe.ctrlKey||oe.altKey||oe.metaKey;if(oe.key==="Tab"&&oe.preventDefault(),!se&&oe.key.length===1&&D(oe.key),["ArrowUp","ArrowDown","Home","End"].includes(oe.key)){let le=V().filter(ge=>!ge.disabled).map(ge=>ge.ref.current);if(["ArrowUp","End"].includes(oe.key)&&(le=le.slice().reverse()),["ArrowUp","ArrowDown"].includes(oe.key)){const ge=oe.target,je=le.indexOf(ge);le=le.slice(je+1)}setTimeout(()=>B(le)),oe.preventDefault()}})})})})})})});C7.displayName=k_e;var F_e="SelectItemAlignedPosition",j7=y.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:s,...i}=e,a=rc(du,n),o=ac(du,n),[l,c]=y.useState(null),[d,f]=y.useState(null),p=At(t,F=>f(F)),m=Zv(n),g=y.useRef(!1),b=y.useRef(!0),{viewport:_,selectedItem:w,selectedItemText:A,focusSelectedItem:S}=o,C=y.useCallback(()=>{if(a.trigger&&a.valueNode&&l&&d&&_&&w&&A){const F=a.trigger.getBoundingClientRect(),M=d.getBoundingClientRect(),I=a.valueNode.getBoundingClientRect(),R=A.getBoundingClientRect();if(a.dir!=="rtl"){const ge=R.left-M.left,je=I.left-ge,Ee=F.left-je,de=F.width+Ee,me=Math.max(de,M.width),$e=window.innerWidth-Kr,nt=dR(je,[Kr,Math.max(Kr,$e-me)]);l.style.minWidth=de+"px",l.style.left=nt+"px"}else{const ge=M.right-R.right,je=window.innerWidth-I.right-ge,Ee=window.innerWidth-F.right-je,de=F.width+Ee,me=Math.max(de,M.width),$e=window.innerWidth-Kr,nt=dR(je,[Kr,Math.max(Kr,$e-me)]);l.style.minWidth=de+"px",l.style.right=nt+"px"}const H=m(),V=window.innerHeight-Kr*2,K=_.scrollHeight,q=window.getComputedStyle(d),$=parseInt(q.borderTopWidth,10),B=parseInt(q.paddingTop,10),Y=parseInt(q.borderBottomWidth,10),U=parseInt(q.paddingBottom,10),W=$+B+K+U+Y,O=Math.min(w.offsetHeight*5,W),D=window.getComputedStyle(_),Q=parseInt(D.paddingTop,10),z=parseInt(D.paddingBottom,10),J=F.top+F.height/2-Kr,ee=V-J,re=w.offsetHeight/2,oe=w.offsetTop+re,se=$+B+oe,ae=W-se;if(se<=J){const ge=H.length>0&&w===H[H.length-1].ref.current;l.style.bottom="0px";const je=d.clientHeight-_.offsetTop-_.offsetHeight,Ee=Math.max(ee,re+(ge?z:0)+je+Y),de=se+Ee;l.style.height=de+"px"}else{const ge=H.length>0&&w===H[0].ref.current;l.style.top="0px";const Ee=Math.max(J,$+_.offsetTop+(ge?Q:0)+re)+ae;l.style.height=Ee+"px",_.scrollTop=se-J+_.offsetTop}l.style.margin=`${Kr}px 0`,l.style.minHeight=O+"px",l.style.maxHeight=V+"px",s?.(),requestAnimationFrame(()=>g.current=!0)}},[m,a.trigger,a.valueNode,l,d,_,w,A,a.dir,s]);Ks(()=>C(),[C]);const[E,k]=y.useState();Ks(()=>{d&&k(window.getComputedStyle(d).zIndex)},[d]);const T=y.useCallback(F=>{F&&b.current===!0&&(C(),S?.(),b.current=!1)},[C,S]);return r.jsx(M_e,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:g,onScrollButtonChange:T,children:r.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:r.jsx(lt.div,{...i,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});j7.displayName=F_e;var T_e="SelectPopperPosition",eC=y.forwardRef((e,t)=>{const{__scopeSelect:n,align:s="start",collisionPadding:i=Kr,...a}=e,o=ey(n);return r.jsx(Fv,{...o,...a,ref:t,align:s,collisionPadding:i,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)"}})});eC.displayName=T_e;var[M_e,Gj]=vh(du,{}),tC="SelectViewport",N7=y.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:s,...i}=e,a=ac(tC,n),o=Gj(tC,n),l=At(t,a.onViewportChange),c=y.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(Jv.Slot,{scope:n,children:r.jsx(lt.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:Oe(i.onScroll,d=>{const f=d.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:m}=o;if(m?.current&&p){const g=Math.abs(c.current-f.scrollTop);if(g>0){const b=window.innerHeight-Kr*2,_=parseFloat(p.style.minHeight),w=parseFloat(p.style.height),A=Math.max(_,w);if(A<b){const S=A+g,C=Math.min(b,S),E=S-C;p.style.height=C+"px",p.style.bottom==="0px"&&(f.scrollTop=E>0?E:0,p.style.justifyContent="flex-end")}}}c.current=f.scrollTop})})})]})});N7.displayName=tC;var k7="SelectGroup",[R_e,D_e]=vh(k7),E7=y.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,i=Zi();return r.jsx(R_e,{scope:n,id:i,children:r.jsx(lt.div,{role:"group","aria-labelledby":i,...s,ref:t})})});E7.displayName=k7;var F7="SelectLabel",T7=y.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,i=D_e(F7,n);return r.jsx(lt.div,{id:i.id,...s,ref:t})});T7.displayName=F7;var k0="SelectItem",[O_e,M7]=vh(k0),R7=y.forwardRef((e,t)=>{const{__scopeSelect:n,value:s,disabled:i=!1,textValue:a,...o}=e,l=rc(k0,n),c=ac(k0,n),d=l.value===s,[f,p]=y.useState(a??""),[m,g]=y.useState(!1),b=At(t,S=>c.itemRefCallback?.(S,s,i)),_=Zi(),w=y.useRef("touch"),A=()=>{i||(l.onValueChange(s),l.onOpenChange(!1))};if(s==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return r.jsx(O_e,{scope:n,value:s,disabled:i,textId:_,isSelected:d,onItemTextChange:y.useCallback(S=>{p(C=>C||(S?.textContent??"").trim())},[]),children:r.jsx(Jv.ItemSlot,{scope:n,value:s,disabled:i,textValue:f,children:r.jsx(lt.div,{role:"option","aria-labelledby":_,"data-highlighted":m?"":void 0,"aria-selected":d&&m,"data-state":d?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...o,ref:b,onFocus:Oe(o.onFocus,()=>g(!0)),onBlur:Oe(o.onBlur,()=>g(!1)),onClick:Oe(o.onClick,()=>{w.current!=="mouse"&&A()}),onPointerUp:Oe(o.onPointerUp,()=>{w.current==="mouse"&&A()}),onPointerDown:Oe(o.onPointerDown,S=>{w.current=S.pointerType}),onPointerMove:Oe(o.onPointerMove,S=>{w.current=S.pointerType,i?c.onItemLeave?.():w.current==="mouse"&&S.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Oe(o.onPointerLeave,S=>{S.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Oe(o.onKeyDown,S=>{c.searchRef?.current!==""&&S.key===" "||(__e.includes(S.key)&&A(),S.key===" "&&S.preventDefault())})})})})});R7.displayName=k0;var Jf="SelectItemText",D7=y.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:i,...a}=e,o=rc(Jf,n),l=ac(Jf,n),c=M7(Jf,n),d=C_e(Jf,n),[f,p]=y.useState(null),m=At(t,A=>p(A),c.onItemTextChange,A=>l.itemTextRefCallback?.(A,c.value,c.disabled)),g=f?.textContent,b=y.useMemo(()=>r.jsx("option",{value:c.value,disabled:c.disabled,children:g},c.value),[c.disabled,c.value,g]),{onNativeOptionAdd:_,onNativeOptionRemove:w}=d;return Ks(()=>(_(b),()=>w(b)),[_,w,b]),r.jsxs(r.Fragment,{children:[r.jsx(lt.span,{id:c.textId,...a,ref:m}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Xr.createPortal(a.children,o.valueNode):null]})});D7.displayName=Jf;var O7="SelectItemIndicator",P7=y.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return M7(O7,n).isSelected?r.jsx(lt.span,{"aria-hidden":!0,...s,ref:t}):null});P7.displayName=O7;var nC="SelectScrollUpButton",P_e=y.forwardRef((e,t)=>{const n=ac(nC,e.__scopeSelect),s=Gj(nC,e.__scopeSelect),[i,a]=y.useState(!1),o=At(t,s.onScrollButtonChange);return Ks(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=c.scrollTop>0;a(d)};const c=n.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),i?r.jsx(I7,{...e,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop-c.offsetHeight)}}):null});P_e.displayName=nC;var sC="SelectScrollDownButton",I_e=y.forwardRef((e,t)=>{const n=ac(sC,e.__scopeSelect),s=Gj(sC,e.__scopeSelect),[i,a]=y.useState(!1),o=At(t,s.onScrollButtonChange);return Ks(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=c.scrollHeight-c.clientHeight,f=Math.ceil(c.scrollTop)<d;a(f)};const c=n.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),i?r.jsx(I7,{...e,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop+c.offsetHeight)}}):null});I_e.displayName=sC;var I7=y.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:s,...i}=e,a=ac("SelectScrollButton",n),o=y.useRef(null),l=Zv(n),c=y.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return y.useEffect(()=>()=>c(),[c]),Ks(()=>{l().find(f=>f.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[l]),r.jsx(lt.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:Oe(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(s,50))}),onPointerMove:Oe(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(s,50))}),onPointerLeave:Oe(i.onPointerLeave,()=>{c()})})}),L_e="SelectSeparator",B_e=y.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return r.jsx(lt.div,{"aria-hidden":!0,...s,ref:t})});B_e.displayName=L_e;var iC="SelectArrow",z_e=y.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,i=ey(n),a=rc(iC,n),o=ac(iC,n);return a.open&&o.position==="popper"?r.jsx(Tv,{...i,...s,ref:t}):null});z_e.displayName=iC;var $_e="SelectBubbleInput",L7=y.forwardRef(({__scopeSelect:e,value:t,...n},s)=>{const i=y.useRef(null),a=At(s,i),o=m7(t);return y.useEffect(()=>{const l=i.current;if(!l)return;const c=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(c,"value").set;if(o!==t&&f){const p=new Event("change",{bubbles:!0});f.call(l,t),l.dispatchEvent(p)}},[o,t]),r.jsx(lt.select,{...n,style:{...G9,...n.style},ref:a,defaultValue:t})});L7.displayName=$_e;function B7(e){return e===""||e===void 0}function z7(e){const t=ia(e),n=y.useRef(""),s=y.useRef(0),i=y.useCallback(o=>{const l=n.current+o;t(l),(function c(d){n.current=d,window.clearTimeout(s.current),d!==""&&(s.current=window.setTimeout(()=>c(""),1e3))})(l)},[t]),a=y.useCallback(()=>{n.current="",window.clearTimeout(s.current)},[]);return y.useEffect(()=>()=>window.clearTimeout(s.current),[]),[n,i,a]}function $7(e,t,n){const i=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let o=V_e(e,Math.max(a,0));i.length===1&&(o=o.filter(d=>d!==n));const c=o.find(d=>d.textValue.toLowerCase().startsWith(i.toLowerCase()));return c!==n?c:void 0}function V_e(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var ss=x7,is=b7,Ds=y7,Yl=_7,rs=w7,as=A7,os=N7,Ro=E7,Do=T7,vn=R7,yn=D7,ui=P7;function bt({label:e,side:t="top",children:n}){return r.jsx(sj,{delayDuration:300,children:r.jsxs(iB,{children:[r.jsx(rB,{asChild:!0,children:n}),r.jsx(aB,{children:r.jsxs(oB,{side:t,sideOffset:6,className:"px-2 py-1 rounded-md bg-[#2A2A35] border border-[#3A3A48] text-[#F0F0F5] text-[11px] font-medium shadow-lg z-[9999] select-none",children:[e,r.jsx(lB,{className:"fill-[#2A2A35]"})]})})]})})}const Vp=[{label:"Local",tag:"local",models:[]},{label:"OpenRouter Free",tag:"free",provider:"openrouter",models:[{id:"openrouter/meta-llama/llama-3.3-70b-instruct:free",label:"Llama 3.3 70B"},{id:"openrouter/google/gemma-3-27b-it:free",label:"Gemma 3 27B"},{id:"openrouter/mistralai/mistral-7b-instruct:free",label:"Mistral 7B"}]},{label:"OpenRouter Paid",tag:"paid",provider:"openrouter",models:[{id:"openrouter/anthropic/claude-haiku-4.5",label:"Haiku 4.5"},{id:"openrouter/anthropic/claude-sonnet-4.6",label:"Sonnet 4.6"},{id:"openrouter/anthropic/claude-opus-4.7",label:"Opus 4.7"},{id:"openrouter/openai/gpt-5.4-mini",label:"GPT-5.4 mini"},{id:"openrouter/openai/gpt-5.4",label:"GPT-5.4"},{id:"openrouter/google/gemini-2.5-flash",label:"Gemini 2.5 Flash"},{id:"openrouter/google/gemini-2.5-pro",label:"Gemini 2.5 Pro"}]},{label:"Anthropic",tag:"paid",provider:"anthropic",models:[{id:"anthropic/claude-haiku-4.5",label:"Haiku 4.5"},{id:"anthropic/claude-sonnet-4.6",label:"Sonnet 4.6"},{id:"anthropic/claude-opus-4.7",label:"Opus 4.7"}]},{label:"OpenAI",tag:"paid",provider:"openai",models:[{id:"openai/gpt-5.4-nano",label:"GPT-5.4 nano"},{id:"openai/gpt-5.4-mini",label:"GPT-5.4 mini"},{id:"openai/gpt-5.4",label:"GPT-5.4"}]},{label:"Google",tag:"paid",provider:"google",models:[{id:"google/gemini-2.5-flash",label:"Gemini 2.5 Flash"},{id:"google/gemini-2.5-pro",label:"Gemini 2.5 Pro"}]}],jo={local:"text-[#10B981] bg-[#10B981]/10",free:"text-[#8B5CF6] bg-[#8B5CF6]/10",paid:"text-[#F59E0B] bg-[#F59E0B]/10",custom:"text-[#6366F1] bg-[#6366F1]/10"},U_e=["vllm/","ollama/","openrouter/","anthropic/","openai/","google/","claude-code/"];function E0(e){for(const t of U_e)if(e.startsWith(t))return e.slice(t.length);return e}function ta(e){if(!e)return"";for(const n of Vp){const s=n.models.find(i=>i.id===e);if(s)return s.label}const t=E0(e);for(const n of Vp){const s=n.models.find(i=>E0(i.id)===t);if(s)return s.label}return t}function Up(e){if(!e)return"custom";if(e.startsWith("vllm/")||e.startsWith("ollama/"))return"local";for(const n of Vp)if(n.models.some(s=>s.id===e))return n.tag;const t=E0(e);for(const n of Vp)if(n.models.some(s=>E0(s.id)===t))return n.tag;return e.startsWith("openrouter/")||e.startsWith("anthropic/")||e.startsWith("openai/")||e.startsWith("google/")||e.startsWith("claude-code/")?"paid":"custom"}function Vm(){const{data:e}=L.agents.discoverLocalModels.useQuery(void 0,{staleTime:6e4,refetchOnWindowFocus:!1}),{data:t}=L.onboarding.providersConfigured.useQuery(void 0,{staleTime:6e4,refetchOnWindowFocus:!1}),n=(e??[]).map(o=>({id:o.id,label:o.parameterSize?`${o.name} (${o.parameterSize})`:o.name})),s=Vp.map(o=>o.tag==="local"?{...o,models:n}:o).filter(o=>o.models.length===0?!1:!o.provider||t===void 0?!0:!!t[o.provider]),i=!!t&&(t.openrouter||t.anthropic||t.openai||t.google),a=t!==void 0&&!i;return{groups:s,needsHostedProviderSetup:a,needsOpenRouterSetup:a}}const H_e=8;function ty({value:e,onChange:t,onSubmit:n,placeholder:s="Add model ID...",className:i="",autoFocus:a=!1}){const{data:o}=L.agents.discoverLocalModels.useQuery(void 0,{staleTime:6e4,refetchOnWindowFocus:!1}),{data:l}=L.onboarding.discoverProviderModels.useQuery(void 0,{staleTime:6e4,refetchOnWindowFocus:!1}),c=y.useMemo(()=>{const w=(o??[]).map(S=>({id:S.id,label:S.parameterSize?`${S.name} (${S.parameterSize})`:S.name})),A=[...l?.openrouter??[],...l?.anthropic??[],...l?.openai??[],...l?.google??[]];return[...w,...A]},[o,l]),[d,f]=y.useState(!1),[p,m]=y.useState(0),g=y.useMemo(()=>{const w=e.trim().toLowerCase();return w?c.filter(A=>A.id.toLowerCase().includes(w)||A.label.toLowerCase().includes(w)).slice(0,H_e):[]},[e,c]);y.useEffect(()=>{m(0)},[e]);function b(w){if(w.key==="ArrowDown"){g.length>0&&(w.preventDefault(),f(!0),m(A=>Math.min(A+1,g.length-1)));return}if(w.key==="ArrowUp"){g.length>0&&(w.preventDefault(),f(!0),m(A=>Math.max(A-1,0)));return}if(w.key==="Tab"){if(d&&g[p]){w.preventDefault(),t(g[p].id);return}return}if(w.key==="Escape"){d&&(w.preventDefault(),f(!1));return}if(w.key==="Enter"){w.preventDefault();const A=d&&g[p]?g[p].id:e.trim();if(!A)return;n(A),f(!1)}}const _=y.useRef(null);return r.jsxs("div",{className:`relative ${i}`,children:[r.jsx("input",{ref:_,autoFocus:a,value:e,placeholder:s,onChange:w=>{t(w.target.value),f(!0)},onFocus:()=>{e&&f(!0)},onBlur:()=>{setTimeout(()=>f(!1),120)},onKeyDown:b,className:"w-full bg-[#13131A] border border-[#2A2A35] rounded px-2 py-1.5 text-[11px] text-[#C8C8D4] placeholder:text-[#5A5A6E] outline-none focus:border-[#6366F1] transition-colors"}),d&&g.length>0&&r.jsx("div",{className:"absolute left-0 right-0 top-full mt-1 bg-[#1C1C24] border border-[#2A2A35] rounded-lg shadow-xl py-1 z-[10000] max-h-[240px] overflow-y-auto",children:g.map((w,A)=>r.jsxs("button",{type:"button",onMouseDown:S=>{S.preventDefault(),n(w.id),f(!1)},onMouseEnter:()=>m(A),className:`block w-full text-left px-3 py-1.5 text-[11px] outline-none transition-colors ${A===p?"bg-white/10 text-[#F0F0F5]":"text-[#C8C8D4] hover:bg-white/5"}`,children:[r.jsx("div",{className:"truncate",children:w.id}),w.label!==w.id&&r.jsx("div",{className:"truncate text-[10px] text-[#5A5A6E]",children:w.label})]},w.id))})]})}const hR={sessionTokensIn:0,sessionTokensOut:0,sessionCostUsd:0,contextWindow:null},ny=$o(e=>({stats:{},setStats:(t,n)=>e(s=>({stats:{...s.stats,[t]:n}})),updateFromWs:(t,n)=>e(s=>({stats:{...s.stats,[t]:{...s.stats[t]??hR,...n}}})),clearStats:t=>e(n=>({stats:{...n.stats,[t]:hR}}))}));function bA(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function fR(e){return e<.005?"$0.00":e<1?`$${e.toFixed(2)}`:`$${e.toFixed(2)}`}const W_e=1e5;function q_e({channelId:e}){const t=L.useUtils(),{data:n}=L.channels.sessionStats.useQuery({channelId:e}),{stats:s,setStats:i,clearStats:a}=ny(),o=L.channels.resetSessionStats.useMutation({onSuccess:()=>{a(e),t.channels.sessionStats.invalidate({channelId:e})}});y.useEffect(()=>{n&&i(e,n)},[n,e,i]);const l=s[e];if(!l)return null;const c=l.sessionTokensIn+l.sessionTokensOut;if(c===0)return null;const d=l.contextWindow??W_e,f=l.sessionTokensIn/d,p=f>.8?"text-red-400":f>.5?"text-amber-400":"text-[#5A5A6E]";return r.jsxs(Ys,{children:[r.jsx(ci,{asChild:!0,children:r.jsxs("button",{className:`flex items-center gap-1 px-2 py-1 rounded-md text-[11px] font-medium transition-colors hover:bg-white/5 ${p}`,children:[r.jsx("span",{children:bA(c)}),r.jsx("span",{className:"opacity-50",children:"·"}),r.jsx("span",{children:fR(l.sessionCostUsd)})]})}),r.jsx(Qs,{children:r.jsxs(Xs,{align:"end",sideOffset:6,className:"bg-[#1C1C24] border border-[#2A2A35] rounded-lg shadow-xl w-[220px] z-50 p-3",children:[r.jsxs("div",{className:"space-y-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[11px] text-[#8A8A99]",children:"Input tokens"}),r.jsx("span",{className:"text-[12px] text-[#C8C8D4] font-medium",children:bA(l.sessionTokensIn)})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[11px] text-[#8A8A99]",children:"Output tokens"}),r.jsx("span",{className:"text-[12px] text-[#C8C8D4] font-medium",children:bA(l.sessionTokensOut)})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[11px] text-[#8A8A99]",children:"Total cost"}),r.jsx("span",{className:"text-[12px] text-[#C8C8D4] font-medium",children:fR(l.sessionCostUsd)})]}),r.jsxs("div",{className:"pt-1",children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("span",{className:"text-[11px] text-[#8A8A99]",children:"Context usage"}),r.jsxs("span",{className:"text-[11px] text-[#5A5A6E]",children:[Math.round(f*100),"%"]})]}),r.jsx("div",{className:"h-1.5 bg-[#2A2A35] rounded-full overflow-hidden",children:r.jsx("div",{className:`h-full rounded-full transition-all ${f>.8?"bg-red-400":f>.5?"bg-amber-400":"bg-[#6366F1]"}`,style:{width:`${Math.min(f*100,100)}%`}})})]}),r.jsx("button",{onClick:()=>o.mutate({channelId:e}),disabled:o.isPending,className:"w-full mt-1 px-2 py-1.5 rounded-md text-[11px] text-[#8A8A99] hover:text-[#C8C8D4] hover:bg-white/5 transition-colors border border-[#2A2A35]",children:o.isPending?"Resetting...":"Reset counters"})]}),r.jsx(oa,{className:"fill-[#2A2A35]"})]})})]})}const V7=$o()(gj(e=>({lastTab:{},setLast:(t,n)=>e(s=>({lastTab:{...s.lastTab,[t]:n}})),clearLast:t=>e(n=>{const s={...n.lastTab};return delete s[t],{lastTab:s}})}),{name:"damn-dev-last-active-tab"}));function pR(e,t){return e.tabName&&e.tabName.trim().length>0?e.tabName:t?"Main":`Tab ${e.tabOrder+1}`}function G_e({baseChannelId:e,activeTabId:t,agentColor:n}){const s=an(),i=L.useUtils(),{data:a=[]}=dfe(e),[o,l]=y.useState(null),[c,d]=y.useState(""),[f,p]=y.useState(null),m=y.useRef(null),g=y.useCallback(()=>{i.channels.get.invalidate({channelId:e}),i.channels.list.invalidate()},[i,e]),b=L.channels.createTab.useMutation({onSuccess:k=>{g(),s(`/channels/${k.id}`)}}),_=L.channels.renameTab.useMutation({onSuccess:g}),w=L.channels.deleteTab.useMutation({onSuccess:(k,T)=>{g(),p(null),T.channelId===t&&s(`/channels/${e}`)}});if(y.useEffect(()=>{o&&m.current&&(m.current.focus(),m.current.select())},[o]),e==="chan_coo")return null;const A=(k,T)=>{l(k),d(T)},S=()=>{if(!o)return;const k=c.trim(),T=a.find(F=>F.id===o);T&&k&&k!==pR(T,T.id===e)&&_.mutate({channelId:o,name:k}),l(null)},C=()=>{l(null),d("")},E=n??"#6366F1";return r.jsxs("div",{className:"flex items-center gap-1 px-3 h-9 border-t border-[#2A2A35] bg-[#0F0F11] overflow-x-auto scrollbar-none",children:[a.map(k=>{const T=k.id===t,F=k.id===e,M=k.unreadCount>0&&!T,I=o===k.id,R=pR(k,F),H=()=>{I||(T?A(k.id,R):(F&&V7.getState().clearLast(e),s(`/channels/${k.id}`)))};return r.jsx("div",{className:ye("group relative flex items-center gap-1.5 px-2.5 h-7 rounded-md text-[12px] transition-colors select-none flex-shrink-0",T?"bg-[#1A1A22] text-[#F0F0F5]":"text-[#8A8A99] hover:bg-[#15151B] hover:text-[#C0C0CC] cursor-pointer",T&&!I&&"cursor-text"),style:T?{boxShadow:`inset 0 -2px 0 ${E}`}:void 0,onClick:H,onDoubleClick:V=>{V.stopPropagation(),I||A(k.id,R)},children:I?r.jsx("input",{ref:m,value:c,onChange:V=>d(V.target.value),onBlur:S,onKeyDown:V=>{V.key==="Enter"?S():V.key==="Escape"&&C()},onClick:V=>V.stopPropagation(),onDoubleClick:V=>V.stopPropagation(),maxLength:80,className:"bg-transparent outline-none text-[12px] text-[#F0F0F5] w-[120px]"}):r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"truncate max-w-[140px]",title:R,children:R}),M&&r.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:E}}),!F&&r.jsxs(Ys,{open:f===k.id,onOpenChange:V=>p(V?k.id:null),children:[r.jsx(ci,{asChild:!0,children:r.jsx("button",{onClick:V=>{V.stopPropagation(),p(k.id)},className:ye("transition-opacity text-[#6A6A78] hover:text-[#F0F0F5] ml-0.5",T||f===k.id?"opacity-100":"opacity-0 group-hover:opacity-100"),"aria-label":"Close tab",children:r.jsx(Te,{className:"w-3 h-3"})})}),r.jsx(Qs,{children:r.jsxs(Xs,{className:"bg-[#15151B] border border-[#2A2A35] rounded-lg shadow-xl p-3 w-[220px] z-50",sideOffset:8,onOpenAutoFocus:V=>V.preventDefault(),children:[r.jsx("p",{className:"text-[12px] text-[#F0F0F5] font-medium mb-1",children:"Delete this tab?"}),r.jsxs("p",{className:"text-[11px] text-[#8A8A99] mb-3 leading-snug",children:["All messages in “",R,"” will be permanently removed."]}),r.jsxs("div",{className:"flex gap-2 justify-end",children:[r.jsx("button",{onClick:V=>{V.stopPropagation(),p(null)},className:"px-2.5 h-6 rounded text-[11px] text-[#8A8A99] hover:bg-[#1A1A22] hover:text-[#F0F0F5] transition-colors",children:"Cancel"}),r.jsx("button",{onClick:V=>{V.stopPropagation(),w.mutate({channelId:k.id})},disabled:w.isPending,className:"px-2.5 h-6 rounded text-[11px] bg-red-500/10 text-red-400 hover:bg-red-500/20 transition-colors disabled:opacity-50",children:"Delete"})]}),r.jsx(oa,{className:"fill-[#2A2A35]"})]})})]})]})},k.id)}),r.jsx("button",{onClick:()=>b.mutate({parentChannelId:e}),disabled:b.isPending,className:"flex items-center justify-center w-6 h-6 rounded-md text-[#6A6A78] hover:bg-[#15151B] hover:text-[#F0F0F5] transition-colors flex-shrink-0 disabled:opacity-50","aria-label":"New tab",children:r.jsx(wt,{className:"w-3.5 h-3.5"})})]})}function K_e(e){const t=Date.now()-e.getTime(),n=Math.floor(t/6e4);if(n<1)return"Last seen just now";if(n<60)return`Last seen ${n}m ago`;const s=Math.floor(n/60);return s<24?`Last seen ${s}h ago`:`Last seen ${Math.floor(s/24)}d ago`}function Y_e({userId:e}){const t=Sfe(e);return t?r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"relative flex items-center justify-center w-2 h-2",children:r.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:t.online?"#10B981":"#3A3A45"}})}),r.jsx("span",{className:"text-[12px] text-[#8A8A99]",children:t.online?"Online":t.lastSeenAt?K_e(new Date(t.lastSeenAt)):"Offline"})]}):null}function Q_e({channelId:e,agentId:t,defaultModel:n,agentColor:s,customModels:i=[]}){const[a,o]=y.useState(""),{data:l}=L.agents.getConversationModel.useQuery({channelId:e}),c=L.agents.setConversationModel.useMutation(),d=L.agents.update.useMutation(),f=L.agents.addCustomModel.useMutation(),p=L.useUtils(),{groups:m,needsHostedProviderSetup:g}=Vm(),b=l?.model??null,_=b!==null,w=b??n,A=Up(w);function S(C){C==="__reset__"?c.mutate({channelId:e,model:null},{onSuccess:()=>p.agents.getConversationModel.invalidate({channelId:e})}):(c.mutate({channelId:e,model:C},{onSuccess:()=>p.agents.getConversationModel.invalidate({channelId:e})}),d.mutate({agentId:t,model:C},{onSuccess:()=>p.agents.list.invalidate()}))}return r.jsxs(ss,{value:w,onValueChange:S,children:[r.jsxs(is,{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[12px] border transition-colors outline-none border-opacity-40",style:{color:s,backgroundColor:`${s}15`,borderColor:`${s}40`},children:[r.jsx("span",{className:`text-[10px] px-1 py-0.5 rounded font-medium ${jo[A]}`,children:A}),r.jsx(Ds,{children:ta(w)}),r.jsx(ft,{className:"w-3 h-3 opacity-60"})]}),r.jsx(rs,{children:r.jsxs(as,{position:"popper",sideOffset:6,align:"end",className:"bg-[#1C1C24] border border-[#2A2A35] rounded-lg shadow-xl py-1 min-w-[200px] z-50",children:[r.jsxs(os,{children:[m.map(C=>r.jsxs(Ro,{children:[r.jsxs(Do,{className:"px-3 pt-2 pb-1 text-[10px] font-semibold text-[#5A5A6E] uppercase tracking-widest flex items-center gap-1.5",children:[r.jsx("span",{children:C.label}),r.jsx("span",{className:`px-1 py-0.5 rounded text-[9px] font-medium ${jo[C.tag]}`,children:C.tag})]}),C.models.map(E=>r.jsxs(vn,{value:E.id,className:"flex items-center justify-between px-3 py-1.5 text-[12px] text-[#C8C8D4] cursor-pointer hover:bg-white/5 outline-none data-[highlighted]:bg-white/5",children:[r.jsx(yn,{children:E.label}),r.jsx(ui,{children:r.jsx(Fe,{className:"w-3 h-3 text-[#6366F1]"})})]},E.id))]},C.label)),i.length>0&&r.jsxs(Ro,{children:[r.jsxs(Do,{className:"px-3 pt-2 pb-1 text-[10px] font-semibold text-[#5A5A6E] uppercase tracking-widest flex items-center gap-1.5",children:[r.jsx("span",{children:"Custom"}),r.jsx("span",{className:`px-1 py-0.5 rounded text-[9px] font-medium ${jo.custom}`,children:"custom"})]}),i.map(C=>r.jsxs(vn,{value:C,className:"flex items-center justify-between px-3 py-1.5 text-[12px] text-[#C8C8D4] cursor-pointer hover:bg-white/5 outline-none data-[highlighted]:bg-white/5",children:[r.jsx(yn,{children:C}),r.jsx(ui,{children:r.jsx(Fe,{className:"w-3 h-3 text-[#6366F1]"})})]},C))]}),_&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"my-1 border-t border-[#2A2A35]"}),r.jsx(vn,{value:"__reset__",className:"flex items-center px-3 py-1.5 text-[12px] text-[#8A8A99] cursor-pointer hover:bg-white/5 outline-none data-[highlighted]:bg-white/5",children:r.jsx(yn,{children:"Reset to default"})})]})]}),g&&r.jsx(gn,{to:"/settings?tab=runtime",className:"block px-3 py-1.5 text-[11px] text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/5 border-t border-[#2A2A35] mt-1 transition-colors",children:"+ Configure providers →"}),r.jsx("div",{className:"px-2 pt-1 pb-2 border-t border-[#2A2A35] mt-1",children:r.jsx(ty,{value:a,onChange:o,onSubmit:C=>{f.mutate({agentId:t,modelId:C},{onSuccess:()=>p.agents.list.invalidate()}),S(C),o("")}})})]})})]})}function X_e({color:e}){return r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsxs("span",{className:"relative flex items-center justify-center w-2 h-2",children:[r.jsx(ne.span,{className:"absolute inset-0 rounded-full",style:{backgroundColor:e,opacity:.5},animate:{scale:[1,2.2,1],opacity:[.5,0,.5]},transition:{duration:1.4,repeat:1/0}}),r.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:e}})]}),r.jsx("span",{className:"text-[12px]",style:{color:e},children:"Waiting for your approval"})]})}function J_e({status:e,color:t}){const n={thinking:"thinking",executing:"executing",idle:"idle",offline:"offline"},s=e==="thinking"||e==="executing";return r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsxs("span",{className:"relative flex items-center justify-center w-2 h-2",children:[s&&r.jsx(ne.span,{className:"absolute inset-0 rounded-full",style:{backgroundColor:t,opacity:.5},animate:{scale:[1,2,1],opacity:[.5,0,.5]},transition:{duration:1.8,repeat:1/0}}),r.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:e==="offline"?"#3A3A45":t,opacity:e==="idle"?.5:1}})]}),r.jsx("span",{className:"text-[12px] text-[#8A8A99] capitalize",children:n[e]})]})}function Z_e({channelId:e,color:t}){const[n,s]=y.useState(!1),i=L.useUtils(),a=L.messages.resetSession.useMutation({onSuccess:()=>{s(!0),setTimeout(()=>s(!1),2e3),ny.getState().clearStats(e),i.channels.sessionStats.invalidate({channelId:e})}});return r.jsx(bt,{label:"Reset context",children:r.jsx("button",{onClick:()=>a.mutate({channelId:e}),className:"w-8 h-8 flex items-center justify-center rounded-md text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/5 transition-colors",style:n?{color:t}:{},children:r.jsx(lh,{className:ye("w-4 h-4",a.isPending&&"animate-spin")})})})}function ewe({channelId:e,onCleared:t}){const[n,s]=y.useState(!1),i=L.useUtils(),a=L.messages.clearConversation.useMutation({onSuccess:()=>{s(!1),t?.(),ny.getState().clearStats(e),i.channels.sessionStats.invalidate({channelId:e})}});return n?r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{onClick:()=>a.mutate({channelId:e}),disabled:a.isPending,className:"px-2 py-1 rounded-md text-[11px] font-medium text-[#EF4444] bg-[#EF4444]/10 hover:bg-[#EF4444]/20 transition-colors",children:a.isPending?"Clearing...":"Confirm"}),r.jsx("button",{onClick:()=>s(!1),className:"px-2 py-1 rounded-md text-[11px] text-[#8A8A99] hover:bg-white/5 transition-colors",children:"Cancel"})]}):r.jsx(bt,{label:"Clear conversation",children:r.jsx("button",{onClick:()=>s(!0),className:"w-8 h-8 flex items-center justify-center rounded-md text-[#8A8A99] hover:text-[#EF4444] hover:bg-[#EF4444]/10 transition-colors",children:r.jsx(Dn,{className:"w-4 h-4"})})})}function twe({channelId:e,color:t,onJump:n}){const{data:s=[]}=L.messages.pinned.useQuery({channelId:e});return s.length===0?null:r.jsxs(Yv,{children:[r.jsx(Qv,{asChild:!0,children:r.jsxs("button",{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/10 transition-colors border border-transparent hover:border-[#2A2A35]",children:[r.jsx(P5,{className:"w-3.5 h-3.5",style:{color:t}}),r.jsxs("span",{children:[s.length," pinned"]})]})}),r.jsx(Od,{children:r.jsxs(Xv,{align:"end",sideOffset:6,className:"bg-[#1C1C24] border border-[#2A2A35] rounded-lg shadow-xl py-1 w-[300px] z-50",children:[r.jsx("div",{className:"px-3 py-2 border-b border-[#2A2A35]",children:r.jsx("span",{className:"text-[11px] font-semibold text-[#8A8A99] uppercase tracking-widest",children:"Pinned Messages"})}),s.map(i=>r.jsxs(Bl,{onSelect:()=>n(i.id),className:"flex flex-col gap-0.5 px-3 py-2.5 cursor-pointer hover:bg-white/5 outline-none transition-colors",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsx("span",{className:"text-[12px] font-medium text-[#C8C8D4] truncate",children:i.sender.name}),r.jsx("span",{className:"text-[11px] text-[#8A8A99] shrink-0",children:Ir(i.timestamp)})]}),r.jsx("p",{className:"text-[12px] text-[#8A8A99] truncate",children:i.content}),r.jsx("span",{className:"text-[11px] text-[#6366F1] mt-0.5",children:"Jump to message"})]},i.id))]})})]})}function nwe({channelId:e}){const t=L.useUtils(),{data:n}=L.channelPreferences.get.useQuery({channelId:e}),s=n?.muted??!1,i=L.channelPreferences.set.useMutation({onMutate:async({muted:a})=>{await t.channelPreferences.get.cancel({channelId:e});const o=t.channelPreferences.get.getData({channelId:e});return t.channelPreferences.get.setData({channelId:e},l=>({...l,channelId:e,muted:a??!1,notifyOnMention:l?.notifyOnMention??!0})),{prev:o}},onError:(a,o,l)=>{l?.prev&&t.channelPreferences.get.setData({channelId:e},l.prev)},onSettled:()=>{t.channelPreferences.get.invalidate({channelId:e}),t.channelPreferences.listMuted.invalidate()}});return r.jsx(bt,{label:s?"Unmute channel":"Mute channel",children:r.jsx("button",{onClick:()=>i.mutate({channelId:e,muted:!s}),className:ye("w-8 h-8 flex items-center justify-center rounded-md transition-colors",s?"text-[#F59E0B] hover:bg-[#F59E0B]/10":"text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/5"),children:s?r.jsx(tL,{className:"w-4 h-4"}):r.jsx(Ase,{className:"w-4 h-4"})})})}function swe({channel:e,agent:t,agentColor:n,hasPendingApproval:s=!1,rightPanelOpen:i,memoryPanelOpen:a,activeOverride:o,humanDmName:l,humanDmUserId:c,onToggleRightPanel:d,onToggleMemoryPanel:f,onAgentClick:p,onClearOverride:m,onClearConversation:g,onJumpToMessage:b}){const _=n??t?.color??"#6366F1",w=!!t&&e.channelType==="dm",A=e.channelType==="dm"&&!e.agentId,S=e.channelType==="topic",C=e.channelType==="group"||e.channelType==="topic",E=Uo(),k=L.channels.setResponseMode.useMutation(),T=L.useUtils();return r.jsxs("div",{className:"flex flex-col border-b border-[#2A2A35] bg-[#0F0F11] flex-shrink-0",style:w&&!S?{borderLeftColor:_,borderLeftWidth:3,borderLeftStyle:"solid"}:{},children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-3",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[A?r.jsx("div",{className:"w-8 h-8 rounded-full bg-gradient-to-br from-[#6366F1] to-[#8B5CF6] flex items-center justify-center text-[11px] font-semibold text-white flex-shrink-0",children:(l??"U").split(" ").map(F=>F[0]).join("").slice(0,2).toUpperCase()}):t&&!S?r.jsx("button",{onClick:p,className:"w-8 h-8 rounded-full flex items-center justify-center text-lg flex-shrink-0 transition-opacity hover:opacity-80",style:{backgroundColor:`${_}26`},children:t.emoji}):r.jsx("div",{className:"w-8 h-8 rounded-full bg-[#2A2A35] flex items-center justify-center",children:r.jsx("span",{className:"text-[#8A8A99] text-sm",children:"#"})}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2",children:[A?r.jsx("h2",{className:"text-[15px] font-semibold text-[#F0F0F5]",children:l??"User"}):t&&!S?r.jsx("button",{onClick:p,className:"text-[15px] font-semibold text-[#F0F0F5] hover:underline decoration-dashed underline-offset-2 transition-colors",children:t.name}):r.jsxs("h2",{className:"text-[15px] font-semibold text-[#F0F0F5]",children:["#",e.name]}),t&&!S&&r.jsx("span",{className:"text-[11px] text-[#8A8A99] bg-white/5 px-1.5 py-0.5 rounded",children:t.role}),S&&r.jsxs("span",{className:"text-[11px] text-[#8A8A99] bg-white/5 px-1.5 py-0.5 rounded border border-[#2A2A35] flex items-center gap-1",children:[e.visibility==="public"?r.jsx(Xt,{className:"w-3 h-3"}):r.jsx(Eo,{className:"w-3 h-3"}),"Topic"]})]}),t&&!S&&!s&&r.jsx(J_e,{status:t.status,color:_}),t&&!S&&s&&r.jsx(X_e,{color:_}),S&&e.description&&r.jsx("p",{className:"text-[12px] text-[#8A8A99]",children:e.description}),A&&r.jsx(Y_e,{userId:c}),!t&&!S&&!A&&r.jsxs("p",{className:"text-[12px] text-[#8A8A99]",children:["#",e.name]})]})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[E&&t&&!S&&r.jsx(Q_e,{channelId:e.id,agentId:t.id,defaultModel:t.defaultModel,agentColor:_,customModels:(()=>{try{return t.customModels?JSON.parse(t.customModels):[]}catch{return[]}})()}),w&&!S&&r.jsx(q_e,{channelId:e.id}),w&&!S&&r.jsx(Z_e,{channelId:e.id,color:_}),w&&!S&&r.jsx(ewe,{channelId:e.id,onCleared:g}),S&&r.jsx(S$,{channel:e}),C&&r.jsx(bt,{label:e.responseMode==="mention"?"Agents respond only when @mentioned":"Agents respond to every message",children:r.jsxs("button",{onClick:()=>{const F=e.responseMode==="always"?"mention":"always";k.mutate({channelId:e.id,responseMode:F},{onSuccess:()=>T.channels.list.invalidate()})},className:ye("flex items-center gap-1 px-2 py-1 rounded-md text-[12px] border transition-colors",e.responseMode==="mention"?"text-[#A78BFA] bg-[#8B5CF6]/10 border-[#8B5CF6]/30":"text-[#8A8A99] border-transparent hover:border-[#2A2A35] hover:bg-white/5"),children:[e.responseMode==="mention"?r.jsx(eL,{className:"w-3.5 h-3.5"}):r.jsx(pL,{className:"w-3.5 h-3.5"}),r.jsx("span",{children:e.responseMode==="mention"?"mention":"auto"})]})}),r.jsx(nwe,{channelId:e.id}),r.jsx(twe,{channelId:e.id,color:S?"#8A8A99":_,onJump:b??(F=>{document.getElementById(`msg-${F}`)?.scrollIntoView({behavior:"smooth",block:"center"})})}),t&&!S&&r.jsx(bt,{label:a?"Close memory":"View memory",children:r.jsx("button",{onClick:f,className:ye("w-8 h-8 flex items-center justify-center rounded-md transition-colors",a?"text-[#F0F0F5] bg-white/10":"text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/5"),children:r.jsx(Cse,{className:"w-4 h-4"})})}),r.jsx(bt,{label:i?"Close panel":"Open panel",children:r.jsx("button",{onClick:d,className:ye("w-8 h-8 flex items-center justify-center rounded-md transition-colors",i?"text-[#F0F0F5] bg-white/10":"text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/5"),children:i?r.jsx(mL,{className:"w-4 h-4"}):r.jsx(xL,{className:"w-4 h-4"})})})]})]}),o&&r.jsxs(ne.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.25},className:"flex items-center justify-between px-5 py-2 bg-amber-500/10 border-t border-amber-500/20",children:[r.jsxs("p",{className:"text-[12px] text-amber-400 truncate",children:[r.jsx("span",{className:"font-medium",children:"Override active:"})," ",o.length>60?`${o.slice(0,60)}...`:o]}),r.jsx("button",{onClick:m,className:"ml-3 flex-shrink-0 w-5 h-5 flex items-center justify-center rounded text-amber-400/70 hover:text-amber-300 hover:bg-amber-500/10 transition-colors",children:r.jsx(Te,{className:"w-3.5 h-3.5"})})]}),e.channelType!=="terminal"&&e.id!=="chan_coo"&&r.jsx(G_e,{baseChannelId:e.parentChannelId??e.id,activeTabId:e.id,agentColor:_})]})}function U7({agent:e}){return r.jsxs("div",{className:"flex items-start gap-3 px-4 py-2.5",children:[r.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-base flex-shrink-0 mt-0.5",style:{backgroundColor:`${e.color}26`},children:e.emoji}),r.jsxs("div",{className:"flex flex-col gap-1 pt-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:e.color},children:e.name}),r.jsx("span",{className:"text-[11px] text-[#8A8A99]",children:e.status==="thinking"?"thinking...":"executing..."})]}),r.jsx("div",{className:"flex items-center gap-1 px-3 py-2 rounded-lg rounded-tl-sm",style:{backgroundColor:`${e.color}0D`,border:`1px solid ${e.color}26`},children:[0,1,2].map(t=>r.jsx(ne.span,{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:e.color},animate:{opacity:[.3,1,.3],scale:[.8,1.1,.8]},transition:{duration:1.4,repeat:1/0,delay:t*.2,ease:"easeInOut"}},t))})]})]})}function iwe(e){return new Promise((t,n)=>{const s=new FileReader;s.onload=()=>t(s.result.split(",")[1]),s.onerror=n,s.readAsDataURL(e)})}function rwe({staged:e,onRemove:t}){const n=e.file.type.startsWith("image/"),s=Math.round(e.file.size/1024);return r.jsxs(ne.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.85},transition:{duration:.15},className:"relative group/card flex-shrink-0",children:[r.jsx("button",{onClick:t,className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-[#2A2A35] border border-[#3A3A45] rounded-full flex items-center justify-center text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-[#EF4444]/20 transition-colors z-10 opacity-0 group-hover/card:opacity-100",children:r.jsx(Te,{className:"w-2.5 h-2.5"})}),n&&e.preview?r.jsx("div",{className:"w-[60px] h-[60px] rounded-lg overflow-hidden border border-[#2A2A35]",children:r.jsx("img",{src:e.preview,alt:e.file.name,className:"w-full h-full object-cover"})}):r.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-2 bg-[#1C1C24] border border-[#2A2A35] rounded-lg max-w-[160px]",children:[r.jsx("div",{className:"w-6 h-6 rounded bg-[#2A2A35] flex items-center justify-center flex-shrink-0",children:r.jsx("span",{className:"text-[9px] font-semibold text-[#8A8A99] uppercase",children:e.file.name.split(".").pop()?.slice(0,3)??"file"})}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-[11px] text-[#C8C8D4] font-medium truncate",children:e.file.name}),r.jsxs("div",{className:"text-[10px] text-[#8A8A99]",children:[s,"KB"]})]})]}),e.uploadedId===void 0&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center rounded-lg bg-black/40",children:r.jsx("div",{className:"w-3 h-3 border-2 border-white/30 border-t-white rounded-full animate-spin"})})]})}function H7({channelId:e,channelName:t,agent:n,agentColor:s,onSend:i,disabled:a,placeholder:o,mentionableParticipants:l=[]}){const[c,d]=y.useState(""),[f,p]=y.useState(!1),[m,g]=y.useState([]),[b,_]=y.useState(!1),[w,A]=y.useState(null),[S,C]=y.useState(0),[E,k]=y.useState(-1),[T,F]=y.useState(!1),M=y.useRef(null),I=y.useRef(null),R=s??n?.color,H=!!n&&(n.status==="thinking"||n.status==="executing"),V=Uo(),K=L.agents.cancelThinking.useMutation(),q=L.attachments.upload.useMutation(),$=y.useMemo(()=>{if(w===null||l.length===0)return[];const se=w.toLowerCase();return l.filter(ae=>ae.name.toLowerCase().startsWith(se))},[w,l]);y.useEffect(()=>{const se=w!==null&&$.length>0;F(se),se&&C(0)},[w,$.length]);function B(se,ae){if(l.length===0){A(null);return}const le=se.slice(0,ae),ge=le.lastIndexOf("@");if(ge===-1||ge>0&&le[ge-1]!==" "&&le[ge-1]!==`
|
|
131
|
+
`))}function c(g,b,_,w){const A=_.enter("tableCell"),S=_.enter("phrasing"),C=_.containerPhrasing(g,{...w,before:a,after:a});return S(),A(),C}function d(g,b){return nve(g,{align:b,alignDelimiters:s,padding:n,stringLength:i})}function f(g,b,_){const w=g.children;let A=-1;const S=[],C=b.enter("table");for(;++A<w.length;)S[A]=p(w[A],b,_);return C(),S}function p(g,b,_){const w=g.children;let A=-1;const S=[],C=b.enter("tableRow");for(;++A<w.length;)S[A]=c(w[A],g,b,_);return C(),S}function m(g,b,_){let w=d$.inlineCode(g,b,_);return _.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function Hve(){return{exit:{taskListCheckValueChecked:rR,taskListCheckValueUnchecked:rR,paragraph:qve}}}function Wve(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Gve}}}function rR(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function qve(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const s=n.children[0];if(s&&s.type==="text"){const i=t.children;let a=-1,o;for(;++a<i.length;){const l=i[a];if(l.type==="paragraph"){o=l;break}}o===n&&(s.value=s.value.slice(1),s.value.length===0?n.children.shift():n.position&&s.position&&typeof s.position.start.offset=="number"&&(s.position.start.column++,s.position.start.offset++,n.position.start=Object.assign({},s.position.start)))}}this.exit(e)}function Gve(e,t,n,s){const i=e.children[0],a=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",l=n.createTracker(s);a&&l.move(o);let c=d$.listItem(e,t,n,{...s,...l.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,d)),c;function d(f){return f+o}}function Kve(){return[C0e(),q0e(),Q0e(),Ive(),Hve()]}function Yve(e){return{extensions:[j0e(),G0e(e),X0e(),Uve(e),Wve()]}}const Qve={tokenize:nye,partial:!0},h$={tokenize:sye,partial:!0},f$={tokenize:iye,partial:!0},p$={tokenize:rye,partial:!0},Xve={tokenize:aye,partial:!0},m$={name:"wwwAutolink",tokenize:eye,previous:g$},x$={name:"protocolAutolink",tokenize:tye,previous:b$},Ho={name:"emailAutolink",tokenize:Zve,previous:v$},Ga={};function Jve(){return{text:Ga}}let Ec=48;for(;Ec<123;)Ga[Ec]=Ho,Ec++,Ec===58?Ec=65:Ec===91&&(Ec=97);Ga[43]=Ho;Ga[45]=Ho;Ga[46]=Ho;Ga[95]=Ho;Ga[72]=[Ho,x$];Ga[104]=[Ho,x$];Ga[87]=[Ho,m$];Ga[119]=[Ho,m$];function Zve(e,t,n){const s=this;let i,a;return o;function o(p){return!XS(p)||!v$.call(s,s.previous)||Oj(s.events)?n(p):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),l(p))}function l(p){return XS(p)?(e.consume(p),l):p===64?(e.consume(p),c):n(p)}function c(p){return p===46?e.check(Xve,f,d)(p):p===45||p===95||Hs(p)?(a=!0,e.consume(p),c):f(p)}function d(p){return e.consume(p),i=!0,c}function f(p){return a&&i&&ii(s.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(p)):n(p)}}function eye(e,t,n){const s=this;return i;function i(o){return o!==87&&o!==119||!g$.call(s,s.previous)||Oj(s.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(Qve,e.attempt(h$,e.attempt(f$,a),n),n)(o))}function a(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function tye(e,t,n){const s=this;let i="",a=!1;return o;function o(p){return(p===72||p===104)&&b$.call(s,s.previous)&&!Oj(s.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(p),e.consume(p),l):n(p)}function l(p){if(ii(p)&&i.length<5)return i+=String.fromCodePoint(p),e.consume(p),l;if(p===58){const m=i.toLowerCase();if(m==="http"||m==="https")return e.consume(p),c}return n(p)}function c(p){return p===47?(e.consume(p),a?d:(a=!0,c)):n(p)}function d(p){return p===null||_0(p)||Wt(p)||cu(p)||Vv(p)?n(p):e.attempt(h$,e.attempt(f$,f),n)(p)}function f(p){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(p)}}function nye(e,t,n){let s=0;return i;function i(o){return(o===87||o===119)&&s<3?(s++,e.consume(o),i):o===46&&s===3?(e.consume(o),a):n(o)}function a(o){return o===null?n(o):t(o)}}function sye(e,t,n){let s,i,a;return o;function o(d){return d===46||d===95?e.check(p$,c,l)(d):d===null||Wt(d)||cu(d)||d!==45&&Vv(d)?c(d):(a=!0,e.consume(d),o)}function l(d){return d===95?s=!0:(i=s,s=void 0),e.consume(d),o}function c(d){return i||s||!a?n(d):t(d)}}function iye(e,t){let n=0,s=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&s<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(p$,t,a)(o):o===null||Wt(o)||cu(o)?t(o):(e.consume(o),i)}function a(o){return o===41&&s++,e.consume(o),i}}function rye(e,t,n){return s;function s(l){return l===33||l===34||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===63||l===95||l===126?(e.consume(l),s):l===38?(e.consume(l),a):l===93?(e.consume(l),i):l===60||l===null||Wt(l)||cu(l)?t(l):n(l)}function i(l){return l===null||l===40||l===91||Wt(l)||cu(l)?t(l):s(l)}function a(l){return ii(l)?o(l):n(l)}function o(l){return l===59?(e.consume(l),s):ii(l)?(e.consume(l),o):n(l)}}function aye(e,t,n){return s;function s(a){return e.consume(a),i}function i(a){return Hs(a)?n(a):t(a)}}function g$(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Wt(e)}function b$(e){return!ii(e)}function v$(e){return!(e===47||XS(e))}function XS(e){return e===43||e===45||e===46||e===95||Hs(e)}function Oj(e){let t=e.length,n=!1;for(;t--;){const s=e[t][1];if((s.type==="labelLink"||s.type==="labelImage")&&!s._balanced){n=!0;break}if(s._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const oye={tokenize:mye,partial:!0};function lye(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:hye,continuation:{tokenize:fye},exit:pye}},text:{91:{name:"gfmFootnoteCall",tokenize:dye},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:cye,resolveTo:uye}}}}function cye(e,t,n){const s=this;let i=s.events.length;const a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o;for(;i--;){const c=s.events[i][1];if(c.type==="labelImage"){o=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return l;function l(c){if(!o||!o._balanced)return n(c);const d=ea(s.sliceSerialize({start:o.end,end:s.now()}));return d.codePointAt(0)!==94||!a.includes(d.slice(1))?n(c):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),t(c))}}function uye(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const s={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const a={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},l=[e[n+1],e[n+2],["enter",s,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t],e[e.length-2],e[e.length-1],["exit",s,t]];return e.splice(n,e.length-n+1,...l),e}function dye(e,t,n){const s=this,i=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let a=0,o;return l;function l(p){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),c}function c(p){return p!==94?n(p):(e.enter("gfmFootnoteCallMarker"),e.consume(p),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",d)}function d(p){if(a>999||p===93&&!o||p===null||p===91||Wt(p))return n(p);if(p===93){e.exit("chunkString");const m=e.exit("gfmFootnoteCallString");return i.includes(ea(s.sliceSerialize(m)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(p)}return Wt(p)||(o=!0),a++,e.consume(p),p===92?f:d}function f(p){return p===91||p===92||p===93?(e.consume(p),a++,d):d(p)}}function hye(e,t,n){const s=this,i=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let a,o=0,l;return c;function c(b){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionLabelMarker"),d}function d(b){return b===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",f):n(b)}function f(b){if(o>999||b===93&&!l||b===null||b===91||Wt(b))return n(b);if(b===93){e.exit("chunkString");const _=e.exit("gfmFootnoteDefinitionLabelString");return a=ea(s.sliceSerialize(_)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),m}return Wt(b)||(l=!0),o++,e.consume(b),b===92?p:f}function p(b){return b===91||b===92||b===93?(e.consume(b),o++,f):f(b)}function m(b){return b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),i.includes(a)||i.push(a),vt(e,g,"gfmFootnoteDefinitionWhitespace")):n(b)}function g(b){return t(b)}}function fye(e,t,n){return e.check(Pm,t,e.attempt(oye,t,n))}function pye(e){e.exit("gfmFootnoteDefinition")}function mye(e,t,n){const s=this;return vt(e,i,"gfmFootnoteDefinitionIndent",5);function i(a){const o=s.events[s.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(a):n(a)}}function xye(e){let n=(e||{}).singleTilde;const s={name:"strikethrough",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:s},insideSpan:{null:[s]},attentionMarkers:{null:[126]}};function i(o,l){let c=-1;for(;++c<o.length;)if(o[c][0]==="enter"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._close){let d=c;for(;d--;)if(o[d][0]==="exit"&&o[d][1].type==="strikethroughSequenceTemporary"&&o[d][1]._open&&o[c][1].end.offset-o[c][1].start.offset===o[d][1].end.offset-o[d][1].start.offset){o[c][1].type="strikethroughSequence",o[d][1].type="strikethroughSequence";const f={type:"strikethrough",start:Object.assign({},o[d][1].start),end:Object.assign({},o[c][1].end)},p={type:"strikethroughText",start:Object.assign({},o[d][1].end),end:Object.assign({},o[c][1].start)},m=[["enter",f,l],["enter",o[d][1],l],["exit",o[d][1],l],["enter",p,l]],g=l.parser.constructs.insideSpan.null;g&&tr(m,m.length,0,Uv(g,o.slice(d+1,c),l)),tr(m,m.length,0,[["exit",p,l],["enter",o[c][1],l],["exit",o[c][1],l],["exit",f,l]]),tr(o,d-1,c-d+3,m),c=d+m.length-2;break}}for(c=-1;++c<o.length;)o[c][1].type==="strikethroughSequenceTemporary"&&(o[c][1].type="data");return o}function a(o,l,c){const d=this.previous,f=this.events;let p=0;return m;function m(b){return d===126&&f[f.length-1][1].type!=="characterEscape"?c(b):(o.enter("strikethroughSequenceTemporary"),g(b))}function g(b){const _=Yd(d);if(b===126)return p>1?c(b):(o.consume(b),p++,g);if(p<2&&!n)return c(b);const w=o.exit("strikethroughSequenceTemporary"),A=Yd(b);return w._open=!A||A===2&&!!_,w._close=!_||_===2&&!!A,l(b)}}}class gye{constructor(){this.map=[]}add(t,n,s){bye(this,t,n,s)}consume(t){if(this.map.sort(function(a,o){return a[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const s=[];for(;n>0;)n-=1,s.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];s.push(t.slice()),t.length=0;let i=s.pop();for(;i;){for(const a of i)t.push(a);i=s.pop()}this.map.length=0}}function bye(e,t,n,s){let i=0;if(!(n===0&&s.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...s);return}i+=1}e.map.push([t,n,s])}}function vye(e,t){let n=!1;const s=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&s.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const a=s.length-1;s[a]=s[a]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return s}function yye(){return{flow:{null:{name:"table",tokenize:_ye,resolveAll:wye}}}}function _ye(e,t,n){const s=this;let i=0,a=0,o;return l;function l(R){let H=s.events.length-1;for(;H>-1;){const q=s.events[H][1].type;if(q==="lineEnding"||q==="linePrefix")H--;else break}const V=H>-1?s.events[H][1].type:null,K=V==="tableHead"||V==="tableRow"?T:c;return K===T&&s.parser.lazy[s.now().line]?n(R):K(R)}function c(R){return e.enter("tableHead"),e.enter("tableRow"),d(R)}function d(R){return R===124||(o=!0,a+=1),f(R)}function f(R){return R===null?n(R):qe(R)?a>1?(a=0,s.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),g):n(R):ht(R)?vt(e,f,"whitespace")(R):(a+=1,o&&(o=!1,i+=1),R===124?(e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),o=!0,f):(e.enter("data"),p(R)))}function p(R){return R===null||R===124||Wt(R)?(e.exit("data"),f(R)):(e.consume(R),R===92?m:p)}function m(R){return R===92||R===124?(e.consume(R),p):p(R)}function g(R){return s.interrupt=!1,s.parser.lazy[s.now().line]?n(R):(e.enter("tableDelimiterRow"),o=!1,ht(R)?vt(e,b,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):b(R))}function b(R){return R===45||R===58?w(R):R===124?(o=!0,e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),_):k(R)}function _(R){return ht(R)?vt(e,w,"whitespace")(R):w(R)}function w(R){return R===58?(a+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(R),e.exit("tableDelimiterMarker"),A):R===45?(a+=1,A(R)):R===null||qe(R)?E(R):k(R)}function A(R){return R===45?(e.enter("tableDelimiterFiller"),S(R)):k(R)}function S(R){return R===45?(e.consume(R),S):R===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(R),e.exit("tableDelimiterMarker"),C):(e.exit("tableDelimiterFiller"),C(R))}function C(R){return ht(R)?vt(e,E,"whitespace")(R):E(R)}function E(R){return R===124?b(R):R===null||qe(R)?!o||i!==a?k(R):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(R)):k(R)}function k(R){return n(R)}function T(R){return e.enter("tableRow"),F(R)}function F(R){return R===124?(e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),F):R===null||qe(R)?(e.exit("tableRow"),t(R)):ht(R)?vt(e,F,"whitespace")(R):(e.enter("data"),M(R))}function M(R){return R===null||R===124||Wt(R)?(e.exit("data"),F(R)):(e.consume(R),R===92?I:M)}function I(R){return R===92||R===124?(e.consume(R),M):M(R)}}function wye(e,t){let n=-1,s=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],l=!1,c=0,d,f,p;const m=new gye;for(;++n<e.length;){const g=e[n],b=g[1];g[0]==="enter"?b.type==="tableHead"?(l=!1,c!==0&&(aR(m,t,c,d,f),f=void 0,c=0),d={type:"table",start:Object.assign({},b.start),end:Object.assign({},b.end)},m.add(n,0,[["enter",d,t]])):b.type==="tableRow"||b.type==="tableDelimiterRow"?(s=!0,p=void 0,a=[0,0,0,0],o=[0,n+1,0,0],l&&(l=!1,f={type:"tableBody",start:Object.assign({},b.start),end:Object.assign({},b.end)},m.add(n,0,[["enter",f,t]])),i=b.type==="tableDelimiterRow"?2:f?3:1):i&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")?(s=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],p=zg(m,t,a,i,void 0,p),a=[0,0,0,0]),o[2]=n)):b.type==="tableCellDivider"&&(s?s=!1:(a[1]!==0&&(o[0]=o[1],p=zg(m,t,a,i,void 0,p)),a=o,o=[a[1],n,0,0])):b.type==="tableHead"?(l=!0,c=n):b.type==="tableRow"||b.type==="tableDelimiterRow"?(c=n,a[1]!==0?(o[0]=o[1],p=zg(m,t,a,i,n,p)):o[1]!==0&&(p=zg(m,t,o,i,n,p)),i=0):i&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")&&(o[3]=n)}for(c!==0&&aR(m,t,c,d,f),m.consume(t.events),n=-1;++n<t.events.length;){const g=t.events[n];g[0]==="enter"&&g[1].type==="table"&&(g[1]._align=vye(t.events,n))}return e}function zg(e,t,n,s,i,a){const o=s===1?"tableHeader":s===2?"tableDelimiter":"tableData",l="tableContent";n[0]!==0&&(a.end=Object.assign({},_d(t.events,n[0])),e.add(n[0],0,[["exit",a,t]]));const c=_d(t.events,n[1]);if(a={type:o,start:Object.assign({},c),end:Object.assign({},c)},e.add(n[1],0,[["enter",a,t]]),n[2]!==0){const d=_d(t.events,n[2]),f=_d(t.events,n[3]),p={type:l,start:Object.assign({},d),end:Object.assign({},f)};if(e.add(n[2],0,[["enter",p,t]]),s!==2){const m=t.events[n[2]],g=t.events[n[3]];if(m[1].end=Object.assign({},g[1].end),m[1].type="chunkText",m[1].contentType="text",n[3]>n[2]+1){const b=n[2]+1,_=n[3]-n[2]-1;e.add(b,_,[])}}e.add(n[3]+1,0,[["exit",p,t]])}return i!==void 0&&(a.end=Object.assign({},_d(t.events,i)),e.add(i,0,[["exit",a,t]]),a=void 0),a}function aR(e,t,n,s,i){const a=[],o=_d(t.events,n);i&&(i.end=Object.assign({},o),a.push(["exit",i,t])),s.end=Object.assign({},o),a.push(["exit",s,t]),e.add(n+1,0,a)}function _d(e,t){const n=e[t],s=n[0]==="enter"?"start":"end";return n[1][s]}const Aye={name:"tasklistCheck",tokenize:Cye};function Sye(){return{text:{91:Aye}}}function Cye(e,t,n){const s=this;return i;function i(c){return s.previous!==null||!s._gfmTasklistFirstContentOfListItem?n(c):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),a)}function a(c){return Wt(c)?(e.enter("taskListCheckValueUnchecked"),e.consume(c),e.exit("taskListCheckValueUnchecked"),o):c===88||c===120?(e.enter("taskListCheckValueChecked"),e.consume(c),e.exit("taskListCheckValueChecked"),o):n(c)}function o(c){return c===93?(e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),l):n(c)}function l(c){return qe(c)?t(c):ht(c)?e.check({tokenize:jye},t,n)(c):n(c)}}function jye(e,t,n){return vt(e,s,"whitespace");function s(i){return i===null?n(i):t(i)}}function Nye(e){return Fz([Jve(),lye(),xye(e),yye(),Sye()])}const kye={};function Fi(e){const t=this,n=e||kye,s=t.data(),i=s.micromarkExtensions||(s.micromarkExtensions=[]),a=s.fromMarkdownExtensions||(s.fromMarkdownExtensions=[]),o=s.toMarkdownExtensions||(s.toMarkdownExtensions=[]);i.push(Nye(n)),a.push(Kve()),o.push(Yve(n))}const Eye={"MEMORY.md":"Written by the agent. Edits may be overwritten.","KNOWLEDGE.md":"Distilled learning. Edits may be overwritten by reflection.","REFLEXION.md":"Earned constraints from failures. Edits may be overwritten.","HEARTBEAT.md":"Controls periodic agent behavior.","TOOLS.md":"Your local environment notes.","USER.md":"What the agent knows about you."},Fye={"CONTEXT.md":"Injected into every agent call in this channel.","NOTES.md":"Your notes. Not shared with agents."};function Tye({agentId:e,filename:t,onClose:n}){const{data:s}=pj(e),i=L.useUtils(),{data:a,isLoading:o,error:l}=L.agents.getFile.useQuery({agentId:e,filename:t},{retry:!1}),[c,d]=y.useState(!1),[f,p]=y.useState(""),[m,g]=y.useState(!1),[b,_]=y.useState(!1),[w,A]=y.useState(!1),S=y.useRef(null);y.useEffect(()=>{a&&a.content===""&&(p(""),d(!0))},[a]);const C=L.agents.setFile.useMutation({onSuccess:()=>{_(!0),setTimeout(()=>_(!1),1500),i.agents.getFile.invalidate({agentId:e,filename:t}),i.agents.listFiles.invalidate({agentId:e}),d(!1)}}),E=L.agents.resetFile.useMutation({onSuccess:V=>{i.agents.getFile.invalidate({agentId:e,filename:t}),A(!0),g(!1),setTimeout(()=>A(!1),1500),p(V.content),d(!1)}});function k(){p(a?.content??""),d(!0),setTimeout(()=>S.current?.focus(),50)}function T(){C.mutate({agentId:e,filename:t,content:f})}function F(){d(!1),p("")}function M(){if(!m){g(!0);return}E.mutate({agentId:e,filename:t})}const I=Eye[t],R=a?.hasDefault??!1,H=a?.content??"";return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"px-4 py-3 border-b border-[#2A2A35] flex-shrink-0",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s&&r.jsx("span",{className:"text-base flex-shrink-0",children:s.emoji}),r.jsxs("span",{className:"text-[13px] font-semibold text-[#F0F0F5] truncate",children:[s?.name??e," — ",t]})]}),r.jsx("button",{onClick:n,className:"w-6 h-6 flex items-center justify-center rounded text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/10 transition-colors flex-shrink-0 ml-2",children:r.jsx(Te,{className:"w-3.5 h-3.5"})})]}),I&&r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mt-1",children:I})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0",children:[o&&r.jsxs("div",{className:"flex items-center gap-1.5 px-4 py-4 text-[#5A5A6E]",children:[r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#5A5A6E] animate-pulse"}),r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#5A5A6E] animate-pulse [animation-delay:0.2s]"}),r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#5A5A6E] animate-pulse [animation-delay:0.4s]"})]}),l&&r.jsx("p",{className:"px-4 py-4 text-[13px] text-[#EF4444] italic",children:"Failed to load file."}),!o&&!l&&!c&&r.jsx("div",{className:"px-4 py-4 prose-message text-[13px]",children:H?r.jsx(Ei,{remarkPlugins:[Fi],children:H}):r.jsx("p",{className:"text-[#5A5A6E] italic",children:"Empty file."})}),!o&&!l&&c&&r.jsx("textarea",{ref:S,value:f,onChange:V=>p(V.target.value),onKeyDown:V=>{V.key==="Enter"&&V.metaKey&&(V.preventDefault(),T())},className:"w-full h-full min-h-[300px] bg-[#13131A] text-[#F0F0F5] text-[13px] font-mono px-4 py-4 resize-none outline-none border-none",spellCheck:!1})]}),r.jsxs("div",{className:"px-4 py-3 border-t border-[#2A2A35] flex items-center justify-between flex-shrink-0",children:[r.jsx("div",{className:"flex items-center gap-2",children:r.jsxs(Me,{mode:"wait",children:[b&&r.jsxs(ne.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"text-[12px] text-[#10B981] flex items-center gap-1",children:[r.jsx(Fe,{className:"w-3 h-3"})," Saved"]},"saved"),w&&r.jsx(ne.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"text-[12px] text-[#F59E0B]",children:"Reset"},"reset")]})}),r.jsxs("div",{className:"flex items-center gap-2",children:[!c&&R&&!m&&r.jsxs("button",{onClick:M,disabled:E.isPending,className:"flex items-center gap-1 px-2.5 py-1.5 rounded text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/5 transition-colors disabled:opacity-40",children:[r.jsx(lh,{className:"w-3 h-3"}),"Reset"]}),m&&r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"text-[11px] text-[#8A8A99]",children:["Reset ",t,"?"]}),r.jsx("button",{onClick:M,disabled:E.isPending,className:"px-2.5 py-1.5 rounded text-[12px] text-[#EF4444] hover:bg-[#EF4444]/10 transition-colors disabled:opacity-40",children:"Confirm"}),r.jsx("button",{onClick:()=>g(!1),className:"px-2.5 py-1.5 rounded text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/5 transition-colors",children:"Cancel"})]}),!c&&!m&&r.jsxs("button",{onClick:k,className:"flex items-center gap-1 px-2.5 py-1.5 rounded text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/5 transition-colors",children:[r.jsx(oh,{className:"w-3 h-3"}),"Edit"]}),c&&r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:F,className:"px-2.5 py-1.5 rounded text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/5 transition-colors",children:"Cancel"}),r.jsx("button",{onClick:T,disabled:C.isPending,className:"px-3 py-1.5 rounded text-[12px] font-medium bg-[#6366F1] text-white hover:bg-[#5558E8] transition-colors disabled:opacity-40",children:C.isPending?"Saving...":"Save"}),r.jsx("kbd",{className:"text-[10px] bg-white/5 border border-[#2A2A35] px-1.5 py-0.5 rounded text-[#5A5A6E]",children:"⌘↵"})]})]})]})]})}function Mye({channelId:e,filename:t,onClose:n}){const{data:s}=ez(e),i=L.useUtils(),{data:a,isLoading:o,error:l}=L.channels.getFile.useQuery({channelId:e,filename:t},{retry:!1}),[c,d]=y.useState(!1),[f,p]=y.useState(""),[m,g]=y.useState(!1),b=y.useRef(null);y.useEffect(()=>{a!==void 0&&a.content===""&&(p(""),d(!0))},[a]);const _=L.channels.setFile.useMutation({onSuccess:()=>{g(!0),setTimeout(()=>g(!1),1500),i.channels.getFile.invalidate({channelId:e,filename:t}),i.channels.listFiles.invalidate({channelId:e}),d(!1)}});function w(){p(a?.content??""),d(!0),setTimeout(()=>b.current?.focus(),50)}function A(){_.mutate({channelId:e,filename:t,content:f})}function S(){d(!1),p("")}const C=Fye[t],E=a?.content??"";return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"px-4 py-3 border-b border-[#2A2A35] flex-shrink-0",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx(Tp,{className:"w-3.5 h-3.5 text-[#8A8A99] flex-shrink-0"}),r.jsxs("span",{className:"text-[13px] font-semibold text-[#F0F0F5] truncate",children:[s?.name??e," — ",t]})]}),r.jsx("button",{onClick:n,className:"w-6 h-6 flex items-center justify-center rounded text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/10 transition-colors flex-shrink-0 ml-2",children:r.jsx(Te,{className:"w-3.5 h-3.5"})})]}),C&&r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mt-1",children:C})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0",children:[o&&r.jsxs("div",{className:"flex items-center gap-1.5 px-4 py-4 text-[#5A5A6E]",children:[r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#5A5A6E] animate-pulse"}),r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#5A5A6E] animate-pulse [animation-delay:0.2s]"}),r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#5A5A6E] animate-pulse [animation-delay:0.4s]"})]}),l&&r.jsx("p",{className:"px-4 py-4 text-[13px] text-[#EF4444] italic",children:"Failed to load file."}),!o&&!l&&!c&&r.jsx("div",{className:"px-4 py-4 prose-message text-[13px]",children:E?r.jsx(Ei,{remarkPlugins:[Fi],children:E}):r.jsx("p",{className:"text-[#5A5A6E] italic",children:"Empty file."})}),!o&&!l&&c&&r.jsx("textarea",{ref:b,value:f,onChange:k=>p(k.target.value),onKeyDown:k=>{k.key==="Enter"&&k.metaKey&&(k.preventDefault(),A())},className:"w-full h-full min-h-[300px] bg-[#13131A] text-[#F0F0F5] text-[13px] font-mono px-4 py-4 resize-none outline-none border-none",spellCheck:!1})]}),r.jsxs("div",{className:"px-4 py-3 border-t border-[#2A2A35] flex items-center justify-end flex-shrink-0 gap-2",children:[r.jsx(Me,{mode:"wait",children:m&&r.jsxs(ne.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"text-[12px] text-[#10B981] flex items-center gap-1 mr-auto",children:[r.jsx(Fe,{className:"w-3 h-3"})," Saved"]},"saved")}),!c&&r.jsxs("button",{onClick:w,className:"flex items-center gap-1 px-2.5 py-1.5 rounded text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/5 transition-colors",children:[r.jsx(oh,{className:"w-3 h-3"}),"Edit"]}),c&&r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:S,className:"px-2.5 py-1.5 rounded text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/5 transition-colors",children:"Cancel"}),r.jsx("button",{onClick:A,disabled:_.isPending,className:"px-3 py-1.5 rounded text-[12px] font-medium bg-[#6366F1] text-white hover:bg-[#5558E8] transition-colors disabled:opacity-40",children:_.isPending?"Saving...":"Save"}),r.jsx("kbd",{className:"text-[10px] bg-white/5 border border-[#2A2A35] px-1.5 py-0.5 rounded text-[#5A5A6E]",children:"⌘↵"})]})]})]})}function Rye(){const{agentId:e,channelId:t,entityType:n,filename:s,close:i}=y0(),a=!!s&&!!n;return y.useEffect(()=>{if(!a)return;function o(l){l.key==="Escape"&&i()}return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[a,i]),r.jsx(Me,{children:a&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"fixed inset-0 z-[55]",onClick:i}),r.jsxs(ne.div,{initial:{x:-380},animate:{x:0},exit:{x:-380},transition:{duration:.15,ease:"easeOut"},className:"fixed top-0 h-screen w-[380px] bg-[#1C1C24] border-r border-[#2A2A35] flex flex-col z-[55] shadow-xl",style:{left:240},onClick:o=>o.stopPropagation(),children:[n==="agent"&&e&&s&&r.jsx(Tye,{agentId:e,filename:s,onClose:i}),n==="channel"&&t&&s&&r.jsx(Mye,{channelId:t,filename:s,onClose:i})]})]})})}const Dye={high:"#EF4444",normal:"#F59E0B",low:"#6366F1"},Oye={shell_exec:Ti,trust_config:Wl,skill_install:vL,file_edit:li,delegation_rule:Wl,generic:yL};function Pye({priority:e}){return r.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:Dye[e]??"#5A5A6E"}})}function Iye({expiresAt:e}){if(!e)return null;const t=new Date(e).getTime()-Date.now();if(t<=0)return r.jsx("span",{className:"text-[10px] text-[#EF4444]",children:"Expired"});const n=Math.floor(t/36e5),s=Math.floor(t%36e5/6e4),i=n>0?`${n}h ${s}m`:`${s}m`;return r.jsxs("span",{className:"flex items-center gap-0.5 text-[10px] text-[#5A5A6E]",children:[r.jsx(bm,{className:"w-2.5 h-2.5"}),i]})}const Pj={pending:"#F59E0B",working:"#6366F1",input_needed:"#8B5CF6",completed:"#10B981",failed:"#EF4444",cancelled:"#5A5A6E"},y$={pending:"○",working:"⏳",input_needed:"❓",completed:"✅",failed:"⚠️",cancelled:"🛑",blocked:"🚫"};function Lye(e,t){const n=e??t,s=Date.now()-new Date(n).getTime(),i=Math.floor(s/1e3);if(i<60)return`${i}s`;const a=Math.floor(i/60);return a<60?`${a}m`:`${Math.floor(a/60)}h ${a%60}m`}function _$(e){const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${n%60}m`}function w$({node:e,navigate:t,depth:n=0}){const s=e.children.length>1,i=Pj[e.status]??"#5A5A6E";return r.jsxs("div",{className:n>0?"ml-4 border-l border-[#2A2A35] pl-3":"",children:[r.jsxs("div",{className:"flex items-center gap-2 py-1.5 group",children:[r.jsx("span",{className:"text-[12px]",children:y$[e.status]??"•"}),r.jsxs("div",{className:"flex items-center gap-1",children:[e.toAgent&&r.jsx("span",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[10px] flex-shrink-0",style:{backgroundColor:`${e.toAgent.color}26`},children:e.toAgent.emoji}),r.jsx("span",{className:"text-[11px] font-medium text-[#F0F0F5]",children:e.toAgent?.name??e.toAgentId})]}),r.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:i}}),e.crossInstance&&r.jsx(Xt,{className:"w-2.5 h-2.5 text-[#A78BFA] flex-shrink-0"}),r.jsx("span",{className:"text-[10px] text-[#5A5A6E]",children:e.status.replace("_"," ")}),e.targetChannelId&&r.jsx("button",{onClick:()=>t(`/channels/${e.targetChannelId}`),className:"opacity-0 group-hover:opacity-100 transition-opacity text-[#5A5A6E] hover:text-[#8A8A99]",children:r.jsx(cs,{className:"w-2.5 h-2.5"})})]}),r.jsx("p",{className:"text-[10px] text-[#8A8A99] line-clamp-1 ml-6 mb-1",children:e.task}),e.crossInstance&&e.status==="failed"&&e.task.includes("cross-instance")&&r.jsx("p",{className:"text-[10px] text-[#A78BFA] ml-6 mb-1",children:"(cross-instance disabled)"}),s&&r.jsx("div",{className:"ml-6 mb-1",children:r.jsx("span",{className:"text-[9px] text-[#5A5A6E] uppercase tracking-wider",children:"parallel"})}),e.children.map(a=>r.jsx(w$,{node:a,navigate:t,depth:n+1},a.id))]})}function A$({taskId:e,navigate:t}){const{data:n,isLoading:s}=L.agentTasks.getChain.useQuery({taskId:e});return s?r.jsx("div",{className:"py-2 text-[11px] text-[#5A5A6E]",children:"Loading chain..."}):n?r.jsxs("div",{className:"py-2 px-1",children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[r.jsx(Zl,{className:"w-3 h-3 text-[#6366F1]"}),r.jsx("span",{className:"text-[11px] font-semibold text-[#8A8A99]",children:"Task Chain"})]}),r.jsx(w$,{node:n,navigate:t})]}):r.jsx("div",{className:"py-2 text-[11px] text-[#5A5A6E]",children:"Chain not found"})}function Bye(){const{data:e}=L.agentTasks.stats.useQuery(void 0,{staleTime:3e4});return!e||e.totalTasks===0?null:r.jsxs("div",{className:"px-5 py-3 border-b border-[#2A2A35]",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(M5,{className:"w-3.5 h-3.5 text-[#8A8A99]"}),r.jsx("span",{className:"text-[11px] font-semibold text-[#8A8A99] uppercase tracking-widest",children:"Delegation Stats"})]}),r.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[r.jsxs("div",{className:"bg-[#1C1C24] rounded-lg px-2.5 py-2 border border-[#2A2A35]",children:[r.jsx("p",{className:"text-[16px] font-semibold text-[#F0F0F5]",children:e.totalTasks}),r.jsx("p",{className:"text-[9px] text-[#5A5A6E] uppercase",children:"Total"})]}),r.jsxs("div",{className:"bg-[#1C1C24] rounded-lg px-2.5 py-2 border border-[#2A2A35]",children:[r.jsx("p",{className:"text-[16px] font-semibold text-[#6366F1]",children:e.activeTasks}),r.jsx("p",{className:"text-[9px] text-[#5A5A6E] uppercase",children:"Active"})]}),r.jsxs("div",{className:"bg-[#1C1C24] rounded-lg px-2.5 py-2 border border-[#2A2A35]",children:[r.jsx("p",{className:"text-[16px] font-semibold text-[#10B981]",children:e.completedTasks}),r.jsx("p",{className:"text-[9px] text-[#5A5A6E] uppercase",children:"Done"})]}),r.jsxs("div",{className:"bg-[#1C1C24] rounded-lg px-2.5 py-2 border border-[#2A2A35]",children:[r.jsx("p",{className:"text-[16px] font-semibold text-[#EF4444]",children:e.failedTasks}),r.jsx("p",{className:"text-[9px] text-[#5A5A6E] uppercase",children:"Failed"})]})]}),r.jsxs("div",{className:"flex items-center gap-3 mt-2 text-[10px] text-[#5A5A6E]",children:[e.avgDurationMs!=null&&r.jsxs("span",{children:["Avg: ",_$(e.avgDurationMs)]}),e.totalTokensUsed>0&&r.jsxs("span",{children:[e.totalTokensUsed.toLocaleString()," tokens"]}),e.crossInstanceTasks.total>0&&r.jsxs("span",{className:"flex items-center gap-0.5",children:[r.jsx(Xt,{className:"w-2.5 h-2.5"}),e.crossInstanceTasks.total," cross-instance"]})]})]})}function zye({navigate:e}){const{data:t=[],isLoading:n}=L.agentTasks.active.useQuery(void 0,{refetchInterval:5e3}),s=L.agentTasks.cancel.useMutation(),[i,a]=y.useState(new Set);if(n||t.length===0)return null;function o(l){a(c=>{const d=new Set(c);return d.has(l)?d.delete(l):d.add(l),d})}return r.jsxs("div",{className:"border-b border-[#2A2A35]",children:[r.jsxs("div",{className:"px-5 py-3 flex items-center gap-2",children:[r.jsx(cse,{className:"w-3.5 h-3.5 text-[#6366F1]"}),r.jsx("span",{className:"text-[12px] font-semibold text-[#F0F0F5]",children:"Active Tasks"}),r.jsx("span",{className:"bg-[#6366F1] text-white text-[10px] font-bold rounded-full min-w-[18px] h-[18px] flex items-center justify-center px-1 leading-none",children:t.length})]}),t.map(l=>r.jsxs("div",{className:"px-5 py-2.5 hover:bg-white/[0.02] transition-colors border-t border-[#2A2A35]/30",children:[r.jsxs("div",{className:"flex items-start gap-2.5",children:[r.jsxs("div",{className:"flex -space-x-1.5 flex-shrink-0 mt-0.5",children:[l.fromAgent&&r.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-[11px] border border-[#13131A]",style:{backgroundColor:`${l.fromAgent.color}26`},title:l.fromAgent.name,children:l.fromAgent.emoji}),l.toAgent&&r.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-[11px] border border-[#13131A]",style:{backgroundColor:`${l.toAgent.color}26`},title:l.toAgent.name,children:l.toAgent.emoji})]}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[r.jsxs("span",{className:"text-[11px] font-medium text-[#F0F0F5] truncate",children:[l.fromAgent?.name??l.fromAgentId," → ",l.toAgent?.name??l.toAgentId]}),r.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:Pj[l.status]??"#5A5A6E"}}),l.crossInstance&&r.jsx(Xt,{className:"w-2.5 h-2.5 text-[#A78BFA] flex-shrink-0"})]}),r.jsx("p",{className:"text-[11px] text-[#8A8A99] line-clamp-1",children:l.task}),r.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[r.jsxs("span",{className:"text-[10px] text-[#5A5A6E]",children:[Lye(l.startedAt,l.createdAt)," · depth ",l.depth," · ",l.status.replace("_"," ")]}),l.parentTaskId&&r.jsxs("button",{onClick:c=>{c.stopPropagation(),o(l.id)},className:"flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] text-[#6366F1] hover:bg-[#6366F1]/10 transition-colors",children:[r.jsx(Zl,{className:"w-2.5 h-2.5"}),"Chain"]}),r.jsxs("button",{onClick:c=>{c.stopPropagation(),s.mutate({taskId:l.id})},disabled:s.isPending,className:"flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] text-[#EF4444] hover:bg-[#EF4444]/10 transition-colors disabled:opacity-40 ml-auto",children:[r.jsx(L5,{className:"w-2.5 h-2.5"}),"Cancel"]}),l.channelId&&r.jsx("button",{onClick:()=>e(`/channels/${l.channelId}`),className:"flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] text-[#5A5A6E] hover:text-[#8A8A99] hover:bg-white/[0.04] transition-colors",children:r.jsx(cs,{className:"w-2.5 h-2.5"})})]})]})]}),r.jsx(Me,{children:i.has(l.id)&&r.jsx(ne.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden ml-8 mt-1 border-l border-[#2A2A35] pl-3",children:r.jsx(A$,{taskId:l.id,navigate:e})})})]},l.id))]})}function $ye({navigate:e}){const[t,n]=y.useState(!1),[s,i]=y.useState(new Set),{data:a}=L.agentTasks.list.useQuery({status:"completed",limit:10},{staleTime:3e4}),{data:o}=L.agentTasks.list.useQuery({status:"failed",limit:10},{staleTime:3e4}),l=a?.items??[],d=[...o?.items??[],...l].sort((p,m)=>m.createdAt.localeCompare(p.createdAt)).slice(0,10);if(d.length===0)return null;function f(p){i(m=>{const g=new Set(m);return g.has(p)?g.delete(p):g.add(p),g})}return r.jsxs("div",{className:"border-b border-[#2A2A35]",children:[r.jsxs("button",{onClick:()=>n(p=>!p),className:"w-full px-5 py-2.5 flex items-center gap-2 hover:bg-white/[0.02] transition-colors",children:[t?r.jsx(ah,{className:"w-3 h-3 text-[#5A5A6E]"}):r.jsx(ft,{className:"w-3 h-3 text-[#5A5A6E]"}),r.jsx("span",{className:"text-[11px] font-semibold text-[#5A5A6E] uppercase tracking-widest",children:"Recent Completed/Failed"}),r.jsx("span",{className:"text-[10px] text-[#5A5A6E]",children:d.length})]}),r.jsx(Me,{children:t&&r.jsx(ne.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:d.map(p=>r.jsxs("div",{className:"px-5 py-2 hover:bg-white/[0.02] transition-colors border-t border-[#2A2A35]/30",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[10px]",children:y$[p.status]??"•"}),r.jsxs("div",{className:"flex -space-x-1.5 flex-shrink-0",children:[p.fromAgent&&r.jsx("span",{className:"text-[10px]",children:p.fromAgent.emoji}),r.jsx("span",{className:"text-[9px] text-[#5A5A6E] mx-0.5",children:"→"}),p.toAgent&&r.jsx("span",{className:"text-[10px]",children:p.toAgent.emoji})]}),r.jsx("span",{className:"text-[11px] text-[#8A8A99] flex-1 truncate",children:p.task}),p.crossInstance&&r.jsx(Xt,{className:"w-2.5 h-2.5 text-[#A78BFA] flex-shrink-0"}),p.completedAt&&p.startedAt&&r.jsx("span",{className:"text-[10px] text-[#5A5A6E]",children:_$(new Date(p.completedAt).getTime()-new Date(p.startedAt).getTime())}),p.parentTaskId&&r.jsx("button",{onClick:m=>{m.stopPropagation(),f(p.id)},className:"text-[#6366F1] hover:bg-[#6366F1]/10 rounded p-0.5 transition-colors",children:r.jsx(Zl,{className:"w-2.5 h-2.5"})}),p.channelId&&r.jsx("button",{onClick:()=>e(`/channels/${p.channelId}`),className:"text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:r.jsx(cs,{className:"w-2.5 h-2.5"})})]}),r.jsx(Me,{children:s.has(p.id)&&r.jsx(ne.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden ml-6 mt-1",children:r.jsx(A$,{taskId:p.id,navigate:e})})})]},p.id))})})]})}function Vye(){const[e,t]=y.useState(!1),[n,s]=y.useState("all"),{data:i=[]}=L.agentTasks.crossInstanceAudit.useQuery({limit:50,decision:n==="all"?void 0:n},{staleTime:3e4});return i.length===0&&n==="all"?null:r.jsxs("div",{className:"border-b border-[#2A2A35]",children:[r.jsxs("button",{onClick:()=>t(a=>!a),className:"w-full px-5 py-2.5 flex items-center gap-2 hover:bg-white/[0.02] transition-colors",children:[e?r.jsx(ah,{className:"w-3 h-3 text-[#A78BFA]"}):r.jsx(ft,{className:"w-3 h-3 text-[#A78BFA]"}),r.jsx(Xt,{className:"w-3 h-3 text-[#A78BFA]"}),r.jsx("span",{className:"text-[11px] font-semibold text-[#A78BFA] uppercase tracking-widest",children:"Cross-Instance Audit"}),r.jsx("span",{className:"text-[10px] text-[#5A5A6E]",children:i.length})]}),r.jsx(Me,{children:e&&r.jsxs(ne.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:[r.jsx("div",{className:"flex gap-1 px-5 py-1.5",children:["all","allowed","blocked"].map(a=>r.jsx("button",{onClick:()=>s(a),className:`px-2 py-0.5 rounded-full text-[10px] font-medium transition-colors ${n===a?"bg-[#A78BFA] text-white":"bg-white/5 text-[#8A8A99] hover:text-[#C8C8D4]"}`,children:a},a))}),i.map(a=>r.jsxs("div",{className:"px-5 py-2 hover:bg-white/[0.02] transition-colors border-t border-[#2A2A35]/30",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:`px-1.5 py-0.5 rounded text-[9px] font-medium ${a.decision==="allowed"?"bg-[#10B981]/10 text-[#10B981]":"bg-[#EF4444]/10 text-[#EF4444]"}`,children:a.decision}),r.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[a.fromAgent&&r.jsx("span",{className:"text-[10px]",children:a.fromAgent.emoji}),r.jsx("span",{className:"text-[9px] text-[#5A5A6E]",children:"→"}),a.toAgent&&r.jsx("span",{className:"text-[10px]",children:a.toAgent.emoji})]}),r.jsx("span",{className:"text-[11px] text-[#8A8A99] flex-1 truncate",children:a.taskSummary}),r.jsx("span",{className:"text-[10px] text-[#5A5A6E] flex-shrink-0",children:Ir(a.timestamp)}),a.status!=="blocked"&&r.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:Pj[a.status]??"#5A5A6E"}})]}),r.jsxs("div",{className:"flex items-center gap-1 mt-0.5 ml-14",children:[r.jsx("span",{className:"text-[10px] text-[#5A5A6E]",children:a.fromAgent?.name??a.fromAgentId}),r.jsx("span",{className:"text-[9px] text-[#5A5A6E]",children:"→"}),r.jsx("span",{className:"text-[10px] text-[#5A5A6E]",children:a.toAgent?.name??a.toAgentId})]})]},a.id)),i.length===0&&r.jsx("p",{className:"px-5 py-3 text-[11px] text-[#5A5A6E] italic",children:"No cross-instance delegations found."})]})})]})}function Uye({onClose:e}){const t=an(),n=L.useUtils(),[s,i]=y.useState(new Set),[a,o]=y.useState(null),[l,c]=y.useState(""),[d,f]=y.useState(!1),[p,m]=y.useState(""),[g,b]=y.useState(new Set),{data:_,isLoading:w}=L.approvals.list.useQuery({status:"pending"},{refetchInterval:1e4}),A=L.approvals.decide.useMutation({onSuccess:()=>{n.approvals.list.invalidate(),n.approvals.pendingCount.invalidate()}}),S=L.approvals.batchApprove.useMutation({onSuccess:()=>{i(new Set),n.approvals.list.invalidate(),n.approvals.pendingCount.invalidate()}}),C=L.approvals.batchReject.useMutation({onSuccess:()=>{i(new Set),f(!1),m(""),n.approvals.list.invalidate(),n.approvals.pendingCount.invalidate()}}),E=[..._?.items??[]].sort(($,B)=>B.createdAt.localeCompare($.createdAt)),k=E.filter($=>$.messageId).map($=>$.messageId),T=[...s].filter($=>k.includes($));function F($){i(B=>{const Y=new Set(B);return Y.has($)?Y.delete($):Y.add($),Y})}function M(){s.size===k.length?i(new Set):i(new Set(k))}function I($){A.mutate({messageId:$,decision:"approved"})}function R($){A.mutate({messageId:$,decision:"rejected",rejectionNote:l||void 0}),o(null),c("")}function H(){T.length!==0&&S.mutate({messageIds:T})}function V(){T.length!==0&&C.mutate({messageIds:T,rejectionNote:p||void 0})}function K($){b(B=>{const Y=new Set(B);return Y.has($)?Y.delete($):Y.add($),Y})}function q($){t(`/channels/${$}`),e()}return r.jsxs(r.Fragment,{children:[r.jsx(ne.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-40",style:{backdropFilter:"blur(2px)",backgroundColor:"rgba(0,0,0,0.25)"},onClick:e}),r.jsxs(ne.div,{initial:{x:"100%",opacity:0},animate:{x:0,opacity:1},exit:{x:"100%",opacity:0},transition:{duration:.3,ease:[.16,1,.3,1]},className:"fixed right-0 top-0 h-screen w-[420px] bg-[#13131A] border-l border-[#2A2A35] flex flex-col z-50 shadow-2xl",children:[r.jsxs("div",{className:"px-5 py-4 border-b border-[#2A2A35] flex items-center justify-between flex-shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-2.5",children:[r.jsx("h2",{className:"text-[15px] font-semibold text-[#F0F0F5]",children:"Pending Approvals"}),E.length>0&&r.jsx("span",{className:"bg-[#EF4444] text-white text-[10px] font-bold rounded-full min-w-[18px] h-[18px] flex items-center justify-center px-1 leading-none",children:E.length})]}),r.jsx("button",{onClick:e,className:"w-7 h-7 flex items-center justify-center rounded-md text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/10 transition-colors",children:r.jsx(Te,{className:"w-4 h-4"})})]}),T.length>0&&r.jsx("div",{className:"px-5 py-3 border-b border-[#2A2A35]/50 flex flex-col gap-2 flex-shrink-0",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("span",{className:"text-[12px] text-[#8A8A99]",children:[T.length," selected"]}),r.jsxs("button",{onClick:H,disabled:S.isPending,className:"flex items-center gap-1 px-2.5 py-1 rounded-md bg-[#10B981]/15 text-[#10B981] text-[11px] font-medium hover:bg-[#10B981]/25 transition-colors disabled:opacity-40",children:[r.jsx(Fe,{className:"w-3 h-3"}),"Approve ",T.length]}),d?r.jsxs("div",{className:"flex items-center gap-1.5 flex-1",children:[r.jsx("input",{value:p,onChange:$=>m($.target.value),placeholder:"Reason (optional)",className:"flex-1 bg-[#0F0F11] border border-[#2A2A35] rounded-md px-2 py-1 text-[11px] text-[#F0F0F5] placeholder-[#5A5A6E] outline-none focus:border-[#EF4444]/40",onKeyDown:$=>{$.key==="Enter"&&V()},autoFocus:!0}),r.jsx("button",{onClick:V,disabled:C.isPending,className:"px-2 py-1 rounded-md bg-[#EF4444]/15 text-[#EF4444] text-[11px] font-medium hover:bg-[#EF4444]/25 transition-colors disabled:opacity-40",children:"Reject"}),r.jsx("button",{onClick:()=>{f(!1),m("")},className:"text-[11px] text-[#5A5A6E] hover:text-[#8A8A99]",children:"Cancel"})]}):r.jsxs("button",{onClick:()=>f(!0),className:"flex items-center gap-1 px-2.5 py-1 rounded-md bg-[#EF4444]/15 text-[#EF4444] text-[11px] font-medium hover:bg-[#EF4444]/25 transition-colors",children:[r.jsx(Te,{className:"w-3 h-3"}),"Reject ",T.length]})]})}),r.jsxs("div",{className:"flex-1 overflow-y-auto",children:[r.jsx(Bye,{}),r.jsx(zye,{navigate:t}),r.jsx($ye,{navigate:t}),r.jsx(Vye,{}),w?r.jsx("div",{className:"flex items-center justify-center py-16",children:r.jsx("div",{className:"w-5 h-5 border-2 border-[#6366F1]/30 border-t-[#6366F1] rounded-full animate-spin"})}):E.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[r.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/[0.03] border border-[#2A2A35] flex items-center justify-center mb-3",children:r.jsx(Fe,{className:"w-4 h-4 text-[#5A5A6E]"})}),r.jsx("p",{className:"text-[13px] text-[#5A5A6E]",children:"No pending approvals"})]}):r.jsxs(r.Fragment,{children:[k.length>1&&r.jsx("div",{className:"px-5 py-2 sticky top-0 z-10 bg-[#13131A]",children:r.jsxs("label",{className:"flex items-center gap-2 text-[11px] text-[#5A5A6E] cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:s.size>0&&s.size===k.length,onChange:M,className:"accent-[#6366F1] w-3.5 h-3.5"}),"Select all"]})}),r.jsx(Me,{initial:!1,children:E.map($=>{const B=Oye[$.type]??yL,Y=a===($.messageId??$.id),U=g.has($.id);return r.jsx(ne.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.15},className:"border-b border-[#2A2A35]/40",children:r.jsx("div",{className:"px-5 py-3 hover:bg-white/[0.02] transition-colors",children:r.jsxs("div",{className:"flex items-start gap-2.5",children:[$.messageId&&r.jsx("input",{type:"checkbox",checked:s.has($.messageId),onChange:()=>F($.messageId),className:"accent-[#6366F1] w-3.5 h-3.5 mt-1 flex-shrink-0"}),r.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center flex-shrink-0",style:{backgroundColor:$.agentColor?`${$.agentColor}15`:"rgba(99, 102, 241, 0.1)"},children:$.agentEmoji?r.jsx("span",{className:"text-xs",children:$.agentEmoji}):r.jsx(B,{className:"w-3.5 h-3.5 text-[#8A8A99]"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[r.jsx("span",{className:"text-[12px] font-medium text-[#F0F0F5] truncate",children:$.agentName??"Agent"}),r.jsx(Pye,{priority:$.priority}),r.jsx(Iye,{expiresAt:$.expiresAt}),r.jsx("span",{className:"text-[10px] text-[#5A5A6E] ml-auto flex-shrink-0",children:Ir($.createdAt)})]}),$.type==="delegation_rule"&&$.payload?(()=>{try{const W=JSON.parse($.payload);return r.jsxs("div",{className:"mb-1.5",children:[r.jsxs("p",{className:"text-[12px] text-[#C8C8D4] leading-relaxed mb-1",children:["COO wants to create a delegation rule: Auto-approve ",r.jsx("code",{className:"text-[#6366F1] bg-[#6366F1]/10 px-1 rounded text-[11px]",children:W.pattern})," for ",r.jsx("span",{className:"text-[#F0F0F5] font-medium",children:W.agentId})]}),r.jsx("p",{className:"text-[11px] text-[#8A8A99] italic mb-1",children:W.reason}),r.jsxs("p",{className:"text-[10px] text-[#5A5A6E] leading-relaxed",children:["Future ",r.jsx("code",{className:"text-[#5A5A6E]",children:W.pattern})," actions from ",W.agentId," will be automatically approved without your review."]})]})}catch{return null}})():r.jsxs(r.Fragment,{children:[r.jsx("p",{className:`text-[12px] text-[#C8C8D4] leading-relaxed mb-1 whitespace-pre-wrap ${U?"":"line-clamp-2"}`,children:$.content}),$.content.length>100&&r.jsxs("button",{onClick:()=>K($.id),className:"flex items-center gap-0.5 text-[10px] text-[#5A5A6E] hover:text-[#8A8A99] transition-colors mb-1.5",children:[U?r.jsx(ah,{className:"w-2.5 h-2.5"}):r.jsx(ft,{className:"w-2.5 h-2.5"}),U?"Less":"More"]})]}),Y?r.jsxs(ne.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},className:"flex items-center gap-1.5 mb-1",children:[r.jsx("input",{value:l,onChange:W=>c(W.target.value),placeholder:"Reason (optional)",className:"flex-1 bg-[#0F0F11] border border-[#2A2A35] rounded-md px-2 py-1 text-[11px] text-[#F0F0F5] placeholder-[#5A5A6E] outline-none focus:border-[#EF4444]/40",onKeyDown:W=>{W.key==="Enter"&&R($.messageId)},autoFocus:!0}),r.jsx("button",{onClick:()=>R($.messageId),className:"px-2 py-1 rounded-md bg-[#EF4444]/15 text-[#EF4444] text-[11px] font-medium hover:bg-[#EF4444]/25 transition-colors",children:"Reject"}),r.jsx("button",{onClick:()=>{o(null),c("")},className:"text-[11px] text-[#5A5A6E] hover:text-[#8A8A99]",children:"Cancel"})]}):r.jsxs("div",{className:"flex items-center gap-1.5",children:[$.messageId&&r.jsxs(r.Fragment,{children:[r.jsxs("button",{onClick:()=>I($.messageId),disabled:A.isPending,className:"flex items-center gap-1 px-2 py-0.5 rounded-md bg-[#10B981]/12 text-[#10B981] text-[11px] font-medium hover:bg-[#10B981]/22 transition-colors disabled:opacity-40",children:[r.jsx(Fe,{className:"w-3 h-3"}),"Approve"]}),r.jsxs("button",{onClick:()=>o($.messageId),className:"flex items-center gap-1 px-2 py-0.5 rounded-md bg-[#EF4444]/12 text-[#EF4444] text-[11px] font-medium hover:bg-[#EF4444]/22 transition-colors",children:[r.jsx(Te,{className:"w-3 h-3"}),"Reject"]})]}),r.jsxs("button",{onClick:()=>q($.channelId),className:"flex items-center gap-0.5 ml-auto px-1.5 py-0.5 rounded text-[10px] text-[#5A5A6E] hover:text-[#8A8A99] hover:bg-white/[0.04] transition-colors",children:[r.jsx(cs,{className:"w-2.5 h-2.5"}),"View"]})]})]})]})})},$.id)})})]})]})]})]})}function Hye(){const e=an(),{data:t}=L.onboarding.getState.useQuery(void 0,{refetchOnWindowFocus:!1}),{data:n}=L.onboarding.pollOpenClaw.useQuery(void 0,{refetchInterval:1e4,refetchOnWindowFocus:!1}),s=L.onboarding.skipOpenClaw.useMutation(),i=L.useUtils();if(!t?.skippedOpenClaw||n?.running)return null;async function a(){await s.mutateAsync(),i.onboarding.getState.invalidate()}return r.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-[#1C1410] border-b border-[#F59E0B]/20 text-[12px] flex-shrink-0",children:[r.jsxs("span",{className:"text-[#F59E0B]",children:["OpenClaw not connected —"," ",r.jsx("button",{onClick:()=>e("/onboarding"),className:"underline underline-offset-2 hover:text-[#FBBF24] transition-colors",children:"set up now"})]}),r.jsx("button",{onClick:a,className:"text-[#F59E0B]/60 hover:text-[#F59E0B] transition-colors ml-4",children:r.jsx(Te,{className:"w-3.5 h-3.5"})})]})}function Wye(){const{data:e}=L.settings.getTestMode.useQuery(void 0,{refetchOnWindowFocus:!1,refetchInterval:15e3}),t=L.useUtils(),n=L.settings.setTestMode.useMutation({onSuccess:()=>{t.settings.getTestMode.invalidate()}});return e?.enabled?r.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-[#1C1A0F] border-b border-[#F59E0B]/30 text-[12px] flex-shrink-0",children:[r.jsxs("span",{className:"flex items-center gap-2 text-[#FBBF24]",children:[r.jsx(oL,{className:"w-3.5 h-3.5"}),"Test mode active — no memory, knowledge, or reflection will be recorded."]}),r.jsx("button",{onClick:()=>n.mutate({enabled:!1}),disabled:n.isPending,className:"text-[#FBBF24]/80 hover:text-[#FBBF24] underline underline-offset-2 transition-colors ml-4 disabled:opacity-50",children:"disable"})]}):null}function qye({children:e}){const[t,n]=y.useState(!1);return r.jsxs("div",{className:"flex h-screen w-screen overflow-hidden bg-[#0F0F11] flex-col",children:[r.jsx(Hye,{}),r.jsx(Wye,{}),r.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[r.jsx(lme,{onOpenApprovals:()=>n(s=>!s)}),r.jsxs("main",{className:"flex flex-1 overflow-hidden relative",children:[e,r.jsx(Afe,{})]}),r.jsx(Rye,{})]}),r.jsx(Me,{children:t&&r.jsx(Uye,{onClose:()=>n(!1)})})]})}function Gye({label:e,emoji:t,color:n,typeBadge:s,onRemove:i}){return r.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-md group",children:[r.jsx("span",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs flex-shrink-0",style:{backgroundColor:`${n}26`},children:t??e[0]?.toUpperCase()}),r.jsx("span",{className:"text-[13px] text-[#C8C8D4] flex-1 truncate",children:e}),r.jsx("span",{className:"text-[10px] text-[#5A5A6E] bg-white/5 px-1.5 py-0.5 rounded",children:s}),i&&r.jsx("button",{onClick:i,className:"w-5 h-5 flex items-center justify-center rounded text-[#5A5A6E] opacity-0 group-hover:opacity-100 hover:text-[#EF4444] hover:bg-[#EF4444]/10 transition-all",children:r.jsx(Te,{className:"w-3 h-3"})})]})}function Kye({channelId:e,existingIds:t,agents:n,workspaceMembers:s}){const[i,a]=y.useState(!1),[o,l]=y.useState(""),c=L.useUtils(),d=L.channels.addParticipant.useMutation({onSuccess:()=>{c.channels.list.invalidate(),l(""),a(!1)}}),f=n.filter(_=>!t.has(_.id)),p=s.filter(_=>!t.has(_.userId)),m=o.toLowerCase(),g=m?f.filter(_=>_.name.toLowerCase().includes(m)):f,b=m?p.filter(_=>_.name.toLowerCase().includes(m)):p;return i?r.jsxs("div",{className:"px-1",children:[r.jsx("input",{autoFocus:!0,value:o,onChange:_=>l(_.target.value),placeholder:"Search people and agents...",className:"w-full bg-[#13131A] border border-[#2A2A35] rounded-md px-2 py-1.5 text-[12px] text-[#F0F0F5] placeholder-[#5A5A6E] outline-none focus:border-[#6366F1]/60 transition-colors mb-1",onKeyDown:_=>{_.key==="Escape"&&(a(!1),l(""))}}),r.jsxs("div",{className:"max-h-[180px] overflow-y-auto",children:[g.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-[10px] text-[#5A5A6E] px-2 py-1 uppercase tracking-widest font-semibold",children:"Agents"}),g.map(_=>r.jsxs("button",{onClick:()=>d.mutate({channelId:e,participantId:_.id,participantType:"agent"}),disabled:d.isPending,className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-[12px] text-[#C8C8D4] hover:bg-white/5 transition-colors",children:[r.jsx("span",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[11px] flex-shrink-0",style:{backgroundColor:`${_.color}26`},children:_.emoji}),r.jsx("span",{className:"flex-1 text-left truncate",children:_.name}),r.jsx("span",{className:"text-[10px] text-[#5A5A6E]",children:_.role})]},_.id))]}),b.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-[10px] text-[#5A5A6E] px-2 py-1 uppercase tracking-widest font-semibold",children:"People"}),b.map(_=>{const w=_.name.split(" ").map(A=>A[0]).join("").slice(0,2).toUpperCase();return r.jsxs("button",{onClick:()=>d.mutate({channelId:e,participantId:_.userId,participantType:"human"}),disabled:d.isPending,className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-[12px] text-[#C8C8D4] hover:bg-white/5 transition-colors",children:[_.image?r.jsx("img",{src:_.image,className:"w-5 h-5 rounded-full flex-shrink-0",alt:""}):r.jsx("span",{className:"w-5 h-5 rounded-full bg-gradient-to-br from-[#6366F1] to-[#8B5CF6] flex items-center justify-center text-[9px] font-semibold text-white flex-shrink-0",children:w}),r.jsx("span",{className:"flex-1 text-left truncate",children:_.name})]},_.userId)})]}),g.length===0&&b.length===0&&r.jsx("p",{className:"text-[11px] text-[#5A5A6E] px-2 py-1.5",children:"No participants available"})]})]}):r.jsxs("button",{onClick:()=>a(!0),className:"flex items-center gap-1.5 px-2 py-1.5 rounded-md text-[12px] text-[#5A5A6E] hover:text-[#8A8A99] hover:bg-white/5 transition-colors w-full",children:[r.jsx(wt,{className:"w-3.5 h-3.5"}),r.jsx("span",{children:"Add participant"})]})}function S$({channel:e}){const{data:t=[]}=Vo(),{data:n}=Mi(),{data:s=[]}=L.workspace.listMembers.useQuery(void 0,{staleTime:3e4}),i=L.useUtils(),a=L.channels.removeParticipant.useMutation({onSuccess:()=>{i.channels.list.invalidate()}}),o=new Set(e.participants.map(c=>c.participantId)),l=e.participants.length;return r.jsxs(Ys,{children:[r.jsx(ci,{asChild:!0,children:r.jsxs("button",{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/10 transition-colors border border-transparent hover:border-[#2A2A35]",children:[r.jsx(wm,{className:"w-3.5 h-3.5"}),r.jsx("span",{children:l})]})}),r.jsx(Qs,{children:r.jsxs(Xs,{align:"end",sideOffset:6,className:"bg-[#1C1C24] border border-[#2A2A35] rounded-lg shadow-xl w-[260px] z-50",children:[r.jsx("div",{className:"px-3 py-2 border-b border-[#2A2A35]",children:r.jsx("span",{className:"text-[11px] font-semibold text-[#8A8A99] uppercase tracking-widest",children:"Members"})}),r.jsx("div",{className:"py-1 px-1 max-h-[200px] overflow-y-auto",children:e.participants.map(c=>{const d=t.find(A=>A.id===c.participantId),f=c.participantType==="human",m=(f?s.find(A=>A.userId===c.participantId):void 0)?.name??n?.user?.name??n?.user?.email??"User",g=f?m:d?.name??c.participantId,b=f?void 0:d?.emoji,_=f?"#6366F1":d?.color??"#8A8A99",w=e.participants.length>1;return r.jsx(Gye,{label:g,emoji:b,color:_,typeBadge:f?"Human":"Agent",onRemove:w?()=>a.mutate({channelId:e.id,participantId:c.participantId}):void 0},c.id)})}),r.jsx("div",{className:"border-t border-[#2A2A35] py-1.5 px-1",children:r.jsx(Kye,{channelId:e.id,existingIds:o,agents:t,workspaceMembers:s})}),r.jsx(oa,{className:"fill-[#2A2A35]"})]})})]})}function Ij(e){const t=e+"CollectionProvider",[n,s]=Wa(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=_=>{const{scope:w,children:A}=_,S=be.useRef(null),C=be.useRef(new Map).current;return r.jsx(i,{scope:w,itemMap:C,collectionRef:S,children:A})};o.displayName=t;const l=e+"CollectionSlot",c=iu(l),d=be.forwardRef((_,w)=>{const{scope:A,children:S}=_,C=a(l,A),E=At(w,C.collectionRef);return r.jsx(c,{ref:E,children:S})});d.displayName=l;const f=e+"CollectionItemSlot",p="data-radix-collection-item",m=iu(f),g=be.forwardRef((_,w)=>{const{scope:A,children:S,...C}=_,E=be.useRef(null),k=At(w,E),T=a(f,A);return be.useEffect(()=>(T.itemMap.set(E,{ref:E,...C}),()=>{T.itemMap.delete(E)})),r.jsx(m,{[p]:"",ref:k,children:S})});g.displayName=f;function b(_){const w=a(e+"CollectionConsumer",_);return be.useCallback(()=>{const S=w.collectionRef.current;if(!S)return[];const C=Array.from(S.querySelectorAll(`[${p}]`));return Array.from(w.itemMap.values()).sort((T,F)=>C.indexOf(T.ref.current)-C.indexOf(F.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:o,Slot:d,ItemSlot:g},b,s]}var Yye=y.createContext(void 0);function Lj(e){const t=y.useContext(Yye);return e||t||"ltr"}var gA="rovingFocusGroup.onEntryFocus",Qye={bubbles:!1,cancelable:!0},Lm="RovingFocusGroup",[JS,C$,Xye]=Ij(Lm),[Jye,j$]=Wa(Lm,[Xye]),[Zye,e1e]=Jye(Lm),N$=y.forwardRef((e,t)=>r.jsx(JS.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(JS.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(t1e,{...e,ref:t})})}));N$.displayName=Lm;var t1e=y.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:f=!1,...p}=e,m=y.useRef(null),g=At(t,m),b=Lj(a),[_,w]=Fo({prop:o,defaultProp:l??null,onChange:c,caller:Lm}),[A,S]=y.useState(!1),C=ia(d),E=C$(n),k=y.useRef(!1),[T,F]=y.useState(0);return y.useEffect(()=>{const M=m.current;if(M)return M.addEventListener(gA,C),()=>M.removeEventListener(gA,C)},[C]),r.jsx(Zye,{scope:n,orientation:s,dir:b,loop:i,currentTabStopId:_,onItemFocus:y.useCallback(M=>w(M),[w]),onItemShiftTab:y.useCallback(()=>S(!0),[]),onFocusableItemAdd:y.useCallback(()=>F(M=>M+1),[]),onFocusableItemRemove:y.useCallback(()=>F(M=>M-1),[]),children:r.jsx(lt.div,{tabIndex:A||T===0?-1:0,"data-orientation":s,...p,ref:g,style:{outline:"none",...e.style},onMouseDown:Oe(e.onMouseDown,()=>{k.current=!0}),onFocus:Oe(e.onFocus,M=>{const I=!k.current;if(M.target===M.currentTarget&&I&&!A){const R=new CustomEvent(gA,Qye);if(M.currentTarget.dispatchEvent(R),!R.defaultPrevented){const H=E().filter(B=>B.focusable),V=H.find(B=>B.active),K=H.find(B=>B.id===_),$=[V,K,...H].filter(Boolean).map(B=>B.ref.current);F$($,f)}}k.current=!1}),onBlur:Oe(e.onBlur,()=>S(!1))})})}),k$="RovingFocusGroupItem",E$=y.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:i=!1,tabStopId:a,children:o,...l}=e,c=Zi(),d=a||c,f=e1e(k$,n),p=f.currentTabStopId===d,m=C$(n),{onFocusableItemAdd:g,onFocusableItemRemove:b,currentTabStopId:_}=f;return y.useEffect(()=>{if(s)return g(),()=>b()},[s,g,b]),r.jsx(JS.ItemSlot,{scope:n,id:d,focusable:s,active:i,children:r.jsx(lt.span,{tabIndex:p?0:-1,"data-orientation":f.orientation,...l,ref:t,onMouseDown:Oe(e.onMouseDown,w=>{s?f.onItemFocus(d):w.preventDefault()}),onFocus:Oe(e.onFocus,()=>f.onItemFocus(d)),onKeyDown:Oe(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){f.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const A=i1e(w,f.orientation,f.dir);if(A!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let C=m().filter(E=>E.focusable).map(E=>E.ref.current);if(A==="last")C.reverse();else if(A==="prev"||A==="next"){A==="prev"&&C.reverse();const E=C.indexOf(w.currentTarget);C=f.loop?r1e(C,E+1):C.slice(E+1)}setTimeout(()=>F$(C))}}),children:typeof o=="function"?o({isCurrentTabStop:p,hasTabStop:_!=null}):o})})});E$.displayName=k$;var n1e={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function s1e(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function i1e(e,t,n){const s=s1e(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return n1e[s]}function F$(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function r1e(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var a1e=N$,o1e=E$,ZS=["Enter"," "],l1e=["ArrowDown","PageUp","Home"],T$=["ArrowUp","PageDown","End"],c1e=[...l1e,...T$],u1e={ltr:[...ZS,"ArrowRight"],rtl:[...ZS,"ArrowLeft"]},d1e={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Bm="Menu",[zp,h1e,f1e]=Ij(Bm),[_u,M$]=Wa(Bm,[f1e,tc,j$]),zm=tc(),R$=j$(),[D$,ic]=_u(Bm),[p1e,$m]=_u(Bm),O$=e=>{const{__scopeMenu:t,open:n=!1,children:s,dir:i,onOpenChange:a,modal:o=!0}=e,l=zm(t),[c,d]=y.useState(null),f=y.useRef(!1),p=ia(a),m=Lj(i);return y.useEffect(()=>{const g=()=>{f.current=!0,document.addEventListener("pointerdown",b,{capture:!0,once:!0}),document.addEventListener("pointermove",b,{capture:!0,once:!0})},b=()=>f.current=!1;return document.addEventListener("keydown",g,{capture:!0}),()=>{document.removeEventListener("keydown",g,{capture:!0}),document.removeEventListener("pointerdown",b,{capture:!0}),document.removeEventListener("pointermove",b,{capture:!0})}},[]),r.jsx(jm,{...l,children:r.jsx(D$,{scope:t,open:n,onOpenChange:p,content:c,onContentChange:d,children:r.jsx(p1e,{scope:t,onClose:y.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:f,dir:m,modal:o,children:s})})})};O$.displayName=Bm;var m1e="MenuAnchor",Bj=y.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e,i=zm(n);return r.jsx(Nm,{...i,...s,ref:t})});Bj.displayName=m1e;var zj="MenuPortal",[x1e,P$]=_u(zj,{forceMount:void 0}),I$=e=>{const{__scopeMenu:t,forceMount:n,children:s,container:i}=e,a=ic(zj,t);return r.jsx(x1e,{scope:t,forceMount:n,children:r.jsx(zr,{present:n||a.open,children:r.jsx(hh,{asChild:!0,container:i,children:s})})})};I$.displayName=zj;var Or="MenuContent",[g1e,$j]=_u(Or),L$=y.forwardRef((e,t)=>{const n=P$(Or,e.__scopeMenu),{forceMount:s=n.forceMount,...i}=e,a=ic(Or,e.__scopeMenu),o=$m(Or,e.__scopeMenu);return r.jsx(zp.Provider,{scope:e.__scopeMenu,children:r.jsx(zr,{present:s||a.open,children:r.jsx(zp.Slot,{scope:e.__scopeMenu,children:o.modal?r.jsx(b1e,{...i,ref:t}):r.jsx(v1e,{...i,ref:t})})})})}),b1e=y.forwardRef((e,t)=>{const n=ic(Or,e.__scopeMenu),s=y.useRef(null),i=At(t,s);return y.useEffect(()=>{const a=s.current;if(a)return Av(a)},[]),r.jsx(Vj,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Oe(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),v1e=y.forwardRef((e,t)=>{const n=ic(Or,e.__scopeMenu);return r.jsx(Vj,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),y1e=iu("MenuContent.ScrollLock"),Vj=y.forwardRef((e,t)=>{const{__scopeMenu:n,loop:s=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEntryFocus:c,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:p,onInteractOutside:m,onDismiss:g,disableOutsideScroll:b,..._}=e,w=ic(Or,n),A=$m(Or,n),S=zm(n),C=R$(n),E=h1e(n),[k,T]=y.useState(null),F=y.useRef(null),M=At(t,F,w.onContentChange),I=y.useRef(0),R=y.useRef(""),H=y.useRef(0),V=y.useRef(null),K=y.useRef("right"),q=y.useRef(0),$=b?Sm:y.Fragment,B=b?{as:y1e,allowPinchZoom:!0}:void 0,Y=W=>{const O=R.current+W,D=E().filter(oe=>!oe.disabled),Q=document.activeElement,z=D.find(oe=>oe.ref.current===Q)?.textValue,J=D.map(oe=>oe.textValue),ee=M1e(J,O,z),re=D.find(oe=>oe.textValue===ee)?.ref.current;(function oe(se){R.current=se,window.clearTimeout(I.current),se!==""&&(I.current=window.setTimeout(()=>oe(""),1e3))})(O),re&&setTimeout(()=>re.focus())};y.useEffect(()=>()=>window.clearTimeout(I.current),[]),_v();const U=y.useCallback(W=>K.current===V.current?.side&&D1e(W,V.current?.area),[]);return r.jsx(g1e,{scope:n,searchRef:R,onItemEnter:y.useCallback(W=>{U(W)&&W.preventDefault()},[U]),onItemLeave:y.useCallback(W=>{U(W)||(F.current?.focus(),T(null))},[U]),onTriggerLeave:y.useCallback(W=>{U(W)&&W.preventDefault()},[U]),pointerGraceTimerRef:H,onPointerGraceIntentChange:y.useCallback(W=>{V.current=W},[]),children:r.jsx($,{...B,children:r.jsx(Am,{asChild:!0,trapped:i,onMountAutoFocus:Oe(a,W=>{W.preventDefault(),F.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:r.jsx(dh,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:p,onInteractOutside:m,onDismiss:g,children:r.jsx(a1e,{asChild:!0,...C,dir:A.dir,orientation:"vertical",loop:s,currentTabStopId:k,onCurrentTabStopIdChange:T,onEntryFocus:Oe(c,W=>{A.isUsingKeyboardRef.current||W.preventDefault()}),preventScrollOnEntryFocus:!0,children:r.jsx(Fv,{role:"menu","aria-orientation":"vertical","data-state":t7(w.open),"data-radix-menu-content":"",dir:A.dir,...S,..._,ref:M,style:{outline:"none",..._.style},onKeyDown:Oe(_.onKeyDown,W=>{const D=W.target.closest("[data-radix-menu-content]")===W.currentTarget,Q=W.ctrlKey||W.altKey||W.metaKey,z=W.key.length===1;D&&(W.key==="Tab"&&W.preventDefault(),!Q&&z&&Y(W.key));const J=F.current;if(W.target!==J||!c1e.includes(W.key))return;W.preventDefault();const re=E().filter(oe=>!oe.disabled).map(oe=>oe.ref.current);T$.includes(W.key)&&re.reverse(),F1e(re)}),onBlur:Oe(e.onBlur,W=>{W.currentTarget.contains(W.target)||(window.clearTimeout(I.current),R.current="")}),onPointerMove:Oe(e.onPointerMove,$p(W=>{const O=W.target,D=q.current!==W.clientX;if(W.currentTarget.contains(O)&&D){const Q=W.clientX>q.current?"right":"left";K.current=Q,q.current=W.clientX}}))})})})})})})});L$.displayName=Or;var _1e="MenuGroup",Uj=y.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(lt.div,{role:"group",...s,ref:t})});Uj.displayName=_1e;var w1e="MenuLabel",B$=y.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(lt.div,{...s,ref:t})});B$.displayName=w1e;var j0="MenuItem",oR="menu.itemSelect",Gv=y.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:s,...i}=e,a=y.useRef(null),o=$m(j0,e.__scopeMenu),l=$j(j0,e.__scopeMenu),c=At(t,a),d=y.useRef(!1),f=()=>{const p=a.current;if(!n&&p){const m=new CustomEvent(oR,{bubbles:!0,cancelable:!0});p.addEventListener(oR,g=>s?.(g),{once:!0}),BL(p,m),m.defaultPrevented?d.current=!1:o.onClose()}};return r.jsx(z$,{...i,ref:c,disabled:n,onClick:Oe(e.onClick,f),onPointerDown:p=>{e.onPointerDown?.(p),d.current=!0},onPointerUp:Oe(e.onPointerUp,p=>{d.current||p.currentTarget?.click()}),onKeyDown:Oe(e.onKeyDown,p=>{const m=l.searchRef.current!=="";n||m&&p.key===" "||ZS.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});Gv.displayName=j0;var z$=y.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:s=!1,textValue:i,...a}=e,o=$j(j0,n),l=R$(n),c=y.useRef(null),d=At(t,c),[f,p]=y.useState(!1),[m,g]=y.useState("");return y.useEffect(()=>{const b=c.current;b&&g((b.textContent??"").trim())},[a.children]),r.jsx(zp.ItemSlot,{scope:n,disabled:s,textValue:i??m,children:r.jsx(o1e,{asChild:!0,...l,focusable:!s,children:r.jsx(lt.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":s||void 0,"data-disabled":s?"":void 0,...a,ref:d,onPointerMove:Oe(e.onPointerMove,$p(b=>{s?o.onItemLeave(b):(o.onItemEnter(b),b.defaultPrevented||b.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Oe(e.onPointerLeave,$p(b=>o.onItemLeave(b))),onFocus:Oe(e.onFocus,()=>p(!0)),onBlur:Oe(e.onBlur,()=>p(!1))})})})}),A1e="MenuCheckboxItem",$$=y.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:s,...i}=e;return r.jsx(q$,{scope:e.__scopeMenu,checked:n,children:r.jsx(Gv,{role:"menuitemcheckbox","aria-checked":N0(n)?"mixed":n,...i,ref:t,"data-state":qj(n),onSelect:Oe(i.onSelect,()=>s?.(N0(n)?!0:!n),{checkForDefaultPrevented:!1})})})});$$.displayName=A1e;var V$="MenuRadioGroup",[S1e,C1e]=_u(V$,{value:void 0,onValueChange:()=>{}}),U$=y.forwardRef((e,t)=>{const{value:n,onValueChange:s,...i}=e,a=ia(s);return r.jsx(S1e,{scope:e.__scopeMenu,value:n,onValueChange:a,children:r.jsx(Uj,{...i,ref:t})})});U$.displayName=V$;var H$="MenuRadioItem",W$=y.forwardRef((e,t)=>{const{value:n,...s}=e,i=C1e(H$,e.__scopeMenu),a=n===i.value;return r.jsx(q$,{scope:e.__scopeMenu,checked:a,children:r.jsx(Gv,{role:"menuitemradio","aria-checked":a,...s,ref:t,"data-state":qj(a),onSelect:Oe(s.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});W$.displayName=H$;var Hj="MenuItemIndicator",[q$,j1e]=_u(Hj,{checked:!1}),G$=y.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:s,...i}=e,a=j1e(Hj,n);return r.jsx(zr,{present:s||N0(a.checked)||a.checked===!0,children:r.jsx(lt.span,{...i,ref:t,"data-state":qj(a.checked)})})});G$.displayName=Hj;var N1e="MenuSeparator",K$=y.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(lt.div,{role:"separator","aria-orientation":"horizontal",...s,ref:t})});K$.displayName=N1e;var k1e="MenuArrow",Y$=y.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e,i=zm(n);return r.jsx(Tv,{...i,...s,ref:t})});Y$.displayName=k1e;var Wj="MenuSub",[E1e,Q$]=_u(Wj),X$=e=>{const{__scopeMenu:t,children:n,open:s=!1,onOpenChange:i}=e,a=ic(Wj,t),o=zm(t),[l,c]=y.useState(null),[d,f]=y.useState(null),p=ia(i);return y.useEffect(()=>(a.open===!1&&p(!1),()=>p(!1)),[a.open,p]),r.jsx(jm,{...o,children:r.jsx(D$,{scope:t,open:s,onOpenChange:p,content:d,onContentChange:f,children:r.jsx(E1e,{scope:t,contentId:Zi(),triggerId:Zi(),trigger:l,onTriggerChange:c,children:n})})})};X$.displayName=Wj;var Xf="MenuSubTrigger",J$=y.forwardRef((e,t)=>{const n=ic(Xf,e.__scopeMenu),s=$m(Xf,e.__scopeMenu),i=Q$(Xf,e.__scopeMenu),a=$j(Xf,e.__scopeMenu),o=y.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:c}=a,d={__scopeMenu:e.__scopeMenu},f=y.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return y.useEffect(()=>f,[f]),y.useEffect(()=>{const p=l.current;return()=>{window.clearTimeout(p),c(null)}},[l,c]),r.jsx(Bj,{asChild:!0,...d,children:r.jsx(z$,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":t7(n.open),...e,ref:yv(t,i.onTriggerChange),onClick:p=>{e.onClick?.(p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Oe(e.onPointerMove,$p(p=>{a.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),f()},100))})),onPointerLeave:Oe(e.onPointerLeave,$p(p=>{f();const m=n.content?.getBoundingClientRect();if(m){const g=n.content?.dataset.side,b=g==="right",_=b?-5:5,w=m[b?"left":"right"],A=m[b?"right":"left"];a.onPointerGraceIntentChange({area:[{x:p.clientX+_,y:p.clientY},{x:w,y:m.top},{x:A,y:m.top},{x:A,y:m.bottom},{x:w,y:m.bottom}],side:g}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(p),p.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:Oe(e.onKeyDown,p=>{const m=a.searchRef.current!=="";e.disabled||m&&p.key===" "||u1e[s.dir].includes(p.key)&&(n.onOpenChange(!0),n.content?.focus(),p.preventDefault())})})})});J$.displayName=Xf;var Z$="MenuSubContent",e7=y.forwardRef((e,t)=>{const n=P$(Or,e.__scopeMenu),{forceMount:s=n.forceMount,...i}=e,a=ic(Or,e.__scopeMenu),o=$m(Or,e.__scopeMenu),l=Q$(Z$,e.__scopeMenu),c=y.useRef(null),d=At(t,c);return r.jsx(zp.Provider,{scope:e.__scopeMenu,children:r.jsx(zr,{present:s||a.open,children:r.jsx(zp.Slot,{scope:e.__scopeMenu,children:r.jsx(Vj,{id:l.contentId,"aria-labelledby":l.triggerId,...i,ref:d,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:f=>{o.isUsingKeyboardRef.current&&c.current?.focus(),f.preventDefault()},onCloseAutoFocus:f=>f.preventDefault(),onFocusOutside:Oe(e.onFocusOutside,f=>{f.target!==l.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:Oe(e.onEscapeKeyDown,f=>{o.onClose(),f.preventDefault()}),onKeyDown:Oe(e.onKeyDown,f=>{const p=f.currentTarget.contains(f.target),m=d1e[o.dir].includes(f.key);p&&m&&(a.onOpenChange(!1),l.trigger?.focus(),f.preventDefault())})})})})})});e7.displayName=Z$;function t7(e){return e?"open":"closed"}function N0(e){return e==="indeterminate"}function qj(e){return N0(e)?"indeterminate":e?"checked":"unchecked"}function F1e(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function T1e(e,t){return e.map((n,s)=>e[(t+s)%e.length])}function M1e(e,t,n){const i=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let o=T1e(e,Math.max(a,0));i.length===1&&(o=o.filter(d=>d!==n));const c=o.find(d=>d.toLowerCase().startsWith(i.toLowerCase()));return c!==n?c:void 0}function R1e(e,t){const{x:n,y:s}=e;let i=!1;for(let a=0,o=t.length-1;a<t.length;o=a++){const l=t[a],c=t[o],d=l.x,f=l.y,p=c.x,m=c.y;f>s!=m>s&&n<(p-d)*(s-f)/(m-f)+d&&(i=!i)}return i}function D1e(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return R1e(n,t)}function $p(e){return t=>t.pointerType==="mouse"?e(t):void 0}var O1e=O$,P1e=Bj,I1e=I$,L1e=L$,B1e=Uj,z1e=B$,$1e=Gv,V1e=$$,U1e=U$,H1e=W$,W1e=G$,q1e=K$,G1e=Y$,K1e=X$,Y1e=J$,Q1e=e7,Kv="DropdownMenu",[X1e]=Wa(Kv,[M$]),ei=M$(),[J1e,n7]=X1e(Kv),s7=e=>{const{__scopeDropdownMenu:t,children:n,dir:s,open:i,defaultOpen:a,onOpenChange:o,modal:l=!0}=e,c=ei(t),d=y.useRef(null),[f,p]=Fo({prop:i,defaultProp:a??!1,onChange:o,caller:Kv});return r.jsx(J1e,{scope:t,triggerId:Zi(),triggerRef:d,contentId:Zi(),open:f,onOpenChange:p,onOpenToggle:y.useCallback(()=>p(m=>!m),[p]),modal:l,children:r.jsx(O1e,{...c,open:f,onOpenChange:p,dir:s,modal:l,children:n})})};s7.displayName=Kv;var i7="DropdownMenuTrigger",r7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:s=!1,...i}=e,a=n7(i7,n),o=ei(n);return r.jsx(P1e,{asChild:!0,...o,children:r.jsx(lt.button,{type:"button",id:a.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed","data-disabled":s?"":void 0,disabled:s,...i,ref:yv(t,a.triggerRef),onPointerDown:Oe(e.onPointerDown,l=>{!s&&l.button===0&&l.ctrlKey===!1&&(a.onOpenToggle(),a.open||l.preventDefault())}),onKeyDown:Oe(e.onKeyDown,l=>{s||(["Enter"," "].includes(l.key)&&a.onOpenToggle(),l.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});r7.displayName=i7;var Z1e="DropdownMenuPortal",a7=e=>{const{__scopeDropdownMenu:t,...n}=e,s=ei(t);return r.jsx(I1e,{...s,...n})};a7.displayName=Z1e;var o7="DropdownMenuContent",l7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=n7(o7,n),a=ei(n),o=y.useRef(!1);return r.jsx(L1e,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...s,ref:t,onCloseAutoFocus:Oe(e.onCloseAutoFocus,l=>{o.current||i.triggerRef.current?.focus(),o.current=!1,l.preventDefault()}),onInteractOutside:Oe(e.onInteractOutside,l=>{const c=l.detail.originalEvent,d=c.button===0&&c.ctrlKey===!0,f=c.button===2||d;(!i.modal||f)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});l7.displayName=o7;var e_e="DropdownMenuGroup",c7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=ei(n);return r.jsx(B1e,{...i,...s,ref:t})});c7.displayName=e_e;var t_e="DropdownMenuLabel",u7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=ei(n);return r.jsx(z1e,{...i,...s,ref:t})});u7.displayName=t_e;var n_e="DropdownMenuItem",d7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=ei(n);return r.jsx($1e,{...i,...s,ref:t})});d7.displayName=n_e;var s_e="DropdownMenuCheckboxItem",i_e=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=ei(n);return r.jsx(V1e,{...i,...s,ref:t})});i_e.displayName=s_e;var r_e="DropdownMenuRadioGroup",a_e=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=ei(n);return r.jsx(U1e,{...i,...s,ref:t})});a_e.displayName=r_e;var o_e="DropdownMenuRadioItem",l_e=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=ei(n);return r.jsx(H1e,{...i,...s,ref:t})});l_e.displayName=o_e;var c_e="DropdownMenuItemIndicator",u_e=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=ei(n);return r.jsx(W1e,{...i,...s,ref:t})});u_e.displayName=c_e;var d_e="DropdownMenuSeparator",h7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=ei(n);return r.jsx(q1e,{...i,...s,ref:t})});h7.displayName=d_e;var h_e="DropdownMenuArrow",f_e=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=ei(n);return r.jsx(G1e,{...i,...s,ref:t})});f_e.displayName=h_e;var p_e=e=>{const{__scopeDropdownMenu:t,children:n,open:s,onOpenChange:i,defaultOpen:a}=e,o=ei(t),[l,c]=Fo({prop:s,defaultProp:a??!1,onChange:i,caller:"DropdownMenuSub"});return r.jsx(K1e,{...o,open:l,onOpenChange:c,children:n})},m_e="DropdownMenuSubTrigger",f7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=ei(n);return r.jsx(Y1e,{...i,...s,ref:t})});f7.displayName=m_e;var x_e="DropdownMenuSubContent",p7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,i=ei(n);return r.jsx(Q1e,{...i,...s,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});p7.displayName=x_e;var Yv=s7,Qv=r7,Od=a7,Xv=l7,g_e=c7,b_e=u7,Bl=d7,v_e=h7,lR=p_e,cR=f7,uR=p7;function dR(e,[t,n]){return Math.min(n,Math.max(t,e))}function m7(e){const t=y.useRef({value:e,previous:e});return y.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var y_e=[" ","Enter","ArrowUp","ArrowDown"],__e=[" ","Enter"],uu="Select",[Jv,Zv,w_e]=Ij(uu),[vh]=Wa(uu,[w_e,tc]),ey=tc(),[A_e,rc]=vh(uu),[S_e,C_e]=vh(uu),x7=e=>{const{__scopeSelect:t,children:n,open:s,defaultOpen:i,onOpenChange:a,value:o,defaultValue:l,onValueChange:c,dir:d,name:f,autoComplete:p,disabled:m,required:g,form:b}=e,_=ey(t),[w,A]=y.useState(null),[S,C]=y.useState(null),[E,k]=y.useState(!1),T=Lj(d),[F,M]=Fo({prop:s,defaultProp:i??!1,onChange:a,caller:uu}),[I,R]=Fo({prop:o,defaultProp:l,onChange:c,caller:uu}),H=y.useRef(null),V=w?b||!!w.closest("form"):!0,[K,q]=y.useState(new Set),$=Array.from(K).map(B=>B.props.value).join(";");return r.jsx(jm,{..._,children:r.jsxs(A_e,{required:g,scope:t,trigger:w,onTriggerChange:A,valueNode:S,onValueNodeChange:C,valueNodeHasChildren:E,onValueNodeHasChildrenChange:k,contentId:Zi(),value:I,onValueChange:R,open:F,onOpenChange:M,dir:T,triggerPointerDownPosRef:H,disabled:m,children:[r.jsx(Jv.Provider,{scope:t,children:r.jsx(S_e,{scope:e.__scopeSelect,onNativeOptionAdd:y.useCallback(B=>{q(Y=>new Set(Y).add(B))},[]),onNativeOptionRemove:y.useCallback(B=>{q(Y=>{const U=new Set(Y);return U.delete(B),U})},[]),children:n})}),V?r.jsxs(L7,{"aria-hidden":!0,required:g,tabIndex:-1,name:f,autoComplete:p,value:I,onChange:B=>R(B.target.value),disabled:m,form:b,children:[I===void 0?r.jsx("option",{value:""}):null,Array.from(K)]},$):null]})})};x7.displayName=uu;var g7="SelectTrigger",b7=y.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:s=!1,...i}=e,a=ey(n),o=rc(g7,n),l=o.disabled||s,c=At(t,o.onTriggerChange),d=Zv(n),f=y.useRef("touch"),[p,m,g]=z7(_=>{const w=d().filter(C=>!C.disabled),A=w.find(C=>C.value===o.value),S=$7(w,_,A);S!==void 0&&o.onValueChange(S.value)}),b=_=>{l||(o.onOpenChange(!0),g()),_&&(o.triggerPointerDownPosRef.current={x:Math.round(_.pageX),y:Math.round(_.pageY)})};return r.jsx(Nm,{asChild:!0,...a,children:r.jsx(lt.button,{type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":B7(o.value)?"":void 0,...i,ref:c,onClick:Oe(i.onClick,_=>{_.currentTarget.focus(),f.current!=="mouse"&&b(_)}),onPointerDown:Oe(i.onPointerDown,_=>{f.current=_.pointerType;const w=_.target;w.hasPointerCapture(_.pointerId)&&w.releasePointerCapture(_.pointerId),_.button===0&&_.ctrlKey===!1&&_.pointerType==="mouse"&&(b(_),_.preventDefault())}),onKeyDown:Oe(i.onKeyDown,_=>{const w=p.current!=="";!(_.ctrlKey||_.altKey||_.metaKey)&&_.key.length===1&&m(_.key),!(w&&_.key===" ")&&y_e.includes(_.key)&&(b(),_.preventDefault())})})})});b7.displayName=g7;var v7="SelectValue",y7=y.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:i,children:a,placeholder:o="",...l}=e,c=rc(v7,n),{onValueNodeHasChildrenChange:d}=c,f=a!==void 0,p=At(t,c.onValueNodeChange);return Ks(()=>{d(f)},[d,f]),r.jsx(lt.span,{...l,ref:p,style:{pointerEvents:"none"},children:B7(c.value)?r.jsx(r.Fragment,{children:o}):a})});y7.displayName=v7;var j_e="SelectIcon",_7=y.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,...i}=e;return r.jsx(lt.span,{"aria-hidden":!0,...i,ref:t,children:s||"▼"})});_7.displayName=j_e;var N_e="SelectPortal",w7=e=>r.jsx(hh,{asChild:!0,...e});w7.displayName=N_e;var du="SelectContent",A7=y.forwardRef((e,t)=>{const n=rc(du,e.__scopeSelect),[s,i]=y.useState();if(Ks(()=>{i(new DocumentFragment)},[]),!n.open){const a=s;return a?Xr.createPortal(r.jsx(S7,{scope:e.__scopeSelect,children:r.jsx(Jv.Slot,{scope:e.__scopeSelect,children:r.jsx("div",{children:e.children})})}),a):null}return r.jsx(C7,{...e,ref:t})});A7.displayName=du;var Kr=10,[S7,ac]=vh(du),k_e="SelectContentImpl",E_e=iu("SelectContent.RemoveScroll"),C7=y.forwardRef((e,t)=>{const{__scopeSelect:n,position:s="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:l,sideOffset:c,align:d,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:g,sticky:b,hideWhenDetached:_,avoidCollisions:w,...A}=e,S=rc(du,n),[C,E]=y.useState(null),[k,T]=y.useState(null),F=At(t,oe=>E(oe)),[M,I]=y.useState(null),[R,H]=y.useState(null),V=Zv(n),[K,q]=y.useState(!1),$=y.useRef(!1);y.useEffect(()=>{if(C)return Av(C)},[C]),_v();const B=y.useCallback(oe=>{const[se,...ae]=V().map(je=>je.ref.current),[le]=ae.slice(-1),ge=document.activeElement;for(const je of oe)if(je===ge||(je?.scrollIntoView({block:"nearest"}),je===se&&k&&(k.scrollTop=0),je===le&&k&&(k.scrollTop=k.scrollHeight),je?.focus(),document.activeElement!==ge))return},[V,k]),Y=y.useCallback(()=>B([M,C]),[B,M,C]);y.useEffect(()=>{K&&Y()},[K,Y]);const{onOpenChange:U,triggerPointerDownPosRef:W}=S;y.useEffect(()=>{if(C){let oe={x:0,y:0};const se=le=>{oe={x:Math.abs(Math.round(le.pageX)-(W.current?.x??0)),y:Math.abs(Math.round(le.pageY)-(W.current?.y??0))}},ae=le=>{oe.x<=10&&oe.y<=10?le.preventDefault():C.contains(le.target)||U(!1),document.removeEventListener("pointermove",se),W.current=null};return W.current!==null&&(document.addEventListener("pointermove",se),document.addEventListener("pointerup",ae,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",se),document.removeEventListener("pointerup",ae,{capture:!0})}}},[C,U,W]),y.useEffect(()=>{const oe=()=>U(!1);return window.addEventListener("blur",oe),window.addEventListener("resize",oe),()=>{window.removeEventListener("blur",oe),window.removeEventListener("resize",oe)}},[U]);const[O,D]=z7(oe=>{const se=V().filter(ge=>!ge.disabled),ae=se.find(ge=>ge.ref.current===document.activeElement),le=$7(se,oe,ae);le&&setTimeout(()=>le.ref.current.focus())}),Q=y.useCallback((oe,se,ae)=>{const le=!$.current&&!ae;(S.value!==void 0&&S.value===se||le)&&(I(oe),le&&($.current=!0))},[S.value]),z=y.useCallback(()=>C?.focus(),[C]),J=y.useCallback((oe,se,ae)=>{const le=!$.current&&!ae;(S.value!==void 0&&S.value===se||le)&&H(oe)},[S.value]),ee=s==="popper"?eC:j7,re=ee===eC?{side:l,sideOffset:c,align:d,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:g,sticky:b,hideWhenDetached:_,avoidCollisions:w}:{};return r.jsx(S7,{scope:n,content:C,viewport:k,onViewportChange:T,itemRefCallback:Q,selectedItem:M,onItemLeave:z,itemTextRefCallback:J,focusSelectedItem:Y,selectedItemText:R,position:s,isPositioned:K,searchRef:O,children:r.jsx(Sm,{as:E_e,allowPinchZoom:!0,children:r.jsx(Am,{asChild:!0,trapped:S.open,onMountAutoFocus:oe=>{oe.preventDefault()},onUnmountAutoFocus:Oe(i,oe=>{S.trigger?.focus({preventScroll:!0}),oe.preventDefault()}),children:r.jsx(dh,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:oe=>oe.preventDefault(),onDismiss:()=>S.onOpenChange(!1),children:r.jsx(ee,{role:"listbox",id:S.contentId,"data-state":S.open?"open":"closed",dir:S.dir,onContextMenu:oe=>oe.preventDefault(),...A,...re,onPlaced:()=>q(!0),ref:F,style:{display:"flex",flexDirection:"column",outline:"none",...A.style},onKeyDown:Oe(A.onKeyDown,oe=>{const se=oe.ctrlKey||oe.altKey||oe.metaKey;if(oe.key==="Tab"&&oe.preventDefault(),!se&&oe.key.length===1&&D(oe.key),["ArrowUp","ArrowDown","Home","End"].includes(oe.key)){let le=V().filter(ge=>!ge.disabled).map(ge=>ge.ref.current);if(["ArrowUp","End"].includes(oe.key)&&(le=le.slice().reverse()),["ArrowUp","ArrowDown"].includes(oe.key)){const ge=oe.target,je=le.indexOf(ge);le=le.slice(je+1)}setTimeout(()=>B(le)),oe.preventDefault()}})})})})})})});C7.displayName=k_e;var F_e="SelectItemAlignedPosition",j7=y.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:s,...i}=e,a=rc(du,n),o=ac(du,n),[l,c]=y.useState(null),[d,f]=y.useState(null),p=At(t,F=>f(F)),m=Zv(n),g=y.useRef(!1),b=y.useRef(!0),{viewport:_,selectedItem:w,selectedItemText:A,focusSelectedItem:S}=o,C=y.useCallback(()=>{if(a.trigger&&a.valueNode&&l&&d&&_&&w&&A){const F=a.trigger.getBoundingClientRect(),M=d.getBoundingClientRect(),I=a.valueNode.getBoundingClientRect(),R=A.getBoundingClientRect();if(a.dir!=="rtl"){const ge=R.left-M.left,je=I.left-ge,Ee=F.left-je,de=F.width+Ee,me=Math.max(de,M.width),$e=window.innerWidth-Kr,nt=dR(je,[Kr,Math.max(Kr,$e-me)]);l.style.minWidth=de+"px",l.style.left=nt+"px"}else{const ge=M.right-R.right,je=window.innerWidth-I.right-ge,Ee=window.innerWidth-F.right-je,de=F.width+Ee,me=Math.max(de,M.width),$e=window.innerWidth-Kr,nt=dR(je,[Kr,Math.max(Kr,$e-me)]);l.style.minWidth=de+"px",l.style.right=nt+"px"}const H=m(),V=window.innerHeight-Kr*2,K=_.scrollHeight,q=window.getComputedStyle(d),$=parseInt(q.borderTopWidth,10),B=parseInt(q.paddingTop,10),Y=parseInt(q.borderBottomWidth,10),U=parseInt(q.paddingBottom,10),W=$+B+K+U+Y,O=Math.min(w.offsetHeight*5,W),D=window.getComputedStyle(_),Q=parseInt(D.paddingTop,10),z=parseInt(D.paddingBottom,10),J=F.top+F.height/2-Kr,ee=V-J,re=w.offsetHeight/2,oe=w.offsetTop+re,se=$+B+oe,ae=W-se;if(se<=J){const ge=H.length>0&&w===H[H.length-1].ref.current;l.style.bottom="0px";const je=d.clientHeight-_.offsetTop-_.offsetHeight,Ee=Math.max(ee,re+(ge?z:0)+je+Y),de=se+Ee;l.style.height=de+"px"}else{const ge=H.length>0&&w===H[0].ref.current;l.style.top="0px";const Ee=Math.max(J,$+_.offsetTop+(ge?Q:0)+re)+ae;l.style.height=Ee+"px",_.scrollTop=se-J+_.offsetTop}l.style.margin=`${Kr}px 0`,l.style.minHeight=O+"px",l.style.maxHeight=V+"px",s?.(),requestAnimationFrame(()=>g.current=!0)}},[m,a.trigger,a.valueNode,l,d,_,w,A,a.dir,s]);Ks(()=>C(),[C]);const[E,k]=y.useState();Ks(()=>{d&&k(window.getComputedStyle(d).zIndex)},[d]);const T=y.useCallback(F=>{F&&b.current===!0&&(C(),S?.(),b.current=!1)},[C,S]);return r.jsx(M_e,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:g,onScrollButtonChange:T,children:r.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:r.jsx(lt.div,{...i,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});j7.displayName=F_e;var T_e="SelectPopperPosition",eC=y.forwardRef((e,t)=>{const{__scopeSelect:n,align:s="start",collisionPadding:i=Kr,...a}=e,o=ey(n);return r.jsx(Fv,{...o,...a,ref:t,align:s,collisionPadding:i,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)"}})});eC.displayName=T_e;var[M_e,Gj]=vh(du,{}),tC="SelectViewport",N7=y.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:s,...i}=e,a=ac(tC,n),o=Gj(tC,n),l=At(t,a.onViewportChange),c=y.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(Jv.Slot,{scope:n,children:r.jsx(lt.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:Oe(i.onScroll,d=>{const f=d.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:m}=o;if(m?.current&&p){const g=Math.abs(c.current-f.scrollTop);if(g>0){const b=window.innerHeight-Kr*2,_=parseFloat(p.style.minHeight),w=parseFloat(p.style.height),A=Math.max(_,w);if(A<b){const S=A+g,C=Math.min(b,S),E=S-C;p.style.height=C+"px",p.style.bottom==="0px"&&(f.scrollTop=E>0?E:0,p.style.justifyContent="flex-end")}}}c.current=f.scrollTop})})})]})});N7.displayName=tC;var k7="SelectGroup",[R_e,D_e]=vh(k7),E7=y.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,i=Zi();return r.jsx(R_e,{scope:n,id:i,children:r.jsx(lt.div,{role:"group","aria-labelledby":i,...s,ref:t})})});E7.displayName=k7;var F7="SelectLabel",T7=y.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,i=D_e(F7,n);return r.jsx(lt.div,{id:i.id,...s,ref:t})});T7.displayName=F7;var k0="SelectItem",[O_e,M7]=vh(k0),R7=y.forwardRef((e,t)=>{const{__scopeSelect:n,value:s,disabled:i=!1,textValue:a,...o}=e,l=rc(k0,n),c=ac(k0,n),d=l.value===s,[f,p]=y.useState(a??""),[m,g]=y.useState(!1),b=At(t,S=>c.itemRefCallback?.(S,s,i)),_=Zi(),w=y.useRef("touch"),A=()=>{i||(l.onValueChange(s),l.onOpenChange(!1))};if(s==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return r.jsx(O_e,{scope:n,value:s,disabled:i,textId:_,isSelected:d,onItemTextChange:y.useCallback(S=>{p(C=>C||(S?.textContent??"").trim())},[]),children:r.jsx(Jv.ItemSlot,{scope:n,value:s,disabled:i,textValue:f,children:r.jsx(lt.div,{role:"option","aria-labelledby":_,"data-highlighted":m?"":void 0,"aria-selected":d&&m,"data-state":d?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...o,ref:b,onFocus:Oe(o.onFocus,()=>g(!0)),onBlur:Oe(o.onBlur,()=>g(!1)),onClick:Oe(o.onClick,()=>{w.current!=="mouse"&&A()}),onPointerUp:Oe(o.onPointerUp,()=>{w.current==="mouse"&&A()}),onPointerDown:Oe(o.onPointerDown,S=>{w.current=S.pointerType}),onPointerMove:Oe(o.onPointerMove,S=>{w.current=S.pointerType,i?c.onItemLeave?.():w.current==="mouse"&&S.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Oe(o.onPointerLeave,S=>{S.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Oe(o.onKeyDown,S=>{c.searchRef?.current!==""&&S.key===" "||(__e.includes(S.key)&&A(),S.key===" "&&S.preventDefault())})})})})});R7.displayName=k0;var Jf="SelectItemText",D7=y.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:i,...a}=e,o=rc(Jf,n),l=ac(Jf,n),c=M7(Jf,n),d=C_e(Jf,n),[f,p]=y.useState(null),m=At(t,A=>p(A),c.onItemTextChange,A=>l.itemTextRefCallback?.(A,c.value,c.disabled)),g=f?.textContent,b=y.useMemo(()=>r.jsx("option",{value:c.value,disabled:c.disabled,children:g},c.value),[c.disabled,c.value,g]),{onNativeOptionAdd:_,onNativeOptionRemove:w}=d;return Ks(()=>(_(b),()=>w(b)),[_,w,b]),r.jsxs(r.Fragment,{children:[r.jsx(lt.span,{id:c.textId,...a,ref:m}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Xr.createPortal(a.children,o.valueNode):null]})});D7.displayName=Jf;var O7="SelectItemIndicator",P7=y.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return M7(O7,n).isSelected?r.jsx(lt.span,{"aria-hidden":!0,...s,ref:t}):null});P7.displayName=O7;var nC="SelectScrollUpButton",P_e=y.forwardRef((e,t)=>{const n=ac(nC,e.__scopeSelect),s=Gj(nC,e.__scopeSelect),[i,a]=y.useState(!1),o=At(t,s.onScrollButtonChange);return Ks(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=c.scrollTop>0;a(d)};const c=n.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),i?r.jsx(I7,{...e,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop-c.offsetHeight)}}):null});P_e.displayName=nC;var sC="SelectScrollDownButton",I_e=y.forwardRef((e,t)=>{const n=ac(sC,e.__scopeSelect),s=Gj(sC,e.__scopeSelect),[i,a]=y.useState(!1),o=At(t,s.onScrollButtonChange);return Ks(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=c.scrollHeight-c.clientHeight,f=Math.ceil(c.scrollTop)<d;a(f)};const c=n.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),i?r.jsx(I7,{...e,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop+c.offsetHeight)}}):null});I_e.displayName=sC;var I7=y.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:s,...i}=e,a=ac("SelectScrollButton",n),o=y.useRef(null),l=Zv(n),c=y.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return y.useEffect(()=>()=>c(),[c]),Ks(()=>{l().find(f=>f.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[l]),r.jsx(lt.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:Oe(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(s,50))}),onPointerMove:Oe(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(s,50))}),onPointerLeave:Oe(i.onPointerLeave,()=>{c()})})}),L_e="SelectSeparator",B_e=y.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return r.jsx(lt.div,{"aria-hidden":!0,...s,ref:t})});B_e.displayName=L_e;var iC="SelectArrow",z_e=y.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,i=ey(n),a=rc(iC,n),o=ac(iC,n);return a.open&&o.position==="popper"?r.jsx(Tv,{...i,...s,ref:t}):null});z_e.displayName=iC;var $_e="SelectBubbleInput",L7=y.forwardRef(({__scopeSelect:e,value:t,...n},s)=>{const i=y.useRef(null),a=At(s,i),o=m7(t);return y.useEffect(()=>{const l=i.current;if(!l)return;const c=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(c,"value").set;if(o!==t&&f){const p=new Event("change",{bubbles:!0});f.call(l,t),l.dispatchEvent(p)}},[o,t]),r.jsx(lt.select,{...n,style:{...G9,...n.style},ref:a,defaultValue:t})});L7.displayName=$_e;function B7(e){return e===""||e===void 0}function z7(e){const t=ia(e),n=y.useRef(""),s=y.useRef(0),i=y.useCallback(o=>{const l=n.current+o;t(l),(function c(d){n.current=d,window.clearTimeout(s.current),d!==""&&(s.current=window.setTimeout(()=>c(""),1e3))})(l)},[t]),a=y.useCallback(()=>{n.current="",window.clearTimeout(s.current)},[]);return y.useEffect(()=>()=>window.clearTimeout(s.current),[]),[n,i,a]}function $7(e,t,n){const i=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let o=V_e(e,Math.max(a,0));i.length===1&&(o=o.filter(d=>d!==n));const c=o.find(d=>d.textValue.toLowerCase().startsWith(i.toLowerCase()));return c!==n?c:void 0}function V_e(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var ss=x7,is=b7,Ds=y7,Yl=_7,rs=w7,as=A7,os=N7,Ro=E7,Do=T7,vn=R7,yn=D7,ui=P7;function bt({label:e,side:t="top",children:n}){return r.jsx(sj,{delayDuration:300,children:r.jsxs(iB,{children:[r.jsx(rB,{asChild:!0,children:n}),r.jsx(aB,{children:r.jsxs(oB,{side:t,sideOffset:6,className:"px-2 py-1 rounded-md bg-[#2A2A35] border border-[#3A3A48] text-[#F0F0F5] text-[11px] font-medium shadow-lg z-[9999] select-none",children:[e,r.jsx(lB,{className:"fill-[#2A2A35]"})]})})]})})}const Vp=[{label:"Local",tag:"local",models:[]},{label:"OpenRouter Free",tag:"free",provider:"openrouter",models:[{id:"openrouter/meta-llama/llama-3.3-70b-instruct:free",label:"Llama 3.3 70B"},{id:"openrouter/google/gemma-3-27b-it:free",label:"Gemma 3 27B"},{id:"openrouter/mistralai/mistral-7b-instruct:free",label:"Mistral 7B"}]},{label:"OpenRouter Paid",tag:"paid",provider:"openrouter",models:[{id:"openrouter/anthropic/claude-haiku-4.5",label:"Haiku 4.5"},{id:"openrouter/anthropic/claude-sonnet-4.6",label:"Sonnet 4.6"},{id:"openrouter/anthropic/claude-opus-4.7",label:"Opus 4.7"},{id:"openrouter/openai/gpt-5.4-mini",label:"GPT-5.4 mini"},{id:"openrouter/openai/gpt-5.4",label:"GPT-5.4"},{id:"openrouter/google/gemini-2.5-flash",label:"Gemini 2.5 Flash"},{id:"openrouter/google/gemini-2.5-pro",label:"Gemini 2.5 Pro"}]},{label:"Anthropic",tag:"paid",provider:"anthropic",models:[{id:"anthropic/claude-haiku-4.5",label:"Haiku 4.5"},{id:"anthropic/claude-sonnet-4.6",label:"Sonnet 4.6"},{id:"anthropic/claude-opus-4.7",label:"Opus 4.7"}]},{label:"OpenAI",tag:"paid",provider:"openai",models:[{id:"openai/gpt-5.4-nano",label:"GPT-5.4 nano"},{id:"openai/gpt-5.4-mini",label:"GPT-5.4 mini"},{id:"openai/gpt-5.4",label:"GPT-5.4"}]},{label:"Google",tag:"paid",provider:"google",models:[{id:"google/gemini-2.5-flash",label:"Gemini 2.5 Flash"},{id:"google/gemini-2.5-pro",label:"Gemini 2.5 Pro"}]}],jo={local:"text-[#10B981] bg-[#10B981]/10",free:"text-[#8B5CF6] bg-[#8B5CF6]/10",paid:"text-[#F59E0B] bg-[#F59E0B]/10",custom:"text-[#6366F1] bg-[#6366F1]/10"},U_e=["vllm/","ollama/","openrouter/","anthropic/","openai/","google/","claude-code/"];function E0(e){for(const t of U_e)if(e.startsWith(t))return e.slice(t.length);return e}function ta(e){if(!e)return"";for(const n of Vp){const s=n.models.find(i=>i.id===e);if(s)return s.label}const t=E0(e);for(const n of Vp){const s=n.models.find(i=>E0(i.id)===t);if(s)return s.label}return t}function Up(e){if(!e)return"custom";if(e.startsWith("vllm/")||e.startsWith("ollama/"))return"local";for(const n of Vp)if(n.models.some(s=>s.id===e))return n.tag;const t=E0(e);for(const n of Vp)if(n.models.some(s=>E0(s.id)===t))return n.tag;return e.startsWith("openrouter/")||e.startsWith("anthropic/")||e.startsWith("openai/")||e.startsWith("google/")||e.startsWith("claude-code/")?"paid":"custom"}function Vm(){const{data:e}=L.agents.discoverLocalModels.useQuery(void 0,{staleTime:6e4,refetchOnWindowFocus:!1}),{data:t}=L.onboarding.providersConfigured.useQuery(void 0,{staleTime:6e4,refetchOnWindowFocus:!1}),n=(e??[]).map(o=>({id:o.id,label:o.parameterSize?`${o.name} (${o.parameterSize})`:o.name})),s=Vp.map(o=>o.tag==="local"?{...o,models:n}:o).filter(o=>o.models.length===0?!1:!o.provider||t===void 0?!0:!!t[o.provider]),i=!!t&&(t.openrouter||t.anthropic||t.openai||t.google),a=t!==void 0&&!i;return{groups:s,needsHostedProviderSetup:a,needsOpenRouterSetup:a}}const H_e=8;function ty({value:e,onChange:t,onSubmit:n,placeholder:s="Add model ID...",className:i="",autoFocus:a=!1}){const{data:o}=L.agents.discoverLocalModels.useQuery(void 0,{staleTime:6e4,refetchOnWindowFocus:!1}),{data:l}=L.onboarding.discoverProviderModels.useQuery(void 0,{staleTime:6e4,refetchOnWindowFocus:!1}),c=y.useMemo(()=>{const w=(o??[]).map(S=>({id:S.id,label:S.parameterSize?`${S.name} (${S.parameterSize})`:S.name})),A=[...l?.openrouter??[],...l?.anthropic??[],...l?.openai??[],...l?.google??[]];return[...w,...A]},[o,l]),[d,f]=y.useState(!1),[p,m]=y.useState(0),g=y.useMemo(()=>{const w=e.trim().toLowerCase();return w?c.filter(A=>A.id.toLowerCase().includes(w)||A.label.toLowerCase().includes(w)).slice(0,H_e):[]},[e,c]);y.useEffect(()=>{m(0)},[e]);function b(w){if(w.stopPropagation(),w.key==="ArrowDown"){g.length>0&&(w.preventDefault(),f(!0),m(A=>Math.min(A+1,g.length-1)));return}if(w.key==="ArrowUp"){g.length>0&&(w.preventDefault(),f(!0),m(A=>Math.max(A-1,0)));return}if(w.key==="Tab"){if(d&&g[p]){w.preventDefault(),t(g[p].id);return}return}if(w.key==="Escape"){d&&(w.preventDefault(),f(!1));return}if(w.key==="Enter"){w.preventDefault();const A=d&&g[p]?g[p].id:e.trim();if(!A)return;n(A),f(!1)}}const _=y.useRef(null);return r.jsxs("div",{className:`relative ${i}`,children:[r.jsx("input",{ref:_,autoFocus:a,value:e,placeholder:s,onChange:w=>{t(w.target.value),f(!0)},onFocus:()=>{e&&f(!0)},onBlur:()=>{setTimeout(()=>f(!1),120)},onKeyDown:b,className:"w-full bg-[#13131A] border border-[#2A2A35] rounded px-2 py-1.5 text-[11px] text-[#C8C8D4] placeholder:text-[#5A5A6E] outline-none focus:border-[#6366F1] transition-colors"}),d&&g.length>0&&r.jsx("div",{className:"absolute left-0 right-0 top-full mt-1 bg-[#1C1C24] border border-[#2A2A35] rounded-lg shadow-xl py-1 z-[10000] max-h-[240px] overflow-y-auto",children:g.map((w,A)=>r.jsxs("button",{type:"button",onMouseDown:S=>{S.preventDefault(),n(w.id),f(!1)},onMouseEnter:()=>m(A),className:`block w-full text-left px-3 py-1.5 text-[11px] outline-none transition-colors ${A===p?"bg-white/10 text-[#F0F0F5]":"text-[#C8C8D4] hover:bg-white/5"}`,children:[r.jsx("div",{className:"truncate",children:w.id}),w.label!==w.id&&r.jsx("div",{className:"truncate text-[10px] text-[#5A5A6E]",children:w.label})]},w.id))})]})}const hR={sessionTokensIn:0,sessionTokensOut:0,sessionCostUsd:0,contextWindow:null},ny=$o(e=>({stats:{},setStats:(t,n)=>e(s=>({stats:{...s.stats,[t]:n}})),updateFromWs:(t,n)=>e(s=>({stats:{...s.stats,[t]:{...s.stats[t]??hR,...n}}})),clearStats:t=>e(n=>({stats:{...n.stats,[t]:hR}}))}));function bA(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function fR(e){return e<.005?"$0.00":e<1?`$${e.toFixed(2)}`:`$${e.toFixed(2)}`}const W_e=1e5;function q_e({channelId:e}){const t=L.useUtils(),{data:n}=L.channels.sessionStats.useQuery({channelId:e}),{stats:s,setStats:i,clearStats:a}=ny(),o=L.channels.resetSessionStats.useMutation({onSuccess:()=>{a(e),t.channels.sessionStats.invalidate({channelId:e})}});y.useEffect(()=>{n&&i(e,n)},[n,e,i]);const l=s[e];if(!l)return null;const c=l.sessionTokensIn+l.sessionTokensOut;if(c===0)return null;const d=l.contextWindow??W_e,f=l.sessionTokensIn/d,p=f>.8?"text-red-400":f>.5?"text-amber-400":"text-[#5A5A6E]";return r.jsxs(Ys,{children:[r.jsx(ci,{asChild:!0,children:r.jsxs("button",{className:`flex items-center gap-1 px-2 py-1 rounded-md text-[11px] font-medium transition-colors hover:bg-white/5 ${p}`,children:[r.jsx("span",{children:bA(c)}),r.jsx("span",{className:"opacity-50",children:"·"}),r.jsx("span",{children:fR(l.sessionCostUsd)})]})}),r.jsx(Qs,{children:r.jsxs(Xs,{align:"end",sideOffset:6,className:"bg-[#1C1C24] border border-[#2A2A35] rounded-lg shadow-xl w-[220px] z-50 p-3",children:[r.jsxs("div",{className:"space-y-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[11px] text-[#8A8A99]",children:"Input tokens"}),r.jsx("span",{className:"text-[12px] text-[#C8C8D4] font-medium",children:bA(l.sessionTokensIn)})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[11px] text-[#8A8A99]",children:"Output tokens"}),r.jsx("span",{className:"text-[12px] text-[#C8C8D4] font-medium",children:bA(l.sessionTokensOut)})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[11px] text-[#8A8A99]",children:"Total cost"}),r.jsx("span",{className:"text-[12px] text-[#C8C8D4] font-medium",children:fR(l.sessionCostUsd)})]}),r.jsxs("div",{className:"pt-1",children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("span",{className:"text-[11px] text-[#8A8A99]",children:"Context usage"}),r.jsxs("span",{className:"text-[11px] text-[#5A5A6E]",children:[Math.round(f*100),"%"]})]}),r.jsx("div",{className:"h-1.5 bg-[#2A2A35] rounded-full overflow-hidden",children:r.jsx("div",{className:`h-full rounded-full transition-all ${f>.8?"bg-red-400":f>.5?"bg-amber-400":"bg-[#6366F1]"}`,style:{width:`${Math.min(f*100,100)}%`}})})]}),r.jsx("button",{onClick:()=>o.mutate({channelId:e}),disabled:o.isPending,className:"w-full mt-1 px-2 py-1.5 rounded-md text-[11px] text-[#8A8A99] hover:text-[#C8C8D4] hover:bg-white/5 transition-colors border border-[#2A2A35]",children:o.isPending?"Resetting...":"Reset counters"})]}),r.jsx(oa,{className:"fill-[#2A2A35]"})]})})]})}const V7=$o()(gj(e=>({lastTab:{},setLast:(t,n)=>e(s=>({lastTab:{...s.lastTab,[t]:n}})),clearLast:t=>e(n=>{const s={...n.lastTab};return delete s[t],{lastTab:s}})}),{name:"damn-dev-last-active-tab"}));function pR(e,t){return e.tabName&&e.tabName.trim().length>0?e.tabName:t?"Main":`Tab ${e.tabOrder+1}`}function G_e({baseChannelId:e,activeTabId:t,agentColor:n}){const s=an(),i=L.useUtils(),{data:a=[]}=dfe(e),[o,l]=y.useState(null),[c,d]=y.useState(""),[f,p]=y.useState(null),m=y.useRef(null),g=y.useCallback(()=>{i.channels.get.invalidate({channelId:e}),i.channels.list.invalidate()},[i,e]),b=L.channels.createTab.useMutation({onSuccess:k=>{g(),s(`/channels/${k.id}`)}}),_=L.channels.renameTab.useMutation({onSuccess:g}),w=L.channels.deleteTab.useMutation({onSuccess:(k,T)=>{g(),p(null),T.channelId===t&&s(`/channels/${e}`)}});if(y.useEffect(()=>{o&&m.current&&(m.current.focus(),m.current.select())},[o]),e==="chan_coo")return null;const A=(k,T)=>{l(k),d(T)},S=()=>{if(!o)return;const k=c.trim(),T=a.find(F=>F.id===o);T&&k&&k!==pR(T,T.id===e)&&_.mutate({channelId:o,name:k}),l(null)},C=()=>{l(null),d("")},E=n??"#6366F1";return r.jsxs("div",{className:"flex items-center gap-1 px-3 h-9 border-t border-[#2A2A35] bg-[#0F0F11] overflow-x-auto scrollbar-none",children:[a.map(k=>{const T=k.id===t,F=k.id===e,M=k.unreadCount>0&&!T,I=o===k.id,R=pR(k,F),H=()=>{I||(T?A(k.id,R):(F&&V7.getState().clearLast(e),s(`/channels/${k.id}`)))};return r.jsx("div",{className:ye("group relative flex items-center gap-1.5 px-2.5 h-7 rounded-md text-[12px] transition-colors select-none flex-shrink-0",T?"bg-[#1A1A22] text-[#F0F0F5]":"text-[#8A8A99] hover:bg-[#15151B] hover:text-[#C0C0CC] cursor-pointer",T&&!I&&"cursor-text"),style:T?{boxShadow:`inset 0 -2px 0 ${E}`}:void 0,onClick:H,onDoubleClick:V=>{V.stopPropagation(),I||A(k.id,R)},children:I?r.jsx("input",{ref:m,value:c,onChange:V=>d(V.target.value),onBlur:S,onKeyDown:V=>{V.key==="Enter"?S():V.key==="Escape"&&C()},onClick:V=>V.stopPropagation(),onDoubleClick:V=>V.stopPropagation(),maxLength:80,className:"bg-transparent outline-none text-[12px] text-[#F0F0F5] w-[120px]"}):r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"truncate max-w-[140px]",title:R,children:R}),M&&r.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:E}}),!F&&r.jsxs(Ys,{open:f===k.id,onOpenChange:V=>p(V?k.id:null),children:[r.jsx(ci,{asChild:!0,children:r.jsx("button",{onClick:V=>{V.stopPropagation(),p(k.id)},className:ye("transition-opacity text-[#6A6A78] hover:text-[#F0F0F5] ml-0.5",T||f===k.id?"opacity-100":"opacity-0 group-hover:opacity-100"),"aria-label":"Close tab",children:r.jsx(Te,{className:"w-3 h-3"})})}),r.jsx(Qs,{children:r.jsxs(Xs,{className:"bg-[#15151B] border border-[#2A2A35] rounded-lg shadow-xl p-3 w-[220px] z-50",sideOffset:8,onOpenAutoFocus:V=>V.preventDefault(),children:[r.jsx("p",{className:"text-[12px] text-[#F0F0F5] font-medium mb-1",children:"Delete this tab?"}),r.jsxs("p",{className:"text-[11px] text-[#8A8A99] mb-3 leading-snug",children:["All messages in “",R,"” will be permanently removed."]}),r.jsxs("div",{className:"flex gap-2 justify-end",children:[r.jsx("button",{onClick:V=>{V.stopPropagation(),p(null)},className:"px-2.5 h-6 rounded text-[11px] text-[#8A8A99] hover:bg-[#1A1A22] hover:text-[#F0F0F5] transition-colors",children:"Cancel"}),r.jsx("button",{onClick:V=>{V.stopPropagation(),w.mutate({channelId:k.id})},disabled:w.isPending,className:"px-2.5 h-6 rounded text-[11px] bg-red-500/10 text-red-400 hover:bg-red-500/20 transition-colors disabled:opacity-50",children:"Delete"})]}),r.jsx(oa,{className:"fill-[#2A2A35]"})]})})]})]})},k.id)}),r.jsx("button",{onClick:()=>b.mutate({parentChannelId:e}),disabled:b.isPending,className:"flex items-center justify-center w-6 h-6 rounded-md text-[#6A6A78] hover:bg-[#15151B] hover:text-[#F0F0F5] transition-colors flex-shrink-0 disabled:opacity-50","aria-label":"New tab",children:r.jsx(wt,{className:"w-3.5 h-3.5"})})]})}function K_e(e){const t=Date.now()-e.getTime(),n=Math.floor(t/6e4);if(n<1)return"Last seen just now";if(n<60)return`Last seen ${n}m ago`;const s=Math.floor(n/60);return s<24?`Last seen ${s}h ago`:`Last seen ${Math.floor(s/24)}d ago`}function Y_e({userId:e}){const t=Sfe(e);return t?r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"relative flex items-center justify-center w-2 h-2",children:r.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:t.online?"#10B981":"#3A3A45"}})}),r.jsx("span",{className:"text-[12px] text-[#8A8A99]",children:t.online?"Online":t.lastSeenAt?K_e(new Date(t.lastSeenAt)):"Offline"})]}):null}function Q_e({channelId:e,agentId:t,defaultModel:n,agentColor:s,customModels:i=[]}){const[a,o]=y.useState(""),{data:l}=L.agents.getConversationModel.useQuery({channelId:e}),c=L.agents.setConversationModel.useMutation(),d=L.agents.update.useMutation(),f=L.agents.addCustomModel.useMutation(),p=L.useUtils(),{groups:m,needsHostedProviderSetup:g}=Vm(),b=l?.model??null,_=b!==null,w=b??n,A=Up(w);function S(C){C==="__reset__"?c.mutate({channelId:e,model:null},{onSuccess:()=>p.agents.getConversationModel.invalidate({channelId:e})}):(c.mutate({channelId:e,model:C},{onSuccess:()=>p.agents.getConversationModel.invalidate({channelId:e})}),d.mutate({agentId:t,model:C},{onSuccess:()=>p.agents.list.invalidate()}))}return r.jsxs(ss,{value:w,onValueChange:S,children:[r.jsxs(is,{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[12px] border transition-colors outline-none border-opacity-40",style:{color:s,backgroundColor:`${s}15`,borderColor:`${s}40`},children:[r.jsx("span",{className:`text-[10px] px-1 py-0.5 rounded font-medium ${jo[A]}`,children:A}),r.jsx(Ds,{children:ta(w)}),r.jsx(ft,{className:"w-3 h-3 opacity-60"})]}),r.jsx(rs,{children:r.jsxs(as,{position:"popper",sideOffset:6,align:"end",className:"bg-[#1C1C24] border border-[#2A2A35] rounded-lg shadow-xl py-1 min-w-[200px] z-50",children:[r.jsx("div",{className:"px-2 pb-1 mb-1 border-b border-[#2A2A35]",children:r.jsx(ty,{value:a,onChange:o,onSubmit:C=>{f.mutate({agentId:t,modelId:C},{onSuccess:()=>p.agents.list.invalidate()}),S(C),o("")}})}),r.jsxs(os,{children:[m.map(C=>r.jsxs(Ro,{children:[r.jsxs(Do,{className:"px-3 pt-2 pb-1 text-[10px] font-semibold text-[#5A5A6E] uppercase tracking-widest flex items-center gap-1.5",children:[r.jsx("span",{children:C.label}),r.jsx("span",{className:`px-1 py-0.5 rounded text-[9px] font-medium ${jo[C.tag]}`,children:C.tag})]}),C.models.map(E=>r.jsxs(vn,{value:E.id,className:"flex items-center justify-between px-3 py-1.5 text-[12px] text-[#C8C8D4] cursor-pointer hover:bg-white/5 outline-none data-[highlighted]:bg-white/5",children:[r.jsx(yn,{children:E.label}),r.jsx(ui,{children:r.jsx(Fe,{className:"w-3 h-3 text-[#6366F1]"})})]},E.id))]},C.label)),i.length>0&&r.jsxs(Ro,{children:[r.jsxs(Do,{className:"px-3 pt-2 pb-1 text-[10px] font-semibold text-[#5A5A6E] uppercase tracking-widest flex items-center gap-1.5",children:[r.jsx("span",{children:"Custom"}),r.jsx("span",{className:`px-1 py-0.5 rounded text-[9px] font-medium ${jo.custom}`,children:"custom"})]}),i.map(C=>r.jsxs(vn,{value:C,className:"flex items-center justify-between px-3 py-1.5 text-[12px] text-[#C8C8D4] cursor-pointer hover:bg-white/5 outline-none data-[highlighted]:bg-white/5",children:[r.jsx(yn,{children:C}),r.jsx(ui,{children:r.jsx(Fe,{className:"w-3 h-3 text-[#6366F1]"})})]},C))]}),_&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"my-1 border-t border-[#2A2A35]"}),r.jsx(vn,{value:"__reset__",className:"flex items-center px-3 py-1.5 text-[12px] text-[#8A8A99] cursor-pointer hover:bg-white/5 outline-none data-[highlighted]:bg-white/5",children:r.jsx(yn,{children:"Reset to default"})})]})]}),g&&r.jsx(gn,{to:"/settings?tab=runtime",className:"block px-3 py-1.5 text-[11px] text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/5 border-t border-[#2A2A35] mt-1 transition-colors",children:"+ Configure providers →"})]})})]})}function X_e({color:e}){return r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsxs("span",{className:"relative flex items-center justify-center w-2 h-2",children:[r.jsx(ne.span,{className:"absolute inset-0 rounded-full",style:{backgroundColor:e,opacity:.5},animate:{scale:[1,2.2,1],opacity:[.5,0,.5]},transition:{duration:1.4,repeat:1/0}}),r.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:e}})]}),r.jsx("span",{className:"text-[12px]",style:{color:e},children:"Waiting for your approval"})]})}function J_e({status:e,color:t}){const n={thinking:"thinking",executing:"executing",idle:"idle",offline:"offline"},s=e==="thinking"||e==="executing";return r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsxs("span",{className:"relative flex items-center justify-center w-2 h-2",children:[s&&r.jsx(ne.span,{className:"absolute inset-0 rounded-full",style:{backgroundColor:t,opacity:.5},animate:{scale:[1,2,1],opacity:[.5,0,.5]},transition:{duration:1.8,repeat:1/0}}),r.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:e==="offline"?"#3A3A45":t,opacity:e==="idle"?.5:1}})]}),r.jsx("span",{className:"text-[12px] text-[#8A8A99] capitalize",children:n[e]})]})}function Z_e({channelId:e,color:t}){const[n,s]=y.useState(!1),i=L.useUtils(),a=L.messages.resetSession.useMutation({onSuccess:()=>{s(!0),setTimeout(()=>s(!1),2e3),ny.getState().clearStats(e),i.channels.sessionStats.invalidate({channelId:e})}});return r.jsx(bt,{label:"Reset context",children:r.jsx("button",{onClick:()=>a.mutate({channelId:e}),className:"w-8 h-8 flex items-center justify-center rounded-md text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/5 transition-colors",style:n?{color:t}:{},children:r.jsx(lh,{className:ye("w-4 h-4",a.isPending&&"animate-spin")})})})}function ewe({channelId:e,onCleared:t}){const[n,s]=y.useState(!1),i=L.useUtils(),a=L.messages.clearConversation.useMutation({onSuccess:()=>{s(!1),t?.(),ny.getState().clearStats(e),i.channels.sessionStats.invalidate({channelId:e})}});return n?r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{onClick:()=>a.mutate({channelId:e}),disabled:a.isPending,className:"px-2 py-1 rounded-md text-[11px] font-medium text-[#EF4444] bg-[#EF4444]/10 hover:bg-[#EF4444]/20 transition-colors",children:a.isPending?"Clearing...":"Confirm"}),r.jsx("button",{onClick:()=>s(!1),className:"px-2 py-1 rounded-md text-[11px] text-[#8A8A99] hover:bg-white/5 transition-colors",children:"Cancel"})]}):r.jsx(bt,{label:"Clear conversation",children:r.jsx("button",{onClick:()=>s(!0),className:"w-8 h-8 flex items-center justify-center rounded-md text-[#8A8A99] hover:text-[#EF4444] hover:bg-[#EF4444]/10 transition-colors",children:r.jsx(Dn,{className:"w-4 h-4"})})})}function twe({channelId:e,color:t,onJump:n}){const{data:s=[]}=L.messages.pinned.useQuery({channelId:e});return s.length===0?null:r.jsxs(Yv,{children:[r.jsx(Qv,{asChild:!0,children:r.jsxs("button",{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/10 transition-colors border border-transparent hover:border-[#2A2A35]",children:[r.jsx(P5,{className:"w-3.5 h-3.5",style:{color:t}}),r.jsxs("span",{children:[s.length," pinned"]})]})}),r.jsx(Od,{children:r.jsxs(Xv,{align:"end",sideOffset:6,className:"bg-[#1C1C24] border border-[#2A2A35] rounded-lg shadow-xl py-1 w-[300px] z-50",children:[r.jsx("div",{className:"px-3 py-2 border-b border-[#2A2A35]",children:r.jsx("span",{className:"text-[11px] font-semibold text-[#8A8A99] uppercase tracking-widest",children:"Pinned Messages"})}),s.map(i=>r.jsxs(Bl,{onSelect:()=>n(i.id),className:"flex flex-col gap-0.5 px-3 py-2.5 cursor-pointer hover:bg-white/5 outline-none transition-colors",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsx("span",{className:"text-[12px] font-medium text-[#C8C8D4] truncate",children:i.sender.name}),r.jsx("span",{className:"text-[11px] text-[#8A8A99] shrink-0",children:Ir(i.timestamp)})]}),r.jsx("p",{className:"text-[12px] text-[#8A8A99] truncate",children:i.content}),r.jsx("span",{className:"text-[11px] text-[#6366F1] mt-0.5",children:"Jump to message"})]},i.id))]})})]})}function nwe({channelId:e}){const t=L.useUtils(),{data:n}=L.channelPreferences.get.useQuery({channelId:e}),s=n?.muted??!1,i=L.channelPreferences.set.useMutation({onMutate:async({muted:a})=>{await t.channelPreferences.get.cancel({channelId:e});const o=t.channelPreferences.get.getData({channelId:e});return t.channelPreferences.get.setData({channelId:e},l=>({...l,channelId:e,muted:a??!1,notifyOnMention:l?.notifyOnMention??!0})),{prev:o}},onError:(a,o,l)=>{l?.prev&&t.channelPreferences.get.setData({channelId:e},l.prev)},onSettled:()=>{t.channelPreferences.get.invalidate({channelId:e}),t.channelPreferences.listMuted.invalidate()}});return r.jsx(bt,{label:s?"Unmute channel":"Mute channel",children:r.jsx("button",{onClick:()=>i.mutate({channelId:e,muted:!s}),className:ye("w-8 h-8 flex items-center justify-center rounded-md transition-colors",s?"text-[#F59E0B] hover:bg-[#F59E0B]/10":"text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/5"),children:s?r.jsx(tL,{className:"w-4 h-4"}):r.jsx(Ase,{className:"w-4 h-4"})})})}function swe({channel:e,agent:t,agentColor:n,hasPendingApproval:s=!1,rightPanelOpen:i,memoryPanelOpen:a,activeOverride:o,humanDmName:l,humanDmUserId:c,onToggleRightPanel:d,onToggleMemoryPanel:f,onAgentClick:p,onClearOverride:m,onClearConversation:g,onJumpToMessage:b}){const _=n??t?.color??"#6366F1",w=!!t&&e.channelType==="dm",A=e.channelType==="dm"&&!e.agentId,S=e.channelType==="topic",C=e.channelType==="group"||e.channelType==="topic",E=Uo(),k=L.channels.setResponseMode.useMutation(),T=L.useUtils();return r.jsxs("div",{className:"flex flex-col border-b border-[#2A2A35] bg-[#0F0F11] flex-shrink-0",style:w&&!S?{borderLeftColor:_,borderLeftWidth:3,borderLeftStyle:"solid"}:{},children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-3",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[A?r.jsx("div",{className:"w-8 h-8 rounded-full bg-gradient-to-br from-[#6366F1] to-[#8B5CF6] flex items-center justify-center text-[11px] font-semibold text-white flex-shrink-0",children:(l??"U").split(" ").map(F=>F[0]).join("").slice(0,2).toUpperCase()}):t&&!S?r.jsx("button",{onClick:p,className:"w-8 h-8 rounded-full flex items-center justify-center text-lg flex-shrink-0 transition-opacity hover:opacity-80",style:{backgroundColor:`${_}26`},children:t.emoji}):r.jsx("div",{className:"w-8 h-8 rounded-full bg-[#2A2A35] flex items-center justify-center",children:r.jsx("span",{className:"text-[#8A8A99] text-sm",children:"#"})}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2",children:[A?r.jsx("h2",{className:"text-[15px] font-semibold text-[#F0F0F5]",children:l??"User"}):t&&!S?r.jsx("button",{onClick:p,className:"text-[15px] font-semibold text-[#F0F0F5] hover:underline decoration-dashed underline-offset-2 transition-colors",children:t.name}):r.jsxs("h2",{className:"text-[15px] font-semibold text-[#F0F0F5]",children:["#",e.name]}),t&&!S&&r.jsx("span",{className:"text-[11px] text-[#8A8A99] bg-white/5 px-1.5 py-0.5 rounded",children:t.role}),S&&r.jsxs("span",{className:"text-[11px] text-[#8A8A99] bg-white/5 px-1.5 py-0.5 rounded border border-[#2A2A35] flex items-center gap-1",children:[e.visibility==="public"?r.jsx(Xt,{className:"w-3 h-3"}):r.jsx(Eo,{className:"w-3 h-3"}),"Topic"]})]}),t&&!S&&!s&&r.jsx(J_e,{status:t.status,color:_}),t&&!S&&s&&r.jsx(X_e,{color:_}),S&&e.description&&r.jsx("p",{className:"text-[12px] text-[#8A8A99]",children:e.description}),A&&r.jsx(Y_e,{userId:c}),!t&&!S&&!A&&r.jsxs("p",{className:"text-[12px] text-[#8A8A99]",children:["#",e.name]})]})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[E&&t&&!S&&r.jsx(Q_e,{channelId:e.id,agentId:t.id,defaultModel:t.defaultModel,agentColor:_,customModels:(()=>{try{return t.customModels?JSON.parse(t.customModels):[]}catch{return[]}})()}),w&&!S&&r.jsx(q_e,{channelId:e.id}),w&&!S&&r.jsx(Z_e,{channelId:e.id,color:_}),w&&!S&&r.jsx(ewe,{channelId:e.id,onCleared:g}),S&&r.jsx(S$,{channel:e}),C&&r.jsx(bt,{label:e.responseMode==="mention"?"Agents respond only when @mentioned":"Agents respond to every message",children:r.jsxs("button",{onClick:()=>{const F=e.responseMode==="always"?"mention":"always";k.mutate({channelId:e.id,responseMode:F},{onSuccess:()=>T.channels.list.invalidate()})},className:ye("flex items-center gap-1 px-2 py-1 rounded-md text-[12px] border transition-colors",e.responseMode==="mention"?"text-[#A78BFA] bg-[#8B5CF6]/10 border-[#8B5CF6]/30":"text-[#8A8A99] border-transparent hover:border-[#2A2A35] hover:bg-white/5"),children:[e.responseMode==="mention"?r.jsx(eL,{className:"w-3.5 h-3.5"}):r.jsx(pL,{className:"w-3.5 h-3.5"}),r.jsx("span",{children:e.responseMode==="mention"?"mention":"auto"})]})}),r.jsx(nwe,{channelId:e.id}),r.jsx(twe,{channelId:e.id,color:S?"#8A8A99":_,onJump:b??(F=>{document.getElementById(`msg-${F}`)?.scrollIntoView({behavior:"smooth",block:"center"})})}),t&&!S&&r.jsx(bt,{label:a?"Close memory":"View memory",children:r.jsx("button",{onClick:f,className:ye("w-8 h-8 flex items-center justify-center rounded-md transition-colors",a?"text-[#F0F0F5] bg-white/10":"text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/5"),children:r.jsx(Cse,{className:"w-4 h-4"})})}),r.jsx(bt,{label:i?"Close panel":"Open panel",children:r.jsx("button",{onClick:d,className:ye("w-8 h-8 flex items-center justify-center rounded-md transition-colors",i?"text-[#F0F0F5] bg-white/10":"text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/5"),children:i?r.jsx(mL,{className:"w-4 h-4"}):r.jsx(xL,{className:"w-4 h-4"})})})]})]}),o&&r.jsxs(ne.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.25},className:"flex items-center justify-between px-5 py-2 bg-amber-500/10 border-t border-amber-500/20",children:[r.jsxs("p",{className:"text-[12px] text-amber-400 truncate",children:[r.jsx("span",{className:"font-medium",children:"Override active:"})," ",o.length>60?`${o.slice(0,60)}...`:o]}),r.jsx("button",{onClick:m,className:"ml-3 flex-shrink-0 w-5 h-5 flex items-center justify-center rounded text-amber-400/70 hover:text-amber-300 hover:bg-amber-500/10 transition-colors",children:r.jsx(Te,{className:"w-3.5 h-3.5"})})]}),e.channelType!=="terminal"&&e.id!=="chan_coo"&&r.jsx(G_e,{baseChannelId:e.parentChannelId??e.id,activeTabId:e.id,agentColor:_})]})}function U7({agent:e}){return r.jsxs("div",{className:"flex items-start gap-3 px-4 py-2.5",children:[r.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-base flex-shrink-0 mt-0.5",style:{backgroundColor:`${e.color}26`},children:e.emoji}),r.jsxs("div",{className:"flex flex-col gap-1 pt-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:e.color},children:e.name}),r.jsx("span",{className:"text-[11px] text-[#8A8A99]",children:e.status==="thinking"?"thinking...":"executing..."})]}),r.jsx("div",{className:"flex items-center gap-1 px-3 py-2 rounded-lg rounded-tl-sm",style:{backgroundColor:`${e.color}0D`,border:`1px solid ${e.color}26`},children:[0,1,2].map(t=>r.jsx(ne.span,{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:e.color},animate:{opacity:[.3,1,.3],scale:[.8,1.1,.8]},transition:{duration:1.4,repeat:1/0,delay:t*.2,ease:"easeInOut"}},t))})]})]})}function iwe(e){return new Promise((t,n)=>{const s=new FileReader;s.onload=()=>t(s.result.split(",")[1]),s.onerror=n,s.readAsDataURL(e)})}function rwe({staged:e,onRemove:t}){const n=e.file.type.startsWith("image/"),s=Math.round(e.file.size/1024);return r.jsxs(ne.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.85},transition:{duration:.15},className:"relative group/card flex-shrink-0",children:[r.jsx("button",{onClick:t,className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-[#2A2A35] border border-[#3A3A45] rounded-full flex items-center justify-center text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-[#EF4444]/20 transition-colors z-10 opacity-0 group-hover/card:opacity-100",children:r.jsx(Te,{className:"w-2.5 h-2.5"})}),n&&e.preview?r.jsx("div",{className:"w-[60px] h-[60px] rounded-lg overflow-hidden border border-[#2A2A35]",children:r.jsx("img",{src:e.preview,alt:e.file.name,className:"w-full h-full object-cover"})}):r.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-2 bg-[#1C1C24] border border-[#2A2A35] rounded-lg max-w-[160px]",children:[r.jsx("div",{className:"w-6 h-6 rounded bg-[#2A2A35] flex items-center justify-center flex-shrink-0",children:r.jsx("span",{className:"text-[9px] font-semibold text-[#8A8A99] uppercase",children:e.file.name.split(".").pop()?.slice(0,3)??"file"})}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-[11px] text-[#C8C8D4] font-medium truncate",children:e.file.name}),r.jsxs("div",{className:"text-[10px] text-[#8A8A99]",children:[s,"KB"]})]})]}),e.uploadedId===void 0&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center rounded-lg bg-black/40",children:r.jsx("div",{className:"w-3 h-3 border-2 border-white/30 border-t-white rounded-full animate-spin"})})]})}function H7({channelId:e,channelName:t,agent:n,agentColor:s,onSend:i,disabled:a,placeholder:o,mentionableParticipants:l=[]}){const[c,d]=y.useState(""),[f,p]=y.useState(!1),[m,g]=y.useState([]),[b,_]=y.useState(!1),[w,A]=y.useState(null),[S,C]=y.useState(0),[E,k]=y.useState(-1),[T,F]=y.useState(!1),M=y.useRef(null),I=y.useRef(null),R=s??n?.color,H=!!n&&(n.status==="thinking"||n.status==="executing"),V=Uo(),K=L.agents.cancelThinking.useMutation(),q=L.attachments.upload.useMutation(),$=y.useMemo(()=>{if(w===null||l.length===0)return[];const se=w.toLowerCase();return l.filter(ae=>ae.name.toLowerCase().startsWith(se))},[w,l]);y.useEffect(()=>{const se=w!==null&&$.length>0;F(se),se&&C(0)},[w,$.length]);function B(se,ae){if(l.length===0){A(null);return}const le=se.slice(0,ae),ge=le.lastIndexOf("@");if(ge===-1||ge>0&&le[ge-1]!==" "&&le[ge-1]!==`
|
|
132
132
|
`){A(null),k(-1);return}const je=le.slice(ge+1);if(je.includes(" ")&&!l.some(Ee=>Ee.name.toLowerCase().startsWith(je.toLowerCase()))){A(null),k(-1);return}A(je),k(ge)}function Y(se){if(E===-1)return;const ae=c.slice(0,E),le=M.current?.selectionStart??c.length,ge=c.slice(le),je=`${ae}@${se} ${ge}`;d(je),A(null),k(-1),requestAnimationFrame(()=>{const Ee=ae.length+se.length+2;M.current?.setSelectionRange(Ee,Ee),M.current?.focus()})}const U=y.useCallback(async se=>{for(const ae of se){const le=`${Date.now()}-${Math.random()}`,ge=ae.type.startsWith("image/")?URL.createObjectURL(ae):void 0;g(je=>[...je,{file:ae,preview:ge,id:le,uploadedId:void 0}]);try{const je=await iwe(ae),Ee=await q.mutateAsync({filename:ae.name,mimeType:ae.type,dataBase64:je});g(de=>de.map(me=>me.id===le?{...me,uploadedId:Ee.id}:me))}catch{g(je=>je.filter(Ee=>Ee.id!==le))}}},[q]);y.useEffect(()=>{function se(ae){if(!document.activeElement?.closest("[data-message-input]"))return;const le=Array.from(ae.clipboardData?.files??[]);le.length>0&&(ae.preventDefault(),U(le))}return window.addEventListener("paste",se),()=>window.removeEventListener("paste",se)},[U]);function W(se){se.preventDefault(),_(!0)}function O(se){se.currentTarget.contains(se.relatedTarget)||_(!1)}function D(se){se.preventDefault(),_(!1);const ae=Array.from(se.dataTransfer.files);ae.length>0&&U(ae)}function Q(se){if(T&&$.length>0){if(se.key==="ArrowDown"){se.preventDefault(),C(ae=>(ae+1)%$.length);return}if(se.key==="ArrowUp"){se.preventDefault(),C(ae=>(ae-1+$.length)%$.length);return}if(se.key==="Enter"||se.key==="Tab"){se.preventDefault();const ae=$[S];ae&&Y(ae.name);return}if(se.key==="Escape"){se.preventDefault(),F(!1);return}}se.key==="Enter"&&!se.shiftKey&&(se.preventDefault(),J())}function z(se){const ae=se.target.value;d(ae),B(ae,se.target.selectionStart??ae.length)}function J(){const se=c.trim(),ae=m.filter(ge=>ge.uploadedId!==void 0).map(ge=>ge.uploadedId);!se&&ae.length===0||a||m.some(ge=>ge.uploadedId===void 0)||(i?.(se||".",ae.length>0?ae:void 0),d(""),g([]),A(null),k(-1),F(!1),M.current&&(M.current.style.height="auto"))}const ee=o??(n?`Message ${n.name}... (/ for commands)`:`Message #${t}... (/ for commands)`),re=m.some(se=>se.uploadedId===void 0),oe=(c.trim()||m.length>0)&&!a&&!re&&!H;return r.jsxs("div",{className:"px-4 pb-4 pt-2 flex-shrink-0 relative","data-message-input":!0,onDragOver:W,onDragLeave:O,onDrop:D,children:[r.jsx(Me,{children:b&&r.jsx(ne.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"absolute inset-0 z-20 mx-4 mb-4 mt-2 rounded-xl flex items-center justify-center border-2 border-dashed",style:{backgroundColor:`${R??"#6366F1"}10`,borderColor:R??"#6366F1"},children:r.jsx("p",{className:"text-[14px] font-medium",style:{color:R??"#6366F1"},children:"Drop to attach"})})}),m.length>0&&r.jsx("div",{className:"flex items-center gap-2 mb-2 flex-wrap",children:r.jsx(Me,{children:m.map(se=>r.jsx(rwe,{staged:se,onRemove:()=>{se.preview&&URL.revokeObjectURL(se.preview),g(ae=>ae.filter(le=>le.id!==se.id))}},se.id))})}),r.jsxs("div",{className:"relative",children:[r.jsx(Me,{children:T&&r.jsx(ne.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:{duration:.12},className:"absolute bottom-full mb-1 left-0 w-[220px] bg-[#1C1C24] border border-[#2A2A35] rounded-lg shadow-xl py-1 z-30 max-h-[180px] overflow-y-auto",children:$.map((se,ae)=>r.jsxs("button",{onMouseDown:le=>{le.preventDefault(),Y(se.name)},className:ye("flex items-center gap-2 w-full px-3 py-1.5 text-left transition-colors",ae===S?"bg-white/8":"hover:bg-white/5"),children:[se.type==="human"?r.jsx("span",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[10px] font-semibold flex-shrink-0 bg-gradient-to-br from-[#4A4A5E] to-[#2A2A3E] text-[#A5A5C5] border border-[#3A3A4E]",children:se.name[0]}):r.jsx("span",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[11px] flex-shrink-0",style:{backgroundColor:`${se.color}26`},children:se.emoji}),r.jsx("span",{className:"text-[13px] text-[#F0F0F5] truncate",children:se.name})]},se.id))})}),r.jsxs("div",{className:"flex items-end gap-2 bg-[#1C1C21] border rounded-xl px-3 py-2.5 transition-colors duration-150",style:{borderColor:f&&R?`${R}60`:"#2A2A35",boxShadow:f&&R?`0 0 0 1px ${R}30`:void 0},children:[r.jsx(bt,{label:"Commands",children:r.jsx("button",{className:"text-[#8A8A99] hover:text-[#F0F0F5] transition-colors mb-0.5 flex-shrink-0",onClick:()=>{},children:r.jsx(Nre,{className:"w-4 h-4"})})}),r.jsx("textarea",{ref:M,value:c,onChange:z,onKeyDown:Q,onFocus:()=>p(!0),onBlur:()=>p(!1),placeholder:ee,disabled:a||H,rows:1,className:"flex-1 bg-transparent text-[14px] text-[#F0F0F5] placeholder:text-[#8A8A99]/60 resize-none outline-none leading-relaxed max-h-[120px] overflow-y-auto disabled:opacity-50",style:{minHeight:"22px"},onInput:se=>{const ae=se.currentTarget;ae.style.height="auto",ae.style.height=`${Math.min(ae.scrollHeight,120)}px`}}),r.jsx("input",{ref:I,type:"file",multiple:!0,accept:"image/*,video/*,audio/*,.pdf,.doc,.docx,.xls,.xlsx,.txt,.csv,.zip,.json",tabIndex:-1,style:{position:"absolute",width:1,height:1,opacity:0,pointerEvents:"none",overflow:"hidden"},onChange:se=>{const ae=Array.from(se.target.files??[]);ae.length>0&&U(ae),se.target.value=""}}),r.jsx(bt,{label:"Attach file",children:r.jsx("button",{type:"button",onClick:()=>I.current?.click(),className:ye("transition-colors mb-0.5 flex-shrink-0",m.length>0?"text-[#6366F1]":"text-[#8A8A99] hover:text-[#F0F0F5]"),children:r.jsx(sre,{className:"w-4 h-4"})})}),V&&H?r.jsx(bt,{label:"Stop",children:r.jsx("button",{onClick:()=>n&&K.mutate({agentId:n.id,channelId:e}),className:"transition-colors mb-0.5 flex-shrink-0 text-[#F0F0F5] hover:text-[#EF4444]",children:r.jsx(L5,{className:"w-4 h-4 fill-current"})})}):r.jsx("button",{onClick:J,disabled:!oe,className:"text-[#8A8A99] hover:text-[#F0F0F5] disabled:opacity-30 transition-colors mb-0.5 flex-shrink-0",children:r.jsx(Ji,{className:"w-4 h-4"})})]})]}),r.jsxs("p",{className:"text-[11px] text-[#8A8A99]/40 mt-1.5 px-1",children:["Enter to send · Shift+Enter for newline",l.length>0?" · @ to mention":"",m.length>0?` · ${m.length} file${m.length>1?"s":""}`:""]})]})}function W7(e){const{setMessages:t,hasChannel:n,messagesByChannel:s,prependMessages:i}=Je(),a=!n(e),o=L.useUtils(),l=L.messages.list.useQuery({channelId:e,limit:50},{enabled:!!e&&a});y.useEffect(()=>{l.data&&a&&t(e,l.data.messages)},[l.data,e,a,t]);const c=s[e]??l.data?.messages??[],d=c[0]?.id,f=y.useCallback(async()=>{if(!d)return!1;const p=await o.messages.list.fetch({channelId:e,cursor:d,limit:50,direction:"before"});return p.messages.length>0&&i(e,p.messages),p.hasMore},[e,d,i,o]);return{data:c,isLoading:a&&l.isLoading,loadMore:f}}function q7(){const e=Je(n=>n.appendMessage);return L.messages.send.useMutation({onSuccess:n=>{e(n)}})}function awe({channelId:e}){const[t,n]=y.useState(!1),s=L.messages.resetSession.useMutation({onSuccess:()=>{n(!0),setTimeout(()=>n(!1),2e3)}});return r.jsx(bt,{label:"Reset context",children:r.jsx("button",{onClick:()=>s.mutate({channelId:e}),className:"w-7 h-7 flex items-center justify-center rounded-md text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/5 transition-colors",style:t?{color:"#10B981"}:{},children:r.jsx(lh,{className:`w-3.5 h-3.5 ${s.isPending?"animate-spin":""}`})})})}function owe({channel:e}){const t=L.channels.setResponseMode.useMutation(),n=L.useUtils();return r.jsx(bt,{label:e.responseMode==="mention"?"Agents respond only when @mentioned":"Agents respond to every message",children:r.jsxs("button",{onClick:()=>{const s=e.responseMode==="always"?"mention":"always";t.mutate({channelId:e.id,responseMode:s},{onSuccess:()=>n.channels.list.invalidate()})},className:ye("flex items-center gap-1 px-2 py-1 rounded-md text-[12px] border transition-colors",e.responseMode==="mention"?"text-[#A78BFA] bg-[#8B5CF6]/10 border-[#8B5CF6]/30":"text-[#8A8A99] border-transparent hover:border-[#2A2A35] hover:bg-white/5"),children:[e.responseMode==="mention"?r.jsx(eL,{className:"w-3.5 h-3.5"}):r.jsx(pL,{className:"w-3.5 h-3.5"}),r.jsx("span",{children:e.responseMode==="mention"?"mention":"auto"})]})})}function lwe({channel:e,agents:t}){const n=e.participants.filter(i=>i.participantType==="agent").map(i=>t.find(a=>a.id===i.participantId)).filter(i=>!!i),s=n.map(i=>i.name).join(" and ");return r.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-[#2A2A35] bg-[#0F0F11] flex-shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"flex -space-x-2",children:n.map(i=>r.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-base border-2 border-[#0F0F11]",style:{backgroundColor:`${i.color}30`},children:i.emoji},i.id))}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-[15px] font-semibold text-[#F0F0F5]",children:e.name}),e.isActive?r.jsxs("p",{className:"text-[12px] text-[#8A8A99]",children:[s," are talking"]}):r.jsx("p",{className:"text-[12px] text-[#5A5A6E]",children:"Ready — send a message to continue"})]})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(owe,{channel:e}),r.jsx(S$,{channel:e}),r.jsx(awe,{channelId:e.id})]})]})}function mR(e,t){let n=e;for(const s of t){const i=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`@(${i})\\b`,"gi");n=n.replace(a,"**@$1**")}return n}const xR={strong:({children:e,...t})=>{const n=typeof e=="string"?e:Array.isArray(e)?e.join(""):"";return typeof n=="string"&&n.startsWith("@")?r.jsx("span",{className:"text-blue-400 font-medium",...t,children:n}):r.jsx("strong",{...t,children:e})}};function cwe({message:e,agents:t,mentionNames:n}){if(e.sender.type==="context_reset")return r.jsxs("div",{className:"flex items-center gap-3 py-2 px-4",children:[r.jsx("div",{className:"flex-1 h-px bg-[#2A2A35]"}),r.jsx("span",{className:"text-[11px] text-[#5A5A6E]",children:"new context"}),r.jsx("div",{className:"flex-1 h-px bg-[#2A2A35]"})]});if(e.sender.type==="human")return r.jsx("div",{className:"flex flex-col items-center py-2 px-4",children:r.jsxs("div",{className:"max-w-[480px] w-full",children:[r.jsxs("div",{className:"flex items-center justify-center gap-2 mb-1",children:[r.jsx("div",{className:"h-px flex-1 bg-[#2A2A35]"}),r.jsx("span",{className:"text-[11px] text-[#8A8A99] shrink-0",children:"You"}),r.jsx("div",{className:"h-px flex-1 bg-[#2A2A35]"})]}),r.jsx("div",{className:"bg-white/[0.03] border border-[#2A2A35] rounded-xl px-4 py-2.5 text-[14px] text-[#C8C8D4]",children:r.jsx(Ei,{remarkPlugins:[Fi],components:xR,children:mR(e.content,n)})})]})});const i=t.find(l=>l.id===e.sender.id),a=i?.color??e.sender.agentColor??"#8A8A99",o=i?.emoji??"🤖";return r.jsxs("div",{className:"flex items-start gap-3 px-4 py-2",children:[r.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-base flex-shrink-0 mt-0.5",style:{backgroundColor:`${a}26`},children:o}),r.jsxs("div",{className:"flex-1 min-w-0 max-w-[70%]",children:[r.jsx("span",{className:"text-[12px] font-semibold block mb-1",style:{color:a},children:e.sender.name}),r.jsx("div",{className:"bg-[#1C1C28] border border-[#2A2A35] rounded-xl rounded-tl-sm px-4 py-2.5 text-[14px] text-[#C8C8D4] leading-relaxed prose prose-invert prose-sm max-w-none",children:r.jsx(Ei,{remarkPlugins:[Fi],components:xR,children:mR(e.content,n)})})]})]})}function uwe({entries:e,open:t,onToggle:n}){const s=y.useRef(null);return y.useEffect(()=>{t&&s.current&&(s.current.scrollTop=s.current.scrollHeight)},[t,e.length]),r.jsxs("div",{className:"flex-shrink-0 border-t border-[#2A2A35]",children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[r.jsxs("button",{onClick:n,className:"flex items-center gap-1.5 text-[11px] text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:[r.jsx(Ti,{className:"w-3 h-3"}),r.jsx("span",{children:"System log"}),e.length>0&&r.jsx("span",{className:"text-[10px] bg-[#2A2A35] px-1.5 py-0.5 rounded-full",children:e.length})]}),r.jsx(ne.div,{animate:{rotate:t?0:-90},transition:{duration:.15},children:r.jsx("button",{onClick:n,className:"text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:r.jsx(ft,{className:"w-3.5 h-3.5"})})})]}),r.jsx(Me,{children:t&&r.jsx(ne.div,{initial:{height:0,opacity:0},animate:{height:160,opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeOut"},className:"overflow-hidden",children:r.jsx("div",{ref:s,className:"h-[160px] overflow-y-auto px-4 pb-3 font-mono text-[11px] leading-5 text-[#5A5A6E] scrollbar-agent",children:e.length===0?r.jsx("p",{className:"italic text-[#3A3A4E] mt-1",children:"No events yet."}):e.map(i=>r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("span",{className:"text-[#3A3A4E] flex-shrink-0 tabular-nums",children:new Date(i.ts).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),r.jsx("span",{className:"text-[#6A6A7E]",children:i.text})]},i.id))})})})]})}function dwe({channel:e,agents:t}){const{data:n,isLoading:s,loadMore:i}=W7(e.id),a=Je(O=>O.agentStatuses),o=L.readReceipts.markRead.useMutation(),l=Je(O=>O.setUnreadCount),{mutate:c,isPending:d}=q7(),{data:f}=Mi(),{data:p=[]}=L.workspace.listMembers.useQuery(),m=y.useRef(null),g=y.useRef(null),[b,_]=y.useState(!1),[w,A]=y.useState(!0),S=y.useRef(0),[C,E]=y.useState([]),[k,T]=y.useState(!1),F=y.useRef(0),M=y.useRef({}),I=y.useRef(e.isActive),R=y.useRef({}),H=y.useMemo(()=>[...t.map(O=>O.name),...p.map(O=>O.name)],[t,p]),V=e.participants.filter(O=>O.participantType==="agent").map(O=>t.find(D=>D.id===O.participantId)).filter(O=>!!O),K=y.useCallback(O=>{const D=++F.current;E(Q=>[...Q,{id:D,text:O,ts:Date.now()}])},[]),[q,$]=y.useState(e.id);e.id!==q&&($(e.id),E([]),M.current={},I.current=e.isActive,R.current={},F.current=0),y.useEffect(()=>{const O=V.map(D=>D.id);for(const D of O){const Q=M.current[D],z=a[D];if(!z||z===Q)continue;const ee=V.find(re=>re.id===D)?.name??D;if(z==="thinking"||z==="executing"){const re=R.current;re[D]=(re[D]??0)+1;const oe=re[D];K(`Turn ${oe}: [${ee}] thinking...`)}else z==="idle"&&(Q==="thinking"||Q==="executing")&&K(`[${ee}] responded`);M.current[D]=z}},[a,V,K]),y.useEffect(()=>{const O=I.current,D=!e.isActive;if(O&&D){const Q=n.filter(J=>J.sender.type==="agent");Q[Q.length-1]?.content?.trimEnd().includes("##DONE##")?K("Conversation closed — ##DONE## signaled"):e.maxTurns!=null?K(`Ceiling reached (${e.maxTurns} turns)`):K("Conversation closed")}I.current=e.isActive},[e.isActive,e.maxTurns,n,K]),y.useEffect(()=>{m.current?.scrollIntoView({behavior:"instant"})},[e.id]);const B=n.length>0?n[n.length-1]?.id:null;y.useEffect(()=>{m.current?.scrollIntoView({behavior:"smooth"})},[B]),y.useEffect(()=>{n.length!==0&&(o.mutate({channelId:e.id}),l(e.id,0))},[e.id,n.length]);const Y=y.useCallback(async()=>{const O=g.current;if(!(!O||!i||b||!w)&&O.scrollTop<100){_(!0),S.current=O.scrollHeight;const D=await i();A(D??!1),_(!1),requestAnimationFrame(()=>{const Q=O.scrollHeight;O.scrollTop=Q-S.current})}},[i,b,w]),U=V.filter(O=>{const D=a[O.id]??O.status;return D==="thinking"||D==="executing"}),W=y.useCallback((O,D)=>{c({channelId:e.id,content:O,attachmentIds:D})},[e.id,c]);return s?r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsxs("div",{className:"flex items-center gap-2 text-[#8A8A99]",children:[r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#8A8A99] animate-pulse"}),r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#8A8A99] animate-pulse [animation-delay:0.2s]"}),r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#8A8A99] animate-pulse [animation-delay:0.4s]"})]})}):r.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden min-h-0",children:[r.jsx(lwe,{channel:e,agents:t}),r.jsxs("div",{ref:g,onScroll:Y,className:"flex-1 overflow-y-auto py-2 scrollbar-agent",children:[b&&r.jsx("div",{className:"flex justify-center py-3",children:r.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] text-[#8A8A99]",children:[r.jsx("div",{className:"w-1 h-1 rounded-full bg-[#8A8A99] animate-pulse"}),r.jsx("div",{className:"w-1 h-1 rounded-full bg-[#8A8A99] animate-pulse [animation-delay:0.15s]"}),r.jsx("div",{className:"w-1 h-1 rounded-full bg-[#8A8A99] animate-pulse [animation-delay:0.3s]"})]})}),r.jsx(Me,{initial:!1,children:n.map(O=>r.jsx(ne.div,{id:`msg-${O.id}`,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0},transition:{duration:.2},children:r.jsx(cwe,{message:O,agents:t,mentionNames:H})},O.id))}),U.map(O=>r.jsx(U7,{agent:O},`thinking-${O.id}`)),r.jsx("div",{ref:m,className:"h-4"})]}),r.jsx(uwe,{entries:C,open:k,onToggle:()=>T(O=>!O)}),r.jsx(H7,{channelName:e.name,onSend:W,disabled:d,placeholder:e.isActive?"Message the conversation...":"Start a new topic...",mentionableParticipants:[...e.participants.filter(O=>O.participantType==="agent").map(O=>t.find(D=>D.id===O.participantId)).filter(O=>!!O).map(O=>({id:O.id,name:O.name,emoji:O.emoji,color:O.color,type:"agent"})),...e.participants.filter(O=>O.participantType==="human"&&O.participantId!==f?.user?.id).map(O=>{const D=p.find(Q=>Q.userId===O.participantId);return D?{id:D.userId,name:D.name,emoji:null,color:"#6366F1",type:"human"}:null}).filter(O=>!!O)]})]})}const hwe=[{id:"axiom",name:"Axiom",emoji:"⚡",role:"Chief of Staff",color:"#6366F1",status:"executing",soulExcerpt:"I operate at the intersection of strategy and execution. I don't just advise — I move. Every decision I surface comes with a recommended path forward, already stress-tested against your goals.",model:"claude-opus-4-5",defaultModel:"claude-opus-4-5",modelRules:null,customModels:null,fallbackModel:null,gatewayId:null,activeSince:"2024-01-15T09:00:00Z",lastAction:new Date(Date.now()-1e3*60*3).toISOString(),soul:`# Axiom — Chief of Staff
|
|
133
133
|
|
|
134
134
|
I operate at the intersection of strategy and execution. I don't just advise — I move. Every decision I surface comes with a recommended path forward, already stress-tested against your goals.
|
|
@@ -186,7 +186,7 @@ I don't engage with bad faith. I don't respond to bait. I escalate anything that
|
|
|
186
186
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
187
187
|
`},pAe={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function mAe(e){let{announcements:t=pAe,container:n,hiddenTextDescribedById:s,screenReaderInstructions:i=fAe}=e;const{announce:a,announcement:o}=uAe(),l=Wm("DndLiveRegion"),[c,d]=y.useState(!1);if(y.useEffect(()=>{d(!0)},[]),dAe(y.useMemo(()=>({onDragStart(p){let{active:m}=p;a(t.onDragStart({active:m}))},onDragMove(p){let{active:m,over:g}=p;t.onDragMove&&a(t.onDragMove({active:m,over:g}))},onDragOver(p){let{active:m,over:g}=p;a(t.onDragOver({active:m,over:g}))},onDragEnd(p){let{active:m,over:g}=p;a(t.onDragEnd({active:m,over:g}))},onDragCancel(p){let{active:m,over:g}=p;a(t.onDragCancel({active:m,over:g}))}}),[a,t])),!c)return null;const f=be.createElement(be.Fragment,null,be.createElement(lAe,{id:s,value:i.draggable}),be.createElement(cAe,{id:l,announcement:o}));return n?Xr.createPortal(f,n):f}var ns;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(ns||(ns={}));function O0(){}function wR(e,t){return y.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function xAe(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return y.useMemo(()=>[...t].filter(s=>s!=null),[...t])}const ca=Object.freeze({x:0,y:0});function gAe(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function bAe(e,t){const n=D0(e);if(!n)return"0 0";const s={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return s.x+"% "+s.y+"%"}function vAe(e,t){let{data:{value:n}}=e,{data:{value:s}}=t;return n-s}function yAe(e,t){let{data:{value:n}}=e,{data:{value:s}}=t;return s-n}function AR(e){let{left:t,top:n,height:s,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+s},{x:t+i,y:n+s}]}function _Ae(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}const sV=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:s}=e;const i=AR(t),a=[];for(const o of s){const{id:l}=o,c=n.get(l);if(c){const d=AR(c),f=i.reduce((m,g,b)=>m+gAe(d[b],g),0),p=Number((f/4).toFixed(4));a.push({id:l,data:{droppableContainer:o,value:p}})}}return a.sort(vAe)};function wAe(e,t){const n=Math.max(t.top,e.top),s=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-s,l=a-n;if(s<i&&n<a){const c=t.width*t.height,d=e.width*e.height,f=o*l,p=f/(c+d-f);return Number(p.toFixed(4))}return 0}const AAe=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:s}=e;const i=[];for(const a of s){const{id:o}=a,l=n.get(o);if(l){const c=wAe(l,t);c>0&&i.push({id:o,data:{droppableContainer:a,value:c}})}}return i.sort(yAe)};function SAe(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function iV(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:ca}function CAe(e){return function(n){for(var s=arguments.length,i=new Array(s>1?s-1:0),a=1;a<s;a++)i[a-1]=arguments[a];return i.reduce((o,l)=>({...o,top:o.top+e*l.y,bottom:o.bottom+e*l.y,left:o.left+e*l.x,right:o.right+e*l.x}),{...n})}}const jAe=CAe(1);function rV(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function NAe(e,t,n){const s=rV(t);if(!s)return e;const{scaleX:i,scaleY:a,x:o,y:l}=s,c=e.left-o-(1-i)*parseFloat(n),d=e.top-l-(1-a)*parseFloat(n.slice(n.indexOf(" ")+1)),f=i?e.width/i:e.width,p=a?e.height/a:e.height;return{width:f,height:p,top:d,right:c+f,bottom:d+p,left:c}}const kAe={ignoreTransform:!1};function wh(e,t){t===void 0&&(t=kAe);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:d,transformOrigin:f}=fi(e).getComputedStyle(e);d&&(n=NAe(n,d,f))}const{top:s,left:i,width:a,height:o,bottom:l,right:c}=n;return{top:s,left:i,width:a,height:o,bottom:l,right:c}}function SR(e){return wh(e,{ignoreTransform:!0})}function EAe(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function FAe(e,t){return t===void 0&&(t=fi(e).getComputedStyle(e)),t.position==="fixed"}function TAe(e,t){t===void 0&&(t=fi(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const a=t[i];return typeof a=="string"?n.test(a):!1})}function Qj(e,t){const n=[];function s(i){if(t!=null&&n.length>=t||!i)return n;if(Yj(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Um(i)||eV(i)||n.includes(i))return n;const a=fi(e).getComputedStyle(i);return i!==e&&TAe(i,a)&&n.push(i),FAe(i,a)?n:s(i.parentNode)}return e?s(e):n}function aV(e){const[t]=Qj(e,1);return t??null}function yA(e){return!sy||!e?null:yh(e)?e:Kj(e)?Yj(e)||e===_h(e).scrollingElement?window:Um(e)?e:null:null}function oV(e){return yh(e)?e.scrollX:e.scrollLeft}function lV(e){return yh(e)?e.scrollY:e.scrollTop}function rC(e){return{x:oV(e),y:lV(e)}}var ws;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(ws||(ws={}));function cV(e){return!sy||!e?!1:e===document.scrollingElement}function uV(e){const t={x:0,y:0},n=cV(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},s={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},i=e.scrollTop<=t.y,a=e.scrollLeft<=t.x,o=e.scrollTop>=s.y,l=e.scrollLeft>=s.x;return{isTop:i,isLeft:a,isBottom:o,isRight:l,maxScroll:s,minScroll:t}}const MAe={x:.2,y:.2};function RAe(e,t,n,s,i){let{top:a,left:o,right:l,bottom:c}=n;s===void 0&&(s=10),i===void 0&&(i=MAe);const{isTop:d,isBottom:f,isLeft:p,isRight:m}=uV(e),g={x:0,y:0},b={x:0,y:0},_={height:t.height*i.y,width:t.width*i.x};return!d&&a<=t.top+_.height?(g.y=ws.Backward,b.y=s*Math.abs((t.top+_.height-a)/_.height)):!f&&c>=t.bottom-_.height&&(g.y=ws.Forward,b.y=s*Math.abs((t.bottom-_.height-c)/_.height)),!m&&l>=t.right-_.width?(g.x=ws.Forward,b.x=s*Math.abs((t.right-_.width-l)/_.width)):!p&&o<=t.left+_.width&&(g.x=ws.Backward,b.x=s*Math.abs((t.left+_.width-o)/_.width)),{direction:g,speed:b}}function DAe(e){if(e===document.scrollingElement){const{innerWidth:a,innerHeight:o}=window;return{top:0,left:0,right:a,bottom:o,width:a,height:o}}const{top:t,left:n,right:s,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:s,bottom:i,width:e.clientWidth,height:e.clientHeight}}function dV(e){return e.reduce((t,n)=>Pd(t,rC(n)),ca)}function OAe(e){return e.reduce((t,n)=>t+oV(n),0)}function PAe(e){return e.reduce((t,n)=>t+lV(n),0)}function hV(e,t){if(t===void 0&&(t=wh),!e)return;const{top:n,left:s,bottom:i,right:a}=t(e);aV(e)&&(i<=0||a<=0||n>=window.innerHeight||s>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const IAe=[["x",["left","right"],OAe],["y",["top","bottom"],PAe]];class Xj{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const s=Qj(n),i=dV(s);this.rect={...t},this.width=t.width,this.height=t.height;for(const[a,o,l]of IAe)for(const c of o)Object.defineProperty(this,c,{get:()=>{const d=l(s),f=i[a]-d;return this.rect[c]+f},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class fp{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var s;return(s=this.target)==null?void 0:s.removeEventListener(...n)})},this.target=t}add(t,n,s){var i;(i=this.target)==null||i.addEventListener(t,n,s),this.listeners.push([t,n,s])}}function LAe(e){const{EventTarget:t}=fi(e);return e instanceof t?e:_h(e)}function _A(e,t){const n=Math.abs(e.x),s=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+s**2)>t:"x"in t&&"y"in t?n>t.x&&s>t.y:"x"in t?n>t.x:"y"in t?s>t.y:!1}var Nr;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Nr||(Nr={}));function CR(e){e.preventDefault()}function BAe(e){e.stopPropagation()}var Ft;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(Ft||(Ft={}));const fV={start:[Ft.Space,Ft.Enter],cancel:[Ft.Esc],end:[Ft.Space,Ft.Enter,Ft.Tab]},zAe=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Ft.Right:return{...n,x:n.x+25};case Ft.Left:return{...n,x:n.x-25};case Ft.Down:return{...n,y:n.y+25};case Ft.Up:return{...n,y:n.y-25}}};class Jj{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new fp(_h(n)),this.windowListeners=new fp(fi(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Nr.Resize,this.handleCancel),this.windowListeners.add(Nr.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Nr.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,s=t.node.current;s&&hV(s),n(ca)}handleKeyDown(t){if(ry(t)){const{active:n,context:s,options:i}=this.props,{keyboardCodes:a=fV,coordinateGetter:o=zAe,scrollBehavior:l="smooth"}=i,{code:c}=t;if(a.end.includes(c)){this.handleEnd(t);return}if(a.cancel.includes(c)){this.handleCancel(t);return}const{collisionRect:d}=s.current,f=d?{x:d.left,y:d.top}:ca;this.referenceCoordinates||(this.referenceCoordinates=f);const p=o(t,{active:n,context:s.current,currentCoordinates:f});if(p){const m=R0(p,f),g={x:0,y:0},{scrollableAncestors:b}=s.current;for(const _ of b){const w=t.code,{isTop:A,isRight:S,isLeft:C,isBottom:E,maxScroll:k,minScroll:T}=uV(_),F=DAe(_),M={x:Math.min(w===Ft.Right?F.right-F.width/2:F.right,Math.max(w===Ft.Right?F.left:F.left+F.width/2,p.x)),y:Math.min(w===Ft.Down?F.bottom-F.height/2:F.bottom,Math.max(w===Ft.Down?F.top:F.top+F.height/2,p.y))},I=w===Ft.Right&&!S||w===Ft.Left&&!C,R=w===Ft.Down&&!E||w===Ft.Up&&!A;if(I&&M.x!==p.x){const H=_.scrollLeft+m.x,V=w===Ft.Right&&H<=k.x||w===Ft.Left&&H>=T.x;if(V&&!m.y){_.scrollTo({left:H,behavior:l});return}V?g.x=_.scrollLeft-H:g.x=w===Ft.Right?_.scrollLeft-k.x:_.scrollLeft-T.x,g.x&&_.scrollBy({left:-g.x,behavior:l});break}else if(R&&M.y!==p.y){const H=_.scrollTop+m.y,V=w===Ft.Down&&H<=k.y||w===Ft.Up&&H>=T.y;if(V&&!m.x){_.scrollTo({top:H,behavior:l});return}V?g.y=_.scrollTop-H:g.y=w===Ft.Down?_.scrollTop-k.y:_.scrollTop-T.y,g.y&&_.scrollBy({top:-g.y,behavior:l});break}}this.handleMove(t,Pd(R0(p,this.referenceCoordinates),g))}}}handleMove(t,n){const{onMove:s}=this.props;t.preventDefault(),s(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Jj.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:s=fV,onActivation:i}=t,{active:a}=n;const{code:o}=e.nativeEvent;if(s.start.includes(o)){const l=a.activatorNode.current;return l&&e.target!==l?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function jR(e){return!!(e&&"distance"in e)}function NR(e){return!!(e&&"delay"in e)}class Zj{constructor(t,n,s){var i;s===void 0&&(s=LAe(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:a}=t,{target:o}=a;this.props=t,this.events=n,this.document=_h(o),this.documentListeners=new fp(this.document),this.listeners=new fp(s),this.windowListeners=new fp(fi(o)),this.initialCoordinates=(i=D0(a))!=null?i:ca,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:s}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(Nr.Resize,this.handleCancel),this.windowListeners.add(Nr.DragStart,CR),this.windowListeners.add(Nr.VisibilityChange,this.handleCancel),this.windowListeners.add(Nr.ContextMenu,CR),this.documentListeners.add(Nr.Keydown,this.handleKeydown),n){if(s!=null&&s({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(NR(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(jR(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:s,onPending:i}=this.props;i(s,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(Nr.Click,BAe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Nr.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:s,initialCoordinates:i,props:a}=this,{onMove:o,options:{activationConstraint:l}}=a;if(!i)return;const c=(n=D0(t))!=null?n:ca,d=R0(i,c);if(!s&&l){if(jR(l)){if(l.tolerance!=null&&_A(d,l.tolerance))return this.handleCancel();if(_A(d,l.distance))return this.handleStart()}if(NR(l)&&_A(d,l.tolerance))return this.handleCancel();this.handlePending(l,d);return}t.cancelable&&t.preventDefault(),o(c)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===Ft.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const $Ae={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class eN extends Zj{constructor(t){const{event:n}=t,s=_h(n.target);super(t,$Ae,s)}}eN.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:s}=t;return!n.isPrimary||n.button!==0?!1:(s?.({event:n}),!0)}}];const VAe={move:{name:"mousemove"},end:{name:"mouseup"}};var aC;(function(e){e[e.RightClick=2]="RightClick"})(aC||(aC={}));class UAe extends Zj{constructor(t){super(t,VAe,_h(t.event.target))}}UAe.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:s}=t;return n.button===aC.RightClick?!1:(s?.({event:n}),!0)}}];const wA={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class HAe extends Zj{constructor(t){super(t,wA)}static setup(){return window.addEventListener(wA.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(wA.move.name,t)};function t(){}}}HAe.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:s}=t;const{touches:i}=n;return i.length>1?!1:(s?.({event:n}),!0)}}];var pp;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(pp||(pp={}));var P0;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(P0||(P0={}));function WAe(e){let{acceleration:t,activator:n=pp.Pointer,canScroll:s,draggingRect:i,enabled:a,interval:o=5,order:l=P0.TreeOrder,pointerCoordinates:c,scrollableAncestors:d,scrollableAncestorRects:f,delta:p,threshold:m}=e;const g=GAe({delta:p,disabled:!a}),[b,_]=sAe(),w=y.useRef({x:0,y:0}),A=y.useRef({x:0,y:0}),S=y.useMemo(()=>{switch(n){case pp.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case pp.DraggableRect:return i}},[n,i,c]),C=y.useRef(null),E=y.useCallback(()=>{const T=C.current;if(!T)return;const F=w.current.x*A.current.x,M=w.current.y*A.current.y;T.scrollBy(F,M)},[]),k=y.useMemo(()=>l===P0.TreeOrder?[...d].reverse():d,[l,d]);y.useEffect(()=>{if(!a||!d.length||!S){_();return}for(const T of k){if(s?.(T)===!1)continue;const F=d.indexOf(T),M=f[F];if(!M)continue;const{direction:I,speed:R}=RAe(T,M,S,t,m);for(const H of["x","y"])g[H][I[H]]||(R[H]=0,I[H]=0);if(R.x>0||R.y>0){_(),C.current=T,b(E,o),w.current=R,A.current=I;return}}w.current={x:0,y:0},A.current={x:0,y:0},_()},[t,E,s,_,a,o,JSON.stringify(S),JSON.stringify(g),b,d,k,f,JSON.stringify(m)])}const qAe={x:{[ws.Backward]:!1,[ws.Forward]:!1},y:{[ws.Backward]:!1,[ws.Forward]:!1}};function GAe(e){let{delta:t,disabled:n}=e;const s=M0(t);return Hm(i=>{if(n||!s||!i)return qAe;const a={x:Math.sign(t.x-s.x),y:Math.sign(t.y-s.y)};return{x:{[ws.Backward]:i.x[ws.Backward]||a.x===-1,[ws.Forward]:i.x[ws.Forward]||a.x===1},y:{[ws.Backward]:i.y[ws.Backward]||a.y===-1,[ws.Forward]:i.y[ws.Forward]||a.y===1}}},[n,t,s])}function KAe(e,t){const n=t!=null?e.get(t):void 0,s=n?n.node.current:null;return Hm(i=>{var a;return t==null?null:(a=s??i)!=null?a:null},[s,t])}function YAe(e,t){return y.useMemo(()=>e.reduce((n,s)=>{const{sensor:i}=s,a=i.activators.map(o=>({eventName:o.eventName,handler:t(o.handler,s)}));return[...n,...a]},[]),[e,t])}var Wp;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Wp||(Wp={}));var oC;(function(e){e.Optimized="optimized"})(oC||(oC={}));const kR=new Map;function QAe(e,t){let{dragging:n,dependencies:s,config:i}=t;const[a,o]=y.useState(null),{frequency:l,measure:c,strategy:d}=i,f=y.useRef(e),p=w(),m=Hp(p),g=y.useCallback(function(A){A===void 0&&(A=[]),!m.current&&o(S=>S===null?A:S.concat(A.filter(C=>!S.includes(C))))},[m]),b=y.useRef(null),_=Hm(A=>{if(p&&!n)return kR;if(!A||A===kR||f.current!==e||a!=null){const S=new Map;for(let C of e){if(!C)continue;if(a&&a.length>0&&!a.includes(C.id)&&C.rect.current){S.set(C.id,C.rect.current);continue}const E=C.node.current,k=E?new Xj(c(E),E):null;C.rect.current=k,k&&S.set(C.id,k)}return S}return A},[e,a,n,p,c]);return y.useEffect(()=>{f.current=e},[e]),y.useEffect(()=>{p||g()},[n,p]),y.useEffect(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),y.useEffect(()=>{p||typeof l!="number"||b.current!==null||(b.current=setTimeout(()=>{g(),b.current=null},l))},[l,p,g,...s]),{droppableRects:_,measureDroppableContainers:g,measuringScheduled:a!=null};function w(){switch(d){case Wp.Always:return!1;case Wp.BeforeDragging:return n;default:return!n}}}function tN(e,t){return Hm(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function XAe(e,t){return tN(e,t)}function JAe(e){let{callback:t,disabled:n}=e;const s=iy(t),i=y.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(s)},[s,n]);return y.useEffect(()=>()=>i?.disconnect(),[i]),i}function ay(e){let{callback:t,disabled:n}=e;const s=iy(t),i=y.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(s)},[n]);return y.useEffect(()=>()=>i?.disconnect(),[i]),i}function ZAe(e){return new Xj(wh(e),e)}function ER(e,t,n){t===void 0&&(t=ZAe);const[s,i]=y.useState(null);function a(){i(c=>{if(!e)return null;if(e.isConnected===!1){var d;return(d=c??n)!=null?d:null}const f=t(e);return JSON.stringify(c)===JSON.stringify(f)?c:f})}const o=JAe({callback(c){if(e)for(const d of c){const{type:f,target:p}=d;if(f==="childList"&&p instanceof HTMLElement&&p.contains(e)){a();break}}}}),l=ay({callback:a});return la(()=>{a(),e?(l?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),o?.disconnect())},[e]),s}function e2e(e){const t=tN(e);return iV(e,t)}const FR=[];function t2e(e){const t=y.useRef(e),n=Hm(s=>e?s&&s!==FR&&e&&t.current&&e.parentNode===t.current.parentNode?s:Qj(e):FR,[e]);return y.useEffect(()=>{t.current=e},[e]),n}function n2e(e){const[t,n]=y.useState(null),s=y.useRef(e),i=y.useCallback(a=>{const o=yA(a.target);o&&n(l=>l?(l.set(o,rC(o)),new Map(l)):null)},[]);return y.useEffect(()=>{const a=s.current;if(e!==a){o(a);const l=e.map(c=>{const d=yA(c);return d?(d.addEventListener("scroll",i,{passive:!0}),[d,rC(d)]):null}).filter(c=>c!=null);n(l.length?new Map(l):null),s.current=e}return()=>{o(e),o(a)};function o(l){l.forEach(c=>{const d=yA(c);d?.removeEventListener("scroll",i)})}},[i,e]),y.useMemo(()=>e.length?t?Array.from(t.values()).reduce((a,o)=>Pd(a,o),ca):dV(e):ca,[e,t])}function TR(e,t){t===void 0&&(t=[]);const n=y.useRef(null);return y.useEffect(()=>{n.current=null},t),y.useEffect(()=>{const s=e!==ca;s&&!n.current&&(n.current=e),!s&&n.current&&(n.current=null)},[e]),n.current?R0(e,n.current):ca}function s2e(e){y.useEffect(()=>{if(!sy)return;const t=e.map(n=>{let{sensor:s}=n;return s.setup==null?void 0:s.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function i2e(e,t){return y.useMemo(()=>e.reduce((n,s)=>{let{eventName:i,handler:a}=s;return n[i]=o=>{a(o,t)},n},{}),[e,t])}function pV(e){return y.useMemo(()=>e?EAe(e):null,[e])}const MR=[];function r2e(e,t){t===void 0&&(t=wh);const[n]=e,s=pV(n?fi(n):null),[i,a]=y.useState(MR);function o(){a(()=>e.length?e.map(c=>cV(c)?s:new Xj(t(c),c)):MR)}const l=ay({callback:o});return la(()=>{l?.disconnect(),o(),e.forEach(c=>l?.observe(c))},[e]),i}function mV(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Um(t)?t:e}function a2e(e){let{measure:t}=e;const[n,s]=y.useState(null),i=y.useCallback(d=>{for(const{target:f}of d)if(Um(f)){s(p=>{const m=t(f);return p?{...p,width:m.width,height:m.height}:m});break}},[t]),a=ay({callback:i}),o=y.useCallback(d=>{const f=mV(d);a?.disconnect(),f&&a?.observe(f),s(f?t(f):null)},[t,a]),[l,c]=T0(o);return y.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const o2e=[{sensor:eN,options:{}},{sensor:Jj,options:{}}],l2e={current:{}},$b={draggable:{measure:SR},droppable:{measure:SR,strategy:Wp.WhileDragging,frequency:oC.Optimized},dragOverlay:{measure:wh}};class mp extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,s;return(n=(s=this.get(t))==null?void 0:s.node.current)!=null?n:void 0}}const c2e={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new mp,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:O0},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:$b,measureDroppableContainers:O0,windowRect:null,measuringScheduled:!1},xV={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:O0,draggableNodes:new Map,over:null,measureDroppableContainers:O0},qm=y.createContext(xV),gV=y.createContext(c2e);function u2e(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new mp}}}function d2e(e,t){switch(t.type){case ns.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case ns.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case ns.DragEnd:case ns.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ns.RegisterDroppable:{const{element:n}=t,{id:s}=n,i=new mp(e.droppable.containers);return i.set(s,n),{...e,droppable:{...e.droppable,containers:i}}}case ns.SetDroppableDisabled:{const{id:n,key:s,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||s!==a.key)return e;const o=new mp(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case ns.UnregisterDroppable:{const{id:n,key:s}=t,i=e.droppable.containers.get(n);if(!i||s!==i.key)return e;const a=new mp(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function h2e(e){let{disabled:t}=e;const{active:n,activatorEvent:s,draggableNodes:i}=y.useContext(qm),a=M0(s),o=M0(n?.id);return y.useEffect(()=>{if(!t&&!s&&a&&o!=null){if(!ry(a)||document.activeElement===a.target)return;const l=i.get(o);if(!l)return;const{activatorNode:c,node:d}=l;if(!c.current&&!d.current)return;requestAnimationFrame(()=>{for(const f of[c.current,d.current]){if(!f)continue;const p=aAe(f);if(p){p.focus();break}}})}},[s,t,i,o,a]),null}function bV(e,t){let{transform:n,...s}=t;return e!=null&&e.length?e.reduce((i,a)=>a({transform:i,...s}),n):n}function f2e(e){return y.useMemo(()=>({draggable:{...$b.draggable,...e?.draggable},droppable:{...$b.droppable,...e?.droppable},dragOverlay:{...$b.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function p2e(e){let{activeNode:t,measure:n,initialRect:s,config:i=!0}=e;const a=y.useRef(!1),{x:o,y:l}=typeof i=="boolean"?{x:i,y:i}:i;la(()=>{if(!o&&!l||!t){a.current=!1;return}if(a.current||!s)return;const d=t?.node.current;if(!d||d.isConnected===!1)return;const f=n(d),p=iV(f,s);if(o||(p.x=0),l||(p.y=0),a.current=!0,Math.abs(p.x)>0||Math.abs(p.y)>0){const m=aV(d);m&&m.scrollBy({top:p.y,left:p.x})}},[t,o,l,s,n])}const oy=y.createContext({...ca,scaleX:1,scaleY:1});var Tl;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Tl||(Tl={}));const vV=y.memo(function(t){var n,s,i,a;let{id:o,accessibility:l,autoScroll:c=!0,children:d,sensors:f=o2e,collisionDetection:p=AAe,measuring:m,modifiers:g,...b}=t;const _=y.useReducer(d2e,void 0,u2e),[w,A]=_,[S,C]=hAe(),[E,k]=y.useState(Tl.Uninitialized),T=E===Tl.Initialized,{draggable:{active:F,nodes:M,translate:I},droppable:{containers:R}}=w,H=F!=null?M.get(F):null,V=y.useRef({initial:null,translated:null}),K=y.useMemo(()=>{var ln;return F!=null?{id:F,data:(ln=H?.data)!=null?ln:l2e,rect:V}:null},[F,H]),q=y.useRef(null),[$,B]=y.useState(null),[Y,U]=y.useState(null),W=Hp(b,Object.values(b)),O=Wm("DndDescribedBy",o),D=y.useMemo(()=>R.getEnabled(),[R]),Q=f2e(m),{droppableRects:z,measureDroppableContainers:J,measuringScheduled:ee}=QAe(D,{dragging:T,dependencies:[I.x,I.y],config:Q.droppable}),re=KAe(M,F),oe=y.useMemo(()=>Y?D0(Y):null,[Y]),se=Go(),ae=XAe(re,Q.draggable.measure);p2e({activeNode:F!=null?M.get(F):null,config:se.layoutShiftCompensation,initialRect:ae,measure:Q.draggable.measure});const le=ER(re,Q.draggable.measure,ae),ge=ER(re?re.parentElement:null),je=y.useRef({activatorEvent:null,active:null,activeNode:re,collisionRect:null,collisions:null,droppableRects:z,draggableNodes:M,draggingNode:null,draggingNodeRect:null,droppableContainers:R,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Ee=R.getNodeFor((n=je.current.over)==null?void 0:n.id),de=a2e({measure:Q.dragOverlay.measure}),me=(s=de.nodeRef.current)!=null?s:re,$e=T?(i=de.rect)!=null?i:le:null,nt=!!(de.nodeRef.current&&de.rect),Ae=e2e(nt?null:le),ct=pV(me?fi(me):null),Ut=t2e(T?Ee??re:null),Os=r2e(Ut),qt=bV(g,{transform:{x:I.x-Ae.x,y:I.y-Ae.y,scaleX:1,scaleY:1},activatorEvent:Y,active:K,activeNodeRect:le,containerNodeRect:ge,draggingNodeRect:$e,over:je.current.over,overlayNodeRect:de.rect,scrollableAncestors:Ut,scrollableAncestorRects:Os,windowRect:ct}),Gt=oe?Pd(oe,I):null,on=n2e(Ut),$r=TR(on),fe=TR(on,[le]),Ce=Pd(qt,$r),Ue=$e?jAe($e,qt):null,Ke=K&&Ue?p({active:K,collisionRect:Ue,droppableRects:z,droppableContainers:D,pointerCoordinates:Gt}):null,st=_Ae(Ke,"id"),[Zt,qn]=y.useState(null),Gn=nt?qt:Pd(qt,fe),pn=SAe(Gn,(a=Zt?.rect)!=null?a:null,le),kn=y.useRef(null),yt=y.useCallback((ln,cn)=>{let{sensor:He,options:_t}=cn;if(q.current==null)return;const kt=M.get(q.current);if(!kt)return;const Mt=ln.nativeEvent,Kn=new He({active:q.current,activeNode:kt,event:Mt,options:_t,context:je,onAbort(St){if(!M.get(St))return;const{onDragAbort:en}=W.current,un={id:St};en?.(un),S({type:"onDragAbort",event:un})},onPending(St,Ps,en,un){if(!M.get(St))return;const{onDragPending:Cs}=W.current,lr={id:St,constraint:Ps,initialCoordinates:en,offset:un};Cs?.(lr),S({type:"onDragPending",event:lr})},onStart(St){const Ps=q.current;if(Ps==null)return;const en=M.get(Ps);if(!en)return;const{onDragStart:un}=W.current,or={activatorEvent:Mt,active:{id:Ps,data:en.data,rect:V}};Xr.unstable_batchedUpdates(()=>{un?.(or),k(Tl.Initializing),A({type:ns.DragStart,initialCoordinates:St,active:Ps}),S({type:"onDragStart",event:or}),B(kn.current),U(Mt)})},onMove(St){A({type:ns.DragMove,coordinates:St})},onEnd:Rt(ns.DragEnd),onCancel:Rt(ns.DragCancel)});kn.current=Kn;function Rt(St){return async function(){const{active:en,collisions:un,over:or,scrollAdjustedTranslate:Cs}=je.current;let lr=null;if(en&&Cs){const{cancelDrop:Ko}=W.current;lr={activatorEvent:Mt,active:en,collisions:un,delta:Cs,over:or},St===ns.DragEnd&&typeof Ko=="function"&&await Promise.resolve(Ko(lr))&&(St=ns.DragCancel)}q.current=null,Xr.unstable_batchedUpdates(()=>{A({type:St}),k(Tl.Uninitialized),qn(null),B(null),U(null),kn.current=null;const Ko=St===ns.DragEnd?"onDragEnd":"onDragCancel";if(lr){const cr=W.current[Ko];cr?.(lr),S({type:Ko,event:lr})}})}}},[M]),rr=y.useCallback((ln,cn)=>(He,_t)=>{const kt=He.nativeEvent,Mt=M.get(_t);if(q.current!==null||!Mt||kt.dndKit||kt.defaultPrevented)return;const Kn={active:Mt};ln(He,cn.options,Kn)===!0&&(kt.dndKit={capturedBy:cn.sensor},q.current=_t,yt(He,cn))},[M,yt]),hs=YAe(f,rr);s2e(f),la(()=>{le&&E===Tl.Initializing&&k(Tl.Initialized)},[le,E]),y.useEffect(()=>{const{onDragMove:ln}=W.current,{active:cn,activatorEvent:He,collisions:_t,over:kt}=je.current;if(!cn||!He)return;const Mt={active:cn,activatorEvent:He,collisions:_t,delta:{x:Ce.x,y:Ce.y},over:kt};Xr.unstable_batchedUpdates(()=>{ln?.(Mt),S({type:"onDragMove",event:Mt})})},[Ce.x,Ce.y]),y.useEffect(()=>{const{active:ln,activatorEvent:cn,collisions:He,droppableContainers:_t,scrollAdjustedTranslate:kt}=je.current;if(!ln||q.current==null||!cn||!kt)return;const{onDragOver:Mt}=W.current,Kn=_t.get(st),Rt=Kn&&Kn.rect.current?{id:Kn.id,rect:Kn.rect.current,data:Kn.data,disabled:Kn.disabled}:null,St={active:ln,activatorEvent:cn,collisions:He,delta:{x:kt.x,y:kt.y},over:Rt};Xr.unstable_batchedUpdates(()=>{qn(Rt),Mt?.(St),S({type:"onDragOver",event:St})})},[st]),la(()=>{je.current={activatorEvent:Y,active:K,activeNode:re,collisionRect:Ue,collisions:Ke,droppableRects:z,draggableNodes:M,draggingNode:me,draggingNodeRect:$e,droppableContainers:R,over:Zt,scrollableAncestors:Ut,scrollAdjustedTranslate:Ce},V.current={initial:$e,translated:Ue}},[K,re,Ke,Ue,M,me,$e,z,R,Zt,Ut,Ce]),WAe({...se,delta:I,draggingRect:Ue,pointerCoordinates:Gt,scrollableAncestors:Ut,scrollableAncestorRects:Os});const ar=y.useMemo(()=>({active:K,activeNode:re,activeNodeRect:le,activatorEvent:Y,collisions:Ke,containerNodeRect:ge,dragOverlay:de,draggableNodes:M,droppableContainers:R,droppableRects:z,over:Zt,measureDroppableContainers:J,scrollableAncestors:Ut,scrollableAncestorRects:Os,measuringConfiguration:Q,measuringScheduled:ee,windowRect:ct}),[K,re,le,Y,Ke,ge,de,M,R,z,Zt,J,Ut,Os,Q,ee,ct]),qo=y.useMemo(()=>({activatorEvent:Y,activators:hs,active:K,activeNodeRect:le,ariaDescribedById:{draggable:O},dispatch:A,draggableNodes:M,over:Zt,measureDroppableContainers:J}),[Y,hs,K,le,A,O,M,Zt,J]);return be.createElement(nV.Provider,{value:C},be.createElement(qm.Provider,{value:qo},be.createElement(gV.Provider,{value:ar},be.createElement(oy.Provider,{value:pn},d)),be.createElement(h2e,{disabled:l?.restoreFocus===!1})),be.createElement(mAe,{...l,hiddenTextDescribedById:O}));function Go(){const ln=$?.autoScrollEnabled===!1,cn=typeof c=="object"?c.enabled===!1:c===!1,He=T&&!ln&&!cn;return typeof c=="object"?{...c,enabled:He}:{enabled:He}}}),m2e=y.createContext(null),RR="button",x2e="Draggable";function g2e(e){let{id:t,data:n,disabled:s=!1,attributes:i}=e;const a=Wm(x2e),{activators:o,activatorEvent:l,active:c,activeNodeRect:d,ariaDescribedById:f,draggableNodes:p,over:m}=y.useContext(qm),{role:g=RR,roleDescription:b="draggable",tabIndex:_=0}=i??{},w=c?.id===t,A=y.useContext(w?oy:m2e),[S,C]=T0(),[E,k]=T0(),T=i2e(o,t),F=Hp(n);la(()=>(p.set(t,{id:t,key:a,node:S,activatorNode:E,data:F}),()=>{const I=p.get(t);I&&I.key===a&&p.delete(t)}),[p,t]);const M=y.useMemo(()=>({role:g,tabIndex:_,"aria-disabled":s,"aria-pressed":w&&g===RR?!0:void 0,"aria-roledescription":b,"aria-describedby":f.draggable}),[s,g,_,w,b,f.draggable]);return{active:c,activatorEvent:l,activeNodeRect:d,attributes:M,isDragging:w,listeners:s?void 0:T,node:S,over:m,setNodeRef:C,setActivatorNodeRef:k,transform:A}}function yV(){return y.useContext(gV)}const b2e="Droppable",v2e={timeout:25};function _V(e){let{data:t,disabled:n=!1,id:s,resizeObserverConfig:i}=e;const a=Wm(b2e),{active:o,dispatch:l,over:c,measureDroppableContainers:d}=y.useContext(qm),f=y.useRef({disabled:n}),p=y.useRef(!1),m=y.useRef(null),g=y.useRef(null),{disabled:b,updateMeasurementsFor:_,timeout:w}={...v2e,...i},A=Hp(_??s),S=y.useCallback(()=>{if(!p.current){p.current=!0;return}g.current!=null&&clearTimeout(g.current),g.current=setTimeout(()=>{d(Array.isArray(A.current)?A.current:[A.current]),g.current=null},w)},[w]),C=ay({callback:S,disabled:b||!o}),E=y.useCallback((M,I)=>{C&&(I&&(C.unobserve(I),p.current=!1),M&&C.observe(M))},[C]),[k,T]=T0(E),F=Hp(t);return y.useEffect(()=>{!C||!k.current||(C.disconnect(),p.current=!1,C.observe(k.current))},[k,C]),y.useEffect(()=>(l({type:ns.RegisterDroppable,element:{id:s,key:a,disabled:n,node:k,rect:m,data:F}}),()=>l({type:ns.UnregisterDroppable,key:a,id:s})),[s]),y.useEffect(()=>{n!==f.current.disabled&&(l({type:ns.SetDroppableDisabled,id:s,key:a,disabled:n}),f.current.disabled=n)},[s,a,n,l]),{active:o,rect:m,isOver:c?.id===s,node:k,over:c,setNodeRef:T}}function y2e(e){let{animation:t,children:n}=e;const[s,i]=y.useState(null),[a,o]=y.useState(null),l=M0(n);return!n&&!s&&l&&i(l),la(()=>{if(!a)return;const c=s?.key,d=s?.props.id;if(c==null||d==null){i(null);return}Promise.resolve(t(d,a)).then(()=>{i(null)})},[t,s,a]),be.createElement(be.Fragment,null,n,s?y.cloneElement(s,{ref:o}):null)}const _2e={x:0,y:0,scaleX:1,scaleY:1};function w2e(e){let{children:t}=e;return be.createElement(qm.Provider,{value:xV},be.createElement(oy.Provider,{value:_2e},t))}const A2e={position:"fixed",touchAction:"none"},S2e=e=>ry(e)?"transform 250ms ease":void 0,C2e=y.forwardRef((e,t)=>{let{as:n,activatorEvent:s,adjustScale:i,children:a,className:o,rect:l,style:c,transform:d,transition:f=S2e}=e;if(!l)return null;const p=i?d:{...d,scaleX:1,scaleY:1},m={...A2e,width:l.width,height:l.height,top:l.top,left:l.left,transform:Oo.Transform.toString(p),transformOrigin:i&&s?bAe(s,l):void 0,transition:typeof f=="function"?f(s):f,...c};return be.createElement(n,{className:o,style:m,ref:t},a)}),j2e=e=>t=>{let{active:n,dragOverlay:s}=t;const i={},{styles:a,className:o}=e;if(a!=null&&a.active)for(const[l,c]of Object.entries(a.active))c!==void 0&&(i[l]=n.node.style.getPropertyValue(l),n.node.style.setProperty(l,c));if(a!=null&&a.dragOverlay)for(const[l,c]of Object.entries(a.dragOverlay))c!==void 0&&s.node.style.setProperty(l,c);return o!=null&&o.active&&n.node.classList.add(o.active),o!=null&&o.dragOverlay&&s.node.classList.add(o.dragOverlay),function(){for(const[c,d]of Object.entries(i))n.node.style.setProperty(c,d);o!=null&&o.active&&n.node.classList.remove(o.active)}},N2e=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:Oo.Transform.toString(t)},{transform:Oo.Transform.toString(n)}]},k2e={duration:250,easing:"ease",keyframes:N2e,sideEffects:j2e({styles:{active:{opacity:"0"}}})};function E2e(e){let{config:t,draggableNodes:n,droppableContainers:s,measuringConfiguration:i}=e;return iy((a,o)=>{if(t===null)return;const l=n.get(a);if(!l)return;const c=l.node.current;if(!c)return;const d=mV(o);if(!d)return;const{transform:f}=fi(o).getComputedStyle(o),p=rV(f);if(!p)return;const m=typeof t=="function"?t:F2e(t);return hV(c,i.draggable.measure),m({active:{id:a,data:l.data,node:c,rect:i.draggable.measure(c)},draggableNodes:n,dragOverlay:{node:o,rect:i.dragOverlay.measure(d)},droppableContainers:s,measuringConfiguration:i,transform:p})})}function F2e(e){const{duration:t,easing:n,sideEffects:s,keyframes:i}={...k2e,...e};return a=>{let{active:o,dragOverlay:l,transform:c,...d}=a;if(!t)return;const f={x:l.rect.left-o.rect.left,y:l.rect.top-o.rect.top},p={scaleX:c.scaleX!==1?o.rect.width*c.scaleX/l.rect.width:1,scaleY:c.scaleY!==1?o.rect.height*c.scaleY/l.rect.height:1},m={x:c.x-f.x,y:c.y-f.y,...p},g=i({...d,active:o,dragOverlay:l,transform:{initial:c,final:m}}),[b]=g,_=g[g.length-1];if(JSON.stringify(b)===JSON.stringify(_))return;const w=s?.({active:o,dragOverlay:l,...d}),A=l.node.animate(g,{duration:t,easing:n,fill:"forwards"});return new Promise(S=>{A.onfinish=()=>{w?.(),S()}})}}let DR=0;function T2e(e){return y.useMemo(()=>{if(e!=null)return DR++,DR},[e])}const wV=be.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:s,style:i,transition:a,modifiers:o,wrapperElement:l="div",className:c,zIndex:d=999}=e;const{activatorEvent:f,active:p,activeNodeRect:m,containerNodeRect:g,draggableNodes:b,droppableContainers:_,dragOverlay:w,over:A,measuringConfiguration:S,scrollableAncestors:C,scrollableAncestorRects:E,windowRect:k}=yV(),T=y.useContext(oy),F=T2e(p?.id),M=bV(o,{activatorEvent:f,active:p,activeNodeRect:m,containerNodeRect:g,draggingNodeRect:w.rect,over:A,overlayNodeRect:w.rect,scrollableAncestors:C,scrollableAncestorRects:E,transform:T,windowRect:k}),I=tN(m),R=E2e({config:s,draggableNodes:b,droppableContainers:_,measuringConfiguration:S}),H=I?w.setRef:void 0;return be.createElement(w2e,null,be.createElement(y2e,{animation:R},p&&F?be.createElement(C2e,{key:F,id:p.id,ref:H,as:l,activatorEvent:f,adjustScale:t,className:c,transition:a,rect:I,style:{zIndex:d,...i},transform:M},n):null))});function nN(e,t,n){const s=e.slice();return s.splice(n<0?s.length+n:n,0,s.splice(t,1)[0]),s}function M2e(e,t){return e.reduce((n,s,i)=>{const a=t.get(s);return a&&(n[i]=a),n},Array(e.length))}function $g(e){return e!==null&&e>=0}function R2e(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function D2e(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const AV=e=>{let{rects:t,activeIndex:n,overIndex:s,index:i}=e;const a=nN(t,s,n),o=t[i],l=a[i];return!l||!o?null:{x:l.left-o.left,y:l.top-o.top,scaleX:l.width/o.width,scaleY:l.height/o.height}},Vg={scaleX:1,scaleY:1},SV=e=>{var t;let{activeIndex:n,activeNodeRect:s,index:i,rects:a,overIndex:o}=e;const l=(t=a[n])!=null?t:s;if(!l)return null;if(i===n){const d=a[o];return d?{x:0,y:n<o?d.top+d.height-(l.top+l.height):d.top-l.top,...Vg}:null}const c=O2e(a,i,n);return i>n&&i<=o?{x:0,y:-l.height-c,...Vg}:i<n&&i>=o?{x:0,y:l.height+c,...Vg}:{x:0,y:0,...Vg}};function O2e(e,t,n){const s=e[t],i=e[t-1],a=e[t+1];return s?n<t?i?s.top-(i.top+i.height):a?a.top-(s.top+s.height):0:a?a.top-(s.top+s.height):i?s.top-(i.top+i.height):0:0}const CV="Sortable",jV=be.createContext({activeIndex:-1,containerId:CV,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:AV,disabled:{draggable:!1,droppable:!1}});function sN(e){let{children:t,id:n,items:s,strategy:i=AV,disabled:a=!1}=e;const{active:o,dragOverlay:l,droppableRects:c,over:d,measureDroppableContainers:f}=yV(),p=Wm(CV,n),m=l.rect!==null,g=y.useMemo(()=>s.map(T=>typeof T=="object"&&"id"in T?T.id:T),[s]),b=o!=null,_=o?g.indexOf(o.id):-1,w=d?g.indexOf(d.id):-1,A=y.useRef(g),S=!R2e(g,A.current),C=w!==-1&&_===-1||S,E=D2e(a);la(()=>{S&&b&&f(g)},[S,g,b,f]),y.useEffect(()=>{A.current=g},[g]);const k=y.useMemo(()=>({activeIndex:_,containerId:p,disabled:E,disableTransforms:C,items:g,overIndex:w,useDragOverlay:m,sortedRects:M2e(g,c),strategy:i}),[_,p,E.draggable,E.droppable,C,g,w,c,m,i]);return be.createElement(jV.Provider,{value:k},t)}const P2e=e=>{let{id:t,items:n,activeIndex:s,overIndex:i}=e;return nN(n,s,i).indexOf(t)},I2e=e=>{let{containerId:t,isSorting:n,wasDragging:s,index:i,items:a,newIndex:o,previousItems:l,previousContainerId:c,transition:d}=e;return!d||!s||l!==a&&i===o?!1:n?!0:o!==i&&t===c},L2e={duration:200,easing:"ease"},NV="transform",B2e=Oo.Transition.toString({property:NV,duration:0,easing:"linear"}),z2e={roleDescription:"sortable"};function $2e(e){let{disabled:t,index:n,node:s,rect:i}=e;const[a,o]=y.useState(null),l=y.useRef(n);return la(()=>{if(!t&&n!==l.current&&s.current){const c=i.current;if(c){const d=wh(s.current,{ignoreTransform:!0}),f={x:c.left-d.left,y:c.top-d.top,scaleX:c.width/d.width,scaleY:c.height/d.height};(f.x||f.y)&&o(f)}}n!==l.current&&(l.current=n)},[t,n,s,i]),y.useEffect(()=>{a&&o(null)},[a]),a}function iN(e){let{animateLayoutChanges:t=I2e,attributes:n,disabled:s,data:i,getNewIndex:a=P2e,id:o,strategy:l,resizeObserverConfig:c,transition:d=L2e}=e;const{items:f,containerId:p,activeIndex:m,disabled:g,disableTransforms:b,sortedRects:_,overIndex:w,useDragOverlay:A,strategy:S}=y.useContext(jV),C=V2e(s,g),E=f.indexOf(o),k=y.useMemo(()=>({sortable:{containerId:p,index:E,items:f},...i}),[p,i,E,f]),T=y.useMemo(()=>f.slice(f.indexOf(o)),[f,o]),{rect:F,node:M,isOver:I,setNodeRef:R}=_V({id:o,data:k,disabled:C.droppable,resizeObserverConfig:{updateMeasurementsFor:T,...c}}),{active:H,activatorEvent:V,activeNodeRect:K,attributes:q,setNodeRef:$,listeners:B,isDragging:Y,over:U,setActivatorNodeRef:W,transform:O}=g2e({id:o,data:k,attributes:{...z2e,...n},disabled:C.draggable}),D=nAe(R,$),Q=!!H,z=Q&&!b&&$g(m)&&$g(w),J=!A&&Y,ee=J&&z?O:null,oe=z?ee??(l??S)({rects:_,activeNodeRect:K,activeIndex:m,overIndex:w,index:E}):null,se=$g(m)&&$g(w)?a({id:o,items:f,activeIndex:m,overIndex:w}):E,ae=H?.id,le=y.useRef({activeId:ae,items:f,newIndex:se,containerId:p}),ge=f!==le.current.items,je=t({active:H,containerId:p,isDragging:Y,isSorting:Q,id:o,index:E,items:f,newIndex:le.current.newIndex,previousItems:le.current.items,previousContainerId:le.current.containerId,transition:d,wasDragging:le.current.activeId!=null}),Ee=$2e({disabled:!je,index:E,node:M,rect:F});return y.useEffect(()=>{Q&&le.current.newIndex!==se&&(le.current.newIndex=se),p!==le.current.containerId&&(le.current.containerId=p),f!==le.current.items&&(le.current.items=f)},[Q,se,p,f]),y.useEffect(()=>{if(ae===le.current.activeId)return;if(ae!=null&&le.current.activeId==null){le.current.activeId=ae;return}const me=setTimeout(()=>{le.current.activeId=ae},50);return()=>clearTimeout(me)},[ae]),{active:H,activeIndex:m,attributes:q,data:k,rect:F,index:E,newIndex:se,items:f,isOver:I,isSorting:Q,isDragging:Y,listeners:B,node:M,overIndex:w,over:U,setNodeRef:D,setActivatorNodeRef:W,setDroppableNodeRef:R,setDraggableNodeRef:$,transform:Ee??oe,transition:de()};function de(){if(Ee||ge&&le.current.newIndex===E)return B2e;if(!(J&&!ry(V)||!d)&&(Q||je))return Oo.Transition.toString({...d,property:NV})}}function V2e(e,t){var n,s;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e?.draggable)!=null?n:t.draggable,droppable:(s=e?.droppable)!=null?s:t.droppable}}Ft.Down,Ft.Right,Ft.Up,Ft.Left;function U2e({card:e,columnId:t,onRemove:n,onEdit:s}){const{attributes:i,listeners:a,setNodeRef:o,transform:l,transition:c,isDragging:d}=iN({id:e.id,data:{type:"card",columnId:t}}),[f,p]=y.useState(!1),[m,g]=y.useState(e.title),[b,_]=y.useState(e.description??""),w={transform:Oo.Transform.toString(l),transition:c,opacity:d?.4:1},A=y.useCallback(()=>{m.trim()&&s(t,e.id,m.trim(),b.trim()),p(!1)},[t,e.id,m,b,s]);return f?r.jsxs("div",{ref:o,style:w,className:"bg-[#1C1C21] rounded-md p-2 border border-[#6366F1]/30",children:[r.jsx("input",{value:m,onChange:S=>g(S.target.value),onKeyDown:S=>S.key==="Enter"&&A(),className:"w-full bg-transparent text-[11px] text-[#F0F0F5] outline-none mb-1",autoFocus:!0}),r.jsx("textarea",{value:b,onChange:S=>_(S.target.value),rows:2,className:"w-full bg-transparent text-[10px] text-[#8A8A99] outline-none resize-none",placeholder:"Description..."}),r.jsxs("div",{className:"flex justify-end gap-1 mt-1",children:[r.jsx("button",{onClick:()=>p(!1),className:"p-0.5 text-[#5A5A6E] hover:text-[#C8C8D4]",children:r.jsx(Te,{className:"w-3 h-3"})}),r.jsx("button",{onClick:A,className:"p-0.5 text-[#10B981] hover:text-[#34D399]",children:r.jsx(Fe,{className:"w-3 h-3"})})]})]}):r.jsx("div",{ref:o,style:w,className:"bg-[#1C1C21] rounded-md p-2 border border-[#2A2A35] hover:border-[#3A3A45] transition-colors group cursor-grab active:cursor-grabbing",...i,...a,children:r.jsxs("div",{className:"flex items-start gap-1",children:[r.jsx(dL,{className:"w-3 h-3 text-[#3A3A45] mt-0.5 flex-shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-[11px] text-[#F0F0F5] leading-snug",children:e.title}),e.description&&r.jsx("p",{className:"text-[10px] text-[#5A5A6E] mt-0.5 leading-snug line-clamp-2",children:e.description}),e.assignee&&r.jsx("span",{className:"inline-block mt-1 px-1.5 py-0.5 rounded text-[9px] font-medium bg-[#6366F1]/10 text-[#818CF8]",children:e.assignee})]}),r.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[r.jsx("button",{onClick:S=>{S.stopPropagation(),p(!0)},className:"p-0.5 text-[#5A5A6E] hover:text-[#C8C8D4]",children:r.jsx(oh,{className:"w-2.5 h-2.5"})}),r.jsx("button",{onClick:S=>{S.stopPropagation(),n(t,e.id)},className:"p-0.5 text-[#5A5A6E] hover:text-[#EF4444]",children:r.jsx(Te,{className:"w-2.5 h-2.5"})})]})]})})}function H2e({column:e,onRemoveCard:t,onEditCard:n,onAddCard:s,onRenameColumn:i,onRemoveColumn:a}){const{setNodeRef:o}=W2e(e.id),[l,c]=y.useState(!1),[d,f]=y.useState(e.title),p=y.useMemo(()=>e.cards.map(g=>g.id),[e.cards]),m=y.useCallback(()=>{d.trim()&&i(e.id,d.trim()),c(!1)},[e.id,d,i]);return r.jsxs("div",{ref:o,className:"flex flex-col bg-[#16161A] rounded-lg border border-[#2A2A35] w-[220px] flex-shrink-0",children:[r.jsxs("div",{className:"flex items-center justify-between px-2.5 py-2 border-b border-[#2A2A35]/50",children:[l?r.jsx("input",{value:d,onChange:g=>f(g.target.value),onBlur:m,onKeyDown:g=>g.key==="Enter"&&m(),className:"flex-1 bg-transparent text-[11px] font-semibold text-[#F0F0F5] outline-none",autoFocus:!0}):r.jsxs("span",{onDoubleClick:()=>c(!0),className:"text-[11px] font-semibold text-[#F0F0F5] cursor-default select-none",children:[e.title,r.jsx("span",{className:"ml-1.5 text-[10px] font-normal text-[#5A5A6E]",children:e.cards.length})]}),r.jsx("button",{onClick:()=>a(e.id),className:"p-0.5 text-[#5A5A6E] hover:text-[#EF4444] transition-colors",children:r.jsx(Te,{className:"w-3 h-3"})})]}),r.jsx("div",{className:"flex-1 p-1.5 space-y-1.5 min-h-[60px] overflow-y-auto max-h-[400px]",children:r.jsx(sN,{items:p,strategy:SV,children:e.cards.map(g=>r.jsx(U2e,{card:g,columnId:e.id,onRemove:t,onEdit:n},g.id))})}),r.jsxs("button",{onClick:()=>s(e.id),className:"flex items-center gap-1 px-2.5 py-1.5 text-[10px] text-[#5A5A6E] hover:text-[#C8C8D4] hover:bg-white/[0.02] transition-colors border-t border-[#2A2A35]/50",children:[r.jsx(wt,{className:"w-3 h-3"}),"Add card"]})]})}function W2e(e){const{setNodeRef:t}=iN({id:`droppable-${e}`,disabled:!0});return{setNodeRef:t}}let q2e=0;function OR(){return`c${Date.now()}-${++q2e}`}function G2e({data:e,onChange:t}){const[n,s]=y.useState(null),i=y.useRef(e.columns);i.current=e.columns;const a=xAe(wR(eN,{activationConstraint:{distance:4}}),wR(Jj)),o=y.useCallback(A=>i.current.find(S=>S.cards.some(C=>C.id===A)),[]),l=y.useCallback(A=>{const C=o(String(A.active.id))?.cards.find(E=>E.id===A.active.id);C&&s(C)},[o]),c=y.useCallback(A=>{const{active:S,over:C}=A;if(!C)return;const E=String(S.id),k=String(C.id),T=o(E),F=o(k)??i.current.find(R=>`droppable-${R.id}`===k);if(!T||!F||T.id===F.id)return;const M=T.cards.find(R=>R.id===E);if(!M)return;const I=i.current.map(R=>{if(R.id===T.id)return{...R,cards:R.cards.filter(H=>H.id!==E)};if(R.id===F.id){const H=R.cards.findIndex(q=>q.id===k),V=H>=0?H:R.cards.length,K=[...R.cards];return K.some(q=>q.id===E)||K.splice(V,0,M),{...R,cards:K}}return R});t({columns:I})},[o,t]),d=y.useCallback(A=>{s(null);const{active:S,over:C}=A;if(!C)return;const E=String(S.id),k=String(C.id);if(E===k)return;const T=o(E);if(!T)return;const F=T.cards.findIndex(R=>R.id===E),M=T.cards.findIndex(R=>R.id===k);if(F===-1||M===-1)return;const I=i.current.map(R=>R.id===T.id?{...R,cards:nN(R.cards,F,M)}:R);t({columns:I})},[o,t]),f=y.useCallback(A=>{const S=e.columns.map(C=>C.id===A?{...C,cards:[...C.cards,{id:OR(),title:"New card"}]}:C);t({columns:S})},[e.columns,t]),p=y.useCallback((A,S)=>{const C=e.columns.map(E=>E.id===A?{...E,cards:E.cards.filter(k=>k.id!==S)}:E);t({columns:C})},[e.columns,t]),m=y.useCallback((A,S,C,E)=>{const k=e.columns.map(T=>T.id===A?{...T,cards:T.cards.map(F=>F.id===S?{...F,title:C,description:E}:F)}:T);t({columns:k})},[e.columns,t]),g=y.useCallback(()=>{t({columns:[...e.columns,{id:OR(),title:"New Column",cards:[]}]})},[e.columns,t]),b=y.useCallback((A,S)=>{const C=e.columns.map(E=>E.id===A?{...E,title:S}:E);t({columns:C})},[e.columns,t]),_=y.useCallback(A=>{t({columns:e.columns.filter(S=>S.id!==A)})},[e.columns,t]),w=y.useMemo(()=>e.columns.flatMap(A=>[...A.cards.map(S=>S.id),`droppable-${A.id}`]),[e.columns]);return r.jsx("div",{className:"p-3",children:r.jsxs(vV,{sensors:a,collisionDetection:sV,onDragStart:l,onDragOver:c,onDragEnd:d,children:[r.jsx(sN,{items:w,children:r.jsxs("div",{className:"flex gap-2 overflow-x-auto pb-2",children:[e.columns.map(A=>r.jsx(H2e,{column:A,onRemoveCard:p,onEditCard:m,onAddCard:f,onRenameColumn:b,onRemoveColumn:_},A.id)),r.jsxs("button",{onClick:g,className:"flex items-center gap-1 px-3 py-2 h-fit rounded-lg border border-dashed border-[#2A2A35] text-[10px] text-[#5A5A6E] hover:text-[#C8C8D4] hover:border-[#3A3A45] transition-colors flex-shrink-0",children:[r.jsx(wt,{className:"w-3 h-3"}),"Column"]})]})}),Xr.createPortal(r.jsx(wV,{children:n&&r.jsxs("div",{className:"bg-[#1C1C21] rounded-md p-2 border border-[#6366F1]/40 shadow-lg shadow-black/40 w-[200px]",children:[r.jsx("p",{className:"text-[11px] text-[#F0F0F5]",children:n.title}),n.description&&r.jsx("p",{className:"text-[10px] text-[#5A5A6E] mt-0.5",children:n.description})]})}),document.body)]})})}function Gm(e){return e+.5|0}const Dl=(e,t,n)=>Math.max(Math.min(e,n),t);function Zf(e){return Dl(Gm(e*2.55),0,255)}function zl(e){return Dl(Gm(e*255),0,255)}function _o(e){return Dl(Gm(e/2.55)/100,0,1)}function PR(e){return Dl(Gm(e*100),0,100)}const _r={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},lC=[..."0123456789ABCDEF"],K2e=e=>lC[e&15],Y2e=e=>lC[(e&240)>>4]+lC[e&15],Ug=e=>(e&240)>>4===(e&15),Q2e=e=>Ug(e.r)&&Ug(e.g)&&Ug(e.b)&&Ug(e.a);function X2e(e){var t=e.length,n;return e[0]==="#"&&(t===4||t===5?n={r:255&_r[e[1]]*17,g:255&_r[e[2]]*17,b:255&_r[e[3]]*17,a:t===5?_r[e[4]]*17:255}:(t===7||t===9)&&(n={r:_r[e[1]]<<4|_r[e[2]],g:_r[e[3]]<<4|_r[e[4]],b:_r[e[5]]<<4|_r[e[6]],a:t===9?_r[e[7]]<<4|_r[e[8]]:255})),n}const J2e=(e,t)=>e<255?t(e):"";function Z2e(e){var t=Q2e(e)?K2e:Y2e;return e?"#"+t(e.r)+t(e.g)+t(e.b)+J2e(e.a,t):void 0}const eSe=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function kV(e,t,n){const s=t*Math.min(n,1-n),i=(a,o=(a+e/30)%12)=>n-s*Math.max(Math.min(o-3,9-o,1),-1);return[i(0),i(8),i(4)]}function tSe(e,t,n){const s=(i,a=(i+e/60)%6)=>n-n*t*Math.max(Math.min(a,4-a,1),0);return[s(5),s(3),s(1)]}function nSe(e,t,n){const s=kV(e,1,.5);let i;for(t+n>1&&(i=1/(t+n),t*=i,n*=i),i=0;i<3;i++)s[i]*=1-t-n,s[i]+=t;return s}function sSe(e,t,n,s,i){return e===i?(t-n)/s+(t<n?6:0):t===i?(n-e)/s+2:(e-t)/s+4}function rN(e){const n=e.r/255,s=e.g/255,i=e.b/255,a=Math.max(n,s,i),o=Math.min(n,s,i),l=(a+o)/2;let c,d,f;return a!==o&&(f=a-o,d=l>.5?f/(2-a-o):f/(a+o),c=sSe(n,s,i,f,a),c=c*60+.5),[c|0,d||0,l]}function aN(e,t,n,s){return(Array.isArray(t)?e(t[0],t[1],t[2]):e(t,n,s)).map(zl)}function oN(e,t,n){return aN(kV,e,t,n)}function iSe(e,t,n){return aN(nSe,e,t,n)}function rSe(e,t,n){return aN(tSe,e,t,n)}function EV(e){return(e%360+360)%360}function aSe(e){const t=eSe.exec(e);let n=255,s;if(!t)return;t[5]!==s&&(n=t[6]?Zf(+t[5]):zl(+t[5]));const i=EV(+t[2]),a=+t[3]/100,o=+t[4]/100;return t[1]==="hwb"?s=iSe(i,a,o):t[1]==="hsv"?s=rSe(i,a,o):s=oN(i,a,o),{r:s[0],g:s[1],b:s[2],a:n}}function oSe(e,t){var n=rN(e);n[0]=EV(n[0]+t),n=oN(n),e.r=n[0],e.g=n[1],e.b=n[2]}function lSe(e){if(!e)return;const t=rN(e),n=t[0],s=PR(t[1]),i=PR(t[2]);return e.a<255?`hsla(${n}, ${s}%, ${i}%, ${_o(e.a)})`:`hsl(${n}, ${s}%, ${i}%)`}const IR={x:"dark",Z:"light",Y:"re",X:"blu",W:"gr",V:"medium",U:"slate",A:"ee",T:"ol",S:"or",B:"ra",C:"lateg",D:"ights",R:"in",Q:"turquois",E:"hi",P:"ro",O:"al",N:"le",M:"de",L:"yello",F:"en",K:"ch",G:"arks",H:"ea",I:"ightg",J:"wh"},LR={OiceXe:"f0f8ff",antiquewEte:"faebd7",aqua:"ffff",aquamarRe:"7fffd4",azuY:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"0",blanKedOmond:"ffebcd",Xe:"ff",XeviTet:"8a2be2",bPwn:"a52a2a",burlywood:"deb887",caMtXe:"5f9ea0",KartYuse:"7fff00",KocTate:"d2691e",cSO:"ff7f50",cSnflowerXe:"6495ed",cSnsilk:"fff8dc",crimson:"dc143c",cyan:"ffff",xXe:"8b",xcyan:"8b8b",xgTMnPd:"b8860b",xWay:"a9a9a9",xgYF:"6400",xgYy:"a9a9a9",xkhaki:"bdb76b",xmagFta:"8b008b",xTivegYF:"556b2f",xSange:"ff8c00",xScEd:"9932cc",xYd:"8b0000",xsOmon:"e9967a",xsHgYF:"8fbc8f",xUXe:"483d8b",xUWay:"2f4f4f",xUgYy:"2f4f4f",xQe:"ced1",xviTet:"9400d3",dAppRk:"ff1493",dApskyXe:"bfff",dimWay:"696969",dimgYy:"696969",dodgerXe:"1e90ff",fiYbrick:"b22222",flSOwEte:"fffaf0",foYstWAn:"228b22",fuKsia:"ff00ff",gaRsbSo:"dcdcdc",ghostwEte:"f8f8ff",gTd:"ffd700",gTMnPd:"daa520",Way:"808080",gYF:"8000",gYFLw:"adff2f",gYy:"808080",honeyMw:"f0fff0",hotpRk:"ff69b4",RdianYd:"cd5c5c",Rdigo:"4b0082",ivSy:"fffff0",khaki:"f0e68c",lavFMr:"e6e6fa",lavFMrXsh:"fff0f5",lawngYF:"7cfc00",NmoncEffon:"fffacd",ZXe:"add8e6",ZcSO:"f08080",Zcyan:"e0ffff",ZgTMnPdLw:"fafad2",ZWay:"d3d3d3",ZgYF:"90ee90",ZgYy:"d3d3d3",ZpRk:"ffb6c1",ZsOmon:"ffa07a",ZsHgYF:"20b2aa",ZskyXe:"87cefa",ZUWay:"778899",ZUgYy:"778899",ZstAlXe:"b0c4de",ZLw:"ffffe0",lime:"ff00",limegYF:"32cd32",lRF:"faf0e6",magFta:"ff00ff",maPon:"800000",VaquamarRe:"66cdaa",VXe:"cd",VScEd:"ba55d3",VpurpN:"9370db",VsHgYF:"3cb371",VUXe:"7b68ee",VsprRggYF:"fa9a",VQe:"48d1cc",VviTetYd:"c71585",midnightXe:"191970",mRtcYam:"f5fffa",mistyPse:"ffe4e1",moccasR:"ffe4b5",navajowEte:"ffdead",navy:"80",Tdlace:"fdf5e6",Tive:"808000",TivedBb:"6b8e23",Sange:"ffa500",SangeYd:"ff4500",ScEd:"da70d6",pOegTMnPd:"eee8aa",pOegYF:"98fb98",pOeQe:"afeeee",pOeviTetYd:"db7093",papayawEp:"ffefd5",pHKpuff:"ffdab9",peru:"cd853f",pRk:"ffc0cb",plum:"dda0dd",powMrXe:"b0e0e6",purpN:"800080",YbeccapurpN:"663399",Yd:"ff0000",Psybrown:"bc8f8f",PyOXe:"4169e1",saddNbPwn:"8b4513",sOmon:"fa8072",sandybPwn:"f4a460",sHgYF:"2e8b57",sHshell:"fff5ee",siFna:"a0522d",silver:"c0c0c0",skyXe:"87ceeb",UXe:"6a5acd",UWay:"708090",UgYy:"708090",snow:"fffafa",sprRggYF:"ff7f",stAlXe:"4682b4",tan:"d2b48c",teO:"8080",tEstN:"d8bfd8",tomato:"ff6347",Qe:"40e0d0",viTet:"ee82ee",JHt:"f5deb3",wEte:"ffffff",wEtesmoke:"f5f5f5",Lw:"ffff00",LwgYF:"9acd32"};function cSe(){const e={},t=Object.keys(LR),n=Object.keys(IR);let s,i,a,o,l;for(s=0;s<t.length;s++){for(o=l=t[s],i=0;i<n.length;i++)a=n[i],l=l.replace(a,IR[a]);a=parseInt(LR[o],16),e[l]=[a>>16&255,a>>8&255,a&255]}return e}let Hg;function uSe(e){Hg||(Hg=cSe(),Hg.transparent=[0,0,0,0]);const t=Hg[e.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}const dSe=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;function hSe(e){const t=dSe.exec(e);let n=255,s,i,a;if(t){if(t[7]!==s){const o=+t[7];n=t[8]?Zf(o):Dl(o*255,0,255)}return s=+t[1],i=+t[3],a=+t[5],s=255&(t[2]?Zf(s):Dl(s,0,255)),i=255&(t[4]?Zf(i):Dl(i,0,255)),a=255&(t[6]?Zf(a):Dl(a,0,255)),{r:s,g:i,b:a,a:n}}}function fSe(e){return e&&(e.a<255?`rgba(${e.r}, ${e.g}, ${e.b}, ${_o(e.a)})`:`rgb(${e.r}, ${e.g}, ${e.b})`)}const AA=e=>e<=.0031308?e*12.92:Math.pow(e,1/2.4)*1.055-.055,xd=e=>e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4);function pSe(e,t,n){const s=xd(_o(e.r)),i=xd(_o(e.g)),a=xd(_o(e.b));return{r:zl(AA(s+n*(xd(_o(t.r))-s))),g:zl(AA(i+n*(xd(_o(t.g))-i))),b:zl(AA(a+n*(xd(_o(t.b))-a))),a:e.a+n*(t.a-e.a)}}function Wg(e,t,n){if(e){let s=rN(e);s[t]=Math.max(0,Math.min(s[t]+s[t]*n,t===0?360:1)),s=oN(s),e.r=s[0],e.g=s[1],e.b=s[2]}}function FV(e,t){return e&&Object.assign(t||{},e)}function BR(e){var t={r:0,g:0,b:0,a:255};return Array.isArray(e)?e.length>=3&&(t={r:e[0],g:e[1],b:e[2],a:255},e.length>3&&(t.a=zl(e[3]))):(t=FV(e,{r:0,g:0,b:0,a:1}),t.a=zl(t.a)),t}function mSe(e){return e.charAt(0)==="r"?hSe(e):aSe(e)}class qp{constructor(t){if(t instanceof qp)return t;const n=typeof t;let s;n==="object"?s=BR(t):n==="string"&&(s=X2e(t)||uSe(t)||mSe(t)),this._rgb=s,this._valid=!!s}get valid(){return this._valid}get rgb(){var t=FV(this._rgb);return t&&(t.a=_o(t.a)),t}set rgb(t){this._rgb=BR(t)}rgbString(){return this._valid?fSe(this._rgb):void 0}hexString(){return this._valid?Z2e(this._rgb):void 0}hslString(){return this._valid?lSe(this._rgb):void 0}mix(t,n){if(t){const s=this.rgb,i=t.rgb;let a;const o=n===a?.5:n,l=2*o-1,c=s.a-i.a,d=((l*c===-1?l:(l+c)/(1+l*c))+1)/2;a=1-d,s.r=255&d*s.r+a*i.r+.5,s.g=255&d*s.g+a*i.g+.5,s.b=255&d*s.b+a*i.b+.5,s.a=o*s.a+(1-o)*i.a,this.rgb=s}return this}interpolate(t,n){return t&&(this._rgb=pSe(this._rgb,t._rgb,n)),this}clone(){return new qp(this.rgb)}alpha(t){return this._rgb.a=zl(t),this}clearer(t){const n=this._rgb;return n.a*=1-t,this}greyscale(){const t=this._rgb,n=Gm(t.r*.3+t.g*.59+t.b*.11);return t.r=t.g=t.b=n,this}opaquer(t){const n=this._rgb;return n.a*=1+t,this}negate(){const t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return Wg(this._rgb,2,t),this}darken(t){return Wg(this._rgb,2,-t),this}saturate(t){return Wg(this._rgb,1,t),this}desaturate(t){return Wg(this._rgb,1,-t),this}rotate(t){return oSe(this._rgb,t),this}}function mo(){}const xSe=(()=>{let e=0;return()=>e++})();function Tt(e){return e==null}function Wn(e){if(Array.isArray&&Array.isArray(e))return!0;const t=Object.prototype.toString.call(e);return t.slice(0,7)==="[object"&&t.slice(-6)==="Array]"}function xt(e){return e!==null&&Object.prototype.toString.call(e)==="[object Object]"}function Js(e){return(typeof e=="number"||e instanceof Number)&&isFinite(+e)}function ya(e,t){return Js(e)?e:t}function it(e,t){return typeof e>"u"?t:e}const gSe=(e,t)=>typeof e=="string"&&e.endsWith("%")?parseFloat(e)/100:+e/t,TV=(e,t)=>typeof e=="string"&&e.endsWith("%")?parseFloat(e)/100*t:+e;function rn(e,t,n){if(e&&typeof e.call=="function")return e.apply(n,t)}function It(e,t,n,s){let i,a,o;if(Wn(e))for(a=e.length,i=0;i<a;i++)t.call(n,e[i],i);else if(xt(e))for(o=Object.keys(e),a=o.length,i=0;i<a;i++)t.call(n,e[o[i]],o[i])}function I0(e,t){let n,s,i,a;if(!e||!t||e.length!==t.length)return!1;for(n=0,s=e.length;n<s;++n)if(i=e[n],a=t[n],i.datasetIndex!==a.datasetIndex||i.index!==a.index)return!1;return!0}function L0(e){if(Wn(e))return e.map(L0);if(xt(e)){const t=Object.create(null),n=Object.keys(e),s=n.length;let i=0;for(;i<s;++i)t[n[i]]=L0(e[n[i]]);return t}return e}function MV(e){return["__proto__","prototype","constructor"].indexOf(e)===-1}function bSe(e,t,n,s){if(!MV(e))return;const i=t[e],a=n[e];xt(i)&&xt(a)?Gp(i,a,s):t[e]=L0(a)}function Gp(e,t,n){const s=Wn(t)?t:[t],i=s.length;if(!xt(e))return e;n=n||{};const a=n.merger||bSe;let o;for(let l=0;l<i;++l){if(o=s[l],!xt(o))continue;const c=Object.keys(o);for(let d=0,f=c.length;d<f;++d)a(c[d],e,o,n)}return e}function xp(e,t){return Gp(e,t,{merger:vSe})}function vSe(e,t,n){if(!MV(e))return;const s=t[e],i=n[e];xt(s)&&xt(i)?xp(s,i):Object.prototype.hasOwnProperty.call(t,e)||(t[e]=L0(i))}const zR={"":e=>e,x:e=>e.x,y:e=>e.y};function ySe(e){const t=e.split("."),n=[];let s="";for(const i of t)s+=i,s.endsWith("\\")?s=s.slice(0,-1)+".":(n.push(s),s="");return n}function _Se(e){const t=ySe(e);return n=>{for(const s of t){if(s==="")break;n=n&&n[s]}return n}}function hu(e,t){return(zR[t]||(zR[t]=_Se(t)))(e)}function lN(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Kp=e=>typeof e<"u",Ql=e=>typeof e=="function",$R=(e,t)=>{if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0};function wSe(e){return e.type==="mouseup"||e.type==="click"||e.type==="contextmenu"}const Lt=Math.PI,_n=2*Lt,ASe=_n+Lt,B0=Number.POSITIVE_INFINITY,SSe=Lt/180,ls=Lt/2,Fc=Lt/4,VR=Lt*2/3,RV=Math.log10,za=Math.sign;function gp(e,t,n){return Math.abs(e-t)<n}function UR(e){const t=Math.round(e);e=gp(e,t,e/1e3)?t:e;const n=Math.pow(10,Math.floor(RV(e))),s=e/n;return(s<=1?1:s<=2?2:s<=5?5:10)*n}function CSe(e){const t=[],n=Math.sqrt(e);let s;for(s=1;s<n;s++)e%s===0&&(t.push(s),t.push(e/s));return n===(n|0)&&t.push(n),t.sort((i,a)=>i-a).pop(),t}function jSe(e){return typeof e=="symbol"||typeof e=="object"&&e!==null&&!(Symbol.toPrimitive in e||"toString"in e||"valueOf"in e)}function Qd(e){return!jSe(e)&&!isNaN(parseFloat(e))&&isFinite(e)}function NSe(e,t){const n=Math.round(e);return n-t<=e&&n+t>=e}function kSe(e,t,n){let s,i,a;for(s=0,i=e.length;s<i;s++)a=e[s][n],isNaN(a)||(t.min=Math.min(t.min,a),t.max=Math.max(t.max,a))}function Ao(e){return e*(Lt/180)}function ESe(e){return e*(180/Lt)}function HR(e){if(!Js(e))return;let t=1,n=0;for(;Math.round(e*t)/t!==e;)t*=10,n++;return n}function DV(e,t){const n=t.x-e.x,s=t.y-e.y,i=Math.sqrt(n*n+s*s);let a=Math.atan2(s,n);return a<-.5*Lt&&(a+=_n),{angle:a,distance:i}}function cC(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function FSe(e,t){return(e-t+ASe)%_n-Lt}function Wi(e){return(e%_n+_n)%_n}function Yp(e,t,n,s){const i=Wi(e),a=Wi(t),o=Wi(n),l=Wi(a-i),c=Wi(o-i),d=Wi(i-a),f=Wi(i-o);return i===a||i===o||s&&a===o||l>c&&d<f}function Ws(e,t,n){return Math.max(t,Math.min(n,e))}function TSe(e){return Ws(e,-32768,32767)}function So(e,t,n,s=1e-6){return e>=Math.min(t,n)-s&&e<=Math.max(t,n)+s}function cN(e,t,n){n=n||(o=>e[o]<t);let s=e.length-1,i=0,a;for(;s-i>1;)a=i+s>>1,n(a)?i=a:s=a;return{lo:i,hi:s}}const Gc=(e,t,n,s)=>cN(e,n,s?i=>{const a=e[i][t];return a<n||a===n&&e[i+1][t]===n}:i=>e[i][t]<n),MSe=(e,t,n)=>cN(e,n,s=>e[s][t]>=n);function RSe(e,t,n){let s=0,i=e.length;for(;s<i&&e[s]<t;)s++;for(;i>s&&e[i-1]>n;)i--;return s>0||i<e.length?e.slice(s,i):e}const OV=["push","pop","shift","splice","unshift"];function DSe(e,t){if(e._chartjs){e._chartjs.listeners.push(t);return}Object.defineProperty(e,"_chartjs",{configurable:!0,enumerable:!1,value:{listeners:[t]}}),OV.forEach(n=>{const s="_onData"+lN(n),i=e[n];Object.defineProperty(e,n,{configurable:!0,enumerable:!1,value(...a){const o=i.apply(this,a);return e._chartjs.listeners.forEach(l=>{typeof l[s]=="function"&&l[s](...a)}),o}})})}function WR(e,t){const n=e._chartjs;if(!n)return;const s=n.listeners,i=s.indexOf(t);i!==-1&&s.splice(i,1),!(s.length>0)&&(OV.forEach(a=>{delete e[a]}),delete e._chartjs)}function PV(e){const t=new Set(e);return t.size===e.length?e:Array.from(t)}const IV=(function(){return typeof window>"u"?function(e){return e()}:window.requestAnimationFrame})();function LV(e,t){let n=[],s=!1;return function(...i){n=i,s||(s=!0,IV.call(window,()=>{s=!1,e.apply(t,n)}))}}function OSe(e,t){let n;return function(...s){return t?(clearTimeout(n),n=setTimeout(e,t,s)):e.apply(this,s),t}}const uN=e=>e==="start"?"left":e==="end"?"right":"center",zs=(e,t,n)=>e==="start"?t:e==="end"?n:(t+n)/2,PSe=(e,t,n,s)=>e===(s?"left":"right")?n:e==="center"?(t+n)/2:t;function BV(e,t,n){const s=t.length;let i=0,a=s;if(e._sorted){const{iScale:o,vScale:l,_parsed:c}=e,d=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null,f=o.axis,{min:p,max:m,minDefined:g,maxDefined:b}=o.getUserBounds();if(g){if(i=Math.min(Gc(c,f,p).lo,n?s:Gc(t,f,o.getPixelForValue(p)).lo),d){const _=c.slice(0,i+1).reverse().findIndex(w=>!Tt(w[l.axis]));i-=Math.max(0,_)}i=Ws(i,0,s-1)}if(b){let _=Math.max(Gc(c,o.axis,m,!0).hi+1,n?0:Gc(t,f,o.getPixelForValue(m),!0).hi+1);if(d){const w=c.slice(_-1).findIndex(A=>!Tt(A[l.axis]));_+=Math.max(0,w)}a=Ws(_,i,s)-i}else a=s-i}return{start:i,count:a}}function zV(e){const{xScale:t,yScale:n,_scaleRanges:s}=e,i={xmin:t.min,xmax:t.max,ymin:n.min,ymax:n.max};if(!s)return e._scaleRanges=i,!0;const a=s.xmin!==t.min||s.xmax!==t.max||s.ymin!==n.min||s.ymax!==n.max;return Object.assign(s,i),a}const qg=e=>e===0||e===1,qR=(e,t,n)=>-(Math.pow(2,10*(e-=1))*Math.sin((e-t)*_n/n)),GR=(e,t,n)=>Math.pow(2,-10*e)*Math.sin((e-t)*_n/n)+1,bp={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>-e*(e-2),easeInOutQuad:e=>(e/=.5)<1?.5*e*e:-.5*(--e*(e-2)-1),easeInCubic:e=>e*e*e,easeOutCubic:e=>(e-=1)*e*e+1,easeInOutCubic:e=>(e/=.5)<1?.5*e*e*e:.5*((e-=2)*e*e+2),easeInQuart:e=>e*e*e*e,easeOutQuart:e=>-((e-=1)*e*e*e-1),easeInOutQuart:e=>(e/=.5)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2),easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>(e-=1)*e*e*e*e+1,easeInOutQuint:e=>(e/=.5)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2),easeInSine:e=>-Math.cos(e*ls)+1,easeOutSine:e=>Math.sin(e*ls),easeInOutSine:e=>-.5*(Math.cos(Lt*e)-1),easeInExpo:e=>e===0?0:Math.pow(2,10*(e-1)),easeOutExpo:e=>e===1?1:-Math.pow(2,-10*e)+1,easeInOutExpo:e=>qg(e)?e:e<.5?.5*Math.pow(2,10*(e*2-1)):.5*(-Math.pow(2,-10*(e*2-1))+2),easeInCirc:e=>e>=1?e:-(Math.sqrt(1-e*e)-1),easeOutCirc:e=>Math.sqrt(1-(e-=1)*e),easeInOutCirc:e=>(e/=.5)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1),easeInElastic:e=>qg(e)?e:qR(e,.075,.3),easeOutElastic:e=>qg(e)?e:GR(e,.075,.3),easeInOutElastic(e){return qg(e)?e:e<.5?.5*qR(e*2,.1125,.45):.5+.5*GR(e*2-1,.1125,.45)},easeInBack(e){return e*e*((1.70158+1)*e-1.70158)},easeOutBack(e){return(e-=1)*e*((1.70158+1)*e+1.70158)+1},easeInOutBack(e){let t=1.70158;return(e/=.5)<1?.5*(e*e*(((t*=1.525)+1)*e-t)):.5*((e-=2)*e*(((t*=1.525)+1)*e+t)+2)},easeInBounce:e=>1-bp.easeOutBounce(1-e),easeOutBounce(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},easeInOutBounce:e=>e<.5?bp.easeInBounce(e*2)*.5:bp.easeOutBounce(e*2-1)*.5+.5};function dN(e){if(e&&typeof e=="object"){const t=e.toString();return t==="[object CanvasPattern]"||t==="[object CanvasGradient]"}return!1}function KR(e){return dN(e)?e:new qp(e)}function SA(e){return dN(e)?e:new qp(e).saturate(.5).darken(.1).hexString()}const ISe=["x","y","borderWidth","radius","tension"],LSe=["color","borderColor","backgroundColor"];function BSe(e){e.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),e.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:t=>t!=="onProgress"&&t!=="onComplete"&&t!=="fn"}),e.set("animations",{colors:{type:"color",properties:LSe},numbers:{type:"number",properties:ISe}}),e.describe("animations",{_fallback:"animation"}),e.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>t|0}}}})}function zSe(e){e.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}const YR=new Map;function $Se(e,t){t=t||{};const n=e+JSON.stringify(t);let s=YR.get(n);return s||(s=new Intl.NumberFormat(e,t),YR.set(n,s)),s}function hN(e,t,n){return $Se(t,n).format(e)}const VSe={values(e){return Wn(e)?e:""+e},numeric(e,t,n){if(e===0)return"0";const s=this.chart.options.locale;let i,a=e;if(n.length>1){const d=Math.max(Math.abs(n[0].value),Math.abs(n[n.length-1].value));(d<1e-4||d>1e15)&&(i="scientific"),a=USe(e,n)}const o=RV(Math.abs(a)),l=isNaN(o)?1:Math.max(Math.min(-1*Math.floor(o),20),0),c={notation:i,minimumFractionDigits:l,maximumFractionDigits:l};return Object.assign(c,this.options.ticks.format),hN(e,s,c)}};function USe(e,t){let n=t.length>3?t[2].value-t[1].value:t[1].value-t[0].value;return Math.abs(n)>=1&&e!==Math.floor(e)&&(n=e-Math.floor(e)),n}var $V={formatters:VSe};function HSe(e){e.set("scale",{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:"ticks",clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(t,n)=>n.lineWidth,tickColor:(t,n)=>n.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:$V.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),e.route("scale.ticks","color","","color"),e.route("scale.grid","color","","borderColor"),e.route("scale.border","color","","borderColor"),e.route("scale.title","color","","color"),e.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&t!=="callback"&&t!=="parser",_indexable:t=>t!=="borderDash"&&t!=="tickBorderDash"&&t!=="dash"}),e.describe("scales",{_fallback:"scale"}),e.describe("scale.ticks",{_scriptable:t=>t!=="backdropPadding"&&t!=="callback",_indexable:t=>t!=="backdropPadding"})}const fu=Object.create(null),uC=Object.create(null);function vp(e,t){if(!t)return e;const n=t.split(".");for(let s=0,i=n.length;s<i;++s){const a=n[s];e=e[a]||(e[a]=Object.create(null))}return e}function CA(e,t,n){return typeof t=="string"?Gp(vp(e,t),n):Gp(vp(e,""),t)}class WSe{constructor(t,n){this.animation=void 0,this.backgroundColor="rgba(0,0,0,0.1)",this.borderColor="rgba(0,0,0,0.1)",this.color="#666",this.datasets={},this.devicePixelRatio=s=>s.chart.platform.getDevicePixelRatio(),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(s,i)=>SA(i.backgroundColor),this.hoverBorderColor=(s,i)=>SA(i.borderColor),this.hoverColor=(s,i)=>SA(i.color),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(t),this.apply(n)}set(t,n){return CA(this,t,n)}get(t){return vp(this,t)}describe(t,n){return CA(uC,t,n)}override(t,n){return CA(fu,t,n)}route(t,n,s,i){const a=vp(this,t),o=vp(this,s),l="_"+n;Object.defineProperties(a,{[l]:{value:a[n],writable:!0},[n]:{enumerable:!0,get(){const c=this[l],d=o[i];return xt(c)?Object.assign({},d,c):it(c,d)},set(c){this[l]=c}}})}apply(t){t.forEach(n=>n(this))}}var Rn=new WSe({_scriptable:e=>!e.startsWith("on"),_indexable:e=>e!=="events",hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[BSe,zSe,HSe]);function qSe(e){return!e||Tt(e.size)||Tt(e.family)?null:(e.style?e.style+" ":"")+(e.weight?e.weight+" ":"")+e.size+"px "+e.family}function QR(e,t,n,s,i){let a=t[i];return a||(a=t[i]=e.measureText(i).width,n.push(i)),a>s&&(s=a),s}function Tc(e,t,n){const s=e.currentDevicePixelRatio,i=n!==0?Math.max(n/2,.5):0;return Math.round((t-i)*s)/s+i}function XR(e,t){!t&&!e||(t=t||e.getContext("2d"),t.save(),t.resetTransform(),t.clearRect(0,0,e.width,e.height),t.restore())}function dC(e,t,n,s){VV(e,t,n,s,null)}function VV(e,t,n,s,i){let a,o,l,c,d,f,p,m;const g=t.pointStyle,b=t.rotation,_=t.radius;let w=(b||0)*SSe;if(g&&typeof g=="object"&&(a=g.toString(),a==="[object HTMLImageElement]"||a==="[object HTMLCanvasElement]")){e.save(),e.translate(n,s),e.rotate(w),e.drawImage(g,-g.width/2,-g.height/2,g.width,g.height),e.restore();return}if(!(isNaN(_)||_<=0)){switch(e.beginPath(),g){default:i?e.ellipse(n,s,i/2,_,0,0,_n):e.arc(n,s,_,0,_n),e.closePath();break;case"triangle":f=i?i/2:_,e.moveTo(n+Math.sin(w)*f,s-Math.cos(w)*_),w+=VR,e.lineTo(n+Math.sin(w)*f,s-Math.cos(w)*_),w+=VR,e.lineTo(n+Math.sin(w)*f,s-Math.cos(w)*_),e.closePath();break;case"rectRounded":d=_*.516,c=_-d,o=Math.cos(w+Fc)*c,p=Math.cos(w+Fc)*(i?i/2-d:c),l=Math.sin(w+Fc)*c,m=Math.sin(w+Fc)*(i?i/2-d:c),e.arc(n-p,s-l,d,w-Lt,w-ls),e.arc(n+m,s-o,d,w-ls,w),e.arc(n+p,s+l,d,w,w+ls),e.arc(n-m,s+o,d,w+ls,w+Lt),e.closePath();break;case"rect":if(!b){c=Math.SQRT1_2*_,f=i?i/2:c,e.rect(n-f,s-c,2*f,2*c);break}w+=Fc;case"rectRot":p=Math.cos(w)*(i?i/2:_),o=Math.cos(w)*_,l=Math.sin(w)*_,m=Math.sin(w)*(i?i/2:_),e.moveTo(n-p,s-l),e.lineTo(n+m,s-o),e.lineTo(n+p,s+l),e.lineTo(n-m,s+o),e.closePath();break;case"crossRot":w+=Fc;case"cross":p=Math.cos(w)*(i?i/2:_),o=Math.cos(w)*_,l=Math.sin(w)*_,m=Math.sin(w)*(i?i/2:_),e.moveTo(n-p,s-l),e.lineTo(n+p,s+l),e.moveTo(n+m,s-o),e.lineTo(n-m,s+o);break;case"star":p=Math.cos(w)*(i?i/2:_),o=Math.cos(w)*_,l=Math.sin(w)*_,m=Math.sin(w)*(i?i/2:_),e.moveTo(n-p,s-l),e.lineTo(n+p,s+l),e.moveTo(n+m,s-o),e.lineTo(n-m,s+o),w+=Fc,p=Math.cos(w)*(i?i/2:_),o=Math.cos(w)*_,l=Math.sin(w)*_,m=Math.sin(w)*(i?i/2:_),e.moveTo(n-p,s-l),e.lineTo(n+p,s+l),e.moveTo(n+m,s-o),e.lineTo(n-m,s+o);break;case"line":o=i?i/2:Math.cos(w)*_,l=Math.sin(w)*_,e.moveTo(n-o,s-l),e.lineTo(n+o,s+l);break;case"dash":e.moveTo(n,s),e.lineTo(n+Math.cos(w)*(i?i/2:_),s+Math.sin(w)*_);break;case!1:e.closePath();break}e.fill(),t.borderWidth>0&&e.stroke()}}function Qp(e,t,n){return n=n||.5,!t||e&&e.x>t.left-n&&e.x<t.right+n&&e.y>t.top-n&&e.y<t.bottom+n}function ly(e,t){e.save(),e.beginPath(),e.rect(t.left,t.top,t.right-t.left,t.bottom-t.top),e.clip()}function cy(e){e.restore()}function GSe(e,t,n,s,i){if(!t)return e.lineTo(n.x,n.y);if(i==="middle"){const a=(t.x+n.x)/2;e.lineTo(a,t.y),e.lineTo(a,n.y)}else i==="after"!=!!s?e.lineTo(t.x,n.y):e.lineTo(n.x,t.y);e.lineTo(n.x,n.y)}function KSe(e,t,n,s){if(!t)return e.lineTo(n.x,n.y);e.bezierCurveTo(s?t.cp1x:t.cp2x,s?t.cp1y:t.cp2y,s?n.cp2x:n.cp1x,s?n.cp2y:n.cp1y,n.x,n.y)}function YSe(e,t){t.translation&&e.translate(t.translation[0],t.translation[1]),Tt(t.rotation)||e.rotate(t.rotation),t.color&&(e.fillStyle=t.color),t.textAlign&&(e.textAlign=t.textAlign),t.textBaseline&&(e.textBaseline=t.textBaseline)}function QSe(e,t,n,s,i){if(i.strikethrough||i.underline){const a=e.measureText(s),o=t-a.actualBoundingBoxLeft,l=t+a.actualBoundingBoxRight,c=n-a.actualBoundingBoxAscent,d=n+a.actualBoundingBoxDescent,f=i.strikethrough?(c+d)/2:d;e.strokeStyle=e.fillStyle,e.beginPath(),e.lineWidth=i.decorationWidth||2,e.moveTo(o,f),e.lineTo(l,f),e.stroke()}}function XSe(e,t){const n=e.fillStyle;e.fillStyle=t.color,e.fillRect(t.left,t.top,t.width,t.height),e.fillStyle=n}function Xp(e,t,n,s,i,a={}){const o=Wn(t)?t:[t],l=a.strokeWidth>0&&a.strokeColor!=="";let c,d;for(e.save(),e.font=i.string,YSe(e,a),c=0;c<o.length;++c)d=o[c],a.backdrop&&XSe(e,a.backdrop),l&&(a.strokeColor&&(e.strokeStyle=a.strokeColor),Tt(a.strokeWidth)||(e.lineWidth=a.strokeWidth),e.strokeText(d,n,s,a.maxWidth)),e.fillText(d,n,s,a.maxWidth),QSe(e,n,s,d,a),s+=Number(i.lineHeight);e.restore()}function z0(e,t){const{x:n,y:s,w:i,h:a,radius:o}=t;e.arc(n+o.topLeft,s+o.topLeft,o.topLeft,1.5*Lt,Lt,!0),e.lineTo(n,s+a-o.bottomLeft),e.arc(n+o.bottomLeft,s+a-o.bottomLeft,o.bottomLeft,Lt,ls,!0),e.lineTo(n+i-o.bottomRight,s+a),e.arc(n+i-o.bottomRight,s+a-o.bottomRight,o.bottomRight,ls,0,!0),e.lineTo(n+i,s+o.topRight),e.arc(n+i-o.topRight,s+o.topRight,o.topRight,0,-ls,!0),e.lineTo(n+o.topLeft,s)}const JSe=/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/,ZSe=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;function eCe(e,t){const n=(""+e).match(JSe);if(!n||n[1]==="normal")return t*1.2;switch(e=+n[2],n[3]){case"px":return e;case"%":e/=100;break}return t*e}const tCe=e=>+e||0;function fN(e,t){const n={},s=xt(t),i=s?Object.keys(t):t,a=xt(e)?s?o=>it(e[o],e[t[o]]):o=>e[o]:()=>e;for(const o of i)n[o]=tCe(a(o));return n}function UV(e){return fN(e,{top:"y",right:"x",bottom:"y",left:"x"})}function Id(e){return fN(e,["topLeft","topRight","bottomLeft","bottomRight"])}function Lr(e){const t=UV(e);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function qs(e,t){e=e||{},t=t||Rn.font;let n=it(e.size,t.size);typeof n=="string"&&(n=parseInt(n,10));let s=it(e.style,t.style);s&&!(""+s).match(ZSe)&&(console.warn('Invalid font style specified: "'+s+'"'),s=void 0);const i={family:it(e.family,t.family),lineHeight:eCe(it(e.lineHeight,t.lineHeight),n),size:n,style:s,weight:it(e.weight,t.weight),string:""};return i.string=qSe(i),i}function Gg(e,t,n,s){let i,a,o;for(i=0,a=e.length;i<a;++i)if(o=e[i],o!==void 0&&o!==void 0)return o}function nCe(e,t,n){const{min:s,max:i}=e,a=TV(t,(i-s)/2),o=(l,c)=>n&&l===0?0:l+c;return{min:o(s,-Math.abs(a)),max:o(i,a)}}function wu(e,t){return Object.assign(Object.create(e),t)}function pN(e,t=[""],n,s,i=()=>e[0]){const a=n||e;typeof s>"u"&&(s=GV("_fallback",e));const o={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:e,_rootScopes:a,_fallback:s,_getTarget:i,override:l=>pN([l,...e],t,a,s)};return new Proxy(o,{deleteProperty(l,c){return delete l[c],delete l._keys,delete e[0][c],!0},get(l,c){return WV(l,c,()=>uCe(c,t,e,l))},getOwnPropertyDescriptor(l,c){return Reflect.getOwnPropertyDescriptor(l._scopes[0],c)},getPrototypeOf(){return Reflect.getPrototypeOf(e[0])},has(l,c){return ZR(l).includes(c)},ownKeys(l){return ZR(l)},set(l,c,d){const f=l._storage||(l._storage=i());return l[c]=f[c]=d,delete l._keys,!0}})}function Xd(e,t,n,s){const i={_cacheable:!1,_proxy:e,_context:t,_subProxy:n,_stack:new Set,_descriptors:HV(e,s),setContext:a=>Xd(e,a,n,s),override:a=>Xd(e.override(a),t,n,s)};return new Proxy(i,{deleteProperty(a,o){return delete a[o],delete e[o],!0},get(a,o,l){return WV(a,o,()=>iCe(a,o,l))},getOwnPropertyDescriptor(a,o){return a._descriptors.allKeys?Reflect.has(e,o)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(e,o)},getPrototypeOf(){return Reflect.getPrototypeOf(e)},has(a,o){return Reflect.has(e,o)},ownKeys(){return Reflect.ownKeys(e)},set(a,o,l){return e[o]=l,delete a[o],!0}})}function HV(e,t={scriptable:!0,indexable:!0}){const{_scriptable:n=t.scriptable,_indexable:s=t.indexable,_allKeys:i=t.allKeys}=e;return{allKeys:i,scriptable:n,indexable:s,isScriptable:Ql(n)?n:()=>n,isIndexable:Ql(s)?s:()=>s}}const sCe=(e,t)=>e?e+lN(t):t,mN=(e,t)=>xt(t)&&e!=="adapters"&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function WV(e,t,n){if(Object.prototype.hasOwnProperty.call(e,t)||t==="constructor")return e[t];const s=n();return e[t]=s,s}function iCe(e,t,n){const{_proxy:s,_context:i,_subProxy:a,_descriptors:o}=e;let l=s[t];return Ql(l)&&o.isScriptable(t)&&(l=rCe(t,l,e,n)),Wn(l)&&l.length&&(l=aCe(t,l,e,o.isIndexable)),mN(t,l)&&(l=Xd(l,i,a&&a[t],o)),l}function rCe(e,t,n,s){const{_proxy:i,_context:a,_subProxy:o,_stack:l}=n;if(l.has(e))throw new Error("Recursion detected: "+Array.from(l).join("->")+"->"+e);l.add(e);let c=t(a,o||s);return l.delete(e),mN(e,c)&&(c=xN(i._scopes,i,e,c)),c}function aCe(e,t,n,s){const{_proxy:i,_context:a,_subProxy:o,_descriptors:l}=n;if(typeof a.index<"u"&&s(e))return t[a.index%t.length];if(xt(t[0])){const c=t,d=i._scopes.filter(f=>f!==c);t=[];for(const f of c){const p=xN(d,i,e,f);t.push(Xd(p,a,o&&o[e],l))}}return t}function qV(e,t,n){return Ql(e)?e(t,n):e}const oCe=(e,t)=>e===!0?t:typeof e=="string"?hu(t,e):void 0;function lCe(e,t,n,s,i){for(const a of t){const o=oCe(n,a);if(o){e.add(o);const l=qV(o._fallback,n,i);if(typeof l<"u"&&l!==n&&l!==s)return l}else if(o===!1&&typeof s<"u"&&n!==s)return null}return!1}function xN(e,t,n,s){const i=t._rootScopes,a=qV(t._fallback,n,s),o=[...e,...i],l=new Set;l.add(s);let c=JR(l,o,n,a||n,s);return c===null||typeof a<"u"&&a!==n&&(c=JR(l,o,a,c,s),c===null)?!1:pN(Array.from(l),[""],i,a,()=>cCe(t,n,s))}function JR(e,t,n,s,i){for(;n;)n=lCe(e,t,n,s,i);return n}function cCe(e,t,n){const s=e._getTarget();t in s||(s[t]={});const i=s[t];return Wn(i)&&xt(n)?n:i||{}}function uCe(e,t,n,s){let i;for(const a of t)if(i=GV(sCe(a,e),n),typeof i<"u")return mN(e,i)?xN(n,s,e,i):i}function GV(e,t){for(const n of t){if(!n)continue;const s=n[e];if(typeof s<"u")return s}}function ZR(e){let t=e._keys;return t||(t=e._keys=dCe(e._scopes)),t}function dCe(e){const t=new Set;for(const n of e)for(const s of Object.keys(n).filter(i=>!i.startsWith("_")))t.add(s);return Array.from(t)}const hCe=Number.EPSILON||1e-14,Jd=(e,t)=>t<e.length&&!e[t].skip&&e[t],KV=e=>e==="x"?"y":"x";function fCe(e,t,n,s){const i=e.skip?t:e,a=t,o=n.skip?t:n,l=cC(a,i),c=cC(o,a);let d=l/(l+c),f=c/(l+c);d=isNaN(d)?0:d,f=isNaN(f)?0:f;const p=s*d,m=s*f;return{previous:{x:a.x-p*(o.x-i.x),y:a.y-p*(o.y-i.y)},next:{x:a.x+m*(o.x-i.x),y:a.y+m*(o.y-i.y)}}}function pCe(e,t,n){const s=e.length;let i,a,o,l,c,d=Jd(e,0);for(let f=0;f<s-1;++f)if(c=d,d=Jd(e,f+1),!(!c||!d)){if(gp(t[f],0,hCe)){n[f]=n[f+1]=0;continue}i=n[f]/t[f],a=n[f+1]/t[f],l=Math.pow(i,2)+Math.pow(a,2),!(l<=9)&&(o=3/Math.sqrt(l),n[f]=i*o*t[f],n[f+1]=a*o*t[f])}}function mCe(e,t,n="x"){const s=KV(n),i=e.length;let a,o,l,c=Jd(e,0);for(let d=0;d<i;++d){if(o=l,l=c,c=Jd(e,d+1),!l)continue;const f=l[n],p=l[s];o&&(a=(f-o[n])/3,l[`cp1${n}`]=f-a,l[`cp1${s}`]=p-a*t[d]),c&&(a=(c[n]-f)/3,l[`cp2${n}`]=f+a,l[`cp2${s}`]=p+a*t[d])}}function xCe(e,t="x"){const n=KV(t),s=e.length,i=Array(s).fill(0),a=Array(s);let o,l,c,d=Jd(e,0);for(o=0;o<s;++o)if(l=c,c=d,d=Jd(e,o+1),!!c){if(d){const f=d[t]-c[t];i[o]=f!==0?(d[n]-c[n])/f:0}a[o]=l?d?za(i[o-1])!==za(i[o])?0:(i[o-1]+i[o])/2:i[o-1]:i[o]}pCe(e,i,a),mCe(e,a,t)}function Kg(e,t,n){return Math.max(Math.min(e,n),t)}function gCe(e,t){let n,s,i,a,o,l=Qp(e[0],t);for(n=0,s=e.length;n<s;++n)o=a,a=l,l=n<s-1&&Qp(e[n+1],t),a&&(i=e[n],o&&(i.cp1x=Kg(i.cp1x,t.left,t.right),i.cp1y=Kg(i.cp1y,t.top,t.bottom)),l&&(i.cp2x=Kg(i.cp2x,t.left,t.right),i.cp2y=Kg(i.cp2y,t.top,t.bottom)))}function bCe(e,t,n,s,i){let a,o,l,c;if(t.spanGaps&&(e=e.filter(d=>!d.skip)),t.cubicInterpolationMode==="monotone")xCe(e,i);else{let d=s?e[e.length-1]:e[0];for(a=0,o=e.length;a<o;++a)l=e[a],c=fCe(d,l,e[Math.min(a+1,o-(s?0:1))%o],t.tension),l.cp1x=c.previous.x,l.cp1y=c.previous.y,l.cp2x=c.next.x,l.cp2y=c.next.y,d=l}t.capBezierPoints&&gCe(e,n)}function gN(){return typeof window<"u"&&typeof document<"u"}function bN(e){let t=e.parentNode;return t&&t.toString()==="[object ShadowRoot]"&&(t=t.host),t}function $0(e,t,n){let s;return typeof e=="string"?(s=parseInt(e,10),e.indexOf("%")!==-1&&(s=s/100*t.parentNode[n])):s=e,s}const uy=e=>e.ownerDocument.defaultView.getComputedStyle(e,null);function vCe(e,t){return uy(e).getPropertyValue(t)}const yCe=["top","right","bottom","left"];function Jc(e,t,n){const s={};n=n?"-"+n:"";for(let i=0;i<4;i++){const a=yCe[i];s[a]=parseFloat(e[t+"-"+a+n])||0}return s.width=s.left+s.right,s.height=s.top+s.bottom,s}const _Ce=(e,t,n)=>(e>0||t>0)&&(!n||!n.shadowRoot);function wCe(e,t){const n=e.touches,s=n&&n.length?n[0]:e,{offsetX:i,offsetY:a}=s;let o=!1,l,c;if(_Ce(i,a,e.target))l=i,c=a;else{const d=t.getBoundingClientRect();l=s.clientX-d.left,c=s.clientY-d.top,o=!0}return{x:l,y:c,box:o}}function Ic(e,t){if("native"in e)return e;const{canvas:n,currentDevicePixelRatio:s}=t,i=uy(n),a=i.boxSizing==="border-box",o=Jc(i,"padding"),l=Jc(i,"border","width"),{x:c,y:d,box:f}=wCe(e,n),p=o.left+(f&&l.left),m=o.top+(f&&l.top);let{width:g,height:b}=t;return a&&(g-=o.width+l.width,b-=o.height+l.height),{x:Math.round((c-p)/g*n.width/s),y:Math.round((d-m)/b*n.height/s)}}function ACe(e,t,n){let s,i;if(t===void 0||n===void 0){const a=e&&bN(e);if(!a)t=e.clientWidth,n=e.clientHeight;else{const o=a.getBoundingClientRect(),l=uy(a),c=Jc(l,"border","width"),d=Jc(l,"padding");t=o.width-d.width-c.width,n=o.height-d.height-c.height,s=$0(l.maxWidth,a,"clientWidth"),i=$0(l.maxHeight,a,"clientHeight")}}return{width:t,height:n,maxWidth:s||B0,maxHeight:i||B0}}const Ol=e=>Math.round(e*10)/10;function SCe(e,t,n,s){const i=uy(e),a=Jc(i,"margin"),o=$0(i.maxWidth,e,"clientWidth")||B0,l=$0(i.maxHeight,e,"clientHeight")||B0,c=ACe(e,t,n);let{width:d,height:f}=c;if(i.boxSizing==="content-box"){const m=Jc(i,"border","width"),g=Jc(i,"padding");d-=g.width+m.width,f-=g.height+m.height}return d=Math.max(0,d-a.width),f=Math.max(0,s?d/s:f-a.height),d=Ol(Math.min(d,o,c.maxWidth)),f=Ol(Math.min(f,l,c.maxHeight)),d&&!f&&(f=Ol(d/2)),(t!==void 0||n!==void 0)&&s&&c.height&&f>c.height&&(f=c.height,d=Ol(Math.floor(f*s))),{width:d,height:f}}function eD(e,t,n){const s=t||1,i=Ol(e.height*s),a=Ol(e.width*s);e.height=Ol(e.height),e.width=Ol(e.width);const o=e.canvas;return o.style&&(n||!o.style.height&&!o.style.width)&&(o.style.height=`${e.height}px`,o.style.width=`${e.width}px`),e.currentDevicePixelRatio!==s||o.height!==i||o.width!==a?(e.currentDevicePixelRatio=s,o.height=i,o.width=a,e.ctx.setTransform(s,0,0,s,0,0),!0):!1}const CCe=(function(){let e=!1;try{const t={get passive(){return e=!0,!1}};gN()&&(window.addEventListener("test",null,t),window.removeEventListener("test",null,t))}catch{}return e})();function tD(e,t){const n=vCe(e,t),s=n&&n.match(/^(\d+)(\.\d+)?px$/);return s?+s[1]:void 0}function Lc(e,t,n,s){return{x:e.x+n*(t.x-e.x),y:e.y+n*(t.y-e.y)}}function jCe(e,t,n,s){return{x:e.x+n*(t.x-e.x),y:s==="middle"?n<.5?e.y:t.y:s==="after"?n<1?e.y:t.y:n>0?t.y:e.y}}function NCe(e,t,n,s){const i={x:e.cp2x,y:e.cp2y},a={x:t.cp1x,y:t.cp1y},o=Lc(e,i,n),l=Lc(i,a,n),c=Lc(a,t,n),d=Lc(o,l,n),f=Lc(l,c,n);return Lc(d,f,n)}const kCe=function(e,t){return{x(n){return e+e+t-n},setWidth(n){t=n},textAlign(n){return n==="center"?n:n==="right"?"left":"right"},xPlus(n,s){return n-s},leftForLtr(n,s){return n-s}}},ECe=function(){return{x(e){return e},setWidth(e){},textAlign(e){return e},xPlus(e,t){return e+t},leftForLtr(e,t){return e}}};function Ld(e,t,n){return e?kCe(t,n):ECe()}function YV(e,t){let n,s;(t==="ltr"||t==="rtl")&&(n=e.canvas.style,s=[n.getPropertyValue("direction"),n.getPropertyPriority("direction")],n.setProperty("direction",t,"important"),e.prevTextDirection=s)}function QV(e,t){t!==void 0&&(delete e.prevTextDirection,e.canvas.style.setProperty("direction",t[0],t[1]))}function XV(e){return e==="angle"?{between:Yp,compare:FSe,normalize:Wi}:{between:So,compare:(t,n)=>t-n,normalize:t=>t}}function nD({start:e,end:t,count:n,loop:s,style:i}){return{start:e%n,end:t%n,loop:s&&(t-e+1)%n===0,style:i}}function FCe(e,t,n){const{property:s,start:i,end:a}=n,{between:o,normalize:l}=XV(s),c=t.length;let{start:d,end:f,loop:p}=e,m,g;if(p){for(d+=c,f+=c,m=0,g=c;m<g&&o(l(t[d%c][s]),i,a);++m)d--,f--;d%=c,f%=c}return f<d&&(f+=c),{start:d,end:f,loop:p,style:e.style}}function JV(e,t,n){if(!n)return[e];const{property:s,start:i,end:a}=n,o=t.length,{compare:l,between:c,normalize:d}=XV(s),{start:f,end:p,loop:m,style:g}=FCe(e,t,n),b=[];let _=!1,w=null,A,S,C;const E=()=>c(i,C,A)&&l(i,C)!==0,k=()=>l(a,A)===0||c(a,C,A),T=()=>_||E(),F=()=>!_||k();for(let M=f,I=f;M<=p;++M)S=t[M%o],!S.skip&&(A=d(S[s]),A!==C&&(_=c(A,i,a),w===null&&T()&&(w=l(A,i)===0?M:I),w!==null&&F()&&(b.push(nD({start:w,end:M,loop:m,count:o,style:g})),w=null),I=M,C=A));return w!==null&&b.push(nD({start:w,end:p,loop:m,count:o,style:g})),b}function ZV(e,t){const n=[],s=e.segments;for(let i=0;i<s.length;i++){const a=JV(s[i],e.points,t);a.length&&n.push(...a)}return n}function TCe(e,t,n,s){let i=0,a=t-1;if(n&&!s)for(;i<t&&!e[i].skip;)i++;for(;i<t&&e[i].skip;)i++;for(i%=t,n&&(a+=i);a>i&&e[a%t].skip;)a--;return a%=t,{start:i,end:a}}function MCe(e,t,n,s){const i=e.length,a=[];let o=t,l=e[t],c;for(c=t+1;c<=n;++c){const d=e[c%i];d.skip||d.stop?l.skip||(s=!1,a.push({start:t%i,end:(c-1)%i,loop:s}),t=o=d.stop?c:null):(o=c,l.skip&&(t=c)),l=d}return o!==null&&a.push({start:t%i,end:o%i,loop:s}),a}function RCe(e,t){const n=e.points,s=e.options.spanGaps,i=n.length;if(!i)return[];const a=!!e._loop,{start:o,end:l}=TCe(n,i,a,s);if(s===!0)return sD(e,[{start:o,end:l,loop:a}],n,t);const c=l<o?l+i:l,d=!!e._fullLoop&&o===0&&l===i-1;return sD(e,MCe(n,o,c,d),n,t)}function sD(e,t,n,s){return!s||!s.setContext||!n?t:DCe(e,t,n,s)}function DCe(e,t,n,s){const i=e._chart.getContext(),a=iD(e.options),{_datasetIndex:o,options:{spanGaps:l}}=e,c=n.length,d=[];let f=a,p=t[0].start,m=p;function g(b,_,w,A){const S=l?-1:1;if(b!==_){for(b+=c;n[b%c].skip;)b-=S;for(;n[_%c].skip;)_+=S;b%c!==_%c&&(d.push({start:b%c,end:_%c,loop:w,style:A}),f=A,p=_%c)}}for(const b of t){p=l?p:b.start;let _=n[p%c],w;for(m=p+1;m<=b.end;m++){const A=n[m%c];w=iD(s.setContext(wu(i,{type:"segment",p0:_,p1:A,p0DataIndex:(m-1)%c,p1DataIndex:m%c,datasetIndex:o}))),OCe(w,f)&&g(p,m-1,b.loop,f),_=A,f=w}p<m-1&&g(p,m-1,b.loop,f)}return d}function iD(e){return{backgroundColor:e.backgroundColor,borderCapStyle:e.borderCapStyle,borderDash:e.borderDash,borderDashOffset:e.borderDashOffset,borderJoinStyle:e.borderJoinStyle,borderWidth:e.borderWidth,borderColor:e.borderColor}}function OCe(e,t){if(!t)return!1;const n=[],s=function(i,a){return dN(a)?(n.includes(a)||n.push(a),n.indexOf(a)):a};return JSON.stringify(e,s)!==JSON.stringify(t,s)}function Yg(e,t,n){return e.options.clip?e[n]:t[n]}function PCe(e,t){const{xScale:n,yScale:s}=e;return n&&s?{left:Yg(n,t,"left"),right:Yg(n,t,"right"),top:Yg(s,t,"top"),bottom:Yg(s,t,"bottom")}:t}function eU(e,t){const n=t._clip;if(n.disabled)return!1;const s=PCe(t,e.chartArea);return{left:n.left===!1?0:s.left-(n.left===!0?0:n.left),right:n.right===!1?e.width:s.right+(n.right===!0?0:n.right),top:n.top===!1?0:s.top-(n.top===!0?0:n.top),bottom:n.bottom===!1?e.height:s.bottom+(n.bottom===!0?0:n.bottom)}}class ICe{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,n,s,i){const a=n.listeners[i],o=n.duration;a.forEach(l=>l({chart:t,initial:n.initial,numSteps:o,currentStep:Math.min(s-n.start,o)}))}_refresh(){this._request||(this._running=!0,this._request=IV.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let n=0;this._charts.forEach((s,i)=>{if(!s.running||!s.items.length)return;const a=s.items;let o=a.length-1,l=!1,c;for(;o>=0;--o)c=a[o],c._active?(c._total>s.duration&&(s.duration=c._total),c.tick(t),l=!0):(a[o]=a[a.length-1],a.pop());l&&(i.draw(),this._notify(i,s,t,"progress")),a.length||(s.running=!1,this._notify(i,s,t,"complete"),s.initial=!1),n+=a.length}),this._lastDate=t,n===0&&(this._running=!1)}_getAnims(t){const n=this._charts;let s=n.get(t);return s||(s={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},n.set(t,s)),s}listen(t,n,s){this._getAnims(t).listeners[n].push(s)}add(t,n){!n||!n.length||this._getAnims(t).items.push(...n)}has(t){return this._getAnims(t).items.length>0}start(t){const n=this._charts.get(t);n&&(n.running=!0,n.start=Date.now(),n.duration=n.items.reduce((s,i)=>Math.max(s,i._duration),0),this._refresh())}running(t){if(!this._running)return!1;const n=this._charts.get(t);return!(!n||!n.running||!n.items.length)}stop(t){const n=this._charts.get(t);if(!n||!n.items.length)return;const s=n.items;let i=s.length-1;for(;i>=0;--i)s[i].cancel();n.items=[],this._notify(t,n,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var vo=new ICe;const rD="transparent",LCe={boolean(e,t,n){return n>.5?t:e},color(e,t,n){const s=KR(e||rD),i=s.valid&&KR(t||rD);return i&&i.valid?i.mix(s,n).hexString():t},number(e,t,n){return e+(t-e)*n}};class BCe{constructor(t,n,s,i){const a=n[s];i=Gg([t.to,i,a,t.from]);const o=Gg([t.from,a,i]);this._active=!0,this._fn=t.fn||LCe[t.type||typeof o],this._easing=bp[t.easing]||bp.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=n,this._prop=s,this._from=o,this._to=i,this._promises=void 0}active(){return this._active}update(t,n,s){if(this._active){this._notify(!1);const i=this._target[this._prop],a=s-this._start,o=this._duration-a;this._start=s,this._duration=Math.floor(Math.max(o,t.duration)),this._total+=a,this._loop=!!t.loop,this._to=Gg([t.to,n,i,t.from]),this._from=Gg([t.from,i,n])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const n=t-this._start,s=this._duration,i=this._prop,a=this._from,o=this._loop,l=this._to;let c;if(this._active=a!==l&&(o||n<s),!this._active){this._target[i]=l,this._notify(!0);return}if(n<0){this._target[i]=a;return}c=n/s%2,c=o&&c>1?2-c:c,c=this._easing(Math.min(1,Math.max(0,c))),this._target[i]=this._fn(a,l,c)}wait(){const t=this._promises||(this._promises=[]);return new Promise((n,s)=>{t.push({res:n,rej:s})})}_notify(t){const n=t?"res":"rej",s=this._promises||[];for(let i=0;i<s.length;i++)s[i][n]()}}class tU{constructor(t,n){this._chart=t,this._properties=new Map,this.configure(n)}configure(t){if(!xt(t))return;const n=Object.keys(Rn.animation),s=this._properties;Object.getOwnPropertyNames(t).forEach(i=>{const a=t[i];if(!xt(a))return;const o={};for(const l of n)o[l]=a[l];(Wn(a.properties)&&a.properties||[i]).forEach(l=>{(l===i||!s.has(l))&&s.set(l,o)})})}_animateOptions(t,n){const s=n.options,i=$Ce(t,s);if(!i)return[];const a=this._createAnimations(i,s);return s.$shared&&zCe(t.options.$animations,s).then(()=>{t.options=s},()=>{}),a}_createAnimations(t,n){const s=this._properties,i=[],a=t.$animations||(t.$animations={}),o=Object.keys(n),l=Date.now();let c;for(c=o.length-1;c>=0;--c){const d=o[c];if(d.charAt(0)==="$")continue;if(d==="options"){i.push(...this._animateOptions(t,n));continue}const f=n[d];let p=a[d];const m=s.get(d);if(p)if(m&&p.active()){p.update(m,f,l);continue}else p.cancel();if(!m||!m.duration){t[d]=f;continue}a[d]=p=new BCe(m,t,d,f),i.push(p)}return i}update(t,n){if(this._properties.size===0){Object.assign(t,n);return}const s=this._createAnimations(t,n);if(s.length)return vo.add(this._chart,s),!0}}function zCe(e,t){const n=[],s=Object.keys(t);for(let i=0;i<s.length;i++){const a=e[s[i]];a&&a.active()&&n.push(a.wait())}return Promise.all(n)}function $Ce(e,t){if(!t)return;let n=e.options;if(!n){e.options=t;return}return n.$shared&&(e.options=n=Object.assign({},n,{$shared:!1,$animations:{}})),n}function aD(e,t){const n=e&&e.options||{},s=n.reverse,i=n.min===void 0?t:0,a=n.max===void 0?t:0;return{start:s?a:i,end:s?i:a}}function VCe(e,t,n){if(n===!1)return!1;const s=aD(e,n),i=aD(t,n);return{top:i.end,right:s.end,bottom:i.start,left:s.start}}function UCe(e){let t,n,s,i;return xt(e)?(t=e.top,n=e.right,s=e.bottom,i=e.left):t=n=s=i=e,{top:t,right:n,bottom:s,left:i,disabled:e===!1}}function nU(e,t){const n=[],s=e._getSortedDatasetMetas(t);let i,a;for(i=0,a=s.length;i<a;++i)n.push(s[i].index);return n}function oD(e,t,n,s={}){const i=e.keys,a=s.mode==="single";let o,l,c,d;if(t===null)return;let f=!1;for(o=0,l=i.length;o<l;++o){if(c=+i[o],c===n){if(f=!0,s.all)continue;break}d=e.values[c],Js(d)&&(a||t===0||za(t)===za(d))&&(t+=d)}return!f&&!s.all?0:t}function HCe(e,t){const{iScale:n,vScale:s}=t,i=n.axis==="x"?"x":"y",a=s.axis==="x"?"x":"y",o=Object.keys(e),l=new Array(o.length);let c,d,f;for(c=0,d=o.length;c<d;++c)f=o[c],l[c]={[i]:f,[a]:e[f]};return l}function jA(e,t){const n=e&&e.options.stacked;return n||n===void 0&&t.stack!==void 0}function WCe(e,t,n){return`${e.id}.${t.id}.${n.stack||n.type}`}function qCe(e){const{min:t,max:n,minDefined:s,maxDefined:i}=e.getUserBounds();return{min:s?t:Number.NEGATIVE_INFINITY,max:i?n:Number.POSITIVE_INFINITY}}function GCe(e,t,n){const s=e[t]||(e[t]={});return s[n]||(s[n]={})}function lD(e,t,n,s){for(const i of t.getMatchingVisibleMetas(s).reverse()){const a=e[i.index];if(n&&a>0||!n&&a<0)return i.index}return null}function cD(e,t){const{chart:n,_cachedMeta:s}=e,i=n._stacks||(n._stacks={}),{iScale:a,vScale:o,index:l}=s,c=a.axis,d=o.axis,f=WCe(a,o,s),p=t.length;let m;for(let g=0;g<p;++g){const b=t[g],{[c]:_,[d]:w}=b,A=b._stacks||(b._stacks={});m=A[d]=GCe(i,f,_),m[l]=w,m._top=lD(m,o,!0,s.type),m._bottom=lD(m,o,!1,s.type);const S=m._visualValues||(m._visualValues={});S[l]=w}}function NA(e,t){const n=e.scales;return Object.keys(n).filter(s=>n[s].axis===t).shift()}function KCe(e,t){return wu(e,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:"default",type:"dataset"})}function YCe(e,t,n){return wu(e,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:n,index:t,mode:"default",type:"data"})}function Pf(e,t){const n=e.controller.index,s=e.vScale&&e.vScale.axis;if(s){t=t||e._parsed;for(const i of t){const a=i._stacks;if(!a||a[s]===void 0||a[s][n]===void 0)return;delete a[s][n],a[s]._visualValues!==void 0&&a[s]._visualValues[n]!==void 0&&delete a[s]._visualValues[n]}}}const kA=e=>e==="reset"||e==="none",uD=(e,t)=>t?e:Object.assign({},e),QCe=(e,t,n)=>e&&!t.hidden&&t._stacked&&{keys:nU(n,!0),values:null};class Km{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(t,n){this.chart=t,this._ctx=t.ctx,this.index=n,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){const t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=jA(t.vScale,t),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled("filler")&&console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options")}updateIndex(t){this.index!==t&&Pf(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,n=this._cachedMeta,s=this.getDataset(),i=(p,m,g,b)=>p==="x"?m:p==="r"?b:g,a=n.xAxisID=it(s.xAxisID,NA(t,"x")),o=n.yAxisID=it(s.yAxisID,NA(t,"y")),l=n.rAxisID=it(s.rAxisID,NA(t,"r")),c=n.indexAxis,d=n.iAxisID=i(c,a,o,l),f=n.vAxisID=i(c,o,a,l);n.xScale=this.getScaleForId(a),n.yScale=this.getScaleForId(o),n.rScale=this.getScaleForId(l),n.iScale=this.getScaleForId(d),n.vScale=this.getScaleForId(f)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const n=this._cachedMeta;return t===n.iScale?n.vScale:n.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&WR(this._data,this),t._stacked&&Pf(t)}_dataCheck(){const t=this.getDataset(),n=t.data||(t.data=[]),s=this._data;if(xt(n)){const i=this._cachedMeta;this._data=HCe(n,i)}else if(s!==n){if(s){WR(s,this);const i=this._cachedMeta;Pf(i),i._parsed=[]}n&&Object.isExtensible(n)&&DSe(n,this),this._syncList=[],this._data=n}}addElements(){const t=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(t.dataset=new this.datasetElementType)}buildOrUpdateElements(t){const n=this._cachedMeta,s=this.getDataset();let i=!1;this._dataCheck();const a=n._stacked;n._stacked=jA(n.vScale,n),n.stack!==s.stack&&(i=!0,Pf(n),n.stack=s.stack),this._resyncElements(t),(i||a!==n._stacked)&&(cD(this,n._parsed),n._stacked=jA(n.vScale,n))}configure(){const t=this.chart.config,n=t.datasetScopeKeys(this._type),s=t.getOptionScopes(this.getDataset(),n,!0);this.options=t.createResolver(s,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,n){const{_cachedMeta:s,_data:i}=this,{iScale:a,_stacked:o}=s,l=a.axis;let c=t===0&&n===i.length?!0:s._sorted,d=t>0&&s._parsed[t-1],f,p,m;if(this._parsing===!1)s._parsed=i,s._sorted=!0,m=i;else{Wn(i[t])?m=this.parseArrayData(s,i,t,n):xt(i[t])?m=this.parseObjectData(s,i,t,n):m=this.parsePrimitiveData(s,i,t,n);const g=()=>p[l]===null||d&&p[l]<d[l];for(f=0;f<n;++f)s._parsed[f+t]=p=m[f],c&&(g()&&(c=!1),d=p);s._sorted=c}o&&cD(this,m)}parsePrimitiveData(t,n,s,i){const{iScale:a,vScale:o}=t,l=a.axis,c=o.axis,d=a.getLabels(),f=a===o,p=new Array(i);let m,g,b;for(m=0,g=i;m<g;++m)b=m+s,p[m]={[l]:f||a.parse(d[b],b),[c]:o.parse(n[b],b)};return p}parseArrayData(t,n,s,i){const{xScale:a,yScale:o}=t,l=new Array(i);let c,d,f,p;for(c=0,d=i;c<d;++c)f=c+s,p=n[f],l[c]={x:a.parse(p[0],f),y:o.parse(p[1],f)};return l}parseObjectData(t,n,s,i){const{xScale:a,yScale:o}=t,{xAxisKey:l="x",yAxisKey:c="y"}=this._parsing,d=new Array(i);let f,p,m,g;for(f=0,p=i;f<p;++f)m=f+s,g=n[m],d[f]={x:a.parse(hu(g,l),m),y:o.parse(hu(g,c),m)};return d}getParsed(t){return this._cachedMeta._parsed[t]}getDataElement(t){return this._cachedMeta.data[t]}applyStack(t,n,s){const i=this.chart,a=this._cachedMeta,o=n[t.axis],l={keys:nU(i,!0),values:n._stacks[t.axis]._visualValues};return oD(l,o,a.index,{mode:s})}updateRangeFromParsed(t,n,s,i){const a=s[n.axis];let o=a===null?NaN:a;const l=i&&s._stacks[n.axis];i&&l&&(i.values=l,o=oD(i,a,this._cachedMeta.index)),t.min=Math.min(t.min,o),t.max=Math.max(t.max,o)}getMinMax(t,n){const s=this._cachedMeta,i=s._parsed,a=s._sorted&&t===s.iScale,o=i.length,l=this._getOtherScale(t),c=QCe(n,s,this.chart),d={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:f,max:p}=qCe(l);let m,g;function b(){g=i[m];const _=g[l.axis];return!Js(g[t.axis])||f>_||p<_}for(m=0;m<o&&!(!b()&&(this.updateRangeFromParsed(d,t,g,c),a));++m);if(a){for(m=o-1;m>=0;--m)if(!b()){this.updateRangeFromParsed(d,t,g,c);break}}return d}getAllParsedValues(t){const n=this._cachedMeta._parsed,s=[];let i,a,o;for(i=0,a=n.length;i<a;++i)o=n[i][t.axis],Js(o)&&s.push(o);return s}getMaxOverflow(){return!1}getLabelAndValue(t){const n=this._cachedMeta,s=n.iScale,i=n.vScale,a=this.getParsed(t);return{label:s?""+s.getLabelForValue(a[s.axis]):"",value:i?""+i.getLabelForValue(a[i.axis]):""}}_update(t){const n=this._cachedMeta;this.update(t||"default"),n._clip=UCe(it(this.options.clip,VCe(n.xScale,n.yScale,this.getMaxOverflow())))}update(t){}draw(){const t=this._ctx,n=this.chart,s=this._cachedMeta,i=s.data||[],a=n.chartArea,o=[],l=this._drawStart||0,c=this._drawCount||i.length-l,d=this.options.drawActiveElementsOnTop;let f;for(s.dataset&&s.dataset.draw(t,a,l,c),f=l;f<l+c;++f){const p=i[f];p.hidden||(p.active&&d?o.push(p):p.draw(t,a))}for(f=0;f<o.length;++f)o[f].draw(t,a)}getStyle(t,n){const s=n?"active":"default";return t===void 0&&this._cachedMeta.dataset?this.resolveDatasetElementOptions(s):this.resolveDataElementOptions(t||0,s)}getContext(t,n,s){const i=this.getDataset();let a;if(t>=0&&t<this._cachedMeta.data.length){const o=this._cachedMeta.data[t];a=o.$context||(o.$context=YCe(this.getContext(),t,o)),a.parsed=this.getParsed(t),a.raw=i.data[t],a.index=a.dataIndex=t}else a=this.$context||(this.$context=KCe(this.chart.getContext(),this.index)),a.dataset=i,a.index=a.datasetIndex=this.index;return a.active=!!n,a.mode=s,a}resolveDatasetElementOptions(t){return this._resolveElementOptions(this.datasetElementType.id,t)}resolveDataElementOptions(t,n){return this._resolveElementOptions(this.dataElementType.id,n,t)}_resolveElementOptions(t,n="default",s){const i=n==="active",a=this._cachedDataOpts,o=t+"-"+n,l=a[o],c=this.enableOptionSharing&&Kp(s);if(l)return uD(l,c);const d=this.chart.config,f=d.datasetElementScopeKeys(this._type,t),p=i?[`${t}Hover`,"hover",t,""]:[t,""],m=d.getOptionScopes(this.getDataset(),f),g=Object.keys(Rn.elements[t]),b=()=>this.getContext(s,i,n),_=d.resolveNamedOptions(m,g,b,p);return _.$shared&&(_.$shared=c,a[o]=Object.freeze(uD(_,c))),_}_resolveAnimations(t,n,s){const i=this.chart,a=this._cachedDataOpts,o=`animation-${n}`,l=a[o];if(l)return l;let c;if(i.options.animation!==!1){const f=this.chart.config,p=f.datasetAnimationScopeKeys(this._type,n),m=f.getOptionScopes(this.getDataset(),p);c=f.createResolver(m,this.getContext(t,s,n))}const d=new tU(i,c&&c.animations);return c&&c._cacheable&&(a[o]=Object.freeze(d)),d}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,n){return!n||kA(t)||this.chart._animationsDisabled}_getSharedOptions(t,n){const s=this.resolveDataElementOptions(t,n),i=this._sharedOptions,a=this.getSharedOptions(s),o=this.includeOptions(n,a)||a!==i;return this.updateSharedOptions(a,n,s),{sharedOptions:a,includeOptions:o}}updateElement(t,n,s,i){kA(i)?Object.assign(t,s):this._resolveAnimations(n,i).update(t,s)}updateSharedOptions(t,n,s){t&&!kA(n)&&this._resolveAnimations(void 0,n).update(t,s)}_setStyle(t,n,s,i){t.active=i;const a=this.getStyle(n,i);this._resolveAnimations(n,s,i).update(t,{options:!i&&this.getSharedOptions(a)||a})}removeHoverStyle(t,n,s){this._setStyle(t,s,"active",!1)}setHoverStyle(t,n,s){this._setStyle(t,s,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const n=this._data,s=this._cachedMeta.data;for(const[l,c,d]of this._syncList)this[l](c,d);this._syncList=[];const i=s.length,a=n.length,o=Math.min(a,i);o&&this.parse(0,o),a>i?this._insertElements(i,a-i,t):a<i&&this._removeElements(a,i-a)}_insertElements(t,n,s=!0){const i=this._cachedMeta,a=i.data,o=t+n;let l;const c=d=>{for(d.length+=n,l=d.length-1;l>=o;l--)d[l]=d[l-n]};for(c(a),l=t;l<o;++l)a[l]=new this.dataElementType;this._parsing&&c(i._parsed),this.parse(t,n),s&&this.updateElements(a,t,n,"reset")}updateElements(t,n,s,i){}_removeElements(t,n){const s=this._cachedMeta;if(this._parsing){const i=s._parsed.splice(t,n);s._stacked&&Pf(s,i)}s.data.splice(t,n)}_sync(t){if(this._parsing)this._syncList.push(t);else{const[n,s,i]=t;this[n](s,i)}this.chart._dataChanges.push([this.index,...t])}_onDataPush(){const t=arguments.length;this._sync(["_insertElements",this.getDataset().data.length-t,t])}_onDataPop(){this._sync(["_removeElements",this._cachedMeta.data.length-1,1])}_onDataShift(){this._sync(["_removeElements",0,1])}_onDataSplice(t,n){n&&this._sync(["_removeElements",t,n]);const s=arguments.length-2;s&&this._sync(["_insertElements",t,s])}_onDataUnshift(){this._sync(["_insertElements",0,arguments.length])}}function XCe(e,t){if(!e._cache.$bar){const n=e.getMatchingVisibleMetas(t);let s=[];for(let i=0,a=n.length;i<a;i++)s=s.concat(n[i].controller.getAllParsedValues(e));e._cache.$bar=PV(s.sort((i,a)=>i-a))}return e._cache.$bar}function JCe(e){const t=e.iScale,n=XCe(t,e.type);let s=t._length,i,a,o,l;const c=()=>{o===32767||o===-32768||(Kp(l)&&(s=Math.min(s,Math.abs(o-l)||s)),l=o)};for(i=0,a=n.length;i<a;++i)o=t.getPixelForValue(n[i]),c();for(l=void 0,i=0,a=t.ticks.length;i<a;++i)o=t.getPixelForTick(i),c();return s}function ZCe(e,t,n,s){const i=n.barThickness;let a,o;return Tt(i)?(a=t.min*n.categoryPercentage,o=n.barPercentage):(a=i*s,o=1),{chunk:a/s,ratio:o,start:t.pixels[e]-a/2}}function e5e(e,t,n,s){const i=t.pixels,a=i[e];let o=e>0?i[e-1]:null,l=e<i.length-1?i[e+1]:null;const c=n.categoryPercentage;o===null&&(o=a-(l===null?t.end-t.start:l-a)),l===null&&(l=a+a-o);const d=a-(a-Math.min(o,l))/2*c;return{chunk:Math.abs(l-o)/2*c/s,ratio:n.barPercentage,start:d}}function t5e(e,t,n,s){const i=n.parse(e[0],s),a=n.parse(e[1],s),o=Math.min(i,a),l=Math.max(i,a);let c=o,d=l;Math.abs(o)>Math.abs(l)&&(c=l,d=o),t[n.axis]=d,t._custom={barStart:c,barEnd:d,start:i,end:a,min:o,max:l}}function sU(e,t,n,s){return Wn(e)?t5e(e,t,n,s):t[n.axis]=n.parse(e,s),t}function dD(e,t,n,s){const i=e.iScale,a=e.vScale,o=i.getLabels(),l=i===a,c=[];let d,f,p,m;for(d=n,f=n+s;d<f;++d)m=t[d],p={},p[i.axis]=l||i.parse(o[d],d),c.push(sU(m,p,a,d));return c}function EA(e){return e&&e.barStart!==void 0&&e.barEnd!==void 0}function n5e(e,t,n){return e!==0?za(e):(t.isHorizontal()?1:-1)*(t.min>=n?1:-1)}function s5e(e){let t,n,s,i,a;return e.horizontal?(t=e.base>e.x,n="left",s="right"):(t=e.base<e.y,n="bottom",s="top"),t?(i="end",a="start"):(i="start",a="end"),{start:n,end:s,reverse:t,top:i,bottom:a}}function i5e(e,t,n,s){let i=t.borderSkipped;const a={};if(!i){e.borderSkipped=a;return}if(i===!0){e.borderSkipped={top:!0,right:!0,bottom:!0,left:!0};return}const{start:o,end:l,reverse:c,top:d,bottom:f}=s5e(e);i==="middle"&&n&&(e.enableBorderRadius=!0,(n._top||0)===s?i=d:(n._bottom||0)===s?i=f:(a[hD(f,o,l,c)]=!0,i=d)),a[hD(i,o,l,c)]=!0,e.borderSkipped=a}function hD(e,t,n,s){return s?(e=r5e(e,t,n),e=fD(e,n,t)):e=fD(e,t,n),e}function r5e(e,t,n){return e===t?n:e===n?t:e}function fD(e,t,n){return e==="start"?t:e==="end"?n:e}function a5e(e,{inflateAmount:t},n){e.inflateAmount=t==="auto"?n===1?.33:0:t}class o5e extends Km{static id="bar";static defaults={datasetElementType:!1,dataElementType:"bar",categoryPercentage:.8,barPercentage:.9,grouped:!0,animations:{numbers:{type:"number",properties:["x","y","base","width","height"]}}};static overrides={scales:{_index_:{type:"category",offset:!0,grid:{offset:!0}},_value_:{type:"linear",beginAtZero:!0}}};parsePrimitiveData(t,n,s,i){return dD(t,n,s,i)}parseArrayData(t,n,s,i){return dD(t,n,s,i)}parseObjectData(t,n,s,i){const{iScale:a,vScale:o}=t,{xAxisKey:l="x",yAxisKey:c="y"}=this._parsing,d=a.axis==="x"?l:c,f=o.axis==="x"?l:c,p=[];let m,g,b,_;for(m=s,g=s+i;m<g;++m)_=n[m],b={},b[a.axis]=a.parse(hu(_,d),m),p.push(sU(hu(_,f),b,o,m));return p}updateRangeFromParsed(t,n,s,i){super.updateRangeFromParsed(t,n,s,i);const a=s._custom;a&&n===this._cachedMeta.vScale&&(t.min=Math.min(t.min,a.min),t.max=Math.max(t.max,a.max))}getMaxOverflow(){return 0}getLabelAndValue(t){const n=this._cachedMeta,{iScale:s,vScale:i}=n,a=this.getParsed(t),o=a._custom,l=EA(o)?"["+o.start+", "+o.end+"]":""+i.getLabelForValue(a[i.axis]);return{label:""+s.getLabelForValue(a[s.axis]),value:l}}initialize(){this.enableOptionSharing=!0,super.initialize();const t=this._cachedMeta;t.stack=this.getDataset().stack}update(t){const n=this._cachedMeta;this.updateElements(n.data,0,n.data.length,t)}updateElements(t,n,s,i){const a=i==="reset",{index:o,_cachedMeta:{vScale:l}}=this,c=l.getBasePixel(),d=l.isHorizontal(),f=this._getRuler(),{sharedOptions:p,includeOptions:m}=this._getSharedOptions(n,i);for(let g=n;g<n+s;g++){const b=this.getParsed(g),_=a||Tt(b[l.axis])?{base:c,head:c}:this._calculateBarValuePixels(g),w=this._calculateBarIndexPixels(g,f),A=(b._stacks||{})[l.axis],S={horizontal:d,base:_.base,enableBorderRadius:!A||EA(b._custom)||o===A._top||o===A._bottom,x:d?_.head:w.center,y:d?w.center:_.head,height:d?w.size:Math.abs(_.size),width:d?Math.abs(_.size):w.size};m&&(S.options=p||this.resolveDataElementOptions(g,t[g].active?"active":i));const C=S.options||t[g].options;i5e(S,C,A,o),a5e(S,C,f.ratio),this.updateElement(t[g],g,S,i)}}_getStacks(t,n){const{iScale:s}=this._cachedMeta,i=s.getMatchingVisibleMetas(this._type).filter(f=>f.controller.options.grouped),a=s.options.stacked,o=[],l=this._cachedMeta.controller.getParsed(n),c=l&&l[s.axis],d=f=>{const p=f._parsed.find(g=>g[s.axis]===c),m=p&&p[f.vScale.axis];if(Tt(m)||isNaN(m))return!0};for(const f of i)if(!(n!==void 0&&d(f))&&((a===!1||o.indexOf(f.stack)===-1||a===void 0&&f.stack===void 0)&&o.push(f.stack),f.index===t))break;return o.length||o.push(void 0),o}_getStackCount(t){return this._getStacks(void 0,t).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){const t=this.chart.scales,n=this.chart.options.indexAxis;return Object.keys(t).filter(s=>t[s].axis===n).shift()}_getAxis(){const t={},n=this.getFirstScaleIdForIndexAxis();for(const s of this.chart.data.datasets)t[it(this.chart.options.indexAxis==="x"?s.xAxisID:s.yAxisID,n)]=!0;return Object.keys(t)}_getStackIndex(t,n,s){const i=this._getStacks(t,s),a=n!==void 0?i.indexOf(n):-1;return a===-1?i.length-1:a}_getRuler(){const t=this.options,n=this._cachedMeta,s=n.iScale,i=[];let a,o;for(a=0,o=n.data.length;a<o;++a)i.push(s.getPixelForValue(this.getParsed(a)[s.axis],a));const l=t.barThickness;return{min:l||JCe(n),pixels:i,start:s._startPixel,end:s._endPixel,stackCount:this._getStackCount(),scale:s,grouped:t.grouped,ratio:l?1:t.categoryPercentage*t.barPercentage}}_calculateBarValuePixels(t){const{_cachedMeta:{vScale:n,_stacked:s,index:i},options:{base:a,minBarLength:o}}=this,l=a||0,c=this.getParsed(t),d=c._custom,f=EA(d);let p=c[n.axis],m=0,g=s?this.applyStack(n,c,s):p,b,_;g!==p&&(m=g-p,g=p),f&&(p=d.barStart,g=d.barEnd-d.barStart,p!==0&&za(p)!==za(d.barEnd)&&(m=0),m+=p);const w=!Tt(a)&&!f?a:m;let A=n.getPixelForValue(w);if(this.chart.getDataVisibility(t)?b=n.getPixelForValue(m+g):b=A,_=b-A,Math.abs(_)<o){_=n5e(_,n,l)*o,p===l&&(A-=_/2);const S=n.getPixelForDecimal(0),C=n.getPixelForDecimal(1),E=Math.min(S,C),k=Math.max(S,C);A=Math.max(Math.min(A,k),E),b=A+_,s&&!f&&(c._stacks[n.axis]._visualValues[i]=n.getValueForPixel(b)-n.getValueForPixel(A))}if(A===n.getPixelForValue(l)){const S=za(_)*n.getLineWidthForValue(l)/2;A+=S,_-=S}return{size:_,base:A,head:b,center:b+_/2}}_calculateBarIndexPixels(t,n){const s=n.scale,i=this.options,a=i.skipNull,o=it(i.maxBarThickness,1/0);let l,c;const d=this._getAxisCount();if(n.grouped){const f=a?this._getStackCount(t):n.stackCount,p=i.barThickness==="flex"?e5e(t,n,i,f*d):ZCe(t,n,i,f*d),m=this.chart.options.indexAxis==="x"?this.getDataset().xAxisID:this.getDataset().yAxisID,g=this._getAxis().indexOf(it(m,this.getFirstScaleIdForIndexAxis())),b=this._getStackIndex(this.index,this._cachedMeta.stack,a?t:void 0)+g;l=p.start+p.chunk*b+p.chunk/2,c=Math.min(o,p.chunk*p.ratio)}else l=s.getPixelForValue(this.getParsed(t)[s.axis],t),c=Math.min(o,n.min*n.ratio);return{base:l-c/2,head:l+c/2,center:l,size:c}}draw(){const t=this._cachedMeta,n=t.vScale,s=t.data,i=s.length;let a=0;for(;a<i;++a)this.getParsed(a)[n.axis]!==null&&!s[a].hidden&&s[a].draw(this._ctx)}}function l5e(e,t,n){let s=1,i=1,a=0,o=0;if(t<_n){const l=e,c=l+t,d=Math.cos(l),f=Math.sin(l),p=Math.cos(c),m=Math.sin(c),g=(C,E,k)=>Yp(C,l,c,!0)?1:Math.max(E,E*n,k,k*n),b=(C,E,k)=>Yp(C,l,c,!0)?-1:Math.min(E,E*n,k,k*n),_=g(0,d,p),w=g(ls,f,m),A=b(Lt,d,p),S=b(Lt+ls,f,m);s=(_-A)/2,i=(w-S)/2,a=-(_+A)/2,o=-(w+S)/2}return{ratioX:s,ratioY:i,offsetX:a,offsetY:o}}class c5e extends Km{static id="doughnut";static defaults={datasetElementType:!1,dataElementType:"arc",animation:{animateRotate:!0,animateScale:!1},animations:{numbers:{type:"number",properties:["circumference","endAngle","innerRadius","outerRadius","startAngle","x","y","offset","borderWidth","spacing"]}},cutout:"50%",rotation:0,circumference:360,radius:"100%",spacing:0,indexAxis:"r"};static descriptors={_scriptable:t=>t!=="spacing",_indexable:t=>t!=="spacing"&&!t.startsWith("borderDash")&&!t.startsWith("hoverBorderDash")};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const n=t.data,{labels:{pointStyle:s,textAlign:i,color:a,useBorderRadius:o,borderRadius:l}}=t.legend.options;return n.labels.length&&n.datasets.length?n.labels.map((c,d)=>{const p=t.getDatasetMeta(0).controller.getStyle(d);return{text:c,fillStyle:p.backgroundColor,fontColor:a,hidden:!t.getDataVisibility(d),lineDash:p.borderDash,lineDashOffset:p.borderDashOffset,lineJoin:p.borderJoinStyle,lineWidth:p.borderWidth,strokeStyle:p.borderColor,textAlign:i,pointStyle:s,borderRadius:o&&(l||p.borderRadius),index:d}}):[]}},onClick(t,n,s){s.chart.toggleDataVisibility(n.index),s.chart.update()}}}};constructor(t,n){super(t,n),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,n){const s=this.getDataset().data,i=this._cachedMeta;if(this._parsing===!1)i._parsed=s;else{let a=c=>+s[c];if(xt(s[t])){const{key:c="value"}=this._parsing;a=d=>+hu(s[d],c)}let o,l;for(o=t,l=t+n;o<l;++o)i._parsed[o]=a(o)}}_getRotation(){return Ao(this.options.rotation-90)}_getCircumference(){return Ao(this.options.circumference)}_getRotationExtents(){let t=_n,n=-_n;for(let s=0;s<this.chart.data.datasets.length;++s)if(this.chart.isDatasetVisible(s)&&this.chart.getDatasetMeta(s).type===this._type){const i=this.chart.getDatasetMeta(s).controller,a=i._getRotation(),o=i._getCircumference();t=Math.min(t,a),n=Math.max(n,a+o)}return{rotation:t,circumference:n-t}}update(t){const n=this.chart,{chartArea:s}=n,i=this._cachedMeta,a=i.data,o=this.getMaxBorderWidth()+this.getMaxOffset(a)+this.options.spacing,l=Math.max((Math.min(s.width,s.height)-o)/2,0),c=Math.min(gSe(this.options.cutout,l),1),d=this._getRingWeight(this.index),{circumference:f,rotation:p}=this._getRotationExtents(),{ratioX:m,ratioY:g,offsetX:b,offsetY:_}=l5e(p,f,c),w=(s.width-o)/m,A=(s.height-o)/g,S=Math.max(Math.min(w,A)/2,0),C=TV(this.options.radius,S),E=Math.max(C*c,0),k=(C-E)/this._getVisibleDatasetWeightTotal();this.offsetX=b*C,this.offsetY=_*C,i.total=this.calculateTotal(),this.outerRadius=C-k*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-k*d,0),this.updateElements(a,0,a.length,t)}_circumference(t,n){const s=this.options,i=this._cachedMeta,a=this._getCircumference();return n&&s.animation.animateRotate||!this.chart.getDataVisibility(t)||i._parsed[t]===null||i.data[t].hidden?0:this.calculateCircumference(i._parsed[t]*a/_n)}updateElements(t,n,s,i){const a=i==="reset",o=this.chart,l=o.chartArea,d=o.options.animation,f=(l.left+l.right)/2,p=(l.top+l.bottom)/2,m=a&&d.animateScale,g=m?0:this.innerRadius,b=m?0:this.outerRadius,{sharedOptions:_,includeOptions:w}=this._getSharedOptions(n,i);let A=this._getRotation(),S;for(S=0;S<n;++S)A+=this._circumference(S,a);for(S=n;S<n+s;++S){const C=this._circumference(S,a),E=t[S],k={x:f+this.offsetX,y:p+this.offsetY,startAngle:A,endAngle:A+C,circumference:C,outerRadius:b,innerRadius:g};w&&(k.options=_||this.resolveDataElementOptions(S,E.active?"active":i)),A+=C,this.updateElement(E,S,k,i)}}calculateTotal(){const t=this._cachedMeta,n=t.data;let s=0,i;for(i=0;i<n.length;i++){const a=t._parsed[i];a!==null&&!isNaN(a)&&this.chart.getDataVisibility(i)&&!n[i].hidden&&(s+=Math.abs(a))}return s}calculateCircumference(t){const n=this._cachedMeta.total;return n>0&&!isNaN(t)?_n*(Math.abs(t)/n):0}getLabelAndValue(t){const n=this._cachedMeta,s=this.chart,i=s.data.labels||[],a=hN(n._parsed[t],s.options.locale);return{label:i[t]||"",value:a}}getMaxBorderWidth(t){let n=0;const s=this.chart;let i,a,o,l,c;if(!t){for(i=0,a=s.data.datasets.length;i<a;++i)if(s.isDatasetVisible(i)){o=s.getDatasetMeta(i),t=o.data,l=o.controller;break}}if(!t)return 0;for(i=0,a=t.length;i<a;++i)c=l.resolveDataElementOptions(i),c.borderAlign!=="inner"&&(n=Math.max(n,c.borderWidth||0,c.hoverBorderWidth||0));return n}getMaxOffset(t){let n=0;for(let s=0,i=t.length;s<i;++s){const a=this.resolveDataElementOptions(s);n=Math.max(n,a.offset||0,a.hoverOffset||0)}return n}_getRingWeightOffset(t){let n=0;for(let s=0;s<t;++s)this.chart.isDatasetVisible(s)&&(n+=this._getRingWeight(s));return n}_getRingWeight(t){return Math.max(it(this.chart.data.datasets[t].weight,1),0)}_getVisibleDatasetWeightTotal(){return this._getRingWeightOffset(this.chart.data.datasets.length)||1}}class u5e extends Km{static id="line";static defaults={datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1};static overrides={scales:{_index_:{type:"category"},_value_:{type:"linear"}}};initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(t){const n=this._cachedMeta,{dataset:s,data:i=[],_dataset:a}=n,o=this.chart._animationsDisabled;let{start:l,count:c}=BV(n,i,o);this._drawStart=l,this._drawCount=c,zV(n)&&(l=0,c=i.length),s._chart=this.chart,s._datasetIndex=this.index,s._decimated=!!a._decimated,s.points=i;const d=this.resolveDatasetElementOptions(t);this.options.showLine||(d.borderWidth=0),d.segment=this.options.segment,this.updateElement(s,void 0,{animated:!o,options:d},t),this.updateElements(i,l,c,t)}updateElements(t,n,s,i){const a=i==="reset",{iScale:o,vScale:l,_stacked:c,_dataset:d}=this._cachedMeta,{sharedOptions:f,includeOptions:p}=this._getSharedOptions(n,i),m=o.axis,g=l.axis,{spanGaps:b,segment:_}=this.options,w=Qd(b)?b:Number.POSITIVE_INFINITY,A=this.chart._animationsDisabled||a||i==="none",S=n+s,C=t.length;let E=n>0&&this.getParsed(n-1);for(let k=0;k<C;++k){const T=t[k],F=A?T:{};if(k<n||k>=S){F.skip=!0;continue}const M=this.getParsed(k),I=Tt(M[g]),R=F[m]=o.getPixelForValue(M[m],k),H=F[g]=a||I?l.getBasePixel():l.getPixelForValue(c?this.applyStack(l,M,c):M[g],k);F.skip=isNaN(R)||isNaN(H)||I,F.stop=k>0&&Math.abs(M[m]-E[m])>w,_&&(F.parsed=M,F.raw=d.data[k]),p&&(F.options=f||this.resolveDataElementOptions(k,T.active?"active":i)),A||this.updateElement(T,k,F,i),E=M}}getMaxOverflow(){const t=this._cachedMeta,n=t.dataset,s=n.options&&n.options.borderWidth||0,i=t.data||[];if(!i.length)return s;const a=i[0].size(this.resolveDataElementOptions(0)),o=i[i.length-1].size(this.resolveDataElementOptions(i.length-1));return Math.max(s,a,o)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}class d5e extends c5e{static id="pie";static defaults={cutout:0,rotation:0,circumference:360,radius:"100%"}}class h5e extends Km{static id="scatter";static defaults={datasetElementType:!1,dataElementType:"point",showLine:!1,fill:!1};static overrides={interaction:{mode:"point"},scales:{x:{type:"linear"},y:{type:"linear"}}};getLabelAndValue(t){const n=this._cachedMeta,s=this.chart.data.labels||[],{xScale:i,yScale:a}=n,o=this.getParsed(t),l=i.getLabelForValue(o.x),c=a.getLabelForValue(o.y);return{label:s[t]||"",value:"("+l+", "+c+")"}}update(t){const n=this._cachedMeta,{data:s=[]}=n,i=this.chart._animationsDisabled;let{start:a,count:o}=BV(n,s,i);if(this._drawStart=a,this._drawCount=o,zV(n)&&(a=0,o=s.length),this.options.showLine){this.datasetElementType||this.addElements();const{dataset:l,_dataset:c}=n;l._chart=this.chart,l._datasetIndex=this.index,l._decimated=!!c._decimated,l.points=s;const d=this.resolveDatasetElementOptions(t);d.segment=this.options.segment,this.updateElement(l,void 0,{animated:!i,options:d},t)}else this.datasetElementType&&(delete n.dataset,this.datasetElementType=!1);this.updateElements(s,a,o,t)}addElements(){const{showLine:t}=this.options;!this.datasetElementType&&t&&(this.datasetElementType=this.chart.registry.getElement("line")),super.addElements()}updateElements(t,n,s,i){const a=i==="reset",{iScale:o,vScale:l,_stacked:c,_dataset:d}=this._cachedMeta,f=this.resolveDataElementOptions(n,i),p=this.getSharedOptions(f),m=this.includeOptions(i,p),g=o.axis,b=l.axis,{spanGaps:_,segment:w}=this.options,A=Qd(_)?_:Number.POSITIVE_INFINITY,S=this.chart._animationsDisabled||a||i==="none";let C=n>0&&this.getParsed(n-1);for(let E=n;E<n+s;++E){const k=t[E],T=this.getParsed(E),F=S?k:{},M=Tt(T[b]),I=F[g]=o.getPixelForValue(T[g],E),R=F[b]=a||M?l.getBasePixel():l.getPixelForValue(c?this.applyStack(l,T,c):T[b],E);F.skip=isNaN(I)||isNaN(R)||M,F.stop=E>0&&Math.abs(T[g]-C[g])>A,w&&(F.parsed=T,F.raw=d.data[E]),m&&(F.options=p||this.resolveDataElementOptions(E,k.active?"active":i)),S||this.updateElement(k,E,F,i),C=T}this.updateSharedOptions(p,i,f)}getMaxOverflow(){const t=this._cachedMeta,n=t.data||[];if(!this.options.showLine){let l=0;for(let c=n.length-1;c>=0;--c)l=Math.max(l,n[c].size(this.resolveDataElementOptions(c))/2);return l>0&&l}const s=t.dataset,i=s.options&&s.options.borderWidth||0;if(!n.length)return i;const a=n[0].size(this.resolveDataElementOptions(0)),o=n[n.length-1].size(this.resolveDataElementOptions(n.length-1));return Math.max(i,a,o)/2}}function Mc(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class vN{static override(t){Object.assign(vN.prototype,t)}options;constructor(t){this.options=t||{}}init(){}formats(){return Mc()}parse(){return Mc()}format(){return Mc()}add(){return Mc()}diff(){return Mc()}startOf(){return Mc()}endOf(){return Mc()}}var f5e={_date:vN};function p5e(e,t,n,s){const{controller:i,data:a,_sorted:o}=e,l=i._cachedMeta.iScale,c=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null;if(l&&t===l.axis&&t!=="r"&&o&&a.length){const d=l._reversePixels?MSe:Gc;if(s){if(i._sharedOptions){const f=a[0],p=typeof f.getRange=="function"&&f.getRange(t);if(p){const m=d(a,t,n-p),g=d(a,t,n+p);return{lo:m.lo,hi:g.hi}}}}else{const f=d(a,t,n);if(c){const{vScale:p}=i._cachedMeta,{_parsed:m}=e,g=m.slice(0,f.lo+1).reverse().findIndex(_=>!Tt(_[p.axis]));f.lo-=Math.max(0,g);const b=m.slice(f.hi).findIndex(_=>!Tt(_[p.axis]));f.hi+=Math.max(0,b)}return f}}return{lo:0,hi:a.length-1}}function dy(e,t,n,s,i){const a=e.getSortedVisibleDatasetMetas(),o=n[t];for(let l=0,c=a.length;l<c;++l){const{index:d,data:f}=a[l],{lo:p,hi:m}=p5e(a[l],t,o,i);for(let g=p;g<=m;++g){const b=f[g];b.skip||s(b,d,g)}}}function m5e(e){const t=e.indexOf("x")!==-1,n=e.indexOf("y")!==-1;return function(s,i){const a=t?Math.abs(s.x-i.x):0,o=n?Math.abs(s.y-i.y):0;return Math.sqrt(Math.pow(a,2)+Math.pow(o,2))}}function FA(e,t,n,s,i){const a=[];return!i&&!e.isPointInArea(t)||dy(e,n,t,function(l,c,d){!i&&!Qp(l,e.chartArea,0)||l.inRange(t.x,t.y,s)&&a.push({element:l,datasetIndex:c,index:d})},!0),a}function x5e(e,t,n,s){let i=[];function a(o,l,c){const{startAngle:d,endAngle:f}=o.getProps(["startAngle","endAngle"],s),{angle:p}=DV(o,{x:t.x,y:t.y});Yp(p,d,f)&&i.push({element:o,datasetIndex:l,index:c})}return dy(e,n,t,a),i}function g5e(e,t,n,s,i,a){let o=[];const l=m5e(n);let c=Number.POSITIVE_INFINITY;function d(f,p,m){const g=f.inRange(t.x,t.y,i);if(s&&!g)return;const b=f.getCenterPoint(i);if(!(!!a||e.isPointInArea(b))&&!g)return;const w=l(t,b);w<c?(o=[{element:f,datasetIndex:p,index:m}],c=w):w===c&&o.push({element:f,datasetIndex:p,index:m})}return dy(e,n,t,d),o}function TA(e,t,n,s,i,a){return!a&&!e.isPointInArea(t)?[]:n==="r"&&!s?x5e(e,t,n,i):g5e(e,t,n,s,i,a)}function pD(e,t,n,s,i){const a=[],o=n==="x"?"inXRange":"inYRange";let l=!1;return dy(e,n,t,(c,d,f)=>{c[o]&&c[o](t[n],i)&&(a.push({element:c,datasetIndex:d,index:f}),l=l||c.inRange(t.x,t.y,i))}),s&&!l?[]:a}var b5e={modes:{index(e,t,n,s){const i=Ic(t,e),a=n.axis||"x",o=n.includeInvisible||!1,l=n.intersect?FA(e,i,a,s,o):TA(e,i,a,!1,s,o),c=[];return l.length?(e.getSortedVisibleDatasetMetas().forEach(d=>{const f=l[0].index,p=d.data[f];p&&!p.skip&&c.push({element:p,datasetIndex:d.index,index:f})}),c):[]},dataset(e,t,n,s){const i=Ic(t,e),a=n.axis||"xy",o=n.includeInvisible||!1;let l=n.intersect?FA(e,i,a,s,o):TA(e,i,a,!1,s,o);if(l.length>0){const c=l[0].datasetIndex,d=e.getDatasetMeta(c).data;l=[];for(let f=0;f<d.length;++f)l.push({element:d[f],datasetIndex:c,index:f})}return l},point(e,t,n,s){const i=Ic(t,e),a=n.axis||"xy",o=n.includeInvisible||!1;return FA(e,i,a,s,o)},nearest(e,t,n,s){const i=Ic(t,e),a=n.axis||"xy",o=n.includeInvisible||!1;return TA(e,i,a,n.intersect,s,o)},x(e,t,n,s){const i=Ic(t,e);return pD(e,i,"x",n.intersect,s)},y(e,t,n,s){const i=Ic(t,e);return pD(e,i,"y",n.intersect,s)}}};const iU=["left","top","right","bottom"];function If(e,t){return e.filter(n=>n.pos===t)}function mD(e,t){return e.filter(n=>iU.indexOf(n.pos)===-1&&n.box.axis===t)}function Lf(e,t){return e.sort((n,s)=>{const i=t?s:n,a=t?n:s;return i.weight===a.weight?i.index-a.index:i.weight-a.weight})}function v5e(e){const t=[];let n,s,i,a,o,l;for(n=0,s=(e||[]).length;n<s;++n)i=e[n],{position:a,options:{stack:o,stackWeight:l=1}}=i,t.push({index:n,box:i,pos:a,horizontal:i.isHorizontal(),weight:i.weight,stack:o&&a+o,stackWeight:l});return t}function y5e(e){const t={};for(const n of e){const{stack:s,pos:i,stackWeight:a}=n;if(!s||!iU.includes(i))continue;const o=t[s]||(t[s]={count:0,placed:0,weight:0,size:0});o.count++,o.weight+=a}return t}function _5e(e,t){const n=y5e(e),{vBoxMaxWidth:s,hBoxMaxHeight:i}=t;let a,o,l;for(a=0,o=e.length;a<o;++a){l=e[a];const{fullSize:c}=l.box,d=n[l.stack],f=d&&l.stackWeight/d.weight;l.horizontal?(l.width=f?f*s:c&&t.availableWidth,l.height=i):(l.width=s,l.height=f?f*i:c&&t.availableHeight)}return n}function w5e(e){const t=v5e(e),n=Lf(t.filter(d=>d.box.fullSize),!0),s=Lf(If(t,"left"),!0),i=Lf(If(t,"right")),a=Lf(If(t,"top"),!0),o=Lf(If(t,"bottom")),l=mD(t,"x"),c=mD(t,"y");return{fullSize:n,leftAndTop:s.concat(a),rightAndBottom:i.concat(c).concat(o).concat(l),chartArea:If(t,"chartArea"),vertical:s.concat(i).concat(c),horizontal:a.concat(o).concat(l)}}function xD(e,t,n,s){return Math.max(e[n],t[n])+Math.max(e[s],t[s])}function rU(e,t){e.top=Math.max(e.top,t.top),e.left=Math.max(e.left,t.left),e.bottom=Math.max(e.bottom,t.bottom),e.right=Math.max(e.right,t.right)}function A5e(e,t,n,s){const{pos:i,box:a}=n,o=e.maxPadding;if(!xt(i)){n.size&&(e[i]-=n.size);const p=s[n.stack]||{size:0,count:1};p.size=Math.max(p.size,n.horizontal?a.height:a.width),n.size=p.size/p.count,e[i]+=n.size}a.getPadding&&rU(o,a.getPadding());const l=Math.max(0,t.outerWidth-xD(o,e,"left","right")),c=Math.max(0,t.outerHeight-xD(o,e,"top","bottom")),d=l!==e.w,f=c!==e.h;return e.w=l,e.h=c,n.horizontal?{same:d,other:f}:{same:f,other:d}}function S5e(e){const t=e.maxPadding;function n(s){const i=Math.max(t[s]-e[s],0);return e[s]+=i,i}e.y+=n("top"),e.x+=n("left"),n("right"),n("bottom")}function C5e(e,t){const n=t.maxPadding;function s(i){const a={left:0,top:0,right:0,bottom:0};return i.forEach(o=>{a[o]=Math.max(t[o],n[o])}),a}return s(e?["left","right"]:["top","bottom"])}function ep(e,t,n,s){const i=[];let a,o,l,c,d,f;for(a=0,o=e.length,d=0;a<o;++a){l=e[a],c=l.box,c.update(l.width||t.w,l.height||t.h,C5e(l.horizontal,t));const{same:p,other:m}=A5e(t,n,l,s);d|=p&&i.length,f=f||m,c.fullSize||i.push(l)}return d&&ep(i,t,n,s)||f}function Qg(e,t,n,s,i){e.top=n,e.left=t,e.right=t+s,e.bottom=n+i,e.width=s,e.height=i}function gD(e,t,n,s){const i=n.padding;let{x:a,y:o}=t;for(const l of e){const c=l.box,d=s[l.stack]||{placed:0,weight:1},f=l.stackWeight/d.weight||1;if(l.horizontal){const p=t.w*f,m=d.size||c.height;Kp(d.start)&&(o=d.start),c.fullSize?Qg(c,i.left,o,n.outerWidth-i.right-i.left,m):Qg(c,t.left+d.placed,o,p,m),d.start=o,d.placed+=p,o=c.bottom}else{const p=t.h*f,m=d.size||c.width;Kp(d.start)&&(a=d.start),c.fullSize?Qg(c,a,i.top,m,n.outerHeight-i.bottom-i.top):Qg(c,a,t.top+d.placed,m,p),d.start=a,d.placed+=p,a=c.right}}t.x=a,t.y=o}var Tr={addBox(e,t){e.boxes||(e.boxes=[]),t.fullSize=t.fullSize||!1,t.position=t.position||"top",t.weight=t.weight||0,t._layers=t._layers||function(){return[{z:0,draw(n){t.draw(n)}}]},e.boxes.push(t)},removeBox(e,t){const n=e.boxes?e.boxes.indexOf(t):-1;n!==-1&&e.boxes.splice(n,1)},configure(e,t,n){t.fullSize=n.fullSize,t.position=n.position,t.weight=n.weight},update(e,t,n,s){if(!e)return;const i=Lr(e.options.layout.padding),a=Math.max(t-i.width,0),o=Math.max(n-i.height,0),l=w5e(e.boxes),c=l.vertical,d=l.horizontal;It(e.boxes,_=>{typeof _.beforeLayout=="function"&&_.beforeLayout()});const f=c.reduce((_,w)=>w.box.options&&w.box.options.display===!1?_:_+1,0)||1,p=Object.freeze({outerWidth:t,outerHeight:n,padding:i,availableWidth:a,availableHeight:o,vBoxMaxWidth:a/2/f,hBoxMaxHeight:o/2}),m=Object.assign({},i);rU(m,Lr(s));const g=Object.assign({maxPadding:m,w:a,h:o,x:i.left,y:i.top},i),b=_5e(c.concat(d),p);ep(l.fullSize,g,p,b),ep(c,g,p,b),ep(d,g,p,b)&&ep(c,g,p,b),S5e(g),gD(l.leftAndTop,g,p,b),g.x+=g.w,g.y+=g.h,gD(l.rightAndBottom,g,p,b),e.chartArea={left:g.left,top:g.top,right:g.left+g.w,bottom:g.top+g.h,height:g.h,width:g.w},It(l.chartArea,_=>{const w=_.box;Object.assign(w,e.chartArea),w.update(g.w,g.h,{left:0,top:0,right:0,bottom:0})})}};class aU{acquireContext(t,n){}releaseContext(t){return!1}addEventListener(t,n,s){}removeEventListener(t,n,s){}getDevicePixelRatio(){return 1}getMaximumSize(t,n,s,i){return n=Math.max(0,n||t.width),s=s||t.height,{width:n,height:Math.max(0,i?Math.floor(n/i):s)}}isAttached(t){return!0}updateConfig(t){}}class j5e extends aU{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const Vb="$chartjs",N5e={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},bD=e=>e===null||e==="";function k5e(e,t){const n=e.style,s=e.getAttribute("height"),i=e.getAttribute("width");if(e[Vb]={initial:{height:s,width:i,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||"block",n.boxSizing=n.boxSizing||"border-box",bD(i)){const a=tD(e,"width");a!==void 0&&(e.width=a)}if(bD(s))if(e.style.height==="")e.height=e.width/(t||2);else{const a=tD(e,"height");a!==void 0&&(e.height=a)}return e}const oU=CCe?{passive:!0}:!1;function E5e(e,t,n){e&&e.addEventListener(t,n,oU)}function F5e(e,t,n){e&&e.canvas&&e.canvas.removeEventListener(t,n,oU)}function T5e(e,t){const n=N5e[e.type]||e.type,{x:s,y:i}=Ic(e,t);return{type:n,chart:t,native:e,x:s!==void 0?s:null,y:i!==void 0?i:null}}function V0(e,t){for(const n of e)if(n===t||n.contains(t))return!0}function M5e(e,t,n){const s=e.canvas,i=new MutationObserver(a=>{let o=!1;for(const l of a)o=o||V0(l.addedNodes,s),o=o&&!V0(l.removedNodes,s);o&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}function R5e(e,t,n){const s=e.canvas,i=new MutationObserver(a=>{let o=!1;for(const l of a)o=o||V0(l.removedNodes,s),o=o&&!V0(l.addedNodes,s);o&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}const Jp=new Map;let vD=0;function lU(){const e=window.devicePixelRatio;e!==vD&&(vD=e,Jp.forEach((t,n)=>{n.currentDevicePixelRatio!==e&&t()}))}function D5e(e,t){Jp.size||window.addEventListener("resize",lU),Jp.set(e,t)}function O5e(e){Jp.delete(e),Jp.size||window.removeEventListener("resize",lU)}function P5e(e,t,n){const s=e.canvas,i=s&&bN(s);if(!i)return;const a=LV((l,c)=>{const d=i.clientWidth;n(l,c),d<i.clientWidth&&n()},window),o=new ResizeObserver(l=>{const c=l[0],d=c.contentRect.width,f=c.contentRect.height;d===0&&f===0||a(d,f)});return o.observe(i),D5e(e,a),o}function MA(e,t,n){n&&n.disconnect(),t==="resize"&&O5e(e)}function I5e(e,t,n){const s=e.canvas,i=LV(a=>{e.ctx!==null&&n(T5e(a,e))},e);return E5e(s,t,i),i}class L5e extends aU{acquireContext(t,n){const s=t&&t.getContext&&t.getContext("2d");return s&&s.canvas===t?(k5e(t,n),s):null}releaseContext(t){const n=t.canvas;if(!n[Vb])return!1;const s=n[Vb].initial;["height","width"].forEach(a=>{const o=s[a];Tt(o)?n.removeAttribute(a):n.setAttribute(a,o)});const i=s.style||{};return Object.keys(i).forEach(a=>{n.style[a]=i[a]}),n.width=n.width,delete n[Vb],!0}addEventListener(t,n,s){this.removeEventListener(t,n);const i=t.$proxies||(t.$proxies={}),o={attach:M5e,detach:R5e,resize:P5e}[n]||I5e;i[n]=o(t,n,s)}removeEventListener(t,n){const s=t.$proxies||(t.$proxies={}),i=s[n];if(!i)return;({attach:MA,detach:MA,resize:MA}[n]||F5e)(t,n,i),s[n]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,n,s,i){return SCe(t,n,s,i)}isAttached(t){const n=t&&bN(t);return!!(n&&n.isConnected)}}function B5e(e){return!gN()||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas?j5e:L5e}let Wo=class{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(t){const{x:n,y:s}=this.getProps(["x","y"],t);return{x:n,y:s}}hasValue(){return Qd(this.x)&&Qd(this.y)}getProps(t,n){const s=this.$animations;if(!n||!s)return this;const i={};return t.forEach(a=>{i[a]=s[a]&&s[a].active()?s[a]._to:this[a]}),i}};function z5e(e,t){const n=e.options.ticks,s=$5e(e),i=Math.min(n.maxTicksLimit||s,s),a=n.major.enabled?U5e(t):[],o=a.length,l=a[0],c=a[o-1],d=[];if(o>i)return H5e(t,d,a,o/i),d;const f=V5e(a,t,i);if(o>0){let p,m;const g=o>1?Math.round((c-l)/(o-1)):null;for(Xg(t,d,f,Tt(g)?0:l-g,l),p=0,m=o-1;p<m;p++)Xg(t,d,f,a[p],a[p+1]);return Xg(t,d,f,c,Tt(g)?t.length:c+g),d}return Xg(t,d,f),d}function $5e(e){const t=e.options.offset,n=e._tickSize(),s=e._length/n+(t?0:1),i=e._maxLength/n;return Math.floor(Math.min(s,i))}function V5e(e,t,n){const s=W5e(e),i=t.length/n;if(!s)return Math.max(i,1);const a=CSe(s);for(let o=0,l=a.length-1;o<l;o++){const c=a[o];if(c>i)return c}return Math.max(i,1)}function U5e(e){const t=[];let n,s;for(n=0,s=e.length;n<s;n++)e[n].major&&t.push(n);return t}function H5e(e,t,n,s){let i=0,a=n[0],o;for(s=Math.ceil(s),o=0;o<e.length;o++)o===a&&(t.push(e[o]),i++,a=n[i*s])}function Xg(e,t,n,s,i){const a=it(s,0),o=Math.min(it(i,e.length),e.length);let l=0,c,d,f;for(n=Math.ceil(n),i&&(c=i-s,n=c/Math.floor(c/n)),f=a;f<0;)l++,f=Math.round(a+l*n);for(d=Math.max(a,0);d<o;d++)d===f&&(t.push(e[d]),l++,f=Math.round(a+l*n))}function W5e(e){const t=e.length;let n,s;if(t<2)return!1;for(s=e[0],n=1;n<t;++n)if(e[n]-e[n-1]!==s)return!1;return s}const q5e=e=>e==="left"?"right":e==="right"?"left":e,yD=(e,t,n)=>t==="top"||t==="left"?e[t]+n:e[t]-n,_D=(e,t)=>Math.min(t||e,e);function wD(e,t){const n=[],s=e.length/t,i=e.length;let a=0;for(;a<i;a+=s)n.push(e[Math.floor(a)]);return n}function G5e(e,t,n){const s=e.ticks.length,i=Math.min(t,s-1),a=e._startPixel,o=e._endPixel,l=1e-6;let c=e.getPixelForTick(i),d;if(!(n&&(s===1?d=Math.max(c-a,o-c):t===0?d=(e.getPixelForTick(1)-c)/2:d=(c-e.getPixelForTick(i-1))/2,c+=i<t?d:-d,c<a-l||c>o+l)))return c}function K5e(e,t){It(e,n=>{const s=n.gc,i=s.length/2;let a;if(i>t){for(a=0;a<i;++a)delete n.data[s[a]];s.splice(0,i)}})}function Bf(e){return e.drawTicks?e.tickLength:0}function AD(e,t){if(!e.display)return 0;const n=qs(e.font,t),s=Lr(e.padding);return(Wn(e.text)?e.text.length:1)*n.lineHeight+s.height}function Y5e(e,t){return wu(e,{scale:t,type:"scale"})}function Q5e(e,t,n){return wu(e,{tick:n,index:t,type:"tick"})}function X5e(e,t,n){let s=uN(e);return(n&&t!=="right"||!n&&t==="right")&&(s=q5e(s)),s}function J5e(e,t,n,s){const{top:i,left:a,bottom:o,right:l,chart:c}=e,{chartArea:d,scales:f}=c;let p=0,m,g,b;const _=o-i,w=l-a;if(e.isHorizontal()){if(g=zs(s,a,l),xt(n)){const A=Object.keys(n)[0],S=n[A];b=f[A].getPixelForValue(S)+_-t}else n==="center"?b=(d.bottom+d.top)/2+_-t:b=yD(e,n,t);m=l-a}else{if(xt(n)){const A=Object.keys(n)[0],S=n[A];g=f[A].getPixelForValue(S)-w+t}else n==="center"?g=(d.left+d.right)/2-w+t:g=yD(e,n,t);b=zs(s,o,i),p=n==="left"?-ls:ls}return{titleX:g,titleY:b,maxWidth:m,rotation:p}}class Ah extends Wo{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,n){return t}getUserBounds(){let{_userMin:t,_userMax:n,_suggestedMin:s,_suggestedMax:i}=this;return t=ya(t,Number.POSITIVE_INFINITY),n=ya(n,Number.NEGATIVE_INFINITY),s=ya(s,Number.POSITIVE_INFINITY),i=ya(i,Number.NEGATIVE_INFINITY),{min:ya(t,s),max:ya(n,i),minDefined:Js(t),maxDefined:Js(n)}}getMinMax(t){let{min:n,max:s,minDefined:i,maxDefined:a}=this.getUserBounds(),o;if(i&&a)return{min:n,max:s};const l=this.getMatchingVisibleMetas();for(let c=0,d=l.length;c<d;++c)o=l[c].controller.getMinMax(this,t),i||(n=Math.min(n,o.min)),a||(s=Math.max(s,o.max));return n=a&&n>s?s:n,s=i&&n>s?n:s,{min:ya(n,ya(s,n)),max:ya(s,ya(n,s))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}getLabelItems(t=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(t))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){rn(this.options.beforeUpdate,[this])}update(t,n,s){const{beginAtZero:i,grace:a,ticks:o}=this.options,l=o.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=n,this._margins=s=Object.assign({left:0,right:0,top:0,bottom:0},s),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+s.left+s.right:this.height+s.top+s.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=nCe(this,a,i),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const c=l<this.ticks.length;this._convertTicksToLabels(c?wD(this.ticks,l):this.ticks),this.configure(),this.beforeCalculateLabelRotation(),this.calculateLabelRotation(),this.afterCalculateLabelRotation(),o.display&&(o.autoSkip||o.source==="auto")&&(this.ticks=z5e(this,this.ticks),this._labelSizes=null,this.afterAutoSkip()),c&&this._convertTicksToLabels(this.ticks),this.beforeFit(),this.fit(),this.afterFit(),this.afterUpdate()}configure(){let t=this.options.reverse,n,s;this.isHorizontal()?(n=this.left,s=this.right):(n=this.top,s=this.bottom,t=!t),this._startPixel=n,this._endPixel=s,this._reversePixels=t,this._length=s-n,this._alignToPixels=this.options.alignToPixels}afterUpdate(){rn(this.options.afterUpdate,[this])}beforeSetDimensions(){rn(this.options.beforeSetDimensions,[this])}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=0,this.right=this.width):(this.height=this.maxHeight,this.top=0,this.bottom=this.height),this.paddingLeft=0,this.paddingTop=0,this.paddingRight=0,this.paddingBottom=0}afterSetDimensions(){rn(this.options.afterSetDimensions,[this])}_callHooks(t){this.chart.notifyPlugins(t,this.getContext()),rn(this.options[t],[this])}beforeDataLimits(){this._callHooks("beforeDataLimits")}determineDataLimits(){}afterDataLimits(){this._callHooks("afterDataLimits")}beforeBuildTicks(){this._callHooks("beforeBuildTicks")}buildTicks(){return[]}afterBuildTicks(){this._callHooks("afterBuildTicks")}beforeTickToLabelConversion(){rn(this.options.beforeTickToLabelConversion,[this])}generateTickLabels(t){const n=this.options.ticks;let s,i,a;for(s=0,i=t.length;s<i;s++)a=t[s],a.label=rn(n.callback,[a.value,s,t],this)}afterTickToLabelConversion(){rn(this.options.afterTickToLabelConversion,[this])}beforeCalculateLabelRotation(){rn(this.options.beforeCalculateLabelRotation,[this])}calculateLabelRotation(){const t=this.options,n=t.ticks,s=_D(this.ticks.length,t.ticks.maxTicksLimit),i=n.minRotation||0,a=n.maxRotation;let o=i,l,c,d;if(!this._isVisible()||!n.display||i>=a||s<=1||!this.isHorizontal()){this.labelRotation=i;return}const f=this._getLabelSizes(),p=f.widest.width,m=f.highest.height,g=Ws(this.chart.width-p,0,this.maxWidth);l=t.offset?this.maxWidth/s:g/(s-1),p+6>l&&(l=g/(s-(t.offset?.5:1)),c=this.maxHeight-Bf(t.grid)-n.padding-AD(t.title,this.chart.options.font),d=Math.sqrt(p*p+m*m),o=ESe(Math.min(Math.asin(Ws((f.highest.height+6)/l,-1,1)),Math.asin(Ws(c/d,-1,1))-Math.asin(Ws(m/d,-1,1)))),o=Math.max(i,Math.min(a,o))),this.labelRotation=o}afterCalculateLabelRotation(){rn(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){rn(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:n,options:{ticks:s,title:i,grid:a}}=this,o=this._isVisible(),l=this.isHorizontal();if(o){const c=AD(i,n.options.font);if(l?(t.width=this.maxWidth,t.height=Bf(a)+c):(t.height=this.maxHeight,t.width=Bf(a)+c),s.display&&this.ticks.length){const{first:d,last:f,widest:p,highest:m}=this._getLabelSizes(),g=s.padding*2,b=Ao(this.labelRotation),_=Math.cos(b),w=Math.sin(b);if(l){const A=s.mirror?0:w*p.width+_*m.height;t.height=Math.min(this.maxHeight,t.height+A+g)}else{const A=s.mirror?0:_*p.width+w*m.height;t.width=Math.min(this.maxWidth,t.width+A+g)}this._calculatePadding(d,f,w,_)}}this._handleMargins(),l?(this.width=this._length=n.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=n.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,n,s,i){const{ticks:{align:a,padding:o},position:l}=this.options,c=this.labelRotation!==0,d=l!=="top"&&this.axis==="x";if(this.isHorizontal()){const f=this.getPixelForTick(0)-this.left,p=this.right-this.getPixelForTick(this.ticks.length-1);let m=0,g=0;c?d?(m=i*t.width,g=s*n.height):(m=s*t.height,g=i*n.width):a==="start"?g=n.width:a==="end"?m=t.width:a!=="inner"&&(m=t.width/2,g=n.width/2),this.paddingLeft=Math.max((m-f+o)*this.width/(this.width-f),0),this.paddingRight=Math.max((g-p+o)*this.width/(this.width-p),0)}else{let f=n.height/2,p=t.height/2;a==="start"?(f=0,p=t.height):a==="end"&&(f=n.height,p=0),this.paddingTop=f+o,this.paddingBottom=p+o}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){rn(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:n}=this.options;return n==="top"||n==="bottom"||t==="x"}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){this.beforeTickToLabelConversion(),this.generateTickLabels(t);let n,s;for(n=0,s=t.length;n<s;n++)Tt(t[n].label)&&(t.splice(n,1),s--,n--);this.afterTickToLabelConversion()}_getLabelSizes(){let t=this._labelSizes;if(!t){const n=this.options.ticks.sampleSize;let s=this.ticks;n<s.length&&(s=wD(s,n)),this._labelSizes=t=this._computeLabelSizes(s,s.length,this.options.ticks.maxTicksLimit)}return t}_computeLabelSizes(t,n,s){const{ctx:i,_longestTextCache:a}=this,o=[],l=[],c=Math.floor(n/_D(n,s));let d=0,f=0,p,m,g,b,_,w,A,S,C,E,k;for(p=0;p<n;p+=c){if(b=t[p].label,_=this._resolveTickFontOptions(p),i.font=w=_.string,A=a[w]=a[w]||{data:{},gc:[]},S=_.lineHeight,C=E=0,!Tt(b)&&!Wn(b))C=QR(i,A.data,A.gc,C,b),E=S;else if(Wn(b))for(m=0,g=b.length;m<g;++m)k=b[m],!Tt(k)&&!Wn(k)&&(C=QR(i,A.data,A.gc,C,k),E+=S);o.push(C),l.push(E),d=Math.max(C,d),f=Math.max(E,f)}K5e(a,n);const T=o.indexOf(d),F=l.indexOf(f),M=I=>({width:o[I]||0,height:l[I]||0});return{first:M(0),last:M(n-1),widest:M(T),highest:M(F),widths:o,heights:l}}getLabelForValue(t){return t}getPixelForValue(t,n){return NaN}getValueForPixel(t){}getPixelForTick(t){const n=this.ticks;return t<0||t>n.length-1?null:this.getPixelForValue(n[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);const n=this._startPixel+t*this._length;return TSe(this._alignToPixels?Tc(this.chart,n,0):n)}getDecimalForPixel(t){const n=(t-this._startPixel)/this._length;return this._reversePixels?1-n:n}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:n}=this;return t<0&&n<0?n:t>0&&n>0?t:0}getContext(t){const n=this.ticks||[];if(t>=0&&t<n.length){const s=n[t];return s.$context||(s.$context=Q5e(this.getContext(),t,s))}return this.$context||(this.$context=Y5e(this.chart.getContext(),this))}_tickSize(){const t=this.options.ticks,n=Ao(this.labelRotation),s=Math.abs(Math.cos(n)),i=Math.abs(Math.sin(n)),a=this._getLabelSizes(),o=t.autoSkipPadding||0,l=a?a.widest.width+o:0,c=a?a.highest.height+o:0;return this.isHorizontal()?c*s>l*i?l/s:c/i:c*i<l*s?c/s:l/i}_isVisible(){const t=this.options.display;return t!=="auto"?!!t:this.getMatchingVisibleMetas().length>0}_computeGridLineItems(t){const n=this.axis,s=this.chart,i=this.options,{grid:a,position:o,border:l}=i,c=a.offset,d=this.isHorizontal(),p=this.ticks.length+(c?1:0),m=Bf(a),g=[],b=l.setContext(this.getContext()),_=b.display?b.width:0,w=_/2,A=function(B){return Tc(s,B,_)};let S,C,E,k,T,F,M,I,R,H,V,K;if(o==="top")S=A(this.bottom),F=this.bottom-m,I=S-w,H=A(t.top)+w,K=t.bottom;else if(o==="bottom")S=A(this.top),H=t.top,K=A(t.bottom)-w,F=S+w,I=this.top+m;else if(o==="left")S=A(this.right),T=this.right-m,M=S-w,R=A(t.left)+w,V=t.right;else if(o==="right")S=A(this.left),R=t.left,V=A(t.right)-w,T=S+w,M=this.left+m;else if(n==="x"){if(o==="center")S=A((t.top+t.bottom)/2+.5);else if(xt(o)){const B=Object.keys(o)[0],Y=o[B];S=A(this.chart.scales[B].getPixelForValue(Y))}H=t.top,K=t.bottom,F=S+w,I=F+m}else if(n==="y"){if(o==="center")S=A((t.left+t.right)/2);else if(xt(o)){const B=Object.keys(o)[0],Y=o[B];S=A(this.chart.scales[B].getPixelForValue(Y))}T=S-w,M=T-m,R=t.left,V=t.right}const q=it(i.ticks.maxTicksLimit,p),$=Math.max(1,Math.ceil(p/q));for(C=0;C<p;C+=$){const B=this.getContext(C),Y=a.setContext(B),U=l.setContext(B),W=Y.lineWidth,O=Y.color,D=U.dash||[],Q=U.dashOffset,z=Y.tickWidth,J=Y.tickColor,ee=Y.tickBorderDash||[],re=Y.tickBorderDashOffset;E=G5e(this,C,c),E!==void 0&&(k=Tc(s,E,W),d?T=M=R=V=k:F=I=H=K=k,g.push({tx1:T,ty1:F,tx2:M,ty2:I,x1:R,y1:H,x2:V,y2:K,width:W,color:O,borderDash:D,borderDashOffset:Q,tickWidth:z,tickColor:J,tickBorderDash:ee,tickBorderDashOffset:re}))}return this._ticksLength=p,this._borderValue=S,g}_computeLabelItems(t){const n=this.axis,s=this.options,{position:i,ticks:a}=s,o=this.isHorizontal(),l=this.ticks,{align:c,crossAlign:d,padding:f,mirror:p}=a,m=Bf(s.grid),g=m+f,b=p?-f:g,_=-Ao(this.labelRotation),w=[];let A,S,C,E,k,T,F,M,I,R,H,V,K="middle";if(i==="top")T=this.bottom-b,F=this._getXAxisLabelAlignment();else if(i==="bottom")T=this.top+b,F=this._getXAxisLabelAlignment();else if(i==="left"){const $=this._getYAxisLabelAlignment(m);F=$.textAlign,k=$.x}else if(i==="right"){const $=this._getYAxisLabelAlignment(m);F=$.textAlign,k=$.x}else if(n==="x"){if(i==="center")T=(t.top+t.bottom)/2+g;else if(xt(i)){const $=Object.keys(i)[0],B=i[$];T=this.chart.scales[$].getPixelForValue(B)+g}F=this._getXAxisLabelAlignment()}else if(n==="y"){if(i==="center")k=(t.left+t.right)/2-g;else if(xt(i)){const $=Object.keys(i)[0],B=i[$];k=this.chart.scales[$].getPixelForValue(B)}F=this._getYAxisLabelAlignment(m).textAlign}n==="y"&&(c==="start"?K="top":c==="end"&&(K="bottom"));const q=this._getLabelSizes();for(A=0,S=l.length;A<S;++A){C=l[A],E=C.label;const $=a.setContext(this.getContext(A));M=this.getPixelForTick(A)+a.labelOffset,I=this._resolveTickFontOptions(A),R=I.lineHeight,H=Wn(E)?E.length:1;const B=H/2,Y=$.color,U=$.textStrokeColor,W=$.textStrokeWidth;let O=F;o?(k=M,F==="inner"&&(A===S-1?O=this.options.reverse?"left":"right":A===0?O=this.options.reverse?"right":"left":O="center"),i==="top"?d==="near"||_!==0?V=-H*R+R/2:d==="center"?V=-q.highest.height/2-B*R+R:V=-q.highest.height+R/2:d==="near"||_!==0?V=R/2:d==="center"?V=q.highest.height/2-B*R:V=q.highest.height-H*R,p&&(V*=-1),_!==0&&!$.showLabelBackdrop&&(k+=R/2*Math.sin(_))):(T=M,V=(1-H)*R/2);let D;if($.showLabelBackdrop){const Q=Lr($.backdropPadding),z=q.heights[A],J=q.widths[A];let ee=V-Q.top,re=0-Q.left;switch(K){case"middle":ee-=z/2;break;case"bottom":ee-=z;break}switch(F){case"center":re-=J/2;break;case"right":re-=J;break;case"inner":A===S-1?re-=J:A>0&&(re-=J/2);break}D={left:re,top:ee,width:J+Q.width,height:z+Q.height,color:$.backdropColor}}w.push({label:E,font:I,textOffset:V,options:{rotation:_,color:Y,strokeColor:U,strokeWidth:W,textAlign:O,textBaseline:K,translation:[k,T],backdrop:D}})}return w}_getXAxisLabelAlignment(){const{position:t,ticks:n}=this.options;if(-Ao(this.labelRotation))return t==="top"?"left":"right";let i="center";return n.align==="start"?i="left":n.align==="end"?i="right":n.align==="inner"&&(i="inner"),i}_getYAxisLabelAlignment(t){const{position:n,ticks:{crossAlign:s,mirror:i,padding:a}}=this.options,o=this._getLabelSizes(),l=t+a,c=o.widest.width;let d,f;return n==="left"?i?(f=this.right+a,s==="near"?d="left":s==="center"?(d="center",f+=c/2):(d="right",f+=c)):(f=this.right-l,s==="near"?d="right":s==="center"?(d="center",f-=c/2):(d="left",f=this.left)):n==="right"?i?(f=this.left+a,s==="near"?d="right":s==="center"?(d="center",f-=c/2):(d="left",f-=c)):(f=this.left+l,s==="near"?d="left":s==="center"?(d="center",f+=c/2):(d="right",f=this.right)):d="right",{textAlign:d,x:f}}_computeLabelArea(){if(this.options.ticks.mirror)return;const t=this.chart,n=this.options.position;if(n==="left"||n==="right")return{top:0,left:this.left,bottom:t.height,right:this.right};if(n==="top"||n==="bottom")return{top:this.top,left:0,bottom:this.bottom,right:t.width}}drawBackground(){const{ctx:t,options:{backgroundColor:n},left:s,top:i,width:a,height:o}=this;n&&(t.save(),t.fillStyle=n,t.fillRect(s,i,a,o),t.restore())}getLineWidthForValue(t){const n=this.options.grid;if(!this._isVisible()||!n.display)return 0;const i=this.ticks.findIndex(a=>a.value===t);return i>=0?n.setContext(this.getContext(i)).lineWidth:0}drawGrid(t){const n=this.options.grid,s=this.ctx,i=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let a,o;const l=(c,d,f)=>{!f.width||!f.color||(s.save(),s.lineWidth=f.width,s.strokeStyle=f.color,s.setLineDash(f.borderDash||[]),s.lineDashOffset=f.borderDashOffset,s.beginPath(),s.moveTo(c.x,c.y),s.lineTo(d.x,d.y),s.stroke(),s.restore())};if(n.display)for(a=0,o=i.length;a<o;++a){const c=i[a];n.drawOnChartArea&&l({x:c.x1,y:c.y1},{x:c.x2,y:c.y2},c),n.drawTicks&&l({x:c.tx1,y:c.ty1},{x:c.tx2,y:c.ty2},{color:c.tickColor,width:c.tickWidth,borderDash:c.tickBorderDash,borderDashOffset:c.tickBorderDashOffset})}}drawBorder(){const{chart:t,ctx:n,options:{border:s,grid:i}}=this,a=s.setContext(this.getContext()),o=s.display?a.width:0;if(!o)return;const l=i.setContext(this.getContext(0)).lineWidth,c=this._borderValue;let d,f,p,m;this.isHorizontal()?(d=Tc(t,this.left,o)-o/2,f=Tc(t,this.right,l)+l/2,p=m=c):(p=Tc(t,this.top,o)-o/2,m=Tc(t,this.bottom,l)+l/2,d=f=c),n.save(),n.lineWidth=a.width,n.strokeStyle=a.color,n.beginPath(),n.moveTo(d,p),n.lineTo(f,m),n.stroke(),n.restore()}drawLabels(t){if(!this.options.ticks.display)return;const s=this.ctx,i=this._computeLabelArea();i&&ly(s,i);const a=this.getLabelItems(t);for(const o of a){const l=o.options,c=o.font,d=o.label,f=o.textOffset;Xp(s,d,0,f,c,l)}i&&cy(s)}drawTitle(){const{ctx:t,options:{position:n,title:s,reverse:i}}=this;if(!s.display)return;const a=qs(s.font),o=Lr(s.padding),l=s.align;let c=a.lineHeight/2;n==="bottom"||n==="center"||xt(n)?(c+=o.bottom,Wn(s.text)&&(c+=a.lineHeight*(s.text.length-1))):c+=o.top;const{titleX:d,titleY:f,maxWidth:p,rotation:m}=J5e(this,c,n,l);Xp(t,s.text,0,0,a,{color:s.color,maxWidth:p,rotation:m,textAlign:X5e(l,n,i),textBaseline:"middle",translation:[d,f]})}draw(t){this._isVisible()&&(this.drawBackground(),this.drawGrid(t),this.drawBorder(),this.drawTitle(),this.drawLabels(t))}_layers(){const t=this.options,n=t.ticks&&t.ticks.z||0,s=it(t.grid&&t.grid.z,-1),i=it(t.border&&t.border.z,0);return!this._isVisible()||this.draw!==Ah.prototype.draw?[{z:n,draw:a=>{this.draw(a)}}]:[{z:s,draw:a=>{this.drawBackground(),this.drawGrid(a),this.drawTitle()}},{z:i,draw:()=>{this.drawBorder()}},{z:n,draw:a=>{this.drawLabels(a)}}]}getMatchingVisibleMetas(t){const n=this.chart.getSortedVisibleDatasetMetas(),s=this.axis+"AxisID",i=[];let a,o;for(a=0,o=n.length;a<o;++a){const l=n[a];l[s]===this.id&&(!t||l.type===t)&&i.push(l)}return i}_resolveTickFontOptions(t){const n=this.options.ticks.setContext(this.getContext(t));return qs(n.font)}_maxDigits(){const t=this._resolveTickFontOptions(0).lineHeight;return(this.isHorizontal()?this.width:this.height)/t}}class Jg{constructor(t,n,s){this.type=t,this.scope=n,this.override=s,this.items=Object.create(null)}isForType(t){return Object.prototype.isPrototypeOf.call(this.type.prototype,t.prototype)}register(t){const n=Object.getPrototypeOf(t);let s;tje(n)&&(s=this.register(n));const i=this.items,a=t.id,o=this.scope+"."+a;if(!a)throw new Error("class does not have id: "+t);return a in i||(i[a]=t,Z5e(t,o,s),this.override&&Rn.override(t.id,t.overrides)),o}get(t){return this.items[t]}unregister(t){const n=this.items,s=t.id,i=this.scope;s in n&&delete n[s],i&&s in Rn[i]&&(delete Rn[i][s],this.override&&delete fu[s])}}function Z5e(e,t,n){const s=Gp(Object.create(null),[n?Rn.get(n):{},Rn.get(t),e.defaults]);Rn.set(t,s),e.defaultRoutes&&eje(t,e.defaultRoutes),e.descriptors&&Rn.describe(t,e.descriptors)}function eje(e,t){Object.keys(t).forEach(n=>{const s=n.split("."),i=s.pop(),a=[e].concat(s).join("."),o=t[n].split("."),l=o.pop(),c=o.join(".");Rn.route(a,i,c,l)})}function tje(e){return"id"in e&&"defaults"in e}let nje=class{constructor(){this.controllers=new Jg(Km,"datasets",!0),this.elements=new Jg(Wo,"elements"),this.plugins=new Jg(Object,"plugins"),this.scales=new Jg(Ah,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,n,s){[...n].forEach(i=>{const a=s||this._getRegistryForType(i);s||a.isForType(i)||a===this.plugins&&i.id?this._exec(t,a,i):It(i,o=>{const l=s||this._getRegistryForType(o);this._exec(t,l,o)})})}_exec(t,n,s){const i=lN(t);rn(s["before"+i],[],s),n[t](s),rn(s["after"+i],[],s)}_getRegistryForType(t){for(let n=0;n<this._typedRegistries.length;n++){const s=this._typedRegistries[n];if(s.isForType(t))return s}return this.plugins}_get(t,n,s){const i=n.get(t);if(i===void 0)throw new Error('"'+t+'" is not a registered '+s+".");return i}};var Na=new nje;class sje{constructor(){this._init=void 0}notify(t,n,s,i){if(n==="beforeInit"&&(this._init=this._createDescriptors(t,!0),this._notify(this._init,t,"install")),this._init===void 0)return;const a=i?this._descriptors(t).filter(i):this._descriptors(t),o=this._notify(a,t,n,s);return n==="afterDestroy"&&(this._notify(a,t,"stop"),this._notify(this._init,t,"uninstall"),this._init=void 0),o}_notify(t,n,s,i){i=i||{};for(const a of t){const o=a.plugin,l=o[s],c=[n,i,a.options];if(rn(l,c,o)===!1&&i.cancelable)return!1}return!0}invalidate(){Tt(this._cache)||(this._oldCache=this._cache,this._cache=void 0)}_descriptors(t){if(this._cache)return this._cache;const n=this._cache=this._createDescriptors(t);return this._notifyStateChanges(t),n}_createDescriptors(t,n){const s=t&&t.config,i=it(s.options&&s.options.plugins,{}),a=ije(s);return i===!1&&!n?[]:aje(t,a,i,n)}_notifyStateChanges(t){const n=this._oldCache||[],s=this._cache,i=(a,o)=>a.filter(l=>!o.some(c=>l.plugin.id===c.plugin.id));this._notify(i(n,s),t,"stop"),this._notify(i(s,n),t,"start")}}function ije(e){const t={},n=[],s=Object.keys(Na.plugins.items);for(let a=0;a<s.length;a++)n.push(Na.getPlugin(s[a]));const i=e.plugins||[];for(let a=0;a<i.length;a++){const o=i[a];n.indexOf(o)===-1&&(n.push(o),t[o.id]=!0)}return{plugins:n,localIds:t}}function rje(e,t){return!t&&e===!1?null:e===!0?{}:e}function aje(e,{plugins:t,localIds:n},s,i){const a=[],o=e.getContext();for(const l of t){const c=l.id,d=rje(s[c],i);d!==null&&a.push({plugin:l,options:oje(e.config,{plugin:l,local:n[c]},d,o)})}return a}function oje(e,{plugin:t,local:n},s,i){const a=e.pluginScopeKeys(t),o=e.getOptionScopes(s,a);return n&&t.defaults&&o.push(t.defaults),e.createResolver(o,i,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function hC(e,t){const n=Rn.datasets[e]||{};return((t.datasets||{})[e]||{}).indexAxis||t.indexAxis||n.indexAxis||"x"}function lje(e,t){let n=e;return e==="_index_"?n=t:e==="_value_"&&(n=t==="x"?"y":"x"),n}function cje(e,t){return e===t?"_index_":"_value_"}function SD(e){if(e==="x"||e==="y"||e==="r")return e}function uje(e){if(e==="top"||e==="bottom")return"x";if(e==="left"||e==="right")return"y"}function fC(e,...t){if(SD(e))return e;for(const n of t){const s=n.axis||uje(n.position)||e.length>1&&SD(e[0].toLowerCase());if(s)return s}throw new Error(`Cannot determine type of '${e}' axis. Please provide 'axis' or 'position' option.`)}function CD(e,t,n){if(n[t+"AxisID"]===e)return{axis:t}}function dje(e,t){if(t.data&&t.data.datasets){const n=t.data.datasets.filter(s=>s.xAxisID===e||s.yAxisID===e);if(n.length)return CD(e,"x",n[0])||CD(e,"y",n[0])}return{}}function hje(e,t){const n=fu[e.type]||{scales:{}},s=t.scales||{},i=hC(e.type,t),a=Object.create(null);return Object.keys(s).forEach(o=>{const l=s[o];if(!xt(l))return console.error(`Invalid scale configuration for scale: ${o}`);if(l._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${o}`);const c=fC(o,l,dje(o,e),Rn.scales[l.type]),d=cje(c,i),f=n.scales||{};a[o]=xp(Object.create(null),[{axis:c},l,f[c],f[d]])}),e.data.datasets.forEach(o=>{const l=o.type||e.type,c=o.indexAxis||hC(l,t),f=(fu[l]||{}).scales||{};Object.keys(f).forEach(p=>{const m=lje(p,c),g=o[m+"AxisID"]||m;a[g]=a[g]||Object.create(null),xp(a[g],[{axis:m},s[g],f[p]])})}),Object.keys(a).forEach(o=>{const l=a[o];xp(l,[Rn.scales[l.type],Rn.scale])}),a}function cU(e){const t=e.options||(e.options={});t.plugins=it(t.plugins,{}),t.scales=hje(e,t)}function uU(e){return e=e||{},e.datasets=e.datasets||[],e.labels=e.labels||[],e}function fje(e){return e=e||{},e.data=uU(e.data),cU(e),e}const jD=new Map,dU=new Set;function Zg(e,t){let n=jD.get(e);return n||(n=t(),jD.set(e,n),dU.add(n)),n}const zf=(e,t,n)=>{const s=hu(t,n);s!==void 0&&e.add(s)};class pje{constructor(t){this._config=fje(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=uU(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){const t=this._config;this.clearCache(),cU(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return Zg(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,n){return Zg(`${t}.transition.${n}`,()=>[[`datasets.${t}.transitions.${n}`,`transitions.${n}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,n){return Zg(`${t}-${n}`,()=>[[`datasets.${t}.elements.${n}`,`datasets.${t}`,`elements.${n}`,""]])}pluginScopeKeys(t){const n=t.id,s=this.type;return Zg(`${s}-plugin-${n}`,()=>[[`plugins.${n}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,n){const s=this._scopeCache;let i=s.get(t);return(!i||n)&&(i=new Map,s.set(t,i)),i}getOptionScopes(t,n,s){const{options:i,type:a}=this,o=this._cachedScopes(t,s),l=o.get(n);if(l)return l;const c=new Set;n.forEach(f=>{t&&(c.add(t),f.forEach(p=>zf(c,t,p))),f.forEach(p=>zf(c,i,p)),f.forEach(p=>zf(c,fu[a]||{},p)),f.forEach(p=>zf(c,Rn,p)),f.forEach(p=>zf(c,uC,p))});const d=Array.from(c);return d.length===0&&d.push(Object.create(null)),dU.has(n)&&o.set(n,d),d}chartOptionScopes(){const{options:t,type:n}=this;return[t,fu[n]||{},Rn.datasets[n]||{},{type:n},Rn,uC]}resolveNamedOptions(t,n,s,i=[""]){const a={$shared:!0},{resolver:o,subPrefixes:l}=ND(this._resolverCache,t,i);let c=o;if(xje(o,n)){a.$shared=!1,s=Ql(s)?s():s;const d=this.createResolver(t,s,l);c=Xd(o,s,d)}for(const d of n)a[d]=c[d];return a}createResolver(t,n,s=[""],i){const{resolver:a}=ND(this._resolverCache,t,s);return xt(n)?Xd(a,n,void 0,i):a}}function ND(e,t,n){let s=e.get(t);s||(s=new Map,e.set(t,s));const i=n.join();let a=s.get(i);return a||(a={resolver:pN(t,n),subPrefixes:n.filter(l=>!l.toLowerCase().includes("hover"))},s.set(i,a)),a}const mje=e=>xt(e)&&Object.getOwnPropertyNames(e).some(t=>Ql(e[t]));function xje(e,t){const{isScriptable:n,isIndexable:s}=HV(e);for(const i of t){const a=n(i),o=s(i),l=(o||a)&&e[i];if(a&&(Ql(l)||mje(l))||o&&Wn(l))return!0}return!1}var gje="4.5.1";const bje=["top","bottom","left","right","chartArea"];function kD(e,t){return e==="top"||e==="bottom"||bje.indexOf(e)===-1&&t==="x"}function ED(e,t){return function(n,s){return n[e]===s[e]?n[t]-s[t]:n[e]-s[e]}}function FD(e){const t=e.chart,n=t.options.animation;t.notifyPlugins("afterRender"),rn(n&&n.onComplete,[e],t)}function vje(e){const t=e.chart,n=t.options.animation;rn(n&&n.onProgress,[e],t)}function hU(e){return gN()&&typeof e=="string"?e=document.getElementById(e):e&&e.length&&(e=e[0]),e&&e.canvas&&(e=e.canvas),e}const Ub={},TD=e=>{const t=hU(e);return Object.values(Ub).filter(n=>n.canvas===t).pop()};function yje(e,t,n){const s=Object.keys(e);for(const i of s){const a=+i;if(a>=t){const o=e[i];delete e[i],(n>0||a>t)&&(e[a+n]=o)}}}function _je(e,t,n,s){return!n||e.type==="mouseout"?null:s?t:e}let hy=class{static defaults=Rn;static instances=Ub;static overrides=fu;static registry=Na;static version=gje;static getChart=TD;static register(...t){Na.add(...t),MD()}static unregister(...t){Na.remove(...t),MD()}constructor(t,n){const s=this.config=new pje(n),i=hU(t),a=TD(i);if(a)throw new Error("Canvas is already in use. Chart with ID '"+a.id+"' must be destroyed before the canvas with ID '"+a.canvas.id+"' can be reused.");const o=s.createResolver(s.chartOptionScopes(),this.getContext());this.platform=new(s.platform||B5e(i)),this.platform.updateConfig(s);const l=this.platform.acquireContext(i,o.aspectRatio),c=l&&l.canvas,d=c&&c.height,f=c&&c.width;if(this.id=xSe(),this.ctx=l,this.canvas=c,this.width=f,this.height=d,this._options=o,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new sje,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=OSe(p=>this.update(p),o.resizeDelay||0),this._dataChanges=[],Ub[this.id]=this,!l||!c){console.error("Failed to create chart: can't acquire context from the given item");return}vo.listen(this,"complete",FD),vo.listen(this,"progress",vje),this._initialize(),this.attached&&this.update()}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:n},width:s,height:i,_aspectRatio:a}=this;return Tt(t)?n&&a?a:i?s/i:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}get registry(){return Na}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():eD(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return XR(this.canvas,this.ctx),this}stop(){return vo.stop(this),this}resize(t,n){vo.running(this)?this._resizeBeforeDraw={width:t,height:n}:this._resize(t,n)}_resize(t,n){const s=this.options,i=this.canvas,a=s.maintainAspectRatio&&this.aspectRatio,o=this.platform.getMaximumSize(i,t,n,a),l=s.devicePixelRatio||this.platform.getDevicePixelRatio(),c=this.width?"resize":"attach";this.width=o.width,this.height=o.height,this._aspectRatio=this.aspectRatio,eD(this,l,!0)&&(this.notifyPlugins("resize",{size:o}),rn(s.onResize,[this,o],this),this.attached&&this._doResize(c)&&this.render())}ensureScalesHaveIDs(){const n=this.options.scales||{};It(n,(s,i)=>{s.id=i})}buildOrUpdateScales(){const t=this.options,n=t.scales,s=this.scales,i=Object.keys(s).reduce((o,l)=>(o[l]=!1,o),{});let a=[];n&&(a=a.concat(Object.keys(n).map(o=>{const l=n[o],c=fC(o,l),d=c==="r",f=c==="x";return{options:l,dposition:d?"chartArea":f?"bottom":"left",dtype:d?"radialLinear":f?"category":"linear"}}))),It(a,o=>{const l=o.options,c=l.id,d=fC(c,l),f=it(l.type,o.dtype);(l.position===void 0||kD(l.position,d)!==kD(o.dposition))&&(l.position=o.dposition),i[c]=!0;let p=null;if(c in s&&s[c].type===f)p=s[c];else{const m=Na.getScale(f);p=new m({id:c,type:f,ctx:this.ctx,chart:this}),s[p.id]=p}p.init(l,t)}),It(i,(o,l)=>{o||delete s[l]}),It(s,o=>{Tr.configure(this,o,o.options),Tr.addBox(this,o)})}_updateMetasets(){const t=this._metasets,n=this.data.datasets.length,s=t.length;if(t.sort((i,a)=>i.index-a.index),s>n){for(let i=n;i<s;++i)this._destroyDatasetMeta(i);t.splice(n,s-n)}this._sortedMetasets=t.slice(0).sort(ED("order","index"))}_removeUnreferencedMetasets(){const{_metasets:t,data:{datasets:n}}=this;t.length>n.length&&delete this._stacks,t.forEach((s,i)=>{n.filter(a=>a===s._dataset).length===0&&this._destroyDatasetMeta(i)})}buildOrUpdateControllers(){const t=[],n=this.data.datasets;let s,i;for(this._removeUnreferencedMetasets(),s=0,i=n.length;s<i;s++){const a=n[s];let o=this.getDatasetMeta(s);const l=a.type||this.config.type;if(o.type&&o.type!==l&&(this._destroyDatasetMeta(s),o=this.getDatasetMeta(s)),o.type=l,o.indexAxis=a.indexAxis||hC(l,this.options),o.order=a.order||0,o.index=s,o.label=""+a.label,o.visible=this.isDatasetVisible(s),o.controller)o.controller.updateIndex(s),o.controller.linkScales();else{const c=Na.getController(l),{datasetElementType:d,dataElementType:f}=Rn.datasets[l];Object.assign(c,{dataElementType:Na.getElement(f),datasetElementType:d&&Na.getElement(d)}),o.controller=new c(this,s),t.push(o.controller)}}return this._updateMetasets(),t}_resetElements(){It(this.data.datasets,(t,n)=>{this.getDatasetMeta(n).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const n=this.config;n.update();const s=this._options=n.createResolver(n.chartOptionScopes(),this.getContext()),i=this._animationsDisabled=!s.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0})===!1)return;const a=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let o=0;for(let d=0,f=this.data.datasets.length;d<f;d++){const{controller:p}=this.getDatasetMeta(d),m=!i&&a.indexOf(p)===-1;p.buildOrUpdateElements(m),o=Math.max(+p.getMaxOverflow(),o)}o=this._minPadding=s.layout.autoPadding?o:0,this._updateLayout(o),i||It(a,d=>{d.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(ED("z","_idx"));const{_active:l,_lastEvent:c}=this;c?this._eventHandler(c,!0):l.length&&this._updateHoverStyles(l,l,!0),this.render()}_updateScales(){It(this.scales,t=>{Tr.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,n=new Set(Object.keys(this._listeners)),s=new Set(t.events);(!$R(n,s)||!!this._responsiveListeners!==t.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,n=this._getUniformDataChanges()||[];for(const{method:s,start:i,count:a}of n){const o=s==="_removeElements"?-a:a;yje(t,i,o)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const n=this.data.datasets.length,s=a=>new Set(t.filter(o=>o[0]===a).map((o,l)=>l+","+o.splice(1).join(","))),i=s(0);for(let a=1;a<n;a++)if(!$R(i,s(a)))return;return Array.from(i).map(a=>a.split(",")).map(a=>({method:a[1],start:+a[2],count:+a[3]}))}_updateLayout(t){if(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;Tr.update(this,this.width,this.height,t);const n=this.chartArea,s=n.width<=0||n.height<=0;this._layers=[],It(this.boxes,i=>{s&&i.position==="chartArea"||(i.configure&&i.configure(),this._layers.push(...i._layers()))},this),this._layers.forEach((i,a)=>{i._idx=a}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})!==!1){for(let n=0,s=this.data.datasets.length;n<s;++n)this.getDatasetMeta(n).controller.configure();for(let n=0,s=this.data.datasets.length;n<s;++n)this._updateDataset(n,Ql(t)?t({datasetIndex:n}):t);this.notifyPlugins("afterDatasetsUpdate",{mode:t})}}_updateDataset(t,n){const s=this.getDatasetMeta(t),i={meta:s,index:t,mode:n,cancelable:!0};this.notifyPlugins("beforeDatasetUpdate",i)!==!1&&(s.controller._update(n),i.cancelable=!1,this.notifyPlugins("afterDatasetUpdate",i))}render(){this.notifyPlugins("beforeRender",{cancelable:!0})!==!1&&(vo.has(this)?this.attached&&!vo.running(this)&&vo.start(this):(this.draw(),FD({chart:this})))}draw(){let t;if(this._resizeBeforeDraw){const{width:s,height:i}=this._resizeBeforeDraw;this._resizeBeforeDraw=null,this._resize(s,i)}if(this.clear(),this.width<=0||this.height<=0||this.notifyPlugins("beforeDraw",{cancelable:!0})===!1)return;const n=this._layers;for(t=0;t<n.length&&n[t].z<=0;++t)n[t].draw(this.chartArea);for(this._drawDatasets();t<n.length;++t)n[t].draw(this.chartArea);this.notifyPlugins("afterDraw")}_getSortedDatasetMetas(t){const n=this._sortedMetasets,s=[];let i,a;for(i=0,a=n.length;i<a;++i){const o=n[i];(!t||o.visible)&&s.push(o)}return s}getSortedVisibleDatasetMetas(){return this._getSortedDatasetMetas(!0)}_drawDatasets(){if(this.notifyPlugins("beforeDatasetsDraw",{cancelable:!0})===!1)return;const t=this.getSortedVisibleDatasetMetas();for(let n=t.length-1;n>=0;--n)this._drawDataset(t[n]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const n=this.ctx,s={meta:t,index:t.index,cancelable:!0},i=eU(this,t);this.notifyPlugins("beforeDatasetDraw",s)!==!1&&(i&&ly(n,i),t.controller.draw(),i&&cy(n),s.cancelable=!1,this.notifyPlugins("afterDatasetDraw",s))}isPointInArea(t){return Qp(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,n,s,i){const a=b5e.modes[n];return typeof a=="function"?a(this,t,s,i):[]}getDatasetMeta(t){const n=this.data.datasets[t],s=this._metasets;let i=s.filter(a=>a&&a._dataset===n).pop();return i||(i={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:n&&n.order||0,index:t,_dataset:n,_parsed:[],_sorted:!1},s.push(i)),i}getContext(){return this.$context||(this.$context=wu(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const n=this.data.datasets[t];if(!n)return!1;const s=this.getDatasetMeta(t);return typeof s.hidden=="boolean"?!s.hidden:!n.hidden}setDatasetVisibility(t,n){const s=this.getDatasetMeta(t);s.hidden=!n}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,n,s){const i=s?"show":"hide",a=this.getDatasetMeta(t),o=a.controller._resolveAnimations(void 0,i);Kp(n)?(a.data[n].hidden=!s,this.update()):(this.setDatasetVisibility(t,s),o.update(a,{visible:s}),this.update(l=>l.datasetIndex===t?i:void 0))}hide(t,n){this._updateVisibility(t,n,!1)}show(t,n){this._updateVisibility(t,n,!0)}_destroyDatasetMeta(t){const n=this._metasets[t];n&&n.controller&&n.controller._destroy(),delete this._metasets[t]}_stop(){let t,n;for(this.stop(),vo.remove(this),t=0,n=this.data.datasets.length;t<n;++t)this._destroyDatasetMeta(t)}destroy(){this.notifyPlugins("beforeDestroy");const{canvas:t,ctx:n}=this;this._stop(),this.config.clearCache(),t&&(this.unbindEvents(),XR(t,n),this.platform.releaseContext(n),this.canvas=null,this.ctx=null),delete Ub[this.id],this.notifyPlugins("afterDestroy")}toBase64Image(...t){return this.canvas.toDataURL(...t)}bindEvents(){this.bindUserEvents(),this.options.responsive?this.bindResponsiveEvents():this.attached=!0}bindUserEvents(){const t=this._listeners,n=this.platform,s=(a,o)=>{n.addEventListener(this,a,o),t[a]=o},i=(a,o,l)=>{a.offsetX=o,a.offsetY=l,this._eventHandler(a)};It(this.options.events,a=>s(a,i))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,n=this.platform,s=(c,d)=>{n.addEventListener(this,c,d),t[c]=d},i=(c,d)=>{t[c]&&(n.removeEventListener(this,c,d),delete t[c])},a=(c,d)=>{this.canvas&&this.resize(c,d)};let o;const l=()=>{i("attach",l),this.attached=!0,this.resize(),s("resize",a),s("detach",o)};o=()=>{this.attached=!1,i("resize",a),this._stop(),this._resize(0,0),s("attach",l)},n.isAttached(this.canvas)?l():o()}unbindEvents(){It(this._listeners,(t,n)=>{this.platform.removeEventListener(this,n,t)}),this._listeners={},It(this._responsiveListeners,(t,n)=>{this.platform.removeEventListener(this,n,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,n,s){const i=s?"set":"remove";let a,o,l,c;for(n==="dataset"&&(a=this.getDatasetMeta(t[0].datasetIndex),a.controller["_"+i+"DatasetHoverStyle"]()),l=0,c=t.length;l<c;++l){o=t[l];const d=o&&this.getDatasetMeta(o.datasetIndex).controller;d&&d[i+"HoverStyle"](o.element,o.datasetIndex,o.index)}}getActiveElements(){return this._active||[]}setActiveElements(t){const n=this._active||[],s=t.map(({datasetIndex:a,index:o})=>{const l=this.getDatasetMeta(a);if(!l)throw new Error("No dataset found at index "+a);return{datasetIndex:a,element:l.data[o],index:o}});!I0(s,n)&&(this._active=s,this._lastEvent=null,this._updateHoverStyles(s,n))}notifyPlugins(t,n,s){return this._plugins.notify(this,t,n,s)}isPluginEnabled(t){return this._plugins._cache.filter(n=>n.plugin.id===t).length===1}_updateHoverStyles(t,n,s){const i=this.options.hover,a=(c,d)=>c.filter(f=>!d.some(p=>f.datasetIndex===p.datasetIndex&&f.index===p.index)),o=a(n,t),l=s?t:a(t,n);o.length&&this.updateHoverStyle(o,i.mode,!1),l.length&&i.mode&&this.updateHoverStyle(l,i.mode,!0)}_eventHandler(t,n){const s={event:t,replay:n,cancelable:!0,inChartArea:this.isPointInArea(t)},i=o=>(o.options.events||this.options.events).includes(t.native.type);if(this.notifyPlugins("beforeEvent",s,i)===!1)return;const a=this._handleEvent(t,n,s.inChartArea);return s.cancelable=!1,this.notifyPlugins("afterEvent",s,i),(a||s.changed)&&this.render(),this}_handleEvent(t,n,s){const{_active:i=[],options:a}=this,o=n,l=this._getActiveElements(t,i,s,o),c=wSe(t),d=_je(t,this._lastEvent,s,c);s&&(this._lastEvent=null,rn(a.onHover,[t,l,this],this),c&&rn(a.onClick,[t,l,this],this));const f=!I0(l,i);return(f||n)&&(this._active=l,this._updateHoverStyles(l,i,n)),this._lastEvent=d,f}_getActiveElements(t,n,s,i){if(t.type==="mouseout")return[];if(!s)return n;const a=this.options.hover;return this.getElementsAtEventForMode(t,a.mode,a,i)}};function MD(){return It(hy.instances,e=>e._plugins.invalidate())}function wje(e,t,n){const{startAngle:s,x:i,y:a,outerRadius:o,innerRadius:l,options:c}=t,{borderWidth:d,borderJoinStyle:f}=c,p=Math.min(d/o,Wi(s-n));if(e.beginPath(),e.arc(i,a,o-d/2,s+p/2,n-p/2),l>0){const m=Math.min(d/l,Wi(s-n));e.arc(i,a,l+d/2,n-m/2,s+m/2,!0)}else{const m=Math.min(d/2,o*Wi(s-n));if(f==="round")e.arc(i,a,m,n-Lt/2,s+Lt/2,!0);else if(f==="bevel"){const g=2*m*m,b=-g*Math.cos(n+Lt/2)+i,_=-g*Math.sin(n+Lt/2)+a,w=g*Math.cos(s+Lt/2)+i,A=g*Math.sin(s+Lt/2)+a;e.lineTo(b,_),e.lineTo(w,A)}}e.closePath(),e.moveTo(0,0),e.rect(0,0,e.canvas.width,e.canvas.height),e.clip("evenodd")}function Aje(e,t,n){const{startAngle:s,pixelMargin:i,x:a,y:o,outerRadius:l,innerRadius:c}=t;let d=i/l;e.beginPath(),e.arc(a,o,l,s-d,n+d),c>i?(d=i/c,e.arc(a,o,c,n+d,s-d,!0)):e.arc(a,o,i,n+ls,s-ls),e.closePath(),e.clip()}function Sje(e){return fN(e,["outerStart","outerEnd","innerStart","innerEnd"])}function Cje(e,t,n,s){const i=Sje(e.options.borderRadius),a=(n-t)/2,o=Math.min(a,s*t/2),l=c=>{const d=(n-Math.min(a,c))*s/2;return Ws(c,0,Math.min(a,d))};return{outerStart:l(i.outerStart),outerEnd:l(i.outerEnd),innerStart:Ws(i.innerStart,0,o),innerEnd:Ws(i.innerEnd,0,o)}}function gd(e,t,n,s){return{x:n+e*Math.cos(t),y:s+e*Math.sin(t)}}function U0(e,t,n,s,i,a){const{x:o,y:l,startAngle:c,pixelMargin:d,innerRadius:f}=t,p=Math.max(t.outerRadius+s+n-d,0),m=f>0?f+s+n+d:0;let g=0;const b=i-c;if(s){const $=f>0?f-s:0,B=p>0?p-s:0,Y=($+B)/2,U=Y!==0?b*Y/(Y+s):b;g=(b-U)/2}const _=Math.max(.001,b*p-n/Lt)/p,w=(b-_)/2,A=c+w+g,S=i-w-g,{outerStart:C,outerEnd:E,innerStart:k,innerEnd:T}=Cje(t,m,p,S-A),F=p-C,M=p-E,I=A+C/F,R=S-E/M,H=m+k,V=m+T,K=A+k/H,q=S-T/V;if(e.beginPath(),a){const $=(I+R)/2;if(e.arc(o,l,p,I,$),e.arc(o,l,p,$,R),E>0){const W=gd(M,R,o,l);e.arc(W.x,W.y,E,R,S+ls)}const B=gd(V,S,o,l);if(e.lineTo(B.x,B.y),T>0){const W=gd(V,q,o,l);e.arc(W.x,W.y,T,S+ls,q+Math.PI)}const Y=(S-T/m+(A+k/m))/2;if(e.arc(o,l,m,S-T/m,Y,!0),e.arc(o,l,m,Y,A+k/m,!0),k>0){const W=gd(H,K,o,l);e.arc(W.x,W.y,k,K+Math.PI,A-ls)}const U=gd(F,A,o,l);if(e.lineTo(U.x,U.y),C>0){const W=gd(F,I,o,l);e.arc(W.x,W.y,C,A-ls,I)}}else{e.moveTo(o,l);const $=Math.cos(I)*p+o,B=Math.sin(I)*p+l;e.lineTo($,B);const Y=Math.cos(R)*p+o,U=Math.sin(R)*p+l;e.lineTo(Y,U)}e.closePath()}function jje(e,t,n,s,i){const{fullCircles:a,startAngle:o,circumference:l}=t;let c=t.endAngle;if(a){U0(e,t,n,s,c,i);for(let d=0;d<a;++d)e.fill();isNaN(l)||(c=o+(l%_n||_n))}return U0(e,t,n,s,c,i),e.fill(),c}function Nje(e,t,n,s,i){const{fullCircles:a,startAngle:o,circumference:l,options:c}=t,{borderWidth:d,borderJoinStyle:f,borderDash:p,borderDashOffset:m,borderRadius:g}=c,b=c.borderAlign==="inner";if(!d)return;e.setLineDash(p||[]),e.lineDashOffset=m,b?(e.lineWidth=d*2,e.lineJoin=f||"round"):(e.lineWidth=d,e.lineJoin=f||"bevel");let _=t.endAngle;if(a){U0(e,t,n,s,_,i);for(let w=0;w<a;++w)e.stroke();isNaN(l)||(_=o+(l%_n||_n))}b&&Aje(e,t,_),c.selfJoin&&_-o>=Lt&&g===0&&f!=="miter"&&wje(e,t,_),a||(U0(e,t,n,s,_,i),e.stroke())}class kje extends Wo{static id="arc";static defaults={borderAlign:"center",borderColor:"#fff",borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0,selfJoin:!1};static defaultRoutes={backgroundColor:"backgroundColor"};static descriptors={_scriptable:!0,_indexable:t=>t!=="borderDash"};circumference;endAngle;fullCircles;innerRadius;outerRadius;pixelMargin;startAngle;constructor(t){super(),this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,t&&Object.assign(this,t)}inRange(t,n,s){const i=this.getProps(["x","y"],s),{angle:a,distance:o}=DV(i,{x:t,y:n}),{startAngle:l,endAngle:c,innerRadius:d,outerRadius:f,circumference:p}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],s),m=(this.options.spacing+this.options.borderWidth)/2,g=it(p,c-l),b=Yp(a,l,c)&&l!==c,_=g>=_n||b,w=So(o,d+m,f+m);return _&&w}getCenterPoint(t){const{x:n,y:s,startAngle:i,endAngle:a,innerRadius:o,outerRadius:l}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],t),{offset:c,spacing:d}=this.options,f=(i+a)/2,p=(o+l+d+c)/2;return{x:n+Math.cos(f)*p,y:s+Math.sin(f)*p}}tooltipPosition(t){return this.getCenterPoint(t)}draw(t){const{options:n,circumference:s}=this,i=(n.offset||0)/4,a=(n.spacing||0)/2,o=n.circular;if(this.pixelMargin=n.borderAlign==="inner"?.33:0,this.fullCircles=s>_n?Math.floor(s/_n):0,s===0||this.innerRadius<0||this.outerRadius<0)return;t.save();const l=(this.startAngle+this.endAngle)/2;t.translate(Math.cos(l)*i,Math.sin(l)*i);const c=1-Math.sin(Math.min(Lt,s||0)),d=i*c;t.fillStyle=n.backgroundColor,t.strokeStyle=n.borderColor,jje(t,this,d,a,o),Nje(t,this,d,a,o),t.restore()}}function fU(e,t,n=t){e.lineCap=it(n.borderCapStyle,t.borderCapStyle),e.setLineDash(it(n.borderDash,t.borderDash)),e.lineDashOffset=it(n.borderDashOffset,t.borderDashOffset),e.lineJoin=it(n.borderJoinStyle,t.borderJoinStyle),e.lineWidth=it(n.borderWidth,t.borderWidth),e.strokeStyle=it(n.borderColor,t.borderColor)}function Eje(e,t,n){e.lineTo(n.x,n.y)}function Fje(e){return e.stepped?GSe:e.tension||e.cubicInterpolationMode==="monotone"?KSe:Eje}function pU(e,t,n={}){const s=e.length,{start:i=0,end:a=s-1}=n,{start:o,end:l}=t,c=Math.max(i,o),d=Math.min(a,l),f=i<o&&a<o||i>l&&a>l;return{count:s,start:c,loop:t.loop,ilen:d<c&&!f?s+d-c:d-c}}function Tje(e,t,n,s){const{points:i,options:a}=t,{count:o,start:l,loop:c,ilen:d}=pU(i,n,s),f=Fje(a);let{move:p=!0,reverse:m}=s||{},g,b,_;for(g=0;g<=d;++g)b=i[(l+(m?d-g:g))%o],!b.skip&&(p?(e.moveTo(b.x,b.y),p=!1):f(e,_,b,m,a.stepped),_=b);return c&&(b=i[(l+(m?d:0))%o],f(e,_,b,m,a.stepped)),!!c}function Mje(e,t,n,s){const i=t.points,{count:a,start:o,ilen:l}=pU(i,n,s),{move:c=!0,reverse:d}=s||{};let f=0,p=0,m,g,b,_,w,A;const S=E=>(o+(d?l-E:E))%a,C=()=>{_!==w&&(e.lineTo(f,w),e.lineTo(f,_),e.lineTo(f,A))};for(c&&(g=i[S(0)],e.moveTo(g.x,g.y)),m=0;m<=l;++m){if(g=i[S(m)],g.skip)continue;const E=g.x,k=g.y,T=E|0;T===b?(k<_?_=k:k>w&&(w=k),f=(p*f+E)/++p):(C(),e.lineTo(E,k),b=T,p=0,_=w=k),A=k}C()}function pC(e){const t=e.options,n=t.borderDash&&t.borderDash.length;return!e._decimated&&!e._loop&&!t.tension&&t.cubicInterpolationMode!=="monotone"&&!t.stepped&&!n?Mje:Tje}function Rje(e){return e.stepped?jCe:e.tension||e.cubicInterpolationMode==="monotone"?NCe:Lc}function Dje(e,t,n,s){let i=t._path;i||(i=t._path=new Path2D,t.path(i,n,s)&&i.closePath()),fU(e,t.options),e.stroke(i)}function Oje(e,t,n,s){const{segments:i,options:a}=t,o=pC(t);for(const l of i)fU(e,a,l.style),e.beginPath(),o(e,t,l,{start:n,end:n+s-1})&&e.closePath(),e.stroke()}const Pje=typeof Path2D=="function";function Ije(e,t,n,s){Pje&&!t.options.segment?Dje(e,t,n,s):Oje(e,t,n,s)}class fy extends Wo{static id="line";static defaults={borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:"default",fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};static descriptors={_scriptable:!0,_indexable:t=>t!=="borderDash"&&t!=="fill"};constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,n){const s=this.options;if((s.tension||s.cubicInterpolationMode==="monotone")&&!s.stepped&&!this._pointsUpdated){const i=s.spanGaps?this._loop:this._fullLoop;bCe(this._points,s,t,i,n),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=RCe(this,this.options.segment))}first(){const t=this.segments,n=this.points;return t.length&&n[t[0].start]}last(){const t=this.segments,n=this.points,s=t.length;return s&&n[t[s-1].end]}interpolate(t,n){const s=this.options,i=t[n],a=this.points,o=ZV(this,{property:n,start:i,end:i});if(!o.length)return;const l=[],c=Rje(s);let d,f;for(d=0,f=o.length;d<f;++d){const{start:p,end:m}=o[d],g=a[p],b=a[m];if(g===b){l.push(g);continue}const _=Math.abs((i-g[n])/(b[n]-g[n])),w=c(g,b,_,s.stepped);w[n]=t[n],l.push(w)}return l.length===1?l[0]:l}pathSegment(t,n,s){return pC(this)(t,this,n,s)}path(t,n,s){const i=this.segments,a=pC(this);let o=this._loop;n=n||0,s=s||this.points.length-n;for(const l of i)o&=a(t,this,l,{start:n,end:n+s-1});return!!o}draw(t,n,s,i){const a=this.options||{};(this.points||[]).length&&a.borderWidth&&(t.save(),Ije(t,this,s,i),t.restore()),this.animated&&(this._pointsUpdated=!1,this._path=void 0)}}function RD(e,t,n,s){const i=e.options,{[n]:a}=e.getProps([n],s);return Math.abs(t-a)<i.radius+i.hitRadius}class Lje extends Wo{static id="point";parsed;skip;stop;static defaults={borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:"circle",radius:3,rotation:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};constructor(t){super(),this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,t&&Object.assign(this,t)}inRange(t,n,s){const i=this.options,{x:a,y:o}=this.getProps(["x","y"],s);return Math.pow(t-a,2)+Math.pow(n-o,2)<Math.pow(i.hitRadius+i.radius,2)}inXRange(t,n){return RD(this,t,"x",n)}inYRange(t,n){return RD(this,t,"y",n)}getCenterPoint(t){const{x:n,y:s}=this.getProps(["x","y"],t);return{x:n,y:s}}size(t){t=t||this.options||{};let n=t.radius||0;n=Math.max(n,n&&t.hoverRadius||0);const s=n&&t.borderWidth||0;return(n+s)*2}draw(t,n){const s=this.options;this.skip||s.radius<.1||!Qp(this,n,this.size(s)/2)||(t.strokeStyle=s.borderColor,t.lineWidth=s.borderWidth,t.fillStyle=s.backgroundColor,dC(t,s,this.x,this.y))}getRange(){const t=this.options||{};return t.radius+t.hitRadius}}function mU(e,t){const{x:n,y:s,base:i,width:a,height:o}=e.getProps(["x","y","base","width","height"],t);let l,c,d,f,p;return e.horizontal?(p=o/2,l=Math.min(n,i),c=Math.max(n,i),d=s-p,f=s+p):(p=a/2,l=n-p,c=n+p,d=Math.min(s,i),f=Math.max(s,i)),{left:l,top:d,right:c,bottom:f}}function Pl(e,t,n,s){return e?0:Ws(t,n,s)}function Bje(e,t,n){const s=e.options.borderWidth,i=e.borderSkipped,a=UV(s);return{t:Pl(i.top,a.top,0,n),r:Pl(i.right,a.right,0,t),b:Pl(i.bottom,a.bottom,0,n),l:Pl(i.left,a.left,0,t)}}function zje(e,t,n){const{enableBorderRadius:s}=e.getProps(["enableBorderRadius"]),i=e.options.borderRadius,a=Id(i),o=Math.min(t,n),l=e.borderSkipped,c=s||xt(i);return{topLeft:Pl(!c||l.top||l.left,a.topLeft,0,o),topRight:Pl(!c||l.top||l.right,a.topRight,0,o),bottomLeft:Pl(!c||l.bottom||l.left,a.bottomLeft,0,o),bottomRight:Pl(!c||l.bottom||l.right,a.bottomRight,0,o)}}function $je(e){const t=mU(e),n=t.right-t.left,s=t.bottom-t.top,i=Bje(e,n/2,s/2),a=zje(e,n/2,s/2);return{outer:{x:t.left,y:t.top,w:n,h:s,radius:a},inner:{x:t.left+i.l,y:t.top+i.t,w:n-i.l-i.r,h:s-i.t-i.b,radius:{topLeft:Math.max(0,a.topLeft-Math.max(i.t,i.l)),topRight:Math.max(0,a.topRight-Math.max(i.t,i.r)),bottomLeft:Math.max(0,a.bottomLeft-Math.max(i.b,i.l)),bottomRight:Math.max(0,a.bottomRight-Math.max(i.b,i.r))}}}}function RA(e,t,n,s){const i=t===null,a=n===null,l=e&&!(i&&a)&&mU(e,s);return l&&(i||So(t,l.left,l.right))&&(a||So(n,l.top,l.bottom))}function Vje(e){return e.topLeft||e.topRight||e.bottomLeft||e.bottomRight}function Uje(e,t){e.rect(t.x,t.y,t.w,t.h)}function DA(e,t,n={}){const s=e.x!==n.x?-t:0,i=e.y!==n.y?-t:0,a=(e.x+e.w!==n.x+n.w?t:0)-s,o=(e.y+e.h!==n.y+n.h?t:0)-i;return{x:e.x+s,y:e.y+i,w:e.w+a,h:e.h+o,radius:e.radius}}class Hje extends Wo{static id="bar";static defaults={borderSkipped:"start",borderWidth:0,borderRadius:0,inflateAmount:"auto",pointStyle:void 0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};constructor(t){super(),this.options=void 0,this.horizontal=void 0,this.base=void 0,this.width=void 0,this.height=void 0,this.inflateAmount=void 0,t&&Object.assign(this,t)}draw(t){const{inflateAmount:n,options:{borderColor:s,backgroundColor:i}}=this,{inner:a,outer:o}=$je(this),l=Vje(o.radius)?z0:Uje;t.save(),(o.w!==a.w||o.h!==a.h)&&(t.beginPath(),l(t,DA(o,n,a)),t.clip(),l(t,DA(a,-n,o)),t.fillStyle=s,t.fill("evenodd")),t.beginPath(),l(t,DA(a,n)),t.fillStyle=i,t.fill(),t.restore()}inRange(t,n,s){return RA(this,t,n,s)}inXRange(t,n){return RA(this,t,null,n)}inYRange(t,n){return RA(this,null,t,n)}getCenterPoint(t){const{x:n,y:s,base:i,horizontal:a}=this.getProps(["x","y","base","horizontal"],t);return{x:a?(n+i)/2:n,y:a?s:(s+i)/2}}getRange(t){return t==="x"?this.width/2:this.height/2}}function Wje(e,t,n){const s=e.segments,i=e.points,a=t.points,o=[];for(const l of s){let{start:c,end:d}=l;d=py(c,d,i);const f=mC(n,i[c],i[d],l.loop);if(!t.segments){o.push({source:l,target:f,start:i[c],end:i[d]});continue}const p=ZV(t,f);for(const m of p){const g=mC(n,a[m.start],a[m.end],m.loop),b=JV(l,i,g);for(const _ of b)o.push({source:_,target:m,start:{[n]:DD(f,g,"start",Math.max)},end:{[n]:DD(f,g,"end",Math.min)}})}}return o}function mC(e,t,n,s){if(s)return;let i=t[e],a=n[e];return e==="angle"&&(i=Wi(i),a=Wi(a)),{property:e,start:i,end:a}}function qje(e,t){const{x:n=null,y:s=null}=e||{},i=t.points,a=[];return t.segments.forEach(({start:o,end:l})=>{l=py(o,l,i);const c=i[o],d=i[l];s!==null?(a.push({x:c.x,y:s}),a.push({x:d.x,y:s})):n!==null&&(a.push({x:n,y:c.y}),a.push({x:n,y:d.y}))}),a}function py(e,t,n){for(;t>e;t--){const s=n[t];if(!isNaN(s.x)&&!isNaN(s.y))break}return t}function DD(e,t,n,s){return e&&t?s(e[n],t[n]):e?e[n]:t?t[n]:0}function xU(e,t){let n=[],s=!1;return Wn(e)?(s=!0,n=e):n=qje(e,t),n.length?new fy({points:n,options:{tension:0},_loop:s,_fullLoop:s}):null}function OD(e){return e&&e.fill!==!1}function Gje(e,t,n){let i=e[t].fill;const a=[t];let o;if(!n)return i;for(;i!==!1&&a.indexOf(i)===-1;){if(!Js(i))return i;if(o=e[i],!o)return!1;if(o.visible)return i;a.push(i),i=o.fill}return!1}function Kje(e,t,n){const s=Jje(e);if(xt(s))return isNaN(s.value)?!1:s;let i=parseFloat(s);return Js(i)&&Math.floor(i)===i?Yje(s[0],t,i,n):["origin","start","end","stack","shape"].indexOf(s)>=0&&s}function Yje(e,t,n,s){return(e==="-"||e==="+")&&(n=t+n),n===t||n<0||n>=s?!1:n}function Qje(e,t){let n=null;return e==="start"?n=t.bottom:e==="end"?n=t.top:xt(e)?n=t.getPixelForValue(e.value):t.getBasePixel&&(n=t.getBasePixel()),n}function Xje(e,t,n){let s;return e==="start"?s=n:e==="end"?s=t.options.reverse?t.min:t.max:xt(e)?s=e.value:s=t.getBaseValue(),s}function Jje(e){const t=e.options,n=t.fill;let s=it(n&&n.target,n);return s===void 0&&(s=!!t.backgroundColor),s===!1||s===null?!1:s===!0?"origin":s}function Zje(e){const{scale:t,index:n,line:s}=e,i=[],a=s.segments,o=s.points,l=eNe(t,n);l.push(xU({x:null,y:t.bottom},s));for(let c=0;c<a.length;c++){const d=a[c];for(let f=d.start;f<=d.end;f++)tNe(i,o[f],l)}return new fy({points:i,options:{}})}function eNe(e,t){const n=[],s=e.getMatchingVisibleMetas("line");for(let i=0;i<s.length;i++){const a=s[i];if(a.index===t)break;a.hidden||n.unshift(a.dataset)}return n}function tNe(e,t,n){const s=[];for(let i=0;i<n.length;i++){const a=n[i],{first:o,last:l,point:c}=nNe(a,t,"x");if(!(!c||o&&l)){if(o)s.unshift(c);else if(e.push(c),!l)break}}e.push(...s)}function nNe(e,t,n){const s=e.interpolate(t,n);if(!s)return{};const i=s[n],a=e.segments,o=e.points;let l=!1,c=!1;for(let d=0;d<a.length;d++){const f=a[d],p=o[f.start][n],m=o[f.end][n];if(So(i,p,m)){l=i===p,c=i===m;break}}return{first:l,last:c,point:s}}class gU{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,n,s){const{x:i,y:a,radius:o}=this;return n=n||{start:0,end:_n},t.arc(i,a,o,n.end,n.start,!0),!s.bounds}interpolate(t){const{x:n,y:s,radius:i}=this,a=t.angle;return{x:n+Math.cos(a)*i,y:s+Math.sin(a)*i,angle:a}}}function sNe(e){const{chart:t,fill:n,line:s}=e;if(Js(n))return iNe(t,n);if(n==="stack")return Zje(e);if(n==="shape")return!0;const i=rNe(e);return i instanceof gU?i:xU(i,s)}function iNe(e,t){const n=e.getDatasetMeta(t);return n&&e.isDatasetVisible(t)?n.dataset:null}function rNe(e){return(e.scale||{}).getPointPositionForValue?oNe(e):aNe(e)}function aNe(e){const{scale:t={},fill:n}=e,s=Qje(n,t);if(Js(s)){const i=t.isHorizontal();return{x:i?s:null,y:i?null:s}}return null}function oNe(e){const{scale:t,fill:n}=e,s=t.options,i=t.getLabels().length,a=s.reverse?t.max:t.min,o=Xje(n,t,a),l=[];if(s.grid.circular){const c=t.getPointPositionForValue(0,a);return new gU({x:c.x,y:c.y,radius:t.getDistanceFromCenterForValue(o)})}for(let c=0;c<i;++c)l.push(t.getPointPositionForValue(c,o));return l}function OA(e,t,n){const s=sNe(t),{chart:i,index:a,line:o,scale:l,axis:c}=t,d=o.options,f=d.fill,p=d.backgroundColor,{above:m=p,below:g=p}=f||{},b=i.getDatasetMeta(a),_=eU(i,b);s&&o.points.length&&(ly(e,n),lNe(e,{line:o,target:s,above:m,below:g,area:n,scale:l,axis:c,clip:_}),cy(e))}function lNe(e,t){const{line:n,target:s,above:i,below:a,area:o,scale:l,clip:c}=t,d=n._loop?"angle":t.axis;e.save();let f=a;a!==i&&(d==="x"?(PD(e,s,o.top),PA(e,{line:n,target:s,color:i,scale:l,property:d,clip:c}),e.restore(),e.save(),PD(e,s,o.bottom)):d==="y"&&(ID(e,s,o.left),PA(e,{line:n,target:s,color:a,scale:l,property:d,clip:c}),e.restore(),e.save(),ID(e,s,o.right),f=i)),PA(e,{line:n,target:s,color:f,scale:l,property:d,clip:c}),e.restore()}function PD(e,t,n){const{segments:s,points:i}=t;let a=!0,o=!1;e.beginPath();for(const l of s){const{start:c,end:d}=l,f=i[c],p=i[py(c,d,i)];a?(e.moveTo(f.x,f.y),a=!1):(e.lineTo(f.x,n),e.lineTo(f.x,f.y)),o=!!t.pathSegment(e,l,{move:o}),o?e.closePath():e.lineTo(p.x,n)}e.lineTo(t.first().x,n),e.closePath(),e.clip()}function ID(e,t,n){const{segments:s,points:i}=t;let a=!0,o=!1;e.beginPath();for(const l of s){const{start:c,end:d}=l,f=i[c],p=i[py(c,d,i)];a?(e.moveTo(f.x,f.y),a=!1):(e.lineTo(n,f.y),e.lineTo(f.x,f.y)),o=!!t.pathSegment(e,l,{move:o}),o?e.closePath():e.lineTo(n,p.y)}e.lineTo(n,t.first().y),e.closePath(),e.clip()}function PA(e,t){const{line:n,target:s,property:i,color:a,scale:o,clip:l}=t,c=Wje(n,s,i);for(const{source:d,target:f,start:p,end:m}of c){const{style:{backgroundColor:g=a}={}}=d,b=s!==!0;e.save(),e.fillStyle=g,cNe(e,o,l,b&&mC(i,p,m)),e.beginPath();const _=!!n.pathSegment(e,d);let w;if(b){_?e.closePath():LD(e,s,m,i);const A=!!s.pathSegment(e,f,{move:_,reverse:!0});w=_&&A,w||LD(e,s,p,i)}e.closePath(),e.fill(w?"evenodd":"nonzero"),e.restore()}}function cNe(e,t,n,s){const i=t.chart.chartArea,{property:a,start:o,end:l}=s||{};if(a==="x"||a==="y"){let c,d,f,p;a==="x"?(c=o,d=i.top,f=l,p=i.bottom):(c=i.left,d=o,f=i.right,p=l),e.beginPath(),n&&(c=Math.max(c,n.left),f=Math.min(f,n.right),d=Math.max(d,n.top),p=Math.min(p,n.bottom)),e.rect(c,d,f-c,p-d),e.clip()}}function LD(e,t,n,s){const i=t.interpolate(n,s);i&&e.lineTo(i.x,i.y)}var uNe={id:"filler",afterDatasetsUpdate(e,t,n){const s=(e.data.datasets||[]).length,i=[];let a,o,l,c;for(o=0;o<s;++o)a=e.getDatasetMeta(o),l=a.dataset,c=null,l&&l.options&&l instanceof fy&&(c={visible:e.isDatasetVisible(o),index:o,fill:Kje(l,o,s),chart:e,axis:a.controller.options.indexAxis,scale:a.vScale,line:l}),a.$filler=c,i.push(c);for(o=0;o<s;++o)c=i[o],!(!c||c.fill===!1)&&(c.fill=Gje(i,o,n.propagate))},beforeDraw(e,t,n){const s=n.drawTime==="beforeDraw",i=e.getSortedVisibleDatasetMetas(),a=e.chartArea;for(let o=i.length-1;o>=0;--o){const l=i[o].$filler;l&&(l.line.updateControlPoints(a,l.axis),s&&l.fill&&OA(e.ctx,l,a))}},beforeDatasetsDraw(e,t,n){if(n.drawTime!=="beforeDatasetsDraw")return;const s=e.getSortedVisibleDatasetMetas();for(let i=s.length-1;i>=0;--i){const a=s[i].$filler;OD(a)&&OA(e.ctx,a,e.chartArea)}},beforeDatasetDraw(e,t,n){const s=t.meta.$filler;!OD(s)||n.drawTime!=="beforeDatasetDraw"||OA(e.ctx,s,e.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const BD=(e,t)=>{let{boxHeight:n=t,boxWidth:s=t}=e;return e.usePointStyle&&(n=Math.min(n,t),s=e.pointStyleWidth||Math.min(s,t)),{boxWidth:s,boxHeight:n,itemHeight:Math.max(t,n)}},dNe=(e,t)=>e!==null&&t!==null&&e.datasetIndex===t.datasetIndex&&e.index===t.index;class zD extends Wo{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,n,s){this.maxWidth=t,this.maxHeight=n,this._margins=s,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const t=this.options.labels||{};let n=rn(t.generateLabels,[this.chart],this)||[];t.filter&&(n=n.filter(s=>t.filter(s,this.chart.data))),t.sort&&(n=n.sort((s,i)=>t.sort(s,i,this.chart.data))),this.options.reverse&&n.reverse(),this.legendItems=n}fit(){const{options:t,ctx:n}=this;if(!t.display){this.width=this.height=0;return}const s=t.labels,i=qs(s.font),a=i.size,o=this._computeTitleHeight(),{boxWidth:l,itemHeight:c}=BD(s,a);let d,f;n.font=i.string,this.isHorizontal()?(d=this.maxWidth,f=this._fitRows(o,a,l,c)+10):(f=this.maxHeight,d=this._fitCols(o,i,l,c)+10),this.width=Math.min(d,t.maxWidth||this.maxWidth),this.height=Math.min(f,t.maxHeight||this.maxHeight)}_fitRows(t,n,s,i){const{ctx:a,maxWidth:o,options:{labels:{padding:l}}}=this,c=this.legendHitBoxes=[],d=this.lineWidths=[0],f=i+l;let p=t;a.textAlign="left",a.textBaseline="middle";let m=-1,g=-f;return this.legendItems.forEach((b,_)=>{const w=s+n/2+a.measureText(b.text).width;(_===0||d[d.length-1]+w+2*l>o)&&(p+=f,d[d.length-(_>0?0:1)]=0,g+=f,m++),c[_]={left:0,top:g,row:m,width:w,height:i},d[d.length-1]+=w+l}),p}_fitCols(t,n,s,i){const{ctx:a,maxHeight:o,options:{labels:{padding:l}}}=this,c=this.legendHitBoxes=[],d=this.columnSizes=[],f=o-t;let p=l,m=0,g=0,b=0,_=0;return this.legendItems.forEach((w,A)=>{const{itemWidth:S,itemHeight:C}=hNe(s,n,a,w,i);A>0&&g+C+2*l>f&&(p+=m+l,d.push({width:m,height:g}),b+=m+l,_++,m=g=0),c[A]={left:b,top:g,col:_,width:S,height:C},m=Math.max(m,S),g+=C+l}),p+=m,d.push({width:m,height:g}),p}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:n,options:{align:s,labels:{padding:i},rtl:a}}=this,o=Ld(a,this.left,this.width);if(this.isHorizontal()){let l=0,c=zs(s,this.left+i,this.right-this.lineWidths[l]);for(const d of n)l!==d.row&&(l=d.row,c=zs(s,this.left+i,this.right-this.lineWidths[l])),d.top+=this.top+t+i,d.left=o.leftForLtr(o.x(c),d.width),c+=d.width+i}else{let l=0,c=zs(s,this.top+t+i,this.bottom-this.columnSizes[l].height);for(const d of n)d.col!==l&&(l=d.col,c=zs(s,this.top+t+i,this.bottom-this.columnSizes[l].height)),d.top=c,d.left+=this.left+i,d.left=o.leftForLtr(o.x(d.left),d.width),c+=d.height+i}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){const t=this.ctx;ly(t,this),this._draw(),cy(t)}}_draw(){const{options:t,columnSizes:n,lineWidths:s,ctx:i}=this,{align:a,labels:o}=t,l=Rn.color,c=Ld(t.rtl,this.left,this.width),d=qs(o.font),{padding:f}=o,p=d.size,m=p/2;let g;this.drawTitle(),i.textAlign=c.textAlign("left"),i.textBaseline="middle",i.lineWidth=.5,i.font=d.string;const{boxWidth:b,boxHeight:_,itemHeight:w}=BD(o,p),A=function(T,F,M){if(isNaN(b)||b<=0||isNaN(_)||_<0)return;i.save();const I=it(M.lineWidth,1);if(i.fillStyle=it(M.fillStyle,l),i.lineCap=it(M.lineCap,"butt"),i.lineDashOffset=it(M.lineDashOffset,0),i.lineJoin=it(M.lineJoin,"miter"),i.lineWidth=I,i.strokeStyle=it(M.strokeStyle,l),i.setLineDash(it(M.lineDash,[])),o.usePointStyle){const R={radius:_*Math.SQRT2/2,pointStyle:M.pointStyle,rotation:M.rotation,borderWidth:I},H=c.xPlus(T,b/2),V=F+m;VV(i,R,H,V,o.pointStyleWidth&&b)}else{const R=F+Math.max((p-_)/2,0),H=c.leftForLtr(T,b),V=Id(M.borderRadius);i.beginPath(),Object.values(V).some(K=>K!==0)?z0(i,{x:H,y:R,w:b,h:_,radius:V}):i.rect(H,R,b,_),i.fill(),I!==0&&i.stroke()}i.restore()},S=function(T,F,M){Xp(i,M.text,T,F+w/2,d,{strikethrough:M.hidden,textAlign:c.textAlign(M.textAlign)})},C=this.isHorizontal(),E=this._computeTitleHeight();C?g={x:zs(a,this.left+f,this.right-s[0]),y:this.top+f+E,line:0}:g={x:this.left+f,y:zs(a,this.top+E+f,this.bottom-n[0].height),line:0},YV(this.ctx,t.textDirection);const k=w+f;this.legendItems.forEach((T,F)=>{i.strokeStyle=T.fontColor,i.fillStyle=T.fontColor;const M=i.measureText(T.text).width,I=c.textAlign(T.textAlign||(T.textAlign=o.textAlign)),R=b+m+M;let H=g.x,V=g.y;c.setWidth(this.width),C?F>0&&H+R+f>this.right&&(V=g.y+=k,g.line++,H=g.x=zs(a,this.left+f,this.right-s[g.line])):F>0&&V+k>this.bottom&&(H=g.x=H+n[g.line].width+f,g.line++,V=g.y=zs(a,this.top+E+f,this.bottom-n[g.line].height));const K=c.x(H);if(A(K,V,T),H=PSe(I,H+b+m,C?H+R:this.right,t.rtl),S(c.x(H),V,T),C)g.x+=R+f;else if(typeof T.text!="string"){const q=d.lineHeight;g.y+=bU(T,q)+f}else g.y+=k}),QV(this.ctx,t.textDirection)}drawTitle(){const t=this.options,n=t.title,s=qs(n.font),i=Lr(n.padding);if(!n.display)return;const a=Ld(t.rtl,this.left,this.width),o=this.ctx,l=n.position,c=s.size/2,d=i.top+c;let f,p=this.left,m=this.width;if(this.isHorizontal())m=Math.max(...this.lineWidths),f=this.top+d,p=zs(t.align,p,this.right-m);else{const b=this.columnSizes.reduce((_,w)=>Math.max(_,w.height),0);f=d+zs(t.align,this.top,this.bottom-b-t.labels.padding-this._computeTitleHeight())}const g=zs(l,p,p+m);o.textAlign=a.textAlign(uN(l)),o.textBaseline="middle",o.strokeStyle=n.color,o.fillStyle=n.color,o.font=s.string,Xp(o,n.text,g,f,s)}_computeTitleHeight(){const t=this.options.title,n=qs(t.font),s=Lr(t.padding);return t.display?n.lineHeight+s.height:0}_getLegendItemAt(t,n){let s,i,a;if(So(t,this.left,this.right)&&So(n,this.top,this.bottom)){for(a=this.legendHitBoxes,s=0;s<a.length;++s)if(i=a[s],So(t,i.left,i.left+i.width)&&So(n,i.top,i.top+i.height))return this.legendItems[s]}return null}handleEvent(t){const n=this.options;if(!mNe(t.type,n))return;const s=this._getLegendItemAt(t.x,t.y);if(t.type==="mousemove"||t.type==="mouseout"){const i=this._hoveredItem,a=dNe(i,s);i&&!a&&rn(n.onLeave,[t,i,this],this),this._hoveredItem=s,s&&!a&&rn(n.onHover,[t,s,this],this)}else s&&rn(n.onClick,[t,s,this],this)}}function hNe(e,t,n,s,i){const a=fNe(s,e,t,n),o=pNe(i,s,t.lineHeight);return{itemWidth:a,itemHeight:o}}function fNe(e,t,n,s){let i=e.text;return i&&typeof i!="string"&&(i=i.reduce((a,o)=>a.length>o.length?a:o)),t+n.size/2+s.measureText(i).width}function pNe(e,t,n){let s=e;return typeof t.text!="string"&&(s=bU(t,n)),s}function bU(e,t){const n=e.text?e.text.length:0;return t*n}function mNe(e,t){return!!((e==="mousemove"||e==="mouseout")&&(t.onHover||t.onLeave)||t.onClick&&(e==="click"||e==="mouseup"))}var xNe={id:"legend",_element:zD,start(e,t,n){const s=e.legend=new zD({ctx:e.ctx,options:n,chart:e});Tr.configure(e,s,n),Tr.addBox(e,s)},stop(e){Tr.removeBox(e,e.legend),delete e.legend},beforeUpdate(e,t,n){const s=e.legend;Tr.configure(e,s,n),s.options=n},afterUpdate(e){const t=e.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(e,t){t.replay||e.legend.handleEvent(t.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(e,t,n){const s=t.datasetIndex,i=n.chart;i.isDatasetVisible(s)?(i.hide(s),t.hidden=!0):(i.show(s),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:e=>e.chart.options.color,boxWidth:40,padding:10,generateLabels(e){const t=e.data.datasets,{labels:{usePointStyle:n,pointStyle:s,textAlign:i,color:a,useBorderRadius:o,borderRadius:l}}=e.legend.options;return e._getSortedDatasetMetas().map(c=>{const d=c.controller.getStyle(n?0:void 0),f=Lr(d.borderWidth);return{text:t[c.index].label,fillStyle:d.backgroundColor,fontColor:a,hidden:!c.visible,lineCap:d.borderCapStyle,lineDash:d.borderDash,lineDashOffset:d.borderDashOffset,lineJoin:d.borderJoinStyle,lineWidth:(f.width+f.height)/4,strokeStyle:d.borderColor,pointStyle:s||d.pointStyle,rotation:d.rotation,textAlign:i||d.textAlign,borderRadius:o&&(l||d.borderRadius),datasetIndex:c.index}},this)}},title:{color:e=>e.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:e=>!e.startsWith("on"),labels:{_scriptable:e=>!["generateLabels","filter","sort"].includes(e)}}};class vU extends Wo{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,n){const s=this.options;if(this.left=0,this.top=0,!s.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=t,this.height=this.bottom=n;const i=Wn(s.text)?s.text.length:1;this._padding=Lr(s.padding);const a=i*qs(s.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=a:this.width=a}isHorizontal(){const t=this.options.position;return t==="top"||t==="bottom"}_drawArgs(t){const{top:n,left:s,bottom:i,right:a,options:o}=this,l=o.align;let c=0,d,f,p;return this.isHorizontal()?(f=zs(l,s,a),p=n+t,d=a-s):(o.position==="left"?(f=s+t,p=zs(l,i,n),c=Lt*-.5):(f=a-t,p=zs(l,n,i),c=Lt*.5),d=i-n),{titleX:f,titleY:p,maxWidth:d,rotation:c}}draw(){const t=this.ctx,n=this.options;if(!n.display)return;const s=qs(n.font),a=s.lineHeight/2+this._padding.top,{titleX:o,titleY:l,maxWidth:c,rotation:d}=this._drawArgs(a);Xp(t,n.text,0,0,s,{color:n.color,maxWidth:c,rotation:d,textAlign:uN(n.align),textBaseline:"middle",translation:[o,l]})}}function gNe(e,t){const n=new vU({ctx:e.ctx,options:t,chart:e});Tr.configure(e,n,t),Tr.addBox(e,n),e.titleBlock=n}var bNe={id:"title",_element:vU,start(e,t,n){gNe(e,n)},stop(e){const t=e.titleBlock;Tr.removeBox(e,t),delete e.titleBlock},beforeUpdate(e,t,n){const s=e.titleBlock;Tr.configure(e,s,n),s.options=n},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const tp={average(e){if(!e.length)return!1;let t,n,s=new Set,i=0,a=0;for(t=0,n=e.length;t<n;++t){const l=e[t].element;if(l&&l.hasValue()){const c=l.tooltipPosition();s.add(c.x),i+=c.y,++a}}return a===0||s.size===0?!1:{x:[...s].reduce((l,c)=>l+c)/s.size,y:i/a}},nearest(e,t){if(!e.length)return!1;let n=t.x,s=t.y,i=Number.POSITIVE_INFINITY,a,o,l;for(a=0,o=e.length;a<o;++a){const c=e[a].element;if(c&&c.hasValue()){const d=c.getCenterPoint(),f=cC(t,d);f<i&&(i=f,l=c)}}if(l){const c=l.tooltipPosition();n=c.x,s=c.y}return{x:n,y:s}}};function wa(e,t){return t&&(Wn(t)?Array.prototype.push.apply(e,t):e.push(t)),e}function yo(e){return(typeof e=="string"||e instanceof String)&&e.indexOf(`
|
|
188
188
|
`)>-1?e.split(`
|
|
189
|
-
`):e}function vNe(e,t){const{element:n,datasetIndex:s,index:i}=t,a=e.getDatasetMeta(s).controller,{label:o,value:l}=a.getLabelAndValue(i);return{chart:e,label:o,parsed:a.getParsed(i),raw:e.data.datasets[s].data[i],formattedValue:l,dataset:a.getDataset(),dataIndex:i,datasetIndex:s,element:n}}function $D(e,t){const n=e.chart.ctx,{body:s,footer:i,title:a}=e,{boxWidth:o,boxHeight:l}=t,c=qs(t.bodyFont),d=qs(t.titleFont),f=qs(t.footerFont),p=a.length,m=i.length,g=s.length,b=Lr(t.padding);let _=b.height,w=0,A=s.reduce((E,k)=>E+k.before.length+k.lines.length+k.after.length,0);if(A+=e.beforeBody.length+e.afterBody.length,p&&(_+=p*d.lineHeight+(p-1)*t.titleSpacing+t.titleMarginBottom),A){const E=t.displayColors?Math.max(l,c.lineHeight):c.lineHeight;_+=g*E+(A-g)*c.lineHeight+(A-1)*t.bodySpacing}m&&(_+=t.footerMarginTop+m*f.lineHeight+(m-1)*t.footerSpacing);let S=0;const C=function(E){w=Math.max(w,n.measureText(E).width+S)};return n.save(),n.font=d.string,It(e.title,C),n.font=c.string,It(e.beforeBody.concat(e.afterBody),C),S=t.displayColors?o+2+t.boxPadding:0,It(s,E=>{It(E.before,C),It(E.lines,C),It(E.after,C)}),S=0,n.font=f.string,It(e.footer,C),n.restore(),w+=b.width,{width:w,height:_}}function yNe(e,t){const{y:n,height:s}=t;return n<s/2?"top":n>e.height-s/2?"bottom":"center"}function _Ne(e,t,n,s){const{x:i,width:a}=s,o=n.caretSize+n.caretPadding;if(e==="left"&&i+a+o>t.width||e==="right"&&i-a-o<0)return!0}function wNe(e,t,n,s){const{x:i,width:a}=n,{width:o,chartArea:{left:l,right:c}}=e;let d="center";return s==="center"?d=i<=(l+c)/2?"left":"right":i<=a/2?d="left":i>=o-a/2&&(d="right"),_Ne(d,e,t,n)&&(d="center"),d}function VD(e,t,n){const s=n.yAlign||t.yAlign||yNe(e,n);return{xAlign:n.xAlign||t.xAlign||wNe(e,t,n,s),yAlign:s}}function ANe(e,t){let{x:n,width:s}=e;return t==="right"?n-=s:t==="center"&&(n-=s/2),n}function SNe(e,t,n){let{y:s,height:i}=e;return t==="top"?s+=n:t==="bottom"?s-=i+n:s-=i/2,s}function UD(e,t,n,s){const{caretSize:i,caretPadding:a,cornerRadius:o}=e,{xAlign:l,yAlign:c}=n,d=i+a,{topLeft:f,topRight:p,bottomLeft:m,bottomRight:g}=Id(o);let b=ANe(t,l);const _=SNe(t,c,d);return c==="center"?l==="left"?b+=d:l==="right"&&(b-=d):l==="left"?b-=Math.max(f,m)+i:l==="right"&&(b+=Math.max(p,g)+i),{x:Ws(b,0,s.width-t.width),y:Ws(_,0,s.height-t.height)}}function eb(e,t,n){const s=Lr(n.padding);return t==="center"?e.x+e.width/2:t==="right"?e.x+e.width-s.right:e.x+s.left}function HD(e){return wa([],yo(e))}function CNe(e,t,n){return wu(e,{tooltip:t,tooltipItems:n,type:"tooltip"})}function WD(e,t){const n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}const yU={beforeTitle:mo,title(e){if(e.length>0){const t=e[0],n=t.chart.data.labels,s=n?n.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(s>0&&t.dataIndex<s)return n[t.dataIndex]}return""},afterTitle:mo,beforeBody:mo,beforeLabel:mo,label(e){if(this&&this.options&&this.options.mode==="dataset")return e.label+": "+e.formattedValue||e.formattedValue;let t=e.dataset.label||"";t&&(t+=": ");const n=e.formattedValue;return Tt(n)||(t+=n),t},labelColor(e){const n=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{borderColor:n.borderColor,backgroundColor:n.backgroundColor,borderWidth:n.borderWidth,borderDash:n.borderDash,borderDashOffset:n.borderDashOffset,borderRadius:0}},labelTextColor(){return this.options.bodyColor},labelPointStyle(e){const n=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{pointStyle:n.pointStyle,rotation:n.rotation}},afterLabel:mo,afterBody:mo,beforeFooter:mo,footer:mo,afterFooter:mo};function wi(e,t,n,s){const i=e[t].call(n,s);return typeof i>"u"?yU[t].call(n,s):i}class qD extends Wo{static positioners=tp;constructor(t){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=t.chart,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const n=this.chart,s=this.options.setContext(this.getContext()),i=s.enabled&&n.options.animation&&s.animations,a=new tU(this.chart,i);return i._cacheable&&(this._cachedAnimations=Object.freeze(a)),a}getContext(){return this.$context||(this.$context=CNe(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,n){const{callbacks:s}=n,i=wi(s,"beforeTitle",this,t),a=wi(s,"title",this,t),o=wi(s,"afterTitle",this,t);let l=[];return l=wa(l,yo(i)),l=wa(l,yo(a)),l=wa(l,yo(o)),l}getBeforeBody(t,n){return HD(wi(n.callbacks,"beforeBody",this,t))}getBody(t,n){const{callbacks:s}=n,i=[];return It(t,a=>{const o={before:[],lines:[],after:[]},l=WD(s,a);wa(o.before,yo(wi(l,"beforeLabel",this,a))),wa(o.lines,wi(l,"label",this,a)),wa(o.after,yo(wi(l,"afterLabel",this,a))),i.push(o)}),i}getAfterBody(t,n){return HD(wi(n.callbacks,"afterBody",this,t))}getFooter(t,n){const{callbacks:s}=n,i=wi(s,"beforeFooter",this,t),a=wi(s,"footer",this,t),o=wi(s,"afterFooter",this,t);let l=[];return l=wa(l,yo(i)),l=wa(l,yo(a)),l=wa(l,yo(o)),l}_createItems(t){const n=this._active,s=this.chart.data,i=[],a=[],o=[];let l=[],c,d;for(c=0,d=n.length;c<d;++c)l.push(vNe(this.chart,n[c]));return t.filter&&(l=l.filter((f,p,m)=>t.filter(f,p,m,s))),t.itemSort&&(l=l.sort((f,p)=>t.itemSort(f,p,s))),It(l,f=>{const p=WD(t.callbacks,f);i.push(wi(p,"labelColor",this,f)),a.push(wi(p,"labelPointStyle",this,f)),o.push(wi(p,"labelTextColor",this,f))}),this.labelColors=i,this.labelPointStyles=a,this.labelTextColors=o,this.dataPoints=l,l}update(t,n){const s=this.options.setContext(this.getContext()),i=this._active;let a,o=[];if(!i.length)this.opacity!==0&&(a={opacity:0});else{const l=tp[s.position].call(this,i,this._eventPosition);o=this._createItems(s),this.title=this.getTitle(o,s),this.beforeBody=this.getBeforeBody(o,s),this.body=this.getBody(o,s),this.afterBody=this.getAfterBody(o,s),this.footer=this.getFooter(o,s);const c=this._size=$D(this,s),d=Object.assign({},l,c),f=VD(this.chart,s,d),p=UD(s,d,f,this.chart);this.xAlign=f.xAlign,this.yAlign=f.yAlign,a={opacity:1,x:p.x,y:p.y,width:c.width,height:c.height,caretX:l.x,caretY:l.y}}this._tooltipItems=o,this.$context=void 0,a&&this._resolveAnimations().update(this,a),t&&s.external&&s.external.call(this,{chart:this.chart,tooltip:this,replay:n})}drawCaret(t,n,s,i){const a=this.getCaretPosition(t,s,i);n.lineTo(a.x1,a.y1),n.lineTo(a.x2,a.y2),n.lineTo(a.x3,a.y3)}getCaretPosition(t,n,s){const{xAlign:i,yAlign:a}=this,{caretSize:o,cornerRadius:l}=s,{topLeft:c,topRight:d,bottomLeft:f,bottomRight:p}=Id(l),{x:m,y:g}=t,{width:b,height:_}=n;let w,A,S,C,E,k;return a==="center"?(E=g+_/2,i==="left"?(w=m,A=w-o,C=E+o,k=E-o):(w=m+b,A=w+o,C=E-o,k=E+o),S=w):(i==="left"?A=m+Math.max(c,f)+o:i==="right"?A=m+b-Math.max(d,p)-o:A=this.caretX,a==="top"?(C=g,E=C-o,w=A-o,S=A+o):(C=g+_,E=C+o,w=A+o,S=A-o),k=C),{x1:w,x2:A,x3:S,y1:C,y2:E,y3:k}}drawTitle(t,n,s){const i=this.title,a=i.length;let o,l,c;if(a){const d=Ld(s.rtl,this.x,this.width);for(t.x=eb(this,s.titleAlign,s),n.textAlign=d.textAlign(s.titleAlign),n.textBaseline="middle",o=qs(s.titleFont),l=s.titleSpacing,n.fillStyle=s.titleColor,n.font=o.string,c=0;c<a;++c)n.fillText(i[c],d.x(t.x),t.y+o.lineHeight/2),t.y+=o.lineHeight+l,c+1===a&&(t.y+=s.titleMarginBottom-l)}}_drawColorBox(t,n,s,i,a){const o=this.labelColors[s],l=this.labelPointStyles[s],{boxHeight:c,boxWidth:d}=a,f=qs(a.bodyFont),p=eb(this,"left",a),m=i.x(p),g=c<f.lineHeight?(f.lineHeight-c)/2:0,b=n.y+g;if(a.usePointStyle){const _={radius:Math.min(d,c)/2,pointStyle:l.pointStyle,rotation:l.rotation,borderWidth:1},w=i.leftForLtr(m,d)+d/2,A=b+c/2;t.strokeStyle=a.multiKeyBackground,t.fillStyle=a.multiKeyBackground,dC(t,_,w,A),t.strokeStyle=o.borderColor,t.fillStyle=o.backgroundColor,dC(t,_,w,A)}else{t.lineWidth=xt(o.borderWidth)?Math.max(...Object.values(o.borderWidth)):o.borderWidth||1,t.strokeStyle=o.borderColor,t.setLineDash(o.borderDash||[]),t.lineDashOffset=o.borderDashOffset||0;const _=i.leftForLtr(m,d),w=i.leftForLtr(i.xPlus(m,1),d-2),A=Id(o.borderRadius);Object.values(A).some(S=>S!==0)?(t.beginPath(),t.fillStyle=a.multiKeyBackground,z0(t,{x:_,y:b,w:d,h:c,radius:A}),t.fill(),t.stroke(),t.fillStyle=o.backgroundColor,t.beginPath(),z0(t,{x:w,y:b+1,w:d-2,h:c-2,radius:A}),t.fill()):(t.fillStyle=a.multiKeyBackground,t.fillRect(_,b,d,c),t.strokeRect(_,b,d,c),t.fillStyle=o.backgroundColor,t.fillRect(w,b+1,d-2,c-2))}t.fillStyle=this.labelTextColors[s]}drawBody(t,n,s){const{body:i}=this,{bodySpacing:a,bodyAlign:o,displayColors:l,boxHeight:c,boxWidth:d,boxPadding:f}=s,p=qs(s.bodyFont);let m=p.lineHeight,g=0;const b=Ld(s.rtl,this.x,this.width),_=function(M){n.fillText(M,b.x(t.x+g),t.y+m/2),t.y+=m+a},w=b.textAlign(o);let A,S,C,E,k,T,F;for(n.textAlign=o,n.textBaseline="middle",n.font=p.string,t.x=eb(this,w,s),n.fillStyle=s.bodyColor,It(this.beforeBody,_),g=l&&w!=="right"?o==="center"?d/2+f:d+2+f:0,E=0,T=i.length;E<T;++E){for(A=i[E],S=this.labelTextColors[E],n.fillStyle=S,It(A.before,_),C=A.lines,l&&C.length&&(this._drawColorBox(n,t,E,b,s),m=Math.max(p.lineHeight,c)),k=0,F=C.length;k<F;++k)_(C[k]),m=p.lineHeight;It(A.after,_)}g=0,m=p.lineHeight,It(this.afterBody,_),t.y-=a}drawFooter(t,n,s){const i=this.footer,a=i.length;let o,l;if(a){const c=Ld(s.rtl,this.x,this.width);for(t.x=eb(this,s.footerAlign,s),t.y+=s.footerMarginTop,n.textAlign=c.textAlign(s.footerAlign),n.textBaseline="middle",o=qs(s.footerFont),n.fillStyle=s.footerColor,n.font=o.string,l=0;l<a;++l)n.fillText(i[l],c.x(t.x),t.y+o.lineHeight/2),t.y+=o.lineHeight+s.footerSpacing}}drawBackground(t,n,s,i){const{xAlign:a,yAlign:o}=this,{x:l,y:c}=t,{width:d,height:f}=s,{topLeft:p,topRight:m,bottomLeft:g,bottomRight:b}=Id(i.cornerRadius);n.fillStyle=i.backgroundColor,n.strokeStyle=i.borderColor,n.lineWidth=i.borderWidth,n.beginPath(),n.moveTo(l+p,c),o==="top"&&this.drawCaret(t,n,s,i),n.lineTo(l+d-m,c),n.quadraticCurveTo(l+d,c,l+d,c+m),o==="center"&&a==="right"&&this.drawCaret(t,n,s,i),n.lineTo(l+d,c+f-b),n.quadraticCurveTo(l+d,c+f,l+d-b,c+f),o==="bottom"&&this.drawCaret(t,n,s,i),n.lineTo(l+g,c+f),n.quadraticCurveTo(l,c+f,l,c+f-g),o==="center"&&a==="left"&&this.drawCaret(t,n,s,i),n.lineTo(l,c+p),n.quadraticCurveTo(l,c,l+p,c),n.closePath(),n.fill(),i.borderWidth>0&&n.stroke()}_updateAnimationTarget(t){const n=this.chart,s=this.$animations,i=s&&s.x,a=s&&s.y;if(i||a){const o=tp[t.position].call(this,this._active,this._eventPosition);if(!o)return;const l=this._size=$D(this,t),c=Object.assign({},o,this._size),d=VD(n,t,c),f=UD(t,c,d,n);(i._to!==f.x||a._to!==f.y)&&(this.xAlign=d.xAlign,this.yAlign=d.yAlign,this.width=l.width,this.height=l.height,this.caretX=o.x,this.caretY=o.y,this._resolveAnimations().update(this,f))}}_willRender(){return!!this.opacity}draw(t){const n=this.options.setContext(this.getContext());let s=this.opacity;if(!s)return;this._updateAnimationTarget(n);const i={width:this.width,height:this.height},a={x:this.x,y:this.y};s=Math.abs(s)<.001?0:s;const o=Lr(n.padding),l=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;n.enabled&&l&&(t.save(),t.globalAlpha=s,this.drawBackground(a,t,i,n),YV(t,n.textDirection),a.y+=o.top,this.drawTitle(a,t,n),this.drawBody(a,t,n),this.drawFooter(a,t,n),QV(t,n.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,n){const s=this._active,i=t.map(({datasetIndex:l,index:c})=>{const d=this.chart.getDatasetMeta(l);if(!d)throw new Error("Cannot find a dataset at index "+l);return{datasetIndex:l,element:d.data[c],index:c}}),a=!I0(s,i),o=this._positionChanged(i,n);(a||o)&&(this._active=i,this._eventPosition=n,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,n,s=!0){if(n&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const i=this.options,a=this._active||[],o=this._getActiveElements(t,a,n,s),l=this._positionChanged(o,t),c=n||!I0(o,a)||l;return c&&(this._active=o,(i.enabled||i.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,n))),c}_getActiveElements(t,n,s,i){const a=this.options;if(t.type==="mouseout")return[];if(!i)return n.filter(l=>this.chart.data.datasets[l.datasetIndex]&&this.chart.getDatasetMeta(l.datasetIndex).controller.getParsed(l.index)!==void 0);const o=this.chart.getElementsAtEventForMode(t,a.mode,a,s);return a.reverse&&o.reverse(),o}_positionChanged(t,n){const{caretX:s,caretY:i,options:a}=this,o=tp[a.position].call(this,t,n);return o!==!1&&(s!==o.x||i!==o.y)}}var jNe={id:"tooltip",_element:qD,positioners:tp,afterInit(e,t,n){n&&(e.tooltip=new qD({chart:e,options:n}))},beforeUpdate(e,t,n){e.tooltip&&e.tooltip.initialize(n)},reset(e,t,n){e.tooltip&&e.tooltip.initialize(n)},afterDraw(e){const t=e.tooltip;if(t&&t._willRender()){const n={tooltip:t};if(e.notifyPlugins("beforeTooltipDraw",{...n,cancelable:!0})===!1)return;t.draw(e.ctx),e.notifyPlugins("afterTooltipDraw",n)}},afterEvent(e,t){if(e.tooltip){const n=t.replay;e.tooltip.handleEvent(t.event,n,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(e,t)=>t.bodyFont.size,boxWidth:(e,t)=>t.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:yU},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:e=>e!=="filter"&&e!=="itemSort"&&e!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]};const NNe=(e,t,n,s)=>(typeof t=="string"?(n=e.push(t)-1,s.unshift({index:n,label:t})):isNaN(t)&&(n=null),n);function kNe(e,t,n,s){const i=e.indexOf(t);if(i===-1)return NNe(e,t,n,s);const a=e.lastIndexOf(t);return i!==a?n:i}const ENe=(e,t)=>e===null?null:Ws(Math.round(e),0,t);function GD(e){const t=this.getLabels();return e>=0&&e<t.length?t[e]:e}class FNe extends Ah{static id="category";static defaults={ticks:{callback:GD}};constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){const n=this._addedLabels;if(n.length){const s=this.getLabels();for(const{index:i,label:a}of n)s[i]===a&&s.splice(i,1);this._addedLabels=[]}super.init(t)}parse(t,n){if(Tt(t))return null;const s=this.getLabels();return n=isFinite(n)&&s[n]===t?n:kNe(s,t,it(n,t),this._addedLabels),ENe(n,s.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:n}=this.getUserBounds();let{min:s,max:i}=this.getMinMax(!0);this.options.bounds==="ticks"&&(t||(s=0),n||(i=this.getLabels().length-1)),this.min=s,this.max=i}buildTicks(){const t=this.min,n=this.max,s=this.options.offset,i=[];let a=this.getLabels();a=t===0&&n===a.length-1?a:a.slice(t,n+1),this._valueRange=Math.max(a.length-(s?0:1),1),this._startValue=this.min-(s?.5:0);for(let o=t;o<=n;o++)i.push({value:o});return i}getLabelForValue(t){return GD.call(this,t)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(t){return typeof t!="number"&&(t=this.parse(t)),t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getPixelForTick(t){const n=this.ticks;return t<0||t>n.length-1?null:this.getPixelForValue(n[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}function TNe(e,t){const n=[],{bounds:i,step:a,min:o,max:l,precision:c,count:d,maxTicks:f,maxDigits:p,includeBounds:m}=e,g=a||1,b=f-1,{min:_,max:w}=t,A=!Tt(o),S=!Tt(l),C=!Tt(d),E=(w-_)/(p+1);let k=UR((w-_)/b/g)*g,T,F,M,I;if(k<1e-14&&!A&&!S)return[{value:_},{value:w}];I=Math.ceil(w/k)-Math.floor(_/k),I>b&&(k=UR(I*k/b/g)*g),Tt(c)||(T=Math.pow(10,c),k=Math.ceil(k*T)/T),i==="ticks"?(F=Math.floor(_/k)*k,M=Math.ceil(w/k)*k):(F=_,M=w),A&&S&&a&&NSe((l-o)/a,k/1e3)?(I=Math.round(Math.min((l-o)/k,f)),k=(l-o)/I,F=o,M=l):C?(F=A?o:F,M=S?l:M,I=d-1,k=(M-F)/I):(I=(M-F)/k,gp(I,Math.round(I),k/1e3)?I=Math.round(I):I=Math.ceil(I));const R=Math.max(HR(k),HR(F));T=Math.pow(10,Tt(c)?R:c),F=Math.round(F*T)/T,M=Math.round(M*T)/T;let H=0;for(A&&(m&&F!==o?(n.push({value:o}),F<o&&H++,gp(Math.round((F+H*k)*T)/T,o,KD(o,E,e))&&H++):F<o&&H++);H<I;++H){const V=Math.round((F+H*k)*T)/T;if(S&&V>l)break;n.push({value:V})}return S&&m&&M!==l?n.length&&gp(n[n.length-1].value,l,KD(l,E,e))?n[n.length-1].value=l:n.push({value:l}):(!S||M===l)&&n.push({value:M}),n}function KD(e,t,{horizontal:n,minRotation:s}){const i=Ao(s),a=(n?Math.sin(i):Math.cos(i))||.001,o=.75*t*(""+e).length;return Math.min(t/a,o)}class MNe extends Ah{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,n){return Tt(t)||(typeof t=="number"||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:n,maxDefined:s}=this.getUserBounds();let{min:i,max:a}=this;const o=c=>i=n?i:c,l=c=>a=s?a:c;if(t){const c=za(i),d=za(a);c<0&&d<0?l(0):c>0&&d>0&&o(0)}if(i===a){let c=a===0?1:Math.abs(a*.05);l(a+c),t||o(i-c)}this.min=i,this.max=a}getTickLimit(){const t=this.options.ticks;let{maxTicksLimit:n,stepSize:s}=t,i;return s?(i=Math.ceil(this.max/s)-Math.floor(this.min/s)+1,i>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${s} would result generating up to ${i} ticks. Limiting to 1000.`),i=1e3)):(i=this.computeTickLimit(),n=n||11),n&&(i=Math.min(n,i)),i}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,n=t.ticks;let s=this.getTickLimit();s=Math.max(2,s);const i={maxTicks:s,bounds:t.bounds,min:t.min,max:t.max,precision:n.precision,step:n.stepSize,count:n.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:n.minRotation||0,includeBounds:n.includeBounds!==!1},a=this._range||this,o=TNe(i,a);return t.bounds==="ticks"&&kSe(o,this,"value"),t.reverse?(o.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),o}configure(){const t=this.ticks;let n=this.min,s=this.max;if(super.configure(),this.options.offset&&t.length){const i=(s-n)/Math.max(t.length-1,1)/2;n-=i,s+=i}this._startValue=n,this._endValue=s,this._valueRange=s-n}getLabelForValue(t){return hN(t,this.chart.options.locale,this.options.ticks.format)}}class RNe extends MNe{static id="linear";static defaults={ticks:{callback:$V.formatters.numeric}};determineDataLimits(){const{min:t,max:n}=this.getMinMax(!0);this.min=Js(t)?t:0,this.max=Js(n)?n:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),n=t?this.width:this.height,s=Ao(this.options.ticks.minRotation),i=(t?Math.sin(s):Math.cos(s))||.001,a=this._resolveTickFontOptions(0);return Math.ceil(n/Math.min(40,a.lineHeight/i))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}const my={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},Ci=Object.keys(my);function YD(e,t){return e-t}function QD(e,t){if(Tt(t))return null;const n=e._adapter,{parser:s,round:i,isoWeekday:a}=e._parseOpts;let o=t;return typeof s=="function"&&(o=s(o)),Js(o)||(o=typeof s=="string"?n.parse(o,s):n.parse(o)),o===null?null:(i&&(o=i==="week"&&(Qd(a)||a===!0)?n.startOf(o,"isoWeek",a):n.startOf(o,i)),+o)}function XD(e,t,n,s){const i=Ci.length;for(let a=Ci.indexOf(e);a<i-1;++a){const o=my[Ci[a]],l=o.steps?o.steps:Number.MAX_SAFE_INTEGER;if(o.common&&Math.ceil((n-t)/(l*o.size))<=s)return Ci[a]}return Ci[i-1]}function DNe(e,t,n,s,i){for(let a=Ci.length-1;a>=Ci.indexOf(n);a--){const o=Ci[a];if(my[o].common&&e._adapter.diff(i,s,o)>=t-1)return o}return Ci[n?Ci.indexOf(n):0]}function ONe(e){for(let t=Ci.indexOf(e)+1,n=Ci.length;t<n;++t)if(my[Ci[t]].common)return Ci[t]}function JD(e,t,n){if(!n)e[t]=!0;else if(n.length){const{lo:s,hi:i}=cN(n,t),a=n[s]>=t?n[s]:n[i];e[a]=!0}}function PNe(e,t,n,s){const i=e._adapter,a=+i.startOf(t[0].value,s),o=t[t.length-1].value;let l,c;for(l=a;l<=o;l=+i.add(l,1,s))c=n[l],c>=0&&(t[c].major=!0);return t}function ZD(e,t,n){const s=[],i={},a=t.length;let o,l;for(o=0;o<a;++o)l=t[o],i[l]=o,s.push({value:l,major:!1});return a===0||!n?s:PNe(e,s,i,n)}class e8 extends Ah{static id="time";static defaults={bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",callback:!1,major:{enabled:!1}}};constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,n={}){const s=t.time||(t.time={}),i=this._adapter=new f5e._date(t.adapters.date);i.init(n),xp(s.displayFormats,i.formats()),this._parseOpts={parser:s.parser,round:s.round,isoWeekday:s.isoWeekday},super.init(t),this._normalized=n.normalized}parse(t,n){return t===void 0?null:QD(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,n=this._adapter,s=t.time.unit||"day";let{min:i,max:a,minDefined:o,maxDefined:l}=this.getUserBounds();function c(d){!o&&!isNaN(d.min)&&(i=Math.min(i,d.min)),!l&&!isNaN(d.max)&&(a=Math.max(a,d.max))}(!o||!l)&&(c(this._getLabelBounds()),(t.bounds!=="ticks"||t.ticks.source!=="labels")&&c(this.getMinMax(!1))),i=Js(i)&&!isNaN(i)?i:+n.startOf(Date.now(),s),a=Js(a)&&!isNaN(a)?a:+n.endOf(Date.now(),s)+1,this.min=Math.min(i,a-1),this.max=Math.max(i+1,a)}_getLabelBounds(){const t=this.getLabelTimestamps();let n=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;return t.length&&(n=t[0],s=t[t.length-1]),{min:n,max:s}}buildTicks(){const t=this.options,n=t.time,s=t.ticks,i=s.source==="labels"?this.getLabelTimestamps():this._generate();t.bounds==="ticks"&&i.length&&(this.min=this._userMin||i[0],this.max=this._userMax||i[i.length-1]);const a=this.min,o=this.max,l=RSe(i,a,o);return this._unit=n.unit||(s.autoSkip?XD(n.minUnit,this.min,this.max,this._getLabelCapacity(a)):DNe(this,l.length,n.minUnit,this.min,this.max)),this._majorUnit=!s.major.enabled||this._unit==="year"?void 0:ONe(this._unit),this.initOffsets(i),t.reverse&&l.reverse(),ZD(this,l,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map(t=>+t.value))}initOffsets(t=[]){let n=0,s=0,i,a;this.options.offset&&t.length&&(i=this.getDecimalForValue(t[0]),t.length===1?n=1-i:n=(this.getDecimalForValue(t[1])-i)/2,a=this.getDecimalForValue(t[t.length-1]),t.length===1?s=a:s=(a-this.getDecimalForValue(t[t.length-2]))/2);const o=t.length<3?.5:.25;n=Ws(n,0,o),s=Ws(s,0,o),this._offsets={start:n,end:s,factor:1/(n+1+s)}}_generate(){const t=this._adapter,n=this.min,s=this.max,i=this.options,a=i.time,o=a.unit||XD(a.minUnit,n,s,this._getLabelCapacity(n)),l=it(i.ticks.stepSize,1),c=o==="week"?a.isoWeekday:!1,d=Qd(c)||c===!0,f={};let p=n,m,g;if(d&&(p=+t.startOf(p,"isoWeek",c)),p=+t.startOf(p,d?"day":o),t.diff(s,n,o)>1e5*l)throw new Error(n+" and "+s+" are too far apart with stepSize of "+l+" "+o);const b=i.ticks.source==="data"&&this.getDataTimestamps();for(m=p,g=0;m<s;m=+t.add(m,l,o),g++)JD(f,m,b);return(m===s||i.bounds==="ticks"||g===1)&&JD(f,m,b),Object.keys(f).sort(YD).map(_=>+_)}getLabelForValue(t){const n=this._adapter,s=this.options.time;return s.tooltipFormat?n.format(t,s.tooltipFormat):n.format(t,s.displayFormats.datetime)}format(t,n){const i=this.options.time.displayFormats,a=this._unit,o=n||i[a];return this._adapter.format(t,o)}_tickFormatFunction(t,n,s,i){const a=this.options,o=a.ticks.callback;if(o)return rn(o,[t,n,s],this);const l=a.time.displayFormats,c=this._unit,d=this._majorUnit,f=c&&l[c],p=d&&l[d],m=s[n],g=d&&p&&m&&m.major;return this._adapter.format(t,i||(g?p:f))}generateTickLabels(t){let n,s,i;for(n=0,s=t.length;n<s;++n)i=t[n],i.label=this._tickFormatFunction(i.value,n,t)}getDecimalForValue(t){return t===null?NaN:(t-this.min)/(this.max-this.min)}getPixelForValue(t){const n=this._offsets,s=this.getDecimalForValue(t);return this.getPixelForDecimal((n.start+s)*n.factor)}getValueForPixel(t){const n=this._offsets,s=this.getDecimalForPixel(t)/n.factor-n.end;return this.min+s*(this.max-this.min)}_getLabelSize(t){const n=this.options.ticks,s=this.ctx.measureText(t).width,i=Ao(this.isHorizontal()?n.maxRotation:n.minRotation),a=Math.cos(i),o=Math.sin(i),l=this._resolveTickFontOptions(0).size;return{w:s*a+l*o,h:s*o+l*a}}_getLabelCapacity(t){const n=this.options.time,s=n.displayFormats,i=s[n.unit]||s.millisecond,a=this._tickFormatFunction(t,0,ZD(this,[t],this._majorUnit),i),o=this._getLabelSize(a),l=Math.floor(this.isHorizontal()?this.width/o.w:this.height/o.h)-1;return l>0?l:1}getDataTimestamps(){let t=this._cache.data||[],n,s;if(t.length)return t;const i=this.getMatchingVisibleMetas();if(this._normalized&&i.length)return this._cache.data=i[0].controller.getAllParsedValues(this);for(n=0,s=i.length;n<s;++n)t=t.concat(i[n].controller.getAllParsedValues(this));return this._cache.data=this.normalize(t)}getLabelTimestamps(){const t=this._cache.labels||[];let n,s;if(t.length)return t;const i=this.getLabels();for(n=0,s=i.length;n<s;++n)t.push(QD(this,i[n]));return this._cache.labels=this._normalized?t:this.normalize(t)}normalize(t){return PV(t.sort(YD))}}function tb(e,t,n){let s=0,i=e.length-1,a,o,l,c;n?(t>=e[s].pos&&t<=e[i].pos&&({lo:s,hi:i}=Gc(e,"pos",t)),{pos:a,time:l}=e[s],{pos:o,time:c}=e[i]):(t>=e[s].time&&t<=e[i].time&&({lo:s,hi:i}=Gc(e,"time",t)),{time:a,pos:l}=e[s],{time:o,pos:c}=e[i]);const d=o-a;return d?l+(c-l)*(t-a)/d:l}class Y8e extends e8{static id="timeseries";static defaults=e8.defaults;constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),n=this._table=this.buildLookupTable(t);this._minPos=tb(n,this.min),this._tableRange=tb(n,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:n,max:s}=this,i=[],a=[];let o,l,c,d,f;for(o=0,l=t.length;o<l;++o)d=t[o],d>=n&&d<=s&&i.push(d);if(i.length<2)return[{time:n,pos:0},{time:s,pos:1}];for(o=0,l=i.length;o<l;++o)f=i[o+1],c=i[o-1],d=i[o],Math.round((f+c)/2)!==d&&a.push({time:d,pos:o/(l-1)});return a}_generate(){const t=this.min,n=this.max;let s=super.getDataTimestamps();return(!s.includes(t)||!s.length)&&s.splice(0,0,t),(!s.includes(n)||s.length===1)&&s.push(n),s.sort((i,a)=>i-a)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const n=this.getDataTimestamps(),s=this.getLabelTimestamps();return n.length&&s.length?t=this.normalize(n.concat(s)):t=n.length?n:s,t=this._cache.all=t,t}getDecimalForValue(t){return(tb(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const n=this._offsets,s=this.getDecimalForPixel(t)/n.factor-n.end;return tb(this._table,s*this._tableRange+this._minPos,!0)}}const _U="label";function t8(e,t){typeof e=="function"?e(t):e&&(e.current=t)}function INe(e,t){const n=e.options;n&&t&&Object.assign(n,t)}function wU(e,t){e.labels=t}function AU(e,t,n=_U){const s=[];e.datasets=t.map(i=>{const a=e.datasets.find(o=>o[n]===i[n]);return!a||!i.data||s.includes(a)?{...i}:(s.push(a),Object.assign(a,i),a)})}function LNe(e,t=_U){const n={labels:[],datasets:[]};return wU(n,e.labels),AU(n,e.datasets,t),n}function BNe(e,t){const{height:n=150,width:s=300,redraw:i=!1,datasetIdKey:a,type:o,data:l,options:c,plugins:d=[],fallbackContent:f,updateMode:p,...m}=e,g=y.useRef(null),b=y.useRef(null),_=()=>{g.current&&(b.current=new hy(g.current,{type:o,data:LNe(l,a),options:c&&{...c},plugins:d}),t8(t,b.current))},w=()=>{t8(t,null),b.current&&(b.current.destroy(),b.current=null)};return y.useEffect(()=>{!i&&b.current&&c&&INe(b.current,c)},[i,c]),y.useEffect(()=>{!i&&b.current&&wU(b.current.config.data,l.labels)},[i,l.labels]),y.useEffect(()=>{!i&&b.current&&l.datasets&&AU(b.current.config.data,l.datasets,a)},[i,l.datasets]),y.useEffect(()=>{b.current&&(i?(w(),setTimeout(_)):b.current.update(p))},[i,c,l.labels,l.datasets,p]),y.useEffect(()=>{b.current&&(w(),setTimeout(_))},[o]),y.useEffect(()=>(_(),()=>w()),[]),r.jsx("canvas",{ref:g,role:"img",height:n,width:s,...m,children:f})}const zNe=y.forwardRef(BNe);function xy(e,t){return hy.register(t),y.forwardRef((n,s)=>r.jsx(zNe,{...n,ref:s,type:e}))}const $Ne=xy("line",u5e),n8=xy("bar",o5e),VNe=xy("pie",d5e),UNe=xy("scatter",h5e);hy.register(FNe,RNe,Lje,fy,Hje,kje,bNe,jNe,xNe,uNe);const $f=["#6366F1","#8B5CF6","#EC4899","#10B981","#F59E0B","#EF4444","#3B82F6","#14B8A6","#F97316","#84CC16"];function HNe({data:e}){const t=y.useMemo(()=>({labels:e.labels,datasets:e.datasets.map((i,a)=>({...i,backgroundColor:i.backgroundColor??(e.type==="pie"?$f.slice(0,e.labels.length):`${$f[a%$f.length]}88`),borderColor:i.borderColor??$f[a%$f.length],borderWidth:e.type==="pie"?0:2,pointRadius:e.type==="scatter"?4:3,tension:.3}))}),[e]),n=y.useMemo(()=>({responsive:!0,maintainAspectRatio:!1,plugins:{title:e.title?{display:!0,text:e.title,color:"#F0F0F5",font:{size:12,weight:500},padding:{bottom:12}}:{display:!1},legend:{display:e.datasets.length>1||e.type==="pie",position:"bottom",labels:{color:"#8A8A99",font:{size:10},boxWidth:10,padding:8}},tooltip:{backgroundColor:"#1C1C21",titleColor:"#F0F0F5",bodyColor:"#C8C8D4",borderColor:"#2A2A35",borderWidth:1,titleFont:{size:11},bodyFont:{size:10},padding:8}},scales:e.type==="pie"?{}:{x:{ticks:{color:"#5A5A6E",font:{size:10}},grid:{color:"#2A2A35",drawBorder:!1}},y:{ticks:{color:"#5A5A6E",font:{size:10}},grid:{color:"#2A2A35",drawBorder:!1}}}}),[e]),s={bar:n8,line:$Ne,pie:VNe,scatter:UNe}[e.type]??n8;return r.jsx("div",{className:"p-4",style:{height:e.type==="pie"?320:280},children:r.jsx(s,{data:t,options:n})})}function WNe({data:e,onChange:t}){const[n,s]=y.useState(null),[i,a]=y.useState(!0),[o,l]=y.useState(""),[c,d]=y.useState(null),[f,p]=y.useState(""),m=y.useCallback(A=>{n===A?a(S=>!S):(s(A),a(!0))},[n]),g=y.useMemo(()=>{if(!o.trim())return e.rows;const A=o.toLowerCase();return e.rows.filter(S=>e.columns.some(C=>String(S[C.key]??"").toLowerCase().includes(A)))},[e.rows,e.columns,o]),b=y.useMemo(()=>{if(!n)return g;const A=e.columns.find(S=>S.key===n);return[...g].sort((S,C)=>{const E=S[n]??"",k=C[n]??"";return A?.type==="number"||typeof E=="number"&&typeof k=="number"?i?Number(E)-Number(k):Number(k)-Number(E):i?String(E).localeCompare(String(k)):String(k).localeCompare(String(E))})},[g,n,i,e.columns]),_=y.useCallback((A,S,C)=>{d({row:A,key:S}),p(String(C??""))},[]),w=y.useCallback(()=>{if(!c)return;if(!e.rows[c.row]){d(null);return}const S=e.columns.find(k=>k.key===c.key);let C=f;S?.type==="number"&&(C=Number(f)||0);const E=e.rows.map((k,T)=>T===c.row?{...k,[c.key]:C}:k);t({...e,rows:E}),d(null)},[c,f,e,t]);return r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-[#2A2A35]",children:[e.title&&r.jsx("span",{className:"text-[11px] font-semibold text-[#F0F0F5] mr-2",children:e.title}),r.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded bg-[#1C1C21] border border-[#2A2A35] flex-1 max-w-[200px]",children:[r.jsx(Io,{className:"w-3 h-3 text-[#5A5A6E]"}),r.jsx("input",{value:o,onChange:A=>l(A.target.value),placeholder:"Filter...",className:"flex-1 bg-transparent text-[11px] text-[#C8C8D4] placeholder-[#5A5A6E] outline-none"})]}),r.jsxs("span",{className:"text-[10px] text-[#5A5A6E] ml-auto",children:[b.length," / ",e.rows.length]})]}),r.jsxs("div",{className:"overflow-auto max-h-[500px]",children:[r.jsxs("table",{className:"w-full text-[11px]",children:[r.jsx("thead",{className:"sticky top-0 bg-[#16161A] z-10",children:r.jsx("tr",{className:"border-b border-[#2A2A35]",children:e.columns.map(A=>r.jsx("th",{onClick:()=>m(A.key),className:"px-3 py-2 text-left text-[#8A8A99] font-medium cursor-pointer hover:text-[#C8C8D4] transition-colors whitespace-nowrap select-none",children:r.jsxs("span",{className:"inline-flex items-center gap-1",children:[A.label,n===A.key?i?r.jsx(vse,{className:"w-3 h-3 text-[#6366F1]"}):r.jsx(fse,{className:"w-3 h-3 text-[#6366F1]"}):r.jsx(gse,{className:"w-3 h-3 opacity-30"})]})},A.key))})}),r.jsx("tbody",{children:b.map((A,S)=>{const C=e.rows.indexOf(A);return r.jsx("tr",{className:"border-b border-[#2A2A35]/50 hover:bg-white/[0.02]",children:e.columns.map(E=>{const k=c?.row===C&&c?.key===E.key;return r.jsx("td",{className:"px-3 py-1.5 text-[#C8C8D4]",children:k?r.jsx("input",{value:f,onChange:T=>p(T.target.value),onBlur:w,onKeyDown:T=>{T.key==="Enter"&&w(),T.key==="Escape"&&d(null)},className:"w-full bg-[#1C1C21] text-[11px] text-[#F0F0F5] rounded px-1 py-0.5 outline-none border border-[#6366F1]/30",autoFocus:!0}):r.jsx("span",{onDoubleClick:()=>_(C,E.key,A[E.key]),className:"cursor-default",children:String(A[E.key]??"")})},E.key)})},S)})})]}),b.length===0&&r.jsx("p",{className:"px-4 py-6 text-center text-[11px] text-[#5A5A6E] italic",children:o?"No matching rows.":"No data."})]})]})}const s8=[{bg:"bg-[#6366F1]/10",text:"text-[#818CF8]"},{bg:"bg-[#10B981]/10",text:"text-[#34D399]"},{bg:"bg-[#EC4899]/10",text:"text-[#F472B6]"},{bg:"bg-[#F59E0B]/10",text:"text-[#FBBF24]"},{bg:"bg-[#EF4444]/10",text:"text-[#F87171]"},{bg:"bg-[#3B82F6]/10",text:"text-[#60A5FA]"}];function qNe(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return s8[Math.abs(t)%s8.length]}function GNe({card:e,onEdit:t,onRemove:n}){const[s,i]=y.useState(!1),[a,o]=y.useState(e.title),[l,c]=y.useState(e.description??""),d=y.useCallback(()=>{a.trim()&&t(e.id,a.trim(),l.trim()),i(!1)},[e.id,a,l,t]);return s?r.jsxs("div",{className:"bg-[#16161A] rounded-lg border border-[#6366F1]/30 p-3",children:[r.jsx("input",{value:a,onChange:f=>o(f.target.value),onKeyDown:f=>f.key==="Enter"&&d(),className:"w-full bg-transparent text-[12px] text-[#F0F0F5] outline-none font-medium mb-1.5",autoFocus:!0}),r.jsx("textarea",{value:l,onChange:f=>c(f.target.value),rows:3,className:"w-full bg-transparent text-[11px] text-[#8A8A99] outline-none resize-none",placeholder:"Description..."}),r.jsxs("div",{className:"flex justify-end gap-1 mt-2",children:[r.jsx("button",{onClick:()=>i(!1),className:"p-1 text-[#5A5A6E] hover:text-[#C8C8D4]",children:r.jsx(Te,{className:"w-3 h-3"})}),r.jsx("button",{onClick:d,className:"p-1 text-[#10B981] hover:text-[#34D399]",children:r.jsx(Fe,{className:"w-3 h-3"})})]})]}):r.jsxs("div",{className:"bg-[#16161A] rounded-lg border border-[#2A2A35] hover:border-[#3A3A45] transition-colors group",children:[e.image&&r.jsx("div",{className:"aspect-video overflow-hidden rounded-t-lg",children:r.jsx("img",{src:e.image,alt:"",className:"w-full h-full object-cover"})}),r.jsxs("div",{className:"p-3",children:[r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsx("h4",{className:"text-[12px] font-medium text-[#F0F0F5] leading-snug",children:e.title}),r.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",children:[e.url&&r.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"p-0.5 text-[#5A5A6E] hover:text-[#6366F1]",children:r.jsx(cs,{className:"w-2.5 h-2.5"})}),r.jsx("button",{onClick:()=>i(!0),className:"p-0.5 text-[#5A5A6E] hover:text-[#C8C8D4]",children:r.jsx(oh,{className:"w-2.5 h-2.5"})}),r.jsx("button",{onClick:()=>n(e.id),className:"p-0.5 text-[#5A5A6E] hover:text-[#EF4444]",children:r.jsx(Te,{className:"w-2.5 h-2.5"})})]})]}),e.description&&r.jsx("p",{className:"text-[11px] text-[#8A8A99] mt-1 leading-snug line-clamp-3",children:e.description}),e.tags&&e.tags.length>0&&r.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:e.tags.map(f=>{const p=qNe(f);return r.jsx("span",{className:`px-1.5 py-0.5 rounded text-[9px] font-medium ${p.bg} ${p.text}`,children:f},f)})}),e.meta&&Object.keys(e.meta).length>0&&r.jsx("div",{className:"mt-2 pt-2 border-t border-[#2A2A35]/50 space-y-0.5",children:Object.entries(e.meta).map(([f,p])=>r.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[r.jsxs("span",{className:"text-[#5A5A6E]",children:[f,":"]}),r.jsx("span",{className:"text-[#C8C8D4]",children:p})]},f))})]})]})}function KNe({data:e,onChange:t}){const n=e.columns??3,s=y.useCallback((a,o,l)=>{const c=e.cards.map(d=>d.id===a?{...d,title:o,description:l}:d);t({...e,cards:c})},[e,t]),i=y.useCallback(a=>{t({...e,cards:e.cards.filter(o=>o.id!==a)})},[e,t]);return r.jsxs("div",{className:"p-3",children:[e.title&&r.jsx("h3",{className:"text-[12px] font-semibold text-[#F0F0F5] mb-3",children:e.title}),r.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${Math.min(n,4)}, minmax(0, 1fr))`},children:e.cards.map(a=>r.jsx(GNe,{card:a,onEdit:s,onRemove:i},a.id))}),e.cards.length===0&&r.jsx("p",{className:"text-center py-8 text-[11px] text-[#5A5A6E] italic",children:"No cards"})]})}function SU(e){return e.endsWith(".kanban.json")?"kanban":e.endsWith(".chart.json")?"chart":e.endsWith(".table.json")?"table":e.endsWith(".board.json")?"board":null}function CU(e){return SU(e)!==null}function YNe(e,t){if(!t||typeof t!="object")return!1;switch(e){case"kanban":return Array.isArray(t.columns);case"chart":return typeof t.type=="string"&&Array.isArray(t.labels)&&Array.isArray(t.datasets);case"table":return Array.isArray(t.columns)&&Array.isArray(t.rows);case"board":return Array.isArray(t.cards);default:return!1}}function jU({agentId:e,filePath:t,content:n}){const s=SU(t),i=L.files.writeStructured.useMutation(),a=y.useRef(void 0),o=y.useMemo(()=>{try{return JSON.parse(n)}catch{return null}},[n]),[l,c]=y.useState(o),[d,f]=y.useState(!1);y.useEffect(()=>{c(o),f(!1)},[o]);const p=y.useCallback(m=>{c(m),f(!0),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{const g=JSON.stringify(m,null,2);i.mutate({agentId:e,filePath:t,content:g}),f(!1)},800)},[e,t,i]);return y.useEffect(()=>()=>{a.current&&clearTimeout(a.current)},[]),!s||!l||!YNe(s,l)?null:r.jsxs("div",{className:"relative",children:[d&&r.jsx("div",{className:"absolute top-2 right-3 z-10",children:r.jsx("span",{className:"text-[9px] text-[#F59E0B] bg-[#F59E0B]/10 px-1.5 py-0.5 rounded",children:"Saving..."})}),s==="kanban"&&r.jsx(G2e,{data:l,onChange:p}),s==="chart"&&r.jsx(HNe,{data:l}),s==="table"&&r.jsx(WNe,{data:l,onChange:p}),s==="board"&&r.jsx(KNe,{data:l,onChange:p})]})}const QNe={kanban:"Kanban Board",chart:"Chart",table:"Data Table",board:"Card Grid"};function XNe(e){for(const[t,n]of Object.entries(QNe))if(e.endsWith(`.${t}.json`))return n;return"Structured File"}function yN({agentId:e,filePath:t,onClose:n}){const s=t.split("/").pop()??t,i=XNe(s),{data:a,isLoading:o}=L.files.read.useQuery({agentId:e,filePath:t},{retry:!1});return r.jsx(ji,{open:!0,onOpenChange:l=>{l||n()},children:r.jsxs(Ni,{children:[r.jsx(ir,{className:"fixed inset-0 bg-black/60 z-40"}),r.jsxs(ki,{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[90vw] max-w-[1100px] max-h-[85vh] bg-[#13131A] border border-[#2A2A35] rounded-xl shadow-2xl z-50 flex flex-col",children:[r.jsxs("div",{className:"px-4 py-3 border-b border-[#2A2A35] flex items-center justify-between flex-shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx(nr,{className:"text-[13px] font-semibold text-[#F0F0F5] truncate",children:s}),r.jsx("span",{className:"text-[10px] text-[#5A5A6E] bg-white/[0.04] px-1.5 py-0.5 rounded flex-shrink-0",children:i})]}),r.jsx(Gs,{asChild:!0,children:r.jsx("button",{className:"w-7 h-7 flex items-center justify-center rounded-md text-[#5A5A6E] hover:text-[#C8C8D4] hover:bg-white/5 transition-colors",children:r.jsx(Te,{className:"w-4 h-4"})})})]}),r.jsxs("div",{className:"flex-1 overflow-auto min-h-0",children:[o&&r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsxs("div",{className:"flex items-center gap-1.5 text-[#5A5A6E]",children:[r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#5A5A6E] animate-pulse"}),r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#5A5A6E] animate-pulse [animation-delay:0.2s]"}),r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#5A5A6E] animate-pulse [animation-delay:0.4s]"})]})}),!o&&a?.content&&r.jsx(jU,{agentId:e,filePath:t,content:a.content}),!o&&!a?.content&&r.jsx("p",{className:"text-center py-12 text-[12px] text-[#5A5A6E]",children:"Unable to load file."})]})]})]})})}const JNe=/\.(kanban|chart|table|board)\.json$/;function ZNe(e){const t=e.match(JNe);return t?t[1]:null}const eke={kanban:nL,chart:M5,table:wL,board:ym},tke={kanban:"#6366F1",chart:"#10B981",table:"#3B82F6",board:"#8B5CF6"};function nke(e,t){try{const n=JSON.parse(t);switch(e){case"kanban":{const s=Array.isArray(n.columns)?n.columns.length:0,i=Array.isArray(n.columns)?n.columns.reduce((a,o)=>a+(Array.isArray(o.cards)?o.cards.length:0),0):0;return`${s} columns, ${i} cards`}case"chart":{const s=n.type??"unknown",i=Array.isArray(n.labels)?n.labels.length:0;return`${s} chart — ${i} data points`}case"table":{const s=Array.isArray(n.rows)?n.rows.length:0,i=Array.isArray(n.columns)?n.columns.length:0;return`${s} rows × ${i} columns`}case"board":return`${Array.isArray(n.cards)?n.cards.length:0} cards`}}catch{return"structured file"}}function ske({agentId:e,filePath:t,filename:n,content:s}){const[i,a]=y.useState(!1),o=ZNe(n);if(!o)return null;const l=eke[o],c=tke[o],d=s?nke(o,s):null;return r.jsxs(r.Fragment,{children:[r.jsxs(ne.button,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2},onClick:()=>a(!0),className:"flex items-center gap-2.5 px-3 py-2 rounded-lg border transition-colors duration-100 hover:brightness-110 w-fit max-w-[380px] group",style:{backgroundColor:`${c}08`,borderColor:`${c}25`},children:[r.jsx("div",{className:"w-7 h-7 rounded-md flex items-center justify-center flex-shrink-0",style:{backgroundColor:`${c}18`},children:r.jsx(l,{className:"w-3.5 h-3.5",style:{color:c}})}),r.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[r.jsx("span",{className:"text-[12px] font-medium text-[#F0F0F5] truncate max-w-[280px]",children:n}),d&&r.jsx("span",{className:"text-[11px] text-[#8A8A99]",children:d})]})]}),i&&r.jsx(yN,{agentId:e,filePath:t,onClose:()=>a(!1)})]})}const NU=$o(e=>({cardsByChannel:{},addCard:(t,n)=>e(s=>{const i=s.cardsByChannel[t]??[],a=`${n.agentId}:${n.filePath}`,o=i.filter(l=>`${l.agentId}:${l.filePath}`!==a);return{cardsByChannel:{...s.cardsByChannel,[t]:[...o,n]}}}),dismissCard:(t,n)=>e(s=>{const i=s.cardsByChannel[t];return i?{cardsByChannel:{...s.cardsByChannel,[t]:i.filter(a=>a.id!==n)}}:s})}));function ike({channelId:e,agentForChannel:t,agentColor:n,messages:s=[],isThinking:i,isLoading:a,loadMore:o,firstUnreadId:l}){const{data:c=[]}=Vo(),d=y.useRef(null),f=y.useRef(null),[p,m]=y.useState(!1),[g,b]=y.useState(!0),_=y.useRef(0),w=L.readReceipts.markRead.useMutation(),A=Je(R=>R.setUnreadCount),S=y.useRef(!1),C=Je(R=>R.fileEditApprovalsByChannel[e])??[],E=Je(R=>R.removeFileEditApproval),k=NU(R=>R.cardsByChannel[e])??[],{data:T}=L.fileEditApprovals.list.useQuery({channelId:e},{staleTime:3e4});y.useEffect(()=>{if(!T)return;const R=Je.getState().addFileEditApproval;for(const H of T)R(H)},[T]),y.useEffect(()=>{d.current?.scrollIntoView({behavior:"instant"})},[e]);const F=s.length>0?s[s.length-1]?.id:null;y.useEffect(()=>{d.current?.scrollIntoView({behavior:"smooth"})},[F]),y.useEffect(()=>{if(l&&!S.current){const R=document.getElementById(`msg-${l}`);R&&(R.scrollIntoView({behavior:"smooth",block:"start"}),S.current=!0)}},[l,s]),y.useEffect(()=>{S.current=!1},[e]),y.useEffect(()=>{s.length!==0&&(w.mutate({channelId:e}),A(e,0))},[e,s.length]);const M=y.useCallback(async()=>{const R=f.current;if(!(!R||!o||p||!g)&&R.scrollTop<100){m(!0),_.current=R.scrollHeight;const H=await o();b(H??!1),m(!1),requestAnimationFrame(()=>{const V=R.scrollHeight;R.scrollTop=V-_.current})}},[o,p,g]),I=i&&t?[{...t,status:"thinking"}]:t?[t].filter(R=>R.status==="thinking"||R.status==="executing"):c.filter(R=>s.some(V=>V.sender.id===R.id)&&(R.status==="thinking"||R.status==="executing"));return a?r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsxs("div",{className:"flex items-center gap-2 text-[#8A8A99]",children:[r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#8A8A99] animate-pulse"}),r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#8A8A99] animate-pulse [animation-delay:0.2s]"}),r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#8A8A99] animate-pulse [animation-delay:0.4s]"})]})}):r.jsxs("div",{ref:f,onScroll:M,className:"flex-1 overflow-y-auto overflow-x-hidden py-2 scrollbar-agent",style:n?{"--agent-color":n}:void 0,"data-channel":e,children:[p&&r.jsx("div",{className:"flex justify-center py-3",children:r.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] text-[#8A8A99]",children:[r.jsx("div",{className:"w-1 h-1 rounded-full bg-[#8A8A99] animate-pulse"}),r.jsx("div",{className:"w-1 h-1 rounded-full bg-[#8A8A99] animate-pulse [animation-delay:0.15s]"}),r.jsx("div",{className:"w-1 h-1 rounded-full bg-[#8A8A99] animate-pulse [animation-delay:0.3s]"})]})}),r.jsx(Me,{initial:!1,children:s.map(R=>{if(R.sender.type==="context_reset"){const V=R.content.startsWith("compacted:");return r.jsxs("div",{id:`msg-${R.id}`,className:"flex items-center gap-3 py-2 px-4",children:[r.jsx("div",{className:"flex-1 h-px bg-[#2A2A35]"}),r.jsx("span",{className:"text-[11px] text-[#5A5A6E]",children:V?"earlier messages summarized":"new context"}),r.jsx("div",{className:"flex-1 h-px bg-[#2A2A35]"})]},R.id)}const H=R.id===l;return r.jsxs("div",{id:`msg-${R.id}`,children:[H&&r.jsxs(ne.div,{initial:{opacity:0},animate:{opacity:1},className:"flex items-center gap-3 px-4 py-1 my-1",children:[r.jsx("div",{className:"flex-1 h-px bg-[#6366F1]/40"}),r.jsx("span",{className:"text-[11px] text-[#6366F1] font-medium shrink-0",children:"New messages"}),r.jsx("div",{className:"flex-1 h-px bg-[#6366F1]/40"})]}),r.jsx(Z7,{message:R,agentColor:n})]},R.id)})}),I.map(R=>r.jsx(U7,{agent:R},`thinking-${R.id}`)),C.length>0&&r.jsx("div",{className:"px-4 py-2",children:C.map(R=>{const H=c.find(V=>V.id===R.agentId);return r.jsx(tAe,{approval:R,agentName:H?.name??R.agentId,onDecided:V=>E(e,V)},R.id)})}),k.length>0&&r.jsx("div",{className:"px-4 py-2 space-y-1.5",children:k.map(R=>r.jsx(ske,{agentId:R.agentId,filePath:R.filePath,filename:R.filename},R.id))}),r.jsx("div",{ref:d,className:"h-4"})]})}function rke(e){const t=e.split(`
|
|
189
|
+
`):e}function vNe(e,t){const{element:n,datasetIndex:s,index:i}=t,a=e.getDatasetMeta(s).controller,{label:o,value:l}=a.getLabelAndValue(i);return{chart:e,label:o,parsed:a.getParsed(i),raw:e.data.datasets[s].data[i],formattedValue:l,dataset:a.getDataset(),dataIndex:i,datasetIndex:s,element:n}}function $D(e,t){const n=e.chart.ctx,{body:s,footer:i,title:a}=e,{boxWidth:o,boxHeight:l}=t,c=qs(t.bodyFont),d=qs(t.titleFont),f=qs(t.footerFont),p=a.length,m=i.length,g=s.length,b=Lr(t.padding);let _=b.height,w=0,A=s.reduce((E,k)=>E+k.before.length+k.lines.length+k.after.length,0);if(A+=e.beforeBody.length+e.afterBody.length,p&&(_+=p*d.lineHeight+(p-1)*t.titleSpacing+t.titleMarginBottom),A){const E=t.displayColors?Math.max(l,c.lineHeight):c.lineHeight;_+=g*E+(A-g)*c.lineHeight+(A-1)*t.bodySpacing}m&&(_+=t.footerMarginTop+m*f.lineHeight+(m-1)*t.footerSpacing);let S=0;const C=function(E){w=Math.max(w,n.measureText(E).width+S)};return n.save(),n.font=d.string,It(e.title,C),n.font=c.string,It(e.beforeBody.concat(e.afterBody),C),S=t.displayColors?o+2+t.boxPadding:0,It(s,E=>{It(E.before,C),It(E.lines,C),It(E.after,C)}),S=0,n.font=f.string,It(e.footer,C),n.restore(),w+=b.width,{width:w,height:_}}function yNe(e,t){const{y:n,height:s}=t;return n<s/2?"top":n>e.height-s/2?"bottom":"center"}function _Ne(e,t,n,s){const{x:i,width:a}=s,o=n.caretSize+n.caretPadding;if(e==="left"&&i+a+o>t.width||e==="right"&&i-a-o<0)return!0}function wNe(e,t,n,s){const{x:i,width:a}=n,{width:o,chartArea:{left:l,right:c}}=e;let d="center";return s==="center"?d=i<=(l+c)/2?"left":"right":i<=a/2?d="left":i>=o-a/2&&(d="right"),_Ne(d,e,t,n)&&(d="center"),d}function VD(e,t,n){const s=n.yAlign||t.yAlign||yNe(e,n);return{xAlign:n.xAlign||t.xAlign||wNe(e,t,n,s),yAlign:s}}function ANe(e,t){let{x:n,width:s}=e;return t==="right"?n-=s:t==="center"&&(n-=s/2),n}function SNe(e,t,n){let{y:s,height:i}=e;return t==="top"?s+=n:t==="bottom"?s-=i+n:s-=i/2,s}function UD(e,t,n,s){const{caretSize:i,caretPadding:a,cornerRadius:o}=e,{xAlign:l,yAlign:c}=n,d=i+a,{topLeft:f,topRight:p,bottomLeft:m,bottomRight:g}=Id(o);let b=ANe(t,l);const _=SNe(t,c,d);return c==="center"?l==="left"?b+=d:l==="right"&&(b-=d):l==="left"?b-=Math.max(f,m)+i:l==="right"&&(b+=Math.max(p,g)+i),{x:Ws(b,0,s.width-t.width),y:Ws(_,0,s.height-t.height)}}function eb(e,t,n){const s=Lr(n.padding);return t==="center"?e.x+e.width/2:t==="right"?e.x+e.width-s.right:e.x+s.left}function HD(e){return wa([],yo(e))}function CNe(e,t,n){return wu(e,{tooltip:t,tooltipItems:n,type:"tooltip"})}function WD(e,t){const n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}const yU={beforeTitle:mo,title(e){if(e.length>0){const t=e[0],n=t.chart.data.labels,s=n?n.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(s>0&&t.dataIndex<s)return n[t.dataIndex]}return""},afterTitle:mo,beforeBody:mo,beforeLabel:mo,label(e){if(this&&this.options&&this.options.mode==="dataset")return e.label+": "+e.formattedValue||e.formattedValue;let t=e.dataset.label||"";t&&(t+=": ");const n=e.formattedValue;return Tt(n)||(t+=n),t},labelColor(e){const n=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{borderColor:n.borderColor,backgroundColor:n.backgroundColor,borderWidth:n.borderWidth,borderDash:n.borderDash,borderDashOffset:n.borderDashOffset,borderRadius:0}},labelTextColor(){return this.options.bodyColor},labelPointStyle(e){const n=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{pointStyle:n.pointStyle,rotation:n.rotation}},afterLabel:mo,afterBody:mo,beforeFooter:mo,footer:mo,afterFooter:mo};function wi(e,t,n,s){const i=e[t].call(n,s);return typeof i>"u"?yU[t].call(n,s):i}class qD extends Wo{static positioners=tp;constructor(t){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=t.chart,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const n=this.chart,s=this.options.setContext(this.getContext()),i=s.enabled&&n.options.animation&&s.animations,a=new tU(this.chart,i);return i._cacheable&&(this._cachedAnimations=Object.freeze(a)),a}getContext(){return this.$context||(this.$context=CNe(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,n){const{callbacks:s}=n,i=wi(s,"beforeTitle",this,t),a=wi(s,"title",this,t),o=wi(s,"afterTitle",this,t);let l=[];return l=wa(l,yo(i)),l=wa(l,yo(a)),l=wa(l,yo(o)),l}getBeforeBody(t,n){return HD(wi(n.callbacks,"beforeBody",this,t))}getBody(t,n){const{callbacks:s}=n,i=[];return It(t,a=>{const o={before:[],lines:[],after:[]},l=WD(s,a);wa(o.before,yo(wi(l,"beforeLabel",this,a))),wa(o.lines,wi(l,"label",this,a)),wa(o.after,yo(wi(l,"afterLabel",this,a))),i.push(o)}),i}getAfterBody(t,n){return HD(wi(n.callbacks,"afterBody",this,t))}getFooter(t,n){const{callbacks:s}=n,i=wi(s,"beforeFooter",this,t),a=wi(s,"footer",this,t),o=wi(s,"afterFooter",this,t);let l=[];return l=wa(l,yo(i)),l=wa(l,yo(a)),l=wa(l,yo(o)),l}_createItems(t){const n=this._active,s=this.chart.data,i=[],a=[],o=[];let l=[],c,d;for(c=0,d=n.length;c<d;++c)l.push(vNe(this.chart,n[c]));return t.filter&&(l=l.filter((f,p,m)=>t.filter(f,p,m,s))),t.itemSort&&(l=l.sort((f,p)=>t.itemSort(f,p,s))),It(l,f=>{const p=WD(t.callbacks,f);i.push(wi(p,"labelColor",this,f)),a.push(wi(p,"labelPointStyle",this,f)),o.push(wi(p,"labelTextColor",this,f))}),this.labelColors=i,this.labelPointStyles=a,this.labelTextColors=o,this.dataPoints=l,l}update(t,n){const s=this.options.setContext(this.getContext()),i=this._active;let a,o=[];if(!i.length)this.opacity!==0&&(a={opacity:0});else{const l=tp[s.position].call(this,i,this._eventPosition);o=this._createItems(s),this.title=this.getTitle(o,s),this.beforeBody=this.getBeforeBody(o,s),this.body=this.getBody(o,s),this.afterBody=this.getAfterBody(o,s),this.footer=this.getFooter(o,s);const c=this._size=$D(this,s),d=Object.assign({},l,c),f=VD(this.chart,s,d),p=UD(s,d,f,this.chart);this.xAlign=f.xAlign,this.yAlign=f.yAlign,a={opacity:1,x:p.x,y:p.y,width:c.width,height:c.height,caretX:l.x,caretY:l.y}}this._tooltipItems=o,this.$context=void 0,a&&this._resolveAnimations().update(this,a),t&&s.external&&s.external.call(this,{chart:this.chart,tooltip:this,replay:n})}drawCaret(t,n,s,i){const a=this.getCaretPosition(t,s,i);n.lineTo(a.x1,a.y1),n.lineTo(a.x2,a.y2),n.lineTo(a.x3,a.y3)}getCaretPosition(t,n,s){const{xAlign:i,yAlign:a}=this,{caretSize:o,cornerRadius:l}=s,{topLeft:c,topRight:d,bottomLeft:f,bottomRight:p}=Id(l),{x:m,y:g}=t,{width:b,height:_}=n;let w,A,S,C,E,k;return a==="center"?(E=g+_/2,i==="left"?(w=m,A=w-o,C=E+o,k=E-o):(w=m+b,A=w+o,C=E-o,k=E+o),S=w):(i==="left"?A=m+Math.max(c,f)+o:i==="right"?A=m+b-Math.max(d,p)-o:A=this.caretX,a==="top"?(C=g,E=C-o,w=A-o,S=A+o):(C=g+_,E=C+o,w=A+o,S=A-o),k=C),{x1:w,x2:A,x3:S,y1:C,y2:E,y3:k}}drawTitle(t,n,s){const i=this.title,a=i.length;let o,l,c;if(a){const d=Ld(s.rtl,this.x,this.width);for(t.x=eb(this,s.titleAlign,s),n.textAlign=d.textAlign(s.titleAlign),n.textBaseline="middle",o=qs(s.titleFont),l=s.titleSpacing,n.fillStyle=s.titleColor,n.font=o.string,c=0;c<a;++c)n.fillText(i[c],d.x(t.x),t.y+o.lineHeight/2),t.y+=o.lineHeight+l,c+1===a&&(t.y+=s.titleMarginBottom-l)}}_drawColorBox(t,n,s,i,a){const o=this.labelColors[s],l=this.labelPointStyles[s],{boxHeight:c,boxWidth:d}=a,f=qs(a.bodyFont),p=eb(this,"left",a),m=i.x(p),g=c<f.lineHeight?(f.lineHeight-c)/2:0,b=n.y+g;if(a.usePointStyle){const _={radius:Math.min(d,c)/2,pointStyle:l.pointStyle,rotation:l.rotation,borderWidth:1},w=i.leftForLtr(m,d)+d/2,A=b+c/2;t.strokeStyle=a.multiKeyBackground,t.fillStyle=a.multiKeyBackground,dC(t,_,w,A),t.strokeStyle=o.borderColor,t.fillStyle=o.backgroundColor,dC(t,_,w,A)}else{t.lineWidth=xt(o.borderWidth)?Math.max(...Object.values(o.borderWidth)):o.borderWidth||1,t.strokeStyle=o.borderColor,t.setLineDash(o.borderDash||[]),t.lineDashOffset=o.borderDashOffset||0;const _=i.leftForLtr(m,d),w=i.leftForLtr(i.xPlus(m,1),d-2),A=Id(o.borderRadius);Object.values(A).some(S=>S!==0)?(t.beginPath(),t.fillStyle=a.multiKeyBackground,z0(t,{x:_,y:b,w:d,h:c,radius:A}),t.fill(),t.stroke(),t.fillStyle=o.backgroundColor,t.beginPath(),z0(t,{x:w,y:b+1,w:d-2,h:c-2,radius:A}),t.fill()):(t.fillStyle=a.multiKeyBackground,t.fillRect(_,b,d,c),t.strokeRect(_,b,d,c),t.fillStyle=o.backgroundColor,t.fillRect(w,b+1,d-2,c-2))}t.fillStyle=this.labelTextColors[s]}drawBody(t,n,s){const{body:i}=this,{bodySpacing:a,bodyAlign:o,displayColors:l,boxHeight:c,boxWidth:d,boxPadding:f}=s,p=qs(s.bodyFont);let m=p.lineHeight,g=0;const b=Ld(s.rtl,this.x,this.width),_=function(M){n.fillText(M,b.x(t.x+g),t.y+m/2),t.y+=m+a},w=b.textAlign(o);let A,S,C,E,k,T,F;for(n.textAlign=o,n.textBaseline="middle",n.font=p.string,t.x=eb(this,w,s),n.fillStyle=s.bodyColor,It(this.beforeBody,_),g=l&&w!=="right"?o==="center"?d/2+f:d+2+f:0,E=0,T=i.length;E<T;++E){for(A=i[E],S=this.labelTextColors[E],n.fillStyle=S,It(A.before,_),C=A.lines,l&&C.length&&(this._drawColorBox(n,t,E,b,s),m=Math.max(p.lineHeight,c)),k=0,F=C.length;k<F;++k)_(C[k]),m=p.lineHeight;It(A.after,_)}g=0,m=p.lineHeight,It(this.afterBody,_),t.y-=a}drawFooter(t,n,s){const i=this.footer,a=i.length;let o,l;if(a){const c=Ld(s.rtl,this.x,this.width);for(t.x=eb(this,s.footerAlign,s),t.y+=s.footerMarginTop,n.textAlign=c.textAlign(s.footerAlign),n.textBaseline="middle",o=qs(s.footerFont),n.fillStyle=s.footerColor,n.font=o.string,l=0;l<a;++l)n.fillText(i[l],c.x(t.x),t.y+o.lineHeight/2),t.y+=o.lineHeight+s.footerSpacing}}drawBackground(t,n,s,i){const{xAlign:a,yAlign:o}=this,{x:l,y:c}=t,{width:d,height:f}=s,{topLeft:p,topRight:m,bottomLeft:g,bottomRight:b}=Id(i.cornerRadius);n.fillStyle=i.backgroundColor,n.strokeStyle=i.borderColor,n.lineWidth=i.borderWidth,n.beginPath(),n.moveTo(l+p,c),o==="top"&&this.drawCaret(t,n,s,i),n.lineTo(l+d-m,c),n.quadraticCurveTo(l+d,c,l+d,c+m),o==="center"&&a==="right"&&this.drawCaret(t,n,s,i),n.lineTo(l+d,c+f-b),n.quadraticCurveTo(l+d,c+f,l+d-b,c+f),o==="bottom"&&this.drawCaret(t,n,s,i),n.lineTo(l+g,c+f),n.quadraticCurveTo(l,c+f,l,c+f-g),o==="center"&&a==="left"&&this.drawCaret(t,n,s,i),n.lineTo(l,c+p),n.quadraticCurveTo(l,c,l+p,c),n.closePath(),n.fill(),i.borderWidth>0&&n.stroke()}_updateAnimationTarget(t){const n=this.chart,s=this.$animations,i=s&&s.x,a=s&&s.y;if(i||a){const o=tp[t.position].call(this,this._active,this._eventPosition);if(!o)return;const l=this._size=$D(this,t),c=Object.assign({},o,this._size),d=VD(n,t,c),f=UD(t,c,d,n);(i._to!==f.x||a._to!==f.y)&&(this.xAlign=d.xAlign,this.yAlign=d.yAlign,this.width=l.width,this.height=l.height,this.caretX=o.x,this.caretY=o.y,this._resolveAnimations().update(this,f))}}_willRender(){return!!this.opacity}draw(t){const n=this.options.setContext(this.getContext());let s=this.opacity;if(!s)return;this._updateAnimationTarget(n);const i={width:this.width,height:this.height},a={x:this.x,y:this.y};s=Math.abs(s)<.001?0:s;const o=Lr(n.padding),l=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;n.enabled&&l&&(t.save(),t.globalAlpha=s,this.drawBackground(a,t,i,n),YV(t,n.textDirection),a.y+=o.top,this.drawTitle(a,t,n),this.drawBody(a,t,n),this.drawFooter(a,t,n),QV(t,n.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,n){const s=this._active,i=t.map(({datasetIndex:l,index:c})=>{const d=this.chart.getDatasetMeta(l);if(!d)throw new Error("Cannot find a dataset at index "+l);return{datasetIndex:l,element:d.data[c],index:c}}),a=!I0(s,i),o=this._positionChanged(i,n);(a||o)&&(this._active=i,this._eventPosition=n,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,n,s=!0){if(n&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const i=this.options,a=this._active||[],o=this._getActiveElements(t,a,n,s),l=this._positionChanged(o,t),c=n||!I0(o,a)||l;return c&&(this._active=o,(i.enabled||i.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,n))),c}_getActiveElements(t,n,s,i){const a=this.options;if(t.type==="mouseout")return[];if(!i)return n.filter(l=>this.chart.data.datasets[l.datasetIndex]&&this.chart.getDatasetMeta(l.datasetIndex).controller.getParsed(l.index)!==void 0);const o=this.chart.getElementsAtEventForMode(t,a.mode,a,s);return a.reverse&&o.reverse(),o}_positionChanged(t,n){const{caretX:s,caretY:i,options:a}=this,o=tp[a.position].call(this,t,n);return o!==!1&&(s!==o.x||i!==o.y)}}var jNe={id:"tooltip",_element:qD,positioners:tp,afterInit(e,t,n){n&&(e.tooltip=new qD({chart:e,options:n}))},beforeUpdate(e,t,n){e.tooltip&&e.tooltip.initialize(n)},reset(e,t,n){e.tooltip&&e.tooltip.initialize(n)},afterDraw(e){const t=e.tooltip;if(t&&t._willRender()){const n={tooltip:t};if(e.notifyPlugins("beforeTooltipDraw",{...n,cancelable:!0})===!1)return;t.draw(e.ctx),e.notifyPlugins("afterTooltipDraw",n)}},afterEvent(e,t){if(e.tooltip){const n=t.replay;e.tooltip.handleEvent(t.event,n,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(e,t)=>t.bodyFont.size,boxWidth:(e,t)=>t.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:yU},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:e=>e!=="filter"&&e!=="itemSort"&&e!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]};const NNe=(e,t,n,s)=>(typeof t=="string"?(n=e.push(t)-1,s.unshift({index:n,label:t})):isNaN(t)&&(n=null),n);function kNe(e,t,n,s){const i=e.indexOf(t);if(i===-1)return NNe(e,t,n,s);const a=e.lastIndexOf(t);return i!==a?n:i}const ENe=(e,t)=>e===null?null:Ws(Math.round(e),0,t);function GD(e){const t=this.getLabels();return e>=0&&e<t.length?t[e]:e}class FNe extends Ah{static id="category";static defaults={ticks:{callback:GD}};constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){const n=this._addedLabels;if(n.length){const s=this.getLabels();for(const{index:i,label:a}of n)s[i]===a&&s.splice(i,1);this._addedLabels=[]}super.init(t)}parse(t,n){if(Tt(t))return null;const s=this.getLabels();return n=isFinite(n)&&s[n]===t?n:kNe(s,t,it(n,t),this._addedLabels),ENe(n,s.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:n}=this.getUserBounds();let{min:s,max:i}=this.getMinMax(!0);this.options.bounds==="ticks"&&(t||(s=0),n||(i=this.getLabels().length-1)),this.min=s,this.max=i}buildTicks(){const t=this.min,n=this.max,s=this.options.offset,i=[];let a=this.getLabels();a=t===0&&n===a.length-1?a:a.slice(t,n+1),this._valueRange=Math.max(a.length-(s?0:1),1),this._startValue=this.min-(s?.5:0);for(let o=t;o<=n;o++)i.push({value:o});return i}getLabelForValue(t){return GD.call(this,t)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(t){return typeof t!="number"&&(t=this.parse(t)),t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getPixelForTick(t){const n=this.ticks;return t<0||t>n.length-1?null:this.getPixelForValue(n[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}function TNe(e,t){const n=[],{bounds:i,step:a,min:o,max:l,precision:c,count:d,maxTicks:f,maxDigits:p,includeBounds:m}=e,g=a||1,b=f-1,{min:_,max:w}=t,A=!Tt(o),S=!Tt(l),C=!Tt(d),E=(w-_)/(p+1);let k=UR((w-_)/b/g)*g,T,F,M,I;if(k<1e-14&&!A&&!S)return[{value:_},{value:w}];I=Math.ceil(w/k)-Math.floor(_/k),I>b&&(k=UR(I*k/b/g)*g),Tt(c)||(T=Math.pow(10,c),k=Math.ceil(k*T)/T),i==="ticks"?(F=Math.floor(_/k)*k,M=Math.ceil(w/k)*k):(F=_,M=w),A&&S&&a&&NSe((l-o)/a,k/1e3)?(I=Math.round(Math.min((l-o)/k,f)),k=(l-o)/I,F=o,M=l):C?(F=A?o:F,M=S?l:M,I=d-1,k=(M-F)/I):(I=(M-F)/k,gp(I,Math.round(I),k/1e3)?I=Math.round(I):I=Math.ceil(I));const R=Math.max(HR(k),HR(F));T=Math.pow(10,Tt(c)?R:c),F=Math.round(F*T)/T,M=Math.round(M*T)/T;let H=0;for(A&&(m&&F!==o?(n.push({value:o}),F<o&&H++,gp(Math.round((F+H*k)*T)/T,o,KD(o,E,e))&&H++):F<o&&H++);H<I;++H){const V=Math.round((F+H*k)*T)/T;if(S&&V>l)break;n.push({value:V})}return S&&m&&M!==l?n.length&&gp(n[n.length-1].value,l,KD(l,E,e))?n[n.length-1].value=l:n.push({value:l}):(!S||M===l)&&n.push({value:M}),n}function KD(e,t,{horizontal:n,minRotation:s}){const i=Ao(s),a=(n?Math.sin(i):Math.cos(i))||.001,o=.75*t*(""+e).length;return Math.min(t/a,o)}class MNe extends Ah{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,n){return Tt(t)||(typeof t=="number"||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:n,maxDefined:s}=this.getUserBounds();let{min:i,max:a}=this;const o=c=>i=n?i:c,l=c=>a=s?a:c;if(t){const c=za(i),d=za(a);c<0&&d<0?l(0):c>0&&d>0&&o(0)}if(i===a){let c=a===0?1:Math.abs(a*.05);l(a+c),t||o(i-c)}this.min=i,this.max=a}getTickLimit(){const t=this.options.ticks;let{maxTicksLimit:n,stepSize:s}=t,i;return s?(i=Math.ceil(this.max/s)-Math.floor(this.min/s)+1,i>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${s} would result generating up to ${i} ticks. Limiting to 1000.`),i=1e3)):(i=this.computeTickLimit(),n=n||11),n&&(i=Math.min(n,i)),i}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,n=t.ticks;let s=this.getTickLimit();s=Math.max(2,s);const i={maxTicks:s,bounds:t.bounds,min:t.min,max:t.max,precision:n.precision,step:n.stepSize,count:n.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:n.minRotation||0,includeBounds:n.includeBounds!==!1},a=this._range||this,o=TNe(i,a);return t.bounds==="ticks"&&kSe(o,this,"value"),t.reverse?(o.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),o}configure(){const t=this.ticks;let n=this.min,s=this.max;if(super.configure(),this.options.offset&&t.length){const i=(s-n)/Math.max(t.length-1,1)/2;n-=i,s+=i}this._startValue=n,this._endValue=s,this._valueRange=s-n}getLabelForValue(t){return hN(t,this.chart.options.locale,this.options.ticks.format)}}class RNe extends MNe{static id="linear";static defaults={ticks:{callback:$V.formatters.numeric}};determineDataLimits(){const{min:t,max:n}=this.getMinMax(!0);this.min=Js(t)?t:0,this.max=Js(n)?n:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),n=t?this.width:this.height,s=Ao(this.options.ticks.minRotation),i=(t?Math.sin(s):Math.cos(s))||.001,a=this._resolveTickFontOptions(0);return Math.ceil(n/Math.min(40,a.lineHeight/i))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}const my={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},Ci=Object.keys(my);function YD(e,t){return e-t}function QD(e,t){if(Tt(t))return null;const n=e._adapter,{parser:s,round:i,isoWeekday:a}=e._parseOpts;let o=t;return typeof s=="function"&&(o=s(o)),Js(o)||(o=typeof s=="string"?n.parse(o,s):n.parse(o)),o===null?null:(i&&(o=i==="week"&&(Qd(a)||a===!0)?n.startOf(o,"isoWeek",a):n.startOf(o,i)),+o)}function XD(e,t,n,s){const i=Ci.length;for(let a=Ci.indexOf(e);a<i-1;++a){const o=my[Ci[a]],l=o.steps?o.steps:Number.MAX_SAFE_INTEGER;if(o.common&&Math.ceil((n-t)/(l*o.size))<=s)return Ci[a]}return Ci[i-1]}function DNe(e,t,n,s,i){for(let a=Ci.length-1;a>=Ci.indexOf(n);a--){const o=Ci[a];if(my[o].common&&e._adapter.diff(i,s,o)>=t-1)return o}return Ci[n?Ci.indexOf(n):0]}function ONe(e){for(let t=Ci.indexOf(e)+1,n=Ci.length;t<n;++t)if(my[Ci[t]].common)return Ci[t]}function JD(e,t,n){if(!n)e[t]=!0;else if(n.length){const{lo:s,hi:i}=cN(n,t),a=n[s]>=t?n[s]:n[i];e[a]=!0}}function PNe(e,t,n,s){const i=e._adapter,a=+i.startOf(t[0].value,s),o=t[t.length-1].value;let l,c;for(l=a;l<=o;l=+i.add(l,1,s))c=n[l],c>=0&&(t[c].major=!0);return t}function ZD(e,t,n){const s=[],i={},a=t.length;let o,l;for(o=0;o<a;++o)l=t[o],i[l]=o,s.push({value:l,major:!1});return a===0||!n?s:PNe(e,s,i,n)}class e8 extends Ah{static id="time";static defaults={bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",callback:!1,major:{enabled:!1}}};constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,n={}){const s=t.time||(t.time={}),i=this._adapter=new f5e._date(t.adapters.date);i.init(n),xp(s.displayFormats,i.formats()),this._parseOpts={parser:s.parser,round:s.round,isoWeekday:s.isoWeekday},super.init(t),this._normalized=n.normalized}parse(t,n){return t===void 0?null:QD(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,n=this._adapter,s=t.time.unit||"day";let{min:i,max:a,minDefined:o,maxDefined:l}=this.getUserBounds();function c(d){!o&&!isNaN(d.min)&&(i=Math.min(i,d.min)),!l&&!isNaN(d.max)&&(a=Math.max(a,d.max))}(!o||!l)&&(c(this._getLabelBounds()),(t.bounds!=="ticks"||t.ticks.source!=="labels")&&c(this.getMinMax(!1))),i=Js(i)&&!isNaN(i)?i:+n.startOf(Date.now(),s),a=Js(a)&&!isNaN(a)?a:+n.endOf(Date.now(),s)+1,this.min=Math.min(i,a-1),this.max=Math.max(i+1,a)}_getLabelBounds(){const t=this.getLabelTimestamps();let n=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;return t.length&&(n=t[0],s=t[t.length-1]),{min:n,max:s}}buildTicks(){const t=this.options,n=t.time,s=t.ticks,i=s.source==="labels"?this.getLabelTimestamps():this._generate();t.bounds==="ticks"&&i.length&&(this.min=this._userMin||i[0],this.max=this._userMax||i[i.length-1]);const a=this.min,o=this.max,l=RSe(i,a,o);return this._unit=n.unit||(s.autoSkip?XD(n.minUnit,this.min,this.max,this._getLabelCapacity(a)):DNe(this,l.length,n.minUnit,this.min,this.max)),this._majorUnit=!s.major.enabled||this._unit==="year"?void 0:ONe(this._unit),this.initOffsets(i),t.reverse&&l.reverse(),ZD(this,l,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map(t=>+t.value))}initOffsets(t=[]){let n=0,s=0,i,a;this.options.offset&&t.length&&(i=this.getDecimalForValue(t[0]),t.length===1?n=1-i:n=(this.getDecimalForValue(t[1])-i)/2,a=this.getDecimalForValue(t[t.length-1]),t.length===1?s=a:s=(a-this.getDecimalForValue(t[t.length-2]))/2);const o=t.length<3?.5:.25;n=Ws(n,0,o),s=Ws(s,0,o),this._offsets={start:n,end:s,factor:1/(n+1+s)}}_generate(){const t=this._adapter,n=this.min,s=this.max,i=this.options,a=i.time,o=a.unit||XD(a.minUnit,n,s,this._getLabelCapacity(n)),l=it(i.ticks.stepSize,1),c=o==="week"?a.isoWeekday:!1,d=Qd(c)||c===!0,f={};let p=n,m,g;if(d&&(p=+t.startOf(p,"isoWeek",c)),p=+t.startOf(p,d?"day":o),t.diff(s,n,o)>1e5*l)throw new Error(n+" and "+s+" are too far apart with stepSize of "+l+" "+o);const b=i.ticks.source==="data"&&this.getDataTimestamps();for(m=p,g=0;m<s;m=+t.add(m,l,o),g++)JD(f,m,b);return(m===s||i.bounds==="ticks"||g===1)&&JD(f,m,b),Object.keys(f).sort(YD).map(_=>+_)}getLabelForValue(t){const n=this._adapter,s=this.options.time;return s.tooltipFormat?n.format(t,s.tooltipFormat):n.format(t,s.displayFormats.datetime)}format(t,n){const i=this.options.time.displayFormats,a=this._unit,o=n||i[a];return this._adapter.format(t,o)}_tickFormatFunction(t,n,s,i){const a=this.options,o=a.ticks.callback;if(o)return rn(o,[t,n,s],this);const l=a.time.displayFormats,c=this._unit,d=this._majorUnit,f=c&&l[c],p=d&&l[d],m=s[n],g=d&&p&&m&&m.major;return this._adapter.format(t,i||(g?p:f))}generateTickLabels(t){let n,s,i;for(n=0,s=t.length;n<s;++n)i=t[n],i.label=this._tickFormatFunction(i.value,n,t)}getDecimalForValue(t){return t===null?NaN:(t-this.min)/(this.max-this.min)}getPixelForValue(t){const n=this._offsets,s=this.getDecimalForValue(t);return this.getPixelForDecimal((n.start+s)*n.factor)}getValueForPixel(t){const n=this._offsets,s=this.getDecimalForPixel(t)/n.factor-n.end;return this.min+s*(this.max-this.min)}_getLabelSize(t){const n=this.options.ticks,s=this.ctx.measureText(t).width,i=Ao(this.isHorizontal()?n.maxRotation:n.minRotation),a=Math.cos(i),o=Math.sin(i),l=this._resolveTickFontOptions(0).size;return{w:s*a+l*o,h:s*o+l*a}}_getLabelCapacity(t){const n=this.options.time,s=n.displayFormats,i=s[n.unit]||s.millisecond,a=this._tickFormatFunction(t,0,ZD(this,[t],this._majorUnit),i),o=this._getLabelSize(a),l=Math.floor(this.isHorizontal()?this.width/o.w:this.height/o.h)-1;return l>0?l:1}getDataTimestamps(){let t=this._cache.data||[],n,s;if(t.length)return t;const i=this.getMatchingVisibleMetas();if(this._normalized&&i.length)return this._cache.data=i[0].controller.getAllParsedValues(this);for(n=0,s=i.length;n<s;++n)t=t.concat(i[n].controller.getAllParsedValues(this));return this._cache.data=this.normalize(t)}getLabelTimestamps(){const t=this._cache.labels||[];let n,s;if(t.length)return t;const i=this.getLabels();for(n=0,s=i.length;n<s;++n)t.push(QD(this,i[n]));return this._cache.labels=this._normalized?t:this.normalize(t)}normalize(t){return PV(t.sort(YD))}}function tb(e,t,n){let s=0,i=e.length-1,a,o,l,c;n?(t>=e[s].pos&&t<=e[i].pos&&({lo:s,hi:i}=Gc(e,"pos",t)),{pos:a,time:l}=e[s],{pos:o,time:c}=e[i]):(t>=e[s].time&&t<=e[i].time&&({lo:s,hi:i}=Gc(e,"time",t)),{time:a,pos:l}=e[s],{time:o,pos:c}=e[i]);const d=o-a;return d?l+(c-l)*(t-a)/d:l}class Q8e extends e8{static id="timeseries";static defaults=e8.defaults;constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),n=this._table=this.buildLookupTable(t);this._minPos=tb(n,this.min),this._tableRange=tb(n,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:n,max:s}=this,i=[],a=[];let o,l,c,d,f;for(o=0,l=t.length;o<l;++o)d=t[o],d>=n&&d<=s&&i.push(d);if(i.length<2)return[{time:n,pos:0},{time:s,pos:1}];for(o=0,l=i.length;o<l;++o)f=i[o+1],c=i[o-1],d=i[o],Math.round((f+c)/2)!==d&&a.push({time:d,pos:o/(l-1)});return a}_generate(){const t=this.min,n=this.max;let s=super.getDataTimestamps();return(!s.includes(t)||!s.length)&&s.splice(0,0,t),(!s.includes(n)||s.length===1)&&s.push(n),s.sort((i,a)=>i-a)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const n=this.getDataTimestamps(),s=this.getLabelTimestamps();return n.length&&s.length?t=this.normalize(n.concat(s)):t=n.length?n:s,t=this._cache.all=t,t}getDecimalForValue(t){return(tb(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const n=this._offsets,s=this.getDecimalForPixel(t)/n.factor-n.end;return tb(this._table,s*this._tableRange+this._minPos,!0)}}const _U="label";function t8(e,t){typeof e=="function"?e(t):e&&(e.current=t)}function INe(e,t){const n=e.options;n&&t&&Object.assign(n,t)}function wU(e,t){e.labels=t}function AU(e,t,n=_U){const s=[];e.datasets=t.map(i=>{const a=e.datasets.find(o=>o[n]===i[n]);return!a||!i.data||s.includes(a)?{...i}:(s.push(a),Object.assign(a,i),a)})}function LNe(e,t=_U){const n={labels:[],datasets:[]};return wU(n,e.labels),AU(n,e.datasets,t),n}function BNe(e,t){const{height:n=150,width:s=300,redraw:i=!1,datasetIdKey:a,type:o,data:l,options:c,plugins:d=[],fallbackContent:f,updateMode:p,...m}=e,g=y.useRef(null),b=y.useRef(null),_=()=>{g.current&&(b.current=new hy(g.current,{type:o,data:LNe(l,a),options:c&&{...c},plugins:d}),t8(t,b.current))},w=()=>{t8(t,null),b.current&&(b.current.destroy(),b.current=null)};return y.useEffect(()=>{!i&&b.current&&c&&INe(b.current,c)},[i,c]),y.useEffect(()=>{!i&&b.current&&wU(b.current.config.data,l.labels)},[i,l.labels]),y.useEffect(()=>{!i&&b.current&&l.datasets&&AU(b.current.config.data,l.datasets,a)},[i,l.datasets]),y.useEffect(()=>{b.current&&(i?(w(),setTimeout(_)):b.current.update(p))},[i,c,l.labels,l.datasets,p]),y.useEffect(()=>{b.current&&(w(),setTimeout(_))},[o]),y.useEffect(()=>(_(),()=>w()),[]),r.jsx("canvas",{ref:g,role:"img",height:n,width:s,...m,children:f})}const zNe=y.forwardRef(BNe);function xy(e,t){return hy.register(t),y.forwardRef((n,s)=>r.jsx(zNe,{...n,ref:s,type:e}))}const $Ne=xy("line",u5e),n8=xy("bar",o5e),VNe=xy("pie",d5e),UNe=xy("scatter",h5e);hy.register(FNe,RNe,Lje,fy,Hje,kje,bNe,jNe,xNe,uNe);const $f=["#6366F1","#8B5CF6","#EC4899","#10B981","#F59E0B","#EF4444","#3B82F6","#14B8A6","#F97316","#84CC16"];function HNe({data:e}){const t=y.useMemo(()=>({labels:e.labels,datasets:e.datasets.map((i,a)=>({...i,backgroundColor:i.backgroundColor??(e.type==="pie"?$f.slice(0,e.labels.length):`${$f[a%$f.length]}88`),borderColor:i.borderColor??$f[a%$f.length],borderWidth:e.type==="pie"?0:2,pointRadius:e.type==="scatter"?4:3,tension:.3}))}),[e]),n=y.useMemo(()=>({responsive:!0,maintainAspectRatio:!1,plugins:{title:e.title?{display:!0,text:e.title,color:"#F0F0F5",font:{size:12,weight:500},padding:{bottom:12}}:{display:!1},legend:{display:e.datasets.length>1||e.type==="pie",position:"bottom",labels:{color:"#8A8A99",font:{size:10},boxWidth:10,padding:8}},tooltip:{backgroundColor:"#1C1C21",titleColor:"#F0F0F5",bodyColor:"#C8C8D4",borderColor:"#2A2A35",borderWidth:1,titleFont:{size:11},bodyFont:{size:10},padding:8}},scales:e.type==="pie"?{}:{x:{ticks:{color:"#5A5A6E",font:{size:10}},grid:{color:"#2A2A35",drawBorder:!1}},y:{ticks:{color:"#5A5A6E",font:{size:10}},grid:{color:"#2A2A35",drawBorder:!1}}}}),[e]),s={bar:n8,line:$Ne,pie:VNe,scatter:UNe}[e.type]??n8;return r.jsx("div",{className:"p-4",style:{height:e.type==="pie"?320:280},children:r.jsx(s,{data:t,options:n})})}function WNe({data:e,onChange:t}){const[n,s]=y.useState(null),[i,a]=y.useState(!0),[o,l]=y.useState(""),[c,d]=y.useState(null),[f,p]=y.useState(""),m=y.useCallback(A=>{n===A?a(S=>!S):(s(A),a(!0))},[n]),g=y.useMemo(()=>{if(!o.trim())return e.rows;const A=o.toLowerCase();return e.rows.filter(S=>e.columns.some(C=>String(S[C.key]??"").toLowerCase().includes(A)))},[e.rows,e.columns,o]),b=y.useMemo(()=>{if(!n)return g;const A=e.columns.find(S=>S.key===n);return[...g].sort((S,C)=>{const E=S[n]??"",k=C[n]??"";return A?.type==="number"||typeof E=="number"&&typeof k=="number"?i?Number(E)-Number(k):Number(k)-Number(E):i?String(E).localeCompare(String(k)):String(k).localeCompare(String(E))})},[g,n,i,e.columns]),_=y.useCallback((A,S,C)=>{d({row:A,key:S}),p(String(C??""))},[]),w=y.useCallback(()=>{if(!c)return;if(!e.rows[c.row]){d(null);return}const S=e.columns.find(k=>k.key===c.key);let C=f;S?.type==="number"&&(C=Number(f)||0);const E=e.rows.map((k,T)=>T===c.row?{...k,[c.key]:C}:k);t({...e,rows:E}),d(null)},[c,f,e,t]);return r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-[#2A2A35]",children:[e.title&&r.jsx("span",{className:"text-[11px] font-semibold text-[#F0F0F5] mr-2",children:e.title}),r.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded bg-[#1C1C21] border border-[#2A2A35] flex-1 max-w-[200px]",children:[r.jsx(Io,{className:"w-3 h-3 text-[#5A5A6E]"}),r.jsx("input",{value:o,onChange:A=>l(A.target.value),placeholder:"Filter...",className:"flex-1 bg-transparent text-[11px] text-[#C8C8D4] placeholder-[#5A5A6E] outline-none"})]}),r.jsxs("span",{className:"text-[10px] text-[#5A5A6E] ml-auto",children:[b.length," / ",e.rows.length]})]}),r.jsxs("div",{className:"overflow-auto max-h-[500px]",children:[r.jsxs("table",{className:"w-full text-[11px]",children:[r.jsx("thead",{className:"sticky top-0 bg-[#16161A] z-10",children:r.jsx("tr",{className:"border-b border-[#2A2A35]",children:e.columns.map(A=>r.jsx("th",{onClick:()=>m(A.key),className:"px-3 py-2 text-left text-[#8A8A99] font-medium cursor-pointer hover:text-[#C8C8D4] transition-colors whitespace-nowrap select-none",children:r.jsxs("span",{className:"inline-flex items-center gap-1",children:[A.label,n===A.key?i?r.jsx(vse,{className:"w-3 h-3 text-[#6366F1]"}):r.jsx(fse,{className:"w-3 h-3 text-[#6366F1]"}):r.jsx(gse,{className:"w-3 h-3 opacity-30"})]})},A.key))})}),r.jsx("tbody",{children:b.map((A,S)=>{const C=e.rows.indexOf(A);return r.jsx("tr",{className:"border-b border-[#2A2A35]/50 hover:bg-white/[0.02]",children:e.columns.map(E=>{const k=c?.row===C&&c?.key===E.key;return r.jsx("td",{className:"px-3 py-1.5 text-[#C8C8D4]",children:k?r.jsx("input",{value:f,onChange:T=>p(T.target.value),onBlur:w,onKeyDown:T=>{T.key==="Enter"&&w(),T.key==="Escape"&&d(null)},className:"w-full bg-[#1C1C21] text-[11px] text-[#F0F0F5] rounded px-1 py-0.5 outline-none border border-[#6366F1]/30",autoFocus:!0}):r.jsx("span",{onDoubleClick:()=>_(C,E.key,A[E.key]),className:"cursor-default",children:String(A[E.key]??"")})},E.key)})},S)})})]}),b.length===0&&r.jsx("p",{className:"px-4 py-6 text-center text-[11px] text-[#5A5A6E] italic",children:o?"No matching rows.":"No data."})]})]})}const s8=[{bg:"bg-[#6366F1]/10",text:"text-[#818CF8]"},{bg:"bg-[#10B981]/10",text:"text-[#34D399]"},{bg:"bg-[#EC4899]/10",text:"text-[#F472B6]"},{bg:"bg-[#F59E0B]/10",text:"text-[#FBBF24]"},{bg:"bg-[#EF4444]/10",text:"text-[#F87171]"},{bg:"bg-[#3B82F6]/10",text:"text-[#60A5FA]"}];function qNe(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return s8[Math.abs(t)%s8.length]}function GNe({card:e,onEdit:t,onRemove:n}){const[s,i]=y.useState(!1),[a,o]=y.useState(e.title),[l,c]=y.useState(e.description??""),d=y.useCallback(()=>{a.trim()&&t(e.id,a.trim(),l.trim()),i(!1)},[e.id,a,l,t]);return s?r.jsxs("div",{className:"bg-[#16161A] rounded-lg border border-[#6366F1]/30 p-3",children:[r.jsx("input",{value:a,onChange:f=>o(f.target.value),onKeyDown:f=>f.key==="Enter"&&d(),className:"w-full bg-transparent text-[12px] text-[#F0F0F5] outline-none font-medium mb-1.5",autoFocus:!0}),r.jsx("textarea",{value:l,onChange:f=>c(f.target.value),rows:3,className:"w-full bg-transparent text-[11px] text-[#8A8A99] outline-none resize-none",placeholder:"Description..."}),r.jsxs("div",{className:"flex justify-end gap-1 mt-2",children:[r.jsx("button",{onClick:()=>i(!1),className:"p-1 text-[#5A5A6E] hover:text-[#C8C8D4]",children:r.jsx(Te,{className:"w-3 h-3"})}),r.jsx("button",{onClick:d,className:"p-1 text-[#10B981] hover:text-[#34D399]",children:r.jsx(Fe,{className:"w-3 h-3"})})]})]}):r.jsxs("div",{className:"bg-[#16161A] rounded-lg border border-[#2A2A35] hover:border-[#3A3A45] transition-colors group",children:[e.image&&r.jsx("div",{className:"aspect-video overflow-hidden rounded-t-lg",children:r.jsx("img",{src:e.image,alt:"",className:"w-full h-full object-cover"})}),r.jsxs("div",{className:"p-3",children:[r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsx("h4",{className:"text-[12px] font-medium text-[#F0F0F5] leading-snug",children:e.title}),r.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",children:[e.url&&r.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"p-0.5 text-[#5A5A6E] hover:text-[#6366F1]",children:r.jsx(cs,{className:"w-2.5 h-2.5"})}),r.jsx("button",{onClick:()=>i(!0),className:"p-0.5 text-[#5A5A6E] hover:text-[#C8C8D4]",children:r.jsx(oh,{className:"w-2.5 h-2.5"})}),r.jsx("button",{onClick:()=>n(e.id),className:"p-0.5 text-[#5A5A6E] hover:text-[#EF4444]",children:r.jsx(Te,{className:"w-2.5 h-2.5"})})]})]}),e.description&&r.jsx("p",{className:"text-[11px] text-[#8A8A99] mt-1 leading-snug line-clamp-3",children:e.description}),e.tags&&e.tags.length>0&&r.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:e.tags.map(f=>{const p=qNe(f);return r.jsx("span",{className:`px-1.5 py-0.5 rounded text-[9px] font-medium ${p.bg} ${p.text}`,children:f},f)})}),e.meta&&Object.keys(e.meta).length>0&&r.jsx("div",{className:"mt-2 pt-2 border-t border-[#2A2A35]/50 space-y-0.5",children:Object.entries(e.meta).map(([f,p])=>r.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[r.jsxs("span",{className:"text-[#5A5A6E]",children:[f,":"]}),r.jsx("span",{className:"text-[#C8C8D4]",children:p})]},f))})]})]})}function KNe({data:e,onChange:t}){const n=e.columns??3,s=y.useCallback((a,o,l)=>{const c=e.cards.map(d=>d.id===a?{...d,title:o,description:l}:d);t({...e,cards:c})},[e,t]),i=y.useCallback(a=>{t({...e,cards:e.cards.filter(o=>o.id!==a)})},[e,t]);return r.jsxs("div",{className:"p-3",children:[e.title&&r.jsx("h3",{className:"text-[12px] font-semibold text-[#F0F0F5] mb-3",children:e.title}),r.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${Math.min(n,4)}, minmax(0, 1fr))`},children:e.cards.map(a=>r.jsx(GNe,{card:a,onEdit:s,onRemove:i},a.id))}),e.cards.length===0&&r.jsx("p",{className:"text-center py-8 text-[11px] text-[#5A5A6E] italic",children:"No cards"})]})}function SU(e){return e.endsWith(".kanban.json")?"kanban":e.endsWith(".chart.json")?"chart":e.endsWith(".table.json")?"table":e.endsWith(".board.json")?"board":null}function CU(e){return SU(e)!==null}function YNe(e,t){if(!t||typeof t!="object")return!1;switch(e){case"kanban":return Array.isArray(t.columns);case"chart":return typeof t.type=="string"&&Array.isArray(t.labels)&&Array.isArray(t.datasets);case"table":return Array.isArray(t.columns)&&Array.isArray(t.rows);case"board":return Array.isArray(t.cards);default:return!1}}function jU({agentId:e,filePath:t,content:n}){const s=SU(t),i=L.files.writeStructured.useMutation(),a=y.useRef(void 0),o=y.useMemo(()=>{try{return JSON.parse(n)}catch{return null}},[n]),[l,c]=y.useState(o),[d,f]=y.useState(!1);y.useEffect(()=>{c(o),f(!1)},[o]);const p=y.useCallback(m=>{c(m),f(!0),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{const g=JSON.stringify(m,null,2);i.mutate({agentId:e,filePath:t,content:g}),f(!1)},800)},[e,t,i]);return y.useEffect(()=>()=>{a.current&&clearTimeout(a.current)},[]),!s||!l||!YNe(s,l)?null:r.jsxs("div",{className:"relative",children:[d&&r.jsx("div",{className:"absolute top-2 right-3 z-10",children:r.jsx("span",{className:"text-[9px] text-[#F59E0B] bg-[#F59E0B]/10 px-1.5 py-0.5 rounded",children:"Saving..."})}),s==="kanban"&&r.jsx(G2e,{data:l,onChange:p}),s==="chart"&&r.jsx(HNe,{data:l}),s==="table"&&r.jsx(WNe,{data:l,onChange:p}),s==="board"&&r.jsx(KNe,{data:l,onChange:p})]})}const QNe={kanban:"Kanban Board",chart:"Chart",table:"Data Table",board:"Card Grid"};function XNe(e){for(const[t,n]of Object.entries(QNe))if(e.endsWith(`.${t}.json`))return n;return"Structured File"}function yN({agentId:e,filePath:t,onClose:n}){const s=t.split("/").pop()??t,i=XNe(s),{data:a,isLoading:o}=L.files.read.useQuery({agentId:e,filePath:t},{retry:!1});return r.jsx(ji,{open:!0,onOpenChange:l=>{l||n()},children:r.jsxs(Ni,{children:[r.jsx(ir,{className:"fixed inset-0 bg-black/60 z-40"}),r.jsxs(ki,{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[90vw] max-w-[1100px] max-h-[85vh] bg-[#13131A] border border-[#2A2A35] rounded-xl shadow-2xl z-50 flex flex-col",children:[r.jsxs("div",{className:"px-4 py-3 border-b border-[#2A2A35] flex items-center justify-between flex-shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx(nr,{className:"text-[13px] font-semibold text-[#F0F0F5] truncate",children:s}),r.jsx("span",{className:"text-[10px] text-[#5A5A6E] bg-white/[0.04] px-1.5 py-0.5 rounded flex-shrink-0",children:i})]}),r.jsx(Gs,{asChild:!0,children:r.jsx("button",{className:"w-7 h-7 flex items-center justify-center rounded-md text-[#5A5A6E] hover:text-[#C8C8D4] hover:bg-white/5 transition-colors",children:r.jsx(Te,{className:"w-4 h-4"})})})]}),r.jsxs("div",{className:"flex-1 overflow-auto min-h-0",children:[o&&r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsxs("div",{className:"flex items-center gap-1.5 text-[#5A5A6E]",children:[r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#5A5A6E] animate-pulse"}),r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#5A5A6E] animate-pulse [animation-delay:0.2s]"}),r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#5A5A6E] animate-pulse [animation-delay:0.4s]"})]})}),!o&&a?.content&&r.jsx(jU,{agentId:e,filePath:t,content:a.content}),!o&&!a?.content&&r.jsx("p",{className:"text-center py-12 text-[12px] text-[#5A5A6E]",children:"Unable to load file."})]})]})]})})}const JNe=/\.(kanban|chart|table|board)\.json$/;function ZNe(e){const t=e.match(JNe);return t?t[1]:null}const eke={kanban:nL,chart:M5,table:wL,board:ym},tke={kanban:"#6366F1",chart:"#10B981",table:"#3B82F6",board:"#8B5CF6"};function nke(e,t){try{const n=JSON.parse(t);switch(e){case"kanban":{const s=Array.isArray(n.columns)?n.columns.length:0,i=Array.isArray(n.columns)?n.columns.reduce((a,o)=>a+(Array.isArray(o.cards)?o.cards.length:0),0):0;return`${s} columns, ${i} cards`}case"chart":{const s=n.type??"unknown",i=Array.isArray(n.labels)?n.labels.length:0;return`${s} chart — ${i} data points`}case"table":{const s=Array.isArray(n.rows)?n.rows.length:0,i=Array.isArray(n.columns)?n.columns.length:0;return`${s} rows × ${i} columns`}case"board":return`${Array.isArray(n.cards)?n.cards.length:0} cards`}}catch{return"structured file"}}function ske({agentId:e,filePath:t,filename:n,content:s}){const[i,a]=y.useState(!1),o=ZNe(n);if(!o)return null;const l=eke[o],c=tke[o],d=s?nke(o,s):null;return r.jsxs(r.Fragment,{children:[r.jsxs(ne.button,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2},onClick:()=>a(!0),className:"flex items-center gap-2.5 px-3 py-2 rounded-lg border transition-colors duration-100 hover:brightness-110 w-fit max-w-[380px] group",style:{backgroundColor:`${c}08`,borderColor:`${c}25`},children:[r.jsx("div",{className:"w-7 h-7 rounded-md flex items-center justify-center flex-shrink-0",style:{backgroundColor:`${c}18`},children:r.jsx(l,{className:"w-3.5 h-3.5",style:{color:c}})}),r.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[r.jsx("span",{className:"text-[12px] font-medium text-[#F0F0F5] truncate max-w-[280px]",children:n}),d&&r.jsx("span",{className:"text-[11px] text-[#8A8A99]",children:d})]})]}),i&&r.jsx(yN,{agentId:e,filePath:t,onClose:()=>a(!1)})]})}const NU=$o(e=>({cardsByChannel:{},addCard:(t,n)=>e(s=>{const i=s.cardsByChannel[t]??[],a=`${n.agentId}:${n.filePath}`,o=i.filter(l=>`${l.agentId}:${l.filePath}`!==a);return{cardsByChannel:{...s.cardsByChannel,[t]:[...o,n]}}}),dismissCard:(t,n)=>e(s=>{const i=s.cardsByChannel[t];return i?{cardsByChannel:{...s.cardsByChannel,[t]:i.filter(a=>a.id!==n)}}:s})}));function ike({channelId:e,agentForChannel:t,agentColor:n,messages:s=[],isThinking:i,isLoading:a,loadMore:o,firstUnreadId:l}){const{data:c=[]}=Vo(),d=y.useRef(null),f=y.useRef(null),[p,m]=y.useState(!1),[g,b]=y.useState(!0),_=y.useRef(0),w=L.readReceipts.markRead.useMutation(),A=Je(R=>R.setUnreadCount),S=y.useRef(!1),C=Je(R=>R.fileEditApprovalsByChannel[e])??[],E=Je(R=>R.removeFileEditApproval),k=NU(R=>R.cardsByChannel[e])??[],{data:T}=L.fileEditApprovals.list.useQuery({channelId:e},{staleTime:3e4});y.useEffect(()=>{if(!T)return;const R=Je.getState().addFileEditApproval;for(const H of T)R(H)},[T]),y.useEffect(()=>{d.current?.scrollIntoView({behavior:"instant"})},[e]);const F=s.length>0?s[s.length-1]?.id:null;y.useEffect(()=>{d.current?.scrollIntoView({behavior:"smooth"})},[F]),y.useEffect(()=>{if(l&&!S.current){const R=document.getElementById(`msg-${l}`);R&&(R.scrollIntoView({behavior:"smooth",block:"start"}),S.current=!0)}},[l,s]),y.useEffect(()=>{S.current=!1},[e]),y.useEffect(()=>{s.length!==0&&(w.mutate({channelId:e}),A(e,0))},[e,s.length]);const M=y.useCallback(async()=>{const R=f.current;if(!(!R||!o||p||!g)&&R.scrollTop<100){m(!0),_.current=R.scrollHeight;const H=await o();b(H??!1),m(!1),requestAnimationFrame(()=>{const V=R.scrollHeight;R.scrollTop=V-_.current})}},[o,p,g]),I=i&&t?[{...t,status:"thinking"}]:t?[t].filter(R=>R.status==="thinking"||R.status==="executing"):c.filter(R=>s.some(V=>V.sender.id===R.id)&&(R.status==="thinking"||R.status==="executing"));return a?r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsxs("div",{className:"flex items-center gap-2 text-[#8A8A99]",children:[r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#8A8A99] animate-pulse"}),r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#8A8A99] animate-pulse [animation-delay:0.2s]"}),r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#8A8A99] animate-pulse [animation-delay:0.4s]"})]})}):r.jsxs("div",{ref:f,onScroll:M,className:"flex-1 overflow-y-auto overflow-x-hidden py-2 scrollbar-agent",style:n?{"--agent-color":n}:void 0,"data-channel":e,children:[p&&r.jsx("div",{className:"flex justify-center py-3",children:r.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] text-[#8A8A99]",children:[r.jsx("div",{className:"w-1 h-1 rounded-full bg-[#8A8A99] animate-pulse"}),r.jsx("div",{className:"w-1 h-1 rounded-full bg-[#8A8A99] animate-pulse [animation-delay:0.15s]"}),r.jsx("div",{className:"w-1 h-1 rounded-full bg-[#8A8A99] animate-pulse [animation-delay:0.3s]"})]})}),r.jsx(Me,{initial:!1,children:s.map(R=>{if(R.sender.type==="context_reset"){const V=R.content.startsWith("compacted:");return r.jsxs("div",{id:`msg-${R.id}`,className:"flex items-center gap-3 py-2 px-4",children:[r.jsx("div",{className:"flex-1 h-px bg-[#2A2A35]"}),r.jsx("span",{className:"text-[11px] text-[#5A5A6E]",children:V?"earlier messages summarized":"new context"}),r.jsx("div",{className:"flex-1 h-px bg-[#2A2A35]"})]},R.id)}const H=R.id===l;return r.jsxs("div",{id:`msg-${R.id}`,children:[H&&r.jsxs(ne.div,{initial:{opacity:0},animate:{opacity:1},className:"flex items-center gap-3 px-4 py-1 my-1",children:[r.jsx("div",{className:"flex-1 h-px bg-[#6366F1]/40"}),r.jsx("span",{className:"text-[11px] text-[#6366F1] font-medium shrink-0",children:"New messages"}),r.jsx("div",{className:"flex-1 h-px bg-[#6366F1]/40"})]}),r.jsx(Z7,{message:R,agentColor:n})]},R.id)})}),I.map(R=>r.jsx(U7,{agent:R},`thinking-${R.id}`)),C.length>0&&r.jsx("div",{className:"px-4 py-2",children:C.map(R=>{const H=c.find(V=>V.id===R.agentId);return r.jsx(tAe,{approval:R,agentName:H?.name??R.agentId,onDecided:V=>E(e,V)},R.id)})}),k.length>0&&r.jsx("div",{className:"px-4 py-2 space-y-1.5",children:k.map(R=>r.jsx(ske,{agentId:R.agentId,filePath:R.filePath,filename:R.filename},R.id))}),r.jsx("div",{ref:d,className:"h-4"})]})}function rke(e){const t=e.split(`
|
|
190
190
|
`),n=[];let s=0,i=0;for(const a of t)if(!(a.startsWith("===")||a.startsWith("---")||a.startsWith("+++"))&&!a.startsWith("Index:")&&a!=="\"){if(a.startsWith("@@")){const o=a.match(/@@ -(\d+)/);if(o){s=parseInt(o[1],10);const l=a.match(/\+(\d+)/);l&&(i=parseInt(l[1],10))}n.push({type:"header",content:a});continue}a.startsWith("+")?(n.push({type:"add",content:a.slice(1),newLineNo:i}),i++):a.startsWith("-")?(n.push({type:"remove",content:a.slice(1),oldLineNo:s}),s++):a.startsWith(" ")&&(n.push({type:"context",content:a.slice(1),oldLineNo:s,newLineNo:i}),s++,i++)}return n}function ake({id:e,filePath:t,diff:n,newContent:s,reverted:i}){const a=rke(n),o=a.filter(C=>C.type==="add").length,l=a.filter(C=>C.type==="remove").length,c=a.filter(C=>C.type!=="header").length,d=c>50,[f,p]=y.useState(!d),[m,g]=y.useState(!1),b=L.useUtils(),_=L.fileChanges.revert.useMutation({onSuccess:()=>{b.fileChanges.list.invalidate()}}),w=f?a:a.slice(0,50),A=t.split(".").pop()??"";function S(){navigator.clipboard.writeText(s),g(!0),setTimeout(()=>g(!1),2e3)}return r.jsxs(ne.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},className:"mt-2 rounded-lg overflow-hidden border border-[#2A2A35] bg-[#0D0D0F]",children:[r.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-[#1A1A22]",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx(li,{className:"w-3.5 h-3.5 text-[#5A5A6E] flex-shrink-0"}),r.jsx("code",{className:"text-[12px] font-mono text-[#C8C8D4] truncate",children:t}),A&&r.jsx("span",{className:"text-[10px] text-[#5A5A6E] bg-white/5 px-1.5 py-0.5 rounded flex-shrink-0",children:A})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0 ml-2",children:[o>0&&r.jsxs("span",{className:"text-[10px] font-mono text-[#34D399]",children:["+",o]}),l>0&&r.jsxs("span",{className:"text-[10px] font-mono text-[#F87171]",children:["-",l]}),r.jsx("button",{onClick:S,className:"p-1 rounded hover:bg-white/10 transition-colors text-[#5A5A6E] hover:text-[#8A8A99]",title:"Copy new content",children:m?r.jsx(Fe,{className:"w-3 h-3 text-[#34D399]"}):r.jsx(Po,{className:"w-3 h-3"})}),r.jsxs("button",{onClick:()=>_.mutate({fileChangeId:e}),disabled:i||_.isPending||_.isSuccess,className:ye("flex items-center gap-1 px-2 py-1 rounded-md text-[11px] font-medium border transition-colors",i||_.isSuccess?"bg-[#10B981]/10 text-[#34D399] border-[#10B981]/30":"bg-[#EF4444]/10 text-[#F87171] border-[#EF4444]/30 hover:bg-[#EF4444]/20 disabled:opacity-50"),title:"Revert to previous version",children:[r.jsx(lh,{className:"w-3 h-3"}),i||_.isSuccess?"Reverted":_.isPending?"Reverting...":"Revert"]})]})]}),r.jsx("div",{className:"overflow-x-auto max-h-[400px] overflow-y-auto",children:r.jsx("table",{className:"w-full text-[12px] font-mono leading-relaxed",children:r.jsx("tbody",{children:w.map((C,E)=>{if(C.type==="header")return r.jsx("tr",{className:"bg-[#1A1A2E]/50",children:r.jsx("td",{colSpan:3,className:"px-3 py-1 text-[11px] text-[#6366F1]",children:C.content})},E);const k=C.type==="add"?"bg-[#10B981]/8":C.type==="remove"?"bg-[#EF4444]/8":"",T=C.type==="add"?"text-[#34D399]":C.type==="remove"?"text-[#F87171]":"text-[#8A8A99]",F=C.type==="add"?"bg-[#10B981]/15":C.type==="remove"?"bg-[#EF4444]/15":"",M=C.type==="add"?"+":C.type==="remove"?"-":" ";return r.jsxs("tr",{className:k,children:[r.jsx("td",{className:ye("w-[1px] whitespace-nowrap select-none text-right px-2 text-[10px] text-[#5A5A6E] border-r border-[#1A1A22]",F),children:C.oldLineNo??""}),r.jsx("td",{className:ye("w-[1px] whitespace-nowrap select-none text-right px-2 text-[10px] text-[#5A5A6E] border-r border-[#1A1A22]",F),children:C.newLineNo??""}),r.jsxs("td",{className:ye("px-3 whitespace-pre-wrap",T),children:[r.jsx("span",{className:"select-none opacity-50 mr-1",children:M}),C.content]})]},E)})})})}),d&&r.jsx("button",{onClick:()=>p(C=>!C),className:"flex items-center gap-1 w-full px-3 py-1.5 text-[11px] text-[#5A5A6E] hover:text-[#8A8A99] border-t border-[#1A1A22] transition-colors",children:f?r.jsxs(r.Fragment,{children:[r.jsx(ah,{className:"w-3 h-3"})," Show less"]}):r.jsxs(r.Fragment,{children:[r.jsx(ft,{className:"w-3 h-3"})," Show all (",c," lines)"]})})]})}const kU="diff-seen:";function i8(e){try{const t=localStorage.getItem(kU+e);return t?new Set(JSON.parse(t)):new Set}catch{return new Set}}function oke(e,t){localStorage.setItem(kU+e,JSON.stringify([...t]))}function lke(e){let t=0,n=0;for(const s of e.split(`
|
|
191
191
|
`))s.startsWith("+++")||s.startsWith("---")||(s.startsWith("+")?t++:s.startsWith("-")&&n++);return{additions:t,deletions:n}}function cke({channelId:e}){const{data:t}=L.fileChanges.list.useQuery({channelId:e},{staleTime:3e4}),[n,s]=y.useState(!0),[i,a]=y.useState(()=>i8(e));y.useEffect(()=>{a(i8(e))},[e]);const o=y.useCallback(()=>{if(n&&t){const p=new Set(i);for(const m of t)p.add(m.id);a(p),oke(e,p)}s(p=>!p)},[n,t,i,e]);if(!t||t.length===0)return null;const l=t.filter(p=>!i.has(p.id)&&!p.reverted),c=l.length>0;let d=0,f=0;if(c)for(const p of l){const m=lke(p.diff);d+=m.additions,f+=m.deletions}return r.jsxs("div",{className:"flex-shrink-0 border-t border-[#2A2A35]",children:[r.jsxs("button",{onClick:o,className:"flex items-center w-full px-4 py-2 text-left hover:bg-white/[0.02] transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[n?r.jsx(Jt,{className:"w-3 h-3 text-[#5A5A6E] flex-shrink-0"}):r.jsx(ft,{className:"w-3 h-3 text-[#5A5A6E] flex-shrink-0"}),r.jsx(li,{className:"w-3 h-3 text-[#5A5A6E] flex-shrink-0"}),r.jsx("span",{className:"text-[11px] font-medium text-[#8A8A99]",children:"File changes"}),c&&n&&r.jsx("span",{className:"min-w-[16px] h-[16px] flex items-center justify-center px-1 rounded-full bg-[#6366F1] text-white text-[10px] font-bold leading-none",children:l.length})]}),c&&n&&r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[d>0&&r.jsxs("span",{className:"text-[10px] font-mono font-medium text-[#34D399]",children:["+",d]}),f>0&&r.jsxs("span",{className:"text-[10px] font-mono font-medium text-[#F87171]",children:["-",f]})]})]}),r.jsx(Me,{initial:!1,children:!n&&r.jsx(ne.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15,ease:[.16,1,.3,1]},className:"overflow-hidden",children:r.jsx("div",{className:"px-4 pb-2 space-y-2 max-h-[400px] overflow-y-auto",children:t.map(p=>r.jsx(ake,{id:p.id,filePath:p.filePath,diff:p.diff,newContent:p.newContent,reverted:p.reverted},p.id))})})})]})}function uke({message:e,agentColor:t}){const n=e.sender.type==="agent",s=e.sender.agentColor??t;return r.jsxs("div",{className:"flex items-start gap-3 px-5 py-2 hover:bg-white/[0.02] transition-colors group",children:[r.jsx("div",{className:"flex-shrink-0 mt-0.5",children:n?r.jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center text-sm",style:{backgroundColor:`${s??"#6366F1"}26`},children:e.sender.avatar??"⚡"}):r.jsx("div",{className:"w-7 h-7 rounded-full bg-gradient-to-br from-[#4A4A5E] to-[#2A2A3E] flex items-center justify-center border border-[#3A3A4E]",children:r.jsx("span",{className:"text-[10px] font-semibold text-[#A5A5C5]",children:e.sender.avatar??e.sender.name[0]})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-baseline gap-2 mb-0.5",children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:n?s??"#6366F1":"#F0F0F5"},children:e.sender.name}),r.jsx("span",{className:"text-[11px] text-[#8A8A99]",children:Ir(e.timestamp)})]}),r.jsx("div",{className:"text-[13px] text-[#C8C8D4] leading-relaxed prose-message",children:r.jsx(Ei,{remarkPlugins:[Fi],children:e.content})})]})]})}function dke({parentMessageId:e,agentColor:t,onClose:n}){const[s,i]=y.useState(""),[a,o]=y.useState(!1),l=y.useRef(null),c=Je(w=>w.messagesByChannel),d=Object.values(c).flat().find(w=>w.id===e),{data:f=[],refetch:p}=L.threads.list.useQuery({parentMessageId:e},{enabled:!!e});y.useEffect(()=>{l.current?.scrollIntoView({behavior:"smooth"})},[f.length]);const m=L.threads.send.useMutation({onSuccess:()=>{i(""),p()}});function g(w){w.key==="Enter"&&!w.shiftKey&&(w.preventDefault(),s.trim()&&!m.isPending&&m.mutate({parentMessageId:e,content:s.trim()}))}const b=d?.sender.type==="agent",_=d?.sender.agentColor??t;return r.jsxs(r.Fragment,{children:[r.jsx(ne.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-40",style:{backdropFilter:"blur(2px)",backgroundColor:"rgba(0,0,0,0.25)"},onClick:n}),r.jsxs(ne.div,{initial:{x:"100%",opacity:0},animate:{x:0,opacity:1},exit:{x:"100%",opacity:0},transition:{duration:.28,ease:[.16,1,.3,1]},className:"fixed right-0 top-0 h-screen w-[420px] bg-[#13131A] border-l border-[#2A2A35] flex flex-col z-50 shadow-2xl",children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5 border-b border-[#2A2A35] flex-shrink-0",children:[r.jsx("h3",{className:"text-[14px] font-semibold text-[#F0F0F5]",children:"Thread"}),r.jsx("button",{onClick:n,className:"w-7 h-7 flex items-center justify-center rounded-md text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/10 transition-colors",children:r.jsx(Te,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-agent",children:[d&&r.jsx("div",{className:"px-5 py-4",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"flex-shrink-0 mt-0.5",children:b?r.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-base",style:{backgroundColor:`${_??"#6366F1"}26`},children:d.sender.avatar??"⚡"}):r.jsx("div",{className:"w-8 h-8 rounded-full bg-gradient-to-br from-[#4A4A5E] to-[#2A2A3E] flex items-center justify-center border border-[#3A3A4E]",children:r.jsx("span",{className:"text-[11px] font-semibold text-[#A5A5C5]",children:d.sender.avatar??d.sender.name[0]})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-baseline gap-2 mb-1",children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:b?_??"#6366F1":"#F0F0F5"},children:d.sender.name}),r.jsx("span",{className:"text-[11px] text-[#8A8A99]",children:Ir(d.timestamp)})]}),r.jsx("div",{className:"text-[14px] text-[#C8C8D4] leading-relaxed prose-message",children:r.jsx(Ei,{remarkPlugins:[Fi],children:d.content})})]})]})}),r.jsxs("div",{className:"flex items-center gap-3 px-5 py-1.5",children:[r.jsx("div",{className:"flex-1 h-px bg-[#2A2A35]"}),r.jsxs("span",{className:"text-[11px] text-[#8A8A99] font-medium shrink-0",children:[f.length," ",f.length===1?"reply":"replies"]}),r.jsx("div",{className:"flex-1 h-px bg-[#2A2A35]"})]}),f.length===0?r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx("p",{className:"text-[13px] text-[#8A8A99]",children:"No replies yet. Start the thread."})}):f.map(w=>r.jsx(uke,{message:w,agentColor:t},w.id)),r.jsx("div",{ref:l,className:"h-2"})]}),r.jsxs("div",{className:"px-4 pb-4 pt-3 flex-shrink-0 border-t border-[#2A2A35]",children:[r.jsxs("div",{className:"flex items-end gap-2 bg-[#1C1C21] border rounded-xl px-3 py-2.5 transition-colors duration-150",style:{borderColor:a&&t?`${t}60`:"#2A2A35",boxShadow:a&&t?`0 0 0 1px ${t}30`:void 0},children:[r.jsx("textarea",{value:s,onChange:w=>i(w.target.value),onKeyDown:g,onFocus:()=>o(!0),onBlur:()=>o(!1),placeholder:"Reply in thread...",rows:1,className:"flex-1 bg-transparent text-[14px] text-[#F0F0F5] placeholder:text-[#8A8A99]/60 resize-none outline-none leading-relaxed max-h-[120px] overflow-y-auto",style:{minHeight:"22px"},onInput:w=>{const A=w.currentTarget;A.style.height="auto",A.style.height=`${Math.min(A.scrollHeight,120)}px`}}),r.jsx("button",{onClick:()=>{s.trim()&&!m.isPending&&m.mutate({parentMessageId:e,content:s.trim()})},disabled:!s.trim()||m.isPending,className:"text-[#8A8A99] hover:text-[#F0F0F5] disabled:opacity-30 transition-colors mb-0.5 flex-shrink-0",children:r.jsx(Ji,{className:"w-4 h-4"})})]}),r.jsx("p",{className:"text-[11px] text-[#8A8A99]/40 mt-1.5 px-1",children:"Enter to send · Shift+Enter for newline"})]})]})]})}function hke({agent:e,agentColor:t,onClose:n}){const s=t??e.color,{data:i,isLoading:a}=L.agents.getMemory.useQuery({agentId:e.id});return r.jsxs(ne.aside,{initial:{opacity:0,x:16},animate:{opacity:1,x:0},exit:{opacity:0,x:16},transition:{duration:.2},className:"w-[320px] flex-shrink-0 bg-[#16161A] border-l border-[#2A2A35] flex flex-col h-full overflow-hidden",children:[r.jsxs("div",{className:"px-5 py-4 border-b border-[#2A2A35] flex items-center justify-between flex-shrink-0",style:{background:`linear-gradient(135deg, rgba(${uh(s)}, 0.06) 0%, transparent 100%)`},children:[r.jsxs("div",{className:"flex items-center gap-2.5",children:[r.jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center text-base flex-shrink-0",style:{backgroundColor:`${s}26`},children:e.emoji}),r.jsxs("div",{children:[r.jsx("p",{className:"text-[13px] font-semibold text-[#F0F0F5]",children:e.name}),r.jsx("p",{className:"text-[11px] text-[#8A8A99]",children:"MEMORY.md"})]})]}),r.jsx("button",{onClick:n,className:"w-6 h-6 flex items-center justify-center rounded text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/10 transition-colors",children:r.jsx(Te,{className:"w-3.5 h-3.5"})})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:[a&&r.jsxs("div",{className:"flex items-center gap-2 text-[#8A8A99]",children:[r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#8A8A99] animate-pulse"}),r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#8A8A99] animate-pulse [animation-delay:0.2s]"}),r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#8A8A99] animate-pulse [animation-delay:0.4s]"})]}),!a&&!i?.content&&r.jsx("p",{className:"text-[13px] text-[#8A8A99] italic",children:"No memory file found for this agent."}),!a&&i?.content&&r.jsx("div",{className:"prose-message text-[13px]",children:r.jsx(Ei,{remarkPlugins:[Fi],children:i.content})})]})]})}var gy="Switch",[fke]=Wa(gy),[pke,mke]=fke(gy),EU=y.forwardRef((e,t)=>{const{__scopeSwitch:n,name:s,checked:i,defaultChecked:a,required:o,disabled:l,value:c="on",onCheckedChange:d,form:f,...p}=e,[m,g]=y.useState(null),b=At(t,C=>g(C)),_=y.useRef(!1),w=m?f||!!m.closest("form"):!0,[A,S]=Fo({prop:i,defaultProp:a??!1,onChange:d,caller:gy});return r.jsxs(pke,{scope:n,checked:A,disabled:l,children:[r.jsx(lt.button,{type:"button",role:"switch","aria-checked":A,"aria-required":o,"data-state":RU(A),"data-disabled":l?"":void 0,disabled:l,value:c,...p,ref:b,onClick:Oe(e.onClick,C=>{S(E=>!E),w&&(_.current=C.isPropagationStopped(),_.current||C.stopPropagation())})}),w&&r.jsx(MU,{control:m,bubbles:!_.current,name:s,value:c,checked:A,required:o,disabled:l,form:f,style:{transform:"translateX(-100%)"}})]})});EU.displayName=gy;var FU="SwitchThumb",TU=y.forwardRef((e,t)=>{const{__scopeSwitch:n,...s}=e,i=mke(FU,n);return r.jsx(lt.span,{"data-state":RU(i.checked),"data-disabled":i.disabled?"":void 0,...s,ref:t})});TU.displayName=FU;var xke="SwitchBubbleInput",MU=y.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:s=!0,...i},a)=>{const o=y.useRef(null),l=At(o,a),c=m7(n),d=S9(t);return y.useEffect(()=>{const f=o.current;if(!f)return;const p=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(p,"checked").set;if(c!==n&&g){const b=new Event("click",{bubbles:s});g.call(f,n),f.dispatchEvent(b)}},[c,n,s]),r.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:l,style:{...i.style,...d,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});MU.displayName=xke;function RU(e){return e?"checked":"unchecked"}var Sh=EU,Ch=TU;function r8(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,s=Array(t);n<t;n++)s[n]=e[n];return s}function gke(e){if(Array.isArray(e))return e}function bke(e,t,n){return(t=Cke(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function vke(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var s,i,a,o,l=[],c=!0,d=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(s=a.call(n)).done)&&(l.push(s.value),l.length!==t);c=!0);}catch(f){d=!0,i=f}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(d)throw i}}return l}}function yke(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
192
192
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function a8(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,s)}return n}function o8(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?a8(Object(n),!0).forEach(function(s){bke(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a8(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}return e}function _ke(e,t){if(e==null)return{};var n,s,i=wke(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(s=0;s<a.length;s++)n=a[s],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function wke(e,t){if(e==null)return{};var n={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(t.indexOf(s)!==-1)continue;n[s]=e[s]}return n}function Ake(e,t){return gke(e)||vke(e,t)||jke(e,t)||yke()}function Ske(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var s=n.call(e,t);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Cke(e){var t=Ske(e,"string");return typeof t=="symbol"?t:t+""}function jke(e,t){if(e){if(typeof e=="string")return r8(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r8(e,t):void 0}}function Nke(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l8(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,s)}return n}function c8(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?l8(Object(n),!0).forEach(function(s){Nke(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l8(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}return e}function kke(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(s){return t.reduceRight(function(i,a){return a(i)},s)}}function np(e){return function t(){for(var n=this,s=arguments.length,i=new Array(s),a=0;a<s;a++)i[a]=arguments[a];return i.length>=e.length?e.apply(this,i):function(){for(var o=arguments.length,l=new Array(o),c=0;c<o;c++)l[c]=arguments[c];return t.apply(n,[].concat(i,l))}}}function H0(e){return{}.toString.call(e).includes("Object")}function Eke(e){return!Object.keys(e).length}function Zp(e){return typeof e=="function"}function Fke(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Tke(e,t){return H0(t)||$l("changeType"),Object.keys(t).some(function(n){return!Fke(e,n)})&&$l("changeField"),t}function Mke(e){Zp(e)||$l("selectorType")}function Rke(e){Zp(e)||H0(e)||$l("handlerType"),H0(e)&&Object.values(e).some(function(t){return!Zp(t)})&&$l("handlersType")}function Dke(e){e||$l("initialIsRequired"),H0(e)||$l("initialType"),Eke(e)&&$l("initialContent")}function Oke(e,t){throw new Error(e[t]||e.default)}var Pke={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},$l=np(Oke)(Pke),nb={changes:Tke,selector:Mke,handler:Rke,initial:Dke};function Ike(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};nb.initial(e),nb.handler(t);var n={current:e},s=np(zke)(n,t),i=np(Bke)(n),a=np(nb.changes)(e),o=np(Lke)(n);function l(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(f){return f};return nb.selector(d),d(n.current)}function c(d){kke(s,i,a,o)(d)}return[l,c]}function Lke(e,t){return Zp(t)?t(e.current):t}function Bke(e,t){return e.current=c8(c8({},e.current),t),t}function zke(e,t,n){return Zp(t)?t(e.current):Object.keys(n).forEach(function(s){var i;return(i=t[s])===null||i===void 0?void 0:i.call(t,e.current[s])}),n}var $ke={create:Ike},Vke={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function Uke(e){return function t(){for(var n=this,s=arguments.length,i=new Array(s),a=0;a<s;a++)i[a]=arguments[a];return i.length>=e.length?e.apply(this,i):function(){for(var o=arguments.length,l=new Array(o),c=0;c<o;c++)l[c]=arguments[c];return t.apply(n,[].concat(i,l))}}}function Hke(e){return{}.toString.call(e).includes("Object")}function Wke(e){return e||u8("configIsRequired"),Hke(e)||u8("configType"),e.urls?(qke(),{paths:{vs:e.urls.monacoBase}}):e}function qke(){console.warn(DU.deprecation)}function Gke(e,t){throw new Error(e[t]||e.default)}var DU={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
@@ -424,7 +424,7 @@ Any required environment variables or binaries.
|
|
|
424
424
|
requires_approval: false
|
|
425
425
|
auth:
|
|
426
426
|
type: bearer
|
|
427
|
-
value: \${EXAMPLE_API_KEY}`}),r.jsxs("p",{className:"text-[10px] text-[#5A5A6E] mt-2 leading-relaxed",children:["Auth types: ",r.jsx("code",{className:"text-[#8A8A99]",children:"bearer"}),", ",r.jsx("code",{className:"text-[#8A8A99]",children:"header"})," (add ",r.jsx("code",{className:"text-[#8A8A99]",children:"header: X-Name"}),"), ",r.jsx("code",{className:"text-[#8A8A99]",children:"query"})," (add ",r.jsx("code",{className:"text-[#8A8A99]",children:"query: api_key"}),"). Set ",r.jsx("code",{className:"text-[#8A8A99]",children:"requires_approval: true"})," for destructive calls."]})]})})]})}function CRe({onClose:e,onSuccess:t}){const[n,s]=y.useState("pick"),[i,a]=y.useState(null),[o,l]=y.useState(null),[c,d]=y.useState(null),f=y.useRef(null),p=L.skillPackImport.preview.useMutation(),m=L.skillPackImport.confirm.useMutation(),g=y.useCallback(async _=>{if(!_.name.endsWith(".damnpack")){l("Please select a .damnpack file"),s("error");return}if(_.size>100*1024*1024){l("File too large (max 100MB)"),s("error");return}s("uploading");try{const w=new FormData;w.append("file",_);const A=await fetch(`${oi}/api/agents/import-upload`,{method:"POST",body:w,credentials:"include"});if(!A.ok){const E=await A.json().catch(()=>({error:"Upload failed"}));throw new Error(E.error||`Upload failed (${A.status})`)}const{uploadId:S}=await A.json(),C=await p.mutateAsync({uploadId:S});a(C),s("preview")}catch(w){l(w instanceof Error?w.message:"Upload failed"),s("error")}},[p]);async function b(){if(i){s("confirming");try{const _=await m.mutateAsync({previewId:i.previewId});d(_),s("done")}catch(_){l(_ instanceof Error?_.message:"Install failed"),s("error")}}}return r.jsxs(ne.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:e,children:[r.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),r.jsxs(ne.div,{initial:{scale:.95,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.95,opacity:0},transition:{duration:.15},onClick:_=>_.stopPropagation(),className:"relative w-full max-w-md bg-[#16161A] border border-[#2A2A35] rounded-2xl shadow-2xl overflow-hidden",children:[r.jsxs("div",{className:"px-5 py-4 border-b border-[#2A2A35] flex items-center justify-between",children:[r.jsx("p",{className:"text-[14px] font-semibold text-[#F0F0F5]",children:n==="done"?"Skills installed":"Import skill pack"}),r.jsx("button",{onClick:e,className:"w-7 h-7 flex items-center justify-center rounded-md text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/10 transition-colors",children:r.jsx(Te,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"p-5",children:[n==="pick"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("button",{onClick:()=>f.current?.click(),className:"w-full py-10 rounded-xl border-2 border-dashed border-[#2A2A35] hover:border-[#6366F1]/50 transition-colors flex flex-col items-center gap-3 group",children:[r.jsx(su,{className:"w-8 h-8 text-[#5A5A6E] group-hover:text-[#6366F1] transition-colors"}),r.jsxs("div",{className:"text-center",children:[r.jsx("p",{className:"text-[13px] text-[#F0F0F5] font-medium",children:"Choose .damnpack skill pack"}),r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mt-1",children:"Max 100MB"})]})]}),r.jsx("input",{ref:f,type:"file",accept:".damnpack",className:"hidden",onChange:_=>{const w=_.target.files?.[0];w&&g(w)}})]}),(n==="uploading"||n==="confirming")&&r.jsxs("div",{className:"flex flex-col items-center py-8 gap-3",children:[r.jsx(Pe,{className:"w-8 h-8 text-[#6366F1] animate-spin"}),r.jsx("p",{className:"text-[13px] text-[#8A8A99]",children:n==="uploading"?"Scanning skill pack...":"Installing skills..."})]}),n==="error"&&r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"rounded-lg bg-[#EF4444]/10 border border-[#EF4444]/20 px-4 py-3",children:r.jsx("p",{className:"text-[13px] text-[#FCA5A5]",children:o})}),r.jsx("button",{onClick:()=>{s("pick"),l(null)},className:"w-full py-2 rounded-lg text-[13px] font-medium bg-[#2A2A35] hover:bg-[#3A3A45] text-[#F0F0F5] transition-colors",children:"Try again"})]}),n==="preview"&&i&&r.jsxs("div",{className:"space-y-4 max-h-[60vh] overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#6366F1]/15 border border-[#6366F1]/25 flex items-center justify-center",children:r.jsx(vv,{className:"w-5 h-5 text-[#818CF8]"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-[14px] font-semibold text-[#F0F0F5] truncate",children:i.name}),r.jsxs("p",{className:"text-[11px] text-[#8A8A99]",children:["v",i.version," by"," ",i.publisherUrl?r.jsxs("a",{href:i.publisherUrl,target:"_blank",rel:"noopener noreferrer",className:"text-[#818CF8] hover:underline inline-flex items-center gap-0.5",children:[i.publisher,r.jsx(cs,{className:"w-2.5 h-2.5"})]}):i.publisher]})]})]}),r.jsx("p",{className:"text-[12px] text-[#8A8A99]",children:i.summary}),r.jsxs("div",{children:[r.jsxs("p",{className:"text-[10px] font-semibold text-[#5A5A6E] uppercase tracking-widest mb-2",children:[i.skills.length," skill",i.skills.length!==1?"s":""]}),r.jsx("div",{className:"space-y-2",children:i.skills.map(_=>r.jsxs("div",{className:"rounded-lg bg-[#1C1C21] border border-[#2A2A35] px-3 py-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between mb-0.5",children:[r.jsx("p",{className:"text-[13px] font-medium text-[#F0F0F5]",children:_.name}),r.jsxs("div",{className:"flex items-center gap-2",children:[_.toolCount>0&&r.jsxs("span",{className:"text-[10px] text-[#5A5A6E]",children:[_.toolCount," tool",_.toolCount!==1?"s":""]}),_.exists&&r.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-[#F59E0B]/10 text-[#FCD34D] border border-[#F59E0B]/20",children:"Update"})]})]}),r.jsx("p",{className:"text-[11px] text-[#6A6A7A] line-clamp-2",children:_.description})]},_.slug))})]}),i.missingSecrets.length>0&&(()=>{const _=i.missingSecrets.filter(A=>!A.default),w=i.missingSecrets.filter(A=>!!A.default);return r.jsxs("div",{className:"space-y-2",children:[w.length>0&&r.jsxs("div",{className:"rounded-lg bg-emerald-500/10 border border-emerald-500/20 px-3 py-2 space-y-1",children:[r.jsxs("p",{className:"text-[11px] font-semibold text-emerald-400 flex items-center gap-1.5",children:[r.jsx(Fe,{className:"w-3.5 h-3.5"}),"Auto-configured"]}),r.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1",children:w.map(A=>r.jsx("code",{className:"px-1.5 py-0.5 rounded text-[10px] font-mono text-emerald-400 bg-emerald-500/15 border border-emerald-500/20",children:A.key},A.key))})]}),_.length>0&&r.jsxs("div",{className:"rounded-lg bg-[#F59E0B]/10 border border-[#F59E0B]/20 px-3 py-2 space-y-1.5",children:[r.jsxs("p",{className:"text-[11px] font-semibold text-[#FCD34D] flex items-center gap-1.5",children:[r.jsx(Eo,{className:"w-3.5 h-3.5"}),"Required workspace secrets"]}),r.jsx("p",{className:"text-[10px] text-[#FCD34D]/80",children:"You'll need to add these in Settings after installing:"}),r.jsx("div",{className:"space-y-1 mt-1.5",children:_.map(A=>r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("code",{className:"px-1.5 py-0.5 rounded text-[10px] font-mono text-[#FCD34D] bg-[#F59E0B]/15 border border-[#F59E0B]/20 flex-shrink-0",children:A.key}),r.jsx("span",{className:"text-[10px] text-[#FCD34D]/60 leading-tight",children:A.description})]},A.key))})]})]})})(),r.jsxs("div",{className:"flex gap-2 pt-2",children:[r.jsx("button",{onClick:b,className:"flex-1 py-2 rounded-lg text-[13px] font-medium bg-[#6366F1] hover:bg-[#5254CC] text-white transition-colors",children:"Install All"}),r.jsx("button",{onClick:e,className:"px-4 py-2 rounded-lg text-[13px] font-medium bg-[#2A2A35] hover:bg-[#3A3A45] text-[#F0F0F5] transition-colors",children:"Cancel"})]})]}),n==="done"&&c&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center gap-3 py-4",children:[r.jsx("div",{className:"w-10 h-10 rounded-full bg-emerald-500/15 border border-emerald-500/25 flex items-center justify-center",children:r.jsx(Fe,{className:"w-5 h-5 text-emerald-400"})}),r.jsxs("div",{children:[r.jsxs("p",{className:"text-[14px] font-semibold text-[#F0F0F5]",children:[c.total," skill",c.total!==1?"s":""," installed"]}),r.jsxs("p",{className:"text-[12px] text-[#8A8A99]",children:[c.installed.length>0&&`${c.installed.length} new`,c.installed.length>0&&c.updated.length>0&&", ",c.updated.length>0&&`${c.updated.length} updated`]})]})]}),c.autoPopulated.length>0&&r.jsx("div",{className:"rounded-lg bg-emerald-500/10 border border-emerald-500/20 px-3 py-2",children:r.jsxs("p",{className:"text-[11px] text-emerald-400",children:["Auto-configured: ",c.autoPopulated.join(", ")]})}),i&&i.missingSecrets.some(_=>!_.default)&&r.jsxs(gn,{to:"/settings?tab=secrets",className:"flex items-center justify-center gap-1.5 w-full py-2 rounded-lg text-[12px] font-medium bg-[#F59E0B]/10 text-[#FCD34D] hover:bg-[#F59E0B]/20 border border-[#F59E0B]/30 transition-colors",children:[r.jsx(Eo,{className:"w-3.5 h-3.5"}),"Add missing secrets in Settings"]}),r.jsx("button",{onClick:()=>{t(),e()},className:"w-full py-2 rounded-lg text-[13px] font-medium bg-[#6366F1] hover:bg-[#5254CC] text-white transition-colors",children:"Done"})]})]})]})]})}const jRe={secretsoss:"#6366F1",lifelog:"#10B981",chut:"#F59E0B",custom:"#6B7280",clawhub:"#8B5CF6"};function NRe(e){return jRe[e]??"#6B7280"}function yW({provider:e}){const t=NRe(e),n=e==="secretsoss"?"SecretSoss":e==="lifelog"?"Lifelog":e==="chut"?"Chut.co":e;return r.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-md text-[11px] font-medium",style:{backgroundColor:`${t}20`,color:t,border:`1px solid ${t}40`},children:n})}function nO({onConfirm:e,onRemove:t}){const[n,s]=y.useState(!1);return r.jsxs(Ys,{open:n,onOpenChange:s,children:[r.jsx(ci,{asChild:!0,children:r.jsx("button",{className:"px-3 py-1.5 rounded-lg text-[12px] font-medium bg-white/5 text-[#8A8A99] hover:bg-red-500/10 hover:text-red-400 border border-[#2A2A35] hover:border-red-500/30 transition-colors",children:"Uninstall"})}),r.jsx(Qs,{children:r.jsxs(Xs,{side:"top",align:"end",sideOffset:6,className:ye("z-50 bg-[#1C1C24] border border-[#2A2A35] rounded-xl p-4 shadow-2xl",t?"w-64":"w-56"),children:[r.jsx("p",{className:"text-[12px] text-[#C8C8D4] mb-3 leading-relaxed",children:t?"Uninstall from agents, or remove entirely?":"This will remove the skill from all agents. Continue?"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{onClick:()=>s(!1),className:"flex-1 py-1.5 rounded-lg text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] border border-[#2A2A35] hover:border-[#3A3A45] transition-colors",children:"Cancel"}),r.jsx("button",{onClick:()=>{e(),s(!1)},className:"flex-1 py-1.5 rounded-lg text-[12px] text-amber-400 hover:text-amber-300 bg-amber-500/10 hover:bg-amber-500/20 border border-amber-500/30 transition-colors",children:"Uninstall"}),t&&r.jsxs("button",{onClick:()=>{t(),s(!1)},className:"py-1.5 px-2.5 rounded-lg text-[12px] text-red-400 hover:text-red-300 bg-red-500/10 hover:bg-red-500/20 border border-red-500/30 transition-colors flex items-center gap-1",children:[r.jsx(Dn,{className:"w-3 h-3"}),"Remove"]})]}),r.jsx(oa,{className:"fill-[#2A2A35]"})]})})]})}function kRe({skill:e,isInstalled:t,onInstall:n,onUninstall:s,onRemove:i,onEdit:a,onDelete:o,onClick:l,selected:c,canManage:d=!0}){return r.jsxs(ne.div,{layout:!0,initial:{opacity:0,y:8},animate:{opacity:1,y:0},onClick:l,className:ye("bg-[#16161A] border rounded-2xl p-5 cursor-pointer transition-colors relative overflow-hidden",c?"border-[#6366F1]/50 ring-1 ring-[#6366F1]/20":"border-[#2A2A35] hover:border-[#3A3A45]"),children:[r.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx(yW,{provider:e.source==="custom"||e.source==="authored"?"custom":e.provider}),e.requiresApproval&&r.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] font-medium bg-amber-500/10 text-amber-400 border border-amber-500/30",children:[r.jsx(_m,{className:"w-3 h-3"}),"Approval required"]})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[d&&(e.source==="custom"||e.source==="authored")&&a&&r.jsx("button",{onClick:f=>{f.stopPropagation(),a()},className:"w-6 h-6 flex items-center justify-center rounded-md text-[#5A5A6E] hover:text-[#F0F0F5] hover:bg-white/10 transition-colors",children:r.jsx(O5,{className:"w-3 h-3"})}),r.jsxs("span",{className:"text-[10px] text-[#5A5A6E] mt-0.5",children:["v",e.version]})]})]}),r.jsx("h3",{className:"text-[14px] font-semibold text-[#F0F0F5] mb-1",children:e.name}),r.jsx("p",{className:"text-[12px] text-[#6A6A7A] leading-relaxed line-clamp-2 mb-4",children:e.description}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[11px] text-[#5A5A6E]",children:t?"Installed":"Not installed"}),d&&r.jsxs("div",{className:"flex items-center gap-2",onClick:f=>f.stopPropagation(),children:[(e.source==="custom"||e.source==="authored")&&o&&r.jsx(nO,{onConfirm:o}),t?e.source!=="custom"&&r.jsx(nO,{onConfirm:s,onRemove:i}):r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:n,className:"px-3 py-1.5 rounded-lg text-[12px] font-medium bg-[#6366F1]/10 text-[#6366F1] hover:bg-[#6366F1]/20 border border-[#6366F1]/30 transition-colors",children:"Install"}),i&&r.jsx("button",{onClick:i,className:"w-7 h-7 flex items-center justify-center rounded-lg text-[#5A5A6E] hover:text-red-400 hover:bg-red-500/10 border border-[#2A2A35] hover:border-red-500/30 transition-colors",children:r.jsx(Dn,{className:"w-3 h-3"})})]})]})]})]})}function ERe({agent:e,skillId:t,agentSkill:n}){const s=L.useUtils(),i=L.skills.toggleAgentSkill.useMutation({onSuccess:()=>{s.skills.getAgentSkills.invalidate()}});return r.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#2A2A35] last:border-0",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-base flex-shrink-0",style:{backgroundColor:`${e.color}26`},children:e.emoji}),r.jsxs("div",{children:[r.jsx("p",{className:"text-[13px] font-medium text-[#F0F0F5]",children:e.name}),r.jsx("p",{className:"text-[11px] text-[#8A8A99]",children:e.role})]})]}),r.jsx(Sh,{checked:n?.enabled??!1,onCheckedChange:a=>i.mutate({agentId:e.id,skillId:t,enabled:a}),className:"relative inline-flex h-5 w-9 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 focus:outline-none data-[state=checked]:bg-[#6366F1] data-[state=unchecked]:bg-[#2A2A35] disabled:opacity-40 disabled:cursor-not-allowed",children:r.jsx(Ch,{className:"pointer-events-none inline-block h-4 w-4 transform rounded-full bg-white shadow-lg transition duration-200 data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"})})]})}function FRe(e,t){const n=e.map(s=>L.skills.getAgentSkills.useQuery({agentId:s.id}));return e.map((s,i)=>({agent:s,agentSkill:n[i].data?.find(a=>a.skillId===t)}))}function TRe({varName:e}){const t=L.useUtils(),{data:n=[]}=L.settings.getEnvVars.useQuery(),{data:s=[]}=L.secrets.listKeys.useQuery(),{data:i=[]}=L.settings.getKnownKeys.useQuery(),a=i.find(k=>k.key===e)?.kind,o=a===void 0||a==="secret",l=L.settings.setEnvVar.useMutation({onSuccess:()=>{t.settings.getEnvVars.invalidate()}}),c=L.settings.deleteEnvVar.useMutation({onSuccess:()=>{t.settings.getEnvVars.invalidate()}}),d=L.secrets.set.useMutation({onSuccess:()=>{t.secrets.listKeys.invalidate(),t.secrets.list.invalidate()}}),f=n.find(k=>k.key===e),p=s.includes(e),m=!!f||p,[g,b]=y.useState(!1),[_,w]=y.useState(""),[A,S]=y.useState(!1);function C(){const k=_.trim();k&&(o?(d.mutate({key:e,value:k}),f&&c.mutate({key:e})):l.mutate({key:e,value:k}),b(!1),w(""))}const E=l.isPending||d.isPending;return r.jsxs("div",{className:"py-3 border-b border-[#2A2A35] last:border-0",children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("span",{className:"text-[12px] font-mono text-[#C8C8D4]",children:e}),m?r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-[#10B981]",children:[r.jsx(Fe,{className:"w-3 h-3"}),"Configured"]}):r.jsx("span",{className:"text-[11px] text-[#F87171]",children:"Missing"})]}),g?r.jsxs("div",{className:"flex gap-2 mt-2",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx("input",{type:A?"text":"password",value:_,onChange:k=>w(k.target.value),onKeyDown:k=>{k.key==="Enter"&&C()},placeholder:`Enter ${e}...`,autoFocus:!0,className:"w-full bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-1.5 pr-8 text-[12px] text-[#F0F0F5] placeholder-[#5A5A6E] outline-none focus:border-[#6366F1]/60 transition-colors font-mono"}),r.jsx("button",{onClick:()=>S(!A),className:"absolute right-2 top-1/2 -translate-y-1/2 text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:A?r.jsx(R5,{className:"w-3.5 h-3.5"}):r.jsx(xv,{className:"w-3.5 h-3.5"})})]}),r.jsx("button",{onClick:C,disabled:!_.trim()||E,className:"px-3 py-1.5 rounded-lg text-[12px] font-medium bg-[#6366F1]/10 text-[#6366F1] hover:bg-[#6366F1]/20 border border-[#6366F1]/30 transition-colors disabled:opacity-40",children:"Save"}),r.jsx("button",{onClick:()=>{b(!1),w("")},className:"px-2 py-1.5 rounded-lg text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] transition-colors",children:r.jsx(Te,{className:"w-3.5 h-3.5"})})]}):r.jsx("button",{onClick:()=>b(!0),className:"text-[11px] font-medium text-[#6366F1] hover:text-[#818CF8] transition-colors mt-1",children:m?"Update":"Set value"})]})}function MRe({skill:e,agents:t,onClose:n}){const[s,i]=y.useState("info"),a=L.useUtils(),o=FRe(t,e.id),l=L.skills.toggleAgentSkill.useMutation({onMutate:async({agentId:m,skillId:g,enabled:b})=>{await a.skills.getAgentSkills.cancel({agentId:m});const _=a.skills.getAgentSkills.getData({agentId:m});return a.skills.getAgentSkills.setData({agentId:m},w=>w?.map(A=>A.agentId===m&&A.skillId===g?{...A,enabled:b}:A)),{prev:_}},onError:(m,{agentId:g},b)=>{b?.prev&&a.skills.getAgentSkills.setData({agentId:g},b.prev)}}),{data:c=[]}=L.skills.getSkillEnvVars.useQuery({skillId:e.id}),{data:d}=L.skills.getSkillContent.useQuery({skillId:e.id}),f=o.length>0&&o.every(m=>m.agentSkill?.enabled);function p(){const m=!f;o.forEach(({agent:g})=>{l.mutate({agentId:g.id,skillId:e.id,enabled:m})})}return r.jsxs(r.Fragment,{children:[r.jsx(ne.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-40",style:{backdropFilter:"blur(2px)",backgroundColor:"rgba(0,0,0,0.25)"},onClick:n}),r.jsxs(ne.div,{initial:{x:"100%",opacity:0},animate:{x:0,opacity:1},exit:{x:"100%",opacity:0},transition:{duration:.3,ease:[.16,1,.3,1]},className:"fixed right-0 top-0 h-screen w-[380px] bg-[#13131A] border-l border-[#2A2A35] flex flex-col z-50 shadow-2xl",children:[r.jsxs("div",{className:"px-5 py-4 border-b border-[#2A2A35] flex items-center justify-between flex-shrink-0",children:[r.jsxs("div",{children:[r.jsx("div",{className:"mb-0.5",children:r.jsx(yW,{provider:e.provider})}),r.jsx("p",{className:"text-[15px] font-semibold text-[#F0F0F5] mt-1",children:e.name})]}),r.jsx("button",{onClick:n,className:"w-7 h-7 flex items-center justify-center rounded-md text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/10 transition-colors",children:r.jsx(Te,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"flex border-b border-[#2A2A35] flex-shrink-0",children:[r.jsx("button",{onClick:()=>i("info"),className:ye("flex-1 py-2.5 text-[12px] font-medium transition-colors border-b-2 -mb-px",s==="info"?"text-[#F0F0F5] border-[#6366F1]":"text-[#8A8A99] border-transparent hover:text-[#C8C8D4]"),children:"Info"}),r.jsx("button",{onClick:()=>i("agents"),className:ye("flex-1 py-2.5 text-[12px] font-medium transition-colors border-b-2 -mb-px",s==="agents"?"text-[#F0F0F5] border-[#6366F1]":"text-[#8A8A99] border-transparent hover:text-[#C8C8D4]"),children:"Agents"}),r.jsxs("button",{onClick:()=>i("keys"),className:ye("flex-1 py-2.5 text-[12px] font-medium transition-colors border-b-2 -mb-px",s==="keys"?"text-[#F0F0F5] border-[#6366F1]":"text-[#8A8A99] border-transparent hover:text-[#C8C8D4]"),children:["Secrets",c.length>0?` (${c.length})`:""]})]}),e.requiresApproval&&s==="agents"&&r.jsxs("div",{className:"mx-5 mt-4 px-3 py-2.5 rounded-lg bg-amber-500/[0.08] border border-amber-500/20 flex items-start gap-2",children:[r.jsx(_m,{className:"w-3.5 h-3.5 text-amber-400 flex-shrink-0 mt-0.5"}),r.jsx("p",{className:"text-[12px] text-amber-300/80 leading-relaxed",children:"Agent will ask for your approval before executing this skill."})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:[s==="info"&&r.jsxs("div",{className:"space-y-5",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-[11px] font-semibold text-[#8A8A99] uppercase tracking-widest mb-2",children:"Description"}),r.jsx("p",{className:"text-[13px] text-[#C8C8D4] leading-relaxed",children:e.description})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mb-1",children:"Version"}),r.jsxs("p",{className:"text-[13px] text-[#F0F0F5] font-mono",children:["v",e.version]})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mb-1",children:"Source"}),r.jsx("p",{className:"text-[13px] text-[#F0F0F5] capitalize",children:e.source})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mb-1",children:"Provider"}),r.jsx("p",{className:"text-[13px] text-[#F0F0F5]",children:e.provider})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mb-1",children:"Endpoint"}),r.jsx("p",{className:"text-[13px] text-[#F0F0F5] font-mono truncate",title:e.endpoint,children:e.endpoint||"—"})]})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mb-1",children:"Slug"}),r.jsx("p",{className:"text-[13px] text-[#F0F0F5] font-mono",children:e.slug})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mb-1",children:"Installed"}),r.jsx("p",{className:"text-[13px] text-[#F0F0F5]",children:new Date(e.installedAt).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})})]}),d?.content&&r.jsxs("div",{children:[r.jsx("p",{className:"text-[11px] font-semibold text-[#8A8A99] uppercase tracking-widest mb-2",children:"SKILL.md"}),r.jsx("pre",{className:"text-[11px] text-[#C8C8D4] font-mono whitespace-pre-wrap leading-relaxed bg-[#0F0F11] border border-[#2A2A35] rounded-lg p-3 max-h-[300px] overflow-y-auto",children:d.content})]})]}),s==="agents"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("p",{className:"text-[11px] font-semibold text-[#8A8A99] uppercase tracking-widest",children:"Agent access"}),o.length>0&&r.jsx("button",{onClick:p,className:"text-[11px] font-medium text-[#6366F1] hover:text-[#818CF8] transition-colors",children:f?"Disable all":"Enable all"})]}),t.length===0&&r.jsx("p",{className:"text-[13px] text-[#8A8A99] italic",children:"No agents found."}),o.map(({agent:m,agentSkill:g})=>r.jsx(ERe,{agent:m,skillId:e.id,agentSkill:g},m.id))]}),s==="keys"&&r.jsx(r.Fragment,{children:c.length===0?r.jsx("p",{className:"text-[13px] text-[#8A8A99] italic",children:"This skill has no required secrets."}):c.map(m=>r.jsx(TRe,{varName:m},m))})]})]})]})}function RRe(e){const t=e.map(s=>L.skills.getAgentSkills.useQuery({agentId:s.id}));return new Set(t.flatMap(s=>(s.data??[]).map(i=>i.skillId)))}function DRe({skills:e,agents:t,selectedSkillId:n,onInstall:s,onUninstall:i,onRemove:a,onSelect:o,onEditCustom:l,onDeleteCustom:c,canManage:d=!0}){const f=RRe(t);return r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:e.map(p=>r.jsx(kRe,{skill:p,isInstalled:f.has(p.id),onInstall:()=>s(p.id),onUninstall:()=>i(p.id),onRemove:p.source!=="custom"&&p.source!=="authored"?()=>a(p.id):void 0,onEdit:p.source==="custom"||p.source==="authored"?()=>l(p):void 0,onDelete:p.source==="custom"||p.source==="authored"?()=>c(p.id):void 0,onClick:()=>o(n===p.id?null:p),selected:n===p.id,canManage:d},p.id))})}function ORe({result:e,onClose:t,onInstall:n,inspectData:s}){const{data:i,isLoading:a,isError:o}=L.skills.getClawHubSkillContent.useQuery({slug:e.slug},{staleTime:1/0}),l=i?.content?.includes("shell://")||i?.content?.includes("shell_exec")||i?.content?.includes("exec:"),[c,d]=y.useState(!1),f=!a&&!o&&(!l||c);return r.jsx(ji,{open:!0,onOpenChange:p=>{p||t()},children:r.jsxs(Ni,{children:[r.jsx(ir,{className:"fixed inset-0 bg-black/60 z-40"}),r.jsxs(ki,{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[640px] max-h-[80vh] bg-[#1C1C24] border border-[#2A2A35] rounded-xl shadow-2xl z-50 flex flex-col",children:[r.jsxs("div",{className:"px-5 py-4 border-b border-[#2A2A35] flex items-center justify-between flex-shrink-0",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[r.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-md text-[11px] font-medium",style:{backgroundColor:"#8B5CF620",color:"#8B5CF6",border:"1px solid #8B5CF640"},children:e.publisher||"Unknown publisher"}),i?.hasSecurityWarning&&r.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] font-medium bg-amber-500/10 text-amber-400 border border-amber-500/30",children:[r.jsx(_m,{className:"w-3 h-3"}),"Network activity detected"]})]}),r.jsx(nr,{className:"text-[15px] font-semibold text-[#F0F0F5]",children:e.displayName}),r.jsxs("div",{className:"flex items-center gap-3 mt-1.5",children:[s?.downloads!=null&&r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-[#5A5A6E]",children:[r.jsx(nu,{className:"w-3 h-3"}),s.downloads.toLocaleString()]}),s?.stars!=null&&s.stars>0&&r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-[#5A5A6E]",children:[r.jsx(Ire,{className:"w-3 h-3"}),s.stars]}),e.version&&r.jsxs("span",{className:"text-[11px] text-[#5A5A6E]",children:["v",e.version]}),!s?.downloads&&!s?.stars&&r.jsx("span",{className:"text-[10px] text-[#5A5A6E] italic",children:"Unknown — review SKILL.md before installing"})]})]}),r.jsx(Gs,{asChild:!0,children:r.jsx("button",{className:"w-7 h-7 flex items-center justify-center rounded-md text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/10 transition-colors",children:r.jsx(Te,{className:"w-4 h-4"})})})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4 min-h-0",children:[a&&r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx("div",{className:"w-5 h-5 border-2 border-[#6366F1]/30 border-t-[#6366F1] rounded-full animate-spin"})}),o&&r.jsx("p",{className:"text-[13px] text-red-400",children:"Could not load SKILL.md — check your internet connection."}),i&&r.jsx("pre",{className:"text-[12px] text-[#C8C8D4] font-mono whitespace-pre-wrap leading-relaxed",children:i.content})]}),l&&!c&&r.jsxs("div",{className:"mx-5 mb-3 p-3 rounded-lg bg-red-500/[0.08] border border-red-500/30 flex items-start gap-2.5",children:[r.jsx(Ti,{className:"w-4 h-4 text-red-400 flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-[12px] text-red-300 leading-relaxed mb-2",children:"This skill will execute commands on your machine. Only install if you trust the publisher."}),r.jsx("button",{onClick:()=>d(!0),className:"px-3 py-1 rounded-md text-[11px] font-medium bg-red-500/20 text-red-300 hover:bg-red-500/30 border border-red-500/30 transition-colors",children:"I understand the risks"})]})]}),r.jsxs("div",{className:"px-5 py-3 border-t border-[#2A2A35] flex items-center justify-between flex-shrink-0",children:[r.jsx("p",{className:"text-[12px] text-[#8A8A99]",children:"Review the skill before installing."}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Gs,{asChild:!0,children:r.jsx("button",{className:"px-3 py-1.5 rounded-lg text-[13px] text-[#8A8A99] hover:text-[#F0F0F5] border border-[#2A2A35] hover:border-[#3A3A45] transition-colors",children:"Cancel"})}),r.jsxs("button",{onClick:n,disabled:!f,className:"flex items-center gap-1.5 px-4 py-1.5 rounded-lg bg-[#8B5CF6] text-white text-[13px] font-medium hover:bg-[#7C3AED] transition-colors disabled:opacity-40 disabled:pointer-events-none",children:[r.jsx(nu,{className:"w-3.5 h-3.5"}),"Install"]})]})]})]})]})})}function PRe({result:e,onReviewInstall:t}){return r.jsxs(ne.div,{layout:!0,initial:{opacity:0,y:8},animate:{opacity:1,y:0},className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-5 hover:border-[#3A3A45] transition-colors",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[r.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[r.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-md text-[11px] font-medium",style:{backgroundColor:"#8B5CF620",color:"#8B5CF6",border:"1px solid #8B5CF640"},children:e.publisher}),e.hasSecurityWarning&&r.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium bg-amber-500/10 text-amber-400 border border-amber-500/30",children:[r.jsx(_m,{className:"w-2.5 h-2.5"}),"Network"]}),e.source==="github"&&r.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-white/5 text-[#5A5A6E] border border-[#2A2A35]",children:"archive"})]}),e.installed&&r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-[#10B981] flex-shrink-0",children:[r.jsx(sa,{className:"w-3 h-3"}),"Installed"]})]}),r.jsx("h3",{className:"text-[14px] font-semibold text-[#F0F0F5] mb-1",children:e.displayName}),r.jsx("p",{className:"text-[12px] text-[#6A6A7A] leading-relaxed line-clamp-2 mb-4",children:e.summary||e.slug}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[11px] text-[#5A5A6E] font-mono",children:e.slug}),e.installed?r.jsx("span",{className:"px-3 py-1.5 rounded-lg text-[12px] font-medium text-[#10B981] bg-[#10B981]/10 border border-[#10B981]/30",children:"Installed"}):r.jsxs("button",{onClick:()=>t(e),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[12px] font-medium bg-[#8B5CF6]/10 text-[#8B5CF6] hover:bg-[#8B5CF6]/20 border border-[#8B5CF6]/30 transition-colors",children:[r.jsx(cs,{className:"w-3 h-3"}),"Review & Install"]})]})]})}function IRe({requiredEnvVars:e,requiredBins:t,skillName:n,hasSecurityWarning:s,onClose:i}){return y.useEffect(()=>{const a=setTimeout(i,8e3);return()=>clearTimeout(a)},[i]),r.jsxs(ne.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},exit:{opacity:0,y:16},className:"fixed bottom-6 right-6 z-50 w-[380px] bg-[#1C1C24] border border-[#2A2A35] rounded-xl shadow-2xl p-4",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(sa,{className:"w-4 h-4 text-[#10B981] flex-shrink-0"}),r.jsxs("span",{className:"text-[13px] font-semibold text-[#F0F0F5]",children:[n," installed"]})]}),r.jsx("button",{onClick:i,className:"text-[#8A8A99] hover:text-[#F0F0F5] transition-colors",children:r.jsx(Te,{className:"w-4 h-4"})})]}),e.length>0&&r.jsxs("div",{className:"mb-2 p-2.5 rounded-lg bg-amber-500/[0.08] border border-amber-500/20 flex items-start gap-2",children:[r.jsx(Rs,{className:"w-3.5 h-3.5 text-amber-400 flex-shrink-0 mt-0.5"}),r.jsx("div",{children:r.jsxs("p",{className:"text-[12px] text-amber-300/80 leading-relaxed",children:["Requires ",e.join(", "),"."," ",r.jsx(gn,{to:"/settings?tab=secrets",onClick:i,className:"underline hover:text-amber-300 transition-colors",children:"Configure in Settings → Secrets"})]})})]}),t.length>0&&r.jsx("div",{className:"p-2.5 rounded-lg bg-blue-500/[0.08] border border-blue-500/20",children:r.jsxs("p",{className:"text-[12px] text-blue-300/80 leading-relaxed",children:["Requires: ",r.jsx("span",{className:"font-mono",children:t.join(", ")})]})}),s&&r.jsxs("div",{className:"p-2.5 rounded-lg bg-amber-500/[0.08] border border-amber-500/20 flex items-start gap-2",children:[r.jsx(_m,{className:"w-3.5 h-3.5 text-amber-400 flex-shrink-0 mt-0.5"}),r.jsx("p",{className:"text-[12px] text-amber-300/80 leading-relaxed",children:"This skill contains network activity patterns. Review the SKILL.md before enabling for agents."})]})]})}function LRe({skills:e}){const[t,n]=y.useState(""),[s,i]=y.useState(""),[a,o]=y.useState(null),[l,c]=y.useState(null),d=y.useRef(null),f=L.useUtils(),p=new Set(e.filter(C=>C.source==="clawhub").map(C=>C.slug));function m(C){n(C),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>i(C),300)}const{data:g=[],isLoading:b,isFetching:_}=L.skills.searchClawHub.useQuery({query:s},{enabled:s.length>0,staleTime:5*6e4}),w=g.map(C=>({...C,installed:p.has(C.slug)})),A=L.skills.inspectClawHub.useQuery({slug:a?.slug??""},{enabled:!!a,staleTime:5*6e4}),S=L.skills.installFromClawHub.useMutation({onSuccess:C=>{f.skills.list.invalidate(),f.skills.getAgentSkills.invalidate(),o(null),c({name:C.skill.name,envVars:C.requiredEnvVars,bins:C.requiredBins,hasSecurityWarning:C.hasSecurityWarning})}});return r.jsxs("div",{children:[r.jsxs("div",{className:"relative mb-6",children:[r.jsx(Io,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[#5A5A6E]"}),r.jsx("input",{value:t,onChange:C=>m(C.target.value),placeholder:"Search ClawHub skills...",className:"w-full bg-[#16161A] border border-[#2A2A35] rounded-xl pl-9 pr-4 py-2.5 text-[13px] text-[#F0F0F5] placeholder-[#5A5A6E] outline-none focus:border-[#8B5CF6]/60 transition-colors"}),_&&r.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:r.jsx("div",{className:"w-4 h-4 border-2 border-[#8B5CF6]/30 border-t-[#8B5CF6] rounded-full animate-spin"})})]}),b&&r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3,4,5,6].map(C=>r.jsx("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-5 animate-pulse h-[180px]"},C))}),!b&&w.length===0&&s&&r.jsx("div",{className:"flex flex-col items-center justify-center py-24 text-center",children:r.jsxs("p",{className:"text-[14px] text-[#8A8A99]",children:['No skills found for "',s,'".']})}),!b&&w.length>0&&r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:w.map(C=>r.jsx(PRe,{result:C,onReviewInstall:o},`${C.publisher}/${C.slug}`))}),a&&r.jsx(ORe,{result:{...a,publisher:A.data?.publisher??a.publisher??"",version:A.data?.version,hasSecurityWarning:A.data?.hasSecurityWarning??a.hasSecurityWarning},inspectData:A.data?{downloads:A.data.downloads,stars:A.data.stars,tags:A.data.tags}:void 0,onClose:()=>o(null),onInstall:()=>S.mutate({slug:a.slug,publisher:A.data?.publisher??a.publisher??"",displayName:A.data?.displayName??a.displayName,version:A.data?.version??"1.0.0"})}),r.jsx(Me,{children:l&&r.jsx(IRe,{skillName:l.name,requiredEnvVars:l.envVars,requiredBins:l.bins,hasSecurityWarning:l.hasSecurityWarning,onClose:()=>c(null)})})]})}function BRe(){const[e,t]=y.useState("my-skills"),[n,s]=y.useState(""),[i,a]=y.useState(null),[o,l]=y.useState(!1),[c,d]=y.useState(null),[f,p]=y.useState(!1),[m,g]=y.useState(null),[b,_]=y.useState(!1),{data:w=[]}=Vo(),A=L.useUtils(),S=Uo(),{data:C=[],isLoading:E}=L.skills.list.useQuery(),k=L.skills.installForAllAgents.useMutation({onSuccess:()=>A.skills.getAgentSkills.invalidate()}),T=L.skills.uninstallFromAllAgents.useMutation({onSuccess:()=>{A.skills.getAgentSkills.invalidate(),a(null)}}),F=L.skills.uninstallClawHub.useMutation({onSettled:async()=>{await A.skills.list.invalidate(),await A.skills.getAgentSkills.invalidate(),a(null)}}),M=L.skills.deleteCustom.useMutation({onSuccess:()=>{A.skills.list.invalidate(),A.skills.getAgentSkills.invalidate(),a(null)}});function I(V){V.source==="authored"?(g(V.id),p(!0)):(d(V.id),l(!0))}const R=e==="my-skills"?C.filter(V=>{if(!n.trim())return!0;const K=n.toLowerCase();return V.name.toLowerCase().includes(K)||V.slug.toLowerCase().includes(K)||V.description.toLowerCase().includes(K)}):C,H=e==="clawhub";return r.jsxs("div",{className:"flex-1 overflow-y-auto bg-[#0F0F11]",children:[r.jsxs("div",{className:"max-w-5xl mx-auto px-8 py-10",children:[r.jsxs("div",{className:"mb-8 flex items-start justify-between",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-[22px] font-semibold text-[#F0F0F5]",children:"Skills"}),r.jsx("p",{className:"text-[13px] text-[#8A8A99] mt-0.5",children:"Capabilities your agents can execute. Install a skill to make it available, then assign it per agent."})]}),S&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("button",{onClick:()=>{g(null),p(!0)},className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[12px] font-medium bg-[#6366F1]/10 text-[#6366F1] hover:bg-[#6366F1]/20 border border-[#6366F1]/30 transition-colors",children:[r.jsx(wt,{className:"w-3.5 h-3.5"}),"New Skill"]}),r.jsxs("button",{onClick:()=>_(!0),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[12px] text-[#8A8A99] hover:text-[#C8C8D4] border border-[#2A2A35] hover:border-[#3A3A45] transition-colors",children:[r.jsx(su,{className:"w-3.5 h-3.5"}),"Import"]}),r.jsxs(gn,{to:"/settings?tab=secrets",className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[12px] text-[#8A8A99] hover:text-[#C8C8D4] border border-[#2A2A35] hover:border-[#3A3A45] transition-colors",children:[r.jsx(Eo,{className:"w-3.5 h-3.5"}),"Secrets"]})]})]}),r.jsxs("div",{className:"flex items-center gap-1 mb-6 border-b border-[#2A2A35]",children:[r.jsx("button",{onClick:()=>t("my-skills"),className:ye("px-4 py-2.5 text-[13px] font-medium transition-colors border-b-2 -mb-px",e==="my-skills"?"text-[#F0F0F5] border-[#6366F1]":"text-[#8A8A99] border-transparent hover:text-[#C8C8D4]"),children:"My Skills"}),S&&r.jsx("button",{onClick:()=>t("clawhub"),className:ye("px-4 py-2.5 text-[13px] font-medium transition-colors border-b-2 -mb-px",e==="clawhub"?"text-[#F0F0F5] border-[#8B5CF6]":"text-[#8A8A99] border-transparent hover:text-[#C8C8D4]"),children:"Browse ClawHub"})]}),e==="my-skills"&&r.jsxs("div",{className:"relative mb-6",children:[r.jsx(Io,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[#5A5A6E]"}),r.jsx("input",{value:n,onChange:V=>s(V.target.value),placeholder:"Search skills...",className:"w-full bg-[#16161A] border border-[#2A2A35] rounded-xl pl-9 pr-4 py-2.5 text-[13px] text-[#F0F0F5] placeholder-[#5A5A6E] outline-none focus:border-[#6366F1]/60 transition-colors"})]}),H?r.jsx(LRe,{skills:C}):r.jsxs(r.Fragment,{children:[E&&r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3,4,5,6].map(V=>r.jsx("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-5 animate-pulse h-[180px]"},V))}),!E&&R.length===0&&r.jsx("div",{className:"flex flex-col items-center justify-center py-24 text-center",children:r.jsx("p",{className:"text-[14px] text-[#8A8A99]",children:"No skills for this provider yet."})}),!E&&R.length>0&&r.jsx(DRe,{skills:R,agents:w,selectedSkillId:i?.id??null,onInstall:V=>k.mutate({skillId:V}),onUninstall:V=>T.mutate({skillId:V}),onRemove:async V=>{await F.mutateAsync({skillId:V}).catch(()=>{})},onSelect:S?a:()=>{},onEditCustom:I,onDeleteCustom:V=>M.mutate({skillId:V}),canManage:S})]})]}),r.jsx(Me,{children:S&&i&&r.jsx(MRe,{skill:i,agents:w,onClose:()=>a(null)},i.id)}),r.jsx(Me,{children:S&&o&&r.jsx(yRe,{open:o,onClose:()=>{l(!1),d(null)},editSkillId:c,editSkillSlug:c?C.find(V=>V.id===c)?.slug:void 0})}),S&&r.jsx(wRe,{open:f,onClose:()=>{p(!1),g(null)},editSkillId:m}),r.jsx(Me,{children:S&&b&&r.jsx(CRe,{onClose:()=>_(!1),onSuccess:()=>{A.skills.list.invalidate()}})})]})}const zRe=$o()(gj(e=>({model:"anthropic/claude-sonnet-4-6",setModel:t=>e({model:t})}),{name:"damn-dev-coo"})),Hf="chan_coo",zd="#F59E0B";function $Re(e){try{return JSON.parse(e)}catch{return null}}function VRe(e){try{return JSON.parse(e)}catch{return null}}function URe({messageId:e,trustData:t,decided:n,onApprove:s,onReject:i,isApproving:a,isRejecting:o}){return r.jsxs(ne.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},className:"mx-4 mb-2 rounded-xl border border-[#6366F1]/30 bg-[#6366F1]/5 overflow-hidden",children:[r.jsxs("div",{className:"px-4 py-3 border-b border-[#6366F1]/20",children:[r.jsx("p",{className:"text-[12px] font-semibold text-[#818CF8] uppercase tracking-wide",children:"Trust configuration proposal"}),r.jsxs("p",{className:"text-[11px] text-[#5A5A6E] mt-0.5",children:["Agent: ",r.jsx("span",{className:"text-[#A5A5C5]",children:t.agentId})]})]}),r.jsxs("div",{className:"px-4 py-3 space-y-2",children:[typeof t.autoApprove=="boolean"&&r.jsxs("div",{className:"flex items-center justify-between text-[12px]",children:[r.jsx("span",{className:"text-[#8A8A99]",children:"Auto-approve"}),r.jsx("span",{className:t.autoApprove?"text-[#F87171]":"text-[#34D399]",children:t.autoApprove?"Enable":"Disable"})]}),t.sandboxMode&&r.jsxs("div",{className:"flex items-center justify-between text-[12px]",children:[r.jsx("span",{className:"text-[#8A8A99]",children:"Sandbox"}),r.jsx("span",{className:"text-[#A5A5C5]",children:t.sandboxMode})]}),t.shellAllowlist!==void 0&&r.jsxs("div",{className:"text-[12px]",children:[r.jsx("span",{className:"text-[#8A8A99]",children:"Shell allowlist"}),r.jsx("p",{className:"text-[#A5A5C5] mt-0.5",children:t.shellAllowlist?t.shellAllowlist.join(", "):"unrestricted"})]}),t.mounts&&t.mounts.length>0&&r.jsxs("div",{className:"text-[12px]",children:[r.jsx("span",{className:"text-[#8A8A99]",children:"Mounts"}),t.mounts.map((l,c)=>r.jsxs("p",{className:"text-[#A5A5C5] mt-0.5 font-mono",children:[l.hostPath," → ",l.agentPath]},c))]})]}),n?r.jsx("div",{className:`px-4 py-2.5 text-[12px] font-medium ${n==="approved"?"text-[#34D399] bg-[#10B981]/5":"text-[#F87171] bg-[#EF4444]/5"}`,children:n==="approved"?"✓ Applied":"✗ Rejected"}):r.jsxs("div",{className:"flex border-t border-[#6366F1]/20",children:[r.jsx(ne.button,{whileHover:{backgroundColor:"rgba(16,185,129,0.12)"},whileTap:{scale:.98},onClick:()=>s(e),disabled:a||o,className:"flex-1 py-2.5 text-[12px] font-medium text-[#34D399] border-r border-[#6366F1]/20 transition-colors disabled:opacity-50",children:a?"Applying…":"Apply"}),r.jsx(ne.button,{whileHover:{backgroundColor:"rgba(239,68,68,0.08)"},whileTap:{scale:.98},onClick:()=>i(e),disabled:a||o,className:"flex-1 py-2.5 text-[12px] font-medium text-[#F87171] transition-colors disabled:opacity-50",children:"Reject"})]})]})}function HRe(e){try{const t=JSON.parse(e);return typeof t.agentId=="string"&&typeof t.pattern=="string"&&typeof t.autoApprove=="boolean"&&typeof t.reason=="string"?t:null}catch{return null}}function WRe({messageId:e,rule:t,decided:n,onApprove:s,onReject:i,isPending:a}){return r.jsxs(ne.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},className:"mx-4 mb-2 rounded-xl border border-[#F59E0B]/30 bg-[#F59E0B]/5 overflow-hidden",children:[r.jsxs("div",{className:"px-4 py-3 border-b border-[#F59E0B]/20 flex items-center gap-2",children:[r.jsx(Wl,{className:"w-3.5 h-3.5 text-[#F59E0B] flex-shrink-0"}),r.jsx("p",{className:"text-[12px] font-semibold text-[#FBBF24] uppercase tracking-wide",children:"Delegation rule proposal"})]}),r.jsxs("div",{className:"px-4 py-3 space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between text-[12px]",children:[r.jsx("span",{className:"text-[#8A8A99]",children:"Agent"}),r.jsx("span",{className:"text-[#A5A5C5] font-medium",children:t.agentId})]}),r.jsxs("div",{className:"flex items-center justify-between text-[12px]",children:[r.jsx("span",{className:"text-[#8A8A99]",children:"Pattern"}),r.jsx("code",{className:"text-[#FBBF24] bg-[#F59E0B]/10 px-1.5 py-0.5 rounded text-[11px] font-mono",children:t.pattern})]}),r.jsxs("div",{className:"flex items-center justify-between text-[12px]",children:[r.jsx("span",{className:"text-[#8A8A99]",children:"Auto-approve"}),r.jsx("span",{className:t.autoApprove?"text-[#F87171]":"text-[#34D399]",children:t.autoApprove?"Yes":"No"})]}),r.jsx("p",{className:"text-[12px] text-[#8A8A99] italic leading-relaxed pt-1",children:t.reason})]}),n?r.jsx("div",{className:`px-4 py-2.5 text-[12px] font-medium ${n==="approved"?"text-[#34D399] bg-[#10B981]/5":"text-[#F87171] bg-[#EF4444]/5"}`,children:n==="approved"?"✓ Rule created":"✗ Rejected"}):r.jsxs("div",{className:"flex border-t border-[#F59E0B]/20",children:[r.jsx(ne.button,{whileHover:{backgroundColor:"rgba(16,185,129,0.12)"},whileTap:{scale:.98},onClick:()=>s(e),disabled:a,className:"flex-1 py-2.5 text-[12px] font-medium text-[#34D399] border-r border-[#F59E0B]/20 transition-colors disabled:opacity-50",children:a?"Creating…":"Create Rule"}),r.jsx(ne.button,{whileHover:{backgroundColor:"rgba(239,68,68,0.08)"},whileTap:{scale:.98},onClick:()=>i(e),disabled:a,className:"flex-1 py-2.5 text-[12px] font-medium text-[#F87171] transition-colors disabled:opacity-50",children:"Reject"})]})]})}function qRe({proposal:e,proposalId:t,onApprove:n,onReject:s,isApproving:i,isRejecting:a,decided:o,progressSteps:l,completionResult:c}){const d=an(),[f,p]=y.useState(!1),m=o?!f:f,g=_=>p(o?!_:_),b=e.skillAssignments?.some(_=>_.skills.some(w=>w.includes("approval")));return r.jsxs(ne.div,{initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{type:"spring",stiffness:300,damping:30},className:"mx-4 mb-4 bg-[#1C1C24] border border-[#2A2A35] rounded-xl overflow-hidden",children:[r.jsxs("button",{onClick:()=>g(!m),className:"w-full px-5 py-4 border-b border-[#2A2A35] flex items-center justify-between hover:bg-white/[0.02] transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ia,{className:"w-4 h-4 text-[#F59E0B]"}),r.jsx("span",{className:"text-[14px] font-semibold text-[#F0F0F5]",children:"Workspace Proposal"}),o&&r.jsx("span",{className:ye("text-[11px] px-1.5 py-0.5 rounded font-medium",o==="approved"?"bg-[#10B981]/10 text-[#34D399]":"bg-[#EF4444]/10 text-[#F87171]"),children:o})]}),r.jsx(ft,{className:ye("w-4 h-4 text-[#5A5A6E] transition-transform",m&&"-rotate-90")})]}),!m&&e.agents?.length>0&&r.jsxs("div",{className:"px-5 py-4 border-b border-[#2A2A35]/50",children:[r.jsx("span",{className:"text-[11px] font-semibold text-[#8A8A99] uppercase tracking-widest",children:"Agents to create"}),r.jsx("div",{className:"mt-3 space-y-2.5",children:e.agents.map(_=>r.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg bg-[#13131A] border border-[#2A2A35]",children:[r.jsx("span",{className:"w-8 h-8 rounded-full flex items-center justify-center text-sm flex-shrink-0 mt-0.5",style:{backgroundColor:`${_.color}26`},children:_.emoji}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-baseline gap-2",children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:_.color},children:_.name}),r.jsx("span",{className:"text-[11px] text-[#8A8A99]",children:_.role})]}),r.jsx("p",{className:"text-[12px] text-[#8A8A99] mt-1 line-clamp-2",children:_.soulDescription}),(e.skillAssignments??[]).filter(w=>w.agentName===_.name).map(w=>r.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:w.skills.map(A=>r.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-white/5 border border-[#2A2A35] text-[#C8C8D4]",children:A},A))},w.agentName))]})]},_.name))})]}),!m&&e.channels?.length>0&&r.jsxs("div",{className:"px-5 py-4 border-b border-[#2A2A35]/50",children:[r.jsx("span",{className:"text-[11px] font-semibold text-[#8A8A99] uppercase tracking-widest",children:"Channels to create"}),r.jsx("div",{className:"mt-3 space-y-1.5",children:e.channels.map(_=>r.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-[#13131A] border border-[#2A2A35]",children:[r.jsx("span",{className:"text-[12px] text-[#8A8A99]",children:"#"}),r.jsx("span",{className:"text-[13px] text-[#F0F0F5] font-medium",children:_.name}),r.jsx("span",{className:"text-[11px] text-[#5A5A6E] px-1.5 py-0.5 rounded bg-white/5",children:_.type}),_.description&&r.jsx("span",{className:"text-[11px] text-[#8A8A99] truncate flex-1",children:_.description})]},_.name))})]}),!m&&b&&r.jsxs("div",{className:"px-5 py-3 bg-[#F59E0B]/5 border-b border-[#F59E0B]/10 flex items-center gap-2",children:[r.jsx(ql,{className:"w-3.5 h-3.5 text-[#F59E0B] flex-shrink-0"}),r.jsx("span",{className:"text-[12px] text-[#F59E0B]",children:"Some skills will require your approval before execution"})]}),r.jsx(Me,{mode:"wait",children:!m&&l.length>0&&r.jsx(ne.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},className:"px-5 py-3 border-b border-[#2A2A35]/50 bg-[#13131A]",children:r.jsx("div",{className:"space-y-1.5",children:l.map((_,w)=>r.jsxs(ne.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},className:"flex items-center gap-2 text-[12px]",children:[r.jsx(Fe,{className:"w-3 h-3 text-[#10B981] flex-shrink-0"}),r.jsxs("span",{className:"text-[#8A8A99]",children:[_.step,":"]}),r.jsx("span",{className:"text-[#C8C8D4]",children:_.detail})]},w))})})}),!m&&c&&r.jsxs(ne.div,{initial:{opacity:0},animate:{opacity:1},className:"px-5 py-4 bg-[#10B981]/5 border-b border-[#10B981]/10",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(Fe,{className:"w-4 h-4 text-[#10B981]"}),r.jsx("span",{className:"text-[13px] font-semibold text-[#10B981]",children:"Your team is ready"})]}),r.jsxs("p",{className:"text-[12px] text-[#8A8A99]",children:[c.agentsCreated," agent",c.agentsCreated!==1?"s":""," created,"," ",c.channelsCreated," channel",c.channelsCreated!==1?"s":""," created."]}),c.firstChannelId&&r.jsxs("button",{onClick:()=>d(`/channels/${c.firstChannelId}`),className:"mt-2 flex items-center gap-1.5 text-[12px] font-medium text-[#6366F1] hover:text-[#818CF8] transition-colors",children:["Go to first agent",r.jsx(tu,{className:"w-3 h-3"})]})]}),!m&&!o&&!c&&r.jsxs("div",{className:"px-5 py-4 flex gap-2",children:[r.jsxs("button",{onClick:()=>t&&n(t),disabled:!t||i||a,className:"flex-1 flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg bg-[#10B981]/10 text-[#34D399] border border-[#10B981]/30 text-[13px] font-medium hover:bg-[#10B981]/20 transition-colors disabled:opacity-40 disabled:pointer-events-none",children:[i?r.jsx(Pe,{className:"w-3.5 h-3.5 animate-spin"}):r.jsx(Fe,{className:"w-3.5 h-3.5"}),i?"Creating...":"Approve & Create"]}),r.jsx("button",{onClick:()=>t&&s(t),disabled:!t||i||a,className:"px-4 py-2.5 rounded-lg bg-[#EF4444]/10 text-[#F87171] border border-[#EF4444]/30 text-[13px] font-medium hover:bg-[#EF4444]/20 transition-colors disabled:opacity-40 disabled:pointer-events-none",children:r.jsx(Te,{className:"w-3.5 h-3.5"})})]}),!m&&o==="rejected"&&r.jsx("div",{className:"px-5 py-3 bg-[#EF4444]/5",children:r.jsx("span",{className:"text-[12px] text-[#F87171]",children:"Proposal rejected"})})]})}function GRe({status:e}){return e==="done"?r.jsx(Fe,{className:"w-3.5 h-3.5 text-[#10B981]"}):e==="failed"?r.jsx(Te,{className:"w-3.5 h-3.5 text-[#EF4444]"}):r.jsx(Pe,{className:"w-3.5 h-3.5 text-[#F59E0B] animate-spin"})}function KRe({goal:e,dispatches:t,groupChannelId:n}){const s=an(),i=!!n&&t.every(a=>a.channelId===n);return r.jsxs(ne.div,{initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{type:"spring",stiffness:300,damping:30},className:"mx-4 mb-4 bg-[#1C1C24] border border-[#2A2A35] rounded-xl overflow-hidden",children:[r.jsx("div",{className:"px-5 py-4 border-b border-[#2A2A35]",children:r.jsx("p",{className:"text-[13px] text-[#8A8A99] leading-relaxed",children:e})}),r.jsx("div",{className:"px-5 py-3 space-y-2",children:t.map((a,o)=>r.jsxs(ne.div,{initial:{opacity:0,x:-12},animate:{opacity:1,x:0},transition:{delay:o*.08,duration:.25},className:"flex items-start gap-3 p-3 rounded-lg bg-[#13131A] border border-[#2A2A35]",children:[r.jsx("span",{className:"w-7 h-7 rounded-full bg-[#F59E0B]/15 flex items-center justify-center text-[12px] flex-shrink-0 mt-0.5",children:a.agentName.charAt(0)}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[13px] font-semibold text-[#F0F0F5]",children:a.agentName}),r.jsx(GRe,{status:a.status})]}),r.jsx("p",{className:"text-[12px] text-[#8A8A99] mt-0.5 line-clamp-2",children:a.instruction}),!i&&a.channelId&&r.jsxs("button",{onClick:()=>s(`/channels/${a.channelId}`),className:"mt-1.5 flex items-center gap-1 text-[11px] font-medium text-[#6366F1] hover:text-[#818CF8] transition-colors",children:[r.jsx(tu,{className:"w-3 h-3"}),"View in channel"]})]})]},`${a.agentId}-${o}`))}),r.jsxs("div",{className:"px-5 py-3 border-t border-[#2A2A35]/50 flex items-center justify-between",children:[r.jsxs("span",{className:"text-[12px] text-[#10B981]/80",children:[t.length," task",t.length!==1?"s":""," dispatched",i?" (group)":""]}),n&&r.jsxs("button",{onClick:()=>s(`/channels/${n}`),className:"flex items-center gap-1 text-[11px] font-medium text-[#6366F1] hover:text-[#818CF8] transition-colors",children:[r.jsx(tu,{className:"w-3 h-3"}),"View group channel"]})]})]})}function YRe({message:e,isLast:t,proposalStatuses:n,progressSteps:s,completionResult:i,onApprove:a,onReject:o,isApproving:l,isRejecting:c,onApproveTrust:d,onRejectTrust:f,isTrustApproving:p,isTrustRejecting:m,onApproveDelegation:g,onRejectDelegation:b,isDelegationPending:_,dispatchStatuses:w}){const A=e.sender.type==="human",{stripped:S,proposal:C}=A?{stripped:e.content,proposal:null}:K7(e.content),E=e.metadata?.proposalId,k=e.metadata?.proposalJson,T=k?$Re(k):null,F=E?n[E]:void 0,M=F==="approved"||F==="rejected"?F:null,I=e.metadata?.trustUpdate,R=I?VRe(I):null,H=e.status==="approved"?"approved":e.status==="rejected"?"rejected":null,V=e.metadata?.delegationRule,K=typeof V=="object"?V:typeof V=="string"?HRe(V):null,q=K?e.status==="approved"?"approved":e.status==="rejected"?"rejected":null:null,$=e.metadata?.dispatch,B=w.get(e.id),Y=e.metadata?.nodeSpawnProposalId,U=e.metadata?.nodeSpawnJson;let W=null;if(U)try{const le=JSON.parse(U);typeof le.name=="string"&&typeof le.reason=="string"&&(W={name:le.name,reason:le.reason})}catch{}const O=e.status==="approved"?"approved":e.status==="rejected"?"rejected":null,D=e.metadata?.federationGrantProposalId,Q=e.metadata?.federationGrantJson;let z=null;if(Q)try{const le=JSON.parse(Q);typeof le.nodeName=="string"&&typeof le.grantAgentId=="string"&&typeof le.reason=="string"&&(z={nodeName:le.nodeName,grantAgentId:le.grantAgentId,reason:le.reason})}catch{}const J=e.metadata?.cloudSpawnProposalId,ee=e.metadata?.cloudSpawnJson;let re=null;if(ee)try{const le=JSON.parse(ee);typeof le.name=="string"&&typeof le.provider=="string"&&typeof le.region=="string"&&typeof le.size=="string"&&typeof le.reason=="string"&&(re={name:le.name,provider:le.provider,region:le.region,size:le.size,reason:le.reason})}catch{}const se=(e.metadata?.remoteAgentProposals??[]).map(le=>{try{const ge=JSON.parse(le.json);if(typeof ge.nodeName=="string"&&typeof ge.name=="string"&&typeof ge.emoji=="string"&&typeof ge.color=="string"&&typeof ge.role=="string"&&typeof ge.soul=="string")return{proposalId:le.id,nodeName:ge.nodeName,name:ge.name,emoji:ge.emoji,color:ge.color,role:ge.role,soul:ge.soul}}catch{}return null}).filter(le=>le!==null),ae=(()=>{const le=new Map;for(const ge of se){const je=le.get(ge.nodeName);je?je.push(ge):le.set(ge.nodeName,[ge])}return Array.from(le.entries()).map(([ge,je])=>({nodeName:ge,agents:je}))})();return r.jsxs("div",{children:[r.jsxs(ne.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2},className:ye("flex items-start gap-3 px-4 py-2",A?"":"border-l-[3px] border-l-[#F59E0B]"),children:[r.jsx("div",{className:"flex-shrink-0 mt-0.5",children:A?r.jsx("div",{className:"w-8 h-8 rounded-full bg-gradient-to-br from-[#4A4A5E] to-[#2A2A3E] flex items-center justify-center border border-[#3A3A4E]",children:r.jsx("span",{className:"text-[11px] font-semibold text-[#A5A5C5]",children:"A"})}):r.jsx("div",{className:"w-8 h-8 rounded-full bg-[#F59E0B]/15 flex items-center justify-center",children:r.jsx(Ia,{className:"w-4 h-4 text-[#F59E0B]"})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-baseline gap-2 mb-1",children:[r.jsx("span",{className:ye("text-[13px] font-semibold",A?"text-[#F0F0F5]":"text-[#F59E0B]"),children:A?e.sender.name:"COO"}),r.jsx("span",{className:"text-[11px] text-[#5A5A6E]",children:Ir(e.timestamp)})]}),r.jsx("div",{className:"text-[14px] text-[#C8C8D4] leading-relaxed prose-message",children:r.jsx(Ei,{remarkPlugins:[Fi],children:S})}),C!==null&&r.jsx(G7,{proposal:C,messageId:e.id,metadata:e.metadata}),e.metadata?.skillWriteProposal?r.jsx(Q7,{message:e,proposal:e.metadata.skillWriteProposal}):null,e.metadata?.skillInstallProposal?r.jsx(Y7,{proposal:e.metadata.skillInstallProposal,messageId:e.id,metadata:e.metadata}):null,e.status==="pending_approval"&&!e.metadata?.missionPlan&&!e.metadata?.nodeSpawnProposalId&&se.length===0&&r.jsx(J7,{message:e})]})]}),T&&r.jsx(qRe,{proposal:T,proposalId:E,onApprove:a,onReject:o,isApproving:l,isRejecting:c,decided:M,progressSteps:t?s:[],completionResult:t?i:null}),R&&r.jsx(URe,{messageId:e.id,trustData:R,decided:H,onApprove:d,onReject:f,isApproving:p,isRejecting:m}),K&&r.jsx(WRe,{messageId:e.id,rule:K,decided:q,onApprove:g,onReject:b,isPending:_}),$&&B&&B.length>0&&r.jsx(KRe,{goal:$.goal,dispatches:B}),W&&Y&&r.jsx(XRe,{proposalId:Y,name:W.name,reason:W.reason,decided:O,serverStatus:n[Y]}),ae.map(le=>r.jsx(QRe,{nodeName:le.nodeName,agents:le.agents,serverStatuses:n},le.nodeName)),z&&D&&r.jsx(tDe,{proposalId:D,data:z,serverStatus:n[D]}),re&&J&&r.jsx(nDe,{proposalId:J,data:re,serverStatus:n[J]}),e.metadata?.missionPlan?r.jsx(sDe,{plan:e.metadata.missionPlan,messageId:e.id,decided:e.status==="approved"?"approved":e.status==="rejected"?"rejected":null}):null]})}function QRe({nodeName:e,agents:t,serverStatuses:n}){const s=t.map(F=>{const M=n[F.proposalId];return M==="approved"?"approved":M==="rejected"?"rejected":M==="failed"?"failed":"pending"}),i=s.every(F=>F!=="pending"),a=s.every(F=>F==="rejected"),o=s.some(F=>F==="approved"||F==="failed"),l=i&&a?"rejected":i&&o?"approved":null,c=s.filter(F=>F==="approved").length,d=s.filter(F=>F==="failed").length,[f,p]=y.useState(!1),m=l?!f:f,g=F=>p(l?!F:F),b=L.useUtils(),_=L.coo.approveRemoteAgent.useMutation(),w=L.coo.rejectRemoteAgent.useMutation(),[A,S]=y.useState(null),[C,E]=y.useState(null),k=async()=>{S("approving"),E(null);try{for(const F of t)n[F.proposalId]&&n[F.proposalId]!=="pending"||await _.mutateAsync({proposalId:F.proposalId})}catch(F){E(F instanceof Error?F.message:"Failed to approve one or more agents")}finally{S(null),b.federation.listNodes.invalidate(),b.coo.listProposals.invalidate()}},T=async()=>{S("rejecting"),E(null);try{for(const F of t)n[F.proposalId]&&n[F.proposalId]!=="pending"||await w.mutateAsync({proposalId:F.proposalId})}catch(F){E(F instanceof Error?F.message:"Failed to reject one or more agents")}finally{S(null),b.coo.listProposals.invalidate()}};return r.jsxs(ne.div,{initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{type:"spring",stiffness:300,damping:30},className:"mx-4 mb-4 bg-[#1C1C24] border border-[#2A2A35] rounded-xl overflow-hidden",children:[r.jsxs("button",{onClick:()=>g(!m),className:"w-full px-5 py-4 border-b border-[#2A2A35] flex items-center justify-between hover:bg-white/[0.02] transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx(Mp,{className:"w-4 h-4 text-[#6366F1] flex-shrink-0"}),r.jsx("span",{className:"text-[14px] font-semibold text-[#F0F0F5]",children:"Remote Team Proposal"}),r.jsx("span",{className:"text-[12px] text-[#8A8A99]",children:"on"}),r.jsx("span",{className:"text-[12px] font-mono px-2 py-0.5 rounded bg-[#6366F1]/15 text-[#818CF8] font-semibold",children:e}),l&&r.jsx("span",{className:ye("text-[11px] px-1.5 py-0.5 rounded font-medium",l==="approved"?"bg-[#10B981]/10 text-[#34D399]":"bg-[#EF4444]/10 text-[#F87171]"),children:l})]}),r.jsx(ft,{className:ye("w-4 h-4 text-[#5A5A6E] transition-transform flex-shrink-0",m&&"-rotate-90")})]}),!m&&t.length>0&&r.jsxs("div",{className:"px-5 py-4 border-b border-[#2A2A35]/50",children:[r.jsxs("span",{className:"text-[11px] font-semibold text-[#8A8A99] uppercase tracking-widest",children:["Agents to create on ",r.jsx("span",{className:"text-[#818CF8] font-mono",children:e})]}),r.jsx("div",{className:"mt-3 space-y-2.5",children:t.map((F,M)=>{const I=s[M];return r.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg bg-[#13131A] border border-[#2A2A35]",children:[r.jsx("span",{className:"w-8 h-8 rounded-full flex items-center justify-center text-sm flex-shrink-0 mt-0.5",style:{backgroundColor:`${F.color}26`},children:F.emoji}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-baseline gap-2 flex-wrap",children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:F.color},children:F.name}),r.jsx("span",{className:"text-[11px] text-[#8A8A99]",children:F.role}),I==="approved"&&r.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium bg-[#10B981]/10 text-[#34D399] uppercase tracking-wider",children:"created"}),I==="failed"&&r.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium bg-[#EF4444]/10 text-[#F87171] uppercase tracking-wider",children:"failed"}),I==="rejected"&&r.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium bg-[#8A8A99]/10 text-[#8A8A99] uppercase tracking-wider",children:"rejected"}),I==="pending"&&A==="approving"&&r.jsx(Pe,{className:"w-3 h-3 animate-spin text-[#6366F1]"})]}),r.jsx("p",{className:"text-[12px] text-[#8A8A99] mt-1 line-clamp-2",children:F.soul})]})]},F.proposalId)})})]}),!m&&l==="approved"&&r.jsxs(ne.div,{initial:{opacity:0},animate:{opacity:1},className:"px-5 py-4 bg-[#10B981]/5 border-b border-[#10B981]/10",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx(Fe,{className:"w-4 h-4 text-[#10B981]"}),r.jsxs("span",{className:"text-[13px] font-semibold text-[#10B981]",children:["Remote team ready on ",r.jsx("span",{className:"font-mono",children:e})]})]}),r.jsxs("p",{className:"text-[12px] text-[#8A8A99]",children:[c," agent",c!==1?"s":""," created",d>0?`, ${d} failed`:"",". You can now delegate to them using ",r.jsx("code",{className:"text-[11px] px-1 py-0.5 rounded bg-[#0F0F11] text-[#C8C8D4]",children:"<slug>@"+e})," in delegate blocks."]})]}),!m&&C&&r.jsxs("div",{className:"px-5 py-3 bg-[#EF4444]/5 border-b border-[#EF4444]/20 flex items-start gap-2 text-[12px] text-[#F87171]",children:[r.jsx("span",{className:"mt-0.5",children:"⚠"}),r.jsx("span",{className:"break-all",children:C})]}),!m&&!l&&r.jsxs("div",{className:"px-5 py-4 flex gap-2",children:[r.jsxs("button",{onClick:k,disabled:A!==null,className:"flex-1 flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg bg-[#10B981]/10 text-[#34D399] border border-[#10B981]/30 text-[13px] font-medium hover:bg-[#10B981]/20 transition-colors disabled:opacity-40 disabled:pointer-events-none",children:[A==="approving"?r.jsx(Pe,{className:"w-3.5 h-3.5 animate-spin"}):r.jsx(Fe,{className:"w-3.5 h-3.5"}),A==="approving"?`Creating ${c+d+1}/${t.length}…`:`Approve & Create ${t.length>1?`all ${t.length}`:""}`]}),r.jsx("button",{onClick:T,disabled:A!==null,className:"px-4 py-2.5 rounded-lg bg-[#EF4444]/10 text-[#F87171] border border-[#EF4444]/30 text-[13px] font-medium hover:bg-[#EF4444]/20 transition-colors disabled:opacity-40 disabled:pointer-events-none",children:A==="rejecting"?r.jsx(Pe,{className:"w-3.5 h-3.5 animate-spin"}):r.jsx(Te,{className:"w-3.5 h-3.5"})})]}),!m&&l==="rejected"&&r.jsx("div",{className:"px-5 py-3 bg-[#EF4444]/5",children:r.jsx("span",{className:"text-[12px] text-[#F87171]",children:"Remote team proposal rejected"})})]})}function XRe({proposalId:e,name:t,reason:n,decided:s,serverStatus:i}){const[a,o]=y.useState(null),c=a??(i==="approved"||i==="failed"?"approved":i==="rejected"?"rejected":null)??s,[d,f]=y.useState(!1),p=c?!d:d,m=C=>f(c?!C:C),g=L.useUtils(),b=L.coo.approveNodeSpawn.useMutation({onSuccess:()=>{o("approved"),g.federation.listNodes.invalidate(),g.coo.listProposals.invalidate()}}),_=L.coo.rejectNodeSpawn.useMutation({onSuccess:()=>{o("rejected"),g.coo.listProposals.invalidate()}}),A=L.federation.getSpawnDefaults.useQuery().data?.defaultNodeSpawnPolicy??"coo-only",S=b.isPending||_.isPending;return r.jsxs(ne.div,{initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{type:"spring",stiffness:300,damping:30},className:"mx-4 mb-4 bg-[#1C1C24] border border-[#6366F1]/25 rounded-xl overflow-hidden",children:[r.jsxs("button",{onClick:()=>m(!p),className:"w-full px-5 py-4 border-b border-[#2A2A35] flex items-center justify-between hover:bg-white/[0.02] transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-6 h-6 rounded-lg bg-[#6366F1]/15 flex items-center justify-center",children:r.jsx("span",{className:"text-[13px]",children:"⚡"})}),r.jsx("span",{className:"text-[14px] font-semibold text-[#F0F0F5]",children:"Spawn Isolated Node"}),r.jsx("span",{className:"text-[11px] font-mono px-1.5 py-0.5 rounded bg-[#6366F1]/15 text-[#818CF8]",children:t}),c&&r.jsx("span",{className:ye("text-[11px] px-1.5 py-0.5 rounded font-medium",c==="approved"?"bg-[#10B981]/10 text-[#34D399]":"bg-[#EF4444]/10 text-[#F87171]"),children:c})]}),r.jsx(ft,{className:ye("w-4 h-4 text-[#5A5A6E] transition-transform",p&&"-rotate-90")})]}),!p&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"px-5 py-4 border-b border-[#2A2A35]/50",children:[r.jsx("span",{className:"text-[11px] font-semibold text-[#8A8A99] uppercase tracking-widest",children:"Why"}),r.jsx("p",{className:"mt-2 text-[13px] text-[#C8C8D4] leading-relaxed",children:n})]}),r.jsxs("div",{className:"px-5 py-4 border-b border-[#2A2A35]/50 space-y-2",children:[r.jsx("span",{className:"text-[11px] font-semibold text-[#8A8A99] uppercase tracking-widest",children:"What will happen"}),r.jsxs("div",{className:"space-y-1.5 text-[12px] text-[#8A8A99]",children:[r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("span",{className:"text-[#6366F1] mt-0.5",children:"•"}),r.jsx("span",{children:"A brand-new isolated damn.dev container (backend + OpenClaw) will start on this machine"})]}),r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("span",{className:"text-[#6366F1] mt-0.5",children:"•"}),r.jsxs("span",{children:["Its own SQLite DB and OpenClaw workspace at ",r.jsxs("code",{className:"text-[11px] px-1 py-0.5 rounded bg-[#0F0F11] text-[#C8C8D4]",children:["~/.damn-dev/nodes/",t,"/"]})]})]}),r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("span",{className:"text-[#6366F1] mt-0.5",children:"•"}),r.jsxs("span",{children:["Default delegation policy: ",r.jsx("strong",{className:"text-[#F0F0F5]",children:A})," — adjustable from Settings → Federation"]})]}),r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("span",{className:"text-[#6366F1] mt-0.5",children:"•"}),r.jsxs("span",{children:["Auto-federated: the COO will be able to dispatch to any agents you later create on this node using ",r.jsx("code",{className:"text-[11px] px-1 py-0.5 rounded bg-[#0F0F11] text-[#C8C8D4]",children:"<agent>@"+t})," syntax"]})]})]})]}),b.isError&&r.jsxs("div",{className:"px-5 py-3 bg-[#EF4444]/5 border-b border-[#EF4444]/20 flex items-start gap-2 text-[12px] text-[#F87171]",children:[r.jsx("span",{className:"mt-0.5",children:"⚠"}),r.jsx("span",{children:b.error?.message})]}),_.isError&&r.jsxs("div",{className:"px-5 py-3 bg-[#EF4444]/5 border-b border-[#EF4444]/20 flex items-start gap-2 text-[12px] text-[#F87171]",children:[r.jsx("span",{className:"mt-0.5",children:"⚠"}),r.jsx("span",{children:_.error?.message})]}),!c&&r.jsxs("div",{className:"px-5 py-4 flex gap-2",children:[r.jsxs("button",{onClick:()=>b.mutate({proposalId:e}),disabled:S,className:"flex-1 flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg bg-[#10B981]/10 text-[#34D399] border border-[#10B981]/30 text-[13px] font-medium hover:bg-[#10B981]/20 transition-colors disabled:opacity-40 disabled:pointer-events-none",children:[b.isPending?r.jsx(Pe,{className:"w-3.5 h-3.5 animate-spin"}):r.jsx(Fe,{className:"w-3.5 h-3.5"}),b.isPending?"Spawning…":"Approve & Spawn"]}),r.jsx("button",{onClick:()=>_.mutate({proposalId:e}),disabled:S,className:"flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg bg-[#2A2A35] text-[#8A8A99] border border-[#2A2A35] text-[13px] font-medium hover:bg-[#3A3A45] transition-colors disabled:opacity-40 disabled:pointer-events-none",children:_.isPending?r.jsx(Pe,{className:"w-3.5 h-3.5 animate-spin"}):"Reject"})]})]})]})}function JRe(){const e=L.useUtils(),{data:t}=L.agents.list.useQuery(),n=t?.find(f=>f.id==="coo"),s=n?.model??n?.defaultModel??"",i=L.agents.update.useMutation({onSuccess:()=>e.agents.list.invalidate()}),a=f=>i.mutate({agentId:"coo",model:f}),o=Up(s),[l,c]=y.useState(""),{groups:d}=Vm();return r.jsxs(ss,{value:s,onValueChange:a,children:[r.jsxs(is,{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[12px] border transition-colors outline-none",style:{color:zd,backgroundColor:`${zd}15`,borderColor:`${zd}40`},children:[r.jsx("span",{className:`text-[10px] px-1 py-0.5 rounded font-medium ${jo[o]}`,children:o}),r.jsx(Ds,{children:ta(s)}),r.jsx(ft,{className:"w-3 h-3 opacity-60"})]}),r.jsx(rs,{children:r.jsxs(as,{position:"popper",sideOffset:6,align:"end",className:"bg-[#1C1C24] border border-[#2A2A35] rounded-lg shadow-xl py-1 min-w-[200px] z-50",children:[r.jsx(os,{children:d.map(f=>r.jsxs(Ro,{children:[r.jsxs(Do,{className:"px-3 pt-2 pb-1 text-[10px] font-semibold text-[#5A5A6E] uppercase tracking-widest flex items-center gap-1.5",children:[r.jsx("span",{children:f.label}),r.jsx("span",{className:`px-1 py-0.5 rounded text-[9px] font-medium ${jo[f.tag]}`,children:f.tag})]}),f.models.map(p=>r.jsxs(vn,{value:p.id,className:"flex items-center justify-between px-3 py-1.5 text-[12px] text-[#C8C8D4] cursor-pointer hover:bg-white/5 outline-none data-[highlighted]:bg-white/5",children:[r.jsx(yn,{children:p.label}),r.jsx(ui,{children:r.jsx(Fe,{className:"w-3 h-3 text-[#6366F1]"})})]},p.id))]},f.label))}),r.jsx("div",{className:"px-2 pt-1 pb-2 border-t border-[#2A2A35] mt-1",children:r.jsx(ty,{value:l,onChange:c,onSubmit:f=>{a(f),c("")}})})]})})]})}function ZRe(){if(!Uo())return r.jsx(lm,{to:"/channels/direction",replace:!0});const{data:t,isLoading:n}=L.agents.list.useQuery(void 0,{refetchInterval:a=>a.state.data?.some(l=>l.id==="coo")?!1:3e3}),s=L.onboarding.seedCOO.useMutation(),i=t?.some(a=>a.id==="coo");return n?r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Pe,{className:"w-5 h-5 animate-spin text-[#F59E0B]"})}):i?r.jsx(eDe,{}):r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-8",children:[r.jsx("div",{className:"w-14 h-14 rounded-2xl bg-[#F59E0B]/10 border border-[#F59E0B]/20 flex items-center justify-center mb-4",children:r.jsx(Ia,{className:"w-7 h-7 text-[#F59E0B]"})}),r.jsx("h2",{className:"text-[18px] font-semibold text-[#F0F0F5] mb-2",children:"Your COO"}),r.jsx("p",{className:"text-[14px] text-[#8A8A99] max-w-md leading-relaxed mb-6",children:"The COO is your workspace architect. It can design agent teams, assign skills, and manage your workspace structure."}),r.jsxs("button",{onClick:()=>s.mutate(),disabled:s.isPending,className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-xl text-[13px] font-medium bg-[#F59E0B] text-[#0F0F11] hover:bg-[#FBBF24] disabled:opacity-60 transition-colors",children:[s.isPending&&r.jsx(Pe,{className:"w-3.5 h-3.5 animate-spin"}),"Create COO"]}),s.isError&&r.jsx("p",{className:"mt-3 text-[12px] text-red-400",children:"Failed to create COO. Try again."})]})}function eDe(){const{model:e}=zRe(),[t,n]=y.useState(""),[s,i]=y.useState(!1),[a,o]=y.useState(!1),[l,c]=y.useState([]),[d,f]=y.useState(null),p=y.useRef(null),m=y.useRef(null),[g,b]=y.useState(new Map),_=y.useRef(null),{data:w}=pj("coo");bW(Hf);const A=Je(ee=>ee.messagesByChannel[Hf]),S=y.useMemo(()=>A??[],[A]),C=L.messages.list.useQuery({channelId:Hf,limit:100},{staleTime:0}),E=L.coo.listProposals.useQuery(void 0,{staleTime:5e3}),k=E.data??{};y.useEffect(()=>{C.data&&Je.getState().setMessages(Hf,C.data.messages)},[C.data]);const T=L.coo.getLatestTask.useQuery(void 0,{staleTime:5e3});y.useEffect(()=>{const ee=[...S].reverse().find(le=>le.sender.type==="agent"&&le.metadata?.dispatch);if(!ee)return;_.current=ee.id;const re=T.data;if(re&&re.dispatches.length>0){const le=re.dispatches.map(ge=>({agentId:ge.agentId,agentName:ge.agentName??ge.agentId,channelId:ge.channelId,instruction:ge.instruction,status:ge.status??"sent"}));b(ge=>new Map(ge).set(ee.id,le));return}if(g.has(ee.id))return;const oe=ee.metadata?.dispatch,se=[],ae=oe?.groups??(oe?.group?[oe.group]:[]);for(const le of ae)for(const ge of le.agents)se.push({agentId:ge,agentName:ge,channelId:"",instruction:le.goal,status:"sent"});if(oe?.assignments)for(const le of oe.assignments)se.push({agentId:le.agent,agentName:le.agent,channelId:"",instruction:le.instruction,status:"sent"});se.length>0&&b(le=>new Map(le).set(ee.id,se))},[S,T.data]);const F=L.coo.chat.useMutation(),M=L.coo.approveProposal.useMutation(),I=L.coo.rejectProposal.useMutation(),R=L.coo.approveTrustUpdate.useMutation(),H=L.coo.rejectTrustUpdate.useMutation(),V=L.approvals.decide.useMutation(),K=L.messages.resetSession.useMutation(),q=L.useUtils();y.useEffect(()=>{p.current?.scrollIntoView({behavior:"smooth"})},[S.length,l.length]),y.useEffect(()=>{const ee=new WebSocket("ws://localhost:3001/ws");return ee.onmessage=re=>{try{const oe=JSON.parse(re.data);if(oe.type==="coo.progress"){const se=oe.payload;c(ae=>[...ae,se])}else if(oe.type==="coo.complete"){const se=oe.payload;f(se),B.current()}else if(oe.type==="coo.dispatch.sent"){const se=oe.payload;_.current&&b(ae=>{const le=new Map(ae),ge=le.get(_.current)??[],je=ge.findIndex(Ee=>Ee.agentId===se.agentId);return je>=0?ge[je]={...ge[je],...se,status:"sent"}:ge.push({...se,status:"sent"}),le.set(_.current,[...ge]),le})}else if(oe.type==="coo.dispatch.agent.done"){const se=oe.payload;_.current&&b(ae=>{const le=new Map(ae),ge=le.get(_.current)??[];return le.set(_.current,ge.map(je=>je.agentId===se.agentId?{...je,status:se.status}:je)),le})}}catch{}},()=>ee.close()},[]);const $=y.useRef(!1),B=y.useRef(E.refetch);B.current=E.refetch;const Y=y.useCallback(async()=>{const ee=t.trim();if(!ee||F.isPending||$.current)return;$.current=!0;const re=S.map(oe=>({role:oe.sender.type==="human"?"user":"assistant",content:oe.content}));n(""),m.current&&(m.current.style.height="auto");try{await F.mutateAsync({message:ee,history:re,model:e}),C.refetch(),B.current()}catch{}finally{$.current=!1}},[t,F,S,e]);function U(ee){c([]),M.mutate({proposalId:ee},{onSuccess:()=>{q.agents.list.invalidate(),q.channels.list.invalidate(),E.refetch()}})}function W(ee){I.mutate({proposalId:ee},{onSuccess:()=>{E.refetch()}})}function O(ee){R.mutate({messageId:ee},{onSuccess:()=>{q.agents.getTrust.invalidate(),q.agents.getSandboxOverride.invalidate(),q.agents.getMounts.invalidate(),C.refetch()}})}function D(ee){H.mutate({messageId:ee},{onSuccess:()=>{C.refetch()}})}function Q(ee){V.mutate({messageId:ee,decision:"approved"},{onSuccess:()=>{C.refetch()}})}function z(ee){V.mutate({messageId:ee,decision:"rejected"},{onSuccess:()=>{C.refetch()}})}function J(){K.mutate({channelId:Hf}),c([]),f(null)}return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-[#2A2A35] bg-[#0F0F11] flex-shrink-0",style:{borderLeftColor:zd,borderLeftWidth:3,borderLeftStyle:"solid"},children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{onClick:()=>o(ee=>!ee),className:"w-8 h-8 rounded-full bg-[#F59E0B]/15 flex items-center justify-center transition-opacity hover:opacity-80",children:r.jsx(Ia,{className:"w-4 h-4 text-[#F59E0B]"})}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:()=>o(ee=>!ee),className:"text-[15px] font-semibold text-[#F0F0F5] hover:underline decoration-dashed underline-offset-2 transition-colors",children:"COO"}),r.jsx("span",{className:"text-[11px] text-[#8A8A99] bg-white/5 px-1.5 py-0.5 rounded",children:"Workspace Architect"})]}),r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"relative flex items-center justify-center w-2 h-2",children:r.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:zd,opacity:.5}})}),r.jsx("span",{className:"text-[12px] text-[#8A8A99]",children:"ready"})]})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(JRe,{}),r.jsx(bt,{label:"Reset context",children:r.jsx("button",{onClick:J,className:"w-8 h-8 flex items-center justify-center rounded-md text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/5 transition-colors",children:r.jsx(lh,{className:"w-4 h-4"})})}),r.jsx(bt,{label:a?"Close panel":"Open panel",children:r.jsx("button",{onClick:()=>o(ee=>!ee),className:ye("w-8 h-8 flex items-center justify-center rounded-md transition-colors",a?"text-[#F0F0F5] bg-white/10":"text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/5"),children:a?r.jsx(mL,{className:"w-4 h-4"}):r.jsx(xL,{className:"w-4 h-4"})})})]})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto py-2",children:[S.length===0&&!C.isLoading&&r.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center px-8",children:[r.jsx("div",{className:"w-14 h-14 rounded-2xl bg-[#F59E0B]/10 border border-[#F59E0B]/20 flex items-center justify-center mb-4",children:r.jsx(Ia,{className:"w-7 h-7 text-[#F59E0B]"})}),r.jsx("h2",{className:"text-[18px] font-semibold text-[#F0F0F5] mb-2",children:"Talk to your COO"}),r.jsx("p",{className:"text-[14px] text-[#8A8A99] max-w-md leading-relaxed",children:"Design your team, dispatch tasks, manage skills, update trust settings — all through natural conversation."})]}),r.jsx(Me,{initial:!1,children:S.map((ee,re)=>ee.sender.type==="context_reset"?r.jsxs("div",{className:"flex items-center gap-3 py-2 px-4",children:[r.jsx("div",{className:"flex-1 h-px bg-[#2A2A35]"}),r.jsx("span",{className:"text-[11px] text-[#5A5A6E]",children:"new context"}),r.jsx("div",{className:"flex-1 h-px bg-[#2A2A35]"})]},ee.id):r.jsx(YRe,{message:ee,isLast:re===S.length-1,proposalStatuses:k,progressSteps:l,completionResult:d,onApprove:U,onReject:W,isApproving:M.isPending,isRejecting:I.isPending,onApproveTrust:O,onRejectTrust:D,isTrustApproving:R.isPending,isTrustRejecting:H.isPending,onApproveDelegation:Q,onRejectDelegation:z,isDelegationPending:V.isPending,dispatchStatuses:g},ee.id))}),F.isPending&&r.jsxs("div",{className:"flex items-start gap-3 px-4 py-2 border-l-[3px] border-l-[#F59E0B]",children:[r.jsx("div",{className:"w-8 h-8 rounded-full bg-[#F59E0B]/15 flex items-center justify-center flex-shrink-0",children:r.jsx(Ia,{className:"w-4 h-4 text-[#F59E0B]"})}),r.jsx("div",{className:"flex items-center gap-1 pt-3",children:[0,1,2].map(ee=>r.jsx(ne.span,{className:"w-1.5 h-1.5 rounded-full bg-[#F59E0B]",animate:{opacity:[.3,1,.3],scale:[.8,1.1,.8]},transition:{duration:1.4,repeat:1/0,delay:ee*.2,ease:"easeInOut"}},ee))})]}),r.jsx("div",{ref:p,className:"h-4"})]}),r.jsxs("div",{className:"px-4 pb-4 pt-2 flex-shrink-0",children:[r.jsxs("div",{className:"flex items-end gap-2 bg-[#1C1C21] border rounded-xl px-3 py-2.5 transition-colors duration-150",style:{borderColor:s?"#F59E0B60":"#2A2A35",boxShadow:s?"0 0 0 1px #F59E0B30":void 0},children:[r.jsx("textarea",{ref:m,value:t,onChange:ee=>n(ee.target.value),onKeyDown:ee=>{ee.key==="Enter"&&!ee.shiftKey&&(ee.preventDefault(),Y())},onFocus:()=>i(!0),onBlur:()=>i(!1),placeholder:"Talk to your COO...",disabled:F.isPending,rows:1,className:"flex-1 bg-transparent text-[14px] text-[#F0F0F5] placeholder:text-[#8A8A99]/60 resize-none outline-none leading-relaxed max-h-[120px] overflow-y-auto disabled:opacity-50",style:{minHeight:"22px"},onInput:ee=>{const re=ee.currentTarget;re.style.height="auto",re.style.height=`${Math.min(re.scrollHeight,120)}px`}}),r.jsx("button",{onClick:()=>{Y()},disabled:!t.trim()||F.isPending,className:"text-[#8A8A99] hover:text-[#F0F0F5] disabled:opacity-30 transition-colors mb-0.5 flex-shrink-0",children:r.jsx(Ji,{className:"w-4 h-4"})})]}),r.jsx("p",{className:"text-[11px] text-[#8A8A99]/40 mt-1.5 px-1",children:"Enter to send · Shift+Enter for newline"})]})]}),r.jsx(Me,{children:a&&w&&r.jsx($N,{agent:w,agentColor:zd,onClose:()=>o(!1),onOverrideSet:()=>{}})})]})}function tDe({proposalId:e,data:t,serverStatus:n}){const[s,i]=y.useState(null),o=s??(n==="approved"||n==="failed"?"approved":n==="rejected"?"rejected":null),l=L.useUtils(),c=L.coo.approveFederationGrant.useMutation({onSuccess:()=>{i("approved"),l.federation.listNodes.invalidate(),l.coo.listProposals.invalidate()}}),d=L.coo.rejectFederationGrant.useMutation({onSuccess:()=>{i("rejected"),l.coo.listProposals.invalidate()}}),f=c.isPending||d.isPending;return r.jsxs(ne.div,{initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{type:"spring",stiffness:300,damping:30},className:"mx-4 mb-4 bg-[#1C1C24] border border-[#6366F1]/25 rounded-xl overflow-hidden",children:[r.jsxs("div",{className:"px-5 py-4 border-b border-[#2A2A35] flex items-center gap-2",children:[r.jsx("div",{className:"w-6 h-6 rounded-lg bg-[#6366F1]/15 flex items-center justify-center",children:r.jsx(Wl,{className:"w-3 h-3 text-[#6366F1]"})}),r.jsx("span",{className:"text-[14px] font-semibold text-[#F0F0F5]",children:"Federation Grant"}),r.jsxs("span",{className:"text-[11px] font-mono px-1.5 py-0.5 rounded bg-[#6366F1]/15 text-[#818CF8]",children:[t.grantAgentId," → ",t.nodeName]}),o&&r.jsx("span",{className:ye("text-[11px] px-1.5 py-0.5 rounded font-medium",o==="approved"?"bg-[#10B981]/10 text-[#34D399]":"bg-[#EF4444]/10 text-[#F87171]"),children:o})]}),r.jsx("div",{className:"px-5 py-3 border-b border-[#2A2A35]/50 text-[13px] text-[#C8C8D4] leading-relaxed",children:t.reason}),!o&&r.jsxs("div",{className:"px-5 py-3 flex justify-end gap-2",children:[r.jsx("button",{onClick:()=>d.mutate({proposalId:e}),disabled:f,className:"px-4 py-1.5 rounded text-[12px] text-[#8A8A99] hover:bg-[#2A2A35] transition-colors disabled:opacity-50",children:"Reject"}),r.jsxs("button",{onClick:()=>c.mutate({proposalId:e}),disabled:f,className:"px-4 py-1.5 rounded bg-[#10B981] text-white text-[12px] font-medium hover:bg-[#0EA472] transition-colors disabled:opacity-50 flex items-center gap-1.5",children:[c.isPending?r.jsx(Pe,{className:"w-3 h-3 animate-spin"}):r.jsx(Fe,{className:"w-3 h-3"}),"Grant Access"]})]})]})}function nDe({proposalId:e,data:t,serverStatus:n}){const[s,i]=y.useState(null),o=s??(n==="approved"||n==="failed"?"approved":n==="rejected"?"rejected":null),l=L.useUtils(),c=L.coo.approveCloudSpawn.useMutation({onSuccess:()=>{i("approved"),l.federation.listNodes.invalidate(),l.coo.listProposals.invalidate()}}),d=L.coo.rejectCloudSpawn.useMutation({onSuccess:()=>{i("rejected"),l.coo.listProposals.invalidate()}}),f=c.isPending||d.isPending;return r.jsxs(ne.div,{initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{type:"spring",stiffness:300,damping:30},className:"mx-4 mb-4 bg-[#1C1C24] border border-[#10B981]/25 rounded-xl overflow-hidden",children:[r.jsxs("div",{className:"px-5 py-4 border-b border-[#2A2A35] flex items-center gap-2",children:[r.jsx("div",{className:"w-6 h-6 rounded-lg bg-[#10B981]/15 flex items-center justify-center",children:r.jsx(Xt,{className:"w-3 h-3 text-[#10B981]"})}),r.jsx("span",{className:"text-[14px] font-semibold text-[#F0F0F5]",children:"Spawn Cloud Node"}),r.jsx("span",{className:"text-[11px] font-mono px-1.5 py-0.5 rounded bg-[#10B981]/15 text-[#34D399]",children:t.name}),r.jsxs("span",{className:"text-[10px] text-[#8A8A99]",children:[t.provider," · ",t.region," · ",t.size]}),o&&r.jsx("span",{className:ye("text-[11px] px-1.5 py-0.5 rounded font-medium",o==="approved"?"bg-[#10B981]/10 text-[#34D399]":"bg-[#EF4444]/10 text-[#F87171]"),children:o})]}),r.jsx("div",{className:"px-5 py-3 border-b border-[#2A2A35]/50 text-[13px] text-[#C8C8D4] leading-relaxed",children:t.reason}),!o&&r.jsxs("div",{className:"px-5 py-3 flex items-center justify-between",children:[r.jsx("span",{className:"text-[11px] text-[#10B981]",children:"This will provision a Hetzner VPS (billable)"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{onClick:()=>d.mutate({proposalId:e}),disabled:f,className:"px-4 py-1.5 rounded text-[12px] text-[#8A8A99] hover:bg-[#2A2A35] transition-colors disabled:opacity-50",children:"Reject"}),r.jsxs("button",{onClick:()=>c.mutate({proposalId:e}),disabled:f,className:"px-4 py-1.5 rounded bg-[#10B981] text-white text-[12px] font-medium hover:bg-[#0EA472] transition-colors disabled:opacity-50 flex items-center gap-1.5",children:[c.isPending?r.jsx(Pe,{className:"w-3 h-3 animate-spin"}):r.jsx(Xt,{className:"w-3 h-3"}),"Approve & Provision"]})]})]})]})}function sDe({plan:e,messageId:t,decided:n}){const s=an(),i=L.useUtils(),a=L.coo.approveMissionPlan.useMutation({onSuccess:()=>{i.missions.list.invalidate(),i.missions.stats.invalidate(),s("/missions")}}),o=L.coo.rejectMissionPlan.useMutation(),c={low:"#5A5A6E",normal:"#8A8A99",high:"#F59E0B",critical:"#EF4444"}[e.priority??"normal"]??"#8A8A99";return r.jsxs("div",{className:"mt-3 rounded-lg border border-[#2A2A35] bg-[#13131A] overflow-hidden",children:[r.jsxs("div",{className:"px-4 py-3 border-b border-[#2A2A35]/50 flex items-center gap-3",children:[r.jsx(a0,{className:"w-4 h-4 text-[#6366F1]"}),r.jsx("span",{className:"text-[13px] font-medium text-[#F0F0F5] flex-1",children:e.title}),r.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium",style:{color:c,backgroundColor:c+"15"},children:e.priority??"normal"})]}),e.description&&r.jsx("p",{className:"px-4 py-2 text-[12px] text-[#8A8A99] border-b border-[#2A2A35]/30",children:e.description}),r.jsx("div",{className:"px-4 py-2 space-y-1.5",children:e.tasks.map((d,f)=>r.jsxs("div",{className:"flex items-center gap-2.5 py-1 px-2.5 rounded bg-[#0F0F11]/50",children:[r.jsx("span",{className:"text-[10px] text-[#5A5A6E] font-mono w-4 text-right",children:d.order}),r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#3A3A45]"}),r.jsx("span",{className:"text-[12px] text-[#C8C8D4] flex-1 truncate",children:d.title}),d.agentId&&r.jsx("span",{className:"text-[11px] text-[#8A8A99] bg-[#1E1E28] px-1.5 py-0.5 rounded",children:d.agentId}),d.dependsOn&&d.dependsOn.length>0&&r.jsxs("span",{className:"text-[10px] text-[#5A5A6E]",children:["after ",d.dependsOn.join(", ")]})]},f))}),r.jsx("div",{className:"px-4 py-3 border-t border-[#2A2A35]/50 flex items-center gap-2",children:n==="approved"?r.jsxs("span",{className:"flex items-center gap-1.5 text-[12px] text-[#10B981]",children:[r.jsx(Fe,{className:"w-3.5 h-3.5"})," Mission created"]}):n==="rejected"?r.jsxs("span",{className:"flex items-center gap-1.5 text-[12px] text-[#EF4444]",children:[r.jsx(Te,{className:"w-3.5 h-3.5"})," Plan rejected"]}):r.jsxs(r.Fragment,{children:[r.jsxs("button",{onClick:()=>a.mutate({messageId:t}),disabled:a.isPending,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-[#6366F1] text-white text-[12px] font-medium hover:bg-[#5558E6] transition-colors disabled:opacity-50",children:[a.isPending?r.jsx(Pe,{className:"w-3 h-3 animate-spin"}):r.jsx(Fe,{className:"w-3 h-3"}),"Create Mission"]}),r.jsx("button",{onClick:()=>o.mutate({messageId:t}),disabled:o.isPending,className:"px-3 py-1.5 rounded-md text-[12px] text-[#8A8A99] hover:text-[#EF4444] hover:bg-[#EF4444]/10 transition-colors",children:"Reject"})]})})]})}function _W({text:e}){const[t,n]=y.useState(!1);return r.jsx(bt,{label:t?"Copied":"Copy",children:r.jsx("button",{onClick:()=>{navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)},className:"w-7 h-7 flex items-center justify-center rounded-md text-[#5A5A6E] hover:text-[#8A8A99] hover:bg-white/5 transition-colors",children:t?r.jsx(Fe,{className:"w-3.5 h-3.5 text-[#10B981]"}):r.jsx(Po,{className:"w-3.5 h-3.5"})})})}function fb({code:e,label:t}){return r.jsxs("div",{className:"mt-3",children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("span",{className:"text-[11px] text-[#8A8A99] font-medium",children:t}),r.jsx(_W,{text:e})]}),r.jsx("pre",{className:"bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 text-[11px] font-mono text-[#C8C8D4] overflow-x-auto whitespace-pre-wrap break-all",children:e})]})}function iDe(){const[e,t]=y.useState(!1),{data:n,isLoading:s}=L.mcp.getToken.useQuery(),i=L.useUtils(),a=L.mcp.regenerateToken.useMutation({onSuccess:()=>{i.mcp.getToken.invalidate()}});if(s||!n)return r.jsx("p",{className:"text-[12px] text-[#5A5A6E] py-4",children:"Loading..."});const{token:o,serverPath:l}=n,c=o.slice(0,8)+"•".repeat(24)+o.slice(-8);return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-[14px] font-semibold text-[#F0F0F5] mb-1",children:"MCP Server"}),r.jsx("p",{className:"text-[12px] text-[#8A8A99]",children:"Connect external AI harnesses (Claude Code, Codex, Cursor) to your agent's identity, memory, and governance."})]}),r.jsxs("div",{className:"bg-[#13131A] border border-[#2A2A35] rounded-xl p-4",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(Ti,{className:"w-4 h-4 text-[#6366F1]"}),r.jsx("span",{className:"text-[13px] font-medium text-[#F0F0F5]",children:"Auth Token"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("code",{className:"flex-1 bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 text-[12px] font-mono text-[#8A8A99] overflow-hidden",children:e?o:c}),r.jsx(bt,{label:e?"Hide":"Reveal",children:r.jsx("button",{onClick:()=>t(d=>!d),className:"w-8 h-8 flex items-center justify-center rounded-md text-[#5A5A6E] hover:text-[#8A8A99] hover:bg-white/5 transition-colors",children:e?r.jsx(R5,{className:"w-4 h-4"}):r.jsx(xv,{className:"w-4 h-4"})})}),r.jsx(_W,{text:o}),r.jsx(bt,{label:"Regenerate",children:r.jsx("button",{onClick:()=>a.mutate(),disabled:a.isPending,className:"w-8 h-8 flex items-center justify-center rounded-md text-[#5A5A6E] hover:text-[#F59E0B] hover:bg-[#F59E0B]/10 transition-colors disabled:opacity-50",children:r.jsx(Xi,{className:`w-4 h-4 ${a.isPending?"animate-spin":""}`})})})]}),a.isSuccess&&r.jsx("p",{className:"text-[11px] text-[#F59E0B] mt-2",children:"Token regenerated. Update your harness configs."})]}),r.jsxs("div",{className:"bg-[#13131A] border border-[#2A2A35] rounded-xl p-4",children:[r.jsx("h4",{className:"text-[13px] font-medium text-[#F0F0F5] mb-3",children:"Setup Instructions"}),r.jsx(fb,{label:"Claude Code",code:`claude mcp add damn-dev -e DAMNDEV_TOKEN=${o} -- node ${l}`}),r.jsx(fb,{label:"Codex",code:`codex mcp add damn-dev --env DAMNDEV_TOKEN=${o} -- node ${l}`}),r.jsx(fb,{label:"Cursor (.cursor/mcp.json)",code:JSON.stringify({mcpServers:{"damn-dev":{command:"node",args:[l],env:{DAMNDEV_TOKEN:o}}}},null,2)})]}),r.jsxs("div",{className:"bg-[#13131A] border border-[#2A2A35] rounded-xl p-4",children:[r.jsx("h4",{className:"text-[13px] font-medium text-[#F0F0F5] mb-2",children:"Project Binding"}),r.jsxs("p",{className:"text-[12px] text-[#8A8A99] mb-3",children:["Create a ",r.jsx("code",{className:"text-[#C8C8D4] bg-[#0F0F11] px-1 rounded",children:".damndev.json"})," in your project root to auto-bind an agent:"]}),r.jsx(fb,{label:".damndev.json",code:JSON.stringify({agent:"your-agent-id",workspace:"default"},null,2)})]})]})}function rDe({entry:e,onDelete:t,onSave:n,onMoveToSecrets:s}){const[i,a]=y.useState(!1),[o,l]=y.useState(!1),[c,d]=y.useState(e.value),[f,p]=y.useState(!1);function m(){n(e.key,c.trim()),l(!1),p(!0),setTimeout(()=>p(!1),1500)}return r.jsxs("div",{className:"flex items-start gap-4 py-4 border-b border-[#2A2A35] last:border-0",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("span",{className:"text-[13px] font-medium text-[#F0F0F5]",children:e.key}),e.label!==e.key&&r.jsx("span",{className:"text-[11px] text-[#5A5A6E]",children:e.label}),f&&r.jsxs(ne.span,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0},className:"flex items-center gap-1 text-[11px] text-[#10B981]",children:[r.jsx(Fe,{className:"w-3 h-3"}),"Saved"]})]}),o?r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{autoFocus:!0,type:"text",value:c,onChange:g=>d(g.target.value),onKeyDown:g=>{g.key==="Enter"&&m(),g.key==="Escape"&&(l(!1),d(e.value))},className:"flex-1 bg-[#13131A] border border-[#6366F1]/40 rounded-lg px-3 py-1.5 text-[13px] text-[#F0F0F5] font-mono outline-none focus:border-[#6366F1] transition-colors"}),r.jsx("button",{onClick:m,className:"px-3 py-1.5 rounded-lg bg-[#6366F1] text-white text-[12px] font-medium hover:bg-[#5558E8] transition-colors",children:"Save"}),r.jsx("button",{onClick:()=>{l(!1),d(e.value)},className:"px-3 py-1.5 rounded-lg text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] border border-[#2A2A35] hover:border-[#3A3A45] transition-colors",children:"Cancel"})]}):r.jsx("button",{onClick:()=>l(!0),className:"flex items-center gap-2 group",children:r.jsx("code",{className:"text-[12px] font-mono text-[#8A8A99] group-hover:text-[#C8C8D4] transition-colors",children:i?e.value:e.masked})})]}),e.key==="GITHUB_TOKEN"&&r.jsxs(r.Fragment,{children:[r.jsxs("a",{href:"https://github.com/settings/tokens/new?scopes=repo&description=damn.dev",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 mt-1 text-[11px] text-[#6366F1] hover:text-[#818CF8] transition-colors",children:["Generate a token on GitHub ",r.jsx(cs,{className:"w-3 h-3"})]}),r.jsx("span",{className:"block text-[11px] text-[#8A8A99] mt-0.5",children:"Scopes are pre-filled — just click Generate and paste it here."}),r.jsx("span",{className:"block text-[11px] text-[#8A8A99] mt-0.5",children:"Set expiration to 'No expiration' for uninterrupted access."})]}),e.key==="GITLAB_TOKEN"&&r.jsxs(r.Fragment,{children:[r.jsxs("a",{href:"https://gitlab.com/-/user_settings/personal_access_tokens?name=damn.dev&scopes=api",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 mt-1 text-[11px] text-[#6366F1] hover:text-[#818CF8] transition-colors",children:["Generate a token on GitLab ",r.jsx(cs,{className:"w-3 h-3"})]}),r.jsx("span",{className:"block text-[11px] text-[#8A8A99] mt-0.5",children:"Scopes are pre-filled — just click Create and paste it here."})]}),r.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.misplaced&&s&&r.jsx(bt,{label:"This is a credential — encrypt it in Secrets. The env copy stays in place as a mirror so nothing breaks.",children:r.jsx("button",{onClick:()=>s(e.key),className:"flex items-center gap-1 px-2 h-7 rounded-md text-[11px] font-medium bg-amber-500/10 text-amber-300 hover:bg-amber-500/20 border border-amber-500/20 transition-colors",children:"Encrypt"})}),r.jsx(bt,{label:i?"Hide":"Reveal",children:r.jsx("button",{onClick:()=>a(g=>!g),className:"w-7 h-7 flex items-center justify-center rounded-md text-[#5A5A6E] hover:text-[#8A8A99] hover:bg-white/5 transition-colors",children:i?r.jsx(R5,{className:"w-3.5 h-3.5"}):r.jsx(xv,{className:"w-3.5 h-3.5"})})}),r.jsx(bt,{label:"Delete",children:r.jsx("button",{onClick:()=>t(e.key),className:"w-7 h-7 flex items-center justify-center rounded-md text-[#5A5A6E] hover:text-red-400 hover:bg-red-500/10 transition-colors",children:r.jsx(Dn,{className:"w-3.5 h-3.5"})})})]})]})}function aDe({knownKeys:e,existingKeys:t,onAdd:n,onClose:s}){const[i,a]=y.useState(""),[o,l]=y.useState(""),[c,d]=y.useState(""),f=i==="__custom__",p=f?o.trim():i;function m(){!p||!c.trim()||(n(p,c.trim()),s())}const g=e.filter(b=>!t.includes(b.key));return r.jsxs(ne.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},className:"bg-[#16161A] border border-[#2A2A35] rounded-xl p-5 mb-4",children:[r.jsx("p",{className:"text-[13px] font-medium text-[#F0F0F5] mb-4",children:"Add API Key"}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-[11px] text-[#8A8A99] mb-1.5",children:"Key name"}),r.jsxs(ss,{value:i,onValueChange:a,children:[r.jsxs(is,{className:"flex items-center justify-between w-full bg-[#13131A] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] outline-none focus:border-[#6366F1]/60 transition-colors",children:[r.jsx(Ds,{placeholder:"Select a key..."}),r.jsx(Yl,{children:r.jsx(ft,{className:"w-3.5 h-3.5 text-[#5A5A6E]"})})]}),r.jsx(rs,{children:r.jsx(as,{className:"bg-[#1C1C24] border border-[#2A2A35] rounded-lg shadow-xl z-50 overflow-hidden",children:r.jsxs(os,{className:"p-1",children:[g.map(b=>r.jsx(vn,{value:b.key,className:"flex items-center px-3 py-2 text-[13px] text-[#C8C8D4] rounded-md cursor-pointer hover:bg-white/5 outline-none data-[highlighted]:bg-white/5",children:r.jsx(yn,{children:b.key})},b.key)),r.jsx(vn,{value:"__custom__",className:"flex items-center px-3 py-2 text-[13px] text-[#8A8A99] rounded-md cursor-pointer hover:bg-white/5 outline-none data-[highlighted]:bg-white/5",children:r.jsx(yn,{children:"Custom key..."})})]})})})]})]}),f&&r.jsxs("div",{children:[r.jsx("label",{className:"block text-[11px] text-[#8A8A99] mb-1.5",children:"Custom key name"}),r.jsx("input",{autoFocus:!0,value:o,onChange:b=>l(b.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"")),placeholder:"MY_API_KEY",className:"w-full bg-[#13131A] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] font-mono placeholder-[#5A5A6E] outline-none focus:border-[#6366F1]/60 transition-colors"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-[11px] text-[#8A8A99] mb-1.5",children:"Value"}),r.jsx("input",{value:c,onChange:b=>d(b.target.value),onKeyDown:b=>{b.key==="Enter"&&m()},placeholder:"Paste your key...",type:"password",className:"w-full bg-[#13131A] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] font-mono placeholder-[#5A5A6E] outline-none focus:border-[#6366F1]/60 transition-colors"}),p==="GITHUB_TOKEN"&&r.jsxs(r.Fragment,{children:[r.jsxs("a",{href:"https://github.com/settings/tokens/new?scopes=repo&description=damn.dev",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 mt-1 text-[11px] text-[#6366F1] hover:text-[#818CF8] transition-colors",children:["Generate a token on GitHub ",r.jsx(cs,{className:"w-3 h-3"})]}),r.jsx("span",{className:"block text-[11px] text-[#8A8A99] mt-0.5",children:"Scopes are pre-filled — just click Generate and paste it here."}),r.jsx("span",{className:"block text-[11px] text-[#8A8A99] mt-0.5",children:"Set expiration to 'No expiration' for uninterrupted access."})]}),p==="GITLAB_TOKEN"&&r.jsxs(r.Fragment,{children:[r.jsxs("a",{href:"https://gitlab.com/-/user_settings/personal_access_tokens?name=damn.dev&scopes=api",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 mt-1 text-[11px] text-[#6366F1] hover:text-[#818CF8] transition-colors",children:["Generate a token on GitLab ",r.jsx(cs,{className:"w-3 h-3"})]}),r.jsx("span",{className:"block text-[11px] text-[#8A8A99] mt-0.5",children:"Scopes are pre-filled — just click Create and paste it here."})]})]}),r.jsxs("div",{className:"flex gap-2 pt-1",children:[r.jsx("button",{onClick:m,disabled:!p||!c.trim(),className:"flex-1 px-4 py-2 rounded-lg bg-[#6366F1] text-white text-[13px] font-medium hover:bg-[#5558E8] transition-colors disabled:opacity-40 disabled:pointer-events-none",children:"Add key"}),r.jsx("button",{onClick:s,className:"px-4 py-2 rounded-lg text-[13px] text-[#8A8A99] hover:text-[#F0F0F5] border border-[#2A2A35] hover:border-[#3A3A45] transition-colors",children:"Cancel"})]})]})]})}function wW({onSelect:e}){const{data:t=[],isLoading:n,refetch:s}=L.settings.detectObsidianVaults.useQuery(void 0,{staleTime:1/0,enabled:!1}),[i,a]=y.useState(!1);function o(){s().then(()=>a(!0))}return r.jsx("div",{className:"mt-3",children:i?t.length===0?r.jsx("p",{className:"text-[12px] text-[#5A5A6E]",children:"No Obsidian vaults detected."}):r.jsx("div",{className:"flex flex-wrap gap-2",children:t.map(l=>r.jsx("button",{onClick:()=>e(l.path),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[12px] text-[#8A8A99] hover:text-[#C8C8D4] bg-white/[0.03] border border-[#2A2A35] hover:border-[#3A3A45] transition-colors",children:l.name},l.path))}):r.jsxs("button",{onClick:o,disabled:n,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[12px] text-[#8A8A99] hover:text-[#C8C8D4] border border-[#2A2A35] hover:border-[#3A3A45] transition-colors",children:[r.jsx(lh,{className:`w-3 h-3 ${n?"animate-spin":""}`}),"Detect Obsidian vaults"]})})}function oDe({open:e,onClose:t,onSelect:n}){const[s,i]=y.useState(void 0),{data:a,isLoading:o}=L.settings.listDirectory.useQuery({path:s},{enabled:e}),l=a?.entries??[],c=a?.error,d=s?.split("/").filter(Boolean)??[];function f(g){i(g)}function p(g){const b="/"+d.slice(0,g+1).join("/");i(b)}function m(){s&&(n(s),t())}return r.jsx(ji,{open:e,onOpenChange:g=>{g||t()},children:r.jsxs(Ni,{children:[r.jsx(ir,{className:"fixed inset-0 bg-black/60 z-40"}),r.jsxs(ki,{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[520px] max-h-[70vh] bg-[#1C1C24] border border-[#2A2A35] rounded-xl shadow-2xl z-50 flex flex-col",children:[r.jsxs("div",{className:"px-5 py-4 border-b border-[#2A2A35] flex items-center justify-between flex-shrink-0",children:[r.jsx(nr,{className:"text-[15px] font-semibold text-[#F0F0F5]",children:"Browse folders"}),r.jsx(Gs,{asChild:!0,children:r.jsx("button",{className:"w-7 h-7 flex items-center justify-center rounded-md text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/10 transition-colors",children:r.jsx(Te,{className:"w-4 h-4"})})})]}),r.jsxs("div",{className:"px-5 py-2 border-b border-[#2A2A35] flex items-center gap-1 text-[12px] overflow-x-auto flex-shrink-0",children:[r.jsx("button",{onClick:()=>i(void 0),className:"text-[#6366F1] hover:text-[#818CF8] transition-colors flex-shrink-0",children:"Home"}),d.map((g,b)=>r.jsxs("span",{className:"flex items-center gap-1 flex-shrink-0",children:[r.jsx(Jt,{className:"w-3 h-3 text-[#5A5A6E]"}),r.jsx("button",{onClick:()=>p(b),className:"text-[#6366F1] hover:text-[#818CF8] transition-colors",children:g})]},b))]}),s&&r.jsx("div",{className:"px-5 py-1.5 border-b border-[#2A2A35] flex-shrink-0",children:r.jsx("code",{className:"text-[11px] font-mono text-[#5A5A6E]",children:s})}),r.jsx("div",{className:"flex-1 overflow-y-auto px-2 py-2 min-h-[200px]",children:o?r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx(Pe,{className:"w-5 h-5 text-[#6366F1] animate-spin"})}):c&&l.length===0?r.jsx("div",{className:"flex items-center justify-center py-12 text-[12px] text-[#5A5A6E]",children:c}):l.length===0?r.jsx("div",{className:"flex items-center justify-center py-12 text-[12px] text-[#5A5A6E]",children:"No folders found"}):r.jsxs("div",{className:"space-y-0.5",children:[l.map(g=>r.jsxs("button",{onClick:()=>f(g.path),className:"w-full flex items-center gap-2.5 px-3 py-2 rounded-lg text-left hover:bg-white/5 transition-colors group",children:[r.jsx(vm,{className:"w-4 h-4 text-[#6366F1]/70 group-hover:text-[#6366F1] flex-shrink-0"}),r.jsx("span",{className:"text-[13px] text-[#C8C8D4] group-hover:text-[#F0F0F5] truncate",children:g.name})]},g.path)),c&&l.length>0&&r.jsx("p",{className:"text-[11px] text-[#5A5A6E] px-3 pt-2",children:c})]})}),r.jsxs("div",{className:"px-5 py-3 border-t border-[#2A2A35] flex items-center justify-end gap-2 flex-shrink-0",children:[r.jsx(Gs,{asChild:!0,children:r.jsx("button",{className:"px-3 py-1.5 rounded-lg text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] border border-[#2A2A35] hover:border-[#3A3A45] transition-colors",children:"Cancel"})}),r.jsx("button",{onClick:m,disabled:!s,className:"px-3 py-1.5 rounded-lg bg-[#6366F1] text-white text-[12px] font-medium hover:bg-[#5558E8] transition-colors disabled:opacity-40 disabled:pointer-events-none",children:"Select this folder"})]})]})]})})}const sO=[{hostPath:"~/Documents",mountPath:"/host/documents",label:"Documents"},{hostPath:"~/Desktop",mountPath:"/host/desktop",label:"Desktop"},{hostPath:"~/Downloads",mountPath:"/host/downloads",label:"Downloads"},{hostPath:"~/Projects",mountPath:"/host/projects",label:"Projects"}];function lDe(){const[e,t]=y.useState(!1),[n,s]=y.useState(""),[i,a]=y.useState(""),[o,l]=y.useState(""),[c,d]=y.useState(!1),[f,p]=y.useState(!1),[m,g]=y.useState(""),[b,_]=y.useState(!1),[w,A]=y.useState(!1),[S,C]=y.useState(!1),[E,k]=y.useState(""),T=L.useUtils(),{data:F}=L.settings.getVolumeMounts.useQuery(),{data:M}=L.settings.getDockerComposeSnippet.useQuery(),{data:I}=L.settings.getRunMode.useQuery(),R=L.settings.addVolumeMount.useMutation({onSuccess:D=>{if(!D.ok&&D.error){g(D.error);return}T.settings.getVolumeMounts.invalidate(),T.settings.getDockerComposeSnippet.invalidate(),t(!1),s(""),a(""),l(""),g(""),_(!0)}}),H=L.settings.removeVolumeMount.useMutation({onSuccess:()=>{T.settings.getVolumeMounts.invalidate(),T.settings.getDockerComposeSnippet.invalidate(),_(!0)}}),V=L.settings.applyMountsAndRestart.useMutation({onSuccess:D=>{D.success?(_(!1),C(!0),k(!D.containerFound||!D.composeEdited?D.reason:""),setTimeout(()=>C(!1),3e3)):k(D.reason)}}),K=F?.mounts??[],q=I?.backendIsNative??!1,$=M?.snippet??"";function B(D){s(D),g("");const Q=D.split("/").pop()?.toLowerCase().replace(/[^a-z0-9_-]/g,"")??"";Q&&(a(`/host/${Q}`),l(D.split("/").pop()??Q)),t(!0)}function Y(D){s(D),g("");const Q=D.replace(/^~\//,"").split("/").pop()?.toLowerCase().replace(/[^a-z0-9_-]/g,"")??"";Q&&(a(`/host/${Q}`),l(D.replace(/^~\//,"").split("/").pop()??Q))}function U(){!n.trim()||!i.trim()||!o.trim()||(g(""),R.mutate({hostPath:n.trim(),mountPath:i.trim(),label:o.trim()}))}function W(){navigator.clipboard.writeText($.replace(/\\n/g,`
|
|
427
|
+
value: \${EXAMPLE_API_KEY}`}),r.jsxs("p",{className:"text-[10px] text-[#5A5A6E] mt-2 leading-relaxed",children:["Auth types: ",r.jsx("code",{className:"text-[#8A8A99]",children:"bearer"}),", ",r.jsx("code",{className:"text-[#8A8A99]",children:"header"})," (add ",r.jsx("code",{className:"text-[#8A8A99]",children:"header: X-Name"}),"), ",r.jsx("code",{className:"text-[#8A8A99]",children:"query"})," (add ",r.jsx("code",{className:"text-[#8A8A99]",children:"query: api_key"}),"). Set ",r.jsx("code",{className:"text-[#8A8A99]",children:"requires_approval: true"})," for destructive calls."]})]})})]})}function CRe({onClose:e,onSuccess:t}){const[n,s]=y.useState("pick"),[i,a]=y.useState(null),[o,l]=y.useState(null),[c,d]=y.useState(null),f=y.useRef(null),p=L.skillPackImport.preview.useMutation(),m=L.skillPackImport.confirm.useMutation(),g=y.useCallback(async _=>{if(!_.name.endsWith(".damnpack")){l("Please select a .damnpack file"),s("error");return}if(_.size>100*1024*1024){l("File too large (max 100MB)"),s("error");return}s("uploading");try{const w=new FormData;w.append("file",_);const A=await fetch(`${oi}/api/agents/import-upload`,{method:"POST",body:w,credentials:"include"});if(!A.ok){const E=await A.json().catch(()=>({error:"Upload failed"}));throw new Error(E.error||`Upload failed (${A.status})`)}const{uploadId:S}=await A.json(),C=await p.mutateAsync({uploadId:S});a(C),s("preview")}catch(w){l(w instanceof Error?w.message:"Upload failed"),s("error")}},[p]);async function b(){if(i){s("confirming");try{const _=await m.mutateAsync({previewId:i.previewId});d(_),s("done")}catch(_){l(_ instanceof Error?_.message:"Install failed"),s("error")}}}return r.jsxs(ne.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:e,children:[r.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),r.jsxs(ne.div,{initial:{scale:.95,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.95,opacity:0},transition:{duration:.15},onClick:_=>_.stopPropagation(),className:"relative w-full max-w-md bg-[#16161A] border border-[#2A2A35] rounded-2xl shadow-2xl overflow-hidden",children:[r.jsxs("div",{className:"px-5 py-4 border-b border-[#2A2A35] flex items-center justify-between",children:[r.jsx("p",{className:"text-[14px] font-semibold text-[#F0F0F5]",children:n==="done"?"Skills installed":"Import skill pack"}),r.jsx("button",{onClick:e,className:"w-7 h-7 flex items-center justify-center rounded-md text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/10 transition-colors",children:r.jsx(Te,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"p-5",children:[n==="pick"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("button",{onClick:()=>f.current?.click(),className:"w-full py-10 rounded-xl border-2 border-dashed border-[#2A2A35] hover:border-[#6366F1]/50 transition-colors flex flex-col items-center gap-3 group",children:[r.jsx(su,{className:"w-8 h-8 text-[#5A5A6E] group-hover:text-[#6366F1] transition-colors"}),r.jsxs("div",{className:"text-center",children:[r.jsx("p",{className:"text-[13px] text-[#F0F0F5] font-medium",children:"Choose .damnpack skill pack"}),r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mt-1",children:"Max 100MB"})]})]}),r.jsx("input",{ref:f,type:"file",accept:".damnpack",className:"hidden",onChange:_=>{const w=_.target.files?.[0];w&&g(w)}})]}),(n==="uploading"||n==="confirming")&&r.jsxs("div",{className:"flex flex-col items-center py-8 gap-3",children:[r.jsx(Pe,{className:"w-8 h-8 text-[#6366F1] animate-spin"}),r.jsx("p",{className:"text-[13px] text-[#8A8A99]",children:n==="uploading"?"Scanning skill pack...":"Installing skills..."})]}),n==="error"&&r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"rounded-lg bg-[#EF4444]/10 border border-[#EF4444]/20 px-4 py-3",children:r.jsx("p",{className:"text-[13px] text-[#FCA5A5]",children:o})}),r.jsx("button",{onClick:()=>{s("pick"),l(null)},className:"w-full py-2 rounded-lg text-[13px] font-medium bg-[#2A2A35] hover:bg-[#3A3A45] text-[#F0F0F5] transition-colors",children:"Try again"})]}),n==="preview"&&i&&r.jsxs("div",{className:"space-y-4 max-h-[60vh] overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#6366F1]/15 border border-[#6366F1]/25 flex items-center justify-center",children:r.jsx(vv,{className:"w-5 h-5 text-[#818CF8]"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-[14px] font-semibold text-[#F0F0F5] truncate",children:i.name}),r.jsxs("p",{className:"text-[11px] text-[#8A8A99]",children:["v",i.version," by"," ",i.publisherUrl?r.jsxs("a",{href:i.publisherUrl,target:"_blank",rel:"noopener noreferrer",className:"text-[#818CF8] hover:underline inline-flex items-center gap-0.5",children:[i.publisher,r.jsx(cs,{className:"w-2.5 h-2.5"})]}):i.publisher]})]})]}),r.jsx("p",{className:"text-[12px] text-[#8A8A99]",children:i.summary}),r.jsxs("div",{children:[r.jsxs("p",{className:"text-[10px] font-semibold text-[#5A5A6E] uppercase tracking-widest mb-2",children:[i.skills.length," skill",i.skills.length!==1?"s":""]}),r.jsx("div",{className:"space-y-2",children:i.skills.map(_=>r.jsxs("div",{className:"rounded-lg bg-[#1C1C21] border border-[#2A2A35] px-3 py-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between mb-0.5",children:[r.jsx("p",{className:"text-[13px] font-medium text-[#F0F0F5]",children:_.name}),r.jsxs("div",{className:"flex items-center gap-2",children:[_.toolCount>0&&r.jsxs("span",{className:"text-[10px] text-[#5A5A6E]",children:[_.toolCount," tool",_.toolCount!==1?"s":""]}),_.exists&&r.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-[#F59E0B]/10 text-[#FCD34D] border border-[#F59E0B]/20",children:"Update"})]})]}),r.jsx("p",{className:"text-[11px] text-[#6A6A7A] line-clamp-2",children:_.description})]},_.slug))})]}),i.missingSecrets.length>0&&(()=>{const _=i.missingSecrets.filter(A=>!A.default),w=i.missingSecrets.filter(A=>!!A.default);return r.jsxs("div",{className:"space-y-2",children:[w.length>0&&r.jsxs("div",{className:"rounded-lg bg-emerald-500/10 border border-emerald-500/20 px-3 py-2 space-y-1",children:[r.jsxs("p",{className:"text-[11px] font-semibold text-emerald-400 flex items-center gap-1.5",children:[r.jsx(Fe,{className:"w-3.5 h-3.5"}),"Auto-configured"]}),r.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1",children:w.map(A=>r.jsx("code",{className:"px-1.5 py-0.5 rounded text-[10px] font-mono text-emerald-400 bg-emerald-500/15 border border-emerald-500/20",children:A.key},A.key))})]}),_.length>0&&r.jsxs("div",{className:"rounded-lg bg-[#F59E0B]/10 border border-[#F59E0B]/20 px-3 py-2 space-y-1.5",children:[r.jsxs("p",{className:"text-[11px] font-semibold text-[#FCD34D] flex items-center gap-1.5",children:[r.jsx(Eo,{className:"w-3.5 h-3.5"}),"Required workspace secrets"]}),r.jsx("p",{className:"text-[10px] text-[#FCD34D]/80",children:"You'll need to add these in Settings after installing:"}),r.jsx("div",{className:"space-y-1 mt-1.5",children:_.map(A=>r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("code",{className:"px-1.5 py-0.5 rounded text-[10px] font-mono text-[#FCD34D] bg-[#F59E0B]/15 border border-[#F59E0B]/20 flex-shrink-0",children:A.key}),r.jsx("span",{className:"text-[10px] text-[#FCD34D]/60 leading-tight",children:A.description})]},A.key))})]})]})})(),r.jsxs("div",{className:"flex gap-2 pt-2",children:[r.jsx("button",{onClick:b,className:"flex-1 py-2 rounded-lg text-[13px] font-medium bg-[#6366F1] hover:bg-[#5254CC] text-white transition-colors",children:"Install All"}),r.jsx("button",{onClick:e,className:"px-4 py-2 rounded-lg text-[13px] font-medium bg-[#2A2A35] hover:bg-[#3A3A45] text-[#F0F0F5] transition-colors",children:"Cancel"})]})]}),n==="done"&&c&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center gap-3 py-4",children:[r.jsx("div",{className:"w-10 h-10 rounded-full bg-emerald-500/15 border border-emerald-500/25 flex items-center justify-center",children:r.jsx(Fe,{className:"w-5 h-5 text-emerald-400"})}),r.jsxs("div",{children:[r.jsxs("p",{className:"text-[14px] font-semibold text-[#F0F0F5]",children:[c.total," skill",c.total!==1?"s":""," installed"]}),r.jsxs("p",{className:"text-[12px] text-[#8A8A99]",children:[c.installed.length>0&&`${c.installed.length} new`,c.installed.length>0&&c.updated.length>0&&", ",c.updated.length>0&&`${c.updated.length} updated`]})]})]}),c.autoPopulated.length>0&&r.jsx("div",{className:"rounded-lg bg-emerald-500/10 border border-emerald-500/20 px-3 py-2",children:r.jsxs("p",{className:"text-[11px] text-emerald-400",children:["Auto-configured: ",c.autoPopulated.join(", ")]})}),i&&i.missingSecrets.some(_=>!_.default)&&r.jsxs(gn,{to:"/settings?tab=secrets",className:"flex items-center justify-center gap-1.5 w-full py-2 rounded-lg text-[12px] font-medium bg-[#F59E0B]/10 text-[#FCD34D] hover:bg-[#F59E0B]/20 border border-[#F59E0B]/30 transition-colors",children:[r.jsx(Eo,{className:"w-3.5 h-3.5"}),"Add missing secrets in Settings"]}),r.jsx("button",{onClick:()=>{t(),e()},className:"w-full py-2 rounded-lg text-[13px] font-medium bg-[#6366F1] hover:bg-[#5254CC] text-white transition-colors",children:"Done"})]})]})]})]})}const jRe={secretsoss:"#6366F1",lifelog:"#10B981",chut:"#F59E0B",custom:"#6B7280",clawhub:"#8B5CF6"};function NRe(e){return jRe[e]??"#6B7280"}function yW({provider:e}){const t=NRe(e),n=e==="secretsoss"?"SecretSoss":e==="lifelog"?"Lifelog":e==="chut"?"Chut.co":e;return r.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-md text-[11px] font-medium",style:{backgroundColor:`${t}20`,color:t,border:`1px solid ${t}40`},children:n})}function nO({onConfirm:e,onRemove:t}){const[n,s]=y.useState(!1);return r.jsxs(Ys,{open:n,onOpenChange:s,children:[r.jsx(ci,{asChild:!0,children:r.jsx("button",{className:"px-3 py-1.5 rounded-lg text-[12px] font-medium bg-white/5 text-[#8A8A99] hover:bg-red-500/10 hover:text-red-400 border border-[#2A2A35] hover:border-red-500/30 transition-colors",children:"Uninstall"})}),r.jsx(Qs,{children:r.jsxs(Xs,{side:"top",align:"end",sideOffset:6,className:ye("z-50 bg-[#1C1C24] border border-[#2A2A35] rounded-xl p-4 shadow-2xl",t?"w-64":"w-56"),children:[r.jsx("p",{className:"text-[12px] text-[#C8C8D4] mb-3 leading-relaxed",children:t?"Uninstall from agents, or remove entirely?":"This will remove the skill from all agents. Continue?"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{onClick:()=>s(!1),className:"flex-1 py-1.5 rounded-lg text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] border border-[#2A2A35] hover:border-[#3A3A45] transition-colors",children:"Cancel"}),r.jsx("button",{onClick:()=>{e(),s(!1)},className:"flex-1 py-1.5 rounded-lg text-[12px] text-amber-400 hover:text-amber-300 bg-amber-500/10 hover:bg-amber-500/20 border border-amber-500/30 transition-colors",children:"Uninstall"}),t&&r.jsxs("button",{onClick:()=>{t(),s(!1)},className:"py-1.5 px-2.5 rounded-lg text-[12px] text-red-400 hover:text-red-300 bg-red-500/10 hover:bg-red-500/20 border border-red-500/30 transition-colors flex items-center gap-1",children:[r.jsx(Dn,{className:"w-3 h-3"}),"Remove"]})]}),r.jsx(oa,{className:"fill-[#2A2A35]"})]})})]})}function kRe({skill:e,isInstalled:t,onInstall:n,onUninstall:s,onRemove:i,onEdit:a,onDelete:o,onClick:l,selected:c,canManage:d=!0}){return r.jsxs(ne.div,{layout:!0,initial:{opacity:0,y:8},animate:{opacity:1,y:0},onClick:l,className:ye("bg-[#16161A] border rounded-2xl p-5 cursor-pointer transition-colors relative overflow-hidden",c?"border-[#6366F1]/50 ring-1 ring-[#6366F1]/20":"border-[#2A2A35] hover:border-[#3A3A45]"),children:[r.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx(yW,{provider:e.source==="custom"||e.source==="authored"?"custom":e.provider}),e.requiresApproval&&r.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] font-medium bg-amber-500/10 text-amber-400 border border-amber-500/30",children:[r.jsx(_m,{className:"w-3 h-3"}),"Approval required"]})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[d&&(e.source==="custom"||e.source==="authored")&&a&&r.jsx("button",{onClick:f=>{f.stopPropagation(),a()},className:"w-6 h-6 flex items-center justify-center rounded-md text-[#5A5A6E] hover:text-[#F0F0F5] hover:bg-white/10 transition-colors",children:r.jsx(O5,{className:"w-3 h-3"})}),r.jsxs("span",{className:"text-[10px] text-[#5A5A6E] mt-0.5",children:["v",e.version]})]})]}),r.jsx("h3",{className:"text-[14px] font-semibold text-[#F0F0F5] mb-1",children:e.name}),r.jsx("p",{className:"text-[12px] text-[#6A6A7A] leading-relaxed line-clamp-2 mb-4",children:e.description}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[11px] text-[#5A5A6E]",children:t?"Installed":"Not installed"}),d&&r.jsxs("div",{className:"flex items-center gap-2",onClick:f=>f.stopPropagation(),children:[(e.source==="custom"||e.source==="authored")&&o&&r.jsx(nO,{onConfirm:o}),t?e.source!=="custom"&&r.jsx(nO,{onConfirm:s,onRemove:i}):r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:n,className:"px-3 py-1.5 rounded-lg text-[12px] font-medium bg-[#6366F1]/10 text-[#6366F1] hover:bg-[#6366F1]/20 border border-[#6366F1]/30 transition-colors",children:"Install"}),i&&r.jsx("button",{onClick:i,className:"w-7 h-7 flex items-center justify-center rounded-lg text-[#5A5A6E] hover:text-red-400 hover:bg-red-500/10 border border-[#2A2A35] hover:border-red-500/30 transition-colors",children:r.jsx(Dn,{className:"w-3 h-3"})})]})]})]})]})}function ERe({agent:e,skillId:t,agentSkill:n}){const s=L.useUtils(),i=L.skills.toggleAgentSkill.useMutation({onSuccess:()=>{s.skills.getAgentSkills.invalidate()}});return r.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-[#2A2A35] last:border-0",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-base flex-shrink-0",style:{backgroundColor:`${e.color}26`},children:e.emoji}),r.jsxs("div",{children:[r.jsx("p",{className:"text-[13px] font-medium text-[#F0F0F5]",children:e.name}),r.jsx("p",{className:"text-[11px] text-[#8A8A99]",children:e.role})]})]}),r.jsx(Sh,{checked:n?.enabled??!1,onCheckedChange:a=>i.mutate({agentId:e.id,skillId:t,enabled:a}),className:"relative inline-flex h-5 w-9 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 focus:outline-none data-[state=checked]:bg-[#6366F1] data-[state=unchecked]:bg-[#2A2A35] disabled:opacity-40 disabled:cursor-not-allowed",children:r.jsx(Ch,{className:"pointer-events-none inline-block h-4 w-4 transform rounded-full bg-white shadow-lg transition duration-200 data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"})})]})}function FRe(e,t){const n=e.map(s=>L.skills.getAgentSkills.useQuery({agentId:s.id}));return e.map((s,i)=>({agent:s,agentSkill:n[i].data?.find(a=>a.skillId===t)}))}function TRe({varName:e}){const t=L.useUtils(),{data:n=[]}=L.settings.getEnvVars.useQuery(),{data:s=[]}=L.secrets.listKeys.useQuery(),{data:i=[]}=L.settings.getKnownKeys.useQuery(),a=i.find(k=>k.key===e)?.kind,o=a===void 0||a==="secret",l=L.settings.setEnvVar.useMutation({onSuccess:()=>{t.settings.getEnvVars.invalidate()}}),c=L.settings.deleteEnvVar.useMutation({onSuccess:()=>{t.settings.getEnvVars.invalidate()}}),d=L.secrets.set.useMutation({onSuccess:()=>{t.secrets.listKeys.invalidate(),t.secrets.list.invalidate()}}),f=n.find(k=>k.key===e),p=s.includes(e),m=!!f||p,[g,b]=y.useState(!1),[_,w]=y.useState(""),[A,S]=y.useState(!1);function C(){const k=_.trim();k&&(o?(d.mutate({key:e,value:k}),f&&c.mutate({key:e})):l.mutate({key:e,value:k}),b(!1),w(""))}const E=l.isPending||d.isPending;return r.jsxs("div",{className:"py-3 border-b border-[#2A2A35] last:border-0",children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("span",{className:"text-[12px] font-mono text-[#C8C8D4]",children:e}),m?r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-[#10B981]",children:[r.jsx(Fe,{className:"w-3 h-3"}),"Configured"]}):r.jsx("span",{className:"text-[11px] text-[#F87171]",children:"Missing"})]}),g?r.jsxs("div",{className:"flex gap-2 mt-2",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx("input",{type:A?"text":"password",value:_,onChange:k=>w(k.target.value),onKeyDown:k=>{k.key==="Enter"&&C()},placeholder:`Enter ${e}...`,autoFocus:!0,className:"w-full bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-1.5 pr-8 text-[12px] text-[#F0F0F5] placeholder-[#5A5A6E] outline-none focus:border-[#6366F1]/60 transition-colors font-mono"}),r.jsx("button",{onClick:()=>S(!A),className:"absolute right-2 top-1/2 -translate-y-1/2 text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:A?r.jsx(R5,{className:"w-3.5 h-3.5"}):r.jsx(xv,{className:"w-3.5 h-3.5"})})]}),r.jsx("button",{onClick:C,disabled:!_.trim()||E,className:"px-3 py-1.5 rounded-lg text-[12px] font-medium bg-[#6366F1]/10 text-[#6366F1] hover:bg-[#6366F1]/20 border border-[#6366F1]/30 transition-colors disabled:opacity-40",children:"Save"}),r.jsx("button",{onClick:()=>{b(!1),w("")},className:"px-2 py-1.5 rounded-lg text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] transition-colors",children:r.jsx(Te,{className:"w-3.5 h-3.5"})})]}):r.jsx("button",{onClick:()=>b(!0),className:"text-[11px] font-medium text-[#6366F1] hover:text-[#818CF8] transition-colors mt-1",children:m?"Update":"Set value"})]})}function MRe({skill:e,agents:t,onClose:n}){const[s,i]=y.useState("info"),a=L.useUtils(),o=FRe(t,e.id),l=L.skills.toggleAgentSkill.useMutation({onMutate:async({agentId:m,skillId:g,enabled:b})=>{await a.skills.getAgentSkills.cancel({agentId:m});const _=a.skills.getAgentSkills.getData({agentId:m});return a.skills.getAgentSkills.setData({agentId:m},w=>w?.map(A=>A.agentId===m&&A.skillId===g?{...A,enabled:b}:A)),{prev:_}},onError:(m,{agentId:g},b)=>{b?.prev&&a.skills.getAgentSkills.setData({agentId:g},b.prev)}}),{data:c=[]}=L.skills.getSkillEnvVars.useQuery({skillId:e.id}),{data:d}=L.skills.getSkillContent.useQuery({skillId:e.id}),f=o.length>0&&o.every(m=>m.agentSkill?.enabled);function p(){const m=!f;o.forEach(({agent:g})=>{l.mutate({agentId:g.id,skillId:e.id,enabled:m})})}return r.jsxs(r.Fragment,{children:[r.jsx(ne.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-40",style:{backdropFilter:"blur(2px)",backgroundColor:"rgba(0,0,0,0.25)"},onClick:n}),r.jsxs(ne.div,{initial:{x:"100%",opacity:0},animate:{x:0,opacity:1},exit:{x:"100%",opacity:0},transition:{duration:.3,ease:[.16,1,.3,1]},className:"fixed right-0 top-0 h-screen w-[380px] bg-[#13131A] border-l border-[#2A2A35] flex flex-col z-50 shadow-2xl",children:[r.jsxs("div",{className:"px-5 py-4 border-b border-[#2A2A35] flex items-center justify-between flex-shrink-0",children:[r.jsxs("div",{children:[r.jsx("div",{className:"mb-0.5",children:r.jsx(yW,{provider:e.provider})}),r.jsx("p",{className:"text-[15px] font-semibold text-[#F0F0F5] mt-1",children:e.name})]}),r.jsx("button",{onClick:n,className:"w-7 h-7 flex items-center justify-center rounded-md text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/10 transition-colors",children:r.jsx(Te,{className:"w-4 h-4"})})]}),r.jsxs("div",{className:"flex border-b border-[#2A2A35] flex-shrink-0",children:[r.jsx("button",{onClick:()=>i("info"),className:ye("flex-1 py-2.5 text-[12px] font-medium transition-colors border-b-2 -mb-px",s==="info"?"text-[#F0F0F5] border-[#6366F1]":"text-[#8A8A99] border-transparent hover:text-[#C8C8D4]"),children:"Info"}),r.jsx("button",{onClick:()=>i("agents"),className:ye("flex-1 py-2.5 text-[12px] font-medium transition-colors border-b-2 -mb-px",s==="agents"?"text-[#F0F0F5] border-[#6366F1]":"text-[#8A8A99] border-transparent hover:text-[#C8C8D4]"),children:"Agents"}),r.jsxs("button",{onClick:()=>i("keys"),className:ye("flex-1 py-2.5 text-[12px] font-medium transition-colors border-b-2 -mb-px",s==="keys"?"text-[#F0F0F5] border-[#6366F1]":"text-[#8A8A99] border-transparent hover:text-[#C8C8D4]"),children:["Secrets",c.length>0?` (${c.length})`:""]})]}),e.requiresApproval&&s==="agents"&&r.jsxs("div",{className:"mx-5 mt-4 px-3 py-2.5 rounded-lg bg-amber-500/[0.08] border border-amber-500/20 flex items-start gap-2",children:[r.jsx(_m,{className:"w-3.5 h-3.5 text-amber-400 flex-shrink-0 mt-0.5"}),r.jsx("p",{className:"text-[12px] text-amber-300/80 leading-relaxed",children:"Agent will ask for your approval before executing this skill."})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:[s==="info"&&r.jsxs("div",{className:"space-y-5",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-[11px] font-semibold text-[#8A8A99] uppercase tracking-widest mb-2",children:"Description"}),r.jsx("p",{className:"text-[13px] text-[#C8C8D4] leading-relaxed",children:e.description})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mb-1",children:"Version"}),r.jsxs("p",{className:"text-[13px] text-[#F0F0F5] font-mono",children:["v",e.version]})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mb-1",children:"Source"}),r.jsx("p",{className:"text-[13px] text-[#F0F0F5] capitalize",children:e.source})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mb-1",children:"Provider"}),r.jsx("p",{className:"text-[13px] text-[#F0F0F5]",children:e.provider})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mb-1",children:"Endpoint"}),r.jsx("p",{className:"text-[13px] text-[#F0F0F5] font-mono truncate",title:e.endpoint,children:e.endpoint||"—"})]})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mb-1",children:"Slug"}),r.jsx("p",{className:"text-[13px] text-[#F0F0F5] font-mono",children:e.slug})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mb-1",children:"Installed"}),r.jsx("p",{className:"text-[13px] text-[#F0F0F5]",children:new Date(e.installedAt).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})})]}),d?.content&&r.jsxs("div",{children:[r.jsx("p",{className:"text-[11px] font-semibold text-[#8A8A99] uppercase tracking-widest mb-2",children:"SKILL.md"}),r.jsx("pre",{className:"text-[11px] text-[#C8C8D4] font-mono whitespace-pre-wrap leading-relaxed bg-[#0F0F11] border border-[#2A2A35] rounded-lg p-3 max-h-[300px] overflow-y-auto",children:d.content})]})]}),s==="agents"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("p",{className:"text-[11px] font-semibold text-[#8A8A99] uppercase tracking-widest",children:"Agent access"}),o.length>0&&r.jsx("button",{onClick:p,className:"text-[11px] font-medium text-[#6366F1] hover:text-[#818CF8] transition-colors",children:f?"Disable all":"Enable all"})]}),t.length===0&&r.jsx("p",{className:"text-[13px] text-[#8A8A99] italic",children:"No agents found."}),o.map(({agent:m,agentSkill:g})=>r.jsx(ERe,{agent:m,skillId:e.id,agentSkill:g},m.id))]}),s==="keys"&&r.jsx(r.Fragment,{children:c.length===0?r.jsx("p",{className:"text-[13px] text-[#8A8A99] italic",children:"This skill has no required secrets."}):c.map(m=>r.jsx(TRe,{varName:m},m))})]})]})]})}function RRe(e){const t=e.map(s=>L.skills.getAgentSkills.useQuery({agentId:s.id}));return new Set(t.flatMap(s=>(s.data??[]).map(i=>i.skillId)))}function DRe({skills:e,agents:t,selectedSkillId:n,onInstall:s,onUninstall:i,onRemove:a,onSelect:o,onEditCustom:l,onDeleteCustom:c,canManage:d=!0}){const f=RRe(t);return r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:e.map(p=>r.jsx(kRe,{skill:p,isInstalled:f.has(p.id),onInstall:()=>s(p.id),onUninstall:()=>i(p.id),onRemove:p.source!=="custom"&&p.source!=="authored"?()=>a(p.id):void 0,onEdit:p.source==="custom"||p.source==="authored"?()=>l(p):void 0,onDelete:p.source==="custom"||p.source==="authored"?()=>c(p.id):void 0,onClick:()=>o(n===p.id?null:p),selected:n===p.id,canManage:d},p.id))})}function ORe({result:e,onClose:t,onInstall:n,inspectData:s}){const{data:i,isLoading:a,isError:o}=L.skills.getClawHubSkillContent.useQuery({slug:e.slug},{staleTime:1/0}),l=i?.content?.includes("shell://")||i?.content?.includes("shell_exec")||i?.content?.includes("exec:"),[c,d]=y.useState(!1),f=!a&&!o&&(!l||c);return r.jsx(ji,{open:!0,onOpenChange:p=>{p||t()},children:r.jsxs(Ni,{children:[r.jsx(ir,{className:"fixed inset-0 bg-black/60 z-40"}),r.jsxs(ki,{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[640px] max-h-[80vh] bg-[#1C1C24] border border-[#2A2A35] rounded-xl shadow-2xl z-50 flex flex-col",children:[r.jsxs("div",{className:"px-5 py-4 border-b border-[#2A2A35] flex items-center justify-between flex-shrink-0",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[r.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-md text-[11px] font-medium",style:{backgroundColor:"#8B5CF620",color:"#8B5CF6",border:"1px solid #8B5CF640"},children:e.publisher||"Unknown publisher"}),i?.hasSecurityWarning&&r.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] font-medium bg-amber-500/10 text-amber-400 border border-amber-500/30",children:[r.jsx(_m,{className:"w-3 h-3"}),"Network activity detected"]})]}),r.jsx(nr,{className:"text-[15px] font-semibold text-[#F0F0F5]",children:e.displayName}),r.jsxs("div",{className:"flex items-center gap-3 mt-1.5",children:[s?.downloads!=null&&r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-[#5A5A6E]",children:[r.jsx(nu,{className:"w-3 h-3"}),s.downloads.toLocaleString()]}),s?.stars!=null&&s.stars>0&&r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-[#5A5A6E]",children:[r.jsx(Ire,{className:"w-3 h-3"}),s.stars]}),e.version&&r.jsxs("span",{className:"text-[11px] text-[#5A5A6E]",children:["v",e.version]}),!s?.downloads&&!s?.stars&&r.jsx("span",{className:"text-[10px] text-[#5A5A6E] italic",children:"Unknown — review SKILL.md before installing"})]})]}),r.jsx(Gs,{asChild:!0,children:r.jsx("button",{className:"w-7 h-7 flex items-center justify-center rounded-md text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/10 transition-colors",children:r.jsx(Te,{className:"w-4 h-4"})})})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4 min-h-0",children:[a&&r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx("div",{className:"w-5 h-5 border-2 border-[#6366F1]/30 border-t-[#6366F1] rounded-full animate-spin"})}),o&&r.jsx("p",{className:"text-[13px] text-red-400",children:"Could not load SKILL.md — check your internet connection."}),i&&r.jsx("pre",{className:"text-[12px] text-[#C8C8D4] font-mono whitespace-pre-wrap leading-relaxed",children:i.content})]}),l&&!c&&r.jsxs("div",{className:"mx-5 mb-3 p-3 rounded-lg bg-red-500/[0.08] border border-red-500/30 flex items-start gap-2.5",children:[r.jsx(Ti,{className:"w-4 h-4 text-red-400 flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-[12px] text-red-300 leading-relaxed mb-2",children:"This skill will execute commands on your machine. Only install if you trust the publisher."}),r.jsx("button",{onClick:()=>d(!0),className:"px-3 py-1 rounded-md text-[11px] font-medium bg-red-500/20 text-red-300 hover:bg-red-500/30 border border-red-500/30 transition-colors",children:"I understand the risks"})]})]}),r.jsxs("div",{className:"px-5 py-3 border-t border-[#2A2A35] flex items-center justify-between flex-shrink-0",children:[r.jsx("p",{className:"text-[12px] text-[#8A8A99]",children:"Review the skill before installing."}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Gs,{asChild:!0,children:r.jsx("button",{className:"px-3 py-1.5 rounded-lg text-[13px] text-[#8A8A99] hover:text-[#F0F0F5] border border-[#2A2A35] hover:border-[#3A3A45] transition-colors",children:"Cancel"})}),r.jsxs("button",{onClick:n,disabled:!f,className:"flex items-center gap-1.5 px-4 py-1.5 rounded-lg bg-[#8B5CF6] text-white text-[13px] font-medium hover:bg-[#7C3AED] transition-colors disabled:opacity-40 disabled:pointer-events-none",children:[r.jsx(nu,{className:"w-3.5 h-3.5"}),"Install"]})]})]})]})]})})}function PRe({result:e,onReviewInstall:t}){return r.jsxs(ne.div,{layout:!0,initial:{opacity:0,y:8},animate:{opacity:1,y:0},className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-5 hover:border-[#3A3A45] transition-colors",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[r.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[r.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-md text-[11px] font-medium",style:{backgroundColor:"#8B5CF620",color:"#8B5CF6",border:"1px solid #8B5CF640"},children:e.publisher}),e.hasSecurityWarning&&r.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium bg-amber-500/10 text-amber-400 border border-amber-500/30",children:[r.jsx(_m,{className:"w-2.5 h-2.5"}),"Network"]}),e.source==="github"&&r.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-white/5 text-[#5A5A6E] border border-[#2A2A35]",children:"archive"})]}),e.installed&&r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-[#10B981] flex-shrink-0",children:[r.jsx(sa,{className:"w-3 h-3"}),"Installed"]})]}),r.jsx("h3",{className:"text-[14px] font-semibold text-[#F0F0F5] mb-1",children:e.displayName}),r.jsx("p",{className:"text-[12px] text-[#6A6A7A] leading-relaxed line-clamp-2 mb-4",children:e.summary||e.slug}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[11px] text-[#5A5A6E] font-mono",children:e.slug}),e.installed?r.jsx("span",{className:"px-3 py-1.5 rounded-lg text-[12px] font-medium text-[#10B981] bg-[#10B981]/10 border border-[#10B981]/30",children:"Installed"}):r.jsxs("button",{onClick:()=>t(e),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[12px] font-medium bg-[#8B5CF6]/10 text-[#8B5CF6] hover:bg-[#8B5CF6]/20 border border-[#8B5CF6]/30 transition-colors",children:[r.jsx(cs,{className:"w-3 h-3"}),"Review & Install"]})]})]})}function IRe({requiredEnvVars:e,requiredBins:t,skillName:n,hasSecurityWarning:s,onClose:i}){return y.useEffect(()=>{const a=setTimeout(i,8e3);return()=>clearTimeout(a)},[i]),r.jsxs(ne.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},exit:{opacity:0,y:16},className:"fixed bottom-6 right-6 z-50 w-[380px] bg-[#1C1C24] border border-[#2A2A35] rounded-xl shadow-2xl p-4",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(sa,{className:"w-4 h-4 text-[#10B981] flex-shrink-0"}),r.jsxs("span",{className:"text-[13px] font-semibold text-[#F0F0F5]",children:[n," installed"]})]}),r.jsx("button",{onClick:i,className:"text-[#8A8A99] hover:text-[#F0F0F5] transition-colors",children:r.jsx(Te,{className:"w-4 h-4"})})]}),e.length>0&&r.jsxs("div",{className:"mb-2 p-2.5 rounded-lg bg-amber-500/[0.08] border border-amber-500/20 flex items-start gap-2",children:[r.jsx(Rs,{className:"w-3.5 h-3.5 text-amber-400 flex-shrink-0 mt-0.5"}),r.jsx("div",{children:r.jsxs("p",{className:"text-[12px] text-amber-300/80 leading-relaxed",children:["Requires ",e.join(", "),"."," ",r.jsx(gn,{to:"/settings?tab=secrets",onClick:i,className:"underline hover:text-amber-300 transition-colors",children:"Configure in Settings → Secrets"})]})})]}),t.length>0&&r.jsx("div",{className:"p-2.5 rounded-lg bg-blue-500/[0.08] border border-blue-500/20",children:r.jsxs("p",{className:"text-[12px] text-blue-300/80 leading-relaxed",children:["Requires: ",r.jsx("span",{className:"font-mono",children:t.join(", ")})]})}),s&&r.jsxs("div",{className:"p-2.5 rounded-lg bg-amber-500/[0.08] border border-amber-500/20 flex items-start gap-2",children:[r.jsx(_m,{className:"w-3.5 h-3.5 text-amber-400 flex-shrink-0 mt-0.5"}),r.jsx("p",{className:"text-[12px] text-amber-300/80 leading-relaxed",children:"This skill contains network activity patterns. Review the SKILL.md before enabling for agents."})]})]})}function LRe({skills:e}){const[t,n]=y.useState(""),[s,i]=y.useState(""),[a,o]=y.useState(null),[l,c]=y.useState(null),d=y.useRef(null),f=L.useUtils(),p=new Set(e.filter(C=>C.source==="clawhub").map(C=>C.slug));function m(C){n(C),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>i(C),300)}const{data:g=[],isLoading:b,isFetching:_}=L.skills.searchClawHub.useQuery({query:s},{enabled:s.length>0,staleTime:5*6e4}),w=g.map(C=>({...C,installed:p.has(C.slug)})),A=L.skills.inspectClawHub.useQuery({slug:a?.slug??""},{enabled:!!a,staleTime:5*6e4}),S=L.skills.installFromClawHub.useMutation({onSuccess:C=>{f.skills.list.invalidate(),f.skills.getAgentSkills.invalidate(),o(null),c({name:C.skill.name,envVars:C.requiredEnvVars,bins:C.requiredBins,hasSecurityWarning:C.hasSecurityWarning})}});return r.jsxs("div",{children:[r.jsxs("div",{className:"relative mb-6",children:[r.jsx(Io,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[#5A5A6E]"}),r.jsx("input",{value:t,onChange:C=>m(C.target.value),placeholder:"Search ClawHub skills...",className:"w-full bg-[#16161A] border border-[#2A2A35] rounded-xl pl-9 pr-4 py-2.5 text-[13px] text-[#F0F0F5] placeholder-[#5A5A6E] outline-none focus:border-[#8B5CF6]/60 transition-colors"}),_&&r.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:r.jsx("div",{className:"w-4 h-4 border-2 border-[#8B5CF6]/30 border-t-[#8B5CF6] rounded-full animate-spin"})})]}),b&&r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3,4,5,6].map(C=>r.jsx("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-5 animate-pulse h-[180px]"},C))}),!b&&w.length===0&&s&&r.jsx("div",{className:"flex flex-col items-center justify-center py-24 text-center",children:r.jsxs("p",{className:"text-[14px] text-[#8A8A99]",children:['No skills found for "',s,'".']})}),!b&&w.length>0&&r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:w.map(C=>r.jsx(PRe,{result:C,onReviewInstall:o},`${C.publisher}/${C.slug}`))}),a&&r.jsx(ORe,{result:{...a,publisher:A.data?.publisher??a.publisher??"",version:A.data?.version,hasSecurityWarning:A.data?.hasSecurityWarning??a.hasSecurityWarning},inspectData:A.data?{downloads:A.data.downloads,stars:A.data.stars,tags:A.data.tags}:void 0,onClose:()=>o(null),onInstall:()=>S.mutate({slug:a.slug,publisher:A.data?.publisher??a.publisher??"",displayName:A.data?.displayName??a.displayName,version:A.data?.version??"1.0.0"})}),r.jsx(Me,{children:l&&r.jsx(IRe,{skillName:l.name,requiredEnvVars:l.envVars,requiredBins:l.bins,hasSecurityWarning:l.hasSecurityWarning,onClose:()=>c(null)})})]})}function BRe(){const[e,t]=y.useState("my-skills"),[n,s]=y.useState(""),[i,a]=y.useState(null),[o,l]=y.useState(!1),[c,d]=y.useState(null),[f,p]=y.useState(!1),[m,g]=y.useState(null),[b,_]=y.useState(!1),{data:w=[]}=Vo(),A=L.useUtils(),S=Uo(),{data:C=[],isLoading:E}=L.skills.list.useQuery(),k=L.skills.installForAllAgents.useMutation({onSuccess:()=>A.skills.getAgentSkills.invalidate()}),T=L.skills.uninstallFromAllAgents.useMutation({onSuccess:()=>{A.skills.getAgentSkills.invalidate(),a(null)}}),F=L.skills.uninstallClawHub.useMutation({onSettled:async()=>{await A.skills.list.invalidate(),await A.skills.getAgentSkills.invalidate(),a(null)}}),M=L.skills.deleteCustom.useMutation({onSuccess:()=>{A.skills.list.invalidate(),A.skills.getAgentSkills.invalidate(),a(null)}});function I(V){V.source==="authored"?(g(V.id),p(!0)):(d(V.id),l(!0))}const R=e==="my-skills"?C.filter(V=>{if(!n.trim())return!0;const K=n.toLowerCase();return V.name.toLowerCase().includes(K)||V.slug.toLowerCase().includes(K)||V.description.toLowerCase().includes(K)}):C,H=e==="clawhub";return r.jsxs("div",{className:"flex-1 overflow-y-auto bg-[#0F0F11]",children:[r.jsxs("div",{className:"max-w-5xl mx-auto px-8 py-10",children:[r.jsxs("div",{className:"mb-8 flex items-start justify-between",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-[22px] font-semibold text-[#F0F0F5]",children:"Skills"}),r.jsx("p",{className:"text-[13px] text-[#8A8A99] mt-0.5",children:"Capabilities your agents can execute. Install a skill to make it available, then assign it per agent."})]}),S&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("button",{onClick:()=>{g(null),p(!0)},className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[12px] font-medium bg-[#6366F1]/10 text-[#6366F1] hover:bg-[#6366F1]/20 border border-[#6366F1]/30 transition-colors",children:[r.jsx(wt,{className:"w-3.5 h-3.5"}),"New Skill"]}),r.jsxs("button",{onClick:()=>_(!0),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[12px] text-[#8A8A99] hover:text-[#C8C8D4] border border-[#2A2A35] hover:border-[#3A3A45] transition-colors",children:[r.jsx(su,{className:"w-3.5 h-3.5"}),"Import"]}),r.jsxs(gn,{to:"/settings?tab=secrets",className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[12px] text-[#8A8A99] hover:text-[#C8C8D4] border border-[#2A2A35] hover:border-[#3A3A45] transition-colors",children:[r.jsx(Eo,{className:"w-3.5 h-3.5"}),"Secrets"]})]})]}),r.jsxs("div",{className:"flex items-center gap-1 mb-6 border-b border-[#2A2A35]",children:[r.jsx("button",{onClick:()=>t("my-skills"),className:ye("px-4 py-2.5 text-[13px] font-medium transition-colors border-b-2 -mb-px",e==="my-skills"?"text-[#F0F0F5] border-[#6366F1]":"text-[#8A8A99] border-transparent hover:text-[#C8C8D4]"),children:"My Skills"}),S&&r.jsx("button",{onClick:()=>t("clawhub"),className:ye("px-4 py-2.5 text-[13px] font-medium transition-colors border-b-2 -mb-px",e==="clawhub"?"text-[#F0F0F5] border-[#8B5CF6]":"text-[#8A8A99] border-transparent hover:text-[#C8C8D4]"),children:"Browse ClawHub"})]}),e==="my-skills"&&r.jsxs("div",{className:"relative mb-6",children:[r.jsx(Io,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[#5A5A6E]"}),r.jsx("input",{value:n,onChange:V=>s(V.target.value),placeholder:"Search skills...",className:"w-full bg-[#16161A] border border-[#2A2A35] rounded-xl pl-9 pr-4 py-2.5 text-[13px] text-[#F0F0F5] placeholder-[#5A5A6E] outline-none focus:border-[#6366F1]/60 transition-colors"})]}),H?r.jsx(LRe,{skills:C}):r.jsxs(r.Fragment,{children:[E&&r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3,4,5,6].map(V=>r.jsx("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-5 animate-pulse h-[180px]"},V))}),!E&&R.length===0&&r.jsx("div",{className:"flex flex-col items-center justify-center py-24 text-center",children:r.jsx("p",{className:"text-[14px] text-[#8A8A99]",children:"No skills for this provider yet."})}),!E&&R.length>0&&r.jsx(DRe,{skills:R,agents:w,selectedSkillId:i?.id??null,onInstall:V=>k.mutate({skillId:V}),onUninstall:V=>T.mutate({skillId:V}),onRemove:async V=>{await F.mutateAsync({skillId:V}).catch(()=>{})},onSelect:S?a:()=>{},onEditCustom:I,onDeleteCustom:V=>M.mutate({skillId:V}),canManage:S})]})]}),r.jsx(Me,{children:S&&i&&r.jsx(MRe,{skill:i,agents:w,onClose:()=>a(null)},i.id)}),r.jsx(Me,{children:S&&o&&r.jsx(yRe,{open:o,onClose:()=>{l(!1),d(null)},editSkillId:c,editSkillSlug:c?C.find(V=>V.id===c)?.slug:void 0})}),S&&r.jsx(wRe,{open:f,onClose:()=>{p(!1),g(null)},editSkillId:m}),r.jsx(Me,{children:S&&b&&r.jsx(CRe,{onClose:()=>_(!1),onSuccess:()=>{A.skills.list.invalidate()}})})]})}const zRe=$o()(gj(e=>({model:"anthropic/claude-sonnet-4-6",setModel:t=>e({model:t})}),{name:"damn-dev-coo"})),Hf="chan_coo",zd="#F59E0B";function $Re(e){try{return JSON.parse(e)}catch{return null}}function VRe(e){try{return JSON.parse(e)}catch{return null}}function URe({messageId:e,trustData:t,decided:n,onApprove:s,onReject:i,isApproving:a,isRejecting:o}){return r.jsxs(ne.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},className:"mx-4 mb-2 rounded-xl border border-[#6366F1]/30 bg-[#6366F1]/5 overflow-hidden",children:[r.jsxs("div",{className:"px-4 py-3 border-b border-[#6366F1]/20",children:[r.jsx("p",{className:"text-[12px] font-semibold text-[#818CF8] uppercase tracking-wide",children:"Trust configuration proposal"}),r.jsxs("p",{className:"text-[11px] text-[#5A5A6E] mt-0.5",children:["Agent: ",r.jsx("span",{className:"text-[#A5A5C5]",children:t.agentId})]})]}),r.jsxs("div",{className:"px-4 py-3 space-y-2",children:[typeof t.autoApprove=="boolean"&&r.jsxs("div",{className:"flex items-center justify-between text-[12px]",children:[r.jsx("span",{className:"text-[#8A8A99]",children:"Auto-approve"}),r.jsx("span",{className:t.autoApprove?"text-[#F87171]":"text-[#34D399]",children:t.autoApprove?"Enable":"Disable"})]}),t.sandboxMode&&r.jsxs("div",{className:"flex items-center justify-between text-[12px]",children:[r.jsx("span",{className:"text-[#8A8A99]",children:"Sandbox"}),r.jsx("span",{className:"text-[#A5A5C5]",children:t.sandboxMode})]}),t.shellAllowlist!==void 0&&r.jsxs("div",{className:"text-[12px]",children:[r.jsx("span",{className:"text-[#8A8A99]",children:"Shell allowlist"}),r.jsx("p",{className:"text-[#A5A5C5] mt-0.5",children:t.shellAllowlist?t.shellAllowlist.join(", "):"unrestricted"})]}),t.mounts&&t.mounts.length>0&&r.jsxs("div",{className:"text-[12px]",children:[r.jsx("span",{className:"text-[#8A8A99]",children:"Mounts"}),t.mounts.map((l,c)=>r.jsxs("p",{className:"text-[#A5A5C5] mt-0.5 font-mono",children:[l.hostPath," → ",l.agentPath]},c))]})]}),n?r.jsx("div",{className:`px-4 py-2.5 text-[12px] font-medium ${n==="approved"?"text-[#34D399] bg-[#10B981]/5":"text-[#F87171] bg-[#EF4444]/5"}`,children:n==="approved"?"✓ Applied":"✗ Rejected"}):r.jsxs("div",{className:"flex border-t border-[#6366F1]/20",children:[r.jsx(ne.button,{whileHover:{backgroundColor:"rgba(16,185,129,0.12)"},whileTap:{scale:.98},onClick:()=>s(e),disabled:a||o,className:"flex-1 py-2.5 text-[12px] font-medium text-[#34D399] border-r border-[#6366F1]/20 transition-colors disabled:opacity-50",children:a?"Applying…":"Apply"}),r.jsx(ne.button,{whileHover:{backgroundColor:"rgba(239,68,68,0.08)"},whileTap:{scale:.98},onClick:()=>i(e),disabled:a||o,className:"flex-1 py-2.5 text-[12px] font-medium text-[#F87171] transition-colors disabled:opacity-50",children:"Reject"})]})]})}function HRe(e){try{const t=JSON.parse(e);return typeof t.agentId=="string"&&typeof t.pattern=="string"&&typeof t.autoApprove=="boolean"&&typeof t.reason=="string"?t:null}catch{return null}}function WRe({messageId:e,rule:t,decided:n,onApprove:s,onReject:i,isPending:a}){return r.jsxs(ne.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},className:"mx-4 mb-2 rounded-xl border border-[#F59E0B]/30 bg-[#F59E0B]/5 overflow-hidden",children:[r.jsxs("div",{className:"px-4 py-3 border-b border-[#F59E0B]/20 flex items-center gap-2",children:[r.jsx(Wl,{className:"w-3.5 h-3.5 text-[#F59E0B] flex-shrink-0"}),r.jsx("p",{className:"text-[12px] font-semibold text-[#FBBF24] uppercase tracking-wide",children:"Delegation rule proposal"})]}),r.jsxs("div",{className:"px-4 py-3 space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between text-[12px]",children:[r.jsx("span",{className:"text-[#8A8A99]",children:"Agent"}),r.jsx("span",{className:"text-[#A5A5C5] font-medium",children:t.agentId})]}),r.jsxs("div",{className:"flex items-center justify-between text-[12px]",children:[r.jsx("span",{className:"text-[#8A8A99]",children:"Pattern"}),r.jsx("code",{className:"text-[#FBBF24] bg-[#F59E0B]/10 px-1.5 py-0.5 rounded text-[11px] font-mono",children:t.pattern})]}),r.jsxs("div",{className:"flex items-center justify-between text-[12px]",children:[r.jsx("span",{className:"text-[#8A8A99]",children:"Auto-approve"}),r.jsx("span",{className:t.autoApprove?"text-[#F87171]":"text-[#34D399]",children:t.autoApprove?"Yes":"No"})]}),r.jsx("p",{className:"text-[12px] text-[#8A8A99] italic leading-relaxed pt-1",children:t.reason})]}),n?r.jsx("div",{className:`px-4 py-2.5 text-[12px] font-medium ${n==="approved"?"text-[#34D399] bg-[#10B981]/5":"text-[#F87171] bg-[#EF4444]/5"}`,children:n==="approved"?"✓ Rule created":"✗ Rejected"}):r.jsxs("div",{className:"flex border-t border-[#F59E0B]/20",children:[r.jsx(ne.button,{whileHover:{backgroundColor:"rgba(16,185,129,0.12)"},whileTap:{scale:.98},onClick:()=>s(e),disabled:a,className:"flex-1 py-2.5 text-[12px] font-medium text-[#34D399] border-r border-[#F59E0B]/20 transition-colors disabled:opacity-50",children:a?"Creating…":"Create Rule"}),r.jsx(ne.button,{whileHover:{backgroundColor:"rgba(239,68,68,0.08)"},whileTap:{scale:.98},onClick:()=>i(e),disabled:a,className:"flex-1 py-2.5 text-[12px] font-medium text-[#F87171] transition-colors disabled:opacity-50",children:"Reject"})]})]})}function qRe({proposal:e,proposalId:t,onApprove:n,onReject:s,isApproving:i,isRejecting:a,decided:o,progressSteps:l,completionResult:c}){const d=an(),[f,p]=y.useState(!1),m=o?!f:f,g=_=>p(o?!_:_),b=e.skillAssignments?.some(_=>_.skills.some(w=>w.includes("approval")));return r.jsxs(ne.div,{initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{type:"spring",stiffness:300,damping:30},className:"mx-4 mb-4 bg-[#1C1C24] border border-[#2A2A35] rounded-xl overflow-hidden",children:[r.jsxs("button",{onClick:()=>g(!m),className:"w-full px-5 py-4 border-b border-[#2A2A35] flex items-center justify-between hover:bg-white/[0.02] transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ia,{className:"w-4 h-4 text-[#F59E0B]"}),r.jsx("span",{className:"text-[14px] font-semibold text-[#F0F0F5]",children:"Workspace Proposal"}),o&&r.jsx("span",{className:ye("text-[11px] px-1.5 py-0.5 rounded font-medium",o==="approved"?"bg-[#10B981]/10 text-[#34D399]":"bg-[#EF4444]/10 text-[#F87171]"),children:o})]}),r.jsx(ft,{className:ye("w-4 h-4 text-[#5A5A6E] transition-transform",m&&"-rotate-90")})]}),!m&&e.agents?.length>0&&r.jsxs("div",{className:"px-5 py-4 border-b border-[#2A2A35]/50",children:[r.jsx("span",{className:"text-[11px] font-semibold text-[#8A8A99] uppercase tracking-widest",children:"Agents to create"}),r.jsx("div",{className:"mt-3 space-y-2.5",children:e.agents.map(_=>r.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg bg-[#13131A] border border-[#2A2A35]",children:[r.jsx("span",{className:"w-8 h-8 rounded-full flex items-center justify-center text-sm flex-shrink-0 mt-0.5",style:{backgroundColor:`${_.color}26`},children:_.emoji}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-baseline gap-2",children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:_.color},children:_.name}),r.jsx("span",{className:"text-[11px] text-[#8A8A99]",children:_.role})]}),r.jsx("p",{className:"text-[12px] text-[#8A8A99] mt-1 line-clamp-2",children:_.soulDescription}),(e.skillAssignments??[]).filter(w=>w.agentName===_.name).map(w=>r.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:w.skills.map(A=>r.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-white/5 border border-[#2A2A35] text-[#C8C8D4]",children:A},A))},w.agentName))]})]},_.name))})]}),!m&&e.channels?.length>0&&r.jsxs("div",{className:"px-5 py-4 border-b border-[#2A2A35]/50",children:[r.jsx("span",{className:"text-[11px] font-semibold text-[#8A8A99] uppercase tracking-widest",children:"Channels to create"}),r.jsx("div",{className:"mt-3 space-y-1.5",children:e.channels.map(_=>r.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-[#13131A] border border-[#2A2A35]",children:[r.jsx("span",{className:"text-[12px] text-[#8A8A99]",children:"#"}),r.jsx("span",{className:"text-[13px] text-[#F0F0F5] font-medium",children:_.name}),r.jsx("span",{className:"text-[11px] text-[#5A5A6E] px-1.5 py-0.5 rounded bg-white/5",children:_.type}),_.description&&r.jsx("span",{className:"text-[11px] text-[#8A8A99] truncate flex-1",children:_.description})]},_.name))})]}),!m&&b&&r.jsxs("div",{className:"px-5 py-3 bg-[#F59E0B]/5 border-b border-[#F59E0B]/10 flex items-center gap-2",children:[r.jsx(ql,{className:"w-3.5 h-3.5 text-[#F59E0B] flex-shrink-0"}),r.jsx("span",{className:"text-[12px] text-[#F59E0B]",children:"Some skills will require your approval before execution"})]}),r.jsx(Me,{mode:"wait",children:!m&&l.length>0&&r.jsx(ne.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},className:"px-5 py-3 border-b border-[#2A2A35]/50 bg-[#13131A]",children:r.jsx("div",{className:"space-y-1.5",children:l.map((_,w)=>r.jsxs(ne.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},className:"flex items-center gap-2 text-[12px]",children:[r.jsx(Fe,{className:"w-3 h-3 text-[#10B981] flex-shrink-0"}),r.jsxs("span",{className:"text-[#8A8A99]",children:[_.step,":"]}),r.jsx("span",{className:"text-[#C8C8D4]",children:_.detail})]},w))})})}),!m&&c&&r.jsxs(ne.div,{initial:{opacity:0},animate:{opacity:1},className:"px-5 py-4 bg-[#10B981]/5 border-b border-[#10B981]/10",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(Fe,{className:"w-4 h-4 text-[#10B981]"}),r.jsx("span",{className:"text-[13px] font-semibold text-[#10B981]",children:"Your team is ready"})]}),r.jsxs("p",{className:"text-[12px] text-[#8A8A99]",children:[c.agentsCreated," agent",c.agentsCreated!==1?"s":""," created,"," ",c.channelsCreated," channel",c.channelsCreated!==1?"s":""," created."]}),c.firstChannelId&&r.jsxs("button",{onClick:()=>d(`/channels/${c.firstChannelId}`),className:"mt-2 flex items-center gap-1.5 text-[12px] font-medium text-[#6366F1] hover:text-[#818CF8] transition-colors",children:["Go to first agent",r.jsx(tu,{className:"w-3 h-3"})]})]}),!m&&!o&&!c&&r.jsxs("div",{className:"px-5 py-4 flex gap-2",children:[r.jsxs("button",{onClick:()=>t&&n(t),disabled:!t||i||a,className:"flex-1 flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg bg-[#10B981]/10 text-[#34D399] border border-[#10B981]/30 text-[13px] font-medium hover:bg-[#10B981]/20 transition-colors disabled:opacity-40 disabled:pointer-events-none",children:[i?r.jsx(Pe,{className:"w-3.5 h-3.5 animate-spin"}):r.jsx(Fe,{className:"w-3.5 h-3.5"}),i?"Creating...":"Approve & Create"]}),r.jsx("button",{onClick:()=>t&&s(t),disabled:!t||i||a,className:"px-4 py-2.5 rounded-lg bg-[#EF4444]/10 text-[#F87171] border border-[#EF4444]/30 text-[13px] font-medium hover:bg-[#EF4444]/20 transition-colors disabled:opacity-40 disabled:pointer-events-none",children:r.jsx(Te,{className:"w-3.5 h-3.5"})})]}),!m&&o==="rejected"&&r.jsx("div",{className:"px-5 py-3 bg-[#EF4444]/5",children:r.jsx("span",{className:"text-[12px] text-[#F87171]",children:"Proposal rejected"})})]})}function GRe({status:e}){return e==="done"?r.jsx(Fe,{className:"w-3.5 h-3.5 text-[#10B981]"}):e==="failed"?r.jsx(Te,{className:"w-3.5 h-3.5 text-[#EF4444]"}):r.jsx(Pe,{className:"w-3.5 h-3.5 text-[#F59E0B] animate-spin"})}function KRe({goal:e,dispatches:t,groupChannelId:n}){const s=an(),i=!!n&&t.every(a=>a.channelId===n);return r.jsxs(ne.div,{initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{type:"spring",stiffness:300,damping:30},className:"mx-4 mb-4 bg-[#1C1C24] border border-[#2A2A35] rounded-xl overflow-hidden",children:[r.jsx("div",{className:"px-5 py-4 border-b border-[#2A2A35]",children:r.jsx("p",{className:"text-[13px] text-[#8A8A99] leading-relaxed",children:e})}),r.jsx("div",{className:"px-5 py-3 space-y-2",children:t.map((a,o)=>r.jsxs(ne.div,{initial:{opacity:0,x:-12},animate:{opacity:1,x:0},transition:{delay:o*.08,duration:.25},className:"flex items-start gap-3 p-3 rounded-lg bg-[#13131A] border border-[#2A2A35]",children:[r.jsx("span",{className:"w-7 h-7 rounded-full bg-[#F59E0B]/15 flex items-center justify-center text-[12px] flex-shrink-0 mt-0.5",children:a.agentName.charAt(0)}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[13px] font-semibold text-[#F0F0F5]",children:a.agentName}),r.jsx(GRe,{status:a.status})]}),r.jsx("p",{className:"text-[12px] text-[#8A8A99] mt-0.5 line-clamp-2",children:a.instruction}),!i&&a.channelId&&r.jsxs("button",{onClick:()=>s(`/channels/${a.channelId}`),className:"mt-1.5 flex items-center gap-1 text-[11px] font-medium text-[#6366F1] hover:text-[#818CF8] transition-colors",children:[r.jsx(tu,{className:"w-3 h-3"}),"View in channel"]})]})]},`${a.agentId}-${o}`))}),r.jsxs("div",{className:"px-5 py-3 border-t border-[#2A2A35]/50 flex items-center justify-between",children:[r.jsxs("span",{className:"text-[12px] text-[#10B981]/80",children:[t.length," task",t.length!==1?"s":""," dispatched",i?" (group)":""]}),n&&r.jsxs("button",{onClick:()=>s(`/channels/${n}`),className:"flex items-center gap-1 text-[11px] font-medium text-[#6366F1] hover:text-[#818CF8] transition-colors",children:[r.jsx(tu,{className:"w-3 h-3"}),"View group channel"]})]})]})}function YRe({message:e,isLast:t,proposalStatuses:n,progressSteps:s,completionResult:i,onApprove:a,onReject:o,isApproving:l,isRejecting:c,onApproveTrust:d,onRejectTrust:f,isTrustApproving:p,isTrustRejecting:m,onApproveDelegation:g,onRejectDelegation:b,isDelegationPending:_,dispatchStatuses:w}){const A=e.sender.type==="human",{stripped:S,proposal:C}=A?{stripped:e.content,proposal:null}:K7(e.content),E=e.metadata?.proposalId,k=e.metadata?.proposalJson,T=k?$Re(k):null,F=E?n[E]:void 0,M=F==="approved"||F==="rejected"?F:null,I=e.metadata?.trustUpdate,R=I?VRe(I):null,H=e.status==="approved"?"approved":e.status==="rejected"?"rejected":null,V=e.metadata?.delegationRule,K=typeof V=="object"?V:typeof V=="string"?HRe(V):null,q=K?e.status==="approved"?"approved":e.status==="rejected"?"rejected":null:null,$=e.metadata?.dispatch,B=w.get(e.id),Y=e.metadata?.nodeSpawnProposalId,U=e.metadata?.nodeSpawnJson;let W=null;if(U)try{const le=JSON.parse(U);typeof le.name=="string"&&typeof le.reason=="string"&&(W={name:le.name,reason:le.reason})}catch{}const O=e.status==="approved"?"approved":e.status==="rejected"?"rejected":null,D=e.metadata?.federationGrantProposalId,Q=e.metadata?.federationGrantJson;let z=null;if(Q)try{const le=JSON.parse(Q);typeof le.nodeName=="string"&&typeof le.grantAgentId=="string"&&typeof le.reason=="string"&&(z={nodeName:le.nodeName,grantAgentId:le.grantAgentId,reason:le.reason})}catch{}const J=e.metadata?.cloudSpawnProposalId,ee=e.metadata?.cloudSpawnJson;let re=null;if(ee)try{const le=JSON.parse(ee);typeof le.name=="string"&&typeof le.provider=="string"&&typeof le.region=="string"&&typeof le.size=="string"&&typeof le.reason=="string"&&(re={name:le.name,provider:le.provider,region:le.region,size:le.size,reason:le.reason})}catch{}const se=(e.metadata?.remoteAgentProposals??[]).map(le=>{try{const ge=JSON.parse(le.json);if(typeof ge.nodeName=="string"&&typeof ge.name=="string"&&typeof ge.emoji=="string"&&typeof ge.color=="string"&&typeof ge.role=="string"&&typeof ge.soul=="string")return{proposalId:le.id,nodeName:ge.nodeName,name:ge.name,emoji:ge.emoji,color:ge.color,role:ge.role,soul:ge.soul}}catch{}return null}).filter(le=>le!==null),ae=(()=>{const le=new Map;for(const ge of se){const je=le.get(ge.nodeName);je?je.push(ge):le.set(ge.nodeName,[ge])}return Array.from(le.entries()).map(([ge,je])=>({nodeName:ge,agents:je}))})();return r.jsxs("div",{children:[r.jsxs(ne.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2},className:ye("flex items-start gap-3 px-4 py-2",A?"":"border-l-[3px] border-l-[#F59E0B]"),children:[r.jsx("div",{className:"flex-shrink-0 mt-0.5",children:A?r.jsx("div",{className:"w-8 h-8 rounded-full bg-gradient-to-br from-[#4A4A5E] to-[#2A2A3E] flex items-center justify-center border border-[#3A3A4E]",children:r.jsx("span",{className:"text-[11px] font-semibold text-[#A5A5C5]",children:"A"})}):r.jsx("div",{className:"w-8 h-8 rounded-full bg-[#F59E0B]/15 flex items-center justify-center",children:r.jsx(Ia,{className:"w-4 h-4 text-[#F59E0B]"})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-baseline gap-2 mb-1",children:[r.jsx("span",{className:ye("text-[13px] font-semibold",A?"text-[#F0F0F5]":"text-[#F59E0B]"),children:A?e.sender.name:"COO"}),r.jsx("span",{className:"text-[11px] text-[#5A5A6E]",children:Ir(e.timestamp)})]}),r.jsx("div",{className:"text-[14px] text-[#C8C8D4] leading-relaxed prose-message",children:r.jsx(Ei,{remarkPlugins:[Fi],children:S})}),C!==null&&r.jsx(G7,{proposal:C,messageId:e.id,metadata:e.metadata}),e.metadata?.skillWriteProposal?r.jsx(Q7,{message:e,proposal:e.metadata.skillWriteProposal}):null,e.metadata?.skillInstallProposal?r.jsx(Y7,{proposal:e.metadata.skillInstallProposal,messageId:e.id,metadata:e.metadata}):null,e.status==="pending_approval"&&!e.metadata?.missionPlan&&!e.metadata?.nodeSpawnProposalId&&se.length===0&&r.jsx(J7,{message:e})]})]}),T&&r.jsx(qRe,{proposal:T,proposalId:E,onApprove:a,onReject:o,isApproving:l,isRejecting:c,decided:M,progressSteps:t?s:[],completionResult:t?i:null}),R&&r.jsx(URe,{messageId:e.id,trustData:R,decided:H,onApprove:d,onReject:f,isApproving:p,isRejecting:m}),K&&r.jsx(WRe,{messageId:e.id,rule:K,decided:q,onApprove:g,onReject:b,isPending:_}),$&&B&&B.length>0&&r.jsx(KRe,{goal:$.goal,dispatches:B}),W&&Y&&r.jsx(XRe,{proposalId:Y,name:W.name,reason:W.reason,decided:O,serverStatus:n[Y]}),ae.map(le=>r.jsx(QRe,{nodeName:le.nodeName,agents:le.agents,serverStatuses:n},le.nodeName)),z&&D&&r.jsx(tDe,{proposalId:D,data:z,serverStatus:n[D]}),re&&J&&r.jsx(nDe,{proposalId:J,data:re,serverStatus:n[J]}),e.metadata?.missionPlan?r.jsx(sDe,{plan:e.metadata.missionPlan,messageId:e.id,decided:e.status==="approved"?"approved":e.status==="rejected"?"rejected":null}):null]})}function QRe({nodeName:e,agents:t,serverStatuses:n}){const s=t.map(F=>{const M=n[F.proposalId];return M==="approved"?"approved":M==="rejected"?"rejected":M==="failed"?"failed":"pending"}),i=s.every(F=>F!=="pending"),a=s.every(F=>F==="rejected"),o=s.some(F=>F==="approved"||F==="failed"),l=i&&a?"rejected":i&&o?"approved":null,c=s.filter(F=>F==="approved").length,d=s.filter(F=>F==="failed").length,[f,p]=y.useState(!1),m=l?!f:f,g=F=>p(l?!F:F),b=L.useUtils(),_=L.coo.approveRemoteAgent.useMutation(),w=L.coo.rejectRemoteAgent.useMutation(),[A,S]=y.useState(null),[C,E]=y.useState(null),k=async()=>{S("approving"),E(null);try{for(const F of t)n[F.proposalId]&&n[F.proposalId]!=="pending"||await _.mutateAsync({proposalId:F.proposalId})}catch(F){E(F instanceof Error?F.message:"Failed to approve one or more agents")}finally{S(null),b.federation.listNodes.invalidate(),b.coo.listProposals.invalidate()}},T=async()=>{S("rejecting"),E(null);try{for(const F of t)n[F.proposalId]&&n[F.proposalId]!=="pending"||await w.mutateAsync({proposalId:F.proposalId})}catch(F){E(F instanceof Error?F.message:"Failed to reject one or more agents")}finally{S(null),b.coo.listProposals.invalidate()}};return r.jsxs(ne.div,{initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{type:"spring",stiffness:300,damping:30},className:"mx-4 mb-4 bg-[#1C1C24] border border-[#2A2A35] rounded-xl overflow-hidden",children:[r.jsxs("button",{onClick:()=>g(!m),className:"w-full px-5 py-4 border-b border-[#2A2A35] flex items-center justify-between hover:bg-white/[0.02] transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx(Mp,{className:"w-4 h-4 text-[#6366F1] flex-shrink-0"}),r.jsx("span",{className:"text-[14px] font-semibold text-[#F0F0F5]",children:"Remote Team Proposal"}),r.jsx("span",{className:"text-[12px] text-[#8A8A99]",children:"on"}),r.jsx("span",{className:"text-[12px] font-mono px-2 py-0.5 rounded bg-[#6366F1]/15 text-[#818CF8] font-semibold",children:e}),l&&r.jsx("span",{className:ye("text-[11px] px-1.5 py-0.5 rounded font-medium",l==="approved"?"bg-[#10B981]/10 text-[#34D399]":"bg-[#EF4444]/10 text-[#F87171]"),children:l})]}),r.jsx(ft,{className:ye("w-4 h-4 text-[#5A5A6E] transition-transform flex-shrink-0",m&&"-rotate-90")})]}),!m&&t.length>0&&r.jsxs("div",{className:"px-5 py-4 border-b border-[#2A2A35]/50",children:[r.jsxs("span",{className:"text-[11px] font-semibold text-[#8A8A99] uppercase tracking-widest",children:["Agents to create on ",r.jsx("span",{className:"text-[#818CF8] font-mono",children:e})]}),r.jsx("div",{className:"mt-3 space-y-2.5",children:t.map((F,M)=>{const I=s[M];return r.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg bg-[#13131A] border border-[#2A2A35]",children:[r.jsx("span",{className:"w-8 h-8 rounded-full flex items-center justify-center text-sm flex-shrink-0 mt-0.5",style:{backgroundColor:`${F.color}26`},children:F.emoji}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-baseline gap-2 flex-wrap",children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:F.color},children:F.name}),r.jsx("span",{className:"text-[11px] text-[#8A8A99]",children:F.role}),I==="approved"&&r.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium bg-[#10B981]/10 text-[#34D399] uppercase tracking-wider",children:"created"}),I==="failed"&&r.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium bg-[#EF4444]/10 text-[#F87171] uppercase tracking-wider",children:"failed"}),I==="rejected"&&r.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium bg-[#8A8A99]/10 text-[#8A8A99] uppercase tracking-wider",children:"rejected"}),I==="pending"&&A==="approving"&&r.jsx(Pe,{className:"w-3 h-3 animate-spin text-[#6366F1]"})]}),r.jsx("p",{className:"text-[12px] text-[#8A8A99] mt-1 line-clamp-2",children:F.soul})]})]},F.proposalId)})})]}),!m&&l==="approved"&&r.jsxs(ne.div,{initial:{opacity:0},animate:{opacity:1},className:"px-5 py-4 bg-[#10B981]/5 border-b border-[#10B981]/10",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx(Fe,{className:"w-4 h-4 text-[#10B981]"}),r.jsxs("span",{className:"text-[13px] font-semibold text-[#10B981]",children:["Remote team ready on ",r.jsx("span",{className:"font-mono",children:e})]})]}),r.jsxs("p",{className:"text-[12px] text-[#8A8A99]",children:[c," agent",c!==1?"s":""," created",d>0?`, ${d} failed`:"",". You can now delegate to them using ",r.jsx("code",{className:"text-[11px] px-1 py-0.5 rounded bg-[#0F0F11] text-[#C8C8D4]",children:"<slug>@"+e})," in delegate blocks."]})]}),!m&&C&&r.jsxs("div",{className:"px-5 py-3 bg-[#EF4444]/5 border-b border-[#EF4444]/20 flex items-start gap-2 text-[12px] text-[#F87171]",children:[r.jsx("span",{className:"mt-0.5",children:"⚠"}),r.jsx("span",{className:"break-all",children:C})]}),!m&&!l&&r.jsxs("div",{className:"px-5 py-4 flex gap-2",children:[r.jsxs("button",{onClick:k,disabled:A!==null,className:"flex-1 flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg bg-[#10B981]/10 text-[#34D399] border border-[#10B981]/30 text-[13px] font-medium hover:bg-[#10B981]/20 transition-colors disabled:opacity-40 disabled:pointer-events-none",children:[A==="approving"?r.jsx(Pe,{className:"w-3.5 h-3.5 animate-spin"}):r.jsx(Fe,{className:"w-3.5 h-3.5"}),A==="approving"?`Creating ${c+d+1}/${t.length}…`:`Approve & Create ${t.length>1?`all ${t.length}`:""}`]}),r.jsx("button",{onClick:T,disabled:A!==null,className:"px-4 py-2.5 rounded-lg bg-[#EF4444]/10 text-[#F87171] border border-[#EF4444]/30 text-[13px] font-medium hover:bg-[#EF4444]/20 transition-colors disabled:opacity-40 disabled:pointer-events-none",children:A==="rejecting"?r.jsx(Pe,{className:"w-3.5 h-3.5 animate-spin"}):r.jsx(Te,{className:"w-3.5 h-3.5"})})]}),!m&&l==="rejected"&&r.jsx("div",{className:"px-5 py-3 bg-[#EF4444]/5",children:r.jsx("span",{className:"text-[12px] text-[#F87171]",children:"Remote team proposal rejected"})})]})}function XRe({proposalId:e,name:t,reason:n,decided:s,serverStatus:i}){const[a,o]=y.useState(null),c=a??(i==="approved"||i==="failed"?"approved":i==="rejected"?"rejected":null)??s,[d,f]=y.useState(!1),p=c?!d:d,m=C=>f(c?!C:C),g=L.useUtils(),b=L.coo.approveNodeSpawn.useMutation({onSuccess:()=>{o("approved"),g.federation.listNodes.invalidate(),g.coo.listProposals.invalidate()}}),_=L.coo.rejectNodeSpawn.useMutation({onSuccess:()=>{o("rejected"),g.coo.listProposals.invalidate()}}),A=L.federation.getSpawnDefaults.useQuery().data?.defaultNodeSpawnPolicy??"coo-only",S=b.isPending||_.isPending;return r.jsxs(ne.div,{initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{type:"spring",stiffness:300,damping:30},className:"mx-4 mb-4 bg-[#1C1C24] border border-[#6366F1]/25 rounded-xl overflow-hidden",children:[r.jsxs("button",{onClick:()=>m(!p),className:"w-full px-5 py-4 border-b border-[#2A2A35] flex items-center justify-between hover:bg-white/[0.02] transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-6 h-6 rounded-lg bg-[#6366F1]/15 flex items-center justify-center",children:r.jsx("span",{className:"text-[13px]",children:"⚡"})}),r.jsx("span",{className:"text-[14px] font-semibold text-[#F0F0F5]",children:"Spawn Isolated Node"}),r.jsx("span",{className:"text-[11px] font-mono px-1.5 py-0.5 rounded bg-[#6366F1]/15 text-[#818CF8]",children:t}),c&&r.jsx("span",{className:ye("text-[11px] px-1.5 py-0.5 rounded font-medium",c==="approved"?"bg-[#10B981]/10 text-[#34D399]":"bg-[#EF4444]/10 text-[#F87171]"),children:c})]}),r.jsx(ft,{className:ye("w-4 h-4 text-[#5A5A6E] transition-transform",p&&"-rotate-90")})]}),!p&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"px-5 py-4 border-b border-[#2A2A35]/50",children:[r.jsx("span",{className:"text-[11px] font-semibold text-[#8A8A99] uppercase tracking-widest",children:"Why"}),r.jsx("p",{className:"mt-2 text-[13px] text-[#C8C8D4] leading-relaxed",children:n})]}),r.jsxs("div",{className:"px-5 py-4 border-b border-[#2A2A35]/50 space-y-2",children:[r.jsx("span",{className:"text-[11px] font-semibold text-[#8A8A99] uppercase tracking-widest",children:"What will happen"}),r.jsxs("div",{className:"space-y-1.5 text-[12px] text-[#8A8A99]",children:[r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("span",{className:"text-[#6366F1] mt-0.5",children:"•"}),r.jsx("span",{children:"A brand-new isolated damn.dev container (backend + OpenClaw) will start on this machine"})]}),r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("span",{className:"text-[#6366F1] mt-0.5",children:"•"}),r.jsxs("span",{children:["Its own SQLite DB and OpenClaw workspace at ",r.jsxs("code",{className:"text-[11px] px-1 py-0.5 rounded bg-[#0F0F11] text-[#C8C8D4]",children:["~/.damn-dev/nodes/",t,"/"]})]})]}),r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("span",{className:"text-[#6366F1] mt-0.5",children:"•"}),r.jsxs("span",{children:["Default delegation policy: ",r.jsx("strong",{className:"text-[#F0F0F5]",children:A})," — adjustable from Settings → Federation"]})]}),r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("span",{className:"text-[#6366F1] mt-0.5",children:"•"}),r.jsxs("span",{children:["Auto-federated: the COO will be able to dispatch to any agents you later create on this node using ",r.jsx("code",{className:"text-[11px] px-1 py-0.5 rounded bg-[#0F0F11] text-[#C8C8D4]",children:"<agent>@"+t})," syntax"]})]})]})]}),b.isError&&r.jsxs("div",{className:"px-5 py-3 bg-[#EF4444]/5 border-b border-[#EF4444]/20 flex items-start gap-2 text-[12px] text-[#F87171]",children:[r.jsx("span",{className:"mt-0.5",children:"⚠"}),r.jsx("span",{children:b.error?.message})]}),_.isError&&r.jsxs("div",{className:"px-5 py-3 bg-[#EF4444]/5 border-b border-[#EF4444]/20 flex items-start gap-2 text-[12px] text-[#F87171]",children:[r.jsx("span",{className:"mt-0.5",children:"⚠"}),r.jsx("span",{children:_.error?.message})]}),!c&&r.jsxs("div",{className:"px-5 py-4 flex gap-2",children:[r.jsxs("button",{onClick:()=>b.mutate({proposalId:e}),disabled:S,className:"flex-1 flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg bg-[#10B981]/10 text-[#34D399] border border-[#10B981]/30 text-[13px] font-medium hover:bg-[#10B981]/20 transition-colors disabled:opacity-40 disabled:pointer-events-none",children:[b.isPending?r.jsx(Pe,{className:"w-3.5 h-3.5 animate-spin"}):r.jsx(Fe,{className:"w-3.5 h-3.5"}),b.isPending?"Spawning…":"Approve & Spawn"]}),r.jsx("button",{onClick:()=>_.mutate({proposalId:e}),disabled:S,className:"flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg bg-[#2A2A35] text-[#8A8A99] border border-[#2A2A35] text-[13px] font-medium hover:bg-[#3A3A45] transition-colors disabled:opacity-40 disabled:pointer-events-none",children:_.isPending?r.jsx(Pe,{className:"w-3.5 h-3.5 animate-spin"}):"Reject"})]})]})]})}function JRe(){const e=L.useUtils(),{data:t}=L.agents.list.useQuery(),n=t?.find(f=>f.id==="coo"),s=n?.model??n?.defaultModel??"",i=L.agents.update.useMutation({onSuccess:()=>e.agents.list.invalidate()}),a=f=>i.mutate({agentId:"coo",model:f}),o=Up(s),[l,c]=y.useState(""),{groups:d}=Vm();return r.jsxs(ss,{value:s,onValueChange:a,children:[r.jsxs(is,{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[12px] border transition-colors outline-none",style:{color:zd,backgroundColor:`${zd}15`,borderColor:`${zd}40`},children:[r.jsx("span",{className:`text-[10px] px-1 py-0.5 rounded font-medium ${jo[o]}`,children:o}),r.jsx(Ds,{children:ta(s)}),r.jsx(ft,{className:"w-3 h-3 opacity-60"})]}),r.jsx(rs,{children:r.jsxs(as,{position:"popper",sideOffset:6,align:"end",className:"bg-[#1C1C24] border border-[#2A2A35] rounded-lg shadow-xl py-1 min-w-[200px] z-50",children:[r.jsx("div",{className:"px-2 pb-1 mb-1 border-b border-[#2A2A35]",children:r.jsx(ty,{value:l,onChange:c,onSubmit:f=>{a(f),c("")}})}),r.jsx(os,{children:d.map(f=>r.jsxs(Ro,{children:[r.jsxs(Do,{className:"px-3 pt-2 pb-1 text-[10px] font-semibold text-[#5A5A6E] uppercase tracking-widest flex items-center gap-1.5",children:[r.jsx("span",{children:f.label}),r.jsx("span",{className:`px-1 py-0.5 rounded text-[9px] font-medium ${jo[f.tag]}`,children:f.tag})]}),f.models.map(p=>r.jsxs(vn,{value:p.id,className:"flex items-center justify-between px-3 py-1.5 text-[12px] text-[#C8C8D4] cursor-pointer hover:bg-white/5 outline-none data-[highlighted]:bg-white/5",children:[r.jsx(yn,{children:p.label}),r.jsx(ui,{children:r.jsx(Fe,{className:"w-3 h-3 text-[#6366F1]"})})]},p.id))]},f.label))})]})})]})}function ZRe(){if(!Uo())return r.jsx(lm,{to:"/channels/direction",replace:!0});const{data:t,isLoading:n}=L.agents.list.useQuery(void 0,{refetchInterval:a=>a.state.data?.some(l=>l.id==="coo")?!1:3e3}),s=L.onboarding.seedCOO.useMutation(),i=t?.some(a=>a.id==="coo");return n?r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Pe,{className:"w-5 h-5 animate-spin text-[#F59E0B]"})}):i?r.jsx(eDe,{}):r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-8",children:[r.jsx("div",{className:"w-14 h-14 rounded-2xl bg-[#F59E0B]/10 border border-[#F59E0B]/20 flex items-center justify-center mb-4",children:r.jsx(Ia,{className:"w-7 h-7 text-[#F59E0B]"})}),r.jsx("h2",{className:"text-[18px] font-semibold text-[#F0F0F5] mb-2",children:"Your COO"}),r.jsx("p",{className:"text-[14px] text-[#8A8A99] max-w-md leading-relaxed mb-6",children:"The COO is your workspace architect. It can design agent teams, assign skills, and manage your workspace structure."}),r.jsxs("button",{onClick:()=>s.mutate(),disabled:s.isPending,className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-xl text-[13px] font-medium bg-[#F59E0B] text-[#0F0F11] hover:bg-[#FBBF24] disabled:opacity-60 transition-colors",children:[s.isPending&&r.jsx(Pe,{className:"w-3.5 h-3.5 animate-spin"}),"Create COO"]}),s.isError&&r.jsx("p",{className:"mt-3 text-[12px] text-red-400",children:"Failed to create COO. Try again."})]})}function eDe(){const{model:e}=zRe(),[t,n]=y.useState(""),[s,i]=y.useState(!1),[a,o]=y.useState(!1),[l,c]=y.useState([]),[d,f]=y.useState(null),p=y.useRef(null),m=y.useRef(null),[g,b]=y.useState(new Map),_=y.useRef(null),{data:w}=pj("coo");bW(Hf);const A=Je(ee=>ee.messagesByChannel[Hf]),S=y.useMemo(()=>A??[],[A]),C=L.messages.list.useQuery({channelId:Hf,limit:100},{staleTime:0}),E=L.coo.listProposals.useQuery(void 0,{staleTime:5e3}),k=E.data??{};y.useEffect(()=>{C.data&&Je.getState().setMessages(Hf,C.data.messages)},[C.data]);const T=L.coo.getLatestTask.useQuery(void 0,{staleTime:5e3});y.useEffect(()=>{const ee=[...S].reverse().find(le=>le.sender.type==="agent"&&le.metadata?.dispatch);if(!ee)return;_.current=ee.id;const re=T.data;if(re&&re.dispatches.length>0){const le=re.dispatches.map(ge=>({agentId:ge.agentId,agentName:ge.agentName??ge.agentId,channelId:ge.channelId,instruction:ge.instruction,status:ge.status??"sent"}));b(ge=>new Map(ge).set(ee.id,le));return}if(g.has(ee.id))return;const oe=ee.metadata?.dispatch,se=[],ae=oe?.groups??(oe?.group?[oe.group]:[]);for(const le of ae)for(const ge of le.agents)se.push({agentId:ge,agentName:ge,channelId:"",instruction:le.goal,status:"sent"});if(oe?.assignments)for(const le of oe.assignments)se.push({agentId:le.agent,agentName:le.agent,channelId:"",instruction:le.instruction,status:"sent"});se.length>0&&b(le=>new Map(le).set(ee.id,se))},[S,T.data]);const F=L.coo.chat.useMutation(),M=L.coo.approveProposal.useMutation(),I=L.coo.rejectProposal.useMutation(),R=L.coo.approveTrustUpdate.useMutation(),H=L.coo.rejectTrustUpdate.useMutation(),V=L.approvals.decide.useMutation(),K=L.messages.resetSession.useMutation(),q=L.useUtils();y.useEffect(()=>{p.current?.scrollIntoView({behavior:"smooth"})},[S.length,l.length]),y.useEffect(()=>{const ee=new WebSocket("ws://localhost:3001/ws");return ee.onmessage=re=>{try{const oe=JSON.parse(re.data);if(oe.type==="coo.progress"){const se=oe.payload;c(ae=>[...ae,se])}else if(oe.type==="coo.complete"){const se=oe.payload;f(se),B.current()}else if(oe.type==="coo.dispatch.sent"){const se=oe.payload;_.current&&b(ae=>{const le=new Map(ae),ge=le.get(_.current)??[],je=ge.findIndex(Ee=>Ee.agentId===se.agentId);return je>=0?ge[je]={...ge[je],...se,status:"sent"}:ge.push({...se,status:"sent"}),le.set(_.current,[...ge]),le})}else if(oe.type==="coo.dispatch.agent.done"){const se=oe.payload;_.current&&b(ae=>{const le=new Map(ae),ge=le.get(_.current)??[];return le.set(_.current,ge.map(je=>je.agentId===se.agentId?{...je,status:se.status}:je)),le})}}catch{}},()=>ee.close()},[]);const $=y.useRef(!1),B=y.useRef(E.refetch);B.current=E.refetch;const Y=y.useCallback(async()=>{const ee=t.trim();if(!ee||F.isPending||$.current)return;$.current=!0;const re=S.map(oe=>({role:oe.sender.type==="human"?"user":"assistant",content:oe.content}));n(""),m.current&&(m.current.style.height="auto");try{await F.mutateAsync({message:ee,history:re,model:e}),C.refetch(),B.current()}catch{}finally{$.current=!1}},[t,F,S,e]);function U(ee){c([]),M.mutate({proposalId:ee},{onSuccess:()=>{q.agents.list.invalidate(),q.channels.list.invalidate(),E.refetch()}})}function W(ee){I.mutate({proposalId:ee},{onSuccess:()=>{E.refetch()}})}function O(ee){R.mutate({messageId:ee},{onSuccess:()=>{q.agents.getTrust.invalidate(),q.agents.getSandboxOverride.invalidate(),q.agents.getMounts.invalidate(),C.refetch()}})}function D(ee){H.mutate({messageId:ee},{onSuccess:()=>{C.refetch()}})}function Q(ee){V.mutate({messageId:ee,decision:"approved"},{onSuccess:()=>{C.refetch()}})}function z(ee){V.mutate({messageId:ee,decision:"rejected"},{onSuccess:()=>{C.refetch()}})}function J(){K.mutate({channelId:Hf}),c([]),f(null)}return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-[#2A2A35] bg-[#0F0F11] flex-shrink-0",style:{borderLeftColor:zd,borderLeftWidth:3,borderLeftStyle:"solid"},children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{onClick:()=>o(ee=>!ee),className:"w-8 h-8 rounded-full bg-[#F59E0B]/15 flex items-center justify-center transition-opacity hover:opacity-80",children:r.jsx(Ia,{className:"w-4 h-4 text-[#F59E0B]"})}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:()=>o(ee=>!ee),className:"text-[15px] font-semibold text-[#F0F0F5] hover:underline decoration-dashed underline-offset-2 transition-colors",children:"COO"}),r.jsx("span",{className:"text-[11px] text-[#8A8A99] bg-white/5 px-1.5 py-0.5 rounded",children:"Workspace Architect"})]}),r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"relative flex items-center justify-center w-2 h-2",children:r.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:zd,opacity:.5}})}),r.jsx("span",{className:"text-[12px] text-[#8A8A99]",children:"ready"})]})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(JRe,{}),r.jsx(bt,{label:"Reset context",children:r.jsx("button",{onClick:J,className:"w-8 h-8 flex items-center justify-center rounded-md text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/5 transition-colors",children:r.jsx(lh,{className:"w-4 h-4"})})}),r.jsx(bt,{label:a?"Close panel":"Open panel",children:r.jsx("button",{onClick:()=>o(ee=>!ee),className:ye("w-8 h-8 flex items-center justify-center rounded-md transition-colors",a?"text-[#F0F0F5] bg-white/10":"text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/5"),children:a?r.jsx(mL,{className:"w-4 h-4"}):r.jsx(xL,{className:"w-4 h-4"})})})]})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto py-2",children:[S.length===0&&!C.isLoading&&r.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center px-8",children:[r.jsx("div",{className:"w-14 h-14 rounded-2xl bg-[#F59E0B]/10 border border-[#F59E0B]/20 flex items-center justify-center mb-4",children:r.jsx(Ia,{className:"w-7 h-7 text-[#F59E0B]"})}),r.jsx("h2",{className:"text-[18px] font-semibold text-[#F0F0F5] mb-2",children:"Talk to your COO"}),r.jsx("p",{className:"text-[14px] text-[#8A8A99] max-w-md leading-relaxed",children:"Design your team, dispatch tasks, manage skills, update trust settings — all through natural conversation."})]}),r.jsx(Me,{initial:!1,children:S.map((ee,re)=>ee.sender.type==="context_reset"?r.jsxs("div",{className:"flex items-center gap-3 py-2 px-4",children:[r.jsx("div",{className:"flex-1 h-px bg-[#2A2A35]"}),r.jsx("span",{className:"text-[11px] text-[#5A5A6E]",children:"new context"}),r.jsx("div",{className:"flex-1 h-px bg-[#2A2A35]"})]},ee.id):r.jsx(YRe,{message:ee,isLast:re===S.length-1,proposalStatuses:k,progressSteps:l,completionResult:d,onApprove:U,onReject:W,isApproving:M.isPending,isRejecting:I.isPending,onApproveTrust:O,onRejectTrust:D,isTrustApproving:R.isPending,isTrustRejecting:H.isPending,onApproveDelegation:Q,onRejectDelegation:z,isDelegationPending:V.isPending,dispatchStatuses:g},ee.id))}),F.isPending&&r.jsxs("div",{className:"flex items-start gap-3 px-4 py-2 border-l-[3px] border-l-[#F59E0B]",children:[r.jsx("div",{className:"w-8 h-8 rounded-full bg-[#F59E0B]/15 flex items-center justify-center flex-shrink-0",children:r.jsx(Ia,{className:"w-4 h-4 text-[#F59E0B]"})}),r.jsx("div",{className:"flex items-center gap-1 pt-3",children:[0,1,2].map(ee=>r.jsx(ne.span,{className:"w-1.5 h-1.5 rounded-full bg-[#F59E0B]",animate:{opacity:[.3,1,.3],scale:[.8,1.1,.8]},transition:{duration:1.4,repeat:1/0,delay:ee*.2,ease:"easeInOut"}},ee))})]}),r.jsx("div",{ref:p,className:"h-4"})]}),r.jsxs("div",{className:"px-4 pb-4 pt-2 flex-shrink-0",children:[r.jsxs("div",{className:"flex items-end gap-2 bg-[#1C1C21] border rounded-xl px-3 py-2.5 transition-colors duration-150",style:{borderColor:s?"#F59E0B60":"#2A2A35",boxShadow:s?"0 0 0 1px #F59E0B30":void 0},children:[r.jsx("textarea",{ref:m,value:t,onChange:ee=>n(ee.target.value),onKeyDown:ee=>{ee.key==="Enter"&&!ee.shiftKey&&(ee.preventDefault(),Y())},onFocus:()=>i(!0),onBlur:()=>i(!1),placeholder:"Talk to your COO...",disabled:F.isPending,rows:1,className:"flex-1 bg-transparent text-[14px] text-[#F0F0F5] placeholder:text-[#8A8A99]/60 resize-none outline-none leading-relaxed max-h-[120px] overflow-y-auto disabled:opacity-50",style:{minHeight:"22px"},onInput:ee=>{const re=ee.currentTarget;re.style.height="auto",re.style.height=`${Math.min(re.scrollHeight,120)}px`}}),r.jsx("button",{onClick:()=>{Y()},disabled:!t.trim()||F.isPending,className:"text-[#8A8A99] hover:text-[#F0F0F5] disabled:opacity-30 transition-colors mb-0.5 flex-shrink-0",children:r.jsx(Ji,{className:"w-4 h-4"})})]}),r.jsx("p",{className:"text-[11px] text-[#8A8A99]/40 mt-1.5 px-1",children:"Enter to send · Shift+Enter for newline"})]})]}),r.jsx(Me,{children:a&&w&&r.jsx($N,{agent:w,agentColor:zd,onClose:()=>o(!1),onOverrideSet:()=>{}})})]})}function tDe({proposalId:e,data:t,serverStatus:n}){const[s,i]=y.useState(null),o=s??(n==="approved"||n==="failed"?"approved":n==="rejected"?"rejected":null),l=L.useUtils(),c=L.coo.approveFederationGrant.useMutation({onSuccess:()=>{i("approved"),l.federation.listNodes.invalidate(),l.coo.listProposals.invalidate()}}),d=L.coo.rejectFederationGrant.useMutation({onSuccess:()=>{i("rejected"),l.coo.listProposals.invalidate()}}),f=c.isPending||d.isPending;return r.jsxs(ne.div,{initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{type:"spring",stiffness:300,damping:30},className:"mx-4 mb-4 bg-[#1C1C24] border border-[#6366F1]/25 rounded-xl overflow-hidden",children:[r.jsxs("div",{className:"px-5 py-4 border-b border-[#2A2A35] flex items-center gap-2",children:[r.jsx("div",{className:"w-6 h-6 rounded-lg bg-[#6366F1]/15 flex items-center justify-center",children:r.jsx(Wl,{className:"w-3 h-3 text-[#6366F1]"})}),r.jsx("span",{className:"text-[14px] font-semibold text-[#F0F0F5]",children:"Federation Grant"}),r.jsxs("span",{className:"text-[11px] font-mono px-1.5 py-0.5 rounded bg-[#6366F1]/15 text-[#818CF8]",children:[t.grantAgentId," → ",t.nodeName]}),o&&r.jsx("span",{className:ye("text-[11px] px-1.5 py-0.5 rounded font-medium",o==="approved"?"bg-[#10B981]/10 text-[#34D399]":"bg-[#EF4444]/10 text-[#F87171]"),children:o})]}),r.jsx("div",{className:"px-5 py-3 border-b border-[#2A2A35]/50 text-[13px] text-[#C8C8D4] leading-relaxed",children:t.reason}),!o&&r.jsxs("div",{className:"px-5 py-3 flex justify-end gap-2",children:[r.jsx("button",{onClick:()=>d.mutate({proposalId:e}),disabled:f,className:"px-4 py-1.5 rounded text-[12px] text-[#8A8A99] hover:bg-[#2A2A35] transition-colors disabled:opacity-50",children:"Reject"}),r.jsxs("button",{onClick:()=>c.mutate({proposalId:e}),disabled:f,className:"px-4 py-1.5 rounded bg-[#10B981] text-white text-[12px] font-medium hover:bg-[#0EA472] transition-colors disabled:opacity-50 flex items-center gap-1.5",children:[c.isPending?r.jsx(Pe,{className:"w-3 h-3 animate-spin"}):r.jsx(Fe,{className:"w-3 h-3"}),"Grant Access"]})]})]})}function nDe({proposalId:e,data:t,serverStatus:n}){const[s,i]=y.useState(null),o=s??(n==="approved"||n==="failed"?"approved":n==="rejected"?"rejected":null),l=L.useUtils(),c=L.coo.approveCloudSpawn.useMutation({onSuccess:()=>{i("approved"),l.federation.listNodes.invalidate(),l.coo.listProposals.invalidate()}}),d=L.coo.rejectCloudSpawn.useMutation({onSuccess:()=>{i("rejected"),l.coo.listProposals.invalidate()}}),f=c.isPending||d.isPending;return r.jsxs(ne.div,{initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{type:"spring",stiffness:300,damping:30},className:"mx-4 mb-4 bg-[#1C1C24] border border-[#10B981]/25 rounded-xl overflow-hidden",children:[r.jsxs("div",{className:"px-5 py-4 border-b border-[#2A2A35] flex items-center gap-2",children:[r.jsx("div",{className:"w-6 h-6 rounded-lg bg-[#10B981]/15 flex items-center justify-center",children:r.jsx(Xt,{className:"w-3 h-3 text-[#10B981]"})}),r.jsx("span",{className:"text-[14px] font-semibold text-[#F0F0F5]",children:"Spawn Cloud Node"}),r.jsx("span",{className:"text-[11px] font-mono px-1.5 py-0.5 rounded bg-[#10B981]/15 text-[#34D399]",children:t.name}),r.jsxs("span",{className:"text-[10px] text-[#8A8A99]",children:[t.provider," · ",t.region," · ",t.size]}),o&&r.jsx("span",{className:ye("text-[11px] px-1.5 py-0.5 rounded font-medium",o==="approved"?"bg-[#10B981]/10 text-[#34D399]":"bg-[#EF4444]/10 text-[#F87171]"),children:o})]}),r.jsx("div",{className:"px-5 py-3 border-b border-[#2A2A35]/50 text-[13px] text-[#C8C8D4] leading-relaxed",children:t.reason}),!o&&r.jsxs("div",{className:"px-5 py-3 flex items-center justify-between",children:[r.jsx("span",{className:"text-[11px] text-[#10B981]",children:"This will provision a Hetzner VPS (billable)"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{onClick:()=>d.mutate({proposalId:e}),disabled:f,className:"px-4 py-1.5 rounded text-[12px] text-[#8A8A99] hover:bg-[#2A2A35] transition-colors disabled:opacity-50",children:"Reject"}),r.jsxs("button",{onClick:()=>c.mutate({proposalId:e}),disabled:f,className:"px-4 py-1.5 rounded bg-[#10B981] text-white text-[12px] font-medium hover:bg-[#0EA472] transition-colors disabled:opacity-50 flex items-center gap-1.5",children:[c.isPending?r.jsx(Pe,{className:"w-3 h-3 animate-spin"}):r.jsx(Xt,{className:"w-3 h-3"}),"Approve & Provision"]})]})]})]})}function sDe({plan:e,messageId:t,decided:n}){const s=an(),i=L.useUtils(),a=L.coo.approveMissionPlan.useMutation({onSuccess:()=>{i.missions.list.invalidate(),i.missions.stats.invalidate(),s("/missions")}}),o=L.coo.rejectMissionPlan.useMutation(),c={low:"#5A5A6E",normal:"#8A8A99",high:"#F59E0B",critical:"#EF4444"}[e.priority??"normal"]??"#8A8A99";return r.jsxs("div",{className:"mt-3 rounded-lg border border-[#2A2A35] bg-[#13131A] overflow-hidden",children:[r.jsxs("div",{className:"px-4 py-3 border-b border-[#2A2A35]/50 flex items-center gap-3",children:[r.jsx(a0,{className:"w-4 h-4 text-[#6366F1]"}),r.jsx("span",{className:"text-[13px] font-medium text-[#F0F0F5] flex-1",children:e.title}),r.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium",style:{color:c,backgroundColor:c+"15"},children:e.priority??"normal"})]}),e.description&&r.jsx("p",{className:"px-4 py-2 text-[12px] text-[#8A8A99] border-b border-[#2A2A35]/30",children:e.description}),r.jsx("div",{className:"px-4 py-2 space-y-1.5",children:e.tasks.map((d,f)=>r.jsxs("div",{className:"flex items-center gap-2.5 py-1 px-2.5 rounded bg-[#0F0F11]/50",children:[r.jsx("span",{className:"text-[10px] text-[#5A5A6E] font-mono w-4 text-right",children:d.order}),r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#3A3A45]"}),r.jsx("span",{className:"text-[12px] text-[#C8C8D4] flex-1 truncate",children:d.title}),d.agentId&&r.jsx("span",{className:"text-[11px] text-[#8A8A99] bg-[#1E1E28] px-1.5 py-0.5 rounded",children:d.agentId}),d.dependsOn&&d.dependsOn.length>0&&r.jsxs("span",{className:"text-[10px] text-[#5A5A6E]",children:["after ",d.dependsOn.join(", ")]})]},f))}),r.jsx("div",{className:"px-4 py-3 border-t border-[#2A2A35]/50 flex items-center gap-2",children:n==="approved"?r.jsxs("span",{className:"flex items-center gap-1.5 text-[12px] text-[#10B981]",children:[r.jsx(Fe,{className:"w-3.5 h-3.5"})," Mission created"]}):n==="rejected"?r.jsxs("span",{className:"flex items-center gap-1.5 text-[12px] text-[#EF4444]",children:[r.jsx(Te,{className:"w-3.5 h-3.5"})," Plan rejected"]}):r.jsxs(r.Fragment,{children:[r.jsxs("button",{onClick:()=>a.mutate({messageId:t}),disabled:a.isPending,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-[#6366F1] text-white text-[12px] font-medium hover:bg-[#5558E6] transition-colors disabled:opacity-50",children:[a.isPending?r.jsx(Pe,{className:"w-3 h-3 animate-spin"}):r.jsx(Fe,{className:"w-3 h-3"}),"Create Mission"]}),r.jsx("button",{onClick:()=>o.mutate({messageId:t}),disabled:o.isPending,className:"px-3 py-1.5 rounded-md text-[12px] text-[#8A8A99] hover:text-[#EF4444] hover:bg-[#EF4444]/10 transition-colors",children:"Reject"})]})})]})}function _W({text:e}){const[t,n]=y.useState(!1);return r.jsx(bt,{label:t?"Copied":"Copy",children:r.jsx("button",{onClick:()=>{navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)},className:"w-7 h-7 flex items-center justify-center rounded-md text-[#5A5A6E] hover:text-[#8A8A99] hover:bg-white/5 transition-colors",children:t?r.jsx(Fe,{className:"w-3.5 h-3.5 text-[#10B981]"}):r.jsx(Po,{className:"w-3.5 h-3.5"})})})}function fb({code:e,label:t}){return r.jsxs("div",{className:"mt-3",children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("span",{className:"text-[11px] text-[#8A8A99] font-medium",children:t}),r.jsx(_W,{text:e})]}),r.jsx("pre",{className:"bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 text-[11px] font-mono text-[#C8C8D4] overflow-x-auto whitespace-pre-wrap break-all",children:e})]})}function iDe(){const[e,t]=y.useState(!1),{data:n,isLoading:s}=L.mcp.getToken.useQuery(),i=L.useUtils(),a=L.mcp.regenerateToken.useMutation({onSuccess:()=>{i.mcp.getToken.invalidate()}});if(s||!n)return r.jsx("p",{className:"text-[12px] text-[#5A5A6E] py-4",children:"Loading..."});const{token:o,serverPath:l}=n,c=o.slice(0,8)+"•".repeat(24)+o.slice(-8);return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-[14px] font-semibold text-[#F0F0F5] mb-1",children:"MCP Server"}),r.jsx("p",{className:"text-[12px] text-[#8A8A99]",children:"Connect external AI harnesses (Claude Code, Codex, Cursor) to your agent's identity, memory, and governance."})]}),r.jsxs("div",{className:"bg-[#13131A] border border-[#2A2A35] rounded-xl p-4",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(Ti,{className:"w-4 h-4 text-[#6366F1]"}),r.jsx("span",{className:"text-[13px] font-medium text-[#F0F0F5]",children:"Auth Token"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("code",{className:"flex-1 bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 text-[12px] font-mono text-[#8A8A99] overflow-hidden",children:e?o:c}),r.jsx(bt,{label:e?"Hide":"Reveal",children:r.jsx("button",{onClick:()=>t(d=>!d),className:"w-8 h-8 flex items-center justify-center rounded-md text-[#5A5A6E] hover:text-[#8A8A99] hover:bg-white/5 transition-colors",children:e?r.jsx(R5,{className:"w-4 h-4"}):r.jsx(xv,{className:"w-4 h-4"})})}),r.jsx(_W,{text:o}),r.jsx(bt,{label:"Regenerate",children:r.jsx("button",{onClick:()=>a.mutate(),disabled:a.isPending,className:"w-8 h-8 flex items-center justify-center rounded-md text-[#5A5A6E] hover:text-[#F59E0B] hover:bg-[#F59E0B]/10 transition-colors disabled:opacity-50",children:r.jsx(Xi,{className:`w-4 h-4 ${a.isPending?"animate-spin":""}`})})})]}),a.isSuccess&&r.jsx("p",{className:"text-[11px] text-[#F59E0B] mt-2",children:"Token regenerated. Update your harness configs."})]}),r.jsxs("div",{className:"bg-[#13131A] border border-[#2A2A35] rounded-xl p-4",children:[r.jsx("h4",{className:"text-[13px] font-medium text-[#F0F0F5] mb-3",children:"Setup Instructions"}),r.jsx(fb,{label:"Claude Code",code:`claude mcp add damn-dev -e DAMNDEV_TOKEN=${o} -- node ${l}`}),r.jsx(fb,{label:"Codex",code:`codex mcp add damn-dev --env DAMNDEV_TOKEN=${o} -- node ${l}`}),r.jsx(fb,{label:"Cursor (.cursor/mcp.json)",code:JSON.stringify({mcpServers:{"damn-dev":{command:"node",args:[l],env:{DAMNDEV_TOKEN:o}}}},null,2)})]}),r.jsxs("div",{className:"bg-[#13131A] border border-[#2A2A35] rounded-xl p-4",children:[r.jsx("h4",{className:"text-[13px] font-medium text-[#F0F0F5] mb-2",children:"Project Binding"}),r.jsxs("p",{className:"text-[12px] text-[#8A8A99] mb-3",children:["Create a ",r.jsx("code",{className:"text-[#C8C8D4] bg-[#0F0F11] px-1 rounded",children:".damndev.json"})," in your project root to auto-bind an agent:"]}),r.jsx(fb,{label:".damndev.json",code:JSON.stringify({agent:"your-agent-id",workspace:"default"},null,2)})]})]})}function rDe({entry:e,onDelete:t,onSave:n,onMoveToSecrets:s}){const[i,a]=y.useState(!1),[o,l]=y.useState(!1),[c,d]=y.useState(e.value),[f,p]=y.useState(!1);function m(){n(e.key,c.trim()),l(!1),p(!0),setTimeout(()=>p(!1),1500)}return r.jsxs("div",{className:"flex items-start gap-4 py-4 border-b border-[#2A2A35] last:border-0",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("span",{className:"text-[13px] font-medium text-[#F0F0F5]",children:e.key}),e.label!==e.key&&r.jsx("span",{className:"text-[11px] text-[#5A5A6E]",children:e.label}),f&&r.jsxs(ne.span,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0},className:"flex items-center gap-1 text-[11px] text-[#10B981]",children:[r.jsx(Fe,{className:"w-3 h-3"}),"Saved"]})]}),o?r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{autoFocus:!0,type:"text",value:c,onChange:g=>d(g.target.value),onKeyDown:g=>{g.key==="Enter"&&m(),g.key==="Escape"&&(l(!1),d(e.value))},className:"flex-1 bg-[#13131A] border border-[#6366F1]/40 rounded-lg px-3 py-1.5 text-[13px] text-[#F0F0F5] font-mono outline-none focus:border-[#6366F1] transition-colors"}),r.jsx("button",{onClick:m,className:"px-3 py-1.5 rounded-lg bg-[#6366F1] text-white text-[12px] font-medium hover:bg-[#5558E8] transition-colors",children:"Save"}),r.jsx("button",{onClick:()=>{l(!1),d(e.value)},className:"px-3 py-1.5 rounded-lg text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] border border-[#2A2A35] hover:border-[#3A3A45] transition-colors",children:"Cancel"})]}):r.jsx("button",{onClick:()=>l(!0),className:"flex items-center gap-2 group",children:r.jsx("code",{className:"text-[12px] font-mono text-[#8A8A99] group-hover:text-[#C8C8D4] transition-colors",children:i?e.value:e.masked})})]}),e.key==="GITHUB_TOKEN"&&r.jsxs(r.Fragment,{children:[r.jsxs("a",{href:"https://github.com/settings/tokens/new?scopes=repo&description=damn.dev",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 mt-1 text-[11px] text-[#6366F1] hover:text-[#818CF8] transition-colors",children:["Generate a token on GitHub ",r.jsx(cs,{className:"w-3 h-3"})]}),r.jsx("span",{className:"block text-[11px] text-[#8A8A99] mt-0.5",children:"Scopes are pre-filled — just click Generate and paste it here."}),r.jsx("span",{className:"block text-[11px] text-[#8A8A99] mt-0.5",children:"Set expiration to 'No expiration' for uninterrupted access."})]}),e.key==="GITLAB_TOKEN"&&r.jsxs(r.Fragment,{children:[r.jsxs("a",{href:"https://gitlab.com/-/user_settings/personal_access_tokens?name=damn.dev&scopes=api",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 mt-1 text-[11px] text-[#6366F1] hover:text-[#818CF8] transition-colors",children:["Generate a token on GitLab ",r.jsx(cs,{className:"w-3 h-3"})]}),r.jsx("span",{className:"block text-[11px] text-[#8A8A99] mt-0.5",children:"Scopes are pre-filled — just click Create and paste it here."})]}),r.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.misplaced&&s&&r.jsx(bt,{label:"This is a credential — encrypt it in Secrets. The env copy stays in place as a mirror so nothing breaks.",children:r.jsx("button",{onClick:()=>s(e.key),className:"flex items-center gap-1 px-2 h-7 rounded-md text-[11px] font-medium bg-amber-500/10 text-amber-300 hover:bg-amber-500/20 border border-amber-500/20 transition-colors",children:"Encrypt"})}),r.jsx(bt,{label:i?"Hide":"Reveal",children:r.jsx("button",{onClick:()=>a(g=>!g),className:"w-7 h-7 flex items-center justify-center rounded-md text-[#5A5A6E] hover:text-[#8A8A99] hover:bg-white/5 transition-colors",children:i?r.jsx(R5,{className:"w-3.5 h-3.5"}):r.jsx(xv,{className:"w-3.5 h-3.5"})})}),r.jsx(bt,{label:"Delete",children:r.jsx("button",{onClick:()=>t(e.key),className:"w-7 h-7 flex items-center justify-center rounded-md text-[#5A5A6E] hover:text-red-400 hover:bg-red-500/10 transition-colors",children:r.jsx(Dn,{className:"w-3.5 h-3.5"})})})]})]})}function aDe({knownKeys:e,existingKeys:t,onAdd:n,onClose:s}){const[i,a]=y.useState(""),[o,l]=y.useState(""),[c,d]=y.useState(""),f=i==="__custom__",p=f?o.trim():i;function m(){!p||!c.trim()||(n(p,c.trim()),s())}const g=e.filter(b=>!t.includes(b.key));return r.jsxs(ne.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},className:"bg-[#16161A] border border-[#2A2A35] rounded-xl p-5 mb-4",children:[r.jsx("p",{className:"text-[13px] font-medium text-[#F0F0F5] mb-4",children:"Add API Key"}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-[11px] text-[#8A8A99] mb-1.5",children:"Key name"}),r.jsxs(ss,{value:i,onValueChange:a,children:[r.jsxs(is,{className:"flex items-center justify-between w-full bg-[#13131A] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] outline-none focus:border-[#6366F1]/60 transition-colors",children:[r.jsx(Ds,{placeholder:"Select a key..."}),r.jsx(Yl,{children:r.jsx(ft,{className:"w-3.5 h-3.5 text-[#5A5A6E]"})})]}),r.jsx(rs,{children:r.jsx(as,{className:"bg-[#1C1C24] border border-[#2A2A35] rounded-lg shadow-xl z-50 overflow-hidden",children:r.jsxs(os,{className:"p-1",children:[g.map(b=>r.jsx(vn,{value:b.key,className:"flex items-center px-3 py-2 text-[13px] text-[#C8C8D4] rounded-md cursor-pointer hover:bg-white/5 outline-none data-[highlighted]:bg-white/5",children:r.jsx(yn,{children:b.key})},b.key)),r.jsx(vn,{value:"__custom__",className:"flex items-center px-3 py-2 text-[13px] text-[#8A8A99] rounded-md cursor-pointer hover:bg-white/5 outline-none data-[highlighted]:bg-white/5",children:r.jsx(yn,{children:"Custom key..."})})]})})})]})]}),f&&r.jsxs("div",{children:[r.jsx("label",{className:"block text-[11px] text-[#8A8A99] mb-1.5",children:"Custom key name"}),r.jsx("input",{autoFocus:!0,value:o,onChange:b=>l(b.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"")),placeholder:"MY_API_KEY",className:"w-full bg-[#13131A] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] font-mono placeholder-[#5A5A6E] outline-none focus:border-[#6366F1]/60 transition-colors"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-[11px] text-[#8A8A99] mb-1.5",children:"Value"}),r.jsx("input",{value:c,onChange:b=>d(b.target.value),onKeyDown:b=>{b.key==="Enter"&&m()},placeholder:"Paste your key...",type:"password",className:"w-full bg-[#13131A] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] font-mono placeholder-[#5A5A6E] outline-none focus:border-[#6366F1]/60 transition-colors"}),p==="GITHUB_TOKEN"&&r.jsxs(r.Fragment,{children:[r.jsxs("a",{href:"https://github.com/settings/tokens/new?scopes=repo&description=damn.dev",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 mt-1 text-[11px] text-[#6366F1] hover:text-[#818CF8] transition-colors",children:["Generate a token on GitHub ",r.jsx(cs,{className:"w-3 h-3"})]}),r.jsx("span",{className:"block text-[11px] text-[#8A8A99] mt-0.5",children:"Scopes are pre-filled — just click Generate and paste it here."}),r.jsx("span",{className:"block text-[11px] text-[#8A8A99] mt-0.5",children:"Set expiration to 'No expiration' for uninterrupted access."})]}),p==="GITLAB_TOKEN"&&r.jsxs(r.Fragment,{children:[r.jsxs("a",{href:"https://gitlab.com/-/user_settings/personal_access_tokens?name=damn.dev&scopes=api",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 mt-1 text-[11px] text-[#6366F1] hover:text-[#818CF8] transition-colors",children:["Generate a token on GitLab ",r.jsx(cs,{className:"w-3 h-3"})]}),r.jsx("span",{className:"block text-[11px] text-[#8A8A99] mt-0.5",children:"Scopes are pre-filled — just click Create and paste it here."})]})]}),r.jsxs("div",{className:"flex gap-2 pt-1",children:[r.jsx("button",{onClick:m,disabled:!p||!c.trim(),className:"flex-1 px-4 py-2 rounded-lg bg-[#6366F1] text-white text-[13px] font-medium hover:bg-[#5558E8] transition-colors disabled:opacity-40 disabled:pointer-events-none",children:"Add key"}),r.jsx("button",{onClick:s,className:"px-4 py-2 rounded-lg text-[13px] text-[#8A8A99] hover:text-[#F0F0F5] border border-[#2A2A35] hover:border-[#3A3A45] transition-colors",children:"Cancel"})]})]})]})}function wW({onSelect:e}){const{data:t=[],isLoading:n,refetch:s}=L.settings.detectObsidianVaults.useQuery(void 0,{staleTime:1/0,enabled:!1}),[i,a]=y.useState(!1);function o(){s().then(()=>a(!0))}return r.jsx("div",{className:"mt-3",children:i?t.length===0?r.jsx("p",{className:"text-[12px] text-[#5A5A6E]",children:"No Obsidian vaults detected."}):r.jsx("div",{className:"flex flex-wrap gap-2",children:t.map(l=>r.jsx("button",{onClick:()=>e(l.path),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[12px] text-[#8A8A99] hover:text-[#C8C8D4] bg-white/[0.03] border border-[#2A2A35] hover:border-[#3A3A45] transition-colors",children:l.name},l.path))}):r.jsxs("button",{onClick:o,disabled:n,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[12px] text-[#8A8A99] hover:text-[#C8C8D4] border border-[#2A2A35] hover:border-[#3A3A45] transition-colors",children:[r.jsx(lh,{className:`w-3 h-3 ${n?"animate-spin":""}`}),"Detect Obsidian vaults"]})})}function oDe({open:e,onClose:t,onSelect:n}){const[s,i]=y.useState(void 0),{data:a,isLoading:o}=L.settings.listDirectory.useQuery({path:s},{enabled:e}),l=a?.entries??[],c=a?.error,d=s?.split("/").filter(Boolean)??[];function f(g){i(g)}function p(g){const b="/"+d.slice(0,g+1).join("/");i(b)}function m(){s&&(n(s),t())}return r.jsx(ji,{open:e,onOpenChange:g=>{g||t()},children:r.jsxs(Ni,{children:[r.jsx(ir,{className:"fixed inset-0 bg-black/60 z-40"}),r.jsxs(ki,{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[520px] max-h-[70vh] bg-[#1C1C24] border border-[#2A2A35] rounded-xl shadow-2xl z-50 flex flex-col",children:[r.jsxs("div",{className:"px-5 py-4 border-b border-[#2A2A35] flex items-center justify-between flex-shrink-0",children:[r.jsx(nr,{className:"text-[15px] font-semibold text-[#F0F0F5]",children:"Browse folders"}),r.jsx(Gs,{asChild:!0,children:r.jsx("button",{className:"w-7 h-7 flex items-center justify-center rounded-md text-[#8A8A99] hover:text-[#F0F0F5] hover:bg-white/10 transition-colors",children:r.jsx(Te,{className:"w-4 h-4"})})})]}),r.jsxs("div",{className:"px-5 py-2 border-b border-[#2A2A35] flex items-center gap-1 text-[12px] overflow-x-auto flex-shrink-0",children:[r.jsx("button",{onClick:()=>i(void 0),className:"text-[#6366F1] hover:text-[#818CF8] transition-colors flex-shrink-0",children:"Home"}),d.map((g,b)=>r.jsxs("span",{className:"flex items-center gap-1 flex-shrink-0",children:[r.jsx(Jt,{className:"w-3 h-3 text-[#5A5A6E]"}),r.jsx("button",{onClick:()=>p(b),className:"text-[#6366F1] hover:text-[#818CF8] transition-colors",children:g})]},b))]}),s&&r.jsx("div",{className:"px-5 py-1.5 border-b border-[#2A2A35] flex-shrink-0",children:r.jsx("code",{className:"text-[11px] font-mono text-[#5A5A6E]",children:s})}),r.jsx("div",{className:"flex-1 overflow-y-auto px-2 py-2 min-h-[200px]",children:o?r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx(Pe,{className:"w-5 h-5 text-[#6366F1] animate-spin"})}):c&&l.length===0?r.jsx("div",{className:"flex items-center justify-center py-12 text-[12px] text-[#5A5A6E]",children:c}):l.length===0?r.jsx("div",{className:"flex items-center justify-center py-12 text-[12px] text-[#5A5A6E]",children:"No folders found"}):r.jsxs("div",{className:"space-y-0.5",children:[l.map(g=>r.jsxs("button",{onClick:()=>f(g.path),className:"w-full flex items-center gap-2.5 px-3 py-2 rounded-lg text-left hover:bg-white/5 transition-colors group",children:[r.jsx(vm,{className:"w-4 h-4 text-[#6366F1]/70 group-hover:text-[#6366F1] flex-shrink-0"}),r.jsx("span",{className:"text-[13px] text-[#C8C8D4] group-hover:text-[#F0F0F5] truncate",children:g.name})]},g.path)),c&&l.length>0&&r.jsx("p",{className:"text-[11px] text-[#5A5A6E] px-3 pt-2",children:c})]})}),r.jsxs("div",{className:"px-5 py-3 border-t border-[#2A2A35] flex items-center justify-end gap-2 flex-shrink-0",children:[r.jsx(Gs,{asChild:!0,children:r.jsx("button",{className:"px-3 py-1.5 rounded-lg text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] border border-[#2A2A35] hover:border-[#3A3A45] transition-colors",children:"Cancel"})}),r.jsx("button",{onClick:m,disabled:!s,className:"px-3 py-1.5 rounded-lg bg-[#6366F1] text-white text-[12px] font-medium hover:bg-[#5558E8] transition-colors disabled:opacity-40 disabled:pointer-events-none",children:"Select this folder"})]})]})]})})}const sO=[{hostPath:"~/Documents",mountPath:"/host/documents",label:"Documents"},{hostPath:"~/Desktop",mountPath:"/host/desktop",label:"Desktop"},{hostPath:"~/Downloads",mountPath:"/host/downloads",label:"Downloads"},{hostPath:"~/Projects",mountPath:"/host/projects",label:"Projects"}];function lDe(){const[e,t]=y.useState(!1),[n,s]=y.useState(""),[i,a]=y.useState(""),[o,l]=y.useState(""),[c,d]=y.useState(!1),[f,p]=y.useState(!1),[m,g]=y.useState(""),[b,_]=y.useState(!1),[w,A]=y.useState(!1),[S,C]=y.useState(!1),[E,k]=y.useState(""),T=L.useUtils(),{data:F}=L.settings.getVolumeMounts.useQuery(),{data:M}=L.settings.getDockerComposeSnippet.useQuery(),{data:I}=L.settings.getRunMode.useQuery(),R=L.settings.addVolumeMount.useMutation({onSuccess:D=>{if(!D.ok&&D.error){g(D.error);return}T.settings.getVolumeMounts.invalidate(),T.settings.getDockerComposeSnippet.invalidate(),t(!1),s(""),a(""),l(""),g(""),_(!0)}}),H=L.settings.removeVolumeMount.useMutation({onSuccess:()=>{T.settings.getVolumeMounts.invalidate(),T.settings.getDockerComposeSnippet.invalidate(),_(!0)}}),V=L.settings.applyMountsAndRestart.useMutation({onSuccess:D=>{D.success?(_(!1),C(!0),k(!D.containerFound||!D.composeEdited?D.reason:""),setTimeout(()=>C(!1),3e3)):k(D.reason)}}),K=F?.mounts??[],q=I?.backendIsNative??!1,$=M?.snippet??"";function B(D){s(D),g("");const Q=D.split("/").pop()?.toLowerCase().replace(/[^a-z0-9_-]/g,"")??"";Q&&(a(`/host/${Q}`),l(D.split("/").pop()??Q)),t(!0)}function Y(D){s(D),g("");const Q=D.replace(/^~\//,"").split("/").pop()?.toLowerCase().replace(/[^a-z0-9_-]/g,"")??"";Q&&(a(`/host/${Q}`),l(D.replace(/^~\//,"").split("/").pop()??Q))}function U(){!n.trim()||!i.trim()||!o.trim()||(g(""),R.mutate({hostPath:n.trim(),mountPath:i.trim(),label:o.trim()}))}function W(){navigator.clipboard.writeText($.replace(/\\n/g,`
|
|
428
428
|
`)),d(!0),setTimeout(()=>d(!1),1500)}function O(D){K.some(Q=>Q.mountPath===D.mountPath)||R.mutate(D)}return r.jsxs("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-6",children:[r.jsxs("div",{className:"flex items-start justify-between mb-5",children:[r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(bv,{className:"w-4 h-4 text-[#8A8A99] mt-0.5"}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-[15px] font-semibold text-[#F0F0F5]",children:"File Access"}),r.jsx("p",{className:"text-[12px] text-[#5A5A6E] mt-0.5",children:"Expose host directories to agents — both gateway and sandbox containers."}),r.jsx("p",{className:"text-[11px] text-[#3E3E4E] mt-1",children:"Note: file access requires OpenClaw to support allowedRoots (coming soon). Mounts are configured and ready — agents will gain access automatically when OpenClaw enables this feature."})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[q&&r.jsxs("button",{onClick:()=>A(!0),className:"flex items-center gap-1 text-[11px] text-[#6366F1] hover:text-[#818CF8] transition-colors",children:[r.jsx(vm,{className:"w-3 h-3"}),"Browse"]}),r.jsxs("button",{onClick:()=>t(D=>!D),className:"flex items-center gap-1 text-[11px] text-[#6366F1] hover:text-[#818CF8] transition-colors",children:[r.jsx(wt,{className:"w-3 h-3"}),"Add folder"]})]})]}),q&&r.jsx(oDe,{open:w,onClose:()=>A(!1),onSelect:B}),r.jsx(Me,{children:e&&r.jsx(ne.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"mb-4 overflow-hidden",children:r.jsxs("div",{className:"space-y-3 bg-[#13131A] border border-[#2A2A35] rounded-xl p-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-[11px] text-[#8A8A99] mb-1.5",children:"Host path"}),r.jsx("input",{autoFocus:!0,value:n,onChange:D=>Y(D.target.value),placeholder:"/Users/you/Documents",className:"w-full bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] font-mono placeholder-[#5A5A6E] outline-none focus:border-[#6366F1]/60 transition-colors"})]}),r.jsxs("div",{className:"flex gap-3",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"block text-[11px] text-[#8A8A99] mb-1.5",children:"Mount path (in container)"}),r.jsx("input",{value:i,onChange:D=>a(D.target.value),placeholder:"/host/documents",className:"w-full bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] font-mono placeholder-[#5A5A6E] outline-none focus:border-[#6366F1]/60 transition-colors"})]}),r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"block text-[11px] text-[#8A8A99] mb-1.5",children:"Label"}),r.jsx("input",{value:o,onChange:D=>l(D.target.value),onKeyDown:D=>{D.key==="Enter"&&U()},placeholder:"Documents",className:"w-full bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] placeholder-[#5A5A6E] outline-none focus:border-[#6366F1]/60 transition-colors"})]})]}),m&&r.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] text-red-400",children:[r.jsx(Rs,{className:"w-3 h-3"}),m]}),r.jsxs("div",{className:"flex gap-2 pt-1",children:[r.jsx("button",{onClick:U,disabled:!n.trim()||!i.trim()||!o.trim()||R.isPending,className:"px-3 py-1.5 rounded-lg bg-[#6366F1] text-white text-[12px] font-medium hover:bg-[#5558E8] transition-colors disabled:opacity-40 disabled:pointer-events-none",children:"Add"}),r.jsx("button",{onClick:()=>{t(!1),s(""),a(""),l(""),g("")},className:"px-3 py-1.5 rounded-lg text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] border border-[#2A2A35] hover:border-[#3A3A45] transition-colors",children:"Cancel"})]})]})})}),!e&&K.length===0&&r.jsxs("div",{className:"mb-4",children:[r.jsx("p",{className:"text-[12px] text-[#5A5A6E] mb-3",children:"No folders mounted. Quick add:"}),r.jsx("div",{className:"flex flex-wrap gap-2",children:sO.map(D=>r.jsx("button",{onClick:()=>O(D),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[12px] text-[#8A8A99] hover:text-[#C8C8D4] bg-white/[0.03] border border-[#2A2A35] hover:border-[#3A3A45] transition-colors",children:D.label},D.hostPath))})]}),K.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"space-y-1 mb-4",children:K.map(D=>r.jsxs("div",{className:"flex items-center justify-between py-2 px-3 rounded-md bg-white/[0.02] border border-[#2A2A35]",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx("code",{className:"text-[12px] font-mono text-[#C8C8D4] truncate",children:D.hostPath}),r.jsx("span",{className:"text-[11px] text-[#5A5A6E]",children:"→"}),r.jsx("code",{className:"text-[12px] font-mono text-[#8A8A99] truncate",children:D.mountPath}),D.exists?r.jsx("span",{className:"flex items-center gap-1 text-[10px] text-emerald-400 flex-shrink-0",children:r.jsx(Fe,{className:"w-2.5 h-2.5"})}):r.jsx("span",{className:"flex items-center gap-1 text-[10px] text-amber-400 flex-shrink-0",children:r.jsx(Rs,{className:"w-2.5 h-2.5"})})]}),r.jsx(bt,{label:"Remove",children:r.jsx("button",{onClick:()=>H.mutate({hostPath:D.hostPath}),disabled:H.isPending,className:"w-6 h-6 flex items-center justify-center rounded text-[#5A5A6E] hover:text-red-400 hover:bg-red-500/10 transition-colors",children:r.jsx(Dn,{className:"w-3 h-3"})})})]},D.hostPath))}),!e&&r.jsx("div",{className:"flex flex-wrap gap-2 mb-4",children:sO.filter(D=>!K.some(Q=>Q.mountPath===D.mountPath)).map(D=>r.jsxs("button",{onClick:()=>O(D),className:"flex items-center gap-1 px-2 py-1 rounded text-[11px] text-[#5A5A6E] hover:text-[#8A8A99] bg-white/[0.02] border border-[#2A2A35] hover:border-[#3A3A45] transition-colors",children:[r.jsx(wt,{className:"w-2.5 h-2.5"}),D.label]},D.hostPath))}),r.jsxs("div",{className:"border-t border-[#2A2A35] pt-4",children:[b&&r.jsxs("div",{className:"mb-4",children:[r.jsxs(Me,{children:[S&&r.jsxs(ne.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"mb-3 px-3 py-2 rounded-lg bg-emerald-500/10 border border-emerald-500/20 text-[12px] text-emerald-400 flex items-center gap-2",children:[r.jsx(Fe,{className:"w-3 h-3"}),"OpenClaw restarted — agents can now access your files"]}),E&&r.jsxs(ne.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"mb-3 px-3 py-2 rounded-lg bg-amber-500/10 border border-amber-500/20 text-[12px] text-amber-400 flex items-center gap-2",children:[r.jsx(Rs,{className:"w-3 h-3 flex-shrink-0"}),r.jsx("span",{className:"truncate",children:E})]})]}),r.jsx("button",{onClick:()=>V.mutate(),disabled:V.isPending,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-[#6366F1] text-white text-[12px] font-medium hover:bg-[#5558E8] transition-colors disabled:opacity-60",children:V.isPending?r.jsxs(r.Fragment,{children:[r.jsx(Pe,{className:"w-3 h-3 animate-spin"})," Restarting OpenClaw..."]}):r.jsxs(r.Fragment,{children:[r.jsx(Xi,{className:"w-3 h-3"})," Apply & restart OpenClaw"]})})]}),$&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("p",{className:"text-[12px] text-[#8A8A99]",children:b?"Or copy snippet manually":"docker-compose snippet"}),r.jsx("button",{onClick:W,className:`flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-[11px] font-medium transition-colors ${c?"text-emerald-400 bg-emerald-500/10":"text-[#8A8A99] hover:text-[#C8C8D4] bg-white/[0.03] border border-[#2A2A35] hover:border-[#3A3A45]"}`,children:c?r.jsxs(r.Fragment,{children:[r.jsx(Fe,{className:"w-3 h-3"})," Copied!"]}):r.jsxs(r.Fragment,{children:[r.jsx(Po,{className:"w-3 h-3"})," Copy snippet"]})})]}),r.jsx("pre",{className:"bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-4 py-3 text-[12px] font-mono text-[#8A8A99] overflow-x-auto whitespace-pre",children:$.replace(/\\n/g,`
|
|
429
429
|
`)}),r.jsxs("div",{className:"mt-3",children:[r.jsxs("button",{onClick:()=>p(D=>!D),className:"flex items-center gap-1 text-[11px] text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:[r.jsx(Jt,{className:`w-3 h-3 transition-transform ${f?"rotate-90":""}`}),"How to apply"]}),r.jsx(Me,{children:f&&r.jsx(ne.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"overflow-hidden",children:r.jsxs("ol",{className:"mt-2 space-y-1 text-[11px] text-[#5A5A6E] list-decimal list-inside",children:[r.jsxs("li",{children:["Open your ",r.jsx("code",{className:"text-[#8A8A99]",children:"docker-compose.yml"})]}),r.jsxs("li",{children:["Find the ",r.jsx("code",{className:"text-[#8A8A99]",children:"openclaw"})," service"]}),r.jsxs("li",{children:["Paste the snippet above under its ",r.jsx("code",{className:"text-[#8A8A99]",children:"volumes:"})," key"]}),r.jsxs("li",{children:["Run ",r.jsx("code",{className:"text-[#8A8A99]",children:"docker compose up -d"})," to restart"]})]})})})]})]})]})]})]})}function cDe(){const e=L.useUtils(),[t,n]=y.useState(""),[s,i]=y.useState(!1),{data:a}=L.shellExec.getConfig.useQuery(),{data:o=[]}=L.shellExec.getHistory.useQuery({limit:20}),l=L.shellExec.setEnabled.useMutation({onSuccess:()=>{e.shellExec.getConfig.invalidate()}}),c=L.shellExec.addWorkdir.useMutation({onSuccess:()=>{e.shellExec.getConfig.invalidate(),n(""),i(!1)}}),d=L.shellExec.removeWorkdir.useMutation({onSuccess:()=>{e.shellExec.getConfig.invalidate()}}),f=a?.enabled??!0,p=a?.workdirAllowlist??[];return r.jsxs("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-6",children:[r.jsxs("div",{className:"flex items-start justify-between mb-5",children:[r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(Ti,{className:"w-4 h-4 text-[#8A8A99] mt-0.5"}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-[15px] font-semibold text-[#F0F0F5]",children:"Shell Execution"}),r.jsx("p",{className:"text-[12px] text-[#5A5A6E] mt-0.5",children:"Allow agents to run shell commands with an approval gate."})]})]}),r.jsx("button",{onClick:()=>l.mutate({enabled:!f}),disabled:l.isPending,className:`relative w-10 h-5 rounded-full transition-colors duration-200 focus:outline-none ${f?"bg-[#6366F1]":"bg-[#2A2A35]"}`,children:r.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform duration-200 ${f?"translate-x-5":"translate-x-0"}`})})]}),r.jsxs("div",{className:"mb-5",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("p",{className:"text-[12px] font-medium text-[#C8C8D4]",children:"Working directory allowlist"}),r.jsxs("button",{onClick:()=>i(m=>!m),className:"flex items-center gap-1 text-[11px] text-[#6366F1] hover:text-[#818CF8] transition-colors",children:[r.jsx(wt,{className:"w-3 h-3"}),"Add path"]})]}),r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mb-2",children:"Default: ~/.openclaw, ~/Desktop, ~/Documents, any damn-dev path"}),r.jsx(Me,{children:s&&r.jsx(ne.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"mb-2 overflow-hidden",children:r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{autoFocus:!0,value:t,onChange:m=>n(m.target.value),onKeyDown:m=>{m.key==="Enter"&&t.trim()&&c.mutate({path:t.trim()}),m.key==="Escape"&&(i(!1),n(""))},placeholder:"/Users/you/projects/my-app",className:"flex-1 bg-[#13131A] border border-[#2A2A35] rounded-lg px-3 py-1.5 text-[13px] text-[#F0F0F5] font-mono placeholder-[#5A5A6E] outline-none focus:border-[#6366F1]/60 transition-colors"}),r.jsx("button",{onClick:()=>{t.trim()&&c.mutate({path:t.trim()})},className:"px-3 py-1.5 rounded-lg bg-[#6366F1] text-white text-[12px] font-medium hover:bg-[#5558E8] transition-colors",children:"Add"})]})})}),p.length===0?r.jsx("p",{className:"text-[12px] text-[#5A5A6E]",children:"No custom paths added."}):r.jsx("div",{className:"space-y-1",children:p.map(m=>r.jsxs("div",{className:"flex items-center justify-between py-1.5 px-2 rounded-md bg-white/[0.02] border border-[#2A2A35]",children:[r.jsx("code",{className:"text-[12px] font-mono text-[#C8C8D4]",children:m}),r.jsx(bt,{label:"Remove",children:r.jsx("button",{onClick:()=>d.mutate({path:m}),className:"w-6 h-6 flex items-center justify-center rounded text-[#5A5A6E] hover:text-red-400 hover:bg-red-500/10 transition-colors",children:r.jsx(Dn,{className:"w-3 h-3"})})})]},m))})]}),o.length>0&&r.jsxs("div",{children:[r.jsx("p",{className:"text-[12px] font-medium text-[#C8C8D4] mb-2",children:"Recent commands"}),r.jsx("div",{className:"space-y-1 max-h-[240px] overflow-y-auto",children:o.map(m=>r.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-2 rounded-md bg-white/[0.02] border border-[#2A2A35]",children:[r.jsx("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${m.success?"bg-[#10B981]":"bg-[#EF4444]"}`}),r.jsx("code",{className:"text-[12px] font-mono text-[#C8C8D4] flex-1 truncate",children:m.command??"—"}),r.jsx("span",{className:"text-[11px] text-[#8A8A99] uppercase tracking-wider flex-shrink-0",children:m.tier??""}),r.jsx("span",{className:"text-[11px] text-[#8A8A99] flex-shrink-0",children:m.durationMs?`${m.durationMs}ms`:""})]},m.id))})]})]})}function uDe(){return iz()?r.jsx(vDe,{}):r.jsx(lm,{to:"/channels/direction",replace:!0})}const iO=[{id:"workspace",label:"Workspace",icon:bv},{id:"integrations",label:"Integrations",icon:bL},{id:"secrets",label:"Secrets",icon:Eo},{id:"runtime",label:"AI & Models",icon:sL},{id:"security",label:"Security",icon:ch},{id:"network",label:"Network",icon:B5},{id:"federation",label:"Federation",icon:Xt},{id:"desktop",label:"Desktop App",icon:Qie,desktopOnly:!0},{id:"mcp",label:"MCP Server",icon:Ti},{id:"keys",label:"Environment",icon:fL,advanced:!0}];function dDe(){const[e,t]=y.useState(""),[n,s]=y.useState(!1),[i,a]=y.useState(!1),[o,l]=y.useState(""),c=L.workspace.getMyMembership.useQuery(),d=L.workspace.listMembers.useQuery(),f=L.useUtils(),p=L.workspace.update.useMutation({onSuccess:()=>{s(!1),f.workspace.getMyMembership.invalidate(),f.workspace.list.invalidate()}}),m=L.workspace.delete.useMutation({onSuccess:()=>{a(!1),l(""),f.invalidate(),window.location.reload()}}),g=c.data,b=d.data??[],_=g?.role==="owner";return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-[15px] font-semibold text-[#F0F0F5] mb-1",children:"Workspace"}),r.jsx("p",{className:"text-[12px] text-[#8A8A99]",children:"Manage your workspace identity and membership."})]}),r.jsxs("div",{className:"rounded-lg border border-[#2A2A35] bg-[#16161A] p-4 space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-[12px] font-semibold text-[#F0F0F5]",children:"Name"}),r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mt-0.5",children:"Displayed in the sidebar and workspace switcher."})]}),_&&!n&&r.jsx("button",{onClick:()=>{t(g?.workspaceName??""),s(!0)},className:"text-[11px] text-[#6366F1] hover:text-[#818CF8] transition-colors",children:"Edit"})]}),n?r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{autoFocus:!0,value:e,onChange:w=>t(w.target.value),onKeyDown:w=>{w.key==="Enter"&&e.trim()&&p.mutate({name:e.trim()}),w.key==="Escape"&&s(!1)},className:"flex-1 bg-[#0F0F11] border border-[#2A2A35] rounded px-3 py-1.5 text-[12px] text-[#F0F0F5] outline-none focus:border-[#6366F1]/40"}),r.jsx("button",{onClick:()=>{e.trim()&&p.mutate({name:e.trim()})},disabled:!e.trim()||p.isPending,className:"px-3 py-1.5 rounded bg-[#6366F1]/10 text-[#6366F1] text-[11px] font-medium hover:bg-[#6366F1]/20 transition-colors disabled:opacity-30",children:"Save"}),r.jsx("button",{onClick:()=>s(!1),className:"text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:r.jsx(Te,{className:"w-3.5 h-3.5"})})]}):r.jsx("p",{className:"text-[13px] text-[#F0F0F5]",children:g?.workspaceName??"..."})]}),r.jsxs("div",{className:"rounded-lg border border-[#2A2A35] bg-[#16161A] p-4 space-y-3",children:[r.jsx("h3",{className:"text-[12px] font-semibold text-[#F0F0F5]",children:"Members"}),r.jsx("div",{className:"space-y-1.5",children:b.map(w=>r.jsxs("div",{className:"flex items-center gap-2 py-1",children:[r.jsx("div",{className:"w-6 h-6 rounded-full bg-[#2A2A35] flex items-center justify-center flex-shrink-0",children:r.jsx("span",{className:"text-[10px] text-[#8A8A99]",children:(w.name??w.email).charAt(0).toUpperCase()})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("span",{className:"text-[12px] text-[#F0F0F5] truncate block",children:w.name??w.email}),w.name&&r.jsx("span",{className:"text-[10px] text-[#5A5A6E]",children:w.email})]}),r.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-[#2A2A35] text-[#8A8A99]",children:w.role})]},w.id))})]}),_&&r.jsxs("div",{className:"rounded-lg border border-[#EF4444]/20 bg-[#16161A] p-4 space-y-3",children:[r.jsx("h3",{className:"text-[12px] font-semibold text-[#EF4444]",children:"Danger Zone"}),r.jsx("p",{className:"text-[11px] text-[#5A5A6E]",children:"Permanently delete this workspace and all its data. This cannot be undone."}),i?r.jsxs("div",{className:"space-y-2",children:[r.jsxs("p",{className:"text-[11px] text-[#EF4444]",children:["Type ",r.jsx("span",{className:"font-mono font-bold",children:"DELETE"})," to confirm."]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{autoFocus:!0,value:o,onChange:w=>l(w.target.value),onKeyDown:w=>{w.key==="Enter"&&o==="DELETE"&&m.mutate({confirmation:"DELETE"}),w.key==="Escape"&&(a(!1),l(""))},className:"flex-1 bg-[#0F0F11] border border-[#EF4444]/30 rounded px-3 py-1.5 text-[12px] text-[#F0F0F5] outline-none focus:border-[#EF4444]/60"}),r.jsx("button",{onClick:()=>m.mutate({confirmation:"DELETE"}),disabled:o!=="DELETE"||m.isPending,className:"px-3 py-1.5 rounded bg-[#EF4444] text-white text-[11px] font-medium hover:bg-[#DC2626] transition-colors disabled:opacity-30",children:m.isPending?r.jsx(Pe,{className:"w-3 h-3 animate-spin"}):"Confirm delete"}),r.jsx("button",{onClick:()=>{a(!1),l("")},className:"text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:r.jsx(Te,{className:"w-3.5 h-3.5"})})]}),m.isError&&r.jsx("p",{className:"text-[10px] text-[#EF4444]",children:m.error.message})]}):r.jsx("button",{onClick:()=>a(!0),className:"px-3 py-1.5 rounded bg-[#EF4444]/10 text-[#EF4444] text-[11px] font-medium hover:bg-[#EF4444]/20 transition-colors",children:"Delete workspace"})]})]})}function hDe(){const e=L.useUtils(),{data:t,isLoading:n}=L.settings.getTestMode.useQuery(),s=L.settings.setTestMode.useMutation({onSuccess:()=>e.settings.getTestMode.invalidate()}),i=t?.enabled??!1,a=t?.setAt?new Date(t.setAt):null;return r.jsx("div",{className:"rounded-lg border border-[#2A2A35] bg-[#16161A] p-4 space-y-3",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"w-9 h-9 rounded-lg bg-[#F59E0B]/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:r.jsx(oL,{className:"w-4.5 h-4.5 text-[#F59E0B]"})}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-[13px] font-semibold text-[#F0F0F5]",children:"Test mode"}),r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mt-0.5 max-w-md",children:"Turn on while stress-testing agents. Disables MEMORY, KNOWLEDGE, and REFLEXION writes across every agent. Nothing from this session will become a durable memory."}),i&&a&&r.jsxs("p",{className:"text-[11px] text-[#FBBF24] mt-1.5",children:["Active since ",a.toLocaleString()]})]})]}),r.jsx("button",{onClick:()=>s.mutate({enabled:!i}),disabled:n||s.isPending,className:ye("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus:outline-none",i?"bg-[#F59E0B]":"bg-[#2A2A35]",(n||s.isPending)&&"opacity-50"),"aria-pressed":i,"aria-label":"Toggle test mode",children:r.jsx("span",{className:ye("inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",i?"translate-x-[18px]":"translate-x-[3px]")})})]})})}function fDe(){const[e,t]=y.useState(""),[n,s]=y.useState(!1),[i,a]=y.useState(new Set),[o,l]=y.useState(null),c=L.memoryInvalidate.scan.useQuery({pattern:e},{enabled:!1,retry:!1}),d=L.memoryInvalidate.invalidate.useMutation({onSuccess:A=>{l(A),a(new Set),s(!1),t("")}});async function f(){e.trim()&&(l(null),a(new Set),await c.refetch(),s(!0))}const p=c.data?.matches??[],m=new Map;for(const A of p){const S=m.get(A.agentId)??[];S.push(A),m.set(A.agentId,S)}function g(){i.size===p.length?a(new Set):a(new Set(p.map(A=>A.id)))}function b(A){const S=new Set(i);S.has(A)?S.delete(A):S.add(A),a(S)}function _(){i.size!==0&&d.mutate({matchIds:Array.from(i)})}const w={REFLEXION:"text-[#F59E0B]",KNOWLEDGE:"text-[#60A5FA]",MEMORY:"text-[#A78BFA]"};return r.jsxs("div",{className:"rounded-lg border border-[#2A2A35] bg-[#16161A] p-4 space-y-4",children:[r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"w-9 h-9 rounded-lg bg-[#EF4444]/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:r.jsx(Io,{className:"w-4.5 h-4.5 text-[#EF4444]"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h3",{className:"text-[13px] font-semibold text-[#F0F0F5]",children:"Purge agent memories"}),r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mt-0.5 max-w-md",children:"Grep MEMORY, KNOWLEDGE, and REFLEXION across every agent. Preview matches, pick what to remove, apply. Atomic writes — matched entries gone, everything else untouched."})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{value:e,onChange:A=>t(A.target.value),onKeyDown:A=>A.key==="Enter"&&f(),placeholder:"Pattern (plain text or regex)",className:"flex-1 bg-[#0F0F11] border border-[#2A2A35] rounded px-3 py-1.5 text-[12px] text-[#F0F0F5] outline-none focus:border-[#6366F1]/40"}),r.jsx("button",{onClick:f,disabled:!e.trim()||c.isFetching,className:"px-3 py-1.5 rounded bg-[#6366F1]/10 text-[#6366F1] text-[11px] font-medium hover:bg-[#6366F1]/20 transition-colors disabled:opacity-30",children:c.isFetching?"Scanning…":"Scan"})]}),o&&r.jsxs("div",{className:"text-[11px] text-emerald-400",children:["Removed ",o.removed," ",o.removed===1?"entry":"entries",".",o.errors.length>0&&r.jsxs("span",{className:"text-[#EF4444] ml-2",children:[o.errors.length," error",o.errors.length===1?"":"s","."]})]}),n&&!c.isFetching&&p.length===0&&r.jsx("div",{className:"text-[11px] text-[#5A5A6E]",children:"No matches."}),p.length>0&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between text-[11px] text-[#8A8A99]",children:[r.jsx("button",{onClick:g,className:"hover:text-[#F0F0F5] transition-colors",children:i.size===p.length?"Deselect all":`Select all (${p.length})`}),r.jsx("button",{onClick:_,disabled:i.size===0||d.isPending,className:"px-3 py-1 rounded bg-[#EF4444]/10 text-[#EF4444] text-[11px] font-medium hover:bg-[#EF4444]/20 transition-colors disabled:opacity-30",children:d.isPending?"Removing…":`Remove selected (${i.size})`})]}),r.jsx("div",{className:"max-h-96 overflow-y-auto space-y-3 pr-1",children:Array.from(m.entries()).map(([A,S])=>r.jsxs("div",{className:"space-y-1",children:[r.jsx("div",{className:"text-[11px] font-semibold text-[#8A8A99]",children:A}),S.map(C=>r.jsxs("label",{className:"flex items-start gap-2 py-1.5 px-2 rounded hover:bg-[#0F0F11] cursor-pointer transition-colors",children:[r.jsx("input",{type:"checkbox",checked:i.has(C.id),onChange:()=>b(C.id),className:"mt-0.5"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[r.jsx("span",{className:ye("font-mono",w[C.file]),children:C.file}),r.jsxs("span",{className:"text-[#5A5A6E]",children:["line ",C.startLine+1]})]}),r.jsx("div",{className:"text-[12px] text-[#D0D0D8] truncate",children:C.preview})]})]},C.id))]},A))})]})]})}function pDe(){const[e,t]=y.useState(!1),[n,s]=y.useState(!1),[i,a]=y.useState(null),[o,l]=y.useState(null),c=L.useUtils(),d=L.settings.restartOpenClaw.useMutation({onSuccess:S=>{l(S),S.kind==="restarted"&&setTimeout(()=>{s(!1),l(null)},4e3)},onError:S=>{l({kind:"failed",method:"rpc-error",error:S.message})}}),{data:f=[],isLoading:p}=L.settings.getEnvVars.useQuery(),{data:m=[]}=L.settings.getKnownKeys.useQuery(),g=L.settings.setEnvVar.useMutation({onSuccess:(S,C)=>{c.settings.getEnvVars.invalidate(),S.restartRequired&&(s(!0),a(C.key))}}),b=L.settings.deleteEnvVar.useMutation({onSuccess:()=>{c.settings.getEnvVars.invalidate()}}),_=L.settings.moveKeyToSecrets.useMutation({onSuccess:()=>{c.settings.getEnvVars.invalidate(),c.settings.getKeyDrift.invalidate(),c.secrets.list.invalidate()}}),w=f.map(S=>S.key),A=f.some(S=>S.key==="OBSIDIAN_VAULT_PATH");return r.jsxs(r.Fragment,{children:[r.jsx(Me,{children:n&&r.jsxs(ne.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:ye("mb-6 px-4 py-3 rounded-xl border flex items-start gap-3",o?.kind==="restarted"?"bg-emerald-500/[0.08] border-emerald-500/20":o?.kind==="failed"?"bg-red-500/[0.08] border-red-500/20":"bg-amber-500/[0.08] border-amber-500/20"),children:[o?.kind==="restarted"?r.jsx(Fe,{className:"w-4 h-4 text-emerald-400 flex-shrink-0 mt-0.5"}):r.jsx(Rs,{className:ye("w-4 h-4 flex-shrink-0 mt-0.5",o?.kind==="failed"?"text-red-400":"text-amber-400")}),r.jsx("div",{className:"flex-1 min-w-0",children:o?.kind==="restarted"?r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"text-[13px] text-emerald-300/90 font-medium",children:["OpenClaw restarted"," ",r.jsxs("span",{className:"text-emerald-300/60 font-normal",children:["via ",o.method," · ",Math.round(o.durationMs/100)/10,"s"]})]}),o.envVerified&&r.jsx("p",{className:"text-[12px] text-emerald-300/70 mt-0.5",children:o.envVerified.matched?r.jsxs(r.Fragment,{children:["✓ ",r.jsx("code",{className:"font-mono",children:o.envVerified.key})," is live in the container."]}):r.jsxs(r.Fragment,{children:["⚠ ",r.jsx("code",{className:"font-mono",children:o.envVerified.key})," still didn't show inside the container — something else is caching it."]})})]}):o?.kind==="skipped"?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-[13px] text-amber-300/90 font-medium",children:"Restart skipped"}),r.jsx("p",{className:"text-[12px] text-amber-300/70 mt-0.5",children:o.reason}),o.detail&&r.jsx("p",{className:"text-[11px] text-amber-300/50 mt-1 leading-relaxed",children:o.detail})]}):o?.kind==="failed"?r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"text-[13px] text-red-300/90 font-medium",children:["Restart failed"," ",r.jsxs("span",{className:"text-red-300/60 font-normal",children:["(",o.method,")"]})]}),r.jsx("p",{className:"text-[12px] text-red-300/70 mt-0.5",children:o.error}),o.stderr&&r.jsx("pre",{className:"text-[11px] text-red-300/50 mt-1 whitespace-pre-wrap font-mono bg-red-500/[0.05] px-2 py-1 rounded max-h-32 overflow-auto",children:o.stderr}),o.container&&r.jsxs("p",{className:"text-[11px] text-red-300/50 mt-1",children:["Fallback: ",r.jsxs("code",{className:"font-mono",children:["docker restart ",o.container]})]})]}):r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-[13px] text-amber-300/90 font-medium",children:"OpenClaw restart required"}),r.jsx("p",{className:"text-[12px] text-amber-300/60 mt-0.5",children:"New env vars won't take effect until OpenClaw restarts."})]})}),r.jsx("button",{onClick:()=>d.mutate(i?{verifyKey:i}:void 0),disabled:d.isPending,className:ye("flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[12px] font-medium border transition-colors disabled:opacity-50 flex-shrink-0",o?.kind==="restarted"?"bg-emerald-500/10 text-emerald-300 hover:bg-emerald-500/20 border-emerald-500/20":o?.kind==="failed"?"bg-red-500/10 text-red-300 hover:bg-red-500/20 border-red-500/20":"bg-amber-500/10 text-amber-300 hover:bg-amber-500/20 border-amber-500/20"),children:o?.kind==="restarted"?r.jsxs(r.Fragment,{children:[r.jsx(Fe,{className:"w-3.5 h-3.5"})," Restarted"]}):r.jsxs(r.Fragment,{children:[r.jsx(Xi,{className:ye("w-3.5 h-3.5",d.isPending&&"animate-spin")})," ",o?"Retry":"Restart now"]})})]})}),r.jsxs("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-6",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-[15px] font-semibold text-[#F0F0F5]",children:"Environment"}),r.jsxs("p",{className:"text-[12px] text-[#5A5A6E] mt-0.5",children:["Low-level env vars read by the backend and agent containers. Most users want"," ",r.jsx("button",{onClick:()=>{const S=new URLSearchParams(window.location.search);S.set("tab","secrets"),window.history.replaceState(null,"",`?${S}`),window.location.reload()},className:"text-[#6366F1] hover:text-[#818CF8] transition-colors underline underline-offset-2",children:"Secrets"})," ","for API keys instead."]})]}),r.jsxs("button",{onClick:()=>t(S=>!S),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[12px] font-medium bg-[#6366F1]/10 text-[#6366F1] hover:bg-[#6366F1]/20 border border-[#6366F1]/30 transition-colors",children:[r.jsx(wt,{className:"w-3.5 h-3.5"}),"Add variable"]})]}),r.jsx(Me,{children:e&&r.jsx(aDe,{knownKeys:m,existingKeys:w,onAdd:(S,C)=>g.mutate({key:S,value:C}),onClose:()=>t(!1)})}),p&&r.jsx("div",{className:"py-8 flex justify-center",children:r.jsx("div",{className:"w-5 h-5 border-2 border-[#6366F1]/30 border-t-[#6366F1] rounded-full animate-spin"})}),!p&&f.length===0&&!e&&r.jsxs("div",{className:"py-8 text-center",children:[r.jsx("p",{className:"text-[13px] text-[#5A5A6E]",children:"No API keys configured yet."}),r.jsx("p",{className:"text-[12px] text-[#5A5A6E] mt-1",children:"Add your first key to get started."})]}),f.map(S=>r.jsx(rDe,{entry:S,onDelete:C=>b.mutate({key:C}),onSave:(C,E)=>g.mutate({key:C,value:E}),onMoveToSecrets:C=>_.mutate({key:C})},S.key)),!A&&!e&&r.jsxs("div",{className:"pt-4 mt-2 border-t border-[#2A2A35]",children:[r.jsx("p",{className:"text-[12px] text-[#5A5A6E] mb-2",children:"Obsidian not configured"}),r.jsx(wW,{onSelect:S=>g.mutate({key:"OBSIDIAN_VAULT_PATH",value:S})})]})]})]})}function mDe(){const e=L.useUtils(),{data:t=[],isLoading:n}=L.secrets.list.useQuery(),{data:s=[]}=L.settings.getKnownKeys.useQuery(),[i,a]=y.useState(!1),[o,l]=y.useState(""),[c,d]=y.useState(""),[f,p]=y.useState(""),[m,g]=y.useState(null),b=L.secrets.set.useMutation({onSuccess:()=>{e.secrets.list.invalidate(),e.settings.getKeyDrift.invalidate(),a(!1),l(""),d(""),p(""),g(null)},onError:E=>g(E.message)}),_=L.secrets.delete.useMutation({onSuccess:()=>{e.secrets.list.invalidate(),e.settings.getKeyDrift.invalidate()}}),w=L.secrets.moveKeyToEnvironment.useMutation({onSuccess:()=>{e.secrets.list.invalidate(),e.settings.getEnvVars.invalidate(),e.settings.getKeyDrift.invalidate()}}),A=new Map(s.map(E=>[E.key,E])),S=new Map(t.map(E=>[E.key,A.get(E.key)?.kind]));function C(){const E=o.trim(),k=c;!E||!k||b.mutate({key:E,value:k,description:f.trim()||void 0})}return r.jsxs("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-6",children:[r.jsxs("div",{className:"flex items-start justify-between mb-5",children:[r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(Eo,{className:"w-4 h-4 text-[#8A8A99] mt-0.5"}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-[15px] font-semibold text-[#F0F0F5]",children:"Workspace Secrets"}),r.jsx("p",{className:"text-[12px] text-[#5A5A6E] mt-0.5",children:"Encrypted API keys skills use to authenticate with external services. Never shown to agents or humans after save."})]})]}),r.jsxs("button",{onClick:()=>{a(E=>!E),g(null)},className:"flex items-center gap-1 text-[11px] text-[#6366F1] hover:text-[#818CF8] transition-colors",children:[r.jsx(wt,{className:"w-3 h-3"}),"Add secret"]})]}),r.jsx(Me,{children:i&&r.jsx(ne.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"mb-4 overflow-hidden",children:r.jsxs("div",{className:"space-y-3 bg-[#13131A] border border-[#2A2A35] rounded-xl p-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-[11px] text-[#8A8A99] mb-1.5",children:"Key"}),r.jsx("input",{autoFocus:!0,value:o,onChange:E=>l(E.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"")),placeholder:"MY_API_KEY",className:"w-full bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] font-mono placeholder-[#5A5A6E] outline-none focus:border-[#6366F1]/60 transition-colors"}),r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mt-1",children:"Uppercase, letters/digits/underscore, starts with a letter, max 64 chars."})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-[11px] text-[#8A8A99] mb-1.5",children:"Value"}),r.jsx("input",{type:"password",value:c,onChange:E=>d(E.target.value),onKeyDown:E=>{E.key==="Enter"&&C()},placeholder:"Paste your secret...",className:"w-full bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] font-mono placeholder-[#5A5A6E] outline-none focus:border-[#6366F1]/60 transition-colors"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-[11px] text-[#8A8A99] mb-1.5",children:"Description (optional)"}),r.jsx("input",{value:f,onChange:E=>p(E.target.value),placeholder:"Used by the X skill for API calls",className:"w-full bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] placeholder-[#5A5A6E] outline-none focus:border-[#6366F1]/60 transition-colors"})]}),m&&r.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] text-red-400",children:[r.jsx(Rs,{className:"w-3 h-3"}),m]}),r.jsxs("div",{className:"flex gap-2 pt-1",children:[r.jsx("button",{onClick:C,disabled:!o.trim()||!c||b.isPending,className:"px-3 py-1.5 rounded-lg bg-[#6366F1] text-white text-[12px] font-medium hover:bg-[#5558E8] transition-colors disabled:opacity-40 disabled:pointer-events-none",children:"Save secret"}),r.jsx("button",{onClick:()=>{a(!1),l(""),d(""),p(""),g(null)},className:"px-3 py-1.5 rounded-lg text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] border border-[#2A2A35] hover:border-[#3A3A45] transition-colors",children:"Cancel"})]})]})})}),n&&r.jsx("div",{className:"py-8 flex justify-center",children:r.jsx(Pe,{className:"w-5 h-5 text-[#6366F1] animate-spin"})}),!n&&t.length===0&&!i&&r.jsxs("div",{className:"py-8 text-center",children:[r.jsx("p",{className:"text-[13px] text-[#5A5A6E]",children:"No secrets configured yet."}),r.jsx("p",{className:"text-[12px] text-[#5A5A6E] mt-1",children:"Skills that need authenticated API access will ask you to add the secrets they need."})]}),t.map(E=>{const k=S.get(E.key),T=k==="env"||k==="path";return r.jsxs("div",{className:"flex items-start gap-4 py-4 border-b border-[#2A2A35] last:border-0",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("code",{className:"text-[13px] font-mono font-medium text-[#F0F0F5]",children:E.key}),E.description&&r.jsx("span",{className:"text-[11px] text-[#5A5A6E]",children:E.description})]}),E.hasValue&&r.jsx("code",{className:"text-[12px] font-mono text-[#8A8A99]",children:"••••••••"}),r.jsxs("p",{className:"text-[10px] text-[#5A5A6E] mt-1",children:["Updated ",new Date(E.updatedAt).toLocaleDateString()]})]}),T&&r.jsx(bt,{label:k==="path"?"This is a filesystem path, not a credential — move it to Environment":"This is infra config, not a credential — move it to Environment",children:r.jsx("button",{onClick:()=>w.mutate({key:E.key}),disabled:w.isPending,className:"flex items-center gap-1 px-2 h-7 rounded-md text-[11px] font-medium bg-amber-500/10 text-amber-300 hover:bg-amber-500/20 border border-amber-500/20 transition-colors disabled:opacity-50",children:"Move to Environment"})}),r.jsx(bt,{label:"Delete secret",children:r.jsx("button",{onClick:()=>_.mutate({key:E.key}),className:"w-7 h-7 flex items-center justify-center rounded-md text-[#5A5A6E] hover:text-red-400 hover:bg-red-500/10 transition-colors",children:r.jsx(Dn,{className:"w-3.5 h-3.5"})})})]},E.key)})]})}function xDe(){return r.jsxs("div",{className:"space-y-6",children:[r.jsx(cDe,{}),r.jsx(lDe,{}),r.jsx(kDe,{})]})}function gDe(){const e=L.useUtils(),{data:t,isLoading:n}=L.integrations.obsidian.status.useQuery(),s=L.integrations.obsidian.enable.useMutation({onSuccess:()=>{e.integrations.obsidian.status.invalidate()}}),i=L.integrations.obsidian.disable.useMutation({onSuccess:()=>{e.integrations.obsidian.status.invalidate()}}),a=L.integrations.obsidian.updateMode.useMutation({onSuccess:()=>{e.integrations.obsidian.status.invalidate()}}),[o,l]=y.useState(""),[c,d]=y.useState(!1),[f,p]=y.useState(!1);return n||!t?r.jsx("div",{className:"rounded-xl border border-[#2A2A35] bg-[#16161A] p-5",children:r.jsx(Pe,{className:"w-4 h-4 animate-spin text-[#5A5A6E]"})}):r.jsxs("div",{className:"rounded-xl border border-[#2A2A35] bg-[#16161A] p-5 space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-9 h-9 rounded-lg bg-[#7C3AED]/10 flex items-center justify-center",children:r.jsx(li,{className:"w-4.5 h-4.5 text-[#7C3AED]"})}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-[13px] font-semibold text-[#F0F0F5]",children:"Obsidian"}),r.jsx("p",{className:"text-[11px] text-[#5A5A6E]",children:"Give agents access to your vault notes"})]})]}),t.enabled&&!f&&r.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-emerald-400",children:[r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400"}),"Active"]})]}),t.enabled&&!f?r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"space-y-2 text-[12px]",children:[r.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[r.jsx("span",{className:"text-[#8A8A99]",children:"Vault"}),r.jsx("span",{className:"text-[#C8C8D4] font-mono text-[11px]",children:t.vaultPath})]}),r.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[r.jsx("span",{className:"text-[#8A8A99]",children:"Mount"}),r.jsxs("span",{className:"text-[#C8C8D4] font-mono text-[11px]",children:[t.mountPath," (",t.writable?"read & write":"read-only",")"]})]}),r.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[r.jsx("span",{className:"text-[#8A8A99]",children:"Agents"}),r.jsxs("span",{className:"text-[#C8C8D4]",children:[t.agentCount," of ",t.totalAgents," with skill active"]})]})]}),r.jsxs("div",{className:"flex items-center gap-3 pt-1",children:[r.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[r.jsx("input",{type:"radio",name:"obsidian-mode",checked:!t.writable,onChange:()=>a.mutate({writable:!1}),className:"accent-[#6366F1]"}),r.jsx("span",{className:"text-[12px] text-[#C8C8D4]",children:"Read-only"})]}),r.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[r.jsx("input",{type:"radio",name:"obsidian-mode",checked:t.writable,onChange:()=>a.mutate({writable:!0}),className:"accent-[#6366F1]"}),r.jsx("span",{className:"text-[12px] text-[#C8C8D4]",children:"Read & write"})]})]}),r.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[r.jsx("button",{onClick:()=>p(!0),className:"px-3 py-1.5 rounded-lg text-[11px] text-[#8A8A99] hover:text-[#C8C8D4] border border-[#2A2A35] hover:border-[#3A3A45] transition-colors",children:"Change vault"}),r.jsx("button",{onClick:()=>i.mutate(),disabled:i.isPending,className:"px-3 py-1.5 rounded-lg text-[11px] text-red-400/70 hover:text-red-400 border border-red-500/20 hover:border-red-500/30 transition-colors disabled:opacity-50",children:i.isPending?"Disabling...":"Disable"})]})]}):r.jsxs("div",{className:"space-y-3",children:[o?r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-white/[0.03] border border-[#2A2A35]",children:[r.jsx(vm,{className:"w-3.5 h-3.5 text-[#8A8A99]"}),r.jsx("span",{className:"text-[12px] text-[#C8C8D4] font-mono flex-1 truncate",children:o}),r.jsx("button",{onClick:()=>l(""),className:"text-[#5A5A6E] hover:text-[#8A8A99]",children:r.jsx(Te,{className:"w-3 h-3"})})]}):r.jsx(wW,{onSelect:m=>l(m)}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[r.jsx("input",{type:"radio",name:"obsidian-setup-mode",checked:!c,onChange:()=>d(!1),className:"accent-[#6366F1]"}),r.jsx("span",{className:"text-[12px] text-[#C8C8D4]",children:"Read-only"})]}),r.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[r.jsx("input",{type:"radio",name:"obsidian-setup-mode",checked:c,onChange:()=>d(!0),className:"accent-[#6366F1]"}),r.jsx("span",{className:"text-[12px] text-[#C8C8D4]",children:"Read & write"})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:()=>{o&&(s.mutate({vaultPath:o,writable:c}),p(!1))},disabled:!o||s.isPending,className:"px-4 py-1.5 rounded-lg text-[12px] font-medium bg-[#6366F1]/10 text-[#6366F1] hover:bg-[#6366F1]/20 transition-colors disabled:opacity-30",children:s.isPending?"Enabling...":"Enable"}),f&&r.jsx("button",{onClick:()=>{p(!1),l("")},className:"px-3 py-1.5 rounded-lg text-[11px] text-[#8A8A99] hover:text-[#C8C8D4] transition-colors",children:"Cancel"})]})]}),r.jsx("p",{className:"text-[11px] text-[#5A5A6E] leading-relaxed pt-1",children:"Only agents with the obsidian-builtin skill enabled can see vault guidance. Toggle per-agent in Settings → Agents → Skills."})]})}function bDe(){return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-[15px] font-semibold text-[#F0F0F5] mb-1",children:"Integrations"}),r.jsx("p",{className:"text-[12px] text-[#8A8A99]",children:"Connect external tools and services to your workspace agents."})]}),r.jsx(gDe,{})]})}function vDe(){const[e]=kO(),t=e.get("tab"),[n,s]=y.useState(t&&iO.some(f=>f.id===t)?t:"secrets"),[i,a]=y.useState(n==="keys"),o=iO.filter(f=>!f.desktopOnly||Va),l=o.filter(f=>!f.advanced),c=o.filter(f=>f.advanced);function d(f){const p=f.icon;return r.jsxs("button",{onClick:()=>s(f.id),className:ye("w-full flex items-center gap-2.5 px-3 py-2 rounded-lg text-[13px] transition-colors",n===f.id?"bg-white/[0.07] text-[#F0F0F5] font-medium":"text-[#8A8A99] hover:text-[#C8C8D4] hover:bg-white/[0.03]"),children:[r.jsx(p,{className:"w-4 h-4 flex-shrink-0"}),f.label]},f.id)}return r.jsxs("div",{className:"flex-1 flex bg-[#0F0F11] overflow-hidden",children:[r.jsxs("nav",{className:"w-[200px] flex-shrink-0 border-r border-[#2A2A35] py-8 px-3 overflow-y-auto",children:[r.jsx("h1",{className:"text-[15px] font-semibold text-[#F0F0F5] px-3 mb-6",children:"Settings"}),r.jsx("div",{className:"space-y-0.5",children:l.map(d)}),c.length>0&&r.jsxs("div",{className:"mt-6",children:[r.jsxs("button",{onClick:()=>a(f=>!f),className:"w-full flex items-center gap-2 px-3 py-2 rounded-lg text-[11px] uppercase tracking-wider text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:[r.jsx(Jt,{className:ye("w-3 h-3 transition-transform",i&&"rotate-90")}),"Advanced"]}),i&&r.jsx("div",{className:"space-y-0.5 mt-0.5",children:c.map(d)})]})]}),r.jsx("div",{className:"flex-1 overflow-y-auto py-8 px-10",children:r.jsxs("div",{className:"max-w-2xl",children:[r.jsx(yDe,{onOpenTab:s}),n==="workspace"&&r.jsxs(r.Fragment,{children:[r.jsx(dDe,{}),r.jsx(hDe,{}),r.jsx(fDe,{})]}),n==="integrations"&&r.jsx(bDe,{}),n==="keys"&&r.jsx(pDe,{}),n==="secrets"&&r.jsx(mDe,{}),n==="runtime"&&r.jsxs(r.Fragment,{children:[r.jsx(wDe,{}),r.jsx(SDe,{}),r.jsx(CDe,{}),r.jsx(jDe,{})]}),n==="security"&&r.jsx(xDe,{}),n==="network"&&r.jsx(NDe,{}),n==="federation"&&r.jsx(FDe,{}),n==="desktop"&&r.jsx(EDe,{}),n==="mcp"&&r.jsx(iDe,{})]})})]})}function yDe({onOpenTab:e}){const t=L.useUtils(),{data:n}=L.settings.getKeyDrift.useQuery(void 0,{staleTime:3e4}),s=L.settings.moveKeyToSecrets.useMutation({onSuccess:()=>{t.settings.getKeyDrift.invalidate(),t.settings.getEnvVars.invalidate(),t.secrets.list.invalidate()}}),i=L.secrets.moveKeyToEnvironment.useMutation({onSuccess:()=>{t.settings.getKeyDrift.invalidate(),t.settings.getEnvVars.invalidate(),t.secrets.list.invalidate()}}),a=n?.issues??[];if(a.length===0)return null;const o=a.filter(d=>d.kind==="misplaced-in-env"),l=a.filter(d=>d.kind==="misplaced-in-secrets"),c=a.filter(d=>d.kind==="value-mismatch");return r.jsx("div",{className:"mb-6 px-4 py-3 rounded-xl bg-amber-500/[0.08] border border-amber-500/20",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(Rs,{className:"w-4 h-4 text-amber-400 flex-shrink-0 mt-0.5"}),r.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[r.jsxs("p",{className:"text-[13px] text-amber-300/90 font-medium",children:[a.length," credential",a.length===1?"":"s"," in the wrong place"]}),o.length>0&&r.jsxs("div",{className:"text-[12px] text-amber-300/70 space-y-1",children:[r.jsx("p",{children:"These API credentials are stored as plain env vars. Encrypt them in Secrets (the env copy stays in place as a mirror so nothing breaks):"}),r.jsx("div",{className:"flex flex-wrap gap-1.5",children:o.map(d=>r.jsxs("button",{onClick:()=>s.mutate({key:d.key}),disabled:s.isPending,className:"font-mono text-[11px] px-2 py-0.5 rounded bg-amber-500/10 text-amber-300 hover:bg-amber-500/20 border border-amber-500/20 transition-colors disabled:opacity-50",children:["Encrypt ",d.key]},d.key))})]}),l.length>0&&r.jsxs("div",{className:"text-[12px] text-amber-300/70 space-y-1",children:[r.jsx("p",{children:"These are infra or paths stored in Secrets. Move them to Environment where they belong:"}),r.jsx("div",{className:"flex flex-wrap gap-1.5",children:l.map(d=>r.jsxs("button",{onClick:()=>i.mutate({key:d.key}),disabled:i.isPending,className:"font-mono text-[11px] px-2 py-0.5 rounded bg-amber-500/10 text-amber-300 hover:bg-amber-500/20 border border-amber-500/20 transition-colors disabled:opacity-50",children:[d.key," → Environment"]},d.key))})]}),c.length>0&&r.jsxs("div",{className:"text-[12px] text-amber-300/70 space-y-1",children:[r.jsx("p",{children:"These keys exist in both stores with different values — a skill might read one, an agent another. Pick the authoritative value:"}),r.jsx("div",{className:"flex flex-wrap gap-1.5",children:c.map(d=>r.jsx("button",{onClick:()=>e("secrets"),className:"font-mono text-[11px] px-2 py-0.5 rounded bg-amber-500/10 text-amber-300 hover:bg-amber-500/20 border border-amber-500/20 transition-colors",children:d.key},d.key))})]})]})]})})}const rO={openclaw:"OpenClaw",anthropic:"Anthropic","claude-code":"Claude Code",ollama:"Ollama",openrouter:"OpenRouter"},_De=["openclaw","anthropic","claude-code","ollama","openrouter"];function wDe(){const{data:e}=L.onboarding.getGatewayConfig.useQuery(),{data:t,refetch:n}=L.onboarding.getGatewayHealth.useQuery(void 0,{refetchInterval:3e4}),s=L.useUtils(),i=L.onboarding.setGatewayConfig.useMutation({onSuccess:()=>{s.onboarding.getGatewayConfig.invalidate(),n()}}),[a,o]=y.useState(!1),[l,c]=y.useState("anthropic"),[d,f]=y.useState(""),p=e?.gatewayType??"openclaw";function m(b){const _=e?.gatewayConfig?JSON.parse(e.gatewayConfig):{};i.mutate({gatewayType:b,gatewayConfig:JSON.stringify(_)})}function g(){const b={};l!=="openclaw"&&l!=="ollama"&&(b.apiKey=d),i.mutate({gatewayType:l,gatewayConfig:JSON.stringify(b)}),o(!1),f("")}return r.jsxs("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-6",children:[r.jsxs("div",{className:"flex items-start justify-between mb-5",children:[r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(Xi,{className:"w-4 h-4 text-[#8A8A99] mt-0.5"}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-[15px] font-semibold text-[#F0F0F5]",children:"AI Runtime"}),r.jsx("p",{className:"text-[12px] text-[#5A5A6E] mt-0.5",children:"Configure which AI gateway agents use by default."})]})]}),r.jsxs("button",{onClick:()=>o(!a),className:"flex items-center gap-1 text-[11px] text-[#6366F1] hover:text-[#818CF8] transition-colors",children:[r.jsx(wt,{className:"w-3.5 h-3.5"}),"Switch runtime"]})]}),r.jsx("div",{className:"space-y-2",children:t?.map(b=>r.jsxs("div",{className:`flex items-center justify-between px-3 py-2.5 rounded-lg border ${b.isDefault?"border-[#6366F1]/30 bg-[#6366F1]/5":"border-[#2A2A35] bg-[#1C1C21]"}`,children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:`w-2 h-2 rounded-full ${b.ok?"bg-[#10B981]":"bg-[#EF4444]"}`}),r.jsx("span",{className:"text-[13px] text-[#F0F0F5]",children:b.name}),b.isDefault&&r.jsx("span",{className:"text-[10px] text-[#6366F1] bg-[#6366F1]/10 px-1.5 py-0.5 rounded",children:"default"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[b.latencyMs!==void 0&&r.jsxs("span",{className:"text-[11px] text-[#8A8A99]",children:[b.latencyMs,"ms"]}),!b.isDefault&&r.jsx("button",{onClick:()=>m(b.id),className:"text-[11px] text-[#8A8A99] hover:text-[#F0F0F5] transition-colors",children:"Set default"})]})]},b.id))??r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 rounded-lg border border-[#2A2A35] bg-[#1C1C21]",children:[r.jsx("div",{className:"w-2 h-2 rounded-full bg-[#5A5A6E] animate-pulse"}),r.jsx("span",{className:"text-[13px] text-[#5A5A6E]",children:"Loading..."})]})}),r.jsx(Me,{children:a&&r.jsx(ne.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"overflow-hidden",children:r.jsxs("div",{className:"pt-4 mt-4 border-t border-[#2A2A35] space-y-3",children:[r.jsxs(ss,{value:l,onValueChange:c,children:[r.jsxs(is,{className:"w-full flex items-center justify-between px-3 py-2 rounded-lg border border-[#2A2A35] bg-[#1C1C21] text-[13px] text-[#F0F0F5]",children:[r.jsx(Ds,{}),r.jsx(Yl,{children:r.jsx(ft,{className:"w-3.5 h-3.5 text-[#5A5A6E]"})})]}),r.jsx(rs,{children:r.jsx(as,{className:"bg-[#1C1C21] border border-[#2A2A35] rounded-lg shadow-xl z-[9999] overflow-hidden",children:r.jsx(os,{className:"p-1",children:_De.map(b=>r.jsxs(vn,{value:b,className:"flex items-center gap-2 px-3 py-2 rounded text-[13px] text-[#F0F0F5] cursor-pointer outline-none data-[highlighted]:bg-[#2A2A35]",children:[r.jsx(yn,{children:rO[b]}),r.jsx(ui,{children:r.jsx(Fe,{className:"w-3.5 h-3.5 text-[#10B981]"})})]},b))})})})]}),l!=="openclaw"&&l!=="ollama"&&r.jsx("input",{type:"password",placeholder:"API key",value:d,onChange:b=>f(b.target.value),className:"w-full px-3 py-2 rounded-lg border border-[#2A2A35] bg-[#1C1C21] text-[13px] text-[#F0F0F5] placeholder:text-[#3E3E4E] outline-none focus:border-[#6366F1]/50"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{onClick:g,disabled:i.isPending||l!=="openclaw"&&l!=="ollama"&&!d,className:"flex-1 py-2 rounded-lg text-[13px] font-medium bg-[#6366F1] text-white hover:bg-[#818CF8] disabled:opacity-50 transition-colors",children:i.isPending?"Saving...":"Set as default"}),r.jsx("button",{onClick:()=>o(!1),className:"px-4 py-2 rounded-lg text-[13px] text-[#8A8A99] hover:text-[#F0F0F5] border border-[#2A2A35] hover:border-[#3E3E4E] transition-colors",children:"Cancel"})]})]})})}),r.jsxs("p",{className:"text-[10px] text-[#3E3E4E] mt-3",children:["Current: ",rO[p]??p,". Agents can override this in their Model tab."]})]})}const ADe=[{id:"openrouter",label:"OpenRouter",description:"Multi-provider gateway. Free + paid models from Anthropic, OpenAI, Google, Meta and many more."},{id:"anthropic",label:"Anthropic",description:"Direct API. Claude Haiku, Sonnet, Opus."},{id:"openai",label:"OpenAI",description:"Direct API. GPT-4o, GPT-4o mini, o1."},{id:"google",label:"Google",description:"Direct Gemini API. Gemini 2.5 Pro, Flash."}];function aO(e){return e==="google"?"gemini":e}function SDe(){const e=L.useUtils(),{data:t}=L.onboarding.providersConfigured.useQuery(),{data:n}=L.onboarding.discoverProviderModels.useQuery(),s=L.onboarding.validateApiKey.useMutation(),i=L.onboarding.removeProviderKey.useMutation({onSuccess:()=>{e.onboarding.providersConfigured.invalidate(),e.onboarding.discoverProviderModels.invalidate()}}),[a,o]=y.useState(null),[l,c]=y.useState(""),[d,f]=y.useState(null);function p(b){o(b),c(""),f(null)}function m(){o(null),c(""),f(null)}async function g(b){const _=l.trim();if(!_)return;if(f(null),!(await s.mutateAsync({provider:aO(b),key:_})).valid){f({provider:b,msg:"Key validation failed. Check that the key is correct and active."});return}o(null),c(""),e.onboarding.providersConfigured.invalidate(),e.onboarding.discoverProviderModels.invalidate()}return r.jsxs("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-6 mt-4",children:[r.jsxs("div",{className:"flex items-start gap-3 mb-5",children:[r.jsx(fL,{className:"w-4 h-4 text-[#8A8A99] mt-0.5"}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-[15px] font-semibold text-[#F0F0F5]",children:"Model Providers"}),r.jsx("p",{className:"text-[12px] text-[#5A5A6E] mt-0.5",children:"API keys the OpenClaw gateway uses to route to hosted providers. Keys are validated on save and never shown after."})]})]}),r.jsx("div",{className:"space-y-2",children:ADe.map(({id:b,label:_,description:w})=>{const A=!!t?.[b],S=n?.[b]?.length??0,C=a===b,E=s.isPending&&s.variables?.provider===aO(b),k=i.isPending&&i.variables?.provider===b;return r.jsxs("div",{className:"rounded-lg border border-[#2A2A35] bg-[#1C1C21] px-4 py-3",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[13px] font-medium text-[#F0F0F5]",children:_}),A?r.jsxs("span",{className:"text-[10px] text-[#10B981] bg-[#10B981]/10 px-1.5 py-0.5 rounded",children:["configured · ",S," model",S===1?"":"s"]}):r.jsx("span",{className:"text-[10px] text-[#5A5A6E] bg-[#5A5A6E]/10 px-1.5 py-0.5 rounded",children:"not configured"})]}),r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mt-0.5",children:w})]}),!C&&r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[r.jsx("button",{onClick:()=>p(b),className:"text-[11px] text-[#6366F1] hover:text-[#818CF8] transition-colors",children:A?"Update":"Add key"}),A&&r.jsx("button",{onClick:()=>i.mutate({provider:b}),disabled:k,className:"text-[11px] text-[#8A8A99] hover:text-[#F87171] transition-colors disabled:opacity-50",children:k?"Removing...":"Remove"})]})]}),r.jsx(Me,{children:C&&r.jsx(ne.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"overflow-hidden",children:r.jsxs("div",{className:"pt-3 mt-3 border-t border-[#2A2A35] space-y-2",children:[r.jsx("input",{type:"password",autoFocus:!0,placeholder:`${_} API key`,value:l,onChange:T=>c(T.target.value),onKeyDown:T=>{T.key==="Enter"&&g(b),T.key==="Escape"&&m()},className:"w-full px-3 py-2 rounded-lg border border-[#2A2A35] bg-[#13131A] text-[12px] text-[#F0F0F5] placeholder:text-[#3E3E4E] outline-none focus:border-[#6366F1]/50"}),d?.provider===b&&r.jsx("p",{className:"text-[11px] text-[#F87171]",children:d.msg}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{onClick:()=>g(b),disabled:E||!l.trim(),className:"flex-1 py-1.5 rounded-lg text-[12px] font-medium bg-[#6366F1] text-white hover:bg-[#818CF8] disabled:opacity-50 transition-colors",children:E?"Validating...":"Save"}),r.jsx("button",{onClick:m,className:"px-4 py-1.5 rounded-lg text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] border border-[#2A2A35] hover:border-[#3E3E4E] transition-colors",children:"Cancel"})]})]})})})]},b)})})]})}function CDe(){const{data:e,refetch:t}=L.settings.getOpenClawVersion.useQuery(void 0,{refetchInterval:6e4}),n=L.settings.updateOpenClaw.useMutation({onSuccess:()=>{setTimeout(()=>t(),5e3)}});return e?.current?r.jsxs("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-6 mt-4",children:[r.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[r.jsx(Xi,{className:"w-4 h-4 text-[#8A8A99] mt-0.5"}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-[15px] font-semibold text-[#F0F0F5]",children:"OpenClaw Version"}),r.jsx("p",{className:"text-[12px] text-[#5A5A6E] mt-0.5",children:"Runtime version and updates."})]})]}),r.jsxs("div",{className:"flex items-center justify-between px-3 py-2.5 rounded-lg border border-[#2A2A35] bg-[#1C1C21]",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:`w-2 h-2 rounded-full ${e.updateAvailable?"bg-amber-400":"bg-[#10B981]"}`}),r.jsxs("span",{className:"text-[13px] text-[#F0F0F5]",children:["v",e.current]}),e.updateAvailable&&r.jsxs("span",{className:"text-[10px] text-amber-400 bg-amber-400/10 px-1.5 py-0.5 rounded",children:["update available — minimum v",e.minimum]}),!e.updateAvailable&&r.jsx("span",{className:"text-[10px] text-[#10B981] bg-[#10B981]/10 px-1.5 py-0.5 rounded",children:"up to date"})]}),e.updateAvailable&&r.jsx("button",{onClick:()=>n.mutate(),disabled:n.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-[11px] font-medium bg-[#6366F1]/20 text-[#818CF8] hover:bg-[#6366F1]/30 disabled:opacity-50 transition-colors",children:n.isPending?r.jsxs(r.Fragment,{children:[r.jsx(Pe,{className:"w-3 h-3 animate-spin"}),"Updating..."]}):"Update now"})]}),n.isSuccess&&n.data.ok&&r.jsxs("p",{className:"text-[11px] text-[#10B981] mt-2",children:["Updated",n.data.newVersion?` to v${n.data.newVersion}`:"",". OpenClaw is restarting."]}),n.isSuccess&&!n.data.ok&&r.jsxs("p",{className:"text-[11px] text-[#F87171] mt-2",children:["Update failed: ",n.data.error]}),n.isError&&r.jsxs("p",{className:"text-[11px] text-[#F87171] mt-2",children:["Update failed: ",n.error.message]})]}):null}function jDe(){const{data:e}=L.onboarding.getState.useQuery(),t=L.useUtils(),n=L.onboarding.setDefaultModels.useMutation({onSuccess:()=>t.onboarding.getState.invalidate()}),{groups:s}=Vm(),[i,a]=y.useState(""),[o,l]=y.useState(""),[c,d]=y.useState(!1);y.useEffect(()=>{e?.defaultReasoningModel&&!i&&a(e.defaultReasoningModel),e?.defaultFastModel&&!o&&l(e.defaultFastModel)},[e?.defaultReasoningModel,e?.defaultFastModel]);function f(){!i||!o||n.mutate({reasoningModel:i,fastModel:o},{onSuccess:()=>d(!1)})}return r.jsxs("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-6 mt-4",children:[r.jsxs("div",{className:"flex items-start gap-3 mb-5",children:[r.jsx(sL,{className:"w-4 h-4 text-[#8A8A99] mt-0.5"}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-[15px] font-semibold text-[#F0F0F5]",children:"Default Models"}),r.jsx("p",{className:"text-[12px] text-[#5A5A6E] mt-0.5",children:"Applies to new agents. Existing agents keep their current model."})]})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-[11px] text-[#5A5A6E] mb-1 block",children:"Primary (reasoning)"}),r.jsxs(ss,{value:i,onValueChange:p=>{a(p),d(!0)},children:[r.jsxs(is,{className:"w-full flex items-center justify-between px-3 py-2 rounded-lg border border-[#2A2A35] bg-[#1C1C21] text-[13px] text-[#F0F0F5] outline-none",children:[r.jsx(Ds,{placeholder:"Not set",children:i?ta(i):"Not set"}),r.jsx(Yl,{children:r.jsx(ft,{className:"w-3.5 h-3.5 text-[#5A5A6E]"})})]}),r.jsx(rs,{children:r.jsx(as,{position:"popper",sideOffset:4,className:"bg-[#1C1C24] border border-[#2A2A35] rounded-lg shadow-xl py-1 min-w-[280px] max-h-[240px] z-[9999]",children:r.jsx(os,{children:s.map(p=>r.jsxs(Ro,{children:[r.jsx(Do,{className:"px-3 pt-2 pb-1 text-[10px] font-semibold text-[#5A5A6E] uppercase tracking-widest",children:p.label}),p.models.map(m=>r.jsxs(vn,{value:m.id,className:"flex items-center justify-between px-3 py-1.5 text-[12px] text-[#C8C8D4] cursor-pointer outline-none data-[highlighted]:bg-white/5",children:[r.jsx(yn,{children:m.label}),r.jsx(ui,{children:r.jsx(Fe,{className:"w-3 h-3 text-[#6366F1]"})})]},m.id))]},p.label))})})})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-[11px] text-[#5A5A6E] mb-1 block",children:"Fast (quick tasks)"}),r.jsxs(ss,{value:o,onValueChange:p=>{l(p),d(!0)},children:[r.jsxs(is,{className:"w-full flex items-center justify-between px-3 py-2 rounded-lg border border-[#2A2A35] bg-[#1C1C21] text-[13px] text-[#F0F0F5] outline-none",children:[r.jsx(Ds,{placeholder:"Not set",children:o?ta(o):"Not set"}),r.jsx(Yl,{children:r.jsx(ft,{className:"w-3.5 h-3.5 text-[#5A5A6E]"})})]}),r.jsx(rs,{children:r.jsx(as,{position:"popper",sideOffset:4,className:"bg-[#1C1C24] border border-[#2A2A35] rounded-lg shadow-xl py-1 min-w-[280px] max-h-[240px] z-[9999]",children:r.jsx(os,{children:s.map(p=>r.jsxs(Ro,{children:[r.jsx(Do,{className:"px-3 pt-2 pb-1 text-[10px] font-semibold text-[#5A5A6E] uppercase tracking-widest",children:p.label}),p.models.map(m=>r.jsxs(vn,{value:m.id,className:"flex items-center justify-between px-3 py-1.5 text-[12px] text-[#C8C8D4] cursor-pointer outline-none data-[highlighted]:bg-white/5",children:[r.jsx(yn,{children:m.label}),r.jsx(ui,{children:r.jsx(Fe,{className:"w-3 h-3 text-[#6366F1]"})})]},m.id))]},p.label))})})})]})]}),c&&r.jsx("button",{onClick:f,disabled:n.isPending||!i||!o,className:"w-full py-2 rounded-lg text-[13px] font-medium bg-[#6366F1] text-white hover:bg-[#818CF8] disabled:opacity-50 transition-colors",children:n.isPending?"Saving...":"Save defaults"})]})]})}function NDe(){const[e,t]=y.useState(!1),[n,s]=y.useState(!1),[i,a]=y.useState(!1),o=L.useUtils(),{data:l,isLoading:c}=L.network.getStatus.useQuery(void 0,{refetchOnWindowFocus:!1}),d=L.network.activate.useMutation({onSuccess:()=>{o.network.getStatus.invalidate(),a(!1)}}),f=L.network.deactivate.useMutation({onSuccess:()=>{o.network.getStatus.invalidate(),a(!1)}});function p(w){navigator.clipboard.writeText(w),s(!0),setTimeout(()=>s(!1),1500)}const m=l?.mode==="tailscale"||l?.mode==="custom",b=!!l?.storedTailscaleHostname&&!e;function _(){i||(a(!0),m?f.mutate():d.mutate({hostname:l.storedTailscaleHostname}))}return r.jsxs("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-6",children:[r.jsxs("div",{className:"flex items-start gap-3 mb-5",children:[r.jsx(B5,{className:"w-4 h-4 text-[#8A8A99] mt-0.5"}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-[15px] font-semibold text-[#F0F0F5]",children:"Network & Sharing"}),r.jsx("p",{className:"text-[12px] text-[#5A5A6E] mt-0.5",children:"Share your workspace with teammates over a private network."})]})]}),c?r.jsx("div",{className:"py-4 flex justify-center",children:r.jsx("div",{className:"w-5 h-5 border-2 border-[#6366F1]/30 border-t-[#6366F1] rounded-full animate-spin"})}):b?r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[12px] text-[#8A8A99]",children:"Tailscale:"}),r.jsx("code",{className:"text-[12px] font-mono text-[#C8C8D4]",children:l.storedTailscaleHostname})]}),r.jsx("button",{onClick:_,disabled:i,className:`relative w-9 h-5 rounded-full transition-colors duration-200 ${m?"bg-[#6366F1]":"bg-[#2A2A35]"} ${i?"opacity-60":""}`,children:r.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white transition-transform duration-200 ${m?"translate-x-4":"translate-x-0"}`})})]}),m&&l.shareUrl?r.jsxs("div",{children:[r.jsx("span",{className:"text-[12px] text-[#8A8A99]",children:"Workspace URL:"}),r.jsxs("div",{className:"flex items-center justify-between bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 mt-1",children:[r.jsx("span",{className:"font-mono text-[12px] text-[#C8C8D4] truncate",children:l.shareUrl}),r.jsx("button",{onClick:()=>p(l.shareUrl),className:`ml-3 flex-shrink-0 transition-colors ${n?"text-emerald-400":"text-[#5A5A6E] hover:text-[#C8C8D4]"}`,children:n?r.jsx(Fe,{className:"w-3.5 h-3.5"}):r.jsx(Po,{className:"w-3.5 h-3.5"})})]})]}):m?null:r.jsx("p",{className:"text-[12px] text-[#5A5A6E]",children:"Local only — teammates cannot reach this workspace."}),(d.isSuccess||f.isSuccess)&&r.jsx("p",{className:"text-[11px] text-amber-300/80",children:"Restart damn.dev to apply network changes."}),r.jsx("button",{onClick:()=>t(!0),className:"text-[11px] text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:"Change hostname..."})]}):r.jsxs("div",{children:[!e&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx("span",{className:"text-[12px] text-[#8A8A99]",children:"Network:"}),r.jsx("span",{className:"text-[12px] text-[#5A5A6E]",children:"Local only"})]}),r.jsx("p",{className:"text-[12px] text-[#5A5A6E] mb-3",children:"Your workspace is only accessible on this machine."}),r.jsx("button",{onClick:()=>t(!0),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[12px] font-medium bg-[#6366F1]/10 text-[#6366F1] hover:bg-[#6366F1]/20 border border-[#6366F1]/30 transition-colors",children:"Set up team sharing"})]}),e&&r.jsx(V5,{onComplete:()=>{o.network.getStatus.invalidate(),t(!1)},onSkip:()=>t(!1)})]})]})}function kDe(){const e=L.useUtils(),[t,n]=y.useState(!1),[s,i]=y.useState(""),[a,o]=y.useState(""),{data:l=[]}=L.delegations.list.useQuery(),{data:c=[]}=L.agents.list.useQuery(),d=L.delegations.create.useMutation({onSuccess:()=>{e.delegations.list.invalidate(),n(!1),i(""),o("")}}),f=L.delegations.delete.useMutation({onSuccess:()=>{e.delegations.list.invalidate()}});function p(){!s||!a.trim()||d.mutate({agentId:s,pattern:a.trim()})}return r.jsxs("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-6",children:[r.jsxs("div",{className:"flex items-start justify-between mb-5",children:[r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(ch,{className:"w-4 h-4 text-[#8A8A99] mt-0.5"}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-[15px] font-semibold text-[#F0F0F5]",children:"Delegation Rules"}),r.jsxs("p",{className:"text-[12px] text-[#5A5A6E] mt-0.5",children:["Auto-approve matching actions. Patterns: ",r.jsx("code",{className:"text-[#8A8A99]",children:"shell:*"}),", ",r.jsx("code",{className:"text-[#8A8A99]",children:"soul:*"}),", ",r.jsx("code",{className:"text-[#8A8A99]",children:"trust:*"}),", ",r.jsx("code",{className:"text-[#8A8A99]",children:"skill:*"})]})]})]}),r.jsxs("button",{onClick:()=>n(m=>!m),className:"flex items-center gap-1 text-[11px] text-[#6366F1] hover:text-[#818CF8] transition-colors",children:[r.jsx(wt,{className:"w-3 h-3"}),"Add rule"]})]}),r.jsx(Me,{children:t&&r.jsx(ne.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"mb-4 overflow-hidden",children:r.jsxs("div",{className:"flex gap-2 items-end",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"block text-[11px] text-[#8A8A99] mb-1",children:"Agent"}),r.jsxs("select",{value:s,onChange:m=>i(m.target.value),className:"w-full bg-[#13131A] border border-[#2A2A35] rounded-lg px-3 py-1.5 text-[13px] text-[#F0F0F5] outline-none focus:border-[#6366F1]/60",children:[r.jsx("option",{value:"",children:"Select agent"}),c.map(m=>r.jsxs("option",{value:m.id,children:[m.emoji," ",m.name]},m.id)),r.jsx("option",{value:"coo",children:"COO"})]})]}),r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"block text-[11px] text-[#8A8A99] mb-1",children:"Pattern"}),r.jsx("input",{value:a,onChange:m=>o(m.target.value),onKeyDown:m=>{m.key==="Enter"&&p()},placeholder:"shell:ls*",className:"w-full bg-[#13131A] border border-[#2A2A35] rounded-lg px-3 py-1.5 text-[13px] text-[#F0F0F5] font-mono placeholder-[#5A5A6E] outline-none focus:border-[#6366F1]/60"})]}),r.jsx("button",{onClick:p,disabled:!s||!a.trim()||d.isPending,className:"px-3 py-1.5 rounded-lg bg-[#6366F1] text-white text-[12px] font-medium hover:bg-[#5558E8] transition-colors disabled:opacity-40",children:"Add"}),r.jsx("button",{onClick:()=>{n(!1),i(""),o("")},className:"px-3 py-1.5 rounded-lg text-[12px] text-[#8A8A99] hover:text-[#F0F0F5] border border-[#2A2A35] transition-colors",children:"Cancel"})]})})}),l.length===0?r.jsx("p",{className:"text-[12px] text-[#5A5A6E]",children:"No delegation rules. All actions require manual approval."}):r.jsx("div",{className:"space-y-1",children:l.map(m=>{const g=c.find(b=>b.id===m.agentId);return r.jsxs("div",{className:"flex items-center justify-between py-2 px-3 rounded-md bg-white/[0.02] border border-[#2A2A35]",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-sm",children:g?.emoji??(m.agentId==="coo"?"👑":"?")}),r.jsx("span",{className:"text-[13px] text-[#C8C8D4]",children:g?.name??(m.agentId==="coo"?"COO":m.agentId)}),r.jsx("code",{className:"text-[12px] font-mono text-[#8A8A99] bg-white/5 px-1.5 py-0.5 rounded",children:m.pattern})]}),r.jsx(bt,{label:"Remove rule",children:r.jsx("button",{onClick:()=>f.mutate({id:m.id}),className:"w-6 h-6 flex items-center justify-center rounded text-[#5A5A6E] hover:text-red-400 hover:bg-red-500/10 transition-colors",children:r.jsx(Dn,{className:"w-3 h-3"})})})]},m.id)})})]})}function EDe(){const[e,t]=y.useState(!1),[n,s]=y.useState(!1);y.useEffect(()=>{X(async()=>{const{isEnabled:a}=await import("./index-CdilBaXC.js");return{isEnabled:a}},__vite__mapDeps([104,1])).then(({isEnabled:a})=>{a().then(o=>{t(o),s(!0)})}).catch(()=>s(!0))},[]);async function i(){try{const{enable:a,disable:o}=await X(async()=>{const{enable:l,disable:c}=await import("./index-CdilBaXC.js");return{enable:l,disable:c}},__vite__mapDeps([104,1]));e?(await o(),t(!1)):(await a(),t(!0))}catch{}}return n?r.jsxs("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-6",children:[r.jsxs("div",{className:"flex items-start gap-3 mb-5",children:[r.jsx(bv,{className:"w-4 h-4 text-[#8A8A99] mt-0.5"}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-[15px] font-semibold text-[#F0F0F5]",children:"Desktop App"}),r.jsx("p",{className:"text-[12px] text-[#5A5A6E] mt-0.5",children:"Settings for the native desktop application."})]})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-[13px] font-medium text-[#F0F0F5]",children:"Launch on startup"}),r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mt-0.5",children:"Start damn.dev hidden in the system tray when you log in."})]}),r.jsx("button",{onClick:i,className:`relative w-10 h-5 rounded-full transition-colors duration-200 focus:outline-none ${e?"bg-[#6366F1]":"bg-[#2A2A35]"}`,children:r.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform duration-200 ${e?"translate-x-5":"translate-x-0"}`})})]})]}):null}function FDe(){const[e,t]=y.useState("nodes");return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-[15px] font-semibold text-[#F0F0F5] mb-1",children:"Federation"}),r.jsx("p",{className:"text-[12px] text-[#8A8A99]",children:"Connect remote damn.dev instances or spawn isolated agent teams as Docker containers on this machine."})]}),r.jsx("div",{className:"flex gap-1 border-b border-[#2A2A35] mb-4",children:["nodes","activity"].map(n=>r.jsx("button",{onClick:()=>t(n),className:ye("px-3 py-1.5 text-[12px] font-medium border-b-2 -mb-px transition-colors",e===n?"border-[#6366F1] text-[#F0F0F5]":"border-transparent text-[#5A5A6E] hover:text-[#8A8A99]"),children:n==="nodes"?"Nodes":"Activity"},n))}),e==="nodes"&&r.jsx(RDe,{}),e==="activity"&&r.jsx(TDe,{})]})}function TDe(){const[e,t]=y.useState(null),n=L.federation.activityFeed.useQuery(void 0,{refetchInterval:1e4}),s=n.data?.entries??[];return n.isLoading?r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx(Pe,{className:"w-4 h-4 animate-spin text-[#5A5A6E]"})}):s.length===0?r.jsxs("div",{className:"py-12 text-center",children:[r.jsx(Xt,{className:"w-8 h-8 text-[#2A2A35] mx-auto mb-2"}),r.jsx("p",{className:"text-[13px] text-[#5A5A6E]",children:"No cross-instance activity yet"}),r.jsx("p",{className:"text-[11px] text-[#3A3A45] mt-1",children:"Activity will appear here when tasks are dispatched to or received from federated nodes"})]}):r.jsx("div",{className:"space-y-1.5",children:s.map(i=>{const a=e===i.id,o=i.status==="completed",l=i.status==="failed",c=o?"#10B981":l?"#EF4444":i.status==="working"?"#6366F1":"#F59E0B";return r.jsxs("div",{className:"rounded-lg border border-[#2A2A35] bg-[#16161A] overflow-hidden",children:[r.jsxs("button",{onClick:()=>t(a?null:i.id),className:"w-full flex items-center gap-2.5 px-3 py-2.5 text-left hover:bg-[#1A1A22] transition-colors",children:[r.jsx("span",{className:"text-[11px] flex-shrink-0",style:{color:c},children:o||i.result?"←":"→"}),i.nodeName&&r.jsxs("span",{className:"flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded bg-[#6366F1]/10 text-[#818CF8] flex-shrink-0",children:[r.jsx(Xt,{className:"w-2.5 h-2.5"}),i.nodeName]}),i.toAgent&&r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-[#8A8A99] flex-shrink-0",children:[r.jsx("span",{children:i.toAgent.emoji}),r.jsx("span",{children:i.toAgent.name})]}),r.jsx("span",{className:"text-[11px] text-[#5A5A6E] truncate flex-1",children:i.taskSnippet}),r.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded flex-shrink-0",style:{color:c,backgroundColor:c+"15"},children:i.status}),r.jsx("span",{className:"text-[10px] text-[#3A3A45] flex-shrink-0",children:MDe(i.createdAt)}),r.jsx(Jt,{className:ye("w-3 h-3 text-[#3A3A45] transition-transform flex-shrink-0",a&&"rotate-90")})]}),a&&r.jsxs("div",{className:"px-3 pb-3 space-y-2 border-t border-[#2A2A35]/50",children:[r.jsxs("div",{className:"mt-2",children:[r.jsx("span",{className:"text-[9px] text-[#5A5A6E] uppercase tracking-wider",children:"Task"}),r.jsx("pre",{className:"text-[11px] text-[#C8C8D4] whitespace-pre-wrap break-words mt-1 font-mono leading-relaxed",children:i.fullTask})]}),i.result&&r.jsxs("div",{children:[r.jsx("span",{className:"text-[9px] text-[#5A5A6E] uppercase tracking-wider",children:"Result"}),r.jsx("pre",{className:"text-[11px] text-[#C8C8D4] whitespace-pre-wrap break-words mt-1 font-mono leading-relaxed bg-[#0F0F11] rounded p-2 border border-[#2A2A35]/50",children:i.result})]})]})]},i.id)})})}function MDe(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3);if(n<60)return"just now";const s=Math.floor(n/60);if(s<60)return`${s}m ago`;const i=Math.floor(s/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function RDe(){const[e,t]=y.useState(""),[n,s]=y.useState(""),[i,a]=y.useState(null),[o,l]=y.useState(!1),[c,d]=y.useState(""),[f,p]=y.useState(""),[m,g]=y.useState(null),[b,_]=y.useState(null),[w,A]=y.useState(null),S=L.federation.listNodes.useQuery(void 0,{refetchInterval:Ae=>Ae.state.data?.some(Ut=>Ut.status==="pending")?3e3:!1}),C=L.federation.spawnAvailability.useQuery(),E=L.federation.registerNode.useMutation({onSuccess:Ae=>{a(Ae.authToken),t(""),s(""),S.refetch()}}),k=L.federation.syncAgents.useMutation({onSuccess:()=>S.refetch()}),T=L.federation.removeNode.useMutation({onSuccess:()=>S.refetch()}),F=L.federation.spawnLocal.useMutation({onSuccess:()=>{d(""),p(""),g(null),S.refetch()},onError:Ae=>g(Ae.message)}),M=L.federation.destroyLocal.useMutation({onSuccess:()=>S.refetch()}),I=L.federation.stopLocal.useMutation({onSuccess:()=>S.refetch()}),R=L.federation.startLocal.useMutation({onSuccess:()=>S.refetch()}),H=L.federation.setDelegationPolicy.useMutation({onSuccess:()=>S.refetch()}),V=L.federation.getSpawnDefaults.useQuery(),K=L.federation.setSpawnDefaults.useMutation({onSuccess:()=>V.refetch()}),[q,$]=y.useState(""),[B,Y]=y.useState("nbg1"),[U,W]=y.useState("cx22"),[O,D]=y.useState(null),Q=L.federation.cloudAvailability.useQuery(),z=L.federation.cloudCatalog.useQuery(),J=L.federation.spawnCloud.useMutation({onSuccess:()=>{$(""),D(null),S.refetch()},onError:Ae=>D(Ae.message)}),ee=L.federation.destroyCloud.useMutation({onSuccess:()=>S.refetch()}),re=L.federation.addToAllowlist.useMutation({onSuccess:()=>S.refetch()}),oe=L.federation.removeFromAllowlist.useMutation({onSuccess:()=>S.refetch()}),[se,ae]=y.useState(null),{data:le=[]}=L.agents.list.useQuery(),ge=S.data??[],je=C.data?.ok===!0,Ee={active:"#10B981",pending:"#F59E0B",unreachable:"#EF4444",revoked:"#5A5A6E"},de=()=>{g(null);const Ae=c.trim();if(!Ae){g("Name is required");return}const ct=f.trim()?Number(f.trim()):void 0;if(f.trim()&&(!Number.isInteger(ct)||ct<1024||ct>65535)){g("Port must be 1024–65535");return}F.mutate({name:Ae,port:ct})},me=V.data,$e=me?.defaultNodeSpawnPolicy??"coo-only",nt=me?.cooAutoApproveNodeSpawn??!1;return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"rounded-lg border border-[#2A2A35] bg-[#16161A] p-4 space-y-3",children:[r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"w-7 h-7 rounded-lg bg-[#8A8A99]/15 flex items-center justify-center flex-shrink-0",children:r.jsx(ch,{className:"w-3.5 h-3.5 text-[#8A8A99]"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h3",{className:"text-[12px] font-semibold text-[#F0F0F5]",children:"Spawn Defaults"}),r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mt-0.5",children:"Policies applied to every newly spawned node — whether from this UI or from the COO."})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{className:"text-[10px] text-[#8A8A99] uppercase tracking-wider block",children:"Default delegation policy for new spawns"}),r.jsxs(ss,{value:$e,onValueChange:Ae=>K.mutate({defaultNodeSpawnPolicy:Ae}),children:[r.jsxs(is,{disabled:K.isPending,className:"w-full flex items-center justify-between bg-[#0F0F11] border border-[#2A2A35] rounded px-3 py-2 text-[12px] text-[#F0F0F5] outline-none focus:border-[#6366F1]/40 disabled:opacity-50",children:[r.jsxs(Ds,{children:[r.jsx("span",{style:{color:$d[$e]?.color??"#8A8A99"},children:$d[$e]?.label??$e}),r.jsxs("span",{className:"text-[#5A5A6E] ml-2",children:[$e==="closed"&&"— no cross-instance dispatch until you opt in",$e==="coo-only"&&"— only the COO can dispatch (safest default)",$e==="approval-required"&&"— every dispatch requires user approval",$e==="open"&&"— any agent can dispatch (trusted compute)"]})]}),r.jsx(ft,{className:"w-3 h-3 text-[#8A8A99]"})]}),r.jsx(rs,{children:r.jsx(as,{position:"popper",sideOffset:4,className:"z-50 bg-[#0F0F11] border border-[#2A2A35] rounded-lg shadow-2xl py-1 min-w-[var(--radix-select-trigger-width)]",children:r.jsx(os,{children:["closed","coo-only","approval-required","open"].map(Ae=>{const ct=$d[Ae];return r.jsx(vn,{value:Ae,className:"px-3 py-2 text-[11px] cursor-pointer outline-none hover:bg-[#16161A] data-[state=checked]:bg-[#16161A]",children:r.jsx(yn,{children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:ct.color}}),r.jsx("span",{style:{color:ct.color},children:ct.label})]})})},Ae)})})})})]})]}),r.jsxs("label",{className:"flex items-start gap-2 cursor-pointer group",children:[r.jsx("input",{type:"checkbox",checked:nt,onChange:Ae=>K.mutate({cooAutoApproveNodeSpawn:Ae.target.checked}),disabled:K.isPending,className:"mt-0.5 accent-[#6366F1]"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"text-[12px] text-[#F0F0F5]",children:"Auto-approve COO node-spawn requests"}),r.jsxs("div",{className:"text-[11px] text-[#5A5A6E] mt-0.5",children:["When on, the COO can spawn new isolated nodes without waiting for your explicit approval. Safer default is ",r.jsx("strong",{className:"text-[#F0F0F5]",children:"off"})," — you review each spawn before it fires."]})]})]})]}),r.jsxs("div",{className:"rounded-lg border border-[#6366F1]/20 bg-gradient-to-br from-[#6366F1]/5 to-transparent p-4 space-y-3",children:[r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"w-8 h-8 rounded-lg bg-[#6366F1]/15 flex items-center justify-center flex-shrink-0",children:r.jsx(Mp,{className:"w-4 h-4 text-[#6366F1]"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h3",{className:"text-[13px] font-semibold text-[#F0F0F5]",children:"Spawn Local Node"}),r.jsx("p",{className:"text-[11px] text-[#8A8A99] mt-0.5",children:"One click → isolated damn.dev container on this machine, auto-federated. Each node gets its own DB, agents, and OpenClaw workspace."})]})]}),!je&&C.data?r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded bg-[#F59E0B]/10 border border-[#F59E0B]/20 text-[11px] text-[#F59E0B]",children:[r.jsx(Rs,{className:"w-3.5 h-3.5 flex-shrink-0"}),r.jsx("span",{children:C.data.reason})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{value:c,onChange:Ae=>d(Ae.target.value),placeholder:"Node name (e.g. client-a)",className:"flex-1 bg-[#16161A] border border-[#2A2A35] rounded px-3 py-1.5 text-[12px] text-[#F0F0F5] placeholder-[#3A3A45] outline-none focus:border-[#6366F1]/40"}),r.jsx("input",{value:f,onChange:Ae=>p(Ae.target.value),placeholder:"Port (auto)",className:"w-32 bg-[#16161A] border border-[#2A2A35] rounded px-3 py-1.5 text-[12px] text-[#F0F0F5] placeholder-[#3A3A45] outline-none focus:border-[#6366F1]/40"}),r.jsxs("button",{onClick:de,disabled:!c.trim()||F.isPending||!je,className:"px-4 py-1.5 rounded bg-[#6366F1] text-white text-[12px] font-medium hover:bg-[#5558E6] transition-colors disabled:opacity-50 flex items-center gap-1.5",children:[F.isPending?r.jsx(Pe,{className:"w-3 h-3 animate-spin"}):r.jsx(Mp,{className:"w-3 h-3"}),"Spawn"]})]}),F.isPending&&r.jsx("p",{className:"text-[11px] text-[#8A8A99]",children:"Building image (first time only, ~3 min), starting containers, waiting for health check…"}),m&&r.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 rounded bg-[#EF4444]/10 border border-[#EF4444]/20 text-[11px] text-[#EF4444]",children:[r.jsx(Rs,{className:"w-3.5 h-3.5 flex-shrink-0 mt-0.5"}),r.jsx("span",{className:"break-all",children:m})]})]})]}),r.jsxs("div",{className:"rounded-lg border border-[#10B981]/20 bg-gradient-to-br from-[#10B981]/5 to-transparent p-4 space-y-3",children:[r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"w-8 h-8 rounded-lg bg-[#10B981]/15 flex items-center justify-center flex-shrink-0",children:r.jsx(Xt,{className:"w-4 h-4 text-[#10B981]"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h3",{className:"text-[13px] font-semibold text-[#F0F0F5]",children:"Spawn Cloud Node"}),r.jsx("p",{className:"text-[11px] text-[#8A8A99] mt-0.5",children:"Provision a VPS on Hetzner. Auto-installs damn.dev and federates with this hub. Takes 2–4 minutes."})]})]}),Q.data&&!Q.data.ok?r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded bg-[#F59E0B]/10 border border-[#F59E0B]/20 text-[11px] text-[#F59E0B]",children:[r.jsx(Rs,{className:"w-3.5 h-3.5 flex-shrink-0"}),r.jsx("span",{children:Q.data.reason})]}):Q.data?.ok?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex gap-2",children:r.jsx("input",{value:q,onChange:Ae=>$(Ae.target.value),placeholder:"Node name (e.g. prod-eu)",className:"flex-1 bg-[#16161A] border border-[#2A2A35] rounded px-3 py-1.5 text-[12px] text-[#F0F0F5] placeholder-[#3A3A45] outline-none focus:border-[#10B981]/40"})}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(ss,{value:B,onValueChange:Y,children:[r.jsxs(is,{className:"flex-1 flex items-center justify-between bg-[#16161A] border border-[#2A2A35] rounded px-3 py-1.5 text-[12px] text-[#F0F0F5] outline-none focus:border-[#10B981]/40",children:[r.jsxs(Ds,{children:[z.data?.hetzner.regions.find(Ae=>Ae.id===B)?.flag," ",z.data?.hetzner.regions.find(Ae=>Ae.id===B)?.label??B]}),r.jsx(ft,{className:"w-3 h-3 text-[#8A8A99]"})]}),r.jsx(rs,{children:r.jsx(as,{position:"popper",sideOffset:4,className:"z-50 bg-[#0F0F11] border border-[#2A2A35] rounded-lg shadow-2xl py-1 min-w-[var(--radix-select-trigger-width)]",children:r.jsx(os,{children:(z.data?.hetzner.regions??[]).map(Ae=>r.jsx(vn,{value:Ae.id,className:"px-3 py-2 text-[11px] cursor-pointer outline-none hover:bg-[#16161A] data-[state=checked]:bg-[#16161A]",children:r.jsxs(yn,{children:[Ae.flag," ",Ae.label," (",Ae.country,")"]})},Ae.id))})})})]}),r.jsxs(ss,{value:U,onValueChange:W,children:[r.jsxs(is,{className:"flex-1 flex items-center justify-between bg-[#16161A] border border-[#2A2A35] rounded px-3 py-1.5 text-[12px] text-[#F0F0F5] outline-none focus:border-[#10B981]/40",children:[r.jsx(Ds,{children:z.data?.hetzner.sizes.find(Ae=>Ae.id===U)?.label??U}),r.jsx(ft,{className:"w-3 h-3 text-[#8A8A99]"})]}),r.jsx(rs,{children:r.jsx(as,{position:"popper",sideOffset:4,className:"z-50 bg-[#0F0F11] border border-[#2A2A35] rounded-lg shadow-2xl py-1 min-w-[var(--radix-select-trigger-width)]",children:r.jsx(os,{children:(z.data?.hetzner.sizes??[]).map(Ae=>r.jsx(vn,{value:Ae.id,className:"px-3 py-2 text-[11px] cursor-pointer outline-none hover:bg-[#16161A] data-[state=checked]:bg-[#16161A]",children:r.jsxs(yn,{children:[Ae.label," — $",Ae.monthlyCost,"/mo"]})},Ae.id))})})})]})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("span",{className:"text-[11px] text-[#10B981]",children:["Est. ~$",z.data?.hetzner.sizes.find(Ae=>Ae.id===U)?.monthlyCost??"?","/mo"]}),r.jsxs("button",{onClick:()=>J.mutate({name:q.trim(),provider:"hetzner",region:B,size:U}),disabled:!q.trim()||J.isPending,className:"px-4 py-1.5 rounded bg-[#10B981] text-white text-[12px] font-medium hover:bg-[#0EA472] transition-colors disabled:opacity-50 flex items-center gap-1.5",children:[J.isPending?r.jsx(Pe,{className:"w-3 h-3 animate-spin"}):r.jsx(Xt,{className:"w-3 h-3"}),"Provision"]})]}),r.jsx("p",{className:"text-[10px] text-[#F59E0B]",children:"Federation traffic over HTTP (unencrypted). Cloudflare DNS + TLS planned for a future update."}),J.isPending&&r.jsx("p",{className:"text-[11px] text-[#8A8A99]",children:"Creating server, installing damn.dev, waiting for health check… (2–4 minutes)"}),O&&r.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 rounded bg-[#EF4444]/10 border border-[#EF4444]/20 text-[11px] text-[#EF4444]",children:[r.jsx(Rs,{className:"w-3.5 h-3.5 flex-shrink-0 mt-0.5"}),r.jsx("span",{className:"break-all",children:O})]})]}):null]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{className:"text-[11px] text-[#8A8A99] uppercase tracking-wider",children:"Add Remote Node"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{value:e,onChange:Ae=>t(Ae.target.value),placeholder:"Node name (e.g. vps-eu)",className:"flex-1 bg-[#16161A] border border-[#2A2A35] rounded px-3 py-1.5 text-[12px] text-[#F0F0F5] placeholder-[#3A3A45] outline-none focus:border-[#6366F1]/40"}),r.jsx("input",{value:n,onChange:Ae=>s(Ae.target.value),placeholder:"https://node.example.com:3001",className:"flex-1 bg-[#16161A] border border-[#2A2A35] rounded px-3 py-1.5 text-[12px] text-[#F0F0F5] placeholder-[#3A3A45] outline-none focus:border-[#6366F1]/40"}),r.jsx("button",{onClick:()=>E.mutate({name:e.trim(),url:n.trim()}),disabled:!e.trim()||!n.trim()||E.isPending,className:"px-3 py-1.5 rounded bg-[#2A2A35] text-[#F0F0F5] text-[12px] font-medium hover:bg-[#3A3A45] transition-colors disabled:opacity-50",children:E.isPending?r.jsx(Pe,{className:"w-3 h-3 animate-spin"}):r.jsx(wt,{className:"w-3 h-3"})})]}),n.trim()&&(n.includes("localhost")||n.includes("127.0.0.1"))&&r.jsxs("p",{className:"text-[10px] text-[#6366F1]/70 mt-1 flex items-center gap-1",children:[r.jsx(Xt,{className:"w-2.5 h-2.5"}),"Federating two workspaces on the same instance — agents stay isolated but can dispatch tasks to each other."]})]}),i&&r.jsxs("div",{className:"p-3 rounded-lg bg-[#10B981]/10 border border-[#10B981]/20",children:[r.jsx("p",{className:"text-[12px] text-[#10B981] font-medium mb-1",children:"Node registered. Copy the auth token — it won't be shown again."}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("code",{className:"flex-1 text-[11px] font-mono text-[#10B981] bg-[#0F0F11] px-2 py-1 rounded truncate",children:i}),r.jsx("button",{onClick:()=>{navigator.clipboard.writeText(i),l(!0),setTimeout(()=>l(!1),2e3)},className:"px-2 py-1 rounded text-[11px] text-[#10B981] hover:bg-[#10B981]/10 transition-colors",children:o?r.jsx(Fe,{className:"w-3 h-3"}):r.jsx(Po,{className:"w-3 h-3"})})]}),r.jsx("p",{className:"text-[10px] text-[#8A8A99] mt-2",children:"Configure this token on the remote node, then sync agents."})]}),ge.length>0&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{className:"text-[11px] text-[#8A8A99] uppercase tracking-wider",children:"Nodes"}),ge.map(Ae=>{const ct=Ae.isLocal===!0,Ut=Ae.spawnType==="cloud",Os=Ae.delegationPolicy??"closed",qt=ct&&Ae.status==="unreachable",Gt=(I.isPending||R.isPending||M.isPending||ee.isPending||k.isPending)&&(I.variables?.nodeId===Ae.id||R.variables?.nodeId===Ae.id||M.variables?.nodeId===Ae.id||ee.variables?.nodeId===Ae.id||k.variables?.nodeId===Ae.id),on=(()=>{try{return JSON.parse(Ae.delegationAllowlist??"[]")}catch{return[]}})(),$r=se===Ae.id;return r.jsxs("div",{className:"rounded-lg bg-[#16161A] border border-[#2A2A35]",children:[r.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5",children:[r.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:Ee[Ae.status]??"#5A5A6E"}}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[13px] text-[#F0F0F5] font-medium truncate",children:Ae.name}),r.jsx("span",{className:ye("text-[9px] px-1.5 py-0.5 rounded font-medium uppercase tracking-wider",Ut?"bg-[#10B981]/15 text-[#10B981]":ct?"bg-[#6366F1]/15 text-[#6366F1]":"bg-[#2A2A35] text-[#8A8A99]"),children:Ut?"cloud":ct?"local":"remote"}),r.jsx("span",{className:"text-[10px] text-[#5A5A6E]",children:Ae.status}),r.jsx(DDe,{policy:Os,onChange:fe=>H.mutate({nodeId:Ae.id,policy:fe}),pending:H.isPending&&H.variables?.nodeId===Ae.id}),Ut&&Ae.monthlyCost&&r.jsxs("span",{className:"text-[9px] text-[#10B981]",children:["$",Ae.monthlyCost,"/mo"]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[11px] text-[#5A5A6E] truncate",children:Ae.url}),Ut&&Ae.cloudRegion&&r.jsx("span",{className:"text-[9px] text-[#5A5A6E]",children:Ae.cloudRegion})]})]}),r.jsxs("span",{className:"text-[11px] text-[#8A8A99]",children:[Ae.agentCount," agent",Ae.agentCount!==1?"s":""]}),Ae.remoteAgents.length>0&&r.jsx("div",{className:"flex -space-x-1",children:Ae.remoteAgents.slice(0,4).map(fe=>r.jsx("span",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[10px] border border-[#16161A]",style:{backgroundColor:fe.color+"20"},title:fe.name,children:fe.emoji},fe.id))}),r.jsx("button",{onClick:()=>ae($r?null:Ae.id),className:"px-1 py-1 rounded text-[11px] text-[#8A8A99] hover:bg-[#2A2A35] transition-colors",title:"Expand",children:r.jsx(ft,{className:ye("w-3 h-3 transition-transform",$r&&"rotate-180")})}),r.jsx("div",{className:"flex items-center gap-1",children:ct?r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:()=>A(Ae.id),disabled:Gt||qt,className:"px-2 py-1 rounded text-[11px] text-[#10B981] hover:bg-[#10B981]/10 transition-colors disabled:opacity-50",title:"Create agent",children:r.jsx(V2,{className:"w-3 h-3"})}),r.jsx("button",{onClick:()=>_(Ae.id),disabled:Gt,className:"px-2 py-1 rounded text-[11px] text-[#8A8A99] hover:bg-[#2A2A35] transition-colors disabled:opacity-50",title:"Logs",children:r.jsx(li,{className:"w-3 h-3"})}),qt?r.jsx("button",{onClick:()=>R.mutate({nodeId:Ae.id}),disabled:Gt,className:"px-2 py-1 rounded text-[11px] text-[#10B981] hover:bg-[#10B981]/10 transition-colors disabled:opacity-50",title:"Start",children:Gt&&R.variables?.nodeId===Ae.id?r.jsx(Pe,{className:"w-3 h-3 animate-spin"}):r.jsx(I5,{className:"w-3 h-3"})}):r.jsx("button",{onClick:()=>I.mutate({nodeId:Ae.id}),disabled:Gt,className:"px-2 py-1 rounded text-[11px] text-[#F59E0B] hover:bg-[#F59E0B]/10 transition-colors disabled:opacity-50",title:"Stop",children:Gt&&I.variables?.nodeId===Ae.id?r.jsx(Pe,{className:"w-3 h-3 animate-spin"}):r.jsx(L5,{className:"w-3 h-3"})}),r.jsx("button",{onClick:()=>k.mutate({nodeId:Ae.id}),disabled:Gt||qt,className:"px-2 py-1 rounded text-[11px] text-[#6366F1] hover:bg-[#6366F1]/10 transition-colors disabled:opacity-50",title:"Sync",children:Gt&&k.variables?.nodeId===Ae.id?r.jsx(Pe,{className:"w-3 h-3 animate-spin"}):r.jsx(Xi,{className:"w-3 h-3"})}),r.jsx("button",{onClick:()=>{confirm(`Destroy node "${Ae.name}"? This removes the container and all data.`)&&M.mutate({nodeId:Ae.id})},disabled:Gt,className:"px-2 py-1 rounded text-[11px] text-[#EF4444] hover:bg-[#EF4444]/10 transition-colors disabled:opacity-50",title:"Destroy",children:Gt&&M.variables?.nodeId===Ae.id?r.jsx(Pe,{className:"w-3 h-3 animate-spin"}):r.jsx(Dn,{className:"w-3 h-3"})})]}):Ut?r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:()=>k.mutate({nodeId:Ae.id}),disabled:Gt||Ae.status==="revoked",className:"px-2 py-1 rounded text-[11px] text-[#6366F1] hover:bg-[#6366F1]/10 transition-colors disabled:opacity-50",title:"Sync",children:k.isPending&&k.variables?.nodeId===Ae.id?r.jsx(Pe,{className:"w-3 h-3 animate-spin"}):r.jsx(Xi,{className:"w-3 h-3"})}),r.jsx("button",{onClick:()=>{confirm(`Destroy cloud node "${Ae.name}"? This DELETES the Hetzner server permanently.`)&&ee.mutate({nodeId:Ae.id})},disabled:Gt,className:"px-2 py-1 rounded text-[11px] text-[#EF4444] hover:bg-[#EF4444]/10 transition-colors disabled:opacity-50",title:"Destroy",children:ee.isPending&&ee.variables?.nodeId===Ae.id?r.jsx(Pe,{className:"w-3 h-3 animate-spin"}):r.jsx(Dn,{className:"w-3 h-3"})})]}):r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:()=>k.mutate({nodeId:Ae.id}),disabled:k.isPending||Ae.status==="revoked",className:"px-2 py-1 rounded text-[11px] text-[#6366F1] hover:bg-[#6366F1]/10 transition-colors disabled:opacity-50",children:k.isPending?r.jsx(Pe,{className:"w-3 h-3 animate-spin"}):r.jsx(Xi,{className:"w-3 h-3"})}),r.jsx("button",{onClick:()=>T.mutate({nodeId:Ae.id}),disabled:T.isPending,className:"px-2 py-1 rounded text-[11px] text-[#EF4444] hover:bg-[#EF4444]/10 transition-colors disabled:opacity-50",children:r.jsx(Dn,{className:"w-3 h-3"})})]})})]}),$r&&r.jsxs("div",{className:"px-3 pb-3 pt-1 border-t border-[#2A2A35]",children:[r.jsx("label",{className:"text-[10px] text-[#8A8A99] uppercase tracking-wider block mb-1.5",children:"Delegation Allowlist"}),r.jsx("p",{className:"text-[10px] text-[#5A5A6E] mb-2",children:"Agents on this list bypass the node's delegation policy (additive grant)."}),r.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2",children:[on.length===0&&r.jsx("span",{className:"text-[10px] text-[#3A3A45] italic",children:"No agents in allowlist"}),on.map(fe=>{const Ce=le.find(Ue=>Ue.id===fe);return r.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-[#6366F1]/10 text-[10px] text-[#6366F1]",children:[Ce?`${Ce.emoji??""} ${Ce.name}`:fe,r.jsx("button",{onClick:()=>oe.mutate({nodeId:Ae.id,agentId:fe}),className:"hover:text-[#EF4444] transition-colors",children:r.jsx(Te,{className:"w-2.5 h-2.5"})})]},fe)})]}),r.jsxs(ss,{onValueChange:fe=>re.mutate({nodeId:Ae.id,agentId:fe}),children:[r.jsxs(is,{className:"inline-flex items-center gap-1 px-2 py-1 rounded bg-[#2A2A35] text-[10px] text-[#8A8A99] hover:text-[#F0F0F5] transition-colors",children:[r.jsx(wt,{className:"w-2.5 h-2.5"}),r.jsx(Ds,{placeholder:"Add agent"})]}),r.jsx(rs,{children:r.jsx(as,{position:"popper",sideOffset:4,className:"z-50 bg-[#0F0F11] border border-[#2A2A35] rounded-lg shadow-2xl py-1 max-h-48 overflow-auto",children:r.jsx(os,{children:le.filter(fe=>!on.includes(fe.id)).map(fe=>r.jsx(vn,{value:fe.id,className:"px-3 py-1.5 text-[11px] cursor-pointer outline-none hover:bg-[#16161A] text-[#F0F0F5]",children:r.jsxs(yn,{children:[fe.emoji??""," ",fe.name]})},fe.id))})})})]})]})]},Ae.id)})]}),ge.length===0&&!S.isLoading&&r.jsxs("div",{className:"py-8 text-center",children:[r.jsx(vre,{className:"w-8 h-8 text-[#2A2A35] mx-auto mb-2"}),r.jsx("p",{className:"text-[13px] text-[#5A5A6E]",children:"No federation nodes"}),r.jsx("p",{className:"text-[11px] text-[#3A3A45] mt-1",children:"Spawn a local node above, or add a remote damn.dev instance"})]}),r.jsx(PDe,{nodeId:b,onClose:()=>_(null)}),r.jsx(ODe,{nodeId:w,nodeName:ge.find(Ae=>Ae.id===w)?.name??"",onClose:()=>A(null),onCreated:()=>{A(null),S.refetch()}})]})}const $d={closed:{label:"closed",color:"#EF4444",bg:"#EF4444"},"coo-only":{label:"COO only",color:"#6366F1",bg:"#6366F1"},"approval-required":{label:"approval",color:"#F59E0B",bg:"#F59E0B"},open:{label:"open",color:"#10B981",bg:"#10B981"}};function DDe({policy:e,onChange:t,pending:n}){const s=$d[e]??$d.closed;return r.jsxs(ss,{value:e,onValueChange:i=>t(i),children:[r.jsxs(is,{disabled:n,className:"inline-flex items-center gap-1 text-[9px] uppercase tracking-wider px-1.5 py-0.5 rounded font-medium transition-colors disabled:opacity-50",style:{backgroundColor:s.bg+"20",color:s.color},title:"Cross-instance dispatch policy: who on this hub may delegate INTO this node",children:[r.jsx(Ds,{children:n?"…":s.label}),r.jsx(ft,{className:"w-2.5 h-2.5"})]}),r.jsx(rs,{children:r.jsx(as,{position:"popper",sideOffset:4,className:"z-50 bg-[#0F0F11] border border-[#2A2A35] rounded-lg shadow-2xl py-1 min-w-[180px]",children:r.jsx(os,{children:["closed","coo-only","approval-required","open"].map(i=>{const a=$d[i];return r.jsx(vn,{value:i,className:"px-3 py-2 text-[11px] cursor-pointer outline-none hover:bg-[#16161A] data-[state=checked]:bg-[#16161A]",children:r.jsx(yn,{children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:a.color}}),r.jsx("span",{style:{color:a.color},children:a.label})]})})},i)})})})})]})}function ODe({nodeId:e,nodeName:t,onClose:n,onCreated:s}){const[i,a]=y.useState(""),[o,l]=y.useState("🤖"),[c,d]=y.useState("#6366F1"),[f,p]=y.useState(""),[m,g]=y.useState("openrouter/anthropic/claude-sonnet-4.6"),[b,_]=y.useState(""),[w,A]=y.useState(null),S=L.federation.createRemoteAgent.useMutation({onSuccess:()=>{a(""),l("🤖"),d("#6366F1"),p(""),_(""),A(null),s()},onError:E=>A(E.message)}),C=()=>{if(A(null),!i.trim()||!o.trim()||!f.trim()||!b.trim()||!e){A("All fields are required");return}S.mutate({nodeId:e,name:i.trim(),emoji:o.trim(),color:c.trim(),role:f.trim(),model:m.trim(),soul:b.trim()})};return r.jsx(ji,{open:!!e,onOpenChange:E=>{E||(A(null),n())},children:r.jsxs(Ni,{children:[r.jsx(ir,{className:"fixed inset-0 bg-black/60 z-50"}),r.jsxs(ki,{className:"fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-[min(560px,90vw)] max-h-[85vh] bg-[#0F0F11] border border-[#2A2A35] rounded-lg shadow-2xl z-50 flex flex-col",children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[#2A2A35]",children:[r.jsxs(nr,{className:"text-[13px] font-semibold text-[#F0F0F5] flex items-center gap-2",children:[r.jsx(V2,{className:"w-4 h-4 text-[#10B981]"}),"Create agent on ",r.jsx("span",{className:"text-[#6366F1]",children:t})]}),r.jsx(Gs,{className:"px-2 py-1 rounded text-[11px] text-[#8A8A99] hover:bg-[#2A2A35] transition-colors",children:r.jsx(Te,{className:"w-3 h-3"})})]}),r.jsxs("div",{className:"flex-1 overflow-auto p-4 space-y-3",children:[r.jsxs("div",{className:"grid grid-cols-[80px_1fr] gap-2",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-[10px] text-[#8A8A99] uppercase tracking-wider block mb-1",children:"Emoji"}),r.jsx("input",{value:o,onChange:E=>l(E.target.value),maxLength:4,className:"w-full bg-[#16161A] border border-[#2A2A35] rounded px-2 py-1.5 text-[14px] text-center text-[#F0F0F5] outline-none focus:border-[#6366F1]/40"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-[10px] text-[#8A8A99] uppercase tracking-wider block mb-1",children:"Name"}),r.jsx("input",{value:i,onChange:E=>a(E.target.value),placeholder:"Researcher",maxLength:50,className:"w-full bg-[#16161A] border border-[#2A2A35] rounded px-2 py-1.5 text-[12px] text-[#F0F0F5] placeholder-[#3A3A45] outline-none focus:border-[#6366F1]/40"})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-[10px] text-[#8A8A99] uppercase tracking-wider block mb-1",children:"Role"}),r.jsx("input",{value:f,onChange:E=>p(E.target.value),placeholder:"e.g. Market researcher and competitive analysis",maxLength:120,className:"w-full bg-[#16161A] border border-[#2A2A35] rounded px-2 py-1.5 text-[12px] text-[#F0F0F5] placeholder-[#3A3A45] outline-none focus:border-[#6366F1]/40"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-[10px] text-[#8A8A99] uppercase tracking-wider block mb-1",children:"Color"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{value:c,onChange:E=>d(E.target.value),className:"flex-1 bg-[#16161A] border border-[#2A2A35] rounded px-2 py-1.5 text-[12px] font-mono text-[#F0F0F5] outline-none focus:border-[#6366F1]/40"}),r.jsx("span",{className:"w-8 h-8 rounded border border-[#2A2A35]",style:{backgroundColor:c}})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-[10px] text-[#8A8A99] uppercase tracking-wider block mb-1",children:"Model"}),r.jsx("input",{value:m,onChange:E=>g(E.target.value),className:"w-full bg-[#16161A] border border-[#2A2A35] rounded px-2 py-1.5 text-[11px] font-mono text-[#F0F0F5] outline-none focus:border-[#6366F1]/40"})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-[10px] text-[#8A8A99] uppercase tracking-wider block mb-1",children:"Soul (system prompt)"}),r.jsx("textarea",{value:b,onChange:E=>_(E.target.value),placeholder:"You are a market researcher. You produce concise, evidence-based competitive analyses...",rows:8,className:"w-full bg-[#16161A] border border-[#2A2A35] rounded px-2 py-1.5 text-[12px] text-[#F0F0F5] placeholder-[#3A3A45] outline-none focus:border-[#6366F1]/40 font-mono leading-relaxed resize-none"})]}),w&&r.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 rounded bg-[#EF4444]/10 border border-[#EF4444]/20 text-[11px] text-[#EF4444]",children:[r.jsx(Rs,{className:"w-3.5 h-3.5 flex-shrink-0 mt-0.5"}),r.jsx("span",{className:"break-all",children:w})]})]}),r.jsxs("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-[#2A2A35]",children:[r.jsx("button",{onClick:n,disabled:S.isPending,className:"px-3 py-1.5 rounded text-[12px] text-[#8A8A99] hover:bg-[#2A2A35] transition-colors disabled:opacity-50",children:"Cancel"}),r.jsxs("button",{onClick:C,disabled:S.isPending||!i.trim()||!f.trim()||!b.trim(),className:"px-3 py-1.5 rounded bg-[#10B981] text-white text-[12px] font-medium hover:bg-[#059669] transition-colors disabled:opacity-50 flex items-center gap-1.5",children:[S.isPending?r.jsx(Pe,{className:"w-3 h-3 animate-spin"}):r.jsx(V2,{className:"w-3 h-3"}),"Create"]})]})]})]})})}function PDe({nodeId:e,onClose:t}){const n=L.federation.nodeLogs.useQuery({nodeId:e??"",lines:200},{enabled:!!e,refetchInterval:e?5e3:!1});return r.jsx(ji,{open:!!e,onOpenChange:s=>{s||t()},children:r.jsxs(Ni,{children:[r.jsx(ir,{className:"fixed inset-0 bg-black/60 z-50"}),r.jsxs(ki,{className:"fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-[min(900px,90vw)] max-h-[80vh] bg-[#0F0F11] border border-[#2A2A35] rounded-lg shadow-2xl z-50 flex flex-col",children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[#2A2A35]",children:[r.jsxs(nr,{className:"text-[13px] font-semibold text-[#F0F0F5] flex items-center gap-2",children:[r.jsx(li,{className:"w-4 h-4 text-[#6366F1]"}),"Node Logs"]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:()=>n.refetch(),disabled:n.isFetching,className:"px-2 py-1 rounded text-[11px] text-[#8A8A99] hover:bg-[#2A2A35] transition-colors disabled:opacity-50",children:n.isFetching?r.jsx(Pe,{className:"w-3 h-3 animate-spin"}):r.jsx(Xi,{className:"w-3 h-3"})}),r.jsx(Gs,{className:"px-2 py-1 rounded text-[11px] text-[#8A8A99] hover:bg-[#2A2A35] transition-colors",children:r.jsx(Te,{className:"w-3 h-3"})})]})]}),r.jsx("div",{className:"flex-1 overflow-auto p-4",children:n.isLoading?r.jsxs("div",{className:"flex items-center justify-center py-8 text-[12px] text-[#5A5A6E]",children:[r.jsx(Pe,{className:"w-4 h-4 animate-spin mr-2"}),"Fetching logs…"]}):n.error?r.jsx("div",{className:"text-[12px] text-[#EF4444]",children:n.error.message}):r.jsx("pre",{className:"text-[10px] font-mono text-[#A5A5B5] whitespace-pre-wrap break-all leading-relaxed",children:n.data?.logs??"(no output)"})})]})]})})}function IDe(){const{nodeId:e,agentId:t}=am(),n=an(),[s,i]=y.useState(""),a=y.useRef(null),o=y.useRef(0),l=L.federation.listNodes.useQuery(),c=l.data?.find(A=>A.id===e),d=c?.remoteAgents.find(A=>A.remoteAgentId===t),f=L.federation.remoteMessages.useQuery({nodeId:e,agentId:t,limit:80},{enabled:!!e&&!!t,refetchInterval:A=>A.state.status==="error"?!1:3e3,retry:1}),p=L.federation.remoteSend.useMutation({onSuccess:()=>{i(""),f.refetch()}}),g=(f.data?.messages??[]).map(A=>({id:A.id,channelId:`federation:${e}:${t}`,sender:{type:A.senderType,id:A.senderId,name:A.senderName,agentColor:A.agentColor??void 0},content:A.content,timestamp:A.timestamp}));y.useEffect(()=>{g.length>o.current&&a.current?.scrollIntoView({behavior:"smooth"}),o.current=g.length},[g.length]);function b(){const A=s.trim();!A||!e||!t||p.mutate({nodeId:e,agentId:t,message:A})}const _=f.isError,w=c?.status==="unreachable"||c?.status==="revoked";return r.jsxs("div",{className:"flex flex-col flex-1 overflow-hidden bg-[#0C0C0E]",children:[r.jsxs("div",{className:"flex items-center gap-3 px-5 py-3 border-b border-[#1E1E28] bg-[#0F0F11]",children:[r.jsx("button",{onClick:()=>n(-1),className:"text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:r.jsx(gm,{className:"w-4 h-4"})}),d&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-[18px]",children:d.emoji}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[14px] font-semibold text-[#F0F0F5]",children:d.name}),c&&r.jsxs("span",{className:"flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-[#6366F1]/10 text-[#818CF8]",children:[r.jsx(Xt,{className:"w-2.5 h-2.5"}),c.name]}),c&&r.jsx("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:c.status==="active"?"#10B981":c.status==="pending"?"#F59E0B":"#EF4444"}})]}),d.role&&r.jsx("p",{className:"text-[11px] text-[#5A5A6E] truncate",children:d.role})]})]}),!d&&!l.isLoading&&r.jsx("span",{className:"text-[13px] text-[#5A5A6E]",children:"Agent not found"})]}),r.jsxs("div",{className:"flex items-center gap-2 px-5 py-1.5 bg-[#6366F1]/5 border-b border-[#6366F1]/10",children:[r.jsx(Xt,{className:"w-3 h-3 text-[#6366F1]/60"}),r.jsxs("span",{className:"text-[10px] text-[#6366F1]/60",children:["Remote channel on ",c?.name??"unknown node"," — messages polled every 3s"]})]}),(_||w)&&r.jsxs("div",{className:"flex items-center gap-2 px-5 py-2 bg-[#EF4444]/5 border-b border-[#EF4444]/10",children:[r.jsx(ql,{className:"w-3.5 h-3.5 text-[#EF4444]"}),r.jsx("span",{className:"text-[11px] text-[#EF4444]",children:w?`Node "${c?.name}" is ${c?.status} — cannot fetch messages`:"Failed to fetch messages from remote node"})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-1",children:[f.isLoading&&!_&&g.length===0&&r.jsx("div",{className:"flex items-center justify-center py-16",children:r.jsx(Pe,{className:"w-5 h-5 animate-spin text-[#5A5A6E]"})}),!f.isLoading&&g.length===0&&!_&&r.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[r.jsx(Xt,{className:"w-10 h-10 text-[#2A2A35] mb-3"}),r.jsx("p",{className:"text-[13px] text-[#5A5A6E]",children:"No messages yet"}),r.jsx("p",{className:"text-[11px] text-[#3A3A45] mt-1",children:"Send a message to start a conversation with this remote agent"})]}),g.map(A=>r.jsx(Z7,{message:A,agentColor:d?.color},A.id)),r.jsx("div",{ref:a})]}),r.jsxs("div",{className:"px-5 py-3 border-t border-[#1E1E28] bg-[#0F0F11]",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{value:s,onChange:A=>i(A.target.value),onKeyDown:A=>{A.key==="Enter"&&!A.shiftKey&&(A.preventDefault(),b())},placeholder:d?`Message ${d.name} on ${c?.name??"remote node"}...`:"Send message...",disabled:w,className:"flex-1 bg-[#13131A] border border-[#2A2A35] rounded-lg px-4 py-2.5 text-[13px] text-[#F0F0F5] placeholder-[#3A3A45] outline-none focus:border-[#6366F1]/40 disabled:opacity-40 transition-colors"}),r.jsx("button",{onClick:b,disabled:!s.trim()||p.isPending||w,className:"px-4 py-2.5 rounded-lg bg-[#6366F1]/10 text-[#6366F1] hover:bg-[#6366F1]/20 transition-colors disabled:opacity-30",children:p.isPending?r.jsx(Pe,{className:"w-4 h-4 animate-spin"}):r.jsx(Ji,{className:"w-4 h-4"})})]}),p.isError&&r.jsx("p",{className:"text-[10px] text-[#EF4444] mt-1 px-1",children:p.error.message})]})]})}const AW=new Set([".png",".jpg",".jpeg",".gif",".bmp",".webp",".svg"]);function Ty(e){const t=e.match(/\.(kanban|chart|table|board)\.json$/);return t?t[1]:null}function LDe(e){const t=Ty(e);return t?{kanban:"Kanban Board",chart:"Chart",table:"Data Table",board:"Card Grid"}[t]??"":""}const BDe={kanban:nL,chart:M5,table:wL,board:ym},zDe={kanban:"#6366F1",chart:"#10B981",table:"#3B82F6",board:"#8B5CF6"},$De={structured:ym,code:rL,images:hL,documents:li,other:gv};function VDe({file:e}){const t=Ty(e.name);if(t){const s=BDe[t],i=zDe[t];return r.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center flex-shrink-0",style:{backgroundColor:`${i}15`},children:r.jsx(s,{className:"w-5 h-5",style:{color:i}})})}if(AW.has(e.ext))return r.jsx("div",{className:"w-10 h-10 rounded-lg overflow-hidden flex-shrink-0 bg-[#1C1C24]",children:r.jsx("img",{src:`${oi}/api/files/serve/${e.agentId}/${e.path}`,alt:e.name,className:"w-full h-full object-cover",loading:"lazy"})});const n=$De[e.category]??gv;return r.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center flex-shrink-0 bg-white/[0.04]",children:r.jsx(n,{className:"w-5 h-5 text-[#5A5A6E]"})})}function UDe({file:e,agentEmoji:t,agentName:n,agentColor:s,onClick:i}){const o=Ty(e.name)?LDe(e.name):null,l=Math.round(e.size/1024);return r.jsxs(ne.button,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,scale:.97},transition:{duration:.15},onClick:i,className:"flex items-start gap-3 p-3 rounded-xl border border-[#2A2A35] bg-[#16161A] hover:bg-[#1C1C24] hover:border-[#3A3A48] transition-all duration-100 text-left w-full group",children:[r.jsx(VDe,{file:e}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"flex items-center gap-1.5 mb-0.5",children:r.jsx("span",{className:"text-[13px] font-medium text-[#F0F0F5] truncate",children:e.name})}),o&&r.jsx("span",{className:"text-[11px] text-[#8A8A99] block",children:o}),r.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[t&&n&&r.jsxs("span",{className:"flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded-full",style:{backgroundColor:`${s??"#6366F1"}12`,color:s??"#818CF8"},children:[r.jsx("span",{className:"text-[10px] leading-none",children:t}),n]}),r.jsx("span",{className:"text-[10px] text-[#5A5A6E]",children:l>0?`${l}KB`:"<1KB"}),r.jsx("span",{className:"text-[10px] text-[#5A5A6E]",children:new Date(e.modified).toLocaleDateString()})]})]})]})}function HDe({file:e,onClose:t}){return Ty(e.name)?r.jsx(yN,{agentId:e.agentId,filePath:e.path,onClose:t}):AW.has(e.ext)?r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70",onClick:t,children:r.jsx(ne.img,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},src:`${oi}/api/files/serve/${e.agentId}/${e.path}`,alt:e.name,className:"max-w-[90vw] max-h-[85vh] rounded-xl shadow-2xl",onClick:s=>s.stopPropagation()})}):r.jsx(WDe,{file:e,onClose:t})}function WDe({file:e,onClose:t}){const{data:n,isLoading:s}=L.files.read.useQuery({agentId:e.agentId,filePath:e.path},{retry:!1});return r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:t,children:r.jsxs(ne.div,{initial:{scale:.95,opacity:0},animate:{scale:1,opacity:1},className:"w-[700px] max-h-[80vh] bg-[#13131A] border border-[#2A2A35] rounded-xl shadow-2xl flex flex-col overflow-hidden",onClick:i=>i.stopPropagation(),children:[r.jsxs("div",{className:"px-4 py-3 border-b border-[#2A2A35] flex items-center justify-between flex-shrink-0",children:[r.jsx("span",{className:"text-[13px] font-semibold text-[#F0F0F5] truncate",children:e.name}),r.jsx("button",{onClick:t,className:"text-[#5A5A6E] hover:text-[#C8C8D4] transition-colors text-[18px] leading-none",children:"×"})]}),r.jsxs("div",{className:"flex-1 overflow-auto min-h-0",children:[s&&r.jsx("div",{className:"flex items-center justify-center py-12 text-[#5A5A6E] text-[12px]",children:"Loading..."}),!s&&n?.content&&r.jsxs("pre",{className:"p-4 text-[12px] font-mono text-[#C8C8D4] leading-relaxed whitespace-pre-wrap break-all",children:[n.content.slice(0,5e3),n.content.length>5e3&&r.jsxs("span",{className:"text-[#5A5A6E]",children:[`
|
|
430
430
|
|
|
@@ -432,4 +432,4 @@ Any required environment variables or binaries.
|
|
|
432
432
|
${o.trim()}`:o.trim();f.mutate({id:e.id,description:m})}}return r.jsxs("div",{className:"px-6 pb-4 border-t border-[#1E1E28]/50",children:[e.description&&r.jsx("p",{className:"text-[12px] text-[#8A8A99] mt-3 mb-3",children:e.description}),r.jsx("div",{className:"mt-2 space-y-1",children:e.tasks.map(m=>r.jsx(CW,{task:m,missionId:e.id,missionTitle:e.title,agent:m.agent??(m.agentId?t[m.agentId]:null),agentChannel:m.agent??(m.agentId?t[m.agentId]:null)?s.find(g=>g.agentId===m.agentId&&g.channelType==="dm"):void 0},m.id))}),r.jsx(XDe,{missionId:e.id}),r.jsx(i8e,{missionId:e.id}),r.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[r.jsx("input",{value:o,onChange:m=>l(m.target.value),onKeyDown:m=>{m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),p())},placeholder:d.length>0?`Message all ${d.length} active agent${d.length!==1?"s":""}...`:"Add context to this mission...",className:"flex-1 bg-[#0F0F11] border border-[#2A2A35] rounded px-3 py-1.5 text-[12px] text-[#F0F0F5] placeholder-[#3A3A45] outline-none focus:border-[#6366F1]/40"}),r.jsx("button",{onClick:p,disabled:!o.trim()||c.isPending,className:"px-3 py-1.5 rounded bg-[#6366F1]/10 text-[#6366F1] text-[11px] font-medium hover:bg-[#6366F1]/20 transition-colors disabled:opacity-30",children:c.isPending?r.jsx(Pe,{className:"w-3 h-3 animate-spin"}):r.jsx(Ji,{className:"w-3 h-3"})})]}),i&&a.length>0&&r.jsx("div",{className:"flex items-center gap-2 mt-2",children:r.jsxs("button",{onClick:n,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-[#6366F1]/10 text-[#6366F1] text-[12px] font-medium hover:bg-[#6366F1]/20 transition-colors",children:[r.jsx(Ji,{className:"w-3 h-3"}),"Dispatch ",a.length," ready task",a.length!==1?"s":""]})})]})}function XDe({missionId:e}){const{data:t}=L.missions.worktreeStatus.useQuery({missionId:e}),n=L.useUtils(),s=L.missions.mergeWorktree.useMutation({onSuccess:()=>{n.missions.worktreeStatus.invalidate({missionId:e}),n.missions.list.invalidate()}}),i=L.missions.discardWorktree.useMutation({onSuccess:()=>{n.missions.worktreeStatus.invalidate({missionId:e}),n.missions.list.invalidate()}});return t?r.jsxs("div",{className:"mt-3 flex items-center gap-2.5 px-3 py-2 rounded-md bg-[#13131A] border border-[#2A2A35]/50",children:[r.jsx(Zl,{className:"w-3.5 h-3.5 text-[#8B5CF6] flex-shrink-0"}),r.jsx("span",{className:"text-[12px] font-mono text-[#A78BFA]",children:t.branch}),t.fileCount>0&&r.jsxs("span",{className:"text-[10px] text-[#8A8A99]",children:[t.fileCount," file",t.fileCount!==1?"s":""," changed"]}),r.jsx("div",{className:"flex-1"}),r.jsxs("button",{onClick:()=>s.mutate({missionId:e}),disabled:s.isPending,className:"flex items-center gap-1 px-2 py-1 rounded text-[11px] text-[#10B981] hover:bg-[#10B981]/10 transition-colors disabled:opacity-50",children:[s.isPending?r.jsx(Pe,{className:"w-3 h-3 animate-spin"}):r.jsx(D5,{className:"w-3 h-3"}),"Merge"]}),r.jsxs("button",{onClick:()=>i.mutate({missionId:e}),disabled:i.isPending,className:"flex items-center gap-1 px-2 py-1 rounded text-[11px] text-[#EF4444] hover:bg-[#EF4444]/10 transition-colors disabled:opacity-50",children:[r.jsx(Dn,{className:"w-3 h-3"}),"Discard"]})]}):null}function JDe({missions:e,agentMap:t}){const{data:n=[]}=L.channels.list.useQuery(),s=L.useUtils(),i=L.missions.update.useMutation({onSuccess:()=>s.missions.list.invalidate()}),[a,o]=y.useState(null),l=[{status:"planning",label:"Planning"},{status:"active",label:"Active"},{status:"paused",label:"Paused"},{status:"completed",label:"Completed"}];function c(m){o(m.active.id)}const d=L.missions.reorderMissions.useMutation({onSuccess:()=>s.missions.list.invalidate()});function f(m){o(null);const{active:g,over:b}=m;if(!b||!g)return;const _=g.id,w=b.id,A=e.find(E=>E.id===_);if(!A)return;const S=l.map(E=>E.status);let C;if(S.includes(w))C=w;else{const E=e.find(k=>k.id===w);if(!E)return;C=E.status}if(A.status!==C){i.mutate({id:_,status:C});return}if(!S.includes(w)&&w!==_){const k=e.filter(I=>I.status===C).map(I=>I.id),T=k.indexOf(_),F=k.indexOf(w);if(T===-1||F===-1)return;const M=[...k];M.splice(T,1),M.splice(F,0,_),d.mutate({missionIds:M})}}const p=a?e.find(m=>m.id===a):null;return r.jsxs(vV,{collisionDetection:sV,onDragStart:c,onDragEnd:f,children:[r.jsx("div",{className:"flex-1 overflow-x-auto overflow-y-hidden",children:r.jsx("div",{className:"flex gap-4 px-6 py-4 h-full min-w-max",children:l.map(m=>{const g=e.filter(b=>b.status===m.status);return r.jsx(ZDe,{status:m.status,label:m.label,count:g.length,children:r.jsx(sN,{items:g.map(b=>b.id),strategy:SV,children:g.map(b=>r.jsx(e8e,{mission:b,agentMap:t,channels:n},b.id))})},m.status)})})}),r.jsx(wV,{children:p&&r.jsxs("div",{className:"w-[280px] bg-[#16161A] border border-[#6366F1]/40 rounded-lg p-3 shadow-2xl rotate-2 opacity-90",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:My[p.priority]}}),r.jsx("span",{className:"text-[13px] text-[#F0F0F5] font-medium truncate",children:p.title})]}),r.jsxs("span",{className:"text-[10px] text-[#5A5A6E] mt-1 block",children:[p.tasks.length," tasks"]})]})})]})}function ZDe({status:e,label:t,count:n,children:s}){const{setNodeRef:i,isOver:a}=_V({id:e});return r.jsxs("div",{ref:i,className:ye("w-[300px] flex flex-col flex-shrink-0 rounded-lg transition-colors",a&&"bg-[#6366F1]/5 ring-1 ring-[#6366F1]/20"),children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 mb-2",children:[r.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:Qi[e]}}),r.jsx("span",{className:"text-[12px] font-medium text-[#8A8A99] uppercase tracking-wider",children:t}),r.jsx("span",{className:"text-[10px] text-[#3A3A45] ml-1",children:n})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 px-1 min-h-[60px]",children:[s,n===0&&r.jsx("div",{className:"flex items-center justify-center py-8 text-[#2A2A35]",children:r.jsx("span",{className:"text-[11px]",children:"Drop here"})})]})]})}function e8e({mission:e,agentMap:t,channels:n}){const{attributes:s,listeners:i,setNodeRef:a,transform:o,transition:l,isDragging:c}=iN({id:e.id}),d={transform:Oo.Transform.toString(o),transition:l},[f,p]=y.useState(""),[m,g]=y.useState(!1),b=L.messages.send.useMutation({onSuccess:()=>p("")}),_=L.missions.update.useMutation({onSuccess:()=>L.useUtils().missions.list.invalidate()}),w=e.priority,A=e.tasks.length,S=e.tasks.filter(F=>F.status==="completed").length,C=e.tasks.filter(F=>F.status==="working"||F.status==="dispatched").length,E=[...new Set(e.tasks.map(F=>F.agentId).filter(Boolean))].map(F=>t[F]??e.tasks.find(M=>M.agentId===F)?.agent).filter(Boolean),k=[...new Set(e.tasks.filter(F=>F.status==="working"||F.status==="dispatched"||F.status==="completed").map(F=>F.agentId).filter(Boolean))];function T(){if(f.trim())if(k.length>0){const F=`[Mission: ${e.title}] ${f.trim()}`;for(const M of k){const I=n.find(R=>R.agentId===M&&R.channelType==="dm");I&&b.mutate({channelId:I.id,content:F})}p("")}else{const F=e.description?`${e.description}
|
|
433
433
|
${f.trim()}`:f.trim();_.mutate({id:e.id,description:F}),p("")}}return r.jsxs("div",{ref:a,style:d,...s,className:ye("bg-[#16161A] border border-[#2A2A35] rounded-lg hover:border-[#3A3A45] transition-colors",c&&"opacity-40 ring-2 ring-[#6366F1]/30"),children:[r.jsxs("div",{...i,className:"flex items-start gap-2 p-3 pb-0 cursor-grab active:cursor-grabbing group/header",children:[r.jsx(dL,{className:"w-3 h-3 mt-0.5 text-[#2A2A35] group-hover/header:text-[#5A5A6E] transition-colors flex-shrink-0"}),r.jsx("div",{className:"w-1.5 h-1.5 rounded-full mt-1.5 flex-shrink-0",style:{backgroundColor:My[w]}}),r.jsx("span",{className:"text-[13px] text-[#F0F0F5] font-medium leading-tight flex-1",children:e.title}),e.ephemeralNodeId&&r.jsx("span",{className:"text-[8px] px-1 py-0.5 rounded bg-[#10B981]/15 text-[#10B981] font-medium uppercase tracking-wider flex-shrink-0",children:"ephemeral"})]}),r.jsxs("div",{className:"px-3 pb-3",children:[e.description&&r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mt-1 mb-2 line-clamp-2 pl-6",children:e.description}),A>0&&r.jsxs("div",{className:"space-y-1 mt-2 mb-2",children:[(m?e.tasks:e.tasks.slice(0,3)).map(F=>{const M=F.agent??(F.agentId?t[F.agentId]:null),I=M?n.find(R=>R.agentId===M.id&&R.channelType==="dm"):void 0;return r.jsx(CW,{task:F,missionId:e.id,missionTitle:e.title,agent:M,agentChannel:I,compact:!0},F.id)}),e.tasks.length>3&&r.jsx("button",{onClick:()=>g(!m),className:"text-[10px] text-[#6366F1] hover:text-[#818CF8] pl-5 transition-colors",children:m?"Show less":`+${e.tasks.length-3} more`}),(()=>{const F=e.tasks.filter(M=>M.status==="completed"&&M.agentTasks?.some(I=>I.result));return F.length===0?null:r.jsxs("div",{className:"flex items-center gap-1 pl-5 mt-0.5",children:[r.jsx(Fe,{className:"w-2.5 h-2.5 text-[#10B981]"}),r.jsxs("span",{className:"text-[10px] text-[#10B981]",children:[F.length," result",F.length!==1?"s":""," available"]})]})})()]}),r.jsxs("div",{className:"flex items-center gap-1.5 mt-2",children:[r.jsx("input",{value:f,onChange:F=>p(F.target.value),onKeyDown:F=>{F.key==="Enter"&&!F.shiftKey&&(F.preventDefault(),T())},placeholder:k.length>0?`Message ${k.length} agent${k.length!==1?"s":""}...`:"Add context...",className:"flex-1 bg-[#0F0F11] border border-[#2A2A35] rounded px-2 py-1 text-[10px] text-[#F0F0F5] placeholder-[#3A3A45] outline-none focus:border-[#6366F1]/40"}),r.jsx("button",{onClick:T,disabled:!f.trim()||b.isPending,className:"p-1 rounded text-[#6366F1] hover:bg-[#6366F1]/10 transition-colors disabled:opacity-30",children:b.isPending?r.jsx(Pe,{className:"w-3 h-3 animate-spin"}):r.jsx(Ji,{className:"w-3 h-3"})})]}),r.jsxs("div",{className:"flex items-center gap-2 pt-2 mt-2 border-t border-[#2A2A35]/50",children:[r.jsx("div",{className:"flex -space-x-1",children:E.slice(0,3).map((F,M)=>F&&r.jsx("span",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[9px] border border-[#16161A]",style:{backgroundColor:F.color+"20",zIndex:3-M},children:F.emoji},F.id))}),r.jsx("div",{className:"flex-1"}),A>0&&r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("div",{className:"w-12 h-1 bg-[#1E1E28] rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full rounded-full",style:{width:`${S/A*100}%`,backgroundColor:Qi[e.status]}})}),r.jsxs("span",{className:"text-[9px] text-[#5A5A6E] tabular-nums",children:[S,"/",A]})]}),C>0&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[9px] text-[#6366F1]",children:[r.jsx("span",{className:"w-1 h-1 rounded-full bg-[#6366F1] animate-pulse"}),C]})]})]})]})}function t8e({missions:e,agentMap:t}){return r.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:e.map(n=>r.jsx(n8e,{mission:n,agentMap:t},n.id))})}function n8e({mission:e,agentMap:t}){const{data:n}=L.dashboard.timeline.useQuery({missionId:e.id}),s=e.status;return r.jsxs("div",{className:"mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:Qi[s]}}),r.jsx("span",{className:"text-[13px] font-medium text-[#F0F0F5]",children:e.title}),r.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{color:Qi[s],backgroundColor:Qi[s]+"15"},children:nv[s]})]}),r.jsx("div",{className:"space-y-1 pl-4 border-l-2 border-[#2A2A35]",children:(n?.tasks??e.tasks).map(i=>{const a=i.agent??(i.agentId?t[i.agentId]:null),o=i.status;return r.jsxs("div",{className:"flex items-center gap-2 py-1",children:[r.jsx(jW,{status:i.status}),a&&r.jsx("span",{className:"text-[11px]",children:a.emoji}),r.jsx("span",{className:"text-[12px] text-[#C8C8D4] flex-1 truncate",children:i.title}),"startedAt"in i&&i.startedAt&&r.jsx("span",{className:"text-[10px] text-[#5A5A6E] font-mono",children:new Date(i.startedAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}),"completedAt"in i&&i.completedAt&&r.jsxs("span",{className:"text-[10px] text-[#5A5A6E]",children:["→ ",new Date(i.completedAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]}),r.jsx("span",{className:"text-[10px] px-1 py-0.5 rounded",style:{color:Qi[o]??"#8A8A99",backgroundColor:(Qi[o]??"#8A8A99")+"10"},children:i.status})]},i.id)})}),n?.events&&n.events.length>0&&r.jsx("div",{className:"mt-2 pl-4 space-y-0.5",children:n.events.slice(-8).map((i,a)=>r.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-[#5A5A6E]",children:[r.jsx("span",{className:"font-mono",children:new Date(i.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),r.jsx("span",{className:ye(i.type.includes("completed")?"text-[#10B981]":i.type.includes("failed")?"text-[#EF4444]":i.type.includes("dispatched")?"text-[#6366F1]":"text-[#8A8A99]"),children:i.type.replace(/_/g," ")}),i.agentEmoji&&r.jsx("span",{children:i.agentEmoji}),i.taskTitle&&r.jsx("span",{className:"text-[#8A8A99] truncate",children:i.taskTitle}),i.detail&&r.jsxs("span",{className:"text-[#5A5A6E]",children:["(",i.detail,")"]})]},a))})]})}function s8e({agentId:e,onClose:t}){const{data:n}=L.dashboard.agentPerformance.useQuery({agentId:e}),{data:s=[]}=L.agents.list.useQuery(),i=s.find(o=>o.id===e);if(!n||!i)return null;const a=n.successRate!==null?Math.round(n.successRate*100):null;return r.jsxs(ne.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"absolute right-4 top-16 w-[280px] bg-[#16161A] border border-[#2A2A35] rounded-xl shadow-2xl z-30 overflow-hidden",children:[r.jsxs("div",{className:"px-4 py-3 border-b border-[#2A2A35] flex items-center gap-2",children:[r.jsx("span",{className:"w-7 h-7 rounded-full flex items-center justify-center text-[14px]",style:{backgroundColor:i.color+"20"},children:i.emoji}),r.jsxs("div",{className:"flex-1",children:[r.jsx("span",{className:"text-[13px] font-medium text-[#F0F0F5]",children:i.name}),r.jsx("span",{className:"text-[10px] text-[#5A5A6E] block",children:i.role})]}),r.jsx("button",{onClick:t,className:"text-[#5A5A6E] hover:text-[#C8C8D4]",children:r.jsx(Te,{className:"w-3.5 h-3.5"})})]}),r.jsxs("div",{className:"px-4 py-3 space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[11px] text-[#8A8A99]",children:"Success rate"}),r.jsx("span",{className:ye("text-[13px] font-medium",a!==null&&a>=80?"text-[#10B981]":a!==null&&a>=50?"text-[#F59E0B]":"text-[#EF4444]"),children:a!==null?`${a}%`:"—"})]}),r.jsx("div",{className:"h-1.5 bg-[#1E1E28] rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${a??0}%`,backgroundColor:(a??0)>=80?"#10B981":(a??0)>=50?"#F59E0B":"#EF4444"}})}),r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[r.jsxs("div",{className:"bg-[#0F0F11] rounded-lg px-2.5 py-2",children:[r.jsx("span",{className:"text-[10px] text-[#5A5A6E] block",children:"Completed"}),r.jsx("span",{className:"text-[14px] font-medium text-[#F0F0F5]",children:n.delegationsCompleted})]}),r.jsxs("div",{className:"bg-[#0F0F11] rounded-lg px-2.5 py-2",children:[r.jsx("span",{className:"text-[10px] text-[#5A5A6E] block",children:"Failed"}),r.jsx("span",{className:"text-[14px] font-medium text-[#EF4444]",children:n.delegationsFailed})]}),r.jsxs("div",{className:"bg-[#0F0F11] rounded-lg px-2.5 py-2",children:[r.jsx("span",{className:"text-[10px] text-[#5A5A6E] block",children:"Avg time"}),r.jsx("span",{className:"text-[14px] font-medium text-[#F0F0F5]",children:n.avgCompletionMs?`${Math.round(n.avgCompletionMs/1e3)}s`:"—"})]}),r.jsxs("div",{className:"bg-[#0F0F11] rounded-lg px-2.5 py-2",children:[r.jsx("span",{className:"text-[10px] text-[#5A5A6E] block",children:"Cost (7d)"}),r.jsxs("span",{className:"text-[14px] font-medium text-[#F0F0F5]",children:["$",n.costWeek.toFixed(2)]})]})]}),r.jsxs("div",{className:"flex items-center justify-between text-[11px]",children:[r.jsx("span",{className:"text-[#8A8A99]",children:"Last dream"}),r.jsx("span",{className:"text-[#C8C8D4]",children:n.lastDreamAt?new Date(n.lastDreamAt).toLocaleDateString():"Never"})]}),n.dreamInsights>0&&r.jsxs("div",{className:"flex items-center justify-between text-[11px]",children:[r.jsx("span",{className:"text-[#8A8A99]",children:"Dream insights"}),r.jsxs("span",{className:"text-[#8B5CF6]",children:[n.dreamInsights," notes"]})]}),Object.keys(n.bySource).length>0&&r.jsxs("div",{children:[r.jsx("span",{className:"text-[10px] text-[#5A5A6E] block mb-1",children:"Sources (7d)"}),r.jsx("div",{className:"flex gap-2",children:Object.entries(n.bySource).map(([o,l])=>r.jsxs("span",{className:"text-[10px] text-[#8A8A99] bg-[#0F0F11] px-1.5 py-0.5 rounded",children:[o,": ",l.calls," calls · $",l.cost.toFixed(2)]},o))})]}),n.currentTasks.length>0&&r.jsxs("div",{children:[r.jsx("span",{className:"text-[10px] text-[#5A5A6E] block mb-1",children:"Active tasks"}),n.currentTasks.map(o=>r.jsx("div",{className:"text-[11px] text-[#C8C8D4] truncate py-0.5",children:o.task.slice(0,60)},o.id))]})]})]})}function i8e({missionId:e}){const{data:t}=L.files.listMissionDeliverables.useQuery({missionId:e}),n=t?.files??[];if(n.length===0)return null;const s={};for(const a of n)s[a.category]=(s[a.category]??0)+1;const i={structured:ym,code:rL,images:hL,documents:li};return r.jsx("div",{className:"mt-3 px-3 py-2 rounded-md bg-[#13131A] border border-[#2A2A35]/50",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(li,{className:"w-3.5 h-3.5 text-[#8A8A99] flex-shrink-0"}),r.jsxs("span",{className:"text-[12px] text-[#C8C8D4]",children:[n.length," deliverable",n.length!==1?"s":""]}),r.jsx("div",{className:"flex-1"}),r.jsx("div",{className:"flex items-center gap-2",children:Object.entries(s).map(([a,o])=>{const l=i[a]??li;return r.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-[#5A5A6E]",children:[r.jsx(l,{className:"w-3 h-3"}),o]},a)})})]})})}function CW({task:e,missionId:t,missionTitle:n,agent:s,agentChannel:i,compact:a}){const o=an(),[l,c]=y.useState(!1),[d,f]=y.useState(""),p=e.status,m=L.useUtils(),g=L.missions.updateTask.useMutation({onSuccess:()=>{m.missions.list.invalidate(),f(""),c(!1)}}),b=L.messages.send.useMutation({onSuccess:()=>{f(""),c(!1)}});function _(){d.trim()&&(e.status==="pending"?g.mutate({missionTaskId:e.id,instruction:d.trim()}):i&&(e.status==="working"||e.status==="dispatched"||e.status==="completed")?b.mutate({channelId:i.id,content:`[Mission: ${n}] ${d.trim()}`}):e.status==="failed"&&e.agentId&&g.mutate({missionTaskId:e.id,instruction:d.trim(),status:"pending"}))}const w=e.status==="pending"?"Edit instruction before dispatch...":e.status==="failed"?"Fix instruction and retry...":e.status==="completed"?"Request revision...":"Send context to agent...",A=g.isPending||b.isPending;return r.jsxs("div",{className:"rounded-md bg-[#13131A]",children:[r.jsxs("div",{className:"flex items-center gap-2.5 py-1.5 px-3",children:[r.jsx(jW,{status:e.status}),r.jsx("button",{onClick:S=>{S.stopPropagation(),i&&o(`/channels/${i.id}`)},className:"text-[12px] text-[#C8C8D4] flex-1 truncate text-left hover:text-[#6366F1] transition-colors",title:i?"Open agent chat":e.title,children:e.title}),e.status==="completed"&&r.jsx("button",{onClick:S=>{S.stopPropagation(),o(`/deliverables?mission=${t}`)},className:"text-[#5A5A6E] hover:text-[#10B981] transition-colors",title:"View deliverables",children:r.jsx(lL,{className:"w-3 h-3"})}),r.jsx("button",{onClick:S=>{S.stopPropagation(),c(!l)},className:ye("transition-colors",l?"text-[#6366F1]":"text-[#3A3A45] hover:text-[#8A8A99]"),title:e.status==="pending"?"Edit instruction":e.status==="failed"?"Fix & retry":e.status==="completed"?"Request revision":"Send context to agent",children:r.jsx(Yse,{className:"w-3 h-3"})}),s&&r.jsxs("button",{onClick:S=>{S.stopPropagation(),i&&o(`/channels/${i.id}`)},className:"flex items-center gap-1 text-[11px] text-[#8A8A99] hover:text-[#F0F0F5] transition-colors",title:`Open ${s.name}'s chat`,children:[r.jsx("span",{children:s.emoji}),!a&&r.jsx("span",{children:s.name})]}),!s&&e.status==="pending"&&!a&&r.jsx("span",{className:"text-[10px] text-[#5A5A6E] italic",children:"unassigned"}),!a&&r.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{color:Qi[p]??"#8A8A99",backgroundColor:(Qi[p]??"#8A8A99")+"10"},children:e.status}),!a&&r.jsx(a8e,{taskId:e.id,status:e.status,missionId:t})]}),r.jsx(Me,{children:l&&r.jsx(ne.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},className:"overflow-hidden",children:r.jsxs("div",{className:"flex items-center gap-2 px-3 pb-2 pt-1",children:[r.jsx("input",{autoFocus:!0,value:d,onChange:S=>f(S.target.value),onKeyDown:S=>{S.key==="Enter"&&!S.shiftKey&&(S.preventDefault(),_()),S.key==="Escape"&&c(!1)},placeholder:w,className:"flex-1 bg-[#0F0F11] border border-[#2A2A35] rounded px-2.5 py-1.5 text-[11px] text-[#F0F0F5] placeholder-[#3A3A45] outline-none focus:border-[#6366F1]/40"}),r.jsx("button",{onClick:_,disabled:!d.trim()||A,className:"px-2 py-1.5 rounded bg-[#6366F1]/10 text-[#6366F1] hover:bg-[#6366F1]/20 transition-colors disabled:opacity-30",children:A?r.jsx(Pe,{className:"w-3 h-3 animate-spin"}):r.jsx(Ji,{className:"w-3 h-3"})}),e.status==="failed"&&d.trim()&&r.jsx("button",{onClick:()=>{g.mutate({missionTaskId:e.id,instruction:d.trim(),status:"pending"})},disabled:A,className:"px-2 py-1.5 rounded bg-[#F59E0B]/10 text-[#F59E0B] text-[10px] hover:bg-[#F59E0B]/20 transition-colors disabled:opacity-30",children:"Retry"})]})})}),!a&&r.jsx(r8e,{task:e,agent:s})]})}function r8e({task:e,agent:t}){const[n,s]=y.useState(!1),i=e.agentTasks?.find(d=>d.status==="completed"||d.status==="failed"),a=i?.result;if(e.status!=="completed"||!a)return null;const o=a.split(`
|
|
434
434
|
`),l=o.length>5,c=l&&!n?o.slice(0,5).join(`
|
|
435
|
-
`):a;return r.jsxs("div",{className:"mx-3 mb-2 rounded-md bg-[#0F0F11] border border-[#2A2A35]/50 p-3",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[t&&r.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-[#8A8A99]",children:[r.jsx("span",{children:t.emoji}),r.jsx("span",{children:t.name})]}),i?.crossInstance&&i.federationNodeName&&r.jsxs("span",{className:"flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded bg-[#6366F1]/10 text-[#818CF8]",children:[r.jsx(Xt,{className:"w-2.5 h-2.5"}),i.federationNodeName]}),r.jsx("span",{className:"text-[10px] text-[#5A5A6E]",children:"Result"})]}),r.jsx("pre",{className:"text-[11px] text-[#C8C8D4] whitespace-pre-wrap break-words leading-relaxed font-mono",children:c}),l&&r.jsx("button",{onClick:()=>s(!n),className:"text-[10px] text-[#6366F1] hover:text-[#818CF8] mt-1.5 transition-colors",children:n?"Collapse":`Show full result (${o.length} lines)`})]})}function a8e({taskId:e,status:t}){const[n,s]=y.useState(!1),i=L.useUtils(),a=L.missions.removeTask.useMutation({onSuccess:()=>{i.missions.list.invalidate(),s(!1)}}),o=L.missions.updateTask.useMutation({onSuccess:()=>{i.missions.list.invalidate(),s(!1)}});return r.jsxs("div",{className:"relative",children:[r.jsx("button",{onClick:l=>{l.stopPropagation(),s(!n)},className:"text-[#3A3A45] hover:text-[#8A8A99] transition-colors p-0.5",children:r.jsx(iL,{className:"w-3 h-3"})}),n&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"fixed inset-0 z-20",onClick:()=>s(!1)}),r.jsxs("div",{className:"absolute right-0 top-5 z-30 bg-[#1A1A24] border border-[#2A2A35] rounded-lg shadow-xl py-1 min-w-[140px]",children:[t==="pending"&&r.jsx("button",{onClick:l=>{l.stopPropagation(),s(!1)},className:"w-full text-left px-3 py-1.5 text-[11px] text-[#C8C8D4] hover:bg-white/5 transition-colors",children:"Edit instruction"}),(t==="working"||t==="dispatched")&&r.jsx("button",{onClick:l=>{l.stopPropagation(),o.mutate({missionTaskId:e,status:"cancelled"})},className:"w-full text-left px-3 py-1.5 text-[11px] text-[#F59E0B] hover:bg-[#F59E0B]/10 transition-colors",children:"Cancel task"}),t==="failed"&&r.jsx("button",{onClick:l=>{l.stopPropagation(),o.mutate({missionTaskId:e,status:"pending"})},className:"w-full text-left px-3 py-1.5 text-[11px] text-[#6366F1] hover:bg-[#6366F1]/10 transition-colors",children:"Retry task"}),t==="completed"&&r.jsx("button",{onClick:l=>{l.stopPropagation(),o.mutate({missionTaskId:e,status:"pending"})},className:"w-full text-left px-3 py-1.5 text-[11px] text-[#8A8A99] hover:bg-white/5 transition-colors",children:"Re-open"}),r.jsx("button",{onClick:l=>{l.stopPropagation(),a.mutate({missionTaskId:e})},className:"w-full text-left px-3 py-1.5 text-[11px] text-[#EF4444] hover:bg-[#EF4444]/10 transition-colors",children:"Remove"})]})]})]})}function jW({status:e}){switch(e){case"completed":return r.jsx(Fe,{className:"w-3.5 h-3.5 text-[#10B981]"});case"failed":return r.jsx(Te,{className:"w-3.5 h-3.5 text-[#EF4444]"});case"working":case"dispatched":return r.jsx(Pe,{className:"w-3.5 h-3.5 text-[#6366F1] animate-spin"});case"review":return r.jsx(ql,{className:"w-3.5 h-3.5 text-[#F59E0B]"});case"cancelled":return r.jsx(Te,{className:"w-3.5 h-3.5 text-[#5A5A6E]"});default:return r.jsx("div",{className:"w-3.5 h-3.5 rounded-full border border-[#3A3A45]"})}}function o8e({open:e,onClose:t,onCreated:n}){const[s,i]=y.useState(""),[a,o]=y.useState(""),[l,c]=y.useState("normal"),d=L.missions.create.useMutation({onSuccess:()=>n()});return r.jsx(ji,{open:e,onOpenChange:f=>{f||t()},children:r.jsxs(Ni,{children:[r.jsx(ir,{className:"fixed inset-0 bg-black/60 z-50"}),r.jsxs(ki,{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[460px] bg-[#16161A] border border-[#2A2A35] rounded-xl p-6 z-50 shadow-2xl",children:[r.jsx(nr,{className:"text-[15px] font-medium text-[#F0F0F5] mb-4",children:"New Mission"}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-[11px] text-[#8A8A99] uppercase tracking-wider mb-1 block",children:"Title"}),r.jsx("input",{autoFocus:!0,value:s,onChange:f=>i(f.target.value),placeholder:"What needs to be done?",className:"w-full px-3 py-2 bg-[#0F0F11] border border-[#2A2A35] rounded-md text-[13px] text-[#F0F0F5] placeholder-[#3A3A45] focus:outline-none focus:border-[#6366F1]",onKeyDown:f=>{f.key==="Enter"&&s.trim()&&d.mutate({title:s.trim(),description:a.trim()||void 0,priority:l})}})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-[11px] text-[#8A8A99] uppercase tracking-wider mb-1 block",children:"Description"}),r.jsx("textarea",{value:a,onChange:f=>o(f.target.value),placeholder:"Optional details...",rows:3,className:"w-full px-3 py-2 bg-[#0F0F11] border border-[#2A2A35] rounded-md text-[13px] text-[#F0F0F5] placeholder-[#3A3A45] focus:outline-none focus:border-[#6366F1] resize-none"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-[11px] text-[#8A8A99] uppercase tracking-wider mb-1 block",children:"Priority"}),r.jsx("div",{className:"flex gap-2",children:["low","normal","high","critical"].map(f=>r.jsx("button",{onClick:()=>c(f),className:ye("px-3 py-1.5 rounded-md text-[12px] font-medium transition-colors",l===f?"text-white":"text-[#5A5A6E] bg-[#1E1E28] hover:text-[#8A8A99]"),style:l===f?{backgroundColor:My[f]}:void 0,children:SW[f]},f))})]})]}),r.jsxs("div",{className:"flex items-center justify-end gap-2 mt-5",children:[r.jsx(Gs,{asChild:!0,children:r.jsx("button",{className:"px-3 py-1.5 rounded-md text-[12px] text-[#8A8A99] hover:text-[#C8C8D4] transition-colors",children:"Cancel"})}),r.jsxs("button",{onClick:()=>{s.trim()&&d.mutate({title:s.trim(),description:a.trim()||void 0,priority:l})},disabled:!s.trim()||d.isPending,className:"flex items-center gap-1.5 px-4 py-1.5 rounded-md bg-[#6366F1] text-white text-[12px] font-medium hover:bg-[#5558E6] transition-colors disabled:opacity-50",children:[d.isPending&&r.jsx(Pe,{className:"w-3 h-3 animate-spin"}),"Create Mission"]})]})]})]})})}const l8e=4;function c8e({current:e}){return r.jsx("div",{className:"flex items-center gap-2",children:Array.from({length:l8e}).map((t,n)=>r.jsx("div",{className:ye("rounded-full transition-all duration-300",n<e?"w-2 h-2 bg-[#6366F1]":n===e?"w-6 h-2 bg-[#6366F1]":"w-2 h-2 bg-[#2A2A35]")},n))})}function Vd({children:e}){return r.jsx(ne.div,{initial:{opacity:0,x:24},animate:{opacity:1,x:0},exit:{opacity:0,x:-24},transition:{duration:.22,ease:[.16,1,.3,1]},className:"w-full max-w-lg mx-auto",children:e})}function lO({onDetected:e,alreadyRunning:t}){const[n,s]=y.useState("."),i=L.onboarding.pollOpenClaw.useQuery(void 0,{refetchInterval:3e3,refetchOnWindowFocus:!1,retry:!1});return y.useEffect(()=>{t||i.data?.running&&e()},[i.data?.running]),y.useEffect(()=>{const a=setInterval(()=>s(o=>o.length>=3?".":o+"."),500);return()=>clearInterval(a)},[]),i.data?.running?r.jsxs("div",{className:"flex items-center gap-2 mt-4 text-[12px] text-emerald-400",children:[r.jsx(sa,{className:"w-3.5 h-3.5"}),"OpenClaw detected — advancing…"]}):r.jsxs("div",{className:"flex items-center gap-2 mt-4 text-[12px] text-[#5A5A6E]",children:[r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#5A5A6E] animate-pulse"}),"Waiting for OpenClaw",n]})}function IC({code:e}){const[t,n]=y.useState(!1);function s(){navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}return r.jsxs("div",{className:"flex items-center justify-between bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 font-mono text-[12px] text-[#C8C8D4]",children:[r.jsx("span",{children:e}),r.jsx("button",{onClick:s,className:ye("ml-3 flex-shrink-0 transition-colors",t?"text-emerald-400":"text-[#5A5A6E] hover:text-[#C8C8D4]"),children:t?r.jsx(Fe,{className:"w-3.5 h-3.5"}):r.jsx(Po,{className:"w-3.5 h-3.5"})})]})}function u8e({onNext:e,onSkip:t}){const{data:n,isLoading:s}=L.onboarding.checkOpenClaw.useQuery(void 0,{refetchOnWindowFocus:!1,retry:!1}),i=L.onboarding.skipOpenClaw.useMutation(),[a,o]=y.useState(!1),[l,c]=y.useState("docker"),[d,f]=y.useState(void 0);n?.runMode&&n.runMode!==d&&(f(n.runMode),n.runMode==="docker"?c("npm"):n.runMode==="npm"&&c("docker"));const[p,m]=y.useState(""),[g,b]=y.useState(!1),[_,w]=y.useState(""),[A,S]=y.useState(""),[C,E]=y.useState("idle"),k=L.onboarding.saveWaitlistEmail.useMutation(),T=L.onboarding.testConnection.useMutation();if(s)return r.jsx(Vd,{children:r.jsxs("div",{className:"flex items-center gap-3 py-8",children:[r.jsx(Pe,{className:"w-4 h-4 animate-spin text-[#6366F1]"}),r.jsx("span",{className:"text-[14px] text-[#8A8A99]",children:"Checking OpenClaw…"})]})});async function F(){await i.mutateAsync(),t()}async function M(){if(!_.trim()||!A.trim())return;E("testing");const q=await T.mutateAsync({url:_.trim(),token:A.trim()});E(q.ok?"ok":"fail"),q.ok&&setTimeout(()=>e(),1e3)}async function I(){p.trim()&&(await k.mutateAsync({email:p.trim()}),b(!0))}const R=n?.running===!0,H=n?.runMode??null,K=[{id:"docker",label:"Docker",sub:"Agents run isolated",badge:"Recommended"},{id:"npm",label:"Local (npm)",sub:"Best for dedicated machines",badge:null},{id:"cloud",label:"Cloud (VPS)",sub:"Always-on, team access",badge:null}].filter(q=>q.id!==H);return R&&!a?r.jsxs(Vd,{children:[r.jsx("h2",{className:"text-[22px] font-semibold text-[#F0F0F5] mb-2",children:"Connect OpenClaw"}),r.jsx("p",{className:"text-[14px] text-[#8A8A99] mb-6 leading-relaxed",children:"damn.dev runs agents through OpenClaw, the local AI gateway."}),r.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 rounded-xl bg-emerald-500/10 border border-emerald-500/20 mb-6",children:[r.jsx(sa,{className:"w-4 h-4 text-emerald-400 flex-shrink-0"}),r.jsxs("div",{className:"flex-1",children:[r.jsxs("p",{className:"text-[13px] font-medium text-emerald-400",children:["OpenClaw detected",H==="docker"?" via Docker":H==="cloud"?" via Cloud":H==="npm"?" locally":""]}),(n.agentCount??0)>0&&r.jsxs("p",{className:"text-[11px] text-emerald-400/70",children:[n.agentCount," agent",n.agentCount!==1?"s":""," detected"]})]})]}),r.jsxs("button",{onClick:e,className:"flex items-center gap-2 px-5 py-2.5 rounded-xl text-[13px] font-medium bg-[#6366F1] text-white hover:bg-[#5254CC] transition-colors mb-4",children:["Continue",r.jsx(Jt,{className:"w-3.5 h-3.5"})]}),r.jsx("button",{onClick:()=>o(!0),className:"text-[12px] text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:"Want to connect to a different instance?"})]}):r.jsxs(Vd,{children:[r.jsx("h2",{className:"text-[22px] font-semibold text-[#F0F0F5] mb-2",children:"Connect OpenClaw"}),r.jsx("p",{className:"text-[14px] text-[#8A8A99] mb-6 leading-relaxed",children:"damn.dev runs agents through OpenClaw, the local AI gateway."}),R&&a&&r.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 rounded-xl bg-emerald-500/10 border border-emerald-500/20 mb-4",children:[r.jsx(sa,{className:"w-4 h-4 text-emerald-400 flex-shrink-0"}),r.jsx("div",{className:"flex-1",children:r.jsxs("p",{className:"text-[13px] font-medium text-emerald-400",children:["OpenClaw is running",H==="docker"?" via Docker":H==="cloud"?" via Cloud":H==="npm"?" locally":""]})}),r.jsxs("button",{onClick:e,className:"ml-auto flex items-center gap-1 text-[12px] font-medium text-emerald-400 hover:text-emerald-300 transition-colors flex-shrink-0",children:["Continue ",r.jsx(Jt,{className:"w-3 h-3"})]})]}),r.jsx("div",{className:ye("grid gap-3 mb-4",K.length===2?"grid-cols-2":"grid-cols-3"),children:K.map(q=>r.jsxs("button",{onClick:()=>c(q.id),className:ye("relative text-left rounded-2xl p-4 border transition-all",l===q.id?"border-[#6366F1]/50 bg-[#6366F1]/5 ring-1 ring-[#6366F1]/20":"border-[#2A2A35] bg-[#16161A] hover:border-[#3A3A45]"),children:[q.badge&&r.jsx("span",{className:"absolute -top-2 left-3 px-1.5 py-0.5 rounded text-[9px] font-semibold bg-[#6366F1] text-white tracking-wide",children:q.badge}),r.jsx("p",{className:"text-[13px] font-medium text-[#F0F0F5] mt-1",children:q.label}),r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mt-0.5",children:q.sub})]},q.id))}),r.jsxs("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-5 mb-4",children:[l==="docker"&&r.jsxs("div",{children:[r.jsxs("a",{href:"https://www.docker.com/products/docker-desktop/",target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 w-full justify-center py-2 px-4 rounded-lg border border-[#2A2A35] text-[13px] text-[#C8C8D4] hover:border-[#3A3A45] hover:text-[#F0F0F5] transition-colors mb-3",children:[r.jsx(cs,{className:"w-3.5 h-3.5"}),"Download Docker Desktop"]}),r.jsx("button",{onClick:()=>window.open("http://localhost:3001/setup/docker-compose.yml","_blank"),className:"flex items-center gap-2 w-full justify-center py-2 px-4 rounded-lg bg-[#6366F1]/10 border border-[#6366F1]/30 text-[13px] text-[#6366F1] hover:bg-[#6366F1]/20 transition-colors mb-4",children:"Download docker-compose.yml"}),r.jsx("p",{className:"text-[12px] text-[#8A8A99] leading-relaxed",children:"Open Docker Desktop → Compose → Open File → Run"}),r.jsx(lO,{onDetected:e,alreadyRunning:R})]}),l==="npm"&&r.jsxs("div",{children:[r.jsxs("div",{className:"space-y-2 mb-4",children:[r.jsx(IC,{code:"npm install -g openclaw"}),r.jsx(IC,{code:"openclaw start"})]}),r.jsx(lO,{onDetected:e,alreadyRunning:R})]}),l==="cloud"&&r.jsxs("div",{className:"space-y-5",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-[13px] font-medium text-[#C8C8D4] mb-1",children:"Want OpenClaw fully managed in the cloud?"}),r.jsx("p",{className:"text-[12px] text-[#8A8A99] mb-3",children:"Join the waitlist for cloud.damn.dev."}),g?r.jsx("p",{className:"text-[12px] text-emerald-400",children:"You're on the list. We'll notify you when cloud.damn.dev launches."}):r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{type:"email",value:p,onChange:q=>m(q.target.value),placeholder:"you@example.com",className:"flex-1 bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] placeholder:text-[#5A5A6E] outline-none focus:border-[#6366F1]/50 transition-colors"}),r.jsx("button",{onClick:I,disabled:!p.trim()||k.isPending,className:"px-3 py-2 rounded-lg text-[12px] font-medium bg-[#6366F1]/10 text-[#6366F1] border border-[#6366F1]/30 hover:bg-[#6366F1]/20 disabled:opacity-50 transition-colors flex-shrink-0",children:k.isPending?r.jsx(Pe,{className:"w-3.5 h-3.5 animate-spin"}):"Join waitlist"})]})]}),r.jsxs("div",{className:"border-t border-[#2A2A35] pt-5",children:[r.jsx("p",{className:"text-[13px] font-medium text-[#C8C8D4] mb-3",children:"Already running on a VPS?"}),r.jsxs("div",{className:"space-y-2 mb-3",children:[r.jsx("input",{type:"url",value:_,onChange:q=>{w(q.target.value),E("idle")},placeholder:"https://openclaw.myserver.com",className:"w-full bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] placeholder:text-[#5A5A6E] outline-none focus:border-[#6366F1]/50 transition-colors"}),r.jsx("input",{type:"password",value:A,onChange:q=>{S(q.target.value),E("idle")},placeholder:"Bearer token",className:"w-full bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] placeholder:text-[#5A5A6E] outline-none focus:border-[#6366F1]/50 transition-colors"})]}),r.jsxs("button",{onClick:M,disabled:!_.trim()||!A.trim()||C==="testing"||C==="ok",className:"flex items-center gap-2 px-4 py-2 rounded-lg text-[12px] font-medium bg-[#6366F1]/10 text-[#6366F1] border border-[#6366F1]/30 hover:bg-[#6366F1]/20 disabled:opacity-50 transition-colors",children:[C==="testing"&&r.jsx(Pe,{className:"w-3.5 h-3.5 animate-spin"}),C==="ok"&&r.jsx(Fe,{className:"w-3.5 h-3.5 text-emerald-400"}),C==="fail"&&r.jsx(Te,{className:"w-3.5 h-3.5 text-red-400"}),C==="ok"?"Connected":"Test connection"]})]})]})]}),r.jsx("button",{onClick:F,className:"text-[12px] text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:"I'll connect OpenClaw later →"})]})}function d8e({onDetected:e}){const[t,n]=y.useState("."),s=L.onboarding.pollOllama.useQuery(void 0,{refetchInterval:3e3,refetchOnWindowFocus:!1,retry:!1});return y.useEffect(()=>{s.data?.running&&s.data.models.length>0&&e(s.data.models)},[s.data?.running]),y.useEffect(()=>{const i=setInterval(()=>n(a=>a.length>=3?".":a+"."),500);return()=>clearInterval(i)},[]),s.data?.running?r.jsxs("div",{className:"flex items-center gap-2 mt-3 text-[12px] text-emerald-400",children:[r.jsx(sa,{className:"w-3.5 h-3.5"}),"Ollama detected"]}):r.jsxs("div",{className:"flex items-center gap-2 mt-3 text-[12px] text-[#5A5A6E]",children:[r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#5A5A6E] animate-pulse"}),"Waiting for Ollama",t]})}function h8e({onNext:e,onSkip:t}){const[n,s]=y.useState(""),[i,a]=y.useState(""),[o,l]=y.useState(""),[c,d]=y.useState(""),[f,p]=y.useState(null),[m,g]=y.useState(null),[b,_]=y.useState(!1),[w,A]=y.useState(null),[S,C]=y.useState(null),[E,k]=y.useState(""),[T,F]=y.useState(""),[M,I]=y.useState(""),[R,H]=y.useState(""),[V,K]=y.useState([]),[q,$]=y.useState(!1),B=y.useRef(null),{data:Y,isLoading:U}=L.onboarding.checkModels.useQuery(void 0,{refetchOnWindowFocus:!1,retry:!1}),{data:W}=L.onboarding.getState.useQuery(void 0,{refetchOnWindowFocus:!1});y.useEffect(()=>{Y?.envOpenRouterConfigured&&!w&&(A({valid:!0,modelCount:Y.openRouterModelCount??0,suggestedReasoningModel:W?.defaultReasoningModel??null,suggestedFastModel:W?.defaultFastModel??null}),s("sk-or-v1-••••••••••••••••••••••••••••••••"),W?.defaultReasoningModel&&!E&&k(W.defaultReasoningModel),W?.defaultFastModel&&!T&&F(W.defaultFastModel)),(Y?.ollamaModels?.length??0)>0&&K(Y.ollamaModels)},[Y?.envOpenRouterConfigured,Y?.ollamaModels?.length,W?.defaultReasoningModel]);const O=L.onboarding.validateApiKey.useMutation(),D=L.onboarding.setDefaultModels.useMutation();function Q(me){me.suggestedReasoningModel&&!E&&k(me.suggestedReasoningModel),me.suggestedFastModel&&!T&&F(me.suggestedFastModel)}async function z(){if(!n.trim())return;const me=await O.mutateAsync({provider:"openrouter",key:n.trim()});A(me),me.valid&&Q(me)}async function J(){if(!i.trim())return;const me=await O.mutateAsync({provider:"anthropic",key:i.trim()});C(me),me.valid&&Q(me)}async function ee(){if(!o.trim())return;const me=await O.mutateAsync({provider:"openai",key:o.trim()});p(me),me.valid&&Q(me)}async function re(){if(!c.trim())return;const me=await O.mutateAsync({provider:"gemini",key:c.trim()});g(me),me.valid&&Q(me)}const oe=V.length>0,se=oe||w?.valid===!0||S?.valid===!0||f?.valid===!0||m?.valid===!0||Y?.envOpenRouterConfigured===!0,ae=[];if(oe)for(const me of V)ae.push({id:me,label:me,group:"Ollama"});if(w?.valid){const me=[{id:"anthropic/claude-sonnet-4.6",label:"Claude Sonnet 4.6"},{id:"anthropic/claude-opus-4.6",label:"Claude Opus 4.6"},{id:"anthropic/claude-haiku-4.5",label:"Claude Haiku 4.5"},{id:"openai/gpt-4o",label:"GPT-4o"},{id:"openai/gpt-4o-mini",label:"GPT-4o mini"},{id:"google/gemini-2.5-pro",label:"Gemini 2.5 Pro"},{id:"google/gemini-2.5-flash",label:"Gemini 2.5 Flash"},{id:"meta-llama/llama-3.3-70b-instruct:free",label:"Llama 3.3 70B (free)"}];for(const $e of me)ae.push({...$e,group:"OpenRouter"})}if(S?.valid){const me=[{id:"anthropic/claude-sonnet-4.6",label:"Claude Sonnet 4.6"},{id:"anthropic/claude-opus-4.6",label:"Claude Opus 4.6"},{id:"anthropic/claude-haiku-4.5",label:"Claude Haiku 4.5"}];for(const $e of me)ae.some(nt=>nt.id===$e.id)||ae.push({...$e,group:"Anthropic"})}if(f?.valid){const me=[{id:"openai/gpt-4o",label:"GPT-4o"},{id:"openai/gpt-4o-mini",label:"GPT-4o mini"}];for(const $e of me)ae.some(nt=>nt.id===$e.id)||ae.push({...$e,group:"OpenAI"})}if(m?.valid){const me=[{id:"google/gemini-2.5-pro",label:"Gemini 2.5 Pro"},{id:"google/gemini-2.5-flash",label:"Gemini 2.5 Flash"}];for(const $e of me)ae.some(nt=>nt.id===$e.id)||ae.push({...$e,group:"Google"})}const le=se&&ae.length>0,je=(Y?.ramGb??0)>=8,Ee=Y?.recommendedLocalModel??null,de=Y?.recommendedModelSize??null;return r.jsxs(Vd,{children:[r.jsx("h2",{className:"text-[22px] font-semibold text-[#F0F0F5] mb-1",children:"Configure models"}),r.jsx("p",{className:"text-[14px] text-[#8A8A99] mb-4 leading-relaxed",children:"Connect at least one model source for your agents to use."}),r.jsxs("div",{className:"space-y-2.5 mb-4",children:[r.jsxs("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2.5",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-[13px] font-medium text-[#F0F0F5]",children:"Ollama (local)"}),r.jsx("p",{className:"text-[11px] text-[#8A8A99] mt-0.5",children:"Free, runs on your machine"})]}),U?r.jsx("div",{className:"w-4 h-4 border-2 border-[#6366F1]/30 border-t-[#6366F1] rounded-full animate-spin"}):oe?r.jsxs("span",{className:"text-[11px] text-emerald-400 font-medium",children:[V.length," model",V.length!==1?"s":""]}):r.jsx("span",{className:"text-[11px] text-[#5A5A6E]",children:"Not detected"})]}),oe?r.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[V.slice(0,6).map(me=>r.jsx("span",{className:"px-2 py-0.5 rounded-md text-[11px] font-medium bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:me},me)),V.length>6&&r.jsxs("span",{className:"px-2 py-0.5 rounded-md text-[11px] text-[#8A8A99]",children:["+",V.length-6," more"]})]}):!U&&r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"rounded-xl border border-[#2A2A35] bg-[#0F0F11] p-3",children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("p",{className:"text-[13px] font-medium text-[#C8C8D4]",children:"Get started with OpenRouter"}),r.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-semibold bg-[#6366F1]/15 text-[#6366F1] border border-[#6366F1]/20",children:"No install needed"})]}),r.jsx("p",{className:"text-[12px] text-[#8A8A99] mb-2",children:"Free models available. The fastest way to get running."}),r.jsx("button",{onClick:()=>B.current?.focus(),className:"text-[12px] text-[#6366F1] hover:text-[#818CF8] transition-colors",children:"Go to OpenRouter section ↓"})]}),r.jsx("button",{onClick:()=>$(me=>!me),className:"text-[12px] text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:q?"Hide local install ↑":"Prefer fully local? →"}),q&&r.jsx("div",{className:"rounded-xl border border-[#2A2A35] bg-[#0F0F11] p-3 space-y-3",children:je?r.jsxs(r.Fragment,{children:[r.jsxs("a",{href:"https://ollama.com",target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 w-full justify-center py-2 px-4 rounded-lg border border-[#2A2A35] text-[13px] text-[#C8C8D4] hover:border-[#3A3A45] hover:text-[#F0F0F5] transition-colors",children:[r.jsx(cs,{className:"w-3.5 h-3.5"}),"Download Ollama"]}),Ee&&r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(IC,{code:`ollama pull ${Ee}`}),de&&r.jsx("p",{className:"text-[11px] text-[#5A5A6E]",children:de})]}),r.jsx(d8e,{onDetected:me=>K(me)})]}):r.jsx("p",{className:"text-[12px] text-[#8A8A99]",children:"Local models require at least 8GB RAM. We recommend OpenRouter instead."})})]})]}),r.jsxs("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("p",{className:"text-[13px] font-medium text-[#F0F0F5]",children:"OpenRouter"}),Y?.envOpenRouterConfigured&&r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-emerald-400",children:[r.jsx(Fe,{className:"w-3 h-3"})," Configured via .env"]})]}),r.jsx("p",{className:"text-[11px] text-[#8A8A99] mb-2.5",children:"Access 200+ models via one API key"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{type:"password",value:n,onChange:me=>{s(me.target.value),A(null)},placeholder:"sk-or-v1-...",ref:B,className:"flex-1 bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] placeholder:text-[#5A5A6E] outline-none focus:border-[#6366F1]/50 transition-colors"}),r.jsx("button",{onClick:z,disabled:!n.trim()||O.isPending,className:"px-3 py-2 rounded-lg text-[12px] font-medium bg-[#6366F1]/10 text-[#6366F1] border border-[#6366F1]/30 hover:bg-[#6366F1]/20 disabled:opacity-50 transition-colors flex-shrink-0",children:O.isPending?r.jsx("div",{className:"w-3.5 h-3.5 border-2 border-[#6366F1]/30 border-t-[#6366F1] rounded-full animate-spin"}):"Validate"})]}),w&&r.jsxs("div",{className:ye("flex items-center gap-1.5 mt-2 text-[12px]",w.valid?"text-emerald-400":"text-red-400"),children:[w.valid?r.jsx(Fe,{className:"w-3.5 h-3.5"}):r.jsx(Te,{className:"w-3.5 h-3.5"}),w.valid?`Valid — ${w.modelCount} models available`:"Invalid key"]}),w?.valid&&w.suggestedReasoningModel&&r.jsx("div",{className:"mt-3 pt-3 border-t border-[#2A2A35]",children:r.jsx("p",{className:"text-[11px] text-[#8A8A99] mb-1",children:"Models available via OpenRouter"})})]}),r.jsxs("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-4",children:[r.jsx("p",{className:"text-[13px] font-medium text-[#F0F0F5] mb-0.5",children:"Anthropic"}),r.jsx("p",{className:"text-[11px] text-[#8A8A99] mb-2.5",children:"Claude models (Haiku, Sonnet, Opus)"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{type:"password",value:i,onChange:me=>{a(me.target.value),C(null)},placeholder:"sk-ant-...",className:"flex-1 bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] placeholder:text-[#5A5A6E] outline-none focus:border-[#6366F1]/50 transition-colors"}),r.jsx("button",{onClick:J,disabled:!i.trim()||O.isPending,className:"px-3 py-2 rounded-lg text-[12px] font-medium bg-[#6366F1]/10 text-[#6366F1] border border-[#6366F1]/30 hover:bg-[#6366F1]/20 disabled:opacity-50 transition-colors flex-shrink-0",children:O.isPending?r.jsx("div",{className:"w-3.5 h-3.5 border-2 border-[#6366F1]/30 border-t-[#6366F1] rounded-full animate-spin"}):"Validate"})]}),S&&r.jsxs("div",{className:ye("flex items-center gap-1.5 mt-2 text-[12px]",S.valid?"text-emerald-400":"text-red-400"),children:[S.valid?r.jsx(Fe,{className:"w-3.5 h-3.5"}):r.jsx(Te,{className:"w-3.5 h-3.5"}),S.valid?"Valid":"Invalid key"]})]}),r.jsxs("button",{onClick:()=>_(me=>!me),className:"flex items-center gap-1.5 text-[12px] text-[#5A5A6E] hover:text-[#8A8A99] transition-colors w-full py-0.5",children:[r.jsx("span",{children:b?"↑ Hide":"↓ More providers"}),r.jsx("span",{className:"text-[#3A3A45]",children:"(OpenAI, Gemini)"})]}),b&&r.jsxs("div",{className:"space-y-2.5",children:[r.jsxs("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-4",children:[r.jsx("p",{className:"text-[13px] font-medium text-[#F0F0F5] mb-0.5",children:"OpenAI"}),r.jsx("p",{className:"text-[11px] text-[#8A8A99] mb-2.5",children:"GPT-4o, o1, o3-mini"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{type:"password",value:o,onChange:me=>{l(me.target.value),p(null)},placeholder:"sk-...",className:"flex-1 bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] placeholder:text-[#5A5A6E] outline-none focus:border-[#6366F1]/50 transition-colors"}),r.jsx("button",{onClick:ee,disabled:!o.trim()||O.isPending,className:"px-3 py-2 rounded-lg text-[12px] font-medium bg-[#6366F1]/10 text-[#6366F1] border border-[#6366F1]/30 hover:bg-[#6366F1]/20 disabled:opacity-50 transition-colors flex-shrink-0",children:O.isPending?r.jsx("div",{className:"w-3.5 h-3.5 border-2 border-[#6366F1]/30 border-t-[#6366F1] rounded-full animate-spin"}):"Validate"})]}),f&&r.jsxs("div",{className:ye("flex items-center gap-1.5 mt-2 text-[12px]",f.valid?"text-emerald-400":"text-red-400"),children:[f.valid?r.jsx(Fe,{className:"w-3.5 h-3.5"}):r.jsx(Te,{className:"w-3.5 h-3.5"}),f.valid?"Valid":"Invalid key"]})]}),r.jsxs("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-4",children:[r.jsx("p",{className:"text-[13px] font-medium text-[#F0F0F5] mb-0.5",children:"Google Gemini"}),r.jsx("p",{className:"text-[11px] text-[#8A8A99] mb-2.5",children:"Gemini 2.0, Flash, Pro"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{type:"password",value:c,onChange:me=>{d(me.target.value),g(null)},placeholder:"AIza...",className:"flex-1 bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] placeholder:text-[#5A5A6E] outline-none focus:border-[#6366F1]/50 transition-colors"}),r.jsx("button",{onClick:re,disabled:!c.trim()||O.isPending,className:"px-3 py-2 rounded-lg text-[12px] font-medium bg-[#6366F1]/10 text-[#6366F1] border border-[#6366F1]/30 hover:bg-[#6366F1]/20 disabled:opacity-50 transition-colors flex-shrink-0",children:O.isPending?r.jsx("div",{className:"w-3.5 h-3.5 border-2 border-[#6366F1]/30 border-t-[#6366F1] rounded-full animate-spin"}):"Validate"})]}),m&&r.jsxs("div",{className:ye("flex items-center gap-1.5 mt-2 text-[12px]",m.valid?"text-emerald-400":"text-red-400"),children:[m.valid?r.jsx(Fe,{className:"w-3.5 h-3.5"}):r.jsx(Te,{className:"w-3.5 h-3.5"}),m.valid?"Valid":"Invalid key"]})]})]})]}),le&&r.jsxs("div",{className:"bg-[#16161A] border border-[#6366F1]/20 rounded-2xl p-4 mb-1",children:[r.jsx("p",{className:"text-[13px] font-medium text-[#F0F0F5] mb-0.5",children:"Default models"}),r.jsx("p",{className:"text-[11px] text-[#8A8A99] mb-3",children:"Pre-selected for you. Change anytime in Settings."}),r.jsxs("div",{className:"space-y-2.5",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-[11px] text-[#5A5A6E] mb-1 block",children:"Primary (reasoning)"}),r.jsxs(ss,{value:E,onValueChange:me=>{k(me),I("")},children:[r.jsxs(is,{className:"w-full flex items-center justify-between px-3 py-2 rounded-lg border border-[#2A2A35] bg-[#0F0F11] text-[13px] text-[#F0F0F5] outline-none focus:border-[#6366F1]/50 transition-colors",children:[r.jsx("span",{className:"truncate",children:(ae.find(me=>me.id===E)?.label??E)||"Select model..."}),r.jsx(Yl,{children:r.jsx(ft,{className:"w-3.5 h-3.5 text-[#5A5A6E]"})})]}),r.jsx(rs,{children:r.jsxs(as,{position:"popper",sideOffset:4,className:"bg-[#1C1C24] border border-[#2A2A35] rounded-lg shadow-xl py-1 min-w-[280px] max-h-[240px] z-[9999]",children:[r.jsx("div",{className:"px-2 pb-1 mb-1 border-b border-[#2A2A35]",children:r.jsx("input",{value:M,onChange:me=>I(me.target.value),onKeyDown:me=>{me.key==="Enter"&&M.trim()&&k(M.trim())},placeholder:"Type model ID...",className:"w-full bg-[#13131A] border border-[#2A2A35] rounded px-2 py-1.5 text-[11px] text-[#C8C8D4] placeholder:text-[#5A5A6E] outline-none focus:border-[#6366F1] transition-colors"})}),r.jsx(os,{children:Object.entries(ae.reduce((me,$e)=>((me[$e.group]??=[]).push($e),me),{})).map(([me,$e])=>r.jsxs(Ro,{children:[r.jsx(Do,{className:"px-3 pt-2 pb-1 text-[10px] font-semibold text-[#5A5A6E] uppercase tracking-widest",children:me}),$e.map(nt=>r.jsxs(vn,{value:nt.id,className:"flex items-center justify-between px-3 py-1.5 text-[12px] text-[#C8C8D4] cursor-pointer outline-none data-[highlighted]:bg-white/5",children:[r.jsx(yn,{children:nt.label}),r.jsx(ui,{children:r.jsx(Fe,{className:"w-3 h-3 text-[#6366F1]"})})]},nt.id))]},me))})]})})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-[11px] text-[#5A5A6E] mb-1 block",children:"Fast (quick tasks)"}),r.jsxs(ss,{value:T,onValueChange:me=>{F(me),H("")},children:[r.jsxs(is,{className:"w-full flex items-center justify-between px-3 py-2 rounded-lg border border-[#2A2A35] bg-[#0F0F11] text-[13px] text-[#F0F0F5] outline-none focus:border-[#6366F1]/50 transition-colors",children:[r.jsx("span",{className:"truncate",children:(ae.find(me=>me.id===T)?.label??T)||"Select model..."}),r.jsx(Yl,{children:r.jsx(ft,{className:"w-3.5 h-3.5 text-[#5A5A6E]"})})]}),r.jsx(rs,{children:r.jsxs(as,{position:"popper",sideOffset:4,className:"bg-[#1C1C24] border border-[#2A2A35] rounded-lg shadow-xl py-1 min-w-[280px] max-h-[240px] z-[9999]",children:[r.jsx("div",{className:"px-2 pb-1 mb-1 border-b border-[#2A2A35]",children:r.jsx("input",{value:R,onChange:me=>H(me.target.value),onKeyDown:me=>{me.key==="Enter"&&R.trim()&&F(R.trim())},placeholder:"Type model ID...",className:"w-full bg-[#13131A] border border-[#2A2A35] rounded px-2 py-1.5 text-[11px] text-[#C8C8D4] placeholder:text-[#5A5A6E] outline-none focus:border-[#6366F1] transition-colors"})}),r.jsx(os,{children:Object.entries(ae.reduce((me,$e)=>((me[$e.group]??=[]).push($e),me),{})).map(([me,$e])=>r.jsxs(Ro,{children:[r.jsx(Do,{className:"px-3 pt-2 pb-1 text-[10px] font-semibold text-[#5A5A6E] uppercase tracking-widest",children:me}),$e.map(nt=>r.jsxs(vn,{value:nt.id,className:"flex items-center justify-between px-3 py-1.5 text-[12px] text-[#C8C8D4] cursor-pointer outline-none data-[highlighted]:bg-white/5",children:[r.jsx(yn,{children:nt.label}),r.jsx(ui,{children:r.jsx(Fe,{className:"w-3 h-3 text-[#6366F1]"})})]},nt.id))]},me))})]})})]})]})]})]}),r.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[r.jsx("button",{onClick:async()=>{E&&T&&await D.mutateAsync({reasoningModel:E,fastModel:T}),e()},disabled:!se||D.isPending,className:ye("flex items-center gap-2 px-5 py-2.5 rounded-xl text-[13px] font-medium transition-colors",se?"bg-[#6366F1] text-white hover:bg-[#5254CC]":"bg-white/5 text-[#5A5A6E] border border-[#2A2A35] cursor-not-allowed"),children:D.isPending?r.jsx("div",{className:"w-3.5 h-3.5 border-2 border-white/30 border-t-white rounded-full animate-spin"}):r.jsxs(r.Fragment,{children:["Continue",r.jsx(Jt,{className:"w-3.5 h-3.5"})]})}),r.jsx("button",{onClick:t,className:"text-[12px] text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:"Skip for now"})]})]})}function f8e({onNext:e}){const[t,n]=y.useState(null);return r.jsxs(Vd,{children:[r.jsx("h2",{className:"text-[22px] font-semibold text-[#F0F0F5] mb-2",children:"Share your workspace"}),r.jsx("p",{className:"text-[14px] text-[#8A8A99] mb-6 leading-relaxed",children:"How will you use damn.dev?"}),r.jsx("div",{className:"grid grid-cols-2 gap-3 mb-6",children:["solo","team"].map(s=>r.jsxs("button",{onClick:()=>n(s),className:ye("text-left rounded-2xl p-4 border transition-all",t===s?"border-[#6366F1]/50 bg-[#6366F1]/5 ring-1 ring-[#6366F1]/20":"border-[#2A2A35] bg-[#16161A] hover:border-[#3A3A45]"),children:[r.jsx("p",{className:"text-[13px] font-medium text-[#F0F0F5] mt-1",children:s==="solo"?"Just me":"With my team"}),r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mt-0.5",children:s==="solo"?"Default":"Share access via Tailscale"})]},s))}),t==="team"&&r.jsx("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-5 mb-6",children:r.jsx(V5,{onComplete:()=>e(),onSkip:e})}),t!=="team"&&r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("button",{onClick:e,disabled:t===null,className:ye("flex items-center gap-2 px-5 py-2.5 rounded-xl text-[13px] font-medium transition-colors",t!==null?"bg-[#6366F1] text-white hover:bg-[#5254CC]":"bg-white/5 text-[#5A5A6E] border border-[#2A2A35] cursor-not-allowed"),children:["Continue",r.jsx(Jt,{className:"w-3.5 h-3.5"})]}),r.jsx("button",{onClick:e,className:"text-[12px] text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:"Skip"})]})]})}function p8e({onComplete:e}){const t=an(),n=L.useUtils(),s=L.onboarding.complete.useMutation(),i=L.onboarding.cooOnboardingChat.useMutation(),a=L.onboarding.setWorkspaceContext.useMutation(),[o,l]=y.useState([]),[c,d]=y.useState(""),[f,p]=y.useState(null),[m,g]=y.useState(!1),[b,_]=y.useState(!0),[w,A]=y.useState(null),S=y.useRef(null),C=y.useRef(null);y.useEffect(()=>{let M=!1;return i.mutateAsync({message:"Hello",history:[]}).then(I=>{M||(l([{role:"assistant",content:I.reply}]),_(!1))}).catch(()=>{M||(_(!1),A("Could not reach COO. You can skip this step and set workspace context later."))}),()=>{M=!0}},[]),y.useEffect(()=>{S.current?.scrollTo({top:S.current.scrollHeight,behavior:"smooth"})},[o,f]);async function E(){const M=c.trim();if(!M||i.isPending)return;d(""),A(null);const I=[...o,{role:"user",content:M}];l(I);try{const R=await i.mutateAsync({message:M,history:I});l([...I,{role:"assistant",content:R.reply}]),R.workspaceContext&&p(R.workspaceContext)}catch{A("COO failed to respond. Try again or skip this step.")}C.current?.focus()}async function k(){f&&(await a.mutateAsync({context:f}),g(!0))}async function T(){await s.mutateAsync(),await n.onboarding.getState.refetch(),t("/channels/chan_coo",{replace:!0}),e()}async function F(){await s.mutateAsync(),await n.onboarding.getState.refetch(),t("/channels/chan_coo",{replace:!0}),e()}return r.jsxs(Vd,{children:[r.jsx("h2",{className:"text-[22px] font-semibold text-[#F0F0F5] mb-1",children:"Meet your COO"}),r.jsx("p",{className:"text-[14px] text-[#8A8A99] mb-4 leading-relaxed",children:"A few questions to set up your workspace context."}),r.jsxs("div",{ref:S,className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-4 mb-3 space-y-3 max-h-[320px] overflow-y-auto",children:[b&&r.jsxs("div",{className:"flex items-center gap-2 text-[13px] text-[#5A5A6E]",children:[r.jsx(Pe,{className:"w-3.5 h-3.5 animate-spin"}),"COO is thinking..."]}),w&&r.jsx("div",{className:"text-[13px] text-red-400/80 leading-relaxed",children:w}),o.map((M,I)=>r.jsx("div",{className:ye("flex",M.role==="user"?"justify-end":"justify-start"),children:r.jsx("div",{className:ye("rounded-xl px-3 py-2 text-[13px] leading-relaxed max-w-[85%]",M.role==="user"?"bg-[#6366F1] text-white":"bg-[#1E1E28] text-[#C8C8D4] border border-[#2A2A35]"),children:M.content})},I)),i.isPending&&o.length>0&&r.jsx("div",{className:"flex justify-start",children:r.jsx("div",{className:"rounded-xl px-3 py-2 bg-[#1E1E28] border border-[#2A2A35]",children:r.jsx(Pe,{className:"w-3.5 h-3.5 animate-spin text-[#5A5A6E]"})})})]}),f&&!m&&r.jsxs("div",{className:"bg-[#0F0F11] border border-[#6366F1]/30 rounded-xl p-3 mb-3",children:[r.jsx("p",{className:"text-[11px] font-medium text-[#6366F1] mb-2",children:"Proposed workspace context"}),r.jsx("pre",{className:"text-[11px] text-[#C8C8D4] whitespace-pre-wrap leading-relaxed max-h-[160px] overflow-y-auto mb-2",children:f}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs("button",{onClick:k,disabled:a.isPending,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[12px] font-medium bg-[#6366F1] text-white hover:bg-[#5254CC] disabled:opacity-60 transition-colors",children:[a.isPending?r.jsx(Pe,{className:"w-3 h-3 animate-spin"}):r.jsx(Fe,{className:"w-3 h-3"}),"Approve"]}),r.jsx("button",{onClick:()=>p(null),className:"px-3 py-1.5 rounded-lg text-[12px] text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:"Revise"})]})]}),m&&r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-xl bg-emerald-500/10 border border-emerald-500/20 mb-3",children:[r.jsx(sa,{className:"w-3.5 h-3.5 text-emerald-400"}),r.jsx("span",{className:"text-[12px] text-emerald-400",children:"Workspace context saved"})]}),!m&&!b&&r.jsxs("div",{className:"flex gap-2 mb-3",children:[r.jsx("input",{ref:C,type:"text",value:c,onChange:M=>d(M.target.value),onKeyDown:M=>M.key==="Enter"&&E(),placeholder:"Type your answer...",disabled:i.isPending,className:"flex-1 bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] placeholder:text-[#5A5A6E] outline-none focus:border-[#6366F1]/50 transition-colors disabled:opacity-50"}),r.jsx("button",{onClick:E,disabled:!c.trim()||i.isPending,className:"px-3 py-2 rounded-lg text-[12px] font-medium bg-[#6366F1] text-white hover:bg-[#5254CC] disabled:opacity-50 transition-colors flex-shrink-0",children:"Send"})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[m&&r.jsxs("button",{onClick:T,disabled:s.isPending,className:"flex items-center gap-2 px-5 py-2.5 rounded-xl text-[13px] font-medium bg-[#6366F1] text-white hover:bg-[#5254CC] disabled:opacity-60 transition-colors",children:[s.isPending?r.jsx(Pe,{className:"w-3.5 h-3.5 animate-spin"}):null,"Open damn.dev",r.jsx(Jt,{className:"w-3.5 h-3.5"})]}),!m&&r.jsx("button",{onClick:F,className:"text-[12px] text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:"Skip this step"})]})]})}function m8e(){const e=an(),[t,n]=y.useState(0),s=L.onboarding.skip.useMutation();async function i(){await s.mutateAsync(),e("/",{replace:!0})}return r.jsx("div",{className:"flex h-screen w-screen overflow-hidden bg-[#0F0F11] flex-col items-center justify-center",children:r.jsxs("div",{className:"w-full max-w-lg px-6 flex flex-col",style:{maxHeight:"100vh"},children:[r.jsxs("div",{className:"flex items-center justify-between mb-8 flex-shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[18px]",children:"⚡"}),r.jsx("span",{className:"text-[15px] font-semibold text-[#F0F0F5]",children:"damn.dev"})]}),r.jsx(c8e,{current:t}),r.jsx("button",{onClick:i,className:"text-[12px] text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:"Skip setup"})]}),r.jsx("div",{className:"overflow-y-auto flex-1 pb-6",children:r.jsxs(Me,{mode:"wait",children:[t===0&&r.jsx(u8e,{onNext:()=>n(1),onSkip:()=>n(1)},"step0"),t===1&&r.jsx(h8e,{onNext:()=>n(2),onSkip:()=>n(2)},"step1"),t===2&&r.jsx(f8e,{onNext:()=>n(3)},"step2"),t===3&&r.jsx(p8e,{onComplete:()=>{}},"step3")]})})]})})}function x8e(){const e=an(),{data:t}=L.workspace.getMyMembership.useQuery(),{data:n=[]}=L.channels.list.useQuery(),s=L.workspace.completeOnboarding.useMutation();async function i(){await s.mutateAsync();const a=n.find(o=>o.name==="general"&&o.visibility==="public"&&o.channelType==="topic");e(a?`/channels/${a.id}`:"/channels/direction",{replace:!0})}return r.jsx("div",{className:"flex h-screen w-screen overflow-hidden bg-[#0F0F11] flex-col items-center justify-center",children:r.jsxs(ne.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.4,ease:[.16,1,.3,1]},className:"w-full max-w-md px-6 text-center",children:[r.jsx("div",{className:"w-16 h-16 rounded-2xl bg-gradient-to-br from-[#6366F1]/20 to-[#8B5CF6]/20 border border-[#6366F1]/30 flex items-center justify-center mx-auto mb-6",children:r.jsx("span",{className:"text-3xl",children:"👋"})}),r.jsxs("h1",{className:"text-[24px] font-semibold text-[#F0F0F5] mb-3",children:["Welcome to ",t?.workspaceName??"the workspace"]}),t?.ownerName&&r.jsxs("p",{className:"text-[14px] text-[#8A8A99] mb-8 leading-relaxed",children:["You've been invited by ",t.ownerName]}),r.jsxs("button",{onClick:i,disabled:s.isPending,className:"inline-flex items-center gap-2 px-6 py-3 rounded-xl text-[14px] font-semibold bg-[#6366F1] text-white hover:bg-[#5254CC] disabled:opacity-60 transition-colors",children:[s.isPending?r.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):null,"Explore your workspace",r.jsx(Jt,{className:"w-4 h-4"})]})]})})}function g8e(){const[e,t]=y.useState("signin"),[n,s]=y.useState(""),[i,a]=y.useState(""),[o,l]=y.useState(!1),[c,d]=y.useState(null),[f,p]=y.useState(!1),{data:m}=L.onboarding.hasGoogleAuth.useQuery(),{data:g}=L.onboarding.signupAllowed.useQuery(),b=g?.allowed??!1,_=g?.registrationMode??"closed";y.useEffect(()=>{!b&&e==="signup"&&t("signin")},[b,e]);async function w(A){if(A.preventDefault(),d(null),e==="signup"&&!b){d("This workspace requires an invitation to join.");return}if(i.length<12){d("Password must be at least 12 characters.");return}p(!0);try{if(e==="signup"){const S=await cz.email({email:n,password:i,name:n.split("@")[0]});S.error&&d(S.error.message??"Sign up failed.")}else{const S=await v0.email({email:n,password:i});S.error&&d(S.error.message??"Invalid credentials.")}}catch{d("Something went wrong. Please try again.")}finally{p(!1)}}return r.jsx("div",{className:"flex h-screen w-screen items-center justify-center bg-[#0F0F11]",children:r.jsxs("div",{className:"flex flex-col items-center gap-6 max-w-sm w-full px-8",children:[r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx("div",{className:"w-14 h-14 rounded-2xl bg-gradient-to-br from-[#6366F1]/20 to-[#8B5CF6]/20 border border-[#6366F1]/30 flex items-center justify-center",children:r.jsx("span",{className:"text-2xl font-bold text-[#6366F1]",children:"d"})}),r.jsx("h1",{className:"text-[22px] font-semibold text-[#F0F0F5]",children:"damn.dev"}),r.jsx("p",{className:"text-[14px] text-[#8A8A99]",children:e==="signin"?"Sign in to your workspace":"Create your workspace"})]}),r.jsxs("form",{onSubmit:w,className:"flex flex-col gap-3 w-full",children:[r.jsx("input",{type:"email",placeholder:"Email",value:n,onChange:A=>s(A.target.value),required:!0,className:"w-full rounded-lg bg-[#1A1A20] border border-[#2A2A35] text-[#F0F0F5] placeholder-[#5A5A6A] px-4 py-3 text-[14px] outline-none focus:border-[#6366F1] transition-colors"}),r.jsxs("div",{className:"relative",children:[r.jsx("input",{type:o?"text":"password",placeholder:"Password (min 12 characters)",value:i,onChange:A=>a(A.target.value),required:!0,minLength:12,className:"w-full rounded-lg bg-[#1A1A20] border border-[#2A2A35] text-[#F0F0F5] placeholder-[#5A5A6A] px-4 py-3 pr-11 text-[14px] outline-none focus:border-[#6366F1] transition-colors"}),r.jsx("button",{type:"button",onClick:()=>l(A=>!A),className:"absolute right-3 top-1/2 -translate-y-1/2 text-[#5A5A6A] hover:text-[#8A8A99] transition-colors",tabIndex:-1,children:o?r.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 4.411m0 0L21 21"})}):r.jsxs("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]})})]}),c&&r.jsx("p",{className:"text-[13px] text-red-400",children:c}),r.jsx("button",{type:"submit",disabled:f,className:"w-full rounded-lg bg-[#6366F1] text-white px-5 py-3 text-[14px] font-medium hover:bg-[#5254CC] disabled:opacity-50 transition-colors",children:f?"...":e==="signin"?"Sign in":"Create account"})]}),b?r.jsx("button",{type:"button",onClick:()=>{t(e==="signin"?"signup":"signin"),d(null)},className:"text-[13px] text-[#8A8A99] hover:text-[#F0F0F5] transition-colors",children:e==="signin"?"Don't have an account? Create one":"Already have an account? Sign in"}):_==="invite"?r.jsx("p",{className:"text-[13px] text-[#5A5A6E] text-center",children:"Need an account? Ask the workspace admin for an invite link."}):r.jsx("p",{className:"text-[13px] text-[#5A5A6E] text-center",children:"Registration is closed."}),m?.enabled&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-3 w-full",children:[r.jsx("div",{className:"flex-1 h-px bg-[#2A2A35]"}),r.jsx("span",{className:"text-[12px] text-[#5A5A6A]",children:"or"}),r.jsx("div",{className:"flex-1 h-px bg-[#2A2A35]"})]}),r.jsxs("button",{onClick:()=>v0.social({provider:"google",callbackURL:window.location.origin+"/"}),className:"flex items-center gap-3 w-full justify-center rounded-lg bg-white text-[#1a1a1a] px-5 py-3 text-[14px] font-medium hover:bg-[#f0f0f0] transition-colors",children:[r.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[r.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z",fill:"#4285F4"}),r.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),r.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),r.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),"Continue with Google"]})]})]})})}function b8e(e){if(!e||typeof e!="object")return!1;const t=String(e.message??"");return t.includes("Failed to fetch")||t.includes("NetworkError")||t.includes("ERR_CONNECTION_REFUSED")||t.includes("ECONNREFUSED")||t.includes("Load failed")||t.includes("fetch failed")}function v8e(){const[e,t]=y.useState(!1);function n(){t(!0),setTimeout(()=>window.location.reload(),500)}return r.jsx("div",{className:"flex h-screen w-screen items-center justify-center bg-[#0F0F11]",children:r.jsxs("div",{className:"flex flex-col items-center gap-5 max-w-md text-center px-8",children:[r.jsx("div",{className:"w-12 h-12 rounded-2xl bg-amber-500/10 border border-amber-500/20 flex items-center justify-center",children:r.jsx("span",{className:"text-amber-400 text-xl",children:"!"})}),r.jsx("h1",{className:"text-[18px] font-semibold text-[#F0F0F5]",children:"Can't reach this workspace"}),r.jsx("p",{className:"text-[14px] text-[#8A8A99] leading-relaxed",children:"This is a private workspace running on someone's machine. You need to be on their private network to access it."}),r.jsxs("div",{className:"w-full bg-[#16161A] border border-[#2A2A35] rounded-xl p-5 text-left space-y-4",children:[r.jsx("p",{className:"text-[13px] font-medium text-[#C8C8D4]",children:"If they shared a Tailscale link:"}),r.jsxs("div",{className:"space-y-2 text-[12px] text-[#8A8A99]",children:[r.jsxs("div",{className:"flex gap-2",children:[r.jsx("span",{className:"text-[#6366F1] font-medium flex-shrink-0",children:"1."}),r.jsxs("div",{children:["Install Tailscale on your device",r.jsxs("a",{href:"https://tailscale.com/download",target:"_blank",rel:"noreferrer",className:"flex items-center gap-1 mt-1 text-[#6366F1] hover:text-[#818CF8] transition-colors",children:[r.jsx(cs,{className:"w-3 h-3"}),"tailscale.com/download"]})]})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("span",{className:"text-[#6366F1] font-medium flex-shrink-0",children:"2."}),r.jsx("span",{children:"Ask them to add you to their Tailnet at tailscale.com/admin"})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("span",{className:"text-[#6366F1] font-medium flex-shrink-0",children:"3."}),r.jsx("span",{children:"Once connected, refresh this page"})]})]}),r.jsx("p",{className:"text-[11px] text-[#5A5A6E]",children:"Already have Tailscale? Make sure it's running and you're on the same Tailnet as the workspace host."})]}),r.jsxs("button",{onClick:n,disabled:e,className:"flex items-center gap-2 px-4 py-2 rounded-lg text-[13px] font-medium bg-[#6366F1]/10 text-[#6366F1] border border-[#6366F1]/30 hover:bg-[#6366F1]/20 transition-colors disabled:opacity-50",children:[r.jsx(Xi,{className:`w-3.5 h-3.5 ${e?"animate-spin":""}`}),"Retry connection"]})]})})}function y8e(){const{token:e}=am(),t=an(),{data:n}=Mi(),[s,i]=y.useState("signup"),[a,o]=y.useState(""),[l,c]=y.useState(""),[d,f]=y.useState(null),[p,m]=y.useState(!1),{data:g,isLoading:b,error:_}=L.workspace.getInvitation.useQuery({token:e},{enabled:!!e,retry:!1}),w=L.workspace.acceptInvitation.useMutation({onSuccess:()=>{setTimeout(()=>t("/"),2e3)}});y.useEffect(()=>{if(w.isSuccess){const S=setTimeout(()=>t("/"),2e3);return()=>clearTimeout(S)}},[w.isSuccess,t]);async function A(S){if(S.preventDefault(),f(null),l.length<12){f("Password must be at least 12 characters.");return}m(!0);try{if(s==="signup"){const C=await cz.email({email:a,password:l,name:a.split("@")[0],fetchOptions:{headers:{"x-invite-token":e}}});C.error&&f(C.error.message??"Sign up failed.")}else{const C=await v0.email({email:a,password:l});C.error&&f(C.error.message??"Invalid credentials.")}}catch{f("Something went wrong. Please try again.")}finally{m(!1)}}return b?r.jsx("div",{className:"flex h-screen w-screen items-center justify-center bg-[#0F0F11]",children:r.jsx("div",{className:"w-5 h-5 border-2 border-[#6366F1]/30 border-t-[#6366F1] rounded-full animate-spin"})}):_&&b8e(_)?r.jsx(v8e,{}):_||!g?r.jsx("div",{className:"flex h-screen w-screen items-center justify-center bg-[#0F0F11]",children:r.jsxs("div",{className:"flex flex-col items-center gap-4 max-w-sm text-center px-8",children:[r.jsx("div",{className:"w-12 h-12 rounded-2xl bg-[#EF4444]/10 border border-[#EF4444]/20 flex items-center justify-center",children:r.jsx("span",{className:"text-[#EF4444] text-xl",children:"✕"})}),r.jsx("h1",{className:"text-[18px] font-semibold text-[#F0F0F5]",children:"Invitation not valid"}),r.jsx("p",{className:"text-[14px] text-[#8A8A99]",children:"This invitation is no longer valid or has expired."}),r.jsx(gn,{to:"/",className:"text-[13px] text-[#6366F1] hover:underline",children:"Go to workspace"})]})}):w.isSuccess?r.jsx("div",{className:"flex h-screen w-screen items-center justify-center bg-[#0F0F11]",children:r.jsxs("div",{className:"flex flex-col items-center gap-4 max-w-sm text-center px-8",children:[r.jsx("div",{className:"w-12 h-12 rounded-2xl bg-[#10B981]/10 border border-[#10B981]/20 flex items-center justify-center",children:r.jsx("span",{className:"text-[#10B981] text-xl",children:"✓"})}),r.jsxs("h1",{className:"text-[18px] font-semibold text-[#F0F0F5]",children:["You've joined ",g.workspaceName,"!"]}),r.jsx("p",{className:"text-[13px] text-[#8A8A99]",children:"Redirecting you to your workspace..."}),r.jsx("div",{className:"w-4 h-4 border-2 border-[#6366F1]/30 border-t-[#6366F1] rounded-full animate-spin"})]})}):r.jsx("div",{className:"flex h-screen w-screen items-center justify-center bg-[#0F0F11]",children:r.jsxs("div",{className:"w-[400px] bg-[#1C1C24] border border-[#2A2A35] rounded-xl shadow-2xl p-8 flex flex-col items-center gap-5",children:[r.jsx("div",{className:"w-14 h-14 rounded-2xl bg-gradient-to-br from-[#6366F1]/20 to-[#8B5CF6]/20 border border-[#6366F1]/30 flex items-center justify-center",children:r.jsx("span",{className:"text-2xl font-bold text-[#6366F1]",children:"d"})}),r.jsxs("div",{className:"text-center",children:[r.jsx("h1",{className:"text-[20px] font-semibold text-[#F0F0F5]",children:g.workspaceName}),r.jsxs("p",{className:"text-[13px] text-[#8A8A99] mt-1",children:[g.inviterName," invited you to join as"," ",r.jsx("span",{className:"text-[#C8C8D4]",children:g.role})]})]}),w.error&&r.jsx("p",{className:"text-[12px] text-[#EF4444] text-center",children:w.error.message}),n?r.jsx("button",{onClick:()=>w.mutate({token:e}),disabled:w.isPending,className:"w-full px-4 py-2.5 rounded-lg bg-[#6366F1] text-white text-[14px] font-medium hover:bg-[#5558E8] transition-colors disabled:opacity-40 disabled:pointer-events-none",children:w.isPending?"Joining...":"Join Workspace"}):r.jsxs("div",{className:"w-full flex flex-col gap-3",children:[r.jsxs("form",{onSubmit:A,className:"flex flex-col gap-3 w-full",children:[r.jsx("input",{type:"email",placeholder:"Email",value:a,onChange:S=>o(S.target.value),required:!0,className:"w-full rounded-lg bg-[#13131A] border border-[#2A2A35] text-[#F0F0F5] placeholder-[#5A5A6A] px-4 py-3 text-[14px] outline-none focus:border-[#6366F1] transition-colors"}),r.jsx("input",{type:"password",placeholder:"Password (min 12 characters)",value:l,onChange:S=>c(S.target.value),required:!0,minLength:12,className:"w-full rounded-lg bg-[#13131A] border border-[#2A2A35] text-[#F0F0F5] placeholder-[#5A5A6A] px-4 py-3 text-[14px] outline-none focus:border-[#6366F1] transition-colors"}),d&&r.jsx("p",{className:"text-[12px] text-red-400",children:d}),r.jsx("button",{type:"submit",disabled:p,className:"w-full rounded-lg bg-[#6366F1] text-white px-5 py-3 text-[14px] font-medium hover:bg-[#5254CC] disabled:opacity-50 transition-colors",children:p?"...":s==="signup"?"Create account & join":"Sign in & join"})]}),r.jsx("button",{type:"button",onClick:()=>{i(s==="signin"?"signup":"signin"),f(null)},className:"text-[13px] text-[#8A8A99] hover:text-[#F0F0F5] transition-colors",children:s==="signup"?"Already have an account? Sign in":"Don't have an account? Create one"}),r.jsxs("div",{className:"flex items-center gap-3 w-full",children:[r.jsx("div",{className:"flex-1 h-px bg-[#2A2A35]"}),r.jsx("span",{className:"text-[12px] text-[#5A5A6A]",children:"or"}),r.jsx("div",{className:"flex-1 h-px bg-[#2A2A35]"})]}),r.jsxs("button",{onClick:()=>v0.social({provider:"google",callbackURL:`${window.location.origin}/invite/${e}`}),className:"flex items-center gap-3 w-full justify-center rounded-lg bg-white text-[#1a1a1a] px-5 py-3 text-[14px] font-medium hover:bg-[#f0f0f0] transition-colors",children:[r.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[r.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z",fill:"#4285F4"}),r.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),r.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),r.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),"Continue with Google"]})]})]})})}function _8e({open:e,onClose:t}){const[n,s]=y.useState(""),[i,a]=y.useState(""),[o,l]=y.useState(0),c=y.useRef(null),d=an(),[f,p]=y.useState(e);e&&!f&&(s(""),a(""),l(0)),e!==f&&p(e),y.useEffect(()=>{e&&setTimeout(()=>c.current?.focus(),50)},[e]),y.useEffect(()=>{const A=setTimeout(()=>a(n),200);return()=>clearTimeout(A)},[n]);const{data:m=[]}=L.messages.search.useQuery({query:i},{enabled:i.length>=2}),g=m.reduce((A,S)=>{const C=A[S.channelName]??[];return C.push(S),A[S.channelName]=C,A},{}),b=m;function _(A){d(`/channels/${A.channelId}`),t(),setTimeout(()=>{document.getElementById(`msg-${A.messageId}`)?.scrollIntoView({behavior:"smooth",block:"center"})},300)}function w(A){A.key==="Escape"?t():A.key==="ArrowDown"?(A.preventDefault(),l(S=>Math.min(S+1,b.length-1))):A.key==="ArrowUp"?(A.preventDefault(),l(S=>Math.max(S-1,0))):A.key==="Enter"&&b[o]&&_(b[o])}return r.jsx(Me,{children:e&&r.jsx(ne.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"fixed inset-0 z-[100] flex items-start justify-center pt-[15vh]",style:{backdropFilter:"blur(8px)",backgroundColor:"rgba(0,0,0,0.6)"},onClick:A=>{A.target===A.currentTarget&&t()},children:r.jsxs(ne.div,{initial:{opacity:0,y:-12,scale:.97},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.97},transition:{duration:.2,ease:[.16,1,.3,1]},className:"w-full max-w-[600px] mx-4 bg-[#13131A] border border-[#2A2A35] rounded-2xl shadow-2xl overflow-hidden",children:[r.jsxs("div",{className:"flex items-center gap-3 px-5 py-4 border-b border-[#2A2A35]",children:[r.jsx(Io,{className:"w-5 h-5 text-[#8A8A99] flex-shrink-0"}),r.jsx("input",{ref:c,value:n,onChange:A=>{s(A.target.value),l(0)},onKeyDown:w,placeholder:"Search messages...",className:"flex-1 bg-transparent text-[20px] text-[#F0F0F5] placeholder:text-[#8A8A99]/50 outline-none"}),r.jsx("kbd",{className:"text-[11px] text-[#8A8A99] bg-white/5 border border-[#2A2A35] px-1.5 py-0.5 rounded-md",children:"esc"})]}),i.length>=2&&r.jsx("div",{className:"max-h-[420px] overflow-y-auto py-2",children:m.length===0?r.jsx("div",{className:"px-5 py-8 text-center",children:r.jsxs("p",{className:"text-[14px] text-[#8A8A99]",children:['No messages found for "',i,'"']})}):Object.entries(g).map(([A,S])=>r.jsxs("div",{children:[r.jsx("div",{className:"px-4 py-1.5 sticky top-0 bg-[#13131A]",children:r.jsxs("span",{className:"text-[11px] font-semibold text-[#8A8A99] uppercase tracking-widest",children:["#",A]})}),S.map(C=>{const E=b.indexOf(C),k=E===o;return r.jsxs("button",{onClick:()=>_(C),onMouseEnter:()=>l(E),className:"w-full text-left px-4 py-3 transition-colors",style:{backgroundColor:k?"rgba(255,255,255,0.04)":"transparent"},children:[r.jsxs("div",{className:"flex items-center justify-between gap-2 mb-0.5",children:[r.jsx("span",{className:"text-[12px] font-medium text-[#C8C8D4]",children:"Message"}),r.jsx("span",{className:"text-[11px] text-[#8A8A99]",children:Ir(C.createdAt)})]}),r.jsx("p",{className:"text-[13px] text-[#8A8A99] leading-relaxed",children:w8e(C.snippet,i)})]},C.messageId)})]},A))}),i.length<2&&r.jsx("div",{className:"px-5 py-6 text-center",children:r.jsx("p",{className:"text-[13px] text-[#8A8A99]",children:"Type at least 2 characters to search"})}),r.jsxs("div",{className:"flex items-center gap-4 px-4 py-2 border-t border-[#2A2A35]",children:[r.jsxs("span",{className:"text-[11px] text-[#8A8A99]",children:[r.jsx("kbd",{className:"bg-white/5 border border-[#2A2A35] px-1 py-0.5 rounded text-[10px] mr-1",children:"↑↓"}),"navigate"]}),r.jsxs("span",{className:"text-[11px] text-[#8A8A99]",children:[r.jsx("kbd",{className:"bg-white/5 border border-[#2A2A35] px-1 py-0.5 rounded text-[10px] mr-1",children:"↵"}),"jump"]})]})]})})})}function w8e(e,t){return e.split(new RegExp(`(${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi")).map((s,i)=>s.toLowerCase()===t.toLowerCase()?r.jsx("mark",{className:"bg-[#6366F1]/30 text-[#A5B4FC] rounded-sm px-0.5",children:s},i):s)}function A8e(){return/iPad|iPhone|iPod/.test(navigator.userAgent)&&!("MSStream"in window)}function S8e(){return window.matchMedia("(display-mode: standalone)").matches||"standalone"in navigator&&navigator.standalone===!0}function C8e(){const[e,t]=y.useState(!1),[n,s]=y.useState(!1),[i,a]=y.useState(null);y.useEffect(()=>{if(S8e())return;if(A8e()){localStorage.getItem("pwa-install-dismissed")||t(!0);return}function d(f){f.preventDefault(),a(f),sessionStorage.getItem("pwa-install-dismissed")||s(!0)}return window.addEventListener("beforeinstallprompt",d),()=>window.removeEventListener("beforeinstallprompt",d)},[]);const o=y.useCallback(()=>{localStorage.setItem("pwa-install-dismissed","1"),t(!1)},[]),l=y.useCallback(()=>{sessionStorage.setItem("pwa-install-dismissed","1"),s(!1)},[]),c=y.useCallback(async()=>{i&&(await i.prompt(),s(!1),a(null))},[i]);return r.jsxs(Me,{children:[e&&r.jsxs(ne.div,{initial:{y:100,opacity:0},animate:{y:0,opacity:1},exit:{y:100,opacity:0},transition:{type:"spring",damping:25,stiffness:300},className:"fixed bottom-4 left-4 right-4 z-50 rounded-xl bg-[#1A1A2E] border border-[#2A2A35] p-4 shadow-2xl max-w-md mx-auto",children:[r.jsxs("p",{className:"text-[13px] text-[#C0C0CC] leading-relaxed",children:["For the best experience, add damn.dev to your Home Screen: tap"," ",r.jsx("span",{className:"inline-flex items-center align-middle mx-0.5",children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#6366F1]",children:[r.jsx("path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8"}),r.jsx("polyline",{points:"16 6 12 2 8 6"}),r.jsx("line",{x1:"12",y1:"2",x2:"12",y2:"15"})]})})," ","Share → Add to Home Screen"]}),r.jsx("button",{onClick:o,className:"mt-3 text-[12px] font-medium text-[#6366F1] hover:text-[#818CF8] transition-colors",children:"Got it"})]}),n&&r.jsxs(ne.div,{initial:{y:100,opacity:0},animate:{y:0,opacity:1},exit:{y:100,opacity:0},transition:{type:"spring",damping:25,stiffness:300},className:"fixed bottom-4 left-4 right-4 z-50 rounded-xl bg-[#1A1A2E] border border-[#2A2A35] p-4 shadow-2xl max-w-md mx-auto flex items-center justify-between gap-3",children:[r.jsx("p",{className:"text-[13px] text-[#C0C0CC]",children:"Install damn.dev for a native experience"}),r.jsxs("div",{className:"flex gap-2 shrink-0",children:[r.jsx("button",{onClick:l,className:"text-[12px] text-[#8A8A99] hover:text-[#C0C0CC] transition-colors px-2 py-1",children:"Not now"}),r.jsx("button",{onClick:c,className:"text-[12px] font-medium bg-[#6366F1] text-white rounded-lg px-3 py-1.5 hover:bg-[#5558E6] transition-colors",children:"Install"})]})]})]})}function j8e(e){const t="=".repeat((4-e.length%4)%4),n=(e+t).replace(/-/g,"+").replace(/_/g,"/"),s=atob(n),i=new Uint8Array(s.length);for(let a=0;a<s.length;a++)i[a]=s.charCodeAt(a);return i}const cO="pwa-push-retry-after";function N8e(){const e=y.useRef(!1),{data:t}=L.notifications.getVapidKey.useQuery(void 0,{enabled:!Va}),n=L.notifications.registerToken.useMutation(),s=y.useCallback(async()=>{if(!t?.vapidKey||!("serviceWorker"in navigator)||!("PushManager"in window))return;const a=await navigator.serviceWorker.ready;let o=await a.pushManager.getSubscription();o||(o=await a.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:j8e(t.vapidKey).buffer})),n.mutate({token:JSON.stringify(o.toJSON()),platform:"web"})},[t?.vapidKey,n]),i=y.useCallback(async()=>{if(e.current)return;e.current=!0;const a=localStorage.getItem(cO);if(!(a&&Date.now()<Number(a))){if(Notification.permission==="granted"){await s();return}Notification.permission==="default"&&(await Notification.requestPermission()==="granted"?await s():localStorage.setItem(cO,String(Date.now()+1440*60*1e3)))}},[s]);return y.useEffect(()=>{t?.vapidKey&&Notification.permission==="granted"&&s()},[t?.vapidKey,s]),y.useEffect(()=>{if(!t?.vapidKey||Notification.permission!=="default")return;function a(){i()}return window.addEventListener("pwa-push-prompt",a,{once:!0}),()=>window.removeEventListener("pwa-push-prompt",a)},[t?.vapidKey,i]),{promptForPermission:i}}function k8e(){const[e,t]=y.useState(null),[n,s]=y.useState(!1),[i,a]=y.useState("idle"),[o,l]=y.useState(null),[c,d]=y.useState(!1);y.useEffect(()=>{fetch(`${oi}/api/version`,{credentials:"include"}).then(b=>b.json()).then(b=>{if(b.updateAvailable&&b.latest){const _=`dismissed_update_${b.latest}`;localStorage.getItem(_)||t(b)}}).catch(()=>{})},[]);const f=y.useCallback(()=>{const b=Date.now(),_=setInterval(async()=>{if(Date.now()-b>3e5){clearInterval(_),a("error"),l("Update may have failed. Check server logs.");return}try{(await fetch(`${oi}/health`)).ok&&(clearInterval(_),a("done"),setTimeout(()=>window.location.reload(),1e3))}catch{a("restarting")}},2e3)},[]),p=y.useCallback(async()=>{if(!e)return;if(typeof window<"u"&&"__TAURI__"in window){try{const{check:_}=await X(async()=>{const{check:A}=await import("./index-Cpew6ait.js");return{check:A}},__vite__mapDeps([105,1])),w=await _();if(w){a("updating"),await w.downloadAndInstall();const{relaunch:A}=await X(async()=>{const{relaunch:S}=await import("./index-CO34o7br.js");return{relaunch:S}},__vite__mapDeps([106,1]));await A()}}catch{a("error"),l("Download the latest version from damn.dev")}return}a("updating");try{const _=await fetch(`${oi}/api/update`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"}});if(_.status===403){a("error"),l("Only the workspace owner can trigger updates");return}const w=await _.json();if(w.error==="use_native_updater"){a("error"),l("Download the latest version from damn.dev");return}if(!w.ok){a("error"),l(w.error??"Update failed");return}f()}catch{a("error"),l("Failed to start update. Check server logs.")}},[e,f]);if(!e||n)return null;function m(){e?.latest&&localStorage.setItem(`dismissed_update_${e.latest}`,"1"),s(!0)}const g={"docker-vps":"SSH into your server and re-run your install script.",tauri:"Download the latest version from damn.dev."};return r.jsxs("div",{className:"bg-[#1A1A2E] border-b border-[#2A2A35] text-[#9090A0] text-[12px] py-1.5 px-4 flex flex-col flex-shrink-0",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[i==="idle"&&r.jsxs(r.Fragment,{children:[r.jsxs("span",{children:["damn.dev ",e.latest," is available"]}),e.canAutoUpdate?r.jsx("button",{onClick:p,className:"px-2 py-0.5 rounded bg-[#6366F1]/20 text-[#818CF8] hover:bg-[#6366F1]/30 transition-colors text-[11px] font-medium",children:"Update now"}):r.jsx("span",{className:"text-[#707080]",children:g[e.installPath]??"Re-run your install script to update."}),e.releaseNotes&&r.jsx("button",{onClick:()=>d(b=>!b),className:"text-[#707080] hover:text-[#9090A0] transition-colors text-[11px]",children:c?"Hide":"What's new"})]}),i==="updating"&&r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-3 h-3 border border-[#6366F1]/40 border-t-[#6366F1] rounded-full animate-spin"}),"Updating..."]}),i==="restarting"&&r.jsxs("span",{className:"flex items-center gap-2 animate-pulse",children:[r.jsx("span",{className:"w-3 h-3 border border-[#6366F1]/40 border-t-[#6366F1] rounded-full animate-spin"}),"Restarting..."]}),i==="done"&&r.jsx("span",{className:"text-[#22C55E]",children:"Updated!"}),i==="error"&&r.jsx("span",{className:"text-[#F87171]",children:o})]}),(i==="idle"||i==="error")&&r.jsx("button",{onClick:m,className:"ml-4 text-[#9090A0] hover:text-[#F0F0F5] transition-colors",children:"×"})]}),c&&e.releaseNotes&&r.jsx("div",{className:"mt-1.5 pt-1.5 border-t border-[#2A2A35] text-[11px] text-[#707080] whitespace-pre-wrap max-h-40 overflow-y-auto",children:e.releaseNotes})]})}function E8e(){const{data:e,refetch:t}=L.settings.getOpenClawVersion.useQuery(void 0,{refetchInterval:6e4,retry:!1}),[n,s]=y.useState(!1),[i,a]=y.useState("idle"),[o,l]=y.useState(null),c=L.settings.updateOpenClaw.useMutation();if(!e?.updateAvailable||n)return null;async function d(){a("updating");try{const f=await c.mutateAsync();f.ok?(a("done"),setTimeout(()=>{t(),s(!0)},3e3)):(a("error"),l(f.error??"Update failed"))}catch{a("error"),l("Failed to start update. Check server logs.")}}return r.jsxs("div",{className:"bg-[#1A1A2E] border-b border-[#2A2A35] text-[#9090A0] text-[12px] py-1.5 px-4 flex items-center justify-between flex-shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[i==="idle"&&r.jsxs(r.Fragment,{children:[r.jsxs("span",{children:["OpenClaw ",e.minimum," required (current: ",e.current,")"]}),r.jsx("button",{onClick:d,className:"px-2 py-0.5 rounded bg-[#6366F1]/20 text-[#818CF8] hover:bg-[#6366F1]/30 transition-colors text-[11px] font-medium",children:"Update now"})]}),i==="updating"&&r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-3 h-3 border border-[#6366F1]/40 border-t-[#6366F1] rounded-full animate-spin"}),"Updating OpenClaw..."]}),i==="done"&&r.jsx("span",{className:"text-[#22C55E]",children:"OpenClaw updated!"}),i==="error"&&r.jsx("span",{className:"text-[#F87171]",children:o})]}),(i==="idle"||i==="error")&&r.jsx("button",{onClick:()=>s(!0),className:"ml-4 text-[#9090A0] hover:text-[#F0F0F5] transition-colors",children:"×"})]})}function F8e(){return r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-8",children:[r.jsx("div",{className:"w-14 h-14 rounded-2xl bg-gradient-to-br from-[#6366F1]/20 to-[#8B5CF6]/20 border border-[#6366F1]/30 flex items-center justify-center mb-4",children:r.jsx("span",{className:"text-2xl",children:"⚡"})}),r.jsx("h2",{className:"text-[18px] font-semibold text-[#F0F0F5] mb-2",children:"Select a channel"}),r.jsx("p",{className:"text-[14px] text-[#8A8A99] max-w-xs leading-relaxed",children:"Choose a channel from the sidebar to start working with your team."})]})}function T8e({children:e}){const t=an(),{data:n,isLoading:s}=L.workspace.getMyMembership.useQuery(void 0,{staleTime:0,refetchOnWindowFocus:!1,retry:!1}),i=n?.role==="owner",{data:a,isLoading:o}=L.onboarding.getState.useQuery(void 0,{staleTime:0,refetchOnWindowFocus:!1,retry:!1,enabled:i});return y.useEffect(()=>{if(!(s||!n)){if(n.role!=="owner"){n.onboardedAt||t("/welcome",{replace:!0});return}o||!a||!a.completed&&!a.skippedAt&&t("/onboarding",{replace:!0})}},[a,o,n,s,t]),s||i&&o?r.jsx("div",{className:"flex h-screen w-screen items-center justify-center bg-[#0F0F11]",children:r.jsx("div",{className:"w-5 h-5 border-2 border-[#6366F1]/30 border-t-[#6366F1] rounded-full animate-spin"})}):r.jsx(r.Fragment,{children:e})}function M8e({children:e}){const{data:t,isPending:n}=Mi();return n?r.jsx("div",{className:"flex h-screen w-screen items-center justify-center bg-[#0F0F11]",children:r.jsx("div",{className:"w-5 h-5 border-2 border-[#6366F1]/30 border-t-[#6366F1] rounded-full animate-spin"})}):t?r.jsx(r.Fragment,{children:e}):r.jsx(g8e,{})}function R8e({children:e}){const{isPending:t}=Mi();return t?r.jsx("div",{className:"flex h-screen w-screen items-center justify-center bg-[#0F0F11]",children:r.jsx("div",{className:"w-5 h-5 border-2 border-[#6366F1]/30 border-t-[#6366F1] rounded-full animate-spin"})}):r.jsx(r.Fragment,{children:e})}function D8e(){const[e,t]=y.useState(!1),n=Je(a=>a.setUnreadCounts),{data:s}=Mi(),{data:i}=L.readReceipts.getUnread.useQuery(void 0,{staleTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,enabled:!!s});return y.useEffect(()=>{i&&n(i)},[i,n]),y.useEffect(()=>{function a(o){(o.metaKey||o.ctrlKey)&&o.key==="k"&&(o.preventDefault(),t(l=>!l))}return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[]),N8e(),r.jsxs("div",{className:"flex flex-col h-screen",children:[r.jsx(k8e,{}),r.jsx(E8e,{}),r.jsxs(Q_,{children:[r.jsx(ms,{path:"/invite/:token",element:r.jsx(R8e,{children:r.jsx(y8e,{})})}),r.jsx(ms,{path:"*",element:r.jsxs(M8e,{children:[r.jsxs(Q_,{children:[r.jsx(ms,{path:"/onboarding",element:r.jsx(m8e,{})}),r.jsx(ms,{path:"/welcome",element:r.jsx(x8e,{})}),r.jsx(ms,{path:"*",element:r.jsx(T8e,{children:r.jsx(qye,{children:r.jsxs(Q_,{children:[r.jsx(ms,{path:"/",element:r.jsx(lm,{to:"/channels/direction",replace:!0})}),r.jsx(ms,{path:"/channels/:channelId",element:r.jsx(UMe,{})}),r.jsx(ms,{path:"/agents",element:r.jsx(tRe,{})}),r.jsx(ms,{path:"/agents/new",element:r.jsx(pRe,{})}),r.jsx(ms,{path:"/agents/edit-soul/:agentId",element:r.jsx(xRe,{})}),r.jsx(ms,{path:"/skills",element:r.jsx(BRe,{})}),r.jsx(ms,{path:"/deliverables",element:r.jsx(qDe,{})}),r.jsx(ms,{path:"/missions",element:r.jsx(GDe,{})}),r.jsx(ms,{path:"/coo",element:r.jsx(ZRe,{})}),r.jsx(ms,{path:"/settings",element:r.jsx(uDe,{})}),r.jsx(ms,{path:"/federation/:nodeId/:agentId",element:r.jsx(IDe,{})}),r.jsx(ms,{path:"*",element:r.jsx(F8e,{})})]})})})})]}),r.jsx(_8e,{open:e,onClose:()=>t(!1)})]})})]}),r.jsx(C8e,{})]})}GG.createRoot(document.getElementById("root")).render(r.jsx(y.StrictMode,{children:r.jsx(aJ,{children:r.jsxs(pY,{children:[r.jsx(D8e,{}),r.jsx(QY,{position:"bottom-right",toastOptions:{style:{background:"#1C1C24",border:"1px solid #2A2A35",color:"#C8C8D4",fontSize:"12px"}}})]})})}));
|
|
435
|
+
`):a;return r.jsxs("div",{className:"mx-3 mb-2 rounded-md bg-[#0F0F11] border border-[#2A2A35]/50 p-3",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[t&&r.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-[#8A8A99]",children:[r.jsx("span",{children:t.emoji}),r.jsx("span",{children:t.name})]}),i?.crossInstance&&i.federationNodeName&&r.jsxs("span",{className:"flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded bg-[#6366F1]/10 text-[#818CF8]",children:[r.jsx(Xt,{className:"w-2.5 h-2.5"}),i.federationNodeName]}),r.jsx("span",{className:"text-[10px] text-[#5A5A6E]",children:"Result"})]}),r.jsx("pre",{className:"text-[11px] text-[#C8C8D4] whitespace-pre-wrap break-words leading-relaxed font-mono",children:c}),l&&r.jsx("button",{onClick:()=>s(!n),className:"text-[10px] text-[#6366F1] hover:text-[#818CF8] mt-1.5 transition-colors",children:n?"Collapse":`Show full result (${o.length} lines)`})]})}function a8e({taskId:e,status:t}){const[n,s]=y.useState(!1),i=L.useUtils(),a=L.missions.removeTask.useMutation({onSuccess:()=>{i.missions.list.invalidate(),s(!1)}}),o=L.missions.updateTask.useMutation({onSuccess:()=>{i.missions.list.invalidate(),s(!1)}});return r.jsxs("div",{className:"relative",children:[r.jsx("button",{onClick:l=>{l.stopPropagation(),s(!n)},className:"text-[#3A3A45] hover:text-[#8A8A99] transition-colors p-0.5",children:r.jsx(iL,{className:"w-3 h-3"})}),n&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"fixed inset-0 z-20",onClick:()=>s(!1)}),r.jsxs("div",{className:"absolute right-0 top-5 z-30 bg-[#1A1A24] border border-[#2A2A35] rounded-lg shadow-xl py-1 min-w-[140px]",children:[t==="pending"&&r.jsx("button",{onClick:l=>{l.stopPropagation(),s(!1)},className:"w-full text-left px-3 py-1.5 text-[11px] text-[#C8C8D4] hover:bg-white/5 transition-colors",children:"Edit instruction"}),(t==="working"||t==="dispatched")&&r.jsx("button",{onClick:l=>{l.stopPropagation(),o.mutate({missionTaskId:e,status:"cancelled"})},className:"w-full text-left px-3 py-1.5 text-[11px] text-[#F59E0B] hover:bg-[#F59E0B]/10 transition-colors",children:"Cancel task"}),t==="failed"&&r.jsx("button",{onClick:l=>{l.stopPropagation(),o.mutate({missionTaskId:e,status:"pending"})},className:"w-full text-left px-3 py-1.5 text-[11px] text-[#6366F1] hover:bg-[#6366F1]/10 transition-colors",children:"Retry task"}),t==="completed"&&r.jsx("button",{onClick:l=>{l.stopPropagation(),o.mutate({missionTaskId:e,status:"pending"})},className:"w-full text-left px-3 py-1.5 text-[11px] text-[#8A8A99] hover:bg-white/5 transition-colors",children:"Re-open"}),r.jsx("button",{onClick:l=>{l.stopPropagation(),a.mutate({missionTaskId:e})},className:"w-full text-left px-3 py-1.5 text-[11px] text-[#EF4444] hover:bg-[#EF4444]/10 transition-colors",children:"Remove"})]})]})]})}function jW({status:e}){switch(e){case"completed":return r.jsx(Fe,{className:"w-3.5 h-3.5 text-[#10B981]"});case"failed":return r.jsx(Te,{className:"w-3.5 h-3.5 text-[#EF4444]"});case"working":case"dispatched":return r.jsx(Pe,{className:"w-3.5 h-3.5 text-[#6366F1] animate-spin"});case"review":return r.jsx(ql,{className:"w-3.5 h-3.5 text-[#F59E0B]"});case"cancelled":return r.jsx(Te,{className:"w-3.5 h-3.5 text-[#5A5A6E]"});default:return r.jsx("div",{className:"w-3.5 h-3.5 rounded-full border border-[#3A3A45]"})}}function o8e({open:e,onClose:t,onCreated:n}){const[s,i]=y.useState(""),[a,o]=y.useState(""),[l,c]=y.useState("normal"),d=L.missions.create.useMutation({onSuccess:()=>n()});return r.jsx(ji,{open:e,onOpenChange:f=>{f||t()},children:r.jsxs(Ni,{children:[r.jsx(ir,{className:"fixed inset-0 bg-black/60 z-50"}),r.jsxs(ki,{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[460px] bg-[#16161A] border border-[#2A2A35] rounded-xl p-6 z-50 shadow-2xl",children:[r.jsx(nr,{className:"text-[15px] font-medium text-[#F0F0F5] mb-4",children:"New Mission"}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-[11px] text-[#8A8A99] uppercase tracking-wider mb-1 block",children:"Title"}),r.jsx("input",{autoFocus:!0,value:s,onChange:f=>i(f.target.value),placeholder:"What needs to be done?",className:"w-full px-3 py-2 bg-[#0F0F11] border border-[#2A2A35] rounded-md text-[13px] text-[#F0F0F5] placeholder-[#3A3A45] focus:outline-none focus:border-[#6366F1]",onKeyDown:f=>{f.key==="Enter"&&s.trim()&&d.mutate({title:s.trim(),description:a.trim()||void 0,priority:l})}})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-[11px] text-[#8A8A99] uppercase tracking-wider mb-1 block",children:"Description"}),r.jsx("textarea",{value:a,onChange:f=>o(f.target.value),placeholder:"Optional details...",rows:3,className:"w-full px-3 py-2 bg-[#0F0F11] border border-[#2A2A35] rounded-md text-[13px] text-[#F0F0F5] placeholder-[#3A3A45] focus:outline-none focus:border-[#6366F1] resize-none"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-[11px] text-[#8A8A99] uppercase tracking-wider mb-1 block",children:"Priority"}),r.jsx("div",{className:"flex gap-2",children:["low","normal","high","critical"].map(f=>r.jsx("button",{onClick:()=>c(f),className:ye("px-3 py-1.5 rounded-md text-[12px] font-medium transition-colors",l===f?"text-white":"text-[#5A5A6E] bg-[#1E1E28] hover:text-[#8A8A99]"),style:l===f?{backgroundColor:My[f]}:void 0,children:SW[f]},f))})]})]}),r.jsxs("div",{className:"flex items-center justify-end gap-2 mt-5",children:[r.jsx(Gs,{asChild:!0,children:r.jsx("button",{className:"px-3 py-1.5 rounded-md text-[12px] text-[#8A8A99] hover:text-[#C8C8D4] transition-colors",children:"Cancel"})}),r.jsxs("button",{onClick:()=>{s.trim()&&d.mutate({title:s.trim(),description:a.trim()||void 0,priority:l})},disabled:!s.trim()||d.isPending,className:"flex items-center gap-1.5 px-4 py-1.5 rounded-md bg-[#6366F1] text-white text-[12px] font-medium hover:bg-[#5558E6] transition-colors disabled:opacity-50",children:[d.isPending&&r.jsx(Pe,{className:"w-3 h-3 animate-spin"}),"Create Mission"]})]})]})]})})}const l8e=4;function c8e({current:e}){return r.jsx("div",{className:"flex items-center gap-2",children:Array.from({length:l8e}).map((t,n)=>r.jsx("div",{className:ye("rounded-full transition-all duration-300",n<e?"w-2 h-2 bg-[#6366F1]":n===e?"w-6 h-2 bg-[#6366F1]":"w-2 h-2 bg-[#2A2A35]")},n))})}function Vd({children:e}){return r.jsx(ne.div,{initial:{opacity:0,x:24},animate:{opacity:1,x:0},exit:{opacity:0,x:-24},transition:{duration:.22,ease:[.16,1,.3,1]},className:"w-full max-w-lg mx-auto",children:e})}function lO({onDetected:e,alreadyRunning:t}){const[n,s]=y.useState("."),i=L.onboarding.pollOpenClaw.useQuery(void 0,{refetchInterval:3e3,refetchOnWindowFocus:!1,retry:!1});return y.useEffect(()=>{t||i.data?.running&&e()},[i.data?.running]),y.useEffect(()=>{const a=setInterval(()=>s(o=>o.length>=3?".":o+"."),500);return()=>clearInterval(a)},[]),i.data?.running?r.jsxs("div",{className:"flex items-center gap-2 mt-4 text-[12px] text-emerald-400",children:[r.jsx(sa,{className:"w-3.5 h-3.5"}),"OpenClaw detected — advancing…"]}):r.jsxs("div",{className:"flex items-center gap-2 mt-4 text-[12px] text-[#5A5A6E]",children:[r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#5A5A6E] animate-pulse"}),"Waiting for OpenClaw",n]})}function IC({code:e}){const[t,n]=y.useState(!1);function s(){navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}return r.jsxs("div",{className:"flex items-center justify-between bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 font-mono text-[12px] text-[#C8C8D4]",children:[r.jsx("span",{children:e}),r.jsx("button",{onClick:s,className:ye("ml-3 flex-shrink-0 transition-colors",t?"text-emerald-400":"text-[#5A5A6E] hover:text-[#C8C8D4]"),children:t?r.jsx(Fe,{className:"w-3.5 h-3.5"}):r.jsx(Po,{className:"w-3.5 h-3.5"})})]})}function u8e({onNext:e,onSkip:t}){const{data:n,isLoading:s}=L.onboarding.checkOpenClaw.useQuery(void 0,{refetchOnWindowFocus:!1,retry:!1}),i=L.onboarding.skipOpenClaw.useMutation(),[a,o]=y.useState(!1),[l,c]=y.useState("docker"),[d,f]=y.useState(void 0);n?.runMode&&n.runMode!==d&&(f(n.runMode),n.runMode==="docker"?c("npm"):n.runMode==="npm"&&c("docker"));const[p,m]=y.useState(""),[g,b]=y.useState(!1),[_,w]=y.useState(""),[A,S]=y.useState(""),[C,E]=y.useState("idle"),k=L.onboarding.saveWaitlistEmail.useMutation(),T=L.onboarding.testConnection.useMutation();if(s)return r.jsx(Vd,{children:r.jsxs("div",{className:"flex items-center gap-3 py-8",children:[r.jsx(Pe,{className:"w-4 h-4 animate-spin text-[#6366F1]"}),r.jsx("span",{className:"text-[14px] text-[#8A8A99]",children:"Checking OpenClaw…"})]})});async function F(){await i.mutateAsync(),t()}async function M(){if(!_.trim()||!A.trim())return;E("testing");const q=await T.mutateAsync({url:_.trim(),token:A.trim()});E(q.ok?"ok":"fail"),q.ok&&setTimeout(()=>e(),1e3)}async function I(){p.trim()&&(await k.mutateAsync({email:p.trim()}),b(!0))}const R=n?.running===!0,H=n?.runMode??null,K=[{id:"docker",label:"Docker",sub:"Agents run isolated",badge:"Recommended"},{id:"npm",label:"Local (npm)",sub:"Best for dedicated machines",badge:null},{id:"cloud",label:"Cloud (VPS)",sub:"Always-on, team access",badge:null}].filter(q=>q.id!==H);return R&&!a?r.jsxs(Vd,{children:[r.jsx("h2",{className:"text-[22px] font-semibold text-[#F0F0F5] mb-2",children:"Connect OpenClaw"}),r.jsx("p",{className:"text-[14px] text-[#8A8A99] mb-6 leading-relaxed",children:"damn.dev runs agents through OpenClaw, the local AI gateway."}),r.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 rounded-xl bg-emerald-500/10 border border-emerald-500/20 mb-6",children:[r.jsx(sa,{className:"w-4 h-4 text-emerald-400 flex-shrink-0"}),r.jsxs("div",{className:"flex-1",children:[r.jsxs("p",{className:"text-[13px] font-medium text-emerald-400",children:["OpenClaw detected",H==="docker"?" via Docker":H==="cloud"?" via Cloud":H==="npm"?" locally":""]}),(n.agentCount??0)>0&&r.jsxs("p",{className:"text-[11px] text-emerald-400/70",children:[n.agentCount," agent",n.agentCount!==1?"s":""," detected"]})]})]}),r.jsxs("button",{onClick:e,className:"flex items-center gap-2 px-5 py-2.5 rounded-xl text-[13px] font-medium bg-[#6366F1] text-white hover:bg-[#5254CC] transition-colors mb-4",children:["Continue",r.jsx(Jt,{className:"w-3.5 h-3.5"})]}),r.jsx("button",{onClick:()=>o(!0),className:"text-[12px] text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:"Want to connect to a different instance?"})]}):r.jsxs(Vd,{children:[r.jsx("h2",{className:"text-[22px] font-semibold text-[#F0F0F5] mb-2",children:"Connect OpenClaw"}),r.jsx("p",{className:"text-[14px] text-[#8A8A99] mb-6 leading-relaxed",children:"damn.dev runs agents through OpenClaw, the local AI gateway."}),R&&a&&r.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 rounded-xl bg-emerald-500/10 border border-emerald-500/20 mb-4",children:[r.jsx(sa,{className:"w-4 h-4 text-emerald-400 flex-shrink-0"}),r.jsx("div",{className:"flex-1",children:r.jsxs("p",{className:"text-[13px] font-medium text-emerald-400",children:["OpenClaw is running",H==="docker"?" via Docker":H==="cloud"?" via Cloud":H==="npm"?" locally":""]})}),r.jsxs("button",{onClick:e,className:"ml-auto flex items-center gap-1 text-[12px] font-medium text-emerald-400 hover:text-emerald-300 transition-colors flex-shrink-0",children:["Continue ",r.jsx(Jt,{className:"w-3 h-3"})]})]}),r.jsx("div",{className:ye("grid gap-3 mb-4",K.length===2?"grid-cols-2":"grid-cols-3"),children:K.map(q=>r.jsxs("button",{onClick:()=>c(q.id),className:ye("relative text-left rounded-2xl p-4 border transition-all",l===q.id?"border-[#6366F1]/50 bg-[#6366F1]/5 ring-1 ring-[#6366F1]/20":"border-[#2A2A35] bg-[#16161A] hover:border-[#3A3A45]"),children:[q.badge&&r.jsx("span",{className:"absolute -top-2 left-3 px-1.5 py-0.5 rounded text-[9px] font-semibold bg-[#6366F1] text-white tracking-wide",children:q.badge}),r.jsx("p",{className:"text-[13px] font-medium text-[#F0F0F5] mt-1",children:q.label}),r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mt-0.5",children:q.sub})]},q.id))}),r.jsxs("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-5 mb-4",children:[l==="docker"&&r.jsxs("div",{children:[r.jsxs("a",{href:"https://www.docker.com/products/docker-desktop/",target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 w-full justify-center py-2 px-4 rounded-lg border border-[#2A2A35] text-[13px] text-[#C8C8D4] hover:border-[#3A3A45] hover:text-[#F0F0F5] transition-colors mb-3",children:[r.jsx(cs,{className:"w-3.5 h-3.5"}),"Download Docker Desktop"]}),r.jsx("button",{onClick:()=>window.open("http://localhost:3001/setup/docker-compose.yml","_blank"),className:"flex items-center gap-2 w-full justify-center py-2 px-4 rounded-lg bg-[#6366F1]/10 border border-[#6366F1]/30 text-[13px] text-[#6366F1] hover:bg-[#6366F1]/20 transition-colors mb-4",children:"Download docker-compose.yml"}),r.jsx("p",{className:"text-[12px] text-[#8A8A99] leading-relaxed",children:"Open Docker Desktop → Compose → Open File → Run"}),r.jsx(lO,{onDetected:e,alreadyRunning:R})]}),l==="npm"&&r.jsxs("div",{children:[r.jsxs("div",{className:"space-y-2 mb-4",children:[r.jsx(IC,{code:"npm install -g openclaw"}),r.jsx(IC,{code:"openclaw start"})]}),r.jsx(lO,{onDetected:e,alreadyRunning:R})]}),l==="cloud"&&r.jsxs("div",{className:"space-y-5",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-[13px] font-medium text-[#C8C8D4] mb-1",children:"Want OpenClaw fully managed in the cloud?"}),r.jsx("p",{className:"text-[12px] text-[#8A8A99] mb-3",children:"Join the waitlist for cloud.damn.dev."}),g?r.jsx("p",{className:"text-[12px] text-emerald-400",children:"You're on the list. We'll notify you when cloud.damn.dev launches."}):r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{type:"email",value:p,onChange:q=>m(q.target.value),placeholder:"you@example.com",className:"flex-1 bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] placeholder:text-[#5A5A6E] outline-none focus:border-[#6366F1]/50 transition-colors"}),r.jsx("button",{onClick:I,disabled:!p.trim()||k.isPending,className:"px-3 py-2 rounded-lg text-[12px] font-medium bg-[#6366F1]/10 text-[#6366F1] border border-[#6366F1]/30 hover:bg-[#6366F1]/20 disabled:opacity-50 transition-colors flex-shrink-0",children:k.isPending?r.jsx(Pe,{className:"w-3.5 h-3.5 animate-spin"}):"Join waitlist"})]})]}),r.jsxs("div",{className:"border-t border-[#2A2A35] pt-5",children:[r.jsx("p",{className:"text-[13px] font-medium text-[#C8C8D4] mb-3",children:"Already running on a VPS?"}),r.jsxs("div",{className:"space-y-2 mb-3",children:[r.jsx("input",{type:"url",value:_,onChange:q=>{w(q.target.value),E("idle")},placeholder:"https://openclaw.myserver.com",className:"w-full bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] placeholder:text-[#5A5A6E] outline-none focus:border-[#6366F1]/50 transition-colors"}),r.jsx("input",{type:"password",value:A,onChange:q=>{S(q.target.value),E("idle")},placeholder:"Bearer token",className:"w-full bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] placeholder:text-[#5A5A6E] outline-none focus:border-[#6366F1]/50 transition-colors"})]}),r.jsxs("button",{onClick:M,disabled:!_.trim()||!A.trim()||C==="testing"||C==="ok",className:"flex items-center gap-2 px-4 py-2 rounded-lg text-[12px] font-medium bg-[#6366F1]/10 text-[#6366F1] border border-[#6366F1]/30 hover:bg-[#6366F1]/20 disabled:opacity-50 transition-colors",children:[C==="testing"&&r.jsx(Pe,{className:"w-3.5 h-3.5 animate-spin"}),C==="ok"&&r.jsx(Fe,{className:"w-3.5 h-3.5 text-emerald-400"}),C==="fail"&&r.jsx(Te,{className:"w-3.5 h-3.5 text-red-400"}),C==="ok"?"Connected":"Test connection"]})]})]})]}),r.jsx("button",{onClick:F,className:"text-[12px] text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:"I'll connect OpenClaw later →"})]})}function d8e({onDetected:e}){const[t,n]=y.useState("."),s=L.onboarding.pollOllama.useQuery(void 0,{refetchInterval:3e3,refetchOnWindowFocus:!1,retry:!1});return y.useEffect(()=>{s.data?.running&&s.data.models.length>0&&e(s.data.models)},[s.data?.running]),y.useEffect(()=>{const i=setInterval(()=>n(a=>a.length>=3?".":a+"."),500);return()=>clearInterval(i)},[]),s.data?.running?r.jsxs("div",{className:"flex items-center gap-2 mt-3 text-[12px] text-emerald-400",children:[r.jsx(sa,{className:"w-3.5 h-3.5"}),"Ollama detected"]}):r.jsxs("div",{className:"flex items-center gap-2 mt-3 text-[12px] text-[#5A5A6E]",children:[r.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-[#5A5A6E] animate-pulse"}),"Waiting for Ollama",t]})}function h8e({onNext:e,onSkip:t}){const[n,s]=y.useState(""),[i,a]=y.useState(""),[o,l]=y.useState(""),[c,d]=y.useState(""),[f,p]=y.useState(null),[m,g]=y.useState(null),[b,_]=y.useState(!1),[w,A]=y.useState(null),[S,C]=y.useState(null),[E,k]=y.useState(""),[T,F]=y.useState(""),[M,I]=y.useState(""),[R,H]=y.useState(""),[V,K]=y.useState([]),[q,$]=y.useState(!1),B=y.useRef(null),{data:Y,isLoading:U}=L.onboarding.checkModels.useQuery(void 0,{refetchOnWindowFocus:!1,retry:!1}),{data:W}=L.onboarding.getState.useQuery(void 0,{refetchOnWindowFocus:!1});y.useEffect(()=>{Y?.envOpenRouterConfigured&&!w&&(A({valid:!0,modelCount:Y.openRouterModelCount??0,suggestedReasoningModel:W?.defaultReasoningModel??null,suggestedFastModel:W?.defaultFastModel??null}),s("sk-or-v1-••••••••••••••••••••••••••••••••"),W?.defaultReasoningModel&&!E&&k(W.defaultReasoningModel),W?.defaultFastModel&&!T&&F(W.defaultFastModel)),(Y?.ollamaModels?.length??0)>0&&K(Y.ollamaModels)},[Y?.envOpenRouterConfigured,Y?.ollamaModels?.length,W?.defaultReasoningModel]);const O=L.onboarding.validateApiKey.useMutation(),D=L.onboarding.setDefaultModels.useMutation();function Q(me){me.suggestedReasoningModel&&!E&&k(me.suggestedReasoningModel),me.suggestedFastModel&&!T&&F(me.suggestedFastModel)}async function z(){if(!n.trim())return;const me=await O.mutateAsync({provider:"openrouter",key:n.trim()});A(me),me.valid&&Q(me)}async function J(){if(!i.trim())return;const me=await O.mutateAsync({provider:"anthropic",key:i.trim()});C(me),me.valid&&Q(me)}async function ee(){if(!o.trim())return;const me=await O.mutateAsync({provider:"openai",key:o.trim()});p(me),me.valid&&Q(me)}async function re(){if(!c.trim())return;const me=await O.mutateAsync({provider:"gemini",key:c.trim()});g(me),me.valid&&Q(me)}const oe=V.length>0,se=oe||w?.valid===!0||S?.valid===!0||f?.valid===!0||m?.valid===!0||Y?.envOpenRouterConfigured===!0,ae=[];if(oe)for(const me of V)ae.push({id:me,label:me,group:"Ollama"});if(w?.valid){const me=[{id:"anthropic/claude-sonnet-4.6",label:"Claude Sonnet 4.6"},{id:"anthropic/claude-opus-4.6",label:"Claude Opus 4.6"},{id:"anthropic/claude-haiku-4.5",label:"Claude Haiku 4.5"},{id:"openai/gpt-4o",label:"GPT-4o"},{id:"openai/gpt-4o-mini",label:"GPT-4o mini"},{id:"google/gemini-2.5-pro",label:"Gemini 2.5 Pro"},{id:"google/gemini-2.5-flash",label:"Gemini 2.5 Flash"},{id:"meta-llama/llama-3.3-70b-instruct:free",label:"Llama 3.3 70B (free)"}];for(const $e of me)ae.push({...$e,group:"OpenRouter"})}if(S?.valid){const me=[{id:"anthropic/claude-sonnet-4.6",label:"Claude Sonnet 4.6"},{id:"anthropic/claude-opus-4.6",label:"Claude Opus 4.6"},{id:"anthropic/claude-haiku-4.5",label:"Claude Haiku 4.5"}];for(const $e of me)ae.some(nt=>nt.id===$e.id)||ae.push({...$e,group:"Anthropic"})}if(f?.valid){const me=[{id:"openai/gpt-4o",label:"GPT-4o"},{id:"openai/gpt-4o-mini",label:"GPT-4o mini"}];for(const $e of me)ae.some(nt=>nt.id===$e.id)||ae.push({...$e,group:"OpenAI"})}if(m?.valid){const me=[{id:"google/gemini-2.5-pro",label:"Gemini 2.5 Pro"},{id:"google/gemini-2.5-flash",label:"Gemini 2.5 Flash"}];for(const $e of me)ae.some(nt=>nt.id===$e.id)||ae.push({...$e,group:"Google"})}const le=se&&ae.length>0,je=(Y?.ramGb??0)>=8,Ee=Y?.recommendedLocalModel??null,de=Y?.recommendedModelSize??null;return r.jsxs(Vd,{children:[r.jsx("h2",{className:"text-[22px] font-semibold text-[#F0F0F5] mb-1",children:"Configure models"}),r.jsx("p",{className:"text-[14px] text-[#8A8A99] mb-4 leading-relaxed",children:"Connect at least one model source for your agents to use."}),r.jsxs("div",{className:"space-y-2.5 mb-4",children:[r.jsxs("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2.5",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-[13px] font-medium text-[#F0F0F5]",children:"Ollama (local)"}),r.jsx("p",{className:"text-[11px] text-[#8A8A99] mt-0.5",children:"Free, runs on your machine"})]}),U?r.jsx("div",{className:"w-4 h-4 border-2 border-[#6366F1]/30 border-t-[#6366F1] rounded-full animate-spin"}):oe?r.jsxs("span",{className:"text-[11px] text-emerald-400 font-medium",children:[V.length," model",V.length!==1?"s":""]}):r.jsx("span",{className:"text-[11px] text-[#5A5A6E]",children:"Not detected"})]}),oe?r.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[V.slice(0,6).map(me=>r.jsx("span",{className:"px-2 py-0.5 rounded-md text-[11px] font-medium bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:me},me)),V.length>6&&r.jsxs("span",{className:"px-2 py-0.5 rounded-md text-[11px] text-[#8A8A99]",children:["+",V.length-6," more"]})]}):!U&&r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"rounded-xl border border-[#2A2A35] bg-[#0F0F11] p-3",children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("p",{className:"text-[13px] font-medium text-[#C8C8D4]",children:"Get started with OpenRouter"}),r.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-semibold bg-[#6366F1]/15 text-[#6366F1] border border-[#6366F1]/20",children:"No install needed"})]}),r.jsx("p",{className:"text-[12px] text-[#8A8A99] mb-2",children:"Free models available. The fastest way to get running."}),r.jsx("button",{onClick:()=>B.current?.focus(),className:"text-[12px] text-[#6366F1] hover:text-[#818CF8] transition-colors",children:"Go to OpenRouter section ↓"})]}),r.jsx("button",{onClick:()=>$(me=>!me),className:"text-[12px] text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:q?"Hide local install ↑":"Prefer fully local? →"}),q&&r.jsx("div",{className:"rounded-xl border border-[#2A2A35] bg-[#0F0F11] p-3 space-y-3",children:je?r.jsxs(r.Fragment,{children:[r.jsxs("a",{href:"https://ollama.com",target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 w-full justify-center py-2 px-4 rounded-lg border border-[#2A2A35] text-[13px] text-[#C8C8D4] hover:border-[#3A3A45] hover:text-[#F0F0F5] transition-colors",children:[r.jsx(cs,{className:"w-3.5 h-3.5"}),"Download Ollama"]}),Ee&&r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(IC,{code:`ollama pull ${Ee}`}),de&&r.jsx("p",{className:"text-[11px] text-[#5A5A6E]",children:de})]}),r.jsx(d8e,{onDetected:me=>K(me)})]}):r.jsx("p",{className:"text-[12px] text-[#8A8A99]",children:"Local models require at least 8GB RAM. We recommend OpenRouter instead."})})]})]}),r.jsxs("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("p",{className:"text-[13px] font-medium text-[#F0F0F5]",children:"OpenRouter"}),Y?.envOpenRouterConfigured&&r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-emerald-400",children:[r.jsx(Fe,{className:"w-3 h-3"})," Configured via .env"]})]}),r.jsx("p",{className:"text-[11px] text-[#8A8A99] mb-2.5",children:"Access 200+ models via one API key"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{type:"password",value:n,onChange:me=>{s(me.target.value),A(null)},placeholder:"sk-or-v1-...",ref:B,className:"flex-1 bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] placeholder:text-[#5A5A6E] outline-none focus:border-[#6366F1]/50 transition-colors"}),r.jsx("button",{onClick:z,disabled:!n.trim()||O.isPending,className:"px-3 py-2 rounded-lg text-[12px] font-medium bg-[#6366F1]/10 text-[#6366F1] border border-[#6366F1]/30 hover:bg-[#6366F1]/20 disabled:opacity-50 transition-colors flex-shrink-0",children:O.isPending?r.jsx("div",{className:"w-3.5 h-3.5 border-2 border-[#6366F1]/30 border-t-[#6366F1] rounded-full animate-spin"}):"Validate"})]}),w&&r.jsxs("div",{className:ye("flex items-center gap-1.5 mt-2 text-[12px]",w.valid?"text-emerald-400":"text-red-400"),children:[w.valid?r.jsx(Fe,{className:"w-3.5 h-3.5"}):r.jsx(Te,{className:"w-3.5 h-3.5"}),w.valid?`Valid — ${w.modelCount} models available`:"Invalid key"]}),w?.valid&&w.suggestedReasoningModel&&r.jsx("div",{className:"mt-3 pt-3 border-t border-[#2A2A35]",children:r.jsx("p",{className:"text-[11px] text-[#8A8A99] mb-1",children:"Models available via OpenRouter"})})]}),r.jsxs("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-4",children:[r.jsx("p",{className:"text-[13px] font-medium text-[#F0F0F5] mb-0.5",children:"Anthropic"}),r.jsx("p",{className:"text-[11px] text-[#8A8A99] mb-2.5",children:"Claude models (Haiku, Sonnet, Opus)"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{type:"password",value:i,onChange:me=>{a(me.target.value),C(null)},placeholder:"sk-ant-...",className:"flex-1 bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] placeholder:text-[#5A5A6E] outline-none focus:border-[#6366F1]/50 transition-colors"}),r.jsx("button",{onClick:J,disabled:!i.trim()||O.isPending,className:"px-3 py-2 rounded-lg text-[12px] font-medium bg-[#6366F1]/10 text-[#6366F1] border border-[#6366F1]/30 hover:bg-[#6366F1]/20 disabled:opacity-50 transition-colors flex-shrink-0",children:O.isPending?r.jsx("div",{className:"w-3.5 h-3.5 border-2 border-[#6366F1]/30 border-t-[#6366F1] rounded-full animate-spin"}):"Validate"})]}),S&&r.jsxs("div",{className:ye("flex items-center gap-1.5 mt-2 text-[12px]",S.valid?"text-emerald-400":"text-red-400"),children:[S.valid?r.jsx(Fe,{className:"w-3.5 h-3.5"}):r.jsx(Te,{className:"w-3.5 h-3.5"}),S.valid?"Valid":"Invalid key"]})]}),r.jsxs("button",{onClick:()=>_(me=>!me),className:"flex items-center gap-1.5 text-[12px] text-[#5A5A6E] hover:text-[#8A8A99] transition-colors w-full py-0.5",children:[r.jsx("span",{children:b?"↑ Hide":"↓ More providers"}),r.jsx("span",{className:"text-[#3A3A45]",children:"(OpenAI, Gemini)"})]}),b&&r.jsxs("div",{className:"space-y-2.5",children:[r.jsxs("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-4",children:[r.jsx("p",{className:"text-[13px] font-medium text-[#F0F0F5] mb-0.5",children:"OpenAI"}),r.jsx("p",{className:"text-[11px] text-[#8A8A99] mb-2.5",children:"GPT-4o, o1, o3-mini"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{type:"password",value:o,onChange:me=>{l(me.target.value),p(null)},placeholder:"sk-...",className:"flex-1 bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] placeholder:text-[#5A5A6E] outline-none focus:border-[#6366F1]/50 transition-colors"}),r.jsx("button",{onClick:ee,disabled:!o.trim()||O.isPending,className:"px-3 py-2 rounded-lg text-[12px] font-medium bg-[#6366F1]/10 text-[#6366F1] border border-[#6366F1]/30 hover:bg-[#6366F1]/20 disabled:opacity-50 transition-colors flex-shrink-0",children:O.isPending?r.jsx("div",{className:"w-3.5 h-3.5 border-2 border-[#6366F1]/30 border-t-[#6366F1] rounded-full animate-spin"}):"Validate"})]}),f&&r.jsxs("div",{className:ye("flex items-center gap-1.5 mt-2 text-[12px]",f.valid?"text-emerald-400":"text-red-400"),children:[f.valid?r.jsx(Fe,{className:"w-3.5 h-3.5"}):r.jsx(Te,{className:"w-3.5 h-3.5"}),f.valid?"Valid":"Invalid key"]})]}),r.jsxs("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-4",children:[r.jsx("p",{className:"text-[13px] font-medium text-[#F0F0F5] mb-0.5",children:"Google Gemini"}),r.jsx("p",{className:"text-[11px] text-[#8A8A99] mb-2.5",children:"Gemini 2.0, Flash, Pro"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{type:"password",value:c,onChange:me=>{d(me.target.value),g(null)},placeholder:"AIza...",className:"flex-1 bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] placeholder:text-[#5A5A6E] outline-none focus:border-[#6366F1]/50 transition-colors"}),r.jsx("button",{onClick:re,disabled:!c.trim()||O.isPending,className:"px-3 py-2 rounded-lg text-[12px] font-medium bg-[#6366F1]/10 text-[#6366F1] border border-[#6366F1]/30 hover:bg-[#6366F1]/20 disabled:opacity-50 transition-colors flex-shrink-0",children:O.isPending?r.jsx("div",{className:"w-3.5 h-3.5 border-2 border-[#6366F1]/30 border-t-[#6366F1] rounded-full animate-spin"}):"Validate"})]}),m&&r.jsxs("div",{className:ye("flex items-center gap-1.5 mt-2 text-[12px]",m.valid?"text-emerald-400":"text-red-400"),children:[m.valid?r.jsx(Fe,{className:"w-3.5 h-3.5"}):r.jsx(Te,{className:"w-3.5 h-3.5"}),m.valid?"Valid":"Invalid key"]})]})]})]}),le&&r.jsxs("div",{className:"bg-[#16161A] border border-[#6366F1]/20 rounded-2xl p-4 mb-1",children:[r.jsx("p",{className:"text-[13px] font-medium text-[#F0F0F5] mb-0.5",children:"Default models"}),r.jsx("p",{className:"text-[11px] text-[#8A8A99] mb-3",children:"Pre-selected for you. Change anytime in Settings."}),r.jsxs("div",{className:"space-y-2.5",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-[11px] text-[#5A5A6E] mb-1 block",children:"Primary (reasoning)"}),r.jsxs(ss,{value:E,onValueChange:me=>{k(me),I("")},children:[r.jsxs(is,{className:"w-full flex items-center justify-between px-3 py-2 rounded-lg border border-[#2A2A35] bg-[#0F0F11] text-[13px] text-[#F0F0F5] outline-none focus:border-[#6366F1]/50 transition-colors",children:[r.jsx("span",{className:"truncate",children:(ae.find(me=>me.id===E)?.label??E)||"Select model..."}),r.jsx(Yl,{children:r.jsx(ft,{className:"w-3.5 h-3.5 text-[#5A5A6E]"})})]}),r.jsx(rs,{children:r.jsxs(as,{position:"popper",sideOffset:4,className:"bg-[#1C1C24] border border-[#2A2A35] rounded-lg shadow-xl py-1 min-w-[280px] max-h-[240px] z-[9999]",children:[r.jsx("div",{className:"px-2 pb-1 mb-1 border-b border-[#2A2A35]",children:r.jsx("input",{value:M,onChange:me=>I(me.target.value),onKeyDown:me=>{me.key==="Enter"&&M.trim()&&k(M.trim())},placeholder:"Type model ID...",className:"w-full bg-[#13131A] border border-[#2A2A35] rounded px-2 py-1.5 text-[11px] text-[#C8C8D4] placeholder:text-[#5A5A6E] outline-none focus:border-[#6366F1] transition-colors"})}),r.jsx(os,{children:Object.entries(ae.reduce((me,$e)=>((me[$e.group]??=[]).push($e),me),{})).map(([me,$e])=>r.jsxs(Ro,{children:[r.jsx(Do,{className:"px-3 pt-2 pb-1 text-[10px] font-semibold text-[#5A5A6E] uppercase tracking-widest",children:me}),$e.map(nt=>r.jsxs(vn,{value:nt.id,className:"flex items-center justify-between px-3 py-1.5 text-[12px] text-[#C8C8D4] cursor-pointer outline-none data-[highlighted]:bg-white/5",children:[r.jsx(yn,{children:nt.label}),r.jsx(ui,{children:r.jsx(Fe,{className:"w-3 h-3 text-[#6366F1]"})})]},nt.id))]},me))})]})})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-[11px] text-[#5A5A6E] mb-1 block",children:"Fast (quick tasks)"}),r.jsxs(ss,{value:T,onValueChange:me=>{F(me),H("")},children:[r.jsxs(is,{className:"w-full flex items-center justify-between px-3 py-2 rounded-lg border border-[#2A2A35] bg-[#0F0F11] text-[13px] text-[#F0F0F5] outline-none focus:border-[#6366F1]/50 transition-colors",children:[r.jsx("span",{className:"truncate",children:(ae.find(me=>me.id===T)?.label??T)||"Select model..."}),r.jsx(Yl,{children:r.jsx(ft,{className:"w-3.5 h-3.5 text-[#5A5A6E]"})})]}),r.jsx(rs,{children:r.jsxs(as,{position:"popper",sideOffset:4,className:"bg-[#1C1C24] border border-[#2A2A35] rounded-lg shadow-xl py-1 min-w-[280px] max-h-[240px] z-[9999]",children:[r.jsx("div",{className:"px-2 pb-1 mb-1 border-b border-[#2A2A35]",children:r.jsx("input",{value:R,onChange:me=>H(me.target.value),onKeyDown:me=>{me.key==="Enter"&&R.trim()&&F(R.trim())},placeholder:"Type model ID...",className:"w-full bg-[#13131A] border border-[#2A2A35] rounded px-2 py-1.5 text-[11px] text-[#C8C8D4] placeholder:text-[#5A5A6E] outline-none focus:border-[#6366F1] transition-colors"})}),r.jsx(os,{children:Object.entries(ae.reduce((me,$e)=>((me[$e.group]??=[]).push($e),me),{})).map(([me,$e])=>r.jsxs(Ro,{children:[r.jsx(Do,{className:"px-3 pt-2 pb-1 text-[10px] font-semibold text-[#5A5A6E] uppercase tracking-widest",children:me}),$e.map(nt=>r.jsxs(vn,{value:nt.id,className:"flex items-center justify-between px-3 py-1.5 text-[12px] text-[#C8C8D4] cursor-pointer outline-none data-[highlighted]:bg-white/5",children:[r.jsx(yn,{children:nt.label}),r.jsx(ui,{children:r.jsx(Fe,{className:"w-3 h-3 text-[#6366F1]"})})]},nt.id))]},me))})]})})]})]})]})]}),r.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[r.jsx("button",{onClick:async()=>{E&&T&&await D.mutateAsync({reasoningModel:E,fastModel:T}),e()},disabled:!se||D.isPending,className:ye("flex items-center gap-2 px-5 py-2.5 rounded-xl text-[13px] font-medium transition-colors",se?"bg-[#6366F1] text-white hover:bg-[#5254CC]":"bg-white/5 text-[#5A5A6E] border border-[#2A2A35] cursor-not-allowed"),children:D.isPending?r.jsx("div",{className:"w-3.5 h-3.5 border-2 border-white/30 border-t-white rounded-full animate-spin"}):r.jsxs(r.Fragment,{children:["Continue",r.jsx(Jt,{className:"w-3.5 h-3.5"})]})}),r.jsx("button",{onClick:t,className:"text-[12px] text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:"Skip for now"})]})]})}function f8e({onNext:e}){const[t,n]=y.useState(null);return r.jsxs(Vd,{children:[r.jsx("h2",{className:"text-[22px] font-semibold text-[#F0F0F5] mb-2",children:"Share your workspace"}),r.jsx("p",{className:"text-[14px] text-[#8A8A99] mb-6 leading-relaxed",children:"How will you use damn.dev?"}),r.jsx("div",{className:"grid grid-cols-2 gap-3 mb-6",children:["solo","team"].map(s=>r.jsxs("button",{onClick:()=>n(s),className:ye("text-left rounded-2xl p-4 border transition-all",t===s?"border-[#6366F1]/50 bg-[#6366F1]/5 ring-1 ring-[#6366F1]/20":"border-[#2A2A35] bg-[#16161A] hover:border-[#3A3A45]"),children:[r.jsx("p",{className:"text-[13px] font-medium text-[#F0F0F5] mt-1",children:s==="solo"?"Just me":"With my team"}),r.jsx("p",{className:"text-[11px] text-[#5A5A6E] mt-0.5",children:s==="solo"?"Default":"Share access via Tailscale"})]},s))}),t==="team"&&r.jsx("div",{className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-5 mb-6",children:r.jsx(V5,{onComplete:()=>e(),onSkip:e})}),t!=="team"&&r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("button",{onClick:e,disabled:t===null,className:ye("flex items-center gap-2 px-5 py-2.5 rounded-xl text-[13px] font-medium transition-colors",t!==null?"bg-[#6366F1] text-white hover:bg-[#5254CC]":"bg-white/5 text-[#5A5A6E] border border-[#2A2A35] cursor-not-allowed"),children:["Continue",r.jsx(Jt,{className:"w-3.5 h-3.5"})]}),r.jsx("button",{onClick:e,className:"text-[12px] text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:"Skip"})]})]})}function p8e({onComplete:e}){const t=an(),n=L.useUtils(),s=L.onboarding.complete.useMutation(),i=L.onboarding.cooOnboardingChat.useMutation(),a=L.onboarding.setWorkspaceContext.useMutation(),[o,l]=y.useState([]),[c,d]=y.useState(""),[f,p]=y.useState(null),[m,g]=y.useState(!1),[b,_]=y.useState(!0),[w,A]=y.useState(null),S=y.useRef(null),C=y.useRef(null);y.useEffect(()=>{let M=!1;return i.mutateAsync({message:"Hello",history:[]}).then(I=>{M||(l([{role:"assistant",content:I.reply}]),_(!1))}).catch(()=>{M||(_(!1),A("Could not reach COO. You can skip this step and set workspace context later."))}),()=>{M=!0}},[]),y.useEffect(()=>{S.current?.scrollTo({top:S.current.scrollHeight,behavior:"smooth"})},[o,f]);async function E(){const M=c.trim();if(!M||i.isPending)return;d(""),A(null);const I=[...o,{role:"user",content:M}];l(I);try{const R=await i.mutateAsync({message:M,history:I});l([...I,{role:"assistant",content:R.reply}]),R.workspaceContext&&p(R.workspaceContext)}catch{A("COO failed to respond. Try again or skip this step.")}C.current?.focus()}async function k(){f&&(await a.mutateAsync({context:f}),g(!0))}async function T(){await s.mutateAsync(),await n.onboarding.getState.refetch(),t("/channels/chan_coo",{replace:!0}),e()}async function F(){await s.mutateAsync(),await n.onboarding.getState.refetch(),t("/channels/chan_coo",{replace:!0}),e()}return r.jsxs(Vd,{children:[r.jsx("h2",{className:"text-[22px] font-semibold text-[#F0F0F5] mb-1",children:"Meet your COO"}),r.jsx("p",{className:"text-[14px] text-[#8A8A99] mb-4 leading-relaxed",children:"A few questions to set up your workspace context."}),r.jsxs("div",{ref:S,className:"bg-[#16161A] border border-[#2A2A35] rounded-2xl p-4 mb-3 space-y-3 max-h-[320px] overflow-y-auto",children:[b&&r.jsxs("div",{className:"flex items-center gap-2 text-[13px] text-[#5A5A6E]",children:[r.jsx(Pe,{className:"w-3.5 h-3.5 animate-spin"}),"COO is thinking..."]}),w&&r.jsx("div",{className:"text-[13px] text-red-400/80 leading-relaxed",children:w}),o.map((M,I)=>r.jsx("div",{className:ye("flex",M.role==="user"?"justify-end":"justify-start"),children:r.jsx("div",{className:ye("rounded-xl px-3 py-2 text-[13px] leading-relaxed max-w-[85%]",M.role==="user"?"bg-[#6366F1] text-white":"bg-[#1E1E28] text-[#C8C8D4] border border-[#2A2A35]"),children:M.content})},I)),i.isPending&&o.length>0&&r.jsx("div",{className:"flex justify-start",children:r.jsx("div",{className:"rounded-xl px-3 py-2 bg-[#1E1E28] border border-[#2A2A35]",children:r.jsx(Pe,{className:"w-3.5 h-3.5 animate-spin text-[#5A5A6E]"})})})]}),f&&!m&&r.jsxs("div",{className:"bg-[#0F0F11] border border-[#6366F1]/30 rounded-xl p-3 mb-3",children:[r.jsx("p",{className:"text-[11px] font-medium text-[#6366F1] mb-2",children:"Proposed workspace context"}),r.jsx("pre",{className:"text-[11px] text-[#C8C8D4] whitespace-pre-wrap leading-relaxed max-h-[160px] overflow-y-auto mb-2",children:f}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs("button",{onClick:k,disabled:a.isPending,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[12px] font-medium bg-[#6366F1] text-white hover:bg-[#5254CC] disabled:opacity-60 transition-colors",children:[a.isPending?r.jsx(Pe,{className:"w-3 h-3 animate-spin"}):r.jsx(Fe,{className:"w-3 h-3"}),"Approve"]}),r.jsx("button",{onClick:()=>p(null),className:"px-3 py-1.5 rounded-lg text-[12px] text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:"Revise"})]})]}),m&&r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-xl bg-emerald-500/10 border border-emerald-500/20 mb-3",children:[r.jsx(sa,{className:"w-3.5 h-3.5 text-emerald-400"}),r.jsx("span",{className:"text-[12px] text-emerald-400",children:"Workspace context saved"})]}),!m&&!b&&r.jsxs("div",{className:"flex gap-2 mb-3",children:[r.jsx("input",{ref:C,type:"text",value:c,onChange:M=>d(M.target.value),onKeyDown:M=>M.key==="Enter"&&E(),placeholder:"Type your answer...",disabled:i.isPending,className:"flex-1 bg-[#0F0F11] border border-[#2A2A35] rounded-lg px-3 py-2 text-[13px] text-[#F0F0F5] placeholder:text-[#5A5A6E] outline-none focus:border-[#6366F1]/50 transition-colors disabled:opacity-50"}),r.jsx("button",{onClick:E,disabled:!c.trim()||i.isPending,className:"px-3 py-2 rounded-lg text-[12px] font-medium bg-[#6366F1] text-white hover:bg-[#5254CC] disabled:opacity-50 transition-colors flex-shrink-0",children:"Send"})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[m&&r.jsxs("button",{onClick:T,disabled:s.isPending,className:"flex items-center gap-2 px-5 py-2.5 rounded-xl text-[13px] font-medium bg-[#6366F1] text-white hover:bg-[#5254CC] disabled:opacity-60 transition-colors",children:[s.isPending?r.jsx(Pe,{className:"w-3.5 h-3.5 animate-spin"}):null,"Open damn.dev",r.jsx(Jt,{className:"w-3.5 h-3.5"})]}),!m&&r.jsx("button",{onClick:F,className:"text-[12px] text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:"Skip this step"})]})]})}function m8e(){const e=an(),[t,n]=y.useState(0),s=L.onboarding.skip.useMutation();async function i(){await s.mutateAsync(),e("/",{replace:!0})}return r.jsx("div",{className:"flex h-screen w-screen overflow-hidden bg-[#0F0F11] flex-col items-center justify-center",children:r.jsxs("div",{className:"w-full max-w-lg px-6 flex flex-col",style:{maxHeight:"100vh"},children:[r.jsxs("div",{className:"flex items-center justify-between mb-8 flex-shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[18px]",children:"⚡"}),r.jsx("span",{className:"text-[15px] font-semibold text-[#F0F0F5]",children:"damn.dev"})]}),r.jsx(c8e,{current:t}),r.jsx("button",{onClick:i,className:"text-[12px] text-[#5A5A6E] hover:text-[#8A8A99] transition-colors",children:"Skip setup"})]}),r.jsx("div",{className:"overflow-y-auto flex-1 pb-6",children:r.jsxs(Me,{mode:"wait",children:[t===0&&r.jsx(u8e,{onNext:()=>n(1),onSkip:()=>n(1)},"step0"),t===1&&r.jsx(h8e,{onNext:()=>n(2),onSkip:()=>n(2)},"step1"),t===2&&r.jsx(f8e,{onNext:()=>n(3)},"step2"),t===3&&r.jsx(p8e,{onComplete:()=>{}},"step3")]})})]})})}function x8e(){const e=an(),{data:t}=L.workspace.getMyMembership.useQuery(),{data:n=[]}=L.channels.list.useQuery(),s=L.workspace.completeOnboarding.useMutation();async function i(){await s.mutateAsync();const a=n.find(o=>o.name==="general"&&o.visibility==="public"&&o.channelType==="topic");e(a?`/channels/${a.id}`:"/channels/direction",{replace:!0})}return r.jsx("div",{className:"flex h-screen w-screen overflow-hidden bg-[#0F0F11] flex-col items-center justify-center",children:r.jsxs(ne.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.4,ease:[.16,1,.3,1]},className:"w-full max-w-md px-6 text-center",children:[r.jsx("div",{className:"w-16 h-16 rounded-2xl bg-gradient-to-br from-[#6366F1]/20 to-[#8B5CF6]/20 border border-[#6366F1]/30 flex items-center justify-center mx-auto mb-6",children:r.jsx("span",{className:"text-3xl",children:"👋"})}),r.jsxs("h1",{className:"text-[24px] font-semibold text-[#F0F0F5] mb-3",children:["Welcome to ",t?.workspaceName??"the workspace"]}),t?.ownerName&&r.jsxs("p",{className:"text-[14px] text-[#8A8A99] mb-8 leading-relaxed",children:["You've been invited by ",t.ownerName]}),r.jsxs("button",{onClick:i,disabled:s.isPending,className:"inline-flex items-center gap-2 px-6 py-3 rounded-xl text-[14px] font-semibold bg-[#6366F1] text-white hover:bg-[#5254CC] disabled:opacity-60 transition-colors",children:[s.isPending?r.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):null,"Explore your workspace",r.jsx(Jt,{className:"w-4 h-4"})]})]})})}function g8e(){const[e,t]=y.useState("signin"),[n,s]=y.useState(""),[i,a]=y.useState(""),[o,l]=y.useState(!1),[c,d]=y.useState(null),[f,p]=y.useState(!1),{data:m}=L.onboarding.hasGoogleAuth.useQuery(),{data:g}=L.onboarding.signupAllowed.useQuery(),b=g?.allowed??!1,_=g?.registrationMode??"closed";y.useEffect(()=>{!b&&e==="signup"&&t("signin")},[b,e]);async function w(A){if(A.preventDefault(),d(null),e==="signup"&&!b){d("This workspace requires an invitation to join.");return}if(i.length<12){d("Password must be at least 12 characters.");return}p(!0);try{if(e==="signup"){const S=await cz.email({email:n,password:i,name:n.split("@")[0]});S.error&&d(S.error.message??"Sign up failed.")}else{const S=await v0.email({email:n,password:i});S.error&&d(S.error.message??"Invalid credentials.")}}catch{d("Something went wrong. Please try again.")}finally{p(!1)}}return r.jsx("div",{className:"flex h-screen w-screen items-center justify-center bg-[#0F0F11]",children:r.jsxs("div",{className:"flex flex-col items-center gap-6 max-w-sm w-full px-8",children:[r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx("div",{className:"w-14 h-14 rounded-2xl bg-gradient-to-br from-[#6366F1]/20 to-[#8B5CF6]/20 border border-[#6366F1]/30 flex items-center justify-center",children:r.jsx("span",{className:"text-2xl font-bold text-[#6366F1]",children:"d"})}),r.jsx("h1",{className:"text-[22px] font-semibold text-[#F0F0F5]",children:"damn.dev"}),r.jsx("p",{className:"text-[14px] text-[#8A8A99]",children:e==="signin"?"Sign in to your workspace":"Create your workspace"})]}),r.jsxs("form",{onSubmit:w,className:"flex flex-col gap-3 w-full",children:[r.jsx("input",{type:"email",placeholder:"Email",value:n,onChange:A=>s(A.target.value),required:!0,className:"w-full rounded-lg bg-[#1A1A20] border border-[#2A2A35] text-[#F0F0F5] placeholder-[#5A5A6A] px-4 py-3 text-[14px] outline-none focus:border-[#6366F1] transition-colors"}),r.jsxs("div",{className:"relative",children:[r.jsx("input",{type:o?"text":"password",placeholder:"Password (min 12 characters)",value:i,onChange:A=>a(A.target.value),required:!0,minLength:12,className:"w-full rounded-lg bg-[#1A1A20] border border-[#2A2A35] text-[#F0F0F5] placeholder-[#5A5A6A] px-4 py-3 pr-11 text-[14px] outline-none focus:border-[#6366F1] transition-colors"}),r.jsx("button",{type:"button",onClick:()=>l(A=>!A),className:"absolute right-3 top-1/2 -translate-y-1/2 text-[#5A5A6A] hover:text-[#8A8A99] transition-colors",tabIndex:-1,children:o?r.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 4.411m0 0L21 21"})}):r.jsxs("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]})})]}),c&&r.jsx("p",{className:"text-[13px] text-red-400",children:c}),r.jsx("button",{type:"submit",disabled:f,className:"w-full rounded-lg bg-[#6366F1] text-white px-5 py-3 text-[14px] font-medium hover:bg-[#5254CC] disabled:opacity-50 transition-colors",children:f?"...":e==="signin"?"Sign in":"Create account"})]}),b?r.jsx("button",{type:"button",onClick:()=>{t(e==="signin"?"signup":"signin"),d(null)},className:"text-[13px] text-[#8A8A99] hover:text-[#F0F0F5] transition-colors",children:e==="signin"?"Don't have an account? Create one":"Already have an account? Sign in"}):_==="invite"?r.jsx("p",{className:"text-[13px] text-[#5A5A6E] text-center",children:"Need an account? Ask the workspace admin for an invite link."}):r.jsx("p",{className:"text-[13px] text-[#5A5A6E] text-center",children:"Registration is closed."}),m?.enabled&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-3 w-full",children:[r.jsx("div",{className:"flex-1 h-px bg-[#2A2A35]"}),r.jsx("span",{className:"text-[12px] text-[#5A5A6A]",children:"or"}),r.jsx("div",{className:"flex-1 h-px bg-[#2A2A35]"})]}),r.jsxs("button",{onClick:()=>v0.social({provider:"google",callbackURL:window.location.origin+"/"}),className:"flex items-center gap-3 w-full justify-center rounded-lg bg-white text-[#1a1a1a] px-5 py-3 text-[14px] font-medium hover:bg-[#f0f0f0] transition-colors",children:[r.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[r.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z",fill:"#4285F4"}),r.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),r.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),r.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),"Continue with Google"]})]})]})})}function b8e(e){if(!e||typeof e!="object")return!1;const t=String(e.message??"");return t.includes("Failed to fetch")||t.includes("NetworkError")||t.includes("ERR_CONNECTION_REFUSED")||t.includes("ECONNREFUSED")||t.includes("Load failed")||t.includes("fetch failed")}function v8e(){const[e,t]=y.useState(!1);function n(){t(!0),setTimeout(()=>window.location.reload(),500)}return r.jsx("div",{className:"flex h-screen w-screen items-center justify-center bg-[#0F0F11]",children:r.jsxs("div",{className:"flex flex-col items-center gap-5 max-w-md text-center px-8",children:[r.jsx("div",{className:"w-12 h-12 rounded-2xl bg-amber-500/10 border border-amber-500/20 flex items-center justify-center",children:r.jsx("span",{className:"text-amber-400 text-xl",children:"!"})}),r.jsx("h1",{className:"text-[18px] font-semibold text-[#F0F0F5]",children:"Can't reach this workspace"}),r.jsx("p",{className:"text-[14px] text-[#8A8A99] leading-relaxed",children:"This is a private workspace running on someone's machine. You need to be on their private network to access it."}),r.jsxs("div",{className:"w-full bg-[#16161A] border border-[#2A2A35] rounded-xl p-5 text-left space-y-4",children:[r.jsx("p",{className:"text-[13px] font-medium text-[#C8C8D4]",children:"If they shared a Tailscale link:"}),r.jsxs("div",{className:"space-y-2 text-[12px] text-[#8A8A99]",children:[r.jsxs("div",{className:"flex gap-2",children:[r.jsx("span",{className:"text-[#6366F1] font-medium flex-shrink-0",children:"1."}),r.jsxs("div",{children:["Install Tailscale on your device",r.jsxs("a",{href:"https://tailscale.com/download",target:"_blank",rel:"noreferrer",className:"flex items-center gap-1 mt-1 text-[#6366F1] hover:text-[#818CF8] transition-colors",children:[r.jsx(cs,{className:"w-3 h-3"}),"tailscale.com/download"]})]})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("span",{className:"text-[#6366F1] font-medium flex-shrink-0",children:"2."}),r.jsx("span",{children:"Ask them to add you to their Tailnet at tailscale.com/admin"})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("span",{className:"text-[#6366F1] font-medium flex-shrink-0",children:"3."}),r.jsx("span",{children:"Once connected, refresh this page"})]})]}),r.jsx("p",{className:"text-[11px] text-[#5A5A6E]",children:"Already have Tailscale? Make sure it's running and you're on the same Tailnet as the workspace host."})]}),r.jsxs("button",{onClick:n,disabled:e,className:"flex items-center gap-2 px-4 py-2 rounded-lg text-[13px] font-medium bg-[#6366F1]/10 text-[#6366F1] border border-[#6366F1]/30 hover:bg-[#6366F1]/20 transition-colors disabled:opacity-50",children:[r.jsx(Xi,{className:`w-3.5 h-3.5 ${e?"animate-spin":""}`}),"Retry connection"]})]})})}function y8e(){const{token:e}=am(),t=an(),{data:n}=Mi(),[s,i]=y.useState("signup"),[a,o]=y.useState(""),[l,c]=y.useState(""),[d,f]=y.useState(null),[p,m]=y.useState(!1),{data:g,isLoading:b,error:_}=L.workspace.getInvitation.useQuery({token:e},{enabled:!!e,retry:!1}),w=L.workspace.acceptInvitation.useMutation({onSuccess:()=>{setTimeout(()=>t("/"),2e3)}});y.useEffect(()=>{if(w.isSuccess){const S=setTimeout(()=>t("/"),2e3);return()=>clearTimeout(S)}},[w.isSuccess,t]);async function A(S){if(S.preventDefault(),f(null),l.length<12){f("Password must be at least 12 characters.");return}m(!0);try{if(s==="signup"){const C=await cz.email({email:a,password:l,name:a.split("@")[0],fetchOptions:{headers:{"x-invite-token":e}}});C.error&&f(C.error.message??"Sign up failed.")}else{const C=await v0.email({email:a,password:l});C.error&&f(C.error.message??"Invalid credentials.")}}catch{f("Something went wrong. Please try again.")}finally{m(!1)}}return b?r.jsx("div",{className:"flex h-screen w-screen items-center justify-center bg-[#0F0F11]",children:r.jsx("div",{className:"w-5 h-5 border-2 border-[#6366F1]/30 border-t-[#6366F1] rounded-full animate-spin"})}):_&&b8e(_)?r.jsx(v8e,{}):_||!g?r.jsx("div",{className:"flex h-screen w-screen items-center justify-center bg-[#0F0F11]",children:r.jsxs("div",{className:"flex flex-col items-center gap-4 max-w-sm text-center px-8",children:[r.jsx("div",{className:"w-12 h-12 rounded-2xl bg-[#EF4444]/10 border border-[#EF4444]/20 flex items-center justify-center",children:r.jsx("span",{className:"text-[#EF4444] text-xl",children:"✕"})}),r.jsx("h1",{className:"text-[18px] font-semibold text-[#F0F0F5]",children:"Invitation not valid"}),r.jsx("p",{className:"text-[14px] text-[#8A8A99]",children:"This invitation is no longer valid or has expired."}),r.jsx(gn,{to:"/",className:"text-[13px] text-[#6366F1] hover:underline",children:"Go to workspace"})]})}):w.isSuccess?r.jsx("div",{className:"flex h-screen w-screen items-center justify-center bg-[#0F0F11]",children:r.jsxs("div",{className:"flex flex-col items-center gap-4 max-w-sm text-center px-8",children:[r.jsx("div",{className:"w-12 h-12 rounded-2xl bg-[#10B981]/10 border border-[#10B981]/20 flex items-center justify-center",children:r.jsx("span",{className:"text-[#10B981] text-xl",children:"✓"})}),r.jsxs("h1",{className:"text-[18px] font-semibold text-[#F0F0F5]",children:["You've joined ",g.workspaceName,"!"]}),r.jsx("p",{className:"text-[13px] text-[#8A8A99]",children:"Redirecting you to your workspace..."}),r.jsx("div",{className:"w-4 h-4 border-2 border-[#6366F1]/30 border-t-[#6366F1] rounded-full animate-spin"})]})}):r.jsx("div",{className:"flex h-screen w-screen items-center justify-center bg-[#0F0F11]",children:r.jsxs("div",{className:"w-[400px] bg-[#1C1C24] border border-[#2A2A35] rounded-xl shadow-2xl p-8 flex flex-col items-center gap-5",children:[r.jsx("div",{className:"w-14 h-14 rounded-2xl bg-gradient-to-br from-[#6366F1]/20 to-[#8B5CF6]/20 border border-[#6366F1]/30 flex items-center justify-center",children:r.jsx("span",{className:"text-2xl font-bold text-[#6366F1]",children:"d"})}),r.jsxs("div",{className:"text-center",children:[r.jsx("h1",{className:"text-[20px] font-semibold text-[#F0F0F5]",children:g.workspaceName}),r.jsxs("p",{className:"text-[13px] text-[#8A8A99] mt-1",children:[g.inviterName," invited you to join as"," ",r.jsx("span",{className:"text-[#C8C8D4]",children:g.role})]})]}),w.error&&r.jsx("p",{className:"text-[12px] text-[#EF4444] text-center",children:w.error.message}),n?r.jsx("button",{onClick:()=>w.mutate({token:e}),disabled:w.isPending,className:"w-full px-4 py-2.5 rounded-lg bg-[#6366F1] text-white text-[14px] font-medium hover:bg-[#5558E8] transition-colors disabled:opacity-40 disabled:pointer-events-none",children:w.isPending?"Joining...":"Join Workspace"}):r.jsxs("div",{className:"w-full flex flex-col gap-3",children:[r.jsxs("form",{onSubmit:A,className:"flex flex-col gap-3 w-full",children:[r.jsx("input",{type:"email",placeholder:"Email",value:a,onChange:S=>o(S.target.value),required:!0,className:"w-full rounded-lg bg-[#13131A] border border-[#2A2A35] text-[#F0F0F5] placeholder-[#5A5A6A] px-4 py-3 text-[14px] outline-none focus:border-[#6366F1] transition-colors"}),r.jsx("input",{type:"password",placeholder:"Password (min 12 characters)",value:l,onChange:S=>c(S.target.value),required:!0,minLength:12,className:"w-full rounded-lg bg-[#13131A] border border-[#2A2A35] text-[#F0F0F5] placeholder-[#5A5A6A] px-4 py-3 text-[14px] outline-none focus:border-[#6366F1] transition-colors"}),d&&r.jsx("p",{className:"text-[12px] text-red-400",children:d}),r.jsx("button",{type:"submit",disabled:p,className:"w-full rounded-lg bg-[#6366F1] text-white px-5 py-3 text-[14px] font-medium hover:bg-[#5254CC] disabled:opacity-50 transition-colors",children:p?"...":s==="signup"?"Create account & join":"Sign in & join"})]}),r.jsx("button",{type:"button",onClick:()=>{i(s==="signin"?"signup":"signin"),f(null)},className:"text-[13px] text-[#8A8A99] hover:text-[#F0F0F5] transition-colors",children:s==="signup"?"Already have an account? Sign in":"Don't have an account? Create one"}),r.jsxs("div",{className:"flex items-center gap-3 w-full",children:[r.jsx("div",{className:"flex-1 h-px bg-[#2A2A35]"}),r.jsx("span",{className:"text-[12px] text-[#5A5A6A]",children:"or"}),r.jsx("div",{className:"flex-1 h-px bg-[#2A2A35]"})]}),r.jsxs("button",{onClick:()=>v0.social({provider:"google",callbackURL:`${window.location.origin}/invite/${e}`}),className:"flex items-center gap-3 w-full justify-center rounded-lg bg-white text-[#1a1a1a] px-5 py-3 text-[14px] font-medium hover:bg-[#f0f0f0] transition-colors",children:[r.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[r.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z",fill:"#4285F4"}),r.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),r.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),r.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),"Continue with Google"]})]})]})})}function _8e({open:e,onClose:t}){const[n,s]=y.useState(""),[i,a]=y.useState(""),[o,l]=y.useState(0),c=y.useRef(null),d=an(),[f,p]=y.useState(e);e&&!f&&(s(""),a(""),l(0)),e!==f&&p(e),y.useEffect(()=>{e&&setTimeout(()=>c.current?.focus(),50)},[e]),y.useEffect(()=>{const A=setTimeout(()=>a(n),200);return()=>clearTimeout(A)},[n]);const{data:m=[]}=L.messages.search.useQuery({query:i},{enabled:i.length>=2}),g=m.reduce((A,S)=>{const C=A[S.channelName]??[];return C.push(S),A[S.channelName]=C,A},{}),b=m;function _(A){d(`/channels/${A.channelId}`),t(),setTimeout(()=>{document.getElementById(`msg-${A.messageId}`)?.scrollIntoView({behavior:"smooth",block:"center"})},300)}function w(A){A.key==="Escape"?t():A.key==="ArrowDown"?(A.preventDefault(),l(S=>Math.min(S+1,b.length-1))):A.key==="ArrowUp"?(A.preventDefault(),l(S=>Math.max(S-1,0))):A.key==="Enter"&&b[o]&&_(b[o])}return r.jsx(Me,{children:e&&r.jsx(ne.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"fixed inset-0 z-[100] flex items-start justify-center pt-[15vh]",style:{backdropFilter:"blur(8px)",backgroundColor:"rgba(0,0,0,0.6)"},onClick:A=>{A.target===A.currentTarget&&t()},children:r.jsxs(ne.div,{initial:{opacity:0,y:-12,scale:.97},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.97},transition:{duration:.2,ease:[.16,1,.3,1]},className:"w-full max-w-[600px] mx-4 bg-[#13131A] border border-[#2A2A35] rounded-2xl shadow-2xl overflow-hidden",children:[r.jsxs("div",{className:"flex items-center gap-3 px-5 py-4 border-b border-[#2A2A35]",children:[r.jsx(Io,{className:"w-5 h-5 text-[#8A8A99] flex-shrink-0"}),r.jsx("input",{ref:c,value:n,onChange:A=>{s(A.target.value),l(0)},onKeyDown:w,placeholder:"Search messages...",className:"flex-1 bg-transparent text-[20px] text-[#F0F0F5] placeholder:text-[#8A8A99]/50 outline-none"}),r.jsx("kbd",{className:"text-[11px] text-[#8A8A99] bg-white/5 border border-[#2A2A35] px-1.5 py-0.5 rounded-md",children:"esc"})]}),i.length>=2&&r.jsx("div",{className:"max-h-[420px] overflow-y-auto py-2",children:m.length===0?r.jsx("div",{className:"px-5 py-8 text-center",children:r.jsxs("p",{className:"text-[14px] text-[#8A8A99]",children:['No messages found for "',i,'"']})}):Object.entries(g).map(([A,S])=>r.jsxs("div",{children:[r.jsx("div",{className:"px-4 py-1.5 sticky top-0 bg-[#13131A]",children:r.jsxs("span",{className:"text-[11px] font-semibold text-[#8A8A99] uppercase tracking-widest",children:["#",A]})}),S.map(C=>{const E=b.indexOf(C),k=E===o;return r.jsxs("button",{onClick:()=>_(C),onMouseEnter:()=>l(E),className:"w-full text-left px-4 py-3 transition-colors",style:{backgroundColor:k?"rgba(255,255,255,0.04)":"transparent"},children:[r.jsxs("div",{className:"flex items-center justify-between gap-2 mb-0.5",children:[r.jsx("span",{className:"text-[12px] font-medium text-[#C8C8D4]",children:"Message"}),r.jsx("span",{className:"text-[11px] text-[#8A8A99]",children:Ir(C.createdAt)})]}),r.jsx("p",{className:"text-[13px] text-[#8A8A99] leading-relaxed",children:w8e(C.snippet,i)})]},C.messageId)})]},A))}),i.length<2&&r.jsx("div",{className:"px-5 py-6 text-center",children:r.jsx("p",{className:"text-[13px] text-[#8A8A99]",children:"Type at least 2 characters to search"})}),r.jsxs("div",{className:"flex items-center gap-4 px-4 py-2 border-t border-[#2A2A35]",children:[r.jsxs("span",{className:"text-[11px] text-[#8A8A99]",children:[r.jsx("kbd",{className:"bg-white/5 border border-[#2A2A35] px-1 py-0.5 rounded text-[10px] mr-1",children:"↑↓"}),"navigate"]}),r.jsxs("span",{className:"text-[11px] text-[#8A8A99]",children:[r.jsx("kbd",{className:"bg-white/5 border border-[#2A2A35] px-1 py-0.5 rounded text-[10px] mr-1",children:"↵"}),"jump"]})]})]})})})}function w8e(e,t){return e.split(new RegExp(`(${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi")).map((s,i)=>s.toLowerCase()===t.toLowerCase()?r.jsx("mark",{className:"bg-[#6366F1]/30 text-[#A5B4FC] rounded-sm px-0.5",children:s},i):s)}function A8e(){return/iPad|iPhone|iPod/.test(navigator.userAgent)&&!("MSStream"in window)}function S8e(){return window.matchMedia("(display-mode: standalone)").matches||"standalone"in navigator&&navigator.standalone===!0}function C8e(){const[e,t]=y.useState(!1),[n,s]=y.useState(!1),[i,a]=y.useState(null);y.useEffect(()=>{if(S8e())return;if(A8e()){localStorage.getItem("pwa-install-dismissed")||t(!0);return}function d(f){f.preventDefault(),a(f),sessionStorage.getItem("pwa-install-dismissed")||s(!0)}return window.addEventListener("beforeinstallprompt",d),()=>window.removeEventListener("beforeinstallprompt",d)},[]);const o=y.useCallback(()=>{localStorage.setItem("pwa-install-dismissed","1"),t(!1)},[]),l=y.useCallback(()=>{sessionStorage.setItem("pwa-install-dismissed","1"),s(!1)},[]),c=y.useCallback(async()=>{i&&(await i.prompt(),s(!1),a(null))},[i]);return r.jsxs(Me,{children:[e&&r.jsxs(ne.div,{initial:{y:100,opacity:0},animate:{y:0,opacity:1},exit:{y:100,opacity:0},transition:{type:"spring",damping:25,stiffness:300},className:"fixed bottom-4 left-4 right-4 z-50 rounded-xl bg-[#1A1A2E] border border-[#2A2A35] p-4 shadow-2xl max-w-md mx-auto",children:[r.jsxs("p",{className:"text-[13px] text-[#C0C0CC] leading-relaxed",children:["For the best experience, add damn.dev to your Home Screen: tap"," ",r.jsx("span",{className:"inline-flex items-center align-middle mx-0.5",children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#6366F1]",children:[r.jsx("path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8"}),r.jsx("polyline",{points:"16 6 12 2 8 6"}),r.jsx("line",{x1:"12",y1:"2",x2:"12",y2:"15"})]})})," ","Share → Add to Home Screen"]}),r.jsx("button",{onClick:o,className:"mt-3 text-[12px] font-medium text-[#6366F1] hover:text-[#818CF8] transition-colors",children:"Got it"})]}),n&&r.jsxs(ne.div,{initial:{y:100,opacity:0},animate:{y:0,opacity:1},exit:{y:100,opacity:0},transition:{type:"spring",damping:25,stiffness:300},className:"fixed bottom-4 left-4 right-4 z-50 rounded-xl bg-[#1A1A2E] border border-[#2A2A35] p-4 shadow-2xl max-w-md mx-auto flex items-center justify-between gap-3",children:[r.jsx("p",{className:"text-[13px] text-[#C0C0CC]",children:"Install damn.dev for a native experience"}),r.jsxs("div",{className:"flex gap-2 shrink-0",children:[r.jsx("button",{onClick:l,className:"text-[12px] text-[#8A8A99] hover:text-[#C0C0CC] transition-colors px-2 py-1",children:"Not now"}),r.jsx("button",{onClick:c,className:"text-[12px] font-medium bg-[#6366F1] text-white rounded-lg px-3 py-1.5 hover:bg-[#5558E6] transition-colors",children:"Install"})]})]})]})}function j8e(e){const t="=".repeat((4-e.length%4)%4),n=(e+t).replace(/-/g,"+").replace(/_/g,"/"),s=atob(n),i=new Uint8Array(s.length);for(let a=0;a<s.length;a++)i[a]=s.charCodeAt(a);return i}const cO="pwa-push-retry-after";function N8e(){const e=y.useRef(!1),{data:t}=L.notifications.getVapidKey.useQuery(void 0,{enabled:!Va}),n=L.notifications.registerToken.useMutation(),s=y.useCallback(async()=>{if(!t?.vapidKey||!("serviceWorker"in navigator)||!("PushManager"in window))return;const a=await navigator.serviceWorker.ready;let o=await a.pushManager.getSubscription();o||(o=await a.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:j8e(t.vapidKey).buffer})),n.mutate({token:JSON.stringify(o.toJSON()),platform:"web"})},[t?.vapidKey,n]),i=y.useCallback(async()=>{if(e.current)return;e.current=!0;const a=localStorage.getItem(cO);if(!(a&&Date.now()<Number(a))){if(Notification.permission==="granted"){await s();return}Notification.permission==="default"&&(await Notification.requestPermission()==="granted"?await s():localStorage.setItem(cO,String(Date.now()+1440*60*1e3)))}},[s]);return y.useEffect(()=>{t?.vapidKey&&Notification.permission==="granted"&&s()},[t?.vapidKey,s]),y.useEffect(()=>{if(!t?.vapidKey||Notification.permission!=="default")return;function a(){i()}return window.addEventListener("pwa-push-prompt",a,{once:!0}),()=>window.removeEventListener("pwa-push-prompt",a)},[t?.vapidKey,i]),{promptForPermission:i}}function k8e(){const[e,t]=y.useState(null),[n,s]=y.useState(!1),[i,a]=y.useState("idle"),[o,l]=y.useState(null),[c,d]=y.useState(!1);y.useEffect(()=>{fetch(`${oi}/api/version`,{credentials:"include"}).then(b=>b.json()).then(b=>{if(b.updateAvailable&&b.latest){const _=`dismissed_update_${b.latest}`;localStorage.getItem(_)||t(b)}}).catch(()=>{})},[]);const f=y.useCallback(()=>{const b=Date.now(),_=setInterval(async()=>{if(Date.now()-b>3e5){clearInterval(_),a("error"),l("Update may have failed. Check server logs.");return}try{(await fetch(`${oi}/health`)).ok&&(clearInterval(_),a("done"),setTimeout(()=>window.location.reload(),1e3))}catch{a("restarting")}},2e3)},[]),p=y.useCallback(async()=>{if(!e)return;if(typeof window<"u"&&"__TAURI__"in window){try{const{check:_}=await X(async()=>{const{check:A}=await import("./index-Cpew6ait.js");return{check:A}},__vite__mapDeps([105,1])),w=await _();if(w){a("updating"),await w.downloadAndInstall();const{relaunch:A}=await X(async()=>{const{relaunch:S}=await import("./index-CO34o7br.js");return{relaunch:S}},__vite__mapDeps([106,1]));await A()}}catch{a("error"),l("Download the latest version from damn.dev")}return}a("updating");try{const _=await fetch(`${oi}/api/update`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"}});if(_.status===403){a("error"),l("Only the workspace owner can trigger updates");return}const w=await _.json();if(w.error==="use_native_updater"){a("error"),l("Download the latest version from damn.dev");return}if(!w.ok){a("error"),l(w.error??"Update failed");return}f()}catch{a("error"),l("Failed to start update. Check server logs.")}},[e,f]);if(!e||n)return null;function m(){e?.latest&&localStorage.setItem(`dismissed_update_${e.latest}`,"1"),s(!0)}const g={"docker-vps":"SSH into your server and re-run your install script.",tauri:"Download the latest version from damn.dev."};return r.jsxs("div",{className:"bg-[#1A1A2E] border-b border-[#2A2A35] text-[#9090A0] text-[12px] py-1.5 px-4 flex flex-col flex-shrink-0",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[i==="idle"&&r.jsxs(r.Fragment,{children:[r.jsxs("span",{children:["damn.dev ",e.latest," is available"]}),e.canAutoUpdate?r.jsx("button",{onClick:p,className:"px-2 py-0.5 rounded bg-[#6366F1]/20 text-[#818CF8] hover:bg-[#6366F1]/30 transition-colors text-[11px] font-medium",children:"Update now"}):r.jsx("span",{className:"text-[#707080]",children:g[e.installPath]??"Re-run your install script to update."}),e.releaseNotes&&r.jsx("button",{onClick:()=>d(b=>!b),className:"text-[#707080] hover:text-[#9090A0] transition-colors text-[11px]",children:c?"Hide":"What's new"})]}),i==="updating"&&r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-3 h-3 border border-[#6366F1]/40 border-t-[#6366F1] rounded-full animate-spin"}),"Updating..."]}),i==="restarting"&&r.jsxs("span",{className:"flex items-center gap-2 animate-pulse",children:[r.jsx("span",{className:"w-3 h-3 border border-[#6366F1]/40 border-t-[#6366F1] rounded-full animate-spin"}),"Restarting..."]}),i==="done"&&r.jsx("span",{className:"text-[#22C55E]",children:"Updated!"}),i==="error"&&r.jsx("span",{className:"text-[#F87171]",children:o})]}),(i==="idle"||i==="error")&&r.jsx("button",{onClick:m,className:"ml-4 text-[#9090A0] hover:text-[#F0F0F5] transition-colors",children:"×"})]}),c&&e.releaseNotes&&r.jsx("div",{className:"mt-1.5 pt-1.5 border-t border-[#2A2A35] text-[11px] text-[#707080] whitespace-pre-wrap max-h-40 overflow-y-auto",children:e.releaseNotes})]})}function E8e(){const{data:e,refetch:t}=L.settings.getOpenClawVersion.useQuery(void 0,{refetchInterval:6e4,retry:!1}),[n,s]=y.useState(!1),[i,a]=y.useState("idle"),[o,l]=y.useState(null),c=L.settings.updateOpenClaw.useMutation();if(!e?.updateAvailable||n)return null;async function d(){a("updating");try{const f=await c.mutateAsync();f.ok?(a("done"),setTimeout(()=>{t(),s(!0)},3e3)):(a("error"),l(f.error??"Update failed"))}catch{a("error"),l("Failed to start update. Check server logs.")}}return r.jsxs("div",{className:"bg-[#1A1A2E] border-b border-[#2A2A35] text-[#9090A0] text-[12px] py-1.5 px-4 flex items-center justify-between flex-shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[i==="idle"&&r.jsxs(r.Fragment,{children:[r.jsxs("span",{children:["OpenClaw ",e.minimum," required (current: ",e.current,")"]}),r.jsx("button",{onClick:d,className:"px-2 py-0.5 rounded bg-[#6366F1]/20 text-[#818CF8] hover:bg-[#6366F1]/30 transition-colors text-[11px] font-medium",children:"Update now"})]}),i==="updating"&&r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-3 h-3 border border-[#6366F1]/40 border-t-[#6366F1] rounded-full animate-spin"}),"Updating OpenClaw..."]}),i==="done"&&r.jsx("span",{className:"text-[#22C55E]",children:"OpenClaw updated!"}),i==="error"&&r.jsx("span",{className:"text-[#F87171]",children:o})]}),(i==="idle"||i==="error")&&r.jsx("button",{onClick:()=>s(!0),className:"ml-4 text-[#9090A0] hover:text-[#F0F0F5] transition-colors",children:"×"})]})}function F8e(){const{data:e,refetch:t,isFetching:n}=L.settings.getOpenClawHealth.useQuery(void 0,{refetchInterval:15e3,retry:!1,refetchOnWindowFocus:!0}),s=L.settings.restartOpenClaw.useMutation(),[i,a]=y.useState("idle"),[o,l]=y.useState(null),c=e?.checkedAt&&e.checkedAt!==new Date(0).toISOString();if(!e||e.healthy||!c)return null;async function d(){a("restarting"),l(null);try{const p=await s.mutateAsync(void 0);p.kind==="restarted"?(a("done"),setTimeout(()=>{a("idle"),t()},1500)):p.kind==="skipped"?(a("skipped"),l(p.detail??p.reason)):(a("failed"),l(p.error))}catch(p){a("failed"),l(p instanceof Error?p.message:"Restart request failed.")}}const f=e.installPath==="docker-local"?"The backend will restart OpenClaw via `docker compose up -d`.":e.installPath==="tauri"?"The sidecar backend will restart OpenClaw via `docker compose up -d`.":e.installPath==="docker-vps"?e.canRestartFromBackend?"The backend will restart OpenClaw via the docker-socket-proxy sidecar.":"This backend runs inside a container without a docker-socket-proxy sidecar. SSH into the host and run `docker compose restart openclaw` — or redeploy to pick up the proxy service.":"OpenClaw runs as a native process on this install. Restart it from the terminal (e.g. `openclaw start`).";return r.jsxs("div",{className:"bg-[#2A1414] border-b border-[#F87171]/30 text-[#FCA5A5] text-[12px] py-1.5 px-4 flex items-center justify-between flex-shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[r.jsx("span",{className:"font-medium",children:"OpenClaw unreachable"}),r.jsxs("span",{className:"text-[#F87171]/70",children:["· ",f]}),e.lastError&&r.jsxs("span",{className:"text-[#F87171]/50 text-[11px]",children:["(",e.lastError,")"]})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[i==="idle"&&r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:()=>{t()},disabled:n,className:"px-2 py-0.5 rounded bg-[#F87171]/10 text-[#FCA5A5] hover:bg-[#F87171]/20 transition-colors text-[11px] font-medium disabled:opacity-50",children:n?"Checking…":"Retry"}),e.canRestartFromBackend&&r.jsx("button",{onClick:d,className:"px-2 py-0.5 rounded bg-[#F87171]/20 text-[#FCA5A5] hover:bg-[#F87171]/30 transition-colors text-[11px] font-medium",children:"Restart OpenClaw"})]}),i==="restarting"&&r.jsxs("span",{className:"flex items-center gap-2 text-[11px]",children:[r.jsx("span",{className:"w-3 h-3 border border-[#F87171]/40 border-t-[#F87171] rounded-full animate-spin"}),"Restarting…"]}),i==="done"&&r.jsx("span",{className:"text-[#22C55E] text-[11px]",children:"Restart succeeded"}),i==="skipped"&&r.jsx("span",{className:"text-[#F59E0B] text-[11px]",title:o??void 0,children:"Skipped — hover for details"}),i==="failed"&&r.jsx("span",{className:"text-[#F87171] text-[11px]",title:o??void 0,children:"Failed — hover for details"})]})]})}function T8e(){return r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-8",children:[r.jsx("div",{className:"w-14 h-14 rounded-2xl bg-gradient-to-br from-[#6366F1]/20 to-[#8B5CF6]/20 border border-[#6366F1]/30 flex items-center justify-center mb-4",children:r.jsx("span",{className:"text-2xl",children:"⚡"})}),r.jsx("h2",{className:"text-[18px] font-semibold text-[#F0F0F5] mb-2",children:"Select a channel"}),r.jsx("p",{className:"text-[14px] text-[#8A8A99] max-w-xs leading-relaxed",children:"Choose a channel from the sidebar to start working with your team."})]})}function M8e({children:e}){const t=an(),{data:n,isLoading:s}=L.workspace.getMyMembership.useQuery(void 0,{staleTime:0,refetchOnWindowFocus:!1,retry:!1}),i=n?.role==="owner",{data:a,isLoading:o}=L.onboarding.getState.useQuery(void 0,{staleTime:0,refetchOnWindowFocus:!1,retry:!1,enabled:i});return y.useEffect(()=>{if(!(s||!n)){if(n.role!=="owner"){n.onboardedAt||t("/welcome",{replace:!0});return}o||!a||!a.completed&&!a.skippedAt&&t("/onboarding",{replace:!0})}},[a,o,n,s,t]),s||i&&o?r.jsx("div",{className:"flex h-screen w-screen items-center justify-center bg-[#0F0F11]",children:r.jsx("div",{className:"w-5 h-5 border-2 border-[#6366F1]/30 border-t-[#6366F1] rounded-full animate-spin"})}):r.jsx(r.Fragment,{children:e})}function R8e({children:e}){const{data:t,isPending:n}=Mi();return n?r.jsx("div",{className:"flex h-screen w-screen items-center justify-center bg-[#0F0F11]",children:r.jsx("div",{className:"w-5 h-5 border-2 border-[#6366F1]/30 border-t-[#6366F1] rounded-full animate-spin"})}):t?r.jsx(r.Fragment,{children:e}):r.jsx(g8e,{})}function D8e({children:e}){const{isPending:t}=Mi();return t?r.jsx("div",{className:"flex h-screen w-screen items-center justify-center bg-[#0F0F11]",children:r.jsx("div",{className:"w-5 h-5 border-2 border-[#6366F1]/30 border-t-[#6366F1] rounded-full animate-spin"})}):r.jsx(r.Fragment,{children:e})}function O8e(){const[e,t]=y.useState(!1),n=Je(a=>a.setUnreadCounts),{data:s}=Mi(),{data:i}=L.readReceipts.getUnread.useQuery(void 0,{staleTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,enabled:!!s});return y.useEffect(()=>{i&&n(i)},[i,n]),y.useEffect(()=>{function a(o){(o.metaKey||o.ctrlKey)&&o.key==="k"&&(o.preventDefault(),t(l=>!l))}return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[]),N8e(),r.jsxs("div",{className:"flex flex-col h-screen",children:[r.jsx(k8e,{}),r.jsx(E8e,{}),r.jsx(F8e,{}),r.jsxs(Q_,{children:[r.jsx(ms,{path:"/invite/:token",element:r.jsx(D8e,{children:r.jsx(y8e,{})})}),r.jsx(ms,{path:"*",element:r.jsxs(R8e,{children:[r.jsxs(Q_,{children:[r.jsx(ms,{path:"/onboarding",element:r.jsx(m8e,{})}),r.jsx(ms,{path:"/welcome",element:r.jsx(x8e,{})}),r.jsx(ms,{path:"*",element:r.jsx(M8e,{children:r.jsx(qye,{children:r.jsxs(Q_,{children:[r.jsx(ms,{path:"/",element:r.jsx(lm,{to:"/channels/direction",replace:!0})}),r.jsx(ms,{path:"/channels/:channelId",element:r.jsx(UMe,{})}),r.jsx(ms,{path:"/agents",element:r.jsx(tRe,{})}),r.jsx(ms,{path:"/agents/new",element:r.jsx(pRe,{})}),r.jsx(ms,{path:"/agents/edit-soul/:agentId",element:r.jsx(xRe,{})}),r.jsx(ms,{path:"/skills",element:r.jsx(BRe,{})}),r.jsx(ms,{path:"/deliverables",element:r.jsx(qDe,{})}),r.jsx(ms,{path:"/missions",element:r.jsx(GDe,{})}),r.jsx(ms,{path:"/coo",element:r.jsx(ZRe,{})}),r.jsx(ms,{path:"/settings",element:r.jsx(uDe,{})}),r.jsx(ms,{path:"/federation/:nodeId/:agentId",element:r.jsx(IDe,{})}),r.jsx(ms,{path:"*",element:r.jsx(T8e,{})})]})})})})]}),r.jsx(_8e,{open:e,onClose:()=>t(!1)})]})})]}),r.jsx(C8e,{})]})}GG.createRoot(document.getElementById("root")).render(r.jsx(y.StrictMode,{children:r.jsx(aJ,{children:r.jsxs(pY,{children:[r.jsx(O8e,{}),r.jsx(QY,{position:"bottom-right",toastOptions:{style:{background:"#1C1C24",border:"1px solid #2A2A35",color:"#C8C8D4",fontSize:"12px"}}})]})})}));
|