@openscout/scout 0.2.64 → 0.2.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -12
- package/bin/openscout-runtime.mjs +42 -0
- package/dist/client/assets/index-BOdG2WWL.css +1 -0
- package/dist/client/assets/index-mL1LA8IG.js +159 -0
- package/dist/client/index.html +2 -2
- package/dist/main.mjs +2404 -550
- package/dist/pair-supervisor.mjs +516 -147
- package/dist/runtime/base-daemon.mjs +1554 -0
- package/dist/runtime/broker-daemon.mjs +42956 -0
- package/dist/runtime/broker-process-manager.mjs +880 -0
- package/dist/runtime/mesh-discover.mjs +906 -0
- package/dist/scout-control-plane-web.mjs +3359 -1721
- package/dist/scout-web-server.mjs +3359 -1721
- package/package.json +4 -6
- package/dist/client/assets/arc.es-DglF81f4.js +0 -188
- package/dist/client/assets/index-BRvY3oC-.js +0 -159
- package/dist/client/assets/index-CUNnl56m.css +0 -1
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
function fO(e,t){for(var n=0;n<t.length;n++){const s=t[n];if(typeof s!="string"&&!Array.isArray(s)){for(const a in s)if(a!=="default"&&!(a in e)){const l=Object.getOwnPropertyDescriptor(s,a);l&&Object.defineProperty(e,a,l.get?l:{enumerable:!0,get:()=>s[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const l of a)if(l.type==="childList")for(const u of l.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&s(u)}).observe(document,{childList:!0,subtree:!0});function n(a){const l={};return a.integrity&&(l.integrity=a.integrity),a.referrerPolicy&&(l.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?l.credentials="include":a.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function s(a){if(a.ep)return;a.ep=!0;const l=n(a);fetch(a.href,l)}})();function Ik(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Mm={exports:{}},Jl={};var x1;function hO(){if(x1)return Jl;x1=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(s,a,l){var u=null;if(l!==void 0&&(u=""+l),a.key!==void 0&&(u=""+a.key),"key"in a){l={};for(var d in a)d!=="key"&&(l[d]=a[d])}else l=a;return a=l.ref,{$$typeof:e,type:s,key:u,ref:a!==void 0?a:null,props:l}}return Jl.Fragment=t,Jl.jsx=n,Jl.jsxs=n,Jl}var w1;function pO(){return w1||(w1=1,Mm.exports=hO()),Mm.exports}var o=pO(),_m={exports:{}},Ge={};var j1;function mO(){if(j1)return Ge;j1=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),u=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),y=Symbol.for("react.activity"),x=Symbol.iterator;function w(I){return I===null||typeof I!="object"?null:(I=x&&I[x]||I["@@iterator"],typeof I=="function"?I:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,k={};function E(I,B,Y){this.props=I,this.context=B,this.refs=k,this.updater=Y||j}E.prototype.isReactComponent={},E.prototype.setState=function(I,B){if(typeof I!="object"&&typeof I!="function"&&I!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,I,B,"setState")},E.prototype.forceUpdate=function(I){this.updater.enqueueForceUpdate(this,I,"forceUpdate")};function C(){}C.prototype=E.prototype;function S(I,B,Y){this.props=I,this.context=B,this.refs=k,this.updater=Y||j}var R=S.prototype=new C;R.constructor=S,N(R,E.prototype),R.isPureReactComponent=!0;var A=Array.isArray;function M(){}var _={H:null,A:null,T:null,S:null},z=Object.prototype.hasOwnProperty;function V(I,B,Y){var Q=Y.ref;return{$$typeof:e,type:I,key:B,ref:Q!==void 0?Q:null,props:Y}}function U(I,B){return V(I.type,B,I.props)}function O(I){return typeof I=="object"&&I!==null&&I.$$typeof===e}function D(I){var B={"=":"=0",":":"=2"};return"$"+I.replace(/[=:]/g,function(Y){return B[Y]})}var H=/\/+/g;function W(I,B){return typeof I=="object"&&I!==null&&I.key!=null?D(""+I.key):B.toString(36)}function q(I){switch(I.status){case"fulfilled":return I.value;case"rejected":throw I.reason;default:switch(typeof I.status=="string"?I.then(M,M):(I.status="pending",I.then(function(B){I.status==="pending"&&(I.status="fulfilled",I.value=B)},function(B){I.status==="pending"&&(I.status="rejected",I.reason=B)})),I.status){case"fulfilled":return I.value;case"rejected":throw I.reason}}throw I}function $(I,B,Y,Q,me){var re=typeof I;(re==="undefined"||re==="boolean")&&(I=null);var ie=!1;if(I===null)ie=!0;else switch(re){case"bigint":case"string":case"number":ie=!0;break;case"object":switch(I.$$typeof){case e:case t:ie=!0;break;case m:return ie=I._init,$(ie(I._payload),B,Y,Q,me)}}if(ie)return me=me(I),ie=Q===""?"."+W(I,0):Q,A(me)?(Y="",ie!=null&&(Y=ie.replace(H,"$&/")+"/"),$(me,B,Y,"",function(Te){return Te})):me!=null&&(O(me)&&(me=U(me,Y+(me.key==null||I&&I.key===me.key?"":(""+me.key).replace(H,"$&/")+"/")+ie)),B.push(me)),1;ie=0;var de=Q===""?".":Q+":";if(A(I))for(var ye=0;ye<I.length;ye++)Q=I[ye],re=de+W(Q,ye),ie+=$(Q,B,Y,re,me);else if(ye=w(I),typeof ye=="function")for(I=ye.call(I),ye=0;!(Q=I.next()).done;)Q=Q.value,re=de+W(Q,ye++),ie+=$(Q,B,Y,re,me);else if(re==="object"){if(typeof I.then=="function")return $(q(I),B,Y,Q,me);throw B=String(I),Error("Objects are not valid as a React child (found: "+(B==="[object Object]"?"object with keys {"+Object.keys(I).join(", ")+"}":B)+"). If you meant to render a collection of children, use an array instead.")}return ie}function L(I,B,Y){if(I==null)return I;var Q=[],me=0;return $(I,Q,"","",function(re){return B.call(Y,re,me++)}),Q}function F(I){if(I._status===-1){var B=I._result;B=B(),B.then(function(Y){(I._status===0||I._status===-1)&&(I._status=1,I._result=Y)},function(Y){(I._status===0||I._status===-1)&&(I._status=2,I._result=Y)}),I._status===-1&&(I._status=0,I._result=B)}if(I._status===1)return I._result.default;throw I._result}var X=typeof reportError=="function"?reportError:function(I){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var B=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof I=="object"&&I!==null&&typeof I.message=="string"?String(I.message):String(I),error:I});if(!window.dispatchEvent(B))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",I);return}console.error(I)},G={map:L,forEach:function(I,B,Y){L(I,function(){B.apply(this,arguments)},Y)},count:function(I){var B=0;return L(I,function(){B++}),B},toArray:function(I){return L(I,function(B){return B})||[]},only:function(I){if(!O(I))throw Error("React.Children.only expected to receive a single React element child.");return I}};return Ge.Activity=y,Ge.Children=G,Ge.Component=E,Ge.Fragment=n,Ge.Profiler=a,Ge.PureComponent=S,Ge.StrictMode=s,Ge.Suspense=p,Ge.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=_,Ge.__COMPILER_RUNTIME={__proto__:null,c:function(I){return _.H.useMemoCache(I)}},Ge.cache=function(I){return function(){return I.apply(null,arguments)}},Ge.cacheSignal=function(){return null},Ge.cloneElement=function(I,B,Y){if(I==null)throw Error("The argument must be a React element, but you passed "+I+".");var Q=N({},I.props),me=I.key;if(B!=null)for(re in B.key!==void 0&&(me=""+B.key),B)!z.call(B,re)||re==="key"||re==="__self"||re==="__source"||re==="ref"&&B.ref===void 0||(Q[re]=B[re]);var re=arguments.length-2;if(re===1)Q.children=Y;else if(1<re){for(var ie=Array(re),de=0;de<re;de++)ie[de]=arguments[de+2];Q.children=ie}return V(I.type,me,Q)},Ge.createContext=function(I){return I={$$typeof:u,_currentValue:I,_currentValue2:I,_threadCount:0,Provider:null,Consumer:null},I.Provider=I,I.Consumer={$$typeof:l,_context:I},I},Ge.createElement=function(I,B,Y){var Q,me={},re=null;if(B!=null)for(Q in B.key!==void 0&&(re=""+B.key),B)z.call(B,Q)&&Q!=="key"&&Q!=="__self"&&Q!=="__source"&&(me[Q]=B[Q]);var ie=arguments.length-2;if(ie===1)me.children=Y;else if(1<ie){for(var de=Array(ie),ye=0;ye<ie;ye++)de[ye]=arguments[ye+2];me.children=de}if(I&&I.defaultProps)for(Q in ie=I.defaultProps,ie)me[Q]===void 0&&(me[Q]=ie[Q]);return V(I,re,me)},Ge.createRef=function(){return{current:null}},Ge.forwardRef=function(I){return{$$typeof:d,render:I}},Ge.isValidElement=O,Ge.lazy=function(I){return{$$typeof:m,_payload:{_status:-1,_result:I},_init:F}},Ge.memo=function(I,B){return{$$typeof:h,type:I,compare:B===void 0?null:B}},Ge.startTransition=function(I){var B=_.T,Y={};_.T=Y;try{var Q=I(),me=_.S;me!==null&&me(Y,Q),typeof Q=="object"&&Q!==null&&typeof Q.then=="function"&&Q.then(M,X)}catch(re){X(re)}finally{B!==null&&Y.types!==null&&(B.types=Y.types),_.T=B}},Ge.unstable_useCacheRefresh=function(){return _.H.useCacheRefresh()},Ge.use=function(I){return _.H.use(I)},Ge.useActionState=function(I,B,Y){return _.H.useActionState(I,B,Y)},Ge.useCallback=function(I,B){return _.H.useCallback(I,B)},Ge.useContext=function(I){return _.H.useContext(I)},Ge.useDebugValue=function(){},Ge.useDeferredValue=function(I,B){return _.H.useDeferredValue(I,B)},Ge.useEffect=function(I,B){return _.H.useEffect(I,B)},Ge.useEffectEvent=function(I){return _.H.useEffectEvent(I)},Ge.useId=function(){return _.H.useId()},Ge.useImperativeHandle=function(I,B,Y){return _.H.useImperativeHandle(I,B,Y)},Ge.useInsertionEffect=function(I,B){return _.H.useInsertionEffect(I,B)},Ge.useLayoutEffect=function(I,B){return _.H.useLayoutEffect(I,B)},Ge.useMemo=function(I,B){return _.H.useMemo(I,B)},Ge.useOptimistic=function(I,B){return _.H.useOptimistic(I,B)},Ge.useReducer=function(I,B,Y){return _.H.useReducer(I,B,Y)},Ge.useRef=function(I){return _.H.useRef(I)},Ge.useState=function(I){return _.H.useState(I)},Ge.useSyncExternalStore=function(I,B,Y){return _.H.useSyncExternalStore(I,B,Y)},Ge.useTransition=function(){return _.H.useTransition()},Ge.version="19.2.3",Ge}var S1;function qc(){return S1||(S1=1,_m.exports=mO()),_m.exports}var g=qc();const Io=Ik(g),Dk=fO({__proto__:null,default:Io},[g]);var Om={exports:{}},Ql={},Im={exports:{}},Dm={};var N1;function gO(){return N1||(N1=1,(function(e){function t($,L){var F=$.length;$.push(L);e:for(;0<F;){var X=F-1>>>1,G=$[X];if(0<a(G,L))$[X]=L,$[F]=G,F=X;else break e}}function n($){return $.length===0?null:$[0]}function s($){if($.length===0)return null;var L=$[0],F=$.pop();if(F!==L){$[0]=F;e:for(var X=0,G=$.length,I=G>>>1;X<I;){var B=2*(X+1)-1,Y=$[B],Q=B+1,me=$[Q];if(0>a(Y,F))Q<G&&0>a(me,Y)?($[X]=me,$[Q]=F,X=Q):($[X]=Y,$[B]=F,X=B);else if(Q<G&&0>a(me,F))$[X]=me,$[Q]=F,X=Q;else break e}}return L}function a($,L){var F=$.sortIndex-L.sortIndex;return F!==0?F:$.id-L.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var u=Date,d=u.now();e.unstable_now=function(){return u.now()-d}}var p=[],h=[],m=1,y=null,x=3,w=!1,j=!1,N=!1,k=!1,E=typeof setTimeout=="function"?setTimeout:null,C=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;function R($){for(var L=n(h);L!==null;){if(L.callback===null)s(h);else if(L.startTime<=$)s(h),L.sortIndex=L.expirationTime,t(p,L);else break;L=n(h)}}function A($){if(N=!1,R($),!j)if(n(p)!==null)j=!0,M||(M=!0,D());else{var L=n(h);L!==null&&q(A,L.startTime-$)}}var M=!1,_=-1,z=5,V=-1;function U(){return k?!0:!(e.unstable_now()-V<z)}function O(){if(k=!1,M){var $=e.unstable_now();V=$;var L=!0;try{e:{j=!1,N&&(N=!1,C(_),_=-1),w=!0;var F=x;try{t:{for(R($),y=n(p);y!==null&&!(y.expirationTime>$&&U());){var X=y.callback;if(typeof X=="function"){y.callback=null,x=y.priorityLevel;var G=X(y.expirationTime<=$);if($=e.unstable_now(),typeof G=="function"){y.callback=G,R($),L=!0;break t}y===n(p)&&s(p),R($)}else s(p);y=n(p)}if(y!==null)L=!0;else{var I=n(h);I!==null&&q(A,I.startTime-$),L=!1}}break e}finally{y=null,x=F,w=!1}L=void 0}}finally{L?D():M=!1}}}var D;if(typeof S=="function")D=function(){S(O)};else if(typeof MessageChannel<"u"){var H=new MessageChannel,W=H.port2;H.port1.onmessage=O,D=function(){W.postMessage(null)}}else D=function(){E(O,0)};function q($,L){_=E(function(){$(e.unstable_now())},L)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function($){$.callback=null},e.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):z=0<$?Math.floor(1e3/$):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_next=function($){switch(x){case 1:case 2:case 3:var L=3;break;default:L=x}var F=x;x=L;try{return $()}finally{x=F}},e.unstable_requestPaint=function(){k=!0},e.unstable_runWithPriority=function($,L){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var F=x;x=$;try{return L()}finally{x=F}},e.unstable_scheduleCallback=function($,L,F){var X=e.unstable_now();switch(typeof F=="object"&&F!==null?(F=F.delay,F=typeof F=="number"&&0<F?X+F:X):F=X,$){case 1:var G=-1;break;case 2:G=250;break;case 5:G=1073741823;break;case 4:G=1e4;break;default:G=5e3}return G=F+G,$={id:m++,callback:L,priorityLevel:$,startTime:F,expirationTime:G,sortIndex:-1},F>X?($.sortIndex=F,t(h,$),n(p)===null&&$===n(h)&&(N?(C(_),_=-1):N=!0,q(A,F-X))):($.sortIndex=G,t(p,$),j||w||(j=!0,M||(M=!0,D()))),$},e.unstable_shouldYield=U,e.unstable_wrapCallback=function($){var L=x;return function(){var F=x;x=L;try{return $.apply(this,arguments)}finally{x=F}}}})(Dm)),Dm}var k1;function vO(){return k1||(k1=1,Im.exports=gO()),Im.exports}var Pm={exports:{}},_n={};var E1;function yO(){if(E1)return _n;E1=1;var e=qc();function t(p){var h="https://react.dev/errors/"+p;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var m=2;m<arguments.length;m++)h+="&args[]="+encodeURIComponent(arguments[m])}return"Minified React error #"+p+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var s={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},a=Symbol.for("react.portal");function l(p,h,m){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:y==null?null:""+y,children:p,containerInfo:h,implementation:m}}var u=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(p,h){if(p==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return _n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,_n.createPortal=function(p,h){var m=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(t(299));return l(p,h,null,m)},_n.flushSync=function(p){var h=u.T,m=s.p;try{if(u.T=null,s.p=2,p)return p()}finally{u.T=h,s.p=m,s.d.f()}},_n.preconnect=function(p,h){typeof p=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,s.d.C(p,h))},_n.prefetchDNS=function(p){typeof p=="string"&&s.d.D(p)},_n.preinit=function(p,h){if(typeof p=="string"&&h&&typeof h.as=="string"){var m=h.as,y=d(m,h.crossOrigin),x=typeof h.integrity=="string"?h.integrity:void 0,w=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;m==="style"?s.d.S(p,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:y,integrity:x,fetchPriority:w}):m==="script"&&s.d.X(p,{crossOrigin:y,integrity:x,fetchPriority:w,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},_n.preinitModule=function(p,h){if(typeof p=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var m=d(h.as,h.crossOrigin);s.d.M(p,{crossOrigin:m,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&s.d.M(p)},_n.preload=function(p,h){if(typeof p=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var m=h.as,y=d(m,h.crossOrigin);s.d.L(p,m,{crossOrigin:y,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},_n.preloadModule=function(p,h){if(typeof p=="string")if(h){var m=d(h.as,h.crossOrigin);s.d.m(p,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:m,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else s.d.m(p)},_n.requestFormReset=function(p){s.d.r(p)},_n.unstable_batchedUpdates=function(p,h){return p(h)},_n.useFormState=function(p,h,m){return u.H.useFormState(p,h,m)},_n.useFormStatus=function(){return u.H.useHostTransitionStatus()},_n.version="19.2.3",_n}var C1;function Pk(){if(C1)return Pm.exports;C1=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Pm.exports=yO(),Pm.exports}var T1;function bO(){if(T1)return Ql;T1=1;var e=vO(),t=qc(),n=Pk();function s(r){var i="https://react.dev/errors/"+r;if(1<arguments.length){i+="?args[]="+encodeURIComponent(arguments[1]);for(var c=2;c<arguments.length;c++)i+="&args[]="+encodeURIComponent(arguments[c])}return"Minified React error #"+r+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function l(r){var i=r,c=r;if(r.alternate)for(;i.return;)i=i.return;else{r=i;do i=r,(i.flags&4098)!==0&&(c=i.return),r=i.return;while(r)}return i.tag===3?c:null}function u(r){if(r.tag===13){var i=r.memoizedState;if(i===null&&(r=r.alternate,r!==null&&(i=r.memoizedState)),i!==null)return i.dehydrated}return null}function d(r){if(r.tag===31){var i=r.memoizedState;if(i===null&&(r=r.alternate,r!==null&&(i=r.memoizedState)),i!==null)return i.dehydrated}return null}function p(r){if(l(r)!==r)throw Error(s(188))}function h(r){var i=r.alternate;if(!i){if(i=l(r),i===null)throw Error(s(188));return i!==r?null:r}for(var c=r,f=i;;){var v=c.return;if(v===null)break;var b=v.alternate;if(b===null){if(f=v.return,f!==null){c=f;continue}break}if(v.child===b.child){for(b=v.child;b;){if(b===c)return p(v),r;if(b===f)return p(v),i;b=b.sibling}throw Error(s(188))}if(c.return!==f.return)c=v,f=b;else{for(var T=!1,P=v.child;P;){if(P===c){T=!0,c=v,f=b;break}if(P===f){T=!0,f=v,c=b;break}P=P.sibling}if(!T){for(P=b.child;P;){if(P===c){T=!0,c=b,f=v;break}if(P===f){T=!0,f=b,c=v;break}P=P.sibling}if(!T)throw Error(s(189))}}if(c.alternate!==f)throw Error(s(190))}if(c.tag!==3)throw Error(s(188));return c.stateNode.current===c?r:i}function m(r){var i=r.tag;if(i===5||i===26||i===27||i===6)return r;for(r=r.child;r!==null;){if(i=m(r),i!==null)return i;r=r.sibling}return null}var y=Object.assign,x=Symbol.for("react.element"),w=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),k=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),C=Symbol.for("react.consumer"),S=Symbol.for("react.context"),R=Symbol.for("react.forward_ref"),A=Symbol.for("react.suspense"),M=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),z=Symbol.for("react.lazy"),V=Symbol.for("react.activity"),U=Symbol.for("react.memo_cache_sentinel"),O=Symbol.iterator;function D(r){return r===null||typeof r!="object"?null:(r=O&&r[O]||r["@@iterator"],typeof r=="function"?r:null)}var H=Symbol.for("react.client.reference");function W(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===H?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case N:return"Fragment";case E:return"Profiler";case k:return"StrictMode";case A:return"Suspense";case M:return"SuspenseList";case V:return"Activity"}if(typeof r=="object")switch(r.$$typeof){case j:return"Portal";case S:return r.displayName||"Context";case C:return(r._context.displayName||"Context")+".Consumer";case R:var i=r.render;return r=r.displayName,r||(r=i.displayName||i.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case _:return i=r.displayName||null,i!==null?i:W(r.type)||"Memo";case z:i=r._payload,r=r._init;try{return W(r(i))}catch{}}return null}var q=Array.isArray,$=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F={pending:!1,data:null,method:null,action:null},X=[],G=-1;function I(r){return{current:r}}function B(r){0>G||(r.current=X[G],X[G]=null,G--)}function Y(r,i){G++,X[G]=r.current,r.current=i}var Q=I(null),me=I(null),re=I(null),ie=I(null);function de(r,i){switch(Y(re,i),Y(me,r),Y(Q,null),i.nodeType){case 9:case 11:r=(r=i.documentElement)&&(r=r.namespaceURI)?Fw(r):0;break;default:if(r=i.tagName,i=i.namespaceURI)i=Fw(i),r=Hw(i,r);else switch(r){case"svg":r=1;break;case"math":r=2;break;default:r=0}}B(Q),Y(Q,r)}function ye(){B(Q),B(me),B(re)}function Te(r){r.memoizedState!==null&&Y(ie,r);var i=Q.current,c=Hw(i,r.type);i!==c&&(Y(me,r),Y(Q,c))}function he(r){me.current===r&&(B(Q),B(me)),ie.current===r&&(B(ie),Yl._currentValue=F)}var ue,we;function We(r){if(ue===void 0)try{throw Error()}catch(c){var i=c.stack.trim().match(/\n( *(at )?)/);ue=i&&i[1]||"",we=-1<c.stack.indexOf(`
|
|
2
|
-
at`)?" (<anonymous>)":-1<c.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
3
|
-
`+ue+r+we}var Ae=!1;function je(r,i){if(!r||Ae)return"";Ae=!0;var c=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var f={DetermineComponentFrameRoot:function(){try{if(i){var pe=function(){throw Error()};if(Object.defineProperty(pe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(pe,[])}catch(ae){var se=ae}Reflect.construct(r,[],pe)}else{try{pe.call()}catch(ae){se=ae}r.call(pe.prototype)}}else{try{throw Error()}catch(ae){se=ae}(pe=r())&&typeof pe.catch=="function"&&pe.catch(function(){})}}catch(ae){if(ae&&se&&typeof ae.stack=="string")return[ae.stack,se.stack]}return[null,null]}};f.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var v=Object.getOwnPropertyDescriptor(f.DetermineComponentFrameRoot,"name");v&&v.configurable&&Object.defineProperty(f.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var b=f.DetermineComponentFrameRoot(),T=b[0],P=b[1];if(T&&P){var Z=T.split(`
|
|
4
|
-
`),ne=P.split(`
|
|
5
|
-
`);for(v=f=0;f<Z.length&&!Z[f].includes("DetermineComponentFrameRoot");)f++;for(;v<ne.length&&!ne[v].includes("DetermineComponentFrameRoot");)v++;if(f===Z.length||v===ne.length)for(f=Z.length-1,v=ne.length-1;1<=f&&0<=v&&Z[f]!==ne[v];)v--;for(;1<=f&&0<=v;f--,v--)if(Z[f]!==ne[v]){if(f!==1||v!==1)do if(f--,v--,0>v||Z[f]!==ne[v]){var le=`
|
|
6
|
-
`+Z[f].replace(" at new "," at ");return r.displayName&&le.includes("<anonymous>")&&(le=le.replace("<anonymous>",r.displayName)),le}while(1<=f&&0<=v);break}}}finally{Ae=!1,Error.prepareStackTrace=c}return(c=r?r.displayName||r.name:"")?We(c):""}function Ee(r,i){switch(r.tag){case 26:case 27:case 5:return We(r.type);case 16:return We("Lazy");case 13:return r.child!==i&&i!==null?We("Suspense Fallback"):We("Suspense");case 19:return We("SuspenseList");case 0:case 15:return je(r.type,!1);case 11:return je(r.type.render,!1);case 1:return je(r.type,!0);case 31:return We("Activity");default:return""}}function Ue(r){try{var i="",c=null;do i+=Ee(r,c),c=r,r=r.return;while(r);return i}catch(f){return`
|
|
7
|
-
Error generating stack: `+f.message+`
|
|
8
|
-
`+f.stack}}var Ve=Object.prototype.hasOwnProperty,Be=e.unstable_scheduleCallback,oe=e.unstable_cancelCallback,ve=e.unstable_shouldYield,xe=e.unstable_requestPaint,Ne=e.unstable_now,ke=e.unstable_getCurrentPriorityLevel,Se=e.unstable_ImmediatePriority,$e=e.unstable_UserBlockingPriority,Pe=e.unstable_NormalPriority,xt=e.unstable_LowPriority,kt=e.unstable_IdlePriority,un=e.log,Xt=e.unstable_setDisableYieldValue,Jt=null,ze=null;function at(r){if(typeof un=="function"&&Xt(r),ze&&typeof ze.setStrictMode=="function")try{ze.setStrictMode(Jt,r)}catch{}}var lt=Math.clz32?Math.clz32:bn,gt=Math.log,Bt=Math.LN2;function bn(r){return r>>>=0,r===0?32:31-(gt(r)/Bt|0)|0}var Wt=256,Mn=262144,dn=4194304;function fn(r){var i=r&42;if(i!==0)return i;switch(r&-r){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return r&261888;case 262144:case 524288:case 1048576:case 2097152:return r&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return r&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return r}}function qs(r,i,c){var f=r.pendingLanes;if(f===0)return 0;var v=0,b=r.suspendedLanes,T=r.pingedLanes;r=r.warmLanes;var P=f&134217727;return P!==0?(f=P&~b,f!==0?v=fn(f):(T&=P,T!==0?v=fn(T):c||(c=P&~r,c!==0&&(v=fn(c))))):(P=f&~b,P!==0?v=fn(P):T!==0?v=fn(T):c||(c=f&~r,c!==0&&(v=fn(c)))),v===0?0:i!==0&&i!==v&&(i&b)===0&&(b=v&-v,c=i&-i,b>=c||b===32&&(c&4194048)!==0)?i:v}function Zs(r,i){return(r.pendingLanes&~(r.suspendedLanes&~r.pingedLanes)&i)===0}function Mi(r,i){switch(r){case 1:case 2:case 4:case 8:case 64:return i+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return i+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ee(){var r=dn;return dn<<=1,(dn&62914560)===0&&(dn=4194304),r}function ge(r){for(var i=[],c=0;31>c;c++)i.push(r);return i}function be(r,i){r.pendingLanes|=i,i!==268435456&&(r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0)}function qe(r,i,c,f,v,b){var T=r.pendingLanes;r.pendingLanes=c,r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0,r.expiredLanes&=c,r.entangledLanes&=c,r.errorRecoveryDisabledLanes&=c,r.shellSuspendCounter=0;var P=r.entanglements,Z=r.expirationTimes,ne=r.hiddenUpdates;for(c=T&~c;0<c;){var le=31-lt(c),pe=1<<le;P[le]=0,Z[le]=-1;var se=ne[le];if(se!==null)for(ne[le]=null,le=0;le<se.length;le++){var ae=se[le];ae!==null&&(ae.lane&=-536870913)}c&=~pe}f!==0&&Ze(r,f,0),b!==0&&v===0&&r.tag!==0&&(r.suspendedLanes|=b&~(T&~i))}function Ze(r,i,c){r.pendingLanes|=i,r.suspendedLanes&=~i;var f=31-lt(i);r.entangledLanes|=i,r.entanglements[f]=r.entanglements[f]|1073741824|c&261930}function dt(r,i){var c=r.entangledLanes|=i;for(r=r.entanglements;c;){var f=31-lt(c),v=1<<f;v&i|r[f]&i&&(r[f]|=i),c&=~v}}function Vt(r,i){var c=i&-i;return c=(c&42)!==0?1:Et(c),(c&(r.suspendedLanes|i))!==0?0:c}function Et(r){switch(r){case 2:r=1;break;case 8:r=4;break;case 32:r=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:r=128;break;case 268435456:r=134217728;break;default:r=0}return r}function mn(r){return r&=-r,2<r?8<r?(r&134217727)!==0?32:268435456:8:2}function xn(){var r=L.p;return r!==0?r:(r=window.event,r===void 0?32:h1(r.type))}function Ws(r,i){var c=L.p;try{return L.p=r,i()}finally{L.p=c}}var Ft=Math.random().toString(36).slice(2),wn="__reactFiber$"+Ft,Hn="__reactProps$"+Ft,_i="__reactContainer$"+Ft,jh="__reactEvents$"+Ft,t_="__reactListeners$"+Ft,n_="__reactHandles$"+Ft,Rb="__reactResources$"+Ft,cl="__reactMarker$"+Ft;function Sh(r){delete r[wn],delete r[Hn],delete r[jh],delete r[t_],delete r[n_]}function Oi(r){var i=r[wn];if(i)return i;for(var c=r.parentNode;c;){if(i=c[_i]||c[wn]){if(c=i.alternate,i.child!==null||c!==null&&c.child!==null)for(r=Xw(r);r!==null;){if(c=r[wn])return c;r=Xw(r)}return i}r=c,c=r.parentNode}return null}function Ii(r){if(r=r[wn]||r[_i]){var i=r.tag;if(i===5||i===6||i===13||i===31||i===26||i===27||i===3)return r}return null}function ul(r){var i=r.tag;if(i===5||i===26||i===27||i===6)return r.stateNode;throw Error(s(33))}function Di(r){var i=r[Rb];return i||(i=r[Rb]={hoistableStyles:new Map,hoistableScripts:new Map}),i}function gn(r){r[cl]=!0}var Mb=new Set,_b={};function $a(r,i){Pi(r,i),Pi(r+"Capture",i)}function Pi(r,i){for(_b[r]=i,r=0;r<i.length;r++)Mb.add(i[r])}var s_=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Ob={},Ib={};function r_(r){return Ve.call(Ib,r)?!0:Ve.call(Ob,r)?!1:s_.test(r)?Ib[r]=!0:(Ob[r]=!0,!1)}function au(r,i,c){if(r_(i))if(c===null)r.removeAttribute(i);else{switch(typeof c){case"undefined":case"function":case"symbol":r.removeAttribute(i);return;case"boolean":var f=i.toLowerCase().slice(0,5);if(f!=="data-"&&f!=="aria-"){r.removeAttribute(i);return}}r.setAttribute(i,""+c)}}function iu(r,i,c){if(c===null)r.removeAttribute(i);else{switch(typeof c){case"undefined":case"function":case"symbol":case"boolean":r.removeAttribute(i);return}r.setAttribute(i,""+c)}}function hr(r,i,c,f){if(f===null)r.removeAttribute(c);else{switch(typeof f){case"undefined":case"function":case"symbol":case"boolean":r.removeAttribute(c);return}r.setAttributeNS(i,c,""+f)}}function ps(r){switch(typeof r){case"bigint":case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function Db(r){var i=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(i==="checkbox"||i==="radio")}function a_(r,i,c){var f=Object.getOwnPropertyDescriptor(r.constructor.prototype,i);if(!r.hasOwnProperty(i)&&typeof f<"u"&&typeof f.get=="function"&&typeof f.set=="function"){var v=f.get,b=f.set;return Object.defineProperty(r,i,{configurable:!0,get:function(){return v.call(this)},set:function(T){c=""+T,b.call(this,T)}}),Object.defineProperty(r,i,{enumerable:f.enumerable}),{getValue:function(){return c},setValue:function(T){c=""+T},stopTracking:function(){r._valueTracker=null,delete r[i]}}}}function Nh(r){if(!r._valueTracker){var i=Db(r)?"checked":"value";r._valueTracker=a_(r,i,""+r[i])}}function Pb(r){if(!r)return!1;var i=r._valueTracker;if(!i)return!0;var c=i.getValue(),f="";return r&&(f=Db(r)?r.checked?"true":"false":r.value),r=f,r!==c?(i.setValue(r),!0):!1}function ou(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}var i_=/[\n"\\]/g;function ms(r){return r.replace(i_,function(i){return"\\"+i.charCodeAt(0).toString(16)+" "})}function kh(r,i,c,f,v,b,T,P){r.name="",T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"?r.type=T:r.removeAttribute("type"),i!=null?T==="number"?(i===0&&r.value===""||r.value!=i)&&(r.value=""+ps(i)):r.value!==""+ps(i)&&(r.value=""+ps(i)):T!=="submit"&&T!=="reset"||r.removeAttribute("value"),i!=null?Eh(r,T,ps(i)):c!=null?Eh(r,T,ps(c)):f!=null&&r.removeAttribute("value"),v==null&&b!=null&&(r.defaultChecked=!!b),v!=null&&(r.checked=v&&typeof v!="function"&&typeof v!="symbol"),P!=null&&typeof P!="function"&&typeof P!="symbol"&&typeof P!="boolean"?r.name=""+ps(P):r.removeAttribute("name")}function zb(r,i,c,f,v,b,T,P){if(b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"&&(r.type=b),i!=null||c!=null){if(!(b!=="submit"&&b!=="reset"||i!=null)){Nh(r);return}c=c!=null?""+ps(c):"",i=i!=null?""+ps(i):c,P||i===r.value||(r.value=i),r.defaultValue=i}f=f??v,f=typeof f!="function"&&typeof f!="symbol"&&!!f,r.checked=P?r.checked:!!f,r.defaultChecked=!!f,T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"&&(r.name=T),Nh(r)}function Eh(r,i,c){i==="number"&&ou(r.ownerDocument)===r||r.defaultValue===""+c||(r.defaultValue=""+c)}function zi(r,i,c,f){if(r=r.options,i){i={};for(var v=0;v<c.length;v++)i["$"+c[v]]=!0;for(c=0;c<r.length;c++)v=i.hasOwnProperty("$"+r[c].value),r[c].selected!==v&&(r[c].selected=v),v&&f&&(r[c].defaultSelected=!0)}else{for(c=""+ps(c),i=null,v=0;v<r.length;v++){if(r[v].value===c){r[v].selected=!0,f&&(r[v].defaultSelected=!0);return}i!==null||r[v].disabled||(i=r[v])}i!==null&&(i.selected=!0)}}function Lb(r,i,c){if(i!=null&&(i=""+ps(i),i!==r.value&&(r.value=i),c==null)){r.defaultValue!==i&&(r.defaultValue=i);return}r.defaultValue=c!=null?""+ps(c):""}function $b(r,i,c,f){if(i==null){if(f!=null){if(c!=null)throw Error(s(92));if(q(f)){if(1<f.length)throw Error(s(93));f=f[0]}c=f}c==null&&(c=""),i=c}c=ps(i),r.defaultValue=c,f=r.textContent,f===c&&f!==""&&f!==null&&(r.value=f),Nh(r)}function Li(r,i){if(i){var c=r.firstChild;if(c&&c===r.lastChild&&c.nodeType===3){c.nodeValue=i;return}}r.textContent=i}var o_=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Ub(r,i,c){var f=i.indexOf("--")===0;c==null||typeof c=="boolean"||c===""?f?r.setProperty(i,""):i==="float"?r.cssFloat="":r[i]="":f?r.setProperty(i,c):typeof c!="number"||c===0||o_.has(i)?i==="float"?r.cssFloat=c:r[i]=(""+c).trim():r[i]=c+"px"}function Bb(r,i,c){if(i!=null&&typeof i!="object")throw Error(s(62));if(r=r.style,c!=null){for(var f in c)!c.hasOwnProperty(f)||i!=null&&i.hasOwnProperty(f)||(f.indexOf("--")===0?r.setProperty(f,""):f==="float"?r.cssFloat="":r[f]="");for(var v in i)f=i[v],i.hasOwnProperty(v)&&c[v]!==f&&Ub(r,v,f)}else for(var b in i)i.hasOwnProperty(b)&&Ub(r,b,i[b])}function Ch(r){if(r.indexOf("-")===-1)return!1;switch(r){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var l_=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),c_=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function lu(r){return c_.test(""+r)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":r}function pr(){}var Th=null;function Ah(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var $i=null,Ui=null;function Vb(r){var i=Ii(r);if(i&&(r=i.stateNode)){var c=r[Hn]||null;e:switch(r=i.stateNode,i.type){case"input":if(kh(r,c.value,c.defaultValue,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name),i=c.name,c.type==="radio"&&i!=null){for(c=r;c.parentNode;)c=c.parentNode;for(c=c.querySelectorAll('input[name="'+ms(""+i)+'"][type="radio"]'),i=0;i<c.length;i++){var f=c[i];if(f!==r&&f.form===r.form){var v=f[Hn]||null;if(!v)throw Error(s(90));kh(f,v.value,v.defaultValue,v.defaultValue,v.checked,v.defaultChecked,v.type,v.name)}}for(i=0;i<c.length;i++)f=c[i],f.form===r.form&&Pb(f)}break e;case"textarea":Lb(r,c.value,c.defaultValue);break e;case"select":i=c.value,i!=null&&zi(r,!!c.multiple,i,!1)}}}var Rh=!1;function Fb(r,i,c){if(Rh)return r(i,c);Rh=!0;try{var f=r(i);return f}finally{if(Rh=!1,($i!==null||Ui!==null)&&(Gu(),$i&&(i=$i,r=Ui,Ui=$i=null,Vb(i),r)))for(i=0;i<r.length;i++)Vb(r[i])}}function dl(r,i){var c=r.stateNode;if(c===null)return null;var f=c[Hn]||null;if(f===null)return null;c=f[i];e:switch(i){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(f=!f.disabled)||(r=r.type,f=!(r==="button"||r==="input"||r==="select"||r==="textarea")),r=!f;break e;default:r=!1}if(r)return null;if(c&&typeof c!="function")throw Error(s(231,i,typeof c));return c}var mr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Mh=!1;if(mr)try{var fl={};Object.defineProperty(fl,"passive",{get:function(){Mh=!0}}),window.addEventListener("test",fl,fl),window.removeEventListener("test",fl,fl)}catch{Mh=!1}var Br=null,_h=null,cu=null;function Hb(){if(cu)return cu;var r,i=_h,c=i.length,f,v="value"in Br?Br.value:Br.textContent,b=v.length;for(r=0;r<c&&i[r]===v[r];r++);var T=c-r;for(f=1;f<=T&&i[c-f]===v[b-f];f++);return cu=v.slice(r,1<f?1-f:void 0)}function uu(r){var i=r.keyCode;return"charCode"in r?(r=r.charCode,r===0&&i===13&&(r=13)):r=i,r===10&&(r=13),32<=r||r===13?r:0}function du(){return!0}function qb(){return!1}function qn(r){function i(c,f,v,b,T){this._reactName=c,this._targetInst=v,this.type=f,this.nativeEvent=b,this.target=T,this.currentTarget=null;for(var P in r)r.hasOwnProperty(P)&&(c=r[P],this[P]=c?c(b):b[P]);return this.isDefaultPrevented=(b.defaultPrevented!=null?b.defaultPrevented:b.returnValue===!1)?du:qb,this.isPropagationStopped=qb,this}return y(i.prototype,{preventDefault:function(){this.defaultPrevented=!0;var c=this.nativeEvent;c&&(c.preventDefault?c.preventDefault():typeof c.returnValue!="unknown"&&(c.returnValue=!1),this.isDefaultPrevented=du)},stopPropagation:function(){var c=this.nativeEvent;c&&(c.stopPropagation?c.stopPropagation():typeof c.cancelBubble!="unknown"&&(c.cancelBubble=!0),this.isPropagationStopped=du)},persist:function(){},isPersistent:du}),i}var Ua={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},fu=qn(Ua),hl=y({},Ua,{view:0,detail:0}),u_=qn(hl),Oh,Ih,pl,hu=y({},hl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ph,button:0,buttons:0,relatedTarget:function(r){return r.relatedTarget===void 0?r.fromElement===r.srcElement?r.toElement:r.fromElement:r.relatedTarget},movementX:function(r){return"movementX"in r?r.movementX:(r!==pl&&(pl&&r.type==="mousemove"?(Oh=r.screenX-pl.screenX,Ih=r.screenY-pl.screenY):Ih=Oh=0,pl=r),Oh)},movementY:function(r){return"movementY"in r?r.movementY:Ih}}),Zb=qn(hu),d_=y({},hu,{dataTransfer:0}),f_=qn(d_),h_=y({},hl,{relatedTarget:0}),Dh=qn(h_),p_=y({},Ua,{animationName:0,elapsedTime:0,pseudoElement:0}),m_=qn(p_),g_=y({},Ua,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),v_=qn(g_),y_=y({},Ua,{data:0}),Wb=qn(y_),b_={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},x_={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},w_={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function j_(r){var i=this.nativeEvent;return i.getModifierState?i.getModifierState(r):(r=w_[r])?!!i[r]:!1}function Ph(){return j_}var S_=y({},hl,{key:function(r){if(r.key){var i=b_[r.key]||r.key;if(i!=="Unidentified")return i}return r.type==="keypress"?(r=uu(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?x_[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ph,charCode:function(r){return r.type==="keypress"?uu(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?uu(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),N_=qn(S_),k_=y({},hu,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Yb=qn(k_),E_=y({},hl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ph}),C_=qn(E_),T_=y({},Ua,{propertyName:0,elapsedTime:0,pseudoElement:0}),A_=qn(T_),R_=y({},hu,{deltaX:function(r){return"deltaX"in r?r.deltaX:"wheelDeltaX"in r?-r.wheelDeltaX:0},deltaY:function(r){return"deltaY"in r?r.deltaY:"wheelDeltaY"in r?-r.wheelDeltaY:"wheelDelta"in r?-r.wheelDelta:0},deltaZ:0,deltaMode:0}),M_=qn(R_),__=y({},Ua,{newState:0,oldState:0}),O_=qn(__),I_=[9,13,27,32],zh=mr&&"CompositionEvent"in window,ml=null;mr&&"documentMode"in document&&(ml=document.documentMode);var D_=mr&&"TextEvent"in window&&!ml,Gb=mr&&(!zh||ml&&8<ml&&11>=ml),Kb=" ",Xb=!1;function Jb(r,i){switch(r){case"keyup":return I_.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Qb(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var Bi=!1;function P_(r,i){switch(r){case"compositionend":return Qb(i);case"keypress":return i.which!==32?null:(Xb=!0,Kb);case"textInput":return r=i.data,r===Kb&&Xb?null:r;default:return null}}function z_(r,i){if(Bi)return r==="compositionend"||!zh&&Jb(r,i)?(r=Hb(),cu=_h=Br=null,Bi=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1<i.char.length)return i.char;if(i.which)return String.fromCharCode(i.which)}return null;case"compositionend":return Gb&&i.locale!=="ko"?null:i.data;default:return null}}var L_={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function ex(r){var i=r&&r.nodeName&&r.nodeName.toLowerCase();return i==="input"?!!L_[r.type]:i==="textarea"}function tx(r,i,c,f){$i?Ui?Ui.push(f):Ui=[f]:$i=f,i=nd(i,"onChange"),0<i.length&&(c=new fu("onChange","change",null,c,f),r.push({event:c,listeners:i}))}var gl=null,vl=null;function $_(r){zw(r,0)}function pu(r){var i=ul(r);if(Pb(i))return r}function nx(r,i){if(r==="change")return i}var sx=!1;if(mr){var Lh;if(mr){var $h="oninput"in document;if(!$h){var rx=document.createElement("div");rx.setAttribute("oninput","return;"),$h=typeof rx.oninput=="function"}Lh=$h}else Lh=!1;sx=Lh&&(!document.documentMode||9<document.documentMode)}function ax(){gl&&(gl.detachEvent("onpropertychange",ix),vl=gl=null)}function ix(r){if(r.propertyName==="value"&&pu(vl)){var i=[];tx(i,vl,r,Ah(r)),Fb($_,i)}}function U_(r,i,c){r==="focusin"?(ax(),gl=i,vl=c,gl.attachEvent("onpropertychange",ix)):r==="focusout"&&ax()}function B_(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return pu(vl)}function V_(r,i){if(r==="click")return pu(i)}function F_(r,i){if(r==="input"||r==="change")return pu(i)}function H_(r,i){return r===i&&(r!==0||1/r===1/i)||r!==r&&i!==i}var ns=typeof Object.is=="function"?Object.is:H_;function yl(r,i){if(ns(r,i))return!0;if(typeof r!="object"||r===null||typeof i!="object"||i===null)return!1;var c=Object.keys(r),f=Object.keys(i);if(c.length!==f.length)return!1;for(f=0;f<c.length;f++){var v=c[f];if(!Ve.call(i,v)||!ns(r[v],i[v]))return!1}return!0}function ox(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function lx(r,i){var c=ox(r);r=0;for(var f;c;){if(c.nodeType===3){if(f=r+c.textContent.length,r<=i&&f>=i)return{node:c,offset:i-r};r=f}e:{for(;c;){if(c.nextSibling){c=c.nextSibling;break e}c=c.parentNode}c=void 0}c=ox(c)}}function cx(r,i){return r&&i?r===i?!0:r&&r.nodeType===3?!1:i&&i.nodeType===3?cx(r,i.parentNode):"contains"in r?r.contains(i):r.compareDocumentPosition?!!(r.compareDocumentPosition(i)&16):!1:!1}function ux(r){r=r!=null&&r.ownerDocument!=null&&r.ownerDocument.defaultView!=null?r.ownerDocument.defaultView:window;for(var i=ou(r.document);i instanceof r.HTMLIFrameElement;){try{var c=typeof i.contentWindow.location.href=="string"}catch{c=!1}if(c)r=i.contentWindow;else break;i=ou(r.document)}return i}function Uh(r){var i=r&&r.nodeName&&r.nodeName.toLowerCase();return i&&(i==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||i==="textarea"||r.contentEditable==="true")}var q_=mr&&"documentMode"in document&&11>=document.documentMode,Vi=null,Bh=null,bl=null,Vh=!1;function dx(r,i,c){var f=c.window===c?c.document:c.nodeType===9?c:c.ownerDocument;Vh||Vi==null||Vi!==ou(f)||(f=Vi,"selectionStart"in f&&Uh(f)?f={start:f.selectionStart,end:f.selectionEnd}:(f=(f.ownerDocument&&f.ownerDocument.defaultView||window).getSelection(),f={anchorNode:f.anchorNode,anchorOffset:f.anchorOffset,focusNode:f.focusNode,focusOffset:f.focusOffset}),bl&&yl(bl,f)||(bl=f,f=nd(Bh,"onSelect"),0<f.length&&(i=new fu("onSelect","select",null,i,c),r.push({event:i,listeners:f}),i.target=Vi)))}function Ba(r,i){var c={};return c[r.toLowerCase()]=i.toLowerCase(),c["Webkit"+r]="webkit"+i,c["Moz"+r]="moz"+i,c}var Fi={animationend:Ba("Animation","AnimationEnd"),animationiteration:Ba("Animation","AnimationIteration"),animationstart:Ba("Animation","AnimationStart"),transitionrun:Ba("Transition","TransitionRun"),transitionstart:Ba("Transition","TransitionStart"),transitioncancel:Ba("Transition","TransitionCancel"),transitionend:Ba("Transition","TransitionEnd")},Fh={},fx={};mr&&(fx=document.createElement("div").style,"AnimationEvent"in window||(delete Fi.animationend.animation,delete Fi.animationiteration.animation,delete Fi.animationstart.animation),"TransitionEvent"in window||delete Fi.transitionend.transition);function Va(r){if(Fh[r])return Fh[r];if(!Fi[r])return r;var i=Fi[r],c;for(c in i)if(i.hasOwnProperty(c)&&c in fx)return Fh[r]=i[c];return r}var hx=Va("animationend"),px=Va("animationiteration"),mx=Va("animationstart"),Z_=Va("transitionrun"),W_=Va("transitionstart"),Y_=Va("transitioncancel"),gx=Va("transitionend"),vx=new Map,Hh="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");Hh.push("scrollEnd");function _s(r,i){vx.set(r,i),$a(i,[r])}var mu=typeof reportError=="function"?reportError:function(r){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var i=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof r=="object"&&r!==null&&typeof r.message=="string"?String(r.message):String(r),error:r});if(!window.dispatchEvent(i))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",r);return}console.error(r)},gs=[],Hi=0,qh=0;function gu(){for(var r=Hi,i=qh=Hi=0;i<r;){var c=gs[i];gs[i++]=null;var f=gs[i];gs[i++]=null;var v=gs[i];gs[i++]=null;var b=gs[i];if(gs[i++]=null,f!==null&&v!==null){var T=f.pending;T===null?v.next=v:(v.next=T.next,T.next=v),f.pending=v}b!==0&&yx(c,v,b)}}function vu(r,i,c,f){gs[Hi++]=r,gs[Hi++]=i,gs[Hi++]=c,gs[Hi++]=f,qh|=f,r.lanes|=f,r=r.alternate,r!==null&&(r.lanes|=f)}function Zh(r,i,c,f){return vu(r,i,c,f),yu(r)}function Fa(r,i){return vu(r,null,null,i),yu(r)}function yx(r,i,c){r.lanes|=c;var f=r.alternate;f!==null&&(f.lanes|=c);for(var v=!1,b=r.return;b!==null;)b.childLanes|=c,f=b.alternate,f!==null&&(f.childLanes|=c),b.tag===22&&(r=b.stateNode,r===null||r._visibility&1||(v=!0)),r=b,b=b.return;return r.tag===3?(b=r.stateNode,v&&i!==null&&(v=31-lt(c),r=b.hiddenUpdates,f=r[v],f===null?r[v]=[i]:f.push(i),i.lane=c|536870912),b):null}function yu(r){if(50<Bl)throw Bl=0,tm=null,Error(s(185));for(var i=r.return;i!==null;)r=i,i=r.return;return r.tag===3?r.stateNode:null}var qi={};function G_(r,i,c,f){this.tag=r,this.key=c,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=i,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=f,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ss(r,i,c,f){return new G_(r,i,c,f)}function Wh(r){return r=r.prototype,!(!r||!r.isReactComponent)}function gr(r,i){var c=r.alternate;return c===null?(c=ss(r.tag,i,r.key,r.mode),c.elementType=r.elementType,c.type=r.type,c.stateNode=r.stateNode,c.alternate=r,r.alternate=c):(c.pendingProps=i,c.type=r.type,c.flags=0,c.subtreeFlags=0,c.deletions=null),c.flags=r.flags&65011712,c.childLanes=r.childLanes,c.lanes=r.lanes,c.child=r.child,c.memoizedProps=r.memoizedProps,c.memoizedState=r.memoizedState,c.updateQueue=r.updateQueue,i=r.dependencies,c.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext},c.sibling=r.sibling,c.index=r.index,c.ref=r.ref,c.refCleanup=r.refCleanup,c}function bx(r,i){r.flags&=65011714;var c=r.alternate;return c===null?(r.childLanes=0,r.lanes=i,r.child=null,r.subtreeFlags=0,r.memoizedProps=null,r.memoizedState=null,r.updateQueue=null,r.dependencies=null,r.stateNode=null):(r.childLanes=c.childLanes,r.lanes=c.lanes,r.child=c.child,r.subtreeFlags=0,r.deletions=null,r.memoizedProps=c.memoizedProps,r.memoizedState=c.memoizedState,r.updateQueue=c.updateQueue,r.type=c.type,i=c.dependencies,r.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),r}function bu(r,i,c,f,v,b){var T=0;if(f=r,typeof r=="function")Wh(r)&&(T=1);else if(typeof r=="string")T=eO(r,c,Q.current)?26:r==="html"||r==="head"||r==="body"?27:5;else e:switch(r){case V:return r=ss(31,c,i,v),r.elementType=V,r.lanes=b,r;case N:return Ha(c.children,v,b,i);case k:T=8,v|=24;break;case E:return r=ss(12,c,i,v|2),r.elementType=E,r.lanes=b,r;case A:return r=ss(13,c,i,v),r.elementType=A,r.lanes=b,r;case M:return r=ss(19,c,i,v),r.elementType=M,r.lanes=b,r;default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case S:T=10;break e;case C:T=9;break e;case R:T=11;break e;case _:T=14;break e;case z:T=16,f=null;break e}T=29,c=Error(s(130,r===null?"null":typeof r,"")),f=null}return i=ss(T,c,i,v),i.elementType=r,i.type=f,i.lanes=b,i}function Ha(r,i,c,f){return r=ss(7,r,f,i),r.lanes=c,r}function Yh(r,i,c){return r=ss(6,r,null,i),r.lanes=c,r}function xx(r){var i=ss(18,null,null,0);return i.stateNode=r,i}function Gh(r,i,c){return i=ss(4,r.children!==null?r.children:[],r.key,i),i.lanes=c,i.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},i}var wx=new WeakMap;function vs(r,i){if(typeof r=="object"&&r!==null){var c=wx.get(r);return c!==void 0?c:(i={value:r,source:i,stack:Ue(i)},wx.set(r,i),i)}return{value:r,source:i,stack:Ue(i)}}var Zi=[],Wi=0,xu=null,xl=0,ys=[],bs=0,Vr=null,Ys=1,Gs="";function vr(r,i){Zi[Wi++]=xl,Zi[Wi++]=xu,xu=r,xl=i}function jx(r,i,c){ys[bs++]=Ys,ys[bs++]=Gs,ys[bs++]=Vr,Vr=r;var f=Ys;r=Gs;var v=32-lt(f)-1;f&=~(1<<v),c+=1;var b=32-lt(i)+v;if(30<b){var T=v-v%5;b=(f&(1<<T)-1).toString(32),f>>=T,v-=T,Ys=1<<32-lt(i)+v|c<<v|f,Gs=b+r}else Ys=1<<b|c<<v|f,Gs=r}function Kh(r){r.return!==null&&(vr(r,1),jx(r,1,0))}function Xh(r){for(;r===xu;)xu=Zi[--Wi],Zi[Wi]=null,xl=Zi[--Wi],Zi[Wi]=null;for(;r===Vr;)Vr=ys[--bs],ys[bs]=null,Gs=ys[--bs],ys[bs]=null,Ys=ys[--bs],ys[bs]=null}function Sx(r,i){ys[bs++]=Ys,ys[bs++]=Gs,ys[bs++]=Vr,Ys=i.id,Gs=i.overflow,Vr=r}var jn=null,Mt=null,ct=!1,Fr=null,xs=!1,Jh=Error(s(519));function Hr(r){var i=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw wl(vs(i,r)),Jh}function Nx(r){var i=r.stateNode,c=r.type,f=r.memoizedProps;switch(i[wn]=r,i[Hn]=f,c){case"dialog":st("cancel",i),st("close",i);break;case"iframe":case"object":case"embed":st("load",i);break;case"video":case"audio":for(c=0;c<Fl.length;c++)st(Fl[c],i);break;case"source":st("error",i);break;case"img":case"image":case"link":st("error",i),st("load",i);break;case"details":st("toggle",i);break;case"input":st("invalid",i),zb(i,f.value,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name,!0);break;case"select":st("invalid",i);break;case"textarea":st("invalid",i),$b(i,f.value,f.defaultValue,f.children)}c=f.children,typeof c!="string"&&typeof c!="number"&&typeof c!="bigint"||i.textContent===""+c||f.suppressHydrationWarning===!0||Bw(i.textContent,c)?(f.popover!=null&&(st("beforetoggle",i),st("toggle",i)),f.onScroll!=null&&st("scroll",i),f.onScrollEnd!=null&&st("scrollend",i),f.onClick!=null&&(i.onclick=pr),i=!0):i=!1,i||Hr(r,!0)}function kx(r){for(jn=r.return;jn;)switch(jn.tag){case 5:case 31:case 13:xs=!1;return;case 27:case 3:xs=!0;return;default:jn=jn.return}}function Yi(r){if(r!==jn)return!1;if(!ct)return kx(r),ct=!0,!1;var i=r.tag,c;if((c=i!==3&&i!==27)&&((c=i===5)&&(c=r.type,c=!(c!=="form"&&c!=="button")||gm(r.type,r.memoizedProps)),c=!c),c&&Mt&&Hr(r),kx(r),i===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(s(317));Mt=Kw(r)}else if(i===31){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(s(317));Mt=Kw(r)}else i===27?(i=Mt,ra(r.type)?(r=wm,wm=null,Mt=r):Mt=i):Mt=jn?js(r.stateNode.nextSibling):null;return!0}function qa(){Mt=jn=null,ct=!1}function Qh(){var r=Fr;return r!==null&&(Gn===null?Gn=r:Gn.push.apply(Gn,r),Fr=null),r}function wl(r){Fr===null?Fr=[r]:Fr.push(r)}var ep=I(null),Za=null,yr=null;function qr(r,i,c){Y(ep,i._currentValue),i._currentValue=c}function br(r){r._currentValue=ep.current,B(ep)}function tp(r,i,c){for(;r!==null;){var f=r.alternate;if((r.childLanes&i)!==i?(r.childLanes|=i,f!==null&&(f.childLanes|=i)):f!==null&&(f.childLanes&i)!==i&&(f.childLanes|=i),r===c)break;r=r.return}}function np(r,i,c,f){var v=r.child;for(v!==null&&(v.return=r);v!==null;){var b=v.dependencies;if(b!==null){var T=v.child;b=b.firstContext;e:for(;b!==null;){var P=b;b=v;for(var Z=0;Z<i.length;Z++)if(P.context===i[Z]){b.lanes|=c,P=b.alternate,P!==null&&(P.lanes|=c),tp(b.return,c,r),f||(T=null);break e}b=P.next}}else if(v.tag===18){if(T=v.return,T===null)throw Error(s(341));T.lanes|=c,b=T.alternate,b!==null&&(b.lanes|=c),tp(T,c,r),T=null}else T=v.child;if(T!==null)T.return=v;else for(T=v;T!==null;){if(T===r){T=null;break}if(v=T.sibling,v!==null){v.return=T.return,T=v;break}T=T.return}v=T}}function Gi(r,i,c,f){r=null;for(var v=i,b=!1;v!==null;){if(!b){if((v.flags&524288)!==0)b=!0;else if((v.flags&262144)!==0)break}if(v.tag===10){var T=v.alternate;if(T===null)throw Error(s(387));if(T=T.memoizedProps,T!==null){var P=v.type;ns(v.pendingProps.value,T.value)||(r!==null?r.push(P):r=[P])}}else if(v===ie.current){if(T=v.alternate,T===null)throw Error(s(387));T.memoizedState.memoizedState!==v.memoizedState.memoizedState&&(r!==null?r.push(Yl):r=[Yl])}v=v.return}r!==null&&np(i,r,c,f),i.flags|=262144}function wu(r){for(r=r.firstContext;r!==null;){if(!ns(r.context._currentValue,r.memoizedValue))return!0;r=r.next}return!1}function Wa(r){Za=r,yr=null,r=r.dependencies,r!==null&&(r.firstContext=null)}function Sn(r){return Ex(Za,r)}function ju(r,i){return Za===null&&Wa(r),Ex(r,i)}function Ex(r,i){var c=i._currentValue;if(i={context:i,memoizedValue:c,next:null},yr===null){if(r===null)throw Error(s(308));yr=i,r.dependencies={lanes:0,firstContext:i},r.flags|=524288}else yr=yr.next=i;return c}var K_=typeof AbortController<"u"?AbortController:function(){var r=[],i=this.signal={aborted:!1,addEventListener:function(c,f){r.push(f)}};this.abort=function(){i.aborted=!0,r.forEach(function(c){return c()})}},X_=e.unstable_scheduleCallback,J_=e.unstable_NormalPriority,sn={$$typeof:S,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function sp(){return{controller:new K_,data:new Map,refCount:0}}function jl(r){r.refCount--,r.refCount===0&&X_(J_,function(){r.controller.abort()})}var Sl=null,rp=0,Ki=0,Xi=null;function Q_(r,i){if(Sl===null){var c=Sl=[];rp=0,Ki=om(),Xi={status:"pending",value:void 0,then:function(f){c.push(f)}}}return rp++,i.then(Cx,Cx),i}function Cx(){if(--rp===0&&Sl!==null){Xi!==null&&(Xi.status="fulfilled");var r=Sl;Sl=null,Ki=0,Xi=null;for(var i=0;i<r.length;i++)(0,r[i])()}}function e2(r,i){var c=[],f={status:"pending",value:null,reason:null,then:function(v){c.push(v)}};return r.then(function(){f.status="fulfilled",f.value=i;for(var v=0;v<c.length;v++)(0,c[v])(i)},function(v){for(f.status="rejected",f.reason=v,v=0;v<c.length;v++)(0,c[v])(void 0)}),f}var Tx=$.S;$.S=function(r,i){dw=Ne(),typeof i=="object"&&i!==null&&typeof i.then=="function"&&Q_(r,i),Tx!==null&&Tx(r,i)};var Ya=I(null);function ap(){var r=Ya.current;return r!==null?r:Ct.pooledCache}function Su(r,i){i===null?Y(Ya,Ya.current):Y(Ya,i.pool)}function Ax(){var r=ap();return r===null?null:{parent:sn._currentValue,pool:r}}var Ji=Error(s(460)),ip=Error(s(474)),Nu=Error(s(542)),ku={then:function(){}};function Rx(r){return r=r.status,r==="fulfilled"||r==="rejected"}function Mx(r,i,c){switch(c=r[c],c===void 0?r.push(i):c!==i&&(i.then(pr,pr),i=c),i.status){case"fulfilled":return i.value;case"rejected":throw r=i.reason,Ox(r),r;default:if(typeof i.status=="string")i.then(pr,pr);else{if(r=Ct,r!==null&&100<r.shellSuspendCounter)throw Error(s(482));r=i,r.status="pending",r.then(function(f){if(i.status==="pending"){var v=i;v.status="fulfilled",v.value=f}},function(f){if(i.status==="pending"){var v=i;v.status="rejected",v.reason=f}})}switch(i.status){case"fulfilled":return i.value;case"rejected":throw r=i.reason,Ox(r),r}throw Ka=i,Ji}}function Ga(r){try{var i=r._init;return i(r._payload)}catch(c){throw c!==null&&typeof c=="object"&&typeof c.then=="function"?(Ka=c,Ji):c}}var Ka=null;function _x(){if(Ka===null)throw Error(s(459));var r=Ka;return Ka=null,r}function Ox(r){if(r===Ji||r===Nu)throw Error(s(483))}var Qi=null,Nl=0;function Eu(r){var i=Nl;return Nl+=1,Qi===null&&(Qi=[]),Mx(Qi,r,i)}function kl(r,i){i=i.props.ref,r.ref=i!==void 0?i:null}function Cu(r,i){throw i.$$typeof===x?Error(s(525)):(r=Object.prototype.toString.call(i),Error(s(31,r==="[object Object]"?"object with keys {"+Object.keys(i).join(", ")+"}":r)))}function Ix(r){function i(J,K){if(r){var te=J.deletions;te===null?(J.deletions=[K],J.flags|=16):te.push(K)}}function c(J,K){if(!r)return null;for(;K!==null;)i(J,K),K=K.sibling;return null}function f(J){for(var K=new Map;J!==null;)J.key!==null?K.set(J.key,J):K.set(J.index,J),J=J.sibling;return K}function v(J,K){return J=gr(J,K),J.index=0,J.sibling=null,J}function b(J,K,te){return J.index=te,r?(te=J.alternate,te!==null?(te=te.index,te<K?(J.flags|=67108866,K):te):(J.flags|=67108866,K)):(J.flags|=1048576,K)}function T(J){return r&&J.alternate===null&&(J.flags|=67108866),J}function P(J,K,te,fe){return K===null||K.tag!==6?(K=Yh(te,J.mode,fe),K.return=J,K):(K=v(K,te),K.return=J,K)}function Z(J,K,te,fe){var Le=te.type;return Le===N?le(J,K,te.props.children,fe,te.key):K!==null&&(K.elementType===Le||typeof Le=="object"&&Le!==null&&Le.$$typeof===z&&Ga(Le)===K.type)?(K=v(K,te.props),kl(K,te),K.return=J,K):(K=bu(te.type,te.key,te.props,null,J.mode,fe),kl(K,te),K.return=J,K)}function ne(J,K,te,fe){return K===null||K.tag!==4||K.stateNode.containerInfo!==te.containerInfo||K.stateNode.implementation!==te.implementation?(K=Gh(te,J.mode,fe),K.return=J,K):(K=v(K,te.children||[]),K.return=J,K)}function le(J,K,te,fe,Le){return K===null||K.tag!==7?(K=Ha(te,J.mode,fe,Le),K.return=J,K):(K=v(K,te),K.return=J,K)}function pe(J,K,te){if(typeof K=="string"&&K!==""||typeof K=="number"||typeof K=="bigint")return K=Yh(""+K,J.mode,te),K.return=J,K;if(typeof K=="object"&&K!==null){switch(K.$$typeof){case w:return te=bu(K.type,K.key,K.props,null,J.mode,te),kl(te,K),te.return=J,te;case j:return K=Gh(K,J.mode,te),K.return=J,K;case z:return K=Ga(K),pe(J,K,te)}if(q(K)||D(K))return K=Ha(K,J.mode,te,null),K.return=J,K;if(typeof K.then=="function")return pe(J,Eu(K),te);if(K.$$typeof===S)return pe(J,ju(J,K),te);Cu(J,K)}return null}function se(J,K,te,fe){var Le=K!==null?K.key:null;if(typeof te=="string"&&te!==""||typeof te=="number"||typeof te=="bigint")return Le!==null?null:P(J,K,""+te,fe);if(typeof te=="object"&&te!==null){switch(te.$$typeof){case w:return te.key===Le?Z(J,K,te,fe):null;case j:return te.key===Le?ne(J,K,te,fe):null;case z:return te=Ga(te),se(J,K,te,fe)}if(q(te)||D(te))return Le!==null?null:le(J,K,te,fe,null);if(typeof te.then=="function")return se(J,K,Eu(te),fe);if(te.$$typeof===S)return se(J,K,ju(J,te),fe);Cu(J,te)}return null}function ae(J,K,te,fe,Le){if(typeof fe=="string"&&fe!==""||typeof fe=="number"||typeof fe=="bigint")return J=J.get(te)||null,P(K,J,""+fe,Le);if(typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case w:return J=J.get(fe.key===null?te:fe.key)||null,Z(K,J,fe,Le);case j:return J=J.get(fe.key===null?te:fe.key)||null,ne(K,J,fe,Le);case z:return fe=Ga(fe),ae(J,K,te,fe,Le)}if(q(fe)||D(fe))return J=J.get(te)||null,le(K,J,fe,Le,null);if(typeof fe.then=="function")return ae(J,K,te,Eu(fe),Le);if(fe.$$typeof===S)return ae(J,K,te,ju(K,fe),Le);Cu(K,fe)}return null}function Me(J,K,te,fe){for(var Le=null,ft=null,Oe=K,Qe=K=0,ot=null;Oe!==null&&Qe<te.length;Qe++){Oe.index>Qe?(ot=Oe,Oe=null):ot=Oe.sibling;var ht=se(J,Oe,te[Qe],fe);if(ht===null){Oe===null&&(Oe=ot);break}r&&Oe&&ht.alternate===null&&i(J,Oe),K=b(ht,K,Qe),ft===null?Le=ht:ft.sibling=ht,ft=ht,Oe=ot}if(Qe===te.length)return c(J,Oe),ct&&vr(J,Qe),Le;if(Oe===null){for(;Qe<te.length;Qe++)Oe=pe(J,te[Qe],fe),Oe!==null&&(K=b(Oe,K,Qe),ft===null?Le=Oe:ft.sibling=Oe,ft=Oe);return ct&&vr(J,Qe),Le}for(Oe=f(Oe);Qe<te.length;Qe++)ot=ae(Oe,J,Qe,te[Qe],fe),ot!==null&&(r&&ot.alternate!==null&&Oe.delete(ot.key===null?Qe:ot.key),K=b(ot,K,Qe),ft===null?Le=ot:ft.sibling=ot,ft=ot);return r&&Oe.forEach(function(ca){return i(J,ca)}),ct&&vr(J,Qe),Le}function Fe(J,K,te,fe){if(te==null)throw Error(s(151));for(var Le=null,ft=null,Oe=K,Qe=K=0,ot=null,ht=te.next();Oe!==null&&!ht.done;Qe++,ht=te.next()){Oe.index>Qe?(ot=Oe,Oe=null):ot=Oe.sibling;var ca=se(J,Oe,ht.value,fe);if(ca===null){Oe===null&&(Oe=ot);break}r&&Oe&&ca.alternate===null&&i(J,Oe),K=b(ca,K,Qe),ft===null?Le=ca:ft.sibling=ca,ft=ca,Oe=ot}if(ht.done)return c(J,Oe),ct&&vr(J,Qe),Le;if(Oe===null){for(;!ht.done;Qe++,ht=te.next())ht=pe(J,ht.value,fe),ht!==null&&(K=b(ht,K,Qe),ft===null?Le=ht:ft.sibling=ht,ft=ht);return ct&&vr(J,Qe),Le}for(Oe=f(Oe);!ht.done;Qe++,ht=te.next())ht=ae(Oe,J,Qe,ht.value,fe),ht!==null&&(r&&ht.alternate!==null&&Oe.delete(ht.key===null?Qe:ht.key),K=b(ht,K,Qe),ft===null?Le=ht:ft.sibling=ht,ft=ht);return r&&Oe.forEach(function(dO){return i(J,dO)}),ct&&vr(J,Qe),Le}function St(J,K,te,fe){if(typeof te=="object"&&te!==null&&te.type===N&&te.key===null&&(te=te.props.children),typeof te=="object"&&te!==null){switch(te.$$typeof){case w:e:{for(var Le=te.key;K!==null;){if(K.key===Le){if(Le=te.type,Le===N){if(K.tag===7){c(J,K.sibling),fe=v(K,te.props.children),fe.return=J,J=fe;break e}}else if(K.elementType===Le||typeof Le=="object"&&Le!==null&&Le.$$typeof===z&&Ga(Le)===K.type){c(J,K.sibling),fe=v(K,te.props),kl(fe,te),fe.return=J,J=fe;break e}c(J,K);break}else i(J,K);K=K.sibling}te.type===N?(fe=Ha(te.props.children,J.mode,fe,te.key),fe.return=J,J=fe):(fe=bu(te.type,te.key,te.props,null,J.mode,fe),kl(fe,te),fe.return=J,J=fe)}return T(J);case j:e:{for(Le=te.key;K!==null;){if(K.key===Le)if(K.tag===4&&K.stateNode.containerInfo===te.containerInfo&&K.stateNode.implementation===te.implementation){c(J,K.sibling),fe=v(K,te.children||[]),fe.return=J,J=fe;break e}else{c(J,K);break}else i(J,K);K=K.sibling}fe=Gh(te,J.mode,fe),fe.return=J,J=fe}return T(J);case z:return te=Ga(te),St(J,K,te,fe)}if(q(te))return Me(J,K,te,fe);if(D(te)){if(Le=D(te),typeof Le!="function")throw Error(s(150));return te=Le.call(te),Fe(J,K,te,fe)}if(typeof te.then=="function")return St(J,K,Eu(te),fe);if(te.$$typeof===S)return St(J,K,ju(J,te),fe);Cu(J,te)}return typeof te=="string"&&te!==""||typeof te=="number"||typeof te=="bigint"?(te=""+te,K!==null&&K.tag===6?(c(J,K.sibling),fe=v(K,te),fe.return=J,J=fe):(c(J,K),fe=Yh(te,J.mode,fe),fe.return=J,J=fe),T(J)):c(J,K)}return function(J,K,te,fe){try{Nl=0;var Le=St(J,K,te,fe);return Qi=null,Le}catch(Oe){if(Oe===Ji||Oe===Nu)throw Oe;var ft=ss(29,Oe,null,J.mode);return ft.lanes=fe,ft.return=J,ft}}}var Xa=Ix(!0),Dx=Ix(!1),Zr=!1;function op(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function lp(r,i){r=r.updateQueue,i.updateQueue===r&&(i.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,callbacks:null})}function Wr(r){return{lane:r,tag:0,payload:null,callback:null,next:null}}function Yr(r,i,c){var f=r.updateQueue;if(f===null)return null;if(f=f.shared,(pt&2)!==0){var v=f.pending;return v===null?i.next=i:(i.next=v.next,v.next=i),f.pending=i,i=yu(r),yx(r,null,c),i}return vu(r,f,i,c),yu(r)}function El(r,i,c){if(i=i.updateQueue,i!==null&&(i=i.shared,(c&4194048)!==0)){var f=i.lanes;f&=r.pendingLanes,c|=f,i.lanes=c,dt(r,c)}}function cp(r,i){var c=r.updateQueue,f=r.alternate;if(f!==null&&(f=f.updateQueue,c===f)){var v=null,b=null;if(c=c.firstBaseUpdate,c!==null){do{var T={lane:c.lane,tag:c.tag,payload:c.payload,callback:null,next:null};b===null?v=b=T:b=b.next=T,c=c.next}while(c!==null);b===null?v=b=i:b=b.next=i}else v=b=i;c={baseState:f.baseState,firstBaseUpdate:v,lastBaseUpdate:b,shared:f.shared,callbacks:f.callbacks},r.updateQueue=c;return}r=c.lastBaseUpdate,r===null?c.firstBaseUpdate=i:r.next=i,c.lastBaseUpdate=i}var up=!1;function Cl(){if(up){var r=Xi;if(r!==null)throw r}}function Tl(r,i,c,f){up=!1;var v=r.updateQueue;Zr=!1;var b=v.firstBaseUpdate,T=v.lastBaseUpdate,P=v.shared.pending;if(P!==null){v.shared.pending=null;var Z=P,ne=Z.next;Z.next=null,T===null?b=ne:T.next=ne,T=Z;var le=r.alternate;le!==null&&(le=le.updateQueue,P=le.lastBaseUpdate,P!==T&&(P===null?le.firstBaseUpdate=ne:P.next=ne,le.lastBaseUpdate=Z))}if(b!==null){var pe=v.baseState;T=0,le=ne=Z=null,P=b;do{var se=P.lane&-536870913,ae=se!==P.lane;if(ae?(it&se)===se:(f&se)===se){se!==0&&se===Ki&&(up=!0),le!==null&&(le=le.next={lane:0,tag:P.tag,payload:P.payload,callback:null,next:null});e:{var Me=r,Fe=P;se=i;var St=c;switch(Fe.tag){case 1:if(Me=Fe.payload,typeof Me=="function"){pe=Me.call(St,pe,se);break e}pe=Me;break e;case 3:Me.flags=Me.flags&-65537|128;case 0:if(Me=Fe.payload,se=typeof Me=="function"?Me.call(St,pe,se):Me,se==null)break e;pe=y({},pe,se);break e;case 2:Zr=!0}}se=P.callback,se!==null&&(r.flags|=64,ae&&(r.flags|=8192),ae=v.callbacks,ae===null?v.callbacks=[se]:ae.push(se))}else ae={lane:se,tag:P.tag,payload:P.payload,callback:P.callback,next:null},le===null?(ne=le=ae,Z=pe):le=le.next=ae,T|=se;if(P=P.next,P===null){if(P=v.shared.pending,P===null)break;ae=P,P=ae.next,ae.next=null,v.lastBaseUpdate=ae,v.shared.pending=null}}while(!0);le===null&&(Z=pe),v.baseState=Z,v.firstBaseUpdate=ne,v.lastBaseUpdate=le,b===null&&(v.shared.lanes=0),Qr|=T,r.lanes=T,r.memoizedState=pe}}function Px(r,i){if(typeof r!="function")throw Error(s(191,r));r.call(i)}function zx(r,i){var c=r.callbacks;if(c!==null)for(r.callbacks=null,r=0;r<c.length;r++)Px(c[r],i)}var eo=I(null),Tu=I(0);function Lx(r,i){r=Tr,Y(Tu,r),Y(eo,i),Tr=r|i.baseLanes}function dp(){Y(Tu,Tr),Y(eo,eo.current)}function fp(){Tr=Tu.current,B(eo),B(Tu)}var rs=I(null),ws=null;function Gr(r){var i=r.alternate;Y(Qt,Qt.current&1),Y(rs,r),ws===null&&(i===null||eo.current!==null||i.memoizedState!==null)&&(ws=r)}function hp(r){Y(Qt,Qt.current),Y(rs,r),ws===null&&(ws=r)}function $x(r){r.tag===22?(Y(Qt,Qt.current),Y(rs,r),ws===null&&(ws=r)):Kr()}function Kr(){Y(Qt,Qt.current),Y(rs,rs.current)}function as(r){B(rs),ws===r&&(ws=null),B(Qt)}var Qt=I(0);function Au(r){for(var i=r;i!==null;){if(i.tag===13){var c=i.memoizedState;if(c!==null&&(c=c.dehydrated,c===null||bm(c)||xm(c)))return i}else if(i.tag===19&&(i.memoizedProps.revealOrder==="forwards"||i.memoizedProps.revealOrder==="backwards"||i.memoizedProps.revealOrder==="unstable_legacy-backwards"||i.memoizedProps.revealOrder==="together")){if((i.flags&128)!==0)return i}else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break;for(;i.sibling===null;){if(i.return===null||i.return===r)return null;i=i.return}i.sibling.return=i.return,i=i.sibling}return null}var xr=0,Je=null,wt=null,rn=null,Ru=!1,to=!1,Ja=!1,Mu=0,Al=0,no=null,t2=0;function Yt(){throw Error(s(321))}function pp(r,i){if(i===null)return!1;for(var c=0;c<i.length&&c<r.length;c++)if(!ns(r[c],i[c]))return!1;return!0}function mp(r,i,c,f,v,b){return xr=b,Je=i,i.memoizedState=null,i.updateQueue=null,i.lanes=0,$.H=r===null||r.memoizedState===null?j0:Rp,Ja=!1,b=c(f,v),Ja=!1,to&&(b=Bx(i,c,f,v)),Ux(r),b}function Ux(r){$.H=_l;var i=wt!==null&&wt.next!==null;if(xr=0,rn=wt=Je=null,Ru=!1,Al=0,no=null,i)throw Error(s(300));r===null||an||(r=r.dependencies,r!==null&&wu(r)&&(an=!0))}function Bx(r,i,c,f){Je=r;var v=0;do{if(to&&(no=null),Al=0,to=!1,25<=v)throw Error(s(301));if(v+=1,rn=wt=null,r.updateQueue!=null){var b=r.updateQueue;b.lastEffect=null,b.events=null,b.stores=null,b.memoCache!=null&&(b.memoCache.index=0)}$.H=S0,b=i(c,f)}while(to);return b}function n2(){var r=$.H,i=r.useState()[0];return i=typeof i.then=="function"?Rl(i):i,r=r.useState()[0],(wt!==null?wt.memoizedState:null)!==r&&(Je.flags|=1024),i}function gp(){var r=Mu!==0;return Mu=0,r}function vp(r,i,c){i.updateQueue=r.updateQueue,i.flags&=-2053,r.lanes&=~c}function yp(r){if(Ru){for(r=r.memoizedState;r!==null;){var i=r.queue;i!==null&&(i.pending=null),r=r.next}Ru=!1}xr=0,rn=wt=Je=null,to=!1,Al=Mu=0,no=null}function zn(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return rn===null?Je.memoizedState=rn=r:rn=rn.next=r,rn}function en(){if(wt===null){var r=Je.alternate;r=r!==null?r.memoizedState:null}else r=wt.next;var i=rn===null?Je.memoizedState:rn.next;if(i!==null)rn=i,wt=r;else{if(r===null)throw Je.alternate===null?Error(s(467)):Error(s(310));wt=r,r={memoizedState:wt.memoizedState,baseState:wt.baseState,baseQueue:wt.baseQueue,queue:wt.queue,next:null},rn===null?Je.memoizedState=rn=r:rn=rn.next=r}return rn}function _u(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Rl(r){var i=Al;return Al+=1,no===null&&(no=[]),r=Mx(no,r,i),i=Je,(rn===null?i.memoizedState:rn.next)===null&&(i=i.alternate,$.H=i===null||i.memoizedState===null?j0:Rp),r}function Ou(r){if(r!==null&&typeof r=="object"){if(typeof r.then=="function")return Rl(r);if(r.$$typeof===S)return Sn(r)}throw Error(s(438,String(r)))}function bp(r){var i=null,c=Je.updateQueue;if(c!==null&&(i=c.memoCache),i==null){var f=Je.alternate;f!==null&&(f=f.updateQueue,f!==null&&(f=f.memoCache,f!=null&&(i={data:f.data.map(function(v){return v.slice()}),index:0})))}if(i==null&&(i={data:[],index:0}),c===null&&(c=_u(),Je.updateQueue=c),c.memoCache=i,c=i.data[i.index],c===void 0)for(c=i.data[i.index]=Array(r),f=0;f<r;f++)c[f]=U;return i.index++,c}function wr(r,i){return typeof i=="function"?i(r):i}function Iu(r){var i=en();return xp(i,wt,r)}function xp(r,i,c){var f=r.queue;if(f===null)throw Error(s(311));f.lastRenderedReducer=c;var v=r.baseQueue,b=f.pending;if(b!==null){if(v!==null){var T=v.next;v.next=b.next,b.next=T}i.baseQueue=v=b,f.pending=null}if(b=r.baseState,v===null)r.memoizedState=b;else{i=v.next;var P=T=null,Z=null,ne=i,le=!1;do{var pe=ne.lane&-536870913;if(pe!==ne.lane?(it&pe)===pe:(xr&pe)===pe){var se=ne.revertLane;if(se===0)Z!==null&&(Z=Z.next={lane:0,revertLane:0,gesture:null,action:ne.action,hasEagerState:ne.hasEagerState,eagerState:ne.eagerState,next:null}),pe===Ki&&(le=!0);else if((xr&se)===se){ne=ne.next,se===Ki&&(le=!0);continue}else pe={lane:0,revertLane:ne.revertLane,gesture:null,action:ne.action,hasEagerState:ne.hasEagerState,eagerState:ne.eagerState,next:null},Z===null?(P=Z=pe,T=b):Z=Z.next=pe,Je.lanes|=se,Qr|=se;pe=ne.action,Ja&&c(b,pe),b=ne.hasEagerState?ne.eagerState:c(b,pe)}else se={lane:pe,revertLane:ne.revertLane,gesture:ne.gesture,action:ne.action,hasEagerState:ne.hasEagerState,eagerState:ne.eagerState,next:null},Z===null?(P=Z=se,T=b):Z=Z.next=se,Je.lanes|=pe,Qr|=pe;ne=ne.next}while(ne!==null&&ne!==i);if(Z===null?T=b:Z.next=P,!ns(b,r.memoizedState)&&(an=!0,le&&(c=Xi,c!==null)))throw c;r.memoizedState=b,r.baseState=T,r.baseQueue=Z,f.lastRenderedState=b}return v===null&&(f.lanes=0),[r.memoizedState,f.dispatch]}function wp(r){var i=en(),c=i.queue;if(c===null)throw Error(s(311));c.lastRenderedReducer=r;var f=c.dispatch,v=c.pending,b=i.memoizedState;if(v!==null){c.pending=null;var T=v=v.next;do b=r(b,T.action),T=T.next;while(T!==v);ns(b,i.memoizedState)||(an=!0),i.memoizedState=b,i.baseQueue===null&&(i.baseState=b),c.lastRenderedState=b}return[b,f]}function Vx(r,i,c){var f=Je,v=en(),b=ct;if(b){if(c===void 0)throw Error(s(407));c=c()}else c=i();var T=!ns((wt||v).memoizedState,c);if(T&&(v.memoizedState=c,an=!0),v=v.queue,Np(qx.bind(null,f,v,r),[r]),v.getSnapshot!==i||T||rn!==null&&rn.memoizedState.tag&1){if(f.flags|=2048,so(9,{destroy:void 0},Hx.bind(null,f,v,c,i),null),Ct===null)throw Error(s(349));b||(xr&127)!==0||Fx(f,i,c)}return c}function Fx(r,i,c){r.flags|=16384,r={getSnapshot:i,value:c},i=Je.updateQueue,i===null?(i=_u(),Je.updateQueue=i,i.stores=[r]):(c=i.stores,c===null?i.stores=[r]:c.push(r))}function Hx(r,i,c,f){i.value=c,i.getSnapshot=f,Zx(i)&&Wx(r)}function qx(r,i,c){return c(function(){Zx(i)&&Wx(r)})}function Zx(r){var i=r.getSnapshot;r=r.value;try{var c=i();return!ns(r,c)}catch{return!0}}function Wx(r){var i=Fa(r,2);i!==null&&Kn(i,r,2)}function jp(r){var i=zn();if(typeof r=="function"){var c=r;if(r=c(),Ja){at(!0);try{c()}finally{at(!1)}}}return i.memoizedState=i.baseState=r,i.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:wr,lastRenderedState:r},i}function Yx(r,i,c,f){return r.baseState=c,xp(r,wt,typeof f=="function"?f:wr)}function s2(r,i,c,f,v){if(zu(r))throw Error(s(485));if(r=i.action,r!==null){var b={payload:v,action:r,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(T){b.listeners.push(T)}};$.T!==null?c(!0):b.isTransition=!1,f(b),c=i.pending,c===null?(b.next=i.pending=b,Gx(i,b)):(b.next=c.next,i.pending=c.next=b)}}function Gx(r,i){var c=i.action,f=i.payload,v=r.state;if(i.isTransition){var b=$.T,T={};$.T=T;try{var P=c(v,f),Z=$.S;Z!==null&&Z(T,P),Kx(r,i,P)}catch(ne){Sp(r,i,ne)}finally{b!==null&&T.types!==null&&(b.types=T.types),$.T=b}}else try{b=c(v,f),Kx(r,i,b)}catch(ne){Sp(r,i,ne)}}function Kx(r,i,c){c!==null&&typeof c=="object"&&typeof c.then=="function"?c.then(function(f){Xx(r,i,f)},function(f){return Sp(r,i,f)}):Xx(r,i,c)}function Xx(r,i,c){i.status="fulfilled",i.value=c,Jx(i),r.state=c,i=r.pending,i!==null&&(c=i.next,c===i?r.pending=null:(c=c.next,i.next=c,Gx(r,c)))}function Sp(r,i,c){var f=r.pending;if(r.pending=null,f!==null){f=f.next;do i.status="rejected",i.reason=c,Jx(i),i=i.next;while(i!==f)}r.action=null}function Jx(r){r=r.listeners;for(var i=0;i<r.length;i++)(0,r[i])()}function Qx(r,i){return i}function e0(r,i){if(ct){var c=Ct.formState;if(c!==null){e:{var f=Je;if(ct){if(Mt){t:{for(var v=Mt,b=xs;v.nodeType!==8;){if(!b){v=null;break t}if(v=js(v.nextSibling),v===null){v=null;break t}}b=v.data,v=b==="F!"||b==="F"?v:null}if(v){Mt=js(v.nextSibling),f=v.data==="F!";break e}}Hr(f)}f=!1}f&&(i=c[0])}}return c=zn(),c.memoizedState=c.baseState=i,f={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Qx,lastRenderedState:i},c.queue=f,c=b0.bind(null,Je,f),f.dispatch=c,f=jp(!1),b=Ap.bind(null,Je,!1,f.queue),f=zn(),v={state:i,dispatch:null,action:r,pending:null},f.queue=v,c=s2.bind(null,Je,v,b,c),v.dispatch=c,f.memoizedState=r,[i,c,!1]}function t0(r){var i=en();return n0(i,wt,r)}function n0(r,i,c){if(i=xp(r,i,Qx)[0],r=Iu(wr)[0],typeof i=="object"&&i!==null&&typeof i.then=="function")try{var f=Rl(i)}catch(T){throw T===Ji?Nu:T}else f=i;i=en();var v=i.queue,b=v.dispatch;return c!==i.memoizedState&&(Je.flags|=2048,so(9,{destroy:void 0},r2.bind(null,v,c),null)),[f,b,r]}function r2(r,i){r.action=i}function s0(r){var i=en(),c=wt;if(c!==null)return n0(i,c,r);en(),i=i.memoizedState,c=en();var f=c.queue.dispatch;return c.memoizedState=r,[i,f,!1]}function so(r,i,c,f){return r={tag:r,create:c,deps:f,inst:i,next:null},i=Je.updateQueue,i===null&&(i=_u(),Je.updateQueue=i),c=i.lastEffect,c===null?i.lastEffect=r.next=r:(f=c.next,c.next=r,r.next=f,i.lastEffect=r),r}function r0(){return en().memoizedState}function Du(r,i,c,f){var v=zn();Je.flags|=r,v.memoizedState=so(1|i,{destroy:void 0},c,f===void 0?null:f)}function Pu(r,i,c,f){var v=en();f=f===void 0?null:f;var b=v.memoizedState.inst;wt!==null&&f!==null&&pp(f,wt.memoizedState.deps)?v.memoizedState=so(i,b,c,f):(Je.flags|=r,v.memoizedState=so(1|i,b,c,f))}function a0(r,i){Du(8390656,8,r,i)}function Np(r,i){Pu(2048,8,r,i)}function a2(r){Je.flags|=4;var i=Je.updateQueue;if(i===null)i=_u(),Je.updateQueue=i,i.events=[r];else{var c=i.events;c===null?i.events=[r]:c.push(r)}}function i0(r){var i=en().memoizedState;return a2({ref:i,nextImpl:r}),function(){if((pt&2)!==0)throw Error(s(440));return i.impl.apply(void 0,arguments)}}function o0(r,i){return Pu(4,2,r,i)}function l0(r,i){return Pu(4,4,r,i)}function c0(r,i){if(typeof i=="function"){r=r();var c=i(r);return function(){typeof c=="function"?c():i(null)}}if(i!=null)return r=r(),i.current=r,function(){i.current=null}}function u0(r,i,c){c=c!=null?c.concat([r]):null,Pu(4,4,c0.bind(null,i,r),c)}function kp(){}function d0(r,i){var c=en();i=i===void 0?null:i;var f=c.memoizedState;return i!==null&&pp(i,f[1])?f[0]:(c.memoizedState=[r,i],r)}function f0(r,i){var c=en();i=i===void 0?null:i;var f=c.memoizedState;if(i!==null&&pp(i,f[1]))return f[0];if(f=r(),Ja){at(!0);try{r()}finally{at(!1)}}return c.memoizedState=[f,i],f}function Ep(r,i,c){return c===void 0||(xr&1073741824)!==0&&(it&261930)===0?r.memoizedState=i:(r.memoizedState=c,r=hw(),Je.lanes|=r,Qr|=r,c)}function h0(r,i,c,f){return ns(c,i)?c:eo.current!==null?(r=Ep(r,c,f),ns(r,i)||(an=!0),r):(xr&42)===0||(xr&1073741824)!==0&&(it&261930)===0?(an=!0,r.memoizedState=c):(r=hw(),Je.lanes|=r,Qr|=r,i)}function p0(r,i,c,f,v){var b=L.p;L.p=b!==0&&8>b?b:8;var T=$.T,P={};$.T=P,Ap(r,!1,i,c);try{var Z=v(),ne=$.S;if(ne!==null&&ne(P,Z),Z!==null&&typeof Z=="object"&&typeof Z.then=="function"){var le=e2(Z,f);Ml(r,i,le,ls(r))}else Ml(r,i,f,ls(r))}catch(pe){Ml(r,i,{then:function(){},status:"rejected",reason:pe},ls())}finally{L.p=b,T!==null&&P.types!==null&&(T.types=P.types),$.T=T}}function i2(){}function Cp(r,i,c,f){if(r.tag!==5)throw Error(s(476));var v=m0(r).queue;p0(r,v,i,F,c===null?i2:function(){return g0(r),c(f)})}function m0(r){var i=r.memoizedState;if(i!==null)return i;i={memoizedState:F,baseState:F,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:wr,lastRenderedState:F},next:null};var c={};return i.next={memoizedState:c,baseState:c,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:wr,lastRenderedState:c},next:null},r.memoizedState=i,r=r.alternate,r!==null&&(r.memoizedState=i),i}function g0(r){var i=m0(r);i.next===null&&(i=r.alternate.memoizedState),Ml(r,i.next.queue,{},ls())}function Tp(){return Sn(Yl)}function v0(){return en().memoizedState}function y0(){return en().memoizedState}function o2(r){for(var i=r.return;i!==null;){switch(i.tag){case 24:case 3:var c=ls();r=Wr(c);var f=Yr(i,r,c);f!==null&&(Kn(f,i,c),El(f,i,c)),i={cache:sp()},r.payload=i;return}i=i.return}}function l2(r,i,c){var f=ls();c={lane:f,revertLane:0,gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},zu(r)?x0(i,c):(c=Zh(r,i,c,f),c!==null&&(Kn(c,r,f),w0(c,i,f)))}function b0(r,i,c){var f=ls();Ml(r,i,c,f)}function Ml(r,i,c,f){var v={lane:f,revertLane:0,gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null};if(zu(r))x0(i,v);else{var b=r.alternate;if(r.lanes===0&&(b===null||b.lanes===0)&&(b=i.lastRenderedReducer,b!==null))try{var T=i.lastRenderedState,P=b(T,c);if(v.hasEagerState=!0,v.eagerState=P,ns(P,T))return vu(r,i,v,0),Ct===null&&gu(),!1}catch{}if(c=Zh(r,i,v,f),c!==null)return Kn(c,r,f),w0(c,i,f),!0}return!1}function Ap(r,i,c,f){if(f={lane:2,revertLane:om(),gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null},zu(r)){if(i)throw Error(s(479))}else i=Zh(r,c,f,2),i!==null&&Kn(i,r,2)}function zu(r){var i=r.alternate;return r===Je||i!==null&&i===Je}function x0(r,i){to=Ru=!0;var c=r.pending;c===null?i.next=i:(i.next=c.next,c.next=i),r.pending=i}function w0(r,i,c){if((c&4194048)!==0){var f=i.lanes;f&=r.pendingLanes,c|=f,i.lanes=c,dt(r,c)}}var _l={readContext:Sn,use:Ou,useCallback:Yt,useContext:Yt,useEffect:Yt,useImperativeHandle:Yt,useLayoutEffect:Yt,useInsertionEffect:Yt,useMemo:Yt,useReducer:Yt,useRef:Yt,useState:Yt,useDebugValue:Yt,useDeferredValue:Yt,useTransition:Yt,useSyncExternalStore:Yt,useId:Yt,useHostTransitionStatus:Yt,useFormState:Yt,useActionState:Yt,useOptimistic:Yt,useMemoCache:Yt,useCacheRefresh:Yt};_l.useEffectEvent=Yt;var j0={readContext:Sn,use:Ou,useCallback:function(r,i){return zn().memoizedState=[r,i===void 0?null:i],r},useContext:Sn,useEffect:a0,useImperativeHandle:function(r,i,c){c=c!=null?c.concat([r]):null,Du(4194308,4,c0.bind(null,i,r),c)},useLayoutEffect:function(r,i){return Du(4194308,4,r,i)},useInsertionEffect:function(r,i){Du(4,2,r,i)},useMemo:function(r,i){var c=zn();i=i===void 0?null:i;var f=r();if(Ja){at(!0);try{r()}finally{at(!1)}}return c.memoizedState=[f,i],f},useReducer:function(r,i,c){var f=zn();if(c!==void 0){var v=c(i);if(Ja){at(!0);try{c(i)}finally{at(!1)}}}else v=i;return f.memoizedState=f.baseState=v,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:v},f.queue=r,r=r.dispatch=l2.bind(null,Je,r),[f.memoizedState,r]},useRef:function(r){var i=zn();return r={current:r},i.memoizedState=r},useState:function(r){r=jp(r);var i=r.queue,c=b0.bind(null,Je,i);return i.dispatch=c,[r.memoizedState,c]},useDebugValue:kp,useDeferredValue:function(r,i){var c=zn();return Ep(c,r,i)},useTransition:function(){var r=jp(!1);return r=p0.bind(null,Je,r.queue,!0,!1),zn().memoizedState=r,[!1,r]},useSyncExternalStore:function(r,i,c){var f=Je,v=zn();if(ct){if(c===void 0)throw Error(s(407));c=c()}else{if(c=i(),Ct===null)throw Error(s(349));(it&127)!==0||Fx(f,i,c)}v.memoizedState=c;var b={value:c,getSnapshot:i};return v.queue=b,a0(qx.bind(null,f,b,r),[r]),f.flags|=2048,so(9,{destroy:void 0},Hx.bind(null,f,b,c,i),null),c},useId:function(){var r=zn(),i=Ct.identifierPrefix;if(ct){var c=Gs,f=Ys;c=(f&~(1<<32-lt(f)-1)).toString(32)+c,i="_"+i+"R_"+c,c=Mu++,0<c&&(i+="H"+c.toString(32)),i+="_"}else c=t2++,i="_"+i+"r_"+c.toString(32)+"_";return r.memoizedState=i},useHostTransitionStatus:Tp,useFormState:e0,useActionState:e0,useOptimistic:function(r){var i=zn();i.memoizedState=i.baseState=r;var c={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return i.queue=c,i=Ap.bind(null,Je,!0,c),c.dispatch=i,[r,i]},useMemoCache:bp,useCacheRefresh:function(){return zn().memoizedState=o2.bind(null,Je)},useEffectEvent:function(r){var i=zn(),c={impl:r};return i.memoizedState=c,function(){if((pt&2)!==0)throw Error(s(440));return c.impl.apply(void 0,arguments)}}},Rp={readContext:Sn,use:Ou,useCallback:d0,useContext:Sn,useEffect:Np,useImperativeHandle:u0,useInsertionEffect:o0,useLayoutEffect:l0,useMemo:f0,useReducer:Iu,useRef:r0,useState:function(){return Iu(wr)},useDebugValue:kp,useDeferredValue:function(r,i){var c=en();return h0(c,wt.memoizedState,r,i)},useTransition:function(){var r=Iu(wr)[0],i=en().memoizedState;return[typeof r=="boolean"?r:Rl(r),i]},useSyncExternalStore:Vx,useId:v0,useHostTransitionStatus:Tp,useFormState:t0,useActionState:t0,useOptimistic:function(r,i){var c=en();return Yx(c,wt,r,i)},useMemoCache:bp,useCacheRefresh:y0};Rp.useEffectEvent=i0;var S0={readContext:Sn,use:Ou,useCallback:d0,useContext:Sn,useEffect:Np,useImperativeHandle:u0,useInsertionEffect:o0,useLayoutEffect:l0,useMemo:f0,useReducer:wp,useRef:r0,useState:function(){return wp(wr)},useDebugValue:kp,useDeferredValue:function(r,i){var c=en();return wt===null?Ep(c,r,i):h0(c,wt.memoizedState,r,i)},useTransition:function(){var r=wp(wr)[0],i=en().memoizedState;return[typeof r=="boolean"?r:Rl(r),i]},useSyncExternalStore:Vx,useId:v0,useHostTransitionStatus:Tp,useFormState:s0,useActionState:s0,useOptimistic:function(r,i){var c=en();return wt!==null?Yx(c,wt,r,i):(c.baseState=r,[r,c.queue.dispatch])},useMemoCache:bp,useCacheRefresh:y0};S0.useEffectEvent=i0;function Mp(r,i,c,f){i=r.memoizedState,c=c(f,i),c=c==null?i:y({},i,c),r.memoizedState=c,r.lanes===0&&(r.updateQueue.baseState=c)}var _p={enqueueSetState:function(r,i,c){r=r._reactInternals;var f=ls(),v=Wr(f);v.payload=i,c!=null&&(v.callback=c),i=Yr(r,v,f),i!==null&&(Kn(i,r,f),El(i,r,f))},enqueueReplaceState:function(r,i,c){r=r._reactInternals;var f=ls(),v=Wr(f);v.tag=1,v.payload=i,c!=null&&(v.callback=c),i=Yr(r,v,f),i!==null&&(Kn(i,r,f),El(i,r,f))},enqueueForceUpdate:function(r,i){r=r._reactInternals;var c=ls(),f=Wr(c);f.tag=2,i!=null&&(f.callback=i),i=Yr(r,f,c),i!==null&&(Kn(i,r,c),El(i,r,c))}};function N0(r,i,c,f,v,b,T){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(f,b,T):i.prototype&&i.prototype.isPureReactComponent?!yl(c,f)||!yl(v,b):!0}function k0(r,i,c,f){r=i.state,typeof i.componentWillReceiveProps=="function"&&i.componentWillReceiveProps(c,f),typeof i.UNSAFE_componentWillReceiveProps=="function"&&i.UNSAFE_componentWillReceiveProps(c,f),i.state!==r&&_p.enqueueReplaceState(i,i.state,null)}function Qa(r,i){var c=i;if("ref"in i){c={};for(var f in i)f!=="ref"&&(c[f]=i[f])}if(r=r.defaultProps){c===i&&(c=y({},c));for(var v in r)c[v]===void 0&&(c[v]=r[v])}return c}function E0(r){mu(r)}function C0(r){console.error(r)}function T0(r){mu(r)}function Lu(r,i){try{var c=r.onUncaughtError;c(i.value,{componentStack:i.stack})}catch(f){setTimeout(function(){throw f})}}function A0(r,i,c){try{var f=r.onCaughtError;f(c.value,{componentStack:c.stack,errorBoundary:i.tag===1?i.stateNode:null})}catch(v){setTimeout(function(){throw v})}}function Op(r,i,c){return c=Wr(c),c.tag=3,c.payload={element:null},c.callback=function(){Lu(r,i)},c}function R0(r){return r=Wr(r),r.tag=3,r}function M0(r,i,c,f){var v=c.type.getDerivedStateFromError;if(typeof v=="function"){var b=f.value;r.payload=function(){return v(b)},r.callback=function(){A0(i,c,f)}}var T=c.stateNode;T!==null&&typeof T.componentDidCatch=="function"&&(r.callback=function(){A0(i,c,f),typeof v!="function"&&(ea===null?ea=new Set([this]):ea.add(this));var P=f.stack;this.componentDidCatch(f.value,{componentStack:P!==null?P:""})})}function c2(r,i,c,f,v){if(c.flags|=32768,f!==null&&typeof f=="object"&&typeof f.then=="function"){if(i=c.alternate,i!==null&&Gi(i,c,v,!0),c=rs.current,c!==null){switch(c.tag){case 31:case 13:return ws===null?Ku():c.alternate===null&&Gt===0&&(Gt=3),c.flags&=-257,c.flags|=65536,c.lanes=v,f===ku?c.flags|=16384:(i=c.updateQueue,i===null?c.updateQueue=new Set([f]):i.add(f),rm(r,f,v)),!1;case 22:return c.flags|=65536,f===ku?c.flags|=16384:(i=c.updateQueue,i===null?(i={transitions:null,markerInstances:null,retryQueue:new Set([f])},c.updateQueue=i):(c=i.retryQueue,c===null?i.retryQueue=new Set([f]):c.add(f)),rm(r,f,v)),!1}throw Error(s(435,c.tag))}return rm(r,f,v),Ku(),!1}if(ct)return i=rs.current,i!==null?((i.flags&65536)===0&&(i.flags|=256),i.flags|=65536,i.lanes=v,f!==Jh&&(r=Error(s(422),{cause:f}),wl(vs(r,c)))):(f!==Jh&&(i=Error(s(423),{cause:f}),wl(vs(i,c))),r=r.current.alternate,r.flags|=65536,v&=-v,r.lanes|=v,f=vs(f,c),v=Op(r.stateNode,f,v),cp(r,v),Gt!==4&&(Gt=2)),!1;var b=Error(s(520),{cause:f});if(b=vs(b,c),Ul===null?Ul=[b]:Ul.push(b),Gt!==4&&(Gt=2),i===null)return!0;f=vs(f,c),c=i;do{switch(c.tag){case 3:return c.flags|=65536,r=v&-v,c.lanes|=r,r=Op(c.stateNode,f,r),cp(c,r),!1;case 1:if(i=c.type,b=c.stateNode,(c.flags&128)===0&&(typeof i.getDerivedStateFromError=="function"||b!==null&&typeof b.componentDidCatch=="function"&&(ea===null||!ea.has(b))))return c.flags|=65536,v&=-v,c.lanes|=v,v=R0(v),M0(v,r,c,f),cp(c,v),!1}c=c.return}while(c!==null);return!1}var Ip=Error(s(461)),an=!1;function Nn(r,i,c,f){i.child=r===null?Dx(i,null,c,f):Xa(i,r.child,c,f)}function _0(r,i,c,f,v){c=c.render;var b=i.ref;if("ref"in f){var T={};for(var P in f)P!=="ref"&&(T[P]=f[P])}else T=f;return Wa(i),f=mp(r,i,c,T,b,v),P=gp(),r!==null&&!an?(vp(r,i,v),jr(r,i,v)):(ct&&P&&Kh(i),i.flags|=1,Nn(r,i,f,v),i.child)}function O0(r,i,c,f,v){if(r===null){var b=c.type;return typeof b=="function"&&!Wh(b)&&b.defaultProps===void 0&&c.compare===null?(i.tag=15,i.type=b,I0(r,i,b,f,v)):(r=bu(c.type,null,f,i,i.mode,v),r.ref=i.ref,r.return=i,i.child=r)}if(b=r.child,!Vp(r,v)){var T=b.memoizedProps;if(c=c.compare,c=c!==null?c:yl,c(T,f)&&r.ref===i.ref)return jr(r,i,v)}return i.flags|=1,r=gr(b,f),r.ref=i.ref,r.return=i,i.child=r}function I0(r,i,c,f,v){if(r!==null){var b=r.memoizedProps;if(yl(b,f)&&r.ref===i.ref)if(an=!1,i.pendingProps=f=b,Vp(r,v))(r.flags&131072)!==0&&(an=!0);else return i.lanes=r.lanes,jr(r,i,v)}return Dp(r,i,c,f,v)}function D0(r,i,c,f){var v=f.children,b=r!==null?r.memoizedState:null;if(r===null&&i.stateNode===null&&(i.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),f.mode==="hidden"){if((i.flags&128)!==0){if(b=b!==null?b.baseLanes|c:c,r!==null){for(f=i.child=r.child,v=0;f!==null;)v=v|f.lanes|f.childLanes,f=f.sibling;f=v&~b}else f=0,i.child=null;return P0(r,i,b,c,f)}if((c&536870912)!==0)i.memoizedState={baseLanes:0,cachePool:null},r!==null&&Su(i,b!==null?b.cachePool:null),b!==null?Lx(i,b):dp(),$x(i);else return f=i.lanes=536870912,P0(r,i,b!==null?b.baseLanes|c:c,c,f)}else b!==null?(Su(i,b.cachePool),Lx(i,b),Kr(),i.memoizedState=null):(r!==null&&Su(i,null),dp(),Kr());return Nn(r,i,v,c),i.child}function Ol(r,i){return r!==null&&r.tag===22||i.stateNode!==null||(i.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),i.sibling}function P0(r,i,c,f,v){var b=ap();return b=b===null?null:{parent:sn._currentValue,pool:b},i.memoizedState={baseLanes:c,cachePool:b},r!==null&&Su(i,null),dp(),$x(i),r!==null&&Gi(r,i,f,!0),i.childLanes=v,null}function $u(r,i){return i=Bu({mode:i.mode,children:i.children},r.mode),i.ref=r.ref,r.child=i,i.return=r,i}function z0(r,i,c){return Xa(i,r.child,null,c),r=$u(i,i.pendingProps),r.flags|=2,as(i),i.memoizedState=null,r}function u2(r,i,c){var f=i.pendingProps,v=(i.flags&128)!==0;if(i.flags&=-129,r===null){if(ct){if(f.mode==="hidden")return r=$u(i,f),i.lanes=536870912,Ol(null,r);if(hp(i),(r=Mt)?(r=Gw(r,xs),r=r!==null&&r.data==="&"?r:null,r!==null&&(i.memoizedState={dehydrated:r,treeContext:Vr!==null?{id:Ys,overflow:Gs}:null,retryLane:536870912,hydrationErrors:null},c=xx(r),c.return=i,i.child=c,jn=i,Mt=null)):r=null,r===null)throw Hr(i);return i.lanes=536870912,null}return $u(i,f)}var b=r.memoizedState;if(b!==null){var T=b.dehydrated;if(hp(i),v)if(i.flags&256)i.flags&=-257,i=z0(r,i,c);else if(i.memoizedState!==null)i.child=r.child,i.flags|=128,i=null;else throw Error(s(558));else if(an||Gi(r,i,c,!1),v=(c&r.childLanes)!==0,an||v){if(f=Ct,f!==null&&(T=Vt(f,c),T!==0&&T!==b.retryLane))throw b.retryLane=T,Fa(r,T),Kn(f,r,T),Ip;Ku(),i=z0(r,i,c)}else r=b.treeContext,Mt=js(T.nextSibling),jn=i,ct=!0,Fr=null,xs=!1,r!==null&&Sx(i,r),i=$u(i,f),i.flags|=4096;return i}return r=gr(r.child,{mode:f.mode,children:f.children}),r.ref=i.ref,i.child=r,r.return=i,r}function Uu(r,i){var c=i.ref;if(c===null)r!==null&&r.ref!==null&&(i.flags|=4194816);else{if(typeof c!="function"&&typeof c!="object")throw Error(s(284));(r===null||r.ref!==c)&&(i.flags|=4194816)}}function Dp(r,i,c,f,v){return Wa(i),c=mp(r,i,c,f,void 0,v),f=gp(),r!==null&&!an?(vp(r,i,v),jr(r,i,v)):(ct&&f&&Kh(i),i.flags|=1,Nn(r,i,c,v),i.child)}function L0(r,i,c,f,v,b){return Wa(i),i.updateQueue=null,c=Bx(i,f,c,v),Ux(r),f=gp(),r!==null&&!an?(vp(r,i,b),jr(r,i,b)):(ct&&f&&Kh(i),i.flags|=1,Nn(r,i,c,b),i.child)}function $0(r,i,c,f,v){if(Wa(i),i.stateNode===null){var b=qi,T=c.contextType;typeof T=="object"&&T!==null&&(b=Sn(T)),b=new c(f,b),i.memoizedState=b.state!==null&&b.state!==void 0?b.state:null,b.updater=_p,i.stateNode=b,b._reactInternals=i,b=i.stateNode,b.props=f,b.state=i.memoizedState,b.refs={},op(i),T=c.contextType,b.context=typeof T=="object"&&T!==null?Sn(T):qi,b.state=i.memoizedState,T=c.getDerivedStateFromProps,typeof T=="function"&&(Mp(i,c,T,f),b.state=i.memoizedState),typeof c.getDerivedStateFromProps=="function"||typeof b.getSnapshotBeforeUpdate=="function"||typeof b.UNSAFE_componentWillMount!="function"&&typeof b.componentWillMount!="function"||(T=b.state,typeof b.componentWillMount=="function"&&b.componentWillMount(),typeof b.UNSAFE_componentWillMount=="function"&&b.UNSAFE_componentWillMount(),T!==b.state&&_p.enqueueReplaceState(b,b.state,null),Tl(i,f,b,v),Cl(),b.state=i.memoizedState),typeof b.componentDidMount=="function"&&(i.flags|=4194308),f=!0}else if(r===null){b=i.stateNode;var P=i.memoizedProps,Z=Qa(c,P);b.props=Z;var ne=b.context,le=c.contextType;T=qi,typeof le=="object"&&le!==null&&(T=Sn(le));var pe=c.getDerivedStateFromProps;le=typeof pe=="function"||typeof b.getSnapshotBeforeUpdate=="function",P=i.pendingProps!==P,le||typeof b.UNSAFE_componentWillReceiveProps!="function"&&typeof b.componentWillReceiveProps!="function"||(P||ne!==T)&&k0(i,b,f,T),Zr=!1;var se=i.memoizedState;b.state=se,Tl(i,f,b,v),Cl(),ne=i.memoizedState,P||se!==ne||Zr?(typeof pe=="function"&&(Mp(i,c,pe,f),ne=i.memoizedState),(Z=Zr||N0(i,c,Z,f,se,ne,T))?(le||typeof b.UNSAFE_componentWillMount!="function"&&typeof b.componentWillMount!="function"||(typeof b.componentWillMount=="function"&&b.componentWillMount(),typeof b.UNSAFE_componentWillMount=="function"&&b.UNSAFE_componentWillMount()),typeof b.componentDidMount=="function"&&(i.flags|=4194308)):(typeof b.componentDidMount=="function"&&(i.flags|=4194308),i.memoizedProps=f,i.memoizedState=ne),b.props=f,b.state=ne,b.context=T,f=Z):(typeof b.componentDidMount=="function"&&(i.flags|=4194308),f=!1)}else{b=i.stateNode,lp(r,i),T=i.memoizedProps,le=Qa(c,T),b.props=le,pe=i.pendingProps,se=b.context,ne=c.contextType,Z=qi,typeof ne=="object"&&ne!==null&&(Z=Sn(ne)),P=c.getDerivedStateFromProps,(ne=typeof P=="function"||typeof b.getSnapshotBeforeUpdate=="function")||typeof b.UNSAFE_componentWillReceiveProps!="function"&&typeof b.componentWillReceiveProps!="function"||(T!==pe||se!==Z)&&k0(i,b,f,Z),Zr=!1,se=i.memoizedState,b.state=se,Tl(i,f,b,v),Cl();var ae=i.memoizedState;T!==pe||se!==ae||Zr||r!==null&&r.dependencies!==null&&wu(r.dependencies)?(typeof P=="function"&&(Mp(i,c,P,f),ae=i.memoizedState),(le=Zr||N0(i,c,le,f,se,ae,Z)||r!==null&&r.dependencies!==null&&wu(r.dependencies))?(ne||typeof b.UNSAFE_componentWillUpdate!="function"&&typeof b.componentWillUpdate!="function"||(typeof b.componentWillUpdate=="function"&&b.componentWillUpdate(f,ae,Z),typeof b.UNSAFE_componentWillUpdate=="function"&&b.UNSAFE_componentWillUpdate(f,ae,Z)),typeof b.componentDidUpdate=="function"&&(i.flags|=4),typeof b.getSnapshotBeforeUpdate=="function"&&(i.flags|=1024)):(typeof b.componentDidUpdate!="function"||T===r.memoizedProps&&se===r.memoizedState||(i.flags|=4),typeof b.getSnapshotBeforeUpdate!="function"||T===r.memoizedProps&&se===r.memoizedState||(i.flags|=1024),i.memoizedProps=f,i.memoizedState=ae),b.props=f,b.state=ae,b.context=Z,f=le):(typeof b.componentDidUpdate!="function"||T===r.memoizedProps&&se===r.memoizedState||(i.flags|=4),typeof b.getSnapshotBeforeUpdate!="function"||T===r.memoizedProps&&se===r.memoizedState||(i.flags|=1024),f=!1)}return b=f,Uu(r,i),f=(i.flags&128)!==0,b||f?(b=i.stateNode,c=f&&typeof c.getDerivedStateFromError!="function"?null:b.render(),i.flags|=1,r!==null&&f?(i.child=Xa(i,r.child,null,v),i.child=Xa(i,null,c,v)):Nn(r,i,c,v),i.memoizedState=b.state,r=i.child):r=jr(r,i,v),r}function U0(r,i,c,f){return qa(),i.flags|=256,Nn(r,i,c,f),i.child}var Pp={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function zp(r){return{baseLanes:r,cachePool:Ax()}}function Lp(r,i,c){return r=r!==null?r.childLanes&~c:0,i&&(r|=os),r}function B0(r,i,c){var f=i.pendingProps,v=!1,b=(i.flags&128)!==0,T;if((T=b)||(T=r!==null&&r.memoizedState===null?!1:(Qt.current&2)!==0),T&&(v=!0,i.flags&=-129),T=(i.flags&32)!==0,i.flags&=-33,r===null){if(ct){if(v?Gr(i):Kr(),(r=Mt)?(r=Gw(r,xs),r=r!==null&&r.data!=="&"?r:null,r!==null&&(i.memoizedState={dehydrated:r,treeContext:Vr!==null?{id:Ys,overflow:Gs}:null,retryLane:536870912,hydrationErrors:null},c=xx(r),c.return=i,i.child=c,jn=i,Mt=null)):r=null,r===null)throw Hr(i);return xm(r)?i.lanes=32:i.lanes=536870912,null}var P=f.children;return f=f.fallback,v?(Kr(),v=i.mode,P=Bu({mode:"hidden",children:P},v),f=Ha(f,v,c,null),P.return=i,f.return=i,P.sibling=f,i.child=P,f=i.child,f.memoizedState=zp(c),f.childLanes=Lp(r,T,c),i.memoizedState=Pp,Ol(null,f)):(Gr(i),$p(i,P))}var Z=r.memoizedState;if(Z!==null&&(P=Z.dehydrated,P!==null)){if(b)i.flags&256?(Gr(i),i.flags&=-257,i=Up(r,i,c)):i.memoizedState!==null?(Kr(),i.child=r.child,i.flags|=128,i=null):(Kr(),P=f.fallback,v=i.mode,f=Bu({mode:"visible",children:f.children},v),P=Ha(P,v,c,null),P.flags|=2,f.return=i,P.return=i,f.sibling=P,i.child=f,Xa(i,r.child,null,c),f=i.child,f.memoizedState=zp(c),f.childLanes=Lp(r,T,c),i.memoizedState=Pp,i=Ol(null,f));else if(Gr(i),xm(P)){if(T=P.nextSibling&&P.nextSibling.dataset,T)var ne=T.dgst;T=ne,f=Error(s(419)),f.stack="",f.digest=T,wl({value:f,source:null,stack:null}),i=Up(r,i,c)}else if(an||Gi(r,i,c,!1),T=(c&r.childLanes)!==0,an||T){if(T=Ct,T!==null&&(f=Vt(T,c),f!==0&&f!==Z.retryLane))throw Z.retryLane=f,Fa(r,f),Kn(T,r,f),Ip;bm(P)||Ku(),i=Up(r,i,c)}else bm(P)?(i.flags|=192,i.child=r.child,i=null):(r=Z.treeContext,Mt=js(P.nextSibling),jn=i,ct=!0,Fr=null,xs=!1,r!==null&&Sx(i,r),i=$p(i,f.children),i.flags|=4096);return i}return v?(Kr(),P=f.fallback,v=i.mode,Z=r.child,ne=Z.sibling,f=gr(Z,{mode:"hidden",children:f.children}),f.subtreeFlags=Z.subtreeFlags&65011712,ne!==null?P=gr(ne,P):(P=Ha(P,v,c,null),P.flags|=2),P.return=i,f.return=i,f.sibling=P,i.child=f,Ol(null,f),f=i.child,P=r.child.memoizedState,P===null?P=zp(c):(v=P.cachePool,v!==null?(Z=sn._currentValue,v=v.parent!==Z?{parent:Z,pool:Z}:v):v=Ax(),P={baseLanes:P.baseLanes|c,cachePool:v}),f.memoizedState=P,f.childLanes=Lp(r,T,c),i.memoizedState=Pp,Ol(r.child,f)):(Gr(i),c=r.child,r=c.sibling,c=gr(c,{mode:"visible",children:f.children}),c.return=i,c.sibling=null,r!==null&&(T=i.deletions,T===null?(i.deletions=[r],i.flags|=16):T.push(r)),i.child=c,i.memoizedState=null,c)}function $p(r,i){return i=Bu({mode:"visible",children:i},r.mode),i.return=r,r.child=i}function Bu(r,i){return r=ss(22,r,null,i),r.lanes=0,r}function Up(r,i,c){return Xa(i,r.child,null,c),r=$p(i,i.pendingProps.children),r.flags|=2,i.memoizedState=null,r}function V0(r,i,c){r.lanes|=i;var f=r.alternate;f!==null&&(f.lanes|=i),tp(r.return,i,c)}function Bp(r,i,c,f,v,b){var T=r.memoizedState;T===null?r.memoizedState={isBackwards:i,rendering:null,renderingStartTime:0,last:f,tail:c,tailMode:v,treeForkCount:b}:(T.isBackwards=i,T.rendering=null,T.renderingStartTime=0,T.last=f,T.tail=c,T.tailMode=v,T.treeForkCount=b)}function F0(r,i,c){var f=i.pendingProps,v=f.revealOrder,b=f.tail;f=f.children;var T=Qt.current,P=(T&2)!==0;if(P?(T=T&1|2,i.flags|=128):T&=1,Y(Qt,T),Nn(r,i,f,c),f=ct?xl:0,!P&&r!==null&&(r.flags&128)!==0)e:for(r=i.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&V0(r,c,i);else if(r.tag===19)V0(r,c,i);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break e;for(;r.sibling===null;){if(r.return===null||r.return===i)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}switch(v){case"forwards":for(c=i.child,v=null;c!==null;)r=c.alternate,r!==null&&Au(r)===null&&(v=c),c=c.sibling;c=v,c===null?(v=i.child,i.child=null):(v=c.sibling,c.sibling=null),Bp(i,!1,v,c,b,f);break;case"backwards":case"unstable_legacy-backwards":for(c=null,v=i.child,i.child=null;v!==null;){if(r=v.alternate,r!==null&&Au(r)===null){i.child=v;break}r=v.sibling,v.sibling=c,c=v,v=r}Bp(i,!0,c,null,b,f);break;case"together":Bp(i,!1,null,null,void 0,f);break;default:i.memoizedState=null}return i.child}function jr(r,i,c){if(r!==null&&(i.dependencies=r.dependencies),Qr|=i.lanes,(c&i.childLanes)===0)if(r!==null){if(Gi(r,i,c,!1),(c&i.childLanes)===0)return null}else return null;if(r!==null&&i.child!==r.child)throw Error(s(153));if(i.child!==null){for(r=i.child,c=gr(r,r.pendingProps),i.child=c,c.return=i;r.sibling!==null;)r=r.sibling,c=c.sibling=gr(r,r.pendingProps),c.return=i;c.sibling=null}return i.child}function Vp(r,i){return(r.lanes&i)!==0?!0:(r=r.dependencies,!!(r!==null&&wu(r)))}function d2(r,i,c){switch(i.tag){case 3:de(i,i.stateNode.containerInfo),qr(i,sn,r.memoizedState.cache),qa();break;case 27:case 5:Te(i);break;case 4:de(i,i.stateNode.containerInfo);break;case 10:qr(i,i.type,i.memoizedProps.value);break;case 31:if(i.memoizedState!==null)return i.flags|=128,hp(i),null;break;case 13:var f=i.memoizedState;if(f!==null)return f.dehydrated!==null?(Gr(i),i.flags|=128,null):(c&i.child.childLanes)!==0?B0(r,i,c):(Gr(i),r=jr(r,i,c),r!==null?r.sibling:null);Gr(i);break;case 19:var v=(r.flags&128)!==0;if(f=(c&i.childLanes)!==0,f||(Gi(r,i,c,!1),f=(c&i.childLanes)!==0),v){if(f)return F0(r,i,c);i.flags|=128}if(v=i.memoizedState,v!==null&&(v.rendering=null,v.tail=null,v.lastEffect=null),Y(Qt,Qt.current),f)break;return null;case 22:return i.lanes=0,D0(r,i,c,i.pendingProps);case 24:qr(i,sn,r.memoizedState.cache)}return jr(r,i,c)}function H0(r,i,c){if(r!==null)if(r.memoizedProps!==i.pendingProps)an=!0;else{if(!Vp(r,c)&&(i.flags&128)===0)return an=!1,d2(r,i,c);an=(r.flags&131072)!==0}else an=!1,ct&&(i.flags&1048576)!==0&&jx(i,xl,i.index);switch(i.lanes=0,i.tag){case 16:e:{var f=i.pendingProps;if(r=Ga(i.elementType),i.type=r,typeof r=="function")Wh(r)?(f=Qa(r,f),i.tag=1,i=$0(null,i,r,f,c)):(i.tag=0,i=Dp(null,i,r,f,c));else{if(r!=null){var v=r.$$typeof;if(v===R){i.tag=11,i=_0(null,i,r,f,c);break e}else if(v===_){i.tag=14,i=O0(null,i,r,f,c);break e}}throw i=W(r)||r,Error(s(306,i,""))}}return i;case 0:return Dp(r,i,i.type,i.pendingProps,c);case 1:return f=i.type,v=Qa(f,i.pendingProps),$0(r,i,f,v,c);case 3:e:{if(de(i,i.stateNode.containerInfo),r===null)throw Error(s(387));f=i.pendingProps;var b=i.memoizedState;v=b.element,lp(r,i),Tl(i,f,null,c);var T=i.memoizedState;if(f=T.cache,qr(i,sn,f),f!==b.cache&&np(i,[sn],c,!0),Cl(),f=T.element,b.isDehydrated)if(b={element:f,isDehydrated:!1,cache:T.cache},i.updateQueue.baseState=b,i.memoizedState=b,i.flags&256){i=U0(r,i,f,c);break e}else if(f!==v){v=vs(Error(s(424)),i),wl(v),i=U0(r,i,f,c);break e}else for(r=i.stateNode.containerInfo,r.nodeType===9?r=r.body:r=r.nodeName==="HTML"?r.ownerDocument.body:r,Mt=js(r.firstChild),jn=i,ct=!0,Fr=null,xs=!0,c=Dx(i,null,f,c),i.child=c;c;)c.flags=c.flags&-3|4096,c=c.sibling;else{if(qa(),f===v){i=jr(r,i,c);break e}Nn(r,i,f,c)}i=i.child}return i;case 26:return Uu(r,i),r===null?(c=t1(i.type,null,i.pendingProps,null))?i.memoizedState=c:ct||(c=i.type,r=i.pendingProps,f=sd(re.current).createElement(c),f[wn]=i,f[Hn]=r,kn(f,c,r),gn(f),i.stateNode=f):i.memoizedState=t1(i.type,r.memoizedProps,i.pendingProps,r.memoizedState),null;case 27:return Te(i),r===null&&ct&&(f=i.stateNode=Jw(i.type,i.pendingProps,re.current),jn=i,xs=!0,v=Mt,ra(i.type)?(wm=v,Mt=js(f.firstChild)):Mt=v),Nn(r,i,i.pendingProps.children,c),Uu(r,i),r===null&&(i.flags|=4194304),i.child;case 5:return r===null&&ct&&((v=f=Mt)&&(f=B2(f,i.type,i.pendingProps,xs),f!==null?(i.stateNode=f,jn=i,Mt=js(f.firstChild),xs=!1,v=!0):v=!1),v||Hr(i)),Te(i),v=i.type,b=i.pendingProps,T=r!==null?r.memoizedProps:null,f=b.children,gm(v,b)?f=null:T!==null&&gm(v,T)&&(i.flags|=32),i.memoizedState!==null&&(v=mp(r,i,n2,null,null,c),Yl._currentValue=v),Uu(r,i),Nn(r,i,f,c),i.child;case 6:return r===null&&ct&&((r=c=Mt)&&(c=V2(c,i.pendingProps,xs),c!==null?(i.stateNode=c,jn=i,Mt=null,r=!0):r=!1),r||Hr(i)),null;case 13:return B0(r,i,c);case 4:return de(i,i.stateNode.containerInfo),f=i.pendingProps,r===null?i.child=Xa(i,null,f,c):Nn(r,i,f,c),i.child;case 11:return _0(r,i,i.type,i.pendingProps,c);case 7:return Nn(r,i,i.pendingProps,c),i.child;case 8:return Nn(r,i,i.pendingProps.children,c),i.child;case 12:return Nn(r,i,i.pendingProps.children,c),i.child;case 10:return f=i.pendingProps,qr(i,i.type,f.value),Nn(r,i,f.children,c),i.child;case 9:return v=i.type._context,f=i.pendingProps.children,Wa(i),v=Sn(v),f=f(v),i.flags|=1,Nn(r,i,f,c),i.child;case 14:return O0(r,i,i.type,i.pendingProps,c);case 15:return I0(r,i,i.type,i.pendingProps,c);case 19:return F0(r,i,c);case 31:return u2(r,i,c);case 22:return D0(r,i,c,i.pendingProps);case 24:return Wa(i),f=Sn(sn),r===null?(v=ap(),v===null&&(v=Ct,b=sp(),v.pooledCache=b,b.refCount++,b!==null&&(v.pooledCacheLanes|=c),v=b),i.memoizedState={parent:f,cache:v},op(i),qr(i,sn,v)):((r.lanes&c)!==0&&(lp(r,i),Tl(i,null,null,c),Cl()),v=r.memoizedState,b=i.memoizedState,v.parent!==f?(v={parent:f,cache:f},i.memoizedState=v,i.lanes===0&&(i.memoizedState=i.updateQueue.baseState=v),qr(i,sn,f)):(f=b.cache,qr(i,sn,f),f!==v.cache&&np(i,[sn],c,!0))),Nn(r,i,i.pendingProps.children,c),i.child;case 29:throw i.pendingProps}throw Error(s(156,i.tag))}function Sr(r){r.flags|=4}function Fp(r,i,c,f,v){if((i=(r.mode&32)!==0)&&(i=!1),i){if(r.flags|=16777216,(v&335544128)===v)if(r.stateNode.complete)r.flags|=8192;else if(vw())r.flags|=8192;else throw Ka=ku,ip}else r.flags&=-16777217}function q0(r,i){if(i.type!=="stylesheet"||(i.state.loading&4)!==0)r.flags&=-16777217;else if(r.flags|=16777216,!i1(i))if(vw())r.flags|=8192;else throw Ka=ku,ip}function Vu(r,i){i!==null&&(r.flags|=4),r.flags&16384&&(i=r.tag!==22?ee():536870912,r.lanes|=i,oo|=i)}function Il(r,i){if(!ct)switch(r.tailMode){case"hidden":i=r.tail;for(var c=null;i!==null;)i.alternate!==null&&(c=i),i=i.sibling;c===null?r.tail=null:c.sibling=null;break;case"collapsed":c=r.tail;for(var f=null;c!==null;)c.alternate!==null&&(f=c),c=c.sibling;f===null?i||r.tail===null?r.tail=null:r.tail.sibling=null:f.sibling=null}}function _t(r){var i=r.alternate!==null&&r.alternate.child===r.child,c=0,f=0;if(i)for(var v=r.child;v!==null;)c|=v.lanes|v.childLanes,f|=v.subtreeFlags&65011712,f|=v.flags&65011712,v.return=r,v=v.sibling;else for(v=r.child;v!==null;)c|=v.lanes|v.childLanes,f|=v.subtreeFlags,f|=v.flags,v.return=r,v=v.sibling;return r.subtreeFlags|=f,r.childLanes=c,i}function f2(r,i,c){var f=i.pendingProps;switch(Xh(i),i.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return _t(i),null;case 1:return _t(i),null;case 3:return c=i.stateNode,f=null,r!==null&&(f=r.memoizedState.cache),i.memoizedState.cache!==f&&(i.flags|=2048),br(sn),ye(),c.pendingContext&&(c.context=c.pendingContext,c.pendingContext=null),(r===null||r.child===null)&&(Yi(i)?Sr(i):r===null||r.memoizedState.isDehydrated&&(i.flags&256)===0||(i.flags|=1024,Qh())),_t(i),null;case 26:var v=i.type,b=i.memoizedState;return r===null?(Sr(i),b!==null?(_t(i),q0(i,b)):(_t(i),Fp(i,v,null,f,c))):b?b!==r.memoizedState?(Sr(i),_t(i),q0(i,b)):(_t(i),i.flags&=-16777217):(r=r.memoizedProps,r!==f&&Sr(i),_t(i),Fp(i,v,r,f,c)),null;case 27:if(he(i),c=re.current,v=i.type,r!==null&&i.stateNode!=null)r.memoizedProps!==f&&Sr(i);else{if(!f){if(i.stateNode===null)throw Error(s(166));return _t(i),null}r=Q.current,Yi(i)?Nx(i):(r=Jw(v,f,c),i.stateNode=r,Sr(i))}return _t(i),null;case 5:if(he(i),v=i.type,r!==null&&i.stateNode!=null)r.memoizedProps!==f&&Sr(i);else{if(!f){if(i.stateNode===null)throw Error(s(166));return _t(i),null}if(b=Q.current,Yi(i))Nx(i);else{var T=sd(re.current);switch(b){case 1:b=T.createElementNS("http://www.w3.org/2000/svg",v);break;case 2:b=T.createElementNS("http://www.w3.org/1998/Math/MathML",v);break;default:switch(v){case"svg":b=T.createElementNS("http://www.w3.org/2000/svg",v);break;case"math":b=T.createElementNS("http://www.w3.org/1998/Math/MathML",v);break;case"script":b=T.createElement("div"),b.innerHTML="<script><\/script>",b=b.removeChild(b.firstChild);break;case"select":b=typeof f.is=="string"?T.createElement("select",{is:f.is}):T.createElement("select"),f.multiple?b.multiple=!0:f.size&&(b.size=f.size);break;default:b=typeof f.is=="string"?T.createElement(v,{is:f.is}):T.createElement(v)}}b[wn]=i,b[Hn]=f;e:for(T=i.child;T!==null;){if(T.tag===5||T.tag===6)b.appendChild(T.stateNode);else if(T.tag!==4&&T.tag!==27&&T.child!==null){T.child.return=T,T=T.child;continue}if(T===i)break e;for(;T.sibling===null;){if(T.return===null||T.return===i)break e;T=T.return}T.sibling.return=T.return,T=T.sibling}i.stateNode=b;e:switch(kn(b,v,f),v){case"button":case"input":case"select":case"textarea":f=!!f.autoFocus;break e;case"img":f=!0;break e;default:f=!1}f&&Sr(i)}}return _t(i),Fp(i,i.type,r===null?null:r.memoizedProps,i.pendingProps,c),null;case 6:if(r&&i.stateNode!=null)r.memoizedProps!==f&&Sr(i);else{if(typeof f!="string"&&i.stateNode===null)throw Error(s(166));if(r=re.current,Yi(i)){if(r=i.stateNode,c=i.memoizedProps,f=null,v=jn,v!==null)switch(v.tag){case 27:case 5:f=v.memoizedProps}r[wn]=i,r=!!(r.nodeValue===c||f!==null&&f.suppressHydrationWarning===!0||Bw(r.nodeValue,c)),r||Hr(i,!0)}else r=sd(r).createTextNode(f),r[wn]=i,i.stateNode=r}return _t(i),null;case 31:if(c=i.memoizedState,r===null||r.memoizedState!==null){if(f=Yi(i),c!==null){if(r===null){if(!f)throw Error(s(318));if(r=i.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(s(557));r[wn]=i}else qa(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;_t(i),r=!1}else c=Qh(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=c),r=!0;if(!r)return i.flags&256?(as(i),i):(as(i),null);if((i.flags&128)!==0)throw Error(s(558))}return _t(i),null;case 13:if(f=i.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(v=Yi(i),f!==null&&f.dehydrated!==null){if(r===null){if(!v)throw Error(s(318));if(v=i.memoizedState,v=v!==null?v.dehydrated:null,!v)throw Error(s(317));v[wn]=i}else qa(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;_t(i),v=!1}else v=Qh(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=v),v=!0;if(!v)return i.flags&256?(as(i),i):(as(i),null)}return as(i),(i.flags&128)!==0?(i.lanes=c,i):(c=f!==null,r=r!==null&&r.memoizedState!==null,c&&(f=i.child,v=null,f.alternate!==null&&f.alternate.memoizedState!==null&&f.alternate.memoizedState.cachePool!==null&&(v=f.alternate.memoizedState.cachePool.pool),b=null,f.memoizedState!==null&&f.memoizedState.cachePool!==null&&(b=f.memoizedState.cachePool.pool),b!==v&&(f.flags|=2048)),c!==r&&c&&(i.child.flags|=8192),Vu(i,i.updateQueue),_t(i),null);case 4:return ye(),r===null&&dm(i.stateNode.containerInfo),_t(i),null;case 10:return br(i.type),_t(i),null;case 19:if(B(Qt),f=i.memoizedState,f===null)return _t(i),null;if(v=(i.flags&128)!==0,b=f.rendering,b===null)if(v)Il(f,!1);else{if(Gt!==0||r!==null&&(r.flags&128)!==0)for(r=i.child;r!==null;){if(b=Au(r),b!==null){for(i.flags|=128,Il(f,!1),r=b.updateQueue,i.updateQueue=r,Vu(i,r),i.subtreeFlags=0,r=c,c=i.child;c!==null;)bx(c,r),c=c.sibling;return Y(Qt,Qt.current&1|2),ct&&vr(i,f.treeForkCount),i.child}r=r.sibling}f.tail!==null&&Ne()>Wu&&(i.flags|=128,v=!0,Il(f,!1),i.lanes=4194304)}else{if(!v)if(r=Au(b),r!==null){if(i.flags|=128,v=!0,r=r.updateQueue,i.updateQueue=r,Vu(i,r),Il(f,!0),f.tail===null&&f.tailMode==="hidden"&&!b.alternate&&!ct)return _t(i),null}else 2*Ne()-f.renderingStartTime>Wu&&c!==536870912&&(i.flags|=128,v=!0,Il(f,!1),i.lanes=4194304);f.isBackwards?(b.sibling=i.child,i.child=b):(r=f.last,r!==null?r.sibling=b:i.child=b,f.last=b)}return f.tail!==null?(r=f.tail,f.rendering=r,f.tail=r.sibling,f.renderingStartTime=Ne(),r.sibling=null,c=Qt.current,Y(Qt,v?c&1|2:c&1),ct&&vr(i,f.treeForkCount),r):(_t(i),null);case 22:case 23:return as(i),fp(),f=i.memoizedState!==null,r!==null?r.memoizedState!==null!==f&&(i.flags|=8192):f&&(i.flags|=8192),f?(c&536870912)!==0&&(i.flags&128)===0&&(_t(i),i.subtreeFlags&6&&(i.flags|=8192)):_t(i),c=i.updateQueue,c!==null&&Vu(i,c.retryQueue),c=null,r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(c=r.memoizedState.cachePool.pool),f=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(f=i.memoizedState.cachePool.pool),f!==c&&(i.flags|=2048),r!==null&&B(Ya),null;case 24:return c=null,r!==null&&(c=r.memoizedState.cache),i.memoizedState.cache!==c&&(i.flags|=2048),br(sn),_t(i),null;case 25:return null;case 30:return null}throw Error(s(156,i.tag))}function h2(r,i){switch(Xh(i),i.tag){case 1:return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 3:return br(sn),ye(),r=i.flags,(r&65536)!==0&&(r&128)===0?(i.flags=r&-65537|128,i):null;case 26:case 27:case 5:return he(i),null;case 31:if(i.memoizedState!==null){if(as(i),i.alternate===null)throw Error(s(340));qa()}return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 13:if(as(i),r=i.memoizedState,r!==null&&r.dehydrated!==null){if(i.alternate===null)throw Error(s(340));qa()}return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 19:return B(Qt),null;case 4:return ye(),null;case 10:return br(i.type),null;case 22:case 23:return as(i),fp(),r!==null&&B(Ya),r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 24:return br(sn),null;case 25:return null;default:return null}}function Z0(r,i){switch(Xh(i),i.tag){case 3:br(sn),ye();break;case 26:case 27:case 5:he(i);break;case 4:ye();break;case 31:i.memoizedState!==null&&as(i);break;case 13:as(i);break;case 19:B(Qt);break;case 10:br(i.type);break;case 22:case 23:as(i),fp(),r!==null&&B(Ya);break;case 24:br(sn)}}function Dl(r,i){try{var c=i.updateQueue,f=c!==null?c.lastEffect:null;if(f!==null){var v=f.next;c=v;do{if((c.tag&r)===r){f=void 0;var b=c.create,T=c.inst;f=b(),T.destroy=f}c=c.next}while(c!==v)}}catch(P){yt(i,i.return,P)}}function Xr(r,i,c){try{var f=i.updateQueue,v=f!==null?f.lastEffect:null;if(v!==null){var b=v.next;f=b;do{if((f.tag&r)===r){var T=f.inst,P=T.destroy;if(P!==void 0){T.destroy=void 0,v=i;var Z=c,ne=P;try{ne()}catch(le){yt(v,Z,le)}}}f=f.next}while(f!==b)}}catch(le){yt(i,i.return,le)}}function W0(r){var i=r.updateQueue;if(i!==null){var c=r.stateNode;try{zx(i,c)}catch(f){yt(r,r.return,f)}}}function Y0(r,i,c){c.props=Qa(r.type,r.memoizedProps),c.state=r.memoizedState;try{c.componentWillUnmount()}catch(f){yt(r,i,f)}}function Pl(r,i){try{var c=r.ref;if(c!==null){switch(r.tag){case 26:case 27:case 5:var f=r.stateNode;break;case 30:f=r.stateNode;break;default:f=r.stateNode}typeof c=="function"?r.refCleanup=c(f):c.current=f}}catch(v){yt(r,i,v)}}function Ks(r,i){var c=r.ref,f=r.refCleanup;if(c!==null)if(typeof f=="function")try{f()}catch(v){yt(r,i,v)}finally{r.refCleanup=null,r=r.alternate,r!=null&&(r.refCleanup=null)}else if(typeof c=="function")try{c(null)}catch(v){yt(r,i,v)}else c.current=null}function G0(r){var i=r.type,c=r.memoizedProps,f=r.stateNode;try{e:switch(i){case"button":case"input":case"select":case"textarea":c.autoFocus&&f.focus();break e;case"img":c.src?f.src=c.src:c.srcSet&&(f.srcset=c.srcSet)}}catch(v){yt(r,r.return,v)}}function Hp(r,i,c){try{var f=r.stateNode;D2(f,r.type,c,i),f[Hn]=i}catch(v){yt(r,r.return,v)}}function K0(r){return r.tag===5||r.tag===3||r.tag===26||r.tag===27&&ra(r.type)||r.tag===4}function qp(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||K0(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.tag===27&&ra(r.type)||r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function Zp(r,i,c){var f=r.tag;if(f===5||f===6)r=r.stateNode,i?(c.nodeType===9?c.body:c.nodeName==="HTML"?c.ownerDocument.body:c).insertBefore(r,i):(i=c.nodeType===9?c.body:c.nodeName==="HTML"?c.ownerDocument.body:c,i.appendChild(r),c=c._reactRootContainer,c!=null||i.onclick!==null||(i.onclick=pr));else if(f!==4&&(f===27&&ra(r.type)&&(c=r.stateNode,i=null),r=r.child,r!==null))for(Zp(r,i,c),r=r.sibling;r!==null;)Zp(r,i,c),r=r.sibling}function Fu(r,i,c){var f=r.tag;if(f===5||f===6)r=r.stateNode,i?c.insertBefore(r,i):c.appendChild(r);else if(f!==4&&(f===27&&ra(r.type)&&(c=r.stateNode),r=r.child,r!==null))for(Fu(r,i,c),r=r.sibling;r!==null;)Fu(r,i,c),r=r.sibling}function X0(r){var i=r.stateNode,c=r.memoizedProps;try{for(var f=r.type,v=i.attributes;v.length;)i.removeAttributeNode(v[0]);kn(i,f,c),i[wn]=r,i[Hn]=c}catch(b){yt(r,r.return,b)}}var Nr=!1,on=!1,Wp=!1,J0=typeof WeakSet=="function"?WeakSet:Set,vn=null;function p2(r,i){if(r=r.containerInfo,pm=ud,r=ux(r),Uh(r)){if("selectionStart"in r)var c={start:r.selectionStart,end:r.selectionEnd};else e:{c=(c=r.ownerDocument)&&c.defaultView||window;var f=c.getSelection&&c.getSelection();if(f&&f.rangeCount!==0){c=f.anchorNode;var v=f.anchorOffset,b=f.focusNode;f=f.focusOffset;try{c.nodeType,b.nodeType}catch{c=null;break e}var T=0,P=-1,Z=-1,ne=0,le=0,pe=r,se=null;t:for(;;){for(var ae;pe!==c||v!==0&&pe.nodeType!==3||(P=T+v),pe!==b||f!==0&&pe.nodeType!==3||(Z=T+f),pe.nodeType===3&&(T+=pe.nodeValue.length),(ae=pe.firstChild)!==null;)se=pe,pe=ae;for(;;){if(pe===r)break t;if(se===c&&++ne===v&&(P=T),se===b&&++le===f&&(Z=T),(ae=pe.nextSibling)!==null)break;pe=se,se=pe.parentNode}pe=ae}c=P===-1||Z===-1?null:{start:P,end:Z}}else c=null}c=c||{start:0,end:0}}else c=null;for(mm={focusedElem:r,selectionRange:c},ud=!1,vn=i;vn!==null;)if(i=vn,r=i.child,(i.subtreeFlags&1028)!==0&&r!==null)r.return=i,vn=r;else for(;vn!==null;){switch(i=vn,b=i.alternate,r=i.flags,i.tag){case 0:if((r&4)!==0&&(r=i.updateQueue,r=r!==null?r.events:null,r!==null))for(c=0;c<r.length;c++)v=r[c],v.ref.impl=v.nextImpl;break;case 11:case 15:break;case 1:if((r&1024)!==0&&b!==null){r=void 0,c=i,v=b.memoizedProps,b=b.memoizedState,f=c.stateNode;try{var Me=Qa(c.type,v);r=f.getSnapshotBeforeUpdate(Me,b),f.__reactInternalSnapshotBeforeUpdate=r}catch(Fe){yt(c,c.return,Fe)}}break;case 3:if((r&1024)!==0){if(r=i.stateNode.containerInfo,c=r.nodeType,c===9)ym(r);else if(c===1)switch(r.nodeName){case"HEAD":case"HTML":case"BODY":ym(r);break;default:r.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((r&1024)!==0)throw Error(s(163))}if(r=i.sibling,r!==null){r.return=i.return,vn=r;break}vn=i.return}}function Q0(r,i,c){var f=c.flags;switch(c.tag){case 0:case 11:case 15:Er(r,c),f&4&&Dl(5,c);break;case 1:if(Er(r,c),f&4)if(r=c.stateNode,i===null)try{r.componentDidMount()}catch(T){yt(c,c.return,T)}else{var v=Qa(c.type,i.memoizedProps);i=i.memoizedState;try{r.componentDidUpdate(v,i,r.__reactInternalSnapshotBeforeUpdate)}catch(T){yt(c,c.return,T)}}f&64&&W0(c),f&512&&Pl(c,c.return);break;case 3:if(Er(r,c),f&64&&(r=c.updateQueue,r!==null)){if(i=null,c.child!==null)switch(c.child.tag){case 27:case 5:i=c.child.stateNode;break;case 1:i=c.child.stateNode}try{zx(r,i)}catch(T){yt(c,c.return,T)}}break;case 27:i===null&&f&4&&X0(c);case 26:case 5:Er(r,c),i===null&&f&4&&G0(c),f&512&&Pl(c,c.return);break;case 12:Er(r,c);break;case 31:Er(r,c),f&4&&nw(r,c);break;case 13:Er(r,c),f&4&&sw(r,c),f&64&&(r=c.memoizedState,r!==null&&(r=r.dehydrated,r!==null&&(c=S2.bind(null,c),F2(r,c))));break;case 22:if(f=c.memoizedState!==null||Nr,!f){i=i!==null&&i.memoizedState!==null||on,v=Nr;var b=on;Nr=f,(on=i)&&!b?Cr(r,c,(c.subtreeFlags&8772)!==0):Er(r,c),Nr=v,on=b}break;case 30:break;default:Er(r,c)}}function ew(r){var i=r.alternate;i!==null&&(r.alternate=null,ew(i)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(i=r.stateNode,i!==null&&Sh(i)),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}var $t=null,Zn=!1;function kr(r,i,c){for(c=c.child;c!==null;)tw(r,i,c),c=c.sibling}function tw(r,i,c){if(ze&&typeof ze.onCommitFiberUnmount=="function")try{ze.onCommitFiberUnmount(Jt,c)}catch{}switch(c.tag){case 26:on||Ks(c,i),kr(r,i,c),c.memoizedState?c.memoizedState.count--:c.stateNode&&(c=c.stateNode,c.parentNode.removeChild(c));break;case 27:on||Ks(c,i);var f=$t,v=Zn;ra(c.type)&&($t=c.stateNode,Zn=!1),kr(r,i,c),ql(c.stateNode),$t=f,Zn=v;break;case 5:on||Ks(c,i);case 6:if(f=$t,v=Zn,$t=null,kr(r,i,c),$t=f,Zn=v,$t!==null)if(Zn)try{($t.nodeType===9?$t.body:$t.nodeName==="HTML"?$t.ownerDocument.body:$t).removeChild(c.stateNode)}catch(b){yt(c,i,b)}else try{$t.removeChild(c.stateNode)}catch(b){yt(c,i,b)}break;case 18:$t!==null&&(Zn?(r=$t,Ww(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,c.stateNode),go(r)):Ww($t,c.stateNode));break;case 4:f=$t,v=Zn,$t=c.stateNode.containerInfo,Zn=!0,kr(r,i,c),$t=f,Zn=v;break;case 0:case 11:case 14:case 15:Xr(2,c,i),on||Xr(4,c,i),kr(r,i,c);break;case 1:on||(Ks(c,i),f=c.stateNode,typeof f.componentWillUnmount=="function"&&Y0(c,i,f)),kr(r,i,c);break;case 21:kr(r,i,c);break;case 22:on=(f=on)||c.memoizedState!==null,kr(r,i,c),on=f;break;default:kr(r,i,c)}}function nw(r,i){if(i.memoizedState===null&&(r=i.alternate,r!==null&&(r=r.memoizedState,r!==null))){r=r.dehydrated;try{go(r)}catch(c){yt(i,i.return,c)}}}function sw(r,i){if(i.memoizedState===null&&(r=i.alternate,r!==null&&(r=r.memoizedState,r!==null&&(r=r.dehydrated,r!==null))))try{go(r)}catch(c){yt(i,i.return,c)}}function m2(r){switch(r.tag){case 31:case 13:case 19:var i=r.stateNode;return i===null&&(i=r.stateNode=new J0),i;case 22:return r=r.stateNode,i=r._retryCache,i===null&&(i=r._retryCache=new J0),i;default:throw Error(s(435,r.tag))}}function Hu(r,i){var c=m2(r);i.forEach(function(f){if(!c.has(f)){c.add(f);var v=N2.bind(null,r,f);f.then(v,v)}})}function Wn(r,i){var c=i.deletions;if(c!==null)for(var f=0;f<c.length;f++){var v=c[f],b=r,T=i,P=T;e:for(;P!==null;){switch(P.tag){case 27:if(ra(P.type)){$t=P.stateNode,Zn=!1;break e}break;case 5:$t=P.stateNode,Zn=!1;break e;case 3:case 4:$t=P.stateNode.containerInfo,Zn=!0;break e}P=P.return}if($t===null)throw Error(s(160));tw(b,T,v),$t=null,Zn=!1,b=v.alternate,b!==null&&(b.return=null),v.return=null}if(i.subtreeFlags&13886)for(i=i.child;i!==null;)rw(i,r),i=i.sibling}var Os=null;function rw(r,i){var c=r.alternate,f=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:Wn(i,r),Yn(r),f&4&&(Xr(3,r,r.return),Dl(3,r),Xr(5,r,r.return));break;case 1:Wn(i,r),Yn(r),f&512&&(on||c===null||Ks(c,c.return)),f&64&&Nr&&(r=r.updateQueue,r!==null&&(f=r.callbacks,f!==null&&(c=r.shared.hiddenCallbacks,r.shared.hiddenCallbacks=c===null?f:c.concat(f))));break;case 26:var v=Os;if(Wn(i,r),Yn(r),f&512&&(on||c===null||Ks(c,c.return)),f&4){var b=c!==null?c.memoizedState:null;if(f=r.memoizedState,c===null)if(f===null)if(r.stateNode===null){e:{f=r.type,c=r.memoizedProps,v=v.ownerDocument||v;t:switch(f){case"title":b=v.getElementsByTagName("title")[0],(!b||b[cl]||b[wn]||b.namespaceURI==="http://www.w3.org/2000/svg"||b.hasAttribute("itemprop"))&&(b=v.createElement(f),v.head.insertBefore(b,v.querySelector("head > title"))),kn(b,f,c),b[wn]=r,gn(b),f=b;break e;case"link":var T=r1("link","href",v).get(f+(c.href||""));if(T){for(var P=0;P<T.length;P++)if(b=T[P],b.getAttribute("href")===(c.href==null||c.href===""?null:c.href)&&b.getAttribute("rel")===(c.rel==null?null:c.rel)&&b.getAttribute("title")===(c.title==null?null:c.title)&&b.getAttribute("crossorigin")===(c.crossOrigin==null?null:c.crossOrigin)){T.splice(P,1);break t}}b=v.createElement(f),kn(b,f,c),v.head.appendChild(b);break;case"meta":if(T=r1("meta","content",v).get(f+(c.content||""))){for(P=0;P<T.length;P++)if(b=T[P],b.getAttribute("content")===(c.content==null?null:""+c.content)&&b.getAttribute("name")===(c.name==null?null:c.name)&&b.getAttribute("property")===(c.property==null?null:c.property)&&b.getAttribute("http-equiv")===(c.httpEquiv==null?null:c.httpEquiv)&&b.getAttribute("charset")===(c.charSet==null?null:c.charSet)){T.splice(P,1);break t}}b=v.createElement(f),kn(b,f,c),v.head.appendChild(b);break;default:throw Error(s(468,f))}b[wn]=r,gn(b),f=b}r.stateNode=f}else a1(v,r.type,r.stateNode);else r.stateNode=s1(v,f,r.memoizedProps);else b!==f?(b===null?c.stateNode!==null&&(c=c.stateNode,c.parentNode.removeChild(c)):b.count--,f===null?a1(v,r.type,r.stateNode):s1(v,f,r.memoizedProps)):f===null&&r.stateNode!==null&&Hp(r,r.memoizedProps,c.memoizedProps)}break;case 27:Wn(i,r),Yn(r),f&512&&(on||c===null||Ks(c,c.return)),c!==null&&f&4&&Hp(r,r.memoizedProps,c.memoizedProps);break;case 5:if(Wn(i,r),Yn(r),f&512&&(on||c===null||Ks(c,c.return)),r.flags&32){v=r.stateNode;try{Li(v,"")}catch(Me){yt(r,r.return,Me)}}f&4&&r.stateNode!=null&&(v=r.memoizedProps,Hp(r,v,c!==null?c.memoizedProps:v)),f&1024&&(Wp=!0);break;case 6:if(Wn(i,r),Yn(r),f&4){if(r.stateNode===null)throw Error(s(162));f=r.memoizedProps,c=r.stateNode;try{c.nodeValue=f}catch(Me){yt(r,r.return,Me)}}break;case 3:if(id=null,v=Os,Os=rd(i.containerInfo),Wn(i,r),Os=v,Yn(r),f&4&&c!==null&&c.memoizedState.isDehydrated)try{go(i.containerInfo)}catch(Me){yt(r,r.return,Me)}Wp&&(Wp=!1,aw(r));break;case 4:f=Os,Os=rd(r.stateNode.containerInfo),Wn(i,r),Yn(r),Os=f;break;case 12:Wn(i,r),Yn(r);break;case 31:Wn(i,r),Yn(r),f&4&&(f=r.updateQueue,f!==null&&(r.updateQueue=null,Hu(r,f)));break;case 13:Wn(i,r),Yn(r),r.child.flags&8192&&r.memoizedState!==null!=(c!==null&&c.memoizedState!==null)&&(Zu=Ne()),f&4&&(f=r.updateQueue,f!==null&&(r.updateQueue=null,Hu(r,f)));break;case 22:v=r.memoizedState!==null;var Z=c!==null&&c.memoizedState!==null,ne=Nr,le=on;if(Nr=ne||v,on=le||Z,Wn(i,r),on=le,Nr=ne,Yn(r),f&8192)e:for(i=r.stateNode,i._visibility=v?i._visibility&-2:i._visibility|1,v&&(c===null||Z||Nr||on||ei(r)),c=null,i=r;;){if(i.tag===5||i.tag===26){if(c===null){Z=c=i;try{if(b=Z.stateNode,v)T=b.style,typeof T.setProperty=="function"?T.setProperty("display","none","important"):T.display="none";else{P=Z.stateNode;var pe=Z.memoizedProps.style,se=pe!=null&&pe.hasOwnProperty("display")?pe.display:null;P.style.display=se==null||typeof se=="boolean"?"":(""+se).trim()}}catch(Me){yt(Z,Z.return,Me)}}}else if(i.tag===6){if(c===null){Z=i;try{Z.stateNode.nodeValue=v?"":Z.memoizedProps}catch(Me){yt(Z,Z.return,Me)}}}else if(i.tag===18){if(c===null){Z=i;try{var ae=Z.stateNode;v?Yw(ae,!0):Yw(Z.stateNode,!1)}catch(Me){yt(Z,Z.return,Me)}}}else if((i.tag!==22&&i.tag!==23||i.memoizedState===null||i===r)&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break e;for(;i.sibling===null;){if(i.return===null||i.return===r)break e;c===i&&(c=null),i=i.return}c===i&&(c=null),i.sibling.return=i.return,i=i.sibling}f&4&&(f=r.updateQueue,f!==null&&(c=f.retryQueue,c!==null&&(f.retryQueue=null,Hu(r,c))));break;case 19:Wn(i,r),Yn(r),f&4&&(f=r.updateQueue,f!==null&&(r.updateQueue=null,Hu(r,f)));break;case 30:break;case 21:break;default:Wn(i,r),Yn(r)}}function Yn(r){var i=r.flags;if(i&2){try{for(var c,f=r.return;f!==null;){if(K0(f)){c=f;break}f=f.return}if(c==null)throw Error(s(160));switch(c.tag){case 27:var v=c.stateNode,b=qp(r);Fu(r,b,v);break;case 5:var T=c.stateNode;c.flags&32&&(Li(T,""),c.flags&=-33);var P=qp(r);Fu(r,P,T);break;case 3:case 4:var Z=c.stateNode.containerInfo,ne=qp(r);Zp(r,ne,Z);break;default:throw Error(s(161))}}catch(le){yt(r,r.return,le)}r.flags&=-3}i&4096&&(r.flags&=-4097)}function aw(r){if(r.subtreeFlags&1024)for(r=r.child;r!==null;){var i=r;aw(i),i.tag===5&&i.flags&1024&&i.stateNode.reset(),r=r.sibling}}function Er(r,i){if(i.subtreeFlags&8772)for(i=i.child;i!==null;)Q0(r,i.alternate,i),i=i.sibling}function ei(r){for(r=r.child;r!==null;){var i=r;switch(i.tag){case 0:case 11:case 14:case 15:Xr(4,i,i.return),ei(i);break;case 1:Ks(i,i.return);var c=i.stateNode;typeof c.componentWillUnmount=="function"&&Y0(i,i.return,c),ei(i);break;case 27:ql(i.stateNode);case 26:case 5:Ks(i,i.return),ei(i);break;case 22:i.memoizedState===null&&ei(i);break;case 30:ei(i);break;default:ei(i)}r=r.sibling}}function Cr(r,i,c){for(c=c&&(i.subtreeFlags&8772)!==0,i=i.child;i!==null;){var f=i.alternate,v=r,b=i,T=b.flags;switch(b.tag){case 0:case 11:case 15:Cr(v,b,c),Dl(4,b);break;case 1:if(Cr(v,b,c),f=b,v=f.stateNode,typeof v.componentDidMount=="function")try{v.componentDidMount()}catch(ne){yt(f,f.return,ne)}if(f=b,v=f.updateQueue,v!==null){var P=f.stateNode;try{var Z=v.shared.hiddenCallbacks;if(Z!==null)for(v.shared.hiddenCallbacks=null,v=0;v<Z.length;v++)Px(Z[v],P)}catch(ne){yt(f,f.return,ne)}}c&&T&64&&W0(b),Pl(b,b.return);break;case 27:X0(b);case 26:case 5:Cr(v,b,c),c&&f===null&&T&4&&G0(b),Pl(b,b.return);break;case 12:Cr(v,b,c);break;case 31:Cr(v,b,c),c&&T&4&&nw(v,b);break;case 13:Cr(v,b,c),c&&T&4&&sw(v,b);break;case 22:b.memoizedState===null&&Cr(v,b,c),Pl(b,b.return);break;case 30:break;default:Cr(v,b,c)}i=i.sibling}}function Yp(r,i){var c=null;r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(c=r.memoizedState.cachePool.pool),r=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(r=i.memoizedState.cachePool.pool),r!==c&&(r!=null&&r.refCount++,c!=null&&jl(c))}function Gp(r,i){r=null,i.alternate!==null&&(r=i.alternate.memoizedState.cache),i=i.memoizedState.cache,i!==r&&(i.refCount++,r!=null&&jl(r))}function Is(r,i,c,f){if(i.subtreeFlags&10256)for(i=i.child;i!==null;)iw(r,i,c,f),i=i.sibling}function iw(r,i,c,f){var v=i.flags;switch(i.tag){case 0:case 11:case 15:Is(r,i,c,f),v&2048&&Dl(9,i);break;case 1:Is(r,i,c,f);break;case 3:Is(r,i,c,f),v&2048&&(r=null,i.alternate!==null&&(r=i.alternate.memoizedState.cache),i=i.memoizedState.cache,i!==r&&(i.refCount++,r!=null&&jl(r)));break;case 12:if(v&2048){Is(r,i,c,f),r=i.stateNode;try{var b=i.memoizedProps,T=b.id,P=b.onPostCommit;typeof P=="function"&&P(T,i.alternate===null?"mount":"update",r.passiveEffectDuration,-0)}catch(Z){yt(i,i.return,Z)}}else Is(r,i,c,f);break;case 31:Is(r,i,c,f);break;case 13:Is(r,i,c,f);break;case 23:break;case 22:b=i.stateNode,T=i.alternate,i.memoizedState!==null?b._visibility&2?Is(r,i,c,f):zl(r,i):b._visibility&2?Is(r,i,c,f):(b._visibility|=2,ro(r,i,c,f,(i.subtreeFlags&10256)!==0||!1)),v&2048&&Yp(T,i);break;case 24:Is(r,i,c,f),v&2048&&Gp(i.alternate,i);break;default:Is(r,i,c,f)}}function ro(r,i,c,f,v){for(v=v&&((i.subtreeFlags&10256)!==0||!1),i=i.child;i!==null;){var b=r,T=i,P=c,Z=f,ne=T.flags;switch(T.tag){case 0:case 11:case 15:ro(b,T,P,Z,v),Dl(8,T);break;case 23:break;case 22:var le=T.stateNode;T.memoizedState!==null?le._visibility&2?ro(b,T,P,Z,v):zl(b,T):(le._visibility|=2,ro(b,T,P,Z,v)),v&&ne&2048&&Yp(T.alternate,T);break;case 24:ro(b,T,P,Z,v),v&&ne&2048&&Gp(T.alternate,T);break;default:ro(b,T,P,Z,v)}i=i.sibling}}function zl(r,i){if(i.subtreeFlags&10256)for(i=i.child;i!==null;){var c=r,f=i,v=f.flags;switch(f.tag){case 22:zl(c,f),v&2048&&Yp(f.alternate,f);break;case 24:zl(c,f),v&2048&&Gp(f.alternate,f);break;default:zl(c,f)}i=i.sibling}}var Ll=8192;function ao(r,i,c){if(r.subtreeFlags&Ll)for(r=r.child;r!==null;)ow(r,i,c),r=r.sibling}function ow(r,i,c){switch(r.tag){case 26:ao(r,i,c),r.flags&Ll&&r.memoizedState!==null&&tO(c,Os,r.memoizedState,r.memoizedProps);break;case 5:ao(r,i,c);break;case 3:case 4:var f=Os;Os=rd(r.stateNode.containerInfo),ao(r,i,c),Os=f;break;case 22:r.memoizedState===null&&(f=r.alternate,f!==null&&f.memoizedState!==null?(f=Ll,Ll=16777216,ao(r,i,c),Ll=f):ao(r,i,c));break;default:ao(r,i,c)}}function lw(r){var i=r.alternate;if(i!==null&&(r=i.child,r!==null)){i.child=null;do i=r.sibling,r.sibling=null,r=i;while(r!==null)}}function $l(r){var i=r.deletions;if((r.flags&16)!==0){if(i!==null)for(var c=0;c<i.length;c++){var f=i[c];vn=f,uw(f,r)}lw(r)}if(r.subtreeFlags&10256)for(r=r.child;r!==null;)cw(r),r=r.sibling}function cw(r){switch(r.tag){case 0:case 11:case 15:$l(r),r.flags&2048&&Xr(9,r,r.return);break;case 3:$l(r);break;case 12:$l(r);break;case 22:var i=r.stateNode;r.memoizedState!==null&&i._visibility&2&&(r.return===null||r.return.tag!==13)?(i._visibility&=-3,qu(r)):$l(r);break;default:$l(r)}}function qu(r){var i=r.deletions;if((r.flags&16)!==0){if(i!==null)for(var c=0;c<i.length;c++){var f=i[c];vn=f,uw(f,r)}lw(r)}for(r=r.child;r!==null;){switch(i=r,i.tag){case 0:case 11:case 15:Xr(8,i,i.return),qu(i);break;case 22:c=i.stateNode,c._visibility&2&&(c._visibility&=-3,qu(i));break;default:qu(i)}r=r.sibling}}function uw(r,i){for(;vn!==null;){var c=vn;switch(c.tag){case 0:case 11:case 15:Xr(8,c,i);break;case 23:case 22:if(c.memoizedState!==null&&c.memoizedState.cachePool!==null){var f=c.memoizedState.cachePool.pool;f!=null&&f.refCount++}break;case 24:jl(c.memoizedState.cache)}if(f=c.child,f!==null)f.return=c,vn=f;else e:for(c=r;vn!==null;){f=vn;var v=f.sibling,b=f.return;if(ew(f),f===c){vn=null;break e}if(v!==null){v.return=b,vn=v;break e}vn=b}}}var g2={getCacheForType:function(r){var i=Sn(sn),c=i.data.get(r);return c===void 0&&(c=r(),i.data.set(r,c)),c},cacheSignal:function(){return Sn(sn).controller.signal}},v2=typeof WeakMap=="function"?WeakMap:Map,pt=0,Ct=null,nt=null,it=0,vt=0,is=null,Jr=!1,io=!1,Kp=!1,Tr=0,Gt=0,Qr=0,ti=0,Xp=0,os=0,oo=0,Ul=null,Gn=null,Jp=!1,Zu=0,dw=0,Wu=1/0,Yu=null,ea=null,hn=0,ta=null,lo=null,Ar=0,Qp=0,em=null,fw=null,Bl=0,tm=null;function ls(){return(pt&2)!==0&&it!==0?it&-it:$.T!==null?om():xn()}function hw(){if(os===0)if((it&536870912)===0||ct){var r=Mn;Mn<<=1,(Mn&3932160)===0&&(Mn=262144),os=r}else os=536870912;return r=rs.current,r!==null&&(r.flags|=32),os}function Kn(r,i,c){(r===Ct&&(vt===2||vt===9)||r.cancelPendingCommit!==null)&&(co(r,0),na(r,it,os,!1)),be(r,c),((pt&2)===0||r!==Ct)&&(r===Ct&&((pt&2)===0&&(ti|=c),Gt===4&&na(r,it,os,!1)),Xs(r))}function pw(r,i,c){if((pt&6)!==0)throw Error(s(327));var f=!c&&(i&127)===0&&(i&r.expiredLanes)===0||Zs(r,i),v=f?x2(r,i):sm(r,i,!0),b=f;do{if(v===0){io&&!f&&na(r,i,0,!1);break}else{if(c=r.current.alternate,b&&!y2(c)){v=sm(r,i,!1),b=!1;continue}if(v===2){if(b=i,r.errorRecoveryDisabledLanes&b)var T=0;else T=r.pendingLanes&-536870913,T=T!==0?T:T&536870912?536870912:0;if(T!==0){i=T;e:{var P=r;v=Ul;var Z=P.current.memoizedState.isDehydrated;if(Z&&(co(P,T).flags|=256),T=sm(P,T,!1),T!==2){if(Kp&&!Z){P.errorRecoveryDisabledLanes|=b,ti|=b,v=4;break e}b=Gn,Gn=v,b!==null&&(Gn===null?Gn=b:Gn.push.apply(Gn,b))}v=T}if(b=!1,v!==2)continue}}if(v===1){co(r,0),na(r,i,0,!0);break}e:{switch(f=r,b=v,b){case 0:case 1:throw Error(s(345));case 4:if((i&4194048)!==i)break;case 6:na(f,i,os,!Jr);break e;case 2:Gn=null;break;case 3:case 5:break;default:throw Error(s(329))}if((i&62914560)===i&&(v=Zu+300-Ne(),10<v)){if(na(f,i,os,!Jr),qs(f,0,!0)!==0)break e;Ar=i,f.timeoutHandle=qw(mw.bind(null,f,c,Gn,Yu,Jp,i,os,ti,oo,Jr,b,"Throttled",-0,0),v);break e}mw(f,c,Gn,Yu,Jp,i,os,ti,oo,Jr,b,null,-0,0)}}break}while(!0);Xs(r)}function mw(r,i,c,f,v,b,T,P,Z,ne,le,pe,se,ae){if(r.timeoutHandle=-1,pe=i.subtreeFlags,pe&8192||(pe&16785408)===16785408){pe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:pr},ow(i,b,pe);var Me=(b&62914560)===b?Zu-Ne():(b&4194048)===b?dw-Ne():0;if(Me=nO(pe,Me),Me!==null){Ar=b,r.cancelPendingCommit=Me(Sw.bind(null,r,i,b,c,f,v,T,P,Z,le,pe,null,se,ae)),na(r,b,T,!ne);return}}Sw(r,i,b,c,f,v,T,P,Z)}function y2(r){for(var i=r;;){var c=i.tag;if((c===0||c===11||c===15)&&i.flags&16384&&(c=i.updateQueue,c!==null&&(c=c.stores,c!==null)))for(var f=0;f<c.length;f++){var v=c[f],b=v.getSnapshot;v=v.value;try{if(!ns(b(),v))return!1}catch{return!1}}if(c=i.child,i.subtreeFlags&16384&&c!==null)c.return=i,i=c;else{if(i===r)break;for(;i.sibling===null;){if(i.return===null||i.return===r)return!0;i=i.return}i.sibling.return=i.return,i=i.sibling}}return!0}function na(r,i,c,f){i&=~Xp,i&=~ti,r.suspendedLanes|=i,r.pingedLanes&=~i,f&&(r.warmLanes|=i),f=r.expirationTimes;for(var v=i;0<v;){var b=31-lt(v),T=1<<b;f[b]=-1,v&=~T}c!==0&&Ze(r,c,i)}function Gu(){return(pt&6)===0?(Vl(0),!1):!0}function nm(){if(nt!==null){if(vt===0)var r=nt.return;else r=nt,yr=Za=null,yp(r),Qi=null,Nl=0,r=nt;for(;r!==null;)Z0(r.alternate,r),r=r.return;nt=null}}function co(r,i){var c=r.timeoutHandle;c!==-1&&(r.timeoutHandle=-1,L2(c)),c=r.cancelPendingCommit,c!==null&&(r.cancelPendingCommit=null,c()),Ar=0,nm(),Ct=r,nt=c=gr(r.current,null),it=i,vt=0,is=null,Jr=!1,io=Zs(r,i),Kp=!1,oo=os=Xp=ti=Qr=Gt=0,Gn=Ul=null,Jp=!1,(i&8)!==0&&(i|=i&32);var f=r.entangledLanes;if(f!==0)for(r=r.entanglements,f&=i;0<f;){var v=31-lt(f),b=1<<v;i|=r[v],f&=~b}return Tr=i,gu(),c}function gw(r,i){Je=null,$.H=_l,i===Ji||i===Nu?(i=_x(),vt=3):i===ip?(i=_x(),vt=4):vt=i===Ip?8:i!==null&&typeof i=="object"&&typeof i.then=="function"?6:1,is=i,nt===null&&(Gt=1,Lu(r,vs(i,r.current)))}function vw(){var r=rs.current;return r===null?!0:(it&4194048)===it?ws===null:(it&62914560)===it||(it&536870912)!==0?r===ws:!1}function yw(){var r=$.H;return $.H=_l,r===null?_l:r}function bw(){var r=$.A;return $.A=g2,r}function Ku(){Gt=4,Jr||(it&4194048)!==it&&rs.current!==null||(io=!0),(Qr&134217727)===0&&(ti&134217727)===0||Ct===null||na(Ct,it,os,!1)}function sm(r,i,c){var f=pt;pt|=2;var v=yw(),b=bw();(Ct!==r||it!==i)&&(Yu=null,co(r,i)),i=!1;var T=Gt;e:do try{if(vt!==0&&nt!==null){var P=nt,Z=is;switch(vt){case 8:nm(),T=6;break e;case 3:case 2:case 9:case 6:rs.current===null&&(i=!0);var ne=vt;if(vt=0,is=null,uo(r,P,Z,ne),c&&io){T=0;break e}break;default:ne=vt,vt=0,is=null,uo(r,P,Z,ne)}}b2(),T=Gt;break}catch(le){gw(r,le)}while(!0);return i&&r.shellSuspendCounter++,yr=Za=null,pt=f,$.H=v,$.A=b,nt===null&&(Ct=null,it=0,gu()),T}function b2(){for(;nt!==null;)xw(nt)}function x2(r,i){var c=pt;pt|=2;var f=yw(),v=bw();Ct!==r||it!==i?(Yu=null,Wu=Ne()+500,co(r,i)):io=Zs(r,i);e:do try{if(vt!==0&&nt!==null){i=nt;var b=is;t:switch(vt){case 1:vt=0,is=null,uo(r,i,b,1);break;case 2:case 9:if(Rx(b)){vt=0,is=null,ww(i);break}i=function(){vt!==2&&vt!==9||Ct!==r||(vt=7),Xs(r)},b.then(i,i);break e;case 3:vt=7;break e;case 4:vt=5;break e;case 7:Rx(b)?(vt=0,is=null,ww(i)):(vt=0,is=null,uo(r,i,b,7));break;case 5:var T=null;switch(nt.tag){case 26:T=nt.memoizedState;case 5:case 27:var P=nt;if(T?i1(T):P.stateNode.complete){vt=0,is=null;var Z=P.sibling;if(Z!==null)nt=Z;else{var ne=P.return;ne!==null?(nt=ne,Xu(ne)):nt=null}break t}}vt=0,is=null,uo(r,i,b,5);break;case 6:vt=0,is=null,uo(r,i,b,6);break;case 8:nm(),Gt=6;break e;default:throw Error(s(462))}}w2();break}catch(le){gw(r,le)}while(!0);return yr=Za=null,$.H=f,$.A=v,pt=c,nt!==null?0:(Ct=null,it=0,gu(),Gt)}function w2(){for(;nt!==null&&!ve();)xw(nt)}function xw(r){var i=H0(r.alternate,r,Tr);r.memoizedProps=r.pendingProps,i===null?Xu(r):nt=i}function ww(r){var i=r,c=i.alternate;switch(i.tag){case 15:case 0:i=L0(c,i,i.pendingProps,i.type,void 0,it);break;case 11:i=L0(c,i,i.pendingProps,i.type.render,i.ref,it);break;case 5:yp(i);default:Z0(c,i),i=nt=bx(i,Tr),i=H0(c,i,Tr)}r.memoizedProps=r.pendingProps,i===null?Xu(r):nt=i}function uo(r,i,c,f){yr=Za=null,yp(i),Qi=null,Nl=0;var v=i.return;try{if(c2(r,v,i,c,it)){Gt=1,Lu(r,vs(c,r.current)),nt=null;return}}catch(b){if(v!==null)throw nt=v,b;Gt=1,Lu(r,vs(c,r.current)),nt=null;return}i.flags&32768?(ct||f===1?r=!0:io||(it&536870912)!==0?r=!1:(Jr=r=!0,(f===2||f===9||f===3||f===6)&&(f=rs.current,f!==null&&f.tag===13&&(f.flags|=16384))),jw(i,r)):Xu(i)}function Xu(r){var i=r;do{if((i.flags&32768)!==0){jw(i,Jr);return}r=i.return;var c=f2(i.alternate,i,Tr);if(c!==null){nt=c;return}if(i=i.sibling,i!==null){nt=i;return}nt=i=r}while(i!==null);Gt===0&&(Gt=5)}function jw(r,i){do{var c=h2(r.alternate,r);if(c!==null){c.flags&=32767,nt=c;return}if(c=r.return,c!==null&&(c.flags|=32768,c.subtreeFlags=0,c.deletions=null),!i&&(r=r.sibling,r!==null)){nt=r;return}nt=r=c}while(r!==null);Gt=6,nt=null}function Sw(r,i,c,f,v,b,T,P,Z){r.cancelPendingCommit=null;do Ju();while(hn!==0);if((pt&6)!==0)throw Error(s(327));if(i!==null){if(i===r.current)throw Error(s(177));if(b=i.lanes|i.childLanes,b|=qh,qe(r,c,b,T,P,Z),r===Ct&&(nt=Ct=null,it=0),lo=i,ta=r,Ar=c,Qp=b,em=v,fw=f,(i.subtreeFlags&10256)!==0||(i.flags&10256)!==0?(r.callbackNode=null,r.callbackPriority=0,k2(Pe,function(){return Tw(),null})):(r.callbackNode=null,r.callbackPriority=0),f=(i.flags&13878)!==0,(i.subtreeFlags&13878)!==0||f){f=$.T,$.T=null,v=L.p,L.p=2,T=pt,pt|=4;try{p2(r,i,c)}finally{pt=T,L.p=v,$.T=f}}hn=1,Nw(),kw(),Ew()}}function Nw(){if(hn===1){hn=0;var r=ta,i=lo,c=(i.flags&13878)!==0;if((i.subtreeFlags&13878)!==0||c){c=$.T,$.T=null;var f=L.p;L.p=2;var v=pt;pt|=4;try{rw(i,r);var b=mm,T=ux(r.containerInfo),P=b.focusedElem,Z=b.selectionRange;if(T!==P&&P&&P.ownerDocument&&cx(P.ownerDocument.documentElement,P)){if(Z!==null&&Uh(P)){var ne=Z.start,le=Z.end;if(le===void 0&&(le=ne),"selectionStart"in P)P.selectionStart=ne,P.selectionEnd=Math.min(le,P.value.length);else{var pe=P.ownerDocument||document,se=pe&&pe.defaultView||window;if(se.getSelection){var ae=se.getSelection(),Me=P.textContent.length,Fe=Math.min(Z.start,Me),St=Z.end===void 0?Fe:Math.min(Z.end,Me);!ae.extend&&Fe>St&&(T=St,St=Fe,Fe=T);var J=lx(P,Fe),K=lx(P,St);if(J&&K&&(ae.rangeCount!==1||ae.anchorNode!==J.node||ae.anchorOffset!==J.offset||ae.focusNode!==K.node||ae.focusOffset!==K.offset)){var te=pe.createRange();te.setStart(J.node,J.offset),ae.removeAllRanges(),Fe>St?(ae.addRange(te),ae.extend(K.node,K.offset)):(te.setEnd(K.node,K.offset),ae.addRange(te))}}}}for(pe=[],ae=P;ae=ae.parentNode;)ae.nodeType===1&&pe.push({element:ae,left:ae.scrollLeft,top:ae.scrollTop});for(typeof P.focus=="function"&&P.focus(),P=0;P<pe.length;P++){var fe=pe[P];fe.element.scrollLeft=fe.left,fe.element.scrollTop=fe.top}}ud=!!pm,mm=pm=null}finally{pt=v,L.p=f,$.T=c}}r.current=i,hn=2}}function kw(){if(hn===2){hn=0;var r=ta,i=lo,c=(i.flags&8772)!==0;if((i.subtreeFlags&8772)!==0||c){c=$.T,$.T=null;var f=L.p;L.p=2;var v=pt;pt|=4;try{Q0(r,i.alternate,i)}finally{pt=v,L.p=f,$.T=c}}hn=3}}function Ew(){if(hn===4||hn===3){hn=0,xe();var r=ta,i=lo,c=Ar,f=fw;(i.subtreeFlags&10256)!==0||(i.flags&10256)!==0?hn=5:(hn=0,lo=ta=null,Cw(r,r.pendingLanes));var v=r.pendingLanes;if(v===0&&(ea=null),mn(c),i=i.stateNode,ze&&typeof ze.onCommitFiberRoot=="function")try{ze.onCommitFiberRoot(Jt,i,void 0,(i.current.flags&128)===128)}catch{}if(f!==null){i=$.T,v=L.p,L.p=2,$.T=null;try{for(var b=r.onRecoverableError,T=0;T<f.length;T++){var P=f[T];b(P.value,{componentStack:P.stack})}}finally{$.T=i,L.p=v}}(Ar&3)!==0&&Ju(),Xs(r),v=r.pendingLanes,(c&261930)!==0&&(v&42)!==0?r===tm?Bl++:(Bl=0,tm=r):Bl=0,Vl(0)}}function Cw(r,i){(r.pooledCacheLanes&=i)===0&&(i=r.pooledCache,i!=null&&(r.pooledCache=null,jl(i)))}function Ju(){return Nw(),kw(),Ew(),Tw()}function Tw(){if(hn!==5)return!1;var r=ta,i=Qp;Qp=0;var c=mn(Ar),f=$.T,v=L.p;try{L.p=32>c?32:c,$.T=null,c=em,em=null;var b=ta,T=Ar;if(hn=0,lo=ta=null,Ar=0,(pt&6)!==0)throw Error(s(331));var P=pt;if(pt|=4,cw(b.current),iw(b,b.current,T,c),pt=P,Vl(0,!1),ze&&typeof ze.onPostCommitFiberRoot=="function")try{ze.onPostCommitFiberRoot(Jt,b)}catch{}return!0}finally{L.p=v,$.T=f,Cw(r,i)}}function Aw(r,i,c){i=vs(c,i),i=Op(r.stateNode,i,2),r=Yr(r,i,2),r!==null&&(be(r,2),Xs(r))}function yt(r,i,c){if(r.tag===3)Aw(r,r,c);else for(;i!==null;){if(i.tag===3){Aw(i,r,c);break}else if(i.tag===1){var f=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof f.componentDidCatch=="function"&&(ea===null||!ea.has(f))){r=vs(c,r),c=R0(2),f=Yr(i,c,2),f!==null&&(M0(c,f,i,r),be(f,2),Xs(f));break}}i=i.return}}function rm(r,i,c){var f=r.pingCache;if(f===null){f=r.pingCache=new v2;var v=new Set;f.set(i,v)}else v=f.get(i),v===void 0&&(v=new Set,f.set(i,v));v.has(c)||(Kp=!0,v.add(c),r=j2.bind(null,r,i,c),i.then(r,r))}function j2(r,i,c){var f=r.pingCache;f!==null&&f.delete(i),r.pingedLanes|=r.suspendedLanes&c,r.warmLanes&=~c,Ct===r&&(it&c)===c&&(Gt===4||Gt===3&&(it&62914560)===it&&300>Ne()-Zu?(pt&2)===0&&co(r,0):Xp|=c,oo===it&&(oo=0)),Xs(r)}function Rw(r,i){i===0&&(i=ee()),r=Fa(r,i),r!==null&&(be(r,i),Xs(r))}function S2(r){var i=r.memoizedState,c=0;i!==null&&(c=i.retryLane),Rw(r,c)}function N2(r,i){var c=0;switch(r.tag){case 31:case 13:var f=r.stateNode,v=r.memoizedState;v!==null&&(c=v.retryLane);break;case 19:f=r.stateNode;break;case 22:f=r.stateNode._retryCache;break;default:throw Error(s(314))}f!==null&&f.delete(i),Rw(r,c)}function k2(r,i){return Be(r,i)}var Qu=null,fo=null,am=!1,ed=!1,im=!1,sa=0;function Xs(r){r!==fo&&r.next===null&&(fo===null?Qu=fo=r:fo=fo.next=r),ed=!0,am||(am=!0,C2())}function Vl(r,i){if(!im&&ed){im=!0;do for(var c=!1,f=Qu;f!==null;){if(r!==0){var v=f.pendingLanes;if(v===0)var b=0;else{var T=f.suspendedLanes,P=f.pingedLanes;b=(1<<31-lt(42|r)+1)-1,b&=v&~(T&~P),b=b&201326741?b&201326741|1:b?b|2:0}b!==0&&(c=!0,Iw(f,b))}else b=it,b=qs(f,f===Ct?b:0,f.cancelPendingCommit!==null||f.timeoutHandle!==-1),(b&3)===0||Zs(f,b)||(c=!0,Iw(f,b));f=f.next}while(c);im=!1}}function E2(){Mw()}function Mw(){ed=am=!1;var r=0;sa!==0&&z2()&&(r=sa);for(var i=Ne(),c=null,f=Qu;f!==null;){var v=f.next,b=_w(f,i);b===0?(f.next=null,c===null?Qu=v:c.next=v,v===null&&(fo=c)):(c=f,(r!==0||(b&3)!==0)&&(ed=!0)),f=v}hn!==0&&hn!==5||Vl(r),sa!==0&&(sa=0)}function _w(r,i){for(var c=r.suspendedLanes,f=r.pingedLanes,v=r.expirationTimes,b=r.pendingLanes&-62914561;0<b;){var T=31-lt(b),P=1<<T,Z=v[T];Z===-1?((P&c)===0||(P&f)!==0)&&(v[T]=Mi(P,i)):Z<=i&&(r.expiredLanes|=P),b&=~P}if(i=Ct,c=it,c=qs(r,r===i?c:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),f=r.callbackNode,c===0||r===i&&(vt===2||vt===9)||r.cancelPendingCommit!==null)return f!==null&&f!==null&&oe(f),r.callbackNode=null,r.callbackPriority=0;if((c&3)===0||Zs(r,c)){if(i=c&-c,i===r.callbackPriority)return i;switch(f!==null&&oe(f),mn(c)){case 2:case 8:c=$e;break;case 32:c=Pe;break;case 268435456:c=kt;break;default:c=Pe}return f=Ow.bind(null,r),c=Be(c,f),r.callbackPriority=i,r.callbackNode=c,i}return f!==null&&f!==null&&oe(f),r.callbackPriority=2,r.callbackNode=null,2}function Ow(r,i){if(hn!==0&&hn!==5)return r.callbackNode=null,r.callbackPriority=0,null;var c=r.callbackNode;if(Ju()&&r.callbackNode!==c)return null;var f=it;return f=qs(r,r===Ct?f:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),f===0?null:(pw(r,f,i),_w(r,Ne()),r.callbackNode!=null&&r.callbackNode===c?Ow.bind(null,r):null)}function Iw(r,i){if(Ju())return null;pw(r,i,!0)}function C2(){$2(function(){(pt&6)!==0?Be(Se,E2):Mw()})}function om(){if(sa===0){var r=Ki;r===0&&(r=Wt,Wt<<=1,(Wt&261888)===0&&(Wt=256)),sa=r}return sa}function Dw(r){return r==null||typeof r=="symbol"||typeof r=="boolean"?null:typeof r=="function"?r:lu(""+r)}function Pw(r,i){var c=i.ownerDocument.createElement("input");return c.name=i.name,c.value=i.value,r.id&&c.setAttribute("form",r.id),i.parentNode.insertBefore(c,i),r=new FormData(r),c.parentNode.removeChild(c),r}function T2(r,i,c,f,v){if(i==="submit"&&c&&c.stateNode===v){var b=Dw((v[Hn]||null).action),T=f.submitter;T&&(i=(i=T[Hn]||null)?Dw(i.formAction):T.getAttribute("formAction"),i!==null&&(b=i,T=null));var P=new fu("action","action",null,f,v);r.push({event:P,listeners:[{instance:null,listener:function(){if(f.defaultPrevented){if(sa!==0){var Z=T?Pw(v,T):new FormData(v);Cp(c,{pending:!0,data:Z,method:v.method,action:b},null,Z)}}else typeof b=="function"&&(P.preventDefault(),Z=T?Pw(v,T):new FormData(v),Cp(c,{pending:!0,data:Z,method:v.method,action:b},b,Z))},currentTarget:v}]})}}for(var lm=0;lm<Hh.length;lm++){var cm=Hh[lm],A2=cm.toLowerCase(),R2=cm[0].toUpperCase()+cm.slice(1);_s(A2,"on"+R2)}_s(hx,"onAnimationEnd"),_s(px,"onAnimationIteration"),_s(mx,"onAnimationStart"),_s("dblclick","onDoubleClick"),_s("focusin","onFocus"),_s("focusout","onBlur"),_s(Z_,"onTransitionRun"),_s(W_,"onTransitionStart"),_s(Y_,"onTransitionCancel"),_s(gx,"onTransitionEnd"),Pi("onMouseEnter",["mouseout","mouseover"]),Pi("onMouseLeave",["mouseout","mouseover"]),Pi("onPointerEnter",["pointerout","pointerover"]),Pi("onPointerLeave",["pointerout","pointerover"]),$a("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),$a("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),$a("onBeforeInput",["compositionend","keypress","textInput","paste"]),$a("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),$a("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),$a("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Fl="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),M2=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Fl));function zw(r,i){i=(i&4)!==0;for(var c=0;c<r.length;c++){var f=r[c],v=f.event;f=f.listeners;e:{var b=void 0;if(i)for(var T=f.length-1;0<=T;T--){var P=f[T],Z=P.instance,ne=P.currentTarget;if(P=P.listener,Z!==b&&v.isPropagationStopped())break e;b=P,v.currentTarget=ne;try{b(v)}catch(le){mu(le)}v.currentTarget=null,b=Z}else for(T=0;T<f.length;T++){if(P=f[T],Z=P.instance,ne=P.currentTarget,P=P.listener,Z!==b&&v.isPropagationStopped())break e;b=P,v.currentTarget=ne;try{b(v)}catch(le){mu(le)}v.currentTarget=null,b=Z}}}}function st(r,i){var c=i[jh];c===void 0&&(c=i[jh]=new Set);var f=r+"__bubble";c.has(f)||(Lw(i,r,2,!1),c.add(f))}function um(r,i,c){var f=0;i&&(f|=4),Lw(c,r,f,i)}var td="_reactListening"+Math.random().toString(36).slice(2);function dm(r){if(!r[td]){r[td]=!0,Mb.forEach(function(c){c!=="selectionchange"&&(M2.has(c)||um(c,!1,r),um(c,!0,r))});var i=r.nodeType===9?r:r.ownerDocument;i===null||i[td]||(i[td]=!0,um("selectionchange",!1,i))}}function Lw(r,i,c,f){switch(h1(i)){case 2:var v=aO;break;case 8:v=iO;break;default:v=Em}c=v.bind(null,i,c,r),v=void 0,!Mh||i!=="touchstart"&&i!=="touchmove"&&i!=="wheel"||(v=!0),f?v!==void 0?r.addEventListener(i,c,{capture:!0,passive:v}):r.addEventListener(i,c,!0):v!==void 0?r.addEventListener(i,c,{passive:v}):r.addEventListener(i,c,!1)}function fm(r,i,c,f,v){var b=f;if((i&1)===0&&(i&2)===0&&f!==null)e:for(;;){if(f===null)return;var T=f.tag;if(T===3||T===4){var P=f.stateNode.containerInfo;if(P===v)break;if(T===4)for(T=f.return;T!==null;){var Z=T.tag;if((Z===3||Z===4)&&T.stateNode.containerInfo===v)return;T=T.return}for(;P!==null;){if(T=Oi(P),T===null)return;if(Z=T.tag,Z===5||Z===6||Z===26||Z===27){f=b=T;continue e}P=P.parentNode}}f=f.return}Fb(function(){var ne=b,le=Ah(c),pe=[];e:{var se=vx.get(r);if(se!==void 0){var ae=fu,Me=r;switch(r){case"keypress":if(uu(c)===0)break e;case"keydown":case"keyup":ae=N_;break;case"focusin":Me="focus",ae=Dh;break;case"focusout":Me="blur",ae=Dh;break;case"beforeblur":case"afterblur":ae=Dh;break;case"click":if(c.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ae=Zb;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ae=f_;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ae=C_;break;case hx:case px:case mx:ae=m_;break;case gx:ae=A_;break;case"scroll":case"scrollend":ae=u_;break;case"wheel":ae=M_;break;case"copy":case"cut":case"paste":ae=v_;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ae=Yb;break;case"toggle":case"beforetoggle":ae=O_}var Fe=(i&4)!==0,St=!Fe&&(r==="scroll"||r==="scrollend"),J=Fe?se!==null?se+"Capture":null:se;Fe=[];for(var K=ne,te;K!==null;){var fe=K;if(te=fe.stateNode,fe=fe.tag,fe!==5&&fe!==26&&fe!==27||te===null||J===null||(fe=dl(K,J),fe!=null&&Fe.push(Hl(K,fe,te))),St)break;K=K.return}0<Fe.length&&(se=new ae(se,Me,null,c,le),pe.push({event:se,listeners:Fe}))}}if((i&7)===0){e:{if(se=r==="mouseover"||r==="pointerover",ae=r==="mouseout"||r==="pointerout",se&&c!==Th&&(Me=c.relatedTarget||c.fromElement)&&(Oi(Me)||Me[_i]))break e;if((ae||se)&&(se=le.window===le?le:(se=le.ownerDocument)?se.defaultView||se.parentWindow:window,ae?(Me=c.relatedTarget||c.toElement,ae=ne,Me=Me?Oi(Me):null,Me!==null&&(St=l(Me),Fe=Me.tag,Me!==St||Fe!==5&&Fe!==27&&Fe!==6)&&(Me=null)):(ae=null,Me=ne),ae!==Me)){if(Fe=Zb,fe="onMouseLeave",J="onMouseEnter",K="mouse",(r==="pointerout"||r==="pointerover")&&(Fe=Yb,fe="onPointerLeave",J="onPointerEnter",K="pointer"),St=ae==null?se:ul(ae),te=Me==null?se:ul(Me),se=new Fe(fe,K+"leave",ae,c,le),se.target=St,se.relatedTarget=te,fe=null,Oi(le)===ne&&(Fe=new Fe(J,K+"enter",Me,c,le),Fe.target=te,Fe.relatedTarget=St,fe=Fe),St=fe,ae&&Me)t:{for(Fe=_2,J=ae,K=Me,te=0,fe=J;fe;fe=Fe(fe))te++;fe=0;for(var Le=K;Le;Le=Fe(Le))fe++;for(;0<te-fe;)J=Fe(J),te--;for(;0<fe-te;)K=Fe(K),fe--;for(;te--;){if(J===K||K!==null&&J===K.alternate){Fe=J;break t}J=Fe(J),K=Fe(K)}Fe=null}else Fe=null;ae!==null&&$w(pe,se,ae,Fe,!1),Me!==null&&St!==null&&$w(pe,St,Me,Fe,!0)}}e:{if(se=ne?ul(ne):window,ae=se.nodeName&&se.nodeName.toLowerCase(),ae==="select"||ae==="input"&&se.type==="file")var ft=nx;else if(ex(se))if(sx)ft=F_;else{ft=B_;var Oe=U_}else ae=se.nodeName,!ae||ae.toLowerCase()!=="input"||se.type!=="checkbox"&&se.type!=="radio"?ne&&Ch(ne.elementType)&&(ft=nx):ft=V_;if(ft&&(ft=ft(r,ne))){tx(pe,ft,c,le);break e}Oe&&Oe(r,se,ne),r==="focusout"&&ne&&se.type==="number"&&ne.memoizedProps.value!=null&&Eh(se,"number",se.value)}switch(Oe=ne?ul(ne):window,r){case"focusin":(ex(Oe)||Oe.contentEditable==="true")&&(Vi=Oe,Bh=ne,bl=null);break;case"focusout":bl=Bh=Vi=null;break;case"mousedown":Vh=!0;break;case"contextmenu":case"mouseup":case"dragend":Vh=!1,dx(pe,c,le);break;case"selectionchange":if(q_)break;case"keydown":case"keyup":dx(pe,c,le)}var Qe;if(zh)e:{switch(r){case"compositionstart":var ot="onCompositionStart";break e;case"compositionend":ot="onCompositionEnd";break e;case"compositionupdate":ot="onCompositionUpdate";break e}ot=void 0}else Bi?Jb(r,c)&&(ot="onCompositionEnd"):r==="keydown"&&c.keyCode===229&&(ot="onCompositionStart");ot&&(Gb&&c.locale!=="ko"&&(Bi||ot!=="onCompositionStart"?ot==="onCompositionEnd"&&Bi&&(Qe=Hb()):(Br=le,_h="value"in Br?Br.value:Br.textContent,Bi=!0)),Oe=nd(ne,ot),0<Oe.length&&(ot=new Wb(ot,r,null,c,le),pe.push({event:ot,listeners:Oe}),Qe?ot.data=Qe:(Qe=Qb(c),Qe!==null&&(ot.data=Qe)))),(Qe=D_?P_(r,c):z_(r,c))&&(ot=nd(ne,"onBeforeInput"),0<ot.length&&(Oe=new Wb("onBeforeInput","beforeinput",null,c,le),pe.push({event:Oe,listeners:ot}),Oe.data=Qe)),T2(pe,r,ne,c,le)}zw(pe,i)})}function Hl(r,i,c){return{instance:r,listener:i,currentTarget:c}}function nd(r,i){for(var c=i+"Capture",f=[];r!==null;){var v=r,b=v.stateNode;if(v=v.tag,v!==5&&v!==26&&v!==27||b===null||(v=dl(r,c),v!=null&&f.unshift(Hl(r,v,b)),v=dl(r,i),v!=null&&f.push(Hl(r,v,b))),r.tag===3)return f;r=r.return}return[]}function _2(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5&&r.tag!==27);return r||null}function $w(r,i,c,f,v){for(var b=i._reactName,T=[];c!==null&&c!==f;){var P=c,Z=P.alternate,ne=P.stateNode;if(P=P.tag,Z!==null&&Z===f)break;P!==5&&P!==26&&P!==27||ne===null||(Z=ne,v?(ne=dl(c,b),ne!=null&&T.unshift(Hl(c,ne,Z))):v||(ne=dl(c,b),ne!=null&&T.push(Hl(c,ne,Z)))),c=c.return}T.length!==0&&r.push({event:i,listeners:T})}var O2=/\r\n?/g,I2=/\u0000|\uFFFD/g;function Uw(r){return(typeof r=="string"?r:""+r).replace(O2,`
|
|
9
|
-
`).replace(I2,"")}function Bw(r,i){return i=Uw(i),Uw(r)===i}function jt(r,i,c,f,v,b){switch(c){case"children":typeof f=="string"?i==="body"||i==="textarea"&&f===""||Li(r,f):(typeof f=="number"||typeof f=="bigint")&&i!=="body"&&Li(r,""+f);break;case"className":iu(r,"class",f);break;case"tabIndex":iu(r,"tabindex",f);break;case"dir":case"role":case"viewBox":case"width":case"height":iu(r,c,f);break;case"style":Bb(r,f,b);break;case"data":if(i!=="object"){iu(r,"data",f);break}case"src":case"href":if(f===""&&(i!=="a"||c!=="href")){r.removeAttribute(c);break}if(f==null||typeof f=="function"||typeof f=="symbol"||typeof f=="boolean"){r.removeAttribute(c);break}f=lu(""+f),r.setAttribute(c,f);break;case"action":case"formAction":if(typeof f=="function"){r.setAttribute(c,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof b=="function"&&(c==="formAction"?(i!=="input"&&jt(r,i,"name",v.name,v,null),jt(r,i,"formEncType",v.formEncType,v,null),jt(r,i,"formMethod",v.formMethod,v,null),jt(r,i,"formTarget",v.formTarget,v,null)):(jt(r,i,"encType",v.encType,v,null),jt(r,i,"method",v.method,v,null),jt(r,i,"target",v.target,v,null)));if(f==null||typeof f=="symbol"||typeof f=="boolean"){r.removeAttribute(c);break}f=lu(""+f),r.setAttribute(c,f);break;case"onClick":f!=null&&(r.onclick=pr);break;case"onScroll":f!=null&&st("scroll",r);break;case"onScrollEnd":f!=null&&st("scrollend",r);break;case"dangerouslySetInnerHTML":if(f!=null){if(typeof f!="object"||!("__html"in f))throw Error(s(61));if(c=f.__html,c!=null){if(v.children!=null)throw Error(s(60));r.innerHTML=c}}break;case"multiple":r.multiple=f&&typeof f!="function"&&typeof f!="symbol";break;case"muted":r.muted=f&&typeof f!="function"&&typeof f!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(f==null||typeof f=="function"||typeof f=="boolean"||typeof f=="symbol"){r.removeAttribute("xlink:href");break}c=lu(""+f),r.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",c);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":f!=null&&typeof f!="function"&&typeof f!="symbol"?r.setAttribute(c,""+f):r.removeAttribute(c);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":f&&typeof f!="function"&&typeof f!="symbol"?r.setAttribute(c,""):r.removeAttribute(c);break;case"capture":case"download":f===!0?r.setAttribute(c,""):f!==!1&&f!=null&&typeof f!="function"&&typeof f!="symbol"?r.setAttribute(c,f):r.removeAttribute(c);break;case"cols":case"rows":case"size":case"span":f!=null&&typeof f!="function"&&typeof f!="symbol"&&!isNaN(f)&&1<=f?r.setAttribute(c,f):r.removeAttribute(c);break;case"rowSpan":case"start":f==null||typeof f=="function"||typeof f=="symbol"||isNaN(f)?r.removeAttribute(c):r.setAttribute(c,f);break;case"popover":st("beforetoggle",r),st("toggle",r),au(r,"popover",f);break;case"xlinkActuate":hr(r,"http://www.w3.org/1999/xlink","xlink:actuate",f);break;case"xlinkArcrole":hr(r,"http://www.w3.org/1999/xlink","xlink:arcrole",f);break;case"xlinkRole":hr(r,"http://www.w3.org/1999/xlink","xlink:role",f);break;case"xlinkShow":hr(r,"http://www.w3.org/1999/xlink","xlink:show",f);break;case"xlinkTitle":hr(r,"http://www.w3.org/1999/xlink","xlink:title",f);break;case"xlinkType":hr(r,"http://www.w3.org/1999/xlink","xlink:type",f);break;case"xmlBase":hr(r,"http://www.w3.org/XML/1998/namespace","xml:base",f);break;case"xmlLang":hr(r,"http://www.w3.org/XML/1998/namespace","xml:lang",f);break;case"xmlSpace":hr(r,"http://www.w3.org/XML/1998/namespace","xml:space",f);break;case"is":au(r,"is",f);break;case"innerText":case"textContent":break;default:(!(2<c.length)||c[0]!=="o"&&c[0]!=="O"||c[1]!=="n"&&c[1]!=="N")&&(c=l_.get(c)||c,au(r,c,f))}}function hm(r,i,c,f,v,b){switch(c){case"style":Bb(r,f,b);break;case"dangerouslySetInnerHTML":if(f!=null){if(typeof f!="object"||!("__html"in f))throw Error(s(61));if(c=f.__html,c!=null){if(v.children!=null)throw Error(s(60));r.innerHTML=c}}break;case"children":typeof f=="string"?Li(r,f):(typeof f=="number"||typeof f=="bigint")&&Li(r,""+f);break;case"onScroll":f!=null&&st("scroll",r);break;case"onScrollEnd":f!=null&&st("scrollend",r);break;case"onClick":f!=null&&(r.onclick=pr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!_b.hasOwnProperty(c))e:{if(c[0]==="o"&&c[1]==="n"&&(v=c.endsWith("Capture"),i=c.slice(2,v?c.length-7:void 0),b=r[Hn]||null,b=b!=null?b[c]:null,typeof b=="function"&&r.removeEventListener(i,b,v),typeof f=="function")){typeof b!="function"&&b!==null&&(c in r?r[c]=null:r.hasAttribute(c)&&r.removeAttribute(c)),r.addEventListener(i,f,v);break e}c in r?r[c]=f:f===!0?r.setAttribute(c,""):au(r,c,f)}}}function kn(r,i,c){switch(i){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":st("error",r),st("load",r);var f=!1,v=!1,b;for(b in c)if(c.hasOwnProperty(b)){var T=c[b];if(T!=null)switch(b){case"src":f=!0;break;case"srcSet":v=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,i));default:jt(r,i,b,T,c,null)}}v&&jt(r,i,"srcSet",c.srcSet,c,null),f&&jt(r,i,"src",c.src,c,null);return;case"input":st("invalid",r);var P=b=T=v=null,Z=null,ne=null;for(f in c)if(c.hasOwnProperty(f)){var le=c[f];if(le!=null)switch(f){case"name":v=le;break;case"type":T=le;break;case"checked":Z=le;break;case"defaultChecked":ne=le;break;case"value":b=le;break;case"defaultValue":P=le;break;case"children":case"dangerouslySetInnerHTML":if(le!=null)throw Error(s(137,i));break;default:jt(r,i,f,le,c,null)}}zb(r,b,P,Z,ne,T,v,!1);return;case"select":st("invalid",r),f=T=b=null;for(v in c)if(c.hasOwnProperty(v)&&(P=c[v],P!=null))switch(v){case"value":b=P;break;case"defaultValue":T=P;break;case"multiple":f=P;default:jt(r,i,v,P,c,null)}i=b,c=T,r.multiple=!!f,i!=null?zi(r,!!f,i,!1):c!=null&&zi(r,!!f,c,!0);return;case"textarea":st("invalid",r),b=v=f=null;for(T in c)if(c.hasOwnProperty(T)&&(P=c[T],P!=null))switch(T){case"value":f=P;break;case"defaultValue":v=P;break;case"children":b=P;break;case"dangerouslySetInnerHTML":if(P!=null)throw Error(s(91));break;default:jt(r,i,T,P,c,null)}$b(r,f,v,b);return;case"option":for(Z in c)c.hasOwnProperty(Z)&&(f=c[Z],f!=null)&&(Z==="selected"?r.selected=f&&typeof f!="function"&&typeof f!="symbol":jt(r,i,Z,f,c,null));return;case"dialog":st("beforetoggle",r),st("toggle",r),st("cancel",r),st("close",r);break;case"iframe":case"object":st("load",r);break;case"video":case"audio":for(f=0;f<Fl.length;f++)st(Fl[f],r);break;case"image":st("error",r),st("load",r);break;case"details":st("toggle",r);break;case"embed":case"source":case"link":st("error",r),st("load",r);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(ne in c)if(c.hasOwnProperty(ne)&&(f=c[ne],f!=null))switch(ne){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,i));default:jt(r,i,ne,f,c,null)}return;default:if(Ch(i)){for(le in c)c.hasOwnProperty(le)&&(f=c[le],f!==void 0&&hm(r,i,le,f,c,void 0));return}}for(P in c)c.hasOwnProperty(P)&&(f=c[P],f!=null&&jt(r,i,P,f,c,null))}function D2(r,i,c,f){switch(i){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var v=null,b=null,T=null,P=null,Z=null,ne=null,le=null;for(ae in c){var pe=c[ae];if(c.hasOwnProperty(ae)&&pe!=null)switch(ae){case"checked":break;case"value":break;case"defaultValue":Z=pe;default:f.hasOwnProperty(ae)||jt(r,i,ae,null,f,pe)}}for(var se in f){var ae=f[se];if(pe=c[se],f.hasOwnProperty(se)&&(ae!=null||pe!=null))switch(se){case"type":b=ae;break;case"name":v=ae;break;case"checked":ne=ae;break;case"defaultChecked":le=ae;break;case"value":T=ae;break;case"defaultValue":P=ae;break;case"children":case"dangerouslySetInnerHTML":if(ae!=null)throw Error(s(137,i));break;default:ae!==pe&&jt(r,i,se,ae,f,pe)}}kh(r,T,P,Z,ne,le,b,v);return;case"select":ae=T=P=se=null;for(b in c)if(Z=c[b],c.hasOwnProperty(b)&&Z!=null)switch(b){case"value":break;case"multiple":ae=Z;default:f.hasOwnProperty(b)||jt(r,i,b,null,f,Z)}for(v in f)if(b=f[v],Z=c[v],f.hasOwnProperty(v)&&(b!=null||Z!=null))switch(v){case"value":se=b;break;case"defaultValue":P=b;break;case"multiple":T=b;default:b!==Z&&jt(r,i,v,b,f,Z)}i=P,c=T,f=ae,se!=null?zi(r,!!c,se,!1):!!f!=!!c&&(i!=null?zi(r,!!c,i,!0):zi(r,!!c,c?[]:"",!1));return;case"textarea":ae=se=null;for(P in c)if(v=c[P],c.hasOwnProperty(P)&&v!=null&&!f.hasOwnProperty(P))switch(P){case"value":break;case"children":break;default:jt(r,i,P,null,f,v)}for(T in f)if(v=f[T],b=c[T],f.hasOwnProperty(T)&&(v!=null||b!=null))switch(T){case"value":se=v;break;case"defaultValue":ae=v;break;case"children":break;case"dangerouslySetInnerHTML":if(v!=null)throw Error(s(91));break;default:v!==b&&jt(r,i,T,v,f,b)}Lb(r,se,ae);return;case"option":for(var Me in c)se=c[Me],c.hasOwnProperty(Me)&&se!=null&&!f.hasOwnProperty(Me)&&(Me==="selected"?r.selected=!1:jt(r,i,Me,null,f,se));for(Z in f)se=f[Z],ae=c[Z],f.hasOwnProperty(Z)&&se!==ae&&(se!=null||ae!=null)&&(Z==="selected"?r.selected=se&&typeof se!="function"&&typeof se!="symbol":jt(r,i,Z,se,f,ae));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Fe in c)se=c[Fe],c.hasOwnProperty(Fe)&&se!=null&&!f.hasOwnProperty(Fe)&&jt(r,i,Fe,null,f,se);for(ne in f)if(se=f[ne],ae=c[ne],f.hasOwnProperty(ne)&&se!==ae&&(se!=null||ae!=null))switch(ne){case"children":case"dangerouslySetInnerHTML":if(se!=null)throw Error(s(137,i));break;default:jt(r,i,ne,se,f,ae)}return;default:if(Ch(i)){for(var St in c)se=c[St],c.hasOwnProperty(St)&&se!==void 0&&!f.hasOwnProperty(St)&&hm(r,i,St,void 0,f,se);for(le in f)se=f[le],ae=c[le],!f.hasOwnProperty(le)||se===ae||se===void 0&&ae===void 0||hm(r,i,le,se,f,ae);return}}for(var J in c)se=c[J],c.hasOwnProperty(J)&&se!=null&&!f.hasOwnProperty(J)&&jt(r,i,J,null,f,se);for(pe in f)se=f[pe],ae=c[pe],!f.hasOwnProperty(pe)||se===ae||se==null&&ae==null||jt(r,i,pe,se,f,ae)}function Vw(r){switch(r){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function P2(){if(typeof performance.getEntriesByType=="function"){for(var r=0,i=0,c=performance.getEntriesByType("resource"),f=0;f<c.length;f++){var v=c[f],b=v.transferSize,T=v.initiatorType,P=v.duration;if(b&&P&&Vw(T)){for(T=0,P=v.responseEnd,f+=1;f<c.length;f++){var Z=c[f],ne=Z.startTime;if(ne>P)break;var le=Z.transferSize,pe=Z.initiatorType;le&&Vw(pe)&&(Z=Z.responseEnd,T+=le*(Z<P?1:(P-ne)/(Z-ne)))}if(--f,i+=8*(b+T)/(v.duration/1e3),r++,10<r)break}}if(0<r)return i/r/1e6}return navigator.connection&&(r=navigator.connection.downlink,typeof r=="number")?r:5}var pm=null,mm=null;function sd(r){return r.nodeType===9?r:r.ownerDocument}function Fw(r){switch(r){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Hw(r,i){if(r===0)switch(i){case"svg":return 1;case"math":return 2;default:return 0}return r===1&&i==="foreignObject"?0:r}function gm(r,i){return r==="textarea"||r==="noscript"||typeof i.children=="string"||typeof i.children=="number"||typeof i.children=="bigint"||typeof i.dangerouslySetInnerHTML=="object"&&i.dangerouslySetInnerHTML!==null&&i.dangerouslySetInnerHTML.__html!=null}var vm=null;function z2(){var r=window.event;return r&&r.type==="popstate"?r===vm?!1:(vm=r,!0):(vm=null,!1)}var qw=typeof setTimeout=="function"?setTimeout:void 0,L2=typeof clearTimeout=="function"?clearTimeout:void 0,Zw=typeof Promise=="function"?Promise:void 0,$2=typeof queueMicrotask=="function"?queueMicrotask:typeof Zw<"u"?function(r){return Zw.resolve(null).then(r).catch(U2)}:qw;function U2(r){setTimeout(function(){throw r})}function ra(r){return r==="head"}function Ww(r,i){var c=i,f=0;do{var v=c.nextSibling;if(r.removeChild(c),v&&v.nodeType===8)if(c=v.data,c==="/$"||c==="/&"){if(f===0){r.removeChild(v),go(i);return}f--}else if(c==="$"||c==="$?"||c==="$~"||c==="$!"||c==="&")f++;else if(c==="html")ql(r.ownerDocument.documentElement);else if(c==="head"){c=r.ownerDocument.head,ql(c);for(var b=c.firstChild;b;){var T=b.nextSibling,P=b.nodeName;b[cl]||P==="SCRIPT"||P==="STYLE"||P==="LINK"&&b.rel.toLowerCase()==="stylesheet"||c.removeChild(b),b=T}}else c==="body"&&ql(r.ownerDocument.body);c=v}while(c);go(i)}function Yw(r,i){var c=r;r=0;do{var f=c.nextSibling;if(c.nodeType===1?i?(c._stashedDisplay=c.style.display,c.style.display="none"):(c.style.display=c._stashedDisplay||"",c.getAttribute("style")===""&&c.removeAttribute("style")):c.nodeType===3&&(i?(c._stashedText=c.nodeValue,c.nodeValue=""):c.nodeValue=c._stashedText||""),f&&f.nodeType===8)if(c=f.data,c==="/$"){if(r===0)break;r--}else c!=="$"&&c!=="$?"&&c!=="$~"&&c!=="$!"||r++;c=f}while(c)}function ym(r){var i=r.firstChild;for(i&&i.nodeType===10&&(i=i.nextSibling);i;){var c=i;switch(i=i.nextSibling,c.nodeName){case"HTML":case"HEAD":case"BODY":ym(c),Sh(c);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(c.rel.toLowerCase()==="stylesheet")continue}r.removeChild(c)}}function B2(r,i,c,f){for(;r.nodeType===1;){var v=c;if(r.nodeName.toLowerCase()!==i.toLowerCase()){if(!f&&(r.nodeName!=="INPUT"||r.type!=="hidden"))break}else if(f){if(!r[cl])switch(i){case"meta":if(!r.hasAttribute("itemprop"))break;return r;case"link":if(b=r.getAttribute("rel"),b==="stylesheet"&&r.hasAttribute("data-precedence"))break;if(b!==v.rel||r.getAttribute("href")!==(v.href==null||v.href===""?null:v.href)||r.getAttribute("crossorigin")!==(v.crossOrigin==null?null:v.crossOrigin)||r.getAttribute("title")!==(v.title==null?null:v.title))break;return r;case"style":if(r.hasAttribute("data-precedence"))break;return r;case"script":if(b=r.getAttribute("src"),(b!==(v.src==null?null:v.src)||r.getAttribute("type")!==(v.type==null?null:v.type)||r.getAttribute("crossorigin")!==(v.crossOrigin==null?null:v.crossOrigin))&&b&&r.hasAttribute("async")&&!r.hasAttribute("itemprop"))break;return r;default:return r}}else if(i==="input"&&r.type==="hidden"){var b=v.name==null?null:""+v.name;if(v.type==="hidden"&&r.getAttribute("name")===b)return r}else return r;if(r=js(r.nextSibling),r===null)break}return null}function V2(r,i,c){if(i==="")return null;for(;r.nodeType!==3;)if((r.nodeType!==1||r.nodeName!=="INPUT"||r.type!=="hidden")&&!c||(r=js(r.nextSibling),r===null))return null;return r}function Gw(r,i){for(;r.nodeType!==8;)if((r.nodeType!==1||r.nodeName!=="INPUT"||r.type!=="hidden")&&!i||(r=js(r.nextSibling),r===null))return null;return r}function bm(r){return r.data==="$?"||r.data==="$~"}function xm(r){return r.data==="$!"||r.data==="$?"&&r.ownerDocument.readyState!=="loading"}function F2(r,i){var c=r.ownerDocument;if(r.data==="$~")r._reactRetry=i;else if(r.data!=="$?"||c.readyState!=="loading")i();else{var f=function(){i(),c.removeEventListener("DOMContentLoaded",f)};c.addEventListener("DOMContentLoaded",f),r._reactRetry=f}}function js(r){for(;r!=null;r=r.nextSibling){var i=r.nodeType;if(i===1||i===3)break;if(i===8){if(i=r.data,i==="$"||i==="$!"||i==="$?"||i==="$~"||i==="&"||i==="F!"||i==="F")break;if(i==="/$"||i==="/&")return null}}return r}var wm=null;function Kw(r){r=r.nextSibling;for(var i=0;r;){if(r.nodeType===8){var c=r.data;if(c==="/$"||c==="/&"){if(i===0)return js(r.nextSibling);i--}else c!=="$"&&c!=="$!"&&c!=="$?"&&c!=="$~"&&c!=="&"||i++}r=r.nextSibling}return null}function Xw(r){r=r.previousSibling;for(var i=0;r;){if(r.nodeType===8){var c=r.data;if(c==="$"||c==="$!"||c==="$?"||c==="$~"||c==="&"){if(i===0)return r;i--}else c!=="/$"&&c!=="/&"||i++}r=r.previousSibling}return null}function Jw(r,i,c){switch(i=sd(c),r){case"html":if(r=i.documentElement,!r)throw Error(s(452));return r;case"head":if(r=i.head,!r)throw Error(s(453));return r;case"body":if(r=i.body,!r)throw Error(s(454));return r;default:throw Error(s(451))}}function ql(r){for(var i=r.attributes;i.length;)r.removeAttributeNode(i[0]);Sh(r)}var Ss=new Map,Qw=new Set;function rd(r){return typeof r.getRootNode=="function"?r.getRootNode():r.nodeType===9?r:r.ownerDocument}var Rr=L.d;L.d={f:H2,r:q2,D:Z2,C:W2,L:Y2,m:G2,X:X2,S:K2,M:J2};function H2(){var r=Rr.f(),i=Gu();return r||i}function q2(r){var i=Ii(r);i!==null&&i.tag===5&&i.type==="form"?g0(i):Rr.r(r)}var ho=typeof document>"u"?null:document;function e1(r,i,c){var f=ho;if(f&&typeof i=="string"&&i){var v=ms(i);v='link[rel="'+r+'"][href="'+v+'"]',typeof c=="string"&&(v+='[crossorigin="'+c+'"]'),Qw.has(v)||(Qw.add(v),r={rel:r,crossOrigin:c,href:i},f.querySelector(v)===null&&(i=f.createElement("link"),kn(i,"link",r),gn(i),f.head.appendChild(i)))}}function Z2(r){Rr.D(r),e1("dns-prefetch",r,null)}function W2(r,i){Rr.C(r,i),e1("preconnect",r,i)}function Y2(r,i,c){Rr.L(r,i,c);var f=ho;if(f&&r&&i){var v='link[rel="preload"][as="'+ms(i)+'"]';i==="image"&&c&&c.imageSrcSet?(v+='[imagesrcset="'+ms(c.imageSrcSet)+'"]',typeof c.imageSizes=="string"&&(v+='[imagesizes="'+ms(c.imageSizes)+'"]')):v+='[href="'+ms(r)+'"]';var b=v;switch(i){case"style":b=po(r);break;case"script":b=mo(r)}Ss.has(b)||(r=y({rel:"preload",href:i==="image"&&c&&c.imageSrcSet?void 0:r,as:i},c),Ss.set(b,r),f.querySelector(v)!==null||i==="style"&&f.querySelector(Zl(b))||i==="script"&&f.querySelector(Wl(b))||(i=f.createElement("link"),kn(i,"link",r),gn(i),f.head.appendChild(i)))}}function G2(r,i){Rr.m(r,i);var c=ho;if(c&&r){var f=i&&typeof i.as=="string"?i.as:"script",v='link[rel="modulepreload"][as="'+ms(f)+'"][href="'+ms(r)+'"]',b=v;switch(f){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":b=mo(r)}if(!Ss.has(b)&&(r=y({rel:"modulepreload",href:r},i),Ss.set(b,r),c.querySelector(v)===null)){switch(f){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(c.querySelector(Wl(b)))return}f=c.createElement("link"),kn(f,"link",r),gn(f),c.head.appendChild(f)}}}function K2(r,i,c){Rr.S(r,i,c);var f=ho;if(f&&r){var v=Di(f).hoistableStyles,b=po(r);i=i||"default";var T=v.get(b);if(!T){var P={loading:0,preload:null};if(T=f.querySelector(Zl(b)))P.loading=5;else{r=y({rel:"stylesheet",href:r,"data-precedence":i},c),(c=Ss.get(b))&&jm(r,c);var Z=T=f.createElement("link");gn(Z),kn(Z,"link",r),Z._p=new Promise(function(ne,le){Z.onload=ne,Z.onerror=le}),Z.addEventListener("load",function(){P.loading|=1}),Z.addEventListener("error",function(){P.loading|=2}),P.loading|=4,ad(T,i,f)}T={type:"stylesheet",instance:T,count:1,state:P},v.set(b,T)}}}function X2(r,i){Rr.X(r,i);var c=ho;if(c&&r){var f=Di(c).hoistableScripts,v=mo(r),b=f.get(v);b||(b=c.querySelector(Wl(v)),b||(r=y({src:r,async:!0},i),(i=Ss.get(v))&&Sm(r,i),b=c.createElement("script"),gn(b),kn(b,"link",r),c.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},f.set(v,b))}}function J2(r,i){Rr.M(r,i);var c=ho;if(c&&r){var f=Di(c).hoistableScripts,v=mo(r),b=f.get(v);b||(b=c.querySelector(Wl(v)),b||(r=y({src:r,async:!0,type:"module"},i),(i=Ss.get(v))&&Sm(r,i),b=c.createElement("script"),gn(b),kn(b,"link",r),c.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},f.set(v,b))}}function t1(r,i,c,f){var v=(v=re.current)?rd(v):null;if(!v)throw Error(s(446));switch(r){case"meta":case"title":return null;case"style":return typeof c.precedence=="string"&&typeof c.href=="string"?(i=po(c.href),c=Di(v).hoistableStyles,f=c.get(i),f||(f={type:"style",instance:null,count:0,state:null},c.set(i,f)),f):{type:"void",instance:null,count:0,state:null};case"link":if(c.rel==="stylesheet"&&typeof c.href=="string"&&typeof c.precedence=="string"){r=po(c.href);var b=Di(v).hoistableStyles,T=b.get(r);if(T||(v=v.ownerDocument||v,T={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},b.set(r,T),(b=v.querySelector(Zl(r)))&&!b._p&&(T.instance=b,T.state.loading=5),Ss.has(r)||(c={rel:"preload",as:"style",href:c.href,crossOrigin:c.crossOrigin,integrity:c.integrity,media:c.media,hrefLang:c.hrefLang,referrerPolicy:c.referrerPolicy},Ss.set(r,c),b||Q2(v,r,c,T.state))),i&&f===null)throw Error(s(528,""));return T}if(i&&f!==null)throw Error(s(529,""));return null;case"script":return i=c.async,c=c.src,typeof c=="string"&&i&&typeof i!="function"&&typeof i!="symbol"?(i=mo(c),c=Di(v).hoistableScripts,f=c.get(i),f||(f={type:"script",instance:null,count:0,state:null},c.set(i,f)),f):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,r))}}function po(r){return'href="'+ms(r)+'"'}function Zl(r){return'link[rel="stylesheet"]['+r+"]"}function n1(r){return y({},r,{"data-precedence":r.precedence,precedence:null})}function Q2(r,i,c,f){r.querySelector('link[rel="preload"][as="style"]['+i+"]")?f.loading=1:(i=r.createElement("link"),f.preload=i,i.addEventListener("load",function(){return f.loading|=1}),i.addEventListener("error",function(){return f.loading|=2}),kn(i,"link",c),gn(i),r.head.appendChild(i))}function mo(r){return'[src="'+ms(r)+'"]'}function Wl(r){return"script[async]"+r}function s1(r,i,c){if(i.count++,i.instance===null)switch(i.type){case"style":var f=r.querySelector('style[data-href~="'+ms(c.href)+'"]');if(f)return i.instance=f,gn(f),f;var v=y({},c,{"data-href":c.href,"data-precedence":c.precedence,href:null,precedence:null});return f=(r.ownerDocument||r).createElement("style"),gn(f),kn(f,"style",v),ad(f,c.precedence,r),i.instance=f;case"stylesheet":v=po(c.href);var b=r.querySelector(Zl(v));if(b)return i.state.loading|=4,i.instance=b,gn(b),b;f=n1(c),(v=Ss.get(v))&&jm(f,v),b=(r.ownerDocument||r).createElement("link"),gn(b);var T=b;return T._p=new Promise(function(P,Z){T.onload=P,T.onerror=Z}),kn(b,"link",f),i.state.loading|=4,ad(b,c.precedence,r),i.instance=b;case"script":return b=mo(c.src),(v=r.querySelector(Wl(b)))?(i.instance=v,gn(v),v):(f=c,(v=Ss.get(b))&&(f=y({},c),Sm(f,v)),r=r.ownerDocument||r,v=r.createElement("script"),gn(v),kn(v,"link",f),r.head.appendChild(v),i.instance=v);case"void":return null;default:throw Error(s(443,i.type))}else i.type==="stylesheet"&&(i.state.loading&4)===0&&(f=i.instance,i.state.loading|=4,ad(f,c.precedence,r));return i.instance}function ad(r,i,c){for(var f=c.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),v=f.length?f[f.length-1]:null,b=v,T=0;T<f.length;T++){var P=f[T];if(P.dataset.precedence===i)b=P;else if(b!==v)break}b?b.parentNode.insertBefore(r,b.nextSibling):(i=c.nodeType===9?c.head:c,i.insertBefore(r,i.firstChild))}function jm(r,i){r.crossOrigin==null&&(r.crossOrigin=i.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=i.referrerPolicy),r.title==null&&(r.title=i.title)}function Sm(r,i){r.crossOrigin==null&&(r.crossOrigin=i.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=i.referrerPolicy),r.integrity==null&&(r.integrity=i.integrity)}var id=null;function r1(r,i,c){if(id===null){var f=new Map,v=id=new Map;v.set(c,f)}else v=id,f=v.get(c),f||(f=new Map,v.set(c,f));if(f.has(r))return f;for(f.set(r,null),c=c.getElementsByTagName(r),v=0;v<c.length;v++){var b=c[v];if(!(b[cl]||b[wn]||r==="link"&&b.getAttribute("rel")==="stylesheet")&&b.namespaceURI!=="http://www.w3.org/2000/svg"){var T=b.getAttribute(i)||"";T=r+T;var P=f.get(T);P?P.push(b):f.set(T,[b])}}return f}function a1(r,i,c){r=r.ownerDocument||r,r.head.insertBefore(c,i==="title"?r.querySelector("head > title"):null)}function eO(r,i,c){if(c===1||i.itemProp!=null)return!1;switch(r){case"meta":case"title":return!0;case"style":if(typeof i.precedence!="string"||typeof i.href!="string"||i.href==="")break;return!0;case"link":if(typeof i.rel!="string"||typeof i.href!="string"||i.href===""||i.onLoad||i.onError)break;return i.rel==="stylesheet"?(r=i.disabled,typeof i.precedence=="string"&&r==null):!0;case"script":if(i.async&&typeof i.async!="function"&&typeof i.async!="symbol"&&!i.onLoad&&!i.onError&&i.src&&typeof i.src=="string")return!0}return!1}function i1(r){return!(r.type==="stylesheet"&&(r.state.loading&3)===0)}function tO(r,i,c,f){if(c.type==="stylesheet"&&(typeof f.media!="string"||matchMedia(f.media).matches!==!1)&&(c.state.loading&4)===0){if(c.instance===null){var v=po(f.href),b=i.querySelector(Zl(v));if(b){i=b._p,i!==null&&typeof i=="object"&&typeof i.then=="function"&&(r.count++,r=od.bind(r),i.then(r,r)),c.state.loading|=4,c.instance=b,gn(b);return}b=i.ownerDocument||i,f=n1(f),(v=Ss.get(v))&&jm(f,v),b=b.createElement("link"),gn(b);var T=b;T._p=new Promise(function(P,Z){T.onload=P,T.onerror=Z}),kn(b,"link",f),c.instance=b}r.stylesheets===null&&(r.stylesheets=new Map),r.stylesheets.set(c,i),(i=c.state.preload)&&(c.state.loading&3)===0&&(r.count++,c=od.bind(r),i.addEventListener("load",c),i.addEventListener("error",c))}}var Nm=0;function nO(r,i){return r.stylesheets&&r.count===0&&cd(r,r.stylesheets),0<r.count||0<r.imgCount?function(c){var f=setTimeout(function(){if(r.stylesheets&&cd(r,r.stylesheets),r.unsuspend){var b=r.unsuspend;r.unsuspend=null,b()}},6e4+i);0<r.imgBytes&&Nm===0&&(Nm=62500*P2());var v=setTimeout(function(){if(r.waitingForImages=!1,r.count===0&&(r.stylesheets&&cd(r,r.stylesheets),r.unsuspend)){var b=r.unsuspend;r.unsuspend=null,b()}},(r.imgBytes>Nm?50:800)+i);return r.unsuspend=c,function(){r.unsuspend=null,clearTimeout(f),clearTimeout(v)}}:null}function od(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)cd(this,this.stylesheets);else if(this.unsuspend){var r=this.unsuspend;this.unsuspend=null,r()}}}var ld=null;function cd(r,i){r.stylesheets=null,r.unsuspend!==null&&(r.count++,ld=new Map,i.forEach(sO,r),ld=null,od.call(r))}function sO(r,i){if(!(i.state.loading&4)){var c=ld.get(r);if(c)var f=c.get(null);else{c=new Map,ld.set(r,c);for(var v=r.querySelectorAll("link[data-precedence],style[data-precedence]"),b=0;b<v.length;b++){var T=v[b];(T.nodeName==="LINK"||T.getAttribute("media")!=="not all")&&(c.set(T.dataset.precedence,T),f=T)}f&&c.set(null,f)}v=i.instance,T=v.getAttribute("data-precedence"),b=c.get(T)||f,b===f&&c.set(null,v),c.set(T,v),this.count++,f=od.bind(this),v.addEventListener("load",f),v.addEventListener("error",f),b?b.parentNode.insertBefore(v,b.nextSibling):(r=r.nodeType===9?r.head:r,r.insertBefore(v,r.firstChild)),i.state.loading|=4}}var Yl={$$typeof:S,Provider:null,Consumer:null,_currentValue:F,_currentValue2:F,_threadCount:0};function rO(r,i,c,f,v,b,T,P,Z){this.tag=1,this.containerInfo=r,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=ge(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ge(0),this.hiddenUpdates=ge(null),this.identifierPrefix=f,this.onUncaughtError=v,this.onCaughtError=b,this.onRecoverableError=T,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Z,this.incompleteTransitions=new Map}function o1(r,i,c,f,v,b,T,P,Z,ne,le,pe){return r=new rO(r,i,c,T,Z,ne,le,pe,P),i=1,b===!0&&(i|=24),b=ss(3,null,null,i),r.current=b,b.stateNode=r,i=sp(),i.refCount++,r.pooledCache=i,i.refCount++,b.memoizedState={element:f,isDehydrated:c,cache:i},op(b),r}function l1(r){return r?(r=qi,r):qi}function c1(r,i,c,f,v,b){v=l1(v),f.context===null?f.context=v:f.pendingContext=v,f=Wr(i),f.payload={element:c},b=b===void 0?null:b,b!==null&&(f.callback=b),c=Yr(r,f,i),c!==null&&(Kn(c,r,i),El(c,r,i))}function u1(r,i){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var c=r.retryLane;r.retryLane=c!==0&&c<i?c:i}}function km(r,i){u1(r,i),(r=r.alternate)&&u1(r,i)}function d1(r){if(r.tag===13||r.tag===31){var i=Fa(r,67108864);i!==null&&Kn(i,r,67108864),km(r,67108864)}}function f1(r){if(r.tag===13||r.tag===31){var i=ls();i=Et(i);var c=Fa(r,i);c!==null&&Kn(c,r,i),km(r,i)}}var ud=!0;function aO(r,i,c,f){var v=$.T;$.T=null;var b=L.p;try{L.p=2,Em(r,i,c,f)}finally{L.p=b,$.T=v}}function iO(r,i,c,f){var v=$.T;$.T=null;var b=L.p;try{L.p=8,Em(r,i,c,f)}finally{L.p=b,$.T=v}}function Em(r,i,c,f){if(ud){var v=Cm(f);if(v===null)fm(r,i,f,dd,c),p1(r,f);else if(lO(v,r,i,c,f))f.stopPropagation();else if(p1(r,f),i&4&&-1<oO.indexOf(r)){for(;v!==null;){var b=Ii(v);if(b!==null)switch(b.tag){case 3:if(b=b.stateNode,b.current.memoizedState.isDehydrated){var T=fn(b.pendingLanes);if(T!==0){var P=b;for(P.pendingLanes|=2,P.entangledLanes|=2;T;){var Z=1<<31-lt(T);P.entanglements[1]|=Z,T&=~Z}Xs(b),(pt&6)===0&&(Wu=Ne()+500,Vl(0))}}break;case 31:case 13:P=Fa(b,2),P!==null&&Kn(P,b,2),Gu(),km(b,2)}if(b=Cm(f),b===null&&fm(r,i,f,dd,c),b===v)break;v=b}v!==null&&f.stopPropagation()}else fm(r,i,f,null,c)}}function Cm(r){return r=Ah(r),Tm(r)}var dd=null;function Tm(r){if(dd=null,r=Oi(r),r!==null){var i=l(r);if(i===null)r=null;else{var c=i.tag;if(c===13){if(r=u(i),r!==null)return r;r=null}else if(c===31){if(r=d(i),r!==null)return r;r=null}else if(c===3){if(i.stateNode.current.memoizedState.isDehydrated)return i.tag===3?i.stateNode.containerInfo:null;r=null}else i!==r&&(r=null)}}return dd=r,null}function h1(r){switch(r){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(ke()){case Se:return 2;case $e:return 8;case Pe:case xt:return 32;case kt:return 268435456;default:return 32}default:return 32}}var Am=!1,aa=null,ia=null,oa=null,Gl=new Map,Kl=new Map,la=[],oO="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function p1(r,i){switch(r){case"focusin":case"focusout":aa=null;break;case"dragenter":case"dragleave":ia=null;break;case"mouseover":case"mouseout":oa=null;break;case"pointerover":case"pointerout":Gl.delete(i.pointerId);break;case"gotpointercapture":case"lostpointercapture":Kl.delete(i.pointerId)}}function Xl(r,i,c,f,v,b){return r===null||r.nativeEvent!==b?(r={blockedOn:i,domEventName:c,eventSystemFlags:f,nativeEvent:b,targetContainers:[v]},i!==null&&(i=Ii(i),i!==null&&d1(i)),r):(r.eventSystemFlags|=f,i=r.targetContainers,v!==null&&i.indexOf(v)===-1&&i.push(v),r)}function lO(r,i,c,f,v){switch(i){case"focusin":return aa=Xl(aa,r,i,c,f,v),!0;case"dragenter":return ia=Xl(ia,r,i,c,f,v),!0;case"mouseover":return oa=Xl(oa,r,i,c,f,v),!0;case"pointerover":var b=v.pointerId;return Gl.set(b,Xl(Gl.get(b)||null,r,i,c,f,v)),!0;case"gotpointercapture":return b=v.pointerId,Kl.set(b,Xl(Kl.get(b)||null,r,i,c,f,v)),!0}return!1}function m1(r){var i=Oi(r.target);if(i!==null){var c=l(i);if(c!==null){if(i=c.tag,i===13){if(i=u(c),i!==null){r.blockedOn=i,Ws(r.priority,function(){f1(c)});return}}else if(i===31){if(i=d(c),i!==null){r.blockedOn=i,Ws(r.priority,function(){f1(c)});return}}else if(i===3&&c.stateNode.current.memoizedState.isDehydrated){r.blockedOn=c.tag===3?c.stateNode.containerInfo:null;return}}}r.blockedOn=null}function fd(r){if(r.blockedOn!==null)return!1;for(var i=r.targetContainers;0<i.length;){var c=Cm(r.nativeEvent);if(c===null){c=r.nativeEvent;var f=new c.constructor(c.type,c);Th=f,c.target.dispatchEvent(f),Th=null}else return i=Ii(c),i!==null&&d1(i),r.blockedOn=c,!1;i.shift()}return!0}function g1(r,i,c){fd(r)&&c.delete(i)}function cO(){Am=!1,aa!==null&&fd(aa)&&(aa=null),ia!==null&&fd(ia)&&(ia=null),oa!==null&&fd(oa)&&(oa=null),Gl.forEach(g1),Kl.forEach(g1)}function hd(r,i){r.blockedOn===i&&(r.blockedOn=null,Am||(Am=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,cO)))}var pd=null;function v1(r){pd!==r&&(pd=r,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){pd===r&&(pd=null);for(var i=0;i<r.length;i+=3){var c=r[i],f=r[i+1],v=r[i+2];if(typeof f!="function"){if(Tm(f||c)===null)continue;break}var b=Ii(c);b!==null&&(r.splice(i,3),i-=3,Cp(b,{pending:!0,data:v,method:c.method,action:f},f,v))}}))}function go(r){function i(Z){return hd(Z,r)}aa!==null&&hd(aa,r),ia!==null&&hd(ia,r),oa!==null&&hd(oa,r),Gl.forEach(i),Kl.forEach(i);for(var c=0;c<la.length;c++){var f=la[c];f.blockedOn===r&&(f.blockedOn=null)}for(;0<la.length&&(c=la[0],c.blockedOn===null);)m1(c),c.blockedOn===null&&la.shift();if(c=(r.ownerDocument||r).$$reactFormReplay,c!=null)for(f=0;f<c.length;f+=3){var v=c[f],b=c[f+1],T=v[Hn]||null;if(typeof b=="function")T||v1(c);else if(T){var P=null;if(b&&b.hasAttribute("formAction")){if(v=b,T=b[Hn]||null)P=T.formAction;else if(Tm(v)!==null)continue}else P=T.action;typeof P=="function"?c[f+1]=P:(c.splice(f,3),f-=3),v1(c)}}}function y1(){function r(b){b.canIntercept&&b.info==="react-transition"&&b.intercept({handler:function(){return new Promise(function(T){return v=T})},focusReset:"manual",scroll:"manual"})}function i(){v!==null&&(v(),v=null),f||setTimeout(c,20)}function c(){if(!f&&!navigation.transition){var b=navigation.currentEntry;b&&b.url!=null&&navigation.navigate(b.url,{state:b.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var f=!1,v=null;return navigation.addEventListener("navigate",r),navigation.addEventListener("navigatesuccess",i),navigation.addEventListener("navigateerror",i),setTimeout(c,100),function(){f=!0,navigation.removeEventListener("navigate",r),navigation.removeEventListener("navigatesuccess",i),navigation.removeEventListener("navigateerror",i),v!==null&&(v(),v=null)}}}function Rm(r){this._internalRoot=r}md.prototype.render=Rm.prototype.render=function(r){var i=this._internalRoot;if(i===null)throw Error(s(409));var c=i.current,f=ls();c1(c,f,r,i,null,null)},md.prototype.unmount=Rm.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var i=r.containerInfo;c1(r.current,2,null,r,null,null),Gu(),i[_i]=null}};function md(r){this._internalRoot=r}md.prototype.unstable_scheduleHydration=function(r){if(r){var i=xn();r={blockedOn:null,target:r,priority:i};for(var c=0;c<la.length&&i!==0&&i<la[c].priority;c++);la.splice(c,0,r),c===0&&m1(r)}};var b1=t.version;if(b1!=="19.2.3")throw Error(s(527,b1,"19.2.3"));L.findDOMNode=function(r){var i=r._reactInternals;if(i===void 0)throw typeof r.render=="function"?Error(s(188)):(r=Object.keys(r).join(","),Error(s(268,r)));return r=h(i),r=r!==null?m(r):null,r=r===null?null:r.stateNode,r};var uO={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:$,reconcilerVersion:"19.2.3"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var gd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!gd.isDisabled&&gd.supportsFiber)try{Jt=gd.inject(uO),ze=gd}catch{}}return Ql.createRoot=function(r,i){if(!a(r))throw Error(s(299));var c=!1,f="",v=E0,b=C0,T=T0;return i!=null&&(i.unstable_strictMode===!0&&(c=!0),i.identifierPrefix!==void 0&&(f=i.identifierPrefix),i.onUncaughtError!==void 0&&(v=i.onUncaughtError),i.onCaughtError!==void 0&&(b=i.onCaughtError),i.onRecoverableError!==void 0&&(T=i.onRecoverableError)),i=o1(r,1,!1,null,null,c,f,null,v,b,T,y1),r[_i]=i.current,dm(r),new Rm(i)},Ql.hydrateRoot=function(r,i,c){if(!a(r))throw Error(s(299));var f=!1,v="",b=E0,T=C0,P=T0,Z=null;return c!=null&&(c.unstable_strictMode===!0&&(f=!0),c.identifierPrefix!==void 0&&(v=c.identifierPrefix),c.onUncaughtError!==void 0&&(b=c.onUncaughtError),c.onCaughtError!==void 0&&(T=c.onCaughtError),c.onRecoverableError!==void 0&&(P=c.onRecoverableError),c.formState!==void 0&&(Z=c.formState)),i=o1(r,1,!0,i,c??null,f,v,Z,b,T,P,y1),i.context=l1(null),c=i.current,f=ls(),f=Et(f),v=Wr(f),v.callback=null,Yr(c,v,f),c=f,i.current.lanes=c,be(i,c),Xs(i),r[_i]=i.current,dm(r),new md(i)},Ql.version="19.2.3",Ql}var A1;function xO(){if(A1)return Om.exports;A1=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Om.exports=bO(),Om.exports}var wO=xO();const zk=(...e)=>e.filter((t,n,s)=>!!t&&t.trim()!==""&&s.indexOf(t)===n).join(" ").trim();const jO=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const SO=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,s)=>s?s.toUpperCase():n.toLowerCase());const R1=e=>{const t=SO(e);return t.charAt(0).toUpperCase()+t.slice(1)};var NO={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const kO=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const EO=g.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:s,className:a="",children:l,iconNode:u,...d},p)=>g.createElement("svg",{ref:p,...NO,width:t,height:t,stroke:e,strokeWidth:s?Number(n)*24/Number(t):n,className:zk("lucide",a),...!l&&!kO(d)&&{"aria-hidden":"true"},...d},[...u.map(([h,m])=>g.createElement(h,m)),...Array.isArray(l)?l:[l]]));const yn=(e,t)=>{const n=g.forwardRef(({className:s,...a},l)=>g.createElement(EO,{ref:l,iconNode:t,className:zk(`lucide-${jO(R1(e))}`,`lucide-${e}`,s),...a}));return n.displayName=R1(e),n};const CO=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],TO=yn("bot",CO);const AO=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],RO=yn("chevron-down",AO);const MO=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],_O=yn("chevron-right",MO);const OO=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}]],Lk=yn("compass",OO);const IO=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],gc=yn("loader-circle",IO);const DO=[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]],PO=yn("map",DO);const zO=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]],LO=yn("mic",zO);const $O=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],UO=yn("radio",$O);const BO=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],$k=yn("refresh-cw",BO);const VO=[["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}],["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09",key:"u4xsad"}],["path",{d:"M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z",key:"676m9"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05",key:"92ym6u"}]],M1=yn("rocket",VO);const FO=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],HO=yn("search",FO);const qO=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Uk=yn("settings",qO);const ZO=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],WO=yn("sliders-horizontal",ZO);const YO=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],GO=yn("sparkles",YO);const KO=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],XO=yn("square",KO);const JO=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],QO=yn("terminal",JO);const eI=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],tI=yn("volume-2",eI);const nI=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]],sI=yn("volume-x",nI),rI=g.createContext(null);function aI(){return g.useContext(rI)}function iI(e){const t=aI();return!t||e.startsWith("inst:")||e.startsWith("hudson.ws.")?e:`inst:${t.instanceId}:${e}`}function oI(e){try{const t=localStorage.getItem(e);if(t)return JSON.parse(t)}catch{}}function lI(e,t){try{localStorage.setItem(e,JSON.stringify(t)),window.dispatchEvent(new CustomEvent("hudson:saved",{detail:{key:e}}))}catch{}}const cI=()=>()=>{},uI=()=>!0,dI=()=>!1;function fI(){return g.useSyncExternalStore(cI,uI,dI)}function Ir(e,t){const n=fI(),s=iI(e),[a,l]=g.useState(t),u=g.useRef(!1);if(n&&!u.current){u.current=!0;const d=oI(s);d!==void 0&&l(d)}return g.useEffect(()=>{n&&lI(s,a)},[s,a,n]),[a,l]}var Bk="vercel.ai.error",hI=Symbol.for(Bk),_1,O1,lr=class Vk extends(O1=Error,_1=hI,O1){constructor({name:t,message:n,cause:s}){super(n),this[_1]=!0,this.name=t,this.cause=s}static isInstance(t){return Vk.hasMarker(t,Bk)}static hasMarker(t,n){const s=Symbol.for(n);return t!=null&&typeof t=="object"&&s in t&&typeof t[s]=="boolean"&&t[s]===!0}};function Fk(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var Hk="AI_InvalidArgumentError",qk=`vercel.ai.error.${Hk}`,pI=Symbol.for(qk),I1,D1,mI=class extends(D1=lr,I1=pI,D1){constructor({message:e,cause:t,argument:n}){super({name:Hk,message:e,cause:t}),this[I1]=!0,this.argument=n}static isInstance(e){return lr.hasMarker(e,qk)}},Zk="AI_JSONParseError",Wk=`vercel.ai.error.${Zk}`,gI=Symbol.for(Wk),P1,z1,L1=class extends(z1=lr,P1=gI,z1){constructor({text:e,cause:t}){super({name:Zk,message:`JSON parsing failed: Text: ${e}.
|
|
10
|
-
Error message: ${Fk(t)}`,cause:t}),this[P1]=!0,this.text=e}static isInstance(e){return lr.hasMarker(e,Wk)}},Yk="AI_TypeValidationError",Gk=`vercel.ai.error.${Yk}`,vI=Symbol.for(Gk),$1,U1,Yo=class Wg extends(U1=lr,$1=vI,U1){constructor({value:t,cause:n,context:s}){let a="Type validation failed";if(s?.field&&(a+=` for ${s.field}`),s?.entityName||s?.entityId){a+=" (";const l=[];s.entityName&&l.push(s.entityName),s.entityId&&l.push(`id: "${s.entityId}"`),a+=l.join(", "),a+=")"}super({name:Yk,message:`${a}: Value: ${JSON.stringify(t)}.
|
|
11
|
-
Error message: ${Fk(n)}`,cause:n}),this[$1]=!0,this.value=t,this.context=s}static isInstance(t){return lr.hasMarker(t,Gk)}static wrap({value:t,cause:n,context:s}){var a,l,u;return Wg.isInstance(n)&&n.value===t&&((a=n.context)==null?void 0:a.field)===s?.field&&((l=n.context)==null?void 0:l.entityName)===s?.entityName&&((u=n.context)==null?void 0:u.entityId)===s?.entityId?n:new Wg({value:t,cause:n,context:s})}};function ce(e,t,n){function s(d,p){if(d._zod||Object.defineProperty(d,"_zod",{value:{def:p,constr:u,traits:new Set},enumerable:!1}),d._zod.traits.has(e))return;d._zod.traits.add(e),t(d,p);const h=u.prototype,m=Object.keys(h);for(let y=0;y<m.length;y++){const x=m[y];x in d||(d[x]=h[x].bind(d))}}const a=n?.Parent??Object;class l extends a{}Object.defineProperty(l,"name",{value:e});function u(d){var p;const h=n?.Parent?new l:this;s(h,d),(p=h._zod).deferred??(p.deferred=[]);for(const m of h._zod.deferred)m();return h}return Object.defineProperty(u,"init",{value:s}),Object.defineProperty(u,Symbol.hasInstance,{value:d=>n?.Parent&&d instanceof n.Parent?!0:d?._zod?.traits?.has(e)}),Object.defineProperty(u,"name",{value:e}),u}class Fo extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Kk extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Xk={};function Ca(e){return Xk}function Jk(e){const t=Object.values(e).filter(s=>typeof s=="number");return Object.entries(e).filter(([s,a])=>t.indexOf(+s)===-1).map(([s,a])=>a)}function Yg(e,t){return typeof t=="bigint"?t.toString():t}function Jf(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function sy(e){return e==null}function ry(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function yI(e,t){const n=(e.toString().split(".")[1]||"").length,s=t.toString();let a=(s.split(".")[1]||"").length;if(a===0&&/\d?e-\d?/.test(s)){const p=s.match(/\d?e-(\d?)/);p?.[1]&&(a=Number.parseInt(p[1]))}const l=n>a?n:a,u=Number.parseInt(e.toFixed(l).replace(".","")),d=Number.parseInt(t.toFixed(l).replace(".",""));return u%d/10**l}const B1=Symbol("evaluating");function ut(e,t,n){let s;Object.defineProperty(e,t,{get(){if(s!==B1)return s===void 0&&(s=B1,s=n()),s},set(a){Object.defineProperty(e,t,{value:a})},configurable:!0})}function Ei(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ma(...e){const t={};for(const n of e){const s=Object.getOwnPropertyDescriptors(n);Object.assign(t,s)}return Object.defineProperties({},t)}function V1(e){return JSON.stringify(e)}function bI(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Qk="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Tc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const xI=Jf(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Go(e){if(Tc(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Tc(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function eE(e){return Go(e)?{...e}:Array.isArray(e)?[...e]:e}const wI=new Set(["string","number","symbol"]);function Ko(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _a(e,t,n){const s=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(s._zod.parent=e),s}function Ie(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function jI(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const SI={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function NI(e,t){const n=e._zod.def,s=n.checks;if(s&&s.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const l=Ma(e._zod.def,{get shape(){const u={};for(const d in t){if(!(d in n.shape))throw new Error(`Unrecognized key: "${d}"`);t[d]&&(u[d]=n.shape[d])}return Ei(this,"shape",u),u},checks:[]});return _a(e,l)}function kI(e,t){const n=e._zod.def,s=n.checks;if(s&&s.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const l=Ma(e._zod.def,{get shape(){const u={...e._zod.def.shape};for(const d in t){if(!(d in n.shape))throw new Error(`Unrecognized key: "${d}"`);t[d]&&delete u[d]}return Ei(this,"shape",u),u},checks:[]});return _a(e,l)}function EI(e,t){if(!Go(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const l=e._zod.def.shape;for(const u in t)if(Object.getOwnPropertyDescriptor(l,u)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const a=Ma(e._zod.def,{get shape(){const l={...e._zod.def.shape,...t};return Ei(this,"shape",l),l}});return _a(e,a)}function CI(e,t){if(!Go(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Ma(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return Ei(this,"shape",s),s}});return _a(e,n)}function TI(e,t){const n=Ma(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t._zod.def.shape};return Ei(this,"shape",s),s},get catchall(){return t._zod.def.catchall},checks:[]});return _a(e,n)}function AI(e,t,n){const a=t._zod.def.checks;if(a&&a.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const u=Ma(t._zod.def,{get shape(){const d=t._zod.def.shape,p={...d};if(n)for(const h in n){if(!(h in d))throw new Error(`Unrecognized key: "${h}"`);n[h]&&(p[h]=e?new e({type:"optional",innerType:d[h]}):d[h])}else for(const h in d)p[h]=e?new e({type:"optional",innerType:d[h]}):d[h];return Ei(this,"shape",p),p},checks:[]});return _a(t,u)}function RI(e,t,n){const s=Ma(t._zod.def,{get shape(){const a=t._zod.def.shape,l={...a};if(n)for(const u in n){if(!(u in l))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(l[u]=new e({type:"nonoptional",innerType:a[u]}))}else for(const u in a)l[u]=new e({type:"nonoptional",innerType:a[u]});return Ei(this,"shape",l),l}});return _a(t,s)}function Do(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Po(e,t){return t.map(n=>{var s;return(s=n).path??(s.path=[]),n.path.unshift(e),n})}function vd(e){return typeof e=="string"?e:e?.message}function Ta(e,t,n){const s={...e,path:e.path??[]};if(!e.message){const a=vd(e.inst?._zod.def?.error?.(e))??vd(t?.error?.(e))??vd(n.customError?.(e))??vd(n.localeError?.(e))??"Invalid input";s.message=a}return delete s.inst,delete s.continue,t?.reportInput||delete s.input,s}function ay(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ac(...e){const[t,n,s]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:s}:{...t}}const tE=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Yg,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},nE=ce("$ZodError",tE),sE=ce("$ZodError",tE,{Parent:Error});function MI(e,t=n=>n.message){const n={},s=[];for(const a of e.issues)a.path.length>0?(n[a.path[0]]=n[a.path[0]]||[],n[a.path[0]].push(t(a))):s.push(t(a));return{formErrors:s,fieldErrors:n}}function _I(e,t=n=>n.message){const n={_errors:[]},s=a=>{for(const l of a.issues)if(l.code==="invalid_union"&&l.errors.length)l.errors.map(u=>s({issues:u}));else if(l.code==="invalid_key")s({issues:l.issues});else if(l.code==="invalid_element")s({issues:l.issues});else if(l.path.length===0)n._errors.push(t(l));else{let u=n,d=0;for(;d<l.path.length;){const p=l.path[d];d===l.path.length-1?(u[p]=u[p]||{_errors:[]},u[p]._errors.push(t(l))):u[p]=u[p]||{_errors:[]},u=u[p],d++}}};return s(e),n}const iy=e=>(t,n,s,a)=>{const l=s?Object.assign(s,{async:!1}):{async:!1},u=t._zod.run({value:n,issues:[]},l);if(u instanceof Promise)throw new Fo;if(u.issues.length){const d=new(a?.Err??e)(u.issues.map(p=>Ta(p,l,Ca())));throw Qk(d,a?.callee),d}return u.value},oy=e=>async(t,n,s,a)=>{const l=s?Object.assign(s,{async:!0}):{async:!0};let u=t._zod.run({value:n,issues:[]},l);if(u instanceof Promise&&(u=await u),u.issues.length){const d=new(a?.Err??e)(u.issues.map(p=>Ta(p,l,Ca())));throw Qk(d,a?.callee),d}return u.value},Qf=e=>(t,n,s)=>{const a=s?{...s,async:!1}:{async:!1},l=t._zod.run({value:n,issues:[]},a);if(l instanceof Promise)throw new Fo;return l.issues.length?{success:!1,error:new(e??nE)(l.issues.map(u=>Ta(u,a,Ca())))}:{success:!0,data:l.value}},OI=Qf(sE),eh=e=>async(t,n,s)=>{const a=s?Object.assign(s,{async:!0}):{async:!0};let l=t._zod.run({value:n,issues:[]},a);return l instanceof Promise&&(l=await l),l.issues.length?{success:!1,error:new e(l.issues.map(u=>Ta(u,a,Ca())))}:{success:!0,data:l.value}},II=eh(sE),DI=e=>(t,n,s)=>{const a=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return iy(e)(t,n,a)},PI=e=>(t,n,s)=>iy(e)(t,n,s),zI=e=>async(t,n,s)=>{const a=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return oy(e)(t,n,a)},LI=e=>async(t,n,s)=>oy(e)(t,n,s),$I=e=>(t,n,s)=>{const a=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return Qf(e)(t,n,a)},UI=e=>(t,n,s)=>Qf(e)(t,n,s),BI=e=>async(t,n,s)=>{const a=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return eh(e)(t,n,a)},VI=e=>async(t,n,s)=>eh(e)(t,n,s),FI=/^[cC][^\s-]{8,}$/,HI=/^[0-9a-z]+$/,qI=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ZI=/^[0-9a-vA-V]{20}$/,WI=/^[A-Za-z0-9]{27}$/,YI=/^[a-zA-Z0-9_-]{21}$/,GI=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,KI=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,F1=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,XI=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,JI="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function QI(){return new RegExp(JI,"u")}const e5=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,t5=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,n5=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,s5=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,r5=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,rE=/^[A-Za-z0-9_-]*$/,a5=/^\+[1-9]\d{6,14}$/,aE="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",i5=new RegExp(`^${aE}$`);function iE(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function o5(e){return new RegExp(`^${iE(e)}$`)}function l5(e){const t=iE({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const s=`${t}(?:${n.join("|")})`;return new RegExp(`^${aE}T(?:${s})$`)}const c5=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},u5=/^-?\d+$/,oE=/^-?\d+(?:\.\d+)?$/,d5=/^(?:true|false)$/i,f5=/^null$/i,h5=/^[^A-Z]*$/,p5=/^[^a-z]*$/,ts=ce("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),lE={number:"number",bigint:"bigint",object:"date"},cE=ce("$ZodCheckLessThan",(e,t)=>{ts.init(e,t);const n=lE[typeof t.value];e._zod.onattach.push(s=>{const a=s._zod.bag,l=(t.inclusive?a.maximum:a.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<l&&(t.inclusive?a.maximum=t.value:a.exclusiveMaximum=t.value)}),e._zod.check=s=>{(t.inclusive?s.value<=t.value:s.value<t.value)||s.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:s.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),uE=ce("$ZodCheckGreaterThan",(e,t)=>{ts.init(e,t);const n=lE[typeof t.value];e._zod.onattach.push(s=>{const a=s._zod.bag,l=(t.inclusive?a.minimum:a.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>l&&(t.inclusive?a.minimum=t.value:a.exclusiveMinimum=t.value)}),e._zod.check=s=>{(t.inclusive?s.value>=t.value:s.value>t.value)||s.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:s.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),m5=ce("$ZodCheckMultipleOf",(e,t)=>{ts.init(e,t),e._zod.onattach.push(n=>{var s;(s=n._zod.bag).multipleOf??(s.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):yI(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),g5=ce("$ZodCheckNumberFormat",(e,t)=>{ts.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),s=n?"int":"number",[a,l]=SI[t.format];e._zod.onattach.push(u=>{const d=u._zod.bag;d.format=t.format,d.minimum=a,d.maximum=l,n&&(d.pattern=u5)}),e._zod.check=u=>{const d=u.value;if(n){if(!Number.isInteger(d)){u.issues.push({expected:s,format:t.format,code:"invalid_type",continue:!1,input:d,inst:e});return}if(!Number.isSafeInteger(d)){d>0?u.issues.push({input:d,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:s,inclusive:!0,continue:!t.abort}):u.issues.push({input:d,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:s,inclusive:!0,continue:!t.abort});return}}d<a&&u.issues.push({origin:"number",input:d,code:"too_small",minimum:a,inclusive:!0,inst:e,continue:!t.abort}),d>l&&u.issues.push({origin:"number",input:d,code:"too_big",maximum:l,inclusive:!0,inst:e,continue:!t.abort})}}),v5=ce("$ZodCheckMaxLength",(e,t)=>{var n;ts.init(e,t),(n=e._zod.def).when??(n.when=s=>{const a=s.value;return!sy(a)&&a.length!==void 0}),e._zod.onattach.push(s=>{const a=s._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<a&&(s._zod.bag.maximum=t.maximum)}),e._zod.check=s=>{const a=s.value;if(a.length<=t.maximum)return;const u=ay(a);s.issues.push({origin:u,code:"too_big",maximum:t.maximum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),y5=ce("$ZodCheckMinLength",(e,t)=>{var n;ts.init(e,t),(n=e._zod.def).when??(n.when=s=>{const a=s.value;return!sy(a)&&a.length!==void 0}),e._zod.onattach.push(s=>{const a=s._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>a&&(s._zod.bag.minimum=t.minimum)}),e._zod.check=s=>{const a=s.value;if(a.length>=t.minimum)return;const u=ay(a);s.issues.push({origin:u,code:"too_small",minimum:t.minimum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),b5=ce("$ZodCheckLengthEquals",(e,t)=>{var n;ts.init(e,t),(n=e._zod.def).when??(n.when=s=>{const a=s.value;return!sy(a)&&a.length!==void 0}),e._zod.onattach.push(s=>{const a=s._zod.bag;a.minimum=t.length,a.maximum=t.length,a.length=t.length}),e._zod.check=s=>{const a=s.value,l=a.length;if(l===t.length)return;const u=ay(a),d=l>t.length;s.issues.push({origin:u,...d?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:s.value,inst:e,continue:!t.abort})}}),th=ce("$ZodCheckStringFormat",(e,t)=>{var n,s;ts.init(e,t),e._zod.onattach.push(a=>{const l=a._zod.bag;l.format=t.format,t.pattern&&(l.patterns??(l.patterns=new Set),l.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=a=>{t.pattern.lastIndex=0,!t.pattern.test(a.value)&&a.issues.push({origin:"string",code:"invalid_format",format:t.format,input:a.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(s=e._zod).check??(s.check=()=>{})}),x5=ce("$ZodCheckRegex",(e,t)=>{th.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),w5=ce("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=h5),th.init(e,t)}),j5=ce("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=p5),th.init(e,t)}),S5=ce("$ZodCheckIncludes",(e,t)=>{ts.init(e,t);const n=Ko(t.includes),s=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=s,e._zod.onattach.push(a=>{const l=a._zod.bag;l.patterns??(l.patterns=new Set),l.patterns.add(s)}),e._zod.check=a=>{a.value.includes(t.includes,t.position)||a.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:a.value,inst:e,continue:!t.abort})}}),N5=ce("$ZodCheckStartsWith",(e,t)=>{ts.init(e,t);const n=new RegExp(`^${Ko(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(s=>{const a=s._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(n)}),e._zod.check=s=>{s.value.startsWith(t.prefix)||s.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:s.value,inst:e,continue:!t.abort})}}),k5=ce("$ZodCheckEndsWith",(e,t)=>{ts.init(e,t);const n=new RegExp(`.*${Ko(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(s=>{const a=s._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(n)}),e._zod.check=s=>{s.value.endsWith(t.suffix)||s.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:s.value,inst:e,continue:!t.abort})}}),E5=ce("$ZodCheckOverwrite",(e,t)=>{ts.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class C5{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const s=t.split(`
|
|
12
|
-
`).filter(u=>u),a=Math.min(...s.map(u=>u.length-u.trimStart().length)),l=s.map(u=>u.slice(a)).map(u=>" ".repeat(this.indent*2)+u);for(const u of l)this.content.push(u)}compile(){const t=Function,n=this?.args,a=[...(this?.content??[""]).map(l=>` ${l}`)];return new t(...n,a.join(`
|
|
13
|
-
`))}}const T5={major:4,minor:3,patch:6},zt=ce("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=T5;const s=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&s.unshift(e);for(const a of s)for(const l of a._zod.onattach)l(e);if(s.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const a=(u,d,p)=>{let h=Do(u),m;for(const y of d){if(y._zod.def.when){if(!y._zod.def.when(u))continue}else if(h)continue;const x=u.issues.length,w=y._zod.check(u);if(w instanceof Promise&&p?.async===!1)throw new Fo;if(m||w instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await w,u.issues.length!==x&&(h||(h=Do(u,x)))});else{if(u.issues.length===x)continue;h||(h=Do(u,x))}}return m?m.then(()=>u):u},l=(u,d,p)=>{if(Do(u))return u.aborted=!0,u;const h=a(d,s,p);if(h instanceof Promise){if(p.async===!1)throw new Fo;return h.then(m=>e._zod.parse(m,p))}return e._zod.parse(h,p)};e._zod.run=(u,d)=>{if(d.skipChecks)return e._zod.parse(u,d);if(d.direction==="backward"){const h=e._zod.parse({value:u.value,issues:[]},{...d,skipChecks:!0});return h instanceof Promise?h.then(m=>l(m,u,d)):l(h,u,d)}const p=e._zod.parse(u,d);if(p instanceof Promise){if(d.async===!1)throw new Fo;return p.then(h=>a(h,s,d))}return a(p,s,d)}}ut(e,"~standard",()=>({validate:a=>{try{const l=OI(e,a);return l.success?{value:l.data}:{issues:l.error?.issues}}catch{return II(e,a).then(u=>u.success?{value:u.data}:{issues:u.error?.issues})}},vendor:"zod",version:1}))}),ly=ce("$ZodString",(e,t)=>{zt.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??c5(e._zod.bag),e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Ut=ce("$ZodStringFormat",(e,t)=>{th.init(e,t),ly.init(e,t)}),A5=ce("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=KI),Ut.init(e,t)}),R5=ce("$ZodUUID",(e,t)=>{if(t.version){const s={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(s===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=F1(s))}else t.pattern??(t.pattern=F1());Ut.init(e,t)}),M5=ce("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=XI),Ut.init(e,t)}),_5=ce("$ZodURL",(e,t)=>{Ut.init(e,t),e._zod.check=n=>{try{const s=n.value.trim(),a=new URL(s);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(a.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(a.protocol.endsWith(":")?a.protocol.slice(0,-1):a.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=a.href:n.value=s;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),O5=ce("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=QI()),Ut.init(e,t)}),I5=ce("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=YI),Ut.init(e,t)}),D5=ce("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=FI),Ut.init(e,t)}),P5=ce("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=HI),Ut.init(e,t)}),z5=ce("$ZodULID",(e,t)=>{t.pattern??(t.pattern=qI),Ut.init(e,t)}),L5=ce("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ZI),Ut.init(e,t)}),$5=ce("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=WI),Ut.init(e,t)}),U5=ce("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=l5(t)),Ut.init(e,t)}),B5=ce("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=i5),Ut.init(e,t)}),V5=ce("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=o5(t)),Ut.init(e,t)}),F5=ce("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=GI),Ut.init(e,t)}),H5=ce("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=e5),Ut.init(e,t),e._zod.bag.format="ipv4"}),q5=ce("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=t5),Ut.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),Z5=ce("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=n5),Ut.init(e,t)}),W5=ce("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=s5),Ut.init(e,t),e._zod.check=n=>{const s=n.value.split("/");try{if(s.length!==2)throw new Error;const[a,l]=s;if(!l)throw new Error;const u=Number(l);if(`${u}`!==l)throw new Error;if(u<0||u>128)throw new Error;new URL(`http://[${a}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function dE(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Y5=ce("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=r5),Ut.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{dE(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function G5(e){if(!rE.test(e))return!1;const t=e.replace(/[-_]/g,s=>s==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return dE(n)}const K5=ce("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=rE),Ut.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{G5(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),X5=ce("$ZodE164",(e,t)=>{t.pattern??(t.pattern=a5),Ut.init(e,t)});function J5(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[s]=n;if(!s)return!1;const a=JSON.parse(atob(s));return!("typ"in a&&a?.typ!=="JWT"||!a.alg||t&&(!("alg"in a)||a.alg!==t))}catch{return!1}}const Q5=ce("$ZodJWT",(e,t)=>{Ut.init(e,t),e._zod.check=n=>{J5(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),fE=ce("$ZodNumber",(e,t)=>{zt.init(e,t),e._zod.pattern=e._zod.bag.pattern??oE,e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const a=n.value;if(typeof a=="number"&&!Number.isNaN(a)&&Number.isFinite(a))return n;const l=typeof a=="number"?Number.isNaN(a)?"NaN":Number.isFinite(a)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:a,inst:e,...l?{received:l}:{}}),n}}),eD=ce("$ZodNumberFormat",(e,t)=>{g5.init(e,t),fE.init(e,t)}),tD=ce("$ZodBoolean",(e,t)=>{zt.init(e,t),e._zod.pattern=d5,e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=!!n.value}catch{}const a=n.value;return typeof a=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:a,inst:e}),n}}),nD=ce("$ZodNull",(e,t)=>{zt.init(e,t),e._zod.pattern=f5,e._zod.values=new Set([null]),e._zod.parse=(n,s)=>{const a=n.value;return a===null||n.issues.push({expected:"null",code:"invalid_type",input:a,inst:e}),n}}),sD=ce("$ZodUnknown",(e,t)=>{zt.init(e,t),e._zod.parse=n=>n}),rD=ce("$ZodNever",(e,t)=>{zt.init(e,t),e._zod.parse=(n,s)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function H1(e,t,n){e.issues.length&&t.issues.push(...Po(n,e.issues)),t.value[n]=e.value}const aD=ce("$ZodArray",(e,t)=>{zt.init(e,t),e._zod.parse=(n,s)=>{const a=n.value;if(!Array.isArray(a))return n.issues.push({expected:"array",code:"invalid_type",input:a,inst:e}),n;n.value=Array(a.length);const l=[];for(let u=0;u<a.length;u++){const d=a[u],p=t.element._zod.run({value:d,issues:[]},s);p instanceof Promise?l.push(p.then(h=>H1(h,n,u))):H1(p,n,u)}return l.length?Promise.all(l).then(()=>n):n}});function pf(e,t,n,s,a){if(e.issues.length){if(a&&!(n in s))return;t.issues.push(...Po(n,e.issues))}e.value===void 0?n in s&&(t.value[n]=void 0):t.value[n]=e.value}function hE(e){const t=Object.keys(e.shape);for(const s of t)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${s}": expected a Zod schema`);const n=jI(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function pE(e,t,n,s,a,l){const u=[],d=a.keySet,p=a.catchall._zod,h=p.def.type,m=p.optout==="optional";for(const y in t){if(d.has(y))continue;if(h==="never"){u.push(y);continue}const x=p.run({value:t[y],issues:[]},s);x instanceof Promise?e.push(x.then(w=>pf(w,n,y,t,m))):pf(x,n,y,t,m)}return u.length&&n.issues.push({code:"unrecognized_keys",keys:u,input:t,inst:l}),e.length?Promise.all(e).then(()=>n):n}const iD=ce("$ZodObject",(e,t)=>{if(zt.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const d=t.shape;Object.defineProperty(t,"shape",{get:()=>{const p={...d};return Object.defineProperty(t,"shape",{value:p}),p}})}const s=Jf(()=>hE(t));ut(e._zod,"propValues",()=>{const d=t.shape,p={};for(const h in d){const m=d[h]._zod;if(m.values){p[h]??(p[h]=new Set);for(const y of m.values)p[h].add(y)}}return p});const a=Tc,l=t.catchall;let u;e._zod.parse=(d,p)=>{u??(u=s.value);const h=d.value;if(!a(h))return d.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),d;d.value={};const m=[],y=u.shape;for(const x of u.keys){const w=y[x],j=w._zod.optout==="optional",N=w._zod.run({value:h[x],issues:[]},p);N instanceof Promise?m.push(N.then(k=>pf(k,d,x,h,j))):pf(N,d,x,h,j)}return l?pE(m,h,d,p,s.value,e):m.length?Promise.all(m).then(()=>d):d}}),oD=ce("$ZodObjectJIT",(e,t)=>{iD.init(e,t);const n=e._zod.parse,s=Jf(()=>hE(t)),a=x=>{const w=new C5(["shape","payload","ctx"]),j=s.value,N=S=>{const R=V1(S);return`shape[${R}]._zod.run({ value: input[${R}], issues: [] }, ctx)`};w.write("const input = payload.value;");const k=Object.create(null);let E=0;for(const S of j.keys)k[S]=`key_${E++}`;w.write("const newResult = {};");for(const S of j.keys){const R=k[S],A=V1(S),_=x[S]?._zod?.optout==="optional";w.write(`const ${R} = ${N(S)};`),_?w.write(`
|
|
14
|
-
if (${R}.issues.length) {
|
|
15
|
-
if (${A} in input) {
|
|
16
|
-
payload.issues = payload.issues.concat(${R}.issues.map(iss => ({
|
|
17
|
-
...iss,
|
|
18
|
-
path: iss.path ? [${A}, ...iss.path] : [${A}]
|
|
19
|
-
})));
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (${R}.value === undefined) {
|
|
24
|
-
if (${A} in input) {
|
|
25
|
-
newResult[${A}] = undefined;
|
|
26
|
-
}
|
|
27
|
-
} else {
|
|
28
|
-
newResult[${A}] = ${R}.value;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
`):w.write(`
|
|
32
|
-
if (${R}.issues.length) {
|
|
33
|
-
payload.issues = payload.issues.concat(${R}.issues.map(iss => ({
|
|
34
|
-
...iss,
|
|
35
|
-
path: iss.path ? [${A}, ...iss.path] : [${A}]
|
|
36
|
-
})));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (${R}.value === undefined) {
|
|
40
|
-
if (${A} in input) {
|
|
41
|
-
newResult[${A}] = undefined;
|
|
42
|
-
}
|
|
43
|
-
} else {
|
|
44
|
-
newResult[${A}] = ${R}.value;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
`)}w.write("payload.value = newResult;"),w.write("return payload;");const C=w.compile();return(S,R)=>C(x,S,R)};let l;const u=Tc,d=!Xk.jitless,h=d&&xI.value,m=t.catchall;let y;e._zod.parse=(x,w)=>{y??(y=s.value);const j=x.value;return u(j)?d&&h&&w?.async===!1&&w.jitless!==!0?(l||(l=a(t.shape)),x=l(x,w),m?pE([],j,x,w,y,e):x):n(x,w):(x.issues.push({expected:"object",code:"invalid_type",input:j,inst:e}),x)}});function q1(e,t,n,s){for(const l of e)if(l.issues.length===0)return t.value=l.value,t;const a=e.filter(l=>!Do(l));return a.length===1?(t.value=a[0].value,a[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(l=>l.issues.map(u=>Ta(u,s,Ca())))}),t)}const mE=ce("$ZodUnion",(e,t)=>{zt.init(e,t),ut(e._zod,"optin",()=>t.options.some(a=>a._zod.optin==="optional")?"optional":void 0),ut(e._zod,"optout",()=>t.options.some(a=>a._zod.optout==="optional")?"optional":void 0),ut(e._zod,"values",()=>{if(t.options.every(a=>a._zod.values))return new Set(t.options.flatMap(a=>Array.from(a._zod.values)))}),ut(e._zod,"pattern",()=>{if(t.options.every(a=>a._zod.pattern)){const a=t.options.map(l=>l._zod.pattern);return new RegExp(`^(${a.map(l=>ry(l.source)).join("|")})$`)}});const n=t.options.length===1,s=t.options[0]._zod.run;e._zod.parse=(a,l)=>{if(n)return s(a,l);let u=!1;const d=[];for(const p of t.options){const h=p._zod.run({value:a.value,issues:[]},l);if(h instanceof Promise)d.push(h),u=!0;else{if(h.issues.length===0)return h;d.push(h)}}return u?Promise.all(d).then(p=>q1(p,a,e,l)):q1(d,a,e,l)}}),lD=ce("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,mE.init(e,t);const n=e._zod.parse;ut(e._zod,"propValues",()=>{const a={};for(const l of t.options){const u=l._zod.propValues;if(!u||Object.keys(u).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(l)}"`);for(const[d,p]of Object.entries(u)){a[d]||(a[d]=new Set);for(const h of p)a[d].add(h)}}return a});const s=Jf(()=>{const a=t.options,l=new Map;for(const u of a){const d=u._zod.propValues?.[t.discriminator];if(!d||d.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(u)}"`);for(const p of d){if(l.has(p))throw new Error(`Duplicate discriminator value "${String(p)}"`);l.set(p,u)}}return l});e._zod.parse=(a,l)=>{const u=a.value;if(!Tc(u))return a.issues.push({code:"invalid_type",expected:"object",input:u,inst:e}),a;const d=s.value.get(u?.[t.discriminator]);return d?d._zod.run(a,l):t.unionFallback?n(a,l):(a.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:u,path:[t.discriminator],inst:e}),a)}}),cD=ce("$ZodIntersection",(e,t)=>{zt.init(e,t),e._zod.parse=(n,s)=>{const a=n.value,l=t.left._zod.run({value:a,issues:[]},s),u=t.right._zod.run({value:a,issues:[]},s);return l instanceof Promise||u instanceof Promise?Promise.all([l,u]).then(([p,h])=>Z1(n,p,h)):Z1(n,l,u)}});function Gg(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Go(e)&&Go(t)){const n=Object.keys(t),s=Object.keys(e).filter(l=>n.indexOf(l)!==-1),a={...e,...t};for(const l of s){const u=Gg(e[l],t[l]);if(!u.valid)return{valid:!1,mergeErrorPath:[l,...u.mergeErrorPath]};a[l]=u.data}return{valid:!0,data:a}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let s=0;s<e.length;s++){const a=e[s],l=t[s],u=Gg(a,l);if(!u.valid)return{valid:!1,mergeErrorPath:[s,...u.mergeErrorPath]};n.push(u.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Z1(e,t,n){const s=new Map;let a;for(const d of t.issues)if(d.code==="unrecognized_keys"){a??(a=d);for(const p of d.keys)s.has(p)||s.set(p,{}),s.get(p).l=!0}else e.issues.push(d);for(const d of n.issues)if(d.code==="unrecognized_keys")for(const p of d.keys)s.has(p)||s.set(p,{}),s.get(p).r=!0;else e.issues.push(d);const l=[...s].filter(([,d])=>d.l&&d.r).map(([d])=>d);if(l.length&&a&&e.issues.push({...a,keys:l}),Do(e))return e;const u=Gg(t.value,n.value);if(!u.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`);return e.value=u.data,e}const uD=ce("$ZodRecord",(e,t)=>{zt.init(e,t),e._zod.parse=(n,s)=>{const a=n.value;if(!Go(a))return n.issues.push({expected:"record",code:"invalid_type",input:a,inst:e}),n;const l=[],u=t.keyType._zod.values;if(u){n.value={};const d=new Set;for(const h of u)if(typeof h=="string"||typeof h=="number"||typeof h=="symbol"){d.add(typeof h=="number"?h.toString():h);const m=t.valueType._zod.run({value:a[h],issues:[]},s);m instanceof Promise?l.push(m.then(y=>{y.issues.length&&n.issues.push(...Po(h,y.issues)),n.value[h]=y.value})):(m.issues.length&&n.issues.push(...Po(h,m.issues)),n.value[h]=m.value)}let p;for(const h in a)d.has(h)||(p=p??[],p.push(h));p&&p.length>0&&n.issues.push({code:"unrecognized_keys",input:a,inst:e,keys:p})}else{n.value={};for(const d of Reflect.ownKeys(a)){if(d==="__proto__")continue;let p=t.keyType._zod.run({value:d,issues:[]},s);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof d=="string"&&oE.test(d)&&p.issues.length){const y=t.keyType._zod.run({value:Number(d),issues:[]},s);if(y instanceof Promise)throw new Error("Async schemas not supported in object keys currently");y.issues.length===0&&(p=y)}if(p.issues.length){t.mode==="loose"?n.value[d]=a[d]:n.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map(y=>Ta(y,s,Ca())),input:d,path:[d],inst:e});continue}const m=t.valueType._zod.run({value:a[d],issues:[]},s);m instanceof Promise?l.push(m.then(y=>{y.issues.length&&n.issues.push(...Po(d,y.issues)),n.value[p.value]=y.value})):(m.issues.length&&n.issues.push(...Po(d,m.issues)),n.value[p.value]=m.value)}}return l.length?Promise.all(l).then(()=>n):n}}),dD=ce("$ZodEnum",(e,t)=>{zt.init(e,t);const n=Jk(t.entries),s=new Set(n);e._zod.values=s,e._zod.pattern=new RegExp(`^(${n.filter(a=>wI.has(typeof a)).map(a=>typeof a=="string"?Ko(a):a.toString()).join("|")})$`),e._zod.parse=(a,l)=>{const u=a.value;return s.has(u)||a.issues.push({code:"invalid_value",values:n,input:u,inst:e}),a}}),fD=ce("$ZodLiteral",(e,t)=>{if(zt.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(s=>typeof s=="string"?Ko(s):s?Ko(s.toString()):String(s)).join("|")})$`),e._zod.parse=(s,a)=>{const l=s.value;return n.has(l)||s.issues.push({code:"invalid_value",values:t.values,input:l,inst:e}),s}}),hD=ce("$ZodTransform",(e,t)=>{zt.init(e,t),e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new Kk(e.constructor.name);const a=t.transform(n.value,n);if(s.async)return(a instanceof Promise?a:Promise.resolve(a)).then(u=>(n.value=u,n));if(a instanceof Promise)throw new Fo;return n.value=a,n}});function W1(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const gE=ce("$ZodOptional",(e,t)=>{zt.init(e,t),e._zod.optin="optional",e._zod.optout="optional",ut(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ut(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ry(n.source)})?$`):void 0}),e._zod.parse=(n,s)=>{if(t.innerType._zod.optin==="optional"){const a=t.innerType._zod.run(n,s);return a instanceof Promise?a.then(l=>W1(l,n.value)):W1(a,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,s)}}),pD=ce("$ZodExactOptional",(e,t)=>{gE.init(e,t),ut(e._zod,"values",()=>t.innerType._zod.values),ut(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,s)=>t.innerType._zod.run(n,s)}),mD=ce("$ZodNullable",(e,t)=>{zt.init(e,t),ut(e._zod,"optin",()=>t.innerType._zod.optin),ut(e._zod,"optout",()=>t.innerType._zod.optout),ut(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ry(n.source)}|null)$`):void 0}),ut(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,s)=>n.value===null?n:t.innerType._zod.run(n,s)}),gD=ce("$ZodDefault",(e,t)=>{zt.init(e,t),e._zod.optin="optional",ut(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);if(n.value===void 0)return n.value=t.defaultValue,n;const a=t.innerType._zod.run(n,s);return a instanceof Promise?a.then(l=>Y1(l,t)):Y1(a,t)}});function Y1(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const vD=ce("$ZodPrefault",(e,t)=>{zt.init(e,t),e._zod.optin="optional",ut(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>(s.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,s))}),yD=ce("$ZodNonOptional",(e,t)=>{zt.init(e,t),ut(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(s=>s!==void 0)):void 0}),e._zod.parse=(n,s)=>{const a=t.innerType._zod.run(n,s);return a instanceof Promise?a.then(l=>G1(l,e)):G1(a,e)}});function G1(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const bD=ce("$ZodCatch",(e,t)=>{zt.init(e,t),ut(e._zod,"optin",()=>t.innerType._zod.optin),ut(e._zod,"optout",()=>t.innerType._zod.optout),ut(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);const a=t.innerType._zod.run(n,s);return a instanceof Promise?a.then(l=>(n.value=l.value,l.issues.length&&(n.value=t.catchValue({...n,error:{issues:l.issues.map(u=>Ta(u,s,Ca()))},input:n.value}),n.issues=[]),n)):(n.value=a.value,a.issues.length&&(n.value=t.catchValue({...n,error:{issues:a.issues.map(l=>Ta(l,s,Ca()))},input:n.value}),n.issues=[]),n)}}),xD=ce("$ZodPipe",(e,t)=>{zt.init(e,t),ut(e._zod,"values",()=>t.in._zod.values),ut(e._zod,"optin",()=>t.in._zod.optin),ut(e._zod,"optout",()=>t.out._zod.optout),ut(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,s)=>{if(s.direction==="backward"){const l=t.out._zod.run(n,s);return l instanceof Promise?l.then(u=>yd(u,t.in,s)):yd(l,t.in,s)}const a=t.in._zod.run(n,s);return a instanceof Promise?a.then(l=>yd(l,t.out,s)):yd(a,t.out,s)}});function yd(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const wD=ce("$ZodReadonly",(e,t)=>{zt.init(e,t),ut(e._zod,"propValues",()=>t.innerType._zod.propValues),ut(e._zod,"values",()=>t.innerType._zod.values),ut(e._zod,"optin",()=>t.innerType?._zod?.optin),ut(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);const a=t.innerType._zod.run(n,s);return a instanceof Promise?a.then(K1):K1(a)}});function K1(e){return e.value=Object.freeze(e.value),e}const jD=ce("$ZodLazy",(e,t)=>{zt.init(e,t),ut(e._zod,"innerType",()=>t.getter()),ut(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),ut(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),ut(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),ut(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(n,s)=>e._zod.innerType._zod.run(n,s)}),SD=ce("$ZodCustom",(e,t)=>{ts.init(e,t),zt.init(e,t),e._zod.parse=(n,s)=>n,e._zod.check=n=>{const s=n.value,a=t.fn(s);if(a instanceof Promise)return a.then(l=>X1(l,n,s,e));X1(a,n,s,e)}});function X1(e,t,n,s){if(!e){const a={code:"custom",input:n,inst:s,path:[...s._zod.def.path??[]],continue:!s._zod.def.abort};s._zod.def.params&&(a.params=s._zod.def.params),t.issues.push(Ac(a))}}var J1;class ND{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const s=n[0];return this._map.set(t,s),s&&typeof s=="object"&&"id"in s&&this._idmap.set(s.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const s={...this.get(n)??{}};delete s.id;const a={...s,...this._map.get(t)};return Object.keys(a).length?a:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function kD(){return new ND}(J1=globalThis).__zod_globalRegistry??(J1.__zod_globalRegistry=kD());const oc=globalThis.__zod_globalRegistry;function ED(e,t){return new e({type:"string",...Ie(t)})}function CD(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Ie(t)})}function Q1(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Ie(t)})}function TD(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Ie(t)})}function AD(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Ie(t)})}function RD(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Ie(t)})}function MD(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Ie(t)})}function _D(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Ie(t)})}function OD(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Ie(t)})}function ID(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Ie(t)})}function DD(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Ie(t)})}function PD(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Ie(t)})}function zD(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Ie(t)})}function LD(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Ie(t)})}function $D(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Ie(t)})}function UD(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Ie(t)})}function BD(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Ie(t)})}function VD(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Ie(t)})}function FD(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Ie(t)})}function HD(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Ie(t)})}function qD(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Ie(t)})}function ZD(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Ie(t)})}function WD(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Ie(t)})}function YD(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Ie(t)})}function GD(e,t){return new e({type:"string",format:"date",check:"string_format",...Ie(t)})}function KD(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Ie(t)})}function XD(e,t){return new e({type:"string",format:"duration",check:"string_format",...Ie(t)})}function JD(e,t){return new e({type:"number",checks:[],...Ie(t)})}function QD(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Ie(t)})}function eP(e,t){return new e({type:"boolean",...Ie(t)})}function tP(e,t){return new e({type:"null",...Ie(t)})}function nP(e){return new e({type:"unknown"})}function sP(e,t){return new e({type:"never",...Ie(t)})}function ej(e,t){return new cE({check:"less_than",...Ie(t),value:e,inclusive:!1})}function zm(e,t){return new cE({check:"less_than",...Ie(t),value:e,inclusive:!0})}function tj(e,t){return new uE({check:"greater_than",...Ie(t),value:e,inclusive:!1})}function Lm(e,t){return new uE({check:"greater_than",...Ie(t),value:e,inclusive:!0})}function nj(e,t){return new m5({check:"multiple_of",...Ie(t),value:e})}function vE(e,t){return new v5({check:"max_length",...Ie(t),maximum:e})}function mf(e,t){return new y5({check:"min_length",...Ie(t),minimum:e})}function yE(e,t){return new b5({check:"length_equals",...Ie(t),length:e})}function rP(e,t){return new x5({check:"string_format",format:"regex",...Ie(t),pattern:e})}function aP(e){return new w5({check:"string_format",format:"lowercase",...Ie(e)})}function iP(e){return new j5({check:"string_format",format:"uppercase",...Ie(e)})}function oP(e,t){return new S5({check:"string_format",format:"includes",...Ie(t),includes:e})}function lP(e,t){return new N5({check:"string_format",format:"starts_with",...Ie(t),prefix:e})}function cP(e,t){return new k5({check:"string_format",format:"ends_with",...Ie(t),suffix:e})}function tl(e){return new E5({check:"overwrite",tx:e})}function uP(e){return tl(t=>t.normalize(e))}function dP(){return tl(e=>e.trim())}function fP(){return tl(e=>e.toLowerCase())}function hP(){return tl(e=>e.toUpperCase())}function pP(){return tl(e=>bI(e))}function mP(e,t,n){return new e({type:"array",element:t,...Ie(n)})}function gP(e,t,n){const s=Ie(n);return s.abort??(s.abort=!0),new e({type:"custom",check:"custom",fn:t,...s})}function vP(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Ie(n)})}function yP(e){const t=bP(n=>(n.addIssue=s=>{if(typeof s=="string")n.issues.push(Ac(s,n.value,t._zod.def));else{const a=s;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=n.value),a.inst??(a.inst=t),a.continue??(a.continue=!t._zod.def.abort),n.issues.push(Ac(a))}},e(n.value,n)));return t}function bP(e,t){const n=new ts({check:"custom",...Ie(t)});return n._zod.check=e,n}function gf(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??oc,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function Rt(e,t,n={path:[],schemaPath:[]}){var s;const a=e._zod.def,l=t.seen.get(e);if(l)return l.count++,n.schemaPath.includes(e)&&(l.cycle=n.path),l.schema;const u={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,u);const d=e._zod.toJSONSchema?.();if(d)u.schema=d;else{const m={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,u.schema,m);else{const x=u.schema,w=t.processors[a.type];if(!w)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${a.type}`);w(e,t,x,m)}const y=e._zod.parent;y&&(u.ref||(u.ref=y),Rt(y,t,m),t.seen.get(y).isParent=!0)}const p=t.metadataRegistry.get(e);return p&&Object.assign(u.schema,p),t.io==="input"&&$n(e)&&(delete u.schema.examples,delete u.schema.default),t.io==="input"&&u.schema._prefault&&((s=u.schema).default??(s.default=u.schema._prefault)),delete u.schema._prefault,t.seen.get(e).schema}function vf(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=new Map;for(const u of e.seen.entries()){const d=e.metadataRegistry.get(u[0])?.id;if(d){const p=s.get(d);if(p&&p!==u[0])throw new Error(`Duplicate schema id "${d}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);s.set(d,u[0])}}const a=u=>{const d=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const y=e.external.registry.get(u[0])?.id,x=e.external.uri??(j=>j);if(y)return{ref:x(y)};const w=u[1].defId??u[1].schema.id??`schema${e.counter++}`;return u[1].defId=w,{defId:w,ref:`${x("__shared")}#/${d}/${w}`}}if(u[1]===n)return{ref:"#"};const h=`#/${d}/`,m=u[1].schema.id??`__schema${e.counter++}`;return{defId:m,ref:h+m}},l=u=>{if(u[1].schema.$ref)return;const d=u[1],{ref:p,defId:h}=a(u);d.def={...d.schema},h&&(d.defId=h);const m=d.schema;for(const y in m)delete m[y];m.$ref=p};if(e.cycles==="throw")for(const u of e.seen.entries()){const d=u[1];if(d.cycle)throw new Error(`Cycle detected: #/${d.cycle?.join("/")}/<root>
|
|
48
|
-
|
|
49
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const u of e.seen.entries()){const d=u[1];if(t===u[0]){l(u);continue}if(e.external){const h=e.external.registry.get(u[0])?.id;if(t!==u[0]&&h){l(u);continue}}if(e.metadataRegistry.get(u[0])?.id){l(u);continue}if(d.cycle){l(u);continue}if(d.count>1&&e.reused==="ref"){l(u);continue}}}function yf(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=u=>{const d=e.seen.get(u);if(d.ref===null)return;const p=d.def??d.schema,h={...p},m=d.ref;if(d.ref=null,m){s(m);const x=e.seen.get(m),w=x.schema;if(w.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(w)):Object.assign(p,w),Object.assign(p,h),u._zod.parent===m)for(const N in p)N==="$ref"||N==="allOf"||N in h||delete p[N];if(w.$ref&&x.def)for(const N in p)N==="$ref"||N==="allOf"||N in x.def&&JSON.stringify(p[N])===JSON.stringify(x.def[N])&&delete p[N]}const y=u._zod.parent;if(y&&y!==m){s(y);const x=e.seen.get(y);if(x?.schema.$ref&&(p.$ref=x.schema.$ref,x.def))for(const w in p)w==="$ref"||w==="allOf"||w in x.def&&JSON.stringify(p[w])===JSON.stringify(x.def[w])&&delete p[w]}e.override({zodSchema:u,jsonSchema:p,path:d.path??[]})};for(const u of[...e.seen.entries()].reverse())s(u[0]);const a={};if(e.target==="draft-2020-12"?a.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?a.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?a.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const u=e.external.registry.get(t)?.id;if(!u)throw new Error("Schema is missing an `id` property");a.$id=e.external.uri(u)}Object.assign(a,n.def??n.schema);const l=e.external?.defs??{};for(const u of e.seen.entries()){const d=u[1];d.def&&d.defId&&(l[d.defId]=d.def)}e.external||Object.keys(l).length>0&&(e.target==="draft-2020-12"?a.$defs=l:a.definitions=l);try{const u=JSON.parse(JSON.stringify(a));return Object.defineProperty(u,"~standard",{value:{...t["~standard"],jsonSchema:{input:bf(t,"input",e.processors),output:bf(t,"output",e.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function $n(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const s=e._zod.def;if(s.type==="transform")return!0;if(s.type==="array")return $n(s.element,n);if(s.type==="set")return $n(s.valueType,n);if(s.type==="lazy")return $n(s.getter(),n);if(s.type==="promise"||s.type==="optional"||s.type==="nonoptional"||s.type==="nullable"||s.type==="readonly"||s.type==="default"||s.type==="prefault")return $n(s.innerType,n);if(s.type==="intersection")return $n(s.left,n)||$n(s.right,n);if(s.type==="record"||s.type==="map")return $n(s.keyType,n)||$n(s.valueType,n);if(s.type==="pipe")return $n(s.in,n)||$n(s.out,n);if(s.type==="object"){for(const a in s.shape)if($n(s.shape[a],n))return!0;return!1}if(s.type==="union"){for(const a of s.options)if($n(a,n))return!0;return!1}if(s.type==="tuple"){for(const a of s.items)if($n(a,n))return!0;return!!(s.rest&&$n(s.rest,n))}return!1}const xP=(e,t={})=>n=>{const s=gf({...n,processors:t});return Rt(e,s),vf(s,e),yf(s,e)},bf=(e,t,n={})=>s=>{const{libraryOptions:a,target:l}=s??{},u=gf({...a??{},target:l,io:t,processors:n});return Rt(e,u),vf(u,e),yf(u,e)},wP={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},bE=(e,t,n,s)=>{const a=n;a.type="string";const{minimum:l,maximum:u,format:d,patterns:p,contentEncoding:h}=e._zod.bag;if(typeof l=="number"&&(a.minLength=l),typeof u=="number"&&(a.maxLength=u),d&&(a.format=wP[d]??d,a.format===""&&delete a.format,d==="time"&&delete a.format),h&&(a.contentEncoding=h),p&&p.size>0){const m=[...p];m.length===1?a.pattern=m[0].source:m.length>1&&(a.allOf=[...m.map(y=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:y.source}))])}},xE=(e,t,n,s)=>{const a=n,{minimum:l,maximum:u,format:d,multipleOf:p,exclusiveMaximum:h,exclusiveMinimum:m}=e._zod.bag;typeof d=="string"&&d.includes("int")?a.type="integer":a.type="number",typeof m=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(a.minimum=m,a.exclusiveMinimum=!0):a.exclusiveMinimum=m),typeof l=="number"&&(a.minimum=l,typeof m=="number"&&t.target!=="draft-04"&&(m>=l?delete a.minimum:delete a.exclusiveMinimum)),typeof h=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(a.maximum=h,a.exclusiveMaximum=!0):a.exclusiveMaximum=h),typeof u=="number"&&(a.maximum=u,typeof h=="number"&&t.target!=="draft-04"&&(h<=u?delete a.maximum:delete a.exclusiveMaximum)),typeof p=="number"&&(a.multipleOf=p)},wE=(e,t,n,s)=>{n.type="boolean"},jP=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},SP=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},jE=(e,t,n,s)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},NP=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},kP=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},SE=(e,t,n,s)=>{n.not={}},EP=(e,t,n,s)=>{},NE=(e,t,n,s)=>{},CP=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},kE=(e,t,n,s)=>{const a=e._zod.def,l=Jk(a.entries);l.every(u=>typeof u=="number")&&(n.type="number"),l.every(u=>typeof u=="string")&&(n.type="string"),n.enum=l},EE=(e,t,n,s)=>{const a=e._zod.def,l=[];for(const u of a.values)if(u===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof u=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");l.push(Number(u))}else l.push(u);if(l.length!==0)if(l.length===1){const u=l[0];n.type=u===null?"null":typeof u,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[u]:n.const=u}else l.every(u=>typeof u=="number")&&(n.type="number"),l.every(u=>typeof u=="string")&&(n.type="string"),l.every(u=>typeof u=="boolean")&&(n.type="boolean"),l.every(u=>u===null)&&(n.type="null"),n.enum=l},TP=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},AP=(e,t,n,s)=>{const a=n,l=e._zod.pattern;if(!l)throw new Error("Pattern not found in template literal");a.type="string",a.pattern=l.source},RP=(e,t,n,s)=>{const a=n,l={type:"string",format:"binary",contentEncoding:"binary"},{minimum:u,maximum:d,mime:p}=e._zod.bag;u!==void 0&&(l.minLength=u),d!==void 0&&(l.maxLength=d),p?p.length===1?(l.contentMediaType=p[0],Object.assign(a,l)):(Object.assign(a,l),a.anyOf=p.map(h=>({contentMediaType:h}))):Object.assign(a,l)},MP=(e,t,n,s)=>{n.type="boolean"},CE=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},_P=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},TE=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},OP=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},IP=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},AE=(e,t,n,s)=>{const a=n,l=e._zod.def,{minimum:u,maximum:d}=e._zod.bag;typeof u=="number"&&(a.minItems=u),typeof d=="number"&&(a.maxItems=d),a.type="array",a.items=Rt(l.element,t,{...s,path:[...s.path,"items"]})},RE=(e,t,n,s)=>{const a=n,l=e._zod.def;a.type="object",a.properties={};const u=l.shape;for(const h in u)a.properties[h]=Rt(u[h],t,{...s,path:[...s.path,"properties",h]});const d=new Set(Object.keys(u)),p=new Set([...d].filter(h=>{const m=l.shape[h]._zod;return t.io==="input"?m.optin===void 0:m.optout===void 0}));p.size>0&&(a.required=Array.from(p)),l.catchall?._zod.def.type==="never"?a.additionalProperties=!1:l.catchall?l.catchall&&(a.additionalProperties=Rt(l.catchall,t,{...s,path:[...s.path,"additionalProperties"]})):t.io==="output"&&(a.additionalProperties=!1)},ME=(e,t,n,s)=>{const a=e._zod.def,l=a.inclusive===!1,u=a.options.map((d,p)=>Rt(d,t,{...s,path:[...s.path,l?"oneOf":"anyOf",p]}));l?n.oneOf=u:n.anyOf=u},_E=(e,t,n,s)=>{const a=e._zod.def,l=Rt(a.left,t,{...s,path:[...s.path,"allOf",0]}),u=Rt(a.right,t,{...s,path:[...s.path,"allOf",1]}),d=h=>"allOf"in h&&Object.keys(h).length===1,p=[...d(l)?l.allOf:[l],...d(u)?u.allOf:[u]];n.allOf=p},DP=(e,t,n,s)=>{const a=n,l=e._zod.def;a.type="array";const u=t.target==="draft-2020-12"?"prefixItems":"items",d=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",p=l.items.map((x,w)=>Rt(x,t,{...s,path:[...s.path,u,w]})),h=l.rest?Rt(l.rest,t,{...s,path:[...s.path,d,...t.target==="openapi-3.0"?[l.items.length]:[]]}):null;t.target==="draft-2020-12"?(a.prefixItems=p,h&&(a.items=h)):t.target==="openapi-3.0"?(a.items={anyOf:p},h&&a.items.anyOf.push(h),a.minItems=p.length,h||(a.maxItems=p.length)):(a.items=p,h&&(a.additionalItems=h));const{minimum:m,maximum:y}=e._zod.bag;typeof m=="number"&&(a.minItems=m),typeof y=="number"&&(a.maxItems=y)},OE=(e,t,n,s)=>{const a=n,l=e._zod.def;a.type="object";const u=l.keyType,p=u._zod.bag?.patterns;if(l.mode==="loose"&&p&&p.size>0){const m=Rt(l.valueType,t,{...s,path:[...s.path,"patternProperties","*"]});a.patternProperties={};for(const y of p)a.patternProperties[y.source]=m}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(a.propertyNames=Rt(l.keyType,t,{...s,path:[...s.path,"propertyNames"]})),a.additionalProperties=Rt(l.valueType,t,{...s,path:[...s.path,"additionalProperties"]});const h=u._zod.values;if(h){const m=[...h].filter(y=>typeof y=="string"||typeof y=="number");m.length>0&&(a.required=m)}},IE=(e,t,n,s)=>{const a=e._zod.def,l=Rt(a.innerType,t,s),u=t.seen.get(e);t.target==="openapi-3.0"?(u.ref=a.innerType,n.nullable=!0):n.anyOf=[l,{type:"null"}]},DE=(e,t,n,s)=>{const a=e._zod.def;Rt(a.innerType,t,s);const l=t.seen.get(e);l.ref=a.innerType},PE=(e,t,n,s)=>{const a=e._zod.def;Rt(a.innerType,t,s);const l=t.seen.get(e);l.ref=a.innerType,n.default=JSON.parse(JSON.stringify(a.defaultValue))},zE=(e,t,n,s)=>{const a=e._zod.def;Rt(a.innerType,t,s);const l=t.seen.get(e);l.ref=a.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(a.defaultValue)))},LE=(e,t,n,s)=>{const a=e._zod.def;Rt(a.innerType,t,s);const l=t.seen.get(e);l.ref=a.innerType;let u;try{u=a.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=u},$E=(e,t,n,s)=>{const a=e._zod.def,l=t.io==="input"?a.in._zod.def.type==="transform"?a.out:a.in:a.out;Rt(l,t,s);const u=t.seen.get(e);u.ref=l},UE=(e,t,n,s)=>{const a=e._zod.def;Rt(a.innerType,t,s);const l=t.seen.get(e);l.ref=a.innerType,n.readOnly=!0},PP=(e,t,n,s)=>{const a=e._zod.def;Rt(a.innerType,t,s);const l=t.seen.get(e);l.ref=a.innerType},cy=(e,t,n,s)=>{const a=e._zod.def;Rt(a.innerType,t,s);const l=t.seen.get(e);l.ref=a.innerType},BE=(e,t,n,s)=>{const a=e._zod.innerType;Rt(a,t,s);const l=t.seen.get(e);l.ref=a},sj={string:bE,number:xE,boolean:wE,bigint:jP,symbol:SP,null:jE,undefined:NP,void:kP,never:SE,any:EP,unknown:NE,date:CP,enum:kE,literal:EE,nan:TP,template_literal:AP,file:RP,success:MP,custom:CE,function:_P,transform:TE,map:OP,set:IP,array:AE,object:RE,union:ME,intersection:_E,tuple:DP,record:OE,nullable:IE,nonoptional:DE,default:PE,prefault:zE,catch:LE,pipe:$E,readonly:UE,promise:PP,optional:cy,lazy:BE};function zP(e,t){if("_idmap"in e){const s=e,a=gf({...t,processors:sj}),l={};for(const p of s._idmap.entries()){const[h,m]=p;Rt(m,a)}const u={},d={registry:s,uri:t?.uri,defs:l};a.external=d;for(const p of s._idmap.entries()){const[h,m]=p;vf(a,m),u[h]=yf(a,m)}if(Object.keys(l).length>0){const p=a.target==="draft-2020-12"?"$defs":"definitions";u.__shared={[p]:l}}return{schemas:u}}const n=gf({...t,processors:sj});return Rt(e,n),vf(n,e),yf(n,e)}const LP=ce("ZodISODateTime",(e,t)=>{U5.init(e,t),qt.init(e,t)});function $P(e){return YD(LP,e)}const UP=ce("ZodISODate",(e,t)=>{B5.init(e,t),qt.init(e,t)});function BP(e){return GD(UP,e)}const VP=ce("ZodISOTime",(e,t)=>{V5.init(e,t),qt.init(e,t)});function FP(e){return KD(VP,e)}const HP=ce("ZodISODuration",(e,t)=>{F5.init(e,t),qt.init(e,t)});function qP(e){return XD(HP,e)}const ZP=(e,t)=>{nE.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>_I(e,n)},flatten:{value:n=>MI(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Yg,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Yg,2)}},isEmpty:{get(){return e.issues.length===0}}})},Ms=ce("ZodError",ZP,{Parent:Error}),WP=iy(Ms),YP=oy(Ms),GP=Qf(Ms),VE=eh(Ms),KP=DI(Ms),XP=PI(Ms),JP=zI(Ms),QP=LI(Ms),e4=$I(Ms),t4=UI(Ms),n4=BI(Ms),s4=VI(Ms),Lt=ce("ZodType",(e,t)=>(zt.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:bf(e,"input"),output:bf(e,"output")}}),e.toJSONSchema=xP(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(Ma(t,{checks:[...t.checks??[],...n.map(s=>typeof s=="function"?{_zod:{check:s,def:{check:"custom"},onattach:[]}}:s)]}),{parent:!0}),e.with=e.check,e.clone=(n,s)=>_a(e,n,s),e.brand=()=>e,e.register=((n,s)=>(n.add(e,s),e)),e.parse=(n,s)=>WP(e,n,s,{callee:e.parse}),e.safeParse=(n,s)=>GP(e,n,s),e.parseAsync=async(n,s)=>YP(e,n,s,{callee:e.parseAsync}),e.safeParseAsync=async(n,s)=>VE(e,n,s),e.spa=e.safeParseAsync,e.encode=(n,s)=>KP(e,n,s),e.decode=(n,s)=>XP(e,n,s),e.encodeAsync=async(n,s)=>JP(e,n,s),e.decodeAsync=async(n,s)=>QP(e,n,s),e.safeEncode=(n,s)=>e4(e,n,s),e.safeDecode=(n,s)=>t4(e,n,s),e.safeEncodeAsync=async(n,s)=>n4(e,n,s),e.safeDecodeAsync=async(n,s)=>s4(e,n,s),e.refine=(n,s)=>e.check(Q4(n,s)),e.superRefine=n=>e.check(ez(n)),e.overwrite=n=>e.check(tl(n)),e.optional=()=>ij(e),e.exactOptional=()=>$4(e),e.nullable=()=>oj(e),e.nullish=()=>ij(oj(e)),e.nonoptional=n=>q4(e,n),e.array=()=>nl(e),e.or=n=>Fn([e,n]),e.and=n=>O4(e,n),e.transform=n=>lj(e,z4(n)),e.default=n=>V4(e,n),e.prefault=n=>H4(e,n),e.catch=n=>W4(e,n),e.pipe=n=>lj(e,n),e.readonly=()=>K4(e),e.describe=n=>{const s=e.clone();return oc.add(s,{description:n}),s},Object.defineProperty(e,"description",{get(){return oc.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return oc.get(e);const s=e.clone();return oc.add(s,n[0]),s},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),FE=ce("_ZodString",(e,t)=>{ly.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(s,a,l)=>bE(e,s,a);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...s)=>e.check(rP(...s)),e.includes=(...s)=>e.check(oP(...s)),e.startsWith=(...s)=>e.check(lP(...s)),e.endsWith=(...s)=>e.check(cP(...s)),e.min=(...s)=>e.check(mf(...s)),e.max=(...s)=>e.check(vE(...s)),e.length=(...s)=>e.check(yE(...s)),e.nonempty=(...s)=>e.check(mf(1,...s)),e.lowercase=s=>e.check(aP(s)),e.uppercase=s=>e.check(iP(s)),e.trim=()=>e.check(dP()),e.normalize=(...s)=>e.check(uP(...s)),e.toLowerCase=()=>e.check(fP()),e.toUpperCase=()=>e.check(hP()),e.slugify=()=>e.check(pP())}),r4=ce("ZodString",(e,t)=>{ly.init(e,t),FE.init(e,t),e.email=n=>e.check(CD(a4,n)),e.url=n=>e.check(_D(i4,n)),e.jwt=n=>e.check(WD(w4,n)),e.emoji=n=>e.check(OD(o4,n)),e.guid=n=>e.check(Q1(rj,n)),e.uuid=n=>e.check(TD(bd,n)),e.uuidv4=n=>e.check(AD(bd,n)),e.uuidv6=n=>e.check(RD(bd,n)),e.uuidv7=n=>e.check(MD(bd,n)),e.nanoid=n=>e.check(ID(l4,n)),e.guid=n=>e.check(Q1(rj,n)),e.cuid=n=>e.check(DD(c4,n)),e.cuid2=n=>e.check(PD(u4,n)),e.ulid=n=>e.check(zD(d4,n)),e.base64=n=>e.check(HD(y4,n)),e.base64url=n=>e.check(qD(b4,n)),e.xid=n=>e.check(LD(f4,n)),e.ksuid=n=>e.check($D(h4,n)),e.ipv4=n=>e.check(UD(p4,n)),e.ipv6=n=>e.check(BD(m4,n)),e.cidrv4=n=>e.check(VD(g4,n)),e.cidrv6=n=>e.check(FD(v4,n)),e.e164=n=>e.check(ZD(x4,n)),e.datetime=n=>e.check($P(n)),e.date=n=>e.check(BP(n)),e.time=n=>e.check(FP(n)),e.duration=n=>e.check(qP(n))});function Ce(e){return ED(r4,e)}const qt=ce("ZodStringFormat",(e,t)=>{Ut.init(e,t),FE.init(e,t)}),a4=ce("ZodEmail",(e,t)=>{M5.init(e,t),qt.init(e,t)}),rj=ce("ZodGUID",(e,t)=>{A5.init(e,t),qt.init(e,t)}),bd=ce("ZodUUID",(e,t)=>{R5.init(e,t),qt.init(e,t)}),i4=ce("ZodURL",(e,t)=>{_5.init(e,t),qt.init(e,t)}),o4=ce("ZodEmoji",(e,t)=>{O5.init(e,t),qt.init(e,t)}),l4=ce("ZodNanoID",(e,t)=>{I5.init(e,t),qt.init(e,t)}),c4=ce("ZodCUID",(e,t)=>{D5.init(e,t),qt.init(e,t)}),u4=ce("ZodCUID2",(e,t)=>{P5.init(e,t),qt.init(e,t)}),d4=ce("ZodULID",(e,t)=>{z5.init(e,t),qt.init(e,t)}),f4=ce("ZodXID",(e,t)=>{L5.init(e,t),qt.init(e,t)}),h4=ce("ZodKSUID",(e,t)=>{$5.init(e,t),qt.init(e,t)}),p4=ce("ZodIPv4",(e,t)=>{H5.init(e,t),qt.init(e,t)}),m4=ce("ZodIPv6",(e,t)=>{q5.init(e,t),qt.init(e,t)}),g4=ce("ZodCIDRv4",(e,t)=>{Z5.init(e,t),qt.init(e,t)}),v4=ce("ZodCIDRv6",(e,t)=>{W5.init(e,t),qt.init(e,t)}),y4=ce("ZodBase64",(e,t)=>{Y5.init(e,t),qt.init(e,t)}),b4=ce("ZodBase64URL",(e,t)=>{K5.init(e,t),qt.init(e,t)}),x4=ce("ZodE164",(e,t)=>{X5.init(e,t),qt.init(e,t)}),w4=ce("ZodJWT",(e,t)=>{Q5.init(e,t),qt.init(e,t)}),HE=ce("ZodNumber",(e,t)=>{fE.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(s,a,l)=>xE(e,s,a),e.gt=(s,a)=>e.check(tj(s,a)),e.gte=(s,a)=>e.check(Lm(s,a)),e.min=(s,a)=>e.check(Lm(s,a)),e.lt=(s,a)=>e.check(ej(s,a)),e.lte=(s,a)=>e.check(zm(s,a)),e.max=(s,a)=>e.check(zm(s,a)),e.int=s=>e.check(aj(s)),e.safe=s=>e.check(aj(s)),e.positive=s=>e.check(tj(0,s)),e.nonnegative=s=>e.check(Lm(0,s)),e.negative=s=>e.check(ej(0,s)),e.nonpositive=s=>e.check(zm(0,s)),e.multipleOf=(s,a)=>e.check(nj(s,a)),e.step=(s,a)=>e.check(nj(s,a)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function j4(e){return JD(HE,e)}const S4=ce("ZodNumberFormat",(e,t)=>{eD.init(e,t),HE.init(e,t)});function aj(e){return QD(S4,e)}const N4=ce("ZodBoolean",(e,t)=>{tD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>wE(e,n,s)});function Un(e){return eP(N4,e)}const k4=ce("ZodNull",(e,t)=>{nD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>jE(e,n,s)});function E4(e){return tP(k4,e)}const C4=ce("ZodUnknown",(e,t)=>{sD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>NE()});function nr(){return nP(C4)}const T4=ce("ZodNever",(e,t)=>{rD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>SE(e,n,s)});function qE(e){return sP(T4,e)}const A4=ce("ZodArray",(e,t)=>{aD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>AE(e,n,s,a),e.element=t.element,e.min=(n,s)=>e.check(mf(n,s)),e.nonempty=n=>e.check(mf(1,n)),e.max=(n,s)=>e.check(vE(n,s)),e.length=(n,s)=>e.check(yE(n,s)),e.unwrap=()=>e.element});function nl(e,t){return mP(A4,e,t)}const ZE=ce("ZodObject",(e,t)=>{oD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>RE(e,n,s,a),ut(e,"shape",()=>t.shape),e.keyof=()=>YE(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:nr()}),e.loose=()=>e.clone({...e._zod.def,catchall:nr()}),e.strict=()=>e.clone({...e._zod.def,catchall:qE()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>EI(e,n),e.safeExtend=n=>CI(e,n),e.merge=n=>TI(e,n),e.pick=n=>NI(e,n),e.omit=n=>kI(e,n),e.partial=(...n)=>AI(GE,e,n[0]),e.required=(...n)=>RI(KE,e,n[0])});function Tt(e,t){const n={type:"object",shape:e??{},...Ie(t)};return new ZE(n)}function Ot(e,t){return new ZE({type:"object",shape:e,catchall:qE(),...Ie(t)})}const WE=ce("ZodUnion",(e,t)=>{mE.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>ME(e,n,s,a),e.options=t.options});function Fn(e,t){return new WE({type:"union",options:e,...Ie(t)})}const R4=ce("ZodDiscriminatedUnion",(e,t)=>{WE.init(e,t),lD.init(e,t)});function M4(e,t,n){return new R4({type:"union",options:t,discriminator:e,...Ie(n)})}const _4=ce("ZodIntersection",(e,t)=>{cD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>_E(e,n,s,a)});function O4(e,t){return new _4({type:"intersection",left:e,right:t})}const I4=ce("ZodRecord",(e,t)=>{uD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>OE(e,n,s,a),e.keyType=t.keyType,e.valueType=t.valueType});function Rc(e,t,n){return new I4({type:"record",keyType:e,valueType:t,...Ie(n)})}const Kg=ce("ZodEnum",(e,t)=>{dD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(s,a,l)=>kE(e,s,a),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(s,a)=>{const l={};for(const u of s)if(n.has(u))l[u]=t.entries[u];else throw new Error(`Key ${u} not found in enum`);return new Kg({...t,checks:[],...Ie(a),entries:l})},e.exclude=(s,a)=>{const l={...t.entries};for(const u of s)if(n.has(u))delete l[u];else throw new Error(`Key ${u} not found in enum`);return new Kg({...t,checks:[],...Ie(a),entries:l})}});function YE(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(s=>[s,s])):e;return new Kg({type:"enum",entries:n,...Ie(t)})}const D4=ce("ZodLiteral",(e,t)=>{fD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>EE(e,n,s),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function He(e,t){return new D4({type:"literal",values:Array.isArray(e)?e:[e],...Ie(t)})}const P4=ce("ZodTransform",(e,t)=>{hD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>TE(e,n),e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new Kk(e.constructor.name);n.addIssue=l=>{if(typeof l=="string")n.issues.push(Ac(l,n.value,t));else{const u=l;u.fatal&&(u.continue=!1),u.code??(u.code="custom"),u.input??(u.input=n.value),u.inst??(u.inst=e),n.issues.push(Ac(u))}};const a=t.transform(n.value,n);return a instanceof Promise?a.then(l=>(n.value=l,n)):(n.value=a,n)}});function z4(e){return new P4({type:"transform",transform:e})}const GE=ce("ZodOptional",(e,t)=>{gE.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>cy(e,n,s,a),e.unwrap=()=>e._zod.def.innerType});function ij(e){return new GE({type:"optional",innerType:e})}const L4=ce("ZodExactOptional",(e,t)=>{pD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>cy(e,n,s,a),e.unwrap=()=>e._zod.def.innerType});function $4(e){return new L4({type:"optional",innerType:e})}const U4=ce("ZodNullable",(e,t)=>{mD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>IE(e,n,s,a),e.unwrap=()=>e._zod.def.innerType});function oj(e){return new U4({type:"nullable",innerType:e})}const B4=ce("ZodDefault",(e,t)=>{gD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>PE(e,n,s,a),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function V4(e,t){return new B4({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():eE(t)}})}const F4=ce("ZodPrefault",(e,t)=>{vD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>zE(e,n,s,a),e.unwrap=()=>e._zod.def.innerType});function H4(e,t){return new F4({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():eE(t)}})}const KE=ce("ZodNonOptional",(e,t)=>{yD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>DE(e,n,s,a),e.unwrap=()=>e._zod.def.innerType});function q4(e,t){return new KE({type:"nonoptional",innerType:e,...Ie(t)})}const Z4=ce("ZodCatch",(e,t)=>{bD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>LE(e,n,s,a),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function W4(e,t){return new Z4({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Y4=ce("ZodPipe",(e,t)=>{xD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>$E(e,n,s,a),e.in=t.in,e.out=t.out});function lj(e,t){return new Y4({type:"pipe",in:e,out:t})}const G4=ce("ZodReadonly",(e,t)=>{wD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>UE(e,n,s,a),e.unwrap=()=>e._zod.def.innerType});function K4(e){return new G4({type:"readonly",innerType:e})}const X4=ce("ZodLazy",(e,t)=>{jD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>BE(e,n,s,a),e.unwrap=()=>e._zod.def.getter()});function J4(e){return new X4({type:"lazy",getter:e})}const uy=ce("ZodCustom",(e,t)=>{SD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>CE(e,n)});function XE(e,t){return gP(uy,e??(()=>!0),t)}function Q4(e,t={}){return vP(uy,e,t)}function ez(e){return yP(e)}function xf(e,t={}){const n=new uy({type:"custom",check:"custom",fn:s=>s instanceof e,abort:!0,...Ie(t)});return n._zod.bag.Class=e,n._zod.check=s=>{s.value instanceof e||s.issues.push({code:"invalid_type",expected:e.name,input:s.value,inst:n,path:[...n._zod.def.path??[]]})},n}var Mc;(function(e){e.assertEqual=a=>{};function t(a){}e.assertIs=t;function n(a){throw new Error}e.assertNever=n,e.arrayToEnum=a=>{const l={};for(const u of a)l[u]=u;return l},e.getValidEnumValues=a=>{const l=e.objectKeys(a).filter(d=>typeof a[a[d]]!="number"),u={};for(const d of l)u[d]=a[d];return e.objectValues(u)},e.objectValues=a=>e.objectKeys(a).map(function(l){return a[l]}),e.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const l=[];for(const u in a)Object.prototype.hasOwnProperty.call(a,u)&&l.push(u);return l},e.find=(a,l)=>{for(const u of a)if(l(u))return u},e.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function s(a,l=" | "){return a.map(u=>typeof u=="string"?`'${u}'`:u).join(l)}e.joinValues=s,e.jsonStringifyReplacer=(a,l)=>typeof l=="bigint"?l.toString():l})(Mc||(Mc={}));var cj;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(cj||(cj={}));Mc.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);Mc.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class wf extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(l){return l.message},s={_errors:[]},a=l=>{for(const u of l.issues)if(u.code==="invalid_union")u.unionErrors.map(a);else if(u.code==="invalid_return_type")a(u.returnTypeError);else if(u.code==="invalid_arguments")a(u.argumentsError);else if(u.path.length===0)s._errors.push(n(u));else{let d=s,p=0;for(;p<u.path.length;){const h=u.path[p];p===u.path.length-1?(d[h]=d[h]||{_errors:[]},d[h]._errors.push(n(u))):d[h]=d[h]||{_errors:[]},d=d[h],p++}}};return a(this),s}static assert(t){if(!(t instanceof wf))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Mc.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n=Object.create(null),s=[];for(const a of this.issues)if(a.path.length>0){const l=a.path[0];n[l]=n[l]||[],n[l].push(t(a))}else s.push(t(a));return{formErrors:s,fieldErrors:n}}get formErrors(){return this.flatten()}}wf.create=e=>new wf(e);var uj;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(uj||(uj={}));var Xe;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(Xe||(Xe={}));class dj extends Error{constructor(t,n){super(t),this.name="ParseError",this.type=n.type,this.field=n.field,this.value=n.value,this.line=n.line}}const fj=10,tz=13,ni=32;function $m(e){}function nz(e){if(typeof e=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=$m,onError:n=$m,onRetry:s=$m,onComment:a}=e;let l="",u=!0,d,p="",h=0,m;function y(C){if(u){u=!1,x(C);return}const S=l===""?C:l+C;l=w(S)}function x(C){C.charCodeAt(0)===239&&C.charCodeAt(1)===187&&C.charCodeAt(2)===191&&(C=C.slice(3));const S=l===""?C:l+C;l=w(S)}function w(C){let S=0;if(C.indexOf("\r")===-1){let R=C.indexOf(`
|
|
50
|
-
`,S);for(;R!==-1;){if(S===R){h>0&&t({id:d,event:m,data:p}),d=void 0,p="",h=0,m=void 0,S=R+1,R=C.indexOf(`
|
|
51
|
-
`,S);continue}const A=C.charCodeAt(S);if(hj(C,S,A)){const M=C.charCodeAt(S+5)===ni?S+6:S+5,_=C.slice(M,R);if(h===0&&C.charCodeAt(R+1)===fj){t({id:d,event:m,data:_}),d=void 0,p="",m=void 0,S=R+2,R=C.indexOf(`
|
|
52
|
-
`,S);continue}p=h===0?_:`${p}
|
|
53
|
-
${_}`,h++}else pj(C,S,A)?m=C.slice(C.charCodeAt(S+6)===ni?S+7:S+6,R)||void 0:j(C,S,R);S=R+1,R=C.indexOf(`
|
|
54
|
-
`,S)}return C.slice(S)}for(;S<C.length;){const R=C.indexOf("\r",S),A=C.indexOf(`
|
|
55
|
-
`,S);let M=-1;if(R!==-1&&A!==-1?M=R<A?R:A:R!==-1?R===C.length-1?M=-1:M=R:A!==-1&&(M=A),M===-1)break;j(C,S,M),S=M+1,C.charCodeAt(S-1)===tz&&C.charCodeAt(S)===fj&&S++}return C.slice(S)}function j(C,S,R){if(S===R){k();return}const A=C.charCodeAt(S);if(hj(C,S,A)){const O=C.charCodeAt(S+5)===ni?S+6:S+5,D=C.slice(O,R);p=h===0?D:`${p}
|
|
56
|
-
${D}`,h++;return}if(pj(C,S,A)){m=C.slice(C.charCodeAt(S+6)===ni?S+7:S+6,R)||void 0;return}if(A===105&&C.charCodeAt(S+1)===100&&C.charCodeAt(S+2)===58){const O=C.slice(C.charCodeAt(S+3)===ni?S+4:S+3,R);d=O.includes("\0")?void 0:O;return}if(A===58){if(a){const O=C.slice(S,R);a(O.slice(C.charCodeAt(S+1)===ni?2:1))}return}const M=C.slice(S,R),_=M.indexOf(":");if(_===-1){N(M,"",M);return}const z=M.slice(0,_),V=M.charCodeAt(_+1)===ni?2:1,U=M.slice(_+V);N(z,U,M)}function N(C,S,R){switch(C){case"event":m=S||void 0;break;case"data":p=h===0?S:`${p}
|
|
57
|
-
${S}`,h++;break;case"id":d=S.includes("\0")?void 0:S;break;case"retry":/^\d+$/.test(S)?s(parseInt(S,10)):n(new dj(`Invalid \`retry\` value: "${S}"`,{type:"invalid-retry",value:S,line:R}));break;default:n(new dj(`Unknown field "${C.length>20?`${C.slice(0,20)}…`:C}"`,{type:"unknown-field",field:C,value:S,line:R}));break}}function k(){h>0&&t({id:d,event:m,data:p}),d=void 0,p="",h=0,m=void 0}function E(C={}){l&&C.consume&&j(l,0,l.length),u=!0,d=void 0,p="",h=0,m=void 0,l=""}return{feed:y,reset:E}}function hj(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function pj(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}class sz extends TransformStream{constructor({onError:t,onRetry:n,onComment:s}={}){let a;super({start(l){a=nz({onEvent:u=>{l.enqueue(u)},onError(u){t==="terminate"?l.error(u):typeof t=="function"&&t(u)},onRetry:n,onComment:s})},transform(l){a.feed(l)}})}}var Zc=({prefix:e,size:t=16,alphabet:n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:s="-"}={})=>{const a=()=>{const l=n.length,u=new Array(t);for(let d=0;d<t;d++)u[d]=n[Math.random()*l|0];return u.join("")};if(e==null)return a;if(n.includes(s))throw new mI({argument:"separator",message:`The separator "${s}" must not be part of the alphabet "${n}".`});return()=>`${e}${s}${a()}`},rz=Zc();function vo(e){if(e==null)return{};const t={};if(e instanceof Headers)e.forEach((n,s)=>{t[s.toLowerCase()]=n});else{Array.isArray(e)||(e=Object.entries(e));for(const[n,s]of e)s!=null&&(t[n.toLowerCase()]=s)}return t}var az=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,iz=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function mj(e){const t=JSON.parse(e);return t===null||typeof t!="object"||az.test(e)===!1&&iz.test(e)===!1?t:oz(t)}function oz(e){let t=[e];for(;t.length;){const n=t;t=[];for(const s of n){if(Object.prototype.hasOwnProperty.call(s,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(s,"constructor")&&s.constructor!==null&&typeof s.constructor=="object"&&Object.prototype.hasOwnProperty.call(s.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const a in s){const l=s[a];l&&typeof l=="object"&&t.push(l)}}}return e}function lz(e){const{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return mj(e)}try{return mj(e)}finally{Error.stackTraceLimit=t}}function dy(e){if(e.type==="object"||Array.isArray(e.type)&&e.type.includes("object")){e.additionalProperties=!1;const{properties:n}=e;if(n!=null)for(const s of Object.keys(n))n[s]=si(n[s])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(si):si(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(si)),e.allOf!=null&&(e.allOf=e.allOf.map(si)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(si));const{definitions:t}=e;if(t!=null)for(const n of Object.keys(t))t[n]=si(t[n]);return e}function si(e){return typeof e=="boolean"?e:dy(e)}var cz=Symbol("Let zodToJsonSchema decide on which parser to use"),gj={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},uz=e=>typeof e=="string"?{...gj,name:e}:{...gj,...e};function fs(){return{}}function dz(e,t){var n,s,a;const l={type:"array"};return(n=e.type)!=null&&n._def&&((a=(s=e.type)==null?void 0:s._def)==null?void 0:a.typeName)!==Xe.ZodAny&&(l.items=bt(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&(l.minItems=e.minLength.value),e.maxLength&&(l.maxItems=e.maxLength.value),e.exactLength&&(l.minItems=e.exactLength.value,l.maxItems=e.exactLength.value),l}function fz(e){const t={type:"integer",format:"int64"};if(!e.checks)return t;for(const n of e.checks)switch(n.kind){case"min":n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case"max":n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case"multipleOf":t.multipleOf=n.value;break}return t}function hz(){return{type:"boolean"}}function JE(e,t){return bt(e.type._def,t)}var pz=(e,t)=>bt(e.innerType._def,t);function QE(e,t,n){const s=n??t.dateStrategy;if(Array.isArray(s))return{anyOf:s.map((a,l)=>QE(e,t,a))};switch(s){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return mz(e)}}var mz=e=>{const t={type:"integer",format:"unix-time"};for(const n of e.checks)switch(n.kind){case"min":t.minimum=n.value;break;case"max":t.maximum=n.value;break}return t};function gz(e,t){return{...bt(e.innerType._def,t),default:e.defaultValue()}}function vz(e,t){return t.effectStrategy==="input"?bt(e.schema._def,t):fs()}function yz(e){return{type:"string",enum:Array.from(e.values)}}var bz=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function xz(e,t){const n=[bt(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),bt(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(a=>!!a),s=[];return n.forEach(a=>{if(bz(a))s.push(...a.allOf);else{let l=a;if("additionalProperties"in a&&a.additionalProperties===!1){const{additionalProperties:u,...d}=a;l=d}s.push(l)}}),s.length?{allOf:s}:void 0}function wz(e){const t=typeof e.value;return t!=="bigint"&&t!=="number"&&t!=="boolean"&&t!=="string"?{type:Array.isArray(e.value)?"array":"object"}:{type:t==="bigint"?"integer":t,const:e.value}}var Um=void 0,Ds={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(Um===void 0&&(Um=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Um),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function eC(e,t){const n={type:"string"};if(e.checks)for(const s of e.checks)switch(s.kind){case"min":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,s.value):s.value;break;case"max":n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,s.value):s.value;break;case"email":switch(t.emailStrategy){case"format:email":Ps(n,"email",s.message,t);break;case"format:idn-email":Ps(n,"idn-email",s.message,t);break;case"pattern:zod":Ln(n,Ds.email,s.message,t);break}break;case"url":Ps(n,"uri",s.message,t);break;case"uuid":Ps(n,"uuid",s.message,t);break;case"regex":Ln(n,s.regex,s.message,t);break;case"cuid":Ln(n,Ds.cuid,s.message,t);break;case"cuid2":Ln(n,Ds.cuid2,s.message,t);break;case"startsWith":Ln(n,RegExp(`^${Bm(s.value,t)}`),s.message,t);break;case"endsWith":Ln(n,RegExp(`${Bm(s.value,t)}$`),s.message,t);break;case"datetime":Ps(n,"date-time",s.message,t);break;case"date":Ps(n,"date",s.message,t);break;case"time":Ps(n,"time",s.message,t);break;case"duration":Ps(n,"duration",s.message,t);break;case"length":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,s.value):s.value,n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,s.value):s.value;break;case"includes":{Ln(n,RegExp(Bm(s.value,t)),s.message,t);break}case"ip":{s.version!=="v6"&&Ps(n,"ipv4",s.message,t),s.version!=="v4"&&Ps(n,"ipv6",s.message,t);break}case"base64url":Ln(n,Ds.base64url,s.message,t);break;case"jwt":Ln(n,Ds.jwt,s.message,t);break;case"cidr":{s.version!=="v6"&&Ln(n,Ds.ipv4Cidr,s.message,t),s.version!=="v4"&&Ln(n,Ds.ipv6Cidr,s.message,t);break}case"emoji":Ln(n,Ds.emoji(),s.message,t);break;case"ulid":{Ln(n,Ds.ulid,s.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{Ps(n,"binary",s.message,t);break}case"contentEncoding:base64":{n.contentEncoding="base64";break}case"pattern:zod":{Ln(n,Ds.base64,s.message,t);break}}break}case"nanoid":Ln(n,Ds.nanoid,s.message,t)}return n}function Bm(e,t){return t.patternStrategy==="escape"?Sz(e):e}var jz=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Sz(e){let t="";for(let n=0;n<e.length;n++)jz.has(e[n])||(t+="\\"),t+=e[n];return t}function Ps(e,t,n,s){var a;e.format||(a=e.anyOf)!=null&&a.some(l=>l.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...n&&s.errorMessages&&{errorMessage:{format:n}}})):e.format=t}function Ln(e,t,n,s){var a;e.pattern||(a=e.allOf)!=null&&a.some(l=>l.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:vj(t,s),...n&&s.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=vj(t,s)}function vj(e,t){var n;if(!t.applyRegexFlags||!e.flags)return e.source;const s={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},a=s.i?e.source.toLowerCase():e.source;let l="",u=!1,d=!1,p=!1;for(let h=0;h<a.length;h++){if(u){l+=a[h],u=!1;continue}if(s.i){if(d){if(a[h].match(/[a-z]/)){p?(l+=a[h],l+=`${a[h-2]}-${a[h]}`.toUpperCase(),p=!1):a[h+1]==="-"&&((n=a[h+2])!=null&&n.match(/[a-z]/))?(l+=a[h],p=!0):l+=`${a[h]}${a[h].toUpperCase()}`;continue}}else if(a[h].match(/[a-z]/)){l+=`[${a[h]}${a[h].toUpperCase()}]`;continue}}if(s.m){if(a[h]==="^"){l+=`(^|(?<=[\r
|
|
58
|
-
]))`;continue}else if(a[h]==="$"){l+=`($|(?=[\r
|
|
59
|
-
]))`;continue}}if(s.s&&a[h]==="."){l+=d?`${a[h]}\r
|
|
60
|
-
`:`[${a[h]}\r
|
|
61
|
-
]`;continue}l+=a[h],a[h]==="\\"?u=!0:d&&a[h]==="]"?d=!1:!d&&a[h]==="["&&(d=!0)}try{new RegExp(l)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return l}function tC(e,t){var n,s,a,l,u,d;const p={type:"object",additionalProperties:(n=bt(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?n:t.allowedAdditionalProperties};if(((s=e.keyType)==null?void 0:s._def.typeName)===Xe.ZodString&&((a=e.keyType._def.checks)!=null&&a.length)){const{type:h,...m}=eC(e.keyType._def,t);return{...p,propertyNames:m}}else{if(((l=e.keyType)==null?void 0:l._def.typeName)===Xe.ZodEnum)return{...p,propertyNames:{enum:e.keyType._def.values}};if(((u=e.keyType)==null?void 0:u._def.typeName)===Xe.ZodBranded&&e.keyType._def.type._def.typeName===Xe.ZodString&&((d=e.keyType._def.type._def.checks)!=null&&d.length)){const{type:h,...m}=JE(e.keyType._def,t);return{...p,propertyNames:m}}}return p}function Nz(e,t){if(t.mapStrategy==="record")return tC(e,t);const n=bt(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||fs(),s=bt(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||fs();return{type:"array",maxItems:125,items:{type:"array",items:[n,s],minItems:2,maxItems:2}}}function kz(e){const t=e.values,s=Object.keys(e.values).filter(l=>typeof t[t[l]]!="number").map(l=>t[l]),a=Array.from(new Set(s.map(l=>typeof l)));return{type:a.length===1?a[0]==="string"?"string":"number":["string","number"],enum:s}}function Ez(){return{not:fs()}}function Cz(){return{type:"null"}}var Xg={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function Tz(e,t){const n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(s=>s._def.typeName in Xg&&(!s._def.checks||!s._def.checks.length))){const s=n.reduce((a,l)=>{const u=Xg[l._def.typeName];return u&&!a.includes(u)?[...a,u]:a},[]);return{type:s.length>1?s:s[0]}}else if(n.every(s=>s._def.typeName==="ZodLiteral"&&!s.description)){const s=n.reduce((a,l)=>{const u=typeof l._def.value;switch(u){case"string":case"number":case"boolean":return[...a,u];case"bigint":return[...a,"integer"];case"object":if(l._def.value===null)return[...a,"null"];default:return a}},[]);if(s.length===n.length){const a=s.filter((l,u,d)=>d.indexOf(l)===u);return{type:a.length>1?a:a[0],enum:n.reduce((l,u)=>l.includes(u._def.value)?l:[...l,u._def.value],[])}}}else if(n.every(s=>s._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((s,a)=>[...s,...a._def.values.filter(l=>!s.includes(l))],[])};return Az(e,t)}var Az=(e,t)=>{const n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((s,a)=>bt(s._def,{...t,currentPath:[...t.currentPath,"anyOf",`${a}`]})).filter(s=>!!s&&(!t.strictUnions||typeof s=="object"&&Object.keys(s).length>0));return n.length?{anyOf:n}:void 0};function Rz(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[Xg[e.innerType._def.typeName],"null"]};const n=bt(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function Mz(e){const t={type:"number"};if(!e.checks)return t;for(const n of e.checks)switch(n.kind){case"int":t.type="integer";break;case"min":n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case"max":n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case"multipleOf":t.multipleOf=n.value;break}return t}function _z(e,t){const n={type:"object",properties:{}},s=[],a=e.shape();for(const u in a){let d=a[u];if(d===void 0||d._def===void 0)continue;const p=Iz(d),h=bt(d._def,{...t,currentPath:[...t.currentPath,"properties",u],propertyPath:[...t.currentPath,"properties",u]});h!==void 0&&(n.properties[u]=h,p||s.push(u))}s.length&&(n.required=s);const l=Oz(e,t);return l!==void 0&&(n.additionalProperties=l),n}function Oz(e,t){if(e.catchall._def.typeName!=="ZodNever")return bt(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function Iz(e){try{return e.isOptional()}catch{return!0}}var Dz=(e,t)=>{var n;if(t.currentPath.toString()===((n=t.propertyPath)==null?void 0:n.toString()))return bt(e.innerType._def,t);const s=bt(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return s?{anyOf:[{not:fs()},s]}:fs()},Pz=(e,t)=>{if(t.pipeStrategy==="input")return bt(e.in._def,t);if(t.pipeStrategy==="output")return bt(e.out._def,t);const n=bt(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),s=bt(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,s].filter(a=>a!==void 0)}};function zz(e,t){return bt(e.type._def,t)}function Lz(e,t){const s={type:"array",uniqueItems:!0,items:bt(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&(s.minItems=e.minSize.value),e.maxSize&&(s.maxItems=e.maxSize.value),s}function $z(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,s)=>bt(n._def,{...t,currentPath:[...t.currentPath,"items",`${s}`]})).reduce((n,s)=>s===void 0?n:[...n,s],[]),additionalItems:bt(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,s)=>bt(n._def,{...t,currentPath:[...t.currentPath,"items",`${s}`]})).reduce((n,s)=>s===void 0?n:[...n,s],[])}}function Uz(){return{not:fs()}}function Bz(){return fs()}var Vz=(e,t)=>bt(e.innerType._def,t),Fz=(e,t,n)=>{switch(t){case Xe.ZodString:return eC(e,n);case Xe.ZodNumber:return Mz(e);case Xe.ZodObject:return _z(e,n);case Xe.ZodBigInt:return fz(e);case Xe.ZodBoolean:return hz();case Xe.ZodDate:return QE(e,n);case Xe.ZodUndefined:return Uz();case Xe.ZodNull:return Cz();case Xe.ZodArray:return dz(e,n);case Xe.ZodUnion:case Xe.ZodDiscriminatedUnion:return Tz(e,n);case Xe.ZodIntersection:return xz(e,n);case Xe.ZodTuple:return $z(e,n);case Xe.ZodRecord:return tC(e,n);case Xe.ZodLiteral:return wz(e);case Xe.ZodEnum:return yz(e);case Xe.ZodNativeEnum:return kz(e);case Xe.ZodNullable:return Rz(e,n);case Xe.ZodOptional:return Dz(e,n);case Xe.ZodMap:return Nz(e,n);case Xe.ZodSet:return Lz(e,n);case Xe.ZodLazy:return()=>e.getter()._def;case Xe.ZodPromise:return zz(e,n);case Xe.ZodNaN:case Xe.ZodNever:return Ez();case Xe.ZodEffects:return vz(e,n);case Xe.ZodAny:return fs();case Xe.ZodUnknown:return Bz();case Xe.ZodDefault:return gz(e,n);case Xe.ZodBranded:return JE(e,n);case Xe.ZodReadonly:return Vz(e,n);case Xe.ZodCatch:return pz(e,n);case Xe.ZodPipeline:return Pz(e,n);case Xe.ZodFunction:case Xe.ZodVoid:case Xe.ZodSymbol:return;default:return(s=>{})()}},Hz=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join("/")};function bt(e,t,n=!1){var s;const a=t.seen.get(e);if(t.override){const p=(s=t.override)==null?void 0:s.call(t,e,t,a,n);if(p!==cz)return p}if(a&&!n){const p=qz(a,t);if(p!==void 0)return p}const l={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,l);const u=Fz(e,e.typeName,t),d=typeof u=="function"?bt(u(),t):u;if(d&&Zz(e,t,d),t.postProcess){const p=t.postProcess(d,e,t);return l.jsonSchema=d,p}return l.jsonSchema=d,d}var qz=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:Hz(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((n,s)=>t.currentPath[s]===n)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),fs()):t.$refStrategy==="seen"?fs():void 0}},Zz=(e,t,n)=>(e.description&&(n.description=e.description),n),Wz=e=>{const t=uz(e),n=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([s,a])=>[a._def,{def:a._def,path:[...t.basePath,t.definitionPath,s],jsonSchema:void 0}]))}},Yz=(e,t)=>{var n;const s=Wz(t);let a=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((h,[m,y])=>{var x;return{...h,[m]:(x=bt(y._def,{...s,currentPath:[...s.basePath,s.definitionPath,m]},!0))!=null?x:fs()}},{}):void 0;const l=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,u=(n=bt(e._def,l===void 0?s:{...s,currentPath:[...s.basePath,s.definitionPath,l]},!1))!=null?n:fs(),d=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;d!==void 0&&(u.title=d);const p=l===void 0?a?{...u,[s.definitionPath]:a}:u:{$ref:[...s.$refStrategy==="relative"?[]:s.basePath,s.definitionPath,l].join("/"),[s.definitionPath]:{...a,[l]:u}};return p.$schema="http://json-schema.org/draft-07/schema#",p},Jg=Symbol.for("vercel.ai.schema");function Gz(e){let t;return()=>(t==null&&(t=e()),t)}function nh(e,{validate:t}={}){return{[Jg]:!0,_type:void 0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function Kz(e){return typeof e=="object"&&e!==null&&Jg in e&&e[Jg]===!0&&"jsonSchema"in e&&"validate"in e}function fy(e){return e==null?nh({properties:{},additionalProperties:!1}):Kz(e)?e:"~standard"in e?e["~standard"].vendor==="zod"?nC(e):Xz(e):e()}function Xz(e){return nh(()=>dy(e["~standard"].jsonSchema.input({target:"draft-07"})),{validate:async t=>{const n=await e["~standard"].validate(t);return"value"in n?{success:!0,value:n.value}:{success:!1,error:new Yo({value:t,cause:n.issues})}}})}function Jz(e,t){var n;const s=(n=void 0)!=null?n:!1;return nh(()=>Yz(e,{$refStrategy:s?"root":"none"}),{validate:async a=>{const l=await e.safeParseAsync(a);return l.success?{success:!0,value:l.data}:{success:!1,error:l.error}}})}function Qz(e,t){var n;const s=(n=void 0)!=null?n:!1;return nh(()=>dy(zP(e,{target:"draft-7",io:"input",reused:s?"ref":"inline"})),{validate:async a=>{const l=await VE(e,a);return l.success?{success:!0,value:l.data}:{success:!1,error:l.error}}})}function e3(e){return"_zod"in e}function nC(e,t){return e3(e)?Qz(e):Jz(e)}async function yj({value:e,schema:t,context:n}){const s=await _c({value:e,schema:t,context:n});if(!s.success)throw Yo.wrap({value:e,cause:s.error,context:n});return s.value}async function _c({value:e,schema:t,context:n}){const s=fy(t);try{if(s.validate==null)return{success:!0,value:e,rawValue:e};const a=await s.validate(e);return a.success?{success:!0,value:a.value,rawValue:e}:{success:!1,error:Yo.wrap({value:e,cause:a.error,context:n}),rawValue:e}}catch(a){return{success:!1,error:Yo.wrap({value:e,cause:a,context:n}),rawValue:e}}}async function xi({text:e,schema:t}){try{const n=lz(e);return t==null?{success:!0,value:n,rawValue:n}:await _c({value:n,schema:t})}catch(n){return{success:!1,error:L1.isInstance(n)?n:new L1({text:e,cause:n}),rawValue:void 0}}}function t3({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new sz).pipeThrough(new TransformStream({async transform({data:n},s){n!=="[DONE]"&&s.enqueue(await xi({text:n,schema:t}))}}))}async function ga(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}var n3=Object.defineProperty,s3=(e,t)=>{for(var n in t)n3(e,n,{get:t[n],enumerable:!0})},sC="AI_NoObjectGeneratedError",rC=`vercel.ai.error.${sC}`,r3=Symbol.for(rC),aC,ja=class extends lr{constructor({message:e="No object generated.",cause:t,text:n,response:s,usage:a,finishReason:l}){super({name:sC,message:e,cause:t}),this[aC]=!0,this.text=n,this.response=s,this.usage=a,this.finishReason=l}static isInstance(e){return lr.hasMarker(e,rC)}};aC=r3;var iC="AI_UIMessageStreamError",oC=`vercel.ai.error.${iC}`,a3=Symbol.for(oC),lC,yo=class extends lr{constructor({chunkType:e,chunkId:t,message:n}){super({name:iC,message:n}),this[lC]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return lr.hasMarker(e,oC)}};lC=a3;var cC=Fn([Ce(),xf(Uint8Array),xf(ArrayBuffer),XE(e=>{var t,n;return(n=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?n:!1},{message:"Must be a Buffer"})]),Oc=J4(()=>Fn([E4(),Ce(),j4(),Un(),Rc(Ce(),Oc.optional()),nl(Oc)])),rt=Rc(Ce(),Rc(Ce(),Oc.optional())),uC=Tt({type:He("text"),text:Ce(),providerOptions:rt.optional()}),i3=Tt({type:He("image"),image:Fn([cC,xf(URL)]),mediaType:Ce().optional(),providerOptions:rt.optional()}),dC=Tt({type:He("file"),data:Fn([cC,xf(URL)]),filename:Ce().optional(),mediaType:Ce(),providerOptions:rt.optional()}),o3=Tt({type:He("reasoning"),text:Ce(),providerOptions:rt.optional()}),l3=Tt({type:He("tool-call"),toolCallId:Ce(),toolName:Ce(),input:nr(),providerOptions:rt.optional(),providerExecuted:Un().optional()}),c3=M4("type",[Tt({type:He("text"),value:Ce(),providerOptions:rt.optional()}),Tt({type:He("json"),value:Oc,providerOptions:rt.optional()}),Tt({type:He("execution-denied"),reason:Ce().optional(),providerOptions:rt.optional()}),Tt({type:He("error-text"),value:Ce(),providerOptions:rt.optional()}),Tt({type:He("error-json"),value:Oc,providerOptions:rt.optional()}),Tt({type:He("content"),value:nl(Fn([Tt({type:He("text"),text:Ce(),providerOptions:rt.optional()}),Tt({type:He("media"),data:Ce(),mediaType:Ce()}),Tt({type:He("file-data"),data:Ce(),mediaType:Ce(),filename:Ce().optional(),providerOptions:rt.optional()}),Tt({type:He("file-url"),url:Ce(),providerOptions:rt.optional()}),Tt({type:He("file-id"),fileId:Fn([Ce(),Rc(Ce(),Ce())]),providerOptions:rt.optional()}),Tt({type:He("image-data"),data:Ce(),mediaType:Ce(),providerOptions:rt.optional()}),Tt({type:He("image-url"),url:Ce(),providerOptions:rt.optional()}),Tt({type:He("image-file-id"),fileId:Fn([Ce(),Rc(Ce(),Ce())]),providerOptions:rt.optional()}),Tt({type:He("custom"),providerOptions:rt.optional()})]))})]),fC=Tt({type:He("tool-result"),toolCallId:Ce(),toolName:Ce(),output:c3,providerOptions:rt.optional()}),u3=Tt({type:He("tool-approval-request"),approvalId:Ce(),toolCallId:Ce()}),d3=Tt({type:He("tool-approval-response"),approvalId:Ce(),approved:Un(),reason:Ce().optional()}),f3=Tt({role:He("system"),content:Ce(),providerOptions:rt.optional()}),h3=Tt({role:He("user"),content:Fn([Ce(),nl(Fn([uC,i3,dC]))]),providerOptions:rt.optional()}),p3=Tt({role:He("assistant"),content:Fn([Ce(),nl(Fn([uC,dC,o3,l3,fC,u3]))]),providerOptions:rt.optional()}),m3=Tt({role:He("tool"),content:nl(Fn([fC,d3])),providerOptions:rt.optional()});Fn([f3,h3,p3,m3]);function hC(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;const n={...e};for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)){const a=t[s];if(a===void 0)continue;const l=s in e?e[s]:void 0,u=a!==null&&typeof a=="object"&&!Array.isArray(a)&&!(a instanceof Date)&&!(a instanceof RegExp),d=l!=null&&typeof l=="object"&&!Array.isArray(l)&&!(l instanceof Date)&&!(l instanceof RegExp);u&&d?n[s]=hC(l,a):n[s]=a}return n}var g3={};s3(g3,{array:()=>x3,choice:()=>w3,json:()=>j3,object:()=>b3,text:()=>y3});function v3(e){const t=["ROOT"];let n=-1,s=null;function a(p,h,m){switch(p){case'"':{n=h,t.pop(),t.push(m),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=h,s=h,t.pop(),t.push(m),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(m),t.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=h,t.pop(),t.push(m),t.push("INSIDE_NUMBER");break}case"{":{n=h,t.pop(),t.push(m),t.push("INSIDE_OBJECT_START");break}case"[":{n=h,t.pop(),t.push(m),t.push("INSIDE_ARRAY_START");break}}}function l(p,h){switch(p){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{n=h,t.pop();break}}}function u(p,h){switch(p){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=h,t.pop();break}}}for(let p=0;p<e.length;p++){const h=e[p];switch(t[t.length-1]){case"ROOT":a(h,p,"FINISH");break;case"INSIDE_OBJECT_START":{switch(h){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{n=p,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{h==='"'&&(t.pop(),t.push("INSIDE_OBJECT_KEY"));break}case"INSIDE_OBJECT_KEY":{h==='"'&&(t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY"));break}case"INSIDE_OBJECT_AFTER_KEY":{h===":"&&(t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE"));break}case"INSIDE_OBJECT_BEFORE_VALUE":{a(h,p,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{l(h,p);break}case"INSIDE_STRING":{switch(h){case'"':{t.pop(),n=p;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:n=p}break}case"INSIDE_ARRAY_START":{h==="]"?(n=p,t.pop()):(n=p,a(h,p,"INSIDE_ARRAY_AFTER_VALUE"));break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(h){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=p,t.pop();break}default:{n=p;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{a(h,p,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),n=p;break}case"INSIDE_NUMBER":{switch(h){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{n=p;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&u(h,p),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&l(h,p);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&l(h,p);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&u(h,p);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const y=e.substring(s,p+1);!"false".startsWith(y)&&!"true".startsWith(y)&&!"null".startsWith(y)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?l(h,p):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&u(h,p)):n=p;break}}}let d=e.slice(0,n+1);for(let p=t.length-1;p>=0;p--)switch(t[p]){case"INSIDE_STRING":{d+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{d+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{d+="]";break}case"INSIDE_LITERAL":{const m=e.substring(s,e.length);"true".startsWith(m)?d+="true".slice(m.length):"false".startsWith(m)?d+="false".slice(m.length):"null".startsWith(m)&&(d+="null".slice(m.length))}}return d}async function Wc(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await xi({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await xi({text:v3(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var y3=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),b3=({schema:e,name:t,description:n})=>{const s=fy(e);return{name:"object",responseFormat:ga(s.jsonSchema).then(a=>({type:"json",schema:a,...t!=null&&{name:t},...n!=null&&{description:n}})),async parseCompleteOutput({text:a},l){const u=await xi({text:a});if(!u.success)throw new ja({message:"No object generated: could not parse the response.",cause:u.error,text:a,response:l.response,usage:l.usage,finishReason:l.finishReason});const d=await _c({value:u.value,schema:s});if(!d.success)throw new ja({message:"No object generated: response did not match schema.",cause:d.error,text:a,response:l.response,usage:l.usage,finishReason:l.finishReason});return d.value},async parsePartialOutput({text:a}){const l=await Wc(a);switch(l.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:l.value}}},createElementStreamTransform(){}}},x3=({element:e,name:t,description:n})=>{const s=fy(e);return{name:"array",responseFormat:ga(s.jsonSchema).then(a=>{const{$schema:l,...u}=a;return{type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:u}},required:["elements"],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}}),async parseCompleteOutput({text:a},l){const u=await xi({text:a});if(!u.success)throw new ja({message:"No object generated: could not parse the response.",cause:u.error,text:a,response:l.response,usage:l.usage,finishReason:l.finishReason});const d=u.value;if(d==null||typeof d!="object"||!("elements"in d)||!Array.isArray(d.elements))throw new ja({message:"No object generated: response did not match schema.",cause:new Yo({value:d,cause:"response must be an object with an elements array"}),text:a,response:l.response,usage:l.usage,finishReason:l.finishReason});for(const p of d.elements){const h=await _c({value:p,schema:s});if(!h.success)throw new ja({message:"No object generated: response did not match schema.",cause:h.error,text:a,response:l.response,usage:l.usage,finishReason:l.finishReason})}return d.elements},async parsePartialOutput({text:a}){const l=await Wc(a);switch(l.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const u=l.value;if(u==null||typeof u!="object"||!("elements"in u)||!Array.isArray(u.elements))return;const d=l.state==="repaired-parse"&&u.elements.length>0?u.elements.slice(0,-1):u.elements,p=[];for(const h of d){const m=await _c({value:h,schema:s});m.success&&p.push(m.value)}return{partial:p}}}},createElementStreamTransform(){let a=0;return new TransformStream({transform({partialOutput:l},u){if(l!=null)for(;a<l.length;a++)u.enqueue(l[a])}})}}},w3=({options:e,name:t,description:n})=>({name:"choice",responseFormat:Promise.resolve({type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{result:{type:"string",enum:e}},required:["result"],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}),async parseCompleteOutput({text:s},a){const l=await xi({text:s});if(!l.success)throw new ja({message:"No object generated: could not parse the response.",cause:l.error,text:s,response:a.response,usage:a.usage,finishReason:a.finishReason});const u=l.value;if(u==null||typeof u!="object"||!("result"in u)||typeof u.result!="string"||!e.includes(u.result))throw new ja({message:"No object generated: response did not match schema.",cause:new Yo({value:u,cause:"response must be an object that contains a choice value."}),text:s,response:a.response,usage:a.usage,finishReason:a.finishReason});return u.result},async parsePartialOutput({text:s}){const a=await Wc(s);switch(a.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const l=a.value;if(l==null||typeof l!="object"||!("result"in l)||typeof l.result!="string")return;const u=e.filter(d=>d.startsWith(l.result));return a.state==="successful-parse"?u.includes(l.result)?{partial:l.result}:void 0:u.length===1?{partial:u[0]}:void 0}}},createElementStreamTransform(){}}),j3=({name:e,description:t}={})=>({name:"json",responseFormat:Promise.resolve({type:"json",...e!=null&&{name:e},...t!=null&&{description:t}}),async parseCompleteOutput({text:n},s){const a=await xi({text:n});if(!a.success)throw new ja({message:"No object generated: could not parse the response.",cause:a.error,text:n,response:s.response,usage:s.usage,finishReason:s.finishReason});return a.value},async parsePartialOutput({text:n}){const s=await Wc(n);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return s.value===void 0?void 0:{partial:s.value}}},createElementStreamTransform(){}});Zc({prefix:"aitxt",size:24});(class extends TransformStream{constructor(){super({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}
|
|
62
|
-
|
|
63
|
-
`)},flush(e){e.enqueue(`data: [DONE]
|
|
64
|
-
|
|
65
|
-
`)}})}});var S3=Gz(()=>nC(Fn([Ot({type:He("text-start"),id:Ce(),providerMetadata:rt.optional()}),Ot({type:He("text-delta"),id:Ce(),delta:Ce(),providerMetadata:rt.optional()}),Ot({type:He("text-end"),id:Ce(),providerMetadata:rt.optional()}),Ot({type:He("error"),errorText:Ce()}),Ot({type:He("tool-input-start"),toolCallId:Ce(),toolName:Ce(),providerExecuted:Un().optional(),providerMetadata:rt.optional(),dynamic:Un().optional(),title:Ce().optional()}),Ot({type:He("tool-input-delta"),toolCallId:Ce(),inputTextDelta:Ce()}),Ot({type:He("tool-input-available"),toolCallId:Ce(),toolName:Ce(),input:nr(),providerExecuted:Un().optional(),providerMetadata:rt.optional(),dynamic:Un().optional(),title:Ce().optional()}),Ot({type:He("tool-input-error"),toolCallId:Ce(),toolName:Ce(),input:nr(),providerExecuted:Un().optional(),providerMetadata:rt.optional(),dynamic:Un().optional(),errorText:Ce(),title:Ce().optional()}),Ot({type:He("tool-approval-request"),approvalId:Ce(),toolCallId:Ce()}),Ot({type:He("tool-output-available"),toolCallId:Ce(),output:nr(),providerExecuted:Un().optional(),providerMetadata:rt.optional(),dynamic:Un().optional(),preliminary:Un().optional()}),Ot({type:He("tool-output-error"),toolCallId:Ce(),errorText:Ce(),providerExecuted:Un().optional(),providerMetadata:rt.optional(),dynamic:Un().optional()}),Ot({type:He("tool-output-denied"),toolCallId:Ce()}),Ot({type:He("reasoning-start"),id:Ce(),providerMetadata:rt.optional()}),Ot({type:He("reasoning-delta"),id:Ce(),delta:Ce(),providerMetadata:rt.optional()}),Ot({type:He("reasoning-end"),id:Ce(),providerMetadata:rt.optional()}),Ot({type:He("source-url"),sourceId:Ce(),url:Ce(),title:Ce().optional(),providerMetadata:rt.optional()}),Ot({type:He("source-document"),sourceId:Ce(),mediaType:Ce(),title:Ce(),filename:Ce().optional(),providerMetadata:rt.optional()}),Ot({type:He("file"),url:Ce(),mediaType:Ce(),providerMetadata:rt.optional()}),Ot({type:XE(e=>typeof e=="string"&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:Ce().optional(),data:nr(),transient:Un().optional()}),Ot({type:He("start-step")}),Ot({type:He("finish-step")}),Ot({type:He("start"),messageId:Ce().optional(),messageMetadata:nr().optional()}),Ot({type:He("finish"),finishReason:YE(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:nr().optional()}),Ot({type:He("abort"),reason:Ce().optional()}),Ot({type:He("message-metadata"),messageMetadata:nr()})])));function N3(e){return e.type.startsWith("data-")}function Qg(e){return e.type.startsWith("tool-")}function pC(e){return e.type==="dynamic-tool"}function wi(e){return Qg(e)||pC(e)}function ev(e){return e.type.split("-").slice(1).join("-")}function mC(e){return pC(e)?e.toolName:ev(e)}function k3({lastMessage:e,messageId:t}){return{message:e?.role==="assistant"?e:{id:t,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function E3({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:s,onError:a,onToolCall:l,onData:u}){return e.pipeThrough(new TransformStream({async transform(d,p){await s(async({state:h,write:m})=>{var y,x,w,j;function N(S){const A=h.message.parts.filter(wi).find(M=>M.toolCallId===S);if(A==null)throw new yo({chunkType:"tool-invocation",chunkId:S,message:`No tool invocation found for tool call ID "${S}".`});return A}function k(S){var R;const A=h.message.parts.find(z=>Qg(z)&&z.toolCallId===S.toolCallId),M=S,_=A;if(A!=null){A.state=S.state,_.input=M.input,_.output=M.output,_.errorText=M.errorText,_.rawInput=M.rawInput,_.preliminary=M.preliminary,S.title!==void 0&&(_.title=S.title),_.providerExecuted=(R=M.providerExecuted)!=null?R:A.providerExecuted;const z=M.providerMetadata;if(z!=null)if(S.state==="output-available"||S.state==="output-error"){const V=A;V.resultProviderMetadata=z}else A.callProviderMetadata=z}else h.message.parts.push({type:`tool-${S.toolName}`,toolCallId:S.toolCallId,state:S.state,title:S.title,input:M.input,output:M.output,rawInput:M.rawInput,errorText:M.errorText,providerExecuted:M.providerExecuted,preliminary:M.preliminary,...M.providerMetadata!=null&&(S.state==="output-available"||S.state==="output-error")?{resultProviderMetadata:M.providerMetadata}:{},...M.providerMetadata!=null&&!(S.state==="output-available"||S.state==="output-error")?{callProviderMetadata:M.providerMetadata}:{}})}function E(S){var R,A;const M=h.message.parts.find(V=>V.type==="dynamic-tool"&&V.toolCallId===S.toolCallId),_=S,z=M;if(M!=null){M.state=S.state,z.toolName=S.toolName,z.input=_.input,z.output=_.output,z.errorText=_.errorText,z.rawInput=(R=_.rawInput)!=null?R:z.rawInput,z.preliminary=_.preliminary,S.title!==void 0&&(z.title=S.title),z.providerExecuted=(A=_.providerExecuted)!=null?A:M.providerExecuted;const V=_.providerMetadata;if(V!=null)if(S.state==="output-available"||S.state==="output-error"){const U=M;U.resultProviderMetadata=V}else M.callProviderMetadata=V}else h.message.parts.push({type:"dynamic-tool",toolName:S.toolName,toolCallId:S.toolCallId,state:S.state,input:_.input,output:_.output,errorText:_.errorText,preliminary:_.preliminary,providerExecuted:_.providerExecuted,title:S.title,..._.providerMetadata!=null&&(S.state==="output-available"||S.state==="output-error")?{resultProviderMetadata:_.providerMetadata}:{},..._.providerMetadata!=null&&!(S.state==="output-available"||S.state==="output-error")?{callProviderMetadata:_.providerMetadata}:{}})}async function C(S){if(S!=null){const R=h.message.metadata!=null?hC(h.message.metadata,S):S;t!=null&&await yj({value:R,schema:t,context:{field:"message.metadata",entityId:h.message.id}}),h.message.metadata=R}}switch(d.type){case"text-start":{const S={type:"text",text:"",providerMetadata:d.providerMetadata,state:"streaming"};h.activeTextParts[d.id]=S,h.message.parts.push(S),m();break}case"text-delta":{const S=h.activeTextParts[d.id];if(S==null)throw new yo({chunkType:"text-delta",chunkId:d.id,message:`Received text-delta for missing text part with ID "${d.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});S.text+=d.delta,S.providerMetadata=(y=d.providerMetadata)!=null?y:S.providerMetadata,m();break}case"text-end":{const S=h.activeTextParts[d.id];if(S==null)throw new yo({chunkType:"text-end",chunkId:d.id,message:`Received text-end for missing text part with ID "${d.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});S.state="done",S.providerMetadata=(x=d.providerMetadata)!=null?x:S.providerMetadata,delete h.activeTextParts[d.id],m();break}case"reasoning-start":{const S={type:"reasoning",text:"",providerMetadata:d.providerMetadata,state:"streaming"};h.activeReasoningParts[d.id]=S,h.message.parts.push(S),m();break}case"reasoning-delta":{const S=h.activeReasoningParts[d.id];if(S==null)throw new yo({chunkType:"reasoning-delta",chunkId:d.id,message:`Received reasoning-delta for missing reasoning part with ID "${d.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});S.text+=d.delta,S.providerMetadata=(w=d.providerMetadata)!=null?w:S.providerMetadata,m();break}case"reasoning-end":{const S=h.activeReasoningParts[d.id];if(S==null)throw new yo({chunkType:"reasoning-end",chunkId:d.id,message:`Received reasoning-end for missing reasoning part with ID "${d.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});S.providerMetadata=(j=d.providerMetadata)!=null?j:S.providerMetadata,S.state="done",delete h.activeReasoningParts[d.id],m();break}case"file":{h.message.parts.push({type:"file",mediaType:d.mediaType,url:d.url,...d.providerMetadata!=null?{providerMetadata:d.providerMetadata}:{}}),m();break}case"source-url":{h.message.parts.push({type:"source-url",sourceId:d.sourceId,url:d.url,title:d.title,providerMetadata:d.providerMetadata}),m();break}case"source-document":{h.message.parts.push({type:"source-document",sourceId:d.sourceId,mediaType:d.mediaType,title:d.title,filename:d.filename,providerMetadata:d.providerMetadata}),m();break}case"tool-input-start":{const S=h.message.parts.filter(Qg);h.partialToolCalls[d.toolCallId]={text:"",toolName:d.toolName,index:S.length,dynamic:d.dynamic,title:d.title},d.dynamic?E({toolCallId:d.toolCallId,toolName:d.toolName,state:"input-streaming",input:void 0,providerExecuted:d.providerExecuted,title:d.title,providerMetadata:d.providerMetadata}):k({toolCallId:d.toolCallId,toolName:d.toolName,state:"input-streaming",input:void 0,providerExecuted:d.providerExecuted,title:d.title,providerMetadata:d.providerMetadata}),m();break}case"tool-input-delta":{const S=h.partialToolCalls[d.toolCallId];if(S==null)throw new yo({chunkType:"tool-input-delta",chunkId:d.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${d.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});S.text+=d.inputTextDelta;const{value:R}=await Wc(S.text);S.dynamic?E({toolCallId:d.toolCallId,toolName:S.toolName,state:"input-streaming",input:R,title:S.title}):k({toolCallId:d.toolCallId,toolName:S.toolName,state:"input-streaming",input:R,title:S.title}),m();break}case"tool-input-available":{d.dynamic?E({toolCallId:d.toolCallId,toolName:d.toolName,state:"input-available",input:d.input,providerExecuted:d.providerExecuted,providerMetadata:d.providerMetadata,title:d.title}):k({toolCallId:d.toolCallId,toolName:d.toolName,state:"input-available",input:d.input,providerExecuted:d.providerExecuted,providerMetadata:d.providerMetadata,title:d.title}),m(),l&&!d.providerExecuted&&await l({toolCall:d});break}case"tool-input-error":{const S=h.message.parts.filter(wi).find(A=>A.toolCallId===d.toolCallId);(S!=null?S.type==="dynamic-tool":!!d.dynamic)?E({toolCallId:d.toolCallId,toolName:d.toolName,state:"output-error",input:d.input,errorText:d.errorText,providerExecuted:d.providerExecuted,providerMetadata:d.providerMetadata}):k({toolCallId:d.toolCallId,toolName:d.toolName,state:"output-error",input:void 0,rawInput:d.input,errorText:d.errorText,providerExecuted:d.providerExecuted,providerMetadata:d.providerMetadata}),m();break}case"tool-approval-request":{const S=N(d.toolCallId);S.state="approval-requested",S.approval={id:d.approvalId},m();break}case"tool-output-denied":{const S=N(d.toolCallId);S.state="output-denied",m();break}case"tool-output-available":{const S=N(d.toolCallId);S.type==="dynamic-tool"?E({toolCallId:d.toolCallId,toolName:S.toolName,state:"output-available",input:S.input,output:d.output,preliminary:d.preliminary,providerExecuted:d.providerExecuted,providerMetadata:d.providerMetadata,title:S.title}):k({toolCallId:d.toolCallId,toolName:ev(S),state:"output-available",input:S.input,output:d.output,providerExecuted:d.providerExecuted,preliminary:d.preliminary,providerMetadata:d.providerMetadata,title:S.title}),m();break}case"tool-output-error":{const S=N(d.toolCallId);S.type==="dynamic-tool"?E({toolCallId:d.toolCallId,toolName:S.toolName,state:"output-error",input:S.input,errorText:d.errorText,providerExecuted:d.providerExecuted,providerMetadata:d.providerMetadata,title:S.title}):k({toolCallId:d.toolCallId,toolName:ev(S),state:"output-error",input:S.input,rawInput:S.rawInput,errorText:d.errorText,providerExecuted:d.providerExecuted,providerMetadata:d.providerMetadata,title:S.title}),m();break}case"start-step":{h.message.parts.push({type:"step-start"});break}case"finish-step":{h.activeTextParts={},h.activeReasoningParts={};break}case"start":{d.messageId!=null&&(h.message.id=d.messageId),await C(d.messageMetadata),(d.messageId!=null||d.messageMetadata!=null)&&m();break}case"finish":{d.finishReason!=null&&(h.finishReason=d.finishReason),await C(d.messageMetadata),d.messageMetadata!=null&&m();break}case"message-metadata":{await C(d.messageMetadata),d.messageMetadata!=null&&m();break}case"error":{a?.(new Error(d.errorText));break}default:if(N3(d)){if(n?.[d.type]!=null){const A=h.message.parts.findIndex(_=>"id"in _&&"data"in _&&_.id===d.id&&_.type===d.type),M=A>=0?A:h.message.parts.length;await yj({value:d.data,schema:n[d.type],context:{field:`message.parts[${M}].data`,entityName:d.type,entityId:d.id}})}const S=d;if(S.transient){u?.(S);break}const R=S.id!=null?h.message.parts.find(A=>S.type===A.type&&S.id===A.id):void 0;R!=null?R.data=S.data:h.message.parts.push(S),u?.(S),m()}}p.enqueue(d)})}}))}async function C3({stream:e,onError:t}){const n=e.getReader();try{for(;;){const{done:s}=await n.read();if(s)break}}catch(s){t?.(s)}finally{n.releaseLock()}}Zc({prefix:"aitxt",size:24});Zc({prefix:"aiobj",size:24});var T3=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(e){return new Promise((t,n)=>{this.queue.push(async()=>{try{await e(),t()}catch(s){n(s)}}),this.processQueue()})}};Zc({prefix:"aiobj",size:24});async function A3(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw new Error("FileList is not supported in the current environment");return Promise.all(Array.from(e).map(async t=>{const{name:n,type:s}=t,a=await new Promise((l,u)=>{const d=new FileReader;d.onload=p=>{var h;l((h=p.target)==null?void 0:h.result)},d.onerror=p=>u(p),d.readAsDataURL(t)});return{type:"file",mediaType:s,filename:n,url:a}}))}var R3=class{constructor({api:e="/api/chat",credentials:t,headers:n,body:s,fetch:a,prepareSendMessagesRequest:l,prepareReconnectToStreamRequest:u}){this.api=e,this.credentials=t,this.headers=n,this.body=s,this.fetch=a,this.prepareSendMessagesRequest=l,this.prepareReconnectToStreamRequest=u}async sendMessages({abortSignal:e,...t}){var n,s,a,l,u;const d=await ga(this.body),p=await ga(this.headers),h=await ga(this.credentials),m={...vo(p),...vo(t.headers)},y=await((n=this.prepareSendMessagesRequest)==null?void 0:n.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...d,...t.body},headers:m,credentials:h,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId})),x=(s=y?.api)!=null?s:this.api,w=y?.headers!==void 0?vo(y.headers):m,j=y?.body!==void 0?y.body:{...d,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId},N=(a=y?.credentials)!=null?a:h,E=await((l=this.fetch)!=null?l:globalThis.fetch)(x,{method:"POST",headers:{"Content-Type":"application/json",...w},body:JSON.stringify(j),credentials:N,signal:e});if(!E.ok)throw new Error((u=await E.text())!=null?u:"Failed to fetch the chat response.");if(!E.body)throw new Error("The response body is empty.");return this.processResponseStream(E.body)}async reconnectToStream(e){var t,n,s,a,l;const u=await ga(this.body),d=await ga(this.headers),p=await ga(this.credentials),h={...vo(d),...vo(e.headers)},m=await((t=this.prepareReconnectToStreamRequest)==null?void 0:t.call(this,{api:this.api,id:e.chatId,body:{...u,...e.body},headers:h,credentials:p,requestMetadata:e.metadata})),y=(n=m?.api)!=null?n:`${this.api}/${e.chatId}/stream`,x=m?.headers!==void 0?vo(m.headers):h,w=(s=m?.credentials)!=null?s:p,N=await((a=this.fetch)!=null?a:globalThis.fetch)(y,{method:"GET",headers:x,credentials:w});if(N.status===204)return null;if(!N.ok)throw new Error((l=await N.text())!=null?l:"Failed to fetch the chat response.");if(!N.body)throw new Error("The response body is empty.");return this.processResponseStream(N.body)}},gC=class extends R3{constructor(e={}){super(e)}processResponseStream(e){return t3({stream:e,schema:S3}).pipeThrough(new TransformStream({async transform(t,n){if(!t.success)throw t.error;n.enqueue(t.value)}}))}},M3=class{constructor({generateId:e=rz,id:t=e(),transport:n=new gC,messageMetadataSchema:s,dataPartSchemas:a,state:l,onError:u,onToolCall:d,onFinish:p,onData:h,sendAutomaticallyWhen:m}){this.activeResponse=void 0,this.jobExecutor=new T3,this.sendMessage=async(y,x)=>{var w,j,N,k;if(y==null){await this.makeRequest({trigger:"submit-message",messageId:(w=this.lastMessage)==null?void 0:w.id,...x});return}let E;if("text"in y||"files"in y?E={parts:[...Array.isArray(y.files)?y.files:await A3(y.files),..."text"in y&&y.text!=null?[{type:"text",text:y.text}]:[]]}:E=y,y.messageId!=null){const C=this.state.messages.findIndex(S=>S.id===y.messageId);if(C===-1)throw new Error(`message with id ${y.messageId} not found`);if(this.state.messages[C].role!=="user")throw new Error(`message with id ${y.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,C+1),this.state.replaceMessage(C,{...E,id:y.messageId,role:(j=E.role)!=null?j:"user",metadata:y.metadata})}else this.state.pushMessage({...E,id:(N=E.id)!=null?N:this.generateId(),role:(k=E.role)!=null?k:"user",metadata:y.metadata});await this.makeRequest({trigger:"submit-message",messageId:y.messageId,...x})},this.regenerate=async({messageId:y,...x}={})=>{const w=y==null?this.state.messages.length-1:this.state.messages.findIndex(j=>j.id===y);if(w===-1)throw new Error(`message ${y} not found`);this.state.messages=this.state.messages.slice(0,this.messages[w].role==="assistant"?w:w+1),await this.makeRequest({trigger:"regenerate-message",messageId:y,...x})},this.resumeStream=async(y={})=>{await this.makeRequest({trigger:"resume-stream",...y})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:y,approved:x,reason:w,options:j})=>this.jobExecutor.run(async()=>{const N=this.state.messages,k=N[N.length-1],E=C=>wi(C)&&C.state==="approval-requested"&&C.approval.id===y?{...C,state:"approval-responded",approval:{id:y,approved:x,reason:w}}:C;this.state.replaceMessage(N.length-1,{...k,parts:k.parts.map(E)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(E)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(C=>{var S;C&&this.makeRequest({trigger:"submit-message",messageId:(S=this.lastMessage)==null?void 0:S.id,...j})})}),this.addToolOutput=async({state:y="output-available",toolCallId:x,output:w,errorText:j,options:N})=>this.jobExecutor.run(async()=>{const k=this.state.messages,E=k[k.length-1],C=S=>wi(S)&&S.toolCallId===x?{...S,state:y,output:w,errorText:j}:S;this.state.replaceMessage(k.length-1,{...E,parts:E.parts.map(C)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(C)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(S=>{var R;S&&this.makeRequest({trigger:"submit-message",messageId:(R=this.lastMessage)==null?void 0:R.id,...N})})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var y;this.status!=="streaming"&&this.status!=="submitted"||(y=this.activeResponse)!=null&&y.abortController&&this.activeResponse.abortController.abort()},this.id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=s,this.dataPartSchemas=a,this.state=l,this.onError=u,this.onToolCall=d,this.onFinish=p,this.onData=h,this.sendAutomaticallyWhen=m}get status(){return this.state.status}setStatus({status:e,error:t}){this.status!==e&&(this.state.status=e,this.state.error=t)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(e){this.state.messages=e}async shouldSendAutomatically(){if(!this.sendAutomaticallyWhen)return!1;const e=this.sendAutomaticallyWhen({messages:this.state.messages});return e&&typeof e=="object"&&"then"in e?await e:e}async makeRequest({trigger:e,metadata:t,headers:n,body:s,messageId:a}){var l,u,d;let p;if(e==="resume-stream")try{const w=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:n,body:s});if(w==null)return;p=w}catch(w){this.onError&&w instanceof Error&&this.onError(w),this.setStatus({status:"error",error:w});return}this.setStatus({status:"submitted",error:void 0});const h=this.lastMessage;let m=!1,y=!1,x=!1;try{const w={state:k3({lastMessage:this.state.snapshot(h),messageId:this.generateId()}),abortController:new AbortController};w.abortController.signal.addEventListener("abort",()=>{m=!0}),this.activeResponse=w;let j;e==="resume-stream"?j=p:j=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:w.abortController.signal,metadata:t,headers:n,body:s,trigger:e,messageId:a});const N=k=>this.jobExecutor.run(()=>k({state:w.state,write:()=>{var E;this.setStatus({status:"streaming"}),w.state.message.id===((E=this.lastMessage)==null?void 0:E.id)?this.state.replaceMessage(this.state.messages.length-1,w.state.message):this.state.pushMessage(w.state.message)}}));await C3({stream:E3({stream:j,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:N,onError:k=>{throw k}}),onError:k=>{throw k}}),this.setStatus({status:"ready"})}catch(w){if(m||w.name==="AbortError")return m=!0,this.setStatus({status:"ready"}),null;x=!0,w instanceof TypeError&&(w.message.toLowerCase().includes("fetch")||w.message.toLowerCase().includes("network"))&&(y=!0),this.onError&&w instanceof Error&&this.onError(w),this.setStatus({status:"error",error:w})}finally{try{(u=this.onFinish)==null||u.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:m,isDisconnect:y,isError:x,finishReason:(l=this.activeResponse)==null?void 0:l.state.finishReason})}catch(w){console.error(w)}this.activeResponse=void 0}!x&&await this.shouldSendAutomatically()&&await this.makeRequest({trigger:"submit-message",messageId:(d=this.lastMessage)==null?void 0:d.id,metadata:t,headers:n,body:s})}},Vm,bj;function _3(){if(bj)return Vm;bj=1;function e(t,n){if(typeof t!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof t}\`.`);let s,a=0;return function(...u){clearTimeout(s);const d=Date.now(),p=d-a,h=n-p;h<=0?(a=d,t.apply(this,u)):s=setTimeout(()=>{a=Date.now(),t.apply(this,u)},h)}}return Vm=e,Vm}var O3=_3();const I3=Ik(O3);var vC=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},It=(e,t,n)=>(vC(e,t,"read from private field"),n?n.call(e):t.get(e)),er=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},ha=(e,t,n,s)=>(vC(e,t,"write to private field"),t.set(e,n),n);function D3(e,t){return t!=null?I3(e,t):e}var Ns,Gd,Kd,lc,cc,uc,Ao,tv,nv,P3=class{constructor(e=[]){er(this,Ns,void 0),er(this,Gd,"ready"),er(this,Kd,void 0),er(this,lc,new Set),er(this,cc,new Set),er(this,uc,new Set),this.pushMessage=t=>{ha(this,Ns,It(this,Ns).concat(t)),It(this,Ao).call(this)},this.popMessage=()=>{ha(this,Ns,It(this,Ns).slice(0,-1)),It(this,Ao).call(this)},this.replaceMessage=(t,n)=>{ha(this,Ns,[...It(this,Ns).slice(0,t),this.snapshot(n),...It(this,Ns).slice(t+1)]),It(this,Ao).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,n)=>{const s=n?D3(t,n):t;return It(this,lc).add(s),()=>{It(this,lc).delete(s)}},this["~registerStatusCallback"]=t=>(It(this,cc).add(t),()=>{It(this,cc).delete(t)}),this["~registerErrorCallback"]=t=>(It(this,uc).add(t),()=>{It(this,uc).delete(t)}),er(this,Ao,()=>{It(this,lc).forEach(t=>t())}),er(this,tv,()=>{It(this,cc).forEach(t=>t())}),er(this,nv,()=>{It(this,uc).forEach(t=>t())}),ha(this,Ns,e)}get status(){return It(this,Gd)}set status(e){ha(this,Gd,e),It(this,tv).call(this)}get error(){return It(this,Kd)}set error(e){ha(this,Kd,e),It(this,nv).call(this)}get messages(){return It(this,Ns)}set messages(e){ha(this,Ns,[...e]),It(this,Ao).call(this)}};Ns=new WeakMap;Gd=new WeakMap;Kd=new WeakMap;lc=new WeakMap;cc=new WeakMap;uc=new WeakMap;Ao=new WeakMap;tv=new WeakMap;nv=new WeakMap;var Ro,xj=class extends M3{constructor({messages:e,...t}){const n=new P3(e);super({...t,state:n}),er(this,Ro,void 0),this["~registerMessagesCallback"]=(s,a)=>It(this,Ro)["~registerMessagesCallback"](s,a),this["~registerStatusCallback"]=s=>It(this,Ro)["~registerStatusCallback"](s),this["~registerErrorCallback"]=s=>It(this,Ro)["~registerErrorCallback"](s),ha(this,Ro,n)}};Ro=new WeakMap;function z3({experimental_throttle:e,resume:t=!1,...n}={}){const s=g.useRef("chat"in n?{}:{onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});"chat"in n||(s.current={onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});const a={...n,onToolCall:x=>{var w,j;return(j=(w=s.current).onToolCall)==null?void 0:j.call(w,x)},onData:x=>{var w,j;return(j=(w=s.current).onData)==null?void 0:j.call(w,x)},onFinish:x=>{var w,j;return(j=(w=s.current).onFinish)==null?void 0:j.call(w,x)},onError:x=>{var w,j;return(j=(w=s.current).onError)==null?void 0:j.call(w,x)},sendAutomaticallyWhen:x=>{var w,j,N;return(N=(j=(w=s.current).sendAutomaticallyWhen)==null?void 0:j.call(w,x))!=null?N:!1}},l=g.useRef("chat"in n?n.chat:new xj(a));("chat"in n&&n.chat!==l.current||"id"in n&&l.current.id!==n.id)&&(l.current="chat"in n?n.chat:new xj(a));const d=g.useCallback(x=>l.current["~registerMessagesCallback"](x,e),[e,l.current.id]),p=g.useSyncExternalStore(d,()=>l.current.messages,()=>l.current.messages),h=g.useSyncExternalStore(l.current["~registerStatusCallback"],()=>l.current.status,()=>l.current.status),m=g.useSyncExternalStore(l.current["~registerErrorCallback"],()=>l.current.error,()=>l.current.error),y=g.useCallback(x=>{typeof x=="function"&&(x=x(l.current.messages)),l.current.messages=x},[l]);return g.useEffect(()=>{t&&l.current.resumeStream()},[t,l]),{id:l.current.id,messages:p,setMessages:y,sendMessage:l.current.sendMessage,regenerate:l.current.regenerate,clearError:l.current.clearError,stop:l.current.stop,error:m,resumeStream:l.current.resumeStream,status:h,addToolResult:l.current.addToolOutput,addToolOutput:l.current.addToolOutput,addToolApprovalResponse:l.current.addToolApprovalResponse}}function L3(e){const t={};for(const n of e.attachmentsRef.current??[])if(e.activeAttachmentsRef.current.has(n.label)){const s=n.content();s!==null&&(t[n.label.toLowerCase()]=s)}return{toolset:e.toolsetRef.current,context:{...e.contextRef.current,...t},mode:e.modeRef.current,sessionId:e.sessionIdRef.current,provider:e.providerRef.current,model:e.modelRef.current}}function $3(e,t){e.current?.(t)}function U3(e,t){e.current?.(t)}function B3(e){const t=new Set;for(const n of e??[])if(n.role==="assistant")for(const s of n.parts??[])s&&wi(s)&&t.add(s.toolCallId);return t}function V3({toolset:e,chatId:t,initialMessages:n,context:s,onToolCall:a,mode:l,attachments:u,provider:d,model:p,sessionId:h,onSessionIdChange:m,onFinish:y,onError:x}){const w=g.useRef(a),j=g.useRef(y),N=g.useRef(x),k=g.useRef(h??crypto.randomUUID()),[E,C]=g.useState(new Set),S=g.useCallback(F=>{C(X=>{const G=new Set(X);return G.has(F)?G.delete(F):G.add(F),G})},[]),[R]=Ir("hudson.settings",{}),A=l??R.aiMode??"api",M=g.useRef(E),_=g.useRef(u),z=g.useRef(s),V=g.useRef(e),U=g.useRef(A),O=g.useRef(d),D=g.useRef(p);g.useEffect(()=>{w.current=a},[a]),g.useEffect(()=>{j.current=y},[y]),g.useEffect(()=>{N.current=x},[x]),g.useEffect(()=>{h&&h!==k.current&&(k.current=h)},[h]),g.useEffect(()=>{m?.(k.current)},[m]),g.useEffect(()=>{M.current=E},[E]),g.useEffect(()=>{_.current=u},[u]),g.useEffect(()=>{z.current=s},[s]),g.useEffect(()=>{V.current=e},[e]),g.useEffect(()=>{U.current=A},[A]),g.useEffect(()=>{O.current=d},[d]),g.useEffect(()=>{D.current=p},[p]);const H=g.useMemo(()=>new gC({api:"/api/ai/chat",body:()=>L3({activeAttachmentsRef:M,attachmentsRef:_,contextRef:z,toolsetRef:V,modeRef:U,sessionIdRef:k,providerRef:O,modelRef:D})}),[]),W=z3({id:t,messages:n,transport:H,onFinish:F=>$3(j,F),onError:F=>U3(N,F)}),q=g.useRef(B3(n)),$=g.useCallback(()=>{const F=crypto.randomUUID();k.current=F,m?.(F),q.current.clear(),W.setMessages([])},[W,m]),{messages:L}=W;return g.useEffect(()=>{if(w.current){for(const F of L)if(F.role==="assistant"){for(const X of F.parts??[])if(X&&wi(X)){if("state"in X&&X.state==="input-streaming")continue;const G=X.toolCallId;if(!q.current.has(G)){q.current.add(G);const I=mC(X);w.current?.(I,X.input??{})}}}}},[L]),{messages:L,sendMessage:W.sendMessage,stop:W.stop,status:W.status,setMessages:W.setMessages,clearChat:$,error:W.error,mode:A,attachments:u??[],activeAttachments:E,toggleAttachment:S}}function F3({app:e,commands:t,state:n,provider:s,model:a,onFinish:l}){const u=g.useMemo(()=>(e.intents??[]).map(h=>({commandId:h.commandId,title:h.title,description:h.description,category:h.category,keywords:h.keywords,shortcut:h.shortcut,dangerous:h.dangerous,params:h.params?.map(m=>({name:m.name,description:m.description,type:m.type,optional:m.optional,enum:m.enum}))})),[e.intents]),d=g.useMemo(()=>({appId:e.id,appName:e.name,appDescription:e.description,intents:u,state:n}),[e.id,e.name,e.description,u,n]),p=g.useCallback(h=>{const m=t.find(y=>y.id===h);if(!m){console.warn(`[useAssistant] no command for id "${h}"`);return}m.action()},[t]);return V3({toolset:"intents",context:d,provider:s,model:a,onFinish:l,onToolCall:(h,m)=>{if(h!=="dispatch")return;const y=m.commandId;typeof y=="string"&&p(y)}})}const H3="modulepreload",q3=function(e){return"/"+e},wj={},vc=function(t,n,s){let a=Promise.resolve();if(n&&n.length>0){let p=function(h){return Promise.all(h.map(m=>Promise.resolve(m).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),d=u?.nonce||u?.getAttribute("nonce");a=p(n.map(h=>{if(h=q3(h),h in wj)return;wj[h]=!0;const m=h.endsWith(".css"),y=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${y}`))return;const x=document.createElement("link");if(x.rel=m?"stylesheet":H3,m||(x.as="script"),x.crossOrigin="",x.href=h,d&&x.setAttribute("nonce",d),document.head.appendChild(x),m)return new Promise((w,j)=>{x.addEventListener("load",w),x.addEventListener("error",()=>j(new Error(`Unable to preload CSS for ${h}`)))})}))}function l(u){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=u,window.dispatchEvent(d),!d.defaultPrevented)throw u}return a.then(u=>{for(const d of u||[])d.status==="rejected"&&l(d.reason);return t().catch(l)})};async function Z3(e){try{return(await e.capabilities())?.daemon?.running?"connected":"warming"}catch(t){if(t&&typeof t=="object"&&"code"in t){const n=t.code,s=String(t.message??"");if(n==="http_error")return s.includes("403")||s.toLowerCase().includes("origin not allowed")?"blocked-origin":"warming"}return"unreachable"}}const W3="audio/ogg;codecs=opus";function Y3(){return typeof MediaRecorder>"u"?void 0:["audio/ogg;codecs=opus","audio/mp4;codecs=mp4a.40.2","audio/mp4","audio/webm;codecs=opus"].find(t=>MediaRecorder.isTypeSupported(t))}function Fm(e){e?.getTracks().forEach(t=>t.stop())}function G3(e){return e.includes("wav")?"wav":e.includes("aac")||e.includes("mp4")?"aac":"opus"}function jj(e,t){return t||e.find(s=>s.type)?.type||W3}function Sj(e){const t=typeof window<"u"?window.location.origin:"this origin";if(e&&typeof e=="object"&&"code"in e&&"message"in e){const n=e;if(n.code==="network_error")return{status:"unavailable",message:"Vox Companion is not reachable on 127.0.0.1:43115. Install Vox.app, or launch it if it is already installed."};if(n.code==="http_error"){const s=n.message??"";return s.includes("Origin not allowed")||s.includes("403")?{status:"error",message:`Vox rejected this origin. Allowlist ${t} in Vox settings and try again.`}:{status:"error",message:"Vox returned an error while transcribing. Check Vox and try again."}}}if(e instanceof DOMException){if(e.name==="NotAllowedError")return{status:"error",message:"Microphone access was denied."};if(e.name==="NotFoundError")return{status:"error",message:"No microphone is available."}}return e instanceof Error?{status:"error",message:e.message}:{status:"error",message:"Voice capture failed."}}async function K3(){const t=(await vc(()=>import("./index-TVkH_WDG.js"),[])).createVoxdClient();return{probe:()=>t.probe(),transcribe:({audio:n,format:s,language:a,metadata:l})=>t.transcribe({audio:n,format:s,language:a,metadata:l}),probeAvailability:()=>Z3(t)}}function X3(e){const{onTranscript:t,surface:n="hudson-assistant",metadata:s,language:a="en",transcribe:l,probe:u}=e,[d,p]=g.useState("idle"),[h,m]=g.useState(null),[y,x]=g.useState(null),w=g.useRef(null),j=g.useRef(null),N=g.useRef([]),k=g.useRef(t);k.current=t;const E=g.useRef(s);E.current=s;const C=g.useRef(null),S=g.useMemo(()=>typeof MediaRecorder<"u"&&typeof navigator<"u"&&!!navigator.mediaDevices?.getUserMedia,[]),R=g.useCallback(async()=>l?{probe:u??(async()=>!0),transcribe:l}:(C.current||(C.current=await K3()),C.current),[l,u]),A=g.useCallback(async(z,V)=>{if(Fm(j.current),j.current=null,w.current=null,z.length===0){p("error"),m("No audio was captured.");return}p("transcribing"),m(null);try{const U=await R(),O=jj(z,V),H=(await U.transcribe({audio:new Blob(z,{type:O}),format:G3(O),language:a,metadata:{surface:n,...E.current}})).text.trim();if(!H)throw new Error("Transcription returned empty text.");x(H),p("ready"),k.current(H)}catch(U){const O=Sj(U);p(O.status),m(O.message)}},[R,a,n]),M=g.useCallback(async()=>{if(!(d==="recording"||d==="transcribing")){if(!S){p("error"),m("This browser cannot capture microphone audio.");return}m(null),x(null);try{const z=await R(),V=z.probeAvailability?await z.probeAvailability():await z.probe()?"connected":"unreachable";if(V==="blocked-origin"){const H=typeof window<"u"?window.location.origin:"this origin";p("error"),m(`Vox rejected this origin. Allowlist ${H} in Vox settings and try again.`);return}if(V==="warming"){p("unavailable"),m("Vox is starting up — try again in a moment.");return}if(V==="unreachable"){p("unavailable"),m("Vox Companion is not reachable on 127.0.0.1:43115. Install Vox.app, or launch it if it is already installed.");return}const U=await navigator.mediaDevices.getUserMedia({audio:!0}),O=Y3(),D=O?new MediaRecorder(U,{mimeType:O}):new MediaRecorder(U);N.current=[],j.current=U,w.current=D,D.ondataavailable=H=>{H.data.size>0&&N.current.push(H.data)},D.onerror=()=>{Fm(j.current),j.current=null,w.current=null,N.current=[],p("error"),m("Voice capture failed while recording.")},D.onstop=()=>{const H=[...N.current];N.current=[],A(H,jj(H,D.mimeType||O||""))},D.start(),p("recording")}catch(z){const V=Sj(z);p(V.status),m(V.message)}}},[A,R,S,d]),_=g.useCallback(()=>{const z=w.current;!z||z.state!=="recording"||(p("transcribing"),z.stop())},[]);return g.useEffect(()=>()=>{const z=w.current;if(z&&z.state==="recording")try{z.stop()}catch{}Fm(j.current),j.current=null,w.current=null,N.current=[]},[]),{status:d,error:h,lastTranscript:y,start:M,stop:_,isSupported:S}}const J3={titleBarInset:0,dragRegionProps:{},onInteractiveMouseDown:void 0,isSSR:!0,apiBaseUrl:"",serviceApiUrl:""},Q3=g.createContext(J3);function Yc(){return g.useContext(Q3)}function eL(){return typeof document>"u"?"wav":document.createElement("audio").canPlayType('audio/mp4; codecs="mp4a.40.2"')?"aac":"wav"}function tL(){const{apiBaseUrl:e}=Yc(),[t,n]=g.useState("idle"),[s,a]=g.useState(null),l=g.useRef(null),u=g.useRef(null),d=g.useRef(0),p=g.useCallback(()=>{d.current+=1;const m=l.current;m&&(m.onended=null,m.onerror=null,m.pause(),l.current=null),u.current&&(URL.revokeObjectURL(u.current),u.current=null),n(y=>y==="speaking"||y==="synthesizing"?"idle":y)},[]),h=g.useCallback(async(m,y={})=>{if(!m||!m.trim())return;const x=d.current+1;d.current=x,n("synthesizing"),a(null);try{const w=await fetch(`${e}/v1/audio/speech`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:m,provider:y.provider,model:y.model,voice:y.voice||void 0,rate:y.rate,format:eL(),metadata:y.metadata})}),j=await w.json();if(!w.ok)throw new Error(j.error||`Speech synthesis failed (${w.status}).`);const N=j.audio?.base64??j.audioBase64,k=j.audio?.mimeType??j.mimeType??"audio/wav";if(!N)throw new Error("Speech synthesis returned no audio.");if(d.current!==x)return;l.current&&(l.current.pause(),l.current=null),u.current&&(URL.revokeObjectURL(u.current),u.current=null);const E=Uint8Array.from(atob(N),A=>A.charCodeAt(0)),C=new Blob([E],{type:k}),S=URL.createObjectURL(C),R=new Audio(S);l.current=R,u.current=S,n("speaking"),R.onended=()=>{l.current===R&&(l.current=null),u.current===S&&(URL.revokeObjectURL(S),u.current=null),n(A=>A==="speaking"?"idle":A)},R.onerror=()=>{l.current===R&&(l.current=null),u.current===S&&(URL.revokeObjectURL(S),u.current=null),n("error"),a("Reply audio could not be played in this browser.")},await R.play()}catch(w){if(d.current!==x)return;p(),n("error"),a(w instanceof Error?w.message:"Reply speech failed.")}},[e,p]);return g.useEffect(()=>()=>{const m=l.current;m&&(m.onended=null,m.onerror=null,m.pause()),u.current&&URL.revokeObjectURL(u.current),l.current=null,u.current=null},[]),{status:t,error:s,speak:h,stop:p,isPlaying:t==="synthesizing"||t==="speaking"}}const sh={panels:{statusBar:"bg-card/95 backdrop-blur-xl border-t border-border/40 shadow-[var(--hud-shadow-bar)] fixed bottom-0 left-0 right-0 z-[60]"},zIndex:{drawer:70},layout:{navHeight:48,statusBarHeight:28}},nL=sh.panels;g.createContext(null);const sL={autoSend:!0,speakReplies:!1,replyProvider:"system",replyModel:"system",replyVoice:"",replyRate:1,spokenReplyStyle:"adaptive",spokenReplyLongResponse:"invite",spokenReplyCodeResponse:"summary",spokenReplyMaxChars:720},rL=3,aL=6,iL=4,oL=320,lL=760,cL=480,uL={balanced:{spokenReplyStyle:"adaptive",spokenReplyLongResponse:"invite",spokenReplyCodeResponse:"summary",spokenReplyMaxChars:720}},ec=uL.balanced;function Sa(e){return e.replace(/\s+/g," ").trim()}function yC(e){return e.replace(/<think>[\s\S]*?<\/think>/g," ")}function Nj(e){return Sa(e.replace(/```[\s\S]*?```/g," ").replace(/`([^`]+)`/g,"$1").replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/^#{1,6}\s+/gm,"").replace(/^\s*>\s?/gm,"").replace(/^\s*[-*+]\s+/gm,"").replace(/^\s*\d+\.\s+/gm,"").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/_([^_]+)_/g,"$1").replace(/~~([^~]+)~~/g,"$1").replace(/\|/g," ").replace(/\n{2,}/g,`
|
|
66
|
-
`).replace(/\n/g," "))}function dL(e){return Sa(e).split(new RegExp("(?<=[.!?])\\s+")).map(t=>t.trim()).filter(Boolean)}function Hm(e,t){if(e.length<=t)return e;const n=e.slice(0,t).trim(),s=n.lastIndexOf(" ");return(s>Math.floor(t*.6)?n.slice(0,s):n).replace(/[,:; -]+$/,"").trim()}function xd(e){return e&&(/[.!?]$/.test(e)?e:`${e}.`)}function bC(e,t,n){const s=dL(e);if(s.length===0)return xd(Hm(Sa(e),n));const a=[];for(const u of s){const d=Sa([...a,u].join(" "));if(a.length>0&&d.length>n||(a.push(u),a.length>=t))break}if(a.length===0)return xd(Hm(s[0]??e,n));const l=Sa(a.join(" "));return l.length<=n?xd(l):xd(Hm(l,n))}function fL(e){return typeof e=="string"?{...ec,spokenReplyStyle:e}:{spokenReplyStyle:e.spokenReplyStyle??ec.spokenReplyStyle,spokenReplyLongResponse:e.spokenReplyLongResponse??ec.spokenReplyLongResponse,spokenReplyCodeResponse:e.spokenReplyCodeResponse??ec.spokenReplyCodeResponse,spokenReplyMaxChars:e.spokenReplyMaxChars??ec.spokenReplyMaxChars}}function hL(e){switch(e){case"full":return{maxSentences:aL,maxChars:lL};case"adaptive":return{maxSentences:iL,maxChars:cL};default:return{maxSentences:rL,maxChars:oL}}}function pL(e){const t=yC(e),n=[...t.matchAll(/```[\s\S]*?```/g)],s=[...t.matchAll(/`[^`]+`/g)],a=t.replace(/```[\s\S]*?```/g," ").replace(/`([^`]+)`/g," $1 "),l=Nj(t),u=Nj(a),d=n.reduce((h,m)=>h+m[0].length,0)+s.reduce((h,m)=>h+m[0].length,0),p=n.length>0||s.length>=2||d>120&&d>l.length*.18||/(const|let|function|class|interface|return|import|export)\s+/.test(t)&&/[{}();]/.test(t);return{cleaned:l,proseOnly:u,codeHeavy:p}}function hy(e,t){const{maxSentences:n,maxChars:s}=hL(t);return bC(e,n,s)}function sv(e){return bC(e,3,260)}function mL(e,t){switch(t.spokenReplyLongResponse){case"summary":return sv(e.cleaned);case"invite":{const n=sv(e.cleaned);return Sa(`${n} The full details are in the written reply. We can talk through any part you want.`)}default:return hy(e.cleaned,t.spokenReplyStyle)}}function gL(e,t){switch(t.spokenReplyCodeResponse){case"read":return hy(e.cleaned,t.spokenReplyStyle);case"mention":return"I included code in the written reply. I can walk through the implementation if you want.";default:{const n=e.proseOnly||e.cleaned,s=n?sv(n):"";return s?Sa(`${s} I also included code in the written reply. I can walk through the implementation if you want.`):"I included code in the written reply. I can walk through the implementation or focus on one piece if you want."}}}function vL(e){const t=(e.parts??[]).filter(n=>n.type==="text").map(n=>"text"in n?n.text??"":"").join("");return Sa(yC(t))}function yL(e,t){const n=fL(t),s=pL(e);return s.cleaned?s.codeHeavy&&n.spokenReplyCodeResponse!=="read"?gL(s,n):s.cleaned.length>n.spokenReplyMaxChars&&n.spokenReplyLongResponse!=="verbatim"?mL(s,n):hy(s.cleaned,n.spokenReplyStyle):""}function py(e={}){const{url:t="ws://localhost:3600",systemPrompt:n,cwd:s,workspaceFiles:a,autoConnect:l=!1,sessionKey:u,orphanTTL:d,backend:p,tmuxSession:h,agent:m,provider:y,model:x}=e,w=u?`hudson.relay.${u}`:null,j=()=>{if(!w)return null;try{return localStorage.getItem(w)}catch{return null}},N=ie=>{if(w)try{ie?localStorage.setItem(w,ie):localStorage.removeItem(w)}catch{}},[k,E]=g.useState("disconnected"),[C,S]=g.useState(null),[R,A]=g.useState(null),[M,_]=g.useState(null),[z,V]=g.useState(s||"~"),U=g.useRef(null),O=g.useRef(null),D=g.useRef({cols:80,rows:24}),H=g.useRef(!1),W=g.useRef(z);W.current=z;const q=g.useRef(j()),$=g.useRef(null),L=g.useCallback(ie=>{const de=U.current;de&&de.readyState===WebSocket.OPEN&&de.send(JSON.stringify(ie))},[]),F=g.useCallback(()=>{O.current&&(clearTimeout(O.current),O.current=null);const ie=U.current;ie&&(ie.close(),U.current=null),H.current=!1,E("disconnected")},[]),X=g.useCallback(()=>{const ie=W.current;return{type:"session:init",cols:D.current.cols,rows:D.current.rows,...n?{systemPrompt:n}:{},...ie?{cwd:ie}:{},...a?{workspaceFiles:a}:{},...d?{orphanTTL:d}:{},...p?{backend:p}:{},...h?{tmuxSession:h}:{},...m?{agent:m}:{},...y?{provider:y}:{},...x?{model:x}:{}}},[n,a,d,p,h,m,y,x]),G=g.useCallback(()=>{H.current||(H.current=!0,q.current?L({type:"session:reconnect",sessionId:q.current,cols:D.current.cols,rows:D.current.rows}):L(X()))},[L,X]),I=g.useCallback(async()=>{U.current&&(U.current.close(),U.current=null),H.current=!1,E("connecting"),A(null),_(null);const ie=t.replace(/^ws(s?):\/\//,"http$1://");try{await fetch(`${ie}/health`,{signal:AbortSignal.timeout(2e3)})}catch{E("error"),A("Relay service is not running");return}const de=new WebSocket(t);U.current=de,de.onopen=()=>{G()},de.onmessage=ye=>{try{const Te=JSON.parse(ye.data);switch(Te.type){case"session:ready":q.current=Te.sessionId,N(Te.sessionId),S(Te.sessionId),E("connected"),A(null),_(null);break;case"session:expired":{q.current=null,N(null),H.current=!1,$.current&&$.current("\x1B[2J\x1B[H"),L(X()),H.current=!0;break}case"session:error":E("error"),A(Te.error||"Session failed to start");break;case"terminal:data":$.current&&Te.data&&$.current(Te.data);break;case"session:exit":q.current=null,N(null),S(null),_(Te.exitCode??null),Te.exitCode!==0?(E("error"),A(Te.reason||`Process exited with code ${Te.exitCode}`)):E("disconnected");break;case"session:detached":q.current=null,N(null),S(null);break}}catch{}},de.onclose=()=>{U.current=null,H.current=!1,E(ye=>ye==="error"?ye:"disconnected")},de.onerror=()=>{E("error"),A("Could not connect to relay")}},[t,G,L,n,a]),B=g.useCallback(ie=>{L({type:"terminal:input",data:ie})},[L]),Y=g.useCallback(ie=>{L({type:"terminal:input",data:ie+"\r"})},[L]),Q=g.useCallback((ie,de)=>{D.current={cols:ie,rows:de},H.current&&L({type:"terminal:resize",cols:ie,rows:de})},[L]),me=g.useCallback(ie=>{$.current=ie},[]);g.useEffect(()=>(l&&I(),()=>{F()}),[]);const re=g.useCallback(()=>{if(F(),q.current=null,S(null),u)try{sessionStorage.removeItem(`hudson.relay.${u}`)}catch{}A(null),_(null),setTimeout(()=>I(),200)},[F,I,u]);return{status:k,sessionId:C,error:R,exitCode:M,cwd:z,setCwd:V,onData:me,sendInput:B,sendLine:Y,resize:Q,connect:I,disconnect:F,restart:re}}const xC=(...e)=>e.filter((t,n,s)=>!!t&&t.trim()!==""&&s.indexOf(t)===n).join(" ").trim();const bL=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const xL=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,s)=>s?s.toUpperCase():n.toLowerCase());const kj=e=>{const t=xL(e);return t.charAt(0).toUpperCase()+t.slice(1)};var wL={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const jL=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const SL=g.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:s,className:a="",children:l,iconNode:u,...d},p)=>g.createElement("svg",{ref:p,...wL,width:t,height:t,stroke:e,strokeWidth:s?Number(n)*24/Number(t):n,className:xC("lucide",a),...!l&&!jL(d)&&{"aria-hidden":"true"},...d},[...u.map(([h,m])=>g.createElement(h,m)),...Array.isArray(l)?l:[l]]));const Zt=(e,t)=>{const n=g.forwardRef(({className:s,...a},l)=>g.createElement(SL,{ref:l,iconNode:t,className:xC(`lucide-${bL(kj(e))}`,`lucide-${e}`,s),...a}));return n.displayName=kj(e),n};const NL=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],kL=Zt("circle-alert",NL);const EL=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],CL=Zt("clock",EL);const TL=[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]],AL=Zt("corner-down-left",TL);const RL=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ej=Zt("loader-circle",RL);const ML=[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]],_L=Zt("map",ML);const OL=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],wC=Zt("maximize-2",OL);const IL=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]],DL=Zt("mic",IL);const PL=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],zL=Zt("minimize-2",PL);const LL=[["path",{d:"M5 12h14",key:"1ays0h"}]],$L=Zt("minus",LL);const UL=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],BL=Zt("panel-left-close",UL);const VL=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],FL=Zt("panel-left-open",VL);const HL=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],qL=Zt("panel-right-close",HL);const ZL=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],WL=Zt("panel-right-open",ZL);const YL=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],GL=Zt("paperclip",YL);const KL=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],XL=Zt("plus",KL);const JL=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],my=Zt("search",JL);const QL=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],e$=Zt("sparkles",QL);const t$=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],jC=Zt("square",t$);const n$=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],s$=Zt("terminal",n$);const r$=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],a$=Zt("trash-2",r$);const i$=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],o$=Zt("volume-2",i$);const l$=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]],c$=Zt("volume-x",l$);const u$=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],SC=Zt("x",u$);function d$({chat:e,placeholder:t="Ask AI...",inputExtras:n,inputStatus:s,inputValue:a,onInputChange:l}){const{messages:u,sendMessage:d,stop:p,status:h,clearChat:m,error:y,attachments:x,activeAttachments:w,toggleAttachment:j}=e,[N,k]=g.useState(""),E=a!==void 0,C=E?a:N,S=U=>{E?l?.(U):k(U)},R=g.useRef(null),A=g.useRef(null),M=h==="streaming"||h==="submitted",_=x.length>0;g.useEffect(()=>{const U=R.current;U&&(U.scrollTop=U.scrollHeight)},[u]),g.useEffect(()=>{A.current?.focus()},[]);const z=U=>{U.preventDefault();const O=C.trim();!O||M||(S(""),d({text:O}))},V=U=>{U.stopPropagation(),U.key==="Enter"&&!U.shiftKey&&(U.preventDefault(),z(U))};return o.jsxs("div",{className:"flex flex-col h-full font-mono text-[12px]",children:[o.jsxs("div",{ref:R,className:"flex-1 overflow-y-auto frame-scrollbar p-3 space-y-3",children:[u.length===0&&o.jsx("div",{className:"text-neutral-500 text-center py-8 select-none",children:t}),u.map(U=>o.jsx("div",{className:`flex ${U.role==="user"?"justify-end":"justify-start"}`,children:o.jsx("div",{className:`max-w-[85%] rounded-lg px-3 py-2 whitespace-pre-wrap break-words leading-relaxed ${U.role==="user"?"bg-emerald-500/10 text-emerald-100 border border-emerald-500/20":"bg-neutral-800/50 text-neutral-200 border border-neutral-700/50"}`,children:(U.parts??[]).map((O,D)=>{if(!O)return null;if(O.type==="text")return o.jsx("span",{children:O.text},D);if(wi(O)){const H=mC(O),W=Object.entries(O.input??{}).map(([q,$])=>`${q}: ${JSON.stringify($)}`).join(", ");return o.jsxs("div",{className:"text-[11px] text-cyan-400/70 mt-1 font-mono",children:[o.jsx("span",{className:"text-neutral-500",children:"↳ "}),H,"(",W,")"]},D)}return null})})},U.id)),M&&u[u.length-1]?.role!=="assistant"&&o.jsx("div",{className:"flex justify-start",children:o.jsx("div",{className:"bg-neutral-800/50 border border-neutral-700/50 rounded-lg px-3 py-2 text-neutral-400",children:o.jsx("span",{className:"animate-pulse",children:"..."})})})]}),y&&o.jsxs("div",{className:"px-3 py-2 bg-red-900/20 border-t border-red-500/30 text-red-400 text-[11px] flex items-center gap-2",children:[o.jsx(kL,{size:12}),o.jsx("span",{className:"truncate",children:y.message||"An error occurred"})]}),o.jsxs("div",{className:"px-3 py-2.5 border-t border-neutral-700/50 bg-neutral-900/50",children:[_&&o.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[o.jsx(GL,{size:11,className:"text-neutral-500 shrink-0"}),x.map(U=>{const O=w.has(U.label);return o.jsx("button",{type:"button",onClick:()=>j(U.label),className:`text-[10px] px-2 py-0.5 rounded-full border transition-colors ${O?"bg-cyan-500/15 text-cyan-300 border-cyan-500/40":"text-neutral-500 border-neutral-700 hover:text-neutral-300 hover:border-neutral-600"}`,children:U.label},U.label)}),w.size>0&&o.jsx("span",{className:"text-[10px] text-neutral-600 ml-1",children:"attached"})]}),o.jsxs("form",{onSubmit:z,className:"flex items-center gap-2 rounded-lg border border-neutral-700 bg-neutral-800/60 px-3 py-2 focus-within:border-emerald-500/40 transition-colors",children:[u.length>0&&o.jsx("button",{type:"button",onClick:()=>m(),className:"p-1 rounded text-neutral-500 hover:text-neutral-300 hover:bg-neutral-700 transition-colors",title:"Clear",children:o.jsx(a$,{size:12})}),o.jsx("input",{ref:A,type:"text",value:C,onChange:U=>S(U.target.value),onKeyDown:V,placeholder:t,className:"flex-1 bg-transparent outline-none text-neutral-100 placeholder:text-neutral-500 caret-emerald-400",disabled:M}),M?o.jsx("button",{type:"button",onClick:()=>p(),className:"p-1.5 rounded text-amber-400 hover:bg-amber-900/20 transition-colors",title:"Stop",children:o.jsx(jC,{size:12})}):o.jsx("button",{type:"submit",disabled:!C.trim(),className:"text-[11px] px-2 py-1 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/30 hover:bg-emerald-500/20 disabled:opacity-30 disabled:cursor-default transition-colors",children:"Send"})]})]})]})}const f$={background:"#1a1a1a",foreground:"#abb2bf",cursor:"#528bff",cursorAccent:"#1a1a1a",selectionBackground:"#3e4451",selectionForeground:"#abb2bf",black:"#1a1a1a",red:"#e06c75",green:"#98c379",yellow:"#e5c07b",blue:"#61afef",magenta:"#c678dd",cyan:"#56b6c2",white:"#abb2bf",brightBlack:"#5c6370",brightRed:"#e06c75",brightGreen:"#98c379",brightYellow:"#e5c07b",brightBlue:"#61afef",brightMagenta:"#c678dd",brightCyan:"#56b6c2",brightWhite:"#ffffff"},h$=`
|
|
67
|
-
.xterm { cursor: text; position: relative; user-select: none; -ms-user-select: none; -webkit-user-select: none; }
|
|
68
|
-
.xterm.focus, .xterm:focus { outline: none; }
|
|
69
|
-
.xterm .xterm-helpers { position: absolute; top: 0; z-index: 5; }
|
|
70
|
-
.xterm .xterm-helper-textarea { padding: 0; border: 0; margin: 0; position: absolute; opacity: 0; left: -9999em; top: 0; width: 0; height: 0; z-index: -5; white-space: nowrap; overflow: hidden; resize: none; }
|
|
71
|
-
.xterm .composition-view { background: #000; color: #FFF; display: none; position: absolute; white-space: nowrap; z-index: 1; }
|
|
72
|
-
.xterm .composition-view.active { display: block; }
|
|
73
|
-
.xterm .xterm-viewport { background-color: #000; overflow-y: scroll; cursor: default; position: absolute; right: 0; left: 0; top: 0; bottom: 0; }
|
|
74
|
-
.xterm .xterm-screen { position: relative; }
|
|
75
|
-
.xterm .xterm-screen canvas { position: absolute; left: 0; top: 0; }
|
|
76
|
-
.xterm-char-measure-element { display: inline-block; visibility: hidden; position: absolute; top: 0; left: -9999em; line-height: normal; }
|
|
77
|
-
.xterm.enable-mouse-events { cursor: default; }
|
|
78
|
-
.xterm.xterm-cursor-pointer, .xterm .xterm-cursor-pointer { cursor: pointer; }
|
|
79
|
-
.xterm.column-select.focus { cursor: crosshair; }
|
|
80
|
-
.xterm .xterm-accessibility:not(.debug), .xterm .xterm-message { position: absolute; left: 0; top: 0; bottom: 0; right: 0; z-index: 10; color: transparent; pointer-events: none; }
|
|
81
|
-
.xterm .xterm-accessibility-tree:not(.debug) *::selection { color: transparent; }
|
|
82
|
-
.xterm .xterm-accessibility-tree { font-family: monospace; user-select: text; white-space: pre; }
|
|
83
|
-
.xterm .xterm-accessibility-tree > div { transform-origin: left; width: fit-content; }
|
|
84
|
-
.xterm .live-region { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
|
|
85
|
-
.xterm-dim { opacity: 1 !important; }
|
|
86
|
-
.xterm-underline-1 { text-decoration: underline; }
|
|
87
|
-
.xterm-underline-2 { text-decoration: double underline; }
|
|
88
|
-
.xterm-underline-3 { text-decoration: wavy underline; }
|
|
89
|
-
.xterm-underline-4 { text-decoration: dotted underline; }
|
|
90
|
-
.xterm-underline-5 { text-decoration: dashed underline; }
|
|
91
|
-
.xterm-overline { text-decoration: overline; }
|
|
92
|
-
.xterm-overline.xterm-underline-1 { text-decoration: overline underline; }
|
|
93
|
-
.xterm-overline.xterm-underline-2 { text-decoration: overline double underline; }
|
|
94
|
-
.xterm-overline.xterm-underline-3 { text-decoration: overline wavy underline; }
|
|
95
|
-
.xterm-overline.xterm-underline-4 { text-decoration: overline dotted underline; }
|
|
96
|
-
.xterm-overline.xterm-underline-5 { text-decoration: overline dashed underline; }
|
|
97
|
-
.xterm-strikethrough { text-decoration: line-through; }
|
|
98
|
-
.xterm-screen .xterm-decoration-container .xterm-decoration { z-index: 6; position: absolute; }
|
|
99
|
-
.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer { z-index: 7; }
|
|
100
|
-
.xterm-decoration-overview-ruler { z-index: 8; position: absolute; top: 0; right: 0; pointer-events: none; }
|
|
101
|
-
.xterm-decoration-top { z-index: 2; position: relative; }
|
|
102
|
-
.xterm .xterm-scrollable-element > .scrollbar { cursor: default; }
|
|
103
|
-
.xterm .xterm-scrollable-element > .scrollbar > .scra { cursor: pointer; font-size: 11px !important; }
|
|
104
|
-
.xterm .xterm-scrollable-element > .visible { opacity: 1; background: rgba(0,0,0,0); transition: opacity 100ms linear; z-index: 11; }
|
|
105
|
-
.xterm .xterm-scrollable-element > .invisible { opacity: 0; pointer-events: none; }
|
|
106
|
-
.xterm .xterm-scrollable-element > .invisible.fade { transition: opacity 800ms linear; }
|
|
107
|
-
.xterm .xterm-scrollable-element > .shadow { position: absolute; display: none; }
|
|
108
|
-
.xterm .xterm-scrollable-element > .shadow.top { display: block; top: 0; left: 3px; height: 3px; width: 100%; }
|
|
109
|
-
.xterm .xterm-scrollable-element > .shadow.left { display: block; top: 3px; left: 0; height: 100%; width: 3px; }
|
|
110
|
-
`;function p$(){if(typeof document>"u"||document.querySelector("[data-xterm-css]"))return;const e=document.createElement("style");e.setAttribute("data-xterm-css",""),e.textContent=h$,document.head.appendChild(e)}function m$(e){return new Promise((t,n)=>{const s=new FileReader;s.onload=()=>{const a=s.result;t(a.split(",")[1])},s.onerror=n,s.readAsDataURL(e)})}function gy({relay:e,fontSize:t=12,fontFamily:n="'JetBrains Mono', 'Hack Nerd Font', monospace",configItems:s,onOpenSettings:a,onStartService:l}){const{status:u,error:d,exitCode:p,cwd:h,setCwd:m,sendInput:y,resize:x,onData:w,connect:j,disconnect:N}=e,[k,E]=g.useState(!1),{apiBaseUrl:C}=Yc(),S=g.useRef(null),R=g.useRef(null),A=g.useRef(null),M=g.useRef(null),[_,z]=g.useState(!1),[V,U]=g.useState(!1),O=g.useRef(0);g.useEffect(()=>{const B=S.current;if(!B)return;const Y=Q=>{Q.key===" "&&!Q.metaKey&&!Q.ctrlKey&&!Q.altKey&&Q.stopPropagation()};return B.addEventListener("keydown",Y),()=>B.removeEventListener("keydown",Y)},[]);const D=`${C}/api/relay/upload`,H=g.useCallback(async B=>{try{const Y=await m$(B),Q=await fetch(D,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:B.name,data:Y})}),{path:me}=await Q.json();return me||null}catch(Y){return console.error("File upload failed:",Y),null}},[D]);g.useEffect(()=>{const B=S.current;if(!B)return;const Y=async Q=>{if(!Q.clipboardData)return;const me=Array.from(Q.clipboardData.items).filter(re=>re.type.startsWith("image/"));if(me.length!==0){Q.preventDefault(),Q.stopPropagation();for(const re of me){const ie=re.getAsFile();if(!ie)continue;const de=await H(ie);de&&y(de)}}};return B.addEventListener("paste",Y),()=>B.removeEventListener("paste",Y)},[y,H]);const W=g.useCallback(B=>{B.preventDefault(),B.dataTransfer.dropEffect="copy"},[]),q=g.useCallback(B=>{B.preventDefault(),O.current++,B.dataTransfer.types.includes("Files")&&U(!0)},[]),$=g.useCallback(B=>{B.preventDefault(),O.current--,O.current===0&&U(!1)},[]),L=g.useCallback(async B=>{B.preventDefault(),O.current=0,U(!1);const Y=Array.from(B.dataTransfer.files).filter(Q=>Q.type.startsWith("image/"));if(Y.length!==0)for(const Q of Y){const me=await H(Q);me&&y(me)}},[y,H]);g.useEffect(()=>{let B=!1,Y=null;async function Q(){const[{Terminal:me},{FitAddon:re},ie]=await Promise.all([vc(()=>import("./xterm-B-qIQCd3.js"),[]),vc(()=>import("./addon-fit-DX4qG4td.js"),[]),vc(()=>import("./addon-webgl-DCtw1yLn.js"),[]).catch(()=>null)]);if(p$(),B||!R.current)return;Y=new me({fontSize:t,fontFamily:n,theme:f$,cursorBlink:!0,cursorStyle:"bar",allowTransparency:!0,scrollback:5e3,convertEol:!1,allowProposedApi:!0});const de=new re;if(Y.loadAddon(de),Y.open(R.current),ie)try{const ye=new ie.WebglAddon;ye.onContextLoss(()=>{ye.dispose()}),Y.loadAddon(ye)}catch{}try{de.fit()}catch{}A.current=Y,M.current=de,x(Y.cols,Y.rows),Y.onData(ye=>{y(ye)}),z(!0)}return Q(),()=>{B=!0,Y&&(Y.dispose(),A.current=null,M.current=null)}},[]),g.useEffect(()=>{const B=A.current;if(B){B.options.fontSize=t,B.options.fontFamily=n;try{M.current?.fit()}catch{}}},[t,n]),g.useEffect(()=>{if(_)return w(B=>{A.current?.write(B)}),()=>{w(()=>{})}},[_,w]),g.useEffect(()=>{const B=R.current;if(!B||!_)return;const Y=new ResizeObserver(()=>{const Q=M.current,me=A.current;if(!(!Q||!me))try{Q.fit(),x(me.cols,me.rows)}catch{}});return Y.observe(B),()=>Y.disconnect()},[_,x]),g.useEffect(()=>{u==="connected"&&A.current&&A.current.focus()},[u]);const F=g.useCallback(()=>{u==="connected"&&A.current&&A.current.focus()},[u]),X=u==="error"&&d==="Relay service is not running",G=g.useCallback(async()=>{if(l){E(!0);try{await l()&&setTimeout(()=>j(),500)}finally{E(!1)}}},[l,j]);let I=null;return X?I=o.jsxs("div",{className:"flex flex-col items-center gap-4 max-w-xs text-center px-4",children:[o.jsx("div",{className:"w-8 h-8 rounded-full bg-amber-500/10 border border-amber-500/20 flex items-center justify-center",children:o.jsx("span",{className:"text-amber-400 text-[14px]",children:"!"})}),o.jsxs("div",{children:[o.jsx("div",{className:"text-[12px] text-neutral-300 font-medium mb-1",children:"Relay service not running"}),o.jsx("div",{className:"text-[11px] text-neutral-500 leading-relaxed",children:l?"Start the relay service to open a terminal session.":"Start the relay service from the Workspace Manager."})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[l&&o.jsx("button",{type:"button",onClick:G,disabled:k,className:"text-[11px] px-4 py-1.5 rounded-full border border-emerald-500/30 text-emerald-400 hover:bg-emerald-500/10 transition-colors font-medium disabled:opacity-50",children:k?"Starting...":"Start Service"}),o.jsx("button",{type:"button",onClick:()=>j(),className:"text-[11px] px-3 py-1.5 rounded-full border border-neutral-700 text-neutral-400 hover:text-neutral-300 hover:bg-white/5 transition-colors",children:"Retry"}),a&&o.jsx("button",{type:"button",onClick:a,className:"text-[11px] px-3 py-1.5 rounded-full border border-neutral-700 text-neutral-400 hover:text-neutral-300 hover:bg-white/5 transition-colors",children:"Settings"})]})]}):u==="error"&&d?I=o.jsxs("div",{className:"flex flex-col items-center gap-3 max-w-md text-center px-4",children:[o.jsx("div",{className:"w-8 h-8 rounded-full bg-red-500/10 flex items-center justify-center",children:o.jsx("span",{className:"text-red-400 text-sm",children:"!"})}),o.jsx("span",{className:"text-red-400 text-[12px] font-medium",children:"Session failed"}),o.jsx("code",{className:"text-[11px] text-neutral-400 bg-neutral-800/80 px-3 py-2 rounded-md whitespace-pre-wrap leading-relaxed max-h-32 overflow-y-auto w-full text-left",children:d}),p!==null&&p!==0&&o.jsxs("span",{className:"text-[10px] text-neutral-600",children:["Exit code ",p]}),o.jsx("button",{type:"button",onClick:()=>j(),className:"text-[11px] px-3 py-1 rounded-full border border-cyan-500/30 text-cyan-400 hover:bg-cyan-500/10 transition-colors",children:"Retry"})]}):u==="disconnected"?I=o.jsxs("div",{className:"flex flex-col items-center gap-4 max-w-xs text-center px-4",children:[o.jsx("div",{className:"w-8 h-8 rounded-full bg-neutral-800 border border-neutral-700 flex items-center justify-center",children:o.jsx("span",{className:"text-neutral-500 text-[14px]",children:"▷"})}),o.jsxs("div",{children:[o.jsx("div",{className:"text-[12px] text-neutral-300 font-medium mb-1",children:"Terminal relay disconnected"}),o.jsx("div",{className:"text-[11px] text-neutral-500 leading-relaxed",children:"Set working directory and connect."})]}),o.jsxs("form",{className:"w-full",onSubmit:B=>{B.preventDefault(),j()},children:[o.jsx("label",{className:"text-[10px] font-mono text-neutral-500 uppercase tracking-wider mb-1 block text-left",children:"Working Directory"}),o.jsx("input",{type:"text",value:h,onChange:B=>m(B.target.value),placeholder:"~/dev/my-project",className:"w-full bg-neutral-800/80 border border-neutral-700/50 rounded px-3 py-1.5 text-[11px] font-mono text-neutral-200 placeholder:text-neutral-600 outline-none focus:border-cyan-500/40 transition-colors",spellCheck:!1,autoComplete:"off"})]}),s&&s.length>0&&o.jsx("div",{className:"w-full grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-[10px] font-mono bg-neutral-800/60 border border-neutral-700/40 rounded-md px-3 py-2",children:s.map(B=>o.jsxs("div",{className:"contents",children:[o.jsx("span",{className:"text-neutral-500",children:B.label}),o.jsx("span",{className:"text-neutral-400 truncate text-left",children:B.value})]},B.label))}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{type:"button",onClick:()=>j(),className:"text-[11px] px-4 py-1.5 rounded-full border border-cyan-500/30 text-cyan-400 hover:bg-cyan-500/10 transition-colors font-medium",children:"Connect"}),a&&o.jsx("button",{type:"button",onClick:a,className:"text-[11px] px-3 py-1.5 rounded-full border border-neutral-700 text-neutral-400 hover:text-neutral-300 hover:bg-white/5 transition-colors",children:"Settings"})]})]}):u==="connecting"&&(I=o.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[o.jsx("div",{className:"w-6 h-6 border-2 border-neutral-600 border-t-cyan-400 rounded-full animate-spin"}),o.jsx("span",{className:"text-[12px] text-neutral-400",children:"Connecting to relay..."}),o.jsx("button",{type:"button",onClick:()=>{N()},className:"text-[10px] px-3 py-1 rounded-full border border-neutral-700 text-neutral-500 hover:text-neutral-300 hover:bg-white/5 transition-colors",children:"Cancel"})]})),o.jsxs("div",{ref:S,className:"relative flex flex-col h-full overflow-hidden",onClick:F,onDragOver:W,onDragEnter:q,onDragLeave:$,onDrop:L,children:[I&&o.jsx("div",{className:"flex items-center justify-center h-full font-mono text-[12px] absolute inset-0 z-10 bg-neutral-900/90",children:I}),V&&o.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center bg-cyan-500/10 border-2 border-dashed border-cyan-500/50 rounded pointer-events-none",children:o.jsx("span",{className:"text-cyan-400 font-mono text-sm",children:"Drop image to get path"})}),o.jsx("div",{ref:R,className:"flex-1 min-h-0 min-w-0 overflow-hidden",style:{visibility:I?"hidden":"visible",padding:"4px 8px"}})]})}function g$({app:e,commands:t,state:n,relayUrl:s="ws://localhost:3600",cwd:a,agent:l="pi",provider:u,model:d,backend:p="pty",tmuxSession:h,workspaceFiles:m,onOpenSettings:y,onStartService:x,voice:w,voiceEnabled:j=!0}){const[N,k]=Ir(`assistant.${e.id}.mode`,"relay"),[E,C]=g.useState(""),S=g.useMemo(()=>({...sL,...w}),[w]),[R,A]=Ir(`assistant.${e.id}.voice.speakReplies`,S.speakReplies),{serviceApiUrl:M}=Yc(),_=g.useMemo(()=>y$(e),[e]),z=py({url:s,systemPrompt:_,cwd:a,workspaceFiles:m,sessionKey:`assistant-${e.id}`,backend:p,tmuxSession:h,agent:l,provider:l==="pi"?u:void 0,model:l==="pi"?d:void 0}),V=g.useCallback(async()=>{if(x)return x();try{return(await(await fetch(`${M}/api/services/execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serviceId:"relay",action:"start",triggeredBy:"assistant"})})).json()).success===!0}catch{return!1}},[x,M]),U=g.useMemo(()=>{const I=[{label:"Relay",value:s},{label:"Agent",value:l}];return a&&I.push({label:"CWD",value:a}),l==="pi"&&d&&I.push({label:"Model",value:d}),I},[s,l,a,d]),O=tL(),[D,H]=g.useState("text"),W=F3({app:e,commands:t,state:n,provider:u,model:d,onFinish:({message:I,isAbort:B,isDisconnect:Y,isError:Q})=>{if(!j||!R||B||Y||Q||I.role!=="assistant")return;const me=vL(I),re=yL(me,S);re&&O.speak(re,{provider:S.replyProvider,model:S.replyModel,voice:S.replyVoice||void 0,rate:S.replyRate,metadata:{surface:"hudson-assistant",appId:e.id,source:D}})}}),q=X3({surface:"hudson-assistant",metadata:{appId:e.id},onTranscript:I=>{const B=[E.trim(),I].filter(Boolean).join(" ");S.autoSend&&W.status!=="streaming"&&W.status!=="submitted"?(C(""),H("voice"),W.sendMessage({text:B})):C(B)}}),$=g.useCallback(()=>{q.status==="recording"?q.stop():q.start()},[q]),L=e.intents?.length??0,F=j,X=q.status==="transcribing",G=q.status==="recording";return o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 border-b border-neutral-700/50 bg-neutral-900/50",children:[o.jsx(e$,{size:11,className:"text-cyan-400/60"}),o.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wider text-neutral-500",children:"Assistant"}),o.jsxs("span",{className:"text-[10px] font-mono text-neutral-600",children:["· ",e.name]}),o.jsx("div",{className:"flex-1"}),F&&N==="chat"&&o.jsx("button",{type:"button",onClick:()=>{R&&O.stop(),A(!R)},className:`p-1 rounded transition-colors ${R?"text-cyan-300 hover:text-cyan-200":"text-neutral-500 hover:text-neutral-300"}`,title:R?"Speaker on (click to mute)":"Speaker off (click to enable)",children:O.isPlaying?o.jsx(Ej,{size:12,className:"animate-spin"}):R?o.jsx(o$,{size:12}):o.jsx(c$,{size:12})}),o.jsxs("div",{className:"flex items-center gap-1 rounded-full border border-neutral-700 p-0.5",children:[o.jsx(Tj,{active:N==="relay",onClick:()=>k("relay"),children:"Relay"}),o.jsx(Tj,{active:N==="chat",onClick:()=>k("chat"),children:"Chat"})]}),N==="relay"&&z.status==="connected"&&o.jsx("button",{type:"button",onClick:()=>z.restart(),className:"text-[10px] px-2 py-0.5 rounded-full border text-cyan-400 border-cyan-500/30 hover:bg-cyan-500/10 transition-colors",title:"Kill session and start fresh",children:"Restart"}),N==="relay"&&z.status==="connected"&&o.jsx("button",{type:"button",onClick:()=>z.disconnect(),className:"text-[10px] px-2 py-0.5 rounded-full border text-red-400 border-red-500/30 hover:bg-red-500/10 transition-colors",children:"Disconnect"}),N==="relay"&&z.status!=="connected"&&z.status!=="connecting"&&o.jsx("button",{type:"button",onClick:()=>z.connect(),className:"text-[10px] px-2 py-0.5 rounded-full border text-emerald-400 border-emerald-500/30 hover:bg-emerald-500/10 transition-colors",children:"Connect"})]}),o.jsx("div",{className:"flex-1 min-h-0",children:N==="relay"?o.jsx(gy,{relay:z,configItems:U,onOpenSettings:y,onStartService:V}):o.jsx(d$,{chat:W,placeholder:L===0?`Ask about ${e.name} — no intents declared, conversation only.`:`Ask ${e.name} to do something… (${L} intent${L===1?"":"s"})`,inputValue:E,onInputChange:I=>{D==="voice"&&I.length===0&&H("text"),C(I)},inputExtras:F&&q.isSupported?o.jsx("button",{type:"button",onClick:$,disabled:X,className:`p-1 rounded transition-colors disabled:opacity-30 ${G?"bg-red-500/15 text-red-300 hover:bg-red-500/20":"text-neutral-500 hover:text-cyan-400"}`,title:G?"Stop recording":"Record voice prompt",children:X?o.jsx(Ej,{size:12,className:"animate-spin"}):G?o.jsx(jC,{size:11}):o.jsx(DL,{size:12})}):void 0,inputStatus:F?o.jsx(v$,{inputStatus:q.status,inputError:q.error,outputStatus:O.status,outputError:O.error}):void 0})})]})}function v$({inputStatus:e,inputError:t,outputStatus:n,outputError:s}){const a=Cj(e)??Cj(n),l=t??s;return!a&&!l?null:o.jsxs("div",{className:"flex items-center gap-2",children:[a&&o.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full border font-mono ${a.className}`,children:a.label}),l&&o.jsx("span",{className:"text-[10px] text-neutral-500 truncate flex-1",title:l,children:l})]})}function Cj(e){switch(e){case"recording":return{label:"listening",className:"border-red-500/20 bg-red-500/10 text-red-300"};case"transcribing":return{label:"transcribing",className:"border-amber-500/20 bg-amber-500/10 text-amber-300"};case"ready":return{label:"draft ready",className:"border-cyan-500/20 bg-cyan-500/10 text-cyan-300"};case"synthesizing":return{label:"voicing",className:"border-cyan-500/20 bg-cyan-500/10 text-cyan-300"};case"speaking":return{label:"speaking",className:"border-emerald-500/20 bg-emerald-500/10 text-emerald-300"};case"unavailable":return{label:"voice offline",className:"border-amber-500/20 bg-amber-500/10 text-amber-300"};case"error":return{label:"voice error",className:"border-red-500/20 bg-red-500/10 text-red-300"};default:return null}}function Tj({active:e,onClick:t,children:n}){return o.jsx("button",{type:"button",onClick:t,className:`text-[10px] px-2 py-0.5 rounded-full transition-colors ${e?"bg-cyan-500/15 text-cyan-300":"text-neutral-500 hover:text-neutral-300"}`,children:n})}function y$(e){const t=[`You are working alongside the user inside the **${e.name}** Hudson app.`];e.description&&t.push(e.description);const n=e.intents??[];if(n.length>0){t.push("","## What this app can do (for context)");for(const s of n)t.push(`- ${s.title} — ${s.description}`);t.push("","These actions live inside the running app. You can describe them to the user, but you do not invoke them yourself — the user can trigger any of them via the command palette (Cmd+K).")}return t.push("","## How to behave","- Be terse. The user is in a terminal; respect their attention.","- Use your own tools (file ops, shell, etc.) freely if it helps.","- When asked to change something inside the app itself, prefer guiding the user to the matching command rather than hacking around it."),t.join(`
|
|
111
|
-
`)}typeof window<"u"&&localStorage.getItem("frame_sounds");function vy(){const{titleBarInset:e}=Yc();return g.useMemo(()=>{const t=sh.layout.navHeight+e;return{navTotalHeight:t,panelTopOffset:t}},[e])}const b$=({panOffset:e,scale:t,onPan:n,onPanStart:s,onPanEnd:a,isPanLocked:l=!1,onClick:u,showGuides:d=!1,onGuidesChange:p,gridOpacity:h=1})=>{const[m,y]=g.useState(d),[x,w]=g.useState(!1),j=g.useRef(!1),N=g.useRef({x:0,y:0}),k=g.useRef({active:!1,startX:0,startY:0}),E=g.useRef(null),C=g.useRef(null),S=g.useRef(null),R=4,A=g.useRef({x:0,y:0}),M=g.useRef(0),_=g.useRef(!1);g.useEffect(()=>{y(d)},[d]);const z=g.useCallback(Y=>{const Q=Y;return Q?Q.tagName==="INPUT"||Q.tagName==="TEXTAREA"||Q.isContentEditable:!1},[]),V=g.useCallback(Y=>{const Q=Y;return Q?!!Q.closest('button, [role="button"], a, input, textarea, select, [data-interactive="true"]'):!1},[]),U=g.useCallback(Y=>{j.current=Y,w(Y)},[]);g.useEffect(()=>{const Y=ie=>{if(M.current=ie.buttons,k.current.active&&(ie.buttons&1)!==1&&(k.current.active=!1),j.current&&(ie.buttons&1)!==1){U(!1),k.current.active=!1,a?.(),document.body.style.cursor="";return}if(l&&j.current){U(!1),k.current.active=!1,a?.(),document.body.style.cursor="";return}const de=E.current?.getBoundingClientRect(),ye=de?ie.clientX-de.left:ie.clientX,Te=de?ie.clientY-de.top:ie.clientY;if(A.current={x:ye,y:Te},C.current&&(C.current.style.left=`${ye}px`),S.current&&(S.current.style.top=`${Te}px`),k.current.active&&!j.current){const he=ie.clientX-k.current.startX,ue=ie.clientY-k.current.startY;Math.hypot(he,ue)>=R&&(k.current.active=!1,U(!0),_.current=!0,s?.(),N.current={x:ie.clientX,y:ie.clientY},document.body.style.cursor="grabbing")}j.current&&(n({x:(ie.clientX-N.current.x)/t,y:(ie.clientY-N.current.y)/t}),N.current={x:ie.clientX,y:ie.clientY})},Q=ie=>{M.current=ie.buttons,k.current.active=!1,j.current&&(U(!1),a?.(),document.body.style.cursor="")},me=ie=>{(ie.metaKey||ie.ctrlKey)&&ie.key==="\\"&&(ie.preventDefault(),y(de=>{const ye=!de;return p?.(ye),ye}))},re=()=>{k.current.active=!1,Q(new MouseEvent("mouseup"))};return window.addEventListener("mousemove",Y),window.addEventListener("mouseup",Q),window.addEventListener("keydown",me),window.addEventListener("blur",re),document.addEventListener("visibilitychange",re),()=>{window.removeEventListener("mousemove",Y),window.removeEventListener("mouseup",Q),window.removeEventListener("keydown",me),window.removeEventListener("blur",re),document.removeEventListener("visibilitychange",re)}},[n,a,s,t,z,V,l,U,p]),g.useEffect(()=>{!l||!j.current||(U(!1),a?.(),document.body.style.cursor="")},[l,a,U]);const O=Y=>{_.current=!1,!(l||Y.button!==0)&&(z(Y.target)||V(Y.target)||(M.current=Y.buttons,k.current={active:!0,startX:Y.clientX,startY:Y.clientY},Y.preventDefault()))},D=Y=>{!_.current&&u&&u(Y),_.current=!1},[H,W]=g.useState({w:0,h:0});g.useEffect(()=>{const Y=()=>W({w:window.innerWidth,h:window.innerHeight});return Y(),window.addEventListener("resize",Y),()=>window.removeEventListener("resize",Y)},[]);const q=Math.max(.4,Math.min(2,t)),$=100*q,L=20*q,F="var(--hud-canvas-dot-minor)",X="var(--hud-canvas-dot-major)",G="color-mix(in srgb, oklch(var(--accent)) 18%, transparent)",I=(H.w/2+e.x*t)%$,B=(H.h/2+e.y*t)%$;return o.jsxs("div",{ref:E,className:`absolute inset-0 z-0 overflow-hidden bg-background ${x?"cursor-grabbing":"cursor-grab"}`,onMouseDown:O,onClick:D,children:[o.jsx("div",{className:"absolute pointer-events-none",style:{inset:"-100px",opacity:.8*h,transition:"opacity 1s ease",backgroundImage:`radial-gradient(circle, ${F} 1px, transparent 1px)`,backgroundSize:`${L}px ${L}px`,backgroundPosition:`${I+100}px ${B+100}px`}}),o.jsx("div",{className:"absolute pointer-events-none",style:{inset:"-100px",opacity:.45*h,transition:"opacity 1s ease",backgroundImage:`radial-gradient(circle, ${X} 1.5px, transparent 1.5px)`,backgroundSize:`${$}px ${$}px`,backgroundPosition:`${I+100}px ${B+100}px`}}),m&&o.jsxs(o.Fragment,{children:[o.jsx("div",{ref:C,className:"absolute top-0 bottom-0 w-px pointer-events-none",style:{left:0,backgroundColor:G}}),o.jsx("div",{ref:S,className:"absolute left-0 right-0 h-px pointer-events-none",style:{top:0,backgroundColor:G}})]})]})},x$=({scale:e,onZoom:t,min:n=.2,max:s=3,step:a=.1})=>{const[l,u]=g.useState(!1),[d,p]=g.useState(""),h=g.useRef(null),m=g.useCallback(k=>Math.min(s,Math.max(n,k)),[n,s]),y=g.useCallback(()=>{t(m(e+a))},[e,a,t,m]),x=g.useCallback(()=>{t(m(e-a))},[e,a,t,m]),w=g.useCallback(()=>{p(Math.round(e*100).toString()),u(!0)},[e]),j=g.useCallback(()=>{u(!1);const k=parseInt(d,10);!isNaN(k)&&k>0&&t(m(k/100))},[d,t,m]),N=g.useCallback(k=>{k.key==="Enter"?j():k.key==="Escape"&&u(!1)},[j]);return g.useEffect(()=>{l&&h.current&&(h.current.focus(),h.current.select())},[l]),o.jsxs("div",{className:"pointer-events-auto flex flex-col items-center bg-card/95 backdrop-blur-xl border border-border/80 rounded-md shadow-[0_0_20px_rgba(0,0,0,0.6)] overflow-hidden",children:[o.jsx("button",{onClick:y,className:"w-9 h-8 flex items-center justify-center hover:bg-accent/10 text-muted-foreground hover:text-foreground transition-colors",title:"Zoom in",children:o.jsx(XL,{size:14})}),o.jsx("div",{className:"w-full border-t border-b border-border/60",children:l?o.jsx("input",{ref:h,type:"text",value:d,onChange:k=>p(k.target.value.replace(/[^0-9]/g,"")),onBlur:j,onKeyDown:N,className:"w-9 py-1.5 text-center text-[11px] font-mono text-foreground bg-background/60 outline-none tabular-nums"}):o.jsxs("button",{onClick:w,className:"w-9 py-1.5 text-center text-[11px] font-mono text-foreground hover:bg-accent/10 transition-colors cursor-text tabular-nums",title:"Click to set zoom",children:[Math.round(e*100),"%"]})}),o.jsx("button",{onClick:x,className:"w-9 h-8 flex items-center justify-center hover:bg-accent/10 text-muted-foreground hover:text-foreground transition-colors",title:"Zoom out",children:o.jsx($L,{size:14})})]})},w$={...Dk};let Aj=0;function j$(e,t="mui"){const[n,s]=g.useState(e),a=e||n;return g.useEffect(()=>{n==null&&(Aj+=1,s(`${t}-${Aj}`))},[n,t]),a}const Rj=w$.useId;function Oa(e,t){if(Rj!==void 0){const n=Rj();return e??(t?`${t}-${n}`:n)}return j$(e,t)}function Ci(e,...t){const n=new URL(`https://base-ui.com/production-error/${e}`);return t.forEach(s=>n.searchParams.append("args[]",s)),`Base UI error #${e}; visit ${n} for the full message.`}const NC=g.createContext(void 0);function rh(e=!0){const t=g.useContext(NC);if(t===void 0&&!e)throw new Error(Ci(25));return t}const kC=g.createContext(void 0);function EC(e){const t=g.useContext(kC);if(t===void 0&&!e)throw new Error(Ci(33));return t}const yy=g.createContext(void 0);function sl(e){const t=g.useContext(yy);if(t===void 0&&!e)throw new Error(Ci(36));return t}const Mj={};function Rs(e,t){const n=g.useRef(Mj);return n.current===Mj&&(n.current=e(t)),n}function Ic(e,t,n,s){const a=Rs(CC).current;return N$(a,e,t,n,s)&&TC(a,[e,t,n,s]),a.callback}function S$(e){const t=Rs(CC).current;return k$(t,e)&&TC(t,e),t.callback}function CC(){return{callback:null,cleanup:null,refs:[]}}function N$(e,t,n,s,a){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==s||e.refs[3]!==a}function k$(e,t){return e.refs.length!==t.length||e.refs.some((n,s)=>n!==t[s])}function TC(e,t){if(e.refs=t,t.every(n=>n==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),n!=null){const s=Array(t.length).fill(null);for(let a=0;a<t.length;a+=1){const l=t[a];if(l!=null)switch(typeof l){case"function":{const u=l(n);typeof u=="function"&&(s[a]=u);break}case"object":{l.current=n;break}}}e.cleanup=()=>{for(let a=0;a<t.length;a+=1){const l=t[a];if(l!=null)switch(typeof l){case"function":{const u=s[a];typeof u=="function"?u():l(null);break}case"object":{l.current=null;break}}}}}}}const E$=parseInt(g.version,10);function by(e){return E$>=e}function _j(e){if(!g.isValidElement(e))return null;const t=e,n=t.props;return(by(19)?n?.ref:t.ref)??null}function rv(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function C$(e,t){const n={};for(const s in e){const a=e[s];if(t?.hasOwnProperty(s)){const l=t[s](a);l!=null&&Object.assign(n,l);continue}a===!0?n[`data-${s.toLowerCase()}`]="":a&&(n[`data-${s.toLowerCase()}`]=a.toString())}return n}function T$(e,t){return typeof e=="function"?e(t):e}function A$(e,t){return typeof e=="function"?e(t):e}const yc={};function ah(e,t,n,s,a){let l={...av(e,yc)};return t&&(l=Xd(l,t)),n&&(l=Xd(l,n)),s&&(l=Xd(l,s)),l}function R$(e){if(e.length===0)return yc;if(e.length===1)return av(e[0],yc);let t={...av(e[0],yc)};for(let n=1;n<e.length;n+=1)t=Xd(t,e[n]);return t}function Xd(e,t){return AC(t)?t(e):M$(e,t)}function M$(e,t){if(!t)return e;for(const n in t){const s=t[n];switch(n){case"style":{e[n]=rv(e.style,s);break}case"className":{e[n]=RC(e.className,s);break}default:_$(n,s)?e[n]=O$(e[n],s):e[n]=s}}return e}function _$(e,t){const n=e.charCodeAt(0),s=e.charCodeAt(1),a=e.charCodeAt(2);return n===111&&s===110&&a>=65&&a<=90&&(typeof t=="function"||typeof t>"u")}function AC(e){return typeof e=="function"}function av(e,t){return AC(e)?e(t):e??yc}function O$(e,t){return t?e?n=>{if(I$(n)){const a=n;iv(a);const l=t(a);return a.baseUIHandlerPrevented||e?.(a),l}const s=t(n);return e?.(n),s}:t:e}function iv(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function RC(e,t){return t?e?t+" "+e:t:e}function I$(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}function MC(){}const _C=Object.freeze([]),Qn=Object.freeze({}),D$=500,P$={style:{transition:"none"}},z$="data-base-ui-click-trigger",L$={fallbackAxisSide:"none"},$$={clipPath:"inset(50%)",position:"fixed",top:0,left:0};function Ia(e,t,n={}){const s=t.render,a=U$(t,n);if(n.enabled===!1)return null;const l=n.state??Qn;return B$(e,s,a,l)}function U$(e,t={}){const{className:n,style:s,render:a}=e,{state:l=Qn,ref:u,props:d,stateAttributesMapping:p,enabled:h=!0}=t,m=h?T$(n,l):void 0,y=h?A$(s,l):void 0,x=h?C$(l,p):Qn,w=h?rv(x,Array.isArray(d)?R$(d):d)??Qn:Qn;return typeof document<"u"&&(h?Array.isArray(u)?w.ref=S$([w.ref,_j(a),...u]):w.ref=Ic(w.ref,_j(a),u):Ic(null,null)),h?(m!==void 0&&(w.className=RC(w.className,m)),y!==void 0&&(w.style=rv(w.style,y)),w):Qn}function B$(e,t,n,s){if(t){if(typeof t=="function")return t(n,s);const a=ah(n,t.props);return a.ref=n.ref,g.cloneElement(t,a)}return V$(e,n)}function V$(e,t){return g.createElement(e,t)}let jf=(function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e})({});const F$={[jf.startingStyle]:""},H$={[jf.endingStyle]:""},q$={transitionStatus(e){return e==="starting"?F$:e==="ending"?H$:null}};let xy=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=jf.startingStyle]="startingStyle",e[e.endingStyle=jf.endingStyle]="endingStyle",e.anchorHidden="data-anchor-hidden",e})({}),Oj=(function(e){return e.popupOpen="data-popup-open",e.pressed="data-pressed",e})({});const Z$={[Oj.popupOpen]:"",[Oj.pressed]:""},W$={[xy.open]:""},Y$={[xy.closed]:""},G$={[xy.anchorHidden]:""},K$={open(e){return e?Z$:null}},OC={open(e){return e?W$:Y$},anchorHidden(e){return e?G$:null}},X$="none",Sf="trigger-press",mi="trigger-hover",Ij="trigger-focus",wy="outside-press",IC="item-press",ih="focus-out",DC="escape-key",Jd="list-navigation",J$="cancel-open",dc="sibling-open",Q$="imperative-action",qm=Dk[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],e6=qm&&qm!==g.useLayoutEffect?qm:e=>e();function Ke(e){const t=Rs(t6).current;return t.next=e,e6(t.effect),t.trampoline}function t6(){const e={next:void 0,callback:n6,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function n6(){}function oh(){return typeof window<"u"}function Da(e){return jy(e)?(e.nodeName||"").toLowerCase():"#document"}function An(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function dr(e){var t;return(t=(jy(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function jy(e){return oh()?e instanceof Node||e instanceof An(e).Node:!1}function Pt(e){return oh()?e instanceof Element||e instanceof An(e).Element:!1}function tn(e){return oh()?e instanceof HTMLElement||e instanceof An(e).HTMLElement:!1}function ov(e){return!oh()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof An(e).ShadowRoot}const s6=new Set(["inline","contents"]);function Ti(e){const{overflow:t,overflowX:n,overflowY:s,display:a}=hs(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&!s6.has(a)}const r6=new Set(["table","td","th"]);function a6(e){return r6.has(Da(e))}const i6=[":popover-open",":modal"];function lh(e){return i6.some(t=>{try{return e.matches(t)}catch{return!1}})}const o6=["transform","translate","scale","rotate","perspective"],l6=["transform","translate","scale","rotate","perspective","filter"],c6=["paint","layout","strict","content"];function Sy(e){const t=ch(),n=Pt(e)?hs(e):e;return o6.some(s=>n[s]?n[s]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||l6.some(s=>(n.willChange||"").includes(s))||c6.some(s=>(n.contain||"").includes(s))}function u6(e){let t=cr(e);for(;tn(t)&&!ar(t);){if(Sy(t))return t;if(lh(t))return null;t=cr(t)}return null}function ch(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const d6=new Set(["html","body","#document"]);function ar(e){return d6.has(Da(e))}function hs(e){return An(e).getComputedStyle(e)}function uh(e){return Pt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function cr(e){if(Da(e)==="html")return e;const t=e.assignedSlot||e.parentNode||ov(e)&&e.host||dr(e);return ov(t)?t.host:t}function PC(e){const t=cr(e);return ar(t)?e.ownerDocument?e.ownerDocument.body:e.body:tn(t)&&Ti(t)?t:PC(t)}function Na(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const a=PC(e),l=a===((s=e.ownerDocument)==null?void 0:s.body),u=An(a);if(l){const d=lv(u);return t.concat(u,u.visualViewport||[],Ti(a)?a:[],d&&n?Na(d):[])}return t.concat(a,Na(a,[],n))}function lv(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const f6=()=>{},Ye=typeof document<"u"?g.useLayoutEffect:f6,h6=g.createContext(void 0);function p6(e=!1){const t=g.useContext(h6);if(t===void 0&&!e)throw new Error(Ci(16));return t}function m6(e){const{focusableWhenDisabled:t,disabled:n,composite:s=!1,tabIndex:a=0,isNativeButton:l}=e,u=s&&t!==!1,d=s&&t===!1;return{props:g.useMemo(()=>{const h={onKeyDown(m){n&&t&&m.key!=="Tab"&&m.preventDefault()}};return s||(h.tabIndex=a,!l&&n&&(h.tabIndex=t?a:-1)),(l&&(t||u)||!l&&n)&&(h["aria-disabled"]=n),l&&(!t||d)&&(h.disabled=n),h},[s,n,t,u,d,l,a])}}function g6(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:s=0,native:a=!0}=e,l=g.useRef(null),u=p6(!0)!==void 0,d=Ke(()=>{const x=l.current;return!!(x?.tagName==="A"&&x?.href)}),{props:p}=m6({focusableWhenDisabled:n,disabled:t,composite:u,tabIndex:s,isNativeButton:a}),h=g.useCallback(()=>{const x=l.current;v6(x)&&u&&t&&p.disabled===void 0&&x.disabled&&(x.disabled=!1)},[t,p.disabled,u]);Ye(h,[h]);const m=g.useCallback((x={})=>{const{onClick:w,onMouseDown:j,onKeyUp:N,onKeyDown:k,onPointerDown:E,...C}=x;return ah({type:a?"button":void 0,onClick(R){if(t){R.preventDefault();return}w?.(R)},onMouseDown(R){t||j?.(R)},onKeyDown(R){if(t||(iv(R),k?.(R)),R.baseUIHandlerPrevented)return;const A=R.target===R.currentTarget&&!a&&!d()&&!t,M=R.key==="Enter",_=R.key===" ";A&&((_||M)&&R.preventDefault(),M&&w?.(R))},onKeyUp(R){t||(iv(R),N?.(R)),!R.baseUIHandlerPrevented&&R.target===R.currentTarget&&!a&&!t&&R.key===" "&&w?.(R)},onPointerDown(R){if(t){R.preventDefault();return}E?.(R)}},a?void 0:{role:"button"},p,C)},[t,p,a,d]),y=Ke(x=>{l.current=x,h()});return{getButtonProps:m,buttonRef:y}}function v6(e){return tn(e)&&e.tagName==="BUTTON"}const y6={type:"regular-item"};function b6(e){const{closeOnClick:t,disabled:n=!1,highlighted:s,id:a,store:l,nativeButton:u,itemMetadata:d,nodeId:p}=e,h=g.useRef(null),m=rh(!0),y=m!==void 0,{events:x}=l.useState("floatingTreeRoot"),{getButtonProps:w,buttonRef:j}=g6({disabled:n,focusableWhenDisabled:!0,native:u}),N=g.useCallback(E=>ah({id:a,role:"menuitem",tabIndex:s?0:-1,onMouseMove(C){p&&x.emit("itemhover",{nodeId:p,target:C.currentTarget})},onMouseEnter(){d.type==="submenu-trigger"&&d.setActive()},onKeyUp(C){C.key===" "&&l.context.typingRef.current&&C.preventBaseUIHandler()},onClick(C){t&&x.emit("close",{domEvent:C,reason:IC})},onMouseUp(C){if(m){const S=m.initialCursorPointRef.current;if(m.initialCursorPointRef.current=null,y&&S&&Math.abs(C.clientX-S.x)<=1&&Math.abs(C.clientY-S.y)<=1)return}h.current&&l.context.allowMouseUpTriggerRef.current&&(!y||C.button===2)&&d.type==="regular-item"&&h.current.click()}},E,w),[a,s,w,t,x,l,y,m,d,p]),k=Ic(h,j);return g.useMemo(()=>({getItemProps:N,itemRef:k}),[N,k])}const zC=g.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function x6(){return g.useContext(zC)}let w6=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function j6(e={}){const{label:t,metadata:n,textRef:s,indexGuessBehavior:a,index:l}=e,{register:u,unregister:d,subscribeMapChange:p,elementsRef:h,labelsRef:m,nextIndexRef:y}=x6(),x=g.useRef(-1),[w,j]=g.useState(l??(a===w6.GuessFromOrder?()=>{if(x.current===-1){const E=y.current;y.current+=1,x.current=E}return x.current}:-1)),N=g.useRef(null),k=g.useCallback(E=>{if(N.current=E,w!==-1&&E!==null&&(h.current[w]=E,m)){const C=t!==void 0;m.current[w]=C?t:s?.current?.textContent??E.textContent}},[w,h,m,t,s]);return Ye(()=>{if(l!=null)return;const E=N.current;if(E)return u(E,n),()=>{d(E)}},[l,u,d,n]),Ye(()=>{if(l==null)return p(E=>{const C=N.current?E.get(N.current)?.index:null;C!=null&&j(C)})},[l,p,j]),g.useMemo(()=>({ref:k,index:w}),[w,k])}function LC(e){return Oa(e,"base-ui")}function cn(e,t,n,s){let a=!1,l=!1;const u=Qn;return{reason:e,event:t??new Event("base-ui"),cancel(){a=!0},allowPropagation(){l=!0},get isCanceled(){return a},get isPropagationAllowed(){return l},trigger:n,...u}}var ji=Pk();const S6=[];function $C(e){g.useEffect(e,S6)}const wd=null;class N6{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=t=>{this.isScheduled=!1;const n=this.callbacks,s=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,s>0)for(let a=0;a<n.length;a+=1)n[a]?.(t)};request(t){const n=this.nextId;return this.nextId+=1,this.callbacks.push(t),this.callbacksCount+=1,!this.isScheduled&&(requestAnimationFrame(this.tick),this.isScheduled=!0),n}cancel(t){const n=t-this.startId;n<0||n>=this.callbacks.length||(this.callbacks[n]=null,this.callbacksCount-=1)}}const jd=new N6;class rr{static create(){return new rr}static request(t){return jd.request(t)}static cancel(t){return jd.cancel(t)}currentId=wd;request(t){this.cancel(),this.currentId=jd.request(()=>{this.currentId=wd,t()})}cancel=()=>{this.currentId!==wd&&(jd.cancel(this.currentId),this.currentId=wd)};disposeEffect=()=>this.cancel}function Ny(){const e=Rs(rr.create).current;return $C(e.disposeEffect),e}function k6(e,t=!1,n=!1){const[s,a]=g.useState(e&&t?"idle":void 0),[l,u]=g.useState(e);return e&&!l&&(u(!0),a("starting")),!e&&l&&s!=="ending"&&!n&&a("ending"),!e&&!l&&s==="ending"&&a(void 0),Ye(()=>{if(!e&&l&&s!=="ending"&&n){const d=rr.request(()=>{a("ending")});return()=>{rr.cancel(d)}}},[e,l,s,n]),Ye(()=>{if(!e||t)return;const d=rr.request(()=>{ji.flushSync(()=>{a(void 0)})});return()=>{rr.cancel(d)}},[t,e]),Ye(()=>{if(!e||!t)return;e&&l&&s!=="idle"&&a("starting");const d=rr.request(()=>{a("idle")});return()=>{rr.cancel(d)}},[t,e,l,a,s]),g.useMemo(()=>({mounted:l,setMounted:u,transitionStatus:s}),[l,s])}function Xn(e){const t=Rs(E6,e).current;return t.next=e,Ye(t.effect),t}function E6(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}function ii(e){return e==null?e:"current"in e?e.current:e}function C6(e,t=!1,n=!0){const s=Ny();return Ke((a,l=null)=>{s.cancel();const u=ii(e);u!=null&&(typeof u.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED?a():s.request(()=>{function d(){u&&Promise.all(u.getAnimations().map(p=>p.finished)).then(()=>{l!=null&&l.aborted||ji.flushSync(a)}).catch(()=>{if(n){if(l!=null&&l.aborted)return;ji.flushSync(a)}else u.getAnimations().length>0&&u.getAnimations().some(p=>p.pending||p.playState!=="finished")&&d()})}t?s.request(d):d()}))})}function UC(e){const{enabled:t=!0,open:n,ref:s,onComplete:a}=e,l=Xn(n),u=Ke(a),d=C6(s,n);g.useEffect(()=>{t&&d(()=>{n===l.current&&u()})},[t,n,u,d,l])}const BC=g.createContext(void 0);function T6(){const e=g.useContext(BC);if(e===void 0)throw new Error(Ci(31));return e}const A6=g.forwardRef(function(t,n){const{render:s,className:a,...l}=t,[u,d]=g.useState(void 0),p=g.useMemo(()=>({setLabelId:d}),[d]),h=Ia("div",t,{ref:n,props:{role:"group","aria-labelledby":u,...l}});return o.jsx(BC.Provider,{value:p,children:h})}),R6=g.forwardRef(function(t,n){const{className:s,render:a,id:l,...u}=t,d=LC(l),{setLabelId:p}=T6();return Ye(()=>(p(d),()=>{p(void 0)}),[p,d]),Ia("div",t,{ref:n,props:{id:d,role:"presentation",...u}})}),M6=g.forwardRef(function(t,n){const{render:s,className:a,id:l,label:u,nativeButton:d=!1,disabled:p=!1,closeOnClick:h=!0,...m}=t,y=j6({label:u}),x=EC(!0),w=LC(l),{store:j}=sl(),N=j.useState("isActive",y.index),k=j.useState("itemProps"),{getItemProps:E,itemRef:C}=b6({closeOnClick:h,disabled:p,highlighted:N,id:w,store:j,nativeButton:d,nodeId:x?.nodeId,itemMetadata:y6}),S=g.useMemo(()=>({disabled:p,highlighted:N}),[p,N]);return Ia("div",t,{state:S,props:[k,m,E],ref:[C,n,y.ref]})}),tc=0;class Xo{static create(){return new Xo}currentId=tc;start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=tc,n()},t)}isStarted(){return this.currentId!==tc}clear=()=>{this.currentId!==tc&&(clearTimeout(this.currentId),this.currentId=tc)};disposeEffect=()=>this.clear}function Fs(){const e=Rs(Xo.create).current;return $C(e.disposeEffect),e}const rl=typeof navigator<"u",Zm=P6(),VC=L6(),FC=z6(),_6=typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter:none"),O6=Zm.platform==="MacIntel"&&Zm.maxTouchPoints>1?!0:/iP(hone|ad|od)|iOS/.test(Zm.platform),I6=rl&&/apple/i.test(navigator.vendor),cv=rl&&/android/i.test(VC)||/android/i.test(FC);rl&&VC.toLowerCase().startsWith("mac")&&navigator.maxTouchPoints;const D6=FC.includes("jsdom/");function P6(){if(!rl)return{platform:"",maxTouchPoints:-1};const e=navigator.userAgentData;return e?.platform?{platform:e.platform,maxTouchPoints:navigator.maxTouchPoints}:{platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??-1}}function z6(){if(!rl)return"";const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:t,version:n})=>`${t}/${n}`).join(" "):navigator.userAgent}function L6(){if(!rl)return"";const e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??""}const uv="data-base-ui-focusable",HC="active",qC="selected",ZC="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",ka="ArrowLeft",Ea="ArrowRight",ky="ArrowUp",Gc="ArrowDown";function ba(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function Dt(e,t){if(!e||!t)return!1;const n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&ov(n)){let s=t;for(;s;){if(e===s)return!0;s=s.parentNode||s.host}}return!1}function Jn(e){return"composedPath"in e?e.composedPath()[0]:e.target}function zs(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return n.target!=null&&t.contains(n.target)}function $6(e){return e.matches("html,body")}function Cn(e){return e?.ownerDocument||document}function U6(e){return tn(e)&&e.matches(ZC)}function dv(e){return e?e.getAttribute("role")==="combobox"&&U6(e):!1}function Nf(e){return e?e.hasAttribute(uv)?e:e.querySelector(`[${uv}]`)||e:null}function Ho(e,t,n=!0){return e.filter(a=>a.parentId===t&&(!n||a.context?.open)).flatMap(a=>[a,...Ho(e,a.id,n)])}function Dj(e,t){let n=[],s=e.find(a=>a.id===t)?.parentId;for(;s;){const a=e.find(l=>l.id===s);s=a?.parentId,a&&(n=n.concat(a))}return n}function Tn(e){e.preventDefault(),e.stopPropagation()}function B6(e){return"nativeEvent"in e}function WC(e){return e.mozInputSource===0&&e.isTrusted?!0:cv&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function YC(e){return D6?!1:!cv&&e.width===0&&e.height===0||cv&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType==="touch"}function V6(e,t){const n=["mouse","pen"];return n.push("",void 0),n.includes(e)}function F6(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}const H6=["top","right","bottom","left"],Jo=Math.min,cs=Math.max,kf=Math.round,zo=Math.floor,ir=e=>({x:e,y:e}),q6={left:"right",right:"left",bottom:"top",top:"bottom"},Z6={start:"end",end:"start"};function fv(e,t,n){return cs(e,Jo(t,n))}function Lr(e,t){return typeof e=="function"?e(t):e}function ds(e){return e.split("-")[0]}function Pa(e){return e.split("-")[1]}function Ey(e){return e==="x"?"y":"x"}function Cy(e){return e==="y"?"height":"width"}const W6=new Set(["top","bottom"]);function Cs(e){return W6.has(ds(e))?"y":"x"}function Ty(e){return Ey(Cs(e))}function Y6(e,t,n){n===void 0&&(n=!1);const s=Pa(e),a=Ty(e),l=Cy(a);let u=a==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[l]>t.floating[l]&&(u=Ef(u)),[u,Ef(u)]}function G6(e){const t=Ef(e);return[hv(e),t,hv(t)]}function hv(e){return e.replace(/start|end/g,t=>Z6[t])}const Pj=["left","right"],zj=["right","left"],K6=["top","bottom"],X6=["bottom","top"];function J6(e,t,n){switch(e){case"top":case"bottom":return n?t?zj:Pj:t?Pj:zj;case"left":case"right":return t?K6:X6;default:return[]}}function Q6(e,t,n,s){const a=Pa(e);let l=J6(ds(e),n==="start",s);return a&&(l=l.map(u=>u+"-"+a),t&&(l=l.concat(l.map(hv)))),l}function Ef(e){return e.replace(/left|right|bottom|top/g,t=>q6[t])}function e8(e){return{top:0,right:0,bottom:0,left:0,...e}}function GC(e){return typeof e!="number"?e8(e):{top:e,right:e,bottom:e,left:e}}function Cf(e){const{x:t,y:n,width:s,height:a}=e;return{width:s,height:a,top:n,left:t,right:t+s,bottom:n+a,x:t,y:n}}function Sd(e,t,n){return Math.floor(e/t)!==n}function bc(e,t){return t<0||t>=e.current.length}function Wm(e,t){return On(e,{disabledIndices:t})}function Lj(e,t){return On(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function On(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:s,amount:a=1}={}){let l=t;do l+=n?-a:a;while(l>=0&&l<=e.current.length-1&&xc(e,l,s));return l}function t8(e,{event:t,orientation:n,loopFocus:s,rtl:a,cols:l,disabledIndices:u,minIndex:d,maxIndex:p,prevIndex:h,stopEvent:m=!1}){let y=h;const x=[],w={};let j=!1;{let E=null,C=-1;e.current.forEach((S,R)=>{if(S==null)return;const A=S.closest('[role="row"]');A&&(j=!0),(A!==E||C===-1)&&(E=A,C+=1,x[C]=[]),x[C].push(R),w[R]=C})}const N=j&&x.length>0&&x.some(E=>E.length!==l);function k(E){if(!N||h===-1)return;const C=w[h];if(C==null)return;const S=x[C].indexOf(h);let R=E==="up"?C-1:C+1;s&&(R<0?R=x.length-1:R>=x.length&&(R=0));const A=new Set;for(;R>=0&&R<x.length&&!A.has(R);){A.add(R);const M=x[R];if(M.length===0){R=E==="up"?R-1:R+1;continue}const _=Math.min(S,M.length-1);for(let z=_;z>=0;z-=1){const V=M[z];if(!xc(e,V,u))return V}R=E==="up"?R-1:R+1,s&&(R<0?R=x.length-1:R>=x.length&&(R=0))}}if(t.key===ky){const E=k("up");if(E!==void 0)m&&Tn(t),y=E;else{if(m&&Tn(t),h===-1)y=p;else if(y=On(e,{startingIndex:y,amount:l,decrement:!0,disabledIndices:u}),s&&(h-l<d||y<0)){const C=h%l,S=p%l,R=p-(S-C);S===C?y=p:y=S>C?R:R-l}bc(e,y)&&(y=h)}}if(t.key===Gc){const E=k("down");E!==void 0?(m&&Tn(t),y=E):(m&&Tn(t),h===-1?y=d:(y=On(e,{startingIndex:h,amount:l,disabledIndices:u}),s&&h+l>p&&(y=On(e,{startingIndex:h%l-l,amount:l,disabledIndices:u}))),bc(e,y)&&(y=h))}if(n==="both"){const E=zo(h/l);t.key===(a?ka:Ea)&&(m&&Tn(t),h%l!==l-1?(y=On(e,{startingIndex:h,disabledIndices:u}),s&&Sd(y,l,E)&&(y=On(e,{startingIndex:h-h%l-1,disabledIndices:u}))):s&&(y=On(e,{startingIndex:h-h%l-1,disabledIndices:u})),Sd(y,l,E)&&(y=h)),t.key===(a?Ea:ka)&&(m&&Tn(t),h%l!==0?(y=On(e,{startingIndex:h,decrement:!0,disabledIndices:u}),s&&Sd(y,l,E)&&(y=On(e,{startingIndex:h+(l-h%l),decrement:!0,disabledIndices:u}))):s&&(y=On(e,{startingIndex:h+(l-h%l),decrement:!0,disabledIndices:u})),Sd(y,l,E)&&(y=h));const C=zo(p/l)===E;bc(e,y)&&(s&&C?y=t.key===(a?Ea:ka)?p:On(e,{startingIndex:h-h%l-1,disabledIndices:u}):y=h)}return y}function n8(e,t,n){const s=[];let a=0;return e.forEach(({width:l,height:u},d)=>{let p=!1;for(n&&(a=0);!p;){const h=[];for(let m=0;m<l;m+=1)for(let y=0;y<u;y+=1)h.push(a+m+y*t);a%t+l<=t&&h.every(m=>s[m]==null)?(h.forEach(m=>{s[m]=d}),p=!0):a+=1}}),[...s]}function s8(e,t,n,s,a){if(e===-1)return-1;const l=n.indexOf(e),u=t[e];switch(a){case"tl":return l;case"tr":return u?l+u.width-1:l;case"bl":return u?l+(u.height-1)*s:l;case"br":return n.lastIndexOf(e);default:return-1}}function r8(e,t){return t.flatMap((n,s)=>e.includes(n)?[s]:[])}function xc(e,t,n){if(typeof n=="function")return n(t);if(n)return n.includes(t);const s=e.current[t];return s?s.hasAttribute("disabled")||s.getAttribute("aria-disabled")==="true":!1}var a8=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],Tf=a8.join(","),KC=typeof Element>"u",Qo=KC?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Af=!KC&&Element.prototype.getRootNode?function(e){var t;return e==null||(t=e.getRootNode)===null||t===void 0?void 0:t.call(e)}:function(e){return e?.ownerDocument},Rf=function(t,n){var s;n===void 0&&(n=!0);var a=t==null||(s=t.getAttribute)===null||s===void 0?void 0:s.call(t,"inert"),l=a===""||a==="true",u=l||n&&t&&(typeof t.closest=="function"?t.closest("[inert]"):Rf(t.parentNode));return u},i8=function(t){var n,s=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"contenteditable");return s===""||s==="true"},XC=function(t,n,s){if(Rf(t))return[];var a=Array.prototype.slice.apply(t.querySelectorAll(Tf));return n&&Qo.call(t,Tf)&&a.unshift(t),a=a.filter(s),a},Mf=function(t,n,s){for(var a=[],l=Array.from(t);l.length;){var u=l.shift();if(!Rf(u,!1))if(u.tagName==="SLOT"){var d=u.assignedElements(),p=d.length?d:u.children,h=Mf(p,!0,s);s.flatten?a.push.apply(a,h):a.push({scopeParent:u,candidates:h})}else{var m=Qo.call(u,Tf);m&&s.filter(u)&&(n||!t.includes(u))&&a.push(u);var y=u.shadowRoot||typeof s.getShadowRoot=="function"&&s.getShadowRoot(u),x=!Rf(y,!1)&&(!s.shadowRootFilter||s.shadowRootFilter(u));if(y&&x){var w=Mf(y===!0?u.children:y.children,!0,s);s.flatten?a.push.apply(a,w):a.push({scopeParent:u,candidates:w})}else l.unshift.apply(l,u.children)}}return a},JC=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},QC=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||i8(t))&&!JC(t)?0:t.tabIndex},o8=function(t,n){var s=QC(t);return s<0&&n&&!JC(t)?0:s},l8=function(t,n){return t.tabIndex===n.tabIndex?t.documentOrder-n.documentOrder:t.tabIndex-n.tabIndex},eT=function(t){return t.tagName==="INPUT"},c8=function(t){return eT(t)&&t.type==="hidden"},u8=function(t){var n=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(s){return s.tagName==="SUMMARY"});return n},d8=function(t,n){for(var s=0;s<t.length;s++)if(t[s].checked&&t[s].form===n)return t[s]},f8=function(t){if(!t.name)return!0;var n=t.form||Af(t),s=function(d){return n.querySelectorAll('input[type="radio"][name="'+d+'"]')},a;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")a=s(window.CSS.escape(t.name));else try{a=s(t.name)}catch(u){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",u.message),!1}var l=d8(a,t.form);return!l||l===t},h8=function(t){return eT(t)&&t.type==="radio"},p8=function(t){return h8(t)&&!f8(t)},m8=function(t){var n,s=t&&Af(t),a=(n=s)===null||n===void 0?void 0:n.host,l=!1;if(s&&s!==t){var u,d,p;for(l=!!((u=a)!==null&&u!==void 0&&(d=u.ownerDocument)!==null&&d!==void 0&&d.contains(a)||t!=null&&(p=t.ownerDocument)!==null&&p!==void 0&&p.contains(t));!l&&a;){var h,m,y;s=Af(a),a=(h=s)===null||h===void 0?void 0:h.host,l=!!((m=a)!==null&&m!==void 0&&(y=m.ownerDocument)!==null&&y!==void 0&&y.contains(a))}}return l},$j=function(t){var n=t.getBoundingClientRect(),s=n.width,a=n.height;return s===0&&a===0},g8=function(t,n){var s=n.displayCheck,a=n.getShadowRoot;if(s==="full-native"&&"checkVisibility"in t){var l=t.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!l}if(getComputedStyle(t).visibility==="hidden")return!0;var u=Qo.call(t,"details>summary:first-of-type"),d=u?t.parentElement:t;if(Qo.call(d,"details:not([open]) *"))return!0;if(!s||s==="full"||s==="full-native"||s==="legacy-full"){if(typeof a=="function"){for(var p=t;t;){var h=t.parentElement,m=Af(t);if(h&&!h.shadowRoot&&a(h)===!0)return $j(t);t.assignedSlot?t=t.assignedSlot:!h&&m!==t.ownerDocument?t=m.host:t=h}t=p}if(m8(t))return!t.getClientRects().length;if(s!=="legacy-full")return!0}else if(s==="non-zero-area")return $j(t);return!1},v8=function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var n=t.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var s=0;s<n.children.length;s++){var a=n.children.item(s);if(a.tagName==="LEGEND")return Qo.call(n,"fieldset[disabled] *")?!0:!a.contains(t)}return!0}n=n.parentElement}return!1},pv=function(t,n){return!(n.disabled||c8(n)||g8(n,t)||u8(n)||v8(n))},mv=function(t,n){return!(p8(n)||QC(n)<0||!pv(t,n))},y8=function(t){var n=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},tT=function(t){var n=[],s=[];return t.forEach(function(a,l){var u=!!a.scopeParent,d=u?a.scopeParent:a,p=o8(d,u),h=u?tT(a.candidates):d;p===0?u?n.push.apply(n,h):n.push(d):s.push({documentOrder:l,tabIndex:p,item:a,isScope:u,content:h})}),s.sort(l8).reduce(function(a,l){return l.isScope?a.push.apply(a,l.content):a.push(l.content),a},[]).concat(n)},dh=function(t,n){n=n||{};var s;return n.getShadowRoot?s=Mf([t],n.includeContainer,{filter:mv.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:y8}):s=XC(t,n.includeContainer,mv.bind(null,n)),tT(s)},b8=function(t,n){n=n||{};var s;return n.getShadowRoot?s=Mf([t],n.includeContainer,{filter:pv.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):s=XC(t,n.includeContainer,pv.bind(null,n)),s},nT=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return Qo.call(t,Tf)===!1?!1:mv(n,t)};const Kc=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function sT(e,t){const n=dh(e,Kc()),s=n.length;if(s===0)return;const a=ba(Cn(e)),l=n.indexOf(a),u=l===-1?t===1?0:s-1:l+t;return n[u]}function rT(e){return sT(Cn(e).body,1)||e}function aT(e){return sT(Cn(e).body,-1)||e}function wc(e,t){const n=t||e.currentTarget,s=e.relatedTarget;return!s||!Dt(n,s)}function x8(e){dh(e,Kc()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function Uj(e){e.querySelectorAll("[data-tabindex]").forEach(n=>{const s=n.dataset.tabindex;delete n.dataset.tabindex,s?n.setAttribute("tabindex",s):n.removeAttribute("tabindex")})}function iT(){const e=new Map;return{emit(t,n){e.get(t)?.forEach(s=>s(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}class oT{nodesRef={current:[]};events=iT();addNode(t){this.nodesRef.current.push(t)}removeNode(t){const n=this.nodesRef.current.findIndex(s=>s===t);n!==-1&&this.nodesRef.current.splice(n,1)}}const lT=g.createContext(null),cT=g.createContext(null),za=()=>g.useContext(lT)?.id||null,al=e=>{const t=g.useContext(cT);return e??t};function w8(e){const t=Oa(),n=al(e),s=za();return Ye(()=>{if(!t)return;const a={id:t,parentId:s};return n?.addNode(a),()=>{n?.removeNode(a)}},[n,t,s]),t}function j8(e){const{children:t,id:n}=e,s=za();return o.jsx(lT.Provider,{value:g.useMemo(()=>({id:n,parentId:s}),[n,s]),children:t})}function S8(e){const{children:t,externalTree:n}=e,s=Rs(()=>n??new oT).current;return o.jsx(cT.Provider,{value:s,children:t})}function Dc(e){return`data-base-ui-${e}`}const uT={clip:"rect(0 0 0 0)",overflow:"hidden",whiteSpace:"nowrap",position:"fixed",top:0,left:0,border:0,padding:0,width:1,height:1,margin:-1};function Si(e){return e?.ownerDocument||document}const _f=g.forwardRef(function(t,n){const[s,a]=g.useState();Ye(()=>{I6&&a("button")},[]);const l={tabIndex:0,role:s};return o.jsx("span",{...t,ref:n,style:uT,"aria-hidden":s?void 0:!0,...l,"data-base-ui-focus-guard":""})});let Bj=0;function Qd(e,t={}){const{preventScroll:n=!1,cancelPrevious:s=!0,sync:a=!1}=t;s&&cancelAnimationFrame(Bj);const l=()=>e?.focus({preventScroll:n});a?l():Bj=requestAnimationFrame(l)}const qo={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function Vj(e){return e==="inert"?qo.inert:e==="aria-hidden"?qo["aria-hidden"]:qo.none}let Nd=new WeakSet,kd={},Ym=0;const dT=e=>e&&(e.host||dT(e.parentNode)),N8=(e,t)=>t.map(n=>{if(e.contains(n))return n;const s=dT(n);return e.contains(s)?s:null}).filter(n=>n!=null);function k8(e,t,n,s){const a="data-base-ui-inert",l=s?"inert":n?"aria-hidden":null,u=N8(t,e),d=new Set,p=new Set(u),h=[];kd[a]||(kd[a]=new WeakMap);const m=kd[a];u.forEach(y),x(t),d.clear();function y(w){!w||d.has(w)||(d.add(w),w.parentNode&&y(w.parentNode))}function x(w){!w||p.has(w)||[].forEach.call(w.children,j=>{if(Da(j)!=="script")if(d.has(j))x(j);else{const N=l?j.getAttribute(l):null,k=N!==null&&N!=="false",E=Vj(l),C=(E.get(j)||0)+1,S=(m.get(j)||0)+1;E.set(j,C),m.set(j,S),h.push(j),C===1&&k&&Nd.add(j),S===1&&j.setAttribute(a,""),!k&&l&&j.setAttribute(l,l==="inert"?"":"true")}})}return Ym+=1,()=>{h.forEach(w=>{const j=Vj(l),k=(j.get(w)||0)-1,E=(m.get(w)||0)-1;j.set(w,k),m.set(w,E),k||(!Nd.has(w)&&l&&w.removeAttribute(l),Nd.delete(w)),E||w.removeAttribute(a)}),Ym-=1,Ym||(qo.inert=new WeakMap,qo["aria-hidden"]=new WeakMap,qo.none=new WeakMap,Nd=new WeakSet,kd={})}}function E8(e,t=!1,n=!1){const s=Cn(e[0]).body;return k8(e.concat(Array.from(s.querySelectorAll("[aria-live]"))),s,t,n)}const fT=g.createContext(null),hT=()=>g.useContext(fT),C8=Dc("portal");function T8(e={}){const{ref:t,container:n,componentProps:s=Qn,elementProps:a,elementState:l}=e,u=Oa(),p=hT()?.portalNode,[h,m]=g.useState(null),[y,x]=g.useState(null),w=g.useRef(null);Ye(()=>{if(n===null){w.current&&(w.current=null,x(null),m(null));return}if(u==null)return;const k=(n&&(jy(n)?n:n.current))??p??document.body;if(k==null){w.current&&(w.current=null,x(null),m(null));return}w.current!==k&&(w.current=k,x(null),m(k))},[n,p,u]);const j=Ia("div",s,{ref:[t,x],state:l,props:[{id:u,[C8]:""},a]});return{portalNode:y,portalSubtree:h&&j?ji.createPortal(j,h):null}}const A8=g.forwardRef(function(t,n){const{children:s,container:a,className:l,render:u,renderGuards:d,...p}=t,{portalNode:h,portalSubtree:m}=T8({container:a,ref:n,componentProps:t,elementProps:p}),y=g.useRef(null),x=g.useRef(null),w=g.useRef(null),j=g.useRef(null),[N,k]=g.useState(null),E=N?.modal,C=N?.open,S=typeof d=="boolean"?d:!!N&&!N.modal&&N.open&&!!h;g.useEffect(()=>{if(!h||E)return;function A(M){h&&wc(M)&&(M.type==="focusin"?Uj:x8)(h)}return h.addEventListener("focusin",A,!0),h.addEventListener("focusout",A,!0),()=>{h.removeEventListener("focusin",A,!0),h.removeEventListener("focusout",A,!0)}},[h,E]),g.useEffect(()=>{!h||C||Uj(h)},[C,h]);const R=g.useMemo(()=>({beforeOutsideRef:y,afterOutsideRef:x,beforeInsideRef:w,afterInsideRef:j,portalNode:h,setFocusManagerState:k}),[h]);return o.jsxs(g.Fragment,{children:[m,o.jsxs(fT.Provider,{value:R,children:[S&&h&&o.jsx(_f,{"data-type":"outside",ref:y,onFocus:A=>{if(wc(A,h))w.current?.focus();else{const M=N?N.domReference:null;aT(M)?.focus()}}}),S&&h&&o.jsx("span",{"aria-owns":h.id,style:$$}),h&&ji.createPortal(s,h),S&&h&&o.jsx(_f,{"data-type":"outside",ref:x,onFocus:A=>{if(wc(A,h))j.current?.focus();else{const M=N?N.domReference:null;rT(M)?.focus(),N?.closeOnFocusOut&&N?.onOpenChange(!1,cn(ih,A.nativeEvent))}}})]})]})});function R8(e,t){const n=An(e.target);return e instanceof n.KeyboardEvent?"keyboard":e instanceof n.FocusEvent?t||"keyboard":"pointerType"in e?e.pointerType||"keyboard":"touches"in e?"touch":e instanceof n.MouseEvent?t||(e.detail===0?"keyboard":"mouse"):""}const Fj=20;let xa=[];function Ay(){xa=xa.filter(e=>e.isConnected)}function M8(e){Ay(),e&&Da(e)!=="body"&&(xa.push(e),xa.length>Fj&&(xa=xa.slice(-Fj)))}function Gm(){return Ay(),xa[xa.length-1]}function _8(e){if(!e)return null;const t=Kc();return nT(e,t)?e:dh(e,t)[0]||e}function O8(e){return!e||!e.isConnected?!1:typeof e.checkVisibility=="function"?e.checkVisibility():hs(e).display!=="none"}function Hj(e,t){if(!t.current.includes("floating")&&!e.getAttribute("role")?.includes("dialog"))return;const n=Kc(),a=b8(e,n).filter(u=>{const d=u.getAttribute("data-tabindex")||"";return nT(u,n)||u.hasAttribute("data-tabindex")&&!d.startsWith("-")}),l=e.getAttribute("tabindex");t.current.includes("floating")||a.length===0?l!=="0"&&e.setAttribute("tabindex","0"):(l!=="-1"||e.hasAttribute("data-tabindex")&&e.getAttribute("data-tabindex")!=="-1")&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}function I8(e){const{context:t,children:n,disabled:s=!1,order:a=["content"],initialFocus:l=!0,returnFocus:u=!0,restoreFocus:d=!1,modal:p=!0,closeOnFocusOut:h=!0,openInteractionType:m="",getInsideElements:y=()=>[],nextFocusableElement:x,previousFocusableElement:w,beforeContentFocusGuardRef:j,externalTree:N}=e,k="rootStore"in t?t.rootStore:t,E=k.useState("open"),C=k.useState("domReferenceElement"),S=k.useState("floatingElement"),{events:R,dataRef:A}=k.context,M=Ke(()=>A.current.floatingContext?.nodeId),_=Ke(y),z=l===!1,V=dv(C)&&z,U=Xn(a),O=Xn(l),D=Xn(u),H=Xn(m),W=al(N),q=hT(),$=g.useRef(null),L=g.useRef(null),F=g.useRef(!1),X=g.useRef(!1),G=g.useRef(!1),I=g.useRef(-1),B=g.useRef(""),Y=g.useRef(""),Q=Fs(),me=Fs(),re=Ny(),ie=q!=null,de=Nf(S),ye=Ke((je=de)=>je?dh(je,Kc()):[]),Te=Ke(je=>{const Ee=ye(je);return U.current.map(()=>Ee).filter(Boolean).flat()});g.useEffect(()=>{if(s||!p)return;function je(Ue){Ue.key==="Tab"&&Dt(de,ba(Cn(de)))&&ye().length===0&&!V&&Tn(Ue)}const Ee=Cn(de);return Ee.addEventListener("keydown",je),()=>{Ee.removeEventListener("keydown",je)}},[s,C,de,p,U,V,ye,Te]),g.useEffect(()=>{if(s||!S)return;function je(Ee){const Ue=Jn(Ee),Be=ye().indexOf(Ue);Be!==-1&&(I.current=Be)}return S.addEventListener("focusin",je),()=>{S.removeEventListener("focusin",je)}},[s,S,ye]),g.useEffect(()=>{if(s||!E)return;const je=Cn(de);function Ee(){G.current=!1}function Ue(Be){const oe=Jn(Be),ve=Dt(S,oe)||Dt(C,oe)||Dt(q?.portalNode,oe);G.current=!ve,Y.current=Be.pointerType||"keyboard"}function Ve(){Y.current="keyboard"}return je.addEventListener("pointerdown",Ue,!0),je.addEventListener("pointerup",Ee,!0),je.addEventListener("pointercancel",Ee,!0),je.addEventListener("keydown",Ve,!0),()=>{je.removeEventListener("pointerdown",Ue,!0),je.removeEventListener("pointerup",Ee,!0),je.removeEventListener("pointercancel",Ee,!0),je.removeEventListener("keydown",Ve,!0)}},[s,S,C,de,E,q]),g.useEffect(()=>{if(s||!h)return;function je(){X.current=!0,me.start(0,()=>{X.current=!1})}function Ee(oe){const ve=oe.relatedTarget,xe=oe.currentTarget,Ne=Jn(oe);queueMicrotask(()=>{const ke=M(),Se=k.context.triggerElements,$e=!(Dt(C,ve)||Dt(S,ve)||Dt(ve,S)||Dt(q?.portalNode,ve)||ve!=null&&Se.hasElement(ve)||Se.hasMatchingElement(Pe=>Dt(Pe,ve))||ve?.hasAttribute(Dc("focus-guard"))||W&&(Ho(W.nodesRef.current,ke).find(Pe=>Dt(Pe.context?.elements.floating,ve)||Dt(Pe.context?.elements.domReference,ve))||Dj(W.nodesRef.current,ke).find(Pe=>[Pe.context?.elements.floating,Nf(Pe.context?.elements.floating)].includes(ve)||Pe.context?.elements.domReference===ve)));if(xe===C&&de&&Hj(de,U),d&&xe!==C&&!O8(Ne)&&ba(Cn(de))===Cn(de).body){if(tn(de)&&(de.focus(),d==="popup")){re.request(()=>{de.focus()});return}const Pe=I.current,xt=ye(),kt=xt[Pe]||xt[xt.length-1]||de;tn(kt)&&kt.focus()}if(A.current.insideReactTree){A.current.insideReactTree=!1;return}(V||!p)&&ve&&$e&&!X.current&&(V||ve!==Gm())&&(F.current=!0,k.setOpen(!1,cn(ih,oe)))})}function Ue(){G.current||(A.current.insideReactTree=!0,Q.start(0,()=>{A.current.insideReactTree=!1}))}const Ve=tn(C)?C:null,Be=[];if(!(!S&&!Ve))return Ve&&(Ve.addEventListener("focusout",Ee),Ve.addEventListener("pointerdown",je),Be.push(()=>{Ve.removeEventListener("focusout",Ee),Ve.removeEventListener("pointerdown",je)})),S&&(S.addEventListener("focusout",Ee),q&&(S.addEventListener("focusout",Ue,!0),Be.push(()=>{S.removeEventListener("focusout",Ue,!0)})),Be.push(()=>{S.removeEventListener("focusout",Ee)})),()=>{Be.forEach(oe=>{oe()})}},[s,C,S,de,p,W,q,k,h,d,ye,V,M,U,A,Q,me,re]);const he=g.useRef(null),ue=g.useRef(null),we=Ic(he,j,q?.beforeInsideRef),We=Ic(ue,q?.afterInsideRef);g.useEffect(()=>{if(s||!S||!E)return;const je=Array.from(q?.portalNode?.querySelectorAll(`[${Dc("portal")}]`)||[]),Ue=(W?Dj(W.nodesRef.current,M()):[]).find(oe=>dv(oe.context?.elements.domReference||null))?.context?.elements.domReference,Ve=[S,Ue,...je,..._(),$.current,L.current,he.current,ue.current,q?.beforeOutsideRef.current,q?.afterOutsideRef.current,ii(w),ii(x),V?C:null].filter(oe=>oe!=null),Be=E8(Ve,p||V);return()=>{Be()}},[E,s,C,S,p,U,q,V,W,M,_,x,w]),Ye(()=>{if(!E||s||!tn(de))return;const je=Cn(de),Ee=ba(je);queueMicrotask(()=>{const Ue=Te(de),Ve=O.current,Be=typeof Ve=="function"?Ve(H.current||""):Ve;if(Be===void 0||Be===!1)return;let oe;Be===!0||Be===null?oe=Ue[0]||de:oe=ii(Be),oe=oe||Ue[0]||de,!Dt(de,Ee)&&Qd(oe,{preventScroll:oe===de})})},[s,E,de,z,Te,O,H]),Ye(()=>{if(s||!de)return;const je=Cn(de),Ee=ba(je);M8(Ee);function Ue(oe){if(oe.open||(B.current=R8(oe.nativeEvent,Y.current)),oe.reason===mi&&oe.nativeEvent.type==="mouseleave"&&(F.current=!0),oe.reason===wy)if(oe.nested)F.current=!1;else if(WC(oe.nativeEvent)||YC(oe.nativeEvent))F.current=!1;else{let ve=!1;document.createElement("div").focus({get preventScroll(){return ve=!0,!1}}),ve?F.current=!1:F.current=!0}}R.on("openchange",Ue);const Ve=je.createElement("span");Ve.setAttribute("tabindex","-1"),Ve.setAttribute("aria-hidden","true"),Object.assign(Ve.style,uT),ie&&C&&C.insertAdjacentElement("afterend",Ve);function Be(){const oe=D.current;let ve=typeof oe=="function"?oe(B.current):oe;if(ve===void 0||ve===!1)return null;if(ve===null&&(ve=!0),typeof ve=="boolean"){const Ne=C||Gm();return Ne&&Ne.isConnected?Ne:Ve}const xe=C||Gm()||Ve;return ii(ve)||xe}return()=>{R.off("openchange",Ue);const oe=ba(je),ve=Dt(S,oe)||W&&Ho(W.nodesRef.current,M(),!1).some(Ne=>Dt(Ne.context?.elements.floating,oe)),xe=Be();queueMicrotask(()=>{const Ne=_8(xe),ke=typeof D.current!="boolean";D.current&&!F.current&&tn(Ne)&&(!(!ke&&Ne!==oe&&oe!==je.body)||ve)&&Ne.focus({preventScroll:!0}),Ve.remove()})}},[s,S,de,D,A,R,W,ie,C,M]),g.useEffect(()=>{queueMicrotask(()=>{F.current=!1})},[s]),g.useEffect(()=>{if(s||!E)return;function je(Ue){Jn(Ue)?.closest(`[${z$}]`)&&(X.current=!0)}const Ee=Cn(de);return Ee.addEventListener("pointerdown",je,!0),()=>{Ee.removeEventListener("pointerdown",je,!0)}},[s,E,de]),Ye(()=>{if(!s&&q)return q.setFocusManagerState({modal:p,closeOnFocusOut:h,open:E,onOpenChange:k.setOpen,domReference:C}),()=>{q.setFocusManagerState(null)}},[s,q,p,E,k,h,C]),Ye(()=>{if(!(s||!de))return Hj(de,U),()=>{queueMicrotask(Ay)}},[s,de,U]);const Ae=!s&&(p?!V:!0)&&(ie||p);return o.jsxs(g.Fragment,{children:[Ae&&o.jsx(_f,{"data-type":"inside",ref:we,onFocus:je=>{if(p){const Ee=Te();Qd(Ee[Ee.length-1])}else q?.portalNode&&(F.current=!1,wc(je,q.portalNode)?rT(C)?.focus():ii(w??q.beforeOutsideRef)?.focus())}}),n,Ae&&o.jsx(_f,{"data-type":"inside",ref:We,onFocus:je=>{p?Qd(Te()[0]):q?.portalNode&&(h&&(F.current=!0),wc(je,q.portalNode)?aT(C)?.focus():ii(x??q.afterOutsideRef)?.focus())}})]})}function qj(e,t,n){let{reference:s,floating:a}=e;const l=Cs(t),u=Ty(t),d=Cy(u),p=ds(t),h=l==="y",m=s.x+s.width/2-a.width/2,y=s.y+s.height/2-a.height/2,x=s[d]/2-a[d]/2;let w;switch(p){case"top":w={x:m,y:s.y-a.height};break;case"bottom":w={x:m,y:s.y+s.height};break;case"right":w={x:s.x+s.width,y};break;case"left":w={x:s.x-a.width,y};break;default:w={x:s.x,y:s.y}}switch(Pa(t)){case"start":w[u]-=x*(n&&h?-1:1);break;case"end":w[u]+=x*(n&&h?-1:1);break}return w}async function D8(e,t){var n;t===void 0&&(t={});const{x:s,y:a,platform:l,rects:u,elements:d,strategy:p}=e,{boundary:h="clippingAncestors",rootBoundary:m="viewport",elementContext:y="floating",altBoundary:x=!1,padding:w=0}=Lr(t,e),j=GC(w),k=d[x?y==="floating"?"reference":"floating":y],E=Cf(await l.getClippingRect({element:(n=await(l.isElement==null?void 0:l.isElement(k)))==null||n?k:k.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(d.floating)),boundary:h,rootBoundary:m,strategy:p})),C=y==="floating"?{x:s,y:a,width:u.floating.width,height:u.floating.height}:u.reference,S=await(l.getOffsetParent==null?void 0:l.getOffsetParent(d.floating)),R=await(l.isElement==null?void 0:l.isElement(S))?await(l.getScale==null?void 0:l.getScale(S))||{x:1,y:1}:{x:1,y:1},A=Cf(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:d,rect:C,offsetParent:S,strategy:p}):C);return{top:(E.top-A.top+j.top)/R.y,bottom:(A.bottom-E.bottom+j.bottom)/R.y,left:(E.left-A.left+j.left)/R.x,right:(A.right-E.right+j.right)/R.x}}const P8=async(e,t,n)=>{const{placement:s="bottom",strategy:a="absolute",middleware:l=[],platform:u}=n,d=l.filter(Boolean),p=await(u.isRTL==null?void 0:u.isRTL(t));let h=await u.getElementRects({reference:e,floating:t,strategy:a}),{x:m,y}=qj(h,s,p),x=s,w={},j=0;for(let k=0;k<d.length;k++){var N;const{name:E,fn:C}=d[k],{x:S,y:R,data:A,reset:M}=await C({x:m,y,initialPlacement:s,placement:x,strategy:a,middlewareData:w,rects:h,platform:{...u,detectOverflow:(N=u.detectOverflow)!=null?N:D8},elements:{reference:e,floating:t}});m=S??m,y=R??y,w={...w,[E]:{...w[E],...A}},M&&j<=50&&(j++,typeof M=="object"&&(M.placement&&(x=M.placement),M.rects&&(h=M.rects===!0?await u.getElementRects({reference:e,floating:t,strategy:a}):M.rects),{x:m,y}=qj(h,x,p)),k=-1)}return{x:m,y,placement:x,strategy:a,middlewareData:w}},z8=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:a,middlewareData:l,rects:u,initialPlacement:d,platform:p,elements:h}=t,{mainAxis:m=!0,crossAxis:y=!0,fallbackPlacements:x,fallbackStrategy:w="bestFit",fallbackAxisSideDirection:j="none",flipAlignment:N=!0,...k}=Lr(e,t);if((n=l.arrow)!=null&&n.alignmentOffset)return{};const E=ds(a),C=Cs(d),S=ds(d)===d,R=await(p.isRTL==null?void 0:p.isRTL(h.floating)),A=x||(S||!N?[Ef(d)]:G6(d)),M=j!=="none";!x&&M&&A.push(...Q6(d,N,j,R));const _=[d,...A],z=await p.detectOverflow(t,k),V=[];let U=((s=l.flip)==null?void 0:s.overflows)||[];if(m&&V.push(z[E]),y){const W=Y6(a,u,R);V.push(z[W[0]],z[W[1]])}if(U=[...U,{placement:a,overflows:V}],!V.every(W=>W<=0)){var O,D;const W=(((O=l.flip)==null?void 0:O.index)||0)+1,q=_[W];if(q&&(!(y==="alignment"?C!==Cs(q):!1)||U.every(F=>Cs(F.placement)===C?F.overflows[0]>0:!0)))return{data:{index:W,overflows:U},reset:{placement:q}};let $=(D=U.filter(L=>L.overflows[0]<=0).sort((L,F)=>L.overflows[1]-F.overflows[1])[0])==null?void 0:D.placement;if(!$)switch(w){case"bestFit":{var H;const L=(H=U.filter(F=>{if(M){const X=Cs(F.placement);return X===C||X==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(X=>X>0).reduce((X,G)=>X+G,0)]).sort((F,X)=>F[1]-X[1])[0])==null?void 0:H[0];L&&($=L);break}case"initialPlacement":$=d;break}if(a!==$)return{reset:{placement:$}}}return{}}}};function Zj(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Wj(e){return H6.some(t=>e[t]>=0)}const L8=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:s}=t,{strategy:a="referenceHidden",...l}=Lr(e,t);switch(a){case"referenceHidden":{const u=await s.detectOverflow(t,{...l,elementContext:"reference"}),d=Zj(u,n.reference);return{data:{referenceHiddenOffsets:d,referenceHidden:Wj(d)}}}case"escaped":{const u=await s.detectOverflow(t,{...l,altBoundary:!0}),d=Zj(u,n.floating);return{data:{escapedOffsets:d,escaped:Wj(d)}}}default:return{}}}}},pT=new Set(["left","top"]);async function $8(e,t){const{placement:n,platform:s,elements:a}=e,l=await(s.isRTL==null?void 0:s.isRTL(a.floating)),u=ds(n),d=Pa(n),p=Cs(n)==="y",h=pT.has(u)?-1:1,m=l&&p?-1:1,y=Lr(t,e);let{mainAxis:x,crossAxis:w,alignmentAxis:j}=typeof y=="number"?{mainAxis:y,crossAxis:0,alignmentAxis:null}:{mainAxis:y.mainAxis||0,crossAxis:y.crossAxis||0,alignmentAxis:y.alignmentAxis};return d&&typeof j=="number"&&(w=d==="end"?j*-1:j),p?{x:w*m,y:x*h}:{x:x*h,y:w*m}}const U8=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:a,y:l,placement:u,middlewareData:d}=t,p=await $8(t,e);return u===((n=d.offset)==null?void 0:n.placement)&&(s=d.arrow)!=null&&s.alignmentOffset?{}:{x:a+p.x,y:l+p.y,data:{...p,placement:u}}}}},B8=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:a,platform:l}=t,{mainAxis:u=!0,crossAxis:d=!1,limiter:p={fn:E=>{let{x:C,y:S}=E;return{x:C,y:S}}},...h}=Lr(e,t),m={x:n,y:s},y=await l.detectOverflow(t,h),x=Cs(ds(a)),w=Ey(x);let j=m[w],N=m[x];if(u){const E=w==="y"?"top":"left",C=w==="y"?"bottom":"right",S=j+y[E],R=j-y[C];j=fv(S,j,R)}if(d){const E=x==="y"?"top":"left",C=x==="y"?"bottom":"right",S=N+y[E],R=N-y[C];N=fv(S,N,R)}const k=p.fn({...t,[w]:j,[x]:N});return{...k,data:{x:k.x-n,y:k.y-s,enabled:{[w]:u,[x]:d}}}}}},V8=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:s,placement:a,rects:l,middlewareData:u}=t,{offset:d=0,mainAxis:p=!0,crossAxis:h=!0}=Lr(e,t),m={x:n,y:s},y=Cs(a),x=Ey(y);let w=m[x],j=m[y];const N=Lr(d,t),k=typeof N=="number"?{mainAxis:N,crossAxis:0}:{mainAxis:0,crossAxis:0,...N};if(p){const S=x==="y"?"height":"width",R=l.reference[x]-l.floating[S]+k.mainAxis,A=l.reference[x]+l.reference[S]-k.mainAxis;w<R?w=R:w>A&&(w=A)}if(h){var E,C;const S=x==="y"?"width":"height",R=pT.has(ds(a)),A=l.reference[y]-l.floating[S]+(R&&((E=u.offset)==null?void 0:E[y])||0)+(R?0:k.crossAxis),M=l.reference[y]+l.reference[S]+(R?0:((C=u.offset)==null?void 0:C[y])||0)-(R?k.crossAxis:0);j<A?j=A:j>M&&(j=M)}return{[x]:w,[y]:j}}}},F8=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,s;const{placement:a,rects:l,platform:u,elements:d}=t,{apply:p=()=>{},...h}=Lr(e,t),m=await u.detectOverflow(t,h),y=ds(a),x=Pa(a),w=Cs(a)==="y",{width:j,height:N}=l.floating;let k,E;y==="top"||y==="bottom"?(k=y,E=x===(await(u.isRTL==null?void 0:u.isRTL(d.floating))?"start":"end")?"left":"right"):(E=y,k=x==="end"?"top":"bottom");const C=N-m.top-m.bottom,S=j-m.left-m.right,R=Jo(N-m[k],C),A=Jo(j-m[E],S),M=!t.middlewareData.shift;let _=R,z=A;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(z=S),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(_=C),M&&!x){const U=cs(m.left,0),O=cs(m.right,0),D=cs(m.top,0),H=cs(m.bottom,0);w?z=j-2*(U!==0||O!==0?U+O:cs(m.left,m.right)):_=N-2*(D!==0||H!==0?D+H:cs(m.top,m.bottom))}await p({...t,availableWidth:z,availableHeight:_});const V=await u.getDimensions(d.floating);return j!==V.width||N!==V.height?{reset:{rects:!0}}:{}}}};function mT(e){const t=hs(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const a=tn(e),l=a?e.offsetWidth:n,u=a?e.offsetHeight:s,d=kf(n)!==l||kf(s)!==u;return d&&(n=l,s=u),{width:n,height:s,$:d}}function Ry(e){return Pt(e)?e:e.contextElement}function Zo(e){const t=Ry(e);if(!tn(t))return ir(1);const n=t.getBoundingClientRect(),{width:s,height:a,$:l}=mT(t);let u=(l?kf(n.width):n.width)/s,d=(l?kf(n.height):n.height)/a;return(!u||!Number.isFinite(u))&&(u=1),(!d||!Number.isFinite(d))&&(d=1),{x:u,y:d}}const H8=ir(0);function gT(e){const t=An(e);return!ch()||!t.visualViewport?H8:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function q8(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==An(e)?!1:t}function Ni(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const a=e.getBoundingClientRect(),l=Ry(e);let u=ir(1);t&&(s?Pt(s)&&(u=Zo(s)):u=Zo(e));const d=q8(l,n,s)?gT(l):ir(0);let p=(a.left+d.x)/u.x,h=(a.top+d.y)/u.y,m=a.width/u.x,y=a.height/u.y;if(l){const x=An(l),w=s&&Pt(s)?An(s):s;let j=x,N=lv(j);for(;N&&s&&w!==j;){const k=Zo(N),E=N.getBoundingClientRect(),C=hs(N),S=E.left+(N.clientLeft+parseFloat(C.paddingLeft))*k.x,R=E.top+(N.clientTop+parseFloat(C.paddingTop))*k.y;p*=k.x,h*=k.y,m*=k.x,y*=k.y,p+=S,h+=R,j=An(N),N=lv(j)}}return Cf({width:m,height:y,x:p,y:h})}function fh(e,t){const n=uh(e).scrollLeft;return t?t.left+n:Ni(dr(e)).left+n}function vT(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-fh(e,n),a=n.top+t.scrollTop;return{x:s,y:a}}function Z8(e){let{elements:t,rect:n,offsetParent:s,strategy:a}=e;const l=a==="fixed",u=dr(s),d=t?lh(t.floating):!1;if(s===u||d&&l)return n;let p={scrollLeft:0,scrollTop:0},h=ir(1);const m=ir(0),y=tn(s);if((y||!y&&!l)&&((Da(s)!=="body"||Ti(u))&&(p=uh(s)),tn(s))){const w=Ni(s);h=Zo(s),m.x=w.x+s.clientLeft,m.y=w.y+s.clientTop}const x=u&&!y&&!l?vT(u,p):ir(0);return{width:n.width*h.x,height:n.height*h.y,x:n.x*h.x-p.scrollLeft*h.x+m.x+x.x,y:n.y*h.y-p.scrollTop*h.y+m.y+x.y}}function W8(e){return Array.from(e.getClientRects())}function Y8(e){const t=dr(e),n=uh(e),s=e.ownerDocument.body,a=cs(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),l=cs(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let u=-n.scrollLeft+fh(e);const d=-n.scrollTop;return hs(s).direction==="rtl"&&(u+=cs(t.clientWidth,s.clientWidth)-a),{width:a,height:l,x:u,y:d}}const Yj=25;function G8(e,t){const n=An(e),s=dr(e),a=n.visualViewport;let l=s.clientWidth,u=s.clientHeight,d=0,p=0;if(a){l=a.width,u=a.height;const m=ch();(!m||m&&t==="fixed")&&(d=a.offsetLeft,p=a.offsetTop)}const h=fh(s);if(h<=0){const m=s.ownerDocument,y=m.body,x=getComputedStyle(y),w=m.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,j=Math.abs(s.clientWidth-y.clientWidth-w);j<=Yj&&(l-=j)}else h<=Yj&&(l+=h);return{width:l,height:u,x:d,y:p}}const K8=new Set(["absolute","fixed"]);function X8(e,t){const n=Ni(e,!0,t==="fixed"),s=n.top+e.clientTop,a=n.left+e.clientLeft,l=tn(e)?Zo(e):ir(1),u=e.clientWidth*l.x,d=e.clientHeight*l.y,p=a*l.x,h=s*l.y;return{width:u,height:d,x:p,y:h}}function Gj(e,t,n){let s;if(t==="viewport")s=G8(e,n);else if(t==="document")s=Y8(dr(e));else if(Pt(t))s=X8(t,n);else{const a=gT(e);s={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return Cf(s)}function yT(e,t){const n=cr(e);return n===t||!Pt(n)||ar(n)?!1:hs(n).position==="fixed"||yT(n,t)}function J8(e,t){const n=t.get(e);if(n)return n;let s=Na(e,[],!1).filter(d=>Pt(d)&&Da(d)!=="body"),a=null;const l=hs(e).position==="fixed";let u=l?cr(e):e;for(;Pt(u)&&!ar(u);){const d=hs(u),p=Sy(u);!p&&d.position==="fixed"&&(a=null),(l?!p&&!a:!p&&d.position==="static"&&!!a&&K8.has(a.position)||Ti(u)&&!p&&yT(e,u))?s=s.filter(m=>m!==u):a=d,u=cr(u)}return t.set(e,s),s}function Q8(e){let{element:t,boundary:n,rootBoundary:s,strategy:a}=e;const u=[...n==="clippingAncestors"?lh(t)?[]:J8(t,this._c):[].concat(n),s],d=u[0],p=u.reduce((h,m)=>{const y=Gj(t,m,a);return h.top=cs(y.top,h.top),h.right=Jo(y.right,h.right),h.bottom=Jo(y.bottom,h.bottom),h.left=cs(y.left,h.left),h},Gj(t,d,a));return{width:p.right-p.left,height:p.bottom-p.top,x:p.left,y:p.top}}function eU(e){const{width:t,height:n}=mT(e);return{width:t,height:n}}function tU(e,t,n){const s=tn(t),a=dr(t),l=n==="fixed",u=Ni(e,!0,l,t);let d={scrollLeft:0,scrollTop:0};const p=ir(0);function h(){p.x=fh(a)}if(s||!s&&!l)if((Da(t)!=="body"||Ti(a))&&(d=uh(t)),s){const w=Ni(t,!0,l,t);p.x=w.x+t.clientLeft,p.y=w.y+t.clientTop}else a&&h();l&&!s&&a&&h();const m=a&&!s&&!l?vT(a,d):ir(0),y=u.left+d.scrollLeft-p.x-m.x,x=u.top+d.scrollTop-p.y-m.y;return{x:y,y:x,width:u.width,height:u.height}}function Km(e){return hs(e).position==="static"}function Kj(e,t){if(!tn(e)||hs(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return dr(e)===n&&(n=n.ownerDocument.body),n}function bT(e,t){const n=An(e);if(lh(e))return n;if(!tn(e)){let a=cr(e);for(;a&&!ar(a);){if(Pt(a)&&!Km(a))return a;a=cr(a)}return n}let s=Kj(e,t);for(;s&&a6(s)&&Km(s);)s=Kj(s,t);return s&&ar(s)&&Km(s)&&!Sy(s)?n:s||u6(e)||n}const nU=async function(e){const t=this.getOffsetParent||bT,n=this.getDimensions,s=await n(e.floating);return{reference:tU(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function sU(e){return hs(e).direction==="rtl"}const rU={convertOffsetParentRelativeRectToViewportRelativeRect:Z8,getDocumentElement:dr,getClippingRect:Q8,getOffsetParent:bT,getElementRects:nU,getClientRects:W8,getDimensions:eU,getScale:Zo,isElement:Pt,isRTL:sU};function xT(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function aU(e,t){let n=null,s;const a=dr(e);function l(){var d;clearTimeout(s),(d=n)==null||d.disconnect(),n=null}function u(d,p){d===void 0&&(d=!1),p===void 0&&(p=1),l();const h=e.getBoundingClientRect(),{left:m,top:y,width:x,height:w}=h;if(d||t(),!x||!w)return;const j=zo(y),N=zo(a.clientWidth-(m+x)),k=zo(a.clientHeight-(y+w)),E=zo(m),S={rootMargin:-j+"px "+-N+"px "+-k+"px "+-E+"px",threshold:cs(0,Jo(1,p))||1};let R=!0;function A(M){const _=M[0].intersectionRatio;if(_!==p){if(!R)return u();_?u(!1,_):s=setTimeout(()=>{u(!1,1e-7)},1e3)}_===1&&!xT(h,e.getBoundingClientRect())&&u(),R=!1}try{n=new IntersectionObserver(A,{...S,root:a.ownerDocument})}catch{n=new IntersectionObserver(A,S)}n.observe(e)}return u(!0),l}function Xj(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:a=!0,ancestorResize:l=!0,elementResize:u=typeof ResizeObserver=="function",layoutShift:d=typeof IntersectionObserver=="function",animationFrame:p=!1}=s,h=Ry(e),m=a||l?[...h?Na(h):[],...Na(t)]:[];m.forEach(E=>{a&&E.addEventListener("scroll",n,{passive:!0}),l&&E.addEventListener("resize",n)});const y=h&&d?aU(h,n):null;let x=-1,w=null;u&&(w=new ResizeObserver(E=>{let[C]=E;C&&C.target===h&&w&&(w.unobserve(t),cancelAnimationFrame(x),x=requestAnimationFrame(()=>{var S;(S=w)==null||S.observe(t)})),n()}),h&&!p&&w.observe(h),w.observe(t));let j,N=p?Ni(e):null;p&&k();function k(){const E=Ni(e);N&&!xT(N,E)&&n(),N=E,j=requestAnimationFrame(k)}return n(),()=>{var E;m.forEach(C=>{a&&C.removeEventListener("scroll",n),l&&C.removeEventListener("resize",n)}),y?.(),(E=w)==null||E.disconnect(),w=null,p&&cancelAnimationFrame(j)}}const iU=U8,oU=B8,lU=z8,cU=F8,uU=L8,dU=V8,fU=(e,t,n)=>{const s=new Map,a={platform:rU,...n},l={...a.platform,_c:s};return P8(e,t,{...a,platform:l})};var hU=typeof document<"u",pU=function(){},ef=hU?g.useLayoutEffect:pU;function Of(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,s,a;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(s=n;s--!==0;)if(!Of(e[s],t[s]))return!1;return!0}if(a=Object.keys(e),n=a.length,n!==Object.keys(t).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(t,a[s]))return!1;for(s=n;s--!==0;){const l=a[s];if(!(l==="_owner"&&e.$$typeof)&&!Of(e[l],t[l]))return!1}return!0}return e!==e&&t!==t}function wT(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Jj(e,t){const n=wT(e);return Math.round(t*n)/n}function Xm(e){const t=g.useRef(e);return ef(()=>{t.current=e}),t}function mU(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:s=[],platform:a,elements:{reference:l,floating:u}={},transform:d=!0,whileElementsMounted:p,open:h}=e,[m,y]=g.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[x,w]=g.useState(s);Of(x,s)||w(s);const[j,N]=g.useState(null),[k,E]=g.useState(null),C=g.useCallback(F=>{F!==M.current&&(M.current=F,N(F))},[]),S=g.useCallback(F=>{F!==_.current&&(_.current=F,E(F))},[]),R=l||j,A=u||k,M=g.useRef(null),_=g.useRef(null),z=g.useRef(m),V=p!=null,U=Xm(p),O=Xm(a),D=Xm(h),H=g.useCallback(()=>{if(!M.current||!_.current)return;const F={placement:t,strategy:n,middleware:x};O.current&&(F.platform=O.current),fU(M.current,_.current,F).then(X=>{const G={...X,isPositioned:D.current!==!1};W.current&&!Of(z.current,G)&&(z.current=G,ji.flushSync(()=>{y(G)}))})},[x,t,n,O,D]);ef(()=>{h===!1&&z.current.isPositioned&&(z.current.isPositioned=!1,y(F=>({...F,isPositioned:!1})))},[h]);const W=g.useRef(!1);ef(()=>(W.current=!0,()=>{W.current=!1}),[]),ef(()=>{if(R&&(M.current=R),A&&(_.current=A),R&&A){if(U.current)return U.current(R,A,H);H()}},[R,A,H,U,V]);const q=g.useMemo(()=>({reference:M,floating:_,setReference:C,setFloating:S}),[C,S]),$=g.useMemo(()=>({reference:R,floating:A}),[R,A]),L=g.useMemo(()=>{const F={position:n,left:0,top:0};if(!$.floating)return F;const X=Jj($.floating,m.x),G=Jj($.floating,m.y);return d?{...F,transform:"translate("+X+"px, "+G+"px)",...wT($.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:X,top:G}},[n,d,$.floating,m.x,m.y]);return g.useMemo(()=>({...m,update:H,refs:q,elements:$,floatingStyles:L}),[m,H,q,$,L])}const gU=(e,t)=>({...iU(e),options:[e,t]}),vU=(e,t)=>({...oU(e),options:[e,t]}),yU=(e,t)=>({...dU(e),options:[e,t]}),bU=(e,t)=>({...lU(e),options:[e,t]}),xU=(e,t)=>({...cU(e),options:[e,t]}),wU=(e,t)=>({...uU(e),options:[e,t]}),jU={intentional:"onClick",sloppy:"onPointerDown"};function SU(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function NU(e,t={}){const n="rootStore"in e?e.rootStore:e,s=n.useState("open"),a=n.useState("floatingElement"),l=n.useState("referenceElement"),u=n.useState("domReferenceElement"),{onOpenChange:d,dataRef:p}=n.context,{enabled:h=!0,escapeKey:m=!0,outsidePress:y=!0,outsidePressEvent:x="sloppy",referencePress:w=!1,referencePressEvent:j="sloppy",ancestorScroll:N=!1,bubbles:k,externalTree:E}=t,C=al(E),S=Ke(typeof y=="function"?y:()=>!1),R=typeof y=="function"?S:y,A=g.useRef(!1),{escapeKey:M,outsidePress:_}=SU(k),z=g.useRef(null),V=Fs(),U=Fs(),O=Ke(()=>{U.clear(),p.current.insideReactTree=!1}),D=g.useRef(!1),H=g.useRef(""),W=Ke(he=>{H.current=he.pointerType}),q=Ke(()=>{const he=H.current,ue=he==="pen"||!he?"mouse":he,we=typeof x=="function"?x():x;return typeof we=="string"?we:we[ue]}),$=Ke(he=>{if(!s||!h||!m||he.key!=="Escape"||D.current)return;const ue=p.current.floatingContext?.nodeId,we=C?Ho(C.nodesRef.current,ue):[];if(!M&&we.length>0){let je=!0;if(we.forEach(Ee=>{Ee.context?.open&&!Ee.context.dataRef.current.__escapeKeyBubbles&&(je=!1)}),!je)return}const We=B6(he)?he.nativeEvent:he,Ae=cn(DC,We);n.setOpen(!1,Ae),!M&&!Ae.isPropagationAllowed&&he.stopPropagation()}),L=Ke(he=>{const ue=q();return ue==="intentional"&&he.type!=="click"||ue==="sloppy"&&he.type==="click"}),F=Ke(()=>{p.current.insideReactTree=!0,U.start(0,O)}),X=Ke((he,ue=!1)=>{if(L(he)){O();return}if(p.current.insideReactTree){O();return}if(q()==="intentional"&&ue||typeof R=="function"&&!R(he))return;const we=Jn(he),We=`[${Dc("inert")}]`,Ae=Cn(n.select("floatingElement")).querySelectorAll(We),je=n.context.triggerElements;if(we&&(je.hasElement(we)||je.hasMatchingElement(oe=>Dt(oe,we))))return;let Ee=Pt(we)?we:null;for(;Ee&&!ar(Ee);){const oe=cr(Ee);if(ar(oe)||!Pt(oe))break;Ee=oe}if(Ae.length&&Pt(we)&&!$6(we)&&!Dt(we,n.select("floatingElement"))&&Array.from(Ae).every(oe=>!Dt(Ee,oe)))return;if(tn(we)&&!("touches"in he)){const oe=ar(we),ve=hs(we),xe=/auto|scroll/,Ne=oe||xe.test(ve.overflowX),ke=oe||xe.test(ve.overflowY),Se=Ne&&we.clientWidth>0&&we.scrollWidth>we.clientWidth,$e=ke&&we.clientHeight>0&&we.scrollHeight>we.clientHeight,Pe=ve.direction==="rtl",xt=$e&&(Pe?he.offsetX<=we.offsetWidth-we.clientWidth:he.offsetX>we.clientWidth),kt=Se&&he.offsetY>we.clientHeight;if(xt||kt)return}const Ue=p.current.floatingContext?.nodeId,Ve=C&&Ho(C.nodesRef.current,Ue).some(oe=>zs(he,oe.context?.elements.floating));if(zs(he,n.select("floatingElement"))||zs(he,n.select("domReferenceElement"))||Ve)return;const Be=C?Ho(C.nodesRef.current,Ue):[];if(Be.length>0){let oe=!0;if(Be.forEach(ve=>{ve.context?.open&&!ve.context.dataRef.current.__outsidePressBubbles&&(oe=!1)}),!oe)return}n.setOpen(!1,cn(wy,he)),O()}),G=Ke(he=>{q()!=="sloppy"||he.pointerType==="touch"||!n.select("open")||!h||zs(he,n.select("floatingElement"))||zs(he,n.select("domReferenceElement"))||X(he)}),I=Ke(he=>{if(q()!=="sloppy"||!n.select("open")||!h||zs(he,n.select("floatingElement"))||zs(he,n.select("domReferenceElement")))return;const ue=he.touches[0];ue&&(z.current={startTime:Date.now(),startX:ue.clientX,startY:ue.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},V.start(1e3,()=>{z.current&&(z.current.dismissOnTouchEnd=!1,z.current.dismissOnMouseDown=!1)}))}),B=Ke(he=>{const ue=Jn(he);function we(){I(he),ue?.removeEventListener(he.type,we)}ue?.addEventListener(he.type,we)}),Y=Ke(he=>{const ue=A.current;if(A.current=!1,V.clear(),he.type==="mousedown"&&z.current&&!z.current.dismissOnMouseDown)return;const we=Jn(he);function We(){he.type==="pointerdown"?G(he):X(he,ue),we?.removeEventListener(he.type,We)}we?.addEventListener(he.type,We)}),Q=Ke(he=>{if(q()!=="sloppy"||!z.current||zs(he,n.select("floatingElement"))||zs(he,n.select("domReferenceElement")))return;const ue=he.touches[0];if(!ue)return;const we=Math.abs(ue.clientX-z.current.startX),We=Math.abs(ue.clientY-z.current.startY),Ae=Math.sqrt(we*we+We*We);Ae>5&&(z.current.dismissOnTouchEnd=!0),Ae>10&&(X(he),V.clear(),z.current=null)}),me=Ke(he=>{const ue=Jn(he);function we(){Q(he),ue?.removeEventListener(he.type,we)}ue?.addEventListener(he.type,we)}),re=Ke(he=>{q()!=="sloppy"||!z.current||zs(he,n.select("floatingElement"))||zs(he,n.select("domReferenceElement"))||(z.current.dismissOnTouchEnd&&X(he),V.clear(),z.current=null)}),ie=Ke(he=>{const ue=Jn(he);function we(){re(he),ue?.removeEventListener(he.type,we)}ue?.addEventListener(he.type,we)});g.useEffect(()=>{if(!s||!h)return;p.current.__escapeKeyBubbles=M,p.current.__outsidePressBubbles=_;const he=new Xo;function ue(Ee){n.setOpen(!1,cn(X$,Ee))}function we(){he.clear(),D.current=!0}function We(){he.start(ch()?5:0,()=>{D.current=!1})}const Ae=Cn(a);Ae.addEventListener("pointerdown",W,!0),m&&(Ae.addEventListener("keydown",$),Ae.addEventListener("compositionstart",we),Ae.addEventListener("compositionend",We)),R&&(Ae.addEventListener("click",Y,!0),Ae.addEventListener("pointerdown",Y,!0),Ae.addEventListener("touchstart",B,!0),Ae.addEventListener("touchmove",me,!0),Ae.addEventListener("touchend",ie,!0),Ae.addEventListener("mousedown",Y,!0));let je=[];return N&&(Pt(u)&&(je=Na(u)),Pt(a)&&(je=je.concat(Na(a))),!Pt(l)&&l&&l.contextElement&&(je=je.concat(Na(l.contextElement)))),je=je.filter(Ee=>Ee!==Ae.defaultView?.visualViewport),je.forEach(Ee=>{Ee.addEventListener("scroll",ue,{passive:!0})}),()=>{Ae.removeEventListener("pointerdown",W,!0),m&&(Ae.removeEventListener("keydown",$),Ae.removeEventListener("compositionstart",we),Ae.removeEventListener("compositionend",We)),R&&(Ae.removeEventListener("click",Y,!0),Ae.removeEventListener("pointerdown",Y,!0),Ae.removeEventListener("touchstart",B,!0),Ae.removeEventListener("touchmove",me,!0),Ae.removeEventListener("touchend",ie,!0),Ae.removeEventListener("mousedown",Y,!0)),je.forEach(Ee=>{Ee.removeEventListener("scroll",ue)}),he.clear()}},[p,a,l,u,m,R,s,d,N,h,M,_,$,X,Y,G,B,me,ie,W,n]),g.useEffect(O,[R,O]);const de=g.useMemo(()=>({onKeyDown:$,...w&&{[jU[j]]:he=>{n.setOpen(!1,cn(Sf,he.nativeEvent))},...j!=="intentional"&&{onClick(he){n.setOpen(!1,cn(Sf,he.nativeEvent))}}}}),[$,n,w,j]),ye=Ke(he=>{const ue=Jn(he.nativeEvent);!Dt(n.select("floatingElement"),ue)||he.button!==0||(A.current=!0)}),Te=g.useMemo(()=>({onKeyDown:$,onPointerDown:ye,onMouseDown:ye,onMouseUp:ye,onClickCapture:F,onMouseDownCapture:F,onPointerDownCapture:F,onMouseUpCapture:F,onTouchEndCapture:F,onTouchMoveCapture:F}),[$,ye,F]);return g.useMemo(()=>h?{reference:de,floating:Te,trigger:de}:{},[h,de,Te])}var If=Symbol("NOT_FOUND");function kU(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function EU(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function CU(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(n=>typeof n=="function")){const n=e.map(s=>typeof s=="function"?`function ${s.name||"unnamed"}()`:typeof s).join(", ");throw new TypeError(`${t}[${n}]`)}}var Qj=e=>Array.isArray(e)?e:[e];function TU(e){const t=Array.isArray(e[0])?e[0]:e;return CU(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function AU(e,t){const n=[],{length:s}=e;for(let a=0;a<s;a++)n.push(e[a].apply(null,t));return n}function RU(e){let t;return{get(n){return t&&e(t.key,n)?t.value:If},put(n,s){t={key:n,value:s}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function MU(e,t){let n=[];function s(d){const p=n.findIndex(h=>t(d,h.key));if(p>-1){const h=n[p];return p>0&&(n.splice(p,1),n.unshift(h)),h.value}return If}function a(d,p){s(d)===If&&(n.unshift({key:d,value:p}),n.length>e&&n.pop())}function l(){return n}function u(){n=[]}return{get:s,put:a,getEntries:l,clear:u}}var _U=(e,t)=>e===t;function OU(e){return function(n,s){if(n===null||s===null||n.length!==s.length)return!1;const{length:a}=n;for(let l=0;l<a;l++)if(!e(n[l],s[l]))return!1;return!0}}function IU(e,t){const n=typeof t=="object"?t:{equalityCheck:t},{equalityCheck:s=_U,maxSize:a=1,resultEqualityCheck:l}=n,u=OU(s);let d=0;const p=a<=1?RU(u):MU(a,u);function h(){let m=p.get(arguments);if(m===If){if(m=e.apply(null,arguments),d++,l){const x=p.getEntries().find(w=>l(w.value,m));x&&(m=x.value,d!==0&&d--)}p.put(arguments,m)}return m}return h.clearCache=()=>{p.clear(),h.resetResultsCount()},h.resultsCount=()=>d,h.resetResultsCount=()=>{d=0},h}var DU=class{constructor(e){this.value=e}deref(){return this.value}},PU=typeof WeakRef<"u"?WeakRef:DU,zU=0,eS=1;function Ed(){return{s:zU,v:void 0,o:null,p:null}}function jT(e,t={}){let n=Ed();const{resultEqualityCheck:s}=t;let a,l=0;function u(){let d=n;const{length:p}=arguments;for(let y=0,x=p;y<x;y++){const w=arguments[y];if(typeof w=="function"||typeof w=="object"&&w!==null){let j=d.o;j===null&&(d.o=j=new WeakMap);const N=j.get(w);N===void 0?(d=Ed(),j.set(w,d)):d=N}else{let j=d.p;j===null&&(d.p=j=new Map);const N=j.get(w);N===void 0?(d=Ed(),j.set(w,d)):d=N}}const h=d;let m;if(d.s===eS)m=d.v;else if(m=e.apply(null,arguments),l++,s){const y=a?.deref?.()??a;y!=null&&s(y,m)&&(m=y,l!==0&&l--),a=typeof m=="object"&&m!==null||typeof m=="function"?new PU(m):m}return h.s=eS,h.v=m,m}return u.clearCache=()=>{n=Ed(),u.resetResultsCount()},u.resultsCount=()=>l,u.resetResultsCount=()=>{l=0},u}function ST(e,...t){const n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,s=(...a)=>{let l=0,u=0,d,p={},h=a.pop();typeof h=="object"&&(p=h,h=a.pop()),kU(h,`createSelector expects an output function after the inputs, but received: [${typeof h}]`);const m={...n,...p},{memoize:y,memoizeOptions:x=[],argsMemoize:w=jT,argsMemoizeOptions:j=[]}=m,N=Qj(x),k=Qj(j),E=TU(a),C=y(function(){return l++,h.apply(null,arguments)},...N),S=w(function(){u++;const A=AU(E,arguments);return d=C.apply(null,A),d},...k);return Object.assign(S,{resultFunc:h,memoizedResultFunc:C,dependencies:E,dependencyRecomputations:()=>u,resetDependencyRecomputations:()=>{u=0},lastResult:()=>d,recomputations:()=>l,resetRecomputations:()=>{l=0},memoize:y,argsMemoize:w})};return Object.assign(s,{withTypes:()=>s}),s}var LU=ST(jT),$U=Object.assign((e,t=LU)=>{EU(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);const n=Object.keys(e),s=n.map(l=>e[l]);return t(s,(...l)=>l.reduce((u,d,p)=>(u[n[p]]=d,u),{}))},{withTypes:()=>$U});ST({memoize:IU,memoizeOptions:{maxSize:1,equalityCheck:Object.is}});const tt=(e,t,n,s,a,l,...u)=>{if(u.length>0)throw new Error(Ci(1));let d;if(e)d=e;else throw new Error("Missing arguments");return d};var Jm={exports:{}},Qm={};var tS;function UU(){if(tS)return Qm;tS=1;var e=qc();function t(y,x){return y===x&&(y!==0||1/y===1/x)||y!==y&&x!==x}var n=typeof Object.is=="function"?Object.is:t,s=e.useState,a=e.useEffect,l=e.useLayoutEffect,u=e.useDebugValue;function d(y,x){var w=x(),j=s({inst:{value:w,getSnapshot:x}}),N=j[0].inst,k=j[1];return l(function(){N.value=w,N.getSnapshot=x,p(N)&&k({inst:N})},[y,w,x]),a(function(){return p(N)&&k({inst:N}),y(function(){p(N)&&k({inst:N})})},[y]),u(w),w}function p(y){var x=y.getSnapshot;y=y.value;try{var w=x();return!n(y,w)}catch{return!0}}function h(y,x){return x()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:d;return Qm.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:m,Qm}var nS;function NT(){return nS||(nS=1,Jm.exports=UU()),Jm.exports}var BU=NT(),eg={exports:{}},tg={};var sS;function VU(){if(sS)return tg;sS=1;var e=qc(),t=NT();function n(h,m){return h===m&&(h!==0||1/h===1/m)||h!==h&&m!==m}var s=typeof Object.is=="function"?Object.is:n,a=t.useSyncExternalStore,l=e.useRef,u=e.useEffect,d=e.useMemo,p=e.useDebugValue;return tg.useSyncExternalStoreWithSelector=function(h,m,y,x,w){var j=l(null);if(j.current===null){var N={hasValue:!1,value:null};j.current=N}else N=j.current;j=d(function(){function E(M){if(!C){if(C=!0,S=M,M=x(M),w!==void 0&&N.hasValue){var _=N.value;if(w(_,M))return R=_}return R=M}if(_=R,s(S,M))return _;var z=x(M);return w!==void 0&&w(_,z)?(S=M,_):(S=M,R=z)}var C=!1,S,R,A=y===void 0?null:y;return[function(){return E(m())},A===null?void 0:function(){return E(A())}]},[m,y,x,w]);var k=a(h,j[0],j[1]);return u(function(){N.hasValue=!0,N.value=k},[k]),p(k),k},tg}var rS;function FU(){return rS||(rS=1,eg.exports=VU()),eg.exports}var HU=FU();const qU=by(19),ZU=qU?YU:GU;function WU(e,t,n,s,a){return ZU(e,t,n,s,a)}function YU(e,t,n,s,a){const l=g.useCallback(()=>t(e.getSnapshot(),n,s,a),[e,t,n,s,a]);return BU.useSyncExternalStore(e.subscribe,l,l)}function GU(e,t,n,s,a){return HU.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,l=>t(l,n,s,a))}class jc{constructor(t){this.state=t,this.listeners=new Set,this.updateTick=0}subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t)});getSnapshot=()=>this.state;setState(t){if(this.state===t)return;this.state=t,this.updateTick+=1;const n=this.updateTick;for(const s of this.listeners){if(n!==this.updateTick)return;s(t)}}update(t){for(const n in t)if(!Object.is(this.state[n],t[n])){jc.prototype.setState.call(this,{...this.state,...t});return}}set(t,n){Object.is(this.state[t],n)||jc.prototype.setState.call(this,{...this.state,[t]:n})}notifyAll(){const t={...this.state};jc.prototype.setState.call(this,t)}}class kT extends jc{constructor(t,n={},s){super(t),this.context=n,this.selectors=s}controlledValues=new Map;useSyncedValue(t,n){g.useDebugValue(t),Ye(()=>{this.state[t]!==n&&this.set(t,n)},[t,n])}useSyncedValueWithCleanup(t,n){Ye(()=>(this.state[t]!==n&&this.set(t,n),()=>{this.set(t,void 0)}),[t,n])}useSyncedValues(t){const n=Object.values(t);Ye(()=>{this.update(t)},n)}useControlledProp(t,n,s){g.useDebugValue(t);const a=n!==void 0;this.controlledValues.has(t)||(this.controlledValues.set(t,a),!a&&!Object.is(this.state[t],s)&&super.setState({...this.state,[t]:s})),Ye(()=>{a&&!Object.is(this.state[t],n)&&super.setState({...this.state,[t]:n})},[t,n,s,a])}set(t,n){this.controlledValues.get(t)!==!0&&super.set(t,n)}update(t){const n={...t};for(const s in n)if(Object.hasOwn(n,s)&&this.controlledValues.get(s)===!0){delete n[s];continue}super.update(n)}setState(t){const n={...t};for(const s in n)if(Object.hasOwn(n,s)&&this.controlledValues.get(s)===!0){delete n[s];continue}super.setState({...this.state,...n})}select=(t,n,s,a)=>{const l=this.selectors[t];return l(this.state,n,s,a)};useState=(t,n,s,a)=>{g.useDebugValue(t);const l=this.selectors[t];return WU(this,l,n,s,a)};useContextCallback(t,n){g.useDebugValue(t);const s=Ke(n??MC);this.context[t]=s}useStateSetter(t){const n=g.useRef(void 0);return n.current===void 0&&(n.current=s=>{this.set(t,s)}),n.current}observe(t,n){let s;typeof t=="function"?s=t:s=this.selectors[t];let a=s(this.state);return n(a,a,this),this.subscribe(l=>{const u=s(l);if(!Object.is(a,u)){const d=a;a=u,n(u,d,this)}})}}const KU={open:tt(e=>e.open),domReferenceElement:tt(e=>e.domReferenceElement),referenceElement:tt(e=>e.positionReference??e.referenceElement),floatingElement:tt(e=>e.floatingElement),floatingId:tt(e=>e.floatingId)};class My extends kT{constructor(t){const{nested:n,noEmit:s,onOpenChange:a,triggerElements:l,...u}=t;super({...u,positionReference:u.referenceElement,domReferenceElement:u.referenceElement},{onOpenChange:a,dataRef:{current:{}},events:iT(),nested:n,noEmit:s,triggerElements:l},KU)}setOpen=(t,n)=>{if((!t||!this.state.open||F6(n.event))&&(this.context.dataRef.current.openEvent=t?n.event:void 0),!this.context.noEmit){const s={open:t,reason:n.reason,nativeEvent:n.event,nested:this.context.nested,triggerElement:n.trigger};this.context.events.emit("openchange",s)}this.context.onOpenChange?.(t,n)}}function XU(e){const t=e.useState("open");Ye(()=>{if(t&&!e.select("activeTriggerId")&&e.context.triggerElements.size===1){const n=e.context.triggerElements.entries().next();if(!n.done){const[s,a]=n.value;e.update({activeTriggerId:s,activeTriggerElement:a})}}},[t,e])}function JU(e,t,n){const{mounted:s,setMounted:a,transitionStatus:l}=k6(e);t.useSyncedValues({mounted:s,transitionStatus:l});const u=Ke(()=>{a(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)}),d=t.useState("preventUnmountingOnClose");return UC({enabled:!d,open:e,ref:t.context.popupRef,onComplete(){e||u()}}),{forceUnmount:u,transitionStatus:l}}class _y{constructor(){this.elements=new Set,this.idMap=new Map}add(t,n){const s=this.idMap.get(t);s!==n&&(s!==void 0&&this.elements.delete(s),this.elements.add(n),this.idMap.set(t,n))}delete(t){const n=this.idMap.get(t);n&&(this.elements.delete(n),this.idMap.delete(t))}hasElement(t){return this.elements.has(t)}hasMatchingElement(t){for(const n of this.elements)if(t(n))return!0;return!1}getById(t){return this.idMap.get(t)}entries(){return this.idMap.entries()}get size(){return this.idMap.size}}function QU(){return new My({open:!1,floatingElement:null,referenceElement:null,triggerElements:new _y,floatingId:"",nested:!1,noEmit:!1,onOpenChange:void 0})}function eB(){return{open:!1,mounted:!1,transitionStatus:"idle",floatingRootContext:QU(),preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,popupElement:null,positionerElement:null,activeTriggerProps:Qn,inactiveTriggerProps:Qn,popupProps:Qn}}const tB={open:tt(e=>e.open),mounted:tt(e=>e.mounted),transitionStatus:tt(e=>e.transitionStatus),floatingRootContext:tt(e=>e.floatingRootContext),preventUnmountingOnClose:tt(e=>e.preventUnmountingOnClose),payload:tt(e=>e.payload),activeTriggerId:tt(e=>e.activeTriggerId),activeTriggerElement:tt(e=>e.mounted?e.activeTriggerElement:null),isTriggerActive:tt((e,t)=>t!==void 0&&e.activeTriggerId===t),isOpenedByTrigger:tt((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.open),isMountedByTrigger:tt((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.mounted),triggerProps:tt((e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps),popupProps:tt(e=>e.popupProps),popupElement:tt(e=>e.popupElement),positionerElement:tt(e=>e.positionerElement)};function nB(e){const{open:t=!1,onOpenChange:n,elements:s={}}=e,a=Oa(),l=za()!=null,u=Rs(()=>new My({open:t,onOpenChange:n,referenceElement:s.reference??null,floatingElement:s.floating??null,triggerElements:s.triggers??new _y,floatingId:a,nested:l,noEmit:e.noEmit||!1})).current;return Ye(()=>{const d={open:t,floatingId:a};s.reference!==void 0&&(d.referenceElement=s.reference,d.domReferenceElement=Pt(s.reference)?s.reference:null),s.floating!==void 0&&(d.floatingElement=s.floating),u.update(d)},[t,a,s.reference,s.floating,u]),u.context.onOpenChange=n,u.context.nested=l,u.context.noEmit=e.noEmit||!1,u}function sB(e={}){const{nodeId:t,externalTree:n}=e,s=nB(e),a=e.rootContext||s,l={reference:a.useState("referenceElement"),floating:a.useState("floatingElement"),domReference:a.useState("domReferenceElement")},[u,d]=g.useState(null),p=g.useRef(null),h=al(n);Ye(()=>{l.domReference&&(p.current=l.domReference)},[l.domReference]);const m=mU({...e,elements:{...l,...u&&{reference:u}}}),y=g.useCallback(_=>{const z=Pt(_)?{getBoundingClientRect:()=>_.getBoundingClientRect(),getClientRects:()=>_.getClientRects(),contextElement:_}:_;d(z),m.refs.setReference(z)},[m.refs]),[x,w]=g.useState(null),[j,N]=g.useState(null);a.useSyncedValue("referenceElement",x),a.useSyncedValue("domReferenceElement",Pt(x)?x:null),a.useSyncedValue("floatingElement",j);const k=g.useCallback(_=>{(Pt(_)||_===null)&&(p.current=_,w(_)),(Pt(m.refs.reference.current)||m.refs.reference.current===null||_!==null&&!Pt(_))&&m.refs.setReference(_)},[m.refs,w]),E=g.useCallback(_=>{N(_),m.refs.setFloating(_)},[m.refs]),C=g.useMemo(()=>({...m.refs,setReference:k,setFloating:E,setPositionReference:y,domReference:p}),[m.refs,k,E,y]),S=g.useMemo(()=>({...m.elements,domReference:l.domReference}),[m.elements,l.domReference]),R=a.useState("open"),A=a.useState("floatingId"),M=g.useMemo(()=>({...m,dataRef:a.context.dataRef,open:R,onOpenChange:a.setOpen,events:a.context.events,floatingId:A,refs:C,elements:S,nodeId:t,rootStore:a}),[m,C,S,t,a,R,A]);return Ye(()=>{a.context.dataRef.current.floatingContext=M;const _=h?.nodesRef.current.find(z=>z.id===t);_&&(_.context=M)}),g.useMemo(()=>({...m,context:M,refs:C,elements:S,rootStore:a}),[m,C,S,M,a])}function rB(e){const{popupStore:t,noEmit:n=!1,treatPopupAsFloatingElement:s=!1,onOpenChange:a}=e,l=Oa(),u=za()!=null,d=t.useState("open"),p=t.useState("activeTriggerElement"),h=t.useState(s?"popupElement":"positionerElement"),m=t.context.triggerElements,y=Rs(()=>new My({open:d,referenceElement:p,floatingElement:h,triggerElements:m,onOpenChange:a,floatingId:l,nested:u,noEmit:n})).current;return Ye(()=>{const x={open:d,floatingId:l,referenceElement:p,floatingElement:h};Pt(p)&&(x.domReferenceElement=p),y.update(x)},[d,l,p,h,y]),y.context.onOpenChange=a,y.context.nested=u,y.context.noEmit=n,y}const aS=Dc("safe-polygon"),aB=`button,a,[role="button"],select,[tabindex]:not([tabindex="-1"]),${ZC}`;function iB(e){return e?!!e.closest(aB):!1}function oB(e){const t=g.useRef(void 0),n=g.useRef(!1),s=g.useRef(void 0),a=g.useRef(!0),l=g.useRef(!1),u=g.useRef(()=>{}),d=g.useRef(!1),p=Fs(),h=Fs(),m=g.useRef(void 0);return g.useMemo(()=>{const y=e.context.dataRef.current;return y.hoverInteractionState||(y.hoverInteractionState={pointerTypeRef:t,interactedInsideRef:n,handlerRef:s,blockMouseMoveRef:a,performedPointerEventsMutationRef:l,unbindMouseMoveRef:u,restTimeoutPendingRef:d,openChangeTimeout:p,restTimeout:h,handleCloseOptionsRef:m}),y.hoverInteractionState},[e,t,n,s,a,l,u,d,p,h,m])}const lB=new Set(["click","mousedown"]);function cB(e,t={}){const n="rootStore"in e?e.rootStore:e,s=n.useState("open"),a=n.useState("floatingElement"),l=n.useState("domReferenceElement"),{dataRef:u}=n.context,{enabled:d=!0,closeDelay:p=0,externalTree:h}=t,{pointerTypeRef:m,interactedInsideRef:y,handlerRef:x,performedPointerEventsMutationRef:w,unbindMouseMoveRef:j,restTimeoutPendingRef:N,openChangeTimeout:k,handleCloseOptionsRef:E}=oB(n),C=al(h),S=za(),R=Ke(()=>y.current?!0:u.current.openEvent?lB.has(u.current.openEvent.type):!1),A=Ke(()=>{const U=u.current.openEvent?.type;return U?.includes("mouse")&&U!=="mousedown"}),M=g.useCallback((U,O=!0)=>{const D=uB(p,m.current);D&&!x.current?k.start(D,()=>n.setOpen(!1,cn(mi,U))):O&&(k.clear(),n.setOpen(!1,cn(mi,U)))},[p,x,n,m,k]),_=Ke(()=>{j.current(),x.current=void 0}),z=Ke(()=>{if(w.current){const U=Cn(a).body;U.style.pointerEvents="",U.removeAttribute(aS),w.current=!1}}),V=Ke(U=>{const O=Jn(U);if(!iB(O)){y.current=!1;return}y.current=!0});Ye(()=>{s||(m.current=void 0,N.current=!1,y.current=!1,_(),z())},[s,m,N,y,_,z]),g.useEffect(()=>()=>{_()},[_]),g.useEffect(()=>z,[z]),Ye(()=>{if(d&&s&&E.current?.blockPointerEvents&&A()&&Pt(l)&&a){w.current=!0;const U=Cn(a).body;U.setAttribute(aS,"");const O=l,D=a,H=C?.nodesRef.current.find(W=>W.id===S)?.context?.elements.floating;return H&&(H.style.pointerEvents=""),U.style.pointerEvents="none",O.style.pointerEvents="auto",D.style.pointerEvents="auto",()=>{U.style.pointerEvents="",O.style.pointerEvents="",D.style.pointerEvents=""}}},[d,s,l,a,E,A,C,S,w]),g.useEffect(()=>{if(!d)return;function U(W){if(R()||!u.current.floatingContext)return;const q=n.context.triggerElements;W.relatedTarget&&q.hasElement(W.relatedTarget)||(z(),_(),R()||M(W))}function O(W){k.clear(),z(),x.current?.(W),_()}function D(W){R()||M(W,!1)}const H=a;return H&&(H.addEventListener("mouseleave",U),H.addEventListener("mouseenter",O),H.addEventListener("mouseleave",D),H.addEventListener("pointerdown",V,!0)),()=>{H&&(H.removeEventListener("mouseleave",U),H.removeEventListener("mouseenter",O),H.removeEventListener("mouseleave",D),H.removeEventListener("pointerdown",V,!0))}})}function uB(e,t){return t&&!V6(t)?0:typeof e=="function"?e():e}function dB(e=[]){const t=e.map(h=>h?.reference),n=e.map(h=>h?.floating),s=e.map(h=>h?.item),a=e.map(h=>h?.trigger),l=g.useCallback(h=>Cd(h,e,"reference"),t),u=g.useCallback(h=>Cd(h,e,"floating"),n),d=g.useCallback(h=>Cd(h,e,"item"),s),p=g.useCallback(h=>Cd(h,e,"trigger"),a);return g.useMemo(()=>({getReferenceProps:l,getFloatingProps:u,getItemProps:d,getTriggerProps:p}),[l,u,d,p])}function Cd(e,t,n){const s=new Map,a=n==="item",l={};n==="floating"&&(l.tabIndex=-1,l[uv]="");for(const u in e)a&&e&&(u===HC||u===qC)||(l[u]=e[u]);for(let u=0;u<t.length;u+=1){let d;const p=t[u]?.[n];typeof p=="function"?d=e?p(e):null:d=p,d&&iS(l,d,a,s)}return iS(l,e,a,s),l}function iS(e,t,n,s){for(const a in t){const l=t[a];n&&(a===HC||a===qC)||(a.startsWith("on")?(s.has(a)||s.set(a,[]),typeof l=="function"&&(s.get(a)?.push(l),e[a]=(...u)=>s.get(a)?.map(d=>d(...u)).find(d=>d!==void 0))):e[a]=l)}}const fB="Escape";function hh(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function Td(e,t){return hh(t,e===ky||e===Gc,e===ka||e===Ea)}function ng(e,t,n){return hh(t,e===Gc,n?e===ka:e===Ea)||e==="Enter"||e===" "||e===""}function hB(e,t,n){return hh(t,n?e===ka:e===Ea,e===Gc)}function pB(e,t,n,s){const a=n?e===Ea:e===ka,l=e===ky;return t==="both"||t==="horizontal"&&s&&s>1?e===fB:hh(t,a,l)}function mB(e,t){const n="rootStore"in e?e.rootStore:e,s=n.useState("open"),a=n.useState("floatingElement"),l=n.useState("domReferenceElement"),u=n.context.dataRef,{listRef:d,activeIndex:p,onNavigate:h=()=>{},enabled:m=!0,selectedIndex:y=null,allowEscape:x=!1,loopFocus:w=!1,nested:j=!1,rtl:N=!1,virtual:k=!1,focusItemOnOpen:E="auto",focusItemOnHover:C=!0,openOnArrowKeyDown:S=!0,disabledIndices:R=void 0,orientation:A="vertical",parentOrientation:M,cols:_=1,scrollItemIntoView:z=!0,itemSizes:V,dense:U=!1,id:O,resetOnPointerLeave:D=!0,externalTree:H}=t,W=Nf(a),q=Xn(W),$=za(),L=al(H);Ye(()=>{u.current.orientation=A},[u,A]);const F=dv(l),X=g.useRef(E),G=g.useRef(y??-1),I=g.useRef(null),B=g.useRef(!0),Y=Ke(xe=>{h(G.current===-1?null:G.current,xe)}),Q=g.useRef(Y),me=g.useRef(!!a),re=g.useRef(s),ie=g.useRef(!1),de=g.useRef(!1),ye=Xn(R),Te=Xn(s),he=Xn(z),ue=Xn(y),we=Xn(D),We=Ke(()=>{function xe($e){k?L?.events.emit("virtualfocus",$e):Qd($e,{sync:ie.current,preventScroll:!0})}const Ne=d.current[G.current],ke=de.current;Ne&&xe(Ne),(ie.current?$e=>$e():requestAnimationFrame)(()=>{const $e=d.current[G.current]||Ne;if(!$e)return;Ne||xe($e);const Pe=he.current;Pe&&je&&(ke||!B.current)&&$e.scrollIntoView?.(typeof Pe=="boolean"?{block:"nearest",inline:"nearest"}:Pe)})});Ye(()=>{m&&(s&&a?(G.current=y??-1,X.current&&y!=null&&(de.current=!0,Y())):me.current&&(G.current=-1,Q.current()))},[m,s,a,y,Y]),Ye(()=>{if(m){if(!s){ie.current=!1;return}if(a)if(p==null){if(ie.current=!1,ue.current!=null)return;if(me.current&&(G.current=-1,We()),(!re.current||!me.current)&&X.current&&(I.current!=null||X.current===!0&&I.current==null)){let xe=0;const Ne=()=>{d.current[0]==null?(xe<2&&(xe?requestAnimationFrame:queueMicrotask)(Ne),xe+=1):(G.current=I.current==null||ng(I.current,A,N)||j?Wm(d):Lj(d),I.current=null,Y())};Ne()}}else bc(d,p)||(G.current=p,We(),de.current=!1)}},[m,s,a,p,ue,j,d,A,N,Y,We,ye]),Ye(()=>{if(!m||a||!L||k||!me.current)return;const xe=L.nodesRef.current,Ne=xe.find($e=>$e.id===$)?.context?.elements.floating,ke=ba(Cn(a)),Se=xe.some($e=>$e.context&&Dt($e.context.elements.floating,ke));Ne&&!Se&&B.current&&Ne.focus({preventScroll:!0})},[m,a,L,$,k]),Ye(()=>{Q.current=Y,re.current=s,me.current=!!a}),Ye(()=>{s||(I.current=null,X.current=E)},[s,E]);const Ae=p!=null,je=g.useMemo(()=>{function xe(ke){if(!Te.current)return;const Se=d.current.indexOf(ke.currentTarget);Se!==-1&&G.current!==Se&&(G.current=Se,Y(ke))}return{onFocus(ke){ie.current=!0,xe(ke)},onClick:({currentTarget:ke})=>ke.focus({preventScroll:!0}),onMouseMove(ke){ie.current=!0,de.current=!1,C&&xe(ke)},onPointerLeave(ke){if(!Te.current||!B.current||ke.pointerType==="touch")return;ie.current=!0;const Se=ke.relatedTarget;!C||d.current.includes(Se)||we.current&&(G.current=-1,Y(ke),k||q.current?.focus({preventScroll:!0}))}}},[Te,q,C,d,Y,we,k]),Ee=g.useCallback(()=>M??L?.nodesRef.current.find(xe=>xe.id===$)?.context?.dataRef?.current.orientation,[$,L,M]),Ue=Ke(xe=>{if(B.current=!1,ie.current=!0,xe.which===229||!Te.current&&xe.currentTarget===q.current)return;if(j&&pB(xe.key,A,N,_)){Td(xe.key,Ee())||Tn(xe),n.setOpen(!1,cn(Jd,xe.nativeEvent)),tn(l)&&(k?L?.events.emit("virtualfocus",l):l.focus());return}const Ne=G.current,ke=Wm(d,R),Se=Lj(d,R);if(F||(xe.key==="Home"&&(Tn(xe),G.current=ke,Y(xe)),xe.key==="End"&&(Tn(xe),G.current=Se,Y(xe))),_>1){const $e=V||Array.from({length:d.current.length},()=>({width:1,height:1})),Pe=n8($e,_,U),xt=Pe.findIndex(Xt=>Xt!=null&&!xc(d,Xt,R)),kt=Pe.reduce((Xt,Jt,ze)=>Jt!=null&&!xc(d,Jt,R)?ze:Xt,-1),un=Pe[t8({current:Pe.map(Xt=>Xt!=null?d.current[Xt]:null)},{event:xe,orientation:A,loopFocus:w,rtl:N,cols:_,disabledIndices:r8([...(typeof R!="function"?R:null)||d.current.map((Xt,Jt)=>xc(d,Jt,R)?Jt:void 0),void 0],Pe),minIndex:xt,maxIndex:kt,prevIndex:s8(G.current>Se?ke:G.current,$e,Pe,_,xe.key===Gc?"bl":xe.key===(N?ka:Ea)?"tr":"tl"),stopEvent:!0})];if(un!=null&&(G.current=un,Y(xe)),A==="both")return}if(Td(xe.key,A)){if(Tn(xe),s&&!k&&ba(xe.currentTarget.ownerDocument)===xe.currentTarget){G.current=ng(xe.key,A,N)?ke:Se,Y(xe);return}ng(xe.key,A,N)?w?Ne>=Se?x&&Ne!==d.current.length?G.current=-1:(ie.current=!1,G.current=ke):G.current=On(d,{startingIndex:Ne,disabledIndices:R}):G.current=Math.min(Se,On(d,{startingIndex:Ne,disabledIndices:R})):w?Ne<=ke?x&&Ne!==-1?G.current=d.current.length:(ie.current=!1,G.current=Se):G.current=On(d,{startingIndex:Ne,decrement:!0,disabledIndices:R}):G.current=Math.max(ke,On(d,{startingIndex:Ne,decrement:!0,disabledIndices:R})),bc(d,G.current)&&(G.current=-1),Y(xe)}}),Ve=g.useMemo(()=>k&&s&&Ae&&{"aria-activedescendant":`${O}-${p}`},[k,s,Ae,O,p]),Be=g.useMemo(()=>({"aria-orientation":A==="both"?void 0:A,...F?{}:Ve,onKeyDown(xe){if(xe.key==="Tab"&&xe.shiftKey&&s&&!k){const Ne=Jn(xe.nativeEvent);if(Ne&&!Dt(q.current,Ne))return;Tn(xe),n.setOpen(!1,cn(ih,xe.nativeEvent)),tn(l)&&l.focus();return}Ue(xe)},onPointerMove(){B.current=!0}}),[Ve,Ue,q,A,F,n,s,k,l]),oe=g.useMemo(()=>{function xe(ke){E==="auto"&&WC(ke.nativeEvent)&&(X.current=!k)}function Ne(ke){X.current=E,E==="auto"&&YC(ke.nativeEvent)&&(X.current=!0)}return{onKeyDown(ke){const Se=n.select("open");B.current=!1;const $e=ke.key.startsWith("Arrow"),Pe=hB(ke.key,Ee(),N),xt=Td(ke.key,A),kt=(j?Pe:xt)||ke.key==="Enter"||ke.key.trim()==="";if(k&&Se)return Ue(ke);if(!(!Se&&!S&&$e)){if(kt){const un=Td(ke.key,Ee());I.current=j&&un?null:ke.key}if(j){Pe&&(Tn(ke),Se?(G.current=Wm(d,ye.current),Y(ke)):n.setOpen(!0,cn(Jd,ke.nativeEvent,ke.currentTarget)));return}xt&&(ue.current!=null&&(G.current=ue.current),Tn(ke),!Se&&S?n.setOpen(!0,cn(Jd,ke.nativeEvent,ke.currentTarget)):Ue(ke),Se&&Y(ke))}},onFocus(ke){n.select("open")&&!k&&(G.current=-1,Y(ke))},onPointerDown:Ne,onPointerEnter:Ne,onMouseDown:xe,onClick:xe}},[Ue,ye,E,d,j,Y,n,S,A,Ee,N,ue,k]),ve=g.useMemo(()=>({...Ve,...oe}),[Ve,oe]);return g.useMemo(()=>m?{reference:ve,floating:Be,item:je,trigger:oe}:{},[m,ve,Be,oe,je])}const gB=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function vB(e,t={}){const n="rootStore"in e?e.rootStore:e,s=n.useState("open"),a=n.useState("floatingId"),l=n.useState("domReferenceElement"),u=n.useState("floatingElement"),{enabled:d=!0,role:p="dialog"}=t,h=Oa(),m=l?.id||h,y=g.useMemo(()=>Nf(u)?.id||a,[u,a]),x=gB.get(p)??p,j=za()!=null,N=g.useMemo(()=>x==="tooltip"||p==="label"?Qn:{"aria-haspopup":x==="alertdialog"?"dialog":x,"aria-expanded":"false",...x==="listbox"&&{role:"combobox"},...x==="menu"&&j&&{role:"menuitem"},...p==="select"&&{"aria-autocomplete":"none"},...p==="combobox"&&{"aria-autocomplete":"list"}},[x,j,p]),k=g.useMemo(()=>x==="tooltip"||p==="label"?{[`aria-${p==="label"?"labelledby":"describedby"}`]:s?y:void 0}:{...N,"aria-expanded":s?"true":"false","aria-controls":s?y:void 0,...x==="menu"&&{id:m}},[x,y,s,m,p,N]),E=g.useMemo(()=>{const S={id:y,...x&&{role:x}};return x==="tooltip"||p==="label"?S:{...S,...x==="menu"&&{"aria-labelledby":m}}},[x,y,m,p]),C=g.useCallback(({active:S,selected:R})=>{const A={role:"option",...S&&{id:`${y}-fui-option`}};switch(p){case"select":case"combobox":return{...A,"aria-selected":R}}return{}},[y,p]);return g.useMemo(()=>d?{reference:k,floating:E,item:C,trigger:N}:{},[d,k,E,N,C])}function yB(e,t){const n="rootStore"in e?e.rootStore:e,s=n.useState("open"),a=n.context.dataRef,{listRef:l,activeIndex:u,onMatch:d,onTypingChange:p,enabled:h=!0,findMatch:m=null,resetMs:y=750,ignoreKeys:x=_C,selectedIndex:w=null}=t,j=Fs(),N=g.useRef(""),k=g.useRef(w??u??-1),E=g.useRef(null);Ye(()=>{s&&(j.clear(),E.current=null,N.current="")},[s,j]),Ye(()=>{s&&N.current===""&&(k.current=w??u??-1)},[s,w,u]);const C=Ke(M=>{M?a.current.typing||(a.current.typing=M,p?.(M)):a.current.typing&&(a.current.typing=M,p?.(M))}),S=Ke(M=>{function _(D,H,W){const q=m?m(H,W):H.find($=>$?.toLocaleLowerCase().indexOf(W.toLocaleLowerCase())===0);return q?D.indexOf(q):-1}const z=l.current;if(N.current.length>0&&N.current[0]!==" "&&(_(z,z,N.current)===-1?C(!1):M.key===" "&&Tn(M)),z==null||x.includes(M.key)||M.key.length!==1||M.ctrlKey||M.metaKey||M.altKey)return;s&&M.key!==" "&&(Tn(M),C(!0)),z.every(D=>D?D[0]?.toLocaleLowerCase()!==D[1]?.toLocaleLowerCase():!0)&&N.current===M.key&&(N.current="",k.current=E.current),N.current+=M.key,j.start(y,()=>{N.current="",k.current=E.current,C(!1)});const U=k.current,O=_(z,[...z.slice((U||0)+1),...z.slice(0,(U||0)+1)],N.current);O!==-1?(d?.(O),E.current=O):M.key!==" "&&(N.current="",C(!1))}),R=g.useMemo(()=>({onKeyDown:S}),[S]),A=g.useMemo(()=>({onKeyDown:S,onKeyUp(M){M.key===" "&&C(!1)}}),[S,C]);return g.useMemo(()=>h?{reference:R,floating:A}:{},[h,R,A])}const bB=g.createContext(void 0);function xB(e){return g.useContext(bB)}const ET="ArrowUp",CT="ArrowDown",TT="ArrowLeft",AT="ArrowRight",RT="Home",MT="End",wB=new Set([TT,AT]),jB=new Set([ET,CT]),SB=new Set([...wB,...jB]);[...SB];const NB=new Set([ET,CT,TT,AT,RT,MT]);function kB(e){return e==="starting"?P$:Qn}const EB={...OC,...q$},CB=g.forwardRef(function(t,n){const{render:s,className:a,finalFocus:l,...u}=t,{store:d}=sl(),{side:p,align:h}=EC(),m=xB()!=null,y=d.useState("open"),x=d.useState("transitionStatus"),w=d.useState("popupProps"),j=d.useState("mounted"),N=d.useState("instantType"),k=d.useState("activeTriggerElement"),E=d.useState("parent"),C=d.useState("lastOpenChangeReason"),S=d.useState("rootId"),R=d.useState("floatingRootContext"),A=d.useState("floatingTreeRoot"),M=d.useState("closeDelay"),_=d.useState("activeTriggerElement");UC({open:y,ref:d.context.popupRef,onComplete(){y&&d.context.onOpenChangeComplete?.(!0)}}),g.useEffect(()=>{function H(W){d.setOpen(!1,cn(W.reason,W.domEvent))}return A.events.on("close",H),()=>{A.events.off("close",H)}},[A.events,d]);const z=d.useState("hoverEnabled"),V=d.useState("disabled");cB(R,{enabled:z&&!V&&E.type!=="context-menu"&&E.type!=="menubar",closeDelay:M});const U=g.useMemo(()=>({transitionStatus:x,side:p,align:h,open:y,nested:E.type==="menu",instant:N}),[x,p,h,y,E.type,N]),O=Ia("div",t,{state:U,ref:[n,d.context.popupRef],stateAttributesMapping:EB,props:[w,{onKeyDown(H){m&&NB.has(H.key)&&H.stopPropagation()}},kB(x),u,{"data-rootownerid":S}]});let D=E.type===void 0||E.type==="context-menu";return(k||E.type==="menubar"&&C!==wy)&&(D=!0),o.jsx(I8,{context:R,modal:!1,disabled:!j,returnFocus:l===void 0?D:l,initialFocus:E.type!=="menu",restoreFocus:!0,externalTree:E.type!=="menubar"?A:void 0,previousFocusableElement:_,nextFocusableElement:E.type===void 0?d.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:E.type===void 0?d.context.beforeContentFocusGuardRef:void 0,children:O})}),_T=g.createContext(void 0);function TB(){const e=g.useContext(_T);if(e===void 0)throw new Error(Ci(32));return e}const AB=g.forwardRef(function(t,n){const{keepMounted:s=!1,...a}=t,{store:l}=sl();return l.useState("mounted")||s?o.jsx(_T.Provider,{value:s,children:o.jsx(A8,{ref:n,...a})}):null});function RB(e){return by(19)?e:e?"true":void 0}const MB=g.createContext(void 0);function OT(){return g.useContext(MB)?.direction??"ltr"}const _B=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:a,rects:l,platform:u,elements:d,middlewareData:p}=t,{element:h,padding:m=0,offsetParent:y="real"}=Lr(e,t)||{};if(h==null)return{};const x=GC(m),w={x:n,y:s},j=Ty(a),N=Cy(j),k=await u.getDimensions(h),E=j==="y",C=E?"top":"left",S=E?"bottom":"right",R=E?"clientHeight":"clientWidth",A=l.reference[N]+l.reference[j]-w[j]-l.floating[N],M=w[j]-l.reference[j],_=y==="real"?await u.getOffsetParent?.(h):d.floating;let z=d.floating[R]||l.floating[N];(!z||!await u.isElement?.(_))&&(z=d.floating[R]||l.floating[N]);const V=A/2-M/2,U=z/2-k[N]/2-1,O=Math.min(x[C],U),D=Math.min(x[S],U),H=O,W=z-k[N]-D,q=z/2-k[N]/2+V,$=fv(H,q,W),L=!p.arrow&&Pa(a)!=null&&q!==$&&l.reference[N]/2-(q<H?O:D)-k[N]/2<0,F=L?q<H?q-H:q-W:0;return{[j]:w[j]+F,data:{[j]:$,centerOffset:q-$-F,...L&&{alignmentOffset:F}},reset:L}}}),OB=(e,t)=>({..._B(e),options:[e,t]}),IB={name:"hide",async fn(e){const{width:t,height:n,x:s,y:a}=e.rects.reference,l=t===0&&n===0&&s===0&&a===0;return{data:{referenceHidden:(await wU().fn(e)).data?.referenceHidden||l}}}},DB={sideX:"left",sideY:"top"};function IT(e,t,n){const s=e==="inline-start"||e==="inline-end";return{top:"top",right:s?n?"inline-start":"inline-end":"right",bottom:"bottom",left:s?n?"inline-end":"inline-start":"left"}[t]}function oS(e,t,n){const{rects:s,placement:a}=e;return{side:IT(t,ds(a),n),align:Pa(a)||"center",anchor:{width:s.reference.width,height:s.reference.height},positioner:{width:s.floating.width,height:s.floating.height}}}function PB(e){const{anchor:t,positionMethod:n="absolute",side:s="bottom",sideOffset:a=0,align:l="center",alignOffset:u=0,collisionBoundary:d,collisionPadding:p=5,sticky:h=!1,arrowPadding:m=5,disableAnchorTracking:y=!1,keepMounted:x=!1,floatingRootContext:w,mounted:j,collisionAvoidance:N,shiftCrossAxis:k=!1,nodeId:E,adaptiveOrigin:C,lazyFlip:S=!1,externalTree:R}=e,[A,M]=g.useState(null);!j&&A!==null&&M(null);const _=N.side||"flip",z=N.align||"flip",V=N.fallbackAxisSide||"end",U=typeof t=="function"?t:void 0,O=Ke(U),D=U?O:t,H=Xn(t),q=OT()==="rtl",$=A||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":q?"left":"right","inline-start":q?"right":"left"}[s],L=l==="center"?$:`${$}-${l}`;let F=p;const X=1,G=s==="bottom"?X:0,I=s==="top"?X:0,B=s==="right"?X:0,Y=s==="left"?X:0;typeof F=="number"?F={top:F+G,right:F+Y,bottom:F+I,left:F+B}:F&&(F={top:(F.top||0)+G,right:(F.right||0)+Y,bottom:(F.bottom||0)+I,left:(F.left||0)+B});const Q={boundary:d==="clipping-ancestors"?"clippingAncestors":d,padding:F},me=g.useRef(null),re=Xn(a),ie=Xn(u),Te=[gU(gt=>{const Bt=oS(gt,s,q),bn=typeof re.current=="function"?re.current(Bt):re.current,Wt=typeof ie.current=="function"?ie.current(Bt):ie.current;return{mainAxis:bn,crossAxis:Wt,alignmentAxis:Wt}},[typeof a!="function"?a:0,typeof u!="function"?u:0,q,s])],he=z==="none"&&_!=="shift",ue=!he&&(h||k||_==="shift"),we=_==="none"?null:bU({...Q,padding:{top:F.top+X,right:F.right+X,bottom:F.bottom+X,left:F.left+X},mainAxis:!k&&_==="flip",crossAxis:z==="flip"?"alignment":!1,fallbackAxisSideDirection:V}),We=he?null:vU(gt=>{const Bt=Si(gt.elements.floating).documentElement;return{...Q,rootBoundary:k?{x:0,y:0,width:Bt.clientWidth,height:Bt.clientHeight}:void 0,mainAxis:z!=="none",crossAxis:ue,limiter:h||k?void 0:yU(bn=>{if(!me.current)return{};const{width:Wt,height:Mn}=me.current.getBoundingClientRect(),dn=Cs(ds(bn.placement)),fn=dn==="y"?Wt:Mn,qs=dn==="y"?F.left+F.right:F.top+F.bottom;return{offset:fn/2+qs/2}})}},[Q,h,k,F,z]);_==="shift"||z==="shift"||l==="center"?Te.push(We,we):Te.push(we,We),Te.push(xU({...Q,apply({elements:{floating:gt},rects:{reference:Bt},availableWidth:bn,availableHeight:Wt}){Object.entries({"--available-width":`${bn}px`,"--available-height":`${Wt}px`,"--anchor-width":`${Bt.width}px`,"--anchor-height":`${Bt.height}px`}).forEach(([Mn,dn])=>{gt.style.setProperty(Mn,dn)})}}),OB(()=>({element:me.current||document.createElement("div"),padding:m,offsetParent:"floating"}),[m]),{name:"transformOrigin",fn(gt){const{elements:Bt,middlewareData:bn,placement:Wt,rects:Mn,y:dn}=gt,fn=ds(Wt),qs=Cs(fn),Zs=me.current,Mi=bn.arrow?.x||0,ee=bn.arrow?.y||0,ge=Zs?.clientWidth||0,be=Zs?.clientHeight||0,qe=Mi+ge/2,Ze=ee+be/2,dt=Math.abs(bn.shift?.y||0),Vt=Mn.reference.height/2,Et=typeof a=="function"?a(oS(gt,s,q)):a,mn=dt>Et,xn={top:`${qe}px calc(100% + ${Et}px)`,bottom:`${qe}px ${-Et}px`,left:`calc(100% + ${Et}px) ${Ze}px`,right:`${-Et}px ${Ze}px`}[fn],Ws=`${qe}px ${Mn.reference.y+Vt-dn}px`;return Bt.floating.style.setProperty("--transform-origin",ue&&qs==="y"&&mn?Ws:xn),{}}},IB,C),Ye(()=>{!j&&w&&w.update({referenceElement:null,floatingElement:null,domReferenceElement:null})},[j,w]);const Ae=g.useMemo(()=>({elementResize:!y&&typeof ResizeObserver<"u",layoutShift:!y&&typeof IntersectionObserver<"u"}),[y]),{refs:je,elements:Ee,x:Ue,y:Ve,middlewareData:Be,update:oe,placement:ve,context:xe,isPositioned:Ne,floatingStyles:ke}=sB({rootContext:w,placement:L,middleware:Te,strategy:n,whileElementsMounted:x?void 0:(...gt)=>Xj(...gt,Ae),nodeId:E,externalTree:R}),{sideX:Se,sideY:$e}=Be.adaptiveOrigin||DB,Pe=Ne?n:"fixed",xt=g.useMemo(()=>C?{position:Pe,[Se]:Ue,[$e]:Ve}:{position:Pe,...ke},[C,Pe,Se,Ue,$e,Ve,ke]),kt=g.useRef(null);Ye(()=>{if(!j)return;const gt=H.current,Bt=typeof gt=="function"?gt():gt,Wt=(lS(Bt)?Bt.current:Bt)||null||null;Wt!==kt.current&&(je.setPositionReference(Wt),kt.current=Wt)},[j,je,D,H]),g.useEffect(()=>{if(!j)return;const gt=H.current;typeof gt!="function"&&lS(gt)&>.current!==kt.current&&(je.setPositionReference(gt.current),kt.current=gt.current)},[j,je,D,H]),g.useEffect(()=>{if(x&&j&&Ee.domReference&&Ee.floating)return Xj(Ee.domReference,Ee.floating,oe,Ae)},[x,j,Ee,oe,Ae]);const un=ds(ve),Xt=IT(s,un,q),Jt=Pa(ve)||"center",ze=!!Be.hide?.referenceHidden;Ye(()=>{S&&j&&Ne&&M(un)},[S,j,Ne,un]);const at=g.useMemo(()=>({position:"absolute",top:Be.arrow?.y,left:Be.arrow?.x}),[Be.arrow]),lt=Be.arrow?.centerOffset!==0;return g.useMemo(()=>({positionerStyles:xt,arrowStyles:at,arrowRef:me,arrowUncentered:lt,side:Xt,align:Jt,physicalSide:un,anchorHidden:ze,refs:je,context:xe,isPositioned:Ne,update:oe}),[xt,at,me,lt,Xt,Jt,un,ze,je,xe,Ne,oe])}function lS(e){return e!=null&&"current"in e}function zB(e){const{children:t,elementsRef:n,labelsRef:s,onMapChange:a}=e,l=Ke(a),u=g.useRef(0),d=Rs($B).current,p=Rs(LB).current,[h,m]=g.useState(0),y=g.useRef(h),x=Ke((E,C)=>{p.set(E,C??null),y.current+=1,m(y.current)}),w=Ke(E=>{p.delete(E),y.current+=1,m(y.current)}),j=g.useMemo(()=>{const E=new Map;return Array.from(p.keys()).filter(S=>S.isConnected).sort(UB).forEach((S,R)=>{const A=p.get(S)??{};E.set(S,{...A,index:R})}),E},[p,h]);Ye(()=>{if(typeof MutationObserver!="function"||j.size===0)return;const E=new MutationObserver(C=>{const S=new Set,R=A=>S.has(A)?S.delete(A):S.add(A);C.forEach(A=>{A.removedNodes.forEach(R),A.addedNodes.forEach(R)}),S.size===0&&(y.current+=1,m(y.current))});return j.forEach((C,S)=>{S.parentElement&&E.observe(S.parentElement,{childList:!0})}),()=>{E.disconnect()}},[j]),Ye(()=>{y.current===h&&(n.current.length!==j.size&&(n.current.length=j.size),s&&s.current.length!==j.size&&(s.current.length=j.size),u.current=j.size),l(j)},[l,j,n,s,h]),Ye(()=>()=>{n.current=[]},[n]),Ye(()=>()=>{s&&(s.current=[])},[s]);const N=Ke(E=>(d.add(E),()=>{d.delete(E)}));Ye(()=>{d.forEach(E=>E(j))},[d,j]);const k=g.useMemo(()=>({register:x,unregister:w,subscribeMapChange:N,elementsRef:n,labelsRef:s,nextIndexRef:u}),[x,w,N,n,s,u]);return o.jsx(zC.Provider,{value:k,children:t})}function LB(){return new Map}function $B(){return new Set}function UB(e,t){const n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}const BB=g.forwardRef(function(t,n){const{cutout:s,...a}=t;let l;if(s){const u=s?.getBoundingClientRect();l=`polygon(
|
|
112
|
-
0% 0%,
|
|
113
|
-
100% 0%,
|
|
114
|
-
100% 100%,
|
|
115
|
-
0% 100%,
|
|
116
|
-
0% 0%,
|
|
117
|
-
${u.left}px ${u.top}px,
|
|
118
|
-
${u.left}px ${u.bottom}px,
|
|
119
|
-
${u.right}px ${u.bottom}px,
|
|
120
|
-
${u.right}px ${u.top}px,
|
|
121
|
-
${u.left}px ${u.top}px
|
|
122
|
-
)`}return o.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...a,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:l}})}),VB=g.forwardRef(function(t,n){const{anchor:s,positionMethod:a="absolute",className:l,render:u,side:d,align:p,sideOffset:h=0,alignOffset:m=0,collisionBoundary:y="clipping-ancestors",collisionPadding:x=5,arrowPadding:w=5,sticky:j=!1,disableAnchorTracking:N=!1,collisionAvoidance:k=L$,...E}=t,{store:C}=sl(),S=TB(),R=rh(!0),A=C.useState("parent"),M=C.useState("floatingRootContext"),_=C.useState("floatingTreeRoot"),z=C.useState("mounted"),V=C.useState("open"),U=C.useState("modal"),O=C.useState("activeTriggerElement"),D=C.useState("lastOpenChangeReason"),H=C.useState("floatingNodeId"),W=C.useState("floatingParentNodeId");let q=s,$=h,L=m,F=p;A.type==="context-menu"&&(q=s??A.context?.anchor,F=F??"start",!d&&F!=="center"&&(L=t.alignOffset??2,$=t.sideOffset??-5));let X=d,G=F;A.type==="menu"?(X=X??"inline-end",G=G??"start"):A.type==="menubar"&&(X=X??"bottom",G=G??"start");const I=A.type==="context-menu",B=PB({anchor:q,floatingRootContext:M,positionMethod:R?"fixed":a,mounted:z,side:X,sideOffset:$,align:G,alignOffset:L,arrowPadding:I?0:w,collisionBoundary:y,collisionPadding:x,sticky:j,nodeId:H,keepMounted:S,disableAnchorTracking:N,collisionAvoidance:k,shiftCrossAxis:I,externalTree:_}),Y=g.useMemo(()=>{const ye={};return V||(ye.pointerEvents="none"),{role:"presentation",hidden:!z,style:{...B.positionerStyles,...ye}}},[V,z,B.positionerStyles]);g.useEffect(()=>{function ye(Te){Te.open?(Te.parentNodeId===H&&C.set("hoverEnabled",!1),Te.nodeId!==H&&Te.parentNodeId===C.select("floatingParentNodeId")&&C.setOpen(!1,cn(dc))):Te.parentNodeId===H&&Te.reason!==dc&&C.set("hoverEnabled",!0)}return _.events.on("menuopenchange",ye),()=>{_.events.off("menuopenchange",ye)}},[C,_.events,H]),g.useEffect(()=>{if(C.select("floatingParentNodeId")==null)return;function ye(Te){if(Te.open||Te.nodeId!==C.select("floatingParentNodeId"))return;const he=Te.reason??dc;C.setOpen(!1,cn(he))}return _.events.on("menuopenchange",ye),()=>{_.events.off("menuopenchange",ye)}},[_.events,C]),g.useEffect(()=>{function ye(Te){!V||Te.nodeId!==C.select("floatingParentNodeId")||Te.target&&O&&O!==Te.target&&C.setOpen(!1,cn(dc))}return _.events.on("itemhover",ye),()=>{_.events.off("itemhover",ye)}},[_.events,V,O,C]),g.useEffect(()=>{const ye={open:V,nodeId:H,parentNodeId:W,reason:C.select("lastOpenChangeReason")};_.events.emit("menuopenchange",ye)},[_.events,V,C,H,W]);const Q=g.useMemo(()=>({open:V,side:B.side,align:B.align,anchorHidden:B.anchorHidden,nested:A.type==="menu"}),[V,B.side,B.align,B.anchorHidden,A.type]),me=g.useMemo(()=>({side:B.side,align:B.align,arrowRef:B.arrowRef,arrowUncentered:B.arrowUncentered,arrowStyles:B.arrowStyles,nodeId:B.context.nodeId}),[B.side,B.align,B.arrowRef,B.arrowUncentered,B.arrowStyles,B.context.nodeId]),re=Ia("div",t,{state:Q,stateAttributesMapping:OC,ref:[n,C.useStateSetter("positionerElement")],props:[Y,E]}),ie=z&&A.type!=="menu"&&(A.type!=="menubar"&&U&&D!==mi||A.type==="menubar"&&A.context.modal);let de=null;return A.type==="menubar"?de=A.context.contentElement:A.type===void 0&&(de=O),o.jsxs(kC.Provider,{value:me,children:[ie&&o.jsx(BB,{ref:A.type==="context-menu"||A.type==="nested-context-menu"?A.context.internalBackdropRef:null,inert:RB(!V),cutout:de}),o.jsx(j8,{id:H,children:o.jsx(zB,{elementsRef:C.context.itemDomElements,labelsRef:C.context.itemLabels,children:re})})]})});let cS={},uS={},dS="";function FB(e){if(typeof document>"u")return!1;const t=Si(e);return An(t).innerWidth-t.documentElement.clientWidth>0}function HB(e){const t=Si(e),n=t.documentElement,s=t.body,a=Ti(n)?n:s,l=a.style.overflow;return a.style.overflow="hidden",()=>{a.style.overflow=l}}function qB(e){const t=Si(e),n=t.documentElement,s=t.body,a=An(n);let l=0,u=0;const d=rr.create(),p=typeof CSS<"u"&&CSS.supports?.("scrollbar-gutter","stable");if(_6&&(a.visualViewport?.scale??1)!==1)return()=>{};function h(){const x=a.getComputedStyle(n),w=a.getComputedStyle(s),k=(x.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";l=n.scrollTop,u=n.scrollLeft,cS={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},dS=n.style.scrollBehavior,uS={position:s.style.position,height:s.style.height,width:s.style.width,boxSizing:s.style.boxSizing,overflowY:s.style.overflowY,overflowX:s.style.overflowX,scrollBehavior:s.style.scrollBehavior};const E=n.scrollHeight>n.clientHeight,C=n.scrollWidth>n.clientWidth,S=x.overflowY==="scroll"||w.overflowY==="scroll",R=x.overflowX==="scroll"||w.overflowX==="scroll",A=Math.max(0,a.innerWidth-n.clientWidth),M=Math.max(0,a.innerHeight-n.clientHeight),_=parseFloat(w.marginTop)+parseFloat(w.marginBottom),z=parseFloat(w.marginLeft)+parseFloat(w.marginRight),V=Ti(n)?n:s;if(p){n.style.scrollbarGutter=k,V.style.overflowY="hidden",V.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:k,overflowY:"hidden",overflowX:"hidden"}),(E||S)&&(n.style.overflowY="scroll"),(C||R)&&(n.style.overflowX="scroll"),Object.assign(s.style,{position:"relative",height:_||M?`calc(100dvh - ${_+M}px)`:"100dvh",width:z||A?`calc(100vw - ${z+A}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),s.scrollTop=l,s.scrollLeft=u,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function m(){Object.assign(n.style,cS),Object.assign(s.style,uS),p||(n.scrollTop=l,n.scrollLeft=u,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=dS)}function y(){m(),d.request(h)}return h(),a.addEventListener("resize",y),()=>{d.cancel(),m(),typeof a.removeEventListener=="function"&&a.removeEventListener("resize",y)}}class ZB{lockCount=0;restore=null;timeoutLock=Xo.create();timeoutUnlock=Xo.create();acquire(t){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(t)),this.release}release=()=>{this.lockCount-=1,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(t){if(this.lockCount===0||this.restore!==null)return;const s=Si(t).documentElement,a=An(s).getComputedStyle(s).overflowY;if(a==="hidden"||a==="clip"){this.restore=MC;return}const l=O6||!FB(t);this.restore=l?HB(t):qB(t)}}const WB=new ZB;function YB(e=!0,t=null){Ye(()=>{if(e)return WB.acquire(t)},[e,t])}const GB=g.createContext(null);function KB(e){return g.useContext(GB)}function XB(e){const t=g.useRef(""),n=g.useCallback(a=>{a.defaultPrevented||(t.current=a.pointerType,e(a,a.pointerType))},[e]);return{onClick:g.useCallback(a=>{if(a.detail===0){e(a,"keyboard");return}"pointerType"in a&&e(a,a.pointerType),e(a,t.current),t.current=""},[e]),onPointerDown:n}}function JB(e){const[t,n]=g.useState(null),s=Ke((d,p)=>{e||n(p)}),a=g.useCallback(()=>{n(null)},[]),{onClick:l,onPointerDown:u}=XB(s);return g.useMemo(()=>({openMethod:t,reset:a,triggerProps:{onClick:l,onPointerDown:u}}),[t,a,l,u])}const QB={...tB,disabled:tt(e=>e.parent.type==="menubar"&&e.parent.context.disabled||e.disabled),modal:tt(e=>(e.parent.type===void 0||e.parent.type==="context-menu")&&(e.modal??!0)),allowMouseEnter:tt(e=>e.parent.type==="menu"?e.parent.store.select("allowMouseEnter"):e.allowMouseEnter),stickIfOpen:tt(e=>e.stickIfOpen),parent:tt(e=>e.parent),rootId:tt(e=>e.parent.type==="menu"?e.parent.store.select("rootId"):e.parent.type!==void 0?e.parent.context.rootId:e.rootId),activeIndex:tt(e=>e.activeIndex),isActive:tt((e,t)=>e.activeIndex===t),hoverEnabled:tt(e=>e.hoverEnabled),instantType:tt(e=>e.instantType),lastOpenChangeReason:tt(e=>e.openChangeReason),floatingTreeRoot:tt(e=>e.parent.type==="menu"?e.parent.store.select("floatingTreeRoot"):e.floatingTreeRoot),floatingNodeId:tt(e=>e.floatingNodeId),floatingParentNodeId:tt(e=>e.floatingParentNodeId),itemProps:tt(e=>e.itemProps),closeDelay:tt(e=>e.closeDelay),keyboardEventRelay:tt(e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type==="menu")return e.parent.store.select("keyboardEventRelay")})};class Oy extends kT{constructor(t){super({...e9(),...t},{positionerRef:g.createRef(),popupRef:g.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:g.createRef(),beforeContentFocusGuardRef:g.createRef(),onOpenChangeComplete:void 0,triggerElements:new _y},QB),this.observe(tt(n=>n.allowMouseEnter),(n,s)=>{this.state.parent.type==="menu"&&n!==s&&this.state.parent.store.set("allowMouseEnter",n)}),this.unsubscribeParentListener=this.observe("parent",n=>{if(this.unsubscribeParentListener?.(),n.type==="menu"){this.unsubscribeParentListener=n.store.subscribe(()=>{this.notifyAll()}),this.context.allowMouseUpTriggerRef=n.store.context.allowMouseUpTriggerRef;return}n.type!==void 0&&(this.context.allowMouseUpTriggerRef=n.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(t,n){this.state.floatingRootContext.context.events.emit("setOpen",{open:t,eventDetails:n})}static useStore(t,n){return Rs(()=>t??new Oy(n)).current}unsubscribeParentListener=null}function e9(){return{...eB(),disabled:!1,modal:!0,allowMouseEnter:!0,stickIfOpen:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new oT,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:Qn,keyboardEventRelay:void 0,closeDelay:0}}const t9=g.createContext(void 0);function n9(){return g.useContext(t9)}function s9(e){const{children:t,open:n,onOpenChange:s,onOpenChangeComplete:a,defaultOpen:l=!1,disabled:u=!1,modal:d,loopFocus:p=!0,orientation:h="vertical",actionsRef:m,closeParentOnEsc:y=!0,handle:x,triggerId:w,defaultTriggerId:j=null,highlightItemOnHover:N=!0}=e,k=rh(!0),E=sl(!0),C=KB(),S=n9(),R=g.useMemo(()=>S&&E?{type:"menu",store:E.store}:C?{type:"menubar",context:C}:k&&!E?{type:"context-menu",context:k}:{type:void 0},[k,E,C,S]),A=Oy.useStore(x?.store,{parent:R}),M=A.useState("floatingTreeRoot"),_=w8(M),z=za();Ye(()=>{k&&!E?A.update({parent:{type:"context-menu",context:k},floatingNodeId:_,floatingParentNodeId:z}):E&&A.update({floatingNodeId:_,floatingParentNodeId:z})},[k,E,_,z,A]),A.useControlledProp("open",n,l),A.useControlledProp("activeTriggerId",w,j),A.useContextCallback("onOpenChangeComplete",a);const V=A.useState("open"),U=A.useState("activeTriggerElement"),O=A.useState("positionerElement"),D=A.useState("hoverEnabled"),H=A.useState("modal"),W=A.useState("disabled"),q=A.useState("lastOpenChangeReason"),$=A.useState("parent"),L=A.useState("activeIndex"),F=A.useState("payload"),X=A.useState("floatingParentNodeId"),G=g.useRef(null),I=X!=null;let B;A.useSyncedValues({disabled:u,modal:$.type===void 0?d:void 0,rootId:Oa()});const{openMethod:Y,triggerProps:Q,reset:me}=JB(V);XU(A);const{forceUnmount:re}=JU(V,A,()=>{A.update({allowMouseEnter:!1,stickIfOpen:!0}),me()}),ie=g.useRef($.type!=="context-menu"),de=Fs();g.useEffect(()=>{if(V||(G.current=null),$.type==="context-menu"){if(!V){de.clear(),ie.current=!1;return}de.start(500,()=>{ie.current=!0})}},[de,V,$.type]),YB(V&&H&&q!==mi&&Y!=="touch",O),Ye(()=>{!V&&!D&&A.set("hoverEnabled",!0)},[V,D,A]);const ye=g.useRef(!0),Te=Fs(),he=Ke((ze,at)=>{const lt=at.reason;if(V===ze&&at.trigger===U||(at.preventUnmountOnClose=()=>{A.set("preventUnmountingOnClose",!0)},!ze&&at.trigger==null&&(at.trigger=U??void 0),s?.(ze,at),at.isCanceled))return;const gt={open:ze,nativeEvent:at.event,reason:at.reason,nested:I};B?.emit("openchange",gt);const Bt=at.event;if(ze===!1&&Bt?.type==="click"&&Bt.pointerType==="touch"&&!ye.current)return;if(!ze&&L!==null){const dn=A.context.itemDomElements.current[L];queueMicrotask(()=>{dn?.setAttribute("tabindex","-1")})}ze&<===Ij?(ye.current=!1,Te.start(300,()=>{ye.current=!0})):(ye.current=!0,Te.clear());const bn=(lt===Sf||lt===IC)&&Bt.detail===0&&Bt?.isTrusted,Wt=!ze&&(lt===DC||lt==null);function Mn(){const dn={open:ze,openChangeReason:lt};G.current=at.event??null;const fn=at.trigger?.id??null;(fn||ze)&&(dn.activeTriggerId=fn,dn.activeTriggerElement=at.trigger??null),A.update(dn)}lt===mi?ji.flushSync(Mn):Mn(),$.type==="menubar"&&(lt===Ij||lt===ih||lt===mi||lt===Jd||lt===dc)?A.set("instantType","group"):bn||Wt?A.set("instantType",bn?"click":"dismiss"):A.set("instantType",void 0)}),ue=g.useCallback(ze=>{const at=cn(ze);return at.preventUnmountOnClose=()=>{A.set("preventUnmountingOnClose",!0)},at},[A]),we=g.useCallback(()=>{A.setOpen(!1,ue(Q$))},[A,ue]);g.useImperativeHandle(m,()=>({unmount:re,close:we}),[re,we]);let We;$.type==="context-menu"&&(We=$.context),g.useImperativeHandle(We?.positionerRef,()=>O,[O]),g.useImperativeHandle(We?.actionsRef,()=>({setOpen:he}),[he]);const Ae=rB({popupStore:A,onOpenChange:he});B=Ae.context.events,g.useEffect(()=>{const ze=({open:at,eventDetails:lt})=>he(at,lt);return B.on("setOpen",ze),()=>{B?.off("setOpen",ze)}},[B,he]);const je=NU(Ae,{enabled:!W,bubbles:y&&$.type==="menu",outsidePress(){return $.type!=="context-menu"||G.current?.type==="contextmenu"?!0:ie.current},externalTree:I?M:void 0}),Ee=vB(Ae,{role:"menu"}),Ue=OT(),Ve=g.useCallback(ze=>{A.select("activeIndex")!==ze&&A.set("activeIndex",ze)},[A]),Be=mB(Ae,{enabled:!W,listRef:A.context.itemDomElements,activeIndex:L,nested:$.type!==void 0,loopFocus:p,orientation:h,parentOrientation:$.type==="menubar"?$.context.orientation:void 0,rtl:Ue==="rtl",disabledIndices:_C,onNavigate:Ve,openOnArrowKeyDown:$.type!=="context-menu",externalTree:I?M:void 0,focusItemOnHover:N}),oe=g.useCallback(ze=>{A.context.typingRef.current=ze},[A]),ve=yB(Ae,{listRef:A.context.itemLabels,activeIndex:L,resetMs:D$,onMatch:ze=>{V&&ze!==L&&A.set("activeIndex",ze)},onTypingChange:oe}),{getReferenceProps:xe,getFloatingProps:Ne,getItemProps:ke,getTriggerProps:Se}=dB([je,Ee,Be,ve]),$e=g.useMemo(()=>{const ze=ah(xe(),{onMouseEnter(){A.set("hoverEnabled",!0)},onMouseMove(){A.set("allowMouseEnter",!0)}},Q);return delete ze.role,ze},[xe,A,Q]),Pe=g.useMemo(()=>{const ze=Se();if(!ze)return ze;const{role:at,["aria-controls"]:lt,...gt}=ze;return gt},[Se]),xt=Ny(),kt=g.useMemo(()=>Ne({onMouseEnter(){$.type==="menu"&&xt.request(()=>A.set("hoverEnabled",!1))},onMouseMove(){A.set("allowMouseEnter",!0)},onClick(){A.select("hoverEnabled")&&A.set("hoverEnabled",!1)},onKeyDown(ze){const at=A.select("keyboardEventRelay");at&&!ze.isPropagationStopped()&&at(ze)}}),[Ne,$.type,xt,A]),un=g.useMemo(()=>ke(),[ke]);A.useSyncedValues({floatingRootContext:Ae,activeTriggerProps:$e,inactiveTriggerProps:Pe,popupProps:kt,itemProps:un});const Xt=g.useMemo(()=>({store:A,parent:R}),[A,R]),Jt=o.jsx(yy.Provider,{value:Xt,children:typeof t=="function"?t({payload:F}):t});return $.type===void 0||$.type==="context-menu"?o.jsx(S8,{externalTree:M,children:Jt}):Jt}function DT(e){if(tn(e)&&e.hasAttribute("data-rootownerid"))return e.getAttribute("data-rootownerid")??void 0;if(!ar(e))return DT(cr(e))}const r9=g.forwardRef(function(t,n){const{className:s,render:a,orientation:l="horizontal",...u}=t,d=g.useMemo(()=>({orientation:l}),[l]);return Ia("div",t,{state:d,ref:n,props:[{role:"separator","aria-orientation":l},u]})});function a9(e){const[t,n]=g.useState({getBoundingClientRect(){return DOMRect.fromRect({width:0,height:0,x:0,y:0})}}),s=g.useRef(null),a=g.useRef(null),l=g.useRef(null),u=g.useRef(null),d=g.useRef(!0),p=g.useRef(null),h=Oa(),m=g.useMemo(()=>({anchor:t,setAnchor:n,actionsRef:l,backdropRef:s,internalBackdropRef:a,positionerRef:u,allowMouseUpTriggerRef:d,initialCursorPointRef:p,rootId:h}),[t,h]);return o.jsx(NC.Provider,{value:m,children:o.jsx(yy.Provider,{value:void 0,children:o.jsx(s9,{...e})})})}const fS=500,i9=g.forwardRef(function(t,n){const{render:s,className:a,...l}=t,{setAnchor:u,actionsRef:d,internalBackdropRef:p,backdropRef:h,positionerRef:m,allowMouseUpTriggerRef:y,initialCursorPointRef:x,rootId:w}=rh(!1),{store:j}=sl(!1),N=j.useState("open"),k=g.useRef(null),E=g.useRef(null),C=Fs(),S=Fs(),R=g.useRef(!1);function A(D,H,W){const q=W.type.startsWith("touch");x.current={x:D,y:H},u({getBoundingClientRect(){return DOMRect.fromRect({width:q?10:0,height:q?10:0,x:D,y:H})}}),R.current=!1,d.current?.setOpen(!0,cn(Sf,W)),S.start(fS,()=>{R.current=!0})}function M(D){y.current=!0,Tn(D),A(D.clientX,D.clientY,D.nativeEvent),Si(k.current).addEventListener("mouseup",W=>{if(y.current=!1,!R.current)return;S.clear(),R.current=!1;const q=Jn(W);Dt(m.current,q)||w&&q&&DT(q)===w||d.current?.setOpen(!1,cn(J$,W))},{once:!0})}function _(D){if(y.current=!1,D.touches.length===1){D.stopPropagation();const H=D.touches[0];E.current={x:H.clientX,y:H.clientY},C.start(fS,()=>{E.current&&A(E.current.x,E.current.y,D.nativeEvent)})}}function z(D){if(C.isStarted()&&E.current&&D.touches.length===1){const H=D.touches[0],W=10,q=Math.abs(H.clientX-E.current.x),$=Math.abs(H.clientY-E.current.y);(q>W||$>W)&&C.clear()}}function V(){C.clear(),E.current=null}g.useEffect(()=>{function D(W){const $=Jn(W);(Dt(k.current,$)||Dt(p.current,$)||Dt(h.current,$))&&W.preventDefault()}const H=Si(k.current);return H.addEventListener("contextmenu",D),()=>{H.removeEventListener("contextmenu",D)}},[h,p]);const U=g.useMemo(()=>({open:N}),[N]);return Ia("div",t,{state:U,ref:[k,n],props:[{onContextMenu:M,onTouchStart:_,onTouchMove:z,onTouchEnd:V,onTouchCancel:V,style:{WebkitTouchCallout:"none"}},l],stateAttributesMapping:K$})}),Iy=g.createContext({});function Dy(e){const t=g.useRef(null);return t.current===null&&(t.current=e()),t.current}const PT=typeof window<"u",zT=PT?g.useLayoutEffect:g.useEffect,ph=g.createContext(null);function Py(e,t){e.indexOf(t)===-1&&e.push(t)}function Df(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const ur=(e,t,n)=>n>t?t:n<e?e:n;let zy=()=>{};const $r={},LT=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function $T(e){return typeof e=="object"&&e!==null}const UT=e=>/^0[^.\s]+$/u.test(e);function BT(e){let t;return()=>(t===void 0&&(t=e()),t)}const As=e=>e,o9=(e,t)=>n=>t(e(n)),Xc=(...e)=>e.reduce(o9),Pc=(e,t,n)=>{const s=t-e;return s===0?1:(n-e)/s};class Ly{constructor(){this.subscriptions=[]}add(t){return Py(this.subscriptions,t),()=>Df(this.subscriptions,t)}notify(t,n,s){const a=this.subscriptions.length;if(a)if(a===1)this.subscriptions[0](t,n,s);else for(let l=0;l<a;l++){const u=this.subscriptions[l];u&&u(t,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const Bs=e=>e*1e3,Ts=e=>e/1e3;function VT(e,t){return t?e*(1e3/t):0}const FT=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,l9=1e-7,c9=12;function u9(e,t,n,s,a){let l,u,d=0;do u=t+(n-t)/2,l=FT(u,s,a)-e,l>0?n=u:t=u;while(Math.abs(l)>l9&&++d<c9);return u}function Jc(e,t,n,s){if(e===t&&n===s)return As;const a=l=>u9(l,0,1,e,n);return l=>l===0||l===1?l:FT(a(l),t,s)}const HT=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,qT=e=>t=>1-e(1-t),ZT=Jc(.33,1.53,.69,.99),$y=qT(ZT),WT=HT($y),YT=e=>(e*=2)<1?.5*$y(e):.5*(2-Math.pow(2,-10*(e-1))),Uy=e=>1-Math.sin(Math.acos(e)),GT=qT(Uy),KT=HT(Uy),d9=Jc(.42,0,1,1),f9=Jc(0,0,.58,1),XT=Jc(.42,0,.58,1),h9=e=>Array.isArray(e)&&typeof e[0]!="number",JT=e=>Array.isArray(e)&&typeof e[0]=="number",p9={linear:As,easeIn:d9,easeInOut:XT,easeOut:f9,circIn:Uy,circInOut:KT,circOut:GT,backIn:$y,backInOut:WT,backOut:ZT,anticipate:YT},m9=e=>typeof e=="string",hS=e=>{if(JT(e)){zy(e.length===4);const[t,n,s,a]=e;return Jc(t,n,s,a)}else if(m9(e))return p9[e];return e},Ad=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function g9(e,t){let n=new Set,s=new Set,a=!1,l=!1;const u=new WeakSet;let d={delta:0,timestamp:0,isProcessing:!1};function p(m){u.has(m)&&(h.schedule(m),e()),m(d)}const h={schedule:(m,y=!1,x=!1)=>{const j=x&&a?n:s;return y&&u.add(m),j.has(m)||j.add(m),m},cancel:m=>{s.delete(m),u.delete(m)},process:m=>{if(d=m,a){l=!0;return}a=!0,[n,s]=[s,n],n.forEach(p),n.clear(),a=!1,l&&(l=!1,h.process(m))}};return h}const v9=40;function QT(e,t){let n=!1,s=!0;const a={delta:0,timestamp:0,isProcessing:!1},l=()=>n=!0,u=Ad.reduce((S,R)=>(S[R]=g9(l),S),{}),{setup:d,read:p,resolveKeyframes:h,preUpdate:m,update:y,preRender:x,render:w,postRender:j}=u,N=()=>{const S=$r.useManualTiming?a.timestamp:performance.now();n=!1,$r.useManualTiming||(a.delta=s?1e3/60:Math.max(Math.min(S-a.timestamp,v9),1)),a.timestamp=S,a.isProcessing=!0,d.process(a),p.process(a),h.process(a),m.process(a),y.process(a),x.process(a),w.process(a),j.process(a),a.isProcessing=!1,n&&t&&(s=!1,e(N))},k=()=>{n=!0,s=!0,a.isProcessing||e(N)};return{schedule:Ad.reduce((S,R)=>{const A=u[R];return S[R]=(M,_=!1,z=!1)=>(n||k(),A.schedule(M,_,z)),S},{}),cancel:S=>{for(let R=0;R<Ad.length;R++)u[Ad[R]].cancel(S)},state:a,steps:u}}const{schedule:At,cancel:Aa,state:En,steps:sg}=QT(typeof requestAnimationFrame<"u"?requestAnimationFrame:As,!0);let tf;function y9(){tf=void 0}const Bn={now:()=>(tf===void 0&&Bn.set(En.isProcessing||$r.useManualTiming?En.timestamp:performance.now()),tf),set:e=>{tf=e,queueMicrotask(y9)}},eA=e=>t=>typeof t=="string"&&t.startsWith(e),tA=eA("--"),b9=eA("var(--"),By=e=>b9(e)?x9.test(e.split("/*")[0].trim()):!1,x9=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function pS(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}const il={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},zc={...il,transform:e=>ur(0,1,e)},Rd={...il,default:1},Sc=e=>Math.round(e*1e5)/1e5,Vy=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function w9(e){return e==null}const j9=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Fy=(e,t)=>n=>!!(typeof n=="string"&&j9.test(n)&&n.startsWith(e)||t&&!w9(n)&&Object.prototype.hasOwnProperty.call(n,t)),nA=(e,t,n)=>s=>{if(typeof s!="string")return s;const[a,l,u,d]=s.match(Vy);return{[e]:parseFloat(a),[t]:parseFloat(l),[n]:parseFloat(u),alpha:d!==void 0?parseFloat(d):1}},S9=e=>ur(0,255,e),rg={...il,transform:e=>Math.round(S9(e))},di={test:Fy("rgb","red"),parse:nA("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:s=1})=>"rgba("+rg.transform(e)+", "+rg.transform(t)+", "+rg.transform(n)+", "+Sc(zc.transform(s))+")"};function N9(e){let t="",n="",s="",a="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),s=e.substring(5,7),a=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),s=e.substring(3,4),a=e.substring(4,5),t+=t,n+=n,s+=s,a+=a),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:a?parseInt(a,16)/255:1}}const gv={test:Fy("#"),parse:N9,transform:di.transform},Qc=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),pa=Qc("deg"),or=Qc("%"),_e=Qc("px"),k9=Qc("vh"),E9=Qc("vw"),mS={...or,parse:e=>or.parse(e)/100,transform:e=>or.transform(e*100)},Lo={test:Fy("hsl","hue"),parse:nA("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:s=1})=>"hsla("+Math.round(e)+", "+or.transform(Sc(t))+", "+or.transform(Sc(n))+", "+Sc(zc.transform(s))+")"},ln={test:e=>di.test(e)||gv.test(e)||Lo.test(e),parse:e=>di.test(e)?di.parse(e):Lo.test(e)?Lo.parse(e):gv.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?di.transform(e):Lo.transform(e),getAnimatableNone:e=>{const t=ln.parse(e);return t.alpha=0,ln.transform(t)}},C9=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function T9(e){return isNaN(e)&&typeof e=="string"&&(e.match(Vy)?.length||0)+(e.match(C9)?.length||0)>0}const sA="number",rA="color",A9="var",R9="var(",gS="${}",M9=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Lc(e){const t=e.toString(),n=[],s={color:[],number:[],var:[]},a=[];let l=0;const d=t.replace(M9,p=>(ln.test(p)?(s.color.push(l),a.push(rA),n.push(ln.parse(p))):p.startsWith(R9)?(s.var.push(l),a.push(A9),n.push(p)):(s.number.push(l),a.push(sA),n.push(parseFloat(p))),++l,gS)).split(gS);return{values:n,split:d,indexes:s,types:a}}function aA(e){return Lc(e).values}function iA(e){const{split:t,types:n}=Lc(e),s=t.length;return a=>{let l="";for(let u=0;u<s;u++)if(l+=t[u],a[u]!==void 0){const d=n[u];d===sA?l+=Sc(a[u]):d===rA?l+=ln.transform(a[u]):l+=a[u]}return l}}const _9=e=>typeof e=="number"?0:ln.test(e)?ln.getAnimatableNone(e):e;function O9(e){const t=aA(e);return iA(e)(t.map(_9))}const Vs={test:T9,parse:aA,createTransformer:iA,getAnimatableNone:O9};function ag(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function I9({hue:e,saturation:t,lightness:n,alpha:s}){e/=360,t/=100,n/=100;let a=0,l=0,u=0;if(!t)a=l=u=n;else{const d=n<.5?n*(1+t):n+t-n*t,p=2*n-d;a=ag(p,d,e+1/3),l=ag(p,d,e),u=ag(p,d,e-1/3)}return{red:Math.round(a*255),green:Math.round(l*255),blue:Math.round(u*255),alpha:s}}function Pf(e,t){return n=>n>0?t:e}const Ht=(e,t,n)=>e+(t-e)*n,ig=(e,t,n)=>{const s=e*e,a=n*(t*t-s)+s;return a<0?0:Math.sqrt(a)},D9=[gv,di,Lo],P9=e=>D9.find(t=>t.test(e));function vS(e){const t=P9(e);if(!t)return!1;let n=t.parse(e);return t===Lo&&(n=I9(n)),n}const yS=(e,t)=>{const n=vS(e),s=vS(t);if(!n||!s)return Pf(e,t);const a={...n};return l=>(a.red=ig(n.red,s.red,l),a.green=ig(n.green,s.green,l),a.blue=ig(n.blue,s.blue,l),a.alpha=Ht(n.alpha,s.alpha,l),di.transform(a))},vv=new Set(["none","hidden"]);function z9(e,t){return vv.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function L9(e,t){return n=>Ht(e,t,n)}function Hy(e){return typeof e=="number"?L9:typeof e=="string"?By(e)?Pf:ln.test(e)?yS:B9:Array.isArray(e)?oA:typeof e=="object"?ln.test(e)?yS:$9:Pf}function oA(e,t){const n=[...e],s=n.length,a=e.map((l,u)=>Hy(l)(l,t[u]));return l=>{for(let u=0;u<s;u++)n[u]=a[u](l);return n}}function $9(e,t){const n={...e,...t},s={};for(const a in n)e[a]!==void 0&&t[a]!==void 0&&(s[a]=Hy(e[a])(e[a],t[a]));return a=>{for(const l in s)n[l]=s[l](a);return n}}function U9(e,t){const n=[],s={color:0,var:0,number:0};for(let a=0;a<t.values.length;a++){const l=t.types[a],u=e.indexes[l][s[l]],d=e.values[u]??0;n[a]=d,s[l]++}return n}const B9=(e,t)=>{const n=Vs.createTransformer(t),s=Lc(e),a=Lc(t);return s.indexes.var.length===a.indexes.var.length&&s.indexes.color.length===a.indexes.color.length&&s.indexes.number.length>=a.indexes.number.length?vv.has(e)&&!a.values.length||vv.has(t)&&!s.values.length?z9(e,t):Xc(oA(U9(s,a),a.values),n):Pf(e,t)};function lA(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?Ht(e,t,n):Hy(e)(e,t)}const V9=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>At.update(t,n),stop:()=>Aa(t),now:()=>En.isProcessing?En.timestamp:Bn.now()}},cA=(e,t,n=10)=>{let s="";const a=Math.max(Math.round(t/n),2);for(let l=0;l<a;l++)s+=Math.round(e(l/(a-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},zf=2e4;function qy(e){let t=0;const n=50;let s=e.next(t);for(;!s.done&&t<zf;)t+=n,s=e.next(t);return t>=zf?1/0:t}function F9(e,t=100,n){const s=n({...e,keyframes:[0,t]}),a=Math.min(qy(s),zf);return{type:"keyframes",ease:l=>s.next(a*l).value/t,duration:Ts(a)}}const H9=5;function uA(e,t,n){const s=Math.max(t-H9,0);return VT(n-e(s),t-s)}const Kt={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},og=.001;function q9({duration:e=Kt.duration,bounce:t=Kt.bounce,velocity:n=Kt.velocity,mass:s=Kt.mass}){let a,l,u=1-t;u=ur(Kt.minDamping,Kt.maxDamping,u),e=ur(Kt.minDuration,Kt.maxDuration,Ts(e)),u<1?(a=h=>{const m=h*u,y=m*e,x=m-n,w=yv(h,u),j=Math.exp(-y);return og-x/w*j},l=h=>{const y=h*u*e,x=y*n+n,w=Math.pow(u,2)*Math.pow(h,2)*e,j=Math.exp(-y),N=yv(Math.pow(h,2),u);return(-a(h)+og>0?-1:1)*((x-w)*j)/N}):(a=h=>{const m=Math.exp(-h*e),y=(h-n)*e+1;return-og+m*y},l=h=>{const m=Math.exp(-h*e),y=(n-h)*(e*e);return m*y});const d=5/e,p=W9(a,l,d);if(e=Bs(e),isNaN(p))return{stiffness:Kt.stiffness,damping:Kt.damping,duration:e};{const h=Math.pow(p,2)*s;return{stiffness:h,damping:u*2*Math.sqrt(s*h),duration:e}}}const Z9=12;function W9(e,t,n){let s=n;for(let a=1;a<Z9;a++)s=s-e(s)/t(s);return s}function yv(e,t){return e*Math.sqrt(1-t*t)}const Y9=["duration","bounce"],G9=["stiffness","damping","mass"];function bS(e,t){return t.some(n=>e[n]!==void 0)}function K9(e){let t={velocity:Kt.velocity,stiffness:Kt.stiffness,damping:Kt.damping,mass:Kt.mass,isResolvedFromDuration:!1,...e};if(!bS(e,G9)&&bS(e,Y9))if(t.velocity=0,e.visualDuration){const n=e.visualDuration,s=2*Math.PI/(n*1.2),a=s*s,l=2*ur(.05,1,1-(e.bounce||0))*Math.sqrt(a);t={...t,mass:Kt.mass,stiffness:a,damping:l}}else{const n=q9({...e,velocity:0});t={...t,...n,mass:Kt.mass},t.isResolvedFromDuration=!0}return t}function Lf(e=Kt.visualDuration,t=Kt.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:s,restDelta:a}=n;const l=n.keyframes[0],u=n.keyframes[n.keyframes.length-1],d={done:!1,value:l},{stiffness:p,damping:h,mass:m,duration:y,velocity:x,isResolvedFromDuration:w}=K9({...n,velocity:-Ts(n.velocity||0)}),j=x||0,N=h/(2*Math.sqrt(p*m)),k=u-l,E=Ts(Math.sqrt(p/m)),C=Math.abs(k)<5;s||(s=C?Kt.restSpeed.granular:Kt.restSpeed.default),a||(a=C?Kt.restDelta.granular:Kt.restDelta.default);let S;if(N<1){const A=yv(E,N);S=M=>{const _=Math.exp(-N*E*M);return u-_*((j+N*E*k)/A*Math.sin(A*M)+k*Math.cos(A*M))}}else if(N===1)S=A=>u-Math.exp(-E*A)*(k+(j+E*k)*A);else{const A=E*Math.sqrt(N*N-1);S=M=>{const _=Math.exp(-N*E*M),z=Math.min(A*M,300);return u-_*((j+N*E*k)*Math.sinh(z)+A*k*Math.cosh(z))/A}}const R={calculatedDuration:w&&y||null,next:A=>{const M=S(A);if(w)d.done=A>=y;else{let _=A===0?j:0;N<1&&(_=A===0?Bs(j):uA(S,A,M));const z=Math.abs(_)<=s,V=Math.abs(u-M)<=a;d.done=z&&V}return d.value=d.done?u:M,d},toString:()=>{const A=Math.min(qy(R),zf),M=cA(_=>R.next(A*_).value,A,30);return A+"ms "+M},toTransition:()=>{}};return R}Lf.applyToOptions=e=>{const t=F9(e,100,Lf);return e.ease=t.ease,e.duration=Bs(t.duration),e.type="keyframes",e};function bv({keyframes:e,velocity:t=0,power:n=.8,timeConstant:s=325,bounceDamping:a=10,bounceStiffness:l=500,modifyTarget:u,min:d,max:p,restDelta:h=.5,restSpeed:m}){const y=e[0],x={done:!1,value:y},w=z=>d!==void 0&&z<d||p!==void 0&&z>p,j=z=>d===void 0?p:p===void 0||Math.abs(d-z)<Math.abs(p-z)?d:p;let N=n*t;const k=y+N,E=u===void 0?k:u(k);E!==k&&(N=E-y);const C=z=>-N*Math.exp(-z/s),S=z=>E+C(z),R=z=>{const V=C(z),U=S(z);x.done=Math.abs(V)<=h,x.value=x.done?E:U};let A,M;const _=z=>{w(x.value)&&(A=z,M=Lf({keyframes:[x.value,j(x.value)],velocity:uA(S,z,x.value),damping:a,stiffness:l,restDelta:h,restSpeed:m}))};return _(0),{calculatedDuration:null,next:z=>{let V=!1;return!M&&A===void 0&&(V=!0,R(z),_(z)),A!==void 0&&z>=A?M.next(z-A):(!V&&R(z),x)}}}function X9(e,t,n){const s=[],a=n||$r.mix||lA,l=e.length-1;for(let u=0;u<l;u++){let d=a(e[u],e[u+1]);if(t){const p=Array.isArray(t)?t[u]||As:t;d=Xc(p,d)}s.push(d)}return s}function J9(e,t,{clamp:n=!0,ease:s,mixer:a}={}){const l=e.length;if(zy(l===t.length),l===1)return()=>t[0];if(l===2&&t[0]===t[1])return()=>t[1];const u=e[0]===e[1];e[0]>e[l-1]&&(e=[...e].reverse(),t=[...t].reverse());const d=X9(t,s,a),p=d.length,h=m=>{if(u&&m<e[0])return t[0];let y=0;if(p>1)for(;y<e.length-2&&!(m<e[y+1]);y++);const x=Pc(e[y],e[y+1],m);return d[y](x)};return n?m=>h(ur(e[0],e[l-1],m)):h}function Q9(e,t){const n=e[e.length-1];for(let s=1;s<=t;s++){const a=Pc(0,t,s);e.push(Ht(n,1,a))}}function eV(e){const t=[0];return Q9(t,e.length-1),t}function tV(e,t){return e.map(n=>n*t)}function nV(e,t){return e.map(()=>t||XT).splice(0,e.length-1)}function Nc({duration:e=300,keyframes:t,times:n,ease:s="easeInOut"}){const a=h9(s)?s.map(hS):hS(s),l={done:!1,value:t[0]},u=tV(n&&n.length===t.length?n:eV(t),e),d=J9(u,t,{ease:Array.isArray(a)?a:nV(t,a)});return{calculatedDuration:e,next:p=>(l.value=d(p),l.done=p>=e,l)}}const sV=e=>e!==null;function Zy(e,{repeat:t,repeatType:n="loop"},s,a=1){const l=e.filter(sV),d=a<0||t&&n!=="loop"&&t%2===1?0:l.length-1;return!d||s===void 0?l[d]:s}const rV={decay:bv,inertia:bv,tween:Nc,keyframes:Nc,spring:Lf};function dA(e){typeof e.type=="string"&&(e.type=rV[e.type])}class Wy{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,n){return this.finished.then(t,n)}}const aV=e=>e/100;class Yy extends Wy{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==Bn.now()&&this.tick(Bn.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;dA(t);const{type:n=Nc,repeat:s=0,repeatDelay:a=0,repeatType:l,velocity:u=0}=t;let{keyframes:d}=t;const p=n||Nc;p!==Nc&&typeof d[0]!="number"&&(this.mixKeyframes=Xc(aV,lA(d[0],d[1])),d=[0,100]);const h=p({...t,keyframes:d});l==="mirror"&&(this.mirroredGenerator=p({...t,keyframes:[...d].reverse(),velocity:-u})),h.calculatedDuration===null&&(h.calculatedDuration=qy(h));const{calculatedDuration:m}=h;this.calculatedDuration=m,this.resolvedDuration=m+a,this.totalDuration=this.resolvedDuration*(s+1)-a,this.generator=h}updateTime(t){const n=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(t,n=!1){const{generator:s,totalDuration:a,mixKeyframes:l,mirroredGenerator:u,resolvedDuration:d,calculatedDuration:p}=this;if(this.startTime===null)return s.next(0);const{delay:h=0,keyframes:m,repeat:y,repeatType:x,repeatDelay:w,type:j,onUpdate:N,finalKeyframe:k}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-a/this.speed,this.startTime)),n?this.currentTime=t:this.updateTime(t);const E=this.currentTime-h*(this.playbackSpeed>=0?1:-1),C=this.playbackSpeed>=0?E<0:E>a;this.currentTime=Math.max(E,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=a);let S=this.currentTime,R=s;if(y){const z=Math.min(this.currentTime,a)/d;let V=Math.floor(z),U=z%1;!U&&z>=1&&(U=1),U===1&&V--,V=Math.min(V,y+1),V%2&&(x==="reverse"?(U=1-U,w&&(U-=w/d)):x==="mirror"&&(R=u)),S=ur(0,1,U)*d}const A=C?{done:!1,value:m[0]}:R.next(S);l&&(A.value=l(A.value));let{done:M}=A;!C&&p!==null&&(M=this.playbackSpeed>=0?this.currentTime>=a:this.currentTime<=0);const _=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&M);return _&&j!==bv&&(A.value=Zy(m,this.options,k,this.speed)),N&&N(A.value),_&&this.finish(),A}then(t,n){return this.finished.then(t,n)}get duration(){return Ts(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Ts(t)}get time(){return Ts(this.currentTime)}set time(t){t=Bs(t),this.currentTime=t,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(t){this.updateTime(Bn.now());const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=Ts(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=V9,startTime:n}=this.options;this.driver||(this.driver=t(a=>this.tick(a))),this.options.onPlay?.();const s=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=s):this.holdTime!==null?this.startTime=s-this.holdTime:this.startTime||(this.startTime=n??s),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(Bn.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),t.observe(this)}}function iV(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const fi=e=>e*180/Math.PI,xv=e=>{const t=fi(Math.atan2(e[1],e[0]));return wv(t)},oV={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:xv,rotateZ:xv,skewX:e=>fi(Math.atan(e[1])),skewY:e=>fi(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},wv=e=>(e=e%360,e<0&&(e+=360),e),xS=xv,wS=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),jS=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),lV={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:wS,scaleY:jS,scale:e=>(wS(e)+jS(e))/2,rotateX:e=>wv(fi(Math.atan2(e[6],e[5]))),rotateY:e=>wv(fi(Math.atan2(-e[2],e[0]))),rotateZ:xS,rotate:xS,skewX:e=>fi(Math.atan(e[4])),skewY:e=>fi(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function jv(e){return e.includes("scale")?1:0}function Sv(e,t){if(!e||e==="none")return jv(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,a;if(n)s=lV,a=n;else{const d=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=oV,a=d}if(!a)return jv(t);const l=s[t],u=a[1].split(",").map(uV);return typeof l=="function"?l(u):u[l]}const cV=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return Sv(n,t)};function uV(e){return parseFloat(e.trim())}const ol=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],ll=new Set(ol),SS=e=>e===il||e===_e,dV=new Set(["x","y","z"]),fV=ol.filter(e=>!dV.has(e));function hV(e){const t=[];return fV.forEach(n=>{const s=e.getValue(n);s!==void 0&&(t.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),t}const wa={width:({x:e},{paddingLeft:t="0",paddingRight:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),height:({y:e},{paddingTop:t="0",paddingBottom:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>Sv(t,"x"),y:(e,{transform:t})=>Sv(t,"y")};wa.translateX=wa.x;wa.translateY=wa.y;const gi=new Set;let Nv=!1,kv=!1,Ev=!1;function fA(){if(kv){const e=Array.from(gi).filter(s=>s.needsMeasurement),t=new Set(e.map(s=>s.element)),n=new Map;t.forEach(s=>{const a=hV(s);a.length&&(n.set(s,a),s.render())}),e.forEach(s=>s.measureInitialState()),t.forEach(s=>{s.render();const a=n.get(s);a&&a.forEach(([l,u])=>{s.getValue(l)?.set(u)})}),e.forEach(s=>s.measureEndState()),e.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}kv=!1,Nv=!1,gi.forEach(e=>e.complete(Ev)),gi.clear()}function hA(){gi.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(kv=!0)})}function pV(){Ev=!0,hA(),fA(),Ev=!1}class Gy{constructor(t,n,s,a,l,u=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=s,this.motionValue=a,this.element=l,this.isAsync=u}scheduleResolve(){this.state="scheduled",this.isAsync?(gi.add(this),Nv||(Nv=!0,At.read(hA),At.resolveKeyframes(fA))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:s,motionValue:a}=this;if(t[0]===null){const l=a?.get(),u=t[t.length-1];if(l!==void 0)t[0]=l;else if(s&&n){const d=s.readValue(n,u);d!=null&&(t[0]=d)}t[0]===void 0&&(t[0]=u),a&&l===void 0&&a.set(t[0])}iV(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),gi.delete(this)}cancel(){this.state==="scheduled"&&(gi.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const mV=e=>e.startsWith("--");function gV(e,t,n){mV(t)?e.style.setProperty(t,n):e.style[t]=n}const vV={};function pA(e,t){const n=BT(e);return()=>vV[t]??n()}const yV=pA(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),mA=pA(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),fc=([e,t,n,s])=>`cubic-bezier(${e}, ${t}, ${n}, ${s})`,NS={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:fc([0,.65,.55,1]),circOut:fc([.55,0,1,.45]),backIn:fc([.31,.01,.66,-.59]),backOut:fc([.33,1.53,.69,.99])};function gA(e,t){if(e)return typeof e=="function"?mA()?cA(e,t):"ease-out":JT(e)?fc(e):Array.isArray(e)?e.map(n=>gA(n,t)||NS.easeOut):NS[e]}function bV(e,t,n,{delay:s=0,duration:a=300,repeat:l=0,repeatType:u="loop",ease:d="easeOut",times:p}={},h=void 0){const m={[t]:n};p&&(m.offset=p);const y=gA(d,a);Array.isArray(y)&&(m.easing=y);const x={delay:s,duration:a,easing:Array.isArray(y)?"linear":y,fill:"both",iterations:l+1,direction:u==="reverse"?"alternate":"normal"};return h&&(x.pseudoElement=h),e.animate(m,x)}function vA(e){return typeof e=="function"&&"applyToOptions"in e}function xV({type:e,...t}){return vA(e)&&mA()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class yA extends Wy{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!t)return;const{element:n,name:s,keyframes:a,pseudoElement:l,allowFlatten:u=!1,finalKeyframe:d,onComplete:p}=t;this.isPseudoElement=!!l,this.allowFlatten=u,this.options=t,zy(typeof t.type!="string");const h=xV(t);this.animation=bV(n,s,a,h,l),h.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!l){const m=Zy(a,this.options,d,this.speed);this.updateMotionValue?this.updateMotionValue(m):gV(n,s,m),this.animation.cancel()}p?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;t==="idle"||t==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){const t=this.options?.element;!this.isPseudoElement&&t?.isConnected&&this.animation.commitStyles?.()}get duration(){const t=this.animation.effect?.getComputedTiming?.().duration||0;return Ts(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Ts(t)}get time(){return Ts(Number(this.animation.currentTime)||0)}set time(t){this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Bs(t)}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(t){this.manualStartTime=this.animation.startTime=t}attachTimeline({timeline:t,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,t&&yV()?(this.animation.timeline=t,As):n(this)}}const bA={anticipate:YT,backInOut:WT,circInOut:KT};function wV(e){return e in bA}function jV(e){typeof e.ease=="string"&&wV(e.ease)&&(e.ease=bA[e.ease])}const lg=10;class SV extends yA{constructor(t){jV(t),dA(t),super(t),t.startTime!==void 0&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:n,onUpdate:s,onComplete:a,element:l,...u}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const d=new Yy({...u,autoplay:!1}),p=Math.max(lg,Bn.now()-this.startTime),h=ur(0,lg,p-lg);n.setWithVelocity(d.sample(Math.max(0,p-h)).value,d.sample(p).value,h),d.stop()}}const kS=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(Vs.test(e)||e==="0")&&!e.startsWith("url("));function NV(e){const t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function kV(e,t,n,s){const a=e[0];if(a===null)return!1;if(t==="display"||t==="visibility")return!0;const l=e[e.length-1],u=kS(a,t),d=kS(l,t);return!u||!d?!1:NV(e)||(n==="spring"||vA(n))&&s}function Cv(e){e.duration=0,e.type="keyframes"}const EV=new Set(["opacity","clipPath","filter","transform"]),CV=BT(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function TV(e){const{motionValue:t,name:n,repeatDelay:s,repeatType:a,damping:l,type:u}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:p,transformTemplate:h}=t.owner.getProps();return CV()&&n&&EV.has(n)&&(n!=="transform"||!h)&&!p&&!s&&a!=="mirror"&&l!==0&&u!=="inertia"}const AV=40;class RV extends Wy{constructor({autoplay:t=!0,delay:n=0,type:s="keyframes",repeat:a=0,repeatDelay:l=0,repeatType:u="loop",keyframes:d,name:p,motionValue:h,element:m,...y}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Bn.now();const x={autoplay:t,delay:n,type:s,repeat:a,repeatDelay:l,repeatType:u,name:p,motionValue:h,element:m,...y},w=m?.KeyframeResolver||Gy;this.keyframeResolver=new w(d,(j,N,k)=>this.onKeyframesResolved(j,N,x,!k),p,h,m),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(t,n,s,a){this.keyframeResolver=void 0;const{name:l,type:u,velocity:d,delay:p,isHandoff:h,onUpdate:m}=s;this.resolvedAt=Bn.now(),kV(t,l,u,d)||(($r.instantAnimations||!p)&&m?.(Zy(t,s,n)),t[0]=t[t.length-1],Cv(s),s.repeat=0);const x={startTime:a?this.resolvedAt?this.resolvedAt-this.createdAt>AV?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:t},w=!h&&TV(x),j=x.motionValue?.owner?.current,N=w?new SV({...x,element:j}):new Yy(x);N.finished.then(()=>{this.notifyFinished()}).catch(As),this.pendingTimeline&&(this.stopTimeline=N.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=N}get finished(){return this._animation?this.animation.finished:this._finished}then(t,n){return this.finished.finally(t).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),pV()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}function xA(e,t,n,s=0,a=1){const l=Array.from(e).sort((h,m)=>h.sortNodePosition(m)).indexOf(t),u=e.size,d=(u-1)*s;return typeof n=="function"?n(l,u):a===1?l*s:d-l*s}const MV=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function _V(e){const t=MV.exec(e);if(!t)return[,];const[,n,s,a]=t;return[`--${n??s}`,a]}function wA(e,t,n=1){const[s,a]=_V(e);if(!s)return;const l=window.getComputedStyle(t).getPropertyValue(s);if(l){const u=l.trim();return LT(u)?parseFloat(u):u}return By(a)?wA(a,t,n+1):a}const OV={type:"spring",stiffness:500,damping:25,restSpeed:10},IV=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),DV={type:"keyframes",duration:.8},PV={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},zV=(e,{keyframes:t})=>t.length>2?DV:ll.has(e)?e.startsWith("scale")?IV(t[1]):OV:PV,LV=e=>e!==null;function $V(e,{repeat:t,repeatType:n="loop"},s){const a=e.filter(LV),l=t&&n!=="loop"&&t%2===1?0:a.length-1;return a[l]}function jA(e,t){if(e?.inherit&&t){const{inherit:n,...s}=e;return{...t,...s}}return e}function Ky(e,t){const n=e?.[t]??e?.default??e;return n!==e?jA(n,e):n}function UV({when:e,delay:t,delayChildren:n,staggerChildren:s,staggerDirection:a,repeat:l,repeatType:u,repeatDelay:d,from:p,elapsed:h,...m}){return!!Object.keys(m).length}const Xy=(e,t,n,s={},a,l)=>u=>{const d=Ky(s,e)||{},p=d.delay||s.delay||0;let{elapsed:h=0}=s;h=h-Bs(p);const m={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...d,delay:-h,onUpdate:x=>{t.set(x),d.onUpdate&&d.onUpdate(x)},onComplete:()=>{u(),d.onComplete&&d.onComplete()},name:e,motionValue:t,element:l?void 0:a};UV(d)||Object.assign(m,zV(e,m)),m.duration&&(m.duration=Bs(m.duration)),m.repeatDelay&&(m.repeatDelay=Bs(m.repeatDelay)),m.from!==void 0&&(m.keyframes[0]=m.from);let y=!1;if((m.type===!1||m.duration===0&&!m.repeatDelay)&&(Cv(m),m.delay===0&&(y=!0)),($r.instantAnimations||$r.skipAnimations||a?.shouldSkipAnimations)&&(y=!0,Cv(m),m.delay=0),m.allowFlatten=!d.type&&!d.ease,y&&!l&&t.get()!==void 0){const x=$V(m.keyframes,d);if(x!==void 0){At.update(()=>{m.onUpdate(x),m.onComplete()});return}}return d.isSync?new Yy(m):new RV(m)};function ES(e){const t=[{},{}];return e?.values.forEach((n,s)=>{t[0][s]=n.get(),t[1][s]=n.getVelocity()}),t}function Jy(e,t,n,s){if(typeof t=="function"){const[a,l]=ES(s);t=t(n!==void 0?n:e.custom,a,l)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[a,l]=ES(s);t=t(n!==void 0?n:e.custom,a,l)}return t}function Wo(e,t,n){const s=e.getProps();return Jy(s,t,n!==void 0?n:s.custom,e)}const SA=new Set(["width","height","top","left","right","bottom",...ol]),CS=30,BV=e=>!isNaN(parseFloat(e));class VV{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const a=Bn.now();if(this.updatedAt!==a&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const l of this.dependents)l.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=Bn.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=BV(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new Ly);const s=this.events[t].add(n);return t==="change"?()=>{s(),At.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-s}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=Bn.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>CS)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,CS);return VT(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function el(e,t){return new VV(e,t)}const Tv=e=>Array.isArray(e);function FV(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,el(n))}function HV(e){return Tv(e)?e[e.length-1]||0:e}function qV(e,t){const n=Wo(e,t);let{transitionEnd:s={},transition:a={},...l}=n||{};l={...l,...s};for(const u in l){const d=HV(l[u]);FV(e,u,d)}}const In=e=>!!(e&&e.getVelocity);function ZV(e){return!!(In(e)&&e.add)}function Av(e,t){const n=e.getValue("willChange");if(ZV(n))return n.add(t);if(!n&&$r.WillChange){const s=new $r.WillChange("auto");e.addValue("willChange",s),s.add(t)}}function Qy(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}const WV="framerAppearId",NA="data-"+Qy(WV);function kA(e){return e.props[NA]}function YV({protectedKeys:e,needsAnimating:t},n){const s=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,s}function EA(e,t,{delay:n=0,transitionOverride:s,type:a}={}){let{transition:l,transitionEnd:u,...d}=t;const p=e.getDefaultTransition();l=l?jA(l,p):p;const h=l?.reduceMotion;s&&(l=s);const m=[],y=a&&e.animationState&&e.animationState.getState()[a];for(const x in d){const w=e.getValue(x,e.latestValues[x]??null),j=d[x];if(j===void 0||y&&YV(y,x))continue;const N={delay:n,...Ky(l||{},x)},k=w.get();if(k!==void 0&&!w.isAnimating&&!Array.isArray(j)&&j===k&&!N.velocity)continue;let E=!1;if(window.MotionHandoffAnimation){const R=kA(e);if(R){const A=window.MotionHandoffAnimation(R,x,At);A!==null&&(N.startTime=A,E=!0)}}Av(e,x);const C=h??e.shouldReduceMotion;w.start(Xy(x,w,j,C&&SA.has(x)?{type:!1}:N,e,E));const S=w.animation;S&&m.push(S)}if(u){const x=()=>At.update(()=>{u&&qV(e,u)});m.length?Promise.all(m).then(x):x()}return m}function Rv(e,t,n={}){const s=Wo(e,t,n.type==="exit"?e.presenceContext?.custom:void 0);let{transition:a=e.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(a=n.transitionOverride);const l=s?()=>Promise.all(EA(e,s,n)):()=>Promise.resolve(),u=e.variantChildren&&e.variantChildren.size?(p=0)=>{const{delayChildren:h=0,staggerChildren:m,staggerDirection:y}=a;return GV(e,t,p,h,m,y,n)}:()=>Promise.resolve(),{when:d}=a;if(d){const[p,h]=d==="beforeChildren"?[l,u]:[u,l];return p().then(()=>h())}else return Promise.all([l(),u(n.delay)])}function GV(e,t,n=0,s=0,a=0,l=1,u){const d=[];for(const p of e.variantChildren)p.notify("AnimationStart",t),d.push(Rv(p,t,{...u,delay:n+(typeof s=="function"?0:s)+xA(e.variantChildren,p,s,a,l)}).then(()=>p.notify("AnimationComplete",t)));return Promise.all(d)}function KV(e,t,n={}){e.notify("AnimationStart",t);let s;if(Array.isArray(t)){const a=t.map(l=>Rv(e,l,n));s=Promise.all(a)}else if(typeof t=="string")s=Rv(e,t,n);else{const a=typeof t=="function"?Wo(e,t,n.custom):t;s=Promise.all(EA(e,a,n))}return s.then(()=>{e.notify("AnimationComplete",t)})}const XV={test:e=>e==="auto",parse:e=>e},CA=e=>t=>t.test(e),TA=[il,_e,or,pa,E9,k9,XV],TS=e=>TA.find(CA(e));function JV(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||UT(e):!0}const QV=new Set(["brightness","contrast","saturate","opacity"]);function e7(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[s]=n.match(Vy)||[];if(!s)return e;const a=n.replace(s,"");let l=QV.has(t)?1:0;return s!==n&&(l*=100),t+"("+l+a+")"}const t7=/\b([a-z-]*)\(.*?\)/gu,Mv={...Vs,getAnimatableNone:e=>{const t=e.match(t7);return t?t.map(e7).join(" "):e}},_v={...Vs,getAnimatableNone:e=>{const t=Vs.parse(e);return Vs.createTransformer(e)(t.map(s=>typeof s=="number"?0:typeof s=="object"?{...s,alpha:1}:s))}},AS={...il,transform:Math.round},n7={rotate:pa,rotateX:pa,rotateY:pa,rotateZ:pa,scale:Rd,scaleX:Rd,scaleY:Rd,scaleZ:Rd,skew:pa,skewX:pa,skewY:pa,distance:_e,translateX:_e,translateY:_e,translateZ:_e,x:_e,y:_e,z:_e,perspective:_e,transformPerspective:_e,opacity:zc,originX:mS,originY:mS,originZ:_e},eb={borderWidth:_e,borderTopWidth:_e,borderRightWidth:_e,borderBottomWidth:_e,borderLeftWidth:_e,borderRadius:_e,borderTopLeftRadius:_e,borderTopRightRadius:_e,borderBottomRightRadius:_e,borderBottomLeftRadius:_e,width:_e,maxWidth:_e,height:_e,maxHeight:_e,top:_e,right:_e,bottom:_e,left:_e,inset:_e,insetBlock:_e,insetBlockStart:_e,insetBlockEnd:_e,insetInline:_e,insetInlineStart:_e,insetInlineEnd:_e,padding:_e,paddingTop:_e,paddingRight:_e,paddingBottom:_e,paddingLeft:_e,paddingBlock:_e,paddingBlockStart:_e,paddingBlockEnd:_e,paddingInline:_e,paddingInlineStart:_e,paddingInlineEnd:_e,margin:_e,marginTop:_e,marginRight:_e,marginBottom:_e,marginLeft:_e,marginBlock:_e,marginBlockStart:_e,marginBlockEnd:_e,marginInline:_e,marginInlineStart:_e,marginInlineEnd:_e,fontSize:_e,backgroundPositionX:_e,backgroundPositionY:_e,...n7,zIndex:AS,fillOpacity:zc,strokeOpacity:zc,numOctaves:AS},s7={...eb,color:ln,backgroundColor:ln,outlineColor:ln,fill:ln,stroke:ln,borderColor:ln,borderTopColor:ln,borderRightColor:ln,borderBottomColor:ln,borderLeftColor:ln,filter:Mv,WebkitFilter:Mv,mask:_v,WebkitMask:_v},AA=e=>s7[e],r7=new Set([Mv,_v]);function RA(e,t){let n=AA(e);return r7.has(n)||(n=Vs),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const a7=new Set(["auto","none","0"]);function i7(e,t,n){let s=0,a;for(;s<e.length&&!a;){const l=e[s];typeof l=="string"&&!a7.has(l)&&Lc(l).values.length&&(a=e[s]),s++}if(a&&n)for(const l of t)e[l]=RA(n,a)}class o7 extends Gy{constructor(t,n,s,a,l){super(t,n,s,a,l,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let m=0;m<t.length;m++){let y=t[m];if(typeof y=="string"&&(y=y.trim(),By(y))){const x=wA(y,n.current);x!==void 0&&(t[m]=x),m===t.length-1&&(this.finalKeyframe=y)}}if(this.resolveNoneKeyframes(),!SA.has(s)||t.length!==2)return;const[a,l]=t,u=TS(a),d=TS(l),p=pS(a),h=pS(l);if(p!==h&&wa[s]){this.needsMeasurement=!0;return}if(u!==d)if(SS(u)&&SS(d))for(let m=0;m<t.length;m++){const y=t[m];typeof y=="string"&&(t[m]=parseFloat(y))}else wa[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,s=[];for(let a=0;a<t.length;a++)(t[a]===null||JV(t[a]))&&s.push(a);s.length&&i7(t,s,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:s}=this;if(!t||!t.current)return;s==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=wa[s](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const a=n[n.length-1];a!==void 0&&t.getValue(s,a).jump(a,!1)}measureEndState(){const{element:t,name:n,unresolvedKeyframes:s}=this;if(!t||!t.current)return;const a=t.getValue(n);a&&a.jump(this.measuredOrigin,!1);const l=s.length-1,u=s[l];s[l]=wa[n](t.measureViewportBox(),window.getComputedStyle(t.current)),u!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=u),this.removedTransforms?.length&&this.removedTransforms.forEach(([d,p])=>{t.getValue(d).set(p)}),this.resolveNoneKeyframes()}}const l7=new Set(["opacity","clipPath","filter","transform"]);function MA(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e=="string"){let s=document;const a=n?.[e]??s.querySelectorAll(e);return a?Array.from(a):[]}return Array.from(e).filter(s=>s!=null)}const _A=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function Ov(e){return $T(e)&&"offsetHeight"in e}const{schedule:tb}=QT(queueMicrotask,!1),$s={x:!1,y:!1};function OA(){return $s.x||$s.y}function c7(e){return e==="x"||e==="y"?$s[e]?null:($s[e]=!0,()=>{$s[e]=!1}):$s.x||$s.y?null:($s.x=$s.y=!0,()=>{$s.x=$s.y=!1})}function IA(e,t){const n=MA(e),s=new AbortController,a={passive:!0,...t,signal:s.signal};return[n,a,()=>s.abort()]}function u7(e){return!(e.pointerType==="touch"||OA())}function d7(e,t,n={}){const[s,a,l]=IA(e,n);return s.forEach(u=>{let d=!1,p=!1,h;const m=()=>{u.removeEventListener("pointerleave",j)},y=k=>{h&&(h(k),h=void 0),m()},x=k=>{d=!1,window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",x),p&&(p=!1,y(k))},w=()=>{d=!0,window.addEventListener("pointerup",x,a),window.addEventListener("pointercancel",x,a)},j=k=>{if(k.pointerType!=="touch"){if(d){p=!0;return}y(k)}},N=k=>{if(!u7(k))return;p=!1;const E=t(u,k);typeof E=="function"&&(h=E,u.addEventListener("pointerleave",j,a))};u.addEventListener("pointerenter",N,a),u.addEventListener("pointerdown",w,a)}),l}const DA=(e,t)=>t?e===t?!0:DA(e,t.parentElement):!1,nb=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,f7=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function h7(e){return f7.has(e.tagName)||e.isContentEditable===!0}const p7=new Set(["INPUT","SELECT","TEXTAREA"]);function m7(e){return p7.has(e.tagName)||e.isContentEditable===!0}const nf=new WeakSet;function RS(e){return t=>{t.key==="Enter"&&e(t)}}function cg(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const g7=(e,t)=>{const n=e.currentTarget;if(!n)return;const s=RS(()=>{if(nf.has(n))return;cg(n,"down");const a=RS(()=>{cg(n,"up")}),l=()=>cg(n,"cancel");n.addEventListener("keyup",a,t),n.addEventListener("blur",l,t)});n.addEventListener("keydown",s,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),t)};function MS(e){return nb(e)&&!OA()}const _S=new WeakSet;function v7(e,t,n={}){const[s,a,l]=IA(e,n),u=d=>{const p=d.currentTarget;if(!MS(d)||_S.has(d))return;nf.add(p),n.stopPropagation&&_S.add(d);const h=t(p,d),m=(w,j)=>{window.removeEventListener("pointerup",y),window.removeEventListener("pointercancel",x),nf.has(p)&&nf.delete(p),MS(w)&&typeof h=="function"&&h(w,{success:j})},y=w=>{m(w,p===window||p===document||n.useGlobalTarget||DA(p,w.target))},x=w=>{m(w,!1)};window.addEventListener("pointerup",y,a),window.addEventListener("pointercancel",x,a)};return s.forEach(d=>{(n.useGlobalTarget?window:d).addEventListener("pointerdown",u,a),Ov(d)&&(d.addEventListener("focus",h=>g7(h,a)),!h7(d)&&!d.hasAttribute("tabindex")&&(d.tabIndex=0))}),l}function sb(e){return $T(e)&&"ownerSVGElement"in e}const sf=new WeakMap;let rf;const PA=(e,t,n)=>(s,a)=>a&&a[0]?a[0][e+"Size"]:sb(s)&&"getBBox"in s?s.getBBox()[t]:s[n],y7=PA("inline","width","offsetWidth"),b7=PA("block","height","offsetHeight");function x7({target:e,borderBoxSize:t}){sf.get(e)?.forEach(n=>{n(e,{get width(){return y7(e,t)},get height(){return b7(e,t)}})})}function w7(e){e.forEach(x7)}function j7(){typeof ResizeObserver>"u"||(rf=new ResizeObserver(w7))}function S7(e,t){rf||j7();const n=MA(e);return n.forEach(s=>{let a=sf.get(s);a||(a=new Set,sf.set(s,a)),a.add(t),rf?.observe(s)}),()=>{n.forEach(s=>{const a=sf.get(s);a?.delete(t),a?.size||rf?.unobserve(s)})}}const af=new Set;let $o;function N7(){$o=()=>{const e={get width(){return window.innerWidth},get height(){return window.innerHeight}};af.forEach(t=>t(e))},window.addEventListener("resize",$o)}function k7(e){return af.add(e),$o||N7(),()=>{af.delete(e),!af.size&&typeof $o=="function"&&(window.removeEventListener("resize",$o),$o=void 0)}}function OS(e,t){return typeof e=="function"?k7(e):S7(e,t)}function E7(e){return sb(e)&&e.tagName==="svg"}const C7=[...TA,ln,Vs],T7=e=>C7.find(CA(e)),IS=()=>({translate:0,scale:1,origin:0,originPoint:0}),Uo=()=>({x:IS(),y:IS()}),DS=()=>({min:0,max:0}),pn=()=>({x:DS(),y:DS()}),A7=new WeakMap;function mh(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function $c(e){return typeof e=="string"||Array.isArray(e)}const rb=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],ab=["initial",...rb];function gh(e){return mh(e.animate)||ab.some(t=>$c(e[t]))}function zA(e){return!!(gh(e)||e.variants)}function R7(e,t,n){for(const s in t){const a=t[s],l=n[s];if(In(a))e.addValue(s,a);else if(In(l))e.addValue(s,el(a,{owner:e}));else if(l!==a)if(e.hasValue(s)){const u=e.getValue(s);u.liveStyle===!0?u.jump(a):u.hasAnimated||u.set(a)}else{const u=e.getStaticValue(s);e.addValue(s,el(u!==void 0?u:a,{owner:e}))}}for(const s in n)t[s]===void 0&&e.removeValue(s);return t}const Iv={current:null},LA={current:!1},M7=typeof window<"u";function _7(){if(LA.current=!0,!!M7)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>Iv.current=e.matches;e.addEventListener("change",t),t()}else Iv.current=!1}const PS=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let $f={};function $A(e){$f=e}function O7(){return $f}class I7{scrapeMotionValuesFromProps(t,n,s){return{}}constructor({parent:t,props:n,presenceContext:s,reducedMotionConfig:a,skipAnimations:l,blockInitialAnimation:u,visualState:d},p={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=Gy,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const w=Bn.now();this.renderScheduledAt<w&&(this.renderScheduledAt=w,At.render(this.render,!1,!0))};const{latestValues:h,renderState:m}=d;this.latestValues=h,this.baseTarget={...h},this.initialValues=n.initial?{...h}:{},this.renderState=m,this.parent=t,this.props=n,this.presenceContext=s,this.depth=t?t.depth+1:0,this.reducedMotionConfig=a,this.skipAnimationsConfig=l,this.options=p,this.blockInitialAnimation=!!u,this.isControllingVariants=gh(n),this.isVariantNode=zA(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:y,...x}=this.scrapeMotionValuesFromProps(n,{},this);for(const w in x){const j=x[w];h[w]!==void 0&&In(j)&&j.set(h[w])}}mount(t){if(this.hasBeenMounted)for(const n in this.initialValues)this.values.get(n)?.jump(this.initialValues[n]),this.latestValues[n]=this.initialValues[n];this.current=t,A7.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,s)=>this.bindToMotionValue(s,n)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(LA.current||_7(),this.shouldReduceMotion=Iv.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),Aa(this.notifyUpdate),Aa(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,n){if(this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)(),n.accelerate&&l7.has(t)&&this.current instanceof HTMLElement){const{factory:u,keyframes:d,times:p,ease:h,duration:m}=n.accelerate,y=new yA({element:this.current,name:t,keyframes:d,times:p,ease:h,duration:Bs(m)}),x=u(y);this.valueSubscriptions.set(t,()=>{x(),y.cancel()});return}const s=ll.has(t);s&&this.onBindTransform&&this.onBindTransform();const a=n.on("change",u=>{this.latestValues[t]=u,this.props.onUpdate&&At.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let l;typeof window<"u"&&window.MotionCheckAppearSync&&(l=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{a(),l&&l(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in $f){const n=$f[t];if(!n)continue;const{isEnabled:s,Feature:a}=n;if(!this.features[t]&&a&&s(this.props)&&(this.features[t]=new a(this)),this.features[t]){const l=this.features[t];l.isMounted?l.update():(l.mount(),l.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):pn()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let s=0;s<PS.length;s++){const a=PS[s];this.propEventSubscriptions[a]&&(this.propEventSubscriptions[a](),delete this.propEventSubscriptions[a]);const l="on"+a,u=t[l];u&&(this.propEventSubscriptions[a]=this.on(a,u))}this.prevMotionValues=R7(this,this.scrapeMotionValuesFromProps(t,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const s=this.values.get(t);n!==s&&(s&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let s=this.values.get(t);return s===void 0&&n!==void 0&&(s=el(n===null?void 0:n,{owner:this}),this.addValue(t,s)),s}readValue(t,n){let s=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return s!=null&&(typeof s=="string"&&(LT(s)||UT(s))?s=parseFloat(s):!T7(s)&&Vs.test(n)&&(s=RA(t,n)),this.setBaseTarget(t,In(s)?s.get():s)),In(s)?s.get():s}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const l=Jy(this.props,n,this.presenceContext?.custom);l&&(s=l[t])}if(n&&s!==void 0)return s;const a=this.getBaseTargetFromProps(this.props,t);return a!==void 0&&!In(a)?a:this.initialValues[t]!==void 0&&s===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new Ly),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){tb.render(this.render)}}class UA extends I7{constructor(){super(...arguments),this.KeyframeResolver=o7}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){const s=t.style;return s?s[n]:void 0}removeValueFromRenderState(t,{vars:n,style:s}){delete n[t],delete s[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;In(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class La{constructor(t){this.isMounted=!1,this.node=t}update(){}}function BA({top:e,left:t,right:n,bottom:s}){return{x:{min:t,max:n},y:{min:e,max:s}}}function D7({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function P7(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),s=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}function ug(e){return e===void 0||e===1}function Dv({scale:e,scaleX:t,scaleY:n}){return!ug(e)||!ug(t)||!ug(n)}function oi(e){return Dv(e)||VA(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function VA(e){return zS(e.x)||zS(e.y)}function zS(e){return e&&e!=="0%"}function Uf(e,t,n){const s=e-n,a=t*s;return n+a}function LS(e,t,n,s,a){return a!==void 0&&(e=Uf(e,a,s)),Uf(e,n,s)+t}function Pv(e,t=0,n=1,s,a){e.min=LS(e.min,t,n,s,a),e.max=LS(e.max,t,n,s,a)}function FA(e,{x:t,y:n}){Pv(e.x,t.translate,t.scale,t.originPoint),Pv(e.y,n.translate,n.scale,n.originPoint)}const $S=.999999999999,US=1.0000000000001;function z7(e,t,n,s=!1){const a=n.length;if(!a)return;t.x=t.y=1;let l,u;for(let d=0;d<a;d++){l=n[d],u=l.projectionDelta;const{visualElement:p}=l.options;p&&p.props.style&&p.props.style.display==="contents"||(s&&l.options.layoutScroll&&l.scroll&&l!==l.root&&Vo(e,{x:-l.scroll.offset.x,y:-l.scroll.offset.y}),u&&(t.x*=u.x.scale,t.y*=u.y.scale,FA(e,u)),s&&oi(l.latestValues)&&Vo(e,l.latestValues))}t.x<US&&t.x>$S&&(t.x=1),t.y<US&&t.y>$S&&(t.y=1)}function Bo(e,t){e.min=e.min+t,e.max=e.max+t}function BS(e,t,n,s,a=.5){const l=Ht(e.min,e.max,a);Pv(e,t,n,l,s)}function Vo(e,t){BS(e.x,t.x,t.scaleX,t.scale,t.originX),BS(e.y,t.y,t.scaleY,t.scale,t.originY)}function HA(e,t){return BA(P7(e.getBoundingClientRect(),t))}function L7(e,t,n){const s=HA(e,n),{scroll:a}=t;return a&&(Bo(s.x,a.offset.x),Bo(s.y,a.offset.y)),s}const $7={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},U7=ol.length;function B7(e,t,n){let s="",a=!0;for(let l=0;l<U7;l++){const u=ol[l],d=e[u];if(d===void 0)continue;let p=!0;if(typeof d=="number")p=d===(u.startsWith("scale")?1:0);else{const h=parseFloat(d);p=u.startsWith("scale")?h===1:h===0}if(!p||n){const h=_A(d,eb[u]);if(!p){a=!1;const m=$7[u]||u;s+=`${m}(${h}) `}n&&(t[u]=h)}}return s=s.trim(),n?s=n(t,a?"":s):a&&(s="none"),s}function ib(e,t,n){const{style:s,vars:a,transformOrigin:l}=e;let u=!1,d=!1;for(const p in t){const h=t[p];if(ll.has(p)){u=!0;continue}else if(tA(p)){a[p]=h;continue}else{const m=_A(h,eb[p]);p.startsWith("origin")?(d=!0,l[p]=m):s[p]=m}}if(t.transform||(u||n?s.transform=B7(t,e.transform,n):s.transform&&(s.transform="none")),d){const{originX:p="50%",originY:h="50%",originZ:m=0}=l;s.transformOrigin=`${p} ${h} ${m}`}}function qA(e,{style:t,vars:n},s,a){const l=e.style;let u;for(u in t)l[u]=t[u];a?.applyProjectionStyles(l,s);for(u in n)l.setProperty(u,n[u])}function VS(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const nc={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(_e.test(e))e=parseFloat(e);else return e;const n=VS(e,t.target.x),s=VS(e,t.target.y);return`${n}% ${s}%`}},V7={correct:(e,{treeScale:t,projectionDelta:n})=>{const s=e,a=Vs.parse(e);if(a.length>5)return s;const l=Vs.createTransformer(e),u=typeof a[0]!="number"?1:0,d=n.x.scale*t.x,p=n.y.scale*t.y;a[0+u]/=d,a[1+u]/=p;const h=Ht(d,p,.5);return typeof a[2+u]=="number"&&(a[2+u]/=h),typeof a[3+u]=="number"&&(a[3+u]/=h),l(a)}},zv={borderRadius:{...nc,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:nc,borderTopRightRadius:nc,borderBottomLeftRadius:nc,borderBottomRightRadius:nc,boxShadow:V7};function ZA(e,{layout:t,layoutId:n}){return ll.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!zv[e]||e==="opacity")}function ob(e,t,n){const s=e.style,a=t?.style,l={};if(!s)return l;for(const u in s)(In(s[u])||a&&In(a[u])||ZA(u,e)||n?.getValue(u)?.liveStyle!==void 0)&&(l[u]=s[u]);return l}function F7(e){return window.getComputedStyle(e)}class H7 extends UA{constructor(){super(...arguments),this.type="html",this.renderInstance=qA}readValueFromInstance(t,n){if(ll.has(n))return this.projection?.isProjecting?jv(n):cV(t,n);{const s=F7(t),a=(tA(n)?s.getPropertyValue(n):s[n])||0;return typeof a=="string"?a.trim():a}}measureInstanceViewportBox(t,{transformPagePoint:n}){return HA(t,n)}build(t,n,s){ib(t,n,s.transformTemplate)}scrapeMotionValuesFromProps(t,n,s){return ob(t,n,s)}}const q7={offset:"stroke-dashoffset",array:"stroke-dasharray"},Z7={offset:"strokeDashoffset",array:"strokeDasharray"};function W7(e,t,n=1,s=0,a=!0){e.pathLength=1;const l=a?q7:Z7;e[l.offset]=`${-s}`,e[l.array]=`${t} ${n}`}const Y7=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function WA(e,{attrX:t,attrY:n,attrScale:s,pathLength:a,pathSpacing:l=1,pathOffset:u=0,...d},p,h,m){if(ib(e,d,h),p){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:y,style:x}=e;y.transform&&(x.transform=y.transform,delete y.transform),(x.transform||y.transformOrigin)&&(x.transformOrigin=y.transformOrigin??"50% 50%",delete y.transformOrigin),x.transform&&(x.transformBox=m?.transformBox??"fill-box",delete y.transformBox);for(const w of Y7)y[w]!==void 0&&(x[w]=y[w],delete y[w]);t!==void 0&&(y.x=t),n!==void 0&&(y.y=n),s!==void 0&&(y.scale=s),a!==void 0&&W7(y,a,l,u,!1)}const YA=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),GA=e=>typeof e=="string"&&e.toLowerCase()==="svg";function G7(e,t,n,s){qA(e,t,void 0,s);for(const a in t.attrs)e.setAttribute(YA.has(a)?a:Qy(a),t.attrs[a])}function KA(e,t,n){const s=ob(e,t,n);for(const a in e)if(In(e[a])||In(t[a])){const l=ol.indexOf(a)!==-1?"attr"+a.charAt(0).toUpperCase()+a.substring(1):a;s[l]=e[a]}return s}class K7 extends UA{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=pn}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(ll.has(n)){const s=AA(n);return s&&s.default||0}return n=YA.has(n)?n:Qy(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,s){return KA(t,n,s)}build(t,n,s){WA(t,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(t,n,s,a){G7(t,n,s,a)}mount(t){this.isSVGTag=GA(t.tagName),super.mount(t)}}const X7=ab.length;function XA(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?XA(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<X7;n++){const s=ab[n],a=e.props[s];($c(a)||a===!1)&&(t[s]=a)}return t}function JA(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let s=0;s<n;s++)if(t[s]!==e[s])return!1;return!0}const J7=[...rb].reverse(),Q7=rb.length;function eF(e){return t=>Promise.all(t.map(({animation:n,options:s})=>KV(e,n,s)))}function tF(e){let t=eF(e),n=FS(),s=!0;const a=p=>(h,m)=>{const y=Wo(e,m,p==="exit"?e.presenceContext?.custom:void 0);if(y){const{transition:x,transitionEnd:w,...j}=y;h={...h,...j,...w}}return h};function l(p){t=p(e)}function u(p){const{props:h}=e,m=XA(e.parent)||{},y=[],x=new Set;let w={},j=1/0;for(let k=0;k<Q7;k++){const E=J7[k],C=n[E],S=h[E]!==void 0?h[E]:m[E],R=$c(S),A=E===p?C.isActive:null;A===!1&&(j=k);let M=S===m[E]&&S!==h[E]&&R;if(M&&s&&e.manuallyAnimateOnMount&&(M=!1),C.protectedKeys={...w},!C.isActive&&A===null||!S&&!C.prevProp||mh(S)||typeof S=="boolean")continue;if(E==="exit"&&C.isActive&&A!==!0){C.prevResolvedValues&&(w={...w,...C.prevResolvedValues});continue}const _=nF(C.prevProp,S);let z=_||E===p&&C.isActive&&!M&&R||k>j&&R,V=!1;const U=Array.isArray(S)?S:[S];let O=U.reduce(a(E),{});A===!1&&(O={});const{prevResolvedValues:D={}}=C,H={...D,...O},W=L=>{z=!0,x.has(L)&&(V=!0,x.delete(L)),C.needsAnimating[L]=!0;const F=e.getValue(L);F&&(F.liveStyle=!1)};for(const L in H){const F=O[L],X=D[L];if(w.hasOwnProperty(L))continue;let G=!1;Tv(F)&&Tv(X)?G=!JA(F,X):G=F!==X,G?F!=null?W(L):x.add(L):F!==void 0&&x.has(L)?W(L):C.protectedKeys[L]=!0}C.prevProp=S,C.prevResolvedValues=O,C.isActive&&(w={...w,...O}),s&&e.blockInitialAnimation&&(z=!1);const q=M&&_;z&&(!q||V)&&y.push(...U.map(L=>{const F={type:E};if(typeof L=="string"&&s&&!q&&e.manuallyAnimateOnMount&&e.parent){const{parent:X}=e,G=Wo(X,L);if(X.enteringChildren&&G){const{delayChildren:I}=G.transition||{};F.delay=xA(X.enteringChildren,e,I)}}return{animation:L,options:F}}))}if(x.size){const k={};if(typeof h.initial!="boolean"){const E=Wo(e,Array.isArray(h.initial)?h.initial[0]:h.initial);E&&E.transition&&(k.transition=E.transition)}x.forEach(E=>{const C=e.getBaseTarget(E),S=e.getValue(E);S&&(S.liveStyle=!0),k[E]=C??null}),y.push({animation:k})}let N=!!y.length;return s&&(h.initial===!1||h.initial===h.animate)&&!e.manuallyAnimateOnMount&&(N=!1),s=!1,N?t(y):Promise.resolve()}function d(p,h){if(n[p].isActive===h)return Promise.resolve();e.variantChildren?.forEach(y=>y.animationState?.setActive(p,h)),n[p].isActive=h;const m=u(p);for(const y in n)n[y].protectedKeys={};return m}return{animateChanges:u,setActive:d,setAnimateFunction:l,getState:()=>n,reset:()=>{n=FS()}}}function nF(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!JA(t,e):!1}function ri(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function FS(){return{animate:ri(!0),whileInView:ri(),whileHover:ri(),whileTap:ri(),whileDrag:ri(),whileFocus:ri(),exit:ri()}}function HS(e,t){e.min=t.min,e.max=t.max}function Ls(e,t){HS(e.x,t.x),HS(e.y,t.y)}function qS(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}const QA=1e-4,sF=1-QA,rF=1+QA,eR=.01,aF=0-eR,iF=0+eR;function Vn(e){return e.max-e.min}function oF(e,t,n){return Math.abs(e-t)<=n}function ZS(e,t,n,s=.5){e.origin=s,e.originPoint=Ht(t.min,t.max,e.origin),e.scale=Vn(n)/Vn(t),e.translate=Ht(n.min,n.max,e.origin)-e.originPoint,(e.scale>=sF&&e.scale<=rF||isNaN(e.scale))&&(e.scale=1),(e.translate>=aF&&e.translate<=iF||isNaN(e.translate))&&(e.translate=0)}function kc(e,t,n,s){ZS(e.x,t.x,n.x,s?s.originX:void 0),ZS(e.y,t.y,n.y,s?s.originY:void 0)}function WS(e,t,n){e.min=n.min+t.min,e.max=e.min+Vn(t)}function lF(e,t,n){WS(e.x,t.x,n.x),WS(e.y,t.y,n.y)}function YS(e,t,n){e.min=t.min-n.min,e.max=e.min+Vn(t)}function Bf(e,t,n){YS(e.x,t.x,n.x),YS(e.y,t.y,n.y)}function GS(e,t,n,s,a){return e-=t,e=Uf(e,1/n,s),a!==void 0&&(e=Uf(e,1/a,s)),e}function cF(e,t=0,n=1,s=.5,a,l=e,u=e){if(or.test(t)&&(t=parseFloat(t),t=Ht(u.min,u.max,t/100)-u.min),typeof t!="number")return;let d=Ht(l.min,l.max,s);e===l&&(d-=t),e.min=GS(e.min,t,n,d,a),e.max=GS(e.max,t,n,d,a)}function KS(e,t,[n,s,a],l,u){cF(e,t[n],t[s],t[a],t.scale,l,u)}const uF=["x","scaleX","originX"],dF=["y","scaleY","originY"];function XS(e,t,n,s){KS(e.x,t,uF,n?n.x:void 0,s?s.x:void 0),KS(e.y,t,dF,n?n.y:void 0,s?s.y:void 0)}function JS(e){return e.translate===0&&e.scale===1}function tR(e){return JS(e.x)&&JS(e.y)}function QS(e,t){return e.min===t.min&&e.max===t.max}function fF(e,t){return QS(e.x,t.x)&&QS(e.y,t.y)}function eN(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function nR(e,t){return eN(e.x,t.x)&&eN(e.y,t.y)}function tN(e){return Vn(e.x)/Vn(e.y)}function nN(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function tr(e){return[e("x"),e("y")]}function hF(e,t,n){let s="";const a=e.x.translate/t.x,l=e.y.translate/t.y,u=n?.z||0;if((a||l||u)&&(s=`translate3d(${a}px, ${l}px, ${u}px) `),(t.x!==1||t.y!==1)&&(s+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:h,rotate:m,rotateX:y,rotateY:x,skewX:w,skewY:j}=n;h&&(s=`perspective(${h}px) ${s}`),m&&(s+=`rotate(${m}deg) `),y&&(s+=`rotateX(${y}deg) `),x&&(s+=`rotateY(${x}deg) `),w&&(s+=`skewX(${w}deg) `),j&&(s+=`skewY(${j}deg) `)}const d=e.x.scale*t.x,p=e.y.scale*t.y;return(d!==1||p!==1)&&(s+=`scale(${d}, ${p})`),s||"none"}const sR=["TopLeft","TopRight","BottomLeft","BottomRight"],pF=sR.length,sN=e=>typeof e=="string"?parseFloat(e):e,rN=e=>typeof e=="number"||_e.test(e);function mF(e,t,n,s,a,l){a?(e.opacity=Ht(0,n.opacity??1,gF(s)),e.opacityExit=Ht(t.opacity??1,0,vF(s))):l&&(e.opacity=Ht(t.opacity??1,n.opacity??1,s));for(let u=0;u<pF;u++){const d=`border${sR[u]}Radius`;let p=aN(t,d),h=aN(n,d);if(p===void 0&&h===void 0)continue;p||(p=0),h||(h=0),p===0||h===0||rN(p)===rN(h)?(e[d]=Math.max(Ht(sN(p),sN(h),s),0),(or.test(h)||or.test(p))&&(e[d]+="%")):e[d]=h}(t.rotate||n.rotate)&&(e.rotate=Ht(t.rotate||0,n.rotate||0,s))}function aN(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const gF=rR(0,.5,GT),vF=rR(.5,.95,As);function rR(e,t,n){return s=>s<e?0:s>t?1:n(Pc(e,t,s))}function yF(e,t,n){const s=In(e)?e:el(e);return s.start(Xy("",s,t,n)),s.animation}function Uc(e,t,n,s={passive:!0}){return e.addEventListener(t,n,s),()=>e.removeEventListener(t,n)}const bF=(e,t)=>e.depth-t.depth;class xF{constructor(){this.children=[],this.isDirty=!1}add(t){Py(this.children,t),this.isDirty=!0}remove(t){Df(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(bF),this.isDirty=!1,this.children.forEach(t)}}function wF(e,t){const n=Bn.now(),s=({timestamp:a})=>{const l=a-n;l>=t&&(Aa(s),e(l-t))};return At.setup(s,!0),()=>Aa(s)}function of(e){return In(e)?e.get():e}class jF{constructor(){this.members=[]}add(t){Py(this.members,t);for(let n=this.members.length-1;n>=0;n--){const s=this.members[n];if(s===t||s===this.lead||s===this.prevLead)continue;const a=s.instance;a&&a.isConnected===!1&&s.isPresent!==!1&&!s.snapshot&&Df(this.members,s)}t.scheduleRender()}remove(t){if(Df(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){const n=this.members.findIndex(a=>t===a);if(n===0)return!1;let s;for(let a=n;a>=0;a--){const l=this.members[a],u=l.instance;if(l.isPresent!==!1&&(!u||u.isConnected!==!1)){s=l;break}}return s?(this.promote(s),!0):!1}promote(t,n){const s=this.lead;if(t!==s&&(this.prevLead=s,this.lead=t,t.show(),s)){s.instance&&s.scheduleRender(),t.scheduleRender();const a=s.options.layoutDependency,l=t.options.layoutDependency;if(!(a!==void 0&&l!==void 0&&a===l)){const p=s.instance;p&&p.isConnected===!1&&!s.snapshot||(t.resumeFrom=s,n&&(t.resumeFrom.preserveOpacity=!0),s.snapshot&&(t.snapshot=s.snapshot,t.snapshot.latestValues=s.animationValues||s.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0))}const{crossfade:d}=t.options;d===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(t=>{const{options:n,resumingFrom:s}=t;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}const lf={hasAnimatedSinceResize:!0,hasEverUpdated:!1},dg=["","X","Y","Z"],SF=1e3;let NF=0;function fg(e,t,n,s){const{latestValues:a}=t;a[e]&&(n[e]=a[e],t.setStaticValue(e,0),s&&(s[e]=0))}function aR(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=kA(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:a,layoutId:l}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",At,!(a||l))}const{parent:s}=e;s&&!s.hasCheckedOptimisedAppear&&aR(s)}function iR({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:s,resetTransform:a}){return class{constructor(u={},d=t?.()){this.id=NF++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(CF),this.nodes.forEach(MF),this.nodes.forEach(_F),this.nodes.forEach(TF)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=u,this.root=d?d.root||d:this,this.path=d?[...d.path,d]:[],this.parent=d,this.depth=d?d.depth+1:0;for(let p=0;p<this.path.length;p++)this.path[p].shouldResetTransform=!0;this.root===this&&(this.nodes=new xF)}addEventListener(u,d){return this.eventHandlers.has(u)||this.eventHandlers.set(u,new Ly),this.eventHandlers.get(u).add(d)}notifyListeners(u,...d){const p=this.eventHandlers.get(u);p&&p.notify(...d)}hasListeners(u){return this.eventHandlers.has(u)}mount(u){if(this.instance)return;this.isSVG=sb(u)&&!E7(u),this.instance=u;const{layoutId:d,layout:p,visualElement:h}=this.options;if(h&&!h.current&&h.mount(u),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(p||d)&&(this.isLayoutDirty=!0),e){let m,y=0;const x=()=>this.root.updateBlockedByResize=!1;At.read(()=>{y=window.innerWidth}),e(u,()=>{const w=window.innerWidth;w!==y&&(y=w,this.root.updateBlockedByResize=!0,m&&m(),m=wF(x,250),lf.hasAnimatedSinceResize&&(lf.hasAnimatedSinceResize=!1,this.nodes.forEach(lN)))})}d&&this.root.registerSharedNode(d,this),this.options.animate!==!1&&h&&(d||p)&&this.addEventListener("didUpdate",({delta:m,hasLayoutChanged:y,hasRelativeLayoutChanged:x,layout:w})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const j=this.options.transition||h.getDefaultTransition()||zF,{onLayoutAnimationStart:N,onLayoutAnimationComplete:k}=h.getProps(),E=!this.targetLayout||!nR(this.targetLayout,w),C=!y&&x;if(this.options.layoutRoot||this.resumeFrom||C||y&&(E||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const S={...Ky(j,"layout"),onPlay:N,onComplete:k};(h.shouldReduceMotion||this.options.layoutRoot)&&(S.delay=0,S.type=!1),this.startAnimation(S),this.setAnimationOrigin(m,C)}else y||lN(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=w})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const u=this.getStack();u&&u.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Aa(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(OF),this.animationId++)}getTransformTemplate(){const{visualElement:u}=this.options;return u&&u.getProps().transformTemplate}willUpdate(u=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&aR(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let m=0;m<this.path.length;m++){const y=this.path[m];y.shouldResetTransform=!0,y.updateScroll("snapshot"),y.options.layoutRoot&&y.willUpdate(!1)}const{layoutId:d,layout:p}=this.options;if(d===void 0&&!p)return;const h=this.getTransformTemplate();this.prevTransformTemplateValue=h?h(this.latestValues,""):void 0,this.updateSnapshot(),u&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(iN);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(oN);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(RF),this.nodes.forEach(kF),this.nodes.forEach(EF)):this.nodes.forEach(oN),this.clearAllSnapshots();const d=Bn.now();En.delta=ur(0,1e3/60,d-En.timestamp),En.timestamp=d,En.isProcessing=!0,sg.update.process(En),sg.preRender.process(En),sg.render.process(En),En.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,tb.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(AF),this.sharedNodes.forEach(IF)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,At.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){At.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Vn(this.snapshot.measuredBox.x)&&!Vn(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let p=0;p<this.path.length;p++)this.path[p].updateScroll();const u=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected=pn(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:d}=this.options;d&&d.notify("LayoutMeasure",this.layout.layoutBox,u?u.layoutBox:void 0)}updateScroll(u="measure"){let d=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===u&&(d=!1),d&&this.instance){const p=s(this.instance);this.scroll={animationId:this.root.animationId,phase:u,isRoot:p,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:p}}}resetTransform(){if(!a)return;const u=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,d=this.projectionDelta&&!tR(this.projectionDelta),p=this.getTransformTemplate(),h=p?p(this.latestValues,""):void 0,m=h!==this.prevTransformTemplateValue;u&&this.instance&&(d||oi(this.latestValues)||m)&&(a(this.instance,h),this.shouldResetTransform=!1,this.scheduleRender())}measure(u=!0){const d=this.measurePageBox();let p=this.removeElementScroll(d);return u&&(p=this.removeTransform(p)),LF(p),{animationId:this.root.animationId,measuredBox:d,layoutBox:p,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:u}=this.options;if(!u)return pn();const d=u.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some($F))){const{scroll:h}=this.root;h&&(Bo(d.x,h.offset.x),Bo(d.y,h.offset.y))}return d}removeElementScroll(u){const d=pn();if(Ls(d,u),this.scroll?.wasRoot)return d;for(let p=0;p<this.path.length;p++){const h=this.path[p],{scroll:m,options:y}=h;h!==this.root&&m&&y.layoutScroll&&(m.wasRoot&&Ls(d,u),Bo(d.x,m.offset.x),Bo(d.y,m.offset.y))}return d}applyTransform(u,d=!1){const p=pn();Ls(p,u);for(let h=0;h<this.path.length;h++){const m=this.path[h];!d&&m.options.layoutScroll&&m.scroll&&m!==m.root&&Vo(p,{x:-m.scroll.offset.x,y:-m.scroll.offset.y}),oi(m.latestValues)&&Vo(p,m.latestValues)}return oi(this.latestValues)&&Vo(p,this.latestValues),p}removeTransform(u){const d=pn();Ls(d,u);for(let p=0;p<this.path.length;p++){const h=this.path[p];if(!h.instance||!oi(h.latestValues))continue;Dv(h.latestValues)&&h.updateSnapshot();const m=pn(),y=h.measurePageBox();Ls(m,y),XS(d,h.latestValues,h.snapshot?h.snapshot.layoutBox:void 0,m)}return oi(this.latestValues)&&XS(d,this.latestValues),d}setTargetDelta(u){this.targetDelta=u,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(u){this.options={...this.options,...u,crossfade:u.crossfade!==void 0?u.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==En.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(u=!1){const d=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=d.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=d.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=d.isSharedProjectionDirty);const p=!!this.resumingFrom||this!==d;if(!(u||p&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:m,layoutId:y}=this.options;if(!this.layout||!(m||y))return;this.resolvedRelativeTargetAt=En.timestamp;const x=this.getClosestProjectingParent();x&&this.linkedParentVersion!==x.layoutVersion&&!x.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(x&&x.layout?this.createRelativeTarget(x,this.layout.layoutBox,x.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=pn(),this.targetWithTransforms=pn()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),lF(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Ls(this.target,this.layout.layoutBox),FA(this.target,this.targetDelta)):Ls(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,x&&!!x.resumingFrom==!!this.resumingFrom&&!x.options.layoutScroll&&x.target&&this.animationProgress!==1?this.createRelativeTarget(x,this.target,x.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||Dv(this.parent.latestValues)||VA(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(u,d,p){this.relativeParent=u,this.linkedParentVersion=u.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=pn(),this.relativeTargetOrigin=pn(),Bf(this.relativeTargetOrigin,d,p),Ls(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){const u=this.getLead(),d=!!this.resumingFrom||this!==u;let p=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(p=!1),d&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(p=!1),this.resolvedRelativeTargetAt===En.timestamp&&(p=!1),p)return;const{layout:h,layoutId:m}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(h||m))return;Ls(this.layoutCorrected,this.layout.layoutBox);const y=this.treeScale.x,x=this.treeScale.y;z7(this.layoutCorrected,this.treeScale,this.path,d),u.layout&&!u.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(u.target=u.layout.layoutBox,u.targetWithTransforms=pn());const{target:w}=u;if(!w){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(qS(this.prevProjectionDelta.x,this.projectionDelta.x),qS(this.prevProjectionDelta.y,this.projectionDelta.y)),kc(this.projectionDelta,this.layoutCorrected,w,this.latestValues),(this.treeScale.x!==y||this.treeScale.y!==x||!nN(this.projectionDelta.x,this.prevProjectionDelta.x)||!nN(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",w))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(u=!0){if(this.options.visualElement?.scheduleRender(),u){const d=this.getStack();d&&d.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Uo(),this.projectionDelta=Uo(),this.projectionDeltaWithTransform=Uo()}setAnimationOrigin(u,d=!1){const p=this.snapshot,h=p?p.latestValues:{},m={...this.latestValues},y=Uo();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!d;const x=pn(),w=p?p.source:void 0,j=this.layout?this.layout.source:void 0,N=w!==j,k=this.getStack(),E=!k||k.members.length<=1,C=!!(N&&!E&&this.options.crossfade===!0&&!this.path.some(PF));this.animationProgress=0;let S;this.mixTargetDelta=R=>{const A=R/1e3;cN(y.x,u.x,A),cN(y.y,u.y,A),this.setTargetDelta(y),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Bf(x,this.layout.layoutBox,this.relativeParent.layout.layoutBox),DF(this.relativeTarget,this.relativeTargetOrigin,x,A),S&&fF(this.relativeTarget,S)&&(this.isProjectionDirty=!1),S||(S=pn()),Ls(S,this.relativeTarget)),N&&(this.animationValues=m,mF(m,h,this.latestValues,A,C,E)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=A},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(u){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Aa(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=At.update(()=>{lf.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=el(0)),this.motionValue.jump(0,!1),this.currentAnimation=yF(this.motionValue,[0,1e3],{...u,velocity:0,isSync:!0,onUpdate:d=>{this.mixTargetDelta(d),u.onUpdate&&u.onUpdate(d)},onStop:()=>{},onComplete:()=>{u.onComplete&&u.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const u=this.getStack();u&&u.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(SF),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const u=this.getLead();let{targetWithTransforms:d,target:p,layout:h,latestValues:m}=u;if(!(!d||!p||!h)){if(this!==u&&this.layout&&h&&oR(this.options.animationType,this.layout.layoutBox,h.layoutBox)){p=this.target||pn();const y=Vn(this.layout.layoutBox.x);p.x.min=u.target.x.min,p.x.max=p.x.min+y;const x=Vn(this.layout.layoutBox.y);p.y.min=u.target.y.min,p.y.max=p.y.min+x}Ls(d,p),Vo(d,m),kc(this.projectionDeltaWithTransform,this.layoutCorrected,d,m)}}registerSharedNode(u,d){this.sharedNodes.has(u)||this.sharedNodes.set(u,new jF),this.sharedNodes.get(u).add(d);const h=d.options.initialPromotionConfig;d.promote({transition:h?h.transition:void 0,preserveFollowOpacity:h&&h.shouldPreserveFollowOpacity?h.shouldPreserveFollowOpacity(d):void 0})}isLead(){const u=this.getStack();return u?u.lead===this:!0}getLead(){const{layoutId:u}=this.options;return u?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:u}=this.options;return u?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:u}=this.options;if(u)return this.root.sharedNodes.get(u)}promote({needsReset:u,transition:d,preserveFollowOpacity:p}={}){const h=this.getStack();h&&h.promote(this,p),u&&(this.projectionDelta=void 0,this.needsReset=!0),d&&this.setOptions({transition:d})}relegate(){const u=this.getStack();return u?u.relegate(this):!1}resetSkewAndRotation(){const{visualElement:u}=this.options;if(!u)return;let d=!1;const{latestValues:p}=u;if((p.z||p.rotate||p.rotateX||p.rotateY||p.rotateZ||p.skewX||p.skewY)&&(d=!0),!d)return;const h={};p.z&&fg("z",u,h,this.animationValues);for(let m=0;m<dg.length;m++)fg(`rotate${dg[m]}`,u,h,this.animationValues),fg(`skew${dg[m]}`,u,h,this.animationValues);u.render();for(const m in h)u.setStaticValue(m,h[m]),this.animationValues&&(this.animationValues[m]=h[m]);u.scheduleRender()}applyProjectionStyles(u,d){if(!this.instance||this.isSVG)return;if(!this.isVisible){u.visibility="hidden";return}const p=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,u.visibility="",u.opacity="",u.pointerEvents=of(d?.pointerEvents)||"",u.transform=p?p(this.latestValues,""):"none";return}const h=this.getLead();if(!this.projectionDelta||!this.layout||!h.target){this.options.layoutId&&(u.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,u.pointerEvents=of(d?.pointerEvents)||""),this.hasProjected&&!oi(this.latestValues)&&(u.transform=p?p({},""):"none",this.hasProjected=!1);return}u.visibility="";const m=h.animationValues||h.latestValues;this.applyTransformsToTarget();let y=hF(this.projectionDeltaWithTransform,this.treeScale,m);p&&(y=p(m,y)),u.transform=y;const{x,y:w}=this.projectionDelta;u.transformOrigin=`${x.origin*100}% ${w.origin*100}% 0`,h.animationValues?u.opacity=h===this?m.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:m.opacityExit:u.opacity=h===this?m.opacity!==void 0?m.opacity:"":m.opacityExit!==void 0?m.opacityExit:0;for(const j in zv){if(m[j]===void 0)continue;const{correct:N,applyTo:k,isCSSVariable:E}=zv[j],C=y==="none"?m[j]:N(m[j],h);if(k){const S=k.length;for(let R=0;R<S;R++)u[k[R]]=C}else E?this.options.visualElement.renderState.vars[j]=C:u[j]=C}this.options.layoutId&&(u.pointerEvents=h===this?of(d?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(u=>u.currentAnimation?.stop()),this.root.nodes.forEach(iN),this.root.sharedNodes.clear()}}}function kF(e){e.updateLayout()}function EF(e){const t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:s}=e.layout,{animationType:a}=e.options,l=t.source!==e.layout.source;a==="size"?tr(m=>{const y=l?t.measuredBox[m]:t.layoutBox[m],x=Vn(y);y.min=n[m].min,y.max=y.min+x}):oR(a,t.layoutBox,n)&&tr(m=>{const y=l?t.measuredBox[m]:t.layoutBox[m],x=Vn(n[m]);y.max=y.min+x,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[m].max=e.relativeTarget[m].min+x)});const u=Uo();kc(u,n,t.layoutBox);const d=Uo();l?kc(d,e.applyTransform(s,!0),t.measuredBox):kc(d,n,t.layoutBox);const p=!tR(u);let h=!1;if(!e.resumeFrom){const m=e.getClosestProjectingParent();if(m&&!m.resumeFrom){const{snapshot:y,layout:x}=m;if(y&&x){const w=pn();Bf(w,t.layoutBox,y.layoutBox);const j=pn();Bf(j,n,x.layoutBox),nR(w,j)||(h=!0),m.options.layoutRoot&&(e.relativeTarget=j,e.relativeTargetOrigin=w,e.relativeParent=m)}}}e.notifyListeners("didUpdate",{layout:n,snapshot:t,delta:d,layoutDelta:u,hasLayoutChanged:p,hasRelativeLayoutChanged:h})}else if(e.isLead()){const{onExitComplete:n}=e.options;n&&n()}e.options.transition=void 0}function CF(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function TF(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function AF(e){e.clearSnapshot()}function iN(e){e.clearMeasurements()}function oN(e){e.isLayoutDirty=!1}function RF(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function lN(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function MF(e){e.resolveTargetDelta()}function _F(e){e.calcProjection()}function OF(e){e.resetSkewAndRotation()}function IF(e){e.removeLeadSnapshot()}function cN(e,t,n){e.translate=Ht(t.translate,0,n),e.scale=Ht(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function uN(e,t,n,s){e.min=Ht(t.min,n.min,s),e.max=Ht(t.max,n.max,s)}function DF(e,t,n,s){uN(e.x,t.x,n.x,s),uN(e.y,t.y,n.y,s)}function PF(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const zF={duration:.45,ease:[.4,0,.1,1]},dN=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),fN=dN("applewebkit/")&&!dN("chrome/")?Math.round:As;function hN(e){e.min=fN(e.min),e.max=fN(e.max)}function LF(e){hN(e.x),hN(e.y)}function oR(e,t,n){return e==="position"||e==="preserve-aspect"&&!oF(tN(t),tN(n),.2)}function $F(e){return e!==e.root&&e.scroll?.wasRoot}const UF=iR({attachResizeListener:(e,t)=>Uc(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),hg={current:void 0},lR=iR({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!hg.current){const e=new UF({});e.mount(window),e.setOptions({layoutScroll:!0}),hg.current=e}return hg.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),lb=g.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function pN(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function BF(...e){return t=>{let n=!1;const s=e.map(a=>{const l=pN(a,t);return!n&&typeof l=="function"&&(n=!0),l});if(n)return()=>{for(let a=0;a<s.length;a++){const l=s[a];typeof l=="function"?l():pN(e[a],null)}}}}function VF(...e){return g.useCallback(BF(...e),e)}class FF extends g.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const s=n.offsetParent,a=Ov(s)&&s.offsetWidth||0,l=Ov(s)&&s.offsetHeight||0,u=this.props.sizeRef.current;u.height=n.offsetHeight||0,u.width=n.offsetWidth||0,u.top=n.offsetTop,u.left=n.offsetLeft,u.right=a-u.width-u.left,u.bottom=l-u.height-u.top}return null}componentDidUpdate(){}render(){return this.props.children}}function HF({children:e,isPresent:t,anchorX:n,anchorY:s,root:a,pop:l}){const u=g.useId(),d=g.useRef(null),p=g.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0}),{nonce:h}=g.useContext(lb),m=e.props?.ref??e?.ref,y=VF(d,m);return g.useInsertionEffect(()=>{const{width:x,height:w,top:j,left:N,right:k,bottom:E}=p.current;if(t||l===!1||!d.current||!x||!w)return;const C=n==="left"?`left: ${N}`:`right: ${k}`,S=s==="bottom"?`bottom: ${E}`:`top: ${j}`;d.current.dataset.motionPopId=u;const R=document.createElement("style");h&&(R.nonce=h);const A=a??document.head;return A.appendChild(R),R.sheet&&R.sheet.insertRule(`
|
|
123
|
-
[data-motion-pop-id="${u}"] {
|
|
124
|
-
position: absolute !important;
|
|
125
|
-
width: ${x}px !important;
|
|
126
|
-
height: ${w}px !important;
|
|
127
|
-
${C}px !important;
|
|
128
|
-
${S}px !important;
|
|
129
|
-
}
|
|
130
|
-
`),()=>{A.contains(R)&&A.removeChild(R)}},[t]),o.jsx(FF,{isPresent:t,childRef:d,sizeRef:p,pop:l,children:l===!1?e:g.cloneElement(e,{ref:y})})}const qF=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:a,presenceAffectsLayout:l,mode:u,anchorX:d,anchorY:p,root:h})=>{const m=Dy(ZF),y=g.useId();let x=!0,w=g.useMemo(()=>(x=!1,{id:y,initial:t,isPresent:n,custom:a,onExitComplete:j=>{m.set(j,!0);for(const N of m.values())if(!N)return;s&&s()},register:j=>(m.set(j,!1),()=>m.delete(j))}),[n,m,s]);return l&&x&&(w={...w}),g.useMemo(()=>{m.forEach((j,N)=>m.set(N,!1))},[n]),g.useEffect(()=>{!n&&!m.size&&s&&s()},[n]),e=o.jsx(HF,{pop:u==="popLayout",isPresent:n,anchorX:d,anchorY:p,root:h,children:e}),o.jsx(ph.Provider,{value:w,children:e})};function ZF(){return new Map}function cR(e=!0){const t=g.useContext(ph);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:a}=t,l=g.useId();g.useEffect(()=>{if(e)return a(l)},[e]);const u=g.useCallback(()=>e&&s&&s(l),[l,s,e]);return!n&&s?[!1,u]:[!0]}const Md=e=>e.key||"";function mN(e){const t=[];return g.Children.forEach(e,n=>{g.isValidElement(n)&&t.push(n)}),t}const WF=({children:e,custom:t,initial:n=!0,onExitComplete:s,presenceAffectsLayout:a=!0,mode:l="sync",propagate:u=!1,anchorX:d="left",anchorY:p="top",root:h})=>{const[m,y]=cR(u),x=g.useMemo(()=>mN(e),[e]),w=u&&!m?[]:x.map(Md),j=g.useRef(!0),N=g.useRef(x),k=Dy(()=>new Map),E=g.useRef(new Set),[C,S]=g.useState(x),[R,A]=g.useState(x);zT(()=>{j.current=!1,N.current=x;for(let z=0;z<R.length;z++){const V=Md(R[z]);w.includes(V)?(k.delete(V),E.current.delete(V)):k.get(V)!==!0&&k.set(V,!1)}},[R,w.length,w.join("-")]);const M=[];if(x!==C){let z=[...x];for(let V=0;V<R.length;V++){const U=R[V],O=Md(U);w.includes(O)||(z.splice(V,0,U),M.push(U))}return l==="wait"&&M.length&&(z=M),A(mN(z)),S(x),null}const{forceRender:_}=g.useContext(Iy);return o.jsx(o.Fragment,{children:R.map(z=>{const V=Md(z),U=u&&!m?!1:x===R||w.includes(V),O=()=>{if(E.current.has(V))return;if(E.current.add(V),k.has(V))k.set(V,!0);else return;let D=!0;k.forEach(H=>{H||(D=!1)}),D&&(_?.(),A(N.current),u&&y?.(),s&&s())};return o.jsx(qF,{isPresent:U,initial:!j.current||n?void 0:!1,custom:t,presenceAffectsLayout:a,mode:l,root:h,onExitComplete:U?void 0:O,anchorX:d,anchorY:p,children:z},V)})})},uR=g.createContext({strict:!1}),gN={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let vN=!1;function YF(){if(vN)return;const e={};for(const t in gN)e[t]={isEnabled:n=>gN[t].some(s=>!!n[s])};$A(e),vN=!0}function dR(){return YF(),O7()}function GF(e){const t=dR();for(const n in e)t[n]={...t[n],...e[n]};$A(t)}const KF=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function Vf(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||KF.has(e)}let fR=e=>!Vf(e);function XF(e){typeof e=="function"&&(fR=t=>t.startsWith("on")?!Vf(t):e(t))}try{XF(require("@emotion/is-prop-valid").default)}catch{}function JF(e,t,n){const s={};for(const a in e)a==="values"&&typeof e.values=="object"||(fR(a)||n===!0&&Vf(a)||!t&&!Vf(a)||e.draggable&&a.startsWith("onDrag"))&&(s[a]=e[a]);return s}const vh=g.createContext({});function QF(e,t){if(gh(e)){const{initial:n,animate:s}=e;return{initial:n===!1||$c(n)?n:void 0,animate:$c(s)?s:void 0}}return e.inherit!==!1?t:{}}function eH(e){const{initial:t,animate:n}=QF(e,g.useContext(vh));return g.useMemo(()=>({initial:t,animate:n}),[yN(t),yN(n)])}function yN(e){return Array.isArray(e)?e.join(" "):e}const cb=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function hR(e,t,n){for(const s in t)!In(t[s])&&!ZA(s,n)&&(e[s]=t[s])}function tH({transformTemplate:e},t){return g.useMemo(()=>{const n=cb();return ib(n,t,e),Object.assign({},n.vars,n.style)},[t])}function nH(e,t){const n=e.style||{},s={};return hR(s,n,e),Object.assign(s,tH(e,t)),s}function sH(e,t){const n={},s=nH(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=s,n}const pR=()=>({...cb(),attrs:{}});function rH(e,t,n,s){const a=g.useMemo(()=>{const l=pR();return WA(l,t,GA(s),e.transformTemplate,e.style),{...l.attrs,style:{...l.style}}},[t]);if(e.style){const l={};hR(l,e.style,e),a.style={...l,...a.style}}return a}const aH=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function ub(e){return typeof e!="string"||e.includes("-")?!1:!!(aH.indexOf(e)>-1||/[A-Z]/u.test(e))}function iH(e,t,n,{latestValues:s},a,l=!1,u){const p=(u??ub(e)?rH:sH)(t,s,a,e),h=JF(t,typeof e=="string",l),m=e!==g.Fragment?{...h,...p,ref:n}:{},{children:y}=t,x=g.useMemo(()=>In(y)?y.get():y,[y]);return g.createElement(e,{...m,children:x})}function oH({scrapeMotionValuesFromProps:e,createRenderState:t},n,s,a){return{latestValues:lH(n,s,a,e),renderState:t()}}function lH(e,t,n,s){const a={},l=s(e,{});for(const x in l)a[x]=of(l[x]);let{initial:u,animate:d}=e;const p=gh(e),h=zA(e);t&&h&&!p&&e.inherit!==!1&&(u===void 0&&(u=t.initial),d===void 0&&(d=t.animate));let m=n?n.initial===!1:!1;m=m||u===!1;const y=m?d:u;if(y&&typeof y!="boolean"&&!mh(y)){const x=Array.isArray(y)?y:[y];for(let w=0;w<x.length;w++){const j=Jy(e,x[w]);if(j){const{transitionEnd:N,transition:k,...E}=j;for(const C in E){let S=E[C];if(Array.isArray(S)){const R=m?S.length-1:0;S=S[R]}S!==null&&(a[C]=S)}for(const C in N)a[C]=N[C]}}}return a}const mR=e=>(t,n)=>{const s=g.useContext(vh),a=g.useContext(ph),l=()=>oH(e,t,s,a);return n?l():Dy(l)},cH=mR({scrapeMotionValuesFromProps:ob,createRenderState:cb}),uH=mR({scrapeMotionValuesFromProps:KA,createRenderState:pR}),dH=Symbol.for("motionComponentSymbol");function fH(e,t,n){const s=g.useRef(n);g.useInsertionEffect(()=>{s.current=n});const a=g.useRef(null);return g.useCallback(l=>{l&&e.onMount?.(l),t&&(l?t.mount(l):t.unmount());const u=s.current;if(typeof u=="function")if(l){const d=u(l);typeof d=="function"&&(a.current=d)}else a.current?(a.current(),a.current=null):u(l);else u&&(u.current=l)},[t])}const gR=g.createContext({});function Mo(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function hH(e,t,n,s,a,l){const{visualElement:u}=g.useContext(vh),d=g.useContext(uR),p=g.useContext(ph),h=g.useContext(lb),m=h.reducedMotion,y=h.skipAnimations,x=g.useRef(null),w=g.useRef(!1);s=s||d.renderer,!x.current&&s&&(x.current=s(e,{visualState:t,parent:u,props:n,presenceContext:p,blockInitialAnimation:p?p.initial===!1:!1,reducedMotionConfig:m,skipAnimations:y,isSVG:l}),w.current&&x.current&&(x.current.manuallyAnimateOnMount=!0));const j=x.current,N=g.useContext(gR);j&&!j.projection&&a&&(j.type==="html"||j.type==="svg")&&pH(x.current,n,a,N);const k=g.useRef(!1);g.useInsertionEffect(()=>{j&&k.current&&j.update(n,p)});const E=n[NA],C=g.useRef(!!E&&!window.MotionHandoffIsComplete?.(E)&&window.MotionHasOptimisedAnimation?.(E));return zT(()=>{w.current=!0,j&&(k.current=!0,window.MotionIsMounted=!0,j.updateFeatures(),j.scheduleRenderMicrotask(),C.current&&j.animationState&&j.animationState.animateChanges())}),g.useEffect(()=>{j&&(!C.current&&j.animationState&&j.animationState.animateChanges(),C.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(E)}),C.current=!1),j.enteringChildren=void 0)}),j}function pH(e,t,n,s){const{layoutId:a,layout:l,drag:u,dragConstraints:d,layoutScroll:p,layoutRoot:h,layoutCrossfade:m}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:vR(e.parent)),e.projection.setOptions({layoutId:a,layout:l,alwaysMeasureLayout:!!u||d&&Mo(d),visualElement:e,animationType:typeof l=="string"?l:"both",initialPromotionConfig:s,crossfade:m,layoutScroll:p,layoutRoot:h})}function vR(e){if(e)return e.options.allowProjection!==!1?e.projection:vR(e.parent)}function pg(e,{forwardMotionProps:t=!1,type:n}={},s,a){s&&GF(s);const l=n?n==="svg":ub(e),u=l?uH:cH;function d(h,m){let y;const x={...g.useContext(lb),...h,layoutId:mH(h)},{isStatic:w}=x,j=eH(h),N=u(h,w);if(!w&&PT){gH();const k=vH(x);y=k.MeasureLayout,j.visualElement=hH(e,N,x,a,k.ProjectionNode,l)}return o.jsxs(vh.Provider,{value:j,children:[y&&j.visualElement?o.jsx(y,{visualElement:j.visualElement,...x}):null,iH(e,h,fH(N,j.visualElement,m),N,w,t,l)]})}d.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const p=g.forwardRef(d);return p[dH]=e,p}function mH({layoutId:e}){const t=g.useContext(Iy).id;return t&&e!==void 0?t+"-"+e:e}function gH(e,t){g.useContext(uR).strict}function vH(e){const t=dR(),{drag:n,layout:s}=t;if(!n&&!s)return{};const a={...n,...s};return{MeasureLayout:n?.isEnabled(e)||s?.isEnabled(e)?a.MeasureLayout:void 0,ProjectionNode:a.ProjectionNode}}function yH(e,t){if(typeof Proxy>"u")return pg;const n=new Map,s=(l,u)=>pg(l,u,e,t),a=(l,u)=>s(l,u);return new Proxy(a,{get:(l,u)=>u==="create"?s:(n.has(u)||n.set(u,pg(u,void 0,e,t)),n.get(u))})}const bH=(e,t)=>t.isSVG??ub(e)?new K7(t):new H7(t,{allowProjection:e!==g.Fragment});class xH extends La{constructor(t){super(t),t.animationState||(t.animationState=tF(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();mh(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let wH=0;class jH extends La{constructor(){super(...arguments),this.id=wH++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===s)return;const a=this.node.animationState.setActive("exit",!t);n&&!t&&a.then(()=>{n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const SH={animation:{Feature:xH},exit:{Feature:jH}};function eu(e){return{point:{x:e.pageX,y:e.pageY}}}const NH=e=>t=>nb(t)&&e(t,eu(t));function Ec(e,t,n,s){return Uc(e,t,NH(n),s)}const yR=({current:e})=>e?e.ownerDocument.defaultView:null,bN=(e,t)=>Math.abs(e-t);function kH(e,t){const n=bN(e.x,t.x),s=bN(e.y,t.y);return Math.sqrt(n**2+s**2)}const xN=new Set(["auto","scroll"]);class bR{constructor(t,n,{transformPagePoint:s,contextWindow:a=window,dragSnapToOrigin:l=!1,distanceThreshold:u=3,element:d}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=w=>{this.handleScroll(w.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const w=gg(this.lastMoveEventInfo,this.history),j=this.startEvent!==null,N=kH(w.offset,{x:0,y:0})>=this.distanceThreshold;if(!j&&!N)return;const{point:k}=w,{timestamp:E}=En;this.history.push({...k,timestamp:E});const{onStart:C,onMove:S}=this.handlers;j||(C&&C(this.lastMoveEvent,w),this.startEvent=this.lastMoveEvent),S&&S(this.lastMoveEvent,w)},this.handlePointerMove=(w,j)=>{this.lastMoveEvent=w,this.lastMoveEventInfo=mg(j,this.transformPagePoint),At.update(this.updatePoint,!0)},this.handlePointerUp=(w,j)=>{this.end();const{onEnd:N,onSessionEnd:k,resumeAnimation:E}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&E&&E(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const C=gg(w.type==="pointercancel"?this.lastMoveEventInfo:mg(j,this.transformPagePoint),this.history);this.startEvent&&N&&N(w,C),k&&k(w,C)},!nb(t))return;this.dragSnapToOrigin=l,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=u,this.contextWindow=a||window;const p=eu(t),h=mg(p,this.transformPagePoint),{point:m}=h,{timestamp:y}=En;this.history=[{...m,timestamp:y}];const{onSessionStart:x}=n;x&&x(t,gg(h,this.history)),this.removeListeners=Xc(Ec(this.contextWindow,"pointermove",this.handlePointerMove),Ec(this.contextWindow,"pointerup",this.handlePointerUp),Ec(this.contextWindow,"pointercancel",this.handlePointerUp)),d&&this.startScrollTracking(d)}startScrollTracking(t){let n=t.parentElement;for(;n;){const s=getComputedStyle(n);(xN.has(s.overflowX)||xN.has(s.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const n=this.scrollPositions.get(t);if(!n)return;const s=t===window,a=s?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},l={x:a.x-n.x,y:a.y-n.y};l.x===0&&l.y===0||(s?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=l.x,this.lastMoveEventInfo.point.y+=l.y):this.history.length>0&&(this.history[0].x-=l.x,this.history[0].y-=l.y),this.scrollPositions.set(t,a),At.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Aa(this.updatePoint)}}function mg(e,t){return t?{point:t(e.point)}:e}function wN(e,t){return{x:e.x-t.x,y:e.y-t.y}}function gg({point:e},t){return{point:e,delta:wN(e,xR(t)),offset:wN(e,EH(t)),velocity:CH(t,.1)}}function EH(e){return e[0]}function xR(e){return e[e.length-1]}function CH(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const a=xR(e);for(;n>=0&&(s=e[n],!(a.timestamp-s.timestamp>Bs(t)));)n--;if(!s)return{x:0,y:0};s===e[0]&&e.length>2&&a.timestamp-s.timestamp>Bs(t)*2&&(s=e[1]);const l=Ts(a.timestamp-s.timestamp);if(l===0)return{x:0,y:0};const u={x:(a.x-s.x)/l,y:(a.y-s.y)/l};return u.x===1/0&&(u.x=0),u.y===1/0&&(u.y=0),u}function TH(e,{min:t,max:n},s){return t!==void 0&&e<t?e=s?Ht(t,e,s.min):Math.max(e,t):n!==void 0&&e>n&&(e=s?Ht(n,e,s.max):Math.min(e,n)),e}function jN(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function AH(e,{top:t,left:n,bottom:s,right:a}){return{x:jN(e.x,n,a),y:jN(e.y,t,s)}}function SN(e,t){let n=t.min-e.min,s=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,s]=[s,n]),{min:n,max:s}}function RH(e,t){return{x:SN(e.x,t.x),y:SN(e.y,t.y)}}function MH(e,t){let n=.5;const s=Vn(e),a=Vn(t);return a>s?n=Pc(t.min,t.max-s,e.min):s>a&&(n=Pc(e.min,e.max-a,t.min)),ur(0,1,n)}function _H(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const Lv=.35;function OH(e=Lv){return e===!1?e=0:e===!0&&(e=Lv),{x:NN(e,"left","right"),y:NN(e,"top","bottom")}}function NN(e,t,n){return{min:kN(e,t),max:kN(e,n)}}function kN(e,t){return typeof e=="number"?e:e[t]||0}const IH=new WeakMap;class DH{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=pn(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:a}=this.visualElement;if(a&&a.isPresent===!1)return;const l=y=>{n&&this.snapToCursor(eu(y).point),this.stopAnimation()},u=(y,x)=>{const{drag:w,dragPropagation:j,onDragStart:N}=this.getProps();if(w&&!j&&(this.openDragLock&&this.openDragLock(),this.openDragLock=c7(w),!this.openDragLock))return;this.latestPointerEvent=y,this.latestPanInfo=x,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),tr(E=>{let C=this.getAxisMotionValue(E).get()||0;if(or.test(C)){const{projection:S}=this.visualElement;if(S&&S.layout){const R=S.layout.layoutBox[E];R&&(C=Vn(R)*(parseFloat(C)/100))}}this.originPoint[E]=C}),N&&At.update(()=>N(y,x),!1,!0),Av(this.visualElement,"transform");const{animationState:k}=this.visualElement;k&&k.setActive("whileDrag",!0)},d=(y,x)=>{this.latestPointerEvent=y,this.latestPanInfo=x;const{dragPropagation:w,dragDirectionLock:j,onDirectionLock:N,onDrag:k}=this.getProps();if(!w&&!this.openDragLock)return;const{offset:E}=x;if(j&&this.currentDirection===null){this.currentDirection=zH(E),this.currentDirection!==null&&N&&N(this.currentDirection);return}this.updateAxis("x",x.point,E),this.updateAxis("y",x.point,E),this.visualElement.render(),k&&At.update(()=>k(y,x),!1,!0)},p=(y,x)=>{this.latestPointerEvent=y,this.latestPanInfo=x,this.stop(y,x),this.latestPointerEvent=null,this.latestPanInfo=null},h=()=>{const{dragSnapToOrigin:y}=this.getProps();(y||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:m}=this.getProps();this.panSession=new bR(t,{onSessionStart:l,onStart:u,onMove:d,onSessionEnd:p,resumeAnimation:h},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:m,distanceThreshold:s,contextWindow:yR(this.visualElement),element:this.visualElement.current})}stop(t,n){const s=t||this.latestPointerEvent,a=n||this.latestPanInfo,l=this.isDragging;if(this.cancel(),!l||!a||!s)return;const{velocity:u}=a;this.startAnimation(u);const{onDragEnd:d}=this.getProps();d&&At.postRender(()=>d(s,a))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,n,s){const{drag:a}=this.getProps();if(!s||!_d(t,a,this.currentDirection))return;const l=this.getAxisMotionValue(t);let u=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(u=TH(u,this.constraints[t],this.elastic[t])),l.set(u)}resolveConstraints(){const{dragConstraints:t,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,a=this.constraints;t&&Mo(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&s?this.constraints=AH(s.layoutBox,t):this.constraints=!1,this.elastic=OH(n),a!==this.constraints&&!Mo(t)&&s&&this.constraints&&!this.hasMutatedConstraints&&tr(l=>{this.constraints!==!1&&this.getAxisMotionValue(l)&&(this.constraints[l]=_H(s.layoutBox[l],this.constraints[l]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Mo(t))return!1;const s=t.current,{projection:a}=this.visualElement;if(!a||!a.layout)return!1;const l=L7(s,a.root,this.visualElement.getTransformPagePoint());let u=RH(a.layout.layoutBox,l);if(n){const d=n(D7(u));this.hasMutatedConstraints=!!d,d&&(u=BA(d))}return u}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:a,dragTransition:l,dragSnapToOrigin:u,onDragTransitionEnd:d}=this.getProps(),p=this.constraints||{},h=tr(m=>{if(!_d(m,n,this.currentDirection))return;let y=p&&p[m]||{};u&&(y={min:0,max:0});const x=a?200:1e6,w=a?40:1e7,j={type:"inertia",velocity:s?t[m]:0,bounceStiffness:x,bounceDamping:w,timeConstant:750,restDelta:1,restSpeed:10,...l,...y};return this.startAxisValueAnimation(m,j)});return Promise.all(h).then(d)}startAxisValueAnimation(t,n){const s=this.getAxisMotionValue(t);return Av(this.visualElement,t),s.start(Xy(t,s,0,n,this.visualElement,!1))}stopAnimation(){tr(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,s=this.visualElement.getProps(),a=s[n];return a||this.visualElement.getValue(t,(s.initial?s.initial[t]:void 0)||0)}snapToCursor(t){tr(n=>{const{drag:s}=this.getProps();if(!_d(n,s,this.currentDirection))return;const{projection:a}=this.visualElement,l=this.getAxisMotionValue(n);if(a&&a.layout){const{min:u,max:d}=a.layout.layoutBox[n],p=l.get()||0;l.set(t[n]-Ht(u,d,.5)+p)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Mo(n)||!s||!this.constraints)return;this.stopAnimation();const a={x:0,y:0};tr(u=>{const d=this.getAxisMotionValue(u);if(d&&this.constraints!==!1){const p=d.get();a[u]=MH({min:p,max:p},this.constraints[u])}});const{transformTemplate:l}=this.visualElement.getProps();this.visualElement.current.style.transform=l?l({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.constraints=!1,this.resolveConstraints(),tr(u=>{if(!_d(u,t,null))return;const d=this.getAxisMotionValue(u),{min:p,max:h}=this.constraints[u];d.set(Ht(p,h,a[u]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;IH.set(this.visualElement,this);const t=this.visualElement.current,n=Ec(t,"pointerdown",h=>{const{drag:m,dragListener:y=!0}=this.getProps(),x=h.target,w=x!==t&&m7(x);m&&y&&!w&&this.start(h)});let s;const a=()=>{const{dragConstraints:h}=this.getProps();Mo(h)&&h.current&&(this.constraints=this.resolveRefConstraints(),s||(s=PH(t,h.current,()=>this.scalePositionWithinConstraints())))},{projection:l}=this.visualElement,u=l.addEventListener("measure",a);l&&!l.layout&&(l.root&&l.root.updateScroll(),l.updateLayout()),At.read(a);const d=Uc(window,"resize",()=>this.scalePositionWithinConstraints()),p=l.addEventListener("didUpdate",(({delta:h,hasLayoutChanged:m})=>{this.isDragging&&m&&(tr(y=>{const x=this.getAxisMotionValue(y);x&&(this.originPoint[y]+=h[y].translate,x.set(x.get()+h[y].translate))}),this.visualElement.render())}));return()=>{d(),n(),u(),p&&p(),s&&s()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:a=!1,dragConstraints:l=!1,dragElastic:u=Lv,dragMomentum:d=!0}=t;return{...t,drag:n,dragDirectionLock:s,dragPropagation:a,dragConstraints:l,dragElastic:u,dragMomentum:d}}}function EN(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function PH(e,t,n){const s=OS(e,EN(n)),a=OS(t,EN(n));return()=>{s(),a()}}function _d(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function zH(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class LH extends La{constructor(t){super(t),this.removeGroupControls=As,this.removeListeners=As,this.controls=new DH(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||As}update(){const{dragControls:t}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};t!==n&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const vg=e=>(t,n)=>{e&&At.update(()=>e(t,n),!1,!0)};class $H extends La{constructor(){super(...arguments),this.removePointerDownListener=As}onPointerDown(t){this.session=new bR(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:yR(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:a}=this.node.getProps();return{onSessionStart:vg(t),onStart:vg(n),onMove:vg(s),onEnd:(l,u)=>{delete this.session,a&&At.postRender(()=>a(l,u))}}}mount(){this.removePointerDownListener=Ec(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let yg=!1;class UH extends g.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s,layoutId:a}=this.props,{projection:l}=t;l&&(n.group&&n.group.add(l),s&&s.register&&a&&s.register(l),yg&&l.root.didUpdate(),l.addEventListener("animationComplete",()=>{this.safeToRemove()}),l.setOptions({...l.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),lf.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:s,drag:a,isPresent:l}=this.props,{projection:u}=s;return u&&(u.isPresent=l,t.layoutDependency!==n&&u.setOptions({...u.options,layoutDependency:n}),yg=!0,a||t.layoutDependency!==n||n===void 0||t.isPresent!==l?u.willUpdate():this.safeToRemove(),t.isPresent!==l&&(l?u.promote():u.relegate()||At.postRender(()=>{const d=u.getStack();(!d||!d.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),tb.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:a}=t;yg=!0,a&&(a.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(a),s&&s.deregister&&s.deregister(a))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function wR(e){const[t,n]=cR(),s=g.useContext(Iy);return o.jsx(UH,{...e,layoutGroup:s,switchLayoutGroup:g.useContext(gR),isPresent:t,safeToRemove:n})}const BH={pan:{Feature:$H},drag:{Feature:LH,ProjectionNode:lR,MeasureLayout:wR}};function CN(e,t,n){const{props:s}=e;e.animationState&&s.whileHover&&e.animationState.setActive("whileHover",n==="Start");const a="onHover"+n,l=s[a];l&&At.postRender(()=>l(t,eu(t)))}class VH extends La{mount(){const{current:t}=this.node;t&&(this.unmount=d7(t,(n,s)=>(CN(this.node,s,"Start"),a=>CN(this.node,a,"End"))))}unmount(){}}class FH extends La{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Xc(Uc(this.node.current,"focus",()=>this.onFocus()),Uc(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function TN(e,t,n){const{props:s}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&s.whileTap&&e.animationState.setActive("whileTap",n==="Start");const a="onTap"+(n==="End"?"":n),l=s[a];l&&At.postRender(()=>l(t,eu(t)))}class HH extends La{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:s}=this.node.props;this.unmount=v7(t,(a,l)=>(TN(this.node,l,"Start"),(u,{success:d})=>TN(this.node,u,d?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:s?.tap===!1})}unmount(){}}const $v=new WeakMap,bg=new WeakMap,qH=e=>{const t=$v.get(e.target);t&&t(e)},ZH=e=>{e.forEach(qH)};function WH({root:e,...t}){const n=e||document;bg.has(n)||bg.set(n,{});const s=bg.get(n),a=JSON.stringify(t);return s[a]||(s[a]=new IntersectionObserver(ZH,{root:e,...t})),s[a]}function YH(e,t,n){const s=WH(t);return $v.set(e,n),s.observe(e),()=>{$v.delete(e),s.unobserve(e)}}const GH={some:0,all:1};class KH extends La{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:s,amount:a="some",once:l}=t,u={root:n?n.current:void 0,rootMargin:s,threshold:typeof a=="number"?a:GH[a]},d=p=>{const{isIntersecting:h}=p;if(this.isInView===h||(this.isInView=h,l&&!h&&this.hasEnteredView))return;h&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",h);const{onViewportEnter:m,onViewportLeave:y}=this.node.getProps(),x=h?m:y;x&&x(p)};return YH(this.node.current,u,d)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(XH(t,n))&&this.startObserver()}unmount(){}}function XH({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const JH={inView:{Feature:KH},tap:{Feature:HH},focus:{Feature:FH},hover:{Feature:VH}},QH={layout:{ProjectionNode:lR,MeasureLayout:wR}},eq={...SH,...JH,...BH,...QH},tq=yH(eq,bH);function nq(e){return"type"in e&&e.type==="separator"}function sq(e){return"type"in e&&e.type==="group"}function AN({item:e}){return o.jsxs(M6,{disabled:e.disabled,onClick:e.action,className:"flex items-center gap-3 px-3 py-1.5 text-[12px] font-mono text-popover-foreground outline-none select-none data-[highlighted]:bg-accent/10 data-[highlighted]:text-accent data-[disabled]:opacity-40 data-[disabled]:pointer-events-none cursor-default",children:[e.icon&&o.jsx("span",{className:"w-4 h-4 flex items-center justify-center text-muted-foreground",children:e.icon}),o.jsx("span",{className:"flex-1",children:e.label}),e.shortcut&&o.jsx("span",{className:"text-muted-foreground text-[10px] ml-4 tracking-wider",children:e.shortcut})]})}const jR=Io.forwardRef(({items:e},t)=>o.jsx(tq.div,{ref:t,initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.1,ease:"easeOut"},children:o.jsx(CB,{className:"bg-popover/95 backdrop-blur-xl border border-border/60 rounded-lg shadow-2xl py-1 min-w-[180px] z-[200] outline-none",children:e.map((n,s)=>nq(n)?o.jsx(r9,{className:"h-px bg-border/60 my-1"},`sep-${s}`):sq(n)?o.jsxs(A6,{children:[o.jsx(R6,{className:"px-3 py-1 text-[10px] font-mono uppercase tracking-widest text-muted-foreground",children:n.label}),n.items.map(a=>o.jsx(AN,{item:a},a.id))]},`grp-${s}`):o.jsx(AN,{item:n},n.id))})}));jR.displayName="PopupContent";function rq({items:e,children:t}){return e.length===0?o.jsx(o.Fragment,{children:t}):o.jsxs(a9,{children:[o.jsx(i9,{render:o.jsx("div",{style:{display:"contents"}}),children:t}),o.jsx(AB,{children:o.jsx(VB,{className:"z-[200]",sideOffset:4,children:o.jsx(WF,{children:o.jsx(jR,{items:e})})})})]})}const RN=()=>{},aq={x:0,y:0},iq=({children:e,hud:t,mode:n="canvas",panOffset:s=aq,scale:a=1,onPan:l=RN,onZoom:u=RN,onPanStart:d,onPanEnd:p,isTransitioning:h=!1,onViewportChange:m,onCanvasClick:y,canvasProps:x,zoomSensitivity:w,zoomControlsRightOffset:j,canvasContextMenuItems:N})=>{const k=g.useRef(null),E=g.useRef(a);E.current=a;const C=g.useRef(u);C.current=u;const S=g.useRef(l);S.current=l;const R=g.useRef(d);R.current=d;const A=g.useRef(p);A.current=p;const M=g.useRef(w);M.current=w;const[_,z]=g.useState(!1),V=g.useRef(!1),[U,O]=g.useState(!1),D=g.useRef(!1),H=g.useRef({x:0,y:0}),W=g.useRef($=>{const L=$.target||document.activeElement;if(!L)return!1;const F=L.tagName;return!!(F==="INPUT"||F==="TEXTAREA"||L.isContentEditable||L.closest?.(".xterm"))});g.useEffect(()=>{if(n!=="canvas")return;const $=X=>{X.key!==" "||X.repeat||W.current(X)||h||(X.preventDefault(),V.current=!0,z(!0))},L=X=>{X.key===" "&&V.current&&(V.current=!1,z(!1),D.current&&(D.current=!1,O(!1),A.current?.()))},F=()=>{V.current&&(V.current=!1,z(!1),D.current&&(D.current=!1,O(!1),A.current?.()))};return window.addEventListener("keydown",$),window.addEventListener("keyup",L),window.addEventListener("blur",F),()=>{window.removeEventListener("keydown",$),window.removeEventListener("keyup",L),window.removeEventListener("blur",F)}},[n,h]);const q=g.useCallback($=>{$.button===0&&($.preventDefault(),D.current=!0,O(!0),H.current={x:$.clientX,y:$.clientY},R.current?.())},[]);return g.useEffect(()=>{if(!_)return;const $=F=>{if(!D.current)return;const X=(F.clientX-H.current.x)/E.current,G=(F.clientY-H.current.y)/E.current;H.current={x:F.clientX,y:F.clientY},S.current({x:X,y:G})},L=()=>{D.current&&(D.current=!1,O(!1),A.current?.())};return window.addEventListener("mousemove",$),window.addEventListener("mouseup",L),()=>{window.removeEventListener("mousemove",$),window.removeEventListener("mouseup",L)}},[_]),g.useEffect(()=>{if(n!=="canvas")return;const $=L=>{if(L.ctrlKey||L.metaKey){L.preventDefault();const F=E.current,X=-L.deltaY*.001*(M.current??1),G=Math.min(Math.max(.2,F+X),3);E.current=G,C.current(G)}};return window.addEventListener("wheel",$,{passive:!1}),()=>window.removeEventListener("wheel",$)},[n]),g.useEffect(()=>{if(!m)return;let $=null;const L=()=>{$&&cancelAnimationFrame($),$=requestAnimationFrame(()=>{m({width:window.innerWidth,height:window.innerHeight})})};return L(),window.addEventListener("resize",L),()=>{window.removeEventListener("resize",L),$&&cancelAnimationFrame($)}},[m]),n==="panel"?o.jsxs("div",{ref:k,className:"fixed inset-0 bg-background text-foreground overflow-hidden font-sans select-none z-0",children:[o.jsx("div",{className:"absolute inset-0 z-10 overflow-auto frame-scrollbar",children:e}),o.jsx("div",{className:"fixed inset-0 z-50 pointer-events-none overflow-hidden",children:t})]}):o.jsxs("div",{ref:k,className:"fixed inset-0 bg-background text-foreground overflow-hidden font-sans select-none z-0",children:[o.jsx(rq,{items:N??[],children:o.jsx(b$,{panOffset:s,scale:a,onPan:l,onPanStart:d,onPanEnd:p,isPanLocked:h,onClick:y,showGuides:x?.showGuides,onGuidesChange:x?.onGuidesChange,gridOpacity:x?.gridOpacity})}),o.jsx("div",{className:"absolute z-10 pointer-events-none",style:{left:"50%",top:"50%",zoom:a},children:o.jsx("div",{style:{position:"absolute",left:s.x,top:s.y},children:e})}),_&&o.jsx("div",{className:`fixed inset-0 z-20 ${U?"cursor-grabbing":"cursor-grab"}`,onMouseDown:q}),o.jsx("div",{className:"fixed bottom-[36px] z-30",style:{right:(j??280)+16},children:o.jsx(x$,{scale:a,onZoom:$=>u($)})}),o.jsx("div",{className:"fixed inset-0 z-50 pointer-events-none overflow-hidden",children:t})]})},bo=4e3,oq=Io.forwardRef(({pan:e,zoom:t,viewportSize:n,height:s,onClick:a,children:l},u)=>{const[d,p]=Io.useState(0),h=g.useRef(null),m=Io.useCallback(C=>{h.current=C,typeof u=="function"?u(C):u&&(u.current=C)},[u]);Io.useEffect(()=>{const C=h.current;if(!C)return;const S=new ResizeObserver(([R])=>p(R.contentRect.width));return S.observe(C),()=>S.disconnect()},[]);const y=d||260,x=n.width/t/bo*y,w=n.height/t/bo*s,j=(-e.x+bo/2)/bo*y,N=(-e.y+bo/2)/bo*s,k=j-x/2,E=N-w/2;return o.jsxs("div",{ref:m,className:"relative cursor-crosshair overflow-hidden",style:{height:`${s}px`},onClick:a,children:[o.jsx("div",{className:"absolute inset-0 opacity-30",style:{backgroundImage:"radial-gradient(circle, var(--hud-canvas-dot-major) 0.5px, transparent 0.5px)",backgroundSize:"14px 14px"}}),o.jsx("div",{className:"absolute top-1/2 left-0 right-0 h-px bg-border/60"}),o.jsx("div",{className:"absolute left-1/2 top-0 bottom-0 w-px bg-border/60"}),o.jsxs("div",{className:"absolute border border-accent/50 bg-accent/10 rounded-[1px] transition-all duration-75 ease-out",style:{left:`${k}px`,top:`${E}px`,width:`${Math.max(x,4)}px`,height:`${Math.max(w,4)}px`},children:[o.jsx("div",{className:"absolute -top-[1px] -left-[1px] w-[3px] h-[3px] bg-accent rounded-full"}),o.jsx("div",{className:"absolute -top-[1px] -right-[1px] w-[3px] h-[3px] bg-accent rounded-full"}),o.jsx("div",{className:"absolute -bottom-[1px] -left-[1px] w-[3px] h-[3px] bg-accent rounded-full"}),o.jsx("div",{className:"absolute -bottom-[1px] -right-[1px] w-[3px] h-[3px] bg-accent rounded-full"})]}),l]})});oq.displayName="MinimapCanvas";const lq=({title:e,subtitle:t,center:n,actions:s,onTitleClick:a,search:l})=>{const{dragRegionProps:u,onInteractiveMouseDown:d}=Yc(),{navTotalHeight:p}=vy(),h=l&&l.value&&l.value.length>0;return o.jsx("div",{"data-frame-panel":"navigation",className:"fixed top-0 left-0 right-0 z-50 pointer-events-auto",...u,children:o.jsxs("div",{className:"bg-background/95 backdrop-blur-xl border-b border-border/80 shadow-[var(--hud-shadow-nav)] flex items-end px-4",style:{height:p},children:[o.jsx("div",{className:"absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-foreground/8 to-transparent"}),o.jsxs("div",{className:"absolute left-4 bottom-0 h-12 z-10 flex items-center gap-3 select-none",onMouseDown:d,children:[o.jsx("button",{onClick:a,className:"text-[22px] font-bold text-foreground tracking-[0.25em] font-mono leading-none bg-transparent border-none cursor-pointer focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none rounded",children:e}),t&&o.jsx("span",{className:"text-xs font-mono text-muted-foreground",children:t})]}),n&&o.jsx("div",{className:"flex-1 flex justify-center h-12 items-center",onMouseDown:d,children:n}),o.jsxs("div",{className:"absolute right-4 bottom-0 h-12 z-10 flex items-center gap-3",onMouseDown:d,children:[s,l&&o.jsxs("div",{className:"relative w-[220px] bg-card border border-input rounded px-2.5 shadow-[inset_0_1px_0_oklch(var(--foreground)/0.02)] hover:border-ring/60 focus-within:border-ring focus-within:ring-1 focus-within:ring-ring/30 focus-within:bg-card transition-all duration-200",children:[o.jsx(my,{size:11,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),o.jsx("input",{type:"text",value:l.value,onChange:m=>l.onChange(m.target.value),placeholder:l.placeholder??"Search...",className:`
|
|
131
|
-
w-full h-7 pl-5 pr-6 bg-transparent text-[12px] font-mono tracking-wider
|
|
132
|
-
placeholder:text-muted-foreground text-foreground
|
|
133
|
-
focus:outline-none transition-all duration-200
|
|
134
|
-
${h?"text-accent":""}
|
|
135
|
-
`}),h&&o.jsx("button",{onClick:()=>l.onChange(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none rounded-sm",children:o.jsx(SC,{size:12})})]})]})]})})},MN=({side:e,title:t,icon:n,isCollapsed:s=!1,onToggleCollapse:a,headerActions:l,footer:u,style:d,width:p,onResizeStart:h,children:m})=>{if(s){const E=e==="left"?FL:WL;return o.jsx("button",{onClick:a,className:`fixed top-1/2 -translate-y-1/2 z-40 ${e==="left"?"left-3":"right-3"} p-2.5 rounded bg-card/95 border border-border/80 hover:border-accent/60 backdrop-blur-xl shadow-[0_0_20px_rgba(0,0,0,0.5),inset_0_1px_0_rgba(255,255,255,0.08)] hover:shadow-[0_0_30px_rgba(16,185,129,0.2),inset_0_1px_0_rgba(255,255,255,0.1)] transition-all duration-200 group pointer-events-auto focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background focus-visible:outline-none`,title:`Expand ${t||"panel"}`,children:o.jsx(E,{size:14,className:"text-muted-foreground group-hover:text-accent transition-colors",strokeWidth:1.5})})}const y=e==="left"?BL:qL,{panelTopOffset:x}=vy(),N=`bg-card/95 backdrop-blur-xl border border-border/80 shadow-[0_0_30px_rgba(0,0,0,0.8),inset_0_1px_0_rgba(255,255,255,0.08)] fixed bottom-[28px] z-40 rounded-none border-t-0 overflow-hidden ${e==="left"?"border-l-0 border-r-0":"border-r-0 border-l-0"}`,k={...d,position:"fixed",top:x,left:e==="left"?0:void 0,right:e==="right"?0:void 0,width:`${p||280}px`};return o.jsxs("div",{"data-frame-panel":e==="left"?"manifest":"inspector",className:`${N} pointer-events-none select-none font-mono text-[11px] flex flex-col`,style:k,children:[h&&o.jsxs("div",{className:`absolute top-0 ${e==="left"?"right-0":"left-0"} bottom-0 w-[7px] cursor-ew-resize z-50 pointer-events-auto group flex items-center justify-center`,onMouseDown:h,children:[o.jsx("div",{className:`absolute top-0 bottom-0 ${e==="left"?"right-0":"left-0"} w-px bg-border/80 group-hover:bg-accent/50 transition-colors`}),o.jsxs("div",{className:"flex flex-col gap-[3px] opacity-0 group-hover:opacity-100 transition-opacity",children:[o.jsx("div",{className:"w-[3px] h-[3px] rounded-full bg-muted-foreground/70 group-hover:bg-accent/70"}),o.jsx("div",{className:"w-[3px] h-[3px] rounded-full bg-muted-foreground/70 group-hover:bg-accent/70"}),o.jsx("div",{className:"w-[3px] h-[3px] rounded-full bg-muted-foreground/70 group-hover:bg-accent/70"})]})]}),!h&&o.jsx("div",{className:`absolute top-0 ${e==="left"?"right-0":"left-0"} bottom-0 w-px bg-border/80`}),o.jsx("div",{className:"absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-foreground/12 to-transparent z-10"}),o.jsxs("div",{className:"pointer-events-auto flex-1 flex flex-col overflow-hidden",children:[t&&o.jsx("div",{className:"shrink-0 p-4 border-b border-border/60",children:o.jsxs("div",{className:"flex items-center justify-between text-foreground text-[12px]",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[n&&o.jsx("span",{className:"text-muted-foreground",children:n}),o.jsx("span",{className:"tracking-widest font-bold uppercase",children:t})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[l,a&&o.jsx("button",{onClick:a,className:"p-1 hover:bg-accent/10 rounded transition-colors text-muted-foreground hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",title:"Collapse panel",children:o.jsx(y,{size:12})})]})]})}),o.jsx("div",{className:"flex-1 overflow-y-auto frame-scrollbar",children:m}),u&&o.jsx("div",{className:"shrink-0",children:u})]})]})},cq={emerald:{dot:"bg-success",ping:"bg-success",text:"text-success"},amber:{dot:"bg-warning",ping:"bg-warning",text:"text-warning"},red:{dot:"bg-destructive",ping:"bg-destructive",text:"text-destructive"},neutral:{dot:"bg-muted-foreground",ping:"bg-muted-foreground",text:"text-muted-foreground"}},uq=({left:e,viewport:t,right:n,isMinimapCollapsed:s=!1,onExpandMinimap:a,status:l={label:"READY",color:"emerald"},onToggleTerminal:u,isTerminalOpen:d=!1})=>{const[p,h]=g.useState(new Date),[m,y]=g.useState(!1),[x,w]=g.useState(!1);g.useEffect(()=>{w(!0);const k=setInterval(()=>h(new Date),1e3);return()=>clearInterval(k)},[]);const j=cq[l.color],N=async()=>{if(!t)return;const k=`PAN: ${t.pan.x.toFixed(0)},${t.pan.y.toFixed(0)} | SIZE: ${t.canvasSize?.w??1024}x${t.canvasSize?.h??1024} | ZOOM: ${(t.zoom*100).toFixed(0)}%`;try{await navigator.clipboard.writeText(k),y(!0),setTimeout(()=>y(!1),1500)}catch{}};return o.jsxs("div",{"data-frame-panel":"status-bar",className:`${nL.statusBar} h-7 flex items-center justify-between px-3 select-none font-mono text-[12px] text-foreground pointer-events-auto`,children:[o.jsxs("div",{className:"flex items-center gap-4",children:[s&&a&&o.jsxs(o.Fragment,{children:[o.jsxs("button",{onClick:a,className:"flex items-center gap-1.5 px-2 py-0.5 rounded bg-muted/60 border border-border/70 hover:bg-muted transition-colors text-muted-foreground hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",title:"Expand minimap",children:[o.jsx(_L,{size:10}),o.jsx("span",{className:"text-[11px] font-bold",children:"MAP"}),o.jsx(wC,{size:8,className:"opacity-60"})]}),o.jsx("div",{className:"h-3 w-px bg-border"})]}),o.jsxs("div",{className:`flex items-center gap-2 ${j.text}`,children:[o.jsxs("div",{className:"relative flex h-2 w-2",children:[o.jsx("span",{className:`animate-ping absolute inline-flex h-full w-full rounded-full ${j.ping} opacity-75`}),o.jsx("span",{className:`relative inline-flex rounded-full h-2 w-2 ${j.dot}`})]}),o.jsx("span",{className:"font-bold tracking-wider",children:l.label})]}),e&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"h-3 w-px bg-border"}),e]})]}),t&&o.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 flex items-center gap-3 opacity-70 hover:opacity-100 transition-opacity",children:o.jsxs("button",{onClick:N,className:"flex items-center gap-3 hover:text-foreground transition-colors cursor-pointer focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none rounded",title:"Copy viewport data",children:[o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("span",{className:"text-muted-foreground",children:"PAN:"}),o.jsxs("span",{className:`tabular-nums ${m?"text-accent":""}`,children:[t.pan.x.toFixed(0),",",t.pan.y.toFixed(0)]})]}),o.jsx("div",{className:"h-3 w-px bg-border"}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("span",{className:"text-muted-foreground",children:"SIZE:"}),o.jsxs("span",{className:`tabular-nums ${m?"text-accent":""}`,children:[t.canvasSize?.w??1024,"x",t.canvasSize?.h??1024]})]}),o.jsx("div",{className:"h-3 w-px bg-border"}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("span",{className:"text-muted-foreground",children:"ZOOM:"}),o.jsxs("span",{className:`tabular-nums ${m?"text-accent":""}`,children:[(t.zoom*100).toFixed(0),"%"]})]})]})}),o.jsxs("div",{className:"flex items-center gap-4",children:[n,n&&o.jsx("div",{className:"h-3 w-px bg-border"}),u&&o.jsxs(o.Fragment,{children:[o.jsxs("button",{onClick:u,className:`flex items-center gap-1.5 px-2 py-1 rounded transition-all focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none ${d?"bg-accent/10 text-accent border border-accent/30":"text-muted-foreground hover:text-foreground hover:bg-muted/70 border border-transparent"}`,title:"Toggle Terminal (Ctrl+`)",children:[o.jsxs("span",{className:"text-[12px]",children:[">","_"]}),o.jsx("span",{className:"uppercase text-[11px] font-semibold tracking-wider",children:"Console"})]}),o.jsx("div",{className:"h-3 w-px bg-border"})]}),o.jsxs("div",{className:"flex items-center gap-1.5 text-foreground min-w-[60px] justify-end",children:[o.jsx(CL,{size:11,className:"text-muted-foreground"}),o.jsx("span",{children:x?p.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"--:--"})]})]})]})},dq=({onOpenCommandPalette:e,extraControls:t})=>o.jsx("div",{className:"select-none font-mono text-[12px] border-t border-border/60",children:o.jsxs("div",{className:"px-3 py-2 flex items-center justify-between",children:[o.jsxs("button",{onClick:e,className:"flex items-center gap-1.5 text-muted-foreground hover:text-foreground transition-colors focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none rounded",children:[o.jsx(my,{size:10}),o.jsx("span",{className:"tracking-widest font-bold uppercase",children:"Command Palette"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[t,o.jsx("kbd",{className:"text-[11px] text-muted-foreground font-mono",children:"⌘K"})]})]})}),{statusBarHeight:Od}=sh.layout,_N=120,fq=({isOpen:e,onClose:t,onToggleMaximize:n,isMaximized:s=!1,height:a=320,onHeightChange:l,title:u,headerActions:d,children:p})=>{const h=g.useRef(!1),m=g.useRef(null),y=g.useCallback(w=>{if(!l)return;w.preventDefault(),h.current=!0;const j=w.clientY,N=a;m.current&&(m.current.style.transition="none");const k=C=>{const S=j-C.clientY,R=window.innerHeight-Od,A=Math.max(_N,Math.min(R,N+S));m.current&&(m.current.style.height=`${A}px`)},E=C=>{h.current=!1,document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",E),m.current&&(m.current.style.transition="");const S=j-C.clientY,R=window.innerHeight-Od;l(Math.max(_N,Math.min(R,N+S)))};document.addEventListener("mousemove",k),document.addEventListener("mouseup",E)},[a,l]),x=s?`calc(100vh - ${Od}px)`:`${a}px`;return o.jsxs("div",{ref:m,className:`
|
|
136
|
-
fixed left-0 right-0 shadow-[0_-10px_40px_rgba(0,0,0,0.8)] flex flex-col border-t border-border
|
|
137
|
-
bg-card/95 backdrop-blur-xl
|
|
138
|
-
${e?"translate-y-0 opacity-100 pointer-events-auto":"translate-y-full opacity-0 pointer-events-none"}
|
|
139
|
-
transition-all duration-300 ease-in-out
|
|
140
|
-
`,style:{bottom:Od,height:x,zIndex:sh.zIndex.drawer},children:[o.jsxs("div",{className:"h-9 bg-card/80 border-b border-border flex items-center justify-between px-3 shrink-0 select-none backdrop-blur-sm",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[u||o.jsxs("div",{className:"flex items-center gap-2 text-accent",children:[o.jsx(s$,{size:14}),o.jsx("span",{className:"text-xs font-bold tracking-widest font-mono",children:"TERMINAL"})]}),d]}),o.jsx("div",{className:"flex-1 flex items-center justify-center h-full cursor-ns-resize text-muted-foreground hover:text-foreground transition-colors group",title:"Drag to Resize",onMouseDown:y,children:o.jsx("div",{className:"w-16 h-1 rounded-full bg-border group-hover:bg-muted-foreground transition-colors"})}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{onClick:n,className:"p-1.5 rounded hover:bg-accent/10 text-muted-foreground hover:text-foreground transition-colors",title:s?"Restore":"Maximize",children:s?o.jsx(zL,{size:14}):o.jsx(wC,{size:14})}),o.jsx("button",{onClick:t,className:"p-1.5 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors",title:"Close",children:o.jsx(SC,{size:14})})]})]}),o.jsx("div",{className:"flex-1 relative overflow-hidden flex flex-col bg-transparent",children:p})]})},hq=({isOpen:e,onClose:t,commands:n})=>{const[s,a]=g.useState(""),[l,u]=g.useState(0),d=g.useRef(null),p=g.useRef(null),h=n.filter(y=>y.label.toLowerCase().includes(s.toLowerCase()));g.useEffect(()=>{e&&(setTimeout(()=>d.current?.focus(),10),a(""),u(0))},[e]),g.useEffect(()=>{u(0)},[s]),g.useEffect(()=>{p.current?.scrollIntoView({behavior:"smooth",block:"nearest"})},[l]);const m=y=>{if((y.key==="ArrowDown"||y.key==="ArrowUp")&&h.length===0){y.preventDefault();return}y.key==="ArrowDown"?(y.preventDefault(),u(x=>(x+1)%h.length)):y.key==="ArrowUp"?(y.preventDefault(),u(x=>(x-1+h.length)%h.length)):y.key==="Enter"?(y.preventDefault(),h[l]&&(h[l].action(),t())):y.key==="Escape"&&t()};return e?o.jsx("div",{className:"fixed inset-0 z-[100] flex items-start justify-center pt-[15vh] bg-background/45 backdrop-blur-[2px] pointer-events-auto",onClick:t,children:o.jsxs("div",{className:"w-[640px] max-w-[90vw] bg-popover border border-border shadow-2xl rounded-lg overflow-hidden flex flex-col animate-in fade-in zoom-in-95 duration-100",onClick:y=>y.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center px-4 py-3 border-b border-border gap-3 focus-within:ring-2 focus-within:ring-ring focus-within:outline-none",children:[o.jsx(my,{className:"text-muted-foreground",size:18}),o.jsx("input",{ref:d,className:"flex-1 bg-transparent border-none outline-none text-popover-foreground placeholder:text-muted-foreground font-mono text-sm",placeholder:"Type a command or search...",value:s,onChange:y=>a(y.target.value),onKeyDown:m,autoFocus:!0}),o.jsx("div",{className:"px-1.5 py-0.5 rounded bg-muted border border-border text-[12px] text-muted-foreground font-mono",children:"ESC"})]}),o.jsxs("div",{className:"max-h-[300px] overflow-y-auto py-2 relative",children:[o.jsx("div",{className:"pb-2",children:h.length===0?o.jsx("div",{className:"px-4 py-8 text-center text-muted-foreground text-xs font-mono",children:"No matching commands"}):h.map((y,x)=>o.jsxs("div",{ref:x===l?p:null,tabIndex:0,className:`px-4 py-2.5 flex items-center gap-3 cursor-pointer transition-colors focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none focus-visible:bg-muted ${x===l?"bg-accent/10 border-l-2 border-accent":"border-l-2 border-transparent hover:bg-muted/70"}`,onClick:()=>{y.action(),t()},onMouseEnter:()=>u(x),children:[y.icon&&o.jsx("div",{className:`${x===l?"text-accent":"text-muted-foreground"}`,children:y.icon}),o.jsx("div",{className:"flex-1",children:o.jsx("div",{className:`text-sm ${x===l?"text-accent":"text-popover-foreground"}`,children:y.label})}),y.shortcut&&o.jsx("div",{className:"text-[12px] font-mono text-muted-foreground bg-muted px-1.5 py-0.5 rounded border border-border",children:y.shortcut}),x===l&&o.jsx(AL,{size:14,className:"text-accent ml-2"})]},y.id))}),h.length>6&&o.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-8 bg-gradient-to-t from-popover to-transparent pointer-events-none"})]}),o.jsxs("div",{className:"px-4 py-1.5 bg-card/90 backdrop-blur-sm border-t border-border flex justify-between items-center text-[12px] text-muted-foreground font-mono relative z-10",children:[o.jsx("span",{children:"Command Palette"}),o.jsxs("span",{children:[h.length," matches"]})]})]})}):null},xg=new Map;function wg(e){if(e)return JSON.parse(e)}function pq(e){return e?JSON.stringify([...new Headers(e).entries()].sort(([t],[n])=>t.localeCompare(n))):""}function mq(e,t){return`${(t?.method??"GET").toUpperCase()}:${e}:${pq(t?.headers)}`}async function ON(e,t){const n=await fetch(e,{...t,headers:{...t?.headers??{},...t?.body?{"content-type":"application/json"}:{}}});if(!n.ok){const s=await n.text();let a=s||`HTTP ${n.status}`;try{const l=JSON.parse(s);l?.error&&(a=l.error)}catch{}throw new Error(a)}return await n.text()}async function Re(e,t){if(!((t?.method??"GET").toUpperCase()==="GET"&&!t?.body))return wg(await ON(e,t));const a=mq(e,t),l=xg.get(a);if(l)return wg(await l);const u=ON(e,t);xg.set(a,u);try{return wg(await u)}finally{xg.delete(a)}}function tu(){return!(typeof window>"u"||new URLSearchParams(window.location.search).has("no-ops"))}function gq(e){switch(e){case"profile":case"observe":case"message":return e;default:return}}function vq(e){switch(e){case"command":case"warroom":return"warroom";case"control":case"mission":return"mission";case"conduct":case"conductor":return"conductor";case"plan":case"agents":case"tail":case"atop":return e;default:return}}function yq(e){switch(e){case"warroom":return"command";case"mission":return"control";case"conductor":return"conduct";default:return e}}function bq(e){const t=new URL(e.toString()),n=t.pathname.replace(/^\/+/,"").split("/").filter(Boolean),s=t.searchParams.get("compose")==="ask"?"ask":void 0,a=gq(t.searchParams.get("tab"));if(n[0]==="agent"&&n[1])return{view:"agent-info",conversationId:decodeURIComponent(n[1])};if(n[0]==="agents"&&n[1]&&n[2]==="c"&&n[3])return{view:"agents",agentId:decodeURIComponent(n[1]),conversationId:decodeURIComponent(n[3]),tab:a??"message"};if(n[0]==="agents"&&n[1]){const l=decodeURIComponent(n[1]);return a==="message"?{view:"agents",agentId:l,conversationId:Dn(l),tab:"message"}:{view:"agents",agentId:l,...a?{tab:a}:{}}}if(n[0]==="agents")return{view:"agents"};if(n[0]==="fleet")return{view:"fleet"};if(n[0]==="c"&&n[1])return{view:"conversation",conversationId:decodeURIComponent(n[1]),...s?{composeMode:s}:{}};if(n[0]==="sessions"&&n[1])return{view:"sessions",sessionId:decodeURIComponent(n[1])};if(n[0]==="sessions")return{view:"sessions"};if(n[0]==="mesh")return{view:"mesh"};if(n[0]==="activity")return{view:"activity"};if(n[0]==="work"&&n[1])return{view:"work",workId:decodeURIComponent(n[1])};if(n[0]==="settings")return{view:"settings"};if(n[0]==="terminal")return{view:"terminal",...n[1]?{agentId:decodeURIComponent(n[1])}:{}};if(n[0]==="ops"){if(!tu())return{view:"inbox"};const l=vq(n[1]);return l?{view:"ops",mode:l}:{view:"ops"}}return{view:"inbox"}}function jg(){return bq(window.location.href)}function xq(e){switch(e.view){case"inbox":return"/";case"conversation":{const t=new URLSearchParams;e.composeMode==="ask"&&t.set("compose","ask");const n=t.toString();return`/c/${encodeURIComponent(e.conversationId)}${n?`?${n}`:""}`}case"agent-info":return`/agent/${encodeURIComponent(e.conversationId)}`;case"agents":{const t=new URLSearchParams,n=!!e.agentId&&!!e.conversationId&&e.conversationId===Dn(e.agentId),s=n?"profile":e.conversationId?"message":"profile";n?t.set("tab","message"):e.tab&&e.tab!==s&&t.set("tab",e.tab);const a=t.toString();return`${e.agentId?n?`/agents/${encodeURIComponent(e.agentId)}`:e.conversationId?`/agents/${encodeURIComponent(e.agentId)}/c/${encodeURIComponent(e.conversationId)}`:`/agents/${encodeURIComponent(e.agentId)}`:"/agents"}${a?`?${a}`:""}`}case"fleet":return"/fleet";case"sessions":return e.sessionId?`/sessions/${encodeURIComponent(e.sessionId)}`:"/sessions";case"mesh":return"/mesh";case"activity":return"/activity";case"work":return`/work/${encodeURIComponent(e.workId)}`;case"settings":return"/settings";case"ops":return e.mode?`/ops/${yq(e.mode)}`:"/ops";case"terminal":return e.agentId?`/terminal/${encodeURIComponent(e.agentId)}`:"/terminal"}}function Sg(e){switch(e.view){case"conversation":return`conv:${e.conversationId}`;case"agent-info":return`agent-info:${e.conversationId}`;case"agents":return e.conversationId?`agent-conv:${e.conversationId}:${e.tab??"message"}`:e.agentId?`agent:${e.agentId}:${e.tab??"profile"}`:"agents";case"sessions":return e.sessionId?`session:${e.sessionId}`:"sessions";case"work":return`work:${e.workId}`;case"ops":return`ops:${e.mode??"plan"}`;default:return e.view}}function wq(){const[e,t]=g.useState(jg),n=g.useRef({});g.useEffect(()=>{const a=()=>{const l=jg();t(l),requestAnimationFrame(()=>{window.scrollTo(0,n.current[Sg(l)]??0)})};return window.addEventListener("popstate",a),()=>window.removeEventListener("popstate",a)},[]);const s=g.useCallback(a=>{const l=a.view==="ops"&&!tu()?{view:"inbox"}:a;n.current[Sg(jg())]=window.scrollY,window.history.pushState(null,"",xq(l)),t(l),requestAnimationFrame(()=>{window.scrollTo(0,n.current[Sg(l)]??0)})},[]);return{route:e,navigate:s}}function SR(e){const t=e.match(/^dm\.operator\.(.+)$/);return t?t[1]:null}function Dn(e){return`dm.operator.${e}`}const jq=["hello","node.upserted","actor.registered","agent.registered","agent.endpoint.upserted","conversation.upserted","binding.upserted","message.posted","invocation.requested","flight.updated","delivery.planned","delivery.attempted","delivery.state.changed","collaboration.upserted","collaboration.event.appended","scout.dispatched"],vi=new Set;let Cc=null,Dr=null,Ff=0;function Sq(e){try{return JSON.parse(e)}catch{return{kind:"unknown"}}}function NR(){Cc?.close(),Cc=null}function Nq(){if(Dr||vi.size===0)return;Ff++;const e=Math.min(3e3*2**(Ff-1),6e4);Dr=setTimeout(()=>{Dr=null,vi.size>0&&kR()},e)}function kq(e){for(const t of[...vi])t(e)}function kR(){if(Cc||vi.size===0)return;const e=new EventSource("/api/events");Cc=e;const t=n=>{kq(Sq(n.data))};e.onopen=()=>{Ff=0},e.onmessage=t;for(const n of jq)e.addEventListener(n,t);e.onerror=()=>{Cc===e?NR():e.close(),Nq()}}function Eq(e){return vi.add(e),Dr&&(clearTimeout(Dr),Dr=null),kR(),()=>{vi.delete(e),!(vi.size>0)&&(Dr&&(clearTimeout(Dr),Dr=null),Ff=0,NR())}}function Rn(e){const t=g.useRef(e);t.current=e,g.useEffect(()=>Eq(n=>{t.current(n)}),[])}function et(e){return e==="working"?"working":!e||e==="offline"?"offline":"available"}function ki(e){return et(e)!=="offline"}function Pn(e){switch(et(e)){case"working":return"Working";case"available":return"Available";default:return"Offline"}}const yh="ranger.main.mini",Cq=new Set([yh,"ranger","@ranger"]),Tq=new Set(["plan","conductor","conduct","warroom","command","mission","control","agents","tail","atop"]),Aq=new Set(["available","working","active","idle","waiting","registered"]);function db(e){return[e.id,e.name,e.handle??"",e.selector??"",e.role??""].map(n=>n.trim().toLowerCase()).some(n=>Cq.has(n)||n==="ranger"||n.startsWith("ranger.")||n.includes(".ranger.")||n.includes(" ranger"))}function Rq(e){return Aq.has(e.state?.trim().toLowerCase()??"")}function IN(e){if(!db(e))return Number.NEGATIVE_INFINITY;let t=0;return Rq(e)&&(t+=100),e.handle?.trim().toLowerCase()==="ranger"&&(t+=20),e.selector?.trim().toLowerCase()==="@ranger"&&(t+=20),e.role?.trim().toLowerCase()==="ranger"&&(t+=10),e.id===yh&&(t+=1),t}function Mq(e){return e.filter(db).sort((t,n)=>{const s=IN(n)-IN(t);return s!==0?s:(n.updatedAt??0)-(t.updatedAt??0)})[0]??null}function _q(e){return Mq(e)?.id??yh}function Oq(e){return Dn(e)}function ER(e,t=yh){const n=e.trim().toLowerCase(),s=t.trim().toLowerCase();return n===s||n==="ranger"||n.startsWith("ranger.")||n.includes(".ranger.")}function Iq(e){const t=[],n=/```(?:scout-ui|scout-ui-action|ranger-ui)\s*([\s\S]*?)```/gi;let s;for(;(s=n.exec(e))!==null;){const a=Dq(s[1]??"");t.push(...a)}return t}function Dq(e){const t=e.trim();if(!t)return[];try{const n=JSON.parse(t);return(Array.isArray(n)?n:[n]).map(a=>CR(a)).filter(a=>!!a)}catch{return[]}}function CR(e){if(!e||typeof e!="object")return null;const t=e,n=t.scoutUi??t.scout_ui??t.rangerUi??t.ranger_ui;if(n)return CR(n);const s=typeof t.type=="string"?t.type:typeof t.action=="string"?t.action:"",a=typeof t.reason=="string"?t.reason:void 0;if(s==="open-ranger"||s==="open_ranger"){const u=t.mode==="tell"?"tell":t.mode==="ask"?"ask":void 0;return{type:"open-ranger",...u?{mode:u}:{},...a?{reason:a}:{}}}if(s==="refresh")return{type:"refresh",...a?{reason:a}:{}};if(s!=="navigate"&&s!=="open")return null;const l=Pq(t.route??t);return l?{type:"navigate",route:l,...a?{reason:a}:{}}:null}function Pq(e){if(!e||typeof e!="object")return null;const t=e;switch(typeof t.view=="string"?t.view:""){case"inbox":return{view:"inbox"};case"fleet":return{view:"fleet"};case"agents":return{view:"agents",...typeof t.agentId=="string"?{agentId:t.agentId}:{},...typeof t.conversationId=="string"?{conversationId:t.conversationId}:{},...t.tab==="profile"||t.tab==="observe"||t.tab==="message"?{tab:t.tab}:{}};case"sessions":return{view:"sessions",...typeof t.sessionId=="string"?{sessionId:t.sessionId}:{}};case"mesh":return{view:"mesh"};case"activity":return{view:"activity"};case"settings":return{view:"settings"};case"terminal":return{view:"terminal",...typeof t.agentId=="string"?{agentId:t.agentId}:{}};case"work":return typeof t.workId=="string"?{view:"work",workId:t.workId}:null;case"conversation":return typeof t.conversationId=="string"?{view:"conversation",conversationId:t.conversationId,...t.composeMode==="ask"||t.composeMode==="tell"?{composeMode:t.composeMode}:{}}:null;case"ops":{const s=typeof t.mode=="string"&&Tq.has(t.mode)?zq(t.mode):void 0;return{view:"ops",...s?{mode:s}:{}}}default:return null}}function zq(e){switch(e){case"command":case"warroom":return"warroom";case"control":case"mission":return"mission";case"conduct":case"conductor":return"conductor";case"plan":case"agents":case"tail":case"atop":return e;default:return}}const TR={current:null,setMenu:null};function bh(){return g.useCallback((e,t)=>{e.preventDefault(),e.stopPropagation(),TR.setMenu?.({position:{x:e.clientX,y:e.clientY},items:t})},[])}function Lq({children:e}){const[t,n]=g.useState(null),s=g.useRef(null);TR.setMenu=n;const a=g.useCallback(()=>n(null),[]);return g.useEffect(()=>{if(!t)return;const l=()=>a(),u=p=>{p.key==="Escape"&&a()},d=()=>a();return window.addEventListener("mousedown",l,!0),window.addEventListener("keydown",u),window.addEventListener("scroll",d,!0),window.addEventListener("contextmenu",a,!0),()=>{window.removeEventListener("mousedown",l,!0),window.removeEventListener("keydown",u),window.removeEventListener("scroll",d,!0),window.removeEventListener("contextmenu",a,!0)}},[t,a]),g.useEffect(()=>{if(!t||!s.current)return;const l=s.current,u=l.getBoundingClientRect(),d=window.innerWidth,p=window.innerHeight;let h=t.position.x,m=t.position.y;h+u.width>d-8&&(h=d-u.width-8),m+u.height>p-8&&(m=p-u.height-8),h<8&&(h=8),m<8&&(m=8),l.style.left=`${h}px`,l.style.top=`${m}px`},[t]),t?o.jsxs(o.Fragment,{children:[e,o.jsx("div",{ref:s,className:"s-context-menu",style:{left:t.position.x,top:t.position.y},role:"menu",onMouseDown:l=>l.stopPropagation(),children:t.items.map((l,u)=>l.kind==="separator"?o.jsx("div",{className:"s-context-menu-sep",role:"separator"},u):o.jsxs("button",{type:"button",className:"s-context-menu-item",role:"menuitem",onClick:()=>{l.onSelect(),a()},children:[o.jsx("span",{className:"s-context-menu-label",children:l.label}),l.shortcut&&o.jsx("span",{className:"s-context-menu-shortcut",children:l.shortcut})]},u))})]}):o.jsx(o.Fragment,{children:e})}const $q=[195,125,300,45,355,210];function DN(e){return`oklch(0.80 0.14 ${e})`}function Uq(e){return`oklch(0.18 0.08 ${e})`}function yi({label:e,right:t}){return o.jsxs("div",{className:"s-settings-section-rule",children:[o.jsx("span",{className:"s-settings-section-label",children:e}),o.jsx("span",{className:"s-settings-section-line"}),t&&o.jsx("span",{className:"s-settings-section-right",children:t})]})}function ks({label:e,hint:t,children:n}){return o.jsxs("div",{className:"s-settings-field",children:[o.jsx("label",{className:"s-settings-field-label",children:e}),n,t&&o.jsx("span",{className:"s-settings-field-hint",children:t})]})}function _o({value:e,onChange:t,mono:n}){return o.jsx("input",{className:`s-settings-input${n?" s-settings-input--mono":""}`,value:e,onChange:s=>t(s.target.value)})}function Bq({value:e,onChange:t,rows:n=3}){return o.jsx("textarea",{className:"s-settings-textarea",value:e,onChange:s=>t(s.target.value),rows:n})}function Vq({value:e,onChange:t,min:n,max:s,step:a=1,unit:l=""}){return o.jsxs("div",{className:"s-settings-slider-wrap",children:[o.jsx("input",{type:"range",min:n,max:s,step:a,value:e,onChange:u=>t(Number(u.target.value))}),o.jsxs("span",{className:"s-settings-slider-value",children:[e," ",l]})]})}function Id({value:e,onChange:t,options:n,stacked:s,columns:a}){return o.jsx("div",{className:s?"s-settings-option-stacked":"s-settings-option-grid",style:s?void 0:{gridTemplateColumns:`repeat(${a??n.length}, 1fr)`},children:n.map(l=>o.jsxs("button",{className:`s-settings-option-btn${e===l.id?" s-settings-option-btn--active":""}`,onClick:()=>t(l.id),children:[o.jsx("span",{className:"s-settings-option-label",children:l.label}),o.jsx("span",{className:"s-settings-option-sub",children:l.sub})]},l.id))})}function Fq({profile:e,update:t}){return o.jsxs("div",{className:"s-settings-col-gap",children:[o.jsx(yi,{label:"Identity",right:"visible to every agent"}),o.jsxs("div",{className:"s-settings-identity-card",children:[o.jsx("span",{className:"s-settings-identity-dot",style:{background:DN(e.hue),color:Uq(e.hue)},children:(e.name||"?")[0].toUpperCase()}),o.jsxs("div",{style:{flex:1},children:[o.jsx("div",{className:"s-settings-identity-name",children:e.name||"Unnamed"}),o.jsxs("div",{className:"s-settings-identity-meta",children:[e.handle||"@you"," · ",e.pronouns||"—"," · operator"]})]}),o.jsxs("div",{className:"s-settings-hue-wrap",children:[o.jsx("span",{className:"s-settings-field-label",children:"Identity hue"}),o.jsx("div",{className:"s-settings-hue-row",children:$q.map(n=>o.jsx("button",{onClick:()=>t({hue:n}),className:`s-settings-hue-dot${e.hue===n?" s-settings-hue-dot--active":""}`,style:{background:DN(n)}},n))})]})]}),o.jsx(ks,{label:"Display name",hint:"Shown when agents address you.",children:o.jsx(_o,{value:e.name,onChange:n=>t({name:n})})}),o.jsx(ks,{label:"Handle",hint:"Used in @mentions across threads.",children:o.jsx(_o,{value:e.handle,onChange:n=>t({handle:n}),mono:!0})}),o.jsx(ks,{label:"Pronouns",children:o.jsx(_o,{value:e.pronouns,onChange:n=>t({pronouns:n})})}),o.jsx(yi,{label:"How agents understand you",right:"shipped as system prompt context"}),o.jsx(ks,{label:"Operator bio",hint:"How you want to be worked with. Agents read this before asking you things.",children:o.jsx(Bq,{value:e.bio,onChange:n=>t({bio:n}),rows:4})}),o.jsxs("div",{className:"s-settings-two-col",children:[o.jsx(ks,{label:"Timezone",children:o.jsx(_o,{value:e.timezone,onChange:n=>t({timezone:n}),mono:!0})}),o.jsx(ks,{label:"Working hours",children:o.jsx(_o,{value:e.workingHours,onChange:n=>t({workingHours:n}),mono:!0})})]})]})}function Hq({profile:e,update:t}){return o.jsxs("div",{className:"s-settings-col-gap",children:[o.jsx(yi,{label:"Interrupt policy"}),o.jsx(ks,{label:"When agents can ping you directly",hint:"Blocking-only means only asks that truly stall work. Others get batched.",children:o.jsx(Id,{value:e.interruptThreshold,onChange:n=>t({interruptThreshold:n}),options:[{id:"always",label:"Always",sub:"any ask, any time"},{id:"blocking-only",label:"Blocking only",sub:"stuck agents · default"},{id:"batched",label:"Batched",sub:"grouped every 15m"},{id:"never",label:"Never",sub:"queue only, I'll check in"}]})}),o.jsxs("div",{className:"s-settings-two-col",children:[o.jsx(ks,{label:"Batch window (min)",children:o.jsx(Vq,{value:e.batchWindow,min:5,max:60,step:5,onChange:n=>t({batchWindow:n}),unit:"min"})}),o.jsx(ks,{label:"Quiet hours",children:o.jsx(_o,{value:e.quietHours,onChange:n=>t({quietHours:n}),mono:!0})})]}),o.jsx(yi,{label:"Where to reach you"}),o.jsx(ks,{label:"Preferred channel",children:o.jsx(Id,{value:e.channel,onChange:n=>t({channel:n}),options:[{id:"here",label:"Here only",sub:"desktop app"},{id:"mobile",label:"Mobile only",sub:"paired phone"},{id:"here+mobile",label:"Both",sub:"whichever is active"}]})}),o.jsx(yi,{label:"Tone calibration",right:"how agents write to you"}),o.jsxs("div",{className:"s-settings-two-col",children:[o.jsx(ks,{label:"Verbosity",children:o.jsx(Id,{stacked:!0,value:e.verbosity,onChange:n=>t({verbosity:n}),options:[{id:"terse",label:"Terse",sub:"one-liners, answers only"},{id:"normal",label:"Normal",sub:"context + answer"},{id:"detailed",label:"Detailed",sub:"show reasoning"}]})}),o.jsx(ks,{label:"Tone",children:o.jsx(Id,{stacked:!0,value:e.tone,onChange:n=>t({tone:n}),options:[{id:"direct",label:"Direct",sub:"no hedging"},{id:"warm",label:"Warm",sub:"friendly, conversational"},{id:"formal",label:"Formal",sub:"business-like"}]})})]})]})}const qq={desktop:"◻",mobile:"▯",tablet:"▭"};function Zq({device:e}){const t=e.status==="this-device"?"var(--accent)":e.status==="online"?"var(--green)":"var(--dim)";return o.jsxs("div",{className:"s-settings-device-row",children:[o.jsx("span",{className:"s-settings-device-icon",children:qq[e.kind]??"□"}),o.jsxs("div",{children:[o.jsx("div",{className:"s-settings-device-name",children:e.name}),o.jsxs("div",{className:"s-settings-device-meta",children:[e.kind," · via ",e.relay," · ",e.lastSeen]})]}),o.jsxs("span",{className:"s-settings-device-status",style:{color:t},children:["●"," ",e.status==="this-device"?"this device":e.status]}),o.jsx("button",{className:"s-btn",disabled:e.status==="this-device",children:e.status==="this-device"?"—":"Unpair"})]})}function Wq({pairing:e}){const t=[{id:"local",name:"This machine",kind:"desktop",status:"this-device",relay:"local",lastSeen:"now"}];if(e?.trustedPeers)for(const n of e.trustedPeers){const s=n.fingerprint===e.connectedPeerFingerprint;t.push({id:n.fingerprint,name:n.name??"Paired device",kind:"mobile",status:s?"online":"offline",relay:"tailscale",lastSeen:n.lastSeenLabel??"—"})}return o.jsxs("div",{className:"s-settings-col-gap",children:[o.jsx(yi,{label:`Paired devices · ${t.length}`}),o.jsx("div",{className:"s-settings-col-gap",style:{gap:10},children:t.map(n=>o.jsx(Zq,{device:n},n.id))}),o.jsx(yi,{label:"Relay"}),o.jsxs("div",{className:"s-settings-relay-card",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"s-settings-relay-title",children:["Relay · ",o.jsxs("span",{className:"s-settings-device-status",style:{color:e?.isRunning?"var(--green)":"var(--dim)"},children:["●"," ",e?.isRunning?"connected":"offline"]})]}),o.jsxs("div",{className:"s-settings-relay-meta",children:[e?.relay??"not configured"," · tailscale"]}),o.jsx("div",{className:"s-settings-relay-desc",children:"Agents route through your relay to reach mobile when the app is backgrounded. End-to-end encrypted; keys never leave your devices."})]}),o.jsx("button",{className:"s-btn",children:"Configure"})]})]})}const Yq=[{id:"operator",label:"Operator",sub:"identity · bio · hours"},{id:"comms",label:"Communication",sub:"how agents reach you"},{id:"devices",label:"Paired devices",sub:"relay · connected"}],Gq={operator:"Operator identity",comms:"Communication",devices:"Paired devices"},Kq={name:"",handle:"",pronouns:"",hue:195,bio:"",timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,workingHours:"08:00 – 18:00",interruptThreshold:"blocking-only",batchWindow:15,channel:"here+mobile",verbosity:"terse",tone:"direct",quietHours:"22:00 – 07:00"};function Xq({open:e,onClose:t}){const{refreshOnboarding:n}=Nt(),[s,a]=g.useState("operator"),[l,u]=g.useState(Kq),[d,p]=g.useState(null),[h,m]=g.useState(!1),y=g.useRef(null),x=g.useCallback(async()=>{try{const N=Re("/api/user"),k=Promise.race([Re("/api/pairing-state"),new Promise((S,R)=>setTimeout(()=>R(new Error("timeout")),3e3))]),[E,C]=await Promise.allSettled([N,k]);E.status==="fulfilled"&&u(E.value),C.status==="fulfilled"&&p(C.value)}finally{m(!0)}},[]);g.useEffect(()=>{e&&x()},[e,x]),g.useEffect(()=>{if(!e)return;const N=k=>{k.key==="Escape"&&t()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[e,t]);const w=g.useCallback(N=>{y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{Re("/api/user",{method:"POST",body:JSON.stringify(N)}).then(()=>n()).catch(()=>{})},400)},[n]),j=g.useCallback(N=>{u(k=>{const E={...k,...N};return w(E),E})},[w]);return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:`s-settings-scrim ${e?"s-settings-scrim--open":"s-settings-scrim--closed"}`,onClick:t}),o.jsxs("div",{className:`s-settings-drawer ${e?"s-settings-drawer--open":"s-settings-drawer--closed"}`,children:[o.jsxs("div",{className:"s-settings-header",children:[o.jsxs("div",{className:"s-settings-header-title",children:["⚙"," SETTINGS"]}),o.jsx("span",{className:"s-settings-header-sep",children:"/"}),o.jsx("span",{className:"s-settings-header-section",children:Gq[s]}),o.jsx("span",{style:{flex:1}}),o.jsx("span",{className:"s-settings-header-hint",children:"ESC to close"}),o.jsx("button",{className:"s-settings-close",onClick:t,children:"×"})]}),o.jsx("nav",{className:"s-settings-rail",children:Yq.map(N=>o.jsxs("button",{onClick:()=>a(N.id),className:`s-settings-rail-btn${s===N.id?" s-settings-rail-btn--active":""}`,children:[o.jsx("span",{className:"s-settings-rail-label",children:N.label}),o.jsx("span",{className:"s-settings-rail-sub",children:N.sub})]},N.id))}),o.jsx("main",{className:"s-settings-content",children:h?o.jsxs(o.Fragment,{children:[s==="operator"&&o.jsx(Fq,{profile:l,update:j}),s==="comms"&&o.jsx(Hq,{profile:l,update:j}),s==="devices"&&o.jsx(Wq,{pairing:d})]}):o.jsx("div",{style:{color:"var(--dim)",fontFamily:"var(--font-mono)",fontSize:12},children:"Loading..."})}),o.jsxs("div",{className:"s-settings-footer",children:[o.jsxs("span",{className:"s-settings-footer-sync",children:["●"," synced"]}),o.jsx("span",{children:"·"}),o.jsx("span",{children:"changes apply instantly to every agent in your fleet"}),o.jsx("span",{style:{flex:1}}),o.jsx("button",{className:"s-btn",onClick:t,children:"Done"})]})]})]})}function Jq({onOpen:e}){return o.jsxs("button",{className:"s-settings-launcher",onClick:e,children:[o.jsx("span",{className:"s-settings-launcher-icon",children:"⚙"}),o.jsx("span",{children:"settings"})]})}const AR=g.createContext(null),Qq=["hello","node.upserted","actor.registered","agent.registered","agent.endpoint.upserted","invocation.requested","flight.updated","delivery.state.changed","scout.dispatched"],eZ=new Set(Qq),tZ={"--hud-bg":"oklch(0.14 0.008 80)","--hud-surface":"oklch(0.18 0.009 80)","--hud-ink":"oklch(0.96 0.008 80)","--hud-muted":"oklch(0.72 0.012 80)","--hud-dim":"oklch(0.58 0.012 80)","--hud-border":"oklch(0.96 0.008 80 / 0.035)","--hud-accent":"oklch(0.86 0.17 125)","--hud-accent-soft":"oklch(0.86 0.17 125 / 0.08)","--hud-shadow-soft":"oklch(0.10 0.006 75 / 0.4)","--hud-chrome-border":"oklch(0.96 0.008 80 / 0.009)","--hud-shadow-panel":"0 12px 34px oklch(0.08 0.006 75 / 0.45)","--hud-shadow-panel-hover":"0 14px 38px oklch(0.08 0.006 75 / 0.52)","--hud-shadow-bar":"0 -10px 28px oklch(0.08 0.006 75 / 0.38)","--hud-shadow-nav":"0 8px 24px oklch(0.08 0.006 75 / 0.32)","--hud-shadow-minimap":"0 10px 24px oklch(0.08 0.006 75 / 0.38)","--hud-status-ok":"oklch(0.80 0.15 155)","--hud-status-warn":"oklch(0.82 0.15 85)","--hud-status-error":"oklch(0.72 0.18 25)","--scout-chrome-ink-strong":"color-mix(in srgb, var(--hud-ink) 92%, transparent)","--scout-chrome-ink":"color-mix(in srgb, var(--hud-ink) 78%, transparent)","--scout-chrome-ink-soft":"color-mix(in srgb, var(--hud-ink) 58%, transparent)","--scout-chrome-ink-faint":"color-mix(in srgb, var(--hud-ink) 38%, transparent)","--scout-chrome-ink-ghost":"color-mix(in srgb, var(--hud-ink) 22%, transparent)","--scout-chrome-hover":"color-mix(in srgb, var(--hud-ink) 4%, transparent)","--scout-chrome-active":"color-mix(in srgb, var(--hud-ink) 8%, transparent)","--scout-chrome-border-soft":"color-mix(in srgb, var(--hud-ink) 4%, transparent)","--scout-chrome-avatar-ink":"#111111","--hud-font-sans":"'Inter Tight', 'Inter', ui-sans-serif, system-ui, sans-serif","--hud-font-mono":"'JetBrains Mono', ui-monospace, Menlo, monospace","--hud-font-serif":"'Instrument Serif', 'Spectral', Georgia, serif"},nZ={"--hud-bg":"oklch(0.978 0.004 85)","--hud-surface":"oklch(0.992 0.003 85)","--hud-ink":"oklch(0.24 0.01 80)","--hud-muted":"oklch(0.56 0.014 80)","--hud-dim":"oklch(0.72 0.01 80)","--hud-border":"oklch(0.88 0.008 82 / 0.95)","--hud-accent":"oklch(0.72 0.16 125)","--hud-accent-soft":"oklch(0.72 0.16 125 / 0.11)","--hud-shadow-soft":"oklch(0.42 0.01 80 / 0.12)","--hud-status-ok":"oklch(0.64 0.16 155)","--hud-status-warn":"oklch(0.72 0.15 85)","--hud-status-error":"oklch(0.62 0.19 25)","--scout-chrome-ink-strong":"color-mix(in srgb, var(--hud-ink) 94%, transparent)","--scout-chrome-ink":"color-mix(in srgb, var(--hud-ink) 78%, transparent)","--scout-chrome-ink-soft":"color-mix(in srgb, var(--hud-ink) 60%, transparent)","--scout-chrome-ink-faint":"color-mix(in srgb, var(--hud-ink) 40%, transparent)","--scout-chrome-ink-ghost":"color-mix(in srgb, var(--hud-ink) 24%, transparent)","--scout-chrome-hover":"color-mix(in srgb, var(--hud-ink) 4%, transparent)","--scout-chrome-active":"color-mix(in srgb, var(--hud-ink) 8%, transparent)","--scout-chrome-border-soft":"color-mix(in srgb, var(--hud-border) 80%, transparent)","--scout-chrome-avatar-ink":"#ffffff","--hud-font-sans":"'Inter Tight', 'Inter', ui-sans-serif, system-ui, sans-serif","--hud-font-mono":"'JetBrains Mono', ui-monospace, Menlo, monospace","--hud-font-serif":"'Instrument Serif', 'Spectral', Georgia, serif"};function Nt(){const e=g.useContext(AR);if(!e)throw new Error("useScout must be used inside ScoutProvider");return e}function sZ({children:e,initialTheme:t="dark"}){const{route:n,navigate:s}=wq(),[a,l]=g.useState([]),[u,d]=g.useState(null),[p,h]=g.useState(!1),m=g.useCallback(()=>h(!0),[]),[y,x]=g.useState(!1),w=g.useCallback(()=>x(!0),[]),j=g.useCallback(()=>x(!1),[]),N=t==="light"?nZ:tZ,k=g.useMemo(()=>_q(a),[a]),E=g.useMemo(()=>Oq(k),[k]),C=g.useCallback(async()=>{const z=await Re("/api/agents").catch(()=>null);z&&l(z)},[]),S=g.useCallback(async()=>{try{const z=await Re("/api/onboarding/state");d(z)}catch{d({hasLocalConfig:!0,hasProjectConfig:!0,hasOperatorName:!0,localConfigPath:null,projectRoot:null,currentDirectory:null,operatorName:null,operatorNameSuggestion:null})}},[]);g.useEffect(()=>{C(),S()},[C,S]);const R=g.useMemo(()=>a.filter(z=>ki(z.state)).length,[a]),A=g.useCallback(z=>{switch(z.type){case"navigate":s(z.route);break;case"open-ranger":s({view:"conversation",conversationId:E,...z.mode==="ask"?{composeMode:"ask"}:{}});break;case"refresh":C();break}},[s,E,C]),M=g.useRef({rangerAgentId:k,applyRangerUiAction:A});M.current={rangerAgentId:k,applyRangerUiAction:A},Rn(z=>{eZ.has(z.kind)&&C();const V=z.kind==="message.posted"&&z.payload&&typeof z.payload=="object"?z.payload.message:null;if(!V||typeof V!="object")return;const U=V,O=typeof U.actorId=="string"?U.actorId:"",D=typeof U.body=="string"?U.body:"";if(!(!O||!D||!ER(O,M.current.rangerAgentId)))for(const H of Iq(D))M.current.applyRangerUiAction(H)}),g.useEffect(()=>{const z=V=>{const U=V.detail,O=U&&typeof U=="object"&&"type"in U?U:null;O&&M.current.applyRangerUiAction(O)};return window.addEventListener("scout:ranger-ui-action",z),window.scoutRanger={applyUiAction:V=>M.current.applyRangerUiAction(V),navigate:V=>M.current.applyRangerUiAction({type:"navigate",route:V})},()=>{window.removeEventListener("scout:ranger-ui-action",z),window.scoutRanger?.applyUiAction&&delete window.scoutRanger}},[]);const _=g.useMemo(()=>({route:n,navigate:s,agents:a,onlineCount:R,reload:C,onboarding:u,refreshOnboarding:S,onboardingSkipped:p,skipOnboarding:m,settingsOpen:y,openSettings:w,closeSettings:j,rangerAgentId:k,rangerConversationId:E,applyRangerUiAction:A}),[n,s,a,R,C,u,S,p,m,y,w,j,k,E,A]);return o.jsx(AR.Provider,{value:_,children:o.jsx("div",{"data-scout-theme":t,"data-scout-theme-mode":t,style:{...N},children:o.jsxs(Lq,{children:[e,o.jsx(Xq,{open:y,onClose:j})]})})})}function rZ(){const{navigate:e,agents:t,reload:n,openSettings:s,rangerConversationId:a,applyRangerUiAction:l}=Nt(),u=tu(),d=g.useCallback(async()=>{try{const h=await Re("/api/ask",{method:"POST",body:JSON.stringify({conversationId:a,body:"What's the state of things? Give me a terse ops summary, the biggest risk, and the next action you recommend."})});e({view:"conversation",conversationId:h.conversationId??a,composeMode:"ask"})}catch{e({view:"conversation",conversationId:a,composeMode:"ask"})}},[e,a]),p=g.useCallback(async h=>{await Re(`/api/agents/${encodeURIComponent(h)}/interrupt`,{method:"POST",body:JSON.stringify({})})},[]);return g.useMemo(()=>{const h=[{id:"nav:home",label:"Go to Home",action:()=>e({view:"inbox"}),shortcut:"Cmd+1"},{id:"nav:agents",label:"Go to Agents",action:()=>e({view:"agents"}),shortcut:"Cmd+2"},{id:"nav:fleet",label:"Go to Fleet",action:()=>e({view:"fleet"}),shortcut:"Cmd+3"},{id:"nav:sessions",label:"Go to Sessions",action:()=>e({view:"sessions"}),shortcut:"Cmd+4"},{id:"nav:activity",label:"Go to Activity",action:()=>e({view:"activity"}),shortcut:"Cmd+5"},{id:"nav:mesh",label:"Go to Mesh",action:()=>e({view:"mesh"}),shortcut:"Cmd+6"},...u?[{id:"nav:ops",label:"Go to Ops",action:()=>e({view:"ops"}),shortcut:"Cmd+7"}]:[],{id:"nav:settings",label:"Open Settings",action:()=>s(),shortcut:"Cmd+,"},{id:"ranger:open",label:"Open Ranger",action:()=>e({view:"conversation",conversationId:a,composeMode:"ask"})},{id:"ranger:state",label:"Ask Ranger for State",action:()=>{d()}},{id:"ranger:ops-tail",label:"Ranger: Open Ops Tail",action:()=>l({type:"navigate",route:{view:"ops",mode:"tail"}})},{id:"nav:pair",label:"Pair Device",action:()=>s()},{id:"scout:reload",label:"Reload Agents",action:()=>{n()}}];for(const m of t)h.push({id:`scout:open:${m.id}`,label:`Open ${m.name}`,action:()=>e({view:"conversation",conversationId:Dn(m.id)})}),h.push({id:`scout:send:${m.id}`,label:`Tell ${m.name}`,action:()=>e({view:"conversation",conversationId:Dn(m.id)})}),h.push({id:`scout:ask:${m.id}`,label:`Ask ${m.name}`,action:()=>e({view:"conversation",conversationId:Dn(m.id),composeMode:"ask"})}),h.push({id:`scout:interrupt:${m.id}`,label:`Interrupt ${m.name}`,action:()=>{p(m.id)}});return h},[t,l,d,p,e,u,a,n,s])}function RR(){const{onlineCount:e}=Nt(),[t,n]=g.useState(null),s=g.useRef(0),a=g.useCallback(async()=>{const l=++s.current;try{const u=await Re("/api/mesh");if(l!==s.current)return;n(u)}catch{if(l!==s.current)return;n(null)}},[]);return g.useEffect(()=>{a();const l=setInterval(()=>{a()},15e3);return()=>clearInterval(l)},[a]),{status:t===null?{label:"Broker: …",color:"neutral"}:t.health.reachable?{label:"Broker: UP",color:"emerald"}:{label:"Broker: DOWN",color:"red"},activeAgents:{label:"Active Agents",count:e},mesh:t===null?{label:"Mesh",value:"checking",color:"neutral"}:t.health.reachable?Object.values(t.nodes).filter(u=>u.id!==t.localNode?.id).length>0?{label:"Mesh",value:"connected",color:"neutral"}:t.identity.discoverable?{label:"Mesh",value:"discoverable",color:"neutral"}:{label:"Mesh",value:"local",color:"amber"}:{label:"Mesh",value:"offline",color:"neutral"}}}function aZ(){return RR().status}const iZ={inbox:"Fleet",conversation:"Conversation","agent-info":"Agent",agents:"Agents",fleet:"Fleet",sessions:"Sessions",activity:"Activity",mesh:"Mesh",settings:"Settings",work:"Work",ops:"Ops"};function oZ(){const{route:e,navigate:t}=Nt(),n=tu(),s=[{label:"Fleet",view:"inbox"},{label:"Agents",view:"agents"},{label:"Sessions",view:"sessions"},{label:"Mesh",view:"mesh"},...n?[{label:"Ops",view:"ops"}]:[]],a=e.view==="fleet"||e.view==="activity"?"inbox":e.view==="conversation"||e.view==="agent-info"?"agents":e.view==="work"?n?"ops":"inbox":e.view,l=e.view==="conversation"||e.view==="agent-info"||e.view==="work"?iZ[e.view]??e.view:null;return g.createElement("div",{className:"scout-nav-tabs"},s.map(({label:u,view:d})=>g.createElement("button",{key:d,className:`scout-nav-tab${a===d?" active":""}`,onClick:()=>t({view:d})},u)),l&&g.createElement("span",{className:"scout-nav-slash"},"/"),l&&g.createElement("span",{className:"scout-nav-crumb"},l))}function lZ(){const{openSettings:e,navigate:t,rangerConversationId:n}=Nt();return g.createElement("div",{className:"scout-nav-actions"},g.createElement("button",{onClick:()=>t({view:"conversation",conversationId:n,composeMode:"ask"}),className:"scout-nav-action scout-nav-action--ranger"},"Ranger"),g.createElement("button",{onClick:()=>e(),className:"scout-nav-action"},"Pair device"))}function cZ(){return"panel"}function uZ(){const{onboarding:e,onboardingSkipped:t,skipOnboarding:n}=Nt();if(!e)return null;if(t)return{active:!1,dismissible:!0};const s=!e.hasLocalConfig,a=!e.hasProjectConfig,l=!e.hasOperatorName;return{active:s||l||a,dismissible:!0,onDismiss:n}}function dZ({app:e,assistant:t=!0}){return o.jsx(e.Provider,{children:o.jsx(hZ,{app:e,assistantEnabled:t})})}function fZ({statusBar:e}){const t=e.mesh.color==="amber"?"text-amber-400":e.mesh.color==="red"?"text-red-400":"text-neutral-100";return o.jsxs("div",{className:"flex items-center gap-3 font-mono text-[12px]",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsxs("span",{className:"text-neutral-500",children:[e.activeAgents.label,":"]}),o.jsx("span",{className:"text-neutral-100",children:e.activeAgents.count})]}),o.jsx("div",{className:"h-3 w-px bg-neutral-700"}),o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsxs("span",{className:"text-neutral-500",children:[e.mesh.label,":"]}),o.jsx("span",{className:t,children:e.mesh.value})]})]})}function hZ({app:e,assistantEnabled:t}){const{navTotalHeight:n}=vy(),s=e.hooks.useCommands(),a=e.hooks.useSearch?.()??null,l=e.hooks.useNavCenter?.()??null,u=e.hooks.useNavActions?.()??null,d=e.hooks.useLayoutMode?.()??e.mode,p=e.hooks.useActiveToolHint?.()??null,h=e.hooks.useTakeover?.()??null,m=h?.active===!0,y=m&&h?.dismissible===!0,x=h?.onDismiss,w=e.slots.Takeover,j=RR(),[N,k]=Ir(`appshell.${e.id}.left`,!1),[E,C]=Ir(`appshell.${e.id}.right`,!1),[S,R]=Ir(`appshell.${e.id}.leftW`,260),[A,M]=Ir(`appshell.${e.id}.rightW`,280),[_,z]=g.useState({x:0,y:0}),[V,U]=g.useState(1),O=g.useCallback(oe=>{z(ve=>({x:ve.x+oe.x,y:ve.y+oe.y}))},[]),D=g.useCallback(oe=>{U(oe)},[]),[H,W]=g.useState(!1),[q,$]=g.useState(!1),[L,F]=Ir(`appshell.${e.id}.termH`,320),X=!!e.slots.Terminal,G=g.useMemo(()=>{const oe=[];return X&&oe.push("terminal"),t&&oe.push("assistant"),oe},[X,t]),I=G[0]??"terminal",[B,Y]=Ir(`appshell.${e.id}.drawerTab`,I),Q=G.includes(B)?B:I,[me,re]=g.useState(!1),[ie,de]=g.useState(new Set),ye=g.useCallback(oe=>{de(ve=>{const xe=new Set(ve);return xe.has(oe)?xe.delete(oe):xe.add(oe),xe})},[]),Te=g.useCallback(oe=>ve=>{ve.preventDefault();const xe=ve.clientX,Ne=oe==="left"?S:A,ke=oe==="left"?R:M,Se=oe==="left"?1:-1,$e=xt=>{const kt=(xt.clientX-xe)*Se;ke(Math.max(200,Math.min(500,Ne+kt)))},Pe=()=>{document.removeEventListener("mousemove",$e),document.removeEventListener("mouseup",Pe)};document.addEventListener("mousemove",$e),document.addEventListener("mouseup",Pe)},[S,A,R,M]),he=g.useMemo(()=>{const oe=[{id:"shell:toggle-left",label:"Toggle Left Panel",shortcut:"Cmd+[",action:()=>k(ve=>!ve)},{id:"shell:toggle-right",label:"Toggle Right Panel",shortcut:"Cmd+]",action:()=>C(ve=>!ve)},{id:"shell:toggle-terminal",label:"Toggle Terminal",shortcut:"Ctrl+`",action:()=>W(ve=>!ve)}];return t&&oe.push({id:"shell:toggle-assistant",label:"Toggle Assistant",shortcut:"Cmd+J",action:()=>{Y("assistant"),W(ve=>!ve||B!=="assistant")}}),oe},[t,B,Y,k,C]),ue=g.useMemo(()=>[...s,...he],[s,he]);g.useEffect(()=>{const oe=ve=>{m||((ve.metaKey||ve.ctrlKey)&&ve.key==="k"&&(ve.preventDefault(),re(!0)),(ve.metaKey||ve.ctrlKey)&&ve.key==="["&&(ve.preventDefault(),k(xe=>!xe)),(ve.metaKey||ve.ctrlKey)&&ve.key==="]"&&(ve.preventDefault(),C(xe=>!xe)),ve.ctrlKey&&ve.key==="`"&&(ve.preventDefault(),W(xe=>!xe)),t&&(ve.metaKey||ve.ctrlKey)&&ve.key==="j"&&(ve.preventDefault(),Y("assistant"),W(xe=>!(xe&&Q==="assistant"))))};return window.addEventListener("keydown",oe),()=>window.removeEventListener("keydown",oe)},[t,Q,Y,k,C,m]),g.useEffect(()=>{const oe=()=>{Y("terminal"),W(!0),F(ve=>ve>window.innerHeight*.8?420:ve)};return window.addEventListener("scout:open-terminal",oe),()=>window.removeEventListener("scout:open-terminal",oe)},[Y,F]);const we=e.slots.Inspector,We=e.slots.RightPanel,Ae=e.tools&&e.tools.length>0,je=o.jsxs(o.Fragment,{children:[we&&o.jsx(we,{}),!we&&We&&o.jsx(We,{}),Ae&&o.jsx("div",{className:"border-t border-neutral-700/50",children:e.tools.map(oe=>{const ve=ie.has(oe.id);return o.jsxs("div",{children:[o.jsxs("button",{onClick:()=>ye(oe.id),className:`w-full flex items-center gap-2 px-4 py-2.5 text-[11px] font-mono tracking-wider uppercase transition-colors hover:bg-white/5 ${p===oe.id?"text-emerald-400":"text-neutral-300"}`,children:[ve?o.jsx(RO,{size:10}):o.jsx(_O,{size:10}),o.jsx("span",{className:"text-neutral-400",children:oe.icon}),o.jsx("span",{className:"font-bold",children:oe.name})]}),ve&&o.jsx("div",{className:"px-4 pb-3",children:o.jsx(oe.Component,{})})]},oe.id)})})]}),Ee=o.jsxs(o.Fragment,{children:[e.slots.LeftFooter&&o.jsx(e.slots.LeftFooter,{}),o.jsx(dq,{onOpenCommandPalette:()=>re(!0)})]}),Ue=g.useRef(null),Ve=g.useRef(null);g.useEffect(()=>{const oe=Ue.current;oe&&(m?oe.setAttribute("inert",""):oe.removeAttribute("inert"))},[m]),g.useEffect(()=>{if(!m)return;const oe=Ve.current;if(oe&&(oe.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])")??oe).focus(),!y)return;const ve=xe=>{xe.key==="Escape"&&(xe.preventDefault(),x?.())};return window.addEventListener("keydown",ve),()=>window.removeEventListener("keydown",ve)},[m,y,x]);const Be=d==="panel"?{position:"absolute",top:n,bottom:28,left:N?0:S,right:E?0:A,overflow:"auto",transition:"left 200ms ease, right 200ms ease"}:{};return o.jsxs(o.Fragment,{children:[o.jsx("div",{ref:Ue,"aria-hidden":m?!0:void 0,style:{display:"contents"},children:o.jsx(iq,{mode:d,panOffset:_,scale:V,onPan:O,onZoom:D,hud:o.jsxs(o.Fragment,{children:[o.jsx(lq,{title:e.name.toUpperCase(),search:a??void 0,center:l,actions:u}),o.jsx(MN,{side:"left",title:e.leftPanel?.title??"Navigation",icon:e.leftPanel?.icon,isCollapsed:N,onToggleCollapse:()=>k(!N),width:S,onResizeStart:Te("left"),footer:Ee,headerActions:e.leftPanel?.headerActions&&o.jsx(e.leftPanel.headerActions,{}),children:e.slots.LeftPanel&&o.jsx(e.slots.LeftPanel,{})}),o.jsx(MN,{side:"right",title:e.rightPanel?.title??"Inspector",icon:e.rightPanel?.icon,isCollapsed:E,onToggleCollapse:()=>C(!E),width:A,onResizeStart:Te("right"),headerActions:e.rightPanel?.headerActions&&o.jsx(e.rightPanel.headerActions,{}),children:je}),o.jsx(uq,{status:j.status,left:o.jsx(fZ,{statusBar:j}),onToggleTerminal:()=>W(oe=>!oe),isTerminalOpen:H}),o.jsx("div",{className:"pointer-events-none",style:{position:"fixed",left:N?0:S,right:E?0:A,bottom:0,top:0,zIndex:45,transition:"left 200ms ease, right 200ms ease",transform:"translateZ(0)"},children:o.jsxs(fq,{isOpen:H,onClose:()=>W(!1),onToggleMaximize:()=>$(oe=>!oe),isMaximized:q,height:Math.min(L,window.innerHeight*.8),onHeightChange:oe=>F(Math.min(oe,window.innerHeight*.8)),title:o.jsx(pZ,{tabs:G,active:Q,onSelect:Y}),children:[Q==="terminal"&&(e.slots.Terminal?o.jsx(e.slots.Terminal,{}):o.jsx("div",{className:"p-4 font-mono text-[12px] text-neutral-400",children:"No terminal content"})),Q==="assistant"&&o.jsx(g$,{app:e,commands:s})]})}),o.jsx(hq,{isOpen:me,onClose:()=>re(!1),commands:ue})]}),children:o.jsx("div",{style:Be,className:"frame-scrollbar",children:o.jsx(e.slots.Content,{})})})}),m&&w?o.jsx("div",{ref:Ve,tabIndex:-1,role:"dialog","aria-modal":"true",style:{position:"fixed",inset:0,zIndex:80,outline:"none"},children:o.jsx(w,{})}):null]})}function pZ({tabs:e,active:t,onSelect:n}){return e.length===0?null:o.jsx("div",{className:"flex items-center gap-0.5",children:e.map(s=>{const a=s===t,l=s==="terminal"?QO:GO,u=s==="terminal"?"TERMINAL":"ASSISTANT",d=s==="terminal"?"text-emerald-400":"text-cyan-400";return o.jsxs("button",{type:"button",onClick:()=>n(s),className:`flex items-center gap-1.5 px-2.5 py-1 rounded text-xs font-bold tracking-widest font-mono transition-colors ${a?`${d} bg-white/[0.04]`:"text-neutral-500 hover:text-neutral-300"}`,children:[o.jsx(l,{size:13}),o.jsx("span",{children:u})]},s)})})}const PN=["#6366f1","#8b5cf6","#0ea5e9","#14b8a6","#f59e0b","#ef4444","#ec4899","#10b981"];function mt(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return PN[Math.abs(t)%PN.length]}function Ur(e){switch(et(e)){case"working":return"var(--green)";case"available":return"var(--accent)";default:return"var(--dim)"}}const mZ={workspace:"workspace",worktree:"workspace",branch:"workspace",profile:"profile",persona:"profile",harness:"harness",runtime:"harness",model:"model",node:"node",host:"node"};function gZ(e){return e.trim().replace(/^@+/,"").replace(/[.,!?;)\]]+$/,"")}function Us(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}const vZ="scout";function yZ(e){return mZ[Us(e)]??null}function MR(e){const t=Us(e.definitionId),n=e.workspaceQualifier?Us(e.workspaceQualifier):void 0,s=e.profile?Us(e.profile):void 0,a=e.harness?Us(e.harness):void 0,l=e.model?Us(e.model):void 0,u=e.nodeQualifier?Us(e.nodeQualifier):void 0;return t?{definitionId:t,...n?{workspaceQualifier:n}:{},...s?{profile:s}:{},...a?{harness:a}:{},...l?{model:l}:{},...u?{nodeQualifier:u}:{}}:null}function _R(e){const t=e.split(".").filter(Boolean),n=t.shift();if(!n)return null;const s={definitionId:n},a=[];for(const l of t){if(l.includes(":")){const[u,d=""]=l.split(":",2),p=yZ(u),h=Us(d);if(!p||!h)return null;p==="workspace"?s.workspaceQualifier=h:p==="profile"?s.profile=h:p==="harness"?s.harness=h:p==="model"?s.model=h:p==="node"&&(s.nodeQualifier=h);continue}a.push(l)}if(a.length===1){const l=Us(a[0]);if(!l)return null;s.workspaceQualifier=l}else if(a.length===2){const l=Us(a[0]),u=Us(a[1]);if(!l||!u)return null;s.workspaceQualifier||(s.workspaceQualifier=l),s.nodeQualifier||(s.nodeQualifier=u)}else if(a.length>2)return null;return OR(s,{raw:e})}function bZ(e){const t=e.indexOf("#"),n=e.indexOf("?");if(t===-1&&n===-1||e.indexOf("#",t+1)!==-1||e.indexOf("?",n+1)!==-1||t!==-1&&n!==-1&&n<t)return null;const s=Math.min(...[t,n].filter(p=>p>=0)),a=e.slice(0,s);if(!a)return null;const l=_R(a);if(!l)return null;const u=t>=0?e.slice(t+1,n>=0?n:e.length):"",d=n>=0?e.slice(n+1):"";return t>=0&&!u||n>=0&&!d||u.includes("#")||u.includes("?")||d.includes("#")||d.includes("?")||l.harness&&u||l.model&&d?null:OR({definitionId:l.definitionId,nodeQualifier:l.nodeQualifier,workspaceQualifier:l.workspaceQualifier,profile:l.profile,harness:u||l.harness,model:d||l.model},{raw:e})}function xZ(e){const t=gZ(e);return!t||t.includes("@")?null:t.includes("#")||t.includes("?")?bZ(t):_R(t)}function zN(e,t={}){const n=MR(e);if(!n)return t.includeSigil===!1?"":"@";const a=[`${t.includeSigil===!1?"":"@"}${n.definitionId}`];return n.workspaceQualifier&&a.push(n.workspaceQualifier),n.profile&&a.push(`profile:${n.profile}`),n.harness&&a.push(`harness:${n.harness}`),n.model&&a.push(`model:${n.model}`),n.nodeQualifier&&a.push(`node:${n.nodeQualifier}`),a.join(".")}function OR(e,t={}){const n=MR(e);return n?{raw:t.raw??zN(n,{includeSigil:!1}),label:zN(n),definitionId:n.definitionId,...n.nodeQualifier?{nodeQualifier:n.nodeQualifier}:{},...n.workspaceQualifier?{workspaceQualifier:n.workspaceQualifier}:{},...n.profile?{profile:n.profile}:{},...n.harness?{harness:n.harness}:{},...n.model?{model:n.model}:{}}:null}function wZ(e){return jZ(e).parsed}function jZ(e){const t=Array.from(e.matchAll(/(^|[\s([{'"`])@([a-z0-9][a-z0-9._/:-]*(?:#[a-z0-9][a-z0-9._/:-]*)?(?:\?[a-z0-9][a-z0-9._/:-]*)?)(?=$|[\s)\]}",.!?:;'"`])/gi)),n=new Map,s=[];for(const a of t){const l=a[2]??"",u=xZ(l);if(!u){l&&s.push(`@${l}`);continue}n.set(u.label,u)}return{parsed:Array.from(n.values()),unparsed:Array.from(new Set(s))}}function SZ(e,t){if(t.length===0)return[{kind:"text",value:e}];const n=new Map;for(const u of t)n.set(u.label.toLowerCase(),u);const s=[];let a=e;const l=/@([a-z0-9][a-z0-9._/:-]*)/i;for(;a.length>0;){const u=l.exec(a);if(!u||u.index===void 0){s.push({kind:"text",value:a});break}u.index>0&&s.push({kind:"text",value:a.slice(0,u.index)});const d=u[0],p=d.toLowerCase(),h=n.get(p);h?s.push({kind:"mention",identity:h}):s.push({kind:"text",value:d}),a=a.slice(u.index+d.length)}return s}function NZ(e,t){const n=[],s=/`([^`\n]+)`|\*\*(.+?)\*\*|\*([^*\s][^*]*?)\*|\[([^\]\n]+)\]\(([^)\s]+)\)/g;let a=0,l,u=0;for(;(l=s.exec(e))!==null;)l.index>a&&n.push(o.jsx("span",{children:e.slice(a,l.index)},`${t}-${u++}`)),l[1]!==void 0?n.push(o.jsx("code",{className:"s-inline-code",children:l[1]},`${t}-${u++}`)):l[2]!==void 0?n.push(o.jsx("strong",{children:l[2]},`${t}-${u++}`)):l[3]!==void 0?n.push(o.jsx("em",{children:l[3]},`${t}-${u++}`)):l[4]!==void 0&&l[5]!==void 0&&kZ(l[5])?n.push(o.jsx("a",{href:l[5],target:"_blank",rel:"noreferrer",children:l[4]},`${t}-${u++}`)):n.push(o.jsx("span",{children:l[0]},`${t}-${u++}`)),a=l.index+l[0].length;return a<e.length&&n.push(o.jsx("span",{children:e.slice(a)},`${t}-${u++}`)),n.length>0?n:[o.jsx("span",{children:e},t)]}function kZ(e){return/^(?:https?:\/\/|mailto:|\/|#)/iu.test(e)}function us(e){if(!e)return e??"";const t=wZ(e);return SZ(e,t).flatMap((s,a)=>{if(s.kind==="text")return NZ(s.value,a*100);const{identity:l}=s,d=l.definitionId===vZ?"var(--accent)":mt(l.definitionId);return o.jsx("span",{className:"s-mention",style:{"--mention-color":d},children:l.label},a)})}function De(e){const t=e<1e12?e*1e3:e,n=Math.floor((Date.now()-t)/1e3);return n<5?"now":n<60?`${n}s`:n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}d`}function hi(e){return new Date(e<1e12?e*1e3:e).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"})}const EZ={"agent.registered":"registered","agent.online":"came online","agent.offline":"went offline","flight.started":"started task","flight.completed":"completed task","flight.updated":"updated task","message.sent":"sent message","message.received":"received message","collaboration.ask":"asked a question","collaboration.answer":"answered",ask_sent:"asked",ask_replied:"replied",ask_working:"working",flight_created:"started task",flight_updated:"updated task",message_sent:"sent",message_received:"received"},CZ={presence:{label:"Presence",tone:"notice"},work:{label:"Execution",tone:"working"},message:{label:"Delivery",tone:"completed"},collaboration:{label:"Coordination",tone:"working"},system:{label:"System",tone:"notice"}};function IR(e){return EZ[e]??e.replace(/[._]/g," ")}function TZ(e){return e.startsWith("agent.")||e.includes("registered")||e.includes("online")||e.includes("offline")?"presence":e.startsWith("flight")||e.startsWith("ask_")?"work":e.startsWith("message")?"message":e.startsWith("collaboration")?"collaboration":"system"}function AZ(e){return(e??"system").charAt(0).toUpperCase()}function DR(e){return e.length<=14?e:`${e.slice(0,8)}...${e.slice(-4)}`}function RZ(e){if(!e)return null;const t=e.split("/").filter(Boolean);return t[t.length-1]??e}function MZ(e){return`${e.actorName??"system"} ${IR(e.kind)}`}function _Z(e){return e.workspaceRoot?`Recorded from ${e.workspaceRoot}.`:e.conversationId?`Linked to thread ${DR(e.conversationId)}.`:"No additional detail was captured for this event."}function OZ({navigate:e}){const[t,n]=g.useState([]),[s,a]=g.useState(null),[l,u]=g.useState(!0),[d,p]=g.useState(!1),[h,m]=g.useState(null),[y,x]=g.useState(null),w=g.useRef([]),j=g.useRef(0),N=g.useRef(null),k=bh();g.useEffect(()=>{w.current=t},[t]);const E=g.useCallback(async(M="initial")=>{const _=++j.current;!(w.current.length>0)&&M!=="background"?(u(!0),m(null)):p(!0);try{const V=await Re("/api/activity");if(_!==j.current)return;n(V),m(null),x(Date.now()),a(U=>V.some(O=>O.id===U)?U:null)}catch(V){if(_!==j.current)return;m(V instanceof Error?V.message:String(V))}finally{_===j.current&&(u(!1),p(!1))}},[]),C=g.useCallback(()=>{N.current||(N.current=setTimeout(()=>{N.current=null,E("background")},250))},[E]);g.useEffect(()=>(E("initial"),()=>{N.current&&clearTimeout(N.current)}),[E]),Rn(C);const S=g.useMemo(()=>{const M=new Set(t.map(z=>z.actorName??"system")),_=new Set(t.map(z=>z.conversationId).filter(z=>!!z));return[{label:"Events",value:`${t.length}`,detail:t.length>0?`Latest ${De(t[0].ts)}`:"Waiting for records"},{label:"Actors",value:`${M.size}`,detail:M.size>0?"Distinct event owners":"No actors yet"},{label:"Threads",value:`${_.size}`,detail:_.size>0?"Conversation-linked records":"No linked threads"}]},[t]),R=!l&&t.length===0&&!!h,A=!l&&t.length===0&&!h;return o.jsxs("div",{className:"sys-surface-page",children:[o.jsxs("div",{className:"sys-page-head",children:[o.jsxs("div",{className:"sys-page-title-group",children:[o.jsx("h2",{className:"sys-page-title",children:"Activity"}),o.jsx("p",{className:"sys-page-subtitle",children:"Broker events, task execution, and collaboration handoffs."})]}),o.jsxs("div",{className:"sys-page-actions",children:[o.jsx("div",{className:"sys-sync-note",children:l?"Loading audit ledger...":h&&t.length>0?`Showing last confirmed snapshot from ${y?De(y):"earlier"}`:y?`Updated ${De(y)}`:"Waiting for first snapshot"}),o.jsx("button",{type:"button",className:"s-btn",disabled:l||d,onClick:()=>{E("manual")},children:d?"Refreshing...":"Refresh"})]})]}),o.jsx("div",{className:"sys-stat-grid",children:S.map(M=>o.jsxs("div",{className:"sys-stat-card",children:[o.jsx("span",{className:"sys-stat-label",children:M.label}),o.jsx("strong",{className:"sys-stat-value",children:M.value}),o.jsx("span",{className:"sys-stat-detail",children:M.detail})]},M.label))}),h&&t.length>0&&o.jsxs("div",{className:"sys-banner sys-banner-warning",children:[o.jsx("strong",{children:"Refresh failed."}),o.jsx("span",{children:h})]}),l&&t.length===0&&o.jsxs("div",{className:"sys-panel sys-state-card",children:[o.jsx("h3",{className:"sys-state-title",children:"Loading activity"}),o.jsx("p",{className:"sys-state-body",children:"Pulling the latest records from the broker database."})]}),R&&o.jsxs("div",{className:"sys-panel sys-state-card sys-state-card-error",children:[o.jsx("h3",{className:"sys-state-title",children:"Activity is unavailable"}),o.jsx("p",{className:"sys-state-body",children:h}),o.jsx("div",{className:"sys-inline-actions",children:o.jsx("button",{type:"button",className:"s-btn",onClick:()=>{E("manual")},children:"Try again"})})]}),A&&o.jsxs("div",{className:"sys-panel sys-state-card",children:[o.jsx("h3",{className:"sys-state-title",children:"No activity yet"}),o.jsx("p",{className:"sys-state-body",children:"Events appear here after agents register, send messages, or advance work."})]}),t.length>0&&o.jsx("div",{className:"sys-audit-list",children:t.map(M=>{const _=s===M.id,z=TZ(M.kind),V=CZ[z],U=RZ(M.workspaceRoot),O=M.summary&&M.summary!==M.title?M.summary:_Z(M);return o.jsxs("article",{className:`sys-audit-entry${_?" sys-audit-entry-expanded":""}`,onContextMenu:D=>{const H=window.getSelection()?.toString().trim(),W=[];H&&(W.push({kind:"action",label:"Copy Selection",shortcut:"⌘C",onSelect:()=>navigator.clipboard.writeText(H)}),W.push({kind:"separator"}));const q=M.title??M.summary??"";q&&W.push({kind:"action",label:"Copy Details",onSelect:()=>navigator.clipboard.writeText(q)}),M.actorName&&W.push({kind:"action",label:"Copy Actor",onSelect:()=>navigator.clipboard.writeText(M.actorName)}),W.push({kind:"action",label:"Copy Event ID",onSelect:()=>navigator.clipboard.writeText(M.id)}),M.conversationId&&(W.push({kind:"separator"}),W.push({kind:"action",label:"Open Thread",onSelect:()=>e({view:"conversation",conversationId:M.conversationId})})),k(D,W)},children:[o.jsxs("button",{type:"button",className:"sys-audit-toggle","aria-expanded":_,onClick:()=>a(_?null:M.id),children:[o.jsxs("div",{className:"sys-audit-stamp",children:[o.jsx("span",{className:"sys-audit-time",children:De(M.ts)}),o.jsx("span",{className:"sys-audit-date",children:hi(M.ts)})]}),o.jsx("div",{className:`sys-audit-marker sys-audit-marker-${V.tone}`,children:o.jsx("span",{})}),o.jsxs("div",{className:"sys-audit-body",children:[o.jsxs("div",{className:"sys-audit-topline",children:[o.jsx("span",{className:"sys-audit-category",children:V.label}),o.jsx("span",{className:"sys-audit-kind",children:IR(M.kind)})]}),o.jsx("h3",{className:"sys-audit-title",children:us(M.title??MZ(M))}),o.jsx("p",{className:"sys-audit-summary",children:us(O)}),o.jsxs("div",{className:"sys-audit-meta",children:[o.jsxs("span",{className:"sys-audit-meta-item",children:[o.jsx("span",{className:"sys-audit-avatar",style:{background:mt(M.actorName??"system")},children:AZ(M.actorName)}),M.actorName??"system"]}),U&&o.jsxs("span",{className:"sys-audit-meta-item",children:["Workspace ",U]}),M.conversationId&&o.jsxs("span",{className:"sys-audit-meta-item",children:["Thread ",DR(M.conversationId)]})]})]}),o.jsx("div",{className:"sys-audit-expand",children:_?"Close":"Details"})]}),_&&o.jsxs("div",{className:"sys-audit-details",children:[o.jsxs("div",{className:"sys-detail-grid",children:[o.jsxs("div",{className:"sys-detail-card",children:[o.jsx("span",{className:"sys-detail-label",children:"Event"}),o.jsx("code",{className:"sys-detail-value",children:M.kind})]}),o.jsxs("div",{className:"sys-detail-card",children:[o.jsx("span",{className:"sys-detail-label",children:"Recorded"}),o.jsx("span",{className:"sys-detail-value",children:hi(M.ts)})]}),o.jsxs("div",{className:"sys-detail-card",children:[o.jsx("span",{className:"sys-detail-label",children:"Actor"}),o.jsx("span",{className:"sys-detail-value",children:M.actorName??"system"})]}),o.jsxs("div",{className:"sys-detail-card",children:[o.jsx("span",{className:"sys-detail-label",children:"Workspace"}),o.jsx("span",{className:"sys-detail-value",children:M.workspaceRoot??"Not attached"})]}),o.jsxs("div",{className:"sys-detail-card",children:[o.jsx("span",{className:"sys-detail-label",children:"Thread"}),o.jsx("span",{className:"sys-detail-value",children:M.conversationId??"Not attached"})]}),o.jsxs("div",{className:"sys-detail-card",children:[o.jsx("span",{className:"sys-detail-label",children:"Record id"}),o.jsx("code",{className:"sys-detail-value",children:M.id})]})]}),M.conversationId&&o.jsx("div",{className:"sys-inline-actions",children:o.jsx("button",{type:"button",className:"s-btn s-btn-sm",onClick:()=>e({view:"conversation",conversationId:M.conversationId}),children:"Open thread"})})]})]},M.id)})})]})}function Ra(e){const t=e?.trim();if(!t)return null;const[n]=t.split(".");return n?.trim()||t}function IZ(e){const t=e.handle?.trim().replace(/^@+/,"");if(t)return`@${t}`;const n=e.selector?.trim();if(n)return n;const s=Ra(e.id);return s?`@${s}`:null}function DZ(e){return e.name?.trim()||e.agentName?.trim()||Ra(e.id)||e.title?.trim()||"Conversation"}function Ng(e){return e?e.replace(/_/g," "):null}function PZ({values:e}){return o.jsx("span",{className:"s-agent-token-list",children:e.map(t=>o.jsx("span",{className:"s-agent-token",children:t},t))})}function Dd({title:e,items:t}){return t.length===0?null:o.jsxs("section",{className:"s-agent-profile-card",children:[o.jsx("div",{className:"s-agent-profile-card-header",children:o.jsx("div",{className:"s-agent-profile-card-title",children:e})}),o.jsx("div",{className:"s-agent-meta-card-body",children:t.map(n=>o.jsxs("div",{className:"s-agent-meta-row",children:[o.jsx("span",{className:"s-agent-meta-label",children:n.label}),o.jsx("span",{className:"s-agent-meta-value",children:n.value})]},n.label))})]})}function zZ({conversationId:e,navigate:t}){const{agents:n}=Nt(),[s,a]=g.useState(null),[l,u]=g.useState(null),d=SR(e),p=g.useCallback(async()=>{u(null);try{const k=await Re(`/api/session/${encodeURIComponent(e)}`).catch(()=>null);a(k)}catch(k){u(k instanceof Error?k.message:String(k)),a(null)}},[e]);g.useEffect(()=>{p()},[p]),Rn(()=>{p()});const h=s?.agentId??d,m=g.useMemo(()=>h?n.find(k=>k.id===h)??null:null,[n,h]);if(!m)return o.jsxs("div",{children:[o.jsx("button",{type:"button",className:"s-back",onClick:()=>t({view:"conversation",conversationId:e}),children:"← Back"}),l&&o.jsx("p",{className:"s-error",children:l}),o.jsx("div",{className:"s-empty",children:o.jsx("p",{children:"Agent not found"})})]});const y=IZ(m),x=[{label:"System ID",value:m.id},{label:"Class",value:Ng(m.agentClass)??"—"},...m.role?[{label:"Role",value:m.role}]:[],...m.selector&&m.selector!==y?[{label:"Selector",value:m.selector}]:[]],w=[...m.project?[{label:"Project",value:m.project}]:[],...m.branch?[{label:"Branch",value:m.branch}]:[],...m.projectRoot?[{label:"Path",value:m.projectRoot}]:[],...m.cwd?[{label:"Working dir",value:m.cwd}]:[]],j=[...m.harness?[{label:"Harness",value:m.harness}]:[],...m.model?[{label:"Model",value:m.model}]:[],...m.transport?[{label:"Transport",value:Ng(m.transport)??m.transport}]:[],...m.wakePolicy?[{label:"Wake policy",value:Ng(m.wakePolicy)??m.wakePolicy}]:[],...m.capabilities.length>0?[{label:"Capabilities",value:o.jsx(PZ,{values:m.capabilities})}]:[]],N=[{label:"Thread ID",value:e},...s?.workspaceRoot?[{label:"Workspace",value:s.workspaceRoot}]:[],...s?.currentBranch?[{label:"Session branch",value:s.currentBranch}]:[],...s?.messageCount!=null?[{label:"Messages",value:String(s.messageCount)}]:[],...s?.lastMessageAt?[{label:"Last message",value:hi(s.lastMessageAt)}]:[],...m.harnessSessionId?[{label:"Harness session",value:m.harnessSessionId}]:[],...m.harnessLogPath?[{label:"Harness log",value:m.harnessLogPath}]:[]];return o.jsxs("div",{className:"s-agent-profile-page",children:[o.jsxs("div",{className:"s-agent-profile-page-topbar",children:[o.jsx("button",{type:"button",className:"s-back",onClick:()=>t({view:"conversation",conversationId:e}),children:"← Conversation"}),o.jsx("button",{type:"button",className:"s-btn",onClick:()=>t({view:"agents",agentId:m.id}),children:"Open in Agents"})]}),l&&o.jsx("p",{className:"s-error",children:l}),o.jsxs("section",{className:"s-agent-profile-hero",children:[o.jsx("div",{className:"s-agent-profile-hero-main",children:o.jsxs("div",{className:"s-agent-profile-hero-title-row",children:[o.jsx("div",{className:"s-avatar s-agent-profile-hero-avatar",style:{background:mt(m.name)},children:m.name[0].toUpperCase()}),o.jsxs("div",{className:"s-agent-profile-hero-copy",children:[o.jsxs("div",{className:"s-agent-casefile-title-meta",children:[o.jsx("span",{className:"s-agent-casefile-record",children:y??Ra(m.id)??m.id}),o.jsxs("span",{className:`s-agent-state-chip s-agent-state-chip-${et(m.state)}`,children:[o.jsx("span",{className:"s-dot",style:{background:Ur(m.state)}}),Pn(m.state)]})]}),o.jsx("h1",{className:"s-agent-profile-hero-title",children:m.name}),o.jsxs("p",{className:"s-agent-profile-hero-context",children:[s?.title?`Conversation: ${s.title}.`:"Attached to the current conversation.",m.updatedAt?` Updated ${De(m.updatedAt)}.`:""]})]})]})}),o.jsx("div",{className:"s-agent-profile-hero-actions",children:o.jsx("button",{type:"button",className:"s-btn s-btn-primary",onClick:()=>t({view:"conversation",conversationId:e}),children:"Open conversation"})})]}),o.jsxs("div",{className:"s-agent-profile-grid",children:[o.jsx(Dd,{title:"Identity",items:x}),o.jsx(Dd,{title:"Workspace",items:w}),o.jsx(Dd,{title:"Runtime",items:j}),o.jsx(Dd,{title:"Conversation context",items:N})]})]})}function LZ(e){return e.attention==="interrupt"?"failed":e.state==="done"?"completed":e.attention==="badge"||e.state==="waiting"||e.state==="review"?"updated":"working"}function $Z(e){switch(e){case"review":return"In review";case"waiting":return"Waiting";case"working":return"Working";case"done":return"Done";default:return e.replace(/_/g," ")}}function UZ(e){switch(e){case"badge":return"Needs attention";case"interrupt":return"Blocked";default:return null}}function LN({items:e,navigate:t,emptyTitle:n,emptyDetail:s}){if(e.length===0){const a=[{titleWidth:"56%",metaWidths:["18%","14%","16%"],summaryWidth:"74%"},{titleWidth:"48%",metaWidths:["16%","20%","12%"],summaryWidth:"62%"}];return o.jsxs("div",{className:"s-work-empty-state",children:[o.jsxs("div",{className:"s-work-empty-copy",children:[o.jsx("p",{className:"s-work-empty-kicker",children:"Quiet for now"}),o.jsx("p",{className:"s-work-empty-title",children:n}),s&&o.jsx("p",{className:"s-work-empty-detail",children:s})]}),o.jsx("div",{className:"s-work-empty-skeleton","aria-hidden":"true",children:a.map((l,u)=>o.jsxs("div",{className:"s-work-empty-row",children:[o.jsxs("div",{className:"s-work-empty-row-header",children:[o.jsx("span",{className:"s-work-empty-line s-work-empty-line-title",style:{width:l.titleWidth}}),o.jsx("span",{className:"s-work-empty-pill"})]}),o.jsx("div",{className:"s-work-empty-row-meta",children:l.metaWidths.map(d=>o.jsx("span",{className:"s-work-empty-line s-work-empty-line-meta",style:{width:d}},d))}),o.jsx("span",{className:"s-work-empty-line s-work-empty-line-summary",style:{width:l.summaryWidth}})]},u))})]})}return o.jsx("div",{className:"s-work-list",children:e.map(a=>{const l=!!a.id||!!a.conversationId,u=UZ(a.attention),d=a.ownerName??a.ownerId??"Unassigned",p=a.id?()=>t({view:"work",workId:a.id}):a.conversationId?()=>t({view:"conversation",conversationId:a.conversationId}):void 0;return o.jsxs("div",{className:`s-work-row${l?" s-work-row-clickable":""}`,onClick:p,children:[o.jsxs("div",{className:"s-work-row-header",children:[o.jsxs("div",{className:"s-work-row-title-wrap",children:[o.jsx("span",{className:"s-work-row-title",children:a.title}),a.priority&&o.jsx("span",{className:"s-badge",children:a.priority})]}),o.jsx("span",{className:`s-pill s-pill-${LZ(a)}`,children:a.currentPhase})]}),o.jsxs("div",{className:"s-work-row-meta",children:[o.jsx("span",{children:d}),o.jsx("span",{children:$Z(a.state)}),a.activeChildWorkCount>0&&o.jsxs("span",{children:[a.activeChildWorkCount," child",a.activeChildWorkCount===1?"":"ren"]}),a.activeFlightCount>0&&o.jsxs("span",{children:[a.activeFlightCount," flight",a.activeFlightCount===1?"":"s"]}),u&&o.jsx("span",{children:u}),o.jsx("span",{children:De(a.lastMeaningfulAt)})]}),a.lastMeaningfulSummary&&o.jsx("p",{className:"s-work-row-summary",children:us(a.lastMeaningfulSummary)})]},a.id)})})}const PR="/api",BZ=`${PR}/health`,VZ=`${PR}/terminal/run`,zR="/ws/terminal",FZ=`${zR}/health`,HZ="/ws/hmr";function qZ(e,t){if(typeof e!="string")return t;const n=e.trim();return n&&`${n.startsWith("/")?"":"/"}${n}`.replace(/\/{2,}/g,"/").replace(/\/+$/g,"")||t}const ZZ={healthPath:BZ,terminalRunPath:VZ,terminalRelayPath:zR,terminalRelayHealthPath:FZ,viteHmrPath:HZ};function LR(){return typeof window>"u"?null:window.__OPENSCOUT_WEB_BOOTSTRAP__??null}function WZ(){const e=LR()?.theme;return typeof e=="string"?e:null}function nu(e){return qZ(LR()?.routes?.[e],ZZ[e])}function $R(){const e=nu("terminalRelayPath");return typeof window>"u"?`ws://localhost:3200${e}`:`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${e}`}function UR(){const e=nu("terminalRelayHealthPath");return typeof window>"u"?`http://localhost:3200${e}`:`${window.location.protocol}//${window.location.host}${e}`}const Uv=/^```([a-z0-9_-]+)?\s*$/iu,BR=/^(#{1,6})\s+(.+)$/u,YZ=/^(?:-{3,}|\*{3,}|_{3,})$/u,GZ=/^\s*[-*]\s+(.+)$/u,KZ=/^\s*\d+[.)]\s+(.+)$/u,XZ=/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?$/u;function JZ(e){const t=e.replace(/\r\n?/gu,`
|
|
141
|
-
`).trim();return t?t.replace(/([^\n])\s+---\s+(?=(?:#{1,6}\s|\*\*|[A-Z0-9]))/gu,`$1
|
|
142
|
-
|
|
143
|
-
---
|
|
144
|
-
|
|
145
|
-
`).replace(/([^\n])\s+(#{1,6}\s+)/gu,`$1
|
|
146
|
-
|
|
147
|
-
$2`).replace(/\n{3,}/gu,`
|
|
148
|
-
|
|
149
|
-
`):""}function VR(e){return e.trim().length===0}function QZ(e){return BR.test(e.trim())}function FR(e){return YZ.test(e.trim())}function Bv(e){return e.match(GZ)?.[1]?.trim()??null}function Vv(e){return e.match(KZ)?.[1]?.trim()??null}function eW(e){return Bv(e)!==null||Vv(e)!==null}function $N(e){return e.trim().replace(/^\|/u,"").replace(/\|$/u,"").split("|").map(n=>n.trim())}function HR(e,t){const n=e[t]?.trim(),s=e[t+1]?.trim();return!!(n&&s&&n.includes("|")&&XZ.test(s))}function tW(e,t){const n=e[t]??"",s=n.trim();return!!(VR(n)||Uv.test(s)||QZ(n)||FR(n)||eW(n)||s.startsWith(">")||HR(e,t))}function nW(e){const t=JZ(e);if(!t)return[];const n=t.split(`
|
|
150
|
-
`),s=[];let a=0;for(;a<n.length;){const l=n[a]??"",u=l.trim();if(!u){a+=1;continue}const d=u.match(Uv);if(d){const x=[];for(a+=1;a<n.length&&!Uv.test(n[a].trim());)x.push(n[a]),a+=1;a<n.length&&(a+=1),s.push({type:"code",language:d[1]??null,text:x.join(`
|
|
151
|
-
`)});continue}if(FR(l)){s.push({type:"hr"}),a+=1;continue}const p=u.match(BR);if(p){s.push({type:"heading",depth:p[1].length,text:p[2].trim()}),a+=1;continue}if(HR(n,a)){const x=$N(n[a]);a+=2;const w=[];for(;a<n.length&&n[a].includes("|")&&!VR(n[a]);)w.push($N(n[a])),a+=1;s.push({type:"table",headers:x,rows:w});continue}const h=Bv(l),m=Vv(l);if(h!==null||m!==null){const x=m!==null,w=[];for(;a<n.length;){const j=x?Vv(n[a]):Bv(n[a]);if(j===null)break;w.push(j),a+=1}s.push({type:"list",ordered:x,items:w});continue}if(u.startsWith(">")){const x=[];for(;a<n.length&&n[a].trim().startsWith(">");)x.push(n[a].trim().replace(/^>\s?/u,"")),a+=1;s.push({type:"blockquote",text:x.join(`
|
|
152
|
-
`).trim()});continue}const y=[];for(;a<n.length&&!tW(n,a);)y.push(n[a].trimEnd()),a+=1;s.push({type:"paragraph",text:y.join(`
|
|
153
|
-
`).trim()})}return s}function sW(e,t){const n=Math.min(6,Math.max(2,e.depth+1));return o.jsx("div",{role:"heading","aria-level":n,className:`s-message-markup-heading s-message-markup-heading-${e.depth}`,children:us(e.text)},t)}function rW(e,t){return o.jsx("div",{className:"s-message-markup-table-wrap",children:o.jsxs("table",{className:"s-message-markup-table",children:[o.jsx("thead",{children:o.jsx("tr",{children:e.headers.map((n,s)=>o.jsx("th",{children:us(n)},`${t}:h:${s}`))})}),o.jsx("tbody",{children:e.rows.map((n,s)=>o.jsx("tr",{children:e.headers.map((a,l)=>o.jsx("td",{children:us(n[l]??"")},`${t}:c:${s}:${l}`))},`${t}:r:${s}`))})]})},t)}function aW(e,t){switch(e.type){case"paragraph":return o.jsx("p",{className:"s-message-markup-paragraph",children:us(e.text)},t);case"heading":return sW(e,t);case"hr":return o.jsx("hr",{className:"s-message-markup-rule"},t);case"list":return e.ordered?o.jsx("ol",{className:"s-message-markup-list",children:e.items.map((n,s)=>o.jsx("li",{children:us(n)},`${t}:${s}`))},t):o.jsx("ul",{className:"s-message-markup-list",children:e.items.map((n,s)=>o.jsx("li",{children:us(n)},`${t}:${s}`))},t);case"blockquote":return o.jsx("blockquote",{className:"s-message-markup-quote",children:us(e.text)},t);case"code":return o.jsx("pre",{className:"s-message-markup-code",children:o.jsx("code",{children:e.text})},t);case"table":return rW(e,t)}}function qR({text:e,className:t}){const n=nW(e??"");return n.length===0?e??"":o.jsx("div",{className:["s-message-markup",t].filter(Boolean).join(" "),children:n.map(aW)})}const ZR="scout:sessions:lastViewed";function fb(){if(typeof localStorage>"u")return{};try{const e=localStorage.getItem(ZR);if(!e)return{};const t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function iW(e,t=Date.now()){const n=fb();n[e]=t;try{localStorage.setItem(ZR,JSON.stringify(n))}catch{}return n}function kg(e,t,n){return e?e>(n[t]??0):!1}async function oW(e){await fetch(nu("terminalRunPath"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:e})})}const Fv=new Set(["completed","failed","cancelled"]),lW={direct:"Direct message",channel:"Channel",group_direct:"Group",thread:"Thread"},UN=[{command:"/ask",label:"/ask",description:"Ask the agent owned work with a reply",insert:"/ask "},{command:"/tell",label:"/tell",description:"Send a heads-up or quick message",insert:"/tell "},{command:"/steer",label:"/steer",description:"Steer the active turn mid-flight",insert:"/steer "},{command:"/route",label:"/route",description:"Route this to another agent",insert:"/route @"},{command:"/inbox",label:"/inbox",description:"Go to the inbox",insert:"/inbox"},{command:"/agents",label:"/agents",description:"Open the agents list",insert:"/agents"},{command:"/fleet",label:"/fleet",description:"Open the fleet view",insert:"/fleet"},{command:"/sessions",label:"/sessions",description:"Browse sessions",insert:"/sessions"},{command:"/mesh",label:"/mesh",description:"Open the mesh view",insert:"/mesh"},{command:"/activity",label:"/activity",description:"Open activity feed",insert:"/activity"},{command:"/settings",label:"/settings",description:"Open settings",insert:"/settings"}];function WR(e,t){if(t<=0)return!0;const n=e[t-1];return!n||/\s/.test(n)}function cW(e,t){if(t===0)return null;let n=t-1;for(;n>=0;){const a=e[n];if(a==="/")break;if(!a||/\s/.test(a))return null;n-=1}if(n<0||e[n]!=="/"||!WR(e,n))return null;const s=e.slice(n+1,t);return/[^a-zA-Z0-9_-]/.test(s)?null:{start:n,query:s}}function uW(e,t){if(t===0)return null;let n=t-1;for(;n>=0;){const a=e[n];if(a==="@")break;if(!a||/\s/.test(a))return null;n-=1}if(n<0||e[n]!=="@"||!WR(e,n))return null;const s=e.slice(n+1,t);return/[^a-zA-Z0-9._/:-]/.test(s)?null:{start:n,query:s}}function es(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?null:e<1e12?e*1e3:e}function dW(e){if(!e)return null;const t=e.replace(/[\\/]+$/,"");return t?t.split(/[\\/]/).filter(Boolean).at(-1)??t:null}function fW(e){return e.kind==="direct"&&e.agentName?e.agentName:e.kind==="direct"&&e.agentId?Ra(e.agentId)??e.agentId:e.title.replace(/\s*<>\s*/g," · ")}function Eg(e){const t=es(e);return t===null?"":new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(t)}function hW(e,t){const n=es(e),s=es(t);if(n===null||s===null)return!1;const a=new Date(n),l=new Date(s);return a.getFullYear()===l.getFullYear()&&a.getMonth()===l.getMonth()&&a.getDate()===l.getDate()}function BN(e){const t=es(e);if(t===null)return"";const n=new Date(t),s=new Date,a=new Date(s.getFullYear(),s.getMonth(),s.getDate()).getTime(),l=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime(),u=1440*60*1e3;return l===a?"Today":l===a-u?"Yesterday":new Intl.DateTimeFormat(void 0,{weekday:"short",month:"short",day:"numeric"}).format(t)}function pW(e){switch(e){case"status":return"Status";case"system":return"System";case"scout.dispatch":return"Dispatch";default:return null}}function Pd(e){return[...e].sort((t,n)=>(es(t.createdAt)??0)-(es(n.createdAt)??0))}function mW(e){return e.filter(t=>!Fv.has(t.state)).sort((t,n)=>(es(n.startedAt)??0)-(es(t.startedAt)??0))[0]??null}function VN(e,t,n){return{id:e.id,invocationId:e.invocationId,agentId:e.targetAgentId||n,agentName:null,conversationId:t,collaborationRecordId:null,state:e.state,summary:e.summary??null,startedAt:e.startedAt??null,completedAt:e.completedAt??null}}function gW(e){const t=e.metadata?.scoutDispatch;if(!t||typeof t!="object")return null;const n=t;return!n.id||!n.kind||!Array.isArray(n.candidates)?null:n}function Hv(e,t){if(e.class==="operator")return!0;const n=e.actorName?.toLowerCase()??"";return n===t.toLowerCase()||n==="operator"||n==="you"}function vW(e,t){return e.reduce((n,s)=>{if(Hv(s,t))return n;const a=es(s.createdAt);return a===null?n:n===null||a>n?a:n},null)}function yW(e,t){switch(t){case"queued":return`${e} has your message and is waiting to start.`;case"waking":return`${e} is waking up now.`;case"waiting":return`${e} is thinking through the request.`;case"running":return`${e} is working on your request.`;default:return`${e} is working on it.`}}function bW(e){const{agentName:t,agentState:n,sending:s,currentFlight:a,showWorkingTurn:l}=e;if(s&&!a)return{label:"Sending",detail:`Handing your message to ${t}.`,tone:"pending",showStrip:!0,showTyping:!1};if(a&&l){const u=a.summary?.trim()||yW(t,a.state);switch(a.state){case"queued":return{label:"Queued",detail:u,tone:"pending",showStrip:!0,showTyping:!0};case"waking":return{label:"Coming online",detail:u,tone:"working",showStrip:!0,showTyping:!0};case"waiting":return{label:"Thinking",detail:u,tone:"working",showStrip:!0,showTyping:!0};default:return{label:"Working",detail:u,tone:"working",showStrip:!0,showTyping:!0}}}return ki(n)?{label:"Available",detail:`${t} is connected.`,tone:"idle",showStrip:!1,showTyping:!1}:{label:"Offline",detail:`${t} is offline right now. Sending a message will wake it up.`,tone:"offline",showStrip:!0,showTyping:!1}}function xW(e,t){switch(e.tone){case"pending":return"var(--accent)";case"working":return"var(--green)";case"offline":return"var(--dim)";default:return Ur(t)}}function wW(){return o.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("path",{d:"m3 11 18-8-8 18-2.8-7.2L3 11Z"}),o.jsx("path",{d:"M10.2 13.8 21 3"})]})}function jW(){return o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:o.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})})}function SW(e){if(!e)return null;if(e.kind==="direct")return e.agentName??Ra(e.agentId)??null;const t=e.participantIds.filter(n=>n!=="operator");return t.length===0?null:t.map(n=>Ra(n)??n).join(", ")}function qv({conversationId:e,initialComposeMode:t,initialDraft:n,navigate:s,embedded:a}){const{agents:l}=Nt(),[u,d]=g.useState(null),[p,h]=g.useState([]),[m,y]=g.useState(null),[x,w]=g.useState([]),[j,N]=g.useState(null),k=g.useRef(null),E=g.useRef(null),C=g.useRef(new Set),S=g.useRef(null),R=g.useRef(0),A=g.useRef(null),M=SR(e),_=u?.agentId??M,z=u?.kind==="direct"||M!==null,V=g.useMemo(()=>_?l.find(ee=>ee.id===_)??null:null,[l,_]),[U,O]=g.useState([]),[D,H]=g.useState(new Set),[W]=g.useState(()=>fb());g.useEffect(()=>{Re("/api/sessions").then(ee=>O(ee.sort((ge,be)=>(be.lastMessageAt??0)-(ge.lastMessageAt??0)))).catch(()=>{}),Re("/api/fleet").then(ee=>{const ge=new Set;for(const be of ee.needsAttention)be.conversationId&&ge.add(be.conversationId),be.agentId&&ge.add(be.agentId);for(const be of ee.activeAsks)be.status==="needs_attention"&&be.conversationId&&ge.add(be.conversationId);H(ge)}).catch(()=>{})},[]);const q=g.useCallback(async()=>{N(null);try{const ee=await Re(`/api/session/${encodeURIComponent(e)}`).catch(()=>null);d(ee);const ge=ee?.agentId??M,be=ee?.kind==="direct"&&ge&&ge.startsWith("local-session-agent-")?Dn(ge):e;if(be!==e){s({view:"conversation",conversationId:be,...t?{composeMode:t}:{}});return}const[qe,Ze]=await Promise.all([Re(`/api/messages?conversationId=${encodeURIComponent(be)}&limit=300`),Re(`/api/flights?conversationId=${encodeURIComponent(be)}`)]);h(Pd(qe)),w(Ze),C.current=new Set(Ze.map(dt=>dt.invocationId)),y(mW(Ze))}catch(ee){N(ee instanceof Error?ee.message:String(ee))}},[e,t,M,s]);g.useEffect(()=>{q()},[q]);const[$,L]=g.useState(null),[F,X]=g.useState(!1);g.useEffect(()=>{if(!_)return;let ee=!1;return Re(`/api/agents/${encodeURIComponent(_)}/session-catalog`).then(ge=>{ee||L(ge)}).catch(()=>{}),()=>{ee=!0}},[_]),g.useEffect(()=>{S.current=m},[m]);const[G,I]=g.useState(()=>n??""),[B,Y]=g.useState(!1),[Q,me]=g.useState("operator"),[re,ie]=g.useState({open:!1,query:"",triggerStart:-1,index:0}),[de,ye]=g.useState({open:!1,query:"",triggerStart:-1,index:0}),[Te,he]=g.useState(null),[ue,we]=g.useState(t==="ask"?"ask":"tell");g.useEffect(()=>{we(z&&t==="ask"?"ask":"tell")},[e,t,z]),g.useEffect(()=>{if(!n)return;const ee=`${e}:${n}`;A.current!==ee&&(A.current=ee,I(n),requestAnimationFrame(()=>E.current?.focus()))},[e,n]);const We=g.useMemo(()=>{const ee=new Set,ge=[];for(const be of l){const qe=be.handle?.trim().replace(/^@+/,"")??Ra(be.id)??be.id;if(!qe)continue;const Ze=qe.toLowerCase();ee.has(Ze)||(ee.add(Ze),ge.push({id:be.id,label:qe,name:be.name??qe,handle:qe}))}return ge.sort((be,qe)=>be.handle.localeCompare(qe.handle))},[l]),Ae=g.useMemo(()=>{if(!re.open)return[];const ee=re.query.toLowerCase();return ee?UN.filter(ge=>ge.command.toLowerCase().startsWith("/"+ee)||ge.command.toLowerCase().includes(ee)):UN},[re.open,re.query]),je=g.useMemo(()=>{if(!de.open)return[];const ee=de.query.toLowerCase();return ee?We.filter(ge=>ge.handle.toLowerCase().includes(ee)||ge.name.toLowerCase().includes(ee)).slice(0,8):We.slice(0,8)},[de.open,de.query,We]),Ee=g.useCallback(()=>{ie(ee=>ee.open?{...ee,open:!1}:ee),ye(ee=>ee.open?{...ee,open:!1}:ee)},[]),Ue=g.useCallback((ee,ge)=>{const be=cW(ee,ge);ie(be?Ze=>({open:!0,query:be.query,triggerStart:be.start,index:Ze.open&&Ze.triggerStart===be.start?Ze.index:0}):Ze=>Ze.open?{...Ze,open:!1}:Ze);const qe=uW(ee,ge);ye(qe?Ze=>({open:!0,query:qe.query,triggerStart:qe.start,index:Ze.open&&Ze.triggerStart===qe.start?Ze.index:0}):Ze=>Ze.open?{...Ze,open:!1}:Ze)},[]),Ve=g.useCallback(ee=>{const ge=E.current,be=re.triggerStart;if(be<0)return;const qe=ge?.selectionStart??G.length,Ze=G.slice(0,be),dt=G.slice(qe),Vt=ee.insert,Et=`${Ze}${Vt}${dt}`;I(Et),ie(mn=>({...mn,open:!1})),requestAnimationFrame(()=>{const mn=E.current;if(!mn)return;const xn=Ze.length+Vt.length;mn.focus(),mn.setSelectionRange(xn,xn)})},[G,re.triggerStart]),Be=g.useCallback(ee=>{const ge=E.current,be=de.triggerStart;if(be<0)return;const qe=ge?.selectionStart??G.length,Ze=G.slice(0,be),dt=G.slice(qe),Vt=dt.length===0||!dt.startsWith(" "),Et=`@${ee.handle}${Vt?" ":""}`,mn=`${Ze}${Et}${dt}`;I(mn),ye(xn=>({...xn,open:!1})),requestAnimationFrame(()=>{const xn=E.current;if(!xn)return;const Ws=Ze.length+Et.length;xn.focus(),xn.setSelectionRange(Ws,Ws)})},[G,de.triggerStart]);g.useEffect(()=>{const ee=E.current;if(!ee)return;ee.style.height="0px";const ge=Math.min(Math.max(ee.scrollHeight,40),160);ee.style.height=`${ge}px`,ee.style.overflowY=ee.scrollHeight>ge?"auto":"hidden"},[G]),g.useEffect(()=>{Re("/api/user").then(ee=>me(ee.name)).catch(()=>{})},[]);const oe=g.useMemo(()=>vW(p,Q),[p,Q]);g.useEffect(()=>{Te===null||oe===null||oe>=Te&&he(null)},[Te,oe]);const ve=g.useMemo(()=>!m||Fv.has(m.state)?!1:(es(m.startedAt)??Te??Date.now())>=(oe??0),[Te,m,oe]),xe=B||Te!==null||ve,Ne=DZ({name:V?.name,agentName:u?.agentName,id:_,title:u?.title}),ke=g.useMemo(()=>bW({agentName:Ne,agentState:V?.state??null,sending:B,currentFlight:m,showWorkingTurn:ve}),[V?.state,Ne,m,B,ve]),Se=u?fW(u):Ne,$e=u?.kind?lW[u.kind]??u.kind:"Conversation";SW(u);const Pe=dW(u?.workspaceRoot),xt=u?.lastMessageAt??p[p.length-1]?.createdAt??null,kt=[Pe?{label:Pe,title:u?.workspaceRoot??void 0}:null,u?.currentBranch?{label:u.currentBranch,title:u.currentBranch}:null,V?.harness??u?.harness?{label:V?.harness??u?.harness??"",title:void 0}:null].filter(ee=>!!ee),un=u?u.participantIds.length:z?2:1,Xt=g.useMemo(()=>(!D.has(e)&&!(_&&D.has(_)),null),[e,_,D]);Rn(g.useCallback(ee=>{if(ee.kind==="message.posted"){const ge=ee.payload?.message;if(!ge||ge.conversationId!==e)return;const be=ge.actorId===_,qe={id:ge.id,conversationId:ge.conversationId,actorName:be?Ne:Q,body:ge.body,createdAt:ge.createdAt,class:be?ge.class:"operator"};if(h(Ze=>{if(Ze.some(dt=>dt.id===ge.id))return Ze;if(!be){const dt=Ze.findIndex(Vt=>Vt.id.startsWith("optimistic-")&&Vt.body===ge.body&&Math.abs((es(Vt.createdAt)??0)-(es(ge.createdAt)??0))<=6e4);if(dt!==-1){const Vt=[...Ze];return Vt[dt]=qe,Pd(Vt)}}return Pd([...Ze,qe])}),be){const Ze=es(ge.createdAt)??Date.now();he(dt=>dt===null||Ze<dt?dt:null),y(dt=>{if(!dt)return dt;const Vt=es(dt.startedAt)??0;return Ze>=Vt?null:dt})}return}if(ee.kind==="invocation.requested"){const ge=ee.payload?.invocation;if(!ge||ge.targetAgentId!==_||ge.conversationId!==e)return;C.current.add(ge.id),he(be=>be??Date.now());return}if(ee.kind==="flight.updated"){const ge=ee.payload?.flight;if(!ge||ge.targetAgentId!==_||!(C.current.has(ge.invocationId)||S.current?.id===ge.id))return;if(Fv.has(ge.state)){y(qe=>qe?.id===ge.id?null:qe),q();return}C.current.add(ge.invocationId),y(VN(ge,e,_??""));return}ee.kind!=="agent.endpoint.upserted"&&ee.kind==="unknown"&&q()},[_,Ne,e,q,Q])),g.useEffect(()=>{if(!xe)return;const ee=setInterval(()=>{q()},5e3);return()=>clearInterval(ee)},[xe,q]),g.useEffect(()=>{const ee=()=>{if(document.visibilityState!=="visible")return;const ge=Date.now();ge-R.current<1e3||(R.current=ge,q())};return window.addEventListener("focus",ee),document.addEventListener("visibilitychange",ee),()=>{window.removeEventListener("focus",ee),document.removeEventListener("visibilitychange",ee)}},[q]);const Jt=p.length+(ke.showTyping?1:0),ze=g.useRef(0);g.useEffect(()=>{Jt>ze.current&&k.current?.scrollIntoView({behavior:"smooth"}),ze.current=Jt},[Jt]);const[,at]=g.useState(0);g.useEffect(()=>{const ee=setInterval(()=>at(ge=>ge+1),15e3);return()=>clearInterval(ee)},[]);const lt=async(ee,ge)=>{const be=ee.trim();if(!be||B)return;const qe=ge?.forceMode??ue,Ze=z?xe?"steer":qe:"tell",dt=Date.now(),Vt={id:`optimistic-${dt}`,conversationId:e,actorName:Q,body:be,createdAt:dt,class:"operator"};Y(!0),he(dt),N(null),h(Et=>Pd([...Et,Vt]));try{const Et=await Re(Ze==="ask"?"/api/ask":"/api/send",{method:"POST",body:JSON.stringify({body:be,conversationId:e})});Et.flight&&(C.current.add(Et.flight.invocationId),y(VN(Et.flight,e,_??"")))}catch(Et){h(mn=>mn.filter(xn=>xn.id!==Vt.id)),he(null),N(Et instanceof Error?Et.message:String(Et))}finally{Y(!1)}},gt=async()=>{const ee=G.trim();ee&&(I(""),await lt(ee))},Bt=async()=>{if(_)try{await Re("/api/agents/"+encodeURIComponent(_)+"/interrupt",{method:"POST",body:JSON.stringify({})})}catch{}},bn=ke.tone==="working"||ke.tone==="pending",Wt=z?xe?"steer":ue:"tell",Mn=z?"Reply — or type / to route, @ to mention an agent, ? to ask a question":`Message ${Ne}...`,dn=!G.trim()&&bn,fn=bh(),qs=g.useCallback((ee,ge)=>{const be=window.getSelection()?.toString().trim(),qe=[];be&&(qe.push({kind:"action",label:"Copy Selection",shortcut:"⌘C",onSelect:()=>navigator.clipboard.writeText(be)}),qe.push({kind:"separator"})),qe.push({kind:"action",label:"Copy Message",onSelect:()=>navigator.clipboard.writeText(ge.body)}),ge.actorName&&!Hv(ge,Q)&&qe.push({kind:"action",label:"Copy Agent ID",onSelect:()=>navigator.clipboard.writeText(ge.actorName??"")}),qe.push({kind:"separator"}),qe.push({kind:"action",label:"Copy Message ID",onSelect:()=>navigator.clipboard.writeText(ge.id)}),fn(ee,qe)},[Q,fn]),Zs=async(ee,ge)=>{const be=`@${ge.agentId} `,qe=G.trim();if(qe){I(""),await lt(`${be}${qe}`,{forceMode:"tell"});return}I(be),E.current?.focus()},Mi=g.useMemo(()=>u?u.participantIds.filter(ee=>ee!=="operator").slice(0,4).map(ee=>{const ge=l.find(be=>be.id===ee);return{id:ee,name:ge?.name??ee}}):[],[u,l]);return o.jsx("div",{className:`s-thread-layout${a?" s-thread-layout--embedded":""}`,children:o.jsxs("div",{className:"s-thread-center",children:[!a&&o.jsxs("div",{className:"s-thread-center-header",onClick:()=>z?s({view:"agent-info",conversationId:e}):void 0,style:z?{cursor:"pointer"}:void 0,onContextMenu:ee=>{const ge=[{kind:"action",label:"Copy Title",onSelect:()=>navigator.clipboard.writeText(Se)}];_&&ge.push({kind:"action",label:"Copy Agent ID",onSelect:()=>navigator.clipboard.writeText(_)}),ge.push({kind:"action",label:"Copy Conversation ID",onSelect:()=>navigator.clipboard.writeText(e)}),fn(ee,ge)},children:[o.jsxs("div",{className:"s-thread-center-header-info",children:[o.jsx("span",{className:"s-thread-center-header-name",children:Se}),o.jsxs("div",{className:"s-thread-center-header-eyebrow",children:[o.jsx("span",{className:"s-thread-center-header-kicker",children:$e}),xt&&o.jsx("span",{className:"s-thread-center-header-time",title:Eg(xt),children:De(xt)})]})]}),o.jsxs("div",{className:"s-thread-center-header-right",children:[kt.length>0&&o.jsx("div",{className:"s-thread-center-header-chips",children:kt.map((ee,ge)=>o.jsx("span",{className:"s-thread-center-chip",title:ee.title,children:ee.label},`${ee.label}-${ge}`))}),Mi.length>0&&o.jsxs("div",{className:"s-thread-center-avatars",children:[Mi.map(ee=>o.jsx("div",{className:"s-ops-avatar",style:{"--size":"22px",background:mt(ee.name)},title:ee.name,children:ee.name[0]?.toUpperCase()??"?"},ee.id)),o.jsx("span",{className:"s-thread-center-participant-count",children:un})]})]})]}),Xt&&o.jsxs("div",{className:"s-thread-pinned-ask",children:[o.jsx("div",{className:"s-thread-pinned-ask-label",children:"Pinned ask · Awaiting operator"}),o.jsx("div",{className:"s-thread-pinned-ask-body",children:Xt.task}),o.jsxs("div",{className:"s-thread-pinned-ask-routing",children:[o.jsx("span",{children:Xt.agentName??Ra(Xt.agentId)??Xt.agentId}),o.jsx("span",{className:"s-thread-pinned-ask-routing-arrow",children:"→"}),o.jsx("span",{children:"You"})]}),o.jsxs("div",{className:"s-thread-pinned-ask-actions",children:[o.jsx("button",{type:"button",className:"s-ops-btn s-ops-btn--primary",onClick:()=>{E.current?.focus()},children:"Answer"}),o.jsx("button",{type:"button",className:"s-ops-btn",children:"Defer"}),o.jsx("button",{type:"button",className:"s-ops-btn",children:"Route"})]}),o.jsx("div",{className:"s-thread-pinned-ask-strip"})]}),ke.showStrip&&o.jsxs("div",{className:`s-thread-status s-thread-status--${ke.tone}`,"aria-live":"polite",children:[o.jsx("span",{className:"s-thread-status-dot",style:{background:xW(ke,V?.state??null)}}),o.jsxs("div",{className:"s-thread-status-copy",children:[o.jsx("span",{className:"s-thread-status-label",children:ke.label}),o.jsx("span",{className:"s-thread-status-detail",children:ke.detail})]})]}),!a&&z&&V&&(V.harnessSessionId||V.harnessLogPath||$?.activeSessionId)&&o.jsxs("details",{className:"s-thread-meta-disclosure",children:[o.jsx("summary",{className:"s-thread-meta-toggle",children:"Session details"}),o.jsxs("div",{className:"s-thread-meta-block",children:[$?.activeSessionId&&o.jsxs("div",{className:"s-thread-meta-row",children:[o.jsx("span",{className:"s-thread-meta-row-label",children:"Session ID"}),o.jsx("span",{className:"s-thread-meta-row-value s-thread-meta-row-value--accent",title:$.activeSessionId,children:$.activeSessionId.slice(0,8)})]}),$?.resumeCommand&&o.jsxs("div",{className:"s-thread-meta-row",children:[o.jsx("span",{className:"s-thread-meta-row-label",children:"Takeover"}),o.jsx("span",{className:"s-thread-meta-row-value",children:o.jsx("button",{type:"button",className:"s-thread-meta-takeover-btn",title:$.resumeCommand,onClick:()=>{oW($.resumeCommand).then(()=>s({view:"terminal",agentId:_??void 0})),X(!0)},children:F?"Going…":`Takeover — ${$.resumeCommand}`})})]}),V.harnessSessionId&&o.jsxs("div",{className:"s-thread-meta-row",children:[o.jsx("span",{className:"s-thread-meta-row-label",children:"Harness Session"}),o.jsx("span",{className:"s-thread-meta-row-value",children:V.harnessSessionId})]}),V.harnessLogPath&&o.jsxs("div",{className:"s-thread-meta-row",children:[o.jsx("span",{className:"s-thread-meta-row-label",children:"Harness Log"}),o.jsx("span",{className:"s-thread-meta-row-value",children:V.harnessLogPath})]})]})]}),j&&o.jsx("p",{className:"s-thread-error",children:j}),o.jsxs("div",{className:"s-thread-feed",children:[o.jsx("div",{className:"s-thread-feed-spacer"}),p.length===0?o.jsxs("div",{className:"s-thread-empty",children:[o.jsx("p",{children:"No messages yet"}),o.jsx("p",{children:z?"Use Tell for quick coordination or Ask for owned work with a reply.":"Start the thread below."})]}):p.map((ee,ge)=>{const be=Hv(ee,Q),qe=gW(ee),Ze=qe?"scout.dispatch":ee.class,dt=pW(Ze),Vt=Ze==="status",Et=ge===0||!hW(p[ge-1]?.createdAt,ee.createdAt),mn=Eg(ee.createdAt),xn=!be&&ee.actorName?l.find(Ft=>Ft.name===ee.actorName)??null:null,Ws=be?Q.toLowerCase():xn?.handle??null;return o.jsxs("div",{className:["s-thread-feed-block",be&&"s-thread-feed-block--you",Et&&"s-thread-feed-block--full-width"].filter(Boolean).join(" "),children:[Et&&o.jsxs("div",{className:"s-thread-day-divider","aria-label":BN(ee.createdAt),children:[o.jsx("span",{className:"s-thread-day-line","aria-hidden":"true"}),o.jsx("span",{className:"s-thread-day-label",children:BN(ee.createdAt)}),o.jsx("span",{className:"s-thread-day-line","aria-hidden":"true"})]}),o.jsx("article",{id:`msg-${ee.id}`,className:["s-thread-msg",be&&"s-thread-msg--you",Vt&&"s-thread-msg--tool"].filter(Boolean).join(" "),"data-class":Ze,onContextMenu:Ft=>qs(Ft,ee),children:o.jsxs("div",{className:"s-thread-msg-card s-thread-msg-card--avatar-row",children:[o.jsx("div",{className:"s-ops-avatar s-thread-msg-avatar",style:{"--size":"28px",background:mt(be?Q:ee.actorName??"?")},children:(be?Q[0]:ee.actorName?.[0]??"?").toUpperCase()}),o.jsxs("div",{className:"s-thread-msg-card-content",children:[o.jsxs("div",{className:"s-thread-msg-header",children:[o.jsxs("div",{className:"s-thread-msg-meta",children:[o.jsx("span",{className:"s-thread-msg-actor",children:be?Q:ee.actorName}),Ws&&o.jsxs("span",{className:"s-thread-msg-handle",children:["@",Ws]}),dt&&o.jsx("span",{className:"s-thread-msg-kind",children:dt})]}),o.jsx("span",{className:"s-thread-msg-time",title:mn,children:De(ee.createdAt)}),o.jsx("button",{type:"button",className:"s-thread-msg-permalink","aria-label":"Copy link to message",title:"Copy link to message",onClick:()=>{const Ft=`${window.location.origin}${window.location.pathname}#msg-${ee.id}`;navigator.clipboard.writeText(Ft)},children:o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("path",{d:"M6.5 9.5a2.5 2.5 0 0 0 3.54 0l2.12-2.12a2.5 2.5 0 0 0-3.54-3.54l-.7.7"}),o.jsx("path",{d:"M9.5 6.5a2.5 2.5 0 0 0-3.54 0L3.84 8.62a2.5 2.5 0 0 0 3.54 3.54l.7-.7"})]})})]}),o.jsx("div",{className:"s-thread-msg-body",title:mn,children:o.jsx(qR,{text:ee.body})}),qe&&qe.candidates.length>0&&o.jsx("div",{className:"s-thread-dispatch",children:qe.candidates.map(Ft=>o.jsxs("button",{type:"button",className:"s-thread-dispatch-tile",onClick:()=>{Zs(qe,Ft)},children:[o.jsxs("span",{className:"s-thread-dispatch-tile-id",children:["@",Ft.agentId]}),o.jsx("span",{className:"s-thread-dispatch-tile-state",children:Ft.endpointState}),o.jsx("span",{className:"s-thread-dispatch-tile-meta",children:[Ft.workspace,Ft.node,Ft.projectRoot].filter(Boolean).join(" · ")||Ft.displayName})]},Ft.agentId))})]})]})})]},ee.id)}),ke.showTyping&&o.jsx("div",{className:"s-thread-feed-block",children:o.jsx("div",{className:"s-thread-msg","aria-live":"polite",children:o.jsxs("div",{className:"s-thread-msg-card s-thread-msg-working-card s-thread-msg-card--avatar-row",children:[o.jsx("div",{className:"s-ops-avatar s-thread-msg-avatar",style:{"--size":"28px",background:mt(Ne)},children:Ne[0]?.toUpperCase()??"?"}),o.jsxs("div",{className:"s-thread-msg-card-content",children:[o.jsxs("div",{className:"s-thread-msg-header",children:[o.jsxs("div",{className:"s-thread-msg-meta",children:[o.jsx("span",{className:"s-thread-msg-actor",children:Ne}),o.jsx("span",{className:"s-thread-msg-kind",children:"Live"})]}),o.jsx("span",{className:"s-thread-msg-time",title:m?.startedAt?Eg(m.startedAt):"now",children:m?.startedAt?De(m.startedAt):"now"})]}),o.jsxs("div",{className:"s-thread-msg-working-body",children:[o.jsxs("span",{className:"s-thread-typing-indicator","aria-hidden":"true",children:[o.jsx("span",{className:"s-thread-typing-dot"}),o.jsx("span",{className:"s-thread-typing-dot"}),o.jsx("span",{className:"s-thread-typing-dot"})]}),o.jsx("span",{className:"s-thread-msg-working-copy",children:ke.detail})]})]})]})})}),o.jsx("div",{ref:k})]}),ke.showTyping&&o.jsxs("div",{className:"s-thread-presence-line",children:[o.jsx("div",{className:"s-thread-presence-line-avatars",children:o.jsx("div",{className:"s-ops-avatar",style:{"--size":"20px",background:mt(Ne)},children:Ne[0]?.toUpperCase()??"?"})}),o.jsxs("span",{className:"s-thread-presence-line-label",children:[Ne," is ",ke.label.toLowerCase(),"..."]}),o.jsx("div",{className:"s-thread-presence-strip"})]}),o.jsx("form",{className:"s-thread-compose",onSubmit:ee=>{ee.preventDefault(),gt()},children:o.jsxs("div",{className:"s-thread-compose-shell",children:[re.open&&Ae.length>0&&o.jsxs("div",{className:"s-thread-compose-suggest",role:"listbox","aria-label":"Slash commands",children:[o.jsx("div",{className:"s-thread-compose-suggest-label",children:"Slash commands"}),Ae.map((ee,ge)=>o.jsxs("button",{type:"button",role:"option","aria-selected":ge===re.index,className:["s-thread-compose-suggest-item",ge===re.index&&"s-thread-compose-suggest-item--active"].filter(Boolean).join(" "),onMouseDown:be=>{be.preventDefault(),Ve(ee)},onMouseEnter:()=>ie(be=>({...be,index:ge})),children:[o.jsx("span",{className:"s-thread-compose-suggest-cmd",children:ee.label}),o.jsx("span",{className:"s-thread-compose-suggest-desc",children:ee.description})]},ee.command))]}),de.open&&je.length>0&&o.jsxs("div",{className:"s-thread-compose-suggest",role:"listbox","aria-label":"Mention agents",children:[o.jsx("div",{className:"s-thread-compose-suggest-label",children:"Mention agent"}),je.map((ee,ge)=>o.jsxs("button",{type:"button",role:"option","aria-selected":ge===de.index,className:["s-thread-compose-suggest-item",ge===de.index&&"s-thread-compose-suggest-item--active"].filter(Boolean).join(" "),onMouseDown:be=>{be.preventDefault(),Be(ee)},onMouseEnter:()=>ye(be=>({...be,index:ge})),children:[o.jsx("span",{className:"s-ops-avatar s-thread-compose-suggest-avatar",style:{"--size":"20px",background:mt(ee.name)},children:ee.name[0]?.toUpperCase()??"?"}),o.jsxs("span",{className:"s-thread-compose-suggest-cmd",children:["@",ee.handle]}),o.jsx("span",{className:"s-thread-compose-suggest-desc",children:ee.name})]},ee.id))]}),o.jsxs("div",{className:"s-thread-compose-row",children:[o.jsx("textarea",{ref:E,className:"s-thread-compose-input",placeholder:Mn,value:G,onChange:ee=>{const ge=ee.target.value;I(ge),Ue(ge,ee.target.selectionStart)},onSelect:ee=>{const ge=ee.currentTarget;Ue(ge.value,ge.selectionStart)},onBlur:()=>{setTimeout(Ee,120)},onKeyDown:ee=>{if(re.open&&Ae.length>0||de.open&&je.length>0){if(ee.key==="ArrowDown"){ee.preventDefault(),re.open?ie(be=>({...be,index:(be.index+1)%Ae.length})):de.open&&ye(be=>({...be,index:(be.index+1)%je.length}));return}if(ee.key==="ArrowUp"){ee.preventDefault(),re.open?ie(be=>({...be,index:(be.index-1+Ae.length)%Ae.length})):de.open&&ye(be=>({...be,index:(be.index-1+je.length)%je.length}));return}if(ee.key==="Escape"){ee.preventDefault(),Ee();return}if(ee.key==="Enter"||ee.key==="Tab"){if(ee.shiftKey)return;if(ee.preventDefault(),re.open){const be=Ae[re.index]??Ae[0];be&&Ve(be)}else if(de.open){const be=je[de.index]??je[0];be&&Be(be)}return}}ee.key!=="Enter"||ee.shiftKey||ee.nativeEvent.isComposing||(ee.preventDefault(),!B&&G.trim()&>())},rows:1}),dn?o.jsx("button",{type:"button",className:"s-thread-compose-send s-thread-compose-send--stop",onClick:()=>{Bt()},"aria-label":"Stop agent",children:o.jsx(jW,{})}):o.jsx("button",{type:"submit",className:"s-thread-compose-send",disabled:B||!G.trim(),"aria-label":Wt==="ask"?"Ask agent":Wt==="steer"?"Steer agent":z?"Tell agent":"Send message",children:o.jsx(wW,{})})]})]})})]})})}async function NW(e){await fetch(nu("terminalRunPath"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:e})})}const YR={think:"var(--dim)",tool:"var(--accent)",ask:"var(--amber)",message:"var(--muted)",note:"var(--green)",system:"var(--dim)",boot:"var(--dim)"},kW={read:"◎",edit:"✎",bash:"$",grep:"⌕",write:"✎",think:"∿"},EW=20,GR=new Intl.NumberFormat("en-US"),CW=new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1});function TW(e){const t=Math.floor(e/60),n=Math.floor(e%60);return`${String(t).padStart(2,"0")}:${String(n).padStart(2,"0")}`}function FN(e,t){return e>=Math.max(0,t-EW)}function sc(e){return typeof e!="number"||!Number.isFinite(e)?null:GR.format(e)}function ua(e){return typeof e!="number"||!Number.isFinite(e)?"—":Math.abs(e)<1e3?GR.format(e):CW.format(e).toLowerCase()}function AW(e){if(!Number.isFinite(e)||e<=0)return"0s";if(e<60)return`${Math.round(e)}s`;const t=Math.round(e),n=Math.floor(t/3600),s=Math.floor(t%3600/60),a=t%60;return n>0?`${n}h ${s}m`:s>=10||a===0?`${s}m`:`${s}m ${a}s`}function HN(e){return!!e&&Object.keys(e).length>0}function Cg(e){return e.filter(t=>!!t)}function RW({event:e}){return o.jsxs("div",{children:[o.jsx("div",{className:"s-observe-think-label",children:"thinking"}),o.jsxs("div",{className:"s-observe-think-text",children:["“",e.text,"”",e.live&&o.jsx("span",{className:"s-observe-cursor"})]})]})}function MW({event:e}){const t=kW[e.tool??""]??"▸",n=!!(e.result||e.diff||e.stream);return o.jsxs("div",{className:"s-observe-tool",children:[o.jsxs("div",{className:`s-observe-tool-header${n?" s-observe-tool-header--has-body":""}`,children:[o.jsx("span",{className:"s-observe-tool-glyph",children:t}),o.jsxs("span",{className:"s-observe-tool-cmd",children:[o.jsx("span",{className:"s-observe-tool-cmd-name",children:e.tool})," ",e.arg]})]}),e.result&&o.jsx("div",{className:"s-observe-tool-result",children:Object.entries(e.result).map(([s,a])=>`${s}: ${a}`).join(" · ")}),e.diff&&o.jsxs("div",{className:"s-observe-tool-diff",children:[o.jsxs("div",{className:"s-observe-tool-diff-stats",children:[o.jsxs("span",{className:"s-observe-tool-diff-add",children:["+",e.diff.add]}),e.diff.del>0&&o.jsxs(o.Fragment,{children:[" ",o.jsxs("span",{className:"s-observe-tool-diff-del",children:["−",e.diff.del]})]})]}),o.jsx("pre",{className:"s-observe-tool-diff-preview",children:e.diff.preview})]}),e.stream&&o.jsx("pre",{className:"s-observe-tool-stream",children:e.stream.join(`
|
|
154
|
-
`)})]})}function _W({event:e}){const t=e.to==="human"?"you":e.to??"?";return o.jsxs("div",{className:"s-observe-ask",children:[o.jsxs("div",{className:"s-observe-ask-label",children:["↗ ask → ",t]}),o.jsxs("div",{className:"s-observe-ask-text",children:["“",e.text,"”"]}),e.answer&&o.jsxs("div",{className:"s-observe-ask-answer",children:[o.jsxs("span",{className:"s-observe-ask-answer-meta",children:["↳ @",e.to??"you"," · +",(e.answerT??e.t)-e.t,"s"]}),o.jsx("div",{className:"s-observe-ask-answer-text",children:e.answer})]})]})}function OW({event:e}){const t=e.to==="human"?"you":e.to??"?";return o.jsxs("div",{children:[o.jsxs("div",{className:"s-observe-message-label",children:["→ message → ",t]}),o.jsx("div",{className:"s-observe-message-text",children:o.jsx(qR,{text:e.text})})]})}function IW({event:e}){return o.jsxs("div",{className:"s-observe-note",children:[o.jsx("span",{className:"s-observe-note-icon",children:"✓"}),o.jsx("span",{className:"s-observe-note-text",children:e.text})]})}function DW({event:e}){return o.jsxs("div",{className:"s-observe-system",children:[o.jsx("span",{className:"s-observe-system-arrow",children:"▸ "}),e.text,e.detail&&o.jsx("div",{className:"s-observe-system-detail",children:e.detail})]})}function PW(){return o.jsxs("div",{className:"s-observe-live",children:[o.jsx("span",{className:"s-observe-live-dot"}),o.jsx("span",{className:"s-observe-live-label",children:"LIVE · tailing session"})]})}function zW({liveSession:e,isLive:t}){const n=e?t?"live":"paused":"replay",s=e?t?"LIVE · tail mode on":"LIVE · tail paused":"REPLAY · saved trace";return o.jsxs("div",{className:`s-observe-tail-state s-observe-tail-state--${n}`,children:[o.jsx("span",{className:"s-observe-tail-state-dot"}),o.jsx("span",{className:"s-observe-tail-state-label",children:s})]})}function LW({event:e,prevT:t}){const n=e.t-t,s=YR[e.kind]??"var(--dim)";return o.jsxs("div",{className:"s-observe-row",children:[n>15&&o.jsxs("div",{className:"s-observe-row-gap",children:["+",n,"s"]}),o.jsx("div",{className:"s-observe-row-time",children:TW(e.t)}),o.jsx("span",{className:"s-observe-row-bead",style:{background:s}}),e.kind==="think"&&o.jsx(RW,{event:e}),e.kind==="tool"&&o.jsx(MW,{event:e}),e.kind==="ask"&&o.jsx(_W,{event:e}),e.kind==="message"&&o.jsx(OW,{event:e}),e.kind==="note"&&o.jsx(IW,{event:e}),(e.kind==="system"||e.kind==="boot")&&o.jsx(DW,{event:e})]})}function $W({events:e,isLive:t}){const n=g.useRef(null);return g.useEffect(()=>{t&&n.current?.scrollIntoView({behavior:"smooth"})},[e.length,t]),o.jsxs("div",{className:"s-observe-stream",children:[o.jsx("div",{className:"s-observe-spine"}),e.map((s,a)=>o.jsx(LW,{event:s,prevT:a>0?e[a-1].t:0},s.id)),o.jsx("div",{ref:n})]})}function UW({data:e,cursor:t}){const a=e.length;if(a<2)return null;const l=276/(a-1),u=e.map((p,h)=>`${h===0?"M":"L"} ${(h*l).toFixed(1)} ${((1-p)*44).toFixed(1)}`).join(" "),d=t*276;return o.jsxs("svg",{viewBox:"0 0 276 44",style:{width:"100%",height:44,display:"block"},children:[o.jsx("defs",{children:o.jsxs("linearGradient",{id:"observeCtxFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[o.jsx("stop",{offset:"0%",stopColor:"var(--accent)",stopOpacity:.25}),o.jsx("stop",{offset:"100%",stopColor:"var(--accent)",stopOpacity:0})]})}),o.jsx("path",{d:`${u} L 276 44 L 0 44 Z`,fill:"url(#observeCtxFill)"}),o.jsx("path",{d:u,fill:"none",stroke:"var(--accent)",strokeWidth:1.2}),o.jsx("line",{x1:d,y1:0,x2:d,y2:44,stroke:"var(--accent)",strokeWidth:1,opacity:.6,strokeDasharray:"2 3"})]})}function BW({state:e}){const t=e==="created"?"var(--green)":e==="modified"?"var(--accent)":"var(--dim)",n=e==="created"?"+":e==="modified"?"~":"◎";return o.jsx("span",{className:"s-observe-file-glyph",style:{background:"color-mix(in srgb, var(--bg) 70%, black)",border:`1px solid color-mix(in srgb, ${t} 40%, var(--border))`,color:t},children:n})}function Mr({label:e,value:t,detail:n}){return o.jsxs("div",{className:"s-observe-stat",children:[o.jsx("div",{className:"s-observe-stat-label",children:e}),o.jsx("div",{className:"s-observe-stat-value",children:t}),n&&o.jsx("div",{className:"s-observe-stat-detail",children:n})]})}function Tg({rows:e}){return e.length===0?null:o.jsx("div",{className:"s-observe-detail-list",children:e.map(t=>o.jsxs("div",{className:"s-observe-detail-row",children:[o.jsx("div",{className:"s-observe-detail-label",children:t.label}),o.jsx("div",{className:`s-observe-detail-value s-observe-detail-value--${t.tone??"default"}${t.wrap?" s-observe-detail-value--wrap":""}`,title:t.title,children:t.value})]},t.label))})}function VW({events:e,duration:t,cursor:n,onCursor:s}){const a=g.useRef(null),l=g.useCallback(u=>{const d=a.current.getBoundingClientRect(),p=u.clientX-d.left;s(Math.max(0,Math.min(t,p/d.width*t)))},[t,s]);return o.jsx("div",{className:"s-observe-track-wrap",children:o.jsxs("div",{ref:a,className:"s-observe-track",onClick:l,children:[e.map(u=>{const d=u.kind==="tool"?6:u.kind==="think"?4:5;return o.jsx("span",{className:"s-observe-track-tick",style:{left:`${u.t/t*100}%`,top:d===6?-2:-1,height:d,background:YR[u.kind]??"var(--dim)"}},u.id)}),o.jsx("div",{className:"s-observe-track-played",style:{width:`${n/t*100}%`}}),o.jsx("span",{className:"s-observe-track-cursor",style:{left:`${n/t*100}%`}})]})})}function qN(e){const t=Date.now()-e;return t<6e4?"just now":t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}function FW(e,t){const n=t-e;return n<6e4?`${Math.floor(n/1e3)}s`:n<36e5?`${Math.floor(n/6e4)}m`:`${Math.floor(n/36e5)}h ${Math.floor(n%36e5/6e4)}m`}function HW({catalog:e,sessionId:t,agentId:n}){const{navigate:s}=Nt(),[a,l]=g.useState(!1),u=e.sessions.find(y=>y.id===e.activeSessionId),d=e.sessions.filter(y=>y.id!==e.activeSessionId&&y.endedAt).sort((y,x)=>(x.endedAt??0)-(y.endedAt??0)).slice(0,5),p=e.activeSessionId??t,h=p?p.slice(0,8):null,m=g.useCallback(()=>{e.resumeCommand&&(NW(e.resumeCommand).then(()=>{s({view:"terminal",agentId:n})}),l(!0))},[e.resumeCommand,s,n]);return o.jsxs("div",{className:"s-observe-session-header",children:[o.jsx("div",{className:"s-observe-session-active",children:o.jsxs("div",{className:"s-observe-session-row",children:[h&&o.jsx("span",{className:"s-observe-session-id",title:p??void 0,children:h}),u&&o.jsxs("span",{className:"s-observe-session-time",children:["started ",qN(u.startedAt)]}),e.resumeCommand&&o.jsx("button",{className:"s-observe-takeover-btn",onClick:m,title:e.resumeCommand,children:a?"Sent":"Takeover"})]})}),d.length>0&&o.jsxs("div",{className:"s-observe-session-history",children:[o.jsxs("div",{className:"s-observe-session-history-label",children:[e.sessions.length," session",e.sessions.length!==1?"s":""," total"]}),d.map(y=>o.jsxs("div",{className:"s-observe-session-past",children:[o.jsx("span",{className:"s-observe-session-id",children:y.id.slice(0,8)}),o.jsxs("span",{className:"s-observe-session-time",children:[qN(y.startedAt),y.endedAt?` · ${FW(y.startedAt,y.endedAt)}`:""]})]},y.id))]})]})}const qW={events:[{id:"observe:empty",t:0,kind:"system",text:"No session trace is available for this agent yet.",detail:"Waiting for a live session or readable history file."}],files:[],contextUsage:[],live:!1};function KR({data:e,agentId:t,sessionId:n}){const s=e??qW,{events:a,files:l,contextUsage:u}=s,d=s.live===!0,[p,h]=g.useState(null);g.useEffect(()=>{if(!t)return;let I=!1;return Re(`/api/agents/${encodeURIComponent(t)}/session-catalog`).then(B=>{I||h(B)}).catch(()=>{}),()=>{I=!0}},[t]);const m=a.length>0?a[a.length-1].t+30:60,[y,x]=g.useState(m),[w,j]=g.useState(!1),[N,k]=g.useState(1),E=g.useRef(m);g.useEffect(()=>{x(I=>{const B=E.current;E.current=m;const Y=FN(I,B);return I>m||Y?m:I})},[m]),g.useEffect(()=>{if(!w)return;const I=setInterval(()=>{x(B=>{const Y=B+N;return Y>=m?(j(!1),m):Y})},100);return()=>clearInterval(I)},[w,m,N]);const C=a.filter(I=>I.t<=y),S=d&&FN(y,m),R=d?S?"Following live":"Jump to live ↦":"Jump to end ↦",A=s.metadata,M=A?.session,_=A?.usage,z=a.filter(I=>I.kind==="tool").length,V=a.filter(I=>I.kind==="think").length,U=a.filter(I=>I.kind==="ask").length,O=a.filter(I=>I.kind==="tool"&&I.tool==="read").length,D=a.filter(I=>I.kind==="tool"&&(I.tool==="edit"||I.tool==="write")).length,H=a.length>0?a[a.length-1].t:0,W=u&&u.length>0?Math.round((u[u.length-1]??0)*100):null,q=[{label:"Input",value:_?.inputTokens},{label:"Output",value:_?.outputTokens},{label:"Cache hit",value:_?.cacheReadInputTokens},{label:"Cache write",value:_?.cacheCreationInputTokens},{label:"Total",value:_?.totalTokens},{label:"Reasoning",value:_?.reasoningOutputTokens}].filter(I=>typeof I.value=="number"),$=Cg([typeof _?.assistantMessages=="number"?{label:"Assistant msgs",value:sc(_.assistantMessages)??"0",tone:"accent"}:null,typeof _?.webSearchRequests=="number"?{label:"Web search",value:sc(_.webSearchRequests)??"0"}:null,typeof _?.webFetchRequests=="number"?{label:"Web fetch",value:sc(_.webFetchRequests)??"0"}:null,_?.serviceTier?{label:"Service tier",value:_.serviceTier,tone:"good"}:null,_?.speed?{label:"Speed",value:_.speed}:null,_?.planType?{label:"Plan",value:_.planType}:null]),L=Cg([typeof _?.contextWindowTokens=="number"?{label:"Model window",value:`${sc(_.contextWindowTokens)} tokens`,title:sc(_.contextWindowTokens)??void 0,tone:"accent"}:null,W!==null?{label:"Derived load",value:`${W}%`,tone:W>=80?"warn":"default"}:null]),F=Cg([M?.model?{label:"Model",value:M.model,tone:"accent"}:null,M?.adapterType?{label:"Adapter",value:M.adapterType}:null,M?.gitBranch?{label:"Branch",value:M.gitBranch}:null,M?.cwd?{label:"Workspace",value:M.cwd,title:M.cwd,wrap:!0}:null,M?.entrypoint?{label:"Entrypoint",value:M.entrypoint}:null,M?.cliVersion?{label:"CLI",value:M.cliVersion}:null,M?.permissionMode?{label:"Permissions",value:M.permissionMode}:null,M?.approvalPolicy?{label:"Approval",value:M.approvalPolicy}:null,M?.sandbox?{label:"Sandbox",value:M.sandbox}:null,M?.userType?{label:"User type",value:M.userType}:null,M?.originator?{label:"Originator",value:M.originator}:null,M?.modelProvider?{label:"Provider",value:M.modelProvider}:null,M?.effort?{label:"Effort",value:M.effort}:null,M?.timezone?{label:"Timezone",value:M.timezone}:null,M?.externalSessionId?{label:"External session",value:M.externalSessionId,title:M.externalSessionId,wrap:!0}:null,M?.threadId?{label:"Thread",value:M.threadId,title:M.threadId,wrap:!0}:null,M?.threadPath?{label:"Thread path",value:M.threadPath,title:M.threadPath,wrap:!0}:null,M?.source?{label:"Runtime source",value:M.source}:null]),X=HN(_),G=HN(M);return o.jsxs("div",{className:"s-observe",children:[o.jsxs("main",{className:"s-observe-main",children:[S&&o.jsx("div",{className:"s-observe-live-sticky",children:o.jsx(PW,{})}),o.jsx($W,{events:C,isLive:S})]}),o.jsxs("aside",{className:"s-observe-rail",children:[p&&p.sessions.length>0&&o.jsxs("div",{children:[o.jsx("div",{className:"s-observe-rail-label",children:"Session"}),o.jsx(HW,{catalog:p,sessionId:n??null,agentId:t})]}),o.jsxs("div",{children:[o.jsx("div",{className:"s-observe-rail-label",children:"Trace stats"}),o.jsxs("div",{className:"s-observe-stats",children:[o.jsx(Mr,{label:"Turns",value:ua(M?.turnCount??0)}),o.jsx(Mr,{label:"Tools",value:ua(z)}),o.jsx(Mr,{label:"Thinks",value:ua(V)}),o.jsx(Mr,{label:"Asks",value:ua(U)}),o.jsx(Mr,{label:"Reads",value:ua(O)}),o.jsx(Mr,{label:"Edits",value:ua(D)}),o.jsx(Mr,{label:"Files",value:ua(l.length)}),o.jsx(Mr,{label:"Window",value:AW(H)})]})]}),o.jsxs("div",{children:[o.jsx("div",{className:"s-observe-rail-label",children:"Context window"}),o.jsx(Tg,{rows:L}),u&&u.length>=2?o.jsxs(o.Fragment,{children:[o.jsx(UW,{data:u,cursor:y/m}),o.jsx("div",{className:"s-observe-ctx-detail",children:"Sparkline shows derived session load across the observed trace."})]}):L.length===0?o.jsx("div",{className:"s-observe-ctx-detail",children:"Unavailable for this session"}):o.jsx("div",{className:"s-observe-ctx-detail",children:"Exact window metadata is available, but no derived load trace was captured."})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"s-observe-rail-label",children:["Files touched · ",l.length]}),o.jsx("div",{className:"s-observe-files",children:l.map(I=>o.jsxs("div",{className:`s-observe-file${I.lastT<=y?" s-observe-file--visible":" s-observe-file--hidden"}`,children:[o.jsx(BW,{state:I.state}),o.jsx("span",{className:"s-observe-file-path",children:I.path}),o.jsxs("span",{className:"s-observe-file-touches",children:["×",I.touches]})]},I.path))})]}),o.jsxs("div",{children:[o.jsx("div",{className:"s-observe-rail-label",children:"Usage"}),q.length>0&&o.jsx("div",{className:"s-observe-stats s-observe-stats--usage",children:q.map(I=>o.jsx(Mr,{label:I.label,value:ua(I.value)},I.label))}),$.length>0?o.jsx(Tg,{rows:$}):X?null:o.jsx("div",{className:"s-observe-ctx-detail",children:"Unavailable for this session"})]}),o.jsxs("div",{children:[o.jsx("div",{className:"s-observe-rail-label",children:"Metadata"}),F.length>0?o.jsx(Tg,{rows:F}):G?null:o.jsx("div",{className:"s-observe-ctx-detail",children:"Unavailable for this session"})]})]}),o.jsxs("footer",{className:"s-observe-scrubber",children:[o.jsx("button",{className:"s-observe-play-btn",onClick:()=>j(!w),children:w?"❚❚":"▶"}),o.jsx("button",{className:"s-observe-rewind-btn",onClick:()=>{x(0),j(!1)},children:"⏮"}),o.jsx(VW,{events:a,duration:m,cursor:y,onCursor:x}),o.jsx("div",{className:"s-observe-speed-group",children:[.5,1,2,4].map(I=>o.jsxs("button",{className:`s-observe-speed-btn${N===I?" s-observe-speed-btn--active":""}`,onClick:()=>k(I),children:[I,"×"]},I))}),o.jsx(zW,{liveSession:d,isLive:S}),o.jsx("button",{className:`s-observe-jump-btn${S?" s-observe-jump-btn--active":""}`,onClick:()=>x(m),children:R})]})]})}async function ZW(e){await fetch(nu("terminalRunPath"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:e})})}function WW(e,t){if(t.filter(a=>a.name===e.name).length<=1)return{name:e.name,qualifier:null};const s=e.project??e.branch??e.id.replace(/^.*\./,"");return{name:e.name,qualifier:s}}function Bc(e){if(!e)return null;const t=e.replace(/_/g," ");return t.toLowerCase()==="relay agent"?"agent":t}function YW(e){const t=[...e].filter(a=>a.kind==="direct"&&!!a.agentId).sort((a,l)=>(l.lastMessageAt??0)-(a.lastMessageAt??0)),n=new Map,s=new Map;for(const a of t)n.has(a.agentId)||(n.set(a.agentId,a.id),s.set(a.agentId,a));return{conversationByAgentId:n,sessionByAgentId:s}}function GW({catalog:e,agentId:t}){const{navigate:n}=Nt(),[s,a]=g.useState(!1),l=e.activeSessionId?.slice(0,8)??null,u=e.sessions.find(p=>p.id===e.activeSessionId),d=()=>{e.resumeCommand&&(ZW(e.resumeCommand).then(()=>n({view:"terminal",agentId:t})),a(!0))};return o.jsxs("div",{className:"s-profile-facet",children:[o.jsx("div",{className:"s-profile-facet-label",children:"Session"}),o.jsxs("div",{className:"s-profile-facet-value s-profile-facet-value--mono",title:e.activeSessionId??void 0,children:[l,e.resumeCommand&&o.jsx("button",{type:"button",className:"s-profile-facet-action",onClick:d,title:e.resumeCommand,children:s?"Going…":"Takeover"})]}),u&&o.jsxs("div",{className:"s-profile-facet-detail",children:[e.sessions.length," session",e.sessions.length!==1?"s":""," · started ",De(u.startedAt)]})]})}function KW({agent:e,fleet:t,navigate:n}){const s=g.useMemo(()=>t?t.activity.filter(l=>l.agentId===e.id||l.actorId===e.id).slice(0,6):[],[t,e.id]),a=g.useMemo(()=>t?t.recentCompleted.filter(l=>l.agentId===e.id).slice(0,4):[],[t,e.id]);return s.length===0&&a.length===0?o.jsxs("div",{className:"s-profile-activity-empty",children:[o.jsx("div",{className:"s-profile-activity-empty-title",children:"Quiet for now"}),o.jsx("div",{className:"s-profile-activity-empty-detail",children:"Activity will appear here as this agent works, receives asks, and completes tasks."})]}):o.jsxs("div",{className:"s-profile-activity-feed",children:[a.map(l=>o.jsxs("div",{className:"s-profile-activity-row",onClick:()=>{l.conversationId&&n({view:"agents",agentId:e.id,conversationId:l.conversationId})},children:[o.jsx("div",{className:"s-profile-activity-dot s-profile-activity-dot--done"}),o.jsxs("div",{className:"s-profile-activity-body",children:[o.jsx("div",{className:"s-profile-activity-title",children:l.summary??l.task}),o.jsxs("div",{className:"s-profile-activity-meta",children:[l.status==="completed"?"completed":l.status,l.completedAt&&` · ${De(l.completedAt)}`]})]})]},l.invocationId)),s.map(l=>o.jsxs("div",{className:"s-profile-activity-row",onClick:()=>{l.conversationId&&n({view:"agents",agentId:e.id,conversationId:l.conversationId})},children:[o.jsx("div",{className:"s-profile-activity-dot"}),o.jsxs("div",{className:"s-profile-activity-body",children:[o.jsx("div",{className:"s-profile-activity-title",children:l.title??l.summary??l.kind}),o.jsxs("div",{className:"s-profile-activity-meta",children:[l.kind.replace(/_/g," "),l.actorName&&` · ${l.actorName}`,` · ${De(l.ts)}`]})]})]},l.id))]})}function hc({label:e,right:t,rightClassName:n}){return o.jsxs("div",{className:"s-profile-section-rule",children:[o.jsx("span",{className:"s-profile-section-rule-label",children:e}),o.jsx("span",{className:"s-profile-section-rule-line"}),t&&o.jsx("span",{className:`s-profile-section-rule-right${n?` ${n}`:""}`,children:t})]})}function XW({messages:e,navigate:t,conversationId:n,agentId:s}){const a=e.slice(-8).reverse();return a.length===0?null:o.jsxs("div",{className:"s-profile-signals",children:[o.jsx(hc,{label:"Recent signal",right:"last 1h"}),o.jsx("div",{className:"s-profile-signal-list",children:a.map(l=>{const d=l.class==="ask"||l.body?.toLowerCase().startsWith("@")?"ASK":"MESSAGE";return o.jsxs("div",{className:"s-profile-signal",onClick:()=>{n&&t({view:"agents",agentId:s,conversationId:n})},children:[o.jsx("div",{className:"s-profile-signal-avatar",style:{background:mt(l.actorName??"?")},children:(l.actorName??"?")[0].toUpperCase()}),o.jsxs("div",{className:"s-profile-signal-body",children:[o.jsxs("div",{className:"s-profile-signal-header",children:[o.jsx("span",{className:"s-profile-signal-kind",children:d}),o.jsx("span",{className:"s-profile-signal-sep",children:"·"}),o.jsx("span",{className:"s-profile-signal-routing",children:l.actorName}),o.jsx("span",{className:"s-profile-signal-time",children:De(l.createdAt)})]}),o.jsx("div",{className:"s-profile-signal-text",children:l.body})]})]},l.id)})})]})}function JW({agent:e,allAgents:t,session:n,conversationId:s,navigate:a,activeTab:l}){const{name:u,qualifier:d}=WW(e,t),[p,h]=g.useState([]),[m,y]=g.useState([]),[x,w]=g.useState(null),[j,N]=g.useState(null),[k,E]=g.useState(!1),[C,S]=g.useState(null),R=et(e.state),A=bh(),M=g.useCallback(async()=>{const[X,G]=await Promise.allSettled([Re(`/api/work?agentId=${encodeURIComponent(e.id)}`),Re("/api/fleet")]);X.status==="fulfilled"&&h(X.value),G.status==="fulfilled"&&w(G.value)},[e.id]),_=g.useCallback(async()=>{if(!s){y([]);return}try{const X=await Re(`/api/messages?conversationId=${encodeURIComponent(s)}&limit=20`);y(X)}catch{y([])}},[s]),z=g.useCallback(async()=>{E(!0);try{const X=await Re(`/api/agents/${encodeURIComponent(e.id)}/observe`);N(X)}catch{N({agentId:e.id,source:"unavailable",fidelity:"synthetic",historyPath:null,sessionId:null,updatedAt:Date.now(),data:{events:[{id:`${e.id}:observe-error`,t:0,kind:"system",text:"Observer data is temporarily unavailable.",detail:"Retrying will resume once the session source becomes reachable."}],files:[],contextUsage:[],live:!1}})}finally{E(!1)}},[e.id]);g.useEffect(()=>{M(),_(),Re(`/api/agents/${encodeURIComponent(e.id)}/session-catalog`).then(S).catch(()=>{})},[M,_,e.id]),g.useEffect(()=>{N(null),E(!1)},[e.id]),g.useEffect(()=>{l==="observe"&&z()},[l,z]),Rn(()=>{M(),_(),l==="observe"&&z()}),g.useEffect(()=>{if(l!=="observe"||!j?.data.live)return;const X=setInterval(()=>{z()},2500);return()=>clearInterval(X)},[l,j?.data.live,z]);const V=p.find(X=>X.state==="working"||X.state==="review"),U=p.filter(X=>X.state==="working"||X.state==="review"||X.state==="waiting"),O=p.filter(X=>X.state==="done").slice(0,5),D=Bc(e.role)??Bc(e.agentClass),H=e.harness,W=[D,H].filter(Boolean).filter((X,G,I)=>I.indexOf(X)===G),q=g.useMemo(()=>t.filter(X=>X.project===e.project).length,[t,e.project]),$=V?.currentPhase==="review"?85:V?.currentPhase==="working"?50:20,L=[{key:"profile",label:"Profile"},{key:"observe",label:"Observe"},{key:"message",label:"Message",disabled:!s}],F=X=>{a({view:"agents",agentId:e.id,...s?{conversationId:s}:{},tab:X})};return o.jsxs("div",{className:`s-profile-center${l!=="profile"?" s-profile-center--tabbed":""}`,children:[o.jsx("button",{type:"button",className:"s-back s-profile-mobile-back",onClick:()=>a({view:"agents"}),children:"← All agents"}),o.jsx("section",{className:"s-profile-identity",onContextMenu:X=>{const G=window.getSelection()?.toString().trim(),I=[];G&&(I.push({kind:"action",label:"Copy Selection",shortcut:"⌘C",onSelect:()=>navigator.clipboard.writeText(G)}),I.push({kind:"separator"})),I.push({kind:"action",label:"Copy Agent Name",onSelect:()=>navigator.clipboard.writeText(u)}),I.push({kind:"action",label:"Copy Agent ID",onSelect:()=>navigator.clipboard.writeText(e.id)}),e.handle&&I.push({kind:"action",label:`Copy @${e.handle}`,onSelect:()=>navigator.clipboard.writeText(`@${e.handle}`)}),A(X,I)},children:o.jsxs("div",{className:"s-profile-identity-top",children:[o.jsxs("div",{className:"s-profile-identity-avatar-wrap",children:[o.jsx("div",{className:"s-profile-identity-avatar",style:{background:mt(e.name)},children:e.name[0].toUpperCase()}),o.jsx("span",{className:`s-profile-identity-pulse s-profile-identity-pulse--${R}`,style:{background:Ur(e.state)}})]}),o.jsxs("div",{className:"s-profile-identity-copy",children:[W.length>0&&o.jsx("div",{className:"s-profile-identity-eyebrow",children:W.join(" · ")}),o.jsxs("h1",{className:"s-profile-identity-name",children:[u,d&&o.jsx("span",{className:"s-profile-identity-name-qualifier",children:d}),e.handle&&o.jsxs("span",{className:"s-profile-identity-name-handle",children:["@",e.handle]})]}),o.jsx("div",{className:"s-profile-identity-state-row",children:o.jsxs("span",{className:"s-profile-identity-state",children:[o.jsx("span",{className:`s-profile-identity-state-dot${R==="working"?" s-profile-identity-state-dot--pulse":""}`,style:{background:Ur(e.state)}}),o.jsx("span",{className:"s-profile-identity-state-label",children:Pn(e.state)}),e.updatedAt&&o.jsxs("span",{className:"s-profile-identity-state-detail",children:["— ",De(e.updatedAt)]})]})})]}),o.jsx("nav",{className:"s-profile-tabs",children:L.map(X=>o.jsx("button",{type:"button",className:`s-profile-tab${l===X.key?" s-profile-tab--active":""}`,disabled:X.disabled,onClick:()=>F(X.key),children:X.label},X.key))})]})}),l==="profile"&&o.jsxs("div",{className:"s-profile-tab-content",children:[(e.project||e.branch||e.cwd||C?.activeSessionId)&&o.jsxs("div",{className:"s-profile-facets",children:[e.project&&o.jsxs("div",{className:"s-profile-facet",children:[o.jsx("div",{className:"s-profile-facet-label",children:"Workspace"}),o.jsx("div",{className:"s-profile-facet-value",children:e.project}),q>1&&o.jsxs("div",{className:"s-profile-facet-detail",children:[q," teammates"]})]}),(e.branch||e.projectRoot)&&o.jsxs("div",{className:"s-profile-facet",children:[o.jsx("div",{className:"s-profile-facet-label",children:"Repo / Branch"}),o.jsx("div",{className:"s-profile-facet-value",children:e.projectRoot?e.projectRoot.split("/").pop():e.project??"—"}),e.branch&&o.jsxs("div",{className:"s-profile-facet-detail",children:[o.jsx("span",{className:"s-profile-facet-accent",children:"⎇"})," ",e.branch]})]}),e.cwd&&o.jsxs("div",{className:"s-profile-facet",children:[o.jsx("div",{className:"s-profile-facet-label",children:"Working Dir"}),o.jsx("div",{className:"s-profile-facet-value",children:e.cwd.startsWith("/Users/")?"~/"+e.cwd.split("/").slice(3).join("/"):e.cwd}),e.updatedAt&&o.jsxs("div",{className:"s-profile-facet-detail",children:["uptime ",De(e.updatedAt)]})]}),C?.activeSessionId&&o.jsx(GW,{catalog:C,agentId:e.id})]}),V&&R==="working"&&o.jsxs(o.Fragment,{children:[o.jsx(hc,{label:"Current task",right:`${$}% · live`}),o.jsxs("div",{className:"s-profile-task",children:[o.jsx("div",{className:"s-profile-task-title",children:V.title}),V.lastMeaningfulSummary&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"s-profile-task-progress",children:o.jsx("div",{className:"s-profile-task-progress-bar",style:{width:`${$}%`}})}),o.jsxs("div",{className:"s-profile-task-action",children:[o.jsx("span",{className:"s-profile-task-action-chevron",children:"›"}),o.jsx("span",{children:V.lastMeaningfulSummary}),o.jsx("span",{className:"s-profile-task-cursor"})]})]}),o.jsxs("div",{className:"s-profile-task-meta",children:[o.jsx("span",{children:V.currentPhase}),o.jsx("span",{children:De(V.lastMeaningfulAt)})]})]})]}),U.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(hc,{label:"Active work",right:`${U.length} in flight`}),o.jsx("div",{className:"s-profile-work",children:o.jsx(LN,{items:U,navigate:a,emptyTitle:"Nothing in flight"})})]}),O.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(hc,{label:U.length>0?"Recently completed":"Recent work",right:`${O.length}`}),o.jsx("div",{className:"s-profile-work",children:o.jsx(LN,{items:O,navigate:a,emptyTitle:""})})]}),o.jsx(hc,{label:"Activity"}),o.jsx("div",{className:"s-profile-work",children:o.jsx(KW,{agent:e,fleet:x,navigate:a})}),o.jsx(XW,{messages:m,navigate:a,conversationId:s,agentId:e.id})]}),l==="observe"&&o.jsx("div",{className:"s-profile-tab-conversation",children:k&&!j?o.jsxs("div",{className:"s-profile-activity-empty",children:[o.jsx("div",{className:"s-profile-activity-empty-title",children:"Loading trace"}),o.jsx("div",{className:"s-profile-activity-empty-detail",children:"Resolving the best available live or history-backed session stream for this agent."})]}):o.jsx(KR,{data:j?.data,agentId:e.id,sessionId:j?.sessionId})}),l==="message"&&s&&o.jsx("div",{className:"s-profile-tab-conversation",children:o.jsx(qv,{conversationId:s,navigate:a,embedded:!0})})]})}function QW({navigate:e,selectedAgentId:t,conversationId:n,tab:s}){const{agents:a}=Nt(),[l,u]=g.useState([]),d=g.useCallback(async()=>{const y=await Re("/api/sessions").catch(()=>null);y&&u(y)},[]);g.useEffect(()=>{d()},[d]),Rn(()=>{d()});const p=t?a.find(y=>y.id===t)??null:null,{conversationByAgentId:h,sessionByAgentId:m}=YW(l);if(p){const y=n??h.get(p.id)??p.conversationId??null,x=s??(n?"message":"profile");return o.jsx(JW,{agent:p,allAgents:a,session:m.get(p.id)??null,conversationId:y,navigate:e,activeTab:x})}return o.jsx(tY,{agents:a,sessionByAgentId:m,conversationByAgentId:h,navigate:e})}const XR="—";function eY(e){const t=new Map;for(const s of e){const a=s.project??"Unscoped",l=t.get(a)??[];l.push(s),t.set(a,l)}const n=[];for(const[s,a]of t){const l=a.find(m=>m.projectRoot)?.projectRoot??null,u=new Map;for(const m of a){const y=m.branch??XR,x=u.get(y)??[];x.push(m),u.set(y,x)}const d=Array.from(u.entries()).map(([m,y])=>{const x=y.filter(Zv).length;return{name:m,agents:y,online:x,kind:x>0?"active":"idle"}}),p=new Set(["main","master","trunk"]);d.sort((m,y)=>{const x=p.has(m.name),w=p.has(y.name);return x!==w?x?-1:1:m.name.localeCompare(y.name)});for(const m of d)m.agents.sort((y,x)=>y.name.localeCompare(x.name));const h=a.reduce((m,y)=>{const x=y.updatedAt;return x&&(m===null||x>m)?x:m},null);n.push({key:s,name:s,path:l,branches:d,totalAgents:a.length,totalOnline:a.filter(Zv).length,lastActivityAt:h})}return n.sort((s,a)=>s.name.localeCompare(a.name)),n}function tY({agents:e,sessionByAgentId:t,conversationByAgentId:n,navigate:s}){if(e.length===0)return o.jsx("div",{className:"s-profile-center",style:{height:"100%"},children:o.jsxs("div",{className:"s-profile-empty",children:[o.jsx("h2",{className:"s-profile-empty-title",children:"No agents yet"}),o.jsx("p",{className:"s-profile-empty-copy",children:"Spawn an agent from a workspace, harness, branch, and model to see it land here."})]})});const a=g.useMemo(()=>eY(e),[e]),l=e.filter(Zv).length,[u,d]=g.useState("cards");return o.jsxs("div",{className:"s-agents-library",children:[o.jsxs("header",{className:"s-agents-library-head",children:[o.jsxs("div",{className:"s-agents-library-title-row",children:[o.jsx("h2",{className:"s-agents-library-title",children:"Agents"}),o.jsxs("span",{className:"s-agents-library-count",children:[l," online · ",e.length," total · ",a.length," ",a.length===1?"repo":"repos"]})]}),o.jsx("div",{className:"s-agents-library-view",role:"tablist","aria-label":"Agent view",children:["pills","rows","cards"].map(p=>o.jsx("button",{type:"button",role:"tab","aria-selected":u===p,className:"s-agents-library-view-btn","data-active":u===p?"true":void 0,onClick:()=>d(p),children:p},p))})]}),o.jsx("div",{className:"s-agents-library-repos",children:a.map(p=>o.jsx(nY,{repo:p,sessionByAgentId:t,conversationByAgentId:n,navigate:s,viewMode:u},p.key))})]})}function nY({repo:e,sessionByAgentId:t,conversationByAgentId:n,navigate:s,viewMode:a}){const[l,u]=g.useState(()=>e.branches[0]?.name??XR),d=e.branches.find(p=>p.name===l)??e.branches[0];return o.jsxs("section",{className:"s-repo-card",children:[o.jsxs("header",{className:"s-repo-card-head",children:[o.jsxs("div",{className:"s-repo-card-identity",children:[o.jsx("h3",{className:"s-repo-card-name",children:e.name}),e.path&&o.jsx("span",{className:"s-repo-card-path",children:e.path})]}),o.jsx("div",{className:"s-repo-card-meta",children:e.lastActivityAt&&o.jsx("span",{children:De(e.lastActivityAt)})})]}),o.jsx("div",{className:"s-repo-card-tabs",role:"tablist","aria-label":"Branches",children:e.branches.map(p=>o.jsxs("button",{type:"button",role:"tab","aria-selected":d?.name===p.name,className:"s-repo-card-tab","data-kind":p.kind,"data-active":d?.name===p.name?"true":void 0,onClick:()=>u(p.name),children:[o.jsx("span",{className:"s-repo-card-tab-name",children:p.name}),p.kind==="unmonitored"?o.jsx("span",{className:"s-repo-card-tab-glyph","aria-hidden":"true",children:"+"}):o.jsx("span",{className:"s-repo-card-tab-count",children:p.online>0?`${p.online}/${p.agents.length}`:`${p.agents.length}`})]},p.name))}),o.jsx("div",{className:"s-repo-card-body",children:d&&d.agents.length>0?o.jsx(sY,{agents:d.agents,sessionByAgentId:t,conversationByAgentId:n,navigate:s,viewMode:a}):o.jsxs("div",{className:"s-repo-card-empty",children:["No agent on ",o.jsx("strong",{children:d?.name}),". Spawn one to start."]})})]})}function Zv(e){return et(e.state)!=="offline"}function sY({agents:e,sessionByAgentId:t,conversationByAgentId:n,navigate:s,viewMode:a}){const l=u=>()=>{const d=n.get(u.id);s({view:"agents",agentId:u.id,...d?{conversationId:d}:{}})};return a==="rows"?o.jsx("div",{className:"s-agent-rows",children:e.map(u=>o.jsx(rY,{agent:u,session:t.get(u.id)??null,onClick:l(u)},u.id))}):a==="cards"?o.jsx("div",{className:"s-agent-grid",children:e.map(u=>o.jsx(aY,{agent:u,session:t.get(u.id)??null,onClick:l(u)},u.id))}):o.jsx("div",{className:"s-agent-log",children:e.map(u=>o.jsx(iY,{agent:u,session:t.get(u.id)??null,onClick:l(u)},u.id))})}function rY({agent:e,session:t,onClick:n}){const s=et(e.state),a=Pn(e.state),l=t?.lastMessageAt??e.updatedAt??null,u=t?.preview??null,d=Bc(e.harness);return o.jsxs("button",{type:"button",className:"s-agent-row","data-state":s,onClick:n,title:a,children:[o.jsx("span",{className:"s-agent-row-name",children:e.name}),o.jsx("span",{className:"s-agent-row-preview",children:u??o.jsx("span",{className:"s-agent-row-preview-quiet",children:a.toLowerCase()})}),d&&o.jsx("span",{className:"s-agent-row-harness",children:d}),l&&o.jsx("span",{className:"s-agent-row-time",children:De(l)})]})}function aY({agent:e,session:t,onClick:n}){const s=et(e.state),a=Pn(e.state),l=t?.lastMessageAt??e.updatedAt??null,u=t?.preview??null,d=[e.harness,e.branch,e.agentClass].map(Bc).filter(p=>!!p);return o.jsxs("button",{type:"button",className:"s-agent-card","data-state":s,onClick:n,title:a,children:[o.jsxs("div",{className:"s-agent-card-row",children:[o.jsx("span",{className:"s-agent-card-name",children:e.name}),l&&o.jsx("span",{className:"s-agent-card-time",children:De(l)})]}),o.jsx("div",{className:"s-agent-card-preview",children:u??o.jsx("span",{className:"s-agent-card-preview-quiet",children:a})}),d.length>0&&o.jsx("div",{className:"s-agent-card-topo",children:d.map((p,h)=>o.jsx("span",{className:"s-agent-card-topo-chip",children:p},`${p}-${h}`))})]})}function iY({agent:e,session:t,onClick:n}){const s=et(e.state),a=Pn(e.state),l=t?.lastMessageAt??e.updatedAt??null,u=t?.preview??null,d=Bc(e.harness),p=[`${e.name} · ${a}`,d?`harness: ${d}`:null,u?`preview: ${u}`:null].filter(Boolean);return o.jsxs("button",{type:"button",className:"s-agent-log-row","data-state":s,onClick:n,title:p.join(`
|
|
155
|
-
`),children:[o.jsx("span",{className:"s-agent-log-time",children:l?De(l):"—"}),o.jsx("span",{className:"s-agent-log-name",children:e.name}),o.jsx("span",{className:"s-agent-log-msg",children:u??o.jsx("span",{className:"s-agent-log-msg-quiet",children:a.toLowerCase()})})]})}function oY(e){return e<5?"Still up":e<12?"Good morning":e<18?"Good afternoon":"Good evening"}function rc(e){return e.status==="fulfilled"?null:e.reason instanceof Error?e.reason.message:String(e.reason)}function lY(e){if(e.kind==="flight_updated"&&/\breplied\.?$/i.test(e.title??""))return 0;const t=(e.title??e.summary??"").trim().toLowerCase();if(/^(kk|k|ok|okay|ping|pong|thanks|thank you)\.?$/.test(t))return 0;switch(e.kind){case"ask_failed":return 110;case"handoff_sent":return 100;case"collaboration_event":return 95;case"agent_message":return 90;case"status_message":return 85;case"ask_working":return 75;case"ask_opened":return 70;case"message_posted":return 60;case"invocation_recorded":return 30;case"flight_updated":return 20;default:return 50}}function cY(e){const t=(e.title??e.summary??"").trim().toLowerCase();return`${e.conversationId??"global"}:${t}`}function uY(e){switch(e){case"ask_opened":return"ask";case"handoff_sent":return"handoff";case"collaboration_event":return"work";case"agent_message":return"message";case"status_message":return"status";case"ask_failed":return"failed";case"ask_working":return"working";case"invocation_recorded":return"recorded";case"flight_updated":return"flight";default:return e.replace(/_/g," ")}}function dY(e,t=12){const n=e.map(l=>({item:l,rank:lY(l)})).filter(({rank:l})=>l>0).sort((l,u)=>{const d=u.item.ts-l.item.ts;return Math.abs(d)>3e4?d:u.rank-l.rank}),s=[],a=new Set;for(const{item:l}of n){const u=cY(l);if(!a.has(u)&&(a.add(u),s.push(l),s.length>=t))break}return s.sort((l,u)=>u.ts-l.ts)}function ZN({navigate:e}){const{agents:t,onboarding:n,reload:s}=Nt(),[a,l]=g.useState([]),[u,d]=g.useState([]),[p,h]=g.useState(null),[m,y]=g.useState([]),[x,w]=g.useState("trailing 7d"),[j,N]=g.useState("3h buckets"),[k,E]=g.useState(!0),[C,S]=g.useState(!1),[R,A]=g.useState(null),[M,_]=g.useState(null),z=g.useRef(null),V=g.useRef(0),U=g.useRef(0),O=g.useRef(null);g.useEffect(()=>{O.current=p},[p]);const D=g.useCallback(async(ue="initial")=>{const we=++V.current;!(O.current!==null)&&ue!=="background"?(E(!0),A(null)):S(!0);const[Ae,je,Ee,Ue,Ve]=await Promise.allSettled([Re("/api/activity"),Re("/api/sessions"),Re("/api/fleet"),Re("/api/heartrate"),s()]);if(we!==V.current)return;Ae.status==="fulfilled"&&l(Ae.value),je.status==="fulfilled"&&d([...je.value].sort((oe,ve)=>(ve.lastMessageAt??0)-(oe.lastMessageAt??0))),Ee.status==="fulfilled"&&(O.current=Ee.value,h(Ee.value)),Ue.status==="fulfilled"&&(y(Ue.value.buckets),w(Ue.value.windowLabel),N(Ue.value.bucketLabel??""));const Be=[rc(Ae),rc(je),rc(Ee),rc(Ue),rc(Ve)].filter(oe=>!!oe);A(Be[0]??null),Be.length<5&&_(Date.now()),E(!1),S(!1)},[s]),H=g.useCallback(()=>{z.current||(z.current=setTimeout(()=>{z.current=null,D("background")},250))},[D]);g.useEffect(()=>(D(),()=>{z.current&&clearTimeout(z.current)}),[D]),Rn(H),g.useEffect(()=>{const ue=setInterval(()=>{document.visibilityState==="visible"&&D("background")},15e3);return()=>clearInterval(ue)},[D]),g.useEffect(()=>{const ue=()=>{if(document.visibilityState!=="visible")return;const we=Date.now();we-U.current<1e3||(U.current=we,D("background"))};return window.addEventListener("focus",ue),document.addEventListener("visibilitychange",ue),()=>{window.removeEventListener("focus",ue),document.removeEventListener("visibilitychange",ue)}},[D]);const W=g.useMemo(()=>t.filter(ue=>et(ue.state)==="working"),[t]),q=g.useMemo(()=>t.filter(ue=>et(ue.state)==="available"),[t]),$=g.useMemo(()=>t.filter(ue=>et(ue.state)==="offline"),[t]),L=g.useMemo(()=>(p?.activeAsks??[]).filter(ue=>ue.status==="needs_attention"||ue.status==="failed"),[p]),F=g.useMemo(()=>(p?.activeAsks??[]).filter(ue=>ue.status==="queued"||ue.status==="working"),[p]),X=g.useMemo(()=>p?.needsAttention??[],[p]),G=g.useMemo(()=>{const ue=new Map;for(const we of F){const We=ue.get(we.agentId);(!We||we.updatedAt>We.updatedAt)&&ue.set(we.agentId,we)}return ue},[F]),I=g.useMemo(()=>F.filter(ue=>!W.some(we=>we.id===ue.agentId)),[W,F]),B=L.length+X.length,Y=g.useMemo(()=>{const ue=[...L.map(we=>we.updatedAt),...X.map(we=>we.updatedAt)];return ue.length>0?Math.min(...ue):null},[L,X]),Q=g.useMemo(()=>dY(a),[a]),me=Q.length===0?"quiet":`latest ${Q.length} signal${Q.length===1?"":"s"}`,re=new Date,ie=oY(re.getHours()),de=tu(),ye=n?.operatorName?.trim()||n?.operatorNameSuggestion?.trim()||"operator",Te=g.useMemo(()=>{const ue=[];return W.length>0&&ue.push(`${W.length} agent${W.length===1?" is":"s are"} working now`),q.length>0&&ue.push(`${q.length} agent${q.length===1?" is":"s are"} available`),B>0&&ue.push(`${B} thing${B===1?"":"s"} need${B===1?"s":""} you`),ue.length===0&&t.length>0&&ue.push(`${t.length} agent${t.length===1?" is":"s are"} registered`),ue.length===0&&ue.push("no agents are connected yet"),ue},[W,q,B,t]),he=k?"syncing":R?`sync issue · ${M?De(M):"waiting"}`:M?`updated ${De(M)}`:"waiting";return o.jsx("div",{className:"s-fleet-home",children:o.jsxs("div",{className:"s-fleet-home-inner",children:[o.jsxs("div",{className:"s-hero",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"s-eyebrow",style:{marginBottom:12},children:["Fleet briefing ·"," ",re.toLocaleDateString([],{weekday:"long",month:"short",day:"numeric"}),o.jsx("span",{className:`s-fleet-sync-note${R?" s-fleet-sync-note--error":""}`,children:he})]}),o.jsxs("h1",{className:"s-hero-greeting",children:[ie,", ",o.jsxs("em",{children:[ye,"."]})]}),o.jsxs("p",{className:"s-hero-narrative",children:[Te.map((ue,we)=>o.jsxs("span",{children:[we>0&&", ",ue.includes("need")?o.jsx("span",{className:"s-hero-warn",children:ue}):o.jsx("strong",{children:ue})]},we)),"."]}),o.jsxs("div",{className:"s-hero-actions",children:[B>0&&o.jsxs("button",{className:"s-btn-fleet s-btn-fleet--primary",onClick:()=>{document.getElementById("home-needs-you")?.scrollIntoView({behavior:"smooth",block:"start"})},children:["Clear queue · ",B]}),de&&o.jsx("button",{className:"s-btn-fleet",onClick:()=>e({view:"ops"}),children:"Open ops center"}),o.jsx("button",{className:"s-btn-fleet",onClick:()=>e({view:"sessions"}),children:"Jump to thread"}),o.jsxs("button",{type:"button",className:"s-btn-fleet s-btn-fleet--icon",disabled:k||C,onClick:()=>{D("manual")},children:[o.jsx($k,{"aria-hidden":"true",size:12,strokeWidth:2,className:C?"s-refresh-spin":void 0}),o.jsx("span",{children:C?"Refreshing":"Refresh"})]})]})]}),o.jsxs("div",{className:"s-heartrate-card",children:[o.jsxs("div",{className:"s-heartrate-header",children:[o.jsx("span",{className:"s-eyebrow",children:"Fleet heart-rate"}),o.jsx("span",{style:{flex:1}}),o.jsxs("span",{className:"s-heartrate-live",children:["● ",x,j?` · ${j}`:""]})]}),o.jsx(hY,{buckets:m}),o.jsxs("div",{className:"s-heartrate-stats",children:[o.jsx(Ag,{label:"Active",value:W.length,color:"var(--green)"}),o.jsx(Ag,{label:"Waiting",value:q.length,color:"var(--amber)"}),o.jsx(Ag,{label:"Offline",value:$.length,color:"var(--dim)"})]})]})]}),o.jsxs("div",{className:"s-fleet-section",id:"home-needs-you",children:[o.jsx(Rg,{label:`Needs you · ${B}`,right:B>0&&Y!==null?o.jsxs("span",{style:{color:"var(--amber)"},children:["oldest ",De(Y)]}):"clear"}),L.length>0&&o.jsx("div",{className:"s-ask-grid",children:L.slice(0,4).map(ue=>o.jsx(mY,{ask:ue,agents:t,navigate:e,operatorName:ye,pending:!0},ue.invocationId))}),X.length>0&&o.jsx("div",{className:"s-attention-list",children:X.map(ue=>o.jsx(gY,{item:ue,navigate:e},ue.recordId))}),B===0&&o.jsx(pY,{agents:t,activeCount:W.length,waitingCount:q.length,offlineCount:$.length,navigate:e})]}),(W.length>0||I.length>0)&&o.jsxs("div",{className:"s-fleet-section",children:[o.jsx(Rg,{label:`What's moving · ${W.length+I.length}`,right:o.jsx("button",{className:"s-link-btn",onClick:()=>e({view:"mesh"}),children:"open mesh ↗"})}),W.length>0&&o.jsx("div",{className:"s-now-grid",style:{gridTemplateColumns:`repeat(${Math.min(W.length,3)}, 1fr)`},children:W.map(ue=>o.jsx(vY,{agent:ue,ask:G.get(ue.id)??null,navigate:e},ue.id))}),I.length>0&&o.jsx("div",{className:"s-moving-ask-list",children:I.map(ue=>o.jsx(yY,{ask:ue,navigate:e},ue.invocationId))})]}),Q.length>0&&o.jsxs("div",{className:"s-fleet-section",children:[o.jsx(Rg,{label:"Since you were away",right:me}),o.jsx(bY,{items:Q,agents:t,navigate:e})]})]})})}function fY(e){if(e.length===0)return"";if(e.length===1)return`M ${e[0].x.toFixed(1)} ${e[0].y.toFixed(1)}`;const t=[`M ${e[0].x.toFixed(1)} ${e[0].y.toFixed(1)}`];for(let n=0;n<e.length-1;n++){const s=e[Math.max(0,n-1)],a=e[n],l=e[n+1],u=e[Math.min(e.length-1,n+2)],d={x:a.x+(l.x-s.x)/6,y:a.y+(l.y-s.y)/6},p={x:l.x-(u.x-a.x)/6,y:l.y-(u.y-a.y)/6};t.push(`C ${d.x.toFixed(1)} ${d.y.toFixed(1)}, ${p.x.toFixed(1)} ${p.y.toFixed(1)}, ${l.x.toFixed(1)} ${l.y.toFixed(1)}`)}return t.join(" ")}function hY({buckets:e}){const u=e.length;if(u<2||e.every(x=>x.count===0))return o.jsxs("svg",{viewBox:"0 0 372 82",style:{width:"100%",height:82,display:"block"},children:[o.jsx("line",{x1:"0",y1:60,x2:372,y2:60,stroke:"var(--border)"}),o.jsx("text",{x:372/2,y:82/2-4,textAnchor:"middle",fill:"var(--dim)",fontSize:"14",letterSpacing:"0.3em",children:"zzz"}),o.jsx("text",{x:372/2,y:82/2+12,textAnchor:"middle",fill:"var(--dim)",fontSize:"10",fontFamily:"var(--hud-font-mono)",opacity:"0.7",children:"nothing to report"})]});const p=372/(u-1),h=e.map((x,w)=>({x:w*p,y:60-Math.max(0,Math.min(1,x.value))*54})),m=fY(h),y=`${m} L 372 60 L 0 60 Z`;return o.jsxs("svg",{viewBox:"0 0 372 82",style:{width:"100%",height:82,display:"block"},children:[o.jsx("defs",{children:o.jsxs("linearGradient",{id:"hrFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[o.jsx("stop",{offset:"0%",stopColor:"var(--accent)",stopOpacity:"0.28"}),o.jsx("stop",{offset:"100%",stopColor:"var(--accent)",stopOpacity:"0"})]})}),o.jsx("line",{x1:"0",y1:6,x2:372,y2:6,stroke:"var(--border)",opacity:"0.18"}),o.jsx("line",{x1:"0",y1:66/2,x2:372,y2:66/2,stroke:"var(--border)",opacity:"0.25"}),o.jsx("line",{x1:"0",y1:60,x2:372,y2:60,stroke:"var(--border)"}),o.jsx("path",{d:y,fill:"url(#hrFill)"}),o.jsx("path",{d:m,fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round"}),o.jsx("circle",{cx:h[u-1].x,cy:h[u-1].y,r:"3.5",fill:"var(--accent)"}),o.jsx("text",{x:"0",y:77,fill:"var(--dim)",fontSize:"9",fontFamily:"var(--font-mono)",children:"7d ago"}),o.jsx("text",{x:372/2,y:77,textAnchor:"middle",fill:"var(--dim)",fontSize:"9",fontFamily:"var(--font-mono)",children:"3d"}),o.jsx("text",{x:372,y:77,textAnchor:"end",fill:"var(--dim)",fontSize:"9",fontFamily:"var(--font-mono)",children:"now"})]})}function Ag({label:e,value:t,color:n}){return o.jsxs("div",{className:"s-stat",children:[o.jsxs("div",{className:"s-stat-label",children:[o.jsx("span",{className:"s-stat-dot",style:{background:n}}),o.jsx("span",{className:"s-eyebrow",children:e})]}),o.jsx("span",{className:"s-stat-value",children:t})]})}function Rg({label:e,right:t}){return o.jsxs("div",{className:"s-section-rule",children:[o.jsx("span",{className:"s-eyebrow",children:e}),o.jsx("span",{className:"s-section-rule-line"}),t&&o.jsx("span",{className:"s-section-rule-right",children:t})]})}function pY({agents:e,activeCount:t,waitingCount:n,offlineCount:s,navigate:a}){const l=g.useMemo(()=>{const u=d=>{switch(et(d.state)){case"working":return 0;case"available":return 1;default:return 2}};return[...e].sort((d,p)=>{const h=u(d)-u(p);return h!==0?h:(p.updatedAt??0)-(d.updatedAt??0)}).slice(0,8)},[e]);return o.jsxs("div",{className:"s-fleet-clear",children:[o.jsxs("div",{className:"s-fleet-clear-head",children:[o.jsxs("div",{children:[o.jsx("span",{className:"s-eyebrow",children:"Fleet overview"}),o.jsx("div",{className:"s-fleet-clear-title",children:e.length===0?"No agents registered":`${e.length} agent${e.length===1?"":"s"} registered`})]}),o.jsx("button",{className:"s-link-btn",onClick:()=>a({view:"agents"}),children:"open agents"})]}),o.jsxs("div",{className:"s-fleet-clear-metrics",children:[o.jsx(Mg,{label:"Working",value:t,color:"var(--green)"}),o.jsx(Mg,{label:"Available",value:n,color:"var(--accent)"}),o.jsx(Mg,{label:"Offline",value:s,color:"var(--dim)"})]}),l.length>0?o.jsx("div",{className:"s-fleet-roster",children:l.map(u=>{const d=et(u.state),p=u.handle?`@${u.handle}`:u.selector??u.id,h=u.role??u.agentClass,m={view:"agents",agentId:u.id,conversationId:u.conversationId||Dn(u.id),tab:d==="offline"?"profile":"observe"};return o.jsxs("button",{className:"s-fleet-roster-row",onClick:()=>a(m),children:[o.jsx("span",{className:"s-fleet-roster-dot",style:{background:Ur(u.state)}}),o.jsx("span",{className:"s-fleet-roster-name",children:u.name}),o.jsxs("span",{className:"s-fleet-roster-meta",children:[p," · ",h]}),o.jsx("span",{className:"s-fleet-roster-state",children:d}),o.jsx("span",{className:"s-fleet-roster-time",children:u.updatedAt?De(u.updatedAt):"no heartbeat"})]},u.id)})}):o.jsx("div",{className:"s-fleet-clear-empty",children:"No roster entries."})]})}function Mg({label:e,value:t,color:n}){return o.jsxs("div",{className:"s-fleet-metric",children:[o.jsx("span",{className:"s-fleet-metric-dot",style:{background:n}}),o.jsx("span",{className:"s-eyebrow",children:e}),o.jsx("span",{className:"s-fleet-metric-value",children:t})]})}function mY({ask:e,agents:t,navigate:n,operatorName:s,pending:a}){const u=t.find(p=>p.id===e.agentId)?.name??e.agentName??e.agentId,d=e.conversationId?{view:"conversation",conversationId:e.conversationId}:{view:"agents",agentId:e.agentId};return o.jsxs("div",{className:`s-ask-block${a?" s-ask-block--pending":""}`,style:{cursor:"pointer"},onClick:()=>n(d),children:[o.jsxs("div",{className:"s-ask-header",children:[o.jsx("span",{className:"s-eyebrow s-ask-label",children:a?"◌ ASK — ATTENTION":"● ASK"}),o.jsx("span",{style:{flex:1}}),o.jsx("span",{className:"s-eyebrow",children:De(e.updatedAt)})]}),o.jsxs("div",{className:"s-ask-body",children:[o.jsx("div",{className:"s-avatar s-avatar-sm",style:{background:mt(u)},children:u[0]?.toUpperCase()??"?"}),o.jsxs("div",{className:"s-ask-body-copy",children:[o.jsxs("div",{className:"s-ask-route",children:[o.jsx("span",{className:"s-ask-route-name",children:u}),o.jsx("span",{children:" → "}),o.jsx("span",{style:{color:"var(--accent)"},children:s})]}),o.jsxs("div",{className:"s-ask-text",children:['"',e.summary??e.task,'"']})]})]}),a&&o.jsxs("div",{className:"s-ask-actions",children:[o.jsx("button",{className:"s-btn-fleet s-btn-fleet--primary",children:"Answer"}),o.jsx("button",{className:"s-btn-fleet",children:"Defer"}),o.jsx("button",{className:"s-btn-fleet",children:"Route…"}),o.jsx("span",{className:"s-ask-thinking",children:o.jsx("span",{className:"s-thinking-strip"})})]})]})}function gY({item:e,navigate:t}){const n=e.kind==="work_item"&&e.recordId?{view:"work",workId:e.recordId}:e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.agentId?{view:"agents",agentId:e.agentId}:null,s=e.kind==="question"?"question":e.state.replace(/_/g," "),a=e.acceptanceState!=="none"?e.acceptanceState.replace(/_/g," "):e.kind==="question"?"awaiting answer":"your move",l=e.kind==="question"?"answer":e.state==="review"?"review":e.acceptanceState==="pending"?"acknowledge":"open work";return o.jsxs("div",{className:`s-attention-row${n?" s-attention-row--clickable":""}`,onClick:n?()=>t(n):void 0,children:[o.jsx("div",{className:"s-attention-row-title",children:e.title}),o.jsxs("div",{className:"s-attention-row-meta",children:[o.jsx("span",{className:"s-eyebrow",children:e.kind==="work_item"?"WORK ITEM":"QUESTION"}),e.agentName&&o.jsx("span",{children:e.agentName}),o.jsx("span",{children:s}),o.jsx("span",{style:{color:"var(--amber)"},children:a}),o.jsx("span",{style:{marginLeft:"auto"},children:De(e.updatedAt)}),n&&o.jsxs("span",{className:"s-attention-row-action",children:[l," ↗"]})]}),e.summary&&o.jsx("p",{className:"s-attention-row-summary",children:e.summary})]})}function vY({agent:e,ask:t,navigate:n}){const s=e.handle?`@${e.handle}`:e.id,a=e.role??e.agentClass,l=e.branch??"main",u=Dn(e.id),d=t?.summary??t?.task??e.cwd??`Working in ${e.project??"workspace"}`;return o.jsxs("div",{className:"s-now-card",onClick:()=>n({view:"agents",agentId:e.id,conversationId:u,tab:"observe"}),children:[o.jsxs("div",{className:"s-now-card-head",children:[o.jsx("div",{className:"s-avatar s-avatar-sm",style:{background:mt(e.name)},children:e.name[0]?.toUpperCase()??"?"}),o.jsxs("div",{className:"s-now-card-copy",children:[o.jsx("div",{className:"s-now-card-name",children:e.name}),o.jsxs("div",{className:"s-now-card-meta",children:[s," · ",a]})]}),o.jsx("span",{className:"s-now-card-live",children:"● live"})]}),o.jsx("div",{className:"s-now-card-task",children:d}),o.jsxs("div",{className:"s-now-card-ticker",children:[o.jsx("span",{className:"s-now-card-ticker-prompt",children:"›"}),o.jsx("span",{className:"s-now-card-ticker-text",children:t?`${t.statusLabel} · ${t.harness??e.harness??"agent"}`:"working"}),o.jsx("span",{className:"s-now-card-cursor"})]}),o.jsxs("div",{className:"s-now-card-footer",children:[o.jsx("span",{children:e.updatedAt?`updated ${De(e.updatedAt)}`:"active"}),o.jsx("span",{children:l})]})]})}function yY({ask:e,navigate:t}){const n=e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.collaborationRecordId?{view:"work",workId:e.collaborationRecordId}:{view:"agents",agentId:e.agentId};return o.jsxs("button",{className:"s-moving-ask-row",onClick:()=>t(n),children:[o.jsx("span",{className:"s-moving-ask-agent",children:e.agentName??e.agentId}),o.jsx("span",{className:"s-moving-ask-title",children:e.summary??e.task}),o.jsx("span",{className:"s-moving-ask-state",children:e.statusLabel}),o.jsx("span",{className:"s-moving-ask-time",children:De(e.updatedAt)})]})}function bY({items:e,agents:t,navigate:n}){const s=[...e].sort((u,d)=>d.ts-u.ts),a={ask_opened:"?",ask_failed:"!",ask_working:"…",handoff_sent:"→",collaboration_event:"◆",agent_message:"·",status_message:"·",message_posted:"·",invocation_recorded:"⌘",flight_updated:"⌘","collaboration.ask":"?","message.sent":"·","message.received":"·","flight.started":"⌘","flight.completed":"⌘","agent.online":"→","agent.offline":"→","agent.registered":"→","collaboration.answer":"↳"},l={ask_opened:"var(--amber)",ask_failed:"var(--red)",ask_working:"var(--amber)",handoff_sent:"var(--accent)",collaboration_event:"var(--green)",agent_message:"var(--dim)",status_message:"var(--muted)",message_posted:"var(--dim)",invocation_recorded:"var(--muted)",flight_updated:"var(--green)","collaboration.ask":"var(--amber)","collaboration.answer":"var(--accent)","message.sent":"var(--dim)","message.received":"var(--dim)","flight.started":"var(--muted)","flight.completed":"var(--green)","agent.online":"var(--accent)","agent.offline":"var(--dim)","agent.registered":"var(--accent)"};return o.jsxs("div",{className:"s-timeline",children:[o.jsx("div",{className:"s-timeline-spine"}),s.map(u=>{const d=u.actorName??"system",p=l[u.kind]??"var(--dim)",h=a[u.kind]??"·",m=uY(u.kind),y=u.conversationId?{view:"conversation",conversationId:u.conversationId}:null;return o.jsxs("div",{className:"s-timeline-row",style:{cursor:y?"pointer":void 0},onClick:y?()=>n(y):void 0,children:[o.jsx("div",{className:"s-timeline-bead",style:{background:p}}),o.jsx("span",{className:"s-timeline-time",children:De(u.ts)}),o.jsxs("div",{className:"s-timeline-actors",children:[o.jsx("span",{className:"s-timeline-kind-mark",style:{color:p},children:h}),o.jsx("div",{className:"s-avatar",style:{width:18,height:18,fontSize:9,background:mt(d)},children:d[0]?.toUpperCase()??"?"}),o.jsx("span",{className:"s-timeline-handle",children:d})]}),o.jsx("span",{className:"s-timeline-text",children:u.title??u.summary??""}),o.jsx("span",{className:"s-timeline-kind",children:m})]},u.id)})]})}const xY=g.lazy(()=>vc(()=>import("./arc.es-DglF81f4.js"),[]).then(e=>({default:e.ArcDiagram})));function bi(e){if(!e)return"";const t=e.replace(/^https?:\/\//,"").split("/")[0],[n]=t.split(":");return n.split(".")[0]}function wY(e){const t=e.hostName?.trim();if(t&&t.toLowerCase()!=="localhost")return bi(t)||t;const n=e.dnsName?.trim().replace(/\.$/,"");return n?bi(n)||n:bi(e.name)||e.name}function Wv(e){if(!e)return"";const t=e.replace(/^https?:\/\//,"").split("/")[0],[n]=t.split(":");return n.replace(/\.$/,"").toLowerCase()}function va(e){const t=Wv(e);return t?t.split(".")[0]??t:""}function jY(e){return e.brokerUrl?bi(e.brokerUrl):e.hostName?bi(e.hostName):e.id.slice(0,10)}function SY(e,t){return Math.abs(e)>=Math.abs(t)?e>=0?["right","left"]:["left","right"]:t>=0?["bottom","top"]:["top","bottom"]}function NY(e,t){const n=va(t.hostName||t.name),s=va(e.localNode?.hostName||e.localNode?.name);return!!s&&n===s}function kY(e,t){const n=new Set([va(e.hostName),va(e.name),...e.addresses.map(a=>Wv(a)),...e.addresses.map(a=>va(a))].filter(Boolean)),s=new Set([va(t.hostName),va(t.name),Wv(t.brokerUrl),va(t.brokerUrl)].filter(Boolean));for(const a of n)if(s.has(a))return!0;return!1}function EY(e){if(!e.localNode)return null;const t=e.localNode.id,n=Object.values(e.nodes).filter(x=>x.id!==t),s=e.tailscale.peers.filter(x=>!NY(e,x)).filter(x=>!n.some(w=>kY(x,w))),a=[...n.map(x=>({kind:"mesh",peer:x})),...s.map(x=>({kind:"tailnet",peer:x}))],l=800,u=300,d=l/2,p=u/2,h={[t]:{x:d,y:p,size:"m"}},m={[t]:{icon:"Database",name:bi(e.localNode.hostName)||e.localNode.name||"broker",subtitle:"this node",color:"violet"}},y=[];if(a.length===0)h.__placeholder={x:d+220,y:p,size:"m"},m.__placeholder={icon:"CircleDashed",name:"No peers yet",subtitle:"awaiting discovery",color:"zinc"},y.push({from:t,to:"__placeholder",fromAnchor:"right",toAnchor:"left",style:"pending"});else{const x=a.length,w=Math.min(170,100+x*10);a.forEach(({kind:j,peer:N},k)=>{const E=k/x*Math.PI*2-Math.PI/2,C=Math.round(d+w*Math.cos(E)),S=Math.round(p+w*Math.sin(E)),R=j==="mesh"?N.id:`tailnet:${N.id}`,A=j==="mesh"?bi(N.hostName)||N.name||"peer":wY(N)||"tailnet",M=j==="mesh"?jY(N):N.online?N.addresses[0]??"tailnet only":"tailnet offline";h[R]={x:C,y:S,size:j==="mesh"?"m":"s"},m[R]={icon:j==="mesh"?"Database":"CircleDashed",name:A,subtitle:M,color:j==="mesh"?N.advertiseScope==="mesh"?"emerald":"zinc":N.online?"sky":"zinc"};const[_,z]=SY(C-d,S-p);y.push({from:t,to:R,fromAnchor:_,toAnchor:z,style:j==="mesh"?N.advertiseScope==="mesh"?"mesh":"local":N.online?"tailnet":"tailnet-offline"})})}return{layout:{width:l,height:u},nodes:h,nodeData:m,connectors:y,connectorStyles:{mesh:{color:"emerald",strokeWidth:2,label:"mesh"},local:{color:"zinc",strokeWidth:1.5},tailnet:{color:"sky",strokeWidth:1.5,dashed:!0,label:"tailnet"},"tailnet-offline":{color:"zinc",strokeWidth:1.25,dashed:!0,label:"tailnet"},pending:{color:"zinc",strokeWidth:1.5,dashed:!0}}}}function CY({mesh:e}){const t=g.useMemo(()=>EY(e),[e]);return t?o.jsx("div",{className:"s-mesh-topology",children:o.jsx(g.Suspense,{fallback:o.jsx("div",{className:"s-mesh-topology-fallback"}),children:o.jsx(xY,{data:t,className:"s-mesh-topology-canvas",mode:"light",theme:"cool",interactive:!0,showArcToggle:!1,defaultZoom:"fit",maxFitZoom:.95,hoverEffects:{dim:!0,lift:!0,glow:!0,highlightEdges:!0}})})}):null}function TY(e){return e.code==="local_only"?"notice":e.severity==="error"?"error":"warning"}function AY(e){switch(e.code){case"tailscale_stopped":return"Stopped";case"local_only":return"Not discoverable";case"mesh_loopback":return"Wrong address";case"discovery_unconfigured":return"No path";default:return"Offline"}}function RY(e){return e?e.replace(/^https?:\/\//,"").split("/")[0]??e:"Unavailable"}function MY(e){const t=e.hostName?.trim();if(t&&t.toLowerCase()!=="localhost")return t;const n=e.dnsName?.trim().replace(/\.$/,"");return n?n.split(".")[0]??n:e.name}function _Y(e){return e==="mesh"?"Announced to mesh":e==="local"?"Local only":e||"Not advertised"}function OY(e){return e.identity.discoverable?"success":e.health.reachable?"warning":"danger"}function IY(e){return e.identity.discoverable?"Discoverable":e.health.reachable?"Not discoverable":"Broker offline"}function DY(e){return!e.health.reachable||e.issues.some(t=>t.severity==="error")?"danger":e.issues.length>0?"warning":"success"}function PY(e){return e.health.reachable?e.issues.some(t=>t.severity==="error")?"Degraded":e.issues.length>0?"Needs attention":"Healthy":"Broker unreachable"}function zY({issue:e}){const t=TY(e);return o.jsxs("article",{className:`sys-issue-card sys-issue-card-${t}`,children:[o.jsxs("div",{className:"sys-issue-head",children:[o.jsx("h3",{className:"sys-issue-title",children:e.title}),o.jsx("span",{className:`sys-chip sys-chip-${t==="error"?"failed":t}`,children:AY(e)})]}),o.jsx("p",{className:"sys-issue-body",children:e.summary}),(e.action||e.actionCommand)&&o.jsxs("div",{className:"sys-issue-action",children:[e.actionCommand&&o.jsx("code",{className:"sys-code-inline",children:e.actionCommand}),e.action&&o.jsx("span",{children:e.action})]})]})}function LY({navigate:e}){const[t,n]=g.useState(null),[s,a]=g.useState(!0),[l,u]=g.useState(!1),[d,p]=g.useState(!1),[h,m]=g.useState(!1),[y,x]=g.useState(null),[w,j]=g.useState(null),[N,k]=g.useState(null),[E,C]=g.useState(null),S=g.useRef(null),R=g.useRef(0);g.useEffect(()=>{S.current=t},[t]);const A=g.useCallback(async(L="initial")=>{const F=++R.current;!(S.current!==null)&&L!=="background"?(a(!0),k(null)):u(!0);try{const G=await Re("/api/mesh");if(F!==R.current)return;n(G),k(null),C(Date.now())}catch(G){if(F!==R.current)return;k(G instanceof Error?G.message:String(G))}finally{F===R.current&&(a(!1),u(!1))}},[]);g.useEffect(()=>{A("initial")},[A]),g.useEffect(()=>{const L=setInterval(()=>{A("background")},1e4);return()=>clearInterval(L)},[A]);const M=g.useCallback(async()=>{p(!0),x(null);try{const L=await Re("/api/mesh/announce",{method:"POST",body:"{}"});n(L),S.current=L,k(null),C(Date.now()),x({tone:L.identity.discoverable?"success":"warning",title:L.identity.discoverable?"Mesh updated.":"Mesh updated, but still needs attention.",message:L.identity.discoverable?"This broker is now announced to the mesh.":"Mesh visibility was updated, but this broker still is not peer-reachable."})}catch(L){x({tone:"warning",title:"Could not announce broker.",message:L instanceof Error?L.message:String(L)})}finally{p(!1)}},[]),_=g.useCallback(async()=>{m(!0),j(null);try{const L=await Re("/api/mesh/tailscale",{method:"POST",body:JSON.stringify({action:"open_app"})});n(L),S.current=L,k(null),C(Date.now()),j({tone:L.tailscale.running?"success":"warning",title:L.tailscale.running?"Tailscale is running.":"Tailscale launch requested.",message:L.tailscale.running?"Mesh discovery can resume on this machine.":"Scout asked macOS to open Tailscale. Approve any prompts, then refresh this page in a moment."})}catch(L){j({tone:"warning",title:"Could not open Tailscale.",message:L instanceof Error?L.message:String(L)})}finally{m(!1)}},[]),z=t?DY(t):"warning",V=t?PY(t):"Loading",U=t?Object.values(t.nodes):[],O=t?.localNode?.id,D=t?.localNode?.hostName?.toLowerCase(),H=U.filter(L=>L.id!==O),W=(t?.tailscale.peers??[]).filter(L=>{const F=L.hostName?.toLowerCase();return!F||F==="localhost"?!0:!(D&&(F===D||F.startsWith(`${D.split(".")[0]}.`)))}),q=t?t.issues.length>0?t.issues:t.warnings.map((L,F)=>({code:`fallback-${F}`,severity:"warning",title:"Mesh notice",summary:L,action:null,actionCommand:null})):[],$=g.useMemo(()=>t?[{label:"Broker",value:t.health.reachable?"Reachable":"Unavailable",detail:t.health.error??RY(t.brokerUrl)},{label:"Discoverable",value:t.identity.discoverable?"Yes":"No",detail:t.identity.modeLabel},{label:"Mesh peers",value:`${H.length}`,detail:H.length>0?"Remote brokers in this mesh":"No remote brokers discovered"},{label:"Tailnet",value:t.tailscale.available?t.tailscale.running?`${W.filter(L=>L.online).length}/${W.length}`:"Stopped":"Unavailable",detail:t.tailscale.available?t.tailscale.running?"Online peers / visible peers":`Backend state: ${t.tailscale.backendState??"unknown"}`:"Tailscale was not detected on this machine"}]:[],[W,t,H.length]);return o.jsxs("div",{className:"sys-surface-page",children:[o.jsxs("div",{className:"sys-page-head",children:[o.jsxs("div",{className:"sys-page-title-group",children:[o.jsx("h2",{className:"sys-page-title",children:"Mesh"}),o.jsx("p",{className:"sys-page-subtitle",children:"Who this broker is, whether peers can discover it, and what the current mesh can see."})]}),o.jsxs("div",{className:"sys-page-actions",children:[o.jsx("span",{className:`sys-chip sys-chip-${z}`,children:V}),t?.tailscale.available&&!t.tailscale.running&&o.jsx("span",{className:"sys-chip sys-chip-warning",children:"Tailnet stopped"}),o.jsx("div",{className:"sys-sync-note",children:s?"Loading system snapshot...":N&&t?`Showing last confirmed snapshot from ${E?De(E):"earlier"}`:E?`Confirmed ${De(E)}`:"Waiting for first snapshot"}),o.jsx("button",{type:"button",className:"s-btn",disabled:s||l,onClick:()=>{A("manual")},children:l?"Refreshing...":"Refresh"})]})]}),N&&t&&o.jsxs("div",{className:"sys-banner sys-banner-warning",children:[o.jsx("strong",{children:"Mesh refresh failed."}),o.jsx("span",{children:N})]}),s&&!t&&o.jsxs("div",{className:"sys-panel sys-state-card",children:[o.jsx("h3",{className:"sys-state-title",children:"Loading mesh status"}),o.jsx("p",{className:"sys-state-body",children:"Inspecting broker reachability and peer discovery inputs."})]}),!s&&!t&&N&&o.jsxs("div",{className:"sys-panel sys-state-card sys-state-card-error",children:[o.jsx("h3",{className:"sys-state-title",children:"Mesh status is unavailable"}),o.jsx("p",{className:"sys-state-body",children:N}),o.jsx("div",{className:"sys-inline-actions",children:o.jsx("button",{type:"button",className:"s-btn",onClick:()=>{A("manual")},children:"Try again"})})]}),t&&o.jsxs(o.Fragment,{children:[o.jsxs("section",{className:"sys-panel sys-mesh-identity",children:[o.jsxs("div",{className:"sys-section-head",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"sys-section-title",children:"This broker"}),o.jsx("p",{className:"sys-section-subtitle",children:"The identity peers will learn if they discover this machine."})]}),o.jsx("span",{className:`sys-chip sys-chip-${OY(t)}`,children:IY(t)})]}),t.tailscale.available&&!t.tailscale.running&&o.jsxs("div",{className:"sys-banner sys-banner-warning",children:[o.jsx("strong",{children:"Tailscale is stopped."}),o.jsx("span",{children:t.tailscale.health[0]??"This machine is showing cached Tailnet peers, but the local Tailscale backend is not running."})]}),t.tailscale.available&&!t.tailscale.running&&o.jsxs("div",{className:"sys-inline-actions",children:[o.jsx("button",{type:"button",className:"s-btn",disabled:h,onClick:()=>{_()},children:h?"Opening Tailscale...":"Open Tailscale"}),o.jsx("button",{type:"button",className:"s-btn",disabled:h||l,onClick:()=>{A("manual")},children:l?"Refreshing...":"Refresh status"})]}),o.jsxs("div",{className:"sys-detail-grid",children:[o.jsxs("div",{className:"sys-detail-card",children:[o.jsx("span",{className:"sys-detail-label",children:"Who Am I"}),o.jsx("span",{className:"sys-detail-value",children:t.identity.name??t.localNode?.name??"Unavailable"})]}),o.jsxs("div",{className:"sys-detail-card",children:[o.jsx("span",{className:"sys-detail-label",children:"Node ID"}),o.jsx("code",{className:"sys-detail-value",children:t.identity.nodeId??"Unavailable"})]}),o.jsxs("div",{className:"sys-detail-card",children:[o.jsx("span",{className:"sys-detail-label",children:"Mesh"}),o.jsx("code",{className:"sys-detail-value",children:t.identity.meshId??"Unassigned"})]}),o.jsxs("div",{className:"sys-detail-card",children:[o.jsx("span",{className:"sys-detail-label",children:"Mode"}),o.jsx("span",{className:"sys-detail-value",children:t.identity.modeLabel})]}),o.jsxs("div",{className:"sys-detail-card",children:[o.jsx("span",{className:"sys-detail-label",children:"Discoverable"}),o.jsx("span",{className:"sys-detail-value",children:t.identity.discoverable?"Yes":"No"})]}),o.jsxs("div",{className:"sys-detail-card",children:[o.jsx("span",{className:"sys-detail-label",children:"Announced As"}),o.jsx("code",{className:"sys-detail-value",children:t.identity.announceUrl??"Not announced"})]})]}),o.jsxs("div",{className:`sys-banner ${t.identity.discoverable?"sys-banner-success":"sys-banner-muted"}`,children:[o.jsx("strong",{children:"How peers find you."}),o.jsx("span",{children:t.identity.discoveryDetail})]}),!t.identity.discoverable&&t.health.reachable&&o.jsx("div",{className:"sys-inline-actions",children:o.jsx("button",{type:"button",className:"s-btn",disabled:d,onClick:()=>{M()},children:d?"Announcing...":"Announce on mesh"})}),y&&o.jsxs("div",{className:`sys-banner ${y.tone==="success"?"sys-banner-success":"sys-banner-warning"}`,children:[o.jsx("strong",{children:y.title}),o.jsx("span",{children:y.message})]}),w&&o.jsxs("div",{className:`sys-banner ${w.tone==="success"?"sys-banner-success":"sys-banner-warning"}`,children:[o.jsx("strong",{children:w.title}),o.jsx("span",{children:w.message})]})]}),o.jsx("div",{className:"sys-stat-grid",children:$.map(L=>o.jsxs("div",{className:"sys-stat-card",children:[o.jsx("span",{className:"sys-stat-label",children:L.label}),o.jsx("strong",{className:"sys-stat-value",children:L.value}),o.jsx("span",{className:"sys-stat-detail",children:L.detail})]},L.label))}),o.jsxs("section",{className:"sys-panel",children:[o.jsx("div",{className:"sys-section-head",children:o.jsxs("div",{children:[o.jsx("h3",{className:"sys-section-title",children:"Health notices"}),o.jsx("p",{className:"sys-section-subtitle",children:"Warnings and errors from the current broker and discovery snapshot."})]})}),q.length>0?o.jsx("div",{className:"sys-issue-grid",children:q.map((L,F)=>o.jsx(zY,{issue:L},`${L.code}-${F}`))}):o.jsxs("div",{className:"sys-list-empty",children:[o.jsx("h3",{children:"No active mesh warnings"}),o.jsx("p",{children:"The broker is reachable and discovery inputs look healthy from this page."})]})]}),o.jsxs("section",{className:"sys-panel",children:[o.jsx("div",{className:"sys-section-head",children:o.jsxs("div",{children:[o.jsx("h3",{className:"sys-section-title",children:"Topology"}),o.jsx("p",{className:"sys-section-subtitle",children:"Current broker relationships plus visible tailnet peers from this machine."})]})}),t.localNode?o.jsx(CY,{mesh:t}):o.jsxs("div",{className:"sys-list-empty",children:[o.jsx("h3",{children:"Topology unavailable"}),o.jsx("p",{children:"A local node record is required before the topology view can render."})]})]}),o.jsxs("section",{className:"sys-panel",children:[o.jsx("div",{className:"sys-section-head",children:o.jsxs("div",{children:[o.jsx("h3",{className:"sys-section-title",children:"Discovered peers"}),o.jsxs("p",{className:"sys-section-subtitle",children:["Remote brokers registered in ",t.meshId??"this mesh","."]})]})}),H.length===0?o.jsxs("div",{className:"sys-list-empty",children:[o.jsx("h3",{children:"No remote brokers discovered"}),o.jsx("p",{children:"This can be normal on a single-node setup. If you expect peers, check the health notices above."})]}):o.jsx("div",{className:"sys-list-grid",children:H.map(L=>o.jsxs("article",{className:"sys-list-card",children:[o.jsxs("div",{className:"sys-list-card-head",children:[o.jsx("h3",{className:"sys-list-card-title",children:L.name}),o.jsx("span",{className:`sys-chip sys-chip-${L.advertiseScope==="mesh"?"success":"neutral"}`,children:_Y(L.advertiseScope)})]}),o.jsxs("div",{className:"sys-list-card-detail",children:[o.jsx("span",{className:"sys-detail-label",children:"Node id"}),o.jsx("code",{className:"sys-detail-value",children:L.id})]}),L.brokerUrl&&o.jsxs("div",{className:"sys-list-card-detail",children:[o.jsx("span",{className:"sys-detail-label",children:"Broker"}),o.jsx("code",{className:"sys-detail-value",children:L.brokerUrl})]}),o.jsxs("div",{className:"sys-list-card-detail",children:[o.jsx("span",{className:"sys-detail-label",children:"Last seen"}),o.jsx("span",{className:"sys-detail-value",children:L.lastSeenAt?De(L.lastSeenAt):"Recently registered"})]})]},L.id))})]}),o.jsxs("section",{className:"sys-panel",children:[o.jsx("div",{className:"sys-section-head",children:o.jsxs("div",{children:[o.jsx("h3",{className:"sys-section-title",children:"Tailnet"}),o.jsx("p",{className:"sys-section-subtitle",children:"External Tailscale peers visible from this machine."})]})}),W.length===0?o.jsxs("div",{className:"sys-list-empty",children:[o.jsx("h3",{children:"No external tailnet peers"}),o.jsx("p",{children:t.tailscale.available?t.tailscale.running?"Only this host is visible in the current tailnet snapshot.":"Tailscale is installed but currently stopped on this machine.":"Tailscale peers were not detected on this machine."})]}):o.jsx("div",{className:"sys-list-grid",children:W.map(L=>o.jsxs("article",{className:"sys-list-card",children:[o.jsxs("div",{className:"sys-list-card-head",children:[o.jsx("h3",{className:"sys-list-card-title",children:MY(L)}),o.jsx("span",{className:`sys-chip sys-chip-${L.online?"success":"failed"}`,children:L.online?"Online":"Offline"})]}),o.jsxs("div",{className:"sys-list-card-detail",children:[o.jsx("span",{className:"sys-detail-label",children:"Address"}),o.jsx("code",{className:"sys-detail-value",children:L.addresses?.[0]??"Unavailable"})]}),o.jsxs("div",{className:"sys-list-card-detail",children:[o.jsx("span",{className:"sys-detail-label",children:"Platform"}),o.jsx("span",{className:"sys-detail-value",children:L.os??"Unknown"})]})]},L.id))})]})]})]})}const $Y=[[/```[\s\S]*?```/g," "],[/`([^`]+)`/g,"$1"],[/!\[([^\]]*)\]\([^)]+\)/g,"$1"],[/\[([^\]]+)\]\([^)]+\)/g,"$1"],[/\*\*(.+?)\*\*/g,"$1"],[/__(.+?)__/g,"$1"],[new RegExp("(?<!\\*)\\*(?!\\*)([^*\\n]+)\\*(?!\\*)","g"),"$1"],[new RegExp("(?<!_)_(?!_)([^_\\n]+)_(?!_)","g"),"$1"],[/~~(.+?)~~/g,"$1"],[/^#{1,6}\s+/gm,""],[/^>\s?/gm,""],[/^[-*+]\s+/gm,""],[/^\d+\.\s+/gm,""],[/^---+\s*$/gm,""],[/^\s*\|.*\|\s*$/gm,""]];function UY(e,t=140){if(!e)return"";let n=e;for(const[s,a]of $Y)n=n.replace(s,a);return n=n.replace(/\s+/g," ").trim(),n.length>t&&(n=`${n.slice(0,t-1)}…`),n}function BY(){const e=window.getSelection();return e!==null&&e.toString().trim().length>0}function VY(e){BY()||e()}const WN={direct:"DM",channel:"Channel",group_direct:"Group",thread:"Thread"},FY=new Set(["all","direct","channel","group_direct","thread"]);function Yv(e){return typeof window>"u"?"":new URLSearchParams(window.location.search).get(e)??""}function HY(e){if(typeof window>"u")return;const t=new URLSearchParams(window.location.search);for(const[s,a]of Object.entries(e))a===null||a===""?t.delete(s):t.set(s,a);const n=t.toString();window.history.replaceState(null,"",window.location.pathname+(n?`?${n}`:""))}function qY(){const e=Yv("view");return FY.has(e)?e:"all"}function ZY(e){return e.kind==="direct"&&e.agentName?e.agentName:e.title.replace(/\s*<>\s*/g," · ")}function WY(e){return e.trim().toLowerCase()}function YY(e){return[e.id,e.title,e.preview??"",e.agentName??"",e.harness??"",e.harnessSessionId??"",e.harnessLogPath??"",...e.participantIds]}function YN(e,t){if(!t)return null;const n=e.harnessSessionId?.trim();return n&&n.toLowerCase().includes(t)?n:null}function GY(e){if(!e)return null;const t=e.replace(/[\\/]+$/,"");return t?t.split(/[\\/]/).filter(Boolean).at(-1)??t:null}function KY(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return"";const t=e<1e12?e*1e3:e;return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(t)}function XY({navigate:e}){const[t,n]=g.useState([]),[s,a]=g.useState(()=>qY()),[l,u]=g.useState(()=>Yv("q")),[d,p]=g.useState(()=>Yv("unread")==="1"),[h,m]=g.useState(()=>fb()),[y,x]=g.useState(0),[w,j]=g.useState(null),N=g.useRef(null),k=g.useRef(null),E=bh(),C=g.useCallback(async()=>{j(null);try{const D=await Re("/api/sessions");n(D.sort((H,W)=>(W.lastMessageAt??0)-(H.lastMessageAt??0)))}catch(D){j(D instanceof Error?D.message:String(D))}},[]);g.useEffect(()=>{C()},[C]),Rn(()=>{C()});const[,S]=g.useState(0);g.useEffect(()=>{const D=setInterval(()=>S(H=>H+1),15e3);return()=>clearInterval(D)},[]),g.useEffect(()=>{HY({view:s==="all"?null:s,q:l.trim()||null,unread:d?"1":null})},[s,l,d]);const R=g.useMemo(()=>Array.from(new Set(t.map(D=>D.kind))),[t]),A=g.useMemo(()=>{const D={all:t.length};for(const H of t)D[H.kind]=(D[H.kind]??0)+1;return D},[t]),M=g.useMemo(()=>WY(l),[l]),_=g.useMemo(()=>t.filter(D=>kg(D.lastMessageAt,D.id,h)).length,[t,h]),z=g.useMemo(()=>t.filter(D=>!(s!=="all"&&D.kind!==s||d&&!kg(D.lastMessageAt,D.id,h)||M&&!YY(D).some(W=>W.toLowerCase().includes(M)))),[t,s,d,h,M]);g.useEffect(()=>{y>=z.length&&x(Math.max(0,z.length-1))},[z.length,y]);const V=g.useCallback((D,H={})=>{if(m(iW(D.id)),H.observe&&D.agentId){e({view:"agents",agentId:D.agentId,conversationId:D.id,tab:"observe"});return}e({view:"conversation",conversationId:D.id})},[e]);g.useEffect(()=>{function D(H){const W=H.target,q=W instanceof HTMLInputElement||W instanceof HTMLTextAreaElement||W instanceof HTMLElement&&W.isContentEditable;if((H.metaKey||H.ctrlKey)&&H.key.toLowerCase()==="k"){H.preventDefault(),N.current?.focus(),N.current?.select();return}if(q){H.key==="Escape"&&W===N.current&&N.current?.blur();return}if(H.key==="/"){H.preventDefault(),N.current?.focus();return}if(H.key==="j"||H.key==="ArrowDown"){H.preventDefault(),x($=>Math.min(z.length-1,$+1));return}if(H.key==="k"||H.key==="ArrowUp"){H.preventDefault(),x($=>Math.max(0,$-1));return}if(H.key==="Enter"||H.key==="o"){const $=z[y];$&&(H.preventDefault(),V($,{observe:!!YN($,M)}))}}return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[z,y,V,M]),g.useEffect(()=>{k.current?.querySelector(`[data-idx="${y}"]`)?.scrollIntoView({block:"nearest"})},[y]);const U=R.length>1,O=d?_>0?`${_} unread threads need attention.`:"No unread threads right now.":z.length===t.length?"Recent activity across every conversation.":`${z.length} conversations match the current filters.`;return o.jsxs("div",{className:"s-sessions-screen s-inbox-thread-redesign",children:[o.jsx("section",{className:"s-thread-overview",children:o.jsxs("div",{className:"s-thread-overview-copy",children:[o.jsxs("div",{className:"s-sessions-header s-thread-overview-heading",children:[o.jsx("h2",{className:"s-page-title",children:"Sessions"}),o.jsxs("span",{className:"s-meta s-tabular",children:[z.length," of ",t.length]})]}),o.jsx("p",{className:"s-thread-overview-summary",children:O})]})}),o.jsxs("section",{className:"s-thread-panel s-thread-panel-list",children:[o.jsxs("div",{className:"s-sessions-toolbar",children:[U&&o.jsxs("div",{className:"s-seg",role:"tablist","aria-label":"Session kind",children:[o.jsx(GN,{label:"All",count:A.all,pressed:s==="all",onClick:()=>a("all")}),R.map(D=>o.jsx(GN,{label:WN[D]??D,count:A[D]??0,pressed:s===D,onClick:()=>a(D)},D))]}),o.jsxs("button",{type:"button",className:`s-seg-standalone${d?" is-on":""}`,onClick:()=>p(D=>!D),"aria-pressed":d,title:"Show unread only",children:[o.jsx("span",{className:"s-dot s-dot-sm","aria-hidden":"true"}),o.jsx("span",{children:"Unread"}),_>0&&o.jsx("span",{className:"s-seg-count",children:_})]}),o.jsxs("div",{className:"s-search",children:[o.jsx("input",{ref:N,type:"text",className:"s-search-input",placeholder:"Search conversations or session IDs…",value:l,onChange:D=>u(D.target.value),onKeyDown:D=>{D.key==="Escape"&&(l?u(""):D.target.blur())}}),o.jsx("kbd",{className:"s-search-kbd",children:"⌘K"})]})]}),w&&o.jsx("p",{className:"s-error",children:w}),z.length===0?o.jsxs("div",{className:"s-empty s-thread-empty-state",children:[o.jsx("p",{children:l||d?"No matches":"No conversations"}),o.jsx("p",{children:l?"Try a different search term.":d?"You're all caught up.":"Conversations appear here when agents communicate."})]}):o.jsx("div",{className:"s-inbox",ref:k,role:"listbox","aria-label":"Sessions",children:z.map((D,H)=>{const W=ZY(D),q=(D.agentName??W)[0]?.toUpperCase()??"?",$=kg(D.lastMessageAt,D.id,h),L=H===y,F=UY(D.preview,160),X=WN[D.kind]??D.kind,G=GY(D.workspaceRoot),I=YN(D,M);return o.jsxs("div",{"data-idx":H,"data-unread":$?"true":"false","data-selected":L?"true":"false",className:"s-inbox-row",role:"option","aria-selected":L,tabIndex:L?0:-1,onClick:()=>{VY(()=>{x(H),V(D,{observe:!!I})})},onMouseEnter:()=>x(H),onContextMenu:B=>{const Y=window.getSelection()?.toString().trim(),Q=[];Y&&(Q.push({kind:"action",label:"Copy Selection",shortcut:"⌘C",onSelect:()=>navigator.clipboard.writeText(Y)}),Q.push({kind:"separator"})),Q.push({kind:"action",label:"Open Conversation",onSelect:()=>V(D)}),D.agentId&&Q.push({kind:"action",label:"Open Observe",onSelect:()=>V(D,{observe:!0})}),Q.push({kind:"action",label:"Copy Title",onSelect:()=>navigator.clipboard.writeText(W)}),D.id&&Q.push({kind:"action",label:"Copy Conversation ID",onSelect:()=>navigator.clipboard.writeText(D.id)});const me=D.harnessSessionId;me&&Q.push({kind:"action",label:"Copy Harness Session ID",onSelect:()=>navigator.clipboard.writeText(me)}),E(B,Q)},children:[o.jsxs("div",{className:"s-session-avatar-wrap",children:[o.jsx("div",{className:"s-avatar",style:{background:mt(D.agentName??W)},"aria-hidden":"true",children:q}),$&&o.jsx("span",{className:"s-session-unread-dot","aria-hidden":"true"})]}),o.jsxs("div",{className:"s-inbox-body",children:[o.jsxs("div",{className:"s-inbox-header",children:[o.jsx("div",{className:"s-session-heading",children:o.jsx("span",{className:"s-inbox-name",title:W,children:W})}),o.jsx("div",{className:"s-session-trailing",children:D.lastMessageAt&&o.jsx("span",{className:"s-inbox-time s-tabular",title:KY(D.lastMessageAt),children:De(D.lastMessageAt)})})]}),F?o.jsx("p",{className:"s-inbox-preview",children:F}):o.jsx("p",{className:"s-inbox-preview s-inbox-preview-empty",children:"No messages yet"}),o.jsxs("div",{className:"s-session-meta-row","aria-label":"Conversation details",children:[o.jsx("span",{className:"s-session-pill",children:X}),I&&o.jsxs("span",{className:"s-session-pill",title:I,children:["session · ",I]}),G&&o.jsx("span",{className:"s-session-pill",title:D.workspaceRoot??void 0,children:G}),D.currentBranch&&o.jsx("span",{className:"s-session-pill",title:D.currentBranch,children:D.currentBranch})]})]})]},D.id)})})]})]})}function GN({label:e,count:t,pressed:n,onClick:s}){return o.jsxs("button",{type:"button",className:"s-seg-btn","aria-pressed":n,onClick:s,children:[o.jsx("span",{children:e}),o.jsx("span",{className:"s-seg-count",children:t})]})}var ci=(e=>(e[e.Border=-1]="Border",e[e.Data=0]="Data",e[e.Function=1]="Function",e[e.Position=2]="Position",e[e.Timing=3]="Timing",e[e.Alignment=4]="Alignment",e))(ci||{});const JY=[0,1],JR=[1,0],QR=[2,3],eM=[3,2],QY={L:JY,M:JR,Q:QR,H:eM},eG=/^\d*$/,tG=/^[A-Z0-9 $%*+./:-]*$/,_g="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",hb=1,pb=40,KN=3,nG=3,zd=40,sG=10,tM=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],nM=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]];class rG{constructor(t,n,s,a){if(this.version=t,this.ecc=n,t<hb||t>pb)throw new RangeError("Version value out of range");if(a<-1||a>7)throw new RangeError("Mask value out of range");this.size=t*4+17;const l=Array.from({length:this.size}).fill(!1);for(let d=0;d<this.size;d++)this.modules.push(l.slice()),this.types.push(l.map(()=>0));this.drawFunctionPatterns();const u=this.addEccAndInterleave(s);if(this.drawCodewords(u),a===-1){let d=1e9;for(let p=0;p<8;p++){this.applyMask(p),this.drawFormatBits(p);const h=this.getPenaltyScore();h<d&&(a=p,d=h),this.applyMask(p)}}this.mask=a,this.applyMask(a),this.drawFormatBits(a)}size;mask;modules=[];types=[];getModule(t,n){return t>=0&&t<this.size&&n>=0&&n<this.size&&this.modules[n][t]}drawFunctionPatterns(){for(let s=0;s<this.size;s++)this.setFunctionModule(6,s,s%2===0,ci.Timing),this.setFunctionModule(s,6,s%2===0,ci.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const t=this.getAlignmentPatternPositions(),n=t.length;for(let s=0;s<n;s++)for(let a=0;a<n;a++)s===0&&a===0||s===0&&a===n-1||s===n-1&&a===0||this.drawAlignmentPattern(t[s],t[a]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(t){const n=this.ecc[1]<<3|t;let s=n;for(let l=0;l<10;l++)s=s<<1^(s>>>9)*1335;const a=(n<<10|s)^21522;for(let l=0;l<=5;l++)this.setFunctionModule(8,l,_r(a,l));this.setFunctionModule(8,7,_r(a,6)),this.setFunctionModule(8,8,_r(a,7)),this.setFunctionModule(7,8,_r(a,8));for(let l=9;l<15;l++)this.setFunctionModule(14-l,8,_r(a,l));for(let l=0;l<8;l++)this.setFunctionModule(this.size-1-l,8,_r(a,l));for(let l=8;l<15;l++)this.setFunctionModule(8,this.size-15+l,_r(a,l));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let t=this.version;for(let s=0;s<12;s++)t=t<<1^(t>>>11)*7973;const n=this.version<<12|t;for(let s=0;s<18;s++){const a=_r(n,s),l=this.size-11+s%3,u=Math.floor(s/3);this.setFunctionModule(l,u,a),this.setFunctionModule(u,l,a)}}drawFinderPattern(t,n){for(let s=-4;s<=4;s++)for(let a=-4;a<=4;a++){const l=Math.max(Math.abs(a),Math.abs(s)),u=t+a,d=n+s;u>=0&&u<this.size&&d>=0&&d<this.size&&this.setFunctionModule(u,d,l!==2&&l!==4,ci.Position)}}drawAlignmentPattern(t,n){for(let s=-2;s<=2;s++)for(let a=-2;a<=2;a++)this.setFunctionModule(t+a,n+s,Math.max(Math.abs(a),Math.abs(s))!==1,ci.Alignment)}setFunctionModule(t,n,s,a=ci.Function){this.modules[n][t]=s,this.types[n][t]=a}addEccAndInterleave(t){const n=this.version,s=this.ecc;if(t.length!==cf(n,s))throw new RangeError("Invalid argument");const a=nM[s[0]][n],l=tM[s[0]][n],u=Math.floor(Gv(n)/8),d=a-u%a,p=Math.floor(u/a),h=[],m=hG(l);for(let x=0,w=0;x<a;x++){const j=t.slice(w,w+p-l+(x<d?0:1));w+=j.length;const N=pG(j,m);x<d&&j.push(0),h.push(j.concat(N))}const y=[];for(let x=0;x<h[0].length;x++)h.forEach((w,j)=>{(x!==p-l||j>=d)&&y.push(w[x])});return y}drawCodewords(t){if(t.length!==Math.floor(Gv(this.version)/8))throw new RangeError("Invalid argument");let n=0;for(let s=this.size-1;s>=1;s-=2){s===6&&(s=5);for(let a=0;a<this.size;a++)for(let l=0;l<2;l++){const u=s-l,p=(s+1&2)===0?this.size-1-a:a;!this.types[p][u]&&n<t.length*8&&(this.modules[p][u]=_r(t[n>>>3],7-(n&7)),n++)}}}applyMask(t){if(t<0||t>7)throw new RangeError("Mask value out of range");for(let n=0;n<this.size;n++)for(let s=0;s<this.size;s++){let a;switch(t){case 0:a=(s+n)%2===0;break;case 1:a=n%2===0;break;case 2:a=s%3===0;break;case 3:a=(s+n)%3===0;break;case 4:a=(Math.floor(s/3)+Math.floor(n/2))%2===0;break;case 5:a=s*n%2+s*n%3===0;break;case 6:a=(s*n%2+s*n%3)%2===0;break;case 7:a=((s+n)%2+s*n%3)%2===0;break;default:throw new Error("Unreachable")}!this.types[n][s]&&a&&(this.modules[n][s]=!this.modules[n][s])}}getPenaltyScore(){let t=0;for(let l=0;l<this.size;l++){let u=!1,d=0;const p=[0,0,0,0,0,0,0];for(let h=0;h<this.size;h++)this.modules[l][h]===u?(d++,d===5?t+=KN:d>5&&t++):(this.finderPenaltyAddHistory(d,p),u||(t+=this.finderPenaltyCountPatterns(p)*zd),u=this.modules[l][h],d=1);t+=this.finderPenaltyTerminateAndCount(u,d,p)*zd}for(let l=0;l<this.size;l++){let u=!1,d=0;const p=[0,0,0,0,0,0,0];for(let h=0;h<this.size;h++)this.modules[h][l]===u?(d++,d===5?t+=KN:d>5&&t++):(this.finderPenaltyAddHistory(d,p),u||(t+=this.finderPenaltyCountPatterns(p)*zd),u=this.modules[h][l],d=1);t+=this.finderPenaltyTerminateAndCount(u,d,p)*zd}for(let l=0;l<this.size-1;l++)for(let u=0;u<this.size-1;u++){const d=this.modules[l][u];d===this.modules[l][u+1]&&d===this.modules[l+1][u]&&d===this.modules[l+1][u+1]&&(t+=nG)}let n=0;for(const l of this.modules)n=l.reduce((u,d)=>u+(d?1:0),n);const s=this.size*this.size,a=Math.ceil(Math.abs(n*20-s*10)/s)-1;return t+=a*sG,t}getAlignmentPatternPositions(){if(this.version===1)return[];{const t=Math.floor(this.version/7)+2,n=this.version===32?26:Math.ceil((this.version*4+4)/(t*2-2))*2,s=[6];for(let a=this.size-7;s.length<t;a-=n)s.splice(1,0,a);return s}}finderPenaltyCountPatterns(t){const n=t[1],s=n>0&&t[2]===n&&t[3]===n*3&&t[4]===n&&t[5]===n;return(s&&t[0]>=n*4&&t[6]>=n?1:0)+(s&&t[6]>=n*4&&t[0]>=n?1:0)}finderPenaltyTerminateAndCount(t,n,s){return t&&(this.finderPenaltyAddHistory(n,s),n=0),n+=this.size,this.finderPenaltyAddHistory(n,s),this.finderPenaltyCountPatterns(s)}finderPenaltyAddHistory(t,n){n[0]===0&&(t+=this.size),n.pop(),n.unshift(t)}}function zr(e,t,n){if(t<0||t>31||e>>>t)throw new RangeError("Value out of range");for(let s=t-1;s>=0;s--)n.push(e>>>s&1)}function _r(e,t){return(e>>>t&1)!==0}class mb{constructor(t,n,s){if(this.mode=t,this.numChars=n,this.bitData=s,n<0)throw new RangeError("Invalid argument");this.bitData=s.slice()}getData(){return this.bitData.slice()}}const aG=[1,10,12,14],iG=[2,9,11,13],oG=[4,8,16,16];function sM(e,t){return e[Math.floor((t+7)/17)+1]}function rM(e){const t=[];for(const n of e)zr(n,8,t);return new mb(oG,e.length,t)}function lG(e){if(!aM(e))throw new RangeError("String contains non-numeric characters");const t=[];for(let n=0;n<e.length;){const s=Math.min(e.length-n,3);zr(Number.parseInt(e.substring(n,n+s),10),s*3+1,t),n+=s}return new mb(aG,e.length,t)}function cG(e){if(!iM(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");const t=[];let n;for(n=0;n+2<=e.length;n+=2){let s=_g.indexOf(e.charAt(n))*45;s+=_g.indexOf(e.charAt(n+1)),zr(s,11,t)}return n<e.length&&zr(_g.indexOf(e.charAt(n)),6,t),new mb(iG,e.length,t)}function uG(e){return e===""?[]:aM(e)?[lG(e)]:iM(e)?[cG(e)]:[rM(fG(e))]}function aM(e){return eG.test(e)}function iM(e){return tG.test(e)}function dG(e,t){let n=0;for(const s of e){const a=sM(s.mode,t);if(s.numChars>=1<<a)return Number.POSITIVE_INFINITY;n+=4+a+s.bitData.length}return n}function fG(e){e=encodeURI(e);const t=[];for(let n=0;n<e.length;n++)e.charAt(n)!=="%"?t.push(e.charCodeAt(n)):(t.push(Number.parseInt(e.substring(n+1,n+3),16)),n+=2);return t}function Gv(e){if(e<hb||e>pb)throw new RangeError("Version number out of range");let t=(16*e+128)*e+64;if(e>=2){const n=Math.floor(e/7)+2;t-=(25*n-10)*n-55,e>=7&&(t-=36)}return t}function cf(e,t){return Math.floor(Gv(e)/8)-tM[t[0]][e]*nM[t[0]][e]}function hG(e){if(e<1||e>255)throw new RangeError("Degree out of range");const t=[];for(let s=0;s<e-1;s++)t.push(0);t.push(1);let n=1;for(let s=0;s<e;s++){for(let a=0;a<t.length;a++)t[a]=Kv(t[a],n),a+1<t.length&&(t[a]^=t[a+1]);n=Kv(n,2)}return t}function pG(e,t){const n=t.map(s=>0);for(const s of e){const a=s^n.shift();n.push(0),t.forEach((l,u)=>n[u]^=Kv(l,a))}return n}function Kv(e,t){if(e>>>8||t>>>8)throw new RangeError("Byte out of range");let n=0;for(let s=7;s>=0;s--)n=n<<1^(n>>>7)*285,n^=(t>>>s&1)*e;return n}function mG(e,t,n=1,s=40,a=-1,l=!0){if(!(hb<=n&&n<=s&&s<=pb)||a<-1||a>7)throw new RangeError("Invalid value");let u,d;for(u=n;;u++){const y=cf(u,t)*8,x=dG(e,u);if(x<=y){d=x;break}if(u>=s)throw new RangeError("Data too long")}for(const y of[JR,QR,eM])l&&d<=cf(u,y)*8&&(t=y);const p=[];for(const y of e){zr(y.mode[0],4,p),zr(y.numChars,sM(y.mode,u),p);for(const x of y.getData())p.push(x)}const h=cf(u,t)*8;zr(0,Math.min(4,h-p.length),p),zr(0,(8-p.length%8)%8,p);for(let y=236;p.length<h;y^=253)zr(y,8,p);const m=Array.from({length:Math.ceil(p.length/8)},()=>0);return p.forEach((y,x)=>m[x>>>3]|=y<<7-(x&7)),new rG(u,t,m,a)}function gG(e,t){const{ecc:n="L",boostEcc:s=!1,minVersion:a=1,maxVersion:l=40,maskPattern:u=-1,border:d=1}=t||{},p=typeof e=="string"?uG(e):Array.isArray(e)?[rM(e)]:void 0;if(!p)throw new Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);const h=mG(p,QY[n],a,l,u,s),m=vG({version:h.version,maskPattern:h.mask,size:h.size,data:h.modules,types:h.types},d);return t?.invert&&(m.data=m.data.map(y=>y.map(x=>!x))),t?.onEncoded?.(m),m}function vG(e,t=1){if(!t)return e;const{size:n}=e,s=n+t*2;e.size=s,e.data.forEach(l=>{for(let u=0;u<t;u++)l.unshift(!1),l.push(!1)});for(let l=0;l<t;l++)e.data.unshift(Array.from({length:s},u=>!1)),e.data.push(Array.from({length:s},u=>!1));const a=ci.Border;e.types.forEach(l=>{for(let u=0;u<t;u++)l.unshift(a),l.push(a)});for(let l=0;l<t;l++)e.types.unshift(Array.from({length:s},u=>a)),e.types.push(Array.from({length:s},u=>a));return e}function XN(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function yG(e,t={}){const n=gG(e,t),{pixelSize:s=10,whiteColor:a="white",blackColor:l="black"}=t,u=n.size*s,d=n.size*s;let p=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${d} ${u}">`;const h=[];for(let m=0;m<n.size;m++)for(let y=0;y<n.size;y++){const x=y*s,w=m*s;n.data[m][y]&&h.push(`M${x},${w}h${s}v${s}h-${s}z`)}return p+=`<rect fill="${XN(a)}" width="${d}" height="${u}"/>`,p+=`<path fill="${XN(l)}" d="${h.join("")}"/>`,p+="</svg>",p}function bG(e){return e?e.replace(/^wss?:\/\//,"").replace(/:\d+$/,""):null}function JN(e){return e?e.length<=18?e:`${e.slice(0,10)}...${e.slice(-6)}`:null}function xG(e){return e?e.status==="paired"||e.status==="connected"?"success":e.status==="error"||e.status==="closed"?"danger":"warning":"warning"}function wG(e,t){if(!e)return null;const n=Math.max(0,Math.floor((e-t)/1e3));if(n===0)return null;if(n<60)return`${n}s`;const s=Math.floor(n/60),a=n%60;return a>0?`${s}m ${a}s`:`${s}m`}function QN({value:e}){const[t,n]=g.useState(!1),s=g.useCallback(()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),1500)})},[e]);return o.jsx("button",{type:"button",className:"sys-copy-btn",onClick:s,title:"Copy",children:t?o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("polyline",{points:"20 6 9 17 4 12"})}):o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),o.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})}function jG({navigate:e}){const[t,n]=g.useState(null),[s,a]=g.useState(""),[l,u]=g.useState(""),[d,p]=g.useState(!0),[h,m]=g.useState(!1),[y,x]=g.useState(!1),[w,j]=g.useState(null),[N,k]=g.useState(null),[E,C]=g.useState(null),[S,R]=g.useState(null),[A,M]=g.useState(()=>Date.now()),[_,z]=g.useState(null),V=g.useRef(null),U=g.useRef(0),O=g.useRef(null);g.useEffect(()=>{V.current=t},[t]),g.useEffect(()=>{O.current=w},[w]);const D=g.useCallback(async(re="initial")=>{if(re==="background"&&O.current)return;const ie=++U.current;!(V.current!==null)&&re!=="background"?(p(!0),k(null)):m(!0);try{const ye=await Re(re==="manual"?"/api/pairing-state/refresh":"/api/pairing-state");if(ie!==U.current)return;n(ye),k(null),R(Date.now())}catch(ye){if(ie!==U.current)return;k(ye instanceof Error?ye.message:String(ye))}finally{ie===U.current&&(p(!1),m(!1))}},[]),H=g.useCallback(async()=>{try{const re=await Re("/api/user");u(re.name),a(re.name),C(null)}catch(re){C(re instanceof Error?re.message:String(re))}},[]),W=g.useRef(!1);g.useEffect(()=>{D("initial"),H()},[D,H]),g.useEffect(()=>{const re=setInterval(()=>{D("background")},1e4);return()=>clearInterval(re)},[D]),g.useEffect(()=>{if(!t?.pairing?.expiresAt)return;M(Date.now());const re=setInterval(()=>{M(Date.now())},1e3);return()=>clearInterval(re)},[t?.pairing?.expiresAt]);const q=g.useCallback(async()=>{x(!0),C(null);try{const re=await Re("/api/user",{method:"POST",body:JSON.stringify({name:s})});u(re.name),a(re.name)}catch(re){C(re instanceof Error?re.message:String(re))}finally{x(!1)}},[s]),$=g.useCallback(async re=>{const ie=++U.current;j(re),k(null);try{const de=await Re("/api/pairing/control",{method:"POST",body:JSON.stringify({action:re})});if(ie!==U.current)return;n(de),R(Date.now())}catch(de){if(ie!==U.current)return;k(de instanceof Error?de.message:String(de))}finally{ie===U.current&&j(null)}},[]);g.useEffect(()=>{!t||t.isRunning||W.current||(W.current=!0,$("start"))},[t,$]);const L=g.useCallback(async re=>{z(re);try{await Re(`/api/pairing/peers/${encodeURIComponent(re)}`,{method:"DELETE"}),D("manual")}catch{}finally{z(null)}},[D]),F=g.useMemo(()=>{const re=t?.pairing?.qrValue?.trim();return re?yG(re,{border:2,ecc:"M",pixelSize:8}):null},[t?.pairing?.qrValue]),X=bG(t?.pairing?.relay??t?.relay??null),G=wG(t?.pairing?.expiresAt,A),B=(t?.trustedPeers.find(re=>re.fingerprint===t.connectedPeerFingerprint)??null)?.name??JN(t?.connectedPeerFingerprint??null),Y=xG(t),Q=s.trim()!==l,me=!d&&!t&&!!N;return o.jsxs("div",{className:"sys-surface-page sys-settings-page",children:[o.jsxs("div",{className:"sys-page-head",children:[o.jsxs("div",{className:"sys-page-title-group",children:[o.jsx("h2",{className:"sys-page-title",children:"Settings"}),o.jsx("p",{className:"sys-page-subtitle",children:"Identity, pairing, and trusted devices."})]}),o.jsxs("div",{className:"sys-page-actions",children:[t&&o.jsx("span",{className:`sys-chip sys-chip-${Y}`,children:t.statusLabel}),o.jsx("div",{className:"sys-sync-note",children:d?"Loading...":N&&t?`Snapshot from ${S?De(S):"earlier"}`:S?`Updated ${De(S)}`:""}),o.jsx("button",{type:"button",className:"s-btn",disabled:d||h||!!w,onClick:()=>{D("manual")},children:h?"Refreshing...":"Refresh"})]})]}),N&&t&&o.jsxs("div",{className:"sys-banner sys-banner-warning",children:[o.jsx("strong",{children:"Refresh failed."}),o.jsx("span",{children:N})]}),E&&o.jsxs("div",{className:"sys-banner sys-banner-warning",children:[o.jsx("strong",{children:"Identity error."}),o.jsx("span",{children:E})]}),d&&!t&&o.jsxs("div",{className:"sys-panel sys-state-card",children:[o.jsx("h3",{className:"sys-state-title",children:"Loading settings"}),o.jsx("p",{className:"sys-state-body",children:"Checking relay status and trusted peers."})]}),me&&o.jsxs("div",{className:"sys-panel sys-state-card sys-state-card-error",children:[o.jsx("h3",{className:"sys-state-title",children:"Pairing unavailable"}),o.jsx("p",{className:"sys-state-body",children:N}),o.jsx("div",{className:"sys-inline-actions",children:o.jsx("button",{type:"button",className:"s-btn",onClick:()=>{D("manual")},children:"Try again"})})]}),o.jsxs("div",{className:"sys-settings-hero",children:[o.jsx("div",{className:"sys-settings-qr-col",children:F?o.jsxs("div",{className:"sys-settings-qr-frame",children:[o.jsx("div",{className:"s-qr",dangerouslySetInnerHTML:{__html:F}}),G&&o.jsxs("span",{className:"sys-settings-qr-expires",children:["Expires in ",G]})]}):o.jsx("div",{className:"sys-settings-qr-empty",children:o.jsx("span",{className:"sys-settings-qr-empty-label",children:"Generating QR..."})})}),o.jsxs("div",{className:"sys-settings-info-col",children:[o.jsxs("div",{className:"sys-input-row",children:[o.jsx("input",{className:"sys-input",type:"text",placeholder:"Your name",value:s,onChange:re=>a(re.target.value),onKeyDown:re=>{re.key==="Enter"&&Q&&!y&&q()}}),o.jsx("button",{type:"button",className:"s-btn s-btn-primary",disabled:!Q||y,onClick:()=>{q()},children:y?"Saving...":"Save"})]}),o.jsxs("div",{className:"sys-settings-kv-list",children:[t?.identityFingerprint&&o.jsxs("div",{className:"sys-settings-kv",children:[o.jsx("span",{className:"sys-settings-kv-label",children:"Fingerprint"}),o.jsxs("span",{className:"sys-settings-kv-value",children:[o.jsx("code",{children:t.identityFingerprint}),o.jsx(QN,{value:t.identityFingerprint})]})]}),X&&o.jsxs("div",{className:"sys-settings-kv",children:[o.jsx("span",{className:"sys-settings-kv-label",children:"Relay"}),o.jsxs("span",{className:"sys-settings-kv-value",children:[o.jsx("code",{children:X}),o.jsx(QN,{value:X})]})]}),t?.statusDetail&&o.jsxs("div",{className:"sys-settings-kv",children:[o.jsx("span",{className:"sys-settings-kv-label",children:"Status"}),o.jsx("span",{className:"sys-settings-kv-value sys-settings-kv-nowrap",children:t.statusDetail})]}),B&&o.jsxs("div",{className:"sys-settings-kv",children:[o.jsx("span",{className:"sys-settings-kv-label",children:"Connected"}),o.jsx("span",{className:"sys-settings-kv-value",children:B})]}),t?.secure&&o.jsxs("div",{className:"sys-settings-kv",children:[o.jsx("span",{className:"sys-settings-kv-label",children:"Security"}),o.jsx("span",{className:"sys-settings-kv-value",children:o.jsx("span",{className:"sys-chip sys-chip-success",children:"Noise XX"})})]})]}),t&&o.jsx("div",{className:"sys-inline-actions sys-settings-controls",children:t.isRunning?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"s-btn",disabled:!!w,onClick:()=>{$("restart")},children:w==="restart"?"Restarting...":"Restart"}),o.jsx("button",{type:"button",className:"s-btn",disabled:!!w,onClick:()=>{$("stop")},children:w==="stop"?"Stopping...":"Stop"})]}):o.jsx("button",{type:"button",className:"s-btn s-btn-primary",disabled:!!w,onClick:()=>{$("start")},children:w==="start"?"Starting...":"Start pairing"})})]})]}),t&&o.jsxs("section",{className:"sys-settings-peers",children:[o.jsx("div",{className:"sys-section-head",children:o.jsxs("div",{children:[o.jsx("h3",{className:"sys-section-title",children:"Trusted peers"}),o.jsxs("p",{className:"sys-section-subtitle",children:[t.trustedPeers.length," device",t.trustedPeers.length!==1?"s":""," paired with this broker."]})]})}),t.trustedPeers.length===0?o.jsxs("div",{className:"sys-list-empty",children:[o.jsx("h3",{children:"No trusted peers"}),o.jsx("p",{children:"Devices appear here after completing pairing."})]}):o.jsxs("table",{className:"sys-peers-table",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{children:"Device"}),o.jsx("th",{children:"Fingerprint"}),o.jsx("th",{children:"Paired"}),o.jsx("th",{children:"Last seen"}),o.jsx("th",{})]})}),o.jsx("tbody",{children:t.trustedPeers.map(re=>{const ie=re.fingerprint===t.connectedPeerFingerprint;return o.jsxs("tr",{className:ie?"sys-peers-row-connected":"",children:[o.jsx("td",{children:o.jsxs("span",{className:"sys-peers-name",children:[re.name??JN(re.fingerprint)??"Peer",ie&&o.jsx("span",{className:"sys-chip sys-chip-success sys-peers-badge",children:"Connected"})]})}),o.jsx("td",{children:o.jsx("code",{className:"sys-peers-fp",children:re.fingerprint})}),o.jsx("td",{children:re.pairedAtLabel??"—"}),o.jsx("td",{children:re.lastSeenLabel??"—"}),o.jsx("td",{children:o.jsx("button",{type:"button",className:"sys-peers-remove",disabled:_===re.fingerprint,onClick:()=>{L(re.fingerprint)},title:"Remove peer",children:_===re.fingerprint?"...":"Remove"})})]},re.fingerprint)})})]})]})]})}const SG=2500,NG=1e4;function oM(e){const[t,n]=g.useState({}),s=g.useRef(!0),a=g.useRef(!1),l=g.useRef(!1),u=e.map(h=>h.id.trim()).filter(h=>h.length>0).join(","),d=e.some(h=>et(h.state)==="working")?SG:NG,p=g.useCallback(async()=>{if(e.length===0){n({});return}if(a.current){l.current=!0;return}a.current=!0;try{const h=u?`?ids=${encodeURIComponent(u)}`:"",m=await Re(`/api/observe/agents${h}`);if(!s.current)return;n(y=>{const x={};for(const w of e)x[w.id]=y[w.id];for(const w of m){const{agentId:j,...N}=w;x[j]=N}return x})}finally{a.current=!1,l.current&&(l.current=!1,p())}},[u,e]);return g.useEffect(()=>{if(s.current=!0,e.length===0)return n({}),()=>{s.current=!1};p();const h=setInterval(()=>{p()},d);return()=>{s.current=!1,clearInterval(h)}},[e.length,p,d]),t}function ya(e){switch(e.kind){case"tool":return`${e.tool??"tool"} ${e.arg??""}`.trim();case"think":return e.text.slice(0,120);case"ask":return`ask: ${e.text}`.slice(0,120);case"message":return e.text.slice(0,100);case"note":return e.text.slice(0,100);case"system":case"boot":return e.text.slice(0,100)}}const pc=340,Hf=220,xo=16,kG=48,EG=36,ek=28,Ld=40,lM=180,cM=140;function CG(e){const t=TG(e);if(t.length===0)return{groups:[],canvasW:0,canvasH:0};const n=Math.max(1,Math.round(Math.sqrt(t.length*1.4))),s=[],a=new Array(n).fill(Ld),l=Array.from({length:n},(p,h)=>Ld+h*(pc*2+xo+kG));for(const p of t){const h=a.indexOf(Math.min(...a)),m=l[h],y=a[h],x=Math.min(2,p.agents.length),w=Math.ceil(p.agents.length/x),j=x*pc+(x-1)*xo,N=ek+w*Hf+(w-1)*xo,k=p.agents.map((E,C)=>{const S=C%x,R=Math.floor(C/x);return{agentId:E.id,x:m+S*(pc+xo),y:y+ek+R*(Hf+xo)}});s.push({label:p.label,x:m,y,w:j,h:N,tiles:k}),a[h]=y+N+EG}const u=Math.max(...l.map((p,h)=>p+pc*2+xo))+Ld,d=Math.max(...a)+Ld;return{groups:s,canvasW:u,canvasH:d}}function TG(e){const t={working:0,available:1,offline:2},n=[...e].sort((l,u)=>{const d=t[et(l.state)]??1,p=t[et(u.state)]??1;return d!==p?d-p:l.name.localeCompare(u.name)}),s=new Map;for(const l of n){const u=l.project??"unassigned";s.has(u)||s.set(u,[]),s.get(u).push(l)}const a=[];for(const[l,u]of s)a.push({label:l,agents:u});return a.sort((l,u)=>u.agents.length-l.agents.length),a}function AG(e){switch(e.kind){case"tool":return`$ ${ya(e)}`;case"think":return`~ ${ya(e)}`;case"ask":return`↗ ${ya(e)}`;case"message":return`→ ${ya(e)}`;case"note":return`+ ${ya(e)}`;case"system":case"boot":return`▸ ${ya(e)}`}}function uM(e,t,n){const s=n?.events.slice(-8).map(AG).filter(Boolean)??[];return s.length>0?s:et(e.state)==="offline"?["No session trace available"]:["Waiting for session trace…",...t?[`task: ${t}`]:[]]}function RG(e){switch(et(e)){case"working":return"var(--green)";case"available":return"var(--accent)";default:return"var(--dim)"}}function MG({color:e,data:t}){const n=t??[];if(n.length<2)return o.jsx("div",{style:{width:80,height:16,display:"flex",alignItems:"center",color:"var(--dim)",fontSize:10,letterSpacing:"0.08em",textTransform:"uppercase"},children:"No ctx"});const s=n.map((a,l)=>`${l/(n.length-1)*100},${20-a*18-1}`).join(" ");return o.jsx("svg",{viewBox:"0 0 100 20",preserveAspectRatio:"none",style:{width:80,height:16},children:o.jsx("polyline",{points:s,fill:"none",stroke:e,strokeWidth:"1"})})}function _G({navigate:e,agents:t}){const[n,s]=g.useState(null),[a,l]=g.useState(null),u=oM(t),d=g.useCallback(async U=>{await Re(`/api/agents/${encodeURIComponent(U)}/interrupt`,{method:"POST",body:JSON.stringify({})})},[]),p=g.useRef(null),[h,m]=g.useState({w:0,h:0}),[y,x]=g.useState({x:0,y:0}),[w,j]=g.useState(1),N=g.useRef(!1),k=g.useRef({x:0,y:0,panX:0,panY:0});g.useEffect(()=>{const U=p.current;if(!U)return;const O=new ResizeObserver(([D])=>{const{width:H,height:W}=D.contentRect;m({w:H,h:W})});return O.observe(U),()=>O.disconnect()},[]);const E=g.useCallback(async()=>{try{l(await Re("/api/fleet"))}catch{}},[]);g.useEffect(()=>{E()},[E]),Rn(()=>{E()});const C=g.useMemo(()=>{const U={};for(const O of a?.activeAsks??[])U[O.agentId]={agentId:O.agentId,task:O.task,summary:O.summary??null};return U},[a]),S=g.useMemo(()=>CG(t),[t]);g.useEffect(()=>{if(S.canvasW===0||h.w===0)return;const U=Math.min(1,h.w/S.canvasW,h.h/S.canvasH),O=Math.max(.15,Math.min(1,U*.92));x({x:(h.w-S.canvasW*O)/2,y:Math.max(8,(h.h-S.canvasH*O)/2)}),j(O)},[S,h]);const R=g.useCallback(U=>{U.target.closest(".s-conductor-tile")||(N.current=!0,k.current={x:U.clientX,y:U.clientY,panX:y.x,panY:y.y})},[y]),A=g.useCallback(U=>{N.current&&x({x:k.current.panX+(U.clientX-k.current.x),y:k.current.panY+(U.clientY-k.current.y)})},[]),M=g.useCallback(()=>{N.current=!1},[]);g.useEffect(()=>{const U=p.current;if(!U)return;const O=D=>{D.preventDefault();const H=U.getBoundingClientRect(),W=D.clientX-H.left,q=D.clientY-H.top,$=D.deltaY>0?.92:1.08,L=Math.max(.2,Math.min(2,w*$)),F=L/w;x(X=>({x:W-(W-X.x)*F,y:q-(q-X.y)*F})),j(L)};return U.addEventListener("wheel",O,{passive:!1}),()=>U.removeEventListener("wheel",O)},[w]);const _=n?t.find(U=>U.id===n):null;g.useEffect(()=>{if(!_)return;const U=O=>{O.key==="Escape"&&s(null)};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[_]);const z=g.useCallback(U=>{const O=p.current;if(!O)return;const D=U.currentTarget.getBoundingClientRect(),H=U.clientX-D.left,W=U.clientY-D.top,q=Math.min(lM/S.canvasW,cM/S.canvasH),$=H/q,L=W/q,F=O.clientWidth,X=O.clientHeight;x({x:F/2-$*w,y:X/2-L*w})},[S,w]),V=g.useMemo(()=>{const U={};for(const O of S.groups)for(const D of O.tiles)U[D.agentId]={x:D.x,y:D.y};return U},[S]);return o.jsxs("div",{className:"s-conductor",children:[o.jsxs("div",{className:"s-conductor-bar",children:[o.jsxs("span",{className:"s-conductor-bar-label",children:[t.length," agent",t.length!==1?"s":""," ·"," ",S.groups.length," workspace",S.groups.length!==1?"s":""]}),o.jsxs("div",{className:"s-conductor-hotkeys",children:[o.jsxs("span",{className:"s-conductor-hotkey",children:[o.jsx("kbd",{children:"F"})," Freeze all"]}),o.jsxs("span",{className:"s-conductor-hotkey",children:[o.jsx("kbd",{children:"B"})," Broadcast"]}),o.jsxs("span",{className:"s-conductor-hotkey",children:[o.jsx("kbd",{children:"R"})," Route ask"]})]})]}),o.jsxs("div",{ref:p,className:"s-conductor-viewport",onMouseDown:R,onMouseMove:A,onMouseUp:M,onMouseLeave:M,children:[o.jsxs("div",{className:"s-conductor-canvas",style:{transform:`translate(${y.x}px, ${y.y}px) scale(${w})`},children:[S.groups.map(U=>o.jsx("div",{className:"s-conductor-group-label",style:{left:U.x,top:U.y},children:U.label},U.label)),t.map(U=>{const O=V[U.id];return O?o.jsx(DG,{agent:U,task:C[U.id]??null,observe:u[U.id]?.data??null,x:O.x,y:O.y,onClick:()=>s(U.id)},U.id):null})]}),o.jsx(OG,{layout:S,agents:t,pan:y,zoom:w,viewportRef:p,onClick:z})]}),_&&o.jsx(IG,{agent:_,task:C[_.id]??null,observe:u[_.id]?.data??null,onClose:()=>s(null),onTell:()=>{s(null),e({view:"conversation",conversationId:Dn(_.id),composeMode:"tell"})},onAsk:()=>{s(null),e({view:"conversation",conversationId:Dn(_.id),composeMode:"ask"})},onFreeze:et(_.state)==="working"?()=>{s(null),d(_.id)}:void 0,onOpenProfile:()=>{s(null),e({view:"agents",agentId:_.id})}})]})}function OG({layout:e,agents:t,pan:n,zoom:s,viewportRef:a,onClick:l}){if(e.canvasW===0||t.length===0)return null;const u=Math.min(lM/e.canvasW,cM/e.canvasH),d=e.canvasW*u,p=e.canvasH*u,h=a.current,m=h?.clientWidth??0,y=h?.clientHeight??0,x=-n.x/s*u,w=-n.y/s*u,j=m/s*u,N=y/s*u;return o.jsxs("div",{className:"s-conductor-minimap",style:{width:d,height:p,opacity:.85},onClick:l,children:[e.groups.map(k=>o.jsx("div",{className:"s-conductor-minimap-group",style:{left:k.x*u,top:k.y*u},children:k.label},k.label)),e.groups.flatMap(k=>k.tiles.map(E=>{const C=t.find(S=>S.id===E.agentId);return o.jsx("div",{className:"s-conductor-minimap-tile",style:{left:E.x*u,top:E.y*u,width:pc*u,height:Hf*u,background:C?mt(C.name):"var(--dim)",opacity:C&&et(C.state)==="working"?.8:.35}},E.agentId)})),o.jsx("div",{className:"s-conductor-minimap-viewport",style:{left:Math.max(0,x),top:Math.max(0,w),width:Math.min(j,d),height:Math.min(N,p)}})]})}function IG({agent:e,task:t,observe:n,onClose:s,onTell:a,onAsk:l,onFreeze:u,onOpenProfile:d}){const p=uM(e,t?.summary??null,n);return o.jsx("div",{className:"s-conductor-overlay",onClick:s,children:o.jsxs("div",{className:"s-conductor-overlay-panel",onClick:h=>h.stopPropagation(),children:[o.jsxs("div",{className:"s-conductor-overlay-header",children:[o.jsx("div",{className:"s-ops-avatar",style:{"--size":"32px",background:mt(e.name)},children:e.name[0]?.toUpperCase()}),o.jsxs("div",{children:[o.jsxs("div",{style:{fontSize:16,fontWeight:500},children:[e.name," ",o.jsx("span",{style:{color:"var(--dim)",fontSize:12},children:e.handle?`@${e.handle}`:""})]}),o.jsxs("div",{className:"s-conductor-tile-meta",children:[e.project??"—"," · ",e.branch??"main"]})]}),o.jsx("span",{style:{flex:1}}),o.jsx("button",{className:"s-ops-btn",onClick:s,children:"ESC"})]}),o.jsxs("div",{className:"s-conductor-overlay-body",children:[o.jsx("div",{className:"s-conductor-overlay-task",children:t?.task??"No active task"}),o.jsxs("div",{className:"s-conductor-overlay-detail",children:["› ",t?.summary??Pn(e.state)]}),o.jsxs("div",{className:"s-conductor-terminal",style:{height:"auto",minHeight:160},children:[p.map((h,m)=>o.jsx("div",{className:`s-conductor-terminal-line${h.startsWith("$")?" s-conductor-terminal-line--cmd":""}${h.startsWith("→")||h.startsWith("+")?" s-conductor-terminal-line--result":""}`,children:h},m)),et(e.state)==="working"&&o.jsx("span",{className:"s-conductor-terminal-cursor"})]})]}),o.jsxs("div",{className:"s-conductor-overlay-footer",children:[o.jsx("button",{className:"s-ops-btn s-ops-btn--primary",onClick:a,children:"Send instruction"}),o.jsx("button",{className:"s-ops-btn",onClick:u,disabled:!u,children:"Freeze"}),o.jsx("button",{className:"s-ops-btn",onClick:l,children:"Route ask"}),o.jsx("span",{style:{flex:1}}),o.jsx("button",{className:"s-ops-btn",onClick:d,children:"Open profile ↗"})]})]})})}function DG({agent:e,task:t,observe:n,x:s,y:a,onClick:l}){const u=mt(e.name),d=RG(e.state),p=Pn(e.state).toUpperCase(),h=uM(e,t?.summary??null,n),m=et(e.state)==="working",y=n?.events[n.events.length-1],x=y?ya(y):t?.summary??Pn(e.state);return o.jsxs("div",{className:"s-conductor-tile",style:{left:s,top:a,height:Hf},onClick:w=>{w.stopPropagation(),l()},children:[o.jsxs("div",{className:"s-conductor-tile-identity",children:[o.jsx("div",{className:"s-ops-avatar",style:{"--size":"24px",background:u},children:e.name[0]?.toUpperCase()}),o.jsxs("div",{className:"s-conductor-tile-identity-copy",children:[o.jsxs("div",{className:"s-conductor-tile-name",children:[e.name,o.jsx("span",{className:"s-conductor-tile-handle",children:e.handle?`@${e.handle}`:""})]}),o.jsxs("div",{className:"s-conductor-tile-meta",children:[e.project??"—"," · ",e.branch??"main"]})]}),o.jsx("span",{className:"s-ops-state-chip",style:{color:d},children:p})]}),o.jsx("div",{className:"s-conductor-tile-task",children:t?.task??"No active task"}),o.jsxs("div",{className:"s-conductor-terminal",children:[h.slice(-4).map((w,j)=>o.jsx("div",{className:`s-conductor-terminal-line${w.startsWith("$")?" s-conductor-terminal-line--cmd":""}${w.startsWith("→")||w.startsWith("+")?" s-conductor-terminal-line--result":""}`,style:{opacity:(j+1)/Math.min(4,h.length)},children:w},j)),m&&o.jsx("span",{className:"s-conductor-terminal-cursor"})]}),o.jsxs("div",{className:"s-conductor-tile-footer",children:[o.jsx(MG,{color:u,data:n?.contextUsage}),o.jsx("span",{className:"s-conductor-tile-detail",children:x}),m&&o.jsx("span",{className:"s-conductor-terminal-cursor"})]})]})}const mc=420,qf=320,wo=20,PG=48,zG=36,tk=28,$d=40,dM=180,fM=140,hM="scout_mc_vp";function LG(e){try{localStorage.setItem(hM,JSON.stringify(e))}catch{}}function $G(){try{const e=localStorage.getItem(hM);if(!e)return null;const t=JSON.parse(e);if(typeof t?.zoom=="number"&&typeof t?.pan?.x=="number"&&typeof t?.pan?.y=="number")return t}catch{}return null}function UG(e){const t=BG(e);if(t.length===0)return{groups:[],canvasW:0,canvasH:0};const n=Math.max(1,Math.round(Math.sqrt(t.length*1.2))),s=[],a=new Array(n).fill($d),l=Array.from({length:n},(p,h)=>$d+h*(mc*2+wo+PG));for(const p of t){const h=a.indexOf(Math.min(...a)),m=l[h],y=a[h],x=Math.min(2,p.agents.length),w=Math.ceil(p.agents.length/x),j=x*mc+(x-1)*wo,N=tk+w*qf+(w-1)*wo,k=p.agents.map((E,C)=>({agentId:E.id,x:m+C%x*(mc+wo),y:y+tk+Math.floor(C/x)*(qf+wo)}));s.push({label:p.label,x:m,y,w:j,h:N,tiles:k}),a[h]=y+N+zG}const u=Math.max(...l.map(p=>p+mc*2+wo))+$d,d=Math.max(...a)+$d;return{groups:s,canvasW:u,canvasH:d}}function BG(e){const t={working:0,available:1,offline:2},n=[...e].sort((l,u)=>{const d=t[et(l.state)]??1,p=t[et(u.state)]??1;return d!==p?d-p:l.name.localeCompare(u.name)}),s=new Map;for(const l of n){const u=l.project??"unassigned";s.has(u)||s.set(u,[]),s.get(u).push(l)}const a=[];for(const[l,u]of s)a.push({label:l,agents:u});return a.sort((l,u)=>u.agents.length-l.agents.length),a}const VG={think:"var(--dim)",tool:"var(--accent)",ask:"var(--amber)",message:"var(--muted)",note:"var(--green)",system:"var(--dim)",boot:"var(--dim)"},FG={think:"think",tool:"tool",ask:"ask",message:"msg",note:"note",system:"sys",boot:"boot"};function HG({navigate:e,agents:t}){const[n,s]=g.useState(null),a=oM(t),l=g.useRef(null),[u,d]=g.useState({w:0,h:0}),[p,h]=g.useState({x:0,y:0}),[m,y]=g.useState(1),[x,w]=g.useState(!1),j=g.useRef(!1),N=g.useRef({x:0,y:0,panX:0,panY:0}),k=g.useRef(!1);g.useEffect(()=>{const O=l.current;if(!O)return;const D=new ResizeObserver(([H])=>{d({w:H.contentRect.width,h:H.contentRect.height})});return D.observe(O),()=>D.disconnect()},[]);const E=g.useMemo(()=>UG(t),[t]),C=g.useRef([]),S=g.useCallback((O=!0)=>{if(E.canvasW===0||u.w===0)return;C.current.forEach(clearTimeout);const D=Math.min(1,u.w/E.canvasW,u.h/E.canvasH),H=Math.max(.15,Math.min(1,D*.92));w(!1),y(H),h({x:(u.w-E.canvasW*H)/2,y:Math.max(8,(u.h-E.canvasH*H)/2)});const W=setTimeout(()=>{w(!0);const $=O?$G():null;$?(h($.pan),y($.zoom)):(h({x:24,y:24}),y(.55))},700),q=setTimeout(()=>w(!1),1700);C.current=[W,q]},[E,u]);g.useEffect(()=>{E.canvasW===0||u.w===0||k.current||(k.current=!0,S(!0))},[E,u,S]),g.useEffect(()=>{const O=setInterval(()=>{LG({pan:p,zoom:m})},3e4);return()=>clearInterval(O)},[p,m]);const R=g.useCallback(O=>{O.target.closest(".s-mission-tile")||(j.current=!0,N.current={x:O.clientX,y:O.clientY,panX:p.x,panY:p.y})},[p]),A=g.useCallback(O=>{j.current&&h({x:N.current.panX+(O.clientX-N.current.x),y:N.current.panY+(O.clientY-N.current.y)})},[]),M=g.useCallback(()=>{j.current=!1},[]);g.useEffect(()=>{const O=l.current;if(!O)return;const D=H=>{H.preventDefault();const W=O.getBoundingClientRect(),q=H.clientX-W.left,$=H.clientY-W.top,L=H.deltaY>0?.92:1.08,F=Math.max(.2,Math.min(2,m*L)),X=F/m;h(G=>({x:q-(q-G.x)*X,y:$-($-G.y)*X})),y(F)};return O.addEventListener("wheel",D,{passive:!1}),()=>O.removeEventListener("wheel",D)},[m]);const _=n?t.find(O=>O.id===n):null;g.useEffect(()=>{const O=D=>{D.target.tagName==="INPUT"||D.target.tagName==="TEXTAREA"||(D.key==="Escape"&&s(null),(D.key==="h"||D.key==="H")&&S(!1))};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[_,S]);const z=g.useCallback(O=>{const D=O.currentTarget.getBoundingClientRect(),H=O.clientX-D.left,W=O.clientY-D.top,q=Math.min(dM/E.canvasW,fM/E.canvasH),$=H/q,L=W/q,F=l.current;F&&h({x:F.clientWidth/2-$*m,y:F.clientHeight/2-L*m})},[E,m]),V=g.useMemo(()=>{const O={};for(const D of E.groups)for(const H of D.tiles)O[H.agentId]={x:H.x,y:H.y};return O},[E]),U=t.filter(O=>et(O.state)==="working").length;return o.jsxs("div",{className:"s-mission",children:[o.jsxs("div",{className:"s-mission-bar",children:[o.jsxs("span",{className:"s-mission-bar-label",children:[t.length," agent",t.length!==1?"s":""," ·"," ",E.groups.length," workspace",E.groups.length!==1?"s":""]}),U>0&&o.jsxs("span",{className:"s-mission-bar-live",children:[o.jsx("span",{className:"s-mission-bar-live-dot"}),U," active"]}),o.jsxs("div",{className:"s-mission-hotkeys",children:[o.jsxs("button",{className:"s-mission-hotkey s-mission-hotkey--btn",onClick:()=>S(!1),title:"Reset to overview",children:[o.jsx("kbd",{children:"H"})," Home"]}),o.jsxs("span",{className:"s-mission-hotkey",children:[o.jsx("kbd",{children:"Esc"})," Close focus"]})]})]}),o.jsxs("div",{ref:l,className:"s-mission-viewport",onMouseDown:R,onMouseMove:A,onMouseUp:M,onMouseLeave:M,children:[t.length===0?o.jsxs("div",{className:"s-mission-empty",children:[o.jsx("div",{className:"s-mission-empty-title",children:"Control"}),o.jsx("div",{className:"s-mission-empty-sub",children:"Connect agents to observe their sessions here."})]}):o.jsxs("div",{className:"s-mission-canvas",style:{transform:`translate(${p.x}px, ${p.y}px) scale(${m})`,transition:x?"transform 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94)":"none"},children:[E.groups.map(O=>o.jsx("div",{className:"s-mission-group-label",style:{left:O.x,top:O.y},children:O.label},O.label)),t.map(O=>{const D=V[O.id];if(!D)return null;const H=a[O.id];return o.jsx(qG,{agent:O,observe:H?.data??null,x:D.x,y:D.y,onClick:()=>s(O.id)},O.id)})]}),t.length>0&&o.jsx(WG,{layout:E,agents:t,pan:p,zoom:m,viewportRef:l,onClick:z})]}),_&&o.jsx(ZG,{agent:_,observe:a[_.id]?.data??null,onClose:()=>s(null),onTell:()=>{s(null),e({view:"conversation",conversationId:Dn(_.id),composeMode:"tell"})},onAsk:()=>{s(null),e({view:"conversation",conversationId:Dn(_.id),composeMode:"ask"})},onProfile:()=>{s(null),e({view:"agents",agentId:_.id})}})]})}function qG({agent:e,observe:t,x:n,y:s,onClick:a}){const l=g.useRef(null),u=et(e.state),d=mt(e.name),p=t?.events??[],h=p.slice(-8),m=t?.live===!0,y=p.some(k=>k.kind==="ask"&&!k.answer),x=t?.contextUsage,w=x&&x.length>0?Math.round(x[x.length-1]*100):null,j=p.filter(k=>k.kind==="tool").length,N=p.filter(k=>k.kind==="tool"&&k.tool==="edit").length;return g.useEffect(()=>{l.current&&(l.current.scrollTop=l.current.scrollHeight)},[p.length]),o.jsxs("div",{className:`s-mission-tile${u==="working"?" s-mission-tile--working":""}${y?" s-mission-tile--asking":""}`,style:{left:n,top:s,height:qf},onClick:k=>{k.stopPropagation(),a()},children:[o.jsxs("div",{className:"s-mission-tile-header",children:[o.jsx("div",{className:"s-ops-avatar",style:{"--size":"22px",background:d},children:e.name[0]?.toUpperCase()}),o.jsxs("div",{className:"s-mission-tile-identity",children:[o.jsxs("div",{className:"s-mission-tile-name",children:[e.name,o.jsx("span",{className:"s-mission-tile-handle",children:e.handle?`@${e.handle}`:""})]}),o.jsxs("div",{className:"s-mission-tile-meta",children:[e.project??"—"," · ",e.branch??"main"]})]}),o.jsx("span",{className:"s-ops-state-chip",style:{color:YG(u)},children:Pn(e.state).toUpperCase()})]}),o.jsx("div",{className:"s-mission-tile-stream",ref:l,children:h.length===0?o.jsx("div",{className:"s-mission-tile-stream-inner",children:o.jsxs("div",{className:"s-mission-evt",children:[o.jsx("span",{className:"s-mission-evt-bead",style:{background:"var(--dim)"}}),o.jsx("span",{className:"s-mission-evt-text",style:{color:"var(--dim)"},children:u==="offline"?"No session data":"Waiting for events…"})]})}):o.jsx("div",{className:"s-mission-tile-stream-inner",children:h.map(k=>o.jsxs("div",{className:"s-mission-evt",children:[o.jsx("span",{className:"s-mission-evt-bead",style:{background:VG[k.kind]??"var(--dim)"}}),o.jsx("span",{className:"s-mission-evt-kind",children:FG[k.kind]??k.kind}),o.jsxs("span",{className:`s-mission-evt-text s-mission-evt-text--${k.kind}`,children:[ya(k),k.live&&o.jsx("span",{className:"s-observe-cursor"})]})]},k.id))})}),o.jsxs("div",{className:"s-mission-tile-footer",children:[w!==null&&o.jsx("div",{className:"s-mission-tile-ctx",title:`Context: ${w}%`,children:o.jsx("div",{className:"s-mission-tile-ctx-fill",style:{width:`${w}%`}})}),o.jsxs("div",{className:"s-mission-tile-stats",children:[j>0&&o.jsxs("span",{children:[j," tools"]}),N>0&&o.jsxs("span",{children:[N," edits"]})]}),m&&o.jsxs("span",{className:"s-mission-tile-live",children:[o.jsx("span",{className:"s-mission-tile-live-dot"}),"LIVE"]})]})]})}function ZG({agent:e,observe:t,onClose:n,onTell:s,onAsk:a,onProfile:l}){const u=mt(e.name);return o.jsx("div",{className:"s-mission-overlay",onClick:n,children:o.jsxs("div",{onClick:d=>d.stopPropagation(),style:{display:"contents"},children:[o.jsxs("div",{className:"s-mission-overlay-header",children:[o.jsx("div",{className:"s-ops-avatar",style:{"--size":"28px",background:u},children:e.name[0]?.toUpperCase()}),o.jsxs("div",{children:[o.jsxs("div",{className:"s-mission-overlay-name",children:[e.name," ",o.jsx("span",{style:{color:"var(--dim)",fontSize:11},children:e.handle?`@${e.handle}`:""})]}),o.jsxs("div",{className:"s-mission-overlay-meta",children:[e.project??"—"," · ",e.branch??"main"," · ",Pn(e.state)]})]}),o.jsxs("div",{className:"s-mission-overlay-actions",children:[o.jsx("button",{className:"s-ops-btn s-ops-btn--primary",onClick:s,children:"Tell"}),o.jsx("button",{className:"s-ops-btn",onClick:a,children:"Ask"}),o.jsx("button",{className:"s-ops-btn",onClick:l,children:"Profile ↗"}),o.jsx("button",{className:"s-ops-btn",onClick:n,children:"ESC"})]})]}),o.jsx("div",{className:"s-mission-overlay-body",children:o.jsx(KR,{data:t??void 0,agentId:e.id})})]})})}function WG({layout:e,agents:t,pan:n,zoom:s,viewportRef:a,onClick:l}){if(e.canvasW===0)return null;const u=Math.min(dM/e.canvasW,fM/e.canvasH),d=e.canvasW*u,p=e.canvasH*u,h=a.current,m=h?.clientWidth??0,y=h?.clientHeight??0,x=-n.x/s*u,w=-n.y/s*u,j=m/s*u,N=y/s*u;return o.jsxs("div",{className:"s-mission-minimap",style:{width:d,height:p},onClick:l,children:[e.groups.map(k=>o.jsx("div",{className:"s-mission-minimap-group",style:{left:k.x*u,top:k.y*u},children:k.label},k.label)),e.groups.flatMap(k=>k.tiles.map(E=>{const C=t.find(S=>S.id===E.agentId);return o.jsx("div",{className:"s-mission-minimap-tile",style:{left:E.x*u,top:E.y*u,width:mc*u,height:qf*u,background:C?mt(C.name):"var(--dim)",opacity:C&&et(C.state)==="working"?.8:.35}},E.agentId)})),o.jsx("div",{className:"s-mission-minimap-viewport",style:{left:Math.max(0,x),top:Math.max(0,w),width:Math.min(j,d),height:Math.min(N,p)}})]})}function YG(e){switch(e){case"working":return"var(--green)";case"available":return"var(--accent)";default:return"var(--dim)"}}const GG=["openai","codex","codex_app_server"],KG=["anthropic","claude","claude-code","claude_stream_json"],ai={"openai:gpt-5.5":{provider:"openai",model:"gpt-5.5",inputPerM:5,cachedInputPerM:.5,cacheWritePerM:null,outputPerM:30,webSearchPer1K:10},"openai:gpt-5.5-pro":{provider:"openai",model:"gpt-5.5-pro",inputPerM:30,cachedInputPerM:null,cacheWritePerM:null,outputPerM:180,webSearchPer1K:10},"openai:gpt-5.4":{provider:"openai",model:"gpt-5.4",inputPerM:2.5,cachedInputPerM:.25,cacheWritePerM:null,outputPerM:15,webSearchPer1K:10},"openai:gpt-5.4-mini":{provider:"openai",model:"gpt-5.4-mini",inputPerM:.75,cachedInputPerM:.075,cacheWritePerM:null,outputPerM:4.5,webSearchPer1K:10},"openai:gpt-5.4-nano":{provider:"openai",model:"gpt-5.4-nano",inputPerM:.2,cachedInputPerM:.02,cacheWritePerM:null,outputPerM:1.25,webSearchPer1K:10},"openai:gpt-5.4-pro":{provider:"openai",model:"gpt-5.4-pro",inputPerM:30,cachedInputPerM:null,cacheWritePerM:null,outputPerM:180,webSearchPer1K:10},"openai:gpt-5.3-codex":{provider:"openai",model:"gpt-5.3-codex",inputPerM:1.75,cachedInputPerM:.175,cacheWritePerM:null,outputPerM:14,webSearchPer1K:10},"openai:gpt-5.3-chat-latest":{provider:"openai",model:"gpt-5.3-chat-latest",inputPerM:1.75,cachedInputPerM:.175,cacheWritePerM:null,outputPerM:14,webSearchPer1K:10},"openai:gpt-5.2":{provider:"openai",model:"gpt-5.2",inputPerM:1.75,cachedInputPerM:.175,cacheWritePerM:null,outputPerM:14,webSearchPer1K:10},"openai:gpt-5.2-codex":{provider:"openai",model:"gpt-5.2-codex",inputPerM:1.75,cachedInputPerM:.175,cacheWritePerM:null,outputPerM:14,webSearchPer1K:10},"openai:gpt-5.2-chat-latest":{provider:"openai",model:"gpt-5.2-chat-latest",inputPerM:1.75,cachedInputPerM:.175,cacheWritePerM:null,outputPerM:14,webSearchPer1K:10},"openai:gpt-5.2-pro":{provider:"openai",model:"gpt-5.2-pro",inputPerM:21,cachedInputPerM:null,cacheWritePerM:null,outputPerM:168,webSearchPer1K:10},"openai:gpt-5.1":{provider:"openai",model:"gpt-5.1",inputPerM:1.25,cachedInputPerM:.125,cacheWritePerM:null,outputPerM:10,webSearchPer1K:10},"openai:gpt-5.1-codex":{provider:"openai",model:"gpt-5.1-codex",inputPerM:1.25,cachedInputPerM:.125,cacheWritePerM:null,outputPerM:10,webSearchPer1K:10},"openai:gpt-5.1-codex-max":{provider:"openai",model:"gpt-5.1-codex-max",inputPerM:1.25,cachedInputPerM:.125,cacheWritePerM:null,outputPerM:10,webSearchPer1K:10},"openai:gpt-5.1-chat-latest":{provider:"openai",model:"gpt-5.1-chat-latest",inputPerM:1.25,cachedInputPerM:.125,cacheWritePerM:null,outputPerM:10,webSearchPer1K:10},"openai:gpt-5":{provider:"openai",model:"gpt-5",inputPerM:1.25,cachedInputPerM:.125,cacheWritePerM:null,outputPerM:10,webSearchPer1K:10},"openai:gpt-5-codex":{provider:"openai",model:"gpt-5-codex",inputPerM:1.25,cachedInputPerM:.125,cacheWritePerM:null,outputPerM:10,webSearchPer1K:10},"openai:gpt-5-chat-latest":{provider:"openai",model:"gpt-5-chat-latest",inputPerM:1.25,cachedInputPerM:.125,cacheWritePerM:null,outputPerM:10,webSearchPer1K:10},"openai:gpt-5-mini":{provider:"openai",model:"gpt-5-mini",inputPerM:.25,cachedInputPerM:.025,cacheWritePerM:null,outputPerM:2,webSearchPer1K:10},"openai:gpt-5-nano":{provider:"openai",model:"gpt-5-nano",inputPerM:.05,cachedInputPerM:.005,cacheWritePerM:null,outputPerM:.4,webSearchPer1K:10},"openai:gpt-5-pro":{provider:"openai",model:"gpt-5-pro",inputPerM:15,cachedInputPerM:null,cacheWritePerM:null,outputPerM:120,webSearchPer1K:10},"openai:gpt-4.1":{provider:"openai",model:"gpt-4.1",inputPerM:2,cachedInputPerM:.5,cacheWritePerM:null,outputPerM:8,webSearchPer1K:10},"openai:gpt-4.1-mini":{provider:"openai",model:"gpt-4.1-mini",inputPerM:.4,cachedInputPerM:.1,cacheWritePerM:null,outputPerM:1.6,webSearchPer1K:10},"openai:gpt-4.1-nano":{provider:"openai",model:"gpt-4.1-nano",inputPerM:.1,cachedInputPerM:.025,cacheWritePerM:null,outputPerM:.4,webSearchPer1K:10},"openai:gpt-4o":{provider:"openai",model:"gpt-4o",inputPerM:2.5,cachedInputPerM:1.25,cacheWritePerM:null,outputPerM:10,webSearchPer1K:10},"openai:gpt-4o-mini":{provider:"openai",model:"gpt-4o-mini",inputPerM:.15,cachedInputPerM:.075,cacheWritePerM:null,outputPerM:.6,webSearchPer1K:10},"anthropic:claude-opus-4.6":{provider:"anthropic",model:"claude-opus-4.6",inputPerM:5,cachedInputPerM:.5,cacheWritePerM:6.25,outputPerM:25,webSearchPer1K:10},"anthropic:claude-opus-4.5":{provider:"anthropic",model:"claude-opus-4.5",inputPerM:5,cachedInputPerM:.5,cacheWritePerM:6.25,outputPerM:25,webSearchPer1K:10},"anthropic:claude-opus-4.1":{provider:"anthropic",model:"claude-opus-4.1",inputPerM:15,cachedInputPerM:1.5,cacheWritePerM:18.75,outputPerM:75,webSearchPer1K:10},"anthropic:claude-opus-4":{provider:"anthropic",model:"claude-opus-4",inputPerM:15,cachedInputPerM:1.5,cacheWritePerM:18.75,outputPerM:75,webSearchPer1K:10},"anthropic:claude-sonnet-4.6":{provider:"anthropic",model:"claude-sonnet-4.6",inputPerM:3,cachedInputPerM:.3,cacheWritePerM:3.75,outputPerM:15,webSearchPer1K:10},"anthropic:claude-sonnet-4.5":{provider:"anthropic",model:"claude-sonnet-4.5",inputPerM:3,cachedInputPerM:.3,cacheWritePerM:3.75,outputPerM:15,webSearchPer1K:10},"anthropic:claude-sonnet-4":{provider:"anthropic",model:"claude-sonnet-4",inputPerM:3,cachedInputPerM:.3,cacheWritePerM:3.75,outputPerM:15,webSearchPer1K:10},"anthropic:claude-3-7-sonnet":{provider:"anthropic",model:"claude-3-7-sonnet",inputPerM:3,cachedInputPerM:.3,cacheWritePerM:3.75,outputPerM:15,webSearchPer1K:10},"anthropic:claude-haiku-4.5":{provider:"anthropic",model:"claude-haiku-4.5",inputPerM:1,cachedInputPerM:.1,cacheWritePerM:1.25,outputPerM:5,webSearchPer1K:10}},XG={"claude-sonnet-4-5":"anthropic:claude-sonnet-4.5","claude-sonnet-4-6":"anthropic:claude-sonnet-4.6","claude-opus-4-5":"anthropic:claude-opus-4.5","claude-opus-4-6":"anthropic:claude-opus-4.6","claude-haiku-4-5":"anthropic:claude-haiku-4.5"};function JG(e){const t=e.provider?.trim().toLowerCase()??"",n=e.adapterType?.trim().toLowerCase()??"",s=pM(e.model)??"",a=[t,n].filter(Boolean);return a.some(l=>GG.some(u=>l.includes(u)))?"openai":a.some(l=>KG.some(u=>l.includes(u)))?"anthropic":s.startsWith("gpt-")||s.startsWith("o")||s.includes("codex")?"openai":s.startsWith("claude-")?"anthropic":"unknown"}function pM(e){return e?e.trim().toLowerCase().replace(/^(openai|anthropic)\//,"").replace(/_/g,"-").replace(/-\d{8}$/,""):null}function QG(e){const t=da(e?.inputTokens),n=da(e?.cacheReadInputTokens),s=da(e?.cacheCreationInputTokens),a=da(e?.outputTokens),l=da(e?.reasoningOutputTokens),u=[t,a].reduce((p,h)=>p+(h??0),0),d=da(e?.totalTokens)??(u||null);return{input:t,uncachedInput:t==null?null:Math.max(0,t-(n??0)-(s??0)),cachedInput:n,cacheWrite:s,output:a,reasoningOutput:l,total:d,webSearchRequests:da(e?.webSearchRequests),webFetchRequests:da(e?.webFetchRequests)}}function eK(e){const t=JG(e),n=pM(e.model),s=QG(e.usage),a=tK(t,n),l=nK(e);if(!a.rateCard)return{provider:t,model:n,rateCard:null,rateCardSource:"unknown",capturedAt:e.capturedAt??Date.now(),usage:s,lineItems:[],totalUsd:null,billedTotalUsd:null,billingMode:l,subscriptionWindows:e.subscriptionWindows??[]};const u=a.rateCard,d=s.uncachedInput??s.input??0,p=s.cachedInput??0,h=s.cacheWrite??0,m=s.output??0,y=s.webSearchRequests??0,x=[Ud("input","Input",d,u.inputPerM,l),Ud("cached_input","Cached input",p,u.cachedInputPerM??u.inputPerM,l),Ud("cache_write","Cache write",h,u.cacheWritePerM??u.inputPerM,l),Ud("output","Output",m,u.outputPerM,l),{key:"web_search",label:"Web search",quantity:y,unit:"requests",rate:u.webSearchPer1K??0,billedRate:l==="subscription"?0:u.webSearchPer1K??0,costUsd:y/1e3*(u.webSearchPer1K??0),billedCostUsd:l==="subscription"?0:y/1e3*(u.webSearchPer1K??0)}].filter(w=>w.quantity>0);return{provider:t,model:n,rateCard:u,rateCardSource:a.source,capturedAt:e.capturedAt??Date.now(),usage:s,lineItems:x,totalUsd:x.reduce((w,j)=>w+j.costUsd,0),billedTotalUsd:x.reduce((w,j)=>w+j.billedCostUsd,0),billingMode:l,subscriptionWindows:e.subscriptionWindows??[]}}function tK(e,t){if(e==="unknown")return{rateCard:null,source:"unknown"};const n=t?`${e}:${t}`:null;if(n&&ai[n])return{rateCard:ai[n],source:"exact"};const s=t?XG[t]:null;if(s&&ai[s])return{rateCard:ai[s],source:"alias"};if(e==="anthropic"){if(t?.includes("opus"))return{rateCard:ai["anthropic:claude-opus-4.5"],source:"provider-default"};if(t?.includes("haiku"))return{rateCard:ai["anthropic:claude-haiku-4.5"],source:"provider-default"};if(t?.includes("sonnet")||!t)return{rateCard:ai["anthropic:claude-sonnet-4.5"],source:"provider-default"}}return{rateCard:null,source:"unknown"}}function Ud(e,t,n,s,a){const l=a==="subscription"?0:s;return{key:e,label:t,quantity:n,unit:"tokens",rate:s,billedRate:l,costUsd:n/1e6*s,billedCostUsd:n/1e6*l}}function da(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function nK(e){if(e.billingMode)return e.billingMode;const t=e.adapterType?.trim().toLowerCase();if(t==="claude-code"||t==="claude_stream_json")return"subscription";const n=e.usage?.planType?.trim().toLowerCase();return!n||n==="api"||n.includes("api")?"api":"subscription"}const Xv=1440*6e4,sK=90*6e4;function nk(e){if(!e)return null;const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function ac(e){return e==null?"—":e>=1e6?`${(e/1e6).toFixed(e>=1e7?0:1)}M`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}K`:String(e)}function sk(e){return e==null?"—":e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(2)}s`}function Bd(e){return e==null?"$—":e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function rK(e,t){if(!e)return null;const n=e.data.events.filter(a=>a.kind==="message"||a.kind==="tool").filter(a=>t-a.t<=sK).sort((a,l)=>a.t-l.t);if(n.length<2)return null;const s=[];for(let a=1;a<n.length;a+=1){const l=n[a].t-n[a-1].t;l>0&&l<12e4&&s.push(l)}return s.length===0?null:Math.round(s.reduce((a,l)=>a+l,0)/s.length)}function aK(e,t){const n=new Array(24).fill(0),s=t-Xv;for(const a of e){if(a.ts<s||a.ts>t)continue;const l=Math.min(23,Math.max(0,Math.floor((a.ts-s)/Xv*n.length)));n[l]+=1}return n}function iK({values:e,warn:t=!1}){const a=Math.max(1,...e),l=e.map((u,d)=>{const p=d/Math.max(1,e.length-1)*92,h=22-u/a*19-1.5;return`${p.toFixed(1)},${h.toFixed(1)}`}).join(" ");return o.jsx("svg",{className:`s-ops-agents-spark${t?" s-ops-agents-spark--warn":""}`,viewBox:"0 0 92 22","aria-hidden":"true",children:o.jsx("polyline",{points:l,fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}function oK(e){return e.transport??nk(e.cwd)??nk(e.projectRoot)??"local"}function lK(e){return e.project??e.role??e.agentClass??"Unassigned"}function cK(e,t,n,s,a,l){const u=t.filter(w=>w.agentId===e.id),d=u.filter(w=>{const j=w.lastMessageAt??0;return j>0&&l-j<=Xv}),p=n.filter(w=>w.actorName===e.name||w.conversationId===e.conversationId),h=a.get(e.id),m=h?.data.metadata?.session?.model??null,y=h?.data.metadata?.session?.modelProvider??null,x=eK({adapterType:h?.data.metadata?.session?.adapterType,capturedAt:h?.updatedAt??l,model:m,provider:y,usage:h?.data.metadata?.usage});return{agent:e,team:lK(e),machine:oK(e),model:m,provider:y,state:et(e.state),activeFlights:s.filter(w=>w.agentId===e.id).length,sessions24h:d.length,throughput:aK(p,l),avgLatencyMs:rK(h,l),usage:x.usage,cost:x,errors:s.filter(w=>w.agentId===e.id&&(w.status==="failed"||w.status==="needs_attention")).length,lastActiveAt:Math.max(0,...u.map(w=>w.lastMessageAt??0),...p.map(w=>w.ts),e.updatedAt??0)||null}}function uK({navigate:e,agents:t}){const[n,s]=g.useState(null),[a,l]=g.useState([]),[u,d]=g.useState([]),[p,h]=g.useState([]),[m,y]=g.useState(""),[x,w]=g.useState(()=>Date.now()),j=g.useCallback(async()=>{const O=t.map($=>$.id).join(","),[D,H,W,q]=await Promise.allSettled([Re("/api/fleet"),Re("/api/sessions"),Re("/api/activity"),O?Re(`/api/observe/agents?ids=${encodeURIComponent(O)}`):Promise.resolve([])]);D.status==="fulfilled"&&s(D.value),H.status==="fulfilled"&&l(H.value),W.status==="fulfilled"&&d(W.value),q.status==="fulfilled"&&h(q.value),w(Date.now())},[t]);g.useEffect(()=>{j()},[j]),Rn(()=>{j()}),g.useEffect(()=>{const O=setInterval(()=>w(Date.now()),1e3);return()=>clearInterval(O)},[]);const N=g.useMemo(()=>new Map(p.map(O=>[O.agentId,O])),[p]),k=g.useMemo(()=>{const O=n?.activeAsks??[];return t.map(D=>cK(D,a,u,O,N,x)).sort((D,H)=>{const W={working:0,available:1,offline:2},q=W[D.state]-W[H.state];return q!==0?q:(H.lastActiveAt??0)-(D.lastActiveAt??0)})},[u,t,n?.activeAsks,x,N,a]),E=g.useMemo(()=>{const O=m.trim().toLowerCase();return O?k.filter(D=>`${D.agent.name} ${D.team} ${D.machine} ${D.agent.handle??""} ${D.agent.harness??""}`.toLowerCase().includes(O)):k},[m,k]),C=k.filter(O=>O.state==="working").length,S=k.filter(O=>O.state!=="offline").length,R=k.reduce((O,D)=>O+(D.usage.total??0),0),A=k.some(O=>O.cost.totalUsd!=null)?k.reduce((O,D)=>O+(D.cost.totalUsd??0),0):null,M=k.some(O=>O.cost.billedTotalUsd!=null)?k.reduce((O,D)=>O+(D.cost.billedTotalUsd??0),0):null,_=(()=>{const O=k.map(D=>D.avgLatencyMs).filter(D=>D!=null);return O.length===0?null:Math.round(O.reduce((D,H)=>D+H,0)/O.length)})(),z=k.reduce((O,D)=>O+D.errors,0),V=g.useMemo(()=>{const O=new Map;for(const D of k)O.set(D.team,(O.get(D.team)??0)+1);return[...O.entries()].sort((D,H)=>H[1]-D[1]).slice(0,6)},[k]),U=g.useMemo(()=>{const O=new Map;for(const D of k)O.set(D.machine,(O.get(D.machine)??0)+1);return[...O.entries()].sort((D,H)=>H[1]-D[1]).slice(0,7)},[k]);return o.jsxs("div",{className:"s-ops-agents",children:[o.jsxs("aside",{className:"s-ops-agents-rail",children:[o.jsxs("div",{className:"s-ops-agents-brand",children:[o.jsx("div",{className:"s-ops-agents-mark",children:"sc"}),o.jsxs("div",{children:[o.jsx("div",{className:"s-ops-agents-brand-name",children:"agentctl"}),o.jsx("div",{className:"s-ops-agents-brand-sub",children:"ops console"})]})]}),o.jsxs("div",{className:"s-ops-agents-rail-group",children:[o.jsx("div",{className:"s-ops-agents-rail-heading",children:"Fleet"}),o.jsxs("button",{className:"s-ops-agents-rail-row",type:"button",children:["Overview ",o.jsx("span",{children:t.length})]}),o.jsxs("button",{className:"s-ops-agents-rail-row s-ops-agents-rail-row--active",type:"button",children:["Agents ",o.jsx("span",{children:S})]}),o.jsxs("button",{className:"s-ops-agents-rail-row",type:"button",children:["Sessions ",o.jsx("span",{children:a.length})]}),o.jsxs("button",{className:"s-ops-agents-rail-row",type:"button",children:["Alerts ",o.jsx("span",{children:z})]})]}),o.jsxs("div",{className:"s-ops-agents-rail-group",children:[o.jsx("div",{className:"s-ops-agents-rail-heading",children:"Teams"}),V.map(([O,D])=>o.jsxs("button",{className:"s-ops-agents-rail-row",type:"button",children:[O,o.jsx("span",{children:D})]},O))]}),o.jsxs("div",{className:"s-ops-agents-rail-group",children:[o.jsx("div",{className:"s-ops-agents-rail-heading",children:"Machines"}),U.map(([O,D])=>o.jsxs("button",{className:"s-ops-agents-rail-row",type:"button",children:[O,o.jsx("span",{children:D})]},O))]})]}),o.jsxs("main",{className:"s-ops-agents-main",children:[o.jsxs("div",{className:"s-ops-agents-toolbar",children:[o.jsxs("div",{className:"s-ops-agents-breadcrumb",children:["Fleet ",o.jsx("span",{children:"/"})," Agents"]}),o.jsxs("div",{className:"s-ops-agents-live",children:[o.jsx("span",{className:"s-ops-agents-live-dot"}),S," active"]}),o.jsxs("div",{className:"s-ops-agents-search",children:[o.jsx(HO,{size:13}),o.jsx("input",{value:m,onChange:O=>y(O.target.value),placeholder:"Search agents, teams, machines..."})]}),o.jsx("button",{className:"s-ops-agents-icon-btn",type:"button",title:"Filters",children:o.jsx(WO,{size:14})})]}),o.jsx("section",{className:"s-ops-agents-hero",children:o.jsxs("div",{children:[o.jsx("div",{className:"s-ops-agents-kicker",children:"Agents"}),o.jsx("h1",{children:"All agents"}),o.jsx("p",{children:"Every registered agent across the local fleet, sorted by live status."})]})}),o.jsxs("section",{className:"s-ops-agents-stats",children:[o.jsx(Vd,{label:"Running",value:String(C),sub:`of ${t.length} total`}),o.jsx(Vd,{label:"Tokens",value:ac(R||null),sub:A==null?"usage metadata pending":`${Bd(A)} API equiv`}),o.jsx(Vd,{label:"Avg latency",value:sk(_),sub:"recent observe events"}),o.jsx(Vd,{label:"Billed",value:Bd(M),sub:"subscription usage can mark this down"})]}),o.jsxs("section",{className:"s-ops-agents-table-panel",children:[o.jsxs("div",{className:"s-ops-agents-table-title",children:["Agents ",o.jsx("span",{children:E.length})]}),o.jsx("div",{className:"s-ops-agents-table-wrap",children:o.jsxs("table",{className:"s-ops-agents-table",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{children:"Agent"}),o.jsx("th",{children:"Team"}),o.jsx("th",{children:"Machine"}),o.jsx("th",{children:"Active"}),o.jsx("th",{children:"24h sessions"}),o.jsx("th",{children:"Throughput"}),o.jsx("th",{children:"Avg latency"}),o.jsx("th",{children:"Input"}),o.jsx("th",{children:"Cache read"}),o.jsx("th",{children:"Cache write"}),o.jsx("th",{children:"Output"}),o.jsx("th",{children:"API equiv"}),o.jsx("th",{children:"Billed"}),o.jsx("th",{children:"Errors"}),o.jsx("th",{children:"Last active"})]})}),o.jsxs("tbody",{children:[E.map(O=>o.jsxs("tr",{onClick:()=>e({view:"agents",agentId:O.agent.id}),children:[o.jsx("td",{children:o.jsxs("div",{className:"s-ops-agents-agent-cell",children:[o.jsx("span",{className:`s-ops-agents-status s-ops-agents-status--${O.state}`}),o.jsxs("span",{children:[o.jsx("strong",{children:O.agent.name}),o.jsx("small",{children:Pn(O.agent.state)})]})]})}),o.jsx("td",{children:O.team}),o.jsx("td",{children:O.machine}),o.jsx("td",{className:"s-ops-agents-num",children:O.activeFlights}),o.jsx("td",{className:"s-ops-agents-num",children:O.sessions24h}),o.jsx("td",{children:o.jsx(iK,{values:O.throughput,warn:O.errors>0})}),o.jsx("td",{className:"s-ops-agents-num",children:sk(O.avgLatencyMs)}),o.jsx("td",{className:"s-ops-agents-num",children:ac(O.usage.uncachedInput??O.usage.input)}),o.jsx("td",{className:"s-ops-agents-num",children:ac(O.usage.cachedInput)}),o.jsx("td",{className:"s-ops-agents-num",children:ac(O.usage.cacheWrite)}),o.jsx("td",{className:"s-ops-agents-num",children:ac(O.usage.output)}),o.jsx("td",{className:`s-ops-agents-num${O.cost.rateCardSource==="unknown"?" s-ops-agents-num--dim":""}`,children:Bd(O.cost.totalUsd)}),o.jsx("td",{className:`s-ops-agents-num${O.cost.billingMode==="subscription"?" s-ops-agents-num--covered":""}`,children:Bd(O.cost.billedTotalUsd)}),o.jsx("td",{className:`s-ops-agents-num${O.errors>0?" s-ops-agents-num--warn":""}`,children:O.errors}),o.jsx("td",{className:"s-ops-agents-last",children:O.lastActiveAt?De(O.lastActiveAt):"—"})]},O.agent.id)),E.length===0&&o.jsx("tr",{children:o.jsx("td",{colSpan:15,className:"s-ops-agents-empty",children:"No agents match the current search."})})]})]})})]})]})]})}function Vd({label:e,value:t,sub:n,tone:s="default"}){return o.jsxs("div",{className:`s-ops-agents-metric s-ops-agents-metric--${s}`,children:[o.jsx("div",{className:"s-ops-agents-metric-label",children:e}),o.jsx("div",{className:"s-ops-agents-metric-value",children:t}),o.jsx("div",{className:"s-ops-agents-metric-sub",children:n})]})}const gb={proposed:{label:"PROPOSED",icon:"◌",color:"var(--dim)"},committed:{label:"COMMITTED",icon:"◐",color:"var(--accent)"},inflight:{label:"IN FLIGHT",icon:"◉",color:"var(--green)"},done:{label:"DONE",icon:"●",color:"var(--muted)"},stuck:{label:"STUCK",icon:"▲",color:"var(--amber)"}};function vb(e){const t=[e];return e.children&&e.children.forEach(n=>t.push(...vb(n))),t}function mM(e,t){if(e.id===t)return e;if(!e.children)return null;for(const n of e.children){const s=mM(n,t);if(s)return s}return null}function rk(e,t){return vb(e).filter(n=>n.kind==="task"&&n.assigneeId===t).length}function gM(e){switch(e){case"done":return 1;case"inflight":return .7;case"committed":return .32;case"stuck":return .18;default:return .1}}function dK(e){return(e.currentPhase||e.state).replace(/\s+/g," ")}function fK(e){return e.state==="done"?"done":e.attention==="interrupt"||e.attention==="badge"||e.state==="waiting"||e.state==="review"?"stuck":e.state==="working"||e.activeFlightCount>0||e.currentPhase==="Working"||e.currentPhase==="Waking"?"inflight":"committed"}function hK(e){switch(e.status){case"working":return"inflight";case"completed":return"done";case"needs_attention":case"failed":return"stuck";default:return"committed"}}function vM(e,t){return typeof e!="number"||!Number.isFinite(e)?null:Math.max(0,Math.round((t-e)/6e4))}function pK(e){return e.recordId?{view:"work",workId:e.recordId}:e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.agentId?{view:"agents",agentId:e.agentId}:null}function yb(e){return e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.collaborationRecordId?{view:"work",workId:e.collaborationRecordId}:{view:"agents",agentId:e.agentId}}function mK(e,t){const n=fK(e),s=e.lastMeaningfulSummary??e.summary??null;return{id:`work:${e.id}`,kind:"task",title:e.title,summary:e.summary??e.lastMeaningfulSummary??null,state:n,assigneeId:e.ownerId??e.nextMoveOwnerId,detail:s,why:e.summary??`Current phase: ${dK(e)}`,progress:gM(n),stuckMins:n==="stuck"?vM(e.lastMeaningfulAt,t):null,updatedAt:e.lastMeaningfulAt,route:{view:"work",workId:e.id}}}function gK(e,t){const n=hK(e);return{id:`ask:${e.invocationId}`,kind:"task",title:e.task,summary:e.summary,state:n,assigneeId:e.agentId,detail:e.summary??e.statusLabel,why:`Ask status: ${e.statusLabel}`,progress:gM(n),stuckMins:n==="stuck"?vM(e.updatedAt,t):null,updatedAt:e.updatedAt,route:yb(e)}}function vK(e,t,n){const s=[];for(const a of e.slice(0,4))s.push({id:`risk:attention:${a.recordId}`,title:a.title,detail:a.summary??(a.kind==="question"?"Waiting on an answer or decision.":"Waiting on the next operator move."),severity:a.kind==="question"?"high":"med"});for(const a of n){if(s.length>=4)break;a.attention==="interrupt"&&s.push({id:`risk:work:${a.id}`,title:a.title,detail:a.lastMeaningfulSummary??"Latest flight failed or the work item is blocked.",severity:"high"})}for(const a of t){if(s.length>=4)break;a.status==="failed"&&s.push({id:`risk:ask:${a.invocationId}`,title:a.task,detail:a.summary??"The delegated ask reported a failure state.",severity:"high"})}return s}const yM=10080*6e4,bM=720*6e4,Zf={blocked:{label:"Blocked",color:"var(--amber)"},active:{label:"Active",color:"var(--green)"},queued:{label:"Queued",color:"var(--accent)"},complete:{label:"Complete",color:"var(--muted)"},needs_review:{label:"Review",color:"var(--amber)"}};function yK(e){return e==="done"||e==="cancelled"}function bK(e,t){const n=[e,...t];return n.some(s=>s.attention!=="silent"||s.state==="waiting"||s.state==="review")?"blocked":n.some(s=>s.state==="working"||s.activeFlightCount>0)?"active":n.every(s=>yK(s.state))?e.acceptanceState==="pending"?"needs_review":"complete":"queued"}function xK(e){return e.status==="failed"||e.status==="needs_attention"?"blocked":e.status==="working"?"active":e.status==="queued"?"queued":"needs_review"}function wK(e,t,n){const s=[e,...t],a=Math.max(...s.map(h=>h.lastMeaningfulAt||h.updatedAt||h.createdAt)),l=s.some(h=>h.attention!=="silent"||h.state==="waiting"||h.state==="review"),u=s.some(h=>h.state==="working"||h.activeFlightCount>0),d=s.every(h=>h.state==="done"),p=s.some(h=>h.state==="open");return l?{state:"blocked",label:"Needs operator check",summary:"A child item is waiting, in review, or marked for attention.",detail:"Completion cannot be trusted until the blocking state is resolved."}:u?{state:"in_progress",label:"Still moving",summary:"At least one item or flight is still active.",detail:"The plan should stay in the ongoing set."}:d?n-a>bM?{state:"needs_review",label:"Done, needs freshness check",summary:"The plan is marked done, but the last meaningful update is no longer fresh.",detail:"Ask the owner to confirm whether the completion state is still accurate."}:{state:"verified",label:"Recently completed",summary:"All visible items are marked done with a recent meaningful update.",detail:"This looks current from the available collaboration state."}:p?{state:"not_started",label:"Queued",summary:"The plan has open work but no active execution signal yet.",detail:"It is ready to be picked up or clarified."}:{state:"needs_review",label:"Needs review",summary:"The plan is in a terminal or quiet state without enough signal to verify completion.",detail:"Use the owner review path before treating this as closed."}}function jK(e,t){if(e.status==="failed"||e.status==="needs_attention")return{state:"blocked",label:"Needs operator check",summary:e.summary??"The ask is blocked or failed.",detail:"Completion cannot be trusted until the ask is resolved."};if(e.status==="queued"||e.status==="working")return{state:"in_progress",label:e.status==="queued"?"Queued":"Still moving",summary:e.summary??e.task,detail:"The ask has not reported a terminal result yet."};const n=e.completedAt??e.updatedAt;return t-n>bM?{state:"needs_review",label:"Completed, needs freshness check",summary:e.summary??e.task,detail:"The completion is older than the review window."}:{state:"verified",label:"Recently completed",summary:e.summary??e.task,detail:"The ask completed recently."}}function xM(e,t){return(t.get(e.id)??[]).flatMap(s=>[s,...xM(s,t)])}function wM(e,t,n){const s=(t.get(e.id)??[]).sort((l,u)=>u.lastMeaningfulAt-l.lastMeaningfulAt).map(l=>wM(l,t,n));return{...mK(e,n),children:s.length>0?s:void 0}}function SK(e){const t=e.map(n=>n.progress).filter(n=>typeof n=="number");return t.length===0?0:t.reduce((n,s)=>n+s,0)/t.length}function NK(e,t){const n=new Set;for(const s of e){const a=s.ownerId?t[s.ownerId]:null,l=s.nextMoveOwnerId?t[s.nextMoveOwnerId]:null;a?.harness&&n.add(a.harness),l?.harness&&n.add(l.harness)}return[...n].sort()}function kK(e,t,n,s){const a=xM(e,t),l=wM(e,t,s),u=vb(l).filter(x=>x.kind==="task"),d=bK(e,a),p=wK(e,a,s),h=l.children&&l.children.length>0?l.children:[l],m={...l,id:`plan:${e.id}`,kind:"mission",badge:`${u.length} item${u.length===1?"":"s"}`,progress:u.length>0?SK(u):l.progress,children:h},y=[e,...a];return{id:`work:${e.id}`,source:"work",title:e.title,summary:e.summary??e.lastMeaningfulSummary,status:d,createdAt:e.createdAt,updatedAt:Math.max(...y.map(x=>x.lastMeaningfulAt||x.updatedAt||x.createdAt)),ownerId:e.ownerId??e.nextMoveOwnerId,ownerName:e.ownerName??e.nextMoveOwnerName,harnesses:NK(y,n),root:m,leafNodes:u,route:{view:"work",workId:e.id},completion:p}}function EK(e,t){const n=gK(e,t),s={...n,id:`plan:ask:${e.invocationId}`,kind:"mission",badge:e.statusLabel,children:[n]};return{id:`ask:${e.invocationId}`,source:"ask",title:e.task,summary:e.summary,status:xK(e),createdAt:e.startedAt??e.updatedAt,updatedAt:e.updatedAt,ownerId:e.agentId,ownerName:e.agentName??e.agentId,harnesses:e.harness?[e.harness]:[],root:s,leafNodes:[n],route:yb(e),completion:jK(e,t)}}function CK(e){return new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function TK(e){const t=e.leafNodes.slice(0,6).map(a=>`- ${gb[a.state].label}: ${a.title}`).join(`
|
|
156
|
-
`),n=e.leafNodes.length>6?`
|
|
157
|
-
- ${e.leafNodes.length-6} more item${e.leafNodes.length-6===1?"":"s"}`:"",s=`${t||"- No visible child items"}${n}`;return["Can you evaluate completion for this plan and update the collaboration state if needed?","",`Plan: ${e.title}`,`Current status: ${Zf[e.status].label}`,`Completion signal: ${e.completion.label}`,`Last visible update: ${CK(e.updatedAt)}`,"",e.completion.summary,e.completion.detail,"","Visible items:",s,"","Please check whether this is actually done, what remains, and whether the plan record is stale."].join(`
|
|
158
|
-
`)}function AK(e){const t=new Map;for(const n of e)if(n.status==="fulfilled")for(const s of n.value)t.set(s.id,s);return[...t.values()]}function RK(e,t,n){return t==="all"?!0:t==="ongoing"?e.status!=="complete":n-Math.max(e.createdAt,e.updatedAt)<=yM}function MK(e,t){const n={blocked:0,active:1,queued:2,needs_review:3,complete:4},s=n[e.status]-n[t.status];return s!==0?s:t.updatedAt-e.updatedAt}function _K({navigate:e,agents:t}){const[n,s]=g.useState(null),[a,l]=g.useState([]),[u,d]=g.useState(null),[p,h]=g.useState(null),[m,y]=g.useState("plan"),[x,w]=g.useState("ongoing"),[j,N]=g.useState(()=>Date.now()),[k,E]=g.useState("loading"),[C,S]=g.useState(null),R=g.useRef(0),A=g.useCallback(async()=>{const O=++R.current,[D,H,W]=await Promise.allSettled([Re("/api/fleet"),Re("/api/work?limit=250"),Re("/api/work?active=false&limit=250")]);if(O!==R.current)return;D.status==="fulfilled"&&s(D.value),(H.status==="fulfilled"||W.status==="fulfilled")&&l(AK([H,W]));const q=[D.status==="rejected"?`fleet: ${D.reason instanceof Error?D.reason.message:String(D.reason)}`:null,H.status==="rejected"?`active work: ${H.reason instanceof Error?H.reason.message:String(H.reason)}`:null,W.status==="rejected"?`recent work: ${W.reason instanceof Error?W.reason.message:String(W.reason)}`:null].filter($=>!!$);S(q.length>0?q.join(" · "):null),E("ready"),N(Date.now())},[]);g.useEffect(()=>{A()},[A]),Rn(()=>{A()}),g.useEffect(()=>{const O=setInterval(()=>N(Date.now()),15e3);return()=>clearInterval(O)},[]);const M=g.useMemo(()=>Object.fromEntries(t.map(O=>[O.id,O])),[t]),_=g.useMemo(()=>{const O=new Map(a.map(G=>[G.id,G])),D=new Map;for(const G of a)if(G.parentId&&O.has(G.parentId)){const I=D.get(G.parentId)??[];I.push(G),D.set(G.parentId,I)}const W=a.filter(G=>!G.parentId||!O.has(G.parentId)).map(G=>kK(G,D,M,j)),q=new Set(a.map(G=>G.id)),$=[...n?.activeAsks??[],...n?.recentCompleted??[]].filter(G=>!G.collaborationRecordId||!q.has(G.collaborationRecordId)).map(G=>EK(G,j)),L=[...W,...$].sort(MK),F=L.filter(G=>RK(G,x,j)),X=new Set;for(const G of L)G.harnesses.forEach(I=>X.add(I));return{records:L,visibleRecords:F,risks:vK(n?.needsAttention??[],n?.activeAsks??[],a),recentCompleted:(n?.recentCompleted??[]).slice(0,4),pendingAttention:n?.needsAttention??[],harnesses:[...X].sort(),counts:{ongoing:L.filter(G=>G.status!=="complete").length,recent:L.filter(G=>j-Math.max(G.createdAt,G.updatedAt)<=yM).length,review:L.filter(G=>G.completion.state==="needs_review").length,blocked:L.filter(G=>G.status==="blocked").length}}},[M,x,n,j,a]),z=g.useMemo(()=>_.records.find(O=>O.id===u)??_.visibleRecords[0]??_.records[0]??null,[_.records,_.visibleRecords,u]),V=p&&z?mM(z.root,p):null,U=k==="loading"&&_.records.length===0;return g.useEffect(()=>{const O=_.visibleRecords[0]?.id??_.records[0]?.id??null;(!u||!_.records.some(D=>D.id===u))&&d(O)},[_.records,_.visibleRecords,u]),g.useEffect(()=>{if(!z){p!==null&&h(null);return}V||h(z.root.id)},[p,V,z]),o.jsx("div",{className:"s-plan",children:o.jsxs("div",{className:"s-plan-inner s-plan-inner--registry",children:[o.jsxs("div",{className:"s-plan-banner",children:[o.jsx("span",{className:"s-plan-banner-badge",children:"Plans"}),o.jsx("span",{className:"s-plan-banner-meta",children:U?"loading plan registry...":`${_.records.length} record${_.records.length===1?"":"s"} · ${_.counts.ongoing} ongoing · ${_.counts.recent} recent · ${_.counts.review} review · ${_.harnesses.length||"no"} harness${_.harnesses.length===1?"":"es"}`}),C&&o.jsxs("span",{className:"s-plan-banner-meta s-plan-banner-meta--error",children:["partial data · ",C]}),o.jsx("span",{style:{flex:1}}),n&&o.jsxs("span",{className:"s-plan-banner-meta",children:["updated ",De(n.generatedAt)]}),o.jsx("button",{className:"s-ops-btn",onClick:()=>e({view:"fleet"}),children:"Open fleet"}),o.jsx("button",{className:"s-ops-btn",onClick:()=>e({view:"sessions"}),children:"Sessions"})]}),o.jsxs("div",{className:"s-plan-col",children:[o.jsx("div",{className:"s-ops-eyebrow",children:"Plan index"}),o.jsx("div",{className:"s-plan-filterbar",children:["ongoing","recent","all"].map(O=>o.jsx("button",{type:"button",className:`s-plan-tree-toggle-btn${x===O?" s-plan-tree-toggle-btn--active":""}`,onClick:()=>w(O),children:O},O))}),o.jsx("div",{className:"s-plan-record-list",children:_.visibleRecords.length===0?o.jsxs("div",{className:"s-plan-change-card",children:[o.jsx("div",{className:"s-plan-change-summary",children:U?"Loading plan registry":C&&_.records.length===0?"Plan data did not load":"No matching plan records"}),o.jsx("div",{className:"s-plan-change-why",children:U?"Fetching collaboration records, active asks, and recent finishes.":C&&_.records.length===0?C:_.records.length===0?"No collaboration records or recent asks are available yet.":"Switch filters to inspect older or completed records."})]}):_.visibleRecords.map(O=>o.jsx(OK,{record:O,selected:O.id===z?.id,onSelect:()=>{d(O.id),h(O.root.id)}},O.id))}),o.jsx("div",{className:"s-ops-eyebrow",style:{marginTop:24},children:"Risks · watch"}),_.risks.length===0?o.jsxs("div",{className:"s-plan-change-card",children:[o.jsx("div",{className:"s-plan-change-summary",children:"No active blockers"}),o.jsx("div",{className:"s-plan-change-why",children:"The queue is clear of explicit questions, failed asks, and blocked work items."})]}):_.risks.map(O=>o.jsx($K,{risk:O},O.id))]}),o.jsxs("div",{className:"s-plan-col",style:{padding:"20px 16px 40px"},children:[z&&o.jsxs("div",{className:"s-plan-readonly-head",children:[o.jsxs("div",{children:[o.jsx("div",{className:"s-ops-eyebrow",children:"Read-only plan"}),o.jsx("h1",{className:"s-plan-title",children:z.title}),o.jsx("p",{className:"s-plan-goal",children:z.summary??z.completion.summary})]}),o.jsx("span",{className:"s-ops-state-chip",style:{color:Zf[z.status].color},children:Zf[z.status].label})]}),o.jsxs("div",{className:"s-plan-tree-header",children:[o.jsx("div",{className:"s-ops-eyebrow",style:{marginBottom:0},children:"Execution tree"}),o.jsxs("span",{className:"s-plan-tree-stats",children:[z?.leafNodes.length??0," item",(z?.leafNodes.length??0)===1?"":"s"," · created ",z?De(z.createdAt):"never"," · updated ",z?De(z.updatedAt):"never"]}),o.jsx("div",{className:"s-plan-tree-toggle",children:["plan","live"].map(O=>o.jsx("button",{className:`s-plan-tree-toggle-btn${m===O?" s-plan-tree-toggle-btn--active":""}`,onClick:()=>y(O),children:O},O))})]}),z?o.jsx(jM,{node:z.root,depth:0,mode:m,selected:p??z.root.id,setSelected:h,agentsById:M,nowMs:j}):o.jsxs("div",{className:"s-plan-change-card",children:[o.jsx("div",{className:"s-plan-change-summary",children:U?"Loading plan registry":"No plan records yet"}),o.jsx("div",{className:"s-plan-change-why",children:U?"Resolving the latest collaboration state.":"Collaboration records and asks will appear here as they are created."})]})]}),o.jsxs("div",{className:"s-plan-col",style:{display:"flex",flexDirection:"column",gap:24},children:[z&&o.jsx(IK,{record:z,navigate:e}),V&&o.jsxs("div",{children:[o.jsx("div",{className:"s-ops-eyebrow",children:"Selected node"}),o.jsx(UK,{node:V,agentsById:M,navigate:e})]}),z&&o.jsxs("div",{children:[o.jsx("div",{className:"s-ops-eyebrow",children:"Agents on plan"}),t.filter(O=>rk(z.root,O.id)>0).length===0?o.jsxs("div",{className:"s-plan-change-card",children:[o.jsx("div",{className:"s-plan-change-summary",children:"No assigned owner"}),o.jsx("div",{className:"s-plan-change-why",children:"This record has no visible owner in the current fleet roster."})]}):t.map(O=>{const D=rk(z.root,O.id);return D===0?null:o.jsxs("div",{className:"s-plan-agent-row",children:[o.jsx("div",{className:"s-ops-avatar",style:{"--size":"22px",background:mt(O.name)},children:O.name[0]?.toUpperCase()}),o.jsxs("div",{className:"s-plan-agent-row-copy",children:[o.jsx("div",{className:"s-plan-agent-row-name",children:O.name}),o.jsxs("div",{className:"s-plan-agent-row-tasks",children:[D," item",D===1?"":"s"," · ",O.harness??"unknown harness"]})]})]},O.id)})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"s-ops-eyebrow",children:["Attention · ",_.pendingAttention.length]}),_.pendingAttention.length===0?o.jsxs("div",{className:"s-plan-change-card",children:[o.jsx("div",{className:"s-plan-change-summary",children:"Nothing is waiting on you"}),o.jsx("div",{className:"s-plan-change-why",children:"Questions, reviews, and blocked work items will show up here as soon as operator input is required."})]}):_.pendingAttention.slice(0,3).map(O=>o.jsx(zK,{item:O,navigate:e},O.recordId))]}),o.jsxs("div",{children:[o.jsxs("div",{className:"s-ops-eyebrow",children:["Recent finishes · ",_.recentCompleted.length]}),_.recentCompleted.length===0?o.jsxs("div",{className:"s-plan-change-card",children:[o.jsx("div",{className:"s-plan-change-summary",children:"No recent completions"}),o.jsx("div",{className:"s-plan-change-why",children:"Completed asks will land here so you can review what just finished without leaving the plan view."})]}):_.recentCompleted.map(O=>o.jsx(LK,{ask:O,navigate:e},O.invocationId))]})]})]})})}function OK({record:e,selected:t,onSelect:n}){const s=Zf[e.status];return o.jsxs("button",{type:"button",className:`s-plan-record${t?" s-plan-record--selected":""}`,onClick:n,children:[o.jsxs("div",{className:"s-plan-record-top",children:[o.jsx("span",{className:"s-plan-change-kind",style:{color:s.color},children:s.label}),o.jsx("span",{className:"s-plan-record-source",children:e.source}),o.jsx("span",{className:"s-plan-record-time",children:De(e.updatedAt)})]}),o.jsx("div",{className:"s-plan-record-title",children:e.title}),o.jsx("div",{className:"s-plan-record-summary",children:e.summary??e.completion.summary}),o.jsxs("div",{className:"s-plan-record-foot",children:[o.jsxs("span",{children:[e.leafNodes.length," item",e.leafNodes.length===1?"":"s"]}),o.jsx("span",{children:e.ownerName??e.ownerId??"unassigned"}),o.jsx("span",{children:e.harnesses.length>0?e.harnesses.join(", "):"unknown harness"})]})]})}function IK({record:e,navigate:t}){const n=e.completion.state==="verified"?"var(--green)":e.completion.state==="blocked"||e.completion.state==="needs_review"?"var(--amber)":"var(--accent)";return o.jsxs("div",{className:"s-plan-detail s-plan-completion",children:[o.jsx("div",{className:"s-ops-eyebrow",children:"Completion"}),o.jsxs("div",{className:"s-plan-detail-header",children:[o.jsx("span",{className:"s-ops-state-chip",style:{color:n},children:e.completion.label}),o.jsxs("span",{className:"s-plan-record-time",children:["updated ",De(e.updatedAt)]})]}),o.jsx("div",{className:"s-plan-detail-title",children:e.completion.summary}),o.jsx("div",{className:"s-plan-detail-why",children:e.completion.detail}),o.jsxs("div",{className:"s-plan-detail-actions",children:[e.route&&o.jsx("button",{className:"s-ops-btn s-ops-btn--primary",onClick:()=>t(e.route),children:"Open editor"}),e.ownerId&&o.jsx("button",{className:"s-ops-btn",onClick:()=>t({view:"conversation",conversationId:Dn(e.ownerId),composeMode:"ask",composeDraft:TK(e)}),children:"Evaluate with owner"})]})]})}function jM({node:e,depth:t,mode:n,selected:s,setSelected:a,agentsById:l,nowMs:u}){const d=e.children&&e.children.length>0;return o.jsxs("div",{children:[o.jsx(DK,{node:e,depth:t,mode:n,selected:s===e.id,onClick:()=>a(e.id),agentsById:l,nowMs:u}),d&&o.jsx("div",{className:t===0?void 0:"s-plan-node-children",children:e.children.map(p=>o.jsx(jM,{node:p,depth:t+1,mode:n,selected:s,setSelected:a,agentsById:l,nowMs:u},p.id))})]})}function DK({node:e,depth:t,mode:n,selected:s,onClick:a,agentsById:l,nowMs:u}){const d=gb[e.state],p=e.assigneeId?l[e.assigneeId]:null,h=e.kind==="mission",m=e.kind==="phase",y=h?"mission":m?"phase":"task";return o.jsxs("div",{className:`s-plan-node s-plan-node--${y}${s?" s-plan-node--selected":""}`,onClick:a,children:[!h&&o.jsx("span",{className:"s-plan-node-icon",style:{color:d.color},children:d.icon}),o.jsxs("div",{className:"s-plan-node-title-wrap",children:[o.jsx("div",{className:"s-plan-node-title-row",style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap"},children:o.jsx("span",{className:`s-plan-node-title s-plan-node-title--${y}${e.state==="done"?" s-plan-node-title--done":""}`,children:e.title})}),o.jsx("div",{className:`s-plan-node-payload${n==="live"?" s-plan-node-payload--live":""}`,children:n==="plan"?o.jsx("span",{children:e.why??e.summary??"—"}):o.jsx(PK,{node:e,nowMs:u})})]}),!h&&o.jsx("div",{className:"s-plan-node-assignee",children:p?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"s-ops-avatar",style:{"--size":"18px",background:mt(p.name)},children:p.name[0]?.toUpperCase()}),o.jsx("span",{className:"s-plan-node-assignee-handle",children:p.handle?`@${p.handle}`:p.name})]}):o.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10.5,color:"var(--dim)"},children:"unassigned"})}),!h&&o.jsxs("div",{className:"s-plan-node-right",children:[o.jsx("div",{className:"s-plan-confidence-bar",children:o.jsx("div",{className:"s-plan-confidence-bar-fill",style:{width:`${(e.progress??0)*100}%`,background:d.color}})}),o.jsx("span",{className:"s-ops-state-chip",style:{color:d.color},children:d.label})]}),h&&o.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:10.5,color:"var(--dim)",letterSpacing:"0.08em"},children:e.badge??"LIVE"})]})}function PK({node:e,nowMs:t}){return e.state==="done"?o.jsxs("span",{style:{opacity:.55},children:["✓ completed ",e.updatedAt?De(e.updatedAt):"recently"]}):e.state==="stuck"?o.jsxs("span",{style:{color:"var(--amber)"},children:["▲ ",e.detail??"blocked",e.stuckMins?` · ${e.stuckMins}m`:""]}):e.state==="inflight"?o.jsxs("span",{children:["› ",e.detail??"working",e.updatedAt?` · ${De(e.updatedAt)}`:""]}):e.state==="committed"?o.jsxs("span",{children:["◐ ",e.detail??"queued",e.updatedAt?` · ${De(e.updatedAt)}`:""]}):o.jsxs("span",{style:{opacity:.55},children:["◌ waiting for first live signal ",e.updatedAt?De(e.updatedAt):""]})}function zK({item:e,navigate:t}){const n=pK(e);return o.jsxs("div",{className:"s-plan-change-card",children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[o.jsx("span",{className:"s-plan-change-kind",style:{color:"var(--amber)"},children:e.kind==="question"?"question":"work item"}),o.jsx("span",{style:{flex:1}}),o.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--dim)"},children:De(e.updatedAt)})]}),o.jsx("div",{className:"s-plan-change-summary",children:e.title}),o.jsx("div",{className:"s-plan-change-why",children:e.summary??`${e.state.replace(/_/g," ")} · ${e.acceptanceState.replace(/_/g," ")}`}),n&&o.jsx("div",{className:"s-plan-change-actions",children:o.jsx("button",{className:"s-ops-btn s-ops-btn--primary",style:{flex:1},onClick:()=>t(n),children:"Open item"})})]})}function LK({ask:e,navigate:t}){const n=yb(e);return o.jsxs("div",{className:"s-plan-change-card s-plan-change-card--accepted",children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[o.jsx("span",{className:"s-plan-change-kind",style:{color:"var(--green)"},children:e.status}),o.jsx("span",{style:{flex:1}}),o.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--dim)"},children:De(e.completedAt??e.updatedAt)})]}),o.jsx("div",{className:"s-plan-change-summary",children:e.summary??e.task}),o.jsxs("div",{className:"s-plan-change-why",children:[e.agentName??e.agentId," · ",e.task]}),n&&o.jsx("div",{className:"s-plan-change-actions",children:o.jsx("button",{className:"s-ops-btn",style:{flex:1},onClick:()=>t(n),children:"Open thread"})})]})}function $K({risk:e}){return o.jsxs("div",{className:"s-plan-risk",children:[o.jsx("span",{className:`s-plan-risk-icon s-plan-risk-icon--${e.severity}`,children:"▲"}),o.jsxs("div",{children:[o.jsx("div",{className:"s-plan-risk-title",children:e.title}),o.jsx("div",{className:"s-plan-risk-detail",children:e.detail})]})]})}function UK({node:e,agentsById:t,navigate:n}){const s=gb[e.state],a=e.assigneeId?t[e.assigneeId]:null;return o.jsxs("div",{className:"s-plan-detail",children:[o.jsxs("div",{className:"s-plan-detail-header",children:[o.jsx("span",{style:{color:s.color},children:s.icon}),o.jsx("span",{className:"s-ops-state-chip",style:{color:s.color,fontSize:10},children:s.label})]}),o.jsx("div",{className:"s-plan-detail-title",children:e.title}),(e.summary||e.detail||e.why)&&o.jsx("div",{className:"s-plan-detail-why",children:e.summary??e.detail??e.why}),a&&o.jsxs("div",{className:"s-plan-detail-assignee",children:[o.jsx("div",{className:"s-ops-avatar",style:{"--size":"22px",background:mt(a.name)},children:a.name[0]?.toUpperCase()}),o.jsxs("div",{style:{flex:1},children:[o.jsx("div",{style:{fontSize:12.5},children:a.name}),o.jsxs("div",{style:{fontSize:10.5,color:"var(--dim)",fontFamily:"var(--font-mono)"},children:[a.project??"—"," · ",a.branch??"main"]})]})]}),o.jsxs("div",{className:"s-plan-detail-actions",children:[e.route&&o.jsx("button",{className:"s-ops-btn s-ops-btn--primary",onClick:()=>n(e.route),children:"Open item"}),a&&o.jsx("button",{className:"s-ops-btn",onClick:()=>n({view:"conversation",conversationId:Dn(a.id),composeMode:"tell"}),children:"Tell owner"}),a&&o.jsx("button",{className:"s-ops-btn",onClick:()=>n({view:"conversation",conversationId:Dn(a.id),composeMode:"ask"}),children:"Ask owner"})]})]})}const ak=48,ik=720;function BK(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(!t)return null;const n=JSON.parse(t);if(!n||typeof n!="object")return null;const s={};for(const[a,l]of Object.entries(n))typeof l=="number"&&Number.isFinite(l)&&l>0&&(s[a]=l);return s}catch{return null}}function Og(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}function VK({storageKey:e,columns:t}){const n=g.useMemo(()=>{const x=BK(e)??{},w={};for(const j of t)w[j.key]=x[j.key]??j.defaultWidth;return w},[e,t]),[s,a]=g.useState(n);g.useEffect(()=>{a(x=>{let w=!1;const j={...x};for(const N of t)j[N.key]==null&&(j[N.key]=N.defaultWidth,w=!0);return w?j:x})},[t]);const l=g.useMemo(()=>{const x=new Map;for(const w of t)x.set(w.key,w);return x},[t]),u=g.useRef(null),d=g.useCallback(x=>{const w=u.current;if(!w)return;const j=x.clientX-w.startX,N=Math.min(w.max,Math.max(w.min,w.startWidth+j));a(k=>k[w.key]===N?k:{...k,[w.key]:N})},[]),p=g.useCallback(()=>{u.current&&(u.current=null,document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p),a(x=>(Og(e,x),x)))},[d,e]);g.useEffect(()=>()=>{window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p)},[d,p]);const h=g.useCallback(x=>{const w=s[x],j=l.get(x),N=j?.minWidth??ak,k=j?.maxWidth??ik;return{style:{width:w,minWidth:N,maxWidth:k},"data-resize-key":x}},[s,l]),m=g.useCallback(x=>({onPointerDown:k=>{if(k.button!==0)return;k.preventDefault(),k.stopPropagation();const E=l.get(x),C=E?.minWidth??ak,S=E?.maxWidth??ik,R=s[x]??E?.defaultWidth??C;u.current={key:x,startX:k.clientX,startWidth:R,min:C,max:S},document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("pointermove",d),window.addEventListener("pointerup",p),window.addEventListener("pointercancel",p)},onClick:k=>{k.stopPropagation()},onDoubleClick:k=>{k.preventDefault(),k.stopPropagation();const E=l.get(x);E&&a(C=>{const S={...C,[x]:E.defaultWidth};return Og(e,S),S})},role:"separator","aria-orientation":"vertical","aria-label":"Resize column",className:"s-resize-handle"}),[s,l,d,p,e]),y=g.useCallback(()=>{a(()=>{const x={};for(const w of t)x[w.key]=w.defaultWidth;return Og(e,x),x})},[t,e]);return{widths:s,getColumnProps:h,getResizeHandleProps:m,resetAll:y}}var FK=Object.create,SM=Object.defineProperty,HK=Object.getOwnPropertyDescriptor,NM=Object.getOwnPropertyNames,qK=Object.getPrototypeOf,ZK=Object.prototype.hasOwnProperty,fr=(e,t)=>function(){return t||(0,e[NM(e)[0]])((t={exports:{}}).exports,t),t.exports},WK=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=NM(t),l=0,u=a.length,d;l<u;l++)d=a[l],!ZK.call(e,d)&&d!==n&&SM(e,d,{get:(p=>t[p]).bind(null,d),enumerable:!(s=HK(t,d))||s.enumerable});return e},nn=(e,t,n)=>(n=e!=null?FK(qK(e)):{},WK(SM(n,"default",{value:e,enumerable:!0}),e)),kM=fr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(e,t){function n(s){"@babel/helpers - typeof";return t.exports=n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},t.exports.__esModule=!0,t.exports.default=t.exports,n(s)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),YK=fr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(e,t){var n=kM().default;function s(a,l){if(n(a)!="object"||!a)return a;var u=a[Symbol.toPrimitive];if(u!==void 0){var d=u.call(a,l||"default");if(n(d)!="object")return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return(l==="string"?String:Number)(a)}t.exports=s,t.exports.__esModule=!0,t.exports.default=t.exports}}),GK=fr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(e,t){var n=kM().default,s=YK();function a(l){var u=s(l,"string");return n(u)=="symbol"?u:u+""}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports}}),Ai=fr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(e,t){var n=GK();function s(a,l,u){return(l=n(l))in a?Object.defineProperty(a,l,{value:u,enumerable:!0,configurable:!0,writable:!0}):a[l]=u,a}t.exports=s,t.exports.__esModule=!0,t.exports.default=t.exports}}),Hs=fr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(e,t){var n=Ai();function s(l,u){var d=Object.keys(l);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(l);u&&(p=p.filter(function(h){return Object.getOwnPropertyDescriptor(l,h).enumerable})),d.push.apply(d,p)}return d}function a(l){for(var u=1;u<arguments.length;u++){var d=arguments[u]!=null?arguments[u]:{};u%2?s(Object(d),!0).forEach(function(p){n(l,p,d[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(d)):s(Object(d)).forEach(function(p){Object.defineProperty(l,p,Object.getOwnPropertyDescriptor(d,p))})}return l}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports}});function su(e){const t={subscribe(n){let s=null,a=!1,l=!1,u=!1;function d(){if(s===null){u=!0;return}l||(l=!0,typeof s=="function"?s():s&&s.unsubscribe())}return s=e({next(p){var h;a||(h=n.next)===null||h===void 0||h.call(n,p)},error(p){var h;a||(a=!0,(h=n.error)===null||h===void 0||h.call(n,p),d())},complete(){var p;a||(a=!0,(p=n.complete)===null||p===void 0||p.call(n),d())}}),u&&d(),{unsubscribe:d}},pipe(...n){return n.reduce(KK,t)}};return t}function KK(e,t){return t(e)}function XK(e){const t=new AbortController;return new Promise((s,a)=>{let l=!1;function u(){l||(l=!0,d.unsubscribe())}t.signal.addEventListener("abort",()=>{a(t.signal.reason)});const d=e.subscribe({next(p){l=!0,s(p),u()},error(p){a(p)},complete(){t.abort(),u()}})})}function JK(e){return t=>{let n=0,s=null;const a=[];function l(){s||(s=t.subscribe({next(d){for(const h of a){var p;(p=h.next)===null||p===void 0||p.call(h,d)}},error(d){for(const h of a){var p;(p=h.error)===null||p===void 0||p.call(h,d)}},complete(){for(const p of a){var d;(d=p.complete)===null||d===void 0||d.call(p)}}}))}function u(){if(n===0&&s){const d=s;s=null,d.unsubscribe()}}return su(d=>(n++,a.push(d),l(),{unsubscribe(){n--,u();const p=a.findIndex(h=>h===d);p>-1&&a.splice(p,1)}}))}}function EM(e){let t=e;const n=[],s=u=>{t!==void 0&&u.next(t),n.push(u)},a=u=>{n.splice(n.indexOf(u),1)},l=su(u=>(s(u),()=>{a(u)}));return l.next=u=>{if(t!==u){t=u;for(const d of n)d.next(u)}},l.get=()=>t,l}function QK(e){return su(t=>{function n(a=0,l=e.op){const u=e.links[a];if(!u)throw new Error("No more links to execute - did you forget to add an ending link?");return u({op:l,next(p){return n(a+1,p)}})}return n().subscribe(t)})}function Vc(e){return!!e&&!Array.isArray(e)&&typeof e=="object"}function eX(){return Object.create(null)}const ok=e=>e();function lk(e=0){return new Promise(t=>setTimeout(t,e))}var tX=Object.create,CM=Object.defineProperty,nX=Object.getOwnPropertyDescriptor,TM=Object.getOwnPropertyNames,sX=Object.getPrototypeOf,rX=Object.prototype.hasOwnProperty,ru=(e,t)=>function(){return t||(0,e[TM(e)[0]])((t={exports:{}}).exports,t),t.exports},aX=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=TM(t),l=0,u=a.length,d;l<u;l++)d=a[l],!rX.call(e,d)&&d!==n&&CM(e,d,{get:(p=>t[p]).bind(null,d),enumerable:!(s=nX(t,d))||s.enumerable});return e},xh=(e,t,n)=>(n=e!=null?tX(sX(e)):{},aX(CM(n,"default",{value:e,enumerable:!0}),e));const AM=()=>{},ck=e=>{Object.freeze&&Object.freeze(e)};function RM(e,t,n){var s;const a=t.join(".");return(s=n[a])!==null&&s!==void 0||(n[a]=new Proxy(AM,{get(l,u){if(!(typeof u!="string"||u==="then"))return RM(e,[...t,u],n)},apply(l,u,d){const p=t[t.length-1];let h={args:d,path:t};return p==="call"?h={args:d.length>=2?[d[1]]:[],path:t.slice(0,-1)}:p==="apply"&&(h={args:d.length>=2?d[1]:[],path:t.slice(0,-1)}),ck(h.args),ck(h.path),e(h)}})),n[a]}const iX=e=>RM(e,[],eX()),oX=e=>new Proxy(AM,{get(t,n){if(n!=="then")return e(n)}});var MM=ru({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(e,t){function n(s){"@babel/helpers - typeof";return t.exports=n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},t.exports.__esModule=!0,t.exports.default=t.exports,n(s)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),lX=ru({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(e,t){var n=MM().default;function s(a,l){if(n(a)!="object"||!a)return a;var u=a[Symbol.toPrimitive];if(u!==void 0){var d=u.call(a,l||"default");if(n(d)!="object")return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return(l==="string"?String:Number)(a)}t.exports=s,t.exports.__esModule=!0,t.exports.default=t.exports}}),cX=ru({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(e,t){var n=MM().default,s=lX();function a(l){var u=s(l,"string");return n(u)=="symbol"?u:u+""}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports}}),_M=ru({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(e,t){var n=cX();function s(a,l,u){return(l=n(l))in a?Object.defineProperty(a,l,{value:u,enumerable:!0,configurable:!0,writable:!0}):a[l]=u,a}t.exports=s,t.exports.__esModule=!0,t.exports.default=t.exports}}),bb=ru({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(e,t){var n=_M();function s(l,u){var d=Object.keys(l);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(l);u&&(p=p.filter(function(h){return Object.getOwnPropertyDescriptor(l,h).enumerable})),d.push.apply(d,p)}return d}function a(l){for(var u=1;u<arguments.length;u++){var d=arguments[u]!=null?arguments[u]:{};u%2?s(Object(d),!0).forEach(function(p){n(l,p,d[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(d)):s(Object(d)).forEach(function(p){Object.defineProperty(l,p,Object.getOwnPropertyDescriptor(d,p))})}return l}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports}});xh(bb());xh(_M());var Fd=xh(bb());function uX(e,t){if("error"in e){const s=t.deserialize(e.error);return{ok:!1,error:(0,Fd.default)((0,Fd.default)({},e),{},{error:s})}}return{ok:!0,result:(0,Fd.default)((0,Fd.default)({},e.result),(!e.result.type||e.result.type==="data")&&{type:"data",data:t.deserialize(e.result.data)})}}var Ig=class extends Error{constructor(){super("Unable to transform response from server")}};function dX(e,t){let n;try{n=uX(e,t)}catch{throw new Ig}if(!n.ok&&(!Vc(n.error.error)||typeof n.error.error.code!="number"))throw new Ig;if(n.ok&&!Vc(n.result))throw new Ig;return n}xh(bb());var Hd=nn(Ai()),jo=nn(Hs());function fX(e){return e instanceof ui}function hX(e){return Vc(e)&&Vc(e.error)&&typeof e.error.code=="number"&&typeof e.error.message=="string"}function pX(e,t){return typeof e=="string"?e:Vc(e)&&typeof e.message=="string"?e.message:t}var ui=class uf extends Error{constructor(t,n){var s,a;const l=n?.cause;super(t,{cause:l}),(0,Hd.default)(this,"cause",void 0),(0,Hd.default)(this,"shape",void 0),(0,Hd.default)(this,"data",void 0),(0,Hd.default)(this,"meta",void 0),this.meta=n?.meta,this.cause=l,this.shape=n==null||(s=n.result)===null||s===void 0?void 0:s.error,this.data=n==null||(a=n.result)===null||a===void 0?void 0:a.error.data,this.name="TRPCClientError",Object.setPrototypeOf(this,uf.prototype)}static from(t,n={}){const s=t;return fX(s)?(n.meta&&(s.meta=(0,jo.default)((0,jo.default)({},s.meta),n.meta)),s):hX(s)?new uf(s.error.message,(0,jo.default)((0,jo.default)({},n),{},{result:s,cause:n.cause})):new uf(pX(s,"Unknown error"),(0,jo.default)((0,jo.default)({},n),{},{cause:s}))}};function mX(e){const t=e;return t?"input"in t?t:{input:t,output:t}:{input:{serialize:n=>n,deserialize:n=>n},output:{serialize:n=>n,deserialize:n=>n}}}nn(Hs());nn(Hs());nn(Hs());nn(Hs());const gX={encode:e=>JSON.stringify(e),decode:e=>{if(typeof e!="string")throw new Error("jsonEncoder received binary data. JSON uses text frames. Use a binary encoder for binary data.");return JSON.parse(e)}},vX={enabled:!1,closeMs:0},yX={enabled:!1,pongTimeoutMs:1e3,intervalMs:5e3},bX=e=>e===0?0:Math.min(1e3*2**e,3e4),OM=(e,...t)=>typeof e=="function"?e(...t):e;var xX=nn(Ai()),So=class IM extends Error{constructor(t){super(t.message,{cause:t.cause}),this.name="TRPCWebSocketClosedError",Object.setPrototypeOf(this,IM.prototype)}},wX=class{constructor(e,t){this.onTimeout=e,this.timeoutMs=t,(0,xX.default)(this,"timeout",void 0)}reset(){this.timeout&&(clearTimeout(this.timeout),this.timeout=setTimeout(this.onTimeout,this.timeoutMs))}start(){clearTimeout(this.timeout),this.timeout=setTimeout(this.onTimeout,this.timeoutMs)}stop(){clearTimeout(this.timeout),this.timeout=void 0}};function DM(){let e,t;return{promise:new Promise((s,a)=>{e=s,t=a}),resolve:e,reject:t}}async function jX(e){const t=await OM(e.url);if(!e.connectionParams)return t;const s=`${t.includes("?")?"&":"?"}connectionParams=1`;return t+s}async function SX(e,t){const n={method:"connectionParams",data:await OM(e)};return t.encode(n)}var uk=nn(Ai()),NX=class{constructor(){(0,uk.default)(this,"outgoingRequests",new Array),(0,uk.default)(this,"pendingRequests",{})}register(e,t){const{promise:n,resolve:s}=DM();return this.outgoingRequests.push({id:String(e.id),message:e,end:n,callbacks:{next:t.next,complete:()=>{t.complete(),s()},error:a=>{t.error(a),s()}}}),()=>{this.delete(e.id),t.complete(),s()}}delete(e){e!==null&&(this.outgoingRequests=this.outgoingRequests.filter(({id:t})=>t!==String(e)),delete this.pendingRequests[String(e)])}flush(){const e=this.outgoingRequests;this.outgoingRequests=[];for(const t of e)this.pendingRequests[t.id]=t;return e}getPendingRequests(){return Object.values(this.pendingRequests)}getPendingRequest(e){return e===null?null:this.pendingRequests[String(e)]}getOutgoingRequests(){return this.outgoingRequests}getRequests(){return[...this.getOutgoingRequests().map(e=>({state:"outgoing",message:e.message,end:e.end,callbacks:e.callbacks})),...this.getPendingRequests().map(e=>({state:"pending",message:e.message,end:e.end,callbacks:e.callbacks}))]}hasPendingRequests(){return this.getPendingRequests().length>0}hasPendingSubscriptions(){return this.getPendingRequests().some(e=>e.message.method==="subscription")}hasOutgoingRequests(){return this.outgoingRequests.length>0}},ma=nn(Ai());function kX(e){const{promise:t,resolve:n,reject:s}=DM();return e.addEventListener("open",()=>{e.removeEventListener("error",s),n()}),e.addEventListener("error",s),t}function EX(e,{intervalMs:t,pongTimeoutMs:n}){let s,a;function l(){s=setTimeout(()=>{e.send("PING"),a=setTimeout(()=>{e.close()},n)},t)}function u(){clearTimeout(s),l()}function d(){clearTimeout(a),u()}e.addEventListener("open",l),e.addEventListener("message",({data:p})=>{clearTimeout(s),l(),p==="PONG"&&d()}),e.addEventListener("close",()=>{clearTimeout(s),clearTimeout(a)})}var PM=class Jv{constructor(t){var n;if((0,ma.default)(this,"id",++Jv.connectCount),(0,ma.default)(this,"WebSocketPonyfill",void 0),(0,ma.default)(this,"urlOptions",void 0),(0,ma.default)(this,"keepAliveOpts",void 0),(0,ma.default)(this,"encoder",void 0),(0,ma.default)(this,"wsObservable",EM(null)),(0,ma.default)(this,"openPromise",null),this.WebSocketPonyfill=(n=t.WebSocketPonyfill)!==null&&n!==void 0?n:WebSocket,!this.WebSocketPonyfill)throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");this.urlOptions=t.urlOptions,this.keepAliveOpts=t.keepAlive,this.encoder=t.encoder}get ws(){return this.wsObservable.get()}set ws(t){this.wsObservable.next(t)}isOpen(){return!!this.ws&&this.ws.readyState===this.WebSocketPonyfill.OPEN&&!this.openPromise}isClosed(){return!!this.ws&&(this.ws.readyState===this.WebSocketPonyfill.CLOSING||this.ws.readyState===this.WebSocketPonyfill.CLOSED)}async open(){var t=this;if(t.openPromise)return t.openPromise;t.id=++Jv.connectCount;const n=jX(t.urlOptions).then(s=>new t.WebSocketPonyfill(s));t.openPromise=n.then(async s=>{t.ws=s,s.binaryType="arraybuffer",s.addEventListener("message",function({data:a}){a==="PING"&&this.send("PONG")}),t.keepAliveOpts.enabled&&EX(s,t.keepAliveOpts),s.addEventListener("close",()=>{t.ws===s&&(t.ws=null)}),await kX(s),t.urlOptions.connectionParams&&s.send(await SX(t.urlOptions.connectionParams,t.encoder))});try{await t.openPromise}finally{t.openPromise=null}}async close(){var t=this;try{await t.openPromise}finally{var n;(n=t.ws)===null||n===void 0||n.close()}}};(0,ma.default)(PM,"connectCount",0);function CX(e){return e.isOpen()?{id:e.id,state:"open",ws:e.ws}:e.isClosed()?{id:e.id,state:"closed",ws:e.ws}:e.ws?{id:e.id,state:"connecting",ws:e.ws}:null}var Js=nn(Ai()),No=nn(Hs()),TX=class{constructor(e){var t,n;(0,Js.default)(this,"connectionState",void 0),(0,Js.default)(this,"allowReconnect",!1),(0,Js.default)(this,"requestManager",new NX),(0,Js.default)(this,"activeConnection",void 0),(0,Js.default)(this,"reconnectRetryDelay",void 0),(0,Js.default)(this,"inactivityTimeout",void 0),(0,Js.default)(this,"callbacks",void 0),(0,Js.default)(this,"lazyMode",void 0),(0,Js.default)(this,"encoder",void 0),(0,Js.default)(this,"reconnecting",null),this.encoder=(t=e.experimental_encoder)!==null&&t!==void 0?t:gX,this.callbacks={onOpen:e.onOpen,onClose:e.onClose,onError:e.onError};const s=(0,No.default)((0,No.default)({},vX),e.lazy);this.inactivityTimeout=new wX(()=>{if(this.requestManager.hasOutgoingRequests()||this.requestManager.hasPendingRequests()){this.inactivityTimeout.reset();return}this.close().catch(()=>null)},s.closeMs),this.activeConnection=new PM({WebSocketPonyfill:e.WebSocket,urlOptions:e,keepAlive:(0,No.default)((0,No.default)({},yX),e.keepAlive),encoder:this.encoder}),this.activeConnection.wsObservable.subscribe({next:a=>{a&&this.setupWebSocketListeners(a)}}),this.reconnectRetryDelay=(n=e.retryDelayMs)!==null&&n!==void 0?n:bX,this.lazyMode=s.enabled,this.connectionState=EM({type:"state",state:s.enabled?"idle":"connecting",error:null}),this.lazyMode||this.open().catch(()=>null)}async open(){var e=this;e.allowReconnect=!0,e.connectionState.get().state==="idle"&&e.connectionState.next({type:"state",state:"connecting",error:null});try{await e.activeConnection.open()}catch(t){return e.reconnect(new So({message:"Initialization error",cause:t})),e.reconnecting}}async close(){var e=this;e.allowReconnect=!1,e.inactivityTimeout.stop();const t=[];for(const n of e.requestManager.getRequests())n.message.method==="subscription"?n.callbacks.complete():n.state==="outgoing"?n.callbacks.error(ui.from(new So({message:"Closed before connection was established"}))):t.push(n.end);await Promise.all(t).catch(()=>null),await e.activeConnection.close().catch(()=>null),e.connectionState.next({type:"state",state:"idle",error:null})}request({op:{id:e,type:t,path:n,input:s,signal:a},transformer:l,lastEventId:u}){return su(d=>{const p=this.batchSend({id:e,method:t,params:{input:l.input.serialize(s),path:n,lastEventId:u}},(0,No.default)((0,No.default)({},d),{},{next(h){const m=dX(h,l.output);if(!m.ok){d.error(ui.from(m.error));return}d.next({result:m.result})}}));return()=>{p(),t==="subscription"&&this.activeConnection.isOpen()&&this.send({id:e,method:"subscription.stop"}),a?.removeEventListener("abort",p)}})}get connection(){return CX(this.activeConnection)}reconnect(e){var t=this;if(this.connectionState.next({type:"state",state:"connecting",error:ui.from(e)}),this.reconnecting)return;const n=async s=>{try{await lk(t.reconnectRetryDelay(s)),t.allowReconnect&&(await t.activeConnection.close(),await t.activeConnection.open(),t.requestManager.hasPendingRequests()&&t.send(t.requestManager.getPendingRequests().map(({message:a})=>a))),t.reconnecting=null}catch{await n(s+1)}};this.reconnecting=n(0)}setupWebSocketListeners(e){var t=this;const n=s=>{const a=this.requestManager.getPendingRequests();for(const{message:l,callbacks:u}of a)l.method!=="subscription"&&(u.error(ui.from(s??new So({message:"WebSocket closed",cause:s}))),this.requestManager.delete(l.id))};e.addEventListener("open",()=>{ok(async()=>{var s,a;t.lazyMode&&t.inactivityTimeout.start(),(s=(a=t.callbacks).onOpen)===null||s===void 0||s.call(a),t.connectionState.next({type:"state",state:"pending",error:null})}).catch(s=>{e.close(3e3),n(s)})}),e.addEventListener("message",({data:s})=>{if(this.inactivityTimeout.reset(),["PING","PONG"].includes(s))return;const a=this.encoder.decode(s);if("method"in a){this.handleIncomingRequest(a);return}this.handleResponseMessage(a)}),e.addEventListener("close",s=>{var a,l;n(s),(a=(l=this.callbacks).onClose)===null||a===void 0||a.call(l,s),(!this.lazyMode||this.requestManager.hasPendingSubscriptions())&&this.reconnect(new So({message:"WebSocket closed",cause:s}))}),e.addEventListener("error",s=>{var a,l;n(s),(a=(l=this.callbacks).onError)===null||a===void 0||a.call(l,s),this.reconnect(new So({message:"WebSocket closed",cause:s}))})}handleResponseMessage(e){const t=this.requestManager.getPendingRequest(e.id);if(!t)return;t.callbacks.next(e);let n=!0;"result"in e&&t.message.method==="subscription"&&(e.result.type==="data"&&(t.message.params.lastEventId=e.result.id),e.result.type!=="stopped"&&(n=!1)),n&&(t.callbacks.complete(),this.requestManager.delete(e.id))}handleIncomingRequest(e){e.method==="reconnect"&&this.reconnect(new So({message:"Server requested reconnect"}))}send(e){if(!this.activeConnection.isOpen())throw new Error("Active connection is not open");const t=e instanceof Array?e:[e];this.activeConnection.ws.send(this.encoder.encode(t.length===1?t[0]:t))}batchSend(e,t){var n=this;return this.inactivityTimeout.reset(),ok(async()=>{n.activeConnection.isOpen()||await n.open(),await lk(0),n.requestManager.hasOutgoingRequests()&&n.send(n.requestManager.flush().map(({message:s})=>s))}).catch(s=>{this.requestManager.delete(e.id),t.error(ui.from(s))}),this.requestManager.register(e,t)}};function AX(e){return new TX(e)}function RX(e){const{client:t}=e,n=mX(e.transformer);return()=>({op:s})=>su(a=>{const l=s.type==="subscription"?t.connectionState.subscribe({next(d){a.next({result:d,context:s.context})}}):null,u=t.request({op:s,transformer:n}).subscribe(a);return()=>{u.unsubscribe(),l?.unsubscribe()}})}var Dg=nn(Ai()),dk=nn(Hs()),MX=class{constructor(e){(0,Dg.default)(this,"links",void 0),(0,Dg.default)(this,"runtime",void 0),(0,Dg.default)(this,"requestId",void 0),this.requestId=0,this.runtime={},this.links=e.links.map(t=>t(this.runtime))}$request(e){var t;return QK({links:this.links,op:(0,dk.default)((0,dk.default)({},e),{},{context:(t=e.context)!==null&&t!==void 0?t:{},id:++this.requestId})}).pipe(JK())}async requestAsPromise(e){var t=this;try{const n=t.$request(e);return(await XK(n)).result.data}catch(n){throw ui.from(n)}}query(e,t,n){return this.requestAsPromise({type:"query",path:e,input:t,context:n?.context,signal:n?.signal})}mutation(e,t,n){return this.requestAsPromise({type:"mutation",path:e,input:t,context:n?.context,signal:n?.signal})}subscription(e,t,n){return this.$request({type:"subscription",path:e,input:t,context:n.context,signal:n.signal}).subscribe({next(a){switch(a.result.type){case"state":{var l;(l=n.onConnectionStateChange)===null||l===void 0||l.call(n,a.result);break}case"started":{var u;(u=n.onStarted)===null||u===void 0||u.call(n,{context:a.context});break}case"stopped":{var d;(d=n.onStopped)===null||d===void 0||d.call(n);break}case"data":case void 0:{var p;(p=n.onData)===null||p===void 0||p.call(n,a.result.data);break}}},error(a){var l;(l=n.onError)===null||l===void 0||l.call(n,a)},complete(){var a;(a=n.onComplete)===null||a===void 0||a.call(n)}})}};const _X=Symbol.for("trpc_untypedClient"),OX={query:"query",mutate:"mutation",subscribe:"subscription"},IX=e=>OX[e];function DX(e){const t=iX(({path:n,args:s})=>{const a=[...n],l=IX(a.pop()),u=a.join(".");return e[l](u,...s)});return oX(n=>n===_X?e:t[n])}function PX(e){const t=new MX(e);return DX(t)}nn(Hs());nn(Hs());var zX=fr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(e,t){function n(a){var l,u,d,p=2;for(typeof Symbol<"u"&&(u=Symbol.asyncIterator,d=Symbol.iterator);p--;){if(u&&(l=a[u])!=null)return l.call(a);if(d&&(l=a[d])!=null)return new s(l.call(a));u="@@asyncIterator",d="@@iterator"}throw new TypeError("Object is not async iterable")}function s(a){function l(u){if(Object(u)!==u)return Promise.reject(new TypeError(u+" is not an object."));var d=u.done;return Promise.resolve(u.value).then(function(p){return{value:p,done:d}})}return s=function(d){this.s=d,this.n=d.next},s.prototype={s:null,n:null,next:function(){return l(this.n.apply(this.s,arguments))},return:function(d){var p=this.s.return;return p===void 0?Promise.resolve({value:d,done:!0}):l(p.apply(this.s,arguments))},throw:function(d){var p=this.s.return;return p===void 0?Promise.reject(d):l(p.apply(this.s,arguments))}},new s(a)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}});nn(zX());nn(Hs());var LX=fr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(e,t){function n(){var s=typeof SuppressedError=="function"?SuppressedError:function(d,p){var h=Error();return h.name="SuppressedError",h.error=d,h.suppressed=p,h},a={},l=[];function u(d,p){if(p!=null){if(Object(p)!==p)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(d)var h=p[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(h===void 0&&(h=p[Symbol.dispose||Symbol.for("Symbol.dispose")],d))var m=h;if(typeof h!="function")throw new TypeError("Object is not disposable.");m&&(h=function(){try{m.call(p)}catch(x){return Promise.reject(x)}}),l.push({v:p,d:h,a:d})}else d&&l.push({d:p,a:d});return p}return{e:a,u:u.bind(null,!1),a:u.bind(null,!0),d:function(){var p,h=this.e,m=0;function y(){for(;p=l.pop();)try{if(!p.a&&m===1)return m=0,l.push(p),Promise.resolve().then(y);if(p.d){var w=p.d.call(p.v);if(p.a)return m|=2,Promise.resolve(w).then(y,x)}else m|=1}catch(j){return x(j)}if(m===1)return h!==a?Promise.reject(h):Promise.resolve();if(h!==a)throw h}function x(w){return h=h!==a?new s(w,h):w,y()}return y()}}}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),zM=fr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(e,t){function n(s,a){this.v=s,this.k=a}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),$X=fr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(e,t){var n=zM();function s(a){return new n(a,0)}t.exports=s,t.exports.__esModule=!0,t.exports.default=t.exports}}),UX=fr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(e,t){var n=zM();function s(l){return function(){return new a(l.apply(this,arguments))}}function a(l){var u,d;function p(m,y){try{var x=l[m](y),w=x.value,j=w instanceof n;Promise.resolve(j?w.v:w).then(function(N){if(j){var k=m==="return"?"return":"next";if(!w.k||N.done)return p(k,N);N=l[k](N).value}h(x.done?"return":"normal",N)},function(N){p("throw",N)})}catch(N){h("throw",N)}}function h(m,y){switch(m){case"return":u.resolve({value:y,done:!0});break;case"throw":u.reject(y);break;default:u.resolve({value:y,done:!1})}(u=u.next)?p(u.key,u.arg):d=null}this._invoke=function(m,y){return new Promise(function(x,w){var j={key:m,arg:y,resolve:x,reject:w,next:null};d?d=d.next=j:(u=d=j,p(m,y))})},typeof l.return!="function"&&(this.return=void 0)}a.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},a.prototype.next=function(l){return this._invoke("next",l)},a.prototype.throw=function(l){return this._invoke("throw",l)},a.prototype.return=function(l){return this._invoke("return",l)},t.exports=s,t.exports.__esModule=!0,t.exports.default=t.exports}});nn(LX());nn($X());nn(UX());nn(Hs());const df=new Set;let Pg=null,fk=null,Wf=null;function BX(){return`ws://${typeof window<"u"?window.location.hostname:"127.0.0.1"}:65535/trpc`}function VX(e){for(const t of[...df])t(e)}function FX(){Wf||(Pg||(Pg=AX({url:BX()}),fk=PX({links:[RX({client:Pg})]})),Wf=fk.tail.events.subscribe(void 0,{onData:e=>{const t=e.data;t&&VX(t)}}))}function HX(){Wf?.unsubscribe(),Wf=null}function LM(e){const t=g.useRef(e);t.current=e,g.useEffect(()=>{const n=s=>t.current(s);return df.add(n),FX(),()=>{df.delete(n),df.size===0&&HX()}},[])}const hk=4e3,qX=500,ZX=5e3,WX=5e3,YX=6e4,Yf={"scout-managed":"scout","hudson-managed":"hudson",unattributed:"native"},xb={tool:"working",run:"active",idle:"idle"};function Qv(e){const t=e.split(/\s+/)[0]??"",n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function GX(e,t=60){const n=e.split(/\s+/);if(n.length===0)return e;n[0]=Qv(n[0]);const s=n.join(" ");return s.length<=t?s:s.slice(0,t-1)+"…"}function KX(e){for(const t of e){const n=Qv(t.command);if(n&&!(n==="sh"||n==="zsh"||n==="bash"||n==="login"))return n}return e[0]?.command?Qv(e[0].command):"—"}function XX(e){const t=e.match(/^(?:(\d+)-)?(?:(\d+):)?(\d+):(\d+)$/);if(!t){const d=e.match(/^(\d+)$/);return d?Number.parseInt(d[1],10):0}const[,n,s,a,l]=t;let u=Number.parseInt(l,10)+Number.parseInt(a,10)*60;return s&&(u+=Number.parseInt(s,10)*3600),n&&(u+=Number.parseInt(n,10)*86400),u}function $M(e){if(e<60)return`${e}s`;if(e<3600)return`${Math.floor(e/60)}m${String(e%60).padStart(2,"0")}`;if(e<86400){const s=Math.floor(e/3600),a=Math.floor(e%3600/60);return`${s}h${String(a).padStart(2,"0")}`}const t=Math.floor(e/86400),n=Math.floor(e%86400/3600);return`${t}d${String(n).padStart(2,"0")}h`}function UM(e,t){if(e==null)return"—";const n=Math.max(0,Math.round((t-e)/1e3));return n<2?"just now":n<60?`${n}s ago`:n<3600?`${Math.floor(n/60)}m ago`:`${Math.floor(n/3600)}h ago`}function JX(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}`}function ey(e){return e?e.slice(0,8):"—"}function BM(e){return e?.trim().toLowerCase()||"unknown"}function QX(e){return BM(e).replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function wb(e){return`s-atop-chip s-atop-chip--harness s-atop-chip--harness-${QX(e)}`}const eJ=/permission-mode/i;function tJ(e){return e.kind!=="system"?!1:eJ.test(e.summary)}function VM(e){return e.kind==="assistant"}function nJ(e,t,n){if(!e)return[];const s=new Map;for(const a of t){let l=s.get(a.pid);l||(l={firstEventAt:a.ts,lastEventAt:a.ts,lastKind:a.kind,lastSummary:a.summary,reqCount:0,toolCount:0,permCount:0,eventCount:0,sessionId:a.sessionId||null,model:null,tokIn:null,tokOut:null,cacheReadIn:null,cacheWriteIn:null},s.set(a.pid,l)),a.ts<l.firstEventAt&&(l.firstEventAt=a.ts),a.ts>=l.lastEventAt&&(l.lastEventAt=a.ts,l.lastKind=a.kind,l.lastSummary=a.summary),l.eventCount++,a.kind==="tool"&&l.toolCount++,VM(a)&&l.reqCount++,tJ(a)&&l.permCount++,a.sessionId&&!l.sessionId&&(l.sessionId=a.sessionId)}return e.processes.map(a=>{const l=s.get(a.pid);let u="idle";l&&n-l.lastEventAt<WX&&(u=l.lastKind==="tool"?"tool":"run");const d=XX(a.etime),p=l?.firstEventAt??null,h=l&&l.firstEventAt<l.lastEventAt?Math.min(Math.max(0,Math.round((l.lastEventAt-l.firstEventAt)/1e3)),d||Number.POSITIVE_INFINITY):0;return{pid:a.pid,ppid:a.ppid,sessionId:l?.sessionId??null,harness:BM(a.source),attribution:a.harness,project:a.cwd?sJ(a.cwd):"(unknown)",cwd:a.cwd??"",command:a.command,parentLabel:KX(a.parentChain??[]),procRuntimeSec:d,procEtime:a.etime,sessionStartAt:p,sessionRuntimeSec:h,status:u,lastEventAt:l?.lastEventAt??null,lastEventKind:l?.lastKind??null,lastSummary:l?.lastSummary??null,reqCount:l?.reqCount??0,toolCount:l?.toolCount??0,permCount:l?.permCount??0,eventCount:l?.eventCount??0,model:l?.model??null,tokIn:l?.tokIn??null,tokOut:l?.tokOut??null,cacheReadIn:l?.cacheReadIn??null,cacheWriteIn:l?.cacheWriteIn??null}})}function Fc(e){if(e.cacheReadIn==null||e.tokIn==null)return null;const t=e.cacheReadIn+e.tokIn;return t===0?null:e.cacheReadIn/t}function li(e){return e==null?"—":e===0?"0":e>=1e6?(e/1e6).toFixed(e>=1e7?0:1)+"M":e>=1e3?(e/1e3).toFixed(e>=1e4?0:1)+"k":String(e)}function FM(e){return e==null?"—":`${Math.round(e*100)}%`}function sJ(e){if(!e)return"";const t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function rJ(e,t,n){const s=n-YX;let a=0;for(const d of t)VM(d)&&d.ts>=s&&a++;const l={total:e.length,running:0,tooling:0,idle:0,harnesses:[],reqsPerMin:a},u=new Map;for(const d of e)d.status==="tool"?(l.tooling++,l.running++):d.status==="run"?l.running++:l.idle++,u.set(d.harness,(u.get(d.harness)??0)+1);return l.harnesses=[...u.entries()].map(([d,p])=>({harness:d,count:p})).sort((d,p)=>p.count-d.count||d.harness.localeCompare(p.harness)),l}const Gf={tool:0,run:1,idle:2};function ko(e){return e??-1}function aJ(e,t,n,s){switch(n){case"status":return(Gf[e.status]-Gf[t.status])*s;case"agent":{const a=e.harness.localeCompare(t.harness);return a!==0?a*s:(e.sessionId??"").localeCompare(t.sessionId??"")*s}case"project":return e.project.localeCompare(t.project)*s;case"reqs":return(e.reqCount-t.reqCount)*s;case"tokIn":return(ko(e.tokIn)-ko(t.tokIn))*s;case"tokOut":return(ko(e.tokOut)-ko(t.tokOut))*s;case"cache":return(ko(Fc(e))-ko(Fc(t)))*s;case"tools":return(e.toolCount-t.toolCount)*s;case"perms":return(e.permCount-t.permCount)*s;case"last":{const a=e.lastEventAt??0,l=t.lastEventAt??0;return(a-l)*s}case"runtime":return(e.sessionRuntimeSec-t.sessionRuntimeSec)*s}}function pk({values:e,color:t}){if(e.length<2)return o.jsx("svg",{className:"s-atop-spark",width:88,height:18,viewBox:"0 0 88 18"});const a=Math.max(1,...e),l=88/(e.length-1),u=e.map((d,p)=>`${(p*l).toFixed(1)},${(18-d/a*18).toFixed(1)}`).join(" ");return o.jsx("svg",{className:"s-atop-spark",width:88,height:18,viewBox:"0 0 88 18",children:o.jsx("polyline",{fill:"none",stroke:t,strokeWidth:"1.25",points:u})})}function iJ(){const[e,t]=g.useState([]),[n,s]=g.useState(null),[a,l]=g.useState(()=>Date.now()),[u,d]=g.useState(""),[p,h]=g.useState(()=>new Set),[m,y]=g.useState(()=>new Set),[x,w]=g.useState("status"),[j,N]=g.useState(1),[k,E]=g.useState(null),C=g.useRef([]),S=g.useRef([]),[R,A]=g.useState([]),[M,_]=g.useState([]),z=g.useCallback(I=>{t(B=>B.length>=hk?[...B.slice(B.length-hk+1),I]:[...B,I])},[]);LM(z),g.useEffect(()=>{let I=!1;return(async()=>{try{const B=await Re(`/api/tail/recent?limit=${qX}`);I||t(B.events??[])}catch{}})(),()=>{I=!0}},[]);const V=g.useCallback(async()=>{try{const I=await Re("/api/tail/discover");s(I)}catch{}},[]);g.useEffect(()=>{V();const I=setInterval(()=>{V()},ZX);return()=>clearInterval(I)},[V]),g.useEffect(()=>{const I=setInterval(()=>l(Date.now()),1e3);return()=>clearInterval(I)},[]);const U=g.useMemo(()=>nJ(n,e,a),[n,e,a]),O=g.useMemo(()=>rJ(U,e,a),[U,e,a]);g.useEffect(()=>{C.current=[...C.current,O.running].slice(-24),S.current=[...S.current,O.tooling].slice(-24),A(C.current),_(S.current)},[O.running,O.tooling]);const D=g.useMemo(()=>{const I=new Set;return U.forEach(B=>I.add(B.harness)),[...I]},[U]),H=g.useMemo(()=>{const I=new Set;return U.forEach(B=>I.add(B.status)),[...I]},[U]),W=g.useMemo(()=>{const I=u.trim().toLowerCase();return U.filter(Y=>{if(p.size>0&&!p.has(Y.harness)||m.size>0&&!m.has(Y.status))return!1;if(!I)return!0;const Q=Yf[Y.attribution];return`${Y.pid} ${Y.project} ${Y.command} ${Y.harness} ${Y.attribution} ${Q} ${Y.sessionId??""} ${Y.lastSummary??""}`.toLowerCase().includes(I)}).slice().sort((Y,Q)=>{const me=Gf[Y.status]-Gf[Q.status];return me!==0&&x!=="status"?me:aJ(Y,Q,x,j)})},[U,u,p,m,x,j]);g.useEffect(()=>{k!=null&&(U.some(I=>I.pid===k)||E(null))},[U,k]),g.useEffect(()=>{const I=B=>{const Y=B.target,Q=Y instanceof HTMLInputElement||Y instanceof HTMLTextAreaElement||(Y?.isContentEditable??!1);if(B.key==="Escape"&&k!=null){B.preventDefault(),E(null);return}if(!Q&&(B.key==="j"||B.key==="k")){if(W.length===0)return;B.preventDefault();const me=W.findIndex(ie=>ie.pid===k),re=B.key==="j"?W[Math.min(W.length-1,me<0?0:me+1)]:W[Math.max(0,me<0?0:me-1)];re&&E(re.pid)}};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[W,k]);const q=I=>{x===I?N(B=>B===1?-1:1):(w(I),N(I==="project"||I==="agent"?1:-1))},$=I=>{h(B=>{const Y=new Set(B);return Y.has(I)?Y.delete(I):Y.add(I),Y})},L=I=>{y(B=>{const Y=new Set(B);return Y.has(I)?Y.delete(I):Y.add(I),Y})},F=g.useMemo(()=>k!=null?U.find(I=>I.pid===k)??null:null,[U,k]),X=g.useMemo(()=>k!=null?n?.processes.find(I=>I.pid===k)??null:null,[n,k]),G=g.useMemo(()=>k==null?[]:e.filter(I=>I.pid===k).slice(-40),[e,k]);return o.jsxs("div",{className:"s-atop",children:[o.jsx(oJ,{summary:O,runHistory:R,toolHistory:M}),o.jsx(lJ,{search:u,onSearch:d,harnessOptions:D,harnessFilter:p,onToggleHarness:$,statusOptions:H,statusFilter:m,onToggleStatus:L,summary:O}),o.jsx(uJ,{rows:W,sortKey:x,sortDir:j,onSort:q,selectedPid:k,onSelect:E,now:a}),o.jsx(dJ,{shown:W.length,total:U.length,hasSelection:k!=null}),F&&o.jsx(fJ,{row:F,process:X,events:G,now:a,onClose:()=>E(null)})]})}function oJ({summary:e,runHistory:t,toolHistory:n}){return o.jsxs("div",{className:"s-atop-summary",children:[o.jsxs("div",{className:"s-atop-summary-cell s-atop-summary-cell--primary",children:[o.jsxs("div",{className:"s-atop-summary-num",children:[o.jsx("strong",{children:e.running}),o.jsxs("span",{className:"s-atop-summary-of",children:["/ ",e.total]})]}),o.jsx("span",{className:"s-atop-summary-lbl",children:"active"}),o.jsx(pk,{values:t,color:"var(--green)"})]}),o.jsxs("div",{className:"s-atop-summary-cell",children:[o.jsx("div",{className:"s-atop-summary-num",children:o.jsx("strong",{children:e.tooling})}),o.jsx("span",{className:"s-atop-summary-lbl",children:"working"}),o.jsx(pk,{values:n,color:"var(--accent)"})]}),o.jsxs("div",{className:"s-atop-summary-cell",children:[o.jsx("div",{className:"s-atop-summary-num",children:o.jsx("strong",{children:e.idle})}),o.jsx("span",{className:"s-atop-summary-lbl",children:"idle"})]}),o.jsxs("div",{className:"s-atop-summary-cell s-atop-summary-cell--breakdown",children:[o.jsx("span",{className:"s-atop-summary-lbl",children:"harness"}),o.jsx("div",{className:"s-atop-summary-row",children:e.harnesses.length>0?e.harnesses.slice(0,4).map(s=>o.jsxs("span",{className:wb(s.harness),children:[s.harness," ",s.count]},s.harness)):o.jsx("span",{className:"s-atop-chip s-atop-chip--mute",children:"none"})})]}),o.jsx("div",{className:"s-atop-summary-spacer"}),o.jsxs("div",{className:"s-atop-summary-cell s-atop-summary-cell--rate",children:[o.jsxs("div",{className:"s-atop-summary-num",children:[o.jsx("strong",{children:e.reqsPerMin}),o.jsx("span",{className:"s-atop-summary-of",children:"/ min"})]}),o.jsx("span",{className:"s-atop-summary-lbl",children:"requests"})]})]})}function lJ({search:e,onSearch:t,harnessOptions:n,harnessFilter:s,onToggleHarness:a,statusOptions:l,statusFilter:u,onToggleStatus:d,summary:p}){const h=x=>p.harnesses.find(w=>w.harness===x)?.count??0,m=x=>x==="tool"?p.tooling:x==="run"?p.running-p.tooling:p.idle,y=g.useRef(null);return g.useEffect(()=>{const x=w=>{if(w.key!=="/")return;const j=w.target;j instanceof HTMLInputElement||j instanceof HTMLTextAreaElement||(j?.isContentEditable??!1)||(w.preventDefault(),y.current?.focus())};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[]),o.jsxs("div",{className:"s-atop-fbar",children:[o.jsxs("div",{className:"s-atop-search",children:[o.jsx("span",{className:"s-atop-search-prompt",children:"▸"}),o.jsx("input",{ref:y,className:"s-atop-search-input",value:e,onChange:x=>t(x.target.value),placeholder:"filter by pid · project · command · summary",spellCheck:!1}),o.jsx("span",{className:"s-atop-search-kbd",children:"/"})]}),n.length>1&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"s-atop-fbar-label",children:"harness"}),n.map(x=>{const w=s.has(x);return o.jsxs("button",{className:`s-atop-pill s-atop-pill--harness${w?" s-atop-pill--on":""}`,onClick:()=>a(x),children:[x,o.jsx("span",{className:"s-atop-pill-ct",children:h(x)})]},x)})]}),l.length>1&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"s-atop-fbar-label",children:"status"}),["tool","run","idle"].filter(x=>l.includes(x)).map(x=>{const w=u.has(x);return o.jsxs("button",{className:`s-atop-pill s-atop-pill--status-${x}${w?" s-atop-pill--on":""}`,onClick:()=>d(x),children:[xb[x],o.jsx("span",{className:"s-atop-pill-ct",children:m(x)})]},x)})]}),o.jsx("div",{className:"s-atop-fbar-spacer"})]})}const zg=[{key:"status",label:"Status",cls:"s-atop-col-status",defaultWidth:96,minWidth:70},{key:"agent",label:"Agent",cls:"s-atop-col-agent",tip:"Harness · short session id",defaultWidth:168,minWidth:110},{key:"project",label:"Project",cls:"s-atop-col-project",defaultWidth:200,minWidth:96,maxWidth:480},{key:"reqs",label:"Reqs",cls:"s-atop-col-num",tip:"Model invocations (assistant turns) for this session",defaultWidth:64,minWidth:56},{key:"tokIn",label:"Tok ↓",cls:"s-atop-col-num",tip:"Input tokens — populated when backend emits usage",defaultWidth:64,minWidth:56},{key:"tokOut",label:"Tok ↑",cls:"s-atop-col-num",tip:"Output tokens — populated when backend emits usage",defaultWidth:64,minWidth:56},{key:"cache",label:"Cache",cls:"s-atop-col-num",tip:"Cache hit rate — populated when backend emits usage",defaultWidth:64,minWidth:56},{key:"tools",label:"Tools",cls:"s-atop-col-num",defaultWidth:64,minWidth:56},{key:"perms",label:"Perms",cls:"s-atop-col-num",tip:"Permission requests — heuristic count of permission-mode events",defaultWidth:64,minWidth:56},{key:"last",label:"Last",cls:"s-atop-col-last",defaultWidth:86,minWidth:64},{key:"runtime",label:"Runtime",cls:"s-atop-col-runtime",tip:"Session duration (active period in current buffer)",defaultWidth:80,minWidth:64}];function ic({value:e,accent:t}){const n=e==null?"s-atop-col-num s-atop-col-num--dim":`s-atop-col-num${t?` s-atop-col-num--${t}`:""}`;return o.jsx("td",{className:n,children:li(e)})}function cJ({value:e}){const t=e==null?"s-atop-col-num s-atop-col-num--dim":"s-atop-col-num";return o.jsx("td",{className:t,children:FM(e)})}function uJ({rows:e,sortKey:t,sortDir:n,onSort:s,selectedPid:a,onSelect:l,now:u}){const{getColumnProps:d,getResizeHandleProps:p}=VK({storageKey:"openscout.atop.cols",columns:zg});return o.jsx("div",{className:"s-atop-table-wrap",children:o.jsxs("table",{className:"s-atop-table",children:[o.jsx("thead",{children:o.jsx("tr",{children:zg.map(h=>o.jsxs("th",{className:`${h.cls??""}${t===h.key?" s-atop-th--sorted":""}`,onClick:()=>s(h.key),title:h.tip,...d(h.key),children:[h.label,t===h.key&&o.jsx("span",{className:"s-atop-th-arrow",children:n===1?"↑":"↓"}),o.jsx("span",{...p(h.key)})]},h.key))})}),o.jsx("tbody",{children:e.length===0?o.jsx("tr",{className:"s-atop-empty-row",children:o.jsx("td",{colSpan:zg.length,children:o.jsxs("div",{className:"s-atop-empty",children:[o.jsx("span",{className:"s-atop-empty-title",children:"no agents match"}),o.jsx("span",{children:"adjust filters or start a session to populate"})]})})}):e.map(h=>o.jsxs("tr",{className:`s-atop-row${a===h.pid?" s-atop-row--selected":""}`,onClick:()=>l(h.pid),children:[o.jsx("td",{className:"s-atop-col-status",children:o.jsxs("span",{className:`s-atop-status s-atop-status--${h.status}`,children:[o.jsx("span",{className:"s-atop-status-dot"}),xb[h.status]]})}),o.jsxs("td",{className:"s-atop-col-agent",children:[o.jsx("span",{className:wb(h.harness),title:`origin: ${Yf[h.attribution]}`,children:h.harness}),o.jsx("span",{className:"s-atop-agent-id",title:h.sessionId??`pid ${h.pid}`,children:ey(h.sessionId)})]}),o.jsx("td",{className:"s-atop-col-project",title:h.cwd,children:h.project}),o.jsx(ic,{value:h.reqCount||null}),o.jsx(ic,{value:h.tokIn}),o.jsx(ic,{value:h.tokOut}),o.jsx(cJ,{value:Fc(h)}),o.jsx(ic,{value:h.toolCount||null}),o.jsx(ic,{value:h.permCount||null,accent:h.permCount>0?"amber":void 0}),o.jsx("td",{className:"s-atop-col-last",children:UM(h.lastEventAt,u)}),o.jsx("td",{className:"s-atop-col-runtime",children:$M(h.sessionRuntimeSec)})]},h.pid))})]})})}function dJ({shown:e,total:t,hasSelection:n}){return o.jsxs("div",{className:"s-atop-keys",children:[o.jsxs("span",{className:"s-atop-keys-count",children:[o.jsx("strong",{children:e})," / ",t," agents"]}),o.jsx("span",{className:"s-atop-keys-spacer"}),o.jsxs("span",{children:[o.jsx("kbd",{children:"/"})," filter"]}),o.jsxs("span",{children:[o.jsx("kbd",{children:"j"}),"/",o.jsx("kbd",{children:"k"})," select"]}),o.jsxs("span",{children:[o.jsx("kbd",{children:"click"})," drill in"]}),n&&o.jsxs("span",{children:[o.jsx("kbd",{children:"esc"})," close"]})]})}function fJ({row:e,process:t,events:n,now:s,onClose:a}){const l=g.useMemo(()=>{const d={};for(const m of n){if(m.kind!=="tool")continue;const y=m.summary.match(/^([a-z_][a-z0-9_]*)/i),x=y?y[1]:"(tool)";d[x]=(d[x]??0)+1}const p=Object.entries(d).sort((m,y)=>y[1]-m[1]).slice(0,6),h=Math.max(1,...p.map(m=>m[1]));return p.map(([m,y])=>({name:m,count:y,frac:y/h}))},[n]),u=n.slice(-40).reverse();return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"s-atop-drawer-bg",onClick:a}),o.jsxs("aside",{className:"s-atop-drawer",role:"dialog","aria-label":`Agent ${e.pid}`,children:[o.jsxs("header",{className:"s-atop-drawer-head",children:[o.jsxs("div",{className:"s-atop-drawer-head-meta",children:[o.jsxs("span",{className:`s-atop-status s-atop-status--${e.status}`,children:[o.jsx("span",{className:"s-atop-status-dot"}),xb[e.status]]}),o.jsxs("span",{className:"s-atop-drawer-pid",children:["pid ",e.pid]}),o.jsx("span",{className:wb(e.harness),title:`origin: ${Yf[e.attribution]}`,children:e.harness}),o.jsxs("span",{className:"s-atop-drawer-session",children:["session ",ey(e.sessionId)]})]}),o.jsx("h2",{className:"s-atop-drawer-title",children:e.project}),o.jsxs("p",{className:"s-atop-drawer-sub",children:["session ",ey(e.sessionId)," · runtime ",$M(e.sessionRuntimeSec)," · last activity ",UM(e.lastEventAt,s)]}),o.jsx("button",{className:"s-atop-drawer-close",onClick:a,"aria-label":"Close",children:"✕"})]}),o.jsxs("div",{className:"s-atop-drawer-body",children:[o.jsxs("section",{children:[o.jsx("h3",{className:"s-atop-drawer-h3",children:"Activity"}),o.jsxs("div",{className:"s-atop-metrics",children:[o.jsx(fa,{label:"Requests",value:li(e.reqCount||null)}),o.jsx(fa,{label:"Tools",value:li(e.toolCount||null)}),o.jsx(fa,{label:"Permissions",value:li(e.permCount||null),accent:e.permCount>0?"amber":void 0}),o.jsx(fa,{label:"Tok in",value:li(e.tokIn),dim:e.tokIn==null}),o.jsx(fa,{label:"Tok out",value:li(e.tokOut),dim:e.tokOut==null}),o.jsx(fa,{label:"Cache hit",value:FM(Fc(e)),dim:Fc(e)==null}),o.jsx(fa,{label:"Model",value:e.model??"—",dim:e.model==null}),o.jsx(fa,{label:"Events",value:li(e.eventCount||null)})]})]}),l.length>0&&o.jsxs("section",{children:[o.jsx("h3",{className:"s-atop-drawer-h3",children:"Tool calls"}),o.jsx("ul",{className:"s-atop-histo",children:l.map(d=>o.jsxs("li",{children:[o.jsx("span",{className:"s-atop-histo-name",children:d.name}),o.jsx("span",{className:"s-atop-histo-bar",children:o.jsx("span",{className:"s-atop-histo-fill",style:{width:`${(d.frac*100).toFixed(1)}%`}})}),o.jsx("span",{className:"s-atop-histo-count",children:d.count})]},d.name))})]}),o.jsxs("section",{children:[o.jsxs("h3",{className:"s-atop-drawer-h3",children:["Recent activity",o.jsxs("span",{className:"s-atop-drawer-h3-aside",children:[n.length," buffered"]})]}),u.length===0?o.jsx("div",{className:"s-atop-peek-empty",children:"no events buffered for this agent yet"}):o.jsx("ol",{className:"s-atop-peek",children:u.map(d=>o.jsxs("li",{className:`s-atop-peek-row s-atop-peek-row--${d.kind}`,children:[o.jsx("span",{className:"s-atop-peek-time",children:JX(d.ts)}),o.jsx("span",{className:"s-atop-peek-kind",children:d.kind}),o.jsx("span",{className:"s-atop-peek-text",children:d.summary})]},d.id))})]}),o.jsxs("section",{className:"s-atop-drawer-section--secondary",children:[o.jsx("h3",{className:"s-atop-drawer-h3",children:"Process"}),o.jsx("code",{className:"s-atop-codeblock",children:e.command}),o.jsxs("dl",{className:"s-atop-kvs",children:[o.jsx("dt",{children:"PID"}),o.jsx("dd",{children:e.pid}),o.jsx("dt",{children:"Parent"}),o.jsxs("dd",{children:[e.parentLabel," (ppid ",e.ppid,")"]}),o.jsx("dt",{children:"Process etime"}),o.jsx("dd",{children:e.procEtime}),o.jsx("dt",{children:"Origin"}),o.jsx("dd",{children:Yf[e.attribution]}),o.jsx("dt",{children:"CWD"}),o.jsx("dd",{children:e.cwd||"(none)"})]}),t?.parentChain&&t.parentChain.length>0&&o.jsx("ol",{className:"s-atop-chain",children:t.parentChain.map(d=>o.jsxs("li",{children:[o.jsx("span",{className:"s-atop-chain-pid",children:d.pid}),o.jsx("span",{className:"s-atop-chain-cmd",children:GX(d.command,80)})]},d.pid))})]})]})]})]})}function fa({label:e,value:t,dim:n,accent:s}){const a=`s-atop-metric${n?" s-atop-metric--dim":""}${s?` s-atop-metric--${s}`:""}`;return o.jsxs("div",{className:a,children:[o.jsx("span",{className:"s-atop-metric-lbl",children:e}),o.jsx("span",{className:"s-atop-metric-val",children:t})]})}const hJ=e=>e==="right"?"railOccupantRight":"railOccupantBottom";function pJ(e,t,n,s){g.useEffect(()=>{if(!n||typeof window>"u"||typeof document>"u")return;const a=hJ(e),l=document.body.dataset[a];document.body.dataset[a]=t,window.dispatchEvent(new CustomEvent("hudson:rail:claim",{detail:{owner:t,side:e}})),l&&l!==t&&window.dispatchEvent(new CustomEvent("hudson:rail:preempted",{detail:{owner:l,side:e,by:t}}));const u=p=>{const h=p.detail;h&&h.side===e&&h.owner!==t&&s?.()},d=p=>{const h=p.detail;h&&h.side===e&&h.owner===t&&s?.()};return window.addEventListener("hudson:rail:claim",u),window.addEventListener("hudson:rail:preempted",d),()=>{window.removeEventListener("hudson:rail:claim",u),window.removeEventListener("hudson:rail:preempted",d),document.body.dataset[a]===t&&delete document.body.dataset[a],window.dispatchEvent(new CustomEvent("hudson:rail:release",{detail:{owner:t,side:e}}))}},[e,t,n,s])}const mJ=620,gJ=360,vJ=280,yJ=900,bJ=720,mk=["a[href]","button:not([disabled])","textarea:not([disabled])","input:not([disabled])","select:not([disabled])","[tabindex]:not([tabindex='-1'])"].join(", ");function xJ({open:e,onClose:t,side:n="right",owner:s,defaultSize:a,minSize:l=vJ,maxSize:u,resizable:d=!1,backdrop:p=!0,scrollLock:h=!1,focusTrap:m=!1,ariaLabel:y,className:x,children:w}){const j=a??(n==="right"?mJ:gJ),N=u??(n==="right"?yJ:bJ),[k,E]=g.useState(j),[C,S]=g.useState(!1),R=g.useRef(null),A=g.useRef(null),M=g.useCallback(()=>t(),[t]);pJ(n,s,e,M),g.useEffect(()=>{if(!e)return;const V=U=>{U.key==="Escape"&&(U.preventDefault(),M())};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[e,M]),g.useEffect(()=>{if(!e||!h)return;const V=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=V}},[e,h]),g.useEffect(()=>{if(!e)return;A.current=document.activeElement;const V=R.current;return V?((V.querySelector(mk)??V).focus(),()=>{A.current?.focus?.()}):void 0},[e]),g.useEffect(()=>{if(!C)return;const V=O=>{if(n==="right"){const D=window.innerWidth-O.clientX;E(Math.min(N,Math.max(l,D)))}else{const D=window.innerHeight-O.clientY;E(Math.min(N,Math.max(l,D)))}},U=()=>S(!1);return window.addEventListener("pointermove",V),window.addEventListener("pointerup",U),window.addEventListener("pointercancel",U),()=>{window.removeEventListener("pointermove",V),window.removeEventListener("pointerup",U),window.removeEventListener("pointercancel",U)}},[C,n,l,N]);const _=V=>{if(!m||V.key!=="Tab")return;const U=R.current;if(!U)return;const O=Array.from(U.querySelectorAll(mk));if(O.length===0){V.preventDefault(),U.focus();return}const D=O[0],H=O[O.length-1],W=document.activeElement;V.shiftKey?(W===D||!U.contains(W))&&(V.preventDefault(),H.focus()):W===H&&(V.preventDefault(),D.focus())};if(!e)return null;const z=n==="right"?{width:k}:{height:k};return o.jsxs(o.Fragment,{children:[p&&o.jsx("div",{className:"s-slide-backdrop","data-side":n,onClick:M,"aria-hidden":"true"}),o.jsxs("aside",{ref:R,className:`s-slide s-slide--${n}${C?" s-slide--resizing":""}${x?` ${x}`:""}`,role:"dialog","aria-modal":"true","aria-label":y,tabIndex:-1,onKeyDown:_,style:z,children:[d&&o.jsx("div",{className:`s-slide-resize s-slide-resize--${n}`,onPointerDown:V=>{V.preventDefault(),S(!0)},role:"separator","aria-orientation":n==="right"?"vertical":"horizontal","aria-label":"Resize panel"}),w]})]})}const gk=5e3,wJ=500,vk=5e3,jJ=3e4,HM={user:">",assistant:"<",tool:"*","tool-result":"=",system:"~",other:"·"},jb={"scout-managed":"scout","hudson-managed":"hudson",unattributed:"native"},qM={"scout-managed":"s-tail-chip--origin-scout","hudson-managed":"s-tail-chip--origin-hudson",unattributed:"s-tail-chip--origin-native"};function Sb(e){return e?.trim().toLowerCase()||"unknown"}function SJ(e,t){const n=new Map,s=e?.transcripts?.length?e.transcripts:e?.processes.length?e.processes:t;for(const a of s){const l=Sb(a.source);n.set(l,(n.get(l)??0)+1)}return[...n.entries()].map(([a,l])=>({source:a,count:l})).sort((a,l)=>l.count-a.count||a.source.localeCompare(l.source))}function NJ(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),s=String(t.getMinutes()).padStart(2,"0"),a=String(t.getSeconds()).padStart(2,"0"),l=String(t.getMilliseconds()).padStart(3,"0");return`${n}:${s}:${a}.${l}`}function kJ(e){return e?(e.split(":")[0]??e).slice(0,8):"—"}function EJ(e,t){if(!t)return!0;const n=jb[e.harness];return`${e.summary} ${e.project} ${e.sessionId} ${e.source} ${e.harness} ${n}`.toLowerCase().includes(t.toLowerCase())}function CJ({navigate:e}={}){const[t,n]=g.useState([]),[s,a]=g.useState(null),[l,u]=g.useState(""),[d,p]=g.useState(!1),[h,m]=g.useState(!1),[y,x]=g.useState(0),[w,j]=g.useState(0),[N,k]=g.useState(null),E=g.useRef(null),C=g.useRef(null),S=g.useRef(!0),R=g.useRef([]),A=g.useCallback(q=>{R.current.push(Date.now()),n($=>$.length>=gk?[...$.slice($.length-gk+1),q]:[...$,q])},[]);LM(A),g.useEffect(()=>{let q=!1;return(async()=>{try{const $=await Re(`/api/tail/recent?limit=${wJ}`);q||n($.events??[])}catch{}})(),()=>{q=!0}},[]);const M=g.useCallback(async()=>{try{const q=await Re("/api/tail/discover");a(q)}catch{}},[]);g.useEffect(()=>{M();const q=setInterval(()=>{M()},jJ);return()=>clearInterval(q)},[M]),g.useEffect(()=>{const q=setInterval(()=>{const L=Date.now()-vk,F=R.current.filter(X=>X>=L);R.current=F,j(F.length/(vk/1e3))},1e3);return()=>clearInterval(q)},[]);const _=g.useMemo(()=>l?t.filter(q=>EJ(q,l)):t,[t,l]);g.useLayoutEffect(()=>{const q=E.current;if(q){if(h){x($=>$+1);return}q.scrollTop=q.scrollHeight}},[_,h]);const z=g.useCallback(()=>{const q=E.current;if(!q)return;const L=q.scrollHeight-q.scrollTop-q.clientHeight<24;S.current=L,L?(m(!1),x(0)):h||m(!0)},[h]),V=g.useCallback(q=>{u(q),p(!0),requestAnimationFrame(()=>C.current?.focus())},[]),U=g.useCallback(q=>{!q||!e||e({view:"sessions",sessionId:q})},[e]),O=g.useCallback(()=>{const q=E.current;q&&(q.scrollTop=q.scrollHeight,m(!1),x(0))},[]);g.useEffect(()=>{const q=$=>{const L=$.target,F=L instanceof HTMLInputElement||L instanceof HTMLTextAreaElement||(L?.isContentEditable??!1);if($.key==="/"&&!F){$.preventDefault(),p(!0),requestAnimationFrame(()=>C.current?.focus());return}if($.key==="Escape"&&d&&document.activeElement===C.current){$.preventDefault(),p(!1),C.current?.blur(),u("");return}($.key==="g"||$.key==="G")&&!F&&($.preventDefault(),O())};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[d,O]);const D=s?.totals,H=D?.transcripts??s?.transcripts?.length??0,W=g.useMemo(()=>SJ(s,t),[s,t]);return o.jsxs("div",{className:"s-tail",children:[o.jsxs("div",{className:"s-tail-status",children:[o.jsxs("span",{className:"s-tail-status-cell",children:[o.jsx("span",{className:"s-tail-rate-pulse"}),o.jsx("strong",{children:H})," log",H===1?"":"s"]}),o.jsxs("span",{className:"s-tail-status-cell",children:[o.jsx("strong",{children:D?.total??0})," proc",(D?.total??0)===1?"":"s"]}),o.jsxs("span",{className:"s-tail-status-cell",children:[o.jsx("strong",{children:w.toFixed(1)})," lines/s"]}),o.jsxs("span",{className:"s-tail-status-cell s-tail-status-cell--harnesses",children:[o.jsx("span",{children:"harness"}),o.jsx("span",{className:"s-tail-status-inline",children:W.length>0?W.slice(0,4).map(q=>o.jsxs("span",{children:[o.jsx("strong",{children:q.count})," ",q.source]},q.source)):o.jsx("strong",{children:"none"})})]}),o.jsx("span",{className:"s-tail-status-spacer"}),h&&o.jsx("span",{className:"s-tail-status-paused",children:"paused"})]}),d&&o.jsxs("div",{className:"s-tail-filter",children:[o.jsx("span",{className:"s-tail-filter-prompt",children:"/"}),o.jsx("input",{ref:C,className:"s-tail-filter-input",value:l,placeholder:"substring across summary · project · session",onChange:q=>u(q.target.value),onKeyDown:q=>{q.key==="Enter"&&(q.preventDefault(),C.current?.blur())},autoFocus:!0,spellCheck:!1}),o.jsx("span",{className:"s-tail-filter-hint",children:"esc to clear"})]}),o.jsxs("div",{className:"s-tail-body",ref:E,onScroll:z,children:[_.length===0?o.jsxs("div",{className:"s-tail-empty",children:[o.jsx("span",{className:"s-tail-empty-title",children:"tail · waiting for transcripts"}),o.jsx("span",{children:H?o.jsxs(o.Fragment,{children:["watching ",H," transcript",H===1?"":"s"]}):o.jsx(o.Fragment,{children:"no moving transcript logs detected · start a session to see traffic"})})]}):_.map(q=>o.jsx(TJ,{event:q,selected:N?.id===q.id,onSelect:k,onProjectClick:V,onSessionClick:U},q.id)),h&&y>0&&o.jsxs("div",{className:"s-tail-divider",onClick:O,role:"button",children:["── paused · ",y," new · click or press G to jump back to live ──"]})]}),o.jsxs("div",{className:"s-tail-keys",children:[o.jsxs("span",{children:[o.jsx("kbd",{children:"j"}),"/",o.jsx("kbd",{children:"k"})," scroll"]}),o.jsxs("span",{children:[o.jsx("kbd",{children:"/"})," filter"]}),o.jsxs("span",{children:[o.jsx("kbd",{children:"G"})," jump live"]}),o.jsxs("span",{children:[o.jsx("kbd",{children:"esc"})," close filter"]}),o.jsx("span",{className:"s-tail-keys-spacer"}),o.jsxs("span",{children:[_.length," / ",t.length," lines buffered"]})]}),N&&o.jsx(MJ,{event:N,onClose:()=>k(null),onProjectClick:V,onSessionClick:U})]})}function TJ({event:e,selected:t,onSelect:n,onProjectClick:s,onSessionClick:a}){const l=qM[e.harness],u=jb[e.harness],d=Sb(e.source);return o.jsxs("div",{className:`s-tail-row s-tail-row--${e.kind}${t?" s-tail-row--selected":""}`,role:"button",tabIndex:0,onClick:()=>n(e),onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),n(e))},children:[o.jsx("span",{className:"s-tail-cell-time",children:NJ(e.ts)}),o.jsx("span",{className:"s-tail-gutter",children:"│"}),o.jsx("span",{className:"s-tail-chip s-tail-chip--harness",children:d}),o.jsx("span",{className:`s-tail-chip ${l}`,title:`origin: ${u}`,children:u}),o.jsxs("span",{className:"s-tail-cell-context",children:[o.jsx(Kf,{className:"s-tail-link s-tail-link--project",onClick:s?()=>s(e.project):void 0,title:`Filter to ${e.project}`,children:o.jsx("strong",{children:e.project})})," · ",o.jsx(Kf,{className:"s-tail-link s-tail-link--session",onClick:a&&e.sessionId?()=>a(e.sessionId):void 0,title:e.sessionId?`Open session ${e.sessionId}`:void 0,children:kJ(e.sessionId)})," · ",o.jsx("span",{className:"s-tail-cell-pid",title:e.pid>0?`pid ${e.pid}`:"file-backed log",children:e.pid>0?e.pid:"log"})]}),o.jsx("span",{className:`s-tail-glyph s-tail-glyph--${e.kind}`,children:HM[e.kind]}),o.jsx("span",{className:"s-tail-summary",children:e.summary})]})}function Kf({className:e,onClick:t,title:n,children:s}){return t?o.jsx("span",{className:`${e} s-tail-link--active`,role:"link",tabIndex:0,title:n,onClick:a=>{a.stopPropagation(),t()},onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),a.stopPropagation(),t())},children:s}):o.jsx("span",{className:e,title:n,children:s})}function AJ(e){const t=new Date(e),n=t.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),a=String(t.getDate()).padStart(2,"0"),l=String(t.getHours()).padStart(2,"0"),u=String(t.getMinutes()).padStart(2,"0"),d=String(t.getSeconds()).padStart(2,"0"),p=String(t.getMilliseconds()).padStart(3,"0");return`${n}-${s}-${a} ${l}:${u}:${d}.${p}`}function ff(e){return(JSON.stringify(e,null,2)??"undefined").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/("(?:\\.|[^"\\])*"\s*:)|("(?:\\.|[^"\\])*")|\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g,(s,a,l,u,d)=>a?`<span class="s-tail-jk">${a}</span>`:l?`<span class="s-tail-js">${l}</span>`:u?`<span class="s-tail-jl">${u}</span>`:d?`<span class="s-tail-jn">${d}</span>`:s)}function RJ(e){if(!e||typeof e!="object")return null;const t=e,s=t.message?.content??t.content;return Array.isArray(s)?s:typeof s=="string"?[{type:"text",text:s}]:null}function MJ({event:e,onClose:t,onProjectClick:n,onSessionClick:s}){const[a,l]=g.useState(!0),u=qM[e.harness],d=jb[e.harness],p=Sb(e.source),h=RJ(e.raw);return o.jsxs(xJ,{open:!0,onClose:t,side:"right",owner:"openscout.tail",resizable:!0,defaultSize:620,minSize:400,maxSize:960,ariaLabel:"Tail event detail",children:[o.jsxs("div",{className:"s-slide-header s-tail-sheet-header",children:[o.jsx("span",{className:`s-tail-glyph s-tail-glyph--${e.kind}`,children:HM[e.kind]}),o.jsx("span",{className:"s-tail-sheet-kind",children:e.kind}),o.jsx("span",{className:"s-tail-chip s-tail-chip--harness",children:p}),o.jsx("span",{className:`s-tail-chip ${u}`,title:`origin: ${d}`,children:d}),o.jsx("span",{className:"s-slide-spacer"}),o.jsx("span",{className:"s-tail-sheet-time",children:AJ(e.ts)}),o.jsx("button",{type:"button",className:"s-slide-close",onClick:t,"aria-label":"Close",children:"×"})]}),o.jsxs("div",{className:"s-slide-body s-tail-sheet-body",children:[o.jsx("section",{className:"s-tail-sheet-section",children:o.jsxs("div",{className:"s-tail-sheet-grid",children:[o.jsx("span",{className:"s-tail-sheet-key",children:"project"}),o.jsx("span",{className:"s-tail-sheet-val",children:o.jsx(Kf,{className:"s-tail-link s-tail-link--project",onClick:n?()=>n(e.project):void 0,title:`Filter to ${e.project}`,children:e.project})}),o.jsx("span",{className:"s-tail-sheet-key",children:"cwd"}),o.jsx("span",{className:"s-tail-sheet-val s-tail-sheet-val--mono",children:e.cwd||"—"}),o.jsx("span",{className:"s-tail-sheet-key",children:"session"}),o.jsx("span",{className:"s-tail-sheet-val s-tail-sheet-val--mono",children:o.jsx(Kf,{className:"s-tail-link s-tail-link--session",onClick:s&&e.sessionId?()=>s(e.sessionId):void 0,title:e.sessionId?`Open session ${e.sessionId}`:void 0,children:e.sessionId||"—"})}),o.jsx("span",{className:"s-tail-sheet-key",children:"harness"}),o.jsx("span",{className:"s-tail-sheet-val s-tail-sheet-val--mono",children:p}),o.jsx("span",{className:"s-tail-sheet-key",children:"origin"}),o.jsx("span",{className:"s-tail-sheet-val s-tail-sheet-val--mono",children:d}),o.jsx("span",{className:"s-tail-sheet-key",children:"pid"}),o.jsxs("span",{className:"s-tail-sheet-val s-tail-sheet-val--mono",children:[e.pid,e.parentPid!=null?` ← ${e.parentPid}`:""]})]})}),o.jsxs("section",{className:"s-tail-sheet-section",children:[o.jsx("h4",{className:"s-tail-sheet-h",children:"summary"}),o.jsx("div",{className:"s-tail-sheet-summary",children:e.summary})]}),h&&h.length>0&&o.jsxs("section",{className:"s-tail-sheet-section",children:[o.jsx("h4",{className:"s-tail-sheet-h",children:"content"}),h.map((m,y)=>o.jsx(_J,{block:m},y))]}),o.jsxs("section",{className:"s-tail-sheet-section",children:[o.jsxs("button",{type:"button",className:"s-tail-sheet-toggle",onClick:()=>l(m=>!m),children:[a?"▾":"▸"," raw event"]}),a&&o.jsx("pre",{className:"s-tail-sheet-json",dangerouslySetInnerHTML:{__html:ff(e.raw??e)}})]})]})]})}function _J({block:e}){if(e.type==="text"){const t=e.text??"";return o.jsx("div",{className:"s-tail-sheet-text",children:t})}if(e.type==="tool_use"){const t=e;return o.jsxs("div",{className:"s-tail-sheet-block s-tail-sheet-block--tool",children:[o.jsxs("div",{className:"s-tail-sheet-block-head",children:[o.jsx("span",{className:"s-tail-glyph s-tail-glyph--tool",children:"*"}),o.jsx("span",{className:"s-tail-sheet-block-title",children:t.name??"tool_use"})]}),o.jsx("pre",{className:"s-tail-sheet-json",dangerouslySetInnerHTML:{__html:ff(t.input??{})}})]})}if(e.type==="tool_result"){const t=e,n=typeof t.content=="string";return o.jsxs("div",{className:`s-tail-sheet-block s-tail-sheet-block--tool-result${t.is_error?" s-tail-sheet-block--err":""}`,children:[o.jsxs("div",{className:"s-tail-sheet-block-head",children:[o.jsx("span",{className:"s-tail-glyph s-tail-glyph--tool-result",children:"="}),o.jsxs("span",{className:"s-tail-sheet-block-title",children:["tool_result",t.is_error?" · error":""]})]}),n?o.jsx("pre",{className:"s-tail-sheet-pre",children:t.content}):o.jsx("pre",{className:"s-tail-sheet-json",dangerouslySetInnerHTML:{__html:ff(t.content??{})}})]})}return o.jsxs("div",{className:"s-tail-sheet-block",children:[o.jsxs("div",{className:"s-tail-sheet-block-head",children:[o.jsx("span",{className:"s-tail-glyph s-tail-glyph--other",children:"·"}),o.jsx("span",{className:"s-tail-sheet-block-title",children:e.type})]}),o.jsx("pre",{className:"s-tail-sheet-json",dangerouslySetInnerHTML:{__html:ff(e)}})]})}const OJ=15*6e4,IJ=1440*6e4,Nb=30*6e4,ZM=1440*6e4,DJ=Nb,PJ=[{label:"30m",value:Nb},{label:"4h",value:240*6e4},{label:"24h",value:ZM}],pi="operator",Pr="broker";function kb(e,t){return typeof e.updatedAt=="number"&&Number.isFinite(e.updatedAt)&&e.updatedAt>0&&e.updatedAt<=t&&t-e.updatedAt<=IJ}function WM(e,t){return et(e.state)!=="offline"&&kb(e,t)&&t-(e.updatedAt??t)>OJ}function wh(e){return e.replace(/[._]/g," ")}function Eb(e,t=84){const n=(e??"").replace(/\s+/g," ").trim();return n?n.length>t?`${n.slice(0,t-1)}...`:n:"No summary available"}function zJ(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Ri(e,t){if(!e||!Number.isFinite(e))return"unknown";const n=Math.max(0,Math.floor((t-e)/1e3));if(n<60)return`${n}s`;const s=Math.floor(n/60);if(s<60)return`${s}m`;const a=Math.floor(s/60);return a<48?`${a}h`:`${Math.floor(a/24)}d`}function Or(e){const t=Math.round(e/6e4);if(t<60)return`${t}m`;const n=t/60;return`${Number.isInteger(n)?n:n.toFixed(1)}h`}function LJ(e){const t=Math.max(1,Math.round(e/6e4));return Math.min(ZM,Math.max(Nb,t*6e4))}function $J(e){const t=e.trim().toLowerCase().match(/^(\d+(?:\.\d+)?)\s*(m|min|mins|minute|minutes|h|hr|hrs|hour|hours|d|day|days)?$/);if(!t)return null;const n=Number(t[1]);if(!Number.isFinite(n)||n<=0)return null;const s=t[2]??"m",a=s.startsWith("d")?1440*6e4:s.startsWith("h")?60*6e4:6e4;return LJ(n*a)}function Xf(e){switch(e){case"critical":return 0;case"warning":return 1;default:return 2}}function Lg(e,t){const n=Xf(e.severity)-Xf(t.severity);return n!==0?n:e.updatedAt-t.updatedAt}function yk(e,t){const n=Xf(e.severity)-Xf(t.severity);return n!==0?n:t.updatedAt-e.updatedAt}function UJ(e){return e.conversationId?{view:"conversation",conversationId:e.conversationId}:null}function YM(e){return"actorId"in e?e.actorId:null}function GM(e){return"agentId"in e?e.agentId:null}function Hc(e,t){if(e===pi)return"Operator";if(e===Pr)return"Broker";const n=t.get(e);return n?n.name:e.replace(/\.mini$/,"").replace(/[._-]+/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function bk(e){return e.replace(/^@/,"").toLowerCase().replace(/[^a-z0-9]+/g,"")}function BJ(e,t){if(!e)return null;const n=e.match(/@([a-zA-Z0-9][a-zA-Z0-9._-]+)/)?.[1];if(!n)return null;const s=bk(n);return t.find(l=>[l.id,l.name,l.handle??"",l.selector??""].some(u=>bk(u)===s))?.id??null}function VJ(e,t){const n=e.conversationId;return!n||!n.startsWith("dm.")?null:n.startsWith("dm.operator.")?pi:t&&n.startsWith(`dm.${t}.`)?n.slice(`dm.${t}.`.length)||null:t&&n.endsWith(`.${t}`)&&n.slice(3,-`.${t}`.length)||null}function FJ(e,t){const n=YM(e),s=e.kind,a=BJ(e.title??e.summary,t),l=VJ(e,n);if(s==="ask_replied"||s==="flight_updated")return pi;if(a&&a!==n)return a;if(l&&l!==n)return l;const u=GM(e);return u&&u!==n?u:Pr}function HJ(e){return YM(e)??GM(e)??Pr}function qJ(e,t){const n=new Map(t.map(w=>[w.id,w])),s=new Map,a=e.slice(0,48).map((w,j)=>{const N=HJ(w),k=FJ(w,t);return s.set(N,(s.get(N)??0)+1),s.set(k,(s.get(k)??0)+1),{id:w.id,fromId:N,toId:k,kind:w.kind,label:Eb(w.title??w.summary,92),ts:w.ts,route:UJ(w)}}),l=[...s.entries()].filter(([w])=>w!==pi&&w!==Pr).sort((w,j)=>j[1]-w[1]).slice(0,18).map(([w])=>w),u=new Set([pi,Pr,...l]),d=1e3,p=620,h=[{id:pi,label:"Operator",detail:"command",kind:"operator",x:118,y:p/2,state:"online",weight:s.get(pi)??0,route:null},{id:Pr,label:"Broker",detail:"message fabric",kind:"broker",x:492,y:p/2,state:"mesh",weight:s.get(Pr)??0,route:{view:"fleet"}}];l.forEach((w,j)=>{const N=n.get(w),k=Math.max(1,l.length),E=-Math.PI*.62+j/Math.max(1,k-1)*Math.PI*1.24,C=j%2===0?250:315,S=630+Math.cos(E)*C,R=p/2+Math.sin(E)*235;h.push({id:w,label:Hc(w,n),detail:N?.project??N?.role??N?.agentClass??"agent endpoint",kind:N?"agent":"external",x:Math.max(250,Math.min(d-70,S)),y:Math.max(70,Math.min(p-70,R)),state:N?Pn(N.state):"External",weight:s.get(w)??0,route:N?{view:"agents",agentId:N.id}:null})});const m=new Map(h.map(w=>[w.id,w])),y=a.filter(w=>u.has(w.fromId)||u.has(w.toId)).slice(0,26).map(w=>{const j=m.get(w.fromId)??m.get(Pr),N=m.get(w.toId)??m.get(Pr);return{...w,from:j,to:N}}),x=[...t.reduce((w,j)=>{const N=j.project??j.role??j.agentClass??"unassigned";return w.set(N,(w.get(N)??0)+1),w},new Map)].sort((w,j)=>j[1]-w[1]).slice(0,6).map(([w,j])=>({name:w,count:j}));return{nodes:h,edges:a,visibleEdges:y,projects:x,messageRate:e.length}}function ZJ(e){const t=[];return e.recordId&&t.push({label:"Open work",route:{view:"work",workId:e.recordId}}),e.conversationId&&t.push({label:"Open conversation",route:{view:"conversation",conversationId:e.conversationId}}),e.agentId&&t.push({label:"Open agent",route:{view:"agents",agentId:e.agentId}}),t}function WJ(e){const t=[];return e.collaborationRecordId&&t.push({label:"Open work",route:{view:"work",workId:e.collaborationRecordId}}),e.conversationId&&t.push({label:"Open conversation",route:{view:"conversation",conversationId:e.conversationId}}),t.push({label:"Open agent",route:{view:"agents",agentId:e.agentId}}),t}function YJ(e){return[{label:"Open agent",route:{view:"agents",agentId:e.id}}]}function GJ(e){const t=e.kind==="question";return{source:"attention",item:e,key:`attention:${e.recordId}`,lane:"attention",severity:t?"critical":"warning",pill:t?"Needs answer":"Needs input",title:e.title||"Unresolved work",summary:Eb(e.summary,140),agentId:e.agentId,agentName:e.agentName,updatedAt:e.updatedAt,startedAt:null,completedAt:null,actions:ZJ(e),meta:[e.agentName??"Unassigned",wh(e.kind),e.state,e.acceptanceState]}}function KJ(e){return e.status==="failed"?"failed":e.status==="completed"?"done":"running"}function XJ(e){return e.status==="failed"||e.attention==="interrupt"?"critical":e.attention==="badge"||e.status==="needs_attention"?"warning":"info"}function xk(e){return{source:"ask",item:e,key:`ask:${e.invocationId}`,lane:KJ(e),severity:XJ(e),pill:e.statusLabel,title:e.task||"Delegated ask",summary:Eb(e.summary,140),agentId:e.agentId,agentName:e.agentName??e.agentId,updatedAt:e.updatedAt,startedAt:e.startedAt,completedAt:e.completedAt,actions:WJ(e),meta:[e.agentName??e.agentId,e.harness??"unknown harness",e.transport??"unknown transport"]}}function JJ(e,t){const n=et(e.state),s=WM(e,t);if(!(n==="offline"&&kb(e,t))&&!s)return null;const l=n==="offline"?"offline":"stale";return{source:"agent",item:e,health:l,key:`agent:${l}:${e.id}`,lane:"attention",severity:"warning",pill:n==="offline"?"Offline":"Stale",title:e.name,summary:n==="offline"?"Agent endpoint is offline.":`No endpoint update for ${Ri(e.updatedAt,t)}.`,agentId:e.id,agentName:e.name,updatedAt:e.updatedAt??t,startedAt:null,completedAt:null,actions:YJ(e),meta:[Pn(e.state),e.project??e.role??e.agentClass,e.harness??"unknown harness"]}}function QJ(e,t,n){const s=(e?.needsAttention??[]).map(GJ),a=(e?.activeAsks??[]).map(xk),l=(e?.recentCompleted??[]).map(xk),u=t.map(d=>JJ(d,n)).filter(d=>!!d);return[...s,...a,...l,...u]}function eQ(e,t){return e.map(n=>{const s=et(n.state),a=WM(n,t),l=kb(n,t),u=a||s==="offline"&&l?"warning":"info",d=a&&s!=="offline"?"Stale":Pn(n.state),p=a?0:s==="working"?1:s==="available"?2:l?3:4;return{key:n.id,name:n.name,state:d,detail:`${n.project??n.role??n.agentClass} / updated ${Ri(n.updatedAt,t)} ago`,route:{view:"agents",agentId:n.id},severity:u,rank:p,updatedAt:n.updatedAt}}).sort((n,s)=>n.rank-s.rank||(s.updatedAt??0)-(n.updatedAt??0)||n.name.localeCompare(s.name))}function tQ(e,t){const n=["s-warroom-decision",`s-warroom-decision--${e.severity}`];return t&&n.push("s-warroom-decision--selected"),n.join(" ")}function nQ(e,t=!1){const n=["s-warroom-kpi"];return e&&n.push("s-warroom-kpi--warn"),t&&n.push("s-warroom-kpi--hot"),n.join(" ")}function sQ({navigate:e,agents:t}){const[n,s]=g.useState(null),[a,l]=g.useState([]),[u,d]=g.useState(null),[p,h]=g.useState(null),[m,y]=g.useState("flow"),[x,w]=g.useState(DJ),[j,N]=g.useState(()=>Date.now()),k=g.useCallback(async()=>{try{const L=await Re("/api/fleet");s(L),L.activity.length>0?l([]):l(await Re("/api/activity"))}catch{const L=await Promise.allSettled([Re("/api/activity")]);L[0].status==="fulfilled"&&l(L[0].value)}N(Date.now())},[]);g.useEffect(()=>{k()},[k]),Rn(()=>{k()}),g.useEffect(()=>{const L=setInterval(()=>N(Date.now()),1e3);return()=>clearInterval(L)},[]);const E=g.useMemo(()=>n?.activity.length?n.activity:a,[a,n?.activity]),C=g.useMemo(()=>{const L=j-x;return E.filter(F=>F.ts>=L&&F.ts<=j)},[E,x,j]),S=g.useMemo(()=>qJ(C,t),[C,t]),R=S.messageRate,A=g.useMemo(()=>QJ(n,t,j),[t,n,j]),M=g.useMemo(()=>A.filter(L=>L.lane==="attention"||L.lane==="failed").sort(Lg),[A]),_=g.useMemo(()=>({attention:A.filter(L=>L.lane==="attention").sort(Lg),running:A.filter(L=>L.lane==="running").sort(yk),failed:A.filter(L=>L.lane==="failed").sort(Lg),done:A.filter(L=>L.lane==="done").sort(yk).slice(0,8)}),[A]);g.useEffect(()=>{const L=M[0]?.key??_.running[0]?.key??_.done[0]?.key??null;if(!L){u!==null&&d(null);return}(!u||!A.some(F=>F.key===u))&&d(L)},[A,_.done,_.running,M,u]);const z=g.useMemo(()=>A.find(L=>L.key===u)??M[0]??_.running[0]??_.done[0]??null,[A,_.done,_.running,M,u]),V=_.failed.length,U=t.filter(L=>et(L.state)!=="offline").length,O=M.filter(L=>L.severity!=="info").length,D=g.useMemo(()=>eQ(t,j),[t,j]),H=g.useMemo(()=>new Map(S.nodes.map(L=>[L.id,L.label])),[S.nodes]),W=g.useMemo(()=>S.edges.find(L=>L.id===p)??null,[S.edges,p]),q=n?`${Ri(n.generatedAt,j)} ago`:"loading",$=m==="flow"?W?wh(W.kind):"No selection":z?z.pill:"No selection";return o.jsxs("div",{className:"s-warroom",children:[o.jsxs("header",{className:"s-warroom-command",children:[o.jsxs("div",{className:"s-warroom-command-main",children:[o.jsx("div",{className:"s-warroom-title",children:"Command"}),o.jsx("div",{className:"s-warroom-subtitle",children:"Live fleet decisions, message flow, and handoffs."}),o.jsxs("div",{className:"s-warroom-statusline",children:["Freshness ",q," / Local time ",zJ(j)]})]}),o.jsxs("div",{className:"s-warroom-kpis",children:[o.jsx($g,{label:"Action needed",value:String(O),detail:`${M.length} queued`,warn:O>0,hot:V>0}),o.jsx($g,{label:"Online",value:`${U}/${t.length}`,detail:"agents",warn:U<t.length}),o.jsx($g,{label:"Messages",value:String(R),detail:`last ${Or(x)}`})]})]}),o.jsxs("div",{className:"s-warroom-layout",children:[o.jsxs("aside",{className:"s-warroom-queue",children:[o.jsx(Ug,{title:"State",meta:M.length===0?"clear":`${M.length} priority`}),o.jsx(rQ,{queueItems:M,selectedKey:z?.key??null,nowMs:j,onSelect:L=>{d(L),y("item")}})]}),o.jsxs("main",{className:"s-warroom-board",children:[o.jsx(Ug,{title:"Message Topology",meta:`${S.visibleEdges.length} visible flows / ${Or(x)}`}),o.jsx(iQ,{network:S,nowMs:j,flowWindowMs:x,selectedFlowId:m==="flow"?W?.id??null:null,onFlowWindowChange:w,onSelectFlow:L=>{h(L),y("flow")}})]}),o.jsxs("aside",{className:"s-warroom-inspector",children:[o.jsx(Ug,{title:"Inspector",meta:$}),m==="flow"?W?o.jsx(lQ,{edge:W,nodeLabels:H,nowMs:j,navigate:e}):o.jsx("div",{className:"s-warroom-empty",children:"Select a message flow to inspect."}):z?o.jsx(cQ,{item:z,nowMs:j,navigate:e}):o.jsx("div",{className:"s-warroom-empty",children:"Select an item to inspect."}),o.jsxs("section",{className:"s-warroom-inspector-card",children:[o.jsx("div",{className:"s-warroom-inspector-title",children:"Agent health"}),o.jsx("div",{className:"s-warroom-health",children:D.slice(0,8).map(L=>o.jsxs("button",{type:"button",className:"s-warroom-health-row",onClick:()=>e(L.route),children:[o.jsx("span",{className:"s-warroom-dot"}),o.jsx("span",{children:L.name}),o.jsx("span",{children:L.state}),o.jsx("span",{children:L.detail})]},L.key))})]})]})]})]})}function $g({label:e,value:t,detail:n,warn:s=!1,hot:a=!1}){return o.jsxs("div",{className:nQ(s,a),children:[o.jsx("div",{className:"s-warroom-kpi-label",children:e}),o.jsx("div",{className:"s-warroom-kpi-value",children:t}),o.jsx("div",{className:"s-warroom-kpi-detail",children:n})]})}function Ug({title:e,meta:t}){return o.jsxs("div",{className:"s-warroom-section-head",children:[o.jsx("div",{className:"s-warroom-section-title",children:e}),o.jsx("div",{className:"s-warroom-section-meta",children:t})]})}function rQ({queueItems:e,selectedKey:t,nowMs:n,onSelect:s}){return o.jsxs("div",{className:"s-warroom-command-stack",children:[o.jsxs("div",{className:"s-warroom-readiness",children:[o.jsx("div",{className:"s-warroom-readiness-mark",children:e.length===0?"CLEAR":"ACTION"}),o.jsx("div",{className:"s-warroom-readiness-body",children:e.length===0?"No operator decisions are blocking the fleet. The topology remains the primary signal.":"Operator input is needed before the fleet can fully drain."})]}),e.length>0&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"s-warroom-section-head s-warroom-section-head--tight",children:[o.jsx("div",{className:"s-warroom-section-title",children:"Decision Queue"}),o.jsxs("div",{className:"s-warroom-section-meta",children:[e.length," priority"]})]}),o.jsx("div",{className:"s-warroom-queue-list",children:e.slice(0,4).map(a=>o.jsx(aQ,{item:a,nowMs:n,selected:a.key===t,onSelect:()=>s(a.key)},a.key))})]})]})}function aQ({item:e,nowMs:t,selected:n,onSelect:s}){return o.jsxs("button",{type:"button",className:tQ(e,n),onClick:s,children:[o.jsxs("div",{className:"s-warroom-decision-top",children:[o.jsx("span",{className:"s-warroom-pill",children:e.pill}),o.jsxs("span",{className:"s-warroom-age",children:[Ri(e.updatedAt,t)," ago"]})]}),o.jsx("div",{className:"s-warroom-decision-title",children:e.title}),o.jsx("div",{className:"s-warroom-decision-summary",children:e.summary}),o.jsx("div",{className:"s-warroom-decision-meta",children:e.meta.filter(Boolean).map((a,l)=>o.jsx("span",{children:a},`${e.key}:meta:${l}`))})]})}function iQ({network:e,nowMs:t,flowWindowMs:n,selectedFlowId:s,onFlowWindowChange:a,onSelectFlow:l}){const u=new Set(e.visibleEdges.map(w=>w.id)),d=new Map(e.nodes.map(w=>[w.id,w.label])),p=e.nodes,h=e.visibleEdges[0]??null,[m,y]=g.useState(Or(n));g.useEffect(()=>{y(Or(n))},[n]);const x=(w=m)=>{const j=$J(w);if(!j){y(Or(n));return}a(j)};return o.jsxs("div",{className:"s-warroom-topology",children:[o.jsxs("div",{className:"s-warroom-windowbar",children:[o.jsxs("div",{className:"s-warroom-windowbar-copy",children:[o.jsx("span",{children:"Flow window"}),o.jsxs("strong",{children:["Last ",Or(n)]})]}),o.jsxs("div",{className:"s-warroom-window-controls",children:[o.jsx("div",{className:"s-warroom-window-tabs","aria-label":"Message flow window presets",children:PJ.map(w=>o.jsx("button",{type:"button",className:`s-warroom-window-tab${w.value===n?" s-warroom-window-tab--active":""}`,onClick:()=>a(w.value),children:w.label},w.value))}),o.jsxs("form",{className:"s-warroom-window-custom",onSubmit:w=>{w.preventDefault(),x()},children:[o.jsx("label",{htmlFor:"s-warroom-window-custom-input",children:"Custom"}),o.jsx("input",{id:"s-warroom-window-custom-input","aria-label":"Custom message flow window",value:m,onChange:w=>y(w.currentTarget.value),onBlur:w=>x(w.currentTarget.value),onKeyDown:w=>{w.key==="Enter"&&(w.preventDefault(),x(w.currentTarget.value),w.currentTarget.blur()),w.key==="Escape"&&(w.preventDefault(),y(Or(n)),w.currentTarget.blur())},spellCheck:!1})]})]})]}),o.jsxs("div",{className:"s-warroom-map",children:[o.jsxs("svg",{className:"s-warroom-map-svg",viewBox:"0 0 1000 620",role:"img","aria-label":"Live message topology",children:[o.jsxs("defs",{children:[o.jsxs("radialGradient",{id:"warroomNodeGlow",cx:"50%",cy:"50%",r:"50%",children:[o.jsx("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:"0.32"}),o.jsx("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:"0"})]}),o.jsxs("filter",{id:"warroomPacketGlow",x:"-60%",y:"-60%",width:"220%",height:"220%",children:[o.jsx("feGaussianBlur",{stdDeviation:"3",result:"blur"}),o.jsxs("feMerge",{children:[o.jsx("feMergeNode",{in:"blur"}),o.jsx("feMergeNode",{in:"SourceGraphic"})]})]})]}),o.jsxs("g",{className:"s-warroom-map-grid","aria-hidden":"true",children:[Array.from({length:13}).map((w,j)=>o.jsx("line",{x1:j*84,y1:"0",x2:j*84,y2:"620"},`v-${j}`)),Array.from({length:8}).map((w,j)=>o.jsx("line",{x1:"0",y1:j*88,x2:"1000",y2:j*88},`h-${j}`))]}),o.jsx("g",{className:"s-warroom-map-projects",children:e.projects.map((w,j)=>o.jsxs("g",{transform:`translate(${760+j%2*100}, ${72+Math.floor(j/2)*38})`,children:[o.jsx("rect",{width:"86",height:"22",rx:"4"}),o.jsx("text",{x:"8",y:"14",children:w.name.slice(0,12)}),o.jsx("text",{x:"72",y:"14",textAnchor:"end",children:w.count})]},w.name))}),o.jsx("g",{className:"s-warroom-map-links",children:e.visibleEdges.map((w,j)=>o.jsx("line",{x1:w.from.x,y1:w.from.y,x2:w.to.x,y2:w.to.y,opacity:Math.max(.18,.72-j*.02)},`${w.id}:line:${j}`))}),o.jsx("g",{className:"s-warroom-map-packets",filter:"url(#warroomPacketGlow)",children:e.visibleEdges.slice(0,18).map((w,j)=>{const N=`M ${w.from.x} ${w.from.y} L ${w.to.x} ${w.to.y}`;return o.jsxs("g",{children:[o.jsx("circle",{className:"s-warroom-packet",r:j<5?4.2:3.2,children:o.jsx("animateMotion",{dur:`${4.2+j%5*.42}s`,begin:`${-(j*.33)}s`,repeatCount:"indefinite",path:N})}),j<7&&o.jsx("circle",{className:"s-warroom-packet s-warroom-packet--ghost",r:"8",children:o.jsx("animateMotion",{dur:`${4.2+j%5*.42}s`,begin:`${-(j*.33)}s`,repeatCount:"indefinite",path:N})})]},`${w.id}:packet:${j}`)})}),o.jsx("g",{className:"s-warroom-map-nodes",children:p.map(w=>o.jsxs("g",{className:`s-warroom-map-node s-warroom-map-node--${w.kind}`,transform:`translate(${w.x}, ${w.y})`,children:[o.jsx("circle",{className:"s-warroom-map-node-glow",r:22+Math.min(16,w.weight*2)}),o.jsx("circle",{className:"s-warroom-map-node-core",r:w.kind==="operator"||w.kind==="broker"?20:15,fill:mt(w.label)}),o.jsx("text",{className:"s-warroom-map-node-initial",y:"4",textAnchor:"middle",children:w.label[0]?.toUpperCase()}),o.jsx("text",{className:"s-warroom-map-node-label",y:w.kind==="agent"||w.kind==="external"?33:40,textAnchor:"middle",children:w.label}),o.jsx("text",{className:"s-warroom-map-node-detail",y:w.kind==="agent"||w.kind==="external"?47:54,textAnchor:"middle",children:w.detail})]},w.id))})]}),o.jsxs("div",{className:"s-warroom-map-caption",children:[o.jsxs("span",{children:[e.nodes.length," nodes"]}),o.jsxs("span",{children:[e.edges.length," messages / ",Or(n)]}),o.jsxs("span",{children:["latest ",h?Ri(h.ts,t):"none"," ago"]})]})]}),o.jsxs("div",{className:"s-warroom-flow-ledger",children:[o.jsxs("div",{className:"s-warroom-flow-ledger-head",children:[o.jsx("span",{children:"Window message flow"}),o.jsxs("span",{children:[e.visibleEdges.length," routes"]})]}),o.jsx("div",{className:"s-warroom-flow-list",children:e.edges.length===0?o.jsxs("div",{className:"s-warroom-empty",children:["No messages in the last ",Or(n),"."]}):e.edges.slice(0,10).map(w=>o.jsx(oQ,{edge:w,active:u.has(w.id),selected:w.id===s,nodeLabels:d,onSelect:()=>l(w.id)},w.id))})]})]})}function oQ({edge:e,active:t,selected:n,nodeLabels:s,onSelect:a}){const l=o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"s-warroom-flow-route",children:[s.get(e.fromId)??Hc(e.fromId,new Map)," ",o.jsx("span",{children:"→"})," ",s.get(e.toId)??Hc(e.toId,new Map)]}),o.jsx("span",{className:"s-warroom-flow-kind",children:wh(e.kind)}),o.jsx("span",{className:"s-warroom-flow-title",children:e.label})]});return o.jsx("button",{type:"button",className:`s-warroom-flow-row${t?" s-warroom-flow-row--active":""}${n?" s-warroom-flow-row--selected":""}`,onClick:a,children:l})}function lQ({edge:e,nodeLabels:t,nowMs:n,navigate:s}){const a=t.get(e.fromId)??Hc(e.fromId,new Map),l=t.get(e.toId)??Hc(e.toId,new Map);return o.jsxs("section",{className:"s-warroom-inspector-card",children:[o.jsxs("div",{className:"s-warroom-inspector-title",children:[a," ","->"," ",l]}),o.jsxs("div",{className:"s-warroom-inspector-meta",children:[o.jsx("span",{children:wh(e.kind)}),o.jsxs("span",{children:[Ri(e.ts,n)," ago"]})]}),o.jsx("div",{className:"s-warroom-inspector-body",children:e.label}),o.jsx("div",{className:"s-warroom-actions",children:e.route?o.jsx("button",{type:"button",className:"s-warroom-action",onClick:()=>s(e.route),children:"Open conversation"}):o.jsx("span",{className:"s-warroom-empty",children:"No route available."})})]})}function cQ({item:e,nowMs:t,navigate:n}){return o.jsxs("section",{className:"s-warroom-inspector-card",children:[o.jsx("div",{className:"s-warroom-inspector-title",children:e.title}),o.jsxs("div",{className:"s-warroom-inspector-meta",children:[e.pill," / updated ",Ri(e.updatedAt,t)," ago"]}),o.jsx("div",{className:"s-warroom-inspector-body",children:e.summary}),o.jsx("div",{className:"s-warroom-inspector-meta",children:e.meta.filter(Boolean).map((s,a)=>o.jsx("span",{children:s},`${e.key}:inspector-meta:${a}`))}),o.jsx("div",{className:"s-warroom-actions",children:e.actions.length===0?o.jsx("span",{className:"s-warroom-empty",children:"No route available."}):e.actions.map(s=>o.jsx("button",{type:"button",className:"s-warroom-action",onClick:()=>n(s.route),children:s.label},s.label))})]})}const uQ=[{id:"warroom",label:"Command"},{id:"mission",label:"Control"},{id:"plan",label:"Plan"},{id:"conductor",label:"Conduct"},{id:"tail",label:"Tail"},{id:"atop",label:"Atop"},{id:"agents",label:"Agents"}];function dQ({navigate:e,mode:t="warroom"}){const{agents:n}=Nt();return o.jsxs("div",{className:"s-ops",children:[o.jsxs("div",{className:"s-ops-header",children:[o.jsx("span",{className:"s-ops-header-title",children:"Ops"}),o.jsx("div",{className:"s-ops-tabs",children:uQ.map(s=>o.jsx("button",{className:`s-ops-tab${t===s.id?" s-ops-tab--active":""}`,onClick:()=>e({view:"ops",mode:s.id}),children:s.label},s.id))})]}),o.jsxs("div",{className:"s-ops-body",children:[t==="mission"&&o.jsx(HG,{navigate:e,agents:n}),t==="agents"&&o.jsx(uK,{navigate:e,agents:n}),t==="plan"&&o.jsx(_K,{navigate:e,agents:n}),t==="conductor"&&o.jsx(_G,{navigate:e,agents:n}),t==="warroom"&&o.jsx(sQ,{navigate:e,agents:n}),t==="tail"&&o.jsx(CJ,{navigate:e}),t==="atop"&&o.jsx(iJ,{})]})]})}function fQ({agentId:e,navigate:t}){const{agents:n}=Nt(),s=e?n.find(d=>d.id===e):null,a=s?mt(s.name):"var(--accent)",l=py({url:$R(),healthUrl:UR(),autoConnect:!0,sessionKey:e?`scout-takeover-${e}`:"scout-takeover"}),u=()=>{t(e?{view:"agents",agentId:e}:{view:"inbox"})};return o.jsxs("div",{className:"s-term",children:[o.jsxs("div",{className:"s-term-bar",children:[o.jsx("button",{className:"s-term-back",onClick:u,children:"← Back"}),s&&o.jsxs("div",{className:"s-term-agent",children:[o.jsx("div",{className:"s-ops-avatar",style:{"--size":"18px",background:a},children:s.name[0]?.toUpperCase()}),o.jsx("span",{className:"s-term-agent-name",children:s.name}),s.handle&&o.jsxs("span",{className:"s-term-agent-handle",children:["@",s.handle]})]}),o.jsx("span",{className:"s-term-label",children:"TAKEOVER"}),o.jsxs("div",{className:"s-term-status",children:[o.jsx("span",{className:`s-term-dot${l.status==="connected"?" s-term-dot--live":l.status==="connecting"?" s-term-dot--connecting":""}`}),l.status==="connected"?"LIVE":l.status==="connecting"?"CONNECTING":"OFFLINE"]})]}),o.jsx("div",{className:"s-term-body",children:o.jsx(gy,{relay:l,fontSize:13,quiet:!0})})]})}function hQ(e){return e.attention==="interrupt"?"failed":e.state==="done"?"completed":e.attention==="badge"||e.state==="waiting"||e.state==="review"?"updated":"working"}function Bg(e){switch(e){case"review":return"In review";case"waiting":return"Waiting";case"working":return"Working";case"done":return"Done";default:return e.replace(/_/g," ")}}function pQ(e){switch(e){case"badge":return"Needs attention";case"interrupt":return"Blocked";default:return null}}function mQ(e){switch(e.kind){case"flight_started":return"flight started";case"flight_completed":return e.detailKind?`flight ${e.detailKind}`:"flight ended";case"message":return"message";default:return e.title??e.detailKind??"event"}}function wk(e){return e.kind==="message"?"message":e.kind==="flight_started"?"flight":e.kind==="flight_completed"?e.detailKind?.includes("fail")?"alert":"done":e.detailKind?.includes("interrupt")||e.detailKind?.includes("block")?"alert":"system"}function Vg({title:e,items:t}){return t.length===0?null:o.jsxs("section",{className:"s-work-fact-card",children:[o.jsx("div",{className:"s-work-fact-card-header",children:o.jsx("div",{className:"s-work-fact-card-title",children:e})}),o.jsx("div",{className:"s-work-fact-card-body",children:t.map(n=>o.jsxs("div",{className:"s-work-fact-row",children:[o.jsx("span",{className:"s-work-fact-label",children:n.label}),o.jsx("span",{className:"s-work-fact-value",children:n.value})]},n.label))})]})}function jk({label:e,value:t,onClick:n}){return o.jsxs("button",{type:"button",className:"s-work-action-row",onClick:n,children:[o.jsx("span",{className:"s-work-action-row-label",children:e}),o.jsx("span",{className:"s-work-action-row-value",children:t})]})}function gQ(e){const t=e.split(".");return t[t.length-1]||e}function vQ({workId:e,navigate:t}){const[n,s]=g.useState(null),[a,l]=g.useState(null),[u,d]=g.useState(!1),p=g.useCallback(async()=>{l(null);try{const N=await Re(`/api/work/${encodeURIComponent(e)}`);s(N)}catch(N){l(N instanceof Error?N.message:String(N)),s(null)}finally{d(!0)}},[e]);if(g.useEffect(()=>{d(!1),p()},[p]),Rn(()=>{p()}),!u)return o.jsxs("div",{children:[o.jsx("button",{type:"button",className:"s-back",onClick:()=>t({view:"inbox"}),children:"← Back"}),o.jsx("div",{className:"s-empty",children:o.jsx("p",{children:"Loading…"})})]});if(!n)return o.jsxs("div",{children:[o.jsx("button",{type:"button",className:"s-back",onClick:()=>t({view:"inbox"}),children:"← Back"}),a&&o.jsx("p",{className:"s-error",children:a}),o.jsx("div",{className:"s-empty",children:o.jsx("p",{children:"Work item not found"})})]});const h=pQ(n.attention),m=n.ownerName??n.ownerId??"Unassigned",y=n.nextMoveOwnerName??n.nextMoveOwnerId??"—",x=[{label:"State",value:Bg(n.state)},{label:"Acceptance",value:n.acceptanceState.replace(/_/g," ")},{label:"Phase",value:n.currentPhase},...h?[{label:"Attention",value:h}]:[]],w=[{label:"Owner",value:m},{label:"Next move",value:y},...n.priority?[{label:"Priority",value:n.priority}]:[],{label:"Conversation",value:n.conversationId?"Attached":"None"}],j=[{label:"Case ID",value:n.id},{label:"Created",value:hi(n.createdAt)},{label:"Updated",value:hi(n.updatedAt)},{label:"Last activity",value:hi(n.lastMeaningfulAt)}];return o.jsxs("div",{className:"s-work-detail s-work-casefile",children:[o.jsxs("div",{className:"s-work-casefile-topbar",children:[o.jsx("button",{type:"button",className:"s-back",onClick:()=>t({view:"inbox"}),children:"← Back"}),o.jsxs("span",{className:"s-work-casefile-record",children:["Case ",gQ(n.id)]})]}),a&&o.jsx("p",{className:"s-error",children:a}),o.jsx("section",{className:"s-work-casefile-hero",children:o.jsxs("div",{className:"s-work-casefile-hero-main",children:[o.jsxs("div",{className:"s-work-casefile-title-row",children:[o.jsx("h1",{className:"s-work-casefile-title",children:n.title}),o.jsx("span",{className:`s-pill s-pill-${hQ(n)}`,children:n.currentPhase})]}),n.lastMeaningfulSummary&&o.jsx("div",{className:"s-work-casefile-summary",children:us(n.lastMeaningfulSummary)}),o.jsxs("div",{className:"s-work-casefile-meta",children:[o.jsxs("span",{children:["Updated ",De(n.updatedAt)]}),o.jsx("span",{children:m}),o.jsx("span",{children:Bg(n.state)}),h&&o.jsx("span",{children:h}),n.priority&&o.jsxs("span",{children:["Priority ",n.priority]})]})]})}),o.jsxs("div",{className:"s-work-casefile-layout",children:[o.jsxs("div",{className:"s-work-casefile-main",children:[o.jsxs("section",{className:"s-work-casefile-section",children:[o.jsx("div",{className:"s-agent-section-heading",children:o.jsx("h2",{className:"s-agent-section-title",children:"Case facts"})}),o.jsxs("div",{className:"s-work-fact-grid",children:[o.jsx(Vg,{title:"Status",items:x}),o.jsx(Vg,{title:"Assignment",items:w})]})]}),n.activeFlights.length>0&&o.jsxs("section",{className:"s-work-casefile-section",children:[o.jsx("div",{className:"s-agent-section-heading",children:o.jsx("h2",{className:"s-agent-section-title",children:"Flights"})}),o.jsx("div",{className:"s-work-flight-list",children:n.activeFlights.map(N=>o.jsxs("button",{type:"button",className:"s-work-flight-card",onClick:N.conversationId?()=>t({view:"conversation",conversationId:N.conversationId}):void 0,disabled:!N.conversationId,children:[o.jsxs("div",{className:"s-work-flight-card-header",children:[o.jsx("span",{className:"s-work-flight-card-title",children:N.agentName??N.agentId}),o.jsx("span",{className:"s-pill s-pill-working",children:N.state})]}),o.jsxs("div",{className:"s-work-flight-card-meta",children:[o.jsx("span",{children:N.startedAt?`Started ${De(N.startedAt)}`:"Start time unavailable"}),N.completedAt&&o.jsxs("span",{children:["Completed ",De(N.completedAt)]})]}),N.summary&&o.jsx("div",{className:"s-work-flight-card-copy",children:N.summary})]},N.id))})]}),n.childWork.length>0&&o.jsxs("section",{className:"s-work-casefile-section",children:[o.jsx("div",{className:"s-agent-section-heading",children:o.jsx("h2",{className:"s-agent-section-title",children:"Child work"})}),o.jsx("div",{className:"s-work-related-list",children:n.childWork.map(N=>o.jsxs("button",{type:"button",className:"s-work-related-card",onClick:()=>t({view:"work",workId:N.id}),children:[o.jsxs("div",{className:"s-work-related-card-header",children:[o.jsx("span",{className:"s-work-related-card-title",children:N.title}),o.jsx("span",{className:`s-pill s-pill-${N.attention==="interrupt"?"failed":"updated"}`,children:N.currentPhase})]}),o.jsxs("div",{className:"s-work-related-card-meta",children:[o.jsx("span",{children:N.ownerName??N.ownerId??"Unassigned"}),o.jsx("span",{children:Bg(N.state)}),o.jsx("span",{children:De(N.lastMeaningfulAt)})]}),N.lastMeaningfulSummary&&o.jsx("div",{className:"s-work-related-card-copy",children:us(N.lastMeaningfulSummary)})]},N.id))})]}),o.jsxs("section",{className:"s-work-casefile-section",children:[o.jsx("div",{className:"s-agent-section-heading",children:o.jsx("h2",{className:"s-agent-section-title",children:"Timeline"})}),n.timeline.length===0?o.jsxs("div",{className:"s-empty",children:[o.jsx("p",{children:"No activity yet."}),o.jsx("p",{children:"Timeline events will appear once the case receives messages or coordination updates."})]}):o.jsx("div",{className:"s-work-timeline",children:n.timeline.map(N=>o.jsxs("button",{type:"button",className:`s-work-timeline-entry${N.conversationId?" s-work-timeline-entry-clickable":""}`,onClick:N.conversationId?()=>t({view:"conversation",conversationId:N.conversationId}):void 0,disabled:!N.conversationId,children:[o.jsx("span",{className:`s-work-timeline-marker s-work-timeline-marker-${wk(N)}`}),o.jsxs("div",{className:"s-work-timeline-content",children:[o.jsxs("div",{className:"s-work-timeline-header",children:[o.jsx("span",{className:"s-work-timeline-time",children:De(N.at)}),o.jsx("span",{className:`s-work-timeline-kind s-work-timeline-kind-${wk(N)}`,children:mQ(N)})]}),o.jsx("div",{className:"s-work-timeline-actor",children:N.actorName??"system"}),N.title&&o.jsx("div",{className:"s-work-timeline-title",children:N.title}),N.summary&&o.jsx("div",{className:"s-work-timeline-summary",children:us(N.summary)}),o.jsx("div",{className:"s-work-timeline-stamp",children:hi(N.at)})]})]},N.id))})]})]}),o.jsxs("aside",{className:"s-work-casefile-side",children:[o.jsx(Vg,{title:"Record",items:j}),o.jsxs("section",{className:"s-work-fact-card",children:[o.jsx("div",{className:"s-work-fact-card-header",children:o.jsx("div",{className:"s-work-fact-card-title",children:"Links"})}),o.jsxs("div",{className:"s-work-action-list",children:[n.conversationId?o.jsx(jk,{label:"Conversation",value:"Open thread",onClick:()=>t({view:"conversation",conversationId:n.conversationId})}):o.jsx("div",{className:"s-work-action-list-empty",children:"No conversation attached."}),n.parentId&&n.parentTitle?o.jsx(jk,{label:"Parent",value:n.parentTitle,onClick:()=>t({view:"work",workId:n.parentId})}):o.jsx("div",{className:"s-work-action-list-empty",children:"No parent work item."})]})]})]})]})]})}function yQ(){const{route:e,navigate:t}=Nt();return o.jsx(bQ,{children:xQ(e,t)})}function bQ({children:e}){return o.jsx("div",{style:{background:"var(--bg)",color:"var(--ink)",minHeight:"100%",height:"100%",display:"flex",flexDirection:"column"},children:e})}function xQ(e,t){switch(e.view){case"conversation":return o.jsx(qv,{conversationId:e.conversationId,initialComposeMode:e.composeMode,initialDraft:e.composeDraft,navigate:t});case"agent-info":return o.jsx(zZ,{conversationId:e.conversationId,navigate:t});case"settings":return o.jsx(jG,{navigate:t});case"agents":return o.jsx(QW,{navigate:t,selectedAgentId:e.agentId,conversationId:e.conversationId,tab:e.tab});case"fleet":return o.jsx(ZN,{navigate:t});case"sessions":return e.sessionId?o.jsx(qv,{conversationId:e.sessionId,navigate:t}):o.jsx(XY,{navigate:t});case"mesh":return o.jsx(LY,{navigate:t});case"activity":return o.jsx(OZ,{navigate:t});case"ops":return o.jsx(dQ,{navigate:t,mode:e.mode});case"terminal":return o.jsx(fQ,{agentId:e.agentId,navigate:t});case"work":return o.jsx(vQ,{workId:e.workId,navigate:t});default:return o.jsx(ZN,{navigate:t})}}function wQ(){const{route:e,agents:t,navigate:n}=Nt();if(e.view!=="agents")return null;const s=e.agentId?t.find(a=>a.id===e.agentId)??null:null;if(!s){const a=t.filter(l=>ki(l.state)).length;return o.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[o.jsx(sr,{label:"Total",value:`${t.length}`}),o.jsx(sr,{label:"Working",value:`${a}`}),o.jsx(sr,{label:"Available",value:`${t.length-a}`}),o.jsx("div",{className:"mt-2 text-[10px] font-mono uppercase tracking-[0.15em] leading-relaxed text-[var(--scout-chrome-ink-ghost)]",children:"Select an agent from the roster to see its context here."})]})}return o.jsx(jQ,{agent:s,agents:t,navigate:n})}function jQ({agent:e,agents:t,navigate:n}){const s=ki(e.state),[a,l]=g.useState(null),u=g.useCallback(async()=>{const d=await Re("/api/fleet").catch(()=>null);d&&l(d)},[]);return g.useEffect(()=>{u()},[u]),Rn(()=>{u()}),o.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[o.jsxs("div",{className:"flex items-center gap-3 border-b border-[var(--scout-chrome-border-soft)] pb-3",children:[o.jsxs("div",{className:"relative flex h-10 w-10 shrink-0 items-center justify-center rounded-full text-[13px] font-mono text-[var(--scout-chrome-avatar-ink)]",style:{background:mt(e.name)},children:[e.name[0]?.toUpperCase()??"?",s&&o.jsx("span",{className:"absolute -right-0.5 -bottom-0.5 h-2.5 w-2.5 rounded-full ring-2 ring-[var(--hud-bg)]",style:{background:Ur(e.state),opacity:et(e.state)==="working"?.85:.6}})]}),o.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[o.jsx("span",{className:"truncate text-[13px] text-[var(--scout-chrome-ink-strong)]",children:e.name}),e.handle&&o.jsxs("span",{className:"text-[10px] font-mono text-cyan-400/70",children:["@",e.handle]})]})]}),o.jsxs(Oo,{label:"State",children:[o.jsxs("div",{className:"flex items-baseline gap-2",children:[o.jsx("span",{className:"w-1.5 h-1.5 rounded-full",style:{background:Ur(e.state),opacity:s?1:.4}}),o.jsx("span",{className:"text-[12px] capitalize text-[var(--scout-chrome-ink)]",children:Pn(e.state)})]}),e.updatedAt&&o.jsxs("div",{className:"mt-1 text-[10px] font-mono text-[var(--scout-chrome-ink-faint)]",children:["Updated ",De(e.updatedAt)]})]}),o.jsx(Oo,{label:"Presence",children:o.jsx(SQ,{focusAgent:e,agents:t,navigate:n})}),a&&o.jsx(NQ,{asks:a.activeAsks,agentId:e.id,navigate:n}),o.jsxs(Oo,{label:"Identity",children:[o.jsx(sr,{label:"Class",value:e.agentClass}),e.role&&o.jsx(sr,{label:"Role",value:e.role}),e.harness&&o.jsx(sr,{label:"Harness",value:e.harness}),e.transport&&o.jsx(sr,{label:"Transport",value:e.transport})]}),(e.project||e.branch||e.cwd)&&o.jsxs(Oo,{label:"Project",children:[e.project&&o.jsx(sr,{label:"Name",value:e.project}),e.branch&&o.jsx(sr,{label:"Branch",value:e.branch}),e.cwd&&o.jsx(sr,{label:"Cwd",value:e.cwd})]}),e.capabilities.length>0&&o.jsx(Oo,{label:`Capabilities · ${e.capabilities.length}`,children:o.jsx("div",{className:"flex flex-wrap gap-1",children:e.capabilities.map(d=>o.jsx("span",{className:"rounded-sm bg-[var(--scout-chrome-hover)] px-1.5 py-0.5 text-[10px] font-mono text-[var(--scout-chrome-ink-soft)]",children:d},d))})})]})}function SQ({focusAgent:e,agents:t,navigate:n}){const p=t.filter(m=>m.id!==e.id).slice(0,8),h=g.useMemo(()=>{const m=[{agent:e,x:120,y:90,focused:!0}];return p.forEach((y,x)=>{const w=2*Math.PI*x/Math.max(p.length,1)-Math.PI/2;m.push({agent:y,x:120+68*Math.cos(w),y:90+68*Math.sin(w),focused:!1})}),m},[e,p,120,90,68]);return o.jsxs("svg",{viewBox:"0 0 240 180",className:"w-full block",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("defs",{children:o.jsxs("radialGradient",{id:"inspMeshGlow",cx:"50%",cy:"50%",r:"50%",children:[o.jsx("stop",{offset:"0%",stopColor:"var(--accent)",stopOpacity:"0.06"}),o.jsx("stop",{offset:"100%",stopColor:"var(--accent)",stopOpacity:"0"})]})}),o.jsx("circle",{cx:120,cy:90,r:82,fill:"url(#inspMeshGlow)"}),o.jsx("circle",{cx:120,cy:90,r:68,fill:"none",stroke:"var(--border)",strokeDasharray:"2 4"}),h.slice(1).map((m,y)=>o.jsxs("g",{children:[o.jsx("line",{x1:120,y1:90,x2:m.x,y2:m.y,stroke:"var(--accent)",strokeWidth:1,opacity:.6}),o.jsx("circle",{r:2,fill:"var(--accent)",children:o.jsx("animateMotion",{dur:`${2+y*.3}s`,repeatCount:"indefinite",path:`M 120,90 L ${m.x},${m.y}`})})]},`e-${m.agent.id}`)),h.map(m=>{const y=et(m.agent.state),x=y==="working"||y==="available",w=m.focused?14:9;return o.jsxs("g",{style:{cursor:"pointer"},onClick:()=>n({view:"agents",agentId:m.agent.id}),children:[x&&o.jsxs("circle",{cx:m.x,cy:m.y,r:w+5,fill:"none",stroke:mt(m.agent.name),strokeWidth:.8,opacity:.3,children:[o.jsx("animate",{attributeName:"r",values:`${w};${w+8};${w}`,dur:"2.5s",repeatCount:"indefinite"}),o.jsx("animate",{attributeName:"opacity",values:"0.3;0;0.3",dur:"2.5s",repeatCount:"indefinite"})]}),o.jsx("circle",{cx:m.x,cy:m.y,r:w,fill:mt(m.agent.name),stroke:m.focused?"var(--accent)":"var(--surface)",strokeWidth:m.focused?1.5:1}),o.jsx("text",{x:m.x,y:m.y,dy:"0.35em",textAnchor:"middle",fontFamily:"var(--font-mono)",fontSize:m.focused?10:8,fontWeight:600,fill:"var(--scout-chrome-avatar-ink)",children:m.agent.name[0].toUpperCase()}),o.jsx("text",{x:m.x,y:m.y+w+10,textAnchor:"middle",fontFamily:"var(--font-mono)",fontSize:8,fill:"var(--dim)",letterSpacing:"0.04em",children:m.agent.name.length>9?m.agent.name.slice(0,8)+"...":m.agent.name})]},m.agent.id)})]})}function NQ({asks:e,agentId:t,navigate:n}){const s=e.filter(a=>a.agentId===t&&(a.status==="needs_attention"||a.status==="queued"));return s.length===0?null:o.jsx(Oo,{label:`Incoming asks · ${s.length}`,children:o.jsx("div",{className:"flex flex-col gap-2",children:s.map(a=>o.jsxs("div",{className:"p-2.5 rounded-md border border-amber-500/30 bg-amber-500/[0.04] cursor-pointer hover:bg-amber-500/[0.08] transition-colors",onClick:()=>{a.conversationId&&n({view:"agents",agentId:t,conversationId:a.conversationId})},children:[o.jsx("div",{className:"text-[9px] font-mono uppercase tracking-[0.12em] text-amber-500/80 mb-1",children:"awaiting"}),o.jsx("div",{className:"line-clamp-2 text-[11px] leading-relaxed text-[var(--scout-chrome-ink)]",children:a.summary??a.task}),o.jsxs("div",{className:"mt-1.5 text-[9px] font-mono text-[var(--scout-chrome-ink-ghost)]",children:[a.harness??"operator"," → ",a.agentName??"agent"]})]},a.invocationId))})})}function Oo({label:e,children:t}){return o.jsxs("div",{className:"flex flex-col",children:[o.jsx("div",{className:"mb-1.5 text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e}),t]})}function sr({label:e,value:t}){return o.jsxs("div",{className:"flex items-baseline justify-between py-0.5 gap-2",children:[o.jsx("span",{className:"shrink-0 text-[10px] font-mono uppercase tracking-wider text-[var(--scout-chrome-ink-faint)]",children:e}),o.jsx("span",{className:"truncate text-[11px] font-mono text-[var(--scout-chrome-ink)]",children:t})]})}function kQ(){const{agents:e,navigate:t}=Nt();if(e.length===0)return o.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center font-mono text-[11px] leading-relaxed text-[var(--scout-chrome-ink-faint)]",children:[o.jsx("div",{className:"mb-1 uppercase tracking-[0.15em]",children:"No agents"}),o.jsx("div",{children:"Connect an agent to see your roster here."})]});const n=e.filter(a=>ki(a.state)),s=e.filter(a=>!ki(a.state));return o.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[n.length>0&&o.jsx(Sk,{label:"Online",count:n.length,children:n.map(a=>o.jsx(Nk,{agent:a,navigate:t},a.id))}),s.length>0&&o.jsx(Sk,{label:"Standby",count:s.length,children:s.map(a=>o.jsx(Nk,{agent:a,navigate:t,dim:!0},a.id))})]})}function Sk({label:e,count:t,children:n}){return o.jsxs("div",{className:"flex flex-col",children:[o.jsxs("div",{className:"flex items-baseline justify-between mb-1.5",children:[o.jsx("span",{className:"text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e}),o.jsx("span",{className:"text-[9px] font-mono tabular-nums text-[var(--scout-chrome-ink-ghost)]",children:t})]}),o.jsx("div",{className:"flex flex-col gap-0.5",children:n})]})}function Nk({agent:e,navigate:t,dim:n}){const s=ki(e.state);return o.jsxs("button",{onClick:()=>t({view:"agents",agentId:e.id}),className:`group flex items-center gap-2.5 px-2 py-1.5 rounded-sm text-left transition-colors ${n?"opacity-60 hover:opacity-100 hover:bg-[var(--scout-chrome-hover)]":"hover:bg-[var(--scout-chrome-hover)]"}`,children:[o.jsxs("div",{className:"relative h-6 w-6 shrink-0 rounded-full text-[10px] font-mono flex items-center justify-center text-[var(--scout-chrome-avatar-ink)]",style:{background:mt(e.name)},children:[e.name[0]?.toUpperCase()??"?",s&&o.jsx("span",{className:"absolute -right-0.5 -bottom-0.5 h-2 w-2 rounded-full bg-emerald-400 ring-2 ring-[var(--hud-bg)]"})]}),o.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[o.jsx("span",{className:"truncate text-[12px] text-[var(--scout-chrome-ink)] transition-colors group-hover:text-[var(--scout-chrome-ink-strong)]",children:e.name}),o.jsx("span",{className:"truncate text-[10px] font-mono text-[var(--scout-chrome-ink-faint)]",children:Pn(e.state)})]}),e.updatedAt&&o.jsx("span",{className:"shrink-0 text-[9px] font-mono tabular-nums text-[var(--scout-chrome-ink-ghost)]",children:De(e.updatedAt)})]})}function EQ(){const{route:e}=Nt(),[t,n]=g.useState([]),s=g.useCallback(async()=>{try{n(await Re("/api/sessions"))}catch{}},[]);if(g.useEffect(()=>{s()},[s]),Rn(()=>{s()}),e.view!=="sessions")return null;const a=e.sessionId?t.find(l=>l.id===e.sessionId)??null:null;if(!a){const l=new Set(t.map(d=>d.kind)),u=t.filter(d=>d.currentBranch).length;return o.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[o.jsx(Qs,{label:"Total",value:`${t.length}`}),o.jsx(Qs,{label:"Kinds",value:`${l.size}`}),o.jsx(Qs,{label:"Branched",value:`${u}`}),o.jsx("div",{className:"mt-2 text-[10px] font-mono uppercase tracking-[0.15em] leading-relaxed text-[var(--scout-chrome-ink-ghost)]",children:"Select a session from the list to see its context here."})]})}return o.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[o.jsxs("div",{className:"border-b border-[var(--scout-chrome-border-soft)] pb-3",children:[o.jsx("div",{className:"text-[13px] leading-snug text-[var(--scout-chrome-ink-strong)]",children:a.title}),o.jsx("div",{className:"text-[10px] font-mono uppercase tracking-wider text-cyan-400/70 mt-1",children:a.kind})]}),a.agentName&&o.jsxs(qd,{label:"Agent",children:[o.jsx(Qs,{label:"Name",value:a.agentName}),a.harness&&o.jsx(Qs,{label:"Harness",value:a.harness})]}),(a.currentBranch||a.workspaceRoot)&&o.jsxs(qd,{label:"Workspace",children:[a.currentBranch&&o.jsx(Qs,{label:"Branch",value:a.currentBranch}),a.workspaceRoot&&o.jsx(Qs,{label:"Root",value:a.workspaceRoot})]}),o.jsxs(qd,{label:"Activity",children:[o.jsx(Qs,{label:"Messages",value:`${a.messageCount}`}),a.lastMessageAt&&o.jsx(Qs,{label:"Last",value:De(a.lastMessageAt)}),a.participantIds.length>0&&o.jsx(Qs,{label:"Participants",value:`${a.participantIds.length}`})]}),a.preview&&o.jsx(qd,{label:"Preview",children:o.jsxs("div",{className:"text-[11px] italic leading-relaxed text-[var(--scout-chrome-ink-soft)]",children:['"',a.preview,'"']})})]})}function qd({label:e,children:t}){return o.jsxs("div",{className:"flex flex-col",children:[o.jsx("div",{className:"mb-1.5 text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e}),t]})}function Qs({label:e,value:t}){return o.jsxs("div",{className:"flex items-baseline justify-between py-0.5 gap-2",children:[o.jsx("span",{className:"shrink-0 text-[10px] font-mono uppercase tracking-wider text-[var(--scout-chrome-ink-faint)]",children:e}),o.jsx("span",{className:"truncate text-[11px] font-mono text-[var(--scout-chrome-ink)]",children:t})]})}function CQ(){const{route:e}=Nt(),t=e.view==="work"?e.workId:null,[n,s]=g.useState(null),a=g.useCallback(async()=>{if(!t){s(null);return}try{s(await Re(`/api/work/${encodeURIComponent(t)}`))}catch{s(null)}},[t]);if(g.useEffect(()=>{a()},[a]),Rn(()=>{t&&a()}),e.view!=="work")return null;if(!n)return o.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center text-[11px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-ghost)]",children:"Loading work item…"});const l=AQ(n.state);return o.jsxs("div",{className:"flex flex-col h-full overflow-y-auto frame-scrollbar p-4 gap-4 text-[11px]",children:[o.jsxs("div",{className:"border-b border-[var(--scout-chrome-border-soft)] pb-3",children:[o.jsxs("div",{className:"text-[9px] font-mono uppercase tracking-[0.15em] text-cyan-400/70 mb-1",children:["Case ",TQ(n.id)]}),o.jsx("div",{className:"text-[13px] leading-snug text-[var(--scout-chrome-ink-strong)]",children:n.title})]}),o.jsxs(Zd,{label:"State",children:[o.jsxs("div",{className:"flex items-baseline gap-2",children:[o.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${l.dot}`}),o.jsx("span",{className:`text-[12px] capitalize ${l.text}`,children:n.state.replace(/_/g," ")})]}),o.jsxs("div",{className:"mt-1 text-[10px] font-mono text-[var(--scout-chrome-ink-faint)]",children:["Phase · ",n.currentPhase]})]}),o.jsxs(Zd,{label:"Ownership",children:[n.ownerName&&o.jsx(Eo,{label:"Owner",value:n.ownerName}),n.nextMoveOwnerName&&o.jsx(Eo,{label:"Next move",value:n.nextMoveOwnerName}),n.priority&&o.jsx(Eo,{label:"Priority",value:n.priority})]}),o.jsxs(Zd,{label:"Activity",children:[o.jsx(Eo,{label:"Children",value:`${n.activeChildWorkCount}`}),o.jsx(Eo,{label:"Flights",value:`${n.activeFlightCount}`}),n.lastMeaningfulAt&&o.jsx(Eo,{label:"Last update",value:De(n.lastMeaningfulAt)})]}),n.attention!=="silent"&&o.jsx("div",{className:`text-[10px] font-mono uppercase tracking-wider px-2 py-1 rounded-sm ${n.attention==="interrupt"?"text-red-300/90 bg-red-500/10 border border-red-500/20":"text-amber-300/90 bg-amber-500/10 border border-amber-500/20"}`,children:n.attention==="interrupt"?"Interrupt":"Needs attention"}),n.lastMeaningfulSummary&&o.jsx(Zd,{label:"Latest",children:o.jsx("div",{className:"text-[11px] italic leading-relaxed text-[var(--scout-chrome-ink-soft)]",children:n.lastMeaningfulSummary})})]})}function TQ(e){return e.length>10?`${e.slice(0,8)}…`:e}function AQ(e){return/complete|done|finished/i.test(e)?{dot:"bg-emerald-400",text:"text-emerald-300/90"}:/fail|error/i.test(e)?{dot:"bg-red-400",text:"text-red-300/90"}:/block|wait|pause/i.test(e)?{dot:"bg-amber-400",text:"text-amber-300/90"}:/active|working|in[_-]?progress/i.test(e)?{dot:"bg-cyan-400",text:"text-cyan-300/90"}:{dot:"bg-[var(--scout-chrome-ink-faint)]",text:"text-[var(--scout-chrome-ink)]"}}function Zd({label:e,children:t}){return o.jsxs("div",{className:"flex flex-col",children:[o.jsx("div",{className:"mb-1.5 text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e}),t]})}function Eo({label:e,value:t}){return o.jsxs("div",{className:"flex items-baseline justify-between py-0.5 gap-2",children:[o.jsx("span",{className:"shrink-0 text-[10px] font-mono uppercase tracking-wider text-[var(--scout-chrome-ink-faint)]",children:e}),o.jsx("span",{className:"truncate text-[11px] font-mono text-[var(--scout-chrome-ink)]",children:t})]})}const RQ=43115,MQ=2e3,_Q=500;function OQ(e){return new IQ(e)}class IQ{base;clientId;probeTimeout;pollInterval;_state="unknown";constructor(t){if(t?.baseUrl)this.base=t.baseUrl.replace(/\/$/,"");else{const n=t?.port??RQ;this.base=`http://127.0.0.1:${n}`}this.clientId=t?.clientId??"vox-web",this.probeTimeout=t?.probeTimeout??MQ,this.pollInterval=t?.pollInterval??_Q}get state(){return this._state}get isConnected(){return this._state==="connected"}async probe(){this._state="probing";try{const n=await(await this.fetch("/health",{timeout:this.probeTimeout})).json();return this._state=n.ok?"connected":"unavailable",n.ok}catch{return this._state="unavailable",!1}}async health(){return(await this.fetch("/health")).json()}async capabilities(){return(await this.fetch("/capabilities")).json()}async transcribe(t){const{audio:n,format:s,language:a,timestamps:l,metadata:u}=t,d=new FormData;if(n instanceof Blob){const h=s??zQ(n.type)??"wav";d.append("audio",n,`audio.${h}`)}else{const h=s??"wav",m=new Blob([n],{type:LQ(h)});d.append("audio",m,`audio.${h}`)}return s&&d.append("format",s),a&&d.append("language",a),l&&d.append("timestamps","true"),d.append("metadata",JSON.stringify(this.withClientMetadata(u))),(await this.fetch("/transcribe",{method:"POST",body:d})).json()}async createJob(t){return(await this.fetch("/jobs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,metadata:this.withClientMetadata(t.metadata)})})).json()}async getJob(t){return(await this.fetch(`/jobs/${t}`)).json()}async align(t){const{jobId:n}=await this.createJob({...t,type:"alignment"});return this.waitForJob(n)}createLiveSession(){return new DQ(t=>this.openLiveSession(t),t=>this.stopLiveSession(t),t=>this.cancelLiveSession(t))}async getLiveSessionStatus(){const s=(await(await this.fetch("/live")).json()).session;return!s||typeof s!="object"?null:{sessionId:String(s.sessionId??""),connectionId:String(s.connectionId??""),clientId:String(s.clientId??""),modelId:String(s.modelId??""),startedAt:String(s.startedAt??""),state:String(s.state??"error")}}async stopLiveSession(t){const s=await(await this.fetch("/live/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{sessionId:t}:{})})).json();return{stopped:!!s.stopped,sessionId:String(s.sessionId??t??"")}}async cancelLiveSession(t){const s=await(await this.fetch("/live/cancel",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{sessionId:t}:{})})).json();return{cancelled:!!s.cancelled,sessionId:String(s.sessionId??t??"")}}launch(){window.location.href="vox://launch"}openSettings(){window.location.href="vox://settings"}async waitForJob(t){for(let s=0;s<600;s++){const a=await this.getJob(t);if(a.status==="completed"){if(!a.result?.alignment)throw new Es("Job completed but no alignment result","no_result");return a.result.alignment}if(a.status==="failed")throw new Es(a.error??"Job failed","job_failed");await PQ(this.pollInterval)}throw new Es("Job timed out","timeout")}async openLiveSession(t){return this.fetch("/live",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientId:this.clientId,modelId:t?.modelId??"parakeet:v3"})})}withClientMetadata(t){const n=t?{...t}:{};return n.clientId==null&&n.surface==null&&(n.clientId=this.clientId),n}async fetch(t,n){const{timeout:s,...a}=n??{},l=new AbortController,u=s?setTimeout(()=>l.abort(),s):void 0;try{const d=await globalThis.fetch(`${this.base}${t}`,{...a,signal:l.signal});if(!d.ok){const p=await d.text().catch(()=>"");throw new Es(`${d.status} ${d.statusText}: ${p}`,"http_error")}return d}catch(d){throw d instanceof Es?d:new Es(d instanceof Error?d.message:"Companion unreachable","network_error")}finally{u&&clearTimeout(u)}}}class Es extends Error{code;constructor(t,n){super(t),this.code=n,this.name="VoxDError"}}class DQ{open;stopRequest;cancelRequest;sessionId=null;runPromise=null;finalEvent=null;stateListeners=new Set;partialListeners=new Set;finalListeners=new Set;errorListeners=new Set;constructor(t,n,s){this.open=t,this.stopRequest=n,this.cancelRequest=s}get id(){return this.sessionId}start(t){return this.runPromise||(this.runPromise=this.run(t)),this.runPromise}async stop(){await this.stopRequest(this.sessionId??void 0)}async cancel(){await this.cancelRequest(this.sessionId??void 0)}onState(t){return this.stateListeners.add(t),()=>this.stateListeners.delete(t)}onPartial(t){return this.partialListeners.add(t),()=>this.partialListeners.delete(t)}onFinal(t){return this.finalListeners.add(t),()=>this.finalListeners.delete(t)}onError(t){return this.errorListeners.add(t),()=>this.errorListeners.delete(t)}close(){this.cancel().catch(t=>{this.emitError(t instanceof Error?t:new Error(String(t)))})}async run(t){try{const n=await this.open(t);if(!n.body)throw new Es("Live session stream did not include a response body.","protocol_error");let s=null;await $Q(n.body,l=>{if(typeof l.error=="string"&&l.error)throw new Es(l.error,"live_session_error");if(typeof l.event=="string"){this.handleEvent(l.event,kk(l.data));return}l.result&&typeof l.result=="object"&&(s=kk(l.result))});const a=this.finalEvent??this.parseResult(s);if(!a)throw new Es("Live session ended without a final result.","protocol_error");return a}catch(n){const s=n instanceof Error?n:new Error(String(n));throw this.emitError(s),s}}handleEvent(t,n){switch(t){case"session.state":{const s={sessionId:String(n.sessionId??this.sessionId??""),state:String(n.state??"error"),previous:n.previous??null,reason:typeof n.reason=="string"?n.reason:void 0};s.sessionId&&(this.sessionId=s.sessionId);for(const a of this.stateListeners)a(s);break}case"session.partial":{const s={sessionId:String(n.sessionId??this.sessionId??""),text:String(n.text??"")};s.sessionId&&(this.sessionId=s.sessionId);for(const a of this.partialListeners)a(s);break}case"session.final":{const s=this.parseResult(n);if(!s)return;this.finalEvent=s,this.sessionId=s.sessionId||this.sessionId;for(const a of this.finalListeners)a(s);break}}}parseResult(t){if(!t)return null;if(t.cancelled)throw new Es(`Live session ${String(t.sessionId??this.sessionId??"")} was cancelled.`,"session_cancelled");return{sessionId:String(t.sessionId??this.sessionId??""),text:String(t.text??""),durationMs:Number(t.durationMs??t.elapsedMs??0),words:Array.isArray(t.words)?t.words:void 0,metrics:BQ(t.metrics)?t.metrics:void 0}}emitError(t){for(const n of this.errorListeners)n(t)}}function PQ(e){return new Promise(t=>setTimeout(t,e))}function zQ(e){if(e.includes("mp3")||e.includes("mpeg"))return"mp3";if(e.includes("wav"))return"wav";if(e.includes("aac")||e.includes("mp4"))return"aac";if(e.includes("opus")||e.includes("ogg"))return"opus"}function LQ(e){switch(e){case"mp3":return"audio/mpeg";case"wav":return"audio/wav";case"aac":return"audio/aac";case"opus":return"audio/ogg; codecs=opus";case"pcm16":return"audio/pcm";default:return"application/octet-stream"}}async function $Q(e,t){const n=e.getReader(),s=new TextDecoder;let a="";try{for(;;){const{value:u,done:d}=await n.read();if(d)break;a+=s.decode(u,{stream:!0}),a=UQ(a,t)}a+=s.decode();const l=a.trim();l&&t(KM(l))}finally{n.releaseLock()}}function UQ(e,t){let n=e;for(;;){const s=n.indexOf(`
|
|
159
|
-
`);if(s===-1)return n;const a=n.slice(0,s).trim();n=n.slice(s+1),a&&t(KM(a))}}function KM(e){try{return JSON.parse(e)}catch{throw new Es("Live session stream returned invalid JSON.","protocol_error")}}function kk(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function BQ(e){return!!(e&&typeof e=="object")}const VQ="http://127.0.0.1:43115",FQ="openscout-web";class Wd{constructor(t=VQ){this.baseUrl=t,this.client=this.createClient()}baseUrl;state="unknown";unavailableReason=null;client;get connectionState(){return this.state}get lastUnavailableReason(){return this.unavailableReason}async probe(t=1200){this.state="probing",this.unavailableReason=null,this.client=this.createClient(t);try{return await this.client.probe()?(await this.client.capabilities(),this.state="connected",!0):(this.state="unavailable",!1)}catch(n){return this.state="unavailable",this.unavailableReason=Ak(n),!1}}launch(t={}){window.location.href=Ek("launch",{source:t.source,returnTo:t.returnTo??Tk(),context:Ck(t.context)})}openSettings(t={}){window.location.href=Ek("settings",{source:t.source,returnTo:t.returnTo??Tk(),context:Ck(t.context)})}async startLive(t={}){const n=this.client.createLiveSession();let s=null;qQ(n,t,l=>{s=l});const a=n.start({modelId:"parakeet:v3"}).then(l=>(s??=XM(l),s)).catch(l=>{throw new Error(Ak(l))});return{get sessionId(){return n.id},result:a,stop:async()=>{await n.stop()},cancel:async()=>{await n.cancel().catch(()=>{})}}}createClient(t=1200){return OQ({baseUrl:this.baseUrl,clientId:FQ,probeTimeout:t})}}async function HQ(e){const t=await fetch("/api/voice/speak",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:e})});if(!t.ok){const a=await t.text().catch(()=>"");try{const l=JSON.parse(a);throw new Error(l.error??`Voice returned HTTP ${t.status}`)}catch(l){throw l instanceof SyntaxError?new Error(a||`Voice returned HTTP ${t.status}`):l}}const n=await t.json();return await new Audio(`data:${n.contentType};base64,${n.audioBase64}`).play(),n}function qQ(e,t,n){e.onState(s=>t.onState?.(s.state)),e.onPartial(s=>t.onPartial?.(s.text)),e.onFinal(s=>{const a=XM(s);n(a),t.onFinal?.(a)})}function XM(e){return{sessionId:e.sessionId,text:e.text.trim(),durationMs:e.durationMs}}function Ek(e,t){const n=new URLSearchParams;for(const[a,l]of Object.entries(t))l&&n.set(a,l);const s=n.toString();return s?`vox://${e}?${s}`:`vox://${e}`}function Ck(e){if(e)return JSON.stringify(e)}function Tk(){try{return window.location.origin}catch{return}}function Ak(e){const t=e instanceof Error?e.message:String(e);return e instanceof Es&&e.code==="http_error"&&/origin not allowed/i.test(t)||/origin not allowed/i.test(t)?"Vox blocked this OpenScout URL. Restart OpenScout so it can register its Vox browser origin, then try again.":t||"Vox request failed."}const ZQ="What's the state of things? Give me a terse ops summary, the biggest risk, and the next action you recommend.";function WQ(){const{agents:e,rangerAgentId:t,rangerConversationId:n,applyRangerUiAction:s,reload:a}=Nt(),l=g.useMemo(()=>e.find(Se=>Se.id===t)??e.find(db)??null,[e,t]),[u,d]=g.useState(""),[p,h]=g.useState(!1),[m,y]=g.useState(null),[x,w]=g.useState(null),[j,N]=g.useState(null),[k,E]=g.useState("probing"),[C,S]=KQ("openscout.ranger.voiceReplies",!1),[R,A]=g.useState(!1),[M,_]=g.useState(null),[z,V]=g.useState(""),[U,O]=g.useState(!1),[D,H]=g.useState(null),[W,q]=g.useState(null),[$,L]=g.useState(null),[F,X]=g.useState(!1),[G,I]=g.useState(!1),[B,Y]=g.useState(!1),[Q,me]=g.useState(null),[re,ie]=g.useState(null),[de,ye]=g.useState(""),[Te,he]=g.useState(""),ue=g.useRef(null),we=g.useRef(null),We=g.useRef(C);We.current=C;const Ae=g.useCallback(async()=>{I(!0),me(null);try{const Se=await Re(`/api/agents/${encodeURIComponent(t)}/config`);ye(Se.model??""),he(Se.systemPrompt),ie(null)}catch(Se){me(Se instanceof Error?Se.message:"Could not load Ranger settings.")}finally{I(!1)}},[t]);g.useEffect(()=>{F&&Ae()},[Ae,F]);const je=g.useCallback(async()=>{Y(!0),me(null),ie(null);try{const Se=await Re(`/api/agents/${encodeURIComponent(t)}/config`,{method:"POST",body:JSON.stringify({model:de,systemPrompt:Te,restart:!0})});ye(Se.config.model??""),he(Se.config.systemPrompt),ie(Se.restarted?"Saved and restarted":"Saved"),await a()}catch(Se){me(Se instanceof Error?Se.message:"Could not save Ranger settings.")}finally{Y(!1)}},[de,Te,t,a]),Ee=g.useCallback(async()=>{const Se=ue.current??new Wd;ue.current=Se,E("probing");const $e=await Se.probe();return w($e),N($e?null:Se.lastUnavailableReason??"Vox Companion is not reachable."),E("idle"),$e},[]);g.useEffect(()=>{Ee()},[Ee]);const Ue=g.useCallback(()=>{const Se=ue.current??new Wd;ue.current=Se,y(null),E("launching"),Se.launch({source:"openscout",context:Rk()}),window.setTimeout(()=>{Ee()},2400)},[Ee]),Ve=g.useCallback(()=>{const Se=ue.current??new Wd;ue.current=Se,Se.openSettings({source:"openscout",context:Rk()})},[]),Be=g.useCallback(async Se=>{const $e=Se.trim();if(!(!$e||p)){h(!0),y(null),H($e),q(null),L("Sending to Ranger");try{await Re("/api/ask",{method:"POST",body:JSON.stringify({body:$e,conversationId:n})}),d(""),L("Waiting for Ranger")}catch(Pe){L(null),y(Pe instanceof Error?Pe.message:"Could not ask Ranger.")}finally{h(!1)}}},[n,p]),oe=g.useCallback(async()=>{if(R)return;const Se=ue.current??new Wd;if(ue.current=Se,y(null),V(""),_("starting"),x!==!0&&!await Ee()){_(null);return}try{const $e=await Se.startLive({onState:_,onPartial:V});we.current=$e,A(!0);const Pe=await $e.result;A(!1),we.current=null,V(""),_("done"),Pe.text&&await Be(Pe.text)}catch($e){A(!1),we.current=null,_("error"),y($e instanceof Error?$e.message:"Vox recording failed.")}},[Be,Ee,R,x]),ve=g.useCallback(async()=>{_("processing"),await we.current?.stop()},[]),xe=g.useCallback(async()=>{await we.current?.cancel(),we.current=null,A(!1),V(""),_(null)},[]);Rn(Se=>{if(Se.kind!=="message.posted")return;const $e=Se.payload&&typeof Se.payload=="object"?Se.payload.message:null;if(!$e||typeof $e!="object")return;const Pe=$e,xt=typeof Pe.conversationId=="string"?Pe.conversationId:"";if(xt&&xt!==n||typeof Pe.actorId!="string"||!ER(Pe.actorId,t)||typeof Pe.body!="string"||!Pe.body.trim())return;const kt=YQ(Pe.body);kt&&(q(kt),L("Ranger replied"),We.current&&(O(!0),HQ(kt).catch(un=>y(un instanceof Error?un.message:"Vox speech failed.")).finally(()=>O(!1))))});const Ne=R?M==="processing"?"Sending":"Stop":k==="probing"?"Checking Vox":k==="launching"?"Opening Vox":x===!1?"Launch Vox":"Start Talking",ke=l?l.state??"registered":"default target";return o.jsxs("section",{className:"flex flex-col gap-3 border-b border-[var(--scout-chrome-border-soft)] p-4",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(TO,{size:14,className:"text-lime-300"}),o.jsx("h2",{className:"font-mono text-[10px] font-bold uppercase tracking-[0.18em] text-[var(--scout-chrome-ink-strong)]",children:"Ranger"})]}),o.jsxs("p",{className:"mt-1 truncate font-mono text-[10px] text-[var(--scout-chrome-ink-faint)]",children:[l?.name??t," · ",ke,l?.model?` · ${l.model}`:""]})]}),o.jsx("button",{type:"button",title:"Ranger settings",onClick:()=>X(Se=>!Se),className:`rounded border p-1.5 transition-colors ${F?"border-lime-300/50 bg-lime-300/10 text-lime-200":"border-[var(--scout-chrome-border-soft)] text-[var(--scout-chrome-ink-faint)] hover:bg-[var(--scout-chrome-hover)] hover:text-[var(--scout-chrome-ink)]"}`,children:o.jsx(Uk,{size:13})})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsx(Yd,{icon:o.jsx(UO,{size:13}),label:"State",onClick:()=>{Be(ZQ)},disabled:p}),o.jsx(Yd,{icon:o.jsx(PO,{size:13}),label:"Ops Tail",onClick:()=>s({type:"navigate",route:{view:"ops",mode:"tail"}})}),o.jsx(Yd,{icon:o.jsx(Lk,{size:13}),label:"Fleet",onClick:()=>s({type:"navigate",route:{view:"fleet"}})}),o.jsx(Yd,{icon:C?o.jsx(tI,{size:13}):o.jsx(sI,{size:13}),label:C?"Replies On":"Replies Off",onClick:()=>S(!C)})]}),F&&o.jsx("div",{className:"rounded border border-[var(--scout-chrome-border-soft)] bg-black/10 p-3",children:o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsxs("label",{className:"flex flex-col gap-1 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-faint)]",children:["Model",o.jsx("input",{value:de,onChange:Se=>ye(Se.target.value),placeholder:"gpt-5.4-mini",className:"rounded border border-[var(--scout-chrome-border-soft)] bg-black/20 px-2 py-1.5 font-mono text-[11px] normal-case tracking-normal text-[var(--scout-chrome-ink)] placeholder:text-[var(--scout-chrome-ink-ghost)]",disabled:G||B})]}),o.jsxs("label",{className:"flex flex-col gap-1 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-faint)]",children:["System Prompt",o.jsx("textarea",{value:Te,onChange:Se=>he(Se.target.value),rows:6,className:"w-full resize-y rounded border border-[var(--scout-chrome-border-soft)] bg-black/20 px-2 py-1.5 font-mono text-[10px] normal-case leading-relaxed tracking-normal text-[var(--scout-chrome-ink)]",disabled:G||B})]}),Q&&o.jsx("div",{className:"font-mono text-[10px] leading-relaxed text-red-300",children:Q}),re&&o.jsx("div",{className:"font-mono text-[10px] leading-relaxed text-lime-200",children:re}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("button",{type:"button",onClick:()=>{je()},disabled:G||B||!Te.trim(),className:"flex items-center justify-center gap-2 rounded bg-lime-300/90 px-2.5 py-2 font-mono text-[10px] font-bold uppercase tracking-[0.12em] text-black transition-opacity disabled:cursor-not-allowed disabled:opacity-40",children:[(G||B)&&o.jsx(gc,{size:13,className:"animate-spin"}),B?"Saving":"Save"]}),o.jsx("button",{type:"button",onClick:()=>{Ae()},disabled:G||B,className:"rounded border border-[var(--scout-chrome-border-soft)] px-2.5 py-2 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-faint)] hover:bg-[var(--scout-chrome-hover)] disabled:cursor-not-allowed disabled:opacity-40",children:"Reload"})]})]})}),x===!1&&o.jsx(GQ,{issue:j,probeState:k,onLaunch:Ue,onRetry:()=>{Ee()},onSettings:Ve}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs("button",{type:"button",onClick:()=>{if(x===!1){Ue();return}R?ve():oe()},className:`flex flex-1 items-center justify-center gap-2 rounded border px-2.5 py-2 font-mono text-[10px] uppercase tracking-[0.12em] transition-colors ${R?"border-lime-300/50 bg-lime-300/10 text-lime-200":"border-[var(--scout-chrome-border-soft)] text-[var(--scout-chrome-ink)] hover:bg-[var(--scout-chrome-hover)]"}`,disabled:p||M==="processing"||k==="probing",children:[M==="processing"||k==="probing"?o.jsx(gc,{size:13,className:"animate-spin"}):R?o.jsx(XO,{size:12,className:"fill-current"}):o.jsx(LO,{size:13}),Ne]}),R&&o.jsx("button",{type:"button",onClick:()=>{xe()},className:"rounded border border-[var(--scout-chrome-border-soft)] px-2.5 py-2 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-faint)] hover:bg-[var(--scout-chrome-hover)]",children:"Discard"})]}),(z||U)&&o.jsx("div",{className:"rounded border border-[var(--scout-chrome-border-soft)] bg-black/10 px-2.5 py-2 font-mono text-[10px] leading-relaxed text-[var(--scout-chrome-ink-faint)]",children:U?"Speaking Ranger reply…":z}),(D||W||$)&&o.jsxs("div",{className:"rounded border border-[var(--scout-chrome-border-soft)] bg-black/10 px-2.5 py-2 font-mono text-[10px] leading-relaxed text-[var(--scout-chrome-ink-faint)]",children:[$&&o.jsx("div",{className:"mb-1 uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-ghost)]",children:$}),D&&o.jsxs("p",{className:"line-clamp-3",children:[o.jsx("span",{className:"text-[var(--scout-chrome-ink-soft)]",children:"You: "}),D]}),W?o.jsxs("p",{className:"mt-1 line-clamp-4",children:[o.jsx("span",{className:"text-lime-200",children:"Ranger: "}),W]}):$==="Waiting for Ranger"?o.jsx("p",{className:"mt-1 text-[var(--scout-chrome-ink-ghost)]",children:"Waiting in the sidebar..."}):null]}),o.jsxs("form",{className:"flex flex-col gap-2",onSubmit:Se=>{Se.preventDefault(),Be(u)},children:[o.jsx("textarea",{value:u,onChange:Se=>d(Se.target.value),placeholder:"Ask Ranger to inspect state or move the UI…",rows:3,className:"w-full resize-none rounded border border-[var(--scout-chrome-border-soft)] bg-black/10 px-2.5 py-2 font-mono text-[11px] leading-relaxed text-[var(--scout-chrome-ink)] placeholder:text-[var(--scout-chrome-ink-ghost)]"}),o.jsxs("button",{type:"submit",disabled:!u.trim()||p,className:"flex items-center justify-center gap-2 rounded bg-lime-300/90 px-2.5 py-2 font-mono text-[10px] font-bold uppercase tracking-[0.12em] text-black transition-opacity disabled:cursor-not-allowed disabled:opacity-40",children:[p&&o.jsx(gc,{size:13,className:"animate-spin"}),"Ask Ranger"]})]}),m&&o.jsx("div",{className:"rounded border border-red-400/30 bg-red-400/10 px-2.5 py-2 font-mono text-[10px] leading-relaxed text-red-200",children:m})]})}function YQ(e){return e.replace(/```(?:scout-ui|scout-ui-action|ranger-ui)\s*[\s\S]*?```/gi,"").trim()}function Rk(){return{requesterName:"OpenScout",productName:"Scout Audio",headline:"Turn on local voice for Ranger",body:"Scout Audio uses Vox for local speech capture and spoken replies. Start Vox, then return here to talk with your workspace.",actionLabel:"Return to OpenScout",logo:{url:new URL("/openscout-icon.png",window.location.href).toString(),symbolName:"sparkles"}}}function Yd({icon:e,label:t,onClick:n,disabled:s}){return o.jsxs("button",{type:"button",onClick:n,disabled:s,className:"flex items-center justify-center gap-1.5 rounded border border-[var(--scout-chrome-border-soft)] px-2 py-1.5 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--scout-chrome-ink)] transition-colors hover:bg-[var(--scout-chrome-hover)] disabled:cursor-not-allowed disabled:opacity-45",children:[e,t]})}function GQ({issue:e,probeState:t,onLaunch:n,onRetry:s,onSettings:a}){const l=t==="probing"||t==="launching";return o.jsxs("div",{className:"rounded border border-lime-300/25 bg-lime-300/[0.06] px-3 py-3 font-mono text-[10px] text-[var(--scout-chrome-ink)]",children:[o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(M1,{size:14,className:"mt-0.5 shrink-0 text-lime-300"}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("div",{className:"uppercase tracking-[0.14em] text-lime-200",children:"Connect Vox"}),o.jsx("p",{className:"mt-1 leading-relaxed text-[var(--scout-chrome-ink-faint)]",children:"Start Vox, then retry once the menu bar icon is visible."}),e&&o.jsx("p",{className:"mt-2 break-words leading-relaxed text-[var(--scout-chrome-ink-ghost)]",children:e})]})]}),o.jsxs("div",{className:"mt-3 grid grid-cols-3 gap-2",children:[o.jsx(Fg,{icon:t==="launching"?o.jsx(gc,{size:12,className:"animate-spin"}):o.jsx(M1,{size:12}),label:t==="launching"?"Opening":"Launch",onClick:n,disabled:t==="probing",title:"Open Vox"}),o.jsx(Fg,{icon:t==="probing"?o.jsx(gc,{size:12,className:"animate-spin"}):o.jsx($k,{size:12}),label:"Retry",onClick:s,disabled:l,title:"Check Vox again"}),o.jsx(Fg,{icon:o.jsx(Uk,{size:12}),label:"Settings",onClick:a,disabled:t==="probing",title:"Open Vox settings"})]})]})}function Fg({icon:e,label:t,onClick:n,disabled:s,title:a}){return o.jsxs("button",{type:"button",title:a,onClick:n,disabled:s,className:"flex min-h-8 items-center justify-center gap-1.5 rounded border border-lime-300/20 px-2 text-[9px] uppercase tracking-[0.12em] text-lime-100 transition-colors hover:bg-lime-300/10 disabled:cursor-not-allowed disabled:opacity-45",children:[e,t]})}function KQ(e,t){const[n,s]=g.useState(()=>{try{const l=window.localStorage.getItem(e);return l===null?t:l==="true"}catch{return t}}),a=g.useCallback(l=>{s(l);try{window.localStorage.setItem(e,l?"true":"false")}catch{}},[e]);return[n,a]}function XQ(){const{route:e}=Nt();let t=null;switch(e.view){case"inbox":case"fleet":t=o.jsx(kQ,{});break;case"agents":case"agent-info":t=o.jsx(wQ,{});break;case"sessions":case"conversation":t=o.jsx(EQ,{});break;case"work":t=o.jsx(CQ,{});break;case"ops":t=null;break;default:t=null}return o.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[o.jsx(WQ,{}),o.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t})]})}function JQ(){const{openSettings:e}=Nt();return o.jsx(Jq,{onOpen:e})}const Co={working:0,available:1,offline:2};function QQ(e){return e.project?e.project.toLowerCase():"other"}function eee(e){const t=new Map;for(const s of e){const a=QQ(s),l=t.get(a);l?l.push(s):t.set(a,[s])}const n=[];for(const[s,a]of t){a.sort((d,p)=>{const h=(Co[et(d.state)]??9)-(Co[et(p.state)]??9);return h!==0?h:(p.updatedAt??0)-(d.updatedAt??0)});const l=a.reduce((d,p)=>{const h=et(p.state);return(Co[h]??9)<(Co[d]??9)?h:d},"offline"),u=Math.max(...a.map(d=>d.updatedAt??0));n.push({key:s,label:s,agents:a,bestState:l,latestUpdate:u})}return n.sort((s,a)=>{const l=(Co[s.bestState]??9)-(Co[a.bestState]??9);return l!==0?l:a.latestUpdate-s.latestUpdate}),n}function tee(e){return e.trim().toLowerCase()}function nee(e){return[e.id,e.name,e.handle??"",e.selector??"",e.project??"",e.branch??"",e.role??"",e.harness??"",e.harnessSessionId??"",e.conversationId,e.harnessLogPath??""]}function see(e,t){return t?nee(e).some(n=>n.toLowerCase().includes(t)):!0}function To(e,t){return t?[e.harnessSessionId,e.conversationId].find(s=>s?.toLowerCase().includes(t))??null:null}function Hg(e,t,n={}){e({view:"agents",agentId:t.id,...n.observe?{conversationId:t.conversationId,tab:"observe"}:{}})}function ree(){const{agents:e,route:t,navigate:n}=Nt(),[s,a]=g.useState(()=>new Set),[l,u]=g.useState(""),d=tee(l),p=d.length>0,h=g.useMemo(()=>e.filter(j=>see(j,d)),[e,d]),m=g.useMemo(()=>eee(h),[h]),y=h[0]??null,x=t.view==="agents"?t.agentId:void 0,w=j=>{a(N=>{const k=new Set(N);return k.has(j)?k.delete(j):k.add(j),k})};return o.jsxs("div",{className:"s-left-roster",children:[o.jsx("div",{className:"s-left-roster-search s-search",children:o.jsx("input",{type:"text",className:"s-search-input",placeholder:"Search agents or session IDs…",value:l,onChange:j=>u(j.target.value),onKeyDown:j=>{j.key==="Escape"&&(l?u(""):j.target.blur()),j.key==="Enter"&&y&&Hg(n,y,{observe:!!To(y,d)})}})}),o.jsx("div",{style:{flex:1,overflow:"auto"},children:e.length===0?o.jsx("div",{className:"s-left-roster-empty",children:"No agents registered"}):h.length===0?o.jsx("div",{className:"s-left-roster-empty",children:"No agents match this session or agent search."}):m.map(j=>{const N=j.agents.length===1,k=p||s.has(j.key),E=N?j.agents[0]:null,C=j.agents.some(R=>R.id===x),S=E?To(E,d):null;return o.jsxs("div",{className:"s-left-roster-parent",children:[o.jsxs("button",{className:`s-left-roster-row${C&&(N||!k)?" s-left-roster-row--active":""}`,onClick:()=>{N?Hg(n,E,{observe:!!S}):w(j.key)},children:[o.jsxs("span",{className:"s-left-roster-avatar-wrap",children:[o.jsx("span",{className:"s-left-roster-avatar",style:{background:mt(j.label)},children:j.label[0].toUpperCase()}),o.jsx("span",{className:`s-left-roster-dot s-left-roster-dot--${j.bestState}`,style:{background:Ur(j.bestState==="working"?"working":j.bestState==="available"?"available":null)}})]}),o.jsxs("span",{className:"s-left-roster-body",children:[o.jsx("span",{className:"s-left-roster-name",children:j.label}),N&&S?o.jsxs("span",{className:"s-left-roster-sub",title:S,children:["session · ",S]}):N&&(E.project||E.branch)&&o.jsxs("span",{className:"s-left-roster-sub",children:[E.name,E.branch?` · ${E.branch}`:""]}),!N&&!k&&o.jsxs("span",{className:"s-left-roster-sub",children:[j.agents.length," agents"]})]}),!N&&o.jsx("span",{className:"s-left-roster-ct",children:k?"▾":"▸"}),N&&E.updatedAt&&o.jsx("span",{className:"s-left-roster-time",children:De(E.updatedAt)})]}),!N&&k&&o.jsx("div",{className:"s-left-roster-instances",children:j.agents.map(R=>o.jsxs("button",{className:`s-left-roster-instance${R.id===x?" s-left-roster-instance--active":""}`,onClick:()=>Hg(n,R,{observe:!!To(R,d)}),title:To(R,d)??void 0,children:[o.jsx("span",{className:`s-left-roster-instance-dot s-left-roster-dot--${et(R.state)}`,style:{background:Ur(R.state)}}),o.jsxs("span",{className:"s-left-roster-instance-label",children:[R.name,R.branch?` · ${R.branch}`:"",To(R,d)?` · ${To(R,d)}`:""]}),R.updatedAt&&o.jsx("span",{className:"s-left-roster-time",children:De(R.updatedAt)})]},R.id))})]},j.key)})})]})}function aee(){const e=py({url:$R(),healthUrl:UR(),autoConnect:!0,sessionKey:"scout-terminal"});return o.jsx("div",{style:{height:"100%",background:"#0d0d0d",overflow:"hidden"},children:o.jsx(gy,{relay:e,fontSize:13})})}function iee(){const{onboarding:e}=Nt();return e?e.hasLocalConfig?e.hasOperatorName?e.hasProjectConfig?null:o.jsx(qg,{children:o.jsx(cee,{})}):o.jsx(qg,{children:o.jsx(lee,{})}):o.jsx(qg,{children:o.jsx(oee,{})}):null}function qg({children:e}){return o.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",overflow:"auto",background:"var(--bg)",color:"var(--ink)"},children:o.jsx("div",{style:{width:"100%",maxWidth:720,padding:"80px 72px",display:"flex",flexDirection:"column",gap:40},children:e})})}function Cb({eyebrow:e,title:t,description:n}){return o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[o.jsx("div",{style:uee,children:e}),o.jsx("div",{style:dee,children:t}),o.jsx("div",{style:fee,children:n})]})}function Tb({primary:e,onPrimary:t,primaryDisabled:n,busy:s}){const{skipOnboarding:a}=Nt();return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:24,paddingTop:8},children:[o.jsx("button",{type:"button",onClick:t,disabled:n||s,style:{...pee,opacity:n||s?.5:1,cursor:n||s?"default":"pointer"},children:s?"Working…":e}),o.jsx("button",{type:"button",onClick:a,style:mee,onMouseEnter:l=>{l.currentTarget.style.color="rgba(255,255,255,0.8)"},onMouseLeave:l=>{l.currentTarget.style.color="rgba(255,255,255,0.45)"},children:"Skip for now"})]})}function Ab({message:e}){return e?o.jsx("div",{style:{borderRadius:8,border:"1px solid rgba(239,68,68,0.35)",backgroundColor:"rgba(239,68,68,0.08)",color:"rgba(252,165,165,0.95)",padding:"12px 16px",fontSize:12,lineHeight:1.5},children:e}):null}function oee(){const{onboarding:e,refreshOnboarding:t}=Nt(),[n,s]=g.useState(!1),[a,l]=g.useState(null),u=async()=>{s(!0),l(null);try{await Re("/api/onboarding/init",{method:"POST",body:"{}"}),await t()}catch(d){l(d instanceof Error?d.message:String(d))}finally{s(!1)}};return o.jsxs(o.Fragment,{children:[o.jsx(Cb,{eyebrow:"First-run setup",title:"Welcome to Scout",description:o.jsxs(o.Fragment,{children:["Scout needs a local config before it can talk to the broker, the web app, and paired devices. This writes"," ",o.jsx("code",{style:ny,children:"~/.openscout/config.json"})," with sensible defaults — you can edit it any time."]})}),o.jsxs("ul",{style:gee,children:[o.jsx(Mk,{label:"Local config (~/.openscout/config.json)",done:!1,hint:"missing"}),o.jsx(Mk,{label:".openscout/project.json in a repo",done:!!e?.hasProjectConfig,hint:e?.hasProjectConfig?e.projectRoot??void 0:"checked after setup"})]}),o.jsx(Ab,{message:a}),o.jsx(Tb,{primary:"Initialize Scout",onPrimary:()=>{u()},busy:n})]})}function lee(){const{onboarding:e,refreshOnboarding:t}=Nt(),n=e?.operatorNameSuggestion??"",[s,a]=g.useState(n),[l,u]=g.useState(!1),[d,p]=g.useState(null);g.useEffect(()=>{!s&&n&&a(n)},[n,s]);const h=async()=>{const m=s.trim();if(!m){p("Name is required.");return}u(!0),p(null);try{await Re("/api/user",{method:"POST",body:JSON.stringify({name:m})}),await t()}catch(y){p(y instanceof Error?y.message:String(y))}finally{u(!1)}};return o.jsxs(o.Fragment,{children:[o.jsx(Cb,{eyebrow:"Step 1 of 2",title:"What should we call you?",description:"Your name shows up on messages you send and in any agent that speaks for you. You can change it later in Settings."}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[o.jsx("label",{style:hf,children:"Your name"}),o.jsx("input",{autoFocus:!0,value:s,onChange:m=>{a(m.target.value),p(null)},onKeyDown:m=>{m.key==="Enter"&&h()},placeholder:n||"Operator",style:ty}),n?o.jsx("div",{style:{fontSize:11,color:"rgba(255,255,255,0.4)",fontFamily:"var(--hud-font-mono)"},children:"Prefilled from your machine."}):null]}),o.jsx(Ab,{message:d}),o.jsx(Tb,{primary:"Continue",onPrimary:()=>{h()},busy:l,primaryDisabled:!s.trim()})]})}function cee(){const{onboarding:e,refreshOnboarding:t}=Nt(),n=e?.currentDirectory??"",[s,a]=g.useState([n||"~/dev"]),[l,u]=g.useState(n),[d,p]=g.useState("claude"),[h,m]=g.useState(!1),[y,x]=g.useState(null),w=(E,C)=>{a(S=>S.map((R,A)=>A===E?C:R))},j=()=>a(E=>[...E,""]),N=E=>a(C=>C.filter((S,R)=>R!==E)),k=async()=>{const E=s.map(S=>S.trim()).filter(Boolean),C=l.trim();if(!C){x("Pick where Scout should anchor this context.");return}m(!0),x(null);try{await Re("/api/onboarding/project",{method:"POST",body:JSON.stringify({contextRoot:C,sourceRoots:E,defaultHarness:d})}),await t()}catch(S){x(S instanceof Error?S.message:String(S))}finally{m(!1)}};return o.jsxs(o.Fragment,{children:[o.jsx(Cb,{eyebrow:"Step 2 of 2",title:"Where do your repos live?",description:o.jsxs(o.Fragment,{children:["Scout scans these folders for projects and anchors this context at"," ",o.jsx("code",{style:ny,children:"<context>/.openscout/project.json"}),"."]})}),o.jsxs("div",{style:Zg,children:[o.jsx("label",{style:hf,children:"Scan folders"}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[s.map((E,C)=>o.jsxs("div",{style:{display:"flex",gap:8},children:[o.jsx("input",{value:E,onChange:S=>w(C,S.target.value),placeholder:C===0?"~/dev":"Add another folder",style:{...ty,flex:1}}),o.jsx("button",{type:"button",onClick:()=>N(C),disabled:s.length<=1,style:{..._k,opacity:s.length<=1?.4:1,cursor:s.length<=1?"default":"pointer"},"aria-label":`Remove folder ${C+1}`,children:"−"})]},C)),o.jsx("button",{type:"button",onClick:j,style:{..._k,alignSelf:"flex-start"},children:"+ Add folder"})]})]}),o.jsxs("div",{style:Zg,children:[o.jsx("label",{style:hf,children:"Context root"}),o.jsx("input",{value:l,onChange:E=>u(E.target.value),placeholder:"~/dev",style:ty}),o.jsxs("div",{style:hee,children:["Scout writes ",o.jsx("code",{style:ny,children:".openscout/project.json"})," ","inside this folder."]})]}),o.jsxs("div",{style:Zg,children:[o.jsx("label",{style:hf,children:"Default harness"}),o.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:["claude","codex"].map(E=>{const C=d===E;return o.jsxs("button",{type:"button",onClick:()=>p(E),style:{...vee,borderColor:C?"var(--accent, #2dd4bf)":"rgba(255,255,255,0.12)",backgroundColor:C?"rgba(45,212,191,0.08)":"rgba(255,255,255,0.02)"},children:[o.jsx("div",{style:{fontSize:15,fontWeight:600,textTransform:"capitalize"},children:E}),o.jsx("div",{style:{fontSize:12,color:"rgba(255,255,255,0.55)",marginTop:6,lineHeight:1.5},children:E==="claude"?"Anthropic Claude Code — local CLI agent.":"OpenAI Codex — cloud agentic sandbox."})]},E)})})]}),o.jsx(Ab,{message:y}),o.jsx(Tb,{primary:"Create project",onPrimary:()=>{k()},busy:h,primaryDisabled:!l.trim()})]})}function Mk({label:e,done:t,hint:n}){return o.jsxs("li",{style:{display:"flex",alignItems:"flex-start",gap:16},children:[o.jsx("span",{style:{marginTop:2,width:20,height:20,borderRadius:999,display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:700,flexShrink:0,backgroundColor:t?"rgba(34,197,94,0.15)":"rgba(239,68,68,0.12)",color:t?"#4ade80":"#f87171"},children:t?"✓":"•"}),o.jsxs("div",{style:{minWidth:0},children:[o.jsx("div",{style:{fontSize:13,lineHeight:1.5,color:t?"rgba(255,255,255,0.75)":"rgba(255,255,255,0.9)"},children:e}),n?o.jsx("div",{style:{fontSize:11,fontFamily:"var(--hud-font-mono)",color:"rgba(255,255,255,0.35)",marginTop:4,wordBreak:"break-all"},children:n}):null]})]})}const uee={fontSize:11,fontFamily:"var(--hud-font-mono)",textTransform:"uppercase",letterSpacing:"0.18em",color:"rgba(255,255,255,0.4)"},dee={fontSize:36,fontWeight:600,letterSpacing:"-0.01em",lineHeight:1.15},fee={fontSize:15,lineHeight:1.75,color:"rgba(255,255,255,0.6)",maxWidth:580},Zg={display:"flex",flexDirection:"column",gap:10},hf={fontSize:11,fontFamily:"var(--hud-font-mono)",textTransform:"uppercase",letterSpacing:"0.15em",color:"rgba(255,255,255,0.5)"},ty={width:"100%",padding:"10px 14px",fontSize:14,fontFamily:"var(--hud-font-mono)",color:"rgba(255,255,255,0.92)",backgroundColor:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.12)",borderRadius:8,outline:"none",boxSizing:"border-box"},hee={fontSize:12,color:"rgba(255,255,255,0.45)",lineHeight:1.6},ny={fontFamily:"var(--hud-font-mono)",fontSize:12,padding:"2px 6px",borderRadius:4,backgroundColor:"rgba(255,255,255,0.06)"},pee={fontSize:13,fontWeight:600,padding:"12px 24px",borderRadius:10,backgroundColor:"var(--accent, #2dd4bf)",color:"#0b0d12",border:"none",transition:"opacity 0.15s ease"},_k={fontSize:13,fontWeight:500,padding:"10px 14px",borderRadius:8,backgroundColor:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.12)",color:"rgba(255,255,255,0.85)",transition:"all 0.15s ease"},mee={fontSize:12,color:"rgba(255,255,255,0.45)",textDecoration:"underline dotted rgba(255,255,255,0.25)",textUnderlineOffset:4,background:"none",border:"none",cursor:"pointer",padding:"4px 2px",transition:"color 0.15s ease"},gee={display:"flex",flexDirection:"column",gap:20,margin:0,padding:0,listStyle:"none"},vee={textAlign:"left",padding:"16px 18px",borderRadius:12,border:"1px solid rgba(255,255,255,0.12)",color:"rgba(255,255,255,0.9)",cursor:"pointer",transition:"all 0.15s ease"},yee=[{commandId:"nav:home",title:"Go to Home",description:"Navigate to the home overview showing queue, threads, signal, and activity",category:"navigation",keywords:["home","inbox","dashboard"],shortcut:"Cmd+1"},{commandId:"nav:agents",title:"Go to Agents",description:"Navigate to the agents roster showing all registered agents",category:"navigation",keywords:["agents","roster","list"],shortcut:"Cmd+2"},{commandId:"nav:fleet",title:"Go to Fleet",description:"Navigate to the fleet overview with agent status summary",category:"navigation",keywords:["fleet","overview","status"],shortcut:"Cmd+3"},{commandId:"nav:sessions",title:"Go to Sessions",description:"Navigate to the sessions list showing all active conversations",category:"navigation",keywords:["sessions","conversations","threads"],shortcut:"Cmd+4"},{commandId:"nav:activity",title:"Go to Activity",description:"Navigate to the activity feed showing recent events",category:"navigation",keywords:["activity","feed","events","log"],shortcut:"Cmd+5"},{commandId:"nav:mesh",title:"Go to Mesh",description:"Navigate to the mesh network view showing nodes and topology",category:"navigation",keywords:["mesh","network","nodes","peers","topology"],shortcut:"Cmd+6"},{commandId:"nav:settings",title:"Open Settings",description:"Open the settings screen for pairing, identity, and relay config",category:"settings",keywords:["settings","preferences","config","pair"],shortcut:"Cmd+,"},{commandId:"nav:pair",title:"Pair Device",description:"Open the device pairing flow to connect a mobile device",category:"settings",keywords:["pair","qr","device","phone","mobile"]},{commandId:"scout:reload",title:"Reload Agents",description:"Refresh the agent list and message state from the broker",category:"workspace",keywords:["reload","refresh","sync"]},{commandId:"scout:open:*",title:"Open Agent Conversation",description:"Open the DM lane for one specific agent. One agent maps to a DM; group work belongs in an explicit channel and broadcasts belong in the shared channel.",category:"navigation",keywords:["open","chat","conversation","dm","message"],params:[{name:"agentId",description:"The agent identifier to open",type:"string"}]},{commandId:"scout:send:*",title:"Tell Agent",description:"Open or compose the DM tell/update path for one specific agent. Use Tell for heads-up, replies, status, and steering an active turn inside the same DM.",category:"workspace",keywords:["tell","message","update","dm","reply","steer"],params:[{name:"agentId",description:"The agent identifier to tell",type:"string"},{name:"message",description:"The message body to send",type:"string"}]},{commandId:"scout:ask:*",title:"Ask Agent",description:"Open the DM ask path for one specific agent. Use Ask when the meaning is 'own this work and get back to me' and keep follow-up in the same DM.",category:"workspace",keywords:["ask","assign","task","dm","work","reply"],params:[{name:"agentId",description:"The agent identifier to ask",type:"string"},{name:"message",description:"The message body to send",type:"string"}]},{commandId:"scout:interrupt:*",title:"Interrupt Agent",description:"Send Ctrl-C to interrupt a working agent. The commandId is scout:interrupt:{agentId}.",category:"workspace",keywords:["stop","interrupt","cancel","halt","kill"],dangerous:!0,params:[{name:"agentId",description:"The agent identifier to interrupt",type:"string"}]}];function JM(e={}){const{initialTheme:t="dark"}=e;return{id:"openscout",name:"Scout",description:"All your agents, one message away. Scout is a control plane for managing coding agents: one agent means a DM, group work means an explicit channel, Tell stays conversational, Ask is owned work with a reply path, and shared updates mean broadcast.",mode:"panel",icon:g.createElement(Lk,{size:14,strokeWidth:1.2}),Provider:({children:n})=>g.createElement(sZ,{initialTheme:t},n),leftPanel:{title:"Agents"},rightPanel:{title:"Context"},slots:{Content:yQ,LeftPanel:ree,LeftFooter:JQ,Inspector:XQ,Takeover:iee,Terminal:aee},intents:yee,hooks:{useCommands:rZ,useStatus:aZ,useNavCenter:oZ,useNavActions:lZ,useLayoutMode:cZ,useTakeover:uZ}}}JM();function Ok(e){return e==="dark"||e==="light"?e:null}function bee(){if(typeof window>"u")return"dark";const e=Ok(WZ());if(e)return e;const t=Ok(new URLSearchParams(window.location.search).get("theme"));return t||"dark"}function xee(e){typeof document>"u"||(document.documentElement.dataset.scoutThemeMode=e,document.documentElement.style.colorScheme=e)}const QM=document.getElementById("root");if(!QM)throw new Error("missing #root");const e_=bee();xee(e_);wO.createRoot(QM).render(o.jsx(g.StrictMode,{children:o.jsx(dZ,{app:JM({initialTheme:e_})})}));export{Dk as F,Io as f,o as j,g as r};
|