@openscout/scout 0.2.63 → 0.2.64
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 +25 -0
- package/dist/client/assets/{arc.es-B2XMIUBi.js → arc.es-DglF81f4.js} +1 -1
- package/dist/client/assets/index-BRvY3oC-.js +159 -0
- package/dist/client/assets/index-CUNnl56m.css +1 -0
- package/dist/client/index.html +2 -2
- package/dist/main.mjs +1084 -1091
- package/dist/pair-supervisor.mjs +39 -10
- package/dist/scout-control-plane-web.mjs +168 -16
- package/dist/scout-web-server.mjs +168 -16
- package/package.json +2 -2
- package/dist/client/assets/index-DB4dwQr2.css +0 -1
- package/dist/client/assets/index-DiSMCren.js +0 -158
- package/dist/control-plane-client/assets/addon-fit-DX4qG4td.js +0 -1
- package/dist/control-plane-client/assets/addon-webgl-DCtw1yLn.js +0 -64
- package/dist/control-plane-client/assets/arc.es-CcKhIPRw.js +0 -188
- package/dist/control-plane-client/assets/index-BGcMYoYJ.css +0 -1
- package/dist/control-plane-client/assets/index-BkEXBsPk.js +0 -140
- package/dist/control-plane-client/assets/xterm-B-qIQCd3.js +0 -16
- package/dist/control-plane-client/index.html +0 -16
- package/dist/control-plane-client/openscout-icon.png +0 -0
- /package/dist/{control-plane-client → client}/assets/index-TVkH_WDG.js +0 -0
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
function eO(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 Nk(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Tm={exports:{}},Xl={};var h1;function tO(){if(h1)return Xl;h1=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 Xl.Fragment=t,Xl.jsx=n,Xl.jsxs=n,Xl}var p1;function nO(){return p1||(p1=1,Tm.exports=tO()),Tm.exports}var o=nO(),Am={exports:{}},Ge={};var m1;function sO(){if(m1)return Ge;m1=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"),b=Symbol.iterator;function w(I){return I===null||typeof I!="object"?null:(I=b&&I[b]||I["@@iterator"],typeof I=="function"?I:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,k={};function T(I,F,G){this.props=I,this.context=F,this.refs=k,this.updater=G||j}T.prototype.isReactComponent={},T.prototype.setState=function(I,F){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,F,"setState")},T.prototype.forceUpdate=function(I){this.updater.enqueueForceUpdate(this,I,"forceUpdate")};function E(){}E.prototype=T.prototype;function S(I,F,G){this.props=I,this.context=F,this.refs=k,this.updater=G||j}var M=S.prototype=new E;M.constructor=S,N(M,T.prototype),M.isPureReactComponent=!0;var R=Array.isArray;function A(){}var _={H:null,A:null,T:null,S:null},$=Object.prototype.hasOwnProperty;function V(I,F,G){var J=G.ref;return{$$typeof:e,type:I,key:F,ref:J!==void 0?J:null,props:G}}function U(I,F){return V(I.type,F,I.props)}function O(I){return typeof I=="object"&&I!==null&&I.$$typeof===e}function P(I){var F={"=":"=0",":":"=2"};return"$"+I.replace(/[=:]/g,function(G){return F[G]})}var q=/\/+/g;function Z(I,F){return typeof I=="object"&&I!==null&&I.key!=null?P(""+I.key):F.toString(36)}function H(I){switch(I.status){case"fulfilled":return I.value;case"rejected":throw I.reason;default:switch(typeof I.status=="string"?I.then(A,A):(I.status="pending",I.then(function(F){I.status==="pending"&&(I.status="fulfilled",I.value=F)},function(F){I.status==="pending"&&(I.status="rejected",I.reason=F)})),I.status){case"fulfilled":return I.value;case"rejected":throw I.reason}}throw I}function L(I,F,G,J,ce){var se=typeof I;(se==="undefined"||se==="boolean")&&(I=null);var ve=!1;if(I===null)ve=!0;else switch(se){case"bigint":case"string":case"number":ve=!0;break;case"object":switch(I.$$typeof){case e:case t:ve=!0;break;case m:return ve=I._init,L(ve(I._payload),F,G,J,ce)}}if(ve)return ce=ce(I),ve=J===""?"."+Z(I,0):J,R(ce)?(G="",ve!=null&&(G=ve.replace(q,"$&/")+"/"),L(ce,F,G,"",function(Ae){return Ae})):ce!=null&&(O(ce)&&(ce=U(ce,G+(ce.key==null||I&&I.key===ce.key?"":(""+ce.key).replace(q,"$&/")+"/")+ve)),F.push(ce)),1;ve=0;var me=J===""?".":J+":";if(R(I))for(var je=0;je<I.length;je++)J=I[je],se=me+Z(J,je),ve+=L(J,F,G,se,ce);else if(je=w(I),typeof je=="function")for(I=je.call(I),je=0;!(J=I.next()).done;)J=J.value,se=me+Z(J,je++),ve+=L(J,F,G,se,ce);else if(se==="object"){if(typeof I.then=="function")return L(H(I),F,G,J,ce);throw F=String(I),Error("Objects are not valid as a React child (found: "+(F==="[object Object]"?"object with keys {"+Object.keys(I).join(", ")+"}":F)+"). If you meant to render a collection of children, use an array instead.")}return ve}function z(I,F,G){if(I==null)return I;var J=[],ce=0;return L(I,J,"","",function(se){return F.call(G,se,ce++)}),J}function B(I){if(I._status===-1){var F=I._result;F=F(),F.then(function(G){(I._status===0||I._status===-1)&&(I._status=1,I._result=G)},function(G){(I._status===0||I._status===-1)&&(I._status=2,I._result=G)}),I._status===-1&&(I._status=0,I._result=F)}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 F=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(F))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",I);return}console.error(I)},W={map:z,forEach:function(I,F,G){z(I,function(){F.apply(this,arguments)},G)},count:function(I){var F=0;return z(I,function(){F++}),F},toArray:function(I){return z(I,function(F){return F})||[]},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=W,Ge.Component=T,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,F,G){if(I==null)throw Error("The argument must be a React element, but you passed "+I+".");var J=N({},I.props),ce=I.key;if(F!=null)for(se in F.key!==void 0&&(ce=""+F.key),F)!$.call(F,se)||se==="key"||se==="__self"||se==="__source"||se==="ref"&&F.ref===void 0||(J[se]=F[se]);var se=arguments.length-2;if(se===1)J.children=G;else if(1<se){for(var ve=Array(se),me=0;me<se;me++)ve[me]=arguments[me+2];J.children=ve}return V(I.type,ce,J)},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,F,G){var J,ce={},se=null;if(F!=null)for(J in F.key!==void 0&&(se=""+F.key),F)$.call(F,J)&&J!=="key"&&J!=="__self"&&J!=="__source"&&(ce[J]=F[J]);var ve=arguments.length-2;if(ve===1)ce.children=G;else if(1<ve){for(var me=Array(ve),je=0;je<ve;je++)me[je]=arguments[je+2];ce.children=me}if(I&&I.defaultProps)for(J in ve=I.defaultProps,ve)ce[J]===void 0&&(ce[J]=ve[J]);return V(I,se,ce)},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:B}},Ge.memo=function(I,F){return{$$typeof:h,type:I,compare:F===void 0?null:F}},Ge.startTransition=function(I){var F=_.T,G={};_.T=G;try{var J=I(),ce=_.S;ce!==null&&ce(G,J),typeof J=="object"&&J!==null&&typeof J.then=="function"&&J.then(A,X)}catch(se){X(se)}finally{F!==null&&G.types!==null&&(F.types=G.types),_.T=F}},Ge.unstable_useCacheRefresh=function(){return _.H.useCacheRefresh()},Ge.use=function(I){return _.H.use(I)},Ge.useActionState=function(I,F,G){return _.H.useActionState(I,F,G)},Ge.useCallback=function(I,F){return _.H.useCallback(I,F)},Ge.useContext=function(I){return _.H.useContext(I)},Ge.useDebugValue=function(){},Ge.useDeferredValue=function(I,F){return _.H.useDeferredValue(I,F)},Ge.useEffect=function(I,F){return _.H.useEffect(I,F)},Ge.useEffectEvent=function(I){return _.H.useEffectEvent(I)},Ge.useId=function(){return _.H.useId()},Ge.useImperativeHandle=function(I,F,G){return _.H.useImperativeHandle(I,F,G)},Ge.useInsertionEffect=function(I,F){return _.H.useInsertionEffect(I,F)},Ge.useLayoutEffect=function(I,F){return _.H.useLayoutEffect(I,F)},Ge.useMemo=function(I,F){return _.H.useMemo(I,F)},Ge.useOptimistic=function(I,F){return _.H.useOptimistic(I,F)},Ge.useReducer=function(I,F,G){return _.H.useReducer(I,F,G)},Ge.useRef=function(I){return _.H.useRef(I)},Ge.useState=function(I){return _.H.useState(I)},Ge.useSyncExternalStore=function(I,F,G){return _.H.useSyncExternalStore(I,F,G)},Ge.useTransition=function(){return _.H.useTransition()},Ge.version="19.2.3",Ge}var g1;function Vc(){return g1||(g1=1,Am.exports=sO()),Am.exports}var g=Vc();const Oo=Nk(g),kk=eO({__proto__:null,default:Oo},[g]);var Mm={exports:{}},Jl={},Rm={exports:{}},_m={};var v1;function rO(){return v1||(v1=1,(function(e){function t(L,z){var B=L.length;L.push(z);e:for(;0<B;){var X=B-1>>>1,W=L[X];if(0<a(W,z))L[X]=z,L[B]=W,B=X;else break e}}function n(L){return L.length===0?null:L[0]}function s(L){if(L.length===0)return null;var z=L[0],B=L.pop();if(B!==z){L[0]=B;e:for(var X=0,W=L.length,I=W>>>1;X<I;){var F=2*(X+1)-1,G=L[F],J=F+1,ce=L[J];if(0>a(G,B))J<W&&0>a(ce,G)?(L[X]=ce,L[J]=B,X=J):(L[X]=G,L[F]=B,X=F);else if(J<W&&0>a(ce,B))L[X]=ce,L[J]=B,X=J;else break e}}return z}function a(L,z){var B=L.sortIndex-z.sortIndex;return B!==0?B:L.id-z.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,b=3,w=!1,j=!1,N=!1,k=!1,T=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;function M(L){for(var z=n(h);z!==null;){if(z.callback===null)s(h);else if(z.startTime<=L)s(h),z.sortIndex=z.expirationTime,t(p,z);else break;z=n(h)}}function R(L){if(N=!1,M(L),!j)if(n(p)!==null)j=!0,A||(A=!0,P());else{var z=n(h);z!==null&&H(R,z.startTime-L)}}var A=!1,_=-1,$=5,V=-1;function U(){return k?!0:!(e.unstable_now()-V<$)}function O(){if(k=!1,A){var L=e.unstable_now();V=L;var z=!0;try{e:{j=!1,N&&(N=!1,E(_),_=-1),w=!0;var B=b;try{t:{for(M(L),y=n(p);y!==null&&!(y.expirationTime>L&&U());){var X=y.callback;if(typeof X=="function"){y.callback=null,b=y.priorityLevel;var W=X(y.expirationTime<=L);if(L=e.unstable_now(),typeof W=="function"){y.callback=W,M(L),z=!0;break t}y===n(p)&&s(p),M(L)}else s(p);y=n(p)}if(y!==null)z=!0;else{var I=n(h);I!==null&&H(R,I.startTime-L),z=!1}}break e}finally{y=null,b=B,w=!1}z=void 0}}finally{z?P():A=!1}}}var P;if(typeof S=="function")P=function(){S(O)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,Z=q.port2;q.port1.onmessage=O,P=function(){Z.postMessage(null)}}else P=function(){T(O,0)};function H(L,z){_=T(function(){L(e.unstable_now())},z)}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(L){L.callback=null},e.unstable_forceFrameRate=function(L){0>L||125<L?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):$=0<L?Math.floor(1e3/L):5},e.unstable_getCurrentPriorityLevel=function(){return b},e.unstable_next=function(L){switch(b){case 1:case 2:case 3:var z=3;break;default:z=b}var B=b;b=z;try{return L()}finally{b=B}},e.unstable_requestPaint=function(){k=!0},e.unstable_runWithPriority=function(L,z){switch(L){case 1:case 2:case 3:case 4:case 5:break;default:L=3}var B=b;b=L;try{return z()}finally{b=B}},e.unstable_scheduleCallback=function(L,z,B){var X=e.unstable_now();switch(typeof B=="object"&&B!==null?(B=B.delay,B=typeof B=="number"&&0<B?X+B:X):B=X,L){case 1:var W=-1;break;case 2:W=250;break;case 5:W=1073741823;break;case 4:W=1e4;break;default:W=5e3}return W=B+W,L={id:m++,callback:z,priorityLevel:L,startTime:B,expirationTime:W,sortIndex:-1},B>X?(L.sortIndex=B,t(h,L),n(p)===null&&L===n(h)&&(N?(E(_),_=-1):N=!0,H(R,B-X))):(L.sortIndex=W,t(p,L),j||w||(j=!0,A||(A=!0,P()))),L},e.unstable_shouldYield=U,e.unstable_wrapCallback=function(L){var z=b;return function(){var B=b;b=z;try{return L.apply(this,arguments)}finally{b=B}}}})(_m)),_m}var y1;function aO(){return y1||(y1=1,Rm.exports=rO()),Rm.exports}var Om={exports:{}},_n={};var x1;function iO(){if(x1)return _n;x1=1;var e=Vc();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),b=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:b,fetchPriority:w}):m==="script"&&s.d.X(p,{crossOrigin:y,integrity:b,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 b1;function Ek(){if(b1)return Om.exports;b1=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=iO(),Om.exports}var w1;function oO(){if(w1)return Jl;w1=1;var e=aO(),t=Vc(),n=Ek();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 x=v.alternate;if(x===null){if(f=v.return,f!==null){c=f;continue}break}if(v.child===x.child){for(x=v.child;x;){if(x===c)return p(v),r;if(x===f)return p(v),i;x=x.sibling}throw Error(s(188))}if(c.return!==f.return)c=v,f=x;else{for(var C=!1,D=v.child;D;){if(D===c){C=!0,c=v,f=x;break}if(D===f){C=!0,f=v,c=x;break}D=D.sibling}if(!C){for(D=x.child;D;){if(D===c){C=!0,c=x,f=v;break}if(D===f){C=!0,f=x,c=v;break}D=D.sibling}if(!C)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,b=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"),T=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),S=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),A=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),$=Symbol.for("react.lazy"),V=Symbol.for("react.activity"),U=Symbol.for("react.memo_cache_sentinel"),O=Symbol.iterator;function P(r){return r===null||typeof r!="object"?null:(r=O&&r[O]||r["@@iterator"],typeof r=="function"?r:null)}var q=Symbol.for("react.client.reference");function Z(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===q?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case N:return"Fragment";case T:return"Profiler";case k:return"StrictMode";case R:return"Suspense";case A:return"SuspenseList";case V:return"Activity"}if(typeof r=="object")switch(r.$$typeof){case j:return"Portal";case S:return r.displayName||"Context";case E:return(r._context.displayName||"Context")+".Consumer";case M: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:Z(r.type)||"Memo";case $:i=r._payload,r=r._init;try{return Z(r(i))}catch{}}return null}var H=Array.isArray,L=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,z=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B={pending:!1,data:null,method:null,action:null},X=[],W=-1;function I(r){return{current:r}}function F(r){0>W||(r.current=X[W],X[W]=null,W--)}function G(r,i){W++,X[W]=r.current,r.current=i}var J=I(null),ce=I(null),se=I(null),ve=I(null);function me(r,i){switch(G(se,i),G(ce,r),G(J,null),i.nodeType){case 9:case 11:r=(r=i.documentElement)&&(r=r.namespaceURI)?Pw(r):0;break;default:if(r=i.tagName,i=i.namespaceURI)i=Pw(i),r=zw(i,r);else switch(r){case"svg":r=1;break;case"math":r=2;break;default:r=0}}F(J),G(J,r)}function je(){F(J),F(ce),F(se)}function Ae(r){r.memoizedState!==null&&G(ve,r);var i=J.current,c=zw(i,r.type);i!==c&&(G(ce,r),G(J,c))}function he(r){ce.current===r&&(F(J),F(ce)),ve.current===r&&(F(ve),Wl._currentValue=B)}var ue,de;function Le(r){if(ue===void 0)try{throw Error()}catch(c){var i=c.stack.trim().match(/\n( *(at )?)/);ue=i&&i[1]||"",de=-1<c.stack.indexOf(`
|
|
2
|
-
at`)?" (<anonymous>)":-1<c.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
3
|
-
`+ue+r+de}var Te=!1;function we(r,i){if(!r||Te)return"";Te=!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 re=ae}Reflect.construct(r,[],pe)}else{try{pe.call()}catch(ae){re=ae}r.call(pe.prototype)}}else{try{throw Error()}catch(ae){re=ae}(pe=r())&&typeof pe.catch=="function"&&pe.catch(function(){})}}catch(ae){if(ae&&re&&typeof ae.stack=="string")return[ae.stack,re.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 x=f.DetermineComponentFrameRoot(),C=x[0],D=x[1];if(C&&D){var Y=C.split(`
|
|
4
|
-
`),ne=D.split(`
|
|
5
|
-
`);for(v=f=0;f<Y.length&&!Y[f].includes("DetermineComponentFrameRoot");)f++;for(;v<ne.length&&!ne[v].includes("DetermineComponentFrameRoot");)v++;if(f===Y.length||v===ne.length)for(f=Y.length-1,v=ne.length-1;1<=f&&0<=v&&Y[f]!==ne[v];)v--;for(;1<=f&&0<=v;f--,v--)if(Y[f]!==ne[v]){if(f!==1||v!==1)do if(f--,v--,0>v||Y[f]!==ne[v]){var oe=`
|
|
6
|
-
`+Y[f].replace(" at new "," at ");return r.displayName&&oe.includes("<anonymous>")&&(oe=oe.replace("<anonymous>",r.displayName)),oe}while(1<=f&&0<=v);break}}}finally{Te=!1,Error.prepareStackTrace=c}return(c=r?r.displayName||r.name:"")?Le(c):""}function Ne(r,i){switch(r.tag){case 26:case 27:case 5:return Le(r.type);case 16:return Le("Lazy");case 13:return r.child!==i&&i!==null?Le("Suspense Fallback"):Le("Suspense");case 19:return Le("SuspenseList");case 0:case 15:return we(r.type,!1);case 11:return we(r.type.render,!1);case 1:return we(r.type,!0);case 31:return Le("Activity");default:return""}}function _e(r){try{var i="",c=null;do i+=Ne(r,c),c=r,r=r.return;while(r);return i}catch(f){return`
|
|
7
|
-
Error generating stack: `+f.message+`
|
|
8
|
-
`+f.stack}}var Fe=Object.prototype.hasOwnProperty,Ve=e.unstable_scheduleCallback,ie=e.unstable_cancelCallback,ye=e.unstable_shouldYield,be=e.unstable_requestPaint,ke=e.unstable_now,Ee=e.unstable_getCurrentPriorityLevel,Se=e.unstable_ImmediatePriority,Be=e.unstable_UserBlockingPriority,ze=e.unstable_NormalPriority,bt=e.unstable_LowPriority,kt=e.unstable_IdlePriority,un=e.log,Xt=e.unstable_setDisableYieldValue,Jt=null,$e=null;function at(r){if(typeof un=="function"&&Xt(r),$e&&typeof $e.setStrictMode=="function")try{$e.setStrictMode(Jt,r)}catch{}}var lt=Math.clz32?Math.clz32:xn,gt=Math.log,Bt=Math.LN2;function xn(r){return r>>>=0,r===0?32:31-(gt(r)/Bt|0)|0}var Wt=256,Rn=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,x=r.suspendedLanes,C=r.pingedLanes;r=r.warmLanes;var D=f&134217727;return D!==0?(f=D&~x,f!==0?v=fn(f):(C&=D,C!==0?v=fn(C):c||(c=D&~r,c!==0&&(v=fn(c))))):(D=f&~x,D!==0?v=fn(D):C!==0?v=fn(C):c||(c=f&~r,c!==0&&(v=fn(c)))),v===0?0:i!==0&&i!==v&&(i&x)===0&&(x=v&-v,c=i&-i,x>=c||x===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 xe(r,i){r.pendingLanes|=i,i!==268435456&&(r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0)}function Ze(r,i,c,f,v,x){var C=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 D=r.entanglements,Y=r.expirationTimes,ne=r.hiddenUpdates;for(c=C&~c;0<c;){var oe=31-lt(c),pe=1<<oe;D[oe]=0,Y[oe]=-1;var re=ne[oe];if(re!==null)for(ne[oe]=null,oe=0;oe<re.length;oe++){var ae=re[oe];ae!==null&&(ae.lane&=-536870913)}c&=~pe}f!==0&&We(r,f,0),x!==0&&v===0&&r.tag!==0&&(r.suspendedLanes|=x&~(C&~i))}function We(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 bn(){var r=z.p;return r!==0?r:(r=window.event,r===void 0?32:i1(r.type))}function Ws(r,i){var c=z.p;try{return z.p=r,i()}finally{z.p=c}}var Ft=Math.random().toString(36).slice(2),wn="__reactFiber$"+Ft,Hn="__reactProps$"+Ft,Ri="__reactContainer$"+Ft,xh="__reactEvents$"+Ft,FR="__reactListeners$"+Ft,HR="__reactHandles$"+Ft,Sx="__reactResources$"+Ft,ll="__reactMarker$"+Ft;function bh(r){delete r[wn],delete r[Hn],delete r[xh],delete r[FR],delete r[HR]}function _i(r){var i=r[wn];if(i)return i;for(var c=r.parentNode;c;){if(i=c[Ri]||c[wn]){if(c=i.alternate,i.child!==null||c!==null&&c.child!==null)for(r=Hw(r);r!==null;){if(c=r[wn])return c;r=Hw(r)}return i}r=c,c=r.parentNode}return null}function Oi(r){if(r=r[wn]||r[Ri]){var i=r.tag;if(i===5||i===6||i===13||i===31||i===26||i===27||i===3)return r}return null}function cl(r){var i=r.tag;if(i===5||i===26||i===27||i===6)return r.stateNode;throw Error(s(33))}function Ii(r){var i=r[Sx];return i||(i=r[Sx]={hoistableStyles:new Map,hoistableScripts:new Map}),i}function gn(r){r[ll]=!0}var Nx=new Set,kx={};function La(r,i){Di(r,i),Di(r+"Capture",i)}function Di(r,i){for(kx[r]=i,r=0;r<i.length;r++)Nx.add(i[r])}var qR=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]*$"),Ex={},Cx={};function ZR(r){return Fe.call(Cx,r)?!0:Fe.call(Ex,r)?!1:qR.test(r)?Cx[r]=!0:(Ex[r]=!0,!1)}function tu(r,i,c){if(ZR(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 nu(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 Tx(r){var i=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(i==="checkbox"||i==="radio")}function WR(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,x=f.set;return Object.defineProperty(r,i,{configurable:!0,get:function(){return v.call(this)},set:function(C){c=""+C,x.call(this,C)}}),Object.defineProperty(r,i,{enumerable:f.enumerable}),{getValue:function(){return c},setValue:function(C){c=""+C},stopTracking:function(){r._valueTracker=null,delete r[i]}}}}function wh(r){if(!r._valueTracker){var i=Tx(r)?"checked":"value";r._valueTracker=WR(r,i,""+r[i])}}function Ax(r){if(!r)return!1;var i=r._valueTracker;if(!i)return!0;var c=i.getValue(),f="";return r&&(f=Tx(r)?r.checked?"true":"false":r.value),r=f,r!==c?(i.setValue(r),!0):!1}function su(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 YR=/[\n"\\]/g;function ms(r){return r.replace(YR,function(i){return"\\"+i.charCodeAt(0).toString(16)+" "})}function jh(r,i,c,f,v,x,C,D){r.name="",C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"?r.type=C:r.removeAttribute("type"),i!=null?C==="number"?(i===0&&r.value===""||r.value!=i)&&(r.value=""+ps(i)):r.value!==""+ps(i)&&(r.value=""+ps(i)):C!=="submit"&&C!=="reset"||r.removeAttribute("value"),i!=null?Sh(r,C,ps(i)):c!=null?Sh(r,C,ps(c)):f!=null&&r.removeAttribute("value"),v==null&&x!=null&&(r.defaultChecked=!!x),v!=null&&(r.checked=v&&typeof v!="function"&&typeof v!="symbol"),D!=null&&typeof D!="function"&&typeof D!="symbol"&&typeof D!="boolean"?r.name=""+ps(D):r.removeAttribute("name")}function Mx(r,i,c,f,v,x,C,D){if(x!=null&&typeof x!="function"&&typeof x!="symbol"&&typeof x!="boolean"&&(r.type=x),i!=null||c!=null){if(!(x!=="submit"&&x!=="reset"||i!=null)){wh(r);return}c=c!=null?""+ps(c):"",i=i!=null?""+ps(i):c,D||i===r.value||(r.value=i),r.defaultValue=i}f=f??v,f=typeof f!="function"&&typeof f!="symbol"&&!!f,r.checked=D?r.checked:!!f,r.defaultChecked=!!f,C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"&&(r.name=C),wh(r)}function Sh(r,i,c){i==="number"&&su(r.ownerDocument)===r||r.defaultValue===""+c||(r.defaultValue=""+c)}function Pi(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 Rx(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 _x(r,i,c,f){if(i==null){if(f!=null){if(c!=null)throw Error(s(92));if(H(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),wh(r)}function zi(r,i){if(i){var c=r.firstChild;if(c&&c===r.lastChild&&c.nodeType===3){c.nodeValue=i;return}}r.textContent=i}var GR=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 Ox(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||GR.has(i)?i==="float"?r.cssFloat=c:r[i]=(""+c).trim():r[i]=c+"px"}function Ix(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&&Ox(r,v,f)}else for(var x in i)i.hasOwnProperty(x)&&Ox(r,x,i[x])}function Nh(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 KR=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"]]),XR=/^[\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 ru(r){return XR.test(""+r)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":r}function pr(){}var kh=null;function Eh(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var Li=null,$i=null;function Dx(r){var i=Oi(r);if(i&&(r=i.stateNode)){var c=r[Hn]||null;e:switch(r=i.stateNode,i.type){case"input":if(jh(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));jh(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&&Ax(f)}break e;case"textarea":Rx(r,c.value,c.defaultValue);break e;case"select":i=c.value,i!=null&&Pi(r,!!c.multiple,i,!1)}}}var Ch=!1;function Px(r,i,c){if(Ch)return r(i,c);Ch=!0;try{var f=r(i);return f}finally{if(Ch=!1,(Li!==null||$i!==null)&&(qu(),Li&&(i=Li,r=$i,$i=Li=null,Dx(i),r)))for(i=0;i<r.length;i++)Dx(r[i])}}function ul(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"),Th=!1;if(mr)try{var dl={};Object.defineProperty(dl,"passive",{get:function(){Th=!0}}),window.addEventListener("test",dl,dl),window.removeEventListener("test",dl,dl)}catch{Th=!1}var Br=null,Ah=null,au=null;function zx(){if(au)return au;var r,i=Ah,c=i.length,f,v="value"in Br?Br.value:Br.textContent,x=v.length;for(r=0;r<c&&i[r]===v[r];r++);var C=c-r;for(f=1;f<=C&&i[c-f]===v[x-f];f++);return au=v.slice(r,1<f?1-f:void 0)}function iu(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 ou(){return!0}function Lx(){return!1}function qn(r){function i(c,f,v,x,C){this._reactName=c,this._targetInst=v,this.type=f,this.nativeEvent=x,this.target=C,this.currentTarget=null;for(var D in r)r.hasOwnProperty(D)&&(c=r[D],this[D]=c?c(x):x[D]);return this.isDefaultPrevented=(x.defaultPrevented!=null?x.defaultPrevented:x.returnValue===!1)?ou:Lx,this.isPropagationStopped=Lx,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=ou)},stopPropagation:function(){var c=this.nativeEvent;c&&(c.stopPropagation?c.stopPropagation():typeof c.cancelBubble!="unknown"&&(c.cancelBubble=!0),this.isPropagationStopped=ou)},persist:function(){},isPersistent:ou}),i}var $a={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},lu=qn($a),fl=y({},$a,{view:0,detail:0}),JR=qn(fl),Mh,Rh,hl,cu=y({},fl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Oh,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!==hl&&(hl&&r.type==="mousemove"?(Mh=r.screenX-hl.screenX,Rh=r.screenY-hl.screenY):Rh=Mh=0,hl=r),Mh)},movementY:function(r){return"movementY"in r?r.movementY:Rh}}),$x=qn(cu),QR=y({},cu,{dataTransfer:0}),e2=qn(QR),t2=y({},fl,{relatedTarget:0}),_h=qn(t2),n2=y({},$a,{animationName:0,elapsedTime:0,pseudoElement:0}),s2=qn(n2),r2=y({},$a,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),a2=qn(r2),i2=y({},$a,{data:0}),Ux=qn(i2),o2={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},l2={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"},c2={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function u2(r){var i=this.nativeEvent;return i.getModifierState?i.getModifierState(r):(r=c2[r])?!!i[r]:!1}function Oh(){return u2}var d2=y({},fl,{key:function(r){if(r.key){var i=o2[r.key]||r.key;if(i!=="Unidentified")return i}return r.type==="keypress"?(r=iu(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?l2[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Oh,charCode:function(r){return r.type==="keypress"?iu(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?iu(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),f2=qn(d2),h2=y({},cu,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Bx=qn(h2),p2=y({},fl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Oh}),m2=qn(p2),g2=y({},$a,{propertyName:0,elapsedTime:0,pseudoElement:0}),v2=qn(g2),y2=y({},cu,{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}),x2=qn(y2),b2=y({},$a,{newState:0,oldState:0}),w2=qn(b2),j2=[9,13,27,32],Ih=mr&&"CompositionEvent"in window,pl=null;mr&&"documentMode"in document&&(pl=document.documentMode);var S2=mr&&"TextEvent"in window&&!pl,Vx=mr&&(!Ih||pl&&8<pl&&11>=pl),Fx=" ",Hx=!1;function qx(r,i){switch(r){case"keyup":return j2.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Zx(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var Ui=!1;function N2(r,i){switch(r){case"compositionend":return Zx(i);case"keypress":return i.which!==32?null:(Hx=!0,Fx);case"textInput":return r=i.data,r===Fx&&Hx?null:r;default:return null}}function k2(r,i){if(Ui)return r==="compositionend"||!Ih&&qx(r,i)?(r=zx(),au=Ah=Br=null,Ui=!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 Vx&&i.locale!=="ko"?null:i.data;default:return null}}var E2={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 Wx(r){var i=r&&r.nodeName&&r.nodeName.toLowerCase();return i==="input"?!!E2[r.type]:i==="textarea"}function Yx(r,i,c,f){Li?$i?$i.push(f):$i=[f]:Li=f,i=Ju(i,"onChange"),0<i.length&&(c=new lu("onChange","change",null,c,f),r.push({event:c,listeners:i}))}var ml=null,gl=null;function C2(r){Mw(r,0)}function uu(r){var i=cl(r);if(Ax(i))return r}function Gx(r,i){if(r==="change")return i}var Kx=!1;if(mr){var Dh;if(mr){var Ph="oninput"in document;if(!Ph){var Xx=document.createElement("div");Xx.setAttribute("oninput","return;"),Ph=typeof Xx.oninput=="function"}Dh=Ph}else Dh=!1;Kx=Dh&&(!document.documentMode||9<document.documentMode)}function Jx(){ml&&(ml.detachEvent("onpropertychange",Qx),gl=ml=null)}function Qx(r){if(r.propertyName==="value"&&uu(gl)){var i=[];Yx(i,gl,r,Eh(r)),Px(C2,i)}}function T2(r,i,c){r==="focusin"?(Jx(),ml=i,gl=c,ml.attachEvent("onpropertychange",Qx)):r==="focusout"&&Jx()}function A2(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return uu(gl)}function M2(r,i){if(r==="click")return uu(i)}function R2(r,i){if(r==="input"||r==="change")return uu(i)}function _2(r,i){return r===i&&(r!==0||1/r===1/i)||r!==r&&i!==i}var ns=typeof Object.is=="function"?Object.is:_2;function vl(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(!Fe.call(i,v)||!ns(r[v],i[v]))return!1}return!0}function eb(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function tb(r,i){var c=eb(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=eb(c)}}function nb(r,i){return r&&i?r===i?!0:r&&r.nodeType===3?!1:i&&i.nodeType===3?nb(r,i.parentNode):"contains"in r?r.contains(i):r.compareDocumentPosition?!!(r.compareDocumentPosition(i)&16):!1:!1}function sb(r){r=r!=null&&r.ownerDocument!=null&&r.ownerDocument.defaultView!=null?r.ownerDocument.defaultView:window;for(var i=su(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=su(r.document)}return i}function zh(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 O2=mr&&"documentMode"in document&&11>=document.documentMode,Bi=null,Lh=null,yl=null,$h=!1;function rb(r,i,c){var f=c.window===c?c.document:c.nodeType===9?c:c.ownerDocument;$h||Bi==null||Bi!==su(f)||(f=Bi,"selectionStart"in f&&zh(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}),yl&&vl(yl,f)||(yl=f,f=Ju(Lh,"onSelect"),0<f.length&&(i=new lu("onSelect","select",null,i,c),r.push({event:i,listeners:f}),i.target=Bi)))}function Ua(r,i){var c={};return c[r.toLowerCase()]=i.toLowerCase(),c["Webkit"+r]="webkit"+i,c["Moz"+r]="moz"+i,c}var Vi={animationend:Ua("Animation","AnimationEnd"),animationiteration:Ua("Animation","AnimationIteration"),animationstart:Ua("Animation","AnimationStart"),transitionrun:Ua("Transition","TransitionRun"),transitionstart:Ua("Transition","TransitionStart"),transitioncancel:Ua("Transition","TransitionCancel"),transitionend:Ua("Transition","TransitionEnd")},Uh={},ab={};mr&&(ab=document.createElement("div").style,"AnimationEvent"in window||(delete Vi.animationend.animation,delete Vi.animationiteration.animation,delete Vi.animationstart.animation),"TransitionEvent"in window||delete Vi.transitionend.transition);function Ba(r){if(Uh[r])return Uh[r];if(!Vi[r])return r;var i=Vi[r],c;for(c in i)if(i.hasOwnProperty(c)&&c in ab)return Uh[r]=i[c];return r}var ib=Ba("animationend"),ob=Ba("animationiteration"),lb=Ba("animationstart"),I2=Ba("transitionrun"),D2=Ba("transitionstart"),P2=Ba("transitioncancel"),cb=Ba("transitionend"),ub=new Map,Bh="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(" ");Bh.push("scrollEnd");function _s(r,i){ub.set(r,i),La(i,[r])}var du=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=[],Fi=0,Vh=0;function fu(){for(var r=Fi,i=Vh=Fi=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 x=gs[i];if(gs[i++]=null,f!==null&&v!==null){var C=f.pending;C===null?v.next=v:(v.next=C.next,C.next=v),f.pending=v}x!==0&&db(c,v,x)}}function hu(r,i,c,f){gs[Fi++]=r,gs[Fi++]=i,gs[Fi++]=c,gs[Fi++]=f,Vh|=f,r.lanes|=f,r=r.alternate,r!==null&&(r.lanes|=f)}function Fh(r,i,c,f){return hu(r,i,c,f),pu(r)}function Va(r,i){return hu(r,null,null,i),pu(r)}function db(r,i,c){r.lanes|=c;var f=r.alternate;f!==null&&(f.lanes|=c);for(var v=!1,x=r.return;x!==null;)x.childLanes|=c,f=x.alternate,f!==null&&(f.childLanes|=c),x.tag===22&&(r=x.stateNode,r===null||r._visibility&1||(v=!0)),r=x,x=x.return;return r.tag===3?(x=r.stateNode,v&&i!==null&&(v=31-lt(c),r=x.hiddenUpdates,f=r[v],f===null?r[v]=[i]:f.push(i),i.lane=c|536870912),x):null}function pu(r){if(50<Ul)throw Ul=0,Jp=null,Error(s(185));for(var i=r.return;i!==null;)r=i,i=r.return;return r.tag===3?r.stateNode:null}var Hi={};function z2(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 z2(r,i,c,f)}function Hh(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 fb(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 mu(r,i,c,f,v,x){var C=0;if(f=r,typeof r=="function")Hh(r)&&(C=1);else if(typeof r=="string")C=V_(r,c,J.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=x,r;case N:return Fa(c.children,v,x,i);case k:C=8,v|=24;break;case T:return r=ss(12,c,i,v|2),r.elementType=T,r.lanes=x,r;case R:return r=ss(13,c,i,v),r.elementType=R,r.lanes=x,r;case A:return r=ss(19,c,i,v),r.elementType=A,r.lanes=x,r;default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case S:C=10;break e;case E:C=9;break e;case M:C=11;break e;case _:C=14;break e;case $:C=16,f=null;break e}C=29,c=Error(s(130,r===null?"null":typeof r,"")),f=null}return i=ss(C,c,i,v),i.elementType=r,i.type=f,i.lanes=x,i}function Fa(r,i,c,f){return r=ss(7,r,f,i),r.lanes=c,r}function qh(r,i,c){return r=ss(6,r,null,i),r.lanes=c,r}function hb(r){var i=ss(18,null,null,0);return i.stateNode=r,i}function Zh(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 pb=new WeakMap;function vs(r,i){if(typeof r=="object"&&r!==null){var c=pb.get(r);return c!==void 0?c:(i={value:r,source:i,stack:_e(i)},pb.set(r,i),i)}return{value:r,source:i,stack:_e(i)}}var qi=[],Zi=0,gu=null,xl=0,ys=[],xs=0,Vr=null,Ys=1,Gs="";function vr(r,i){qi[Zi++]=xl,qi[Zi++]=gu,gu=r,xl=i}function mb(r,i,c){ys[xs++]=Ys,ys[xs++]=Gs,ys[xs++]=Vr,Vr=r;var f=Ys;r=Gs;var v=32-lt(f)-1;f&=~(1<<v),c+=1;var x=32-lt(i)+v;if(30<x){var C=v-v%5;x=(f&(1<<C)-1).toString(32),f>>=C,v-=C,Ys=1<<32-lt(i)+v|c<<v|f,Gs=x+r}else Ys=1<<x|c<<v|f,Gs=r}function Wh(r){r.return!==null&&(vr(r,1),mb(r,1,0))}function Yh(r){for(;r===gu;)gu=qi[--Zi],qi[Zi]=null,xl=qi[--Zi],qi[Zi]=null;for(;r===Vr;)Vr=ys[--xs],ys[xs]=null,Gs=ys[--xs],ys[xs]=null,Ys=ys[--xs],ys[xs]=null}function gb(r,i){ys[xs++]=Ys,ys[xs++]=Gs,ys[xs++]=Vr,Ys=i.id,Gs=i.overflow,Vr=r}var jn=null,Rt=null,ct=!1,Fr=null,bs=!1,Gh=Error(s(519));function Hr(r){var i=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw bl(vs(i,r)),Gh}function vb(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<Vl.length;c++)st(Vl[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),Mx(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),_x(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||Iw(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 yb(r){for(jn=r.return;jn;)switch(jn.tag){case 5:case 31:case 13:bs=!1;return;case 27:case 3:bs=!0;return;default:jn=jn.return}}function Wi(r){if(r!==jn)return!1;if(!ct)return yb(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")||hm(r.type,r.memoizedProps)),c=!c),c&&Rt&&Hr(r),yb(r),i===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(s(317));Rt=Fw(r)}else if(i===31){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(s(317));Rt=Fw(r)}else i===27?(i=Rt,ra(r.type)?(r=ym,ym=null,Rt=r):Rt=i):Rt=jn?js(r.stateNode.nextSibling):null;return!0}function Ha(){Rt=jn=null,ct=!1}function Kh(){var r=Fr;return r!==null&&(Gn===null?Gn=r:Gn.push.apply(Gn,r),Fr=null),r}function bl(r){Fr===null?Fr=[r]:Fr.push(r)}var Xh=I(null),qa=null,yr=null;function qr(r,i,c){G(Xh,i._currentValue),i._currentValue=c}function xr(r){r._currentValue=Xh.current,F(Xh)}function Jh(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 Qh(r,i,c,f){var v=r.child;for(v!==null&&(v.return=r);v!==null;){var x=v.dependencies;if(x!==null){var C=v.child;x=x.firstContext;e:for(;x!==null;){var D=x;x=v;for(var Y=0;Y<i.length;Y++)if(D.context===i[Y]){x.lanes|=c,D=x.alternate,D!==null&&(D.lanes|=c),Jh(x.return,c,r),f||(C=null);break e}x=D.next}}else if(v.tag===18){if(C=v.return,C===null)throw Error(s(341));C.lanes|=c,x=C.alternate,x!==null&&(x.lanes|=c),Jh(C,c,r),C=null}else C=v.child;if(C!==null)C.return=v;else for(C=v;C!==null;){if(C===r){C=null;break}if(v=C.sibling,v!==null){v.return=C.return,C=v;break}C=C.return}v=C}}function Yi(r,i,c,f){r=null;for(var v=i,x=!1;v!==null;){if(!x){if((v.flags&524288)!==0)x=!0;else if((v.flags&262144)!==0)break}if(v.tag===10){var C=v.alternate;if(C===null)throw Error(s(387));if(C=C.memoizedProps,C!==null){var D=v.type;ns(v.pendingProps.value,C.value)||(r!==null?r.push(D):r=[D])}}else if(v===ve.current){if(C=v.alternate,C===null)throw Error(s(387));C.memoizedState.memoizedState!==v.memoizedState.memoizedState&&(r!==null?r.push(Wl):r=[Wl])}v=v.return}r!==null&&Qh(i,r,c,f),i.flags|=262144}function vu(r){for(r=r.firstContext;r!==null;){if(!ns(r.context._currentValue,r.memoizedValue))return!0;r=r.next}return!1}function Za(r){qa=r,yr=null,r=r.dependencies,r!==null&&(r.firstContext=null)}function Sn(r){return xb(qa,r)}function yu(r,i){return qa===null&&Za(r),xb(r,i)}function xb(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 L2=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()})}},$2=e.unstable_scheduleCallback,U2=e.unstable_NormalPriority,sn={$$typeof:S,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ep(){return{controller:new L2,data:new Map,refCount:0}}function wl(r){r.refCount--,r.refCount===0&&$2(U2,function(){r.controller.abort()})}var jl=null,tp=0,Gi=0,Ki=null;function B2(r,i){if(jl===null){var c=jl=[];tp=0,Gi=rm(),Ki={status:"pending",value:void 0,then:function(f){c.push(f)}}}return tp++,i.then(bb,bb),i}function bb(){if(--tp===0&&jl!==null){Ki!==null&&(Ki.status="fulfilled");var r=jl;jl=null,Gi=0,Ki=null;for(var i=0;i<r.length;i++)(0,r[i])()}}function V2(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 wb=L.S;L.S=function(r,i){rw=ke(),typeof i=="object"&&i!==null&&typeof i.then=="function"&&B2(r,i),wb!==null&&wb(r,i)};var Wa=I(null);function np(){var r=Wa.current;return r!==null?r:Ct.pooledCache}function xu(r,i){i===null?G(Wa,Wa.current):G(Wa,i.pool)}function jb(){var r=np();return r===null?null:{parent:sn._currentValue,pool:r}}var Xi=Error(s(460)),sp=Error(s(474)),bu=Error(s(542)),wu={then:function(){}};function Sb(r){return r=r.status,r==="fulfilled"||r==="rejected"}function Nb(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,Eb(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,Eb(r),r}throw Ga=i,Xi}}function Ya(r){try{var i=r._init;return i(r._payload)}catch(c){throw c!==null&&typeof c=="object"&&typeof c.then=="function"?(Ga=c,Xi):c}}var Ga=null;function kb(){if(Ga===null)throw Error(s(459));var r=Ga;return Ga=null,r}function Eb(r){if(r===Xi||r===bu)throw Error(s(483))}var Ji=null,Sl=0;function ju(r){var i=Sl;return Sl+=1,Ji===null&&(Ji=[]),Nb(Ji,r,i)}function Nl(r,i){i=i.props.ref,r.ref=i!==void 0?i:null}function Su(r,i){throw i.$$typeof===b?Error(s(525)):(r=Object.prototype.toString.call(i),Error(s(31,r==="[object Object]"?"object with keys {"+Object.keys(i).join(", ")+"}":r)))}function Cb(r){function i(Q,K){if(r){var te=Q.deletions;te===null?(Q.deletions=[K],Q.flags|=16):te.push(K)}}function c(Q,K){if(!r)return null;for(;K!==null;)i(Q,K),K=K.sibling;return null}function f(Q){for(var K=new Map;Q!==null;)Q.key!==null?K.set(Q.key,Q):K.set(Q.index,Q),Q=Q.sibling;return K}function v(Q,K){return Q=gr(Q,K),Q.index=0,Q.sibling=null,Q}function x(Q,K,te){return Q.index=te,r?(te=Q.alternate,te!==null?(te=te.index,te<K?(Q.flags|=67108866,K):te):(Q.flags|=67108866,K)):(Q.flags|=1048576,K)}function C(Q){return r&&Q.alternate===null&&(Q.flags|=67108866),Q}function D(Q,K,te,fe){return K===null||K.tag!==6?(K=qh(te,Q.mode,fe),K.return=Q,K):(K=v(K,te),K.return=Q,K)}function Y(Q,K,te,fe){var Ue=te.type;return Ue===N?oe(Q,K,te.props.children,fe,te.key):K!==null&&(K.elementType===Ue||typeof Ue=="object"&&Ue!==null&&Ue.$$typeof===$&&Ya(Ue)===K.type)?(K=v(K,te.props),Nl(K,te),K.return=Q,K):(K=mu(te.type,te.key,te.props,null,Q.mode,fe),Nl(K,te),K.return=Q,K)}function ne(Q,K,te,fe){return K===null||K.tag!==4||K.stateNode.containerInfo!==te.containerInfo||K.stateNode.implementation!==te.implementation?(K=Zh(te,Q.mode,fe),K.return=Q,K):(K=v(K,te.children||[]),K.return=Q,K)}function oe(Q,K,te,fe,Ue){return K===null||K.tag!==7?(K=Fa(te,Q.mode,fe,Ue),K.return=Q,K):(K=v(K,te),K.return=Q,K)}function pe(Q,K,te){if(typeof K=="string"&&K!==""||typeof K=="number"||typeof K=="bigint")return K=qh(""+K,Q.mode,te),K.return=Q,K;if(typeof K=="object"&&K!==null){switch(K.$$typeof){case w:return te=mu(K.type,K.key,K.props,null,Q.mode,te),Nl(te,K),te.return=Q,te;case j:return K=Zh(K,Q.mode,te),K.return=Q,K;case $:return K=Ya(K),pe(Q,K,te)}if(H(K)||P(K))return K=Fa(K,Q.mode,te,null),K.return=Q,K;if(typeof K.then=="function")return pe(Q,ju(K),te);if(K.$$typeof===S)return pe(Q,yu(Q,K),te);Su(Q,K)}return null}function re(Q,K,te,fe){var Ue=K!==null?K.key:null;if(typeof te=="string"&&te!==""||typeof te=="number"||typeof te=="bigint")return Ue!==null?null:D(Q,K,""+te,fe);if(typeof te=="object"&&te!==null){switch(te.$$typeof){case w:return te.key===Ue?Y(Q,K,te,fe):null;case j:return te.key===Ue?ne(Q,K,te,fe):null;case $:return te=Ya(te),re(Q,K,te,fe)}if(H(te)||P(te))return Ue!==null?null:oe(Q,K,te,fe,null);if(typeof te.then=="function")return re(Q,K,ju(te),fe);if(te.$$typeof===S)return re(Q,K,yu(Q,te),fe);Su(Q,te)}return null}function ae(Q,K,te,fe,Ue){if(typeof fe=="string"&&fe!==""||typeof fe=="number"||typeof fe=="bigint")return Q=Q.get(te)||null,D(K,Q,""+fe,Ue);if(typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case w:return Q=Q.get(fe.key===null?te:fe.key)||null,Y(K,Q,fe,Ue);case j:return Q=Q.get(fe.key===null?te:fe.key)||null,ne(K,Q,fe,Ue);case $:return fe=Ya(fe),ae(Q,K,te,fe,Ue)}if(H(fe)||P(fe))return Q=Q.get(te)||null,oe(K,Q,fe,Ue,null);if(typeof fe.then=="function")return ae(Q,K,te,ju(fe),Ue);if(fe.$$typeof===S)return ae(Q,K,te,yu(K,fe),Ue);Su(K,fe)}return null}function Re(Q,K,te,fe){for(var Ue=null,ft=null,Ie=K,Qe=K=0,ot=null;Ie!==null&&Qe<te.length;Qe++){Ie.index>Qe?(ot=Ie,Ie=null):ot=Ie.sibling;var ht=re(Q,Ie,te[Qe],fe);if(ht===null){Ie===null&&(Ie=ot);break}r&&Ie&&ht.alternate===null&&i(Q,Ie),K=x(ht,K,Qe),ft===null?Ue=ht:ft.sibling=ht,ft=ht,Ie=ot}if(Qe===te.length)return c(Q,Ie),ct&&vr(Q,Qe),Ue;if(Ie===null){for(;Qe<te.length;Qe++)Ie=pe(Q,te[Qe],fe),Ie!==null&&(K=x(Ie,K,Qe),ft===null?Ue=Ie:ft.sibling=Ie,ft=Ie);return ct&&vr(Q,Qe),Ue}for(Ie=f(Ie);Qe<te.length;Qe++)ot=ae(Ie,Q,Qe,te[Qe],fe),ot!==null&&(r&&ot.alternate!==null&&Ie.delete(ot.key===null?Qe:ot.key),K=x(ot,K,Qe),ft===null?Ue=ot:ft.sibling=ot,ft=ot);return r&&Ie.forEach(function(ca){return i(Q,ca)}),ct&&vr(Q,Qe),Ue}function He(Q,K,te,fe){if(te==null)throw Error(s(151));for(var Ue=null,ft=null,Ie=K,Qe=K=0,ot=null,ht=te.next();Ie!==null&&!ht.done;Qe++,ht=te.next()){Ie.index>Qe?(ot=Ie,Ie=null):ot=Ie.sibling;var ca=re(Q,Ie,ht.value,fe);if(ca===null){Ie===null&&(Ie=ot);break}r&&Ie&&ca.alternate===null&&i(Q,Ie),K=x(ca,K,Qe),ft===null?Ue=ca:ft.sibling=ca,ft=ca,Ie=ot}if(ht.done)return c(Q,Ie),ct&&vr(Q,Qe),Ue;if(Ie===null){for(;!ht.done;Qe++,ht=te.next())ht=pe(Q,ht.value,fe),ht!==null&&(K=x(ht,K,Qe),ft===null?Ue=ht:ft.sibling=ht,ft=ht);return ct&&vr(Q,Qe),Ue}for(Ie=f(Ie);!ht.done;Qe++,ht=te.next())ht=ae(Ie,Q,Qe,ht.value,fe),ht!==null&&(r&&ht.alternate!==null&&Ie.delete(ht.key===null?Qe:ht.key),K=x(ht,K,Qe),ft===null?Ue=ht:ft.sibling=ht,ft=ht);return r&&Ie.forEach(function(Q_){return i(Q,Q_)}),ct&&vr(Q,Qe),Ue}function St(Q,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 Ue=te.key;K!==null;){if(K.key===Ue){if(Ue=te.type,Ue===N){if(K.tag===7){c(Q,K.sibling),fe=v(K,te.props.children),fe.return=Q,Q=fe;break e}}else if(K.elementType===Ue||typeof Ue=="object"&&Ue!==null&&Ue.$$typeof===$&&Ya(Ue)===K.type){c(Q,K.sibling),fe=v(K,te.props),Nl(fe,te),fe.return=Q,Q=fe;break e}c(Q,K);break}else i(Q,K);K=K.sibling}te.type===N?(fe=Fa(te.props.children,Q.mode,fe,te.key),fe.return=Q,Q=fe):(fe=mu(te.type,te.key,te.props,null,Q.mode,fe),Nl(fe,te),fe.return=Q,Q=fe)}return C(Q);case j:e:{for(Ue=te.key;K!==null;){if(K.key===Ue)if(K.tag===4&&K.stateNode.containerInfo===te.containerInfo&&K.stateNode.implementation===te.implementation){c(Q,K.sibling),fe=v(K,te.children||[]),fe.return=Q,Q=fe;break e}else{c(Q,K);break}else i(Q,K);K=K.sibling}fe=Zh(te,Q.mode,fe),fe.return=Q,Q=fe}return C(Q);case $:return te=Ya(te),St(Q,K,te,fe)}if(H(te))return Re(Q,K,te,fe);if(P(te)){if(Ue=P(te),typeof Ue!="function")throw Error(s(150));return te=Ue.call(te),He(Q,K,te,fe)}if(typeof te.then=="function")return St(Q,K,ju(te),fe);if(te.$$typeof===S)return St(Q,K,yu(Q,te),fe);Su(Q,te)}return typeof te=="string"&&te!==""||typeof te=="number"||typeof te=="bigint"?(te=""+te,K!==null&&K.tag===6?(c(Q,K.sibling),fe=v(K,te),fe.return=Q,Q=fe):(c(Q,K),fe=qh(te,Q.mode,fe),fe.return=Q,Q=fe),C(Q)):c(Q,K)}return function(Q,K,te,fe){try{Sl=0;var Ue=St(Q,K,te,fe);return Ji=null,Ue}catch(Ie){if(Ie===Xi||Ie===bu)throw Ie;var ft=ss(29,Ie,null,Q.mode);return ft.lanes=fe,ft.return=Q,ft}}}var Ka=Cb(!0),Tb=Cb(!1),Zr=!1;function rp(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ap(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=pu(r),db(r,null,c),i}return hu(r,f,i,c),pu(r)}function kl(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 ip(r,i){var c=r.updateQueue,f=r.alternate;if(f!==null&&(f=f.updateQueue,c===f)){var v=null,x=null;if(c=c.firstBaseUpdate,c!==null){do{var C={lane:c.lane,tag:c.tag,payload:c.payload,callback:null,next:null};x===null?v=x=C:x=x.next=C,c=c.next}while(c!==null);x===null?v=x=i:x=x.next=i}else v=x=i;c={baseState:f.baseState,firstBaseUpdate:v,lastBaseUpdate:x,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 op=!1;function El(){if(op){var r=Ki;if(r!==null)throw r}}function Cl(r,i,c,f){op=!1;var v=r.updateQueue;Zr=!1;var x=v.firstBaseUpdate,C=v.lastBaseUpdate,D=v.shared.pending;if(D!==null){v.shared.pending=null;var Y=D,ne=Y.next;Y.next=null,C===null?x=ne:C.next=ne,C=Y;var oe=r.alternate;oe!==null&&(oe=oe.updateQueue,D=oe.lastBaseUpdate,D!==C&&(D===null?oe.firstBaseUpdate=ne:D.next=ne,oe.lastBaseUpdate=Y))}if(x!==null){var pe=v.baseState;C=0,oe=ne=Y=null,D=x;do{var re=D.lane&-536870913,ae=re!==D.lane;if(ae?(it&re)===re:(f&re)===re){re!==0&&re===Gi&&(op=!0),oe!==null&&(oe=oe.next={lane:0,tag:D.tag,payload:D.payload,callback:null,next:null});e:{var Re=r,He=D;re=i;var St=c;switch(He.tag){case 1:if(Re=He.payload,typeof Re=="function"){pe=Re.call(St,pe,re);break e}pe=Re;break e;case 3:Re.flags=Re.flags&-65537|128;case 0:if(Re=He.payload,re=typeof Re=="function"?Re.call(St,pe,re):Re,re==null)break e;pe=y({},pe,re);break e;case 2:Zr=!0}}re=D.callback,re!==null&&(r.flags|=64,ae&&(r.flags|=8192),ae=v.callbacks,ae===null?v.callbacks=[re]:ae.push(re))}else ae={lane:re,tag:D.tag,payload:D.payload,callback:D.callback,next:null},oe===null?(ne=oe=ae,Y=pe):oe=oe.next=ae,C|=re;if(D=D.next,D===null){if(D=v.shared.pending,D===null)break;ae=D,D=ae.next,ae.next=null,v.lastBaseUpdate=ae,v.shared.pending=null}}while(!0);oe===null&&(Y=pe),v.baseState=Y,v.firstBaseUpdate=ne,v.lastBaseUpdate=oe,x===null&&(v.shared.lanes=0),Qr|=C,r.lanes=C,r.memoizedState=pe}}function Ab(r,i){if(typeof r!="function")throw Error(s(191,r));r.call(i)}function Mb(r,i){var c=r.callbacks;if(c!==null)for(r.callbacks=null,r=0;r<c.length;r++)Ab(c[r],i)}var Qi=I(null),Nu=I(0);function Rb(r,i){r=Tr,G(Nu,r),G(Qi,i),Tr=r|i.baseLanes}function lp(){G(Nu,Tr),G(Qi,Qi.current)}function cp(){Tr=Nu.current,F(Qi),F(Nu)}var rs=I(null),ws=null;function Gr(r){var i=r.alternate;G(Qt,Qt.current&1),G(rs,r),ws===null&&(i===null||Qi.current!==null||i.memoizedState!==null)&&(ws=r)}function up(r){G(Qt,Qt.current),G(rs,r),ws===null&&(ws=r)}function _b(r){r.tag===22?(G(Qt,Qt.current),G(rs,r),ws===null&&(ws=r)):Kr()}function Kr(){G(Qt,Qt.current),G(rs,rs.current)}function as(r){F(rs),ws===r&&(ws=null),F(Qt)}var Qt=I(0);function ku(r){for(var i=r;i!==null;){if(i.tag===13){var c=i.memoizedState;if(c!==null&&(c=c.dehydrated,c===null||gm(c)||vm(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 br=0,Je=null,wt=null,rn=null,Eu=!1,eo=!1,Xa=!1,Cu=0,Tl=0,to=null,F2=0;function Yt(){throw Error(s(321))}function dp(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 fp(r,i,c,f,v,x){return br=x,Je=i,i.memoizedState=null,i.updateQueue=null,i.lanes=0,L.H=r===null||r.memoizedState===null?m0:Cp,Xa=!1,x=c(f,v),Xa=!1,eo&&(x=Ib(i,c,f,v)),Ob(r),x}function Ob(r){L.H=Rl;var i=wt!==null&&wt.next!==null;if(br=0,rn=wt=Je=null,Eu=!1,Tl=0,to=null,i)throw Error(s(300));r===null||an||(r=r.dependencies,r!==null&&vu(r)&&(an=!0))}function Ib(r,i,c,f){Je=r;var v=0;do{if(eo&&(to=null),Tl=0,eo=!1,25<=v)throw Error(s(301));if(v+=1,rn=wt=null,r.updateQueue!=null){var x=r.updateQueue;x.lastEffect=null,x.events=null,x.stores=null,x.memoCache!=null&&(x.memoCache.index=0)}L.H=g0,x=i(c,f)}while(eo);return x}function H2(){var r=L.H,i=r.useState()[0];return i=typeof i.then=="function"?Al(i):i,r=r.useState()[0],(wt!==null?wt.memoizedState:null)!==r&&(Je.flags|=1024),i}function hp(){var r=Cu!==0;return Cu=0,r}function pp(r,i,c){i.updateQueue=r.updateQueue,i.flags&=-2053,r.lanes&=~c}function mp(r){if(Eu){for(r=r.memoizedState;r!==null;){var i=r.queue;i!==null&&(i.pending=null),r=r.next}Eu=!1}br=0,rn=wt=Je=null,eo=!1,Tl=Cu=0,to=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 Tu(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Al(r){var i=Tl;return Tl+=1,to===null&&(to=[]),r=Nb(to,r,i),i=Je,(rn===null?i.memoizedState:rn.next)===null&&(i=i.alternate,L.H=i===null||i.memoizedState===null?m0:Cp),r}function Au(r){if(r!==null&&typeof r=="object"){if(typeof r.then=="function")return Al(r);if(r.$$typeof===S)return Sn(r)}throw Error(s(438,String(r)))}function gp(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=Tu(),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 Mu(r){var i=en();return vp(i,wt,r)}function vp(r,i,c){var f=r.queue;if(f===null)throw Error(s(311));f.lastRenderedReducer=c;var v=r.baseQueue,x=f.pending;if(x!==null){if(v!==null){var C=v.next;v.next=x.next,x.next=C}i.baseQueue=v=x,f.pending=null}if(x=r.baseState,v===null)r.memoizedState=x;else{i=v.next;var D=C=null,Y=null,ne=i,oe=!1;do{var pe=ne.lane&-536870913;if(pe!==ne.lane?(it&pe)===pe:(br&pe)===pe){var re=ne.revertLane;if(re===0)Y!==null&&(Y=Y.next={lane:0,revertLane:0,gesture:null,action:ne.action,hasEagerState:ne.hasEagerState,eagerState:ne.eagerState,next:null}),pe===Gi&&(oe=!0);else if((br&re)===re){ne=ne.next,re===Gi&&(oe=!0);continue}else pe={lane:0,revertLane:ne.revertLane,gesture:null,action:ne.action,hasEagerState:ne.hasEagerState,eagerState:ne.eagerState,next:null},Y===null?(D=Y=pe,C=x):Y=Y.next=pe,Je.lanes|=re,Qr|=re;pe=ne.action,Xa&&c(x,pe),x=ne.hasEagerState?ne.eagerState:c(x,pe)}else re={lane:pe,revertLane:ne.revertLane,gesture:ne.gesture,action:ne.action,hasEagerState:ne.hasEagerState,eagerState:ne.eagerState,next:null},Y===null?(D=Y=re,C=x):Y=Y.next=re,Je.lanes|=pe,Qr|=pe;ne=ne.next}while(ne!==null&&ne!==i);if(Y===null?C=x:Y.next=D,!ns(x,r.memoizedState)&&(an=!0,oe&&(c=Ki,c!==null)))throw c;r.memoizedState=x,r.baseState=C,r.baseQueue=Y,f.lastRenderedState=x}return v===null&&(f.lanes=0),[r.memoizedState,f.dispatch]}function yp(r){var i=en(),c=i.queue;if(c===null)throw Error(s(311));c.lastRenderedReducer=r;var f=c.dispatch,v=c.pending,x=i.memoizedState;if(v!==null){c.pending=null;var C=v=v.next;do x=r(x,C.action),C=C.next;while(C!==v);ns(x,i.memoizedState)||(an=!0),i.memoizedState=x,i.baseQueue===null&&(i.baseState=x),c.lastRenderedState=x}return[x,f]}function Db(r,i,c){var f=Je,v=en(),x=ct;if(x){if(c===void 0)throw Error(s(407));c=c()}else c=i();var C=!ns((wt||v).memoizedState,c);if(C&&(v.memoizedState=c,an=!0),v=v.queue,wp(Lb.bind(null,f,v,r),[r]),v.getSnapshot!==i||C||rn!==null&&rn.memoizedState.tag&1){if(f.flags|=2048,no(9,{destroy:void 0},zb.bind(null,f,v,c,i),null),Ct===null)throw Error(s(349));x||(br&127)!==0||Pb(f,i,c)}return c}function Pb(r,i,c){r.flags|=16384,r={getSnapshot:i,value:c},i=Je.updateQueue,i===null?(i=Tu(),Je.updateQueue=i,i.stores=[r]):(c=i.stores,c===null?i.stores=[r]:c.push(r))}function zb(r,i,c,f){i.value=c,i.getSnapshot=f,$b(i)&&Ub(r)}function Lb(r,i,c){return c(function(){$b(i)&&Ub(r)})}function $b(r){var i=r.getSnapshot;r=r.value;try{var c=i();return!ns(r,c)}catch{return!0}}function Ub(r){var i=Va(r,2);i!==null&&Kn(i,r,2)}function xp(r){var i=zn();if(typeof r=="function"){var c=r;if(r=c(),Xa){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 Bb(r,i,c,f){return r.baseState=c,vp(r,wt,typeof f=="function"?f:wr)}function q2(r,i,c,f,v){if(Ou(r))throw Error(s(485));if(r=i.action,r!==null){var x={payload:v,action:r,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(C){x.listeners.push(C)}};L.T!==null?c(!0):x.isTransition=!1,f(x),c=i.pending,c===null?(x.next=i.pending=x,Vb(i,x)):(x.next=c.next,i.pending=c.next=x)}}function Vb(r,i){var c=i.action,f=i.payload,v=r.state;if(i.isTransition){var x=L.T,C={};L.T=C;try{var D=c(v,f),Y=L.S;Y!==null&&Y(C,D),Fb(r,i,D)}catch(ne){bp(r,i,ne)}finally{x!==null&&C.types!==null&&(x.types=C.types),L.T=x}}else try{x=c(v,f),Fb(r,i,x)}catch(ne){bp(r,i,ne)}}function Fb(r,i,c){c!==null&&typeof c=="object"&&typeof c.then=="function"?c.then(function(f){Hb(r,i,f)},function(f){return bp(r,i,f)}):Hb(r,i,c)}function Hb(r,i,c){i.status="fulfilled",i.value=c,qb(i),r.state=c,i=r.pending,i!==null&&(c=i.next,c===i?r.pending=null:(c=c.next,i.next=c,Vb(r,c)))}function bp(r,i,c){var f=r.pending;if(r.pending=null,f!==null){f=f.next;do i.status="rejected",i.reason=c,qb(i),i=i.next;while(i!==f)}r.action=null}function qb(r){r=r.listeners;for(var i=0;i<r.length;i++)(0,r[i])()}function Zb(r,i){return i}function Wb(r,i){if(ct){var c=Ct.formState;if(c!==null){e:{var f=Je;if(ct){if(Rt){t:{for(var v=Rt,x=bs;v.nodeType!==8;){if(!x){v=null;break t}if(v=js(v.nextSibling),v===null){v=null;break t}}x=v.data,v=x==="F!"||x==="F"?v:null}if(v){Rt=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:Zb,lastRenderedState:i},c.queue=f,c=f0.bind(null,Je,f),f.dispatch=c,f=xp(!1),x=Ep.bind(null,Je,!1,f.queue),f=zn(),v={state:i,dispatch:null,action:r,pending:null},f.queue=v,c=q2.bind(null,Je,v,x,c),v.dispatch=c,f.memoizedState=r,[i,c,!1]}function Yb(r){var i=en();return Gb(i,wt,r)}function Gb(r,i,c){if(i=vp(r,i,Zb)[0],r=Mu(wr)[0],typeof i=="object"&&i!==null&&typeof i.then=="function")try{var f=Al(i)}catch(C){throw C===Xi?bu:C}else f=i;i=en();var v=i.queue,x=v.dispatch;return c!==i.memoizedState&&(Je.flags|=2048,no(9,{destroy:void 0},Z2.bind(null,v,c),null)),[f,x,r]}function Z2(r,i){r.action=i}function Kb(r){var i=en(),c=wt;if(c!==null)return Gb(i,c,r);en(),i=i.memoizedState,c=en();var f=c.queue.dispatch;return c.memoizedState=r,[i,f,!1]}function no(r,i,c,f){return r={tag:r,create:c,deps:f,inst:i,next:null},i=Je.updateQueue,i===null&&(i=Tu(),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 Xb(){return en().memoizedState}function Ru(r,i,c,f){var v=zn();Je.flags|=r,v.memoizedState=no(1|i,{destroy:void 0},c,f===void 0?null:f)}function _u(r,i,c,f){var v=en();f=f===void 0?null:f;var x=v.memoizedState.inst;wt!==null&&f!==null&&dp(f,wt.memoizedState.deps)?v.memoizedState=no(i,x,c,f):(Je.flags|=r,v.memoizedState=no(1|i,x,c,f))}function Jb(r,i){Ru(8390656,8,r,i)}function wp(r,i){_u(2048,8,r,i)}function W2(r){Je.flags|=4;var i=Je.updateQueue;if(i===null)i=Tu(),Je.updateQueue=i,i.events=[r];else{var c=i.events;c===null?i.events=[r]:c.push(r)}}function Qb(r){var i=en().memoizedState;return W2({ref:i,nextImpl:r}),function(){if((pt&2)!==0)throw Error(s(440));return i.impl.apply(void 0,arguments)}}function e0(r,i){return _u(4,2,r,i)}function t0(r,i){return _u(4,4,r,i)}function n0(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 s0(r,i,c){c=c!=null?c.concat([r]):null,_u(4,4,n0.bind(null,i,r),c)}function jp(){}function r0(r,i){var c=en();i=i===void 0?null:i;var f=c.memoizedState;return i!==null&&dp(i,f[1])?f[0]:(c.memoizedState=[r,i],r)}function a0(r,i){var c=en();i=i===void 0?null:i;var f=c.memoizedState;if(i!==null&&dp(i,f[1]))return f[0];if(f=r(),Xa){at(!0);try{r()}finally{at(!1)}}return c.memoizedState=[f,i],f}function Sp(r,i,c){return c===void 0||(br&1073741824)!==0&&(it&261930)===0?r.memoizedState=i:(r.memoizedState=c,r=iw(),Je.lanes|=r,Qr|=r,c)}function i0(r,i,c,f){return ns(c,i)?c:Qi.current!==null?(r=Sp(r,c,f),ns(r,i)||(an=!0),r):(br&42)===0||(br&1073741824)!==0&&(it&261930)===0?(an=!0,r.memoizedState=c):(r=iw(),Je.lanes|=r,Qr|=r,i)}function o0(r,i,c,f,v){var x=z.p;z.p=x!==0&&8>x?x:8;var C=L.T,D={};L.T=D,Ep(r,!1,i,c);try{var Y=v(),ne=L.S;if(ne!==null&&ne(D,Y),Y!==null&&typeof Y=="object"&&typeof Y.then=="function"){var oe=V2(Y,f);Ml(r,i,oe,ls(r))}else Ml(r,i,f,ls(r))}catch(pe){Ml(r,i,{then:function(){},status:"rejected",reason:pe},ls())}finally{z.p=x,C!==null&&D.types!==null&&(C.types=D.types),L.T=C}}function Y2(){}function Np(r,i,c,f){if(r.tag!==5)throw Error(s(476));var v=l0(r).queue;o0(r,v,i,B,c===null?Y2:function(){return c0(r),c(f)})}function l0(r){var i=r.memoizedState;if(i!==null)return i;i={memoizedState:B,baseState:B,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:wr,lastRenderedState:B},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 c0(r){var i=l0(r);i.next===null&&(i=r.alternate.memoizedState),Ml(r,i.next.queue,{},ls())}function kp(){return Sn(Wl)}function u0(){return en().memoizedState}function d0(){return en().memoizedState}function G2(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),kl(f,i,c)),i={cache:ep()},r.payload=i;return}i=i.return}}function K2(r,i,c){var f=ls();c={lane:f,revertLane:0,gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},Ou(r)?h0(i,c):(c=Fh(r,i,c,f),c!==null&&(Kn(c,r,f),p0(c,i,f)))}function f0(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(Ou(r))h0(i,v);else{var x=r.alternate;if(r.lanes===0&&(x===null||x.lanes===0)&&(x=i.lastRenderedReducer,x!==null))try{var C=i.lastRenderedState,D=x(C,c);if(v.hasEagerState=!0,v.eagerState=D,ns(D,C))return hu(r,i,v,0),Ct===null&&fu(),!1}catch{}if(c=Fh(r,i,v,f),c!==null)return Kn(c,r,f),p0(c,i,f),!0}return!1}function Ep(r,i,c,f){if(f={lane:2,revertLane:rm(),gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null},Ou(r)){if(i)throw Error(s(479))}else i=Fh(r,c,f,2),i!==null&&Kn(i,r,2)}function Ou(r){var i=r.alternate;return r===Je||i!==null&&i===Je}function h0(r,i){eo=Eu=!0;var c=r.pending;c===null?i.next=i:(i.next=c.next,c.next=i),r.pending=i}function p0(r,i,c){if((c&4194048)!==0){var f=i.lanes;f&=r.pendingLanes,c|=f,i.lanes=c,dt(r,c)}}var Rl={readContext:Sn,use:Au,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};Rl.useEffectEvent=Yt;var m0={readContext:Sn,use:Au,useCallback:function(r,i){return zn().memoizedState=[r,i===void 0?null:i],r},useContext:Sn,useEffect:Jb,useImperativeHandle:function(r,i,c){c=c!=null?c.concat([r]):null,Ru(4194308,4,n0.bind(null,i,r),c)},useLayoutEffect:function(r,i){return Ru(4194308,4,r,i)},useInsertionEffect:function(r,i){Ru(4,2,r,i)},useMemo:function(r,i){var c=zn();i=i===void 0?null:i;var f=r();if(Xa){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(Xa){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=K2.bind(null,Je,r),[f.memoizedState,r]},useRef:function(r){var i=zn();return r={current:r},i.memoizedState=r},useState:function(r){r=xp(r);var i=r.queue,c=f0.bind(null,Je,i);return i.dispatch=c,[r.memoizedState,c]},useDebugValue:jp,useDeferredValue:function(r,i){var c=zn();return Sp(c,r,i)},useTransition:function(){var r=xp(!1);return r=o0.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||Pb(f,i,c)}v.memoizedState=c;var x={value:c,getSnapshot:i};return v.queue=x,Jb(Lb.bind(null,f,x,r),[r]),f.flags|=2048,no(9,{destroy:void 0},zb.bind(null,f,x,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=Cu++,0<c&&(i+="H"+c.toString(32)),i+="_"}else c=F2++,i="_"+i+"r_"+c.toString(32)+"_";return r.memoizedState=i},useHostTransitionStatus:kp,useFormState:Wb,useActionState:Wb,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=Ep.bind(null,Je,!0,c),c.dispatch=i,[r,i]},useMemoCache:gp,useCacheRefresh:function(){return zn().memoizedState=G2.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)}}},Cp={readContext:Sn,use:Au,useCallback:r0,useContext:Sn,useEffect:wp,useImperativeHandle:s0,useInsertionEffect:e0,useLayoutEffect:t0,useMemo:a0,useReducer:Mu,useRef:Xb,useState:function(){return Mu(wr)},useDebugValue:jp,useDeferredValue:function(r,i){var c=en();return i0(c,wt.memoizedState,r,i)},useTransition:function(){var r=Mu(wr)[0],i=en().memoizedState;return[typeof r=="boolean"?r:Al(r),i]},useSyncExternalStore:Db,useId:u0,useHostTransitionStatus:kp,useFormState:Yb,useActionState:Yb,useOptimistic:function(r,i){var c=en();return Bb(c,wt,r,i)},useMemoCache:gp,useCacheRefresh:d0};Cp.useEffectEvent=Qb;var g0={readContext:Sn,use:Au,useCallback:r0,useContext:Sn,useEffect:wp,useImperativeHandle:s0,useInsertionEffect:e0,useLayoutEffect:t0,useMemo:a0,useReducer:yp,useRef:Xb,useState:function(){return yp(wr)},useDebugValue:jp,useDeferredValue:function(r,i){var c=en();return wt===null?Sp(c,r,i):i0(c,wt.memoizedState,r,i)},useTransition:function(){var r=yp(wr)[0],i=en().memoizedState;return[typeof r=="boolean"?r:Al(r),i]},useSyncExternalStore:Db,useId:u0,useHostTransitionStatus:kp,useFormState:Kb,useActionState:Kb,useOptimistic:function(r,i){var c=en();return wt!==null?Bb(c,wt,r,i):(c.baseState=r,[r,c.queue.dispatch])},useMemoCache:gp,useCacheRefresh:d0};g0.useEffectEvent=Qb;function Tp(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 Ap={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),kl(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),kl(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),kl(i,r,c))}};function v0(r,i,c,f,v,x,C){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(f,x,C):i.prototype&&i.prototype.isPureReactComponent?!vl(c,f)||!vl(v,x):!0}function y0(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&&Ap.enqueueReplaceState(i,i.state,null)}function Ja(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 x0(r){du(r)}function b0(r){console.error(r)}function w0(r){du(r)}function Iu(r,i){try{var c=r.onUncaughtError;c(i.value,{componentStack:i.stack})}catch(f){setTimeout(function(){throw f})}}function j0(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 Mp(r,i,c){return c=Wr(c),c.tag=3,c.payload={element:null},c.callback=function(){Iu(r,i)},c}function S0(r){return r=Wr(r),r.tag=3,r}function N0(r,i,c,f){var v=c.type.getDerivedStateFromError;if(typeof v=="function"){var x=f.value;r.payload=function(){return v(x)},r.callback=function(){j0(i,c,f)}}var C=c.stateNode;C!==null&&typeof C.componentDidCatch=="function"&&(r.callback=function(){j0(i,c,f),typeof v!="function"&&(ea===null?ea=new Set([this]):ea.add(this));var D=f.stack;this.componentDidCatch(f.value,{componentStack:D!==null?D:""})})}function X2(r,i,c,f,v){if(c.flags|=32768,f!==null&&typeof f=="object"&&typeof f.then=="function"){if(i=c.alternate,i!==null&&Yi(i,c,v,!0),c=rs.current,c!==null){switch(c.tag){case 31:case 13:return ws===null?Zu():c.alternate===null&&Gt===0&&(Gt=3),c.flags&=-257,c.flags|=65536,c.lanes=v,f===wu?c.flags|=16384:(i=c.updateQueue,i===null?c.updateQueue=new Set([f]):i.add(f),tm(r,f,v)),!1;case 22:return c.flags|=65536,f===wu?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)),tm(r,f,v)),!1}throw Error(s(435,c.tag))}return tm(r,f,v),Zu(),!1}if(ct)return i=rs.current,i!==null?((i.flags&65536)===0&&(i.flags|=256),i.flags|=65536,i.lanes=v,f!==Gh&&(r=Error(s(422),{cause:f}),bl(vs(r,c)))):(f!==Gh&&(i=Error(s(423),{cause:f}),bl(vs(i,c))),r=r.current.alternate,r.flags|=65536,v&=-v,r.lanes|=v,f=vs(f,c),v=Mp(r.stateNode,f,v),ip(r,v),Gt!==4&&(Gt=2)),!1;var x=Error(s(520),{cause:f});if(x=vs(x,c),$l===null?$l=[x]:$l.push(x),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=Mp(c.stateNode,f,r),ip(c,r),!1;case 1:if(i=c.type,x=c.stateNode,(c.flags&128)===0&&(typeof i.getDerivedStateFromError=="function"||x!==null&&typeof x.componentDidCatch=="function"&&(ea===null||!ea.has(x))))return c.flags|=65536,v&=-v,c.lanes|=v,v=S0(v),N0(v,r,c,f),ip(c,v),!1}c=c.return}while(c!==null);return!1}var Rp=Error(s(461)),an=!1;function Nn(r,i,c,f){i.child=r===null?Tb(i,null,c,f):Ka(i,r.child,c,f)}function k0(r,i,c,f,v){c=c.render;var x=i.ref;if("ref"in f){var C={};for(var D in f)D!=="ref"&&(C[D]=f[D])}else C=f;return Za(i),f=fp(r,i,c,C,x,v),D=hp(),r!==null&&!an?(pp(r,i,v),jr(r,i,v)):(ct&&D&&Wh(i),i.flags|=1,Nn(r,i,f,v),i.child)}function E0(r,i,c,f,v){if(r===null){var x=c.type;return typeof x=="function"&&!Hh(x)&&x.defaultProps===void 0&&c.compare===null?(i.tag=15,i.type=x,C0(r,i,x,f,v)):(r=mu(c.type,null,f,i,i.mode,v),r.ref=i.ref,r.return=i,i.child=r)}if(x=r.child,!$p(r,v)){var C=x.memoizedProps;if(c=c.compare,c=c!==null?c:vl,c(C,f)&&r.ref===i.ref)return jr(r,i,v)}return i.flags|=1,r=gr(x,f),r.ref=i.ref,r.return=i,i.child=r}function C0(r,i,c,f,v){if(r!==null){var x=r.memoizedProps;if(vl(x,f)&&r.ref===i.ref)if(an=!1,i.pendingProps=f=x,$p(r,v))(r.flags&131072)!==0&&(an=!0);else return i.lanes=r.lanes,jr(r,i,v)}return _p(r,i,c,f,v)}function T0(r,i,c,f){var v=f.children,x=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(x=x!==null?x.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&~x}else f=0,i.child=null;return A0(r,i,x,c,f)}if((c&536870912)!==0)i.memoizedState={baseLanes:0,cachePool:null},r!==null&&xu(i,x!==null?x.cachePool:null),x!==null?Rb(i,x):lp(),_b(i);else return f=i.lanes=536870912,A0(r,i,x!==null?x.baseLanes|c:c,c,f)}else x!==null?(xu(i,x.cachePool),Rb(i,x),Kr(),i.memoizedState=null):(r!==null&&xu(i,null),lp(),Kr());return Nn(r,i,v,c),i.child}function _l(r,i){return r!==null&&r.tag===22||i.stateNode!==null||(i.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),i.sibling}function A0(r,i,c,f,v){var x=np();return x=x===null?null:{parent:sn._currentValue,pool:x},i.memoizedState={baseLanes:c,cachePool:x},r!==null&&xu(i,null),lp(),_b(i),r!==null&&Yi(r,i,f,!0),i.childLanes=v,null}function Du(r,i){return i=zu({mode:i.mode,children:i.children},r.mode),i.ref=r.ref,r.child=i,i.return=r,i}function M0(r,i,c){return Ka(i,r.child,null,c),r=Du(i,i.pendingProps),r.flags|=2,as(i),i.memoizedState=null,r}function J2(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=Du(i,f),i.lanes=536870912,_l(null,r);if(up(i),(r=Rt)?(r=Vw(r,bs),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=hb(r),c.return=i,i.child=c,jn=i,Rt=null)):r=null,r===null)throw Hr(i);return i.lanes=536870912,null}return Du(i,f)}var x=r.memoizedState;if(x!==null){var C=x.dehydrated;if(up(i),v)if(i.flags&256)i.flags&=-257,i=M0(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||Yi(r,i,c,!1),v=(c&r.childLanes)!==0,an||v){if(f=Ct,f!==null&&(C=Vt(f,c),C!==0&&C!==x.retryLane))throw x.retryLane=C,Va(r,C),Kn(f,r,C),Rp;Zu(),i=M0(r,i,c)}else r=x.treeContext,Rt=js(C.nextSibling),jn=i,ct=!0,Fr=null,bs=!1,r!==null&&gb(i,r),i=Du(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 Pu(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 _p(r,i,c,f,v){return Za(i),c=fp(r,i,c,f,void 0,v),f=hp(),r!==null&&!an?(pp(r,i,v),jr(r,i,v)):(ct&&f&&Wh(i),i.flags|=1,Nn(r,i,c,v),i.child)}function R0(r,i,c,f,v,x){return Za(i),i.updateQueue=null,c=Ib(i,f,c,v),Ob(r),f=hp(),r!==null&&!an?(pp(r,i,x),jr(r,i,x)):(ct&&f&&Wh(i),i.flags|=1,Nn(r,i,c,x),i.child)}function _0(r,i,c,f,v){if(Za(i),i.stateNode===null){var x=Hi,C=c.contextType;typeof C=="object"&&C!==null&&(x=Sn(C)),x=new c(f,x),i.memoizedState=x.state!==null&&x.state!==void 0?x.state:null,x.updater=Ap,i.stateNode=x,x._reactInternals=i,x=i.stateNode,x.props=f,x.state=i.memoizedState,x.refs={},rp(i),C=c.contextType,x.context=typeof C=="object"&&C!==null?Sn(C):Hi,x.state=i.memoizedState,C=c.getDerivedStateFromProps,typeof C=="function"&&(Tp(i,c,C,f),x.state=i.memoizedState),typeof c.getDerivedStateFromProps=="function"||typeof x.getSnapshotBeforeUpdate=="function"||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(C=x.state,typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount(),C!==x.state&&Ap.enqueueReplaceState(x,x.state,null),Cl(i,f,x,v),El(),x.state=i.memoizedState),typeof x.componentDidMount=="function"&&(i.flags|=4194308),f=!0}else if(r===null){x=i.stateNode;var D=i.memoizedProps,Y=Ja(c,D);x.props=Y;var ne=x.context,oe=c.contextType;C=Hi,typeof oe=="object"&&oe!==null&&(C=Sn(oe));var pe=c.getDerivedStateFromProps;oe=typeof pe=="function"||typeof x.getSnapshotBeforeUpdate=="function",D=i.pendingProps!==D,oe||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(D||ne!==C)&&y0(i,x,f,C),Zr=!1;var re=i.memoizedState;x.state=re,Cl(i,f,x,v),El(),ne=i.memoizedState,D||re!==ne||Zr?(typeof pe=="function"&&(Tp(i,c,pe,f),ne=i.memoizedState),(Y=Zr||v0(i,c,Y,f,re,ne,C))?(oe||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount()),typeof x.componentDidMount=="function"&&(i.flags|=4194308)):(typeof x.componentDidMount=="function"&&(i.flags|=4194308),i.memoizedProps=f,i.memoizedState=ne),x.props=f,x.state=ne,x.context=C,f=Y):(typeof x.componentDidMount=="function"&&(i.flags|=4194308),f=!1)}else{x=i.stateNode,ap(r,i),C=i.memoizedProps,oe=Ja(c,C),x.props=oe,pe=i.pendingProps,re=x.context,ne=c.contextType,Y=Hi,typeof ne=="object"&&ne!==null&&(Y=Sn(ne)),D=c.getDerivedStateFromProps,(ne=typeof D=="function"||typeof x.getSnapshotBeforeUpdate=="function")||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(C!==pe||re!==Y)&&y0(i,x,f,Y),Zr=!1,re=i.memoizedState,x.state=re,Cl(i,f,x,v),El();var ae=i.memoizedState;C!==pe||re!==ae||Zr||r!==null&&r.dependencies!==null&&vu(r.dependencies)?(typeof D=="function"&&(Tp(i,c,D,f),ae=i.memoizedState),(oe=Zr||v0(i,c,oe,f,re,ae,Y)||r!==null&&r.dependencies!==null&&vu(r.dependencies))?(ne||typeof x.UNSAFE_componentWillUpdate!="function"&&typeof x.componentWillUpdate!="function"||(typeof x.componentWillUpdate=="function"&&x.componentWillUpdate(f,ae,Y),typeof x.UNSAFE_componentWillUpdate=="function"&&x.UNSAFE_componentWillUpdate(f,ae,Y)),typeof x.componentDidUpdate=="function"&&(i.flags|=4),typeof x.getSnapshotBeforeUpdate=="function"&&(i.flags|=1024)):(typeof x.componentDidUpdate!="function"||C===r.memoizedProps&&re===r.memoizedState||(i.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||C===r.memoizedProps&&re===r.memoizedState||(i.flags|=1024),i.memoizedProps=f,i.memoizedState=ae),x.props=f,x.state=ae,x.context=Y,f=oe):(typeof x.componentDidUpdate!="function"||C===r.memoizedProps&&re===r.memoizedState||(i.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||C===r.memoizedProps&&re===r.memoizedState||(i.flags|=1024),f=!1)}return x=f,Pu(r,i),f=(i.flags&128)!==0,x||f?(x=i.stateNode,c=f&&typeof c.getDerivedStateFromError!="function"?null:x.render(),i.flags|=1,r!==null&&f?(i.child=Ka(i,r.child,null,v),i.child=Ka(i,null,c,v)):Nn(r,i,c,v),i.memoizedState=x.state,r=i.child):r=jr(r,i,v),r}function O0(r,i,c,f){return Ha(),i.flags|=256,Nn(r,i,c,f),i.child}var Op={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Ip(r){return{baseLanes:r,cachePool:jb()}}function Dp(r,i,c){return r=r!==null?r.childLanes&~c:0,i&&(r|=os),r}function I0(r,i,c){var f=i.pendingProps,v=!1,x=(i.flags&128)!==0,C;if((C=x)||(C=r!==null&&r.memoizedState===null?!1:(Qt.current&2)!==0),C&&(v=!0,i.flags&=-129),C=(i.flags&32)!==0,i.flags&=-33,r===null){if(ct){if(v?Gr(i):Kr(),(r=Rt)?(r=Vw(r,bs),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=hb(r),c.return=i,i.child=c,jn=i,Rt=null)):r=null,r===null)throw Hr(i);return vm(r)?i.lanes=32:i.lanes=536870912,null}var D=f.children;return f=f.fallback,v?(Kr(),v=i.mode,D=zu({mode:"hidden",children:D},v),f=Fa(f,v,c,null),D.return=i,f.return=i,D.sibling=f,i.child=D,f=i.child,f.memoizedState=Ip(c),f.childLanes=Dp(r,C,c),i.memoizedState=Op,_l(null,f)):(Gr(i),Pp(i,D))}var Y=r.memoizedState;if(Y!==null&&(D=Y.dehydrated,D!==null)){if(x)i.flags&256?(Gr(i),i.flags&=-257,i=zp(r,i,c)):i.memoizedState!==null?(Kr(),i.child=r.child,i.flags|=128,i=null):(Kr(),D=f.fallback,v=i.mode,f=zu({mode:"visible",children:f.children},v),D=Fa(D,v,c,null),D.flags|=2,f.return=i,D.return=i,f.sibling=D,i.child=f,Ka(i,r.child,null,c),f=i.child,f.memoizedState=Ip(c),f.childLanes=Dp(r,C,c),i.memoizedState=Op,i=_l(null,f));else if(Gr(i),vm(D)){if(C=D.nextSibling&&D.nextSibling.dataset,C)var ne=C.dgst;C=ne,f=Error(s(419)),f.stack="",f.digest=C,bl({value:f,source:null,stack:null}),i=zp(r,i,c)}else if(an||Yi(r,i,c,!1),C=(c&r.childLanes)!==0,an||C){if(C=Ct,C!==null&&(f=Vt(C,c),f!==0&&f!==Y.retryLane))throw Y.retryLane=f,Va(r,f),Kn(C,r,f),Rp;gm(D)||Zu(),i=zp(r,i,c)}else gm(D)?(i.flags|=192,i.child=r.child,i=null):(r=Y.treeContext,Rt=js(D.nextSibling),jn=i,ct=!0,Fr=null,bs=!1,r!==null&&gb(i,r),i=Pp(i,f.children),i.flags|=4096);return i}return v?(Kr(),D=f.fallback,v=i.mode,Y=r.child,ne=Y.sibling,f=gr(Y,{mode:"hidden",children:f.children}),f.subtreeFlags=Y.subtreeFlags&65011712,ne!==null?D=gr(ne,D):(D=Fa(D,v,c,null),D.flags|=2),D.return=i,f.return=i,f.sibling=D,i.child=f,_l(null,f),f=i.child,D=r.child.memoizedState,D===null?D=Ip(c):(v=D.cachePool,v!==null?(Y=sn._currentValue,v=v.parent!==Y?{parent:Y,pool:Y}:v):v=jb(),D={baseLanes:D.baseLanes|c,cachePool:v}),f.memoizedState=D,f.childLanes=Dp(r,C,c),i.memoizedState=Op,_l(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&&(C=i.deletions,C===null?(i.deletions=[r],i.flags|=16):C.push(r)),i.child=c,i.memoizedState=null,c)}function Pp(r,i){return i=zu({mode:"visible",children:i},r.mode),i.return=r,r.child=i}function zu(r,i){return r=ss(22,r,null,i),r.lanes=0,r}function zp(r,i,c){return Ka(i,r.child,null,c),r=Pp(i,i.pendingProps.children),r.flags|=2,i.memoizedState=null,r}function D0(r,i,c){r.lanes|=i;var f=r.alternate;f!==null&&(f.lanes|=i),Jh(r.return,i,c)}function Lp(r,i,c,f,v,x){var C=r.memoizedState;C===null?r.memoizedState={isBackwards:i,rendering:null,renderingStartTime:0,last:f,tail:c,tailMode:v,treeForkCount:x}:(C.isBackwards=i,C.rendering=null,C.renderingStartTime=0,C.last=f,C.tail=c,C.tailMode=v,C.treeForkCount=x)}function P0(r,i,c){var f=i.pendingProps,v=f.revealOrder,x=f.tail;f=f.children;var C=Qt.current,D=(C&2)!==0;if(D?(C=C&1|2,i.flags|=128):C&=1,G(Qt,C),Nn(r,i,f,c),f=ct?xl:0,!D&&r!==null&&(r.flags&128)!==0)e:for(r=i.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&D0(r,c,i);else if(r.tag===19)D0(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&&ku(r)===null&&(v=c),c=c.sibling;c=v,c===null?(v=i.child,i.child=null):(v=c.sibling,c.sibling=null),Lp(i,!1,v,c,x,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&&ku(r)===null){i.child=v;break}r=v.sibling,v.sibling=c,c=v,v=r}Lp(i,!0,c,null,x,f);break;case"together":Lp(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(Yi(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 $p(r,i){return(r.lanes&i)!==0?!0:(r=r.dependencies,!!(r!==null&&vu(r)))}function Q2(r,i,c){switch(i.tag){case 3:me(i,i.stateNode.containerInfo),qr(i,sn,r.memoizedState.cache),Ha();break;case 27:case 5:Ae(i);break;case 4:me(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,up(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?I0(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||(Yi(r,i,c,!1),f=(c&i.childLanes)!==0),v){if(f)return P0(r,i,c);i.flags|=128}if(v=i.memoizedState,v!==null&&(v.rendering=null,v.tail=null,v.lastEffect=null),G(Qt,Qt.current),f)break;return null;case 22:return i.lanes=0,T0(r,i,c,i.pendingProps);case 24:qr(i,sn,r.memoizedState.cache)}return jr(r,i,c)}function z0(r,i,c){if(r!==null)if(r.memoizedProps!==i.pendingProps)an=!0;else{if(!$p(r,c)&&(i.flags&128)===0)return an=!1,Q2(r,i,c);an=(r.flags&131072)!==0}else an=!1,ct&&(i.flags&1048576)!==0&&mb(i,xl,i.index);switch(i.lanes=0,i.tag){case 16:e:{var f=i.pendingProps;if(r=Ya(i.elementType),i.type=r,typeof r=="function")Hh(r)?(f=Ja(r,f),i.tag=1,i=_0(null,i,r,f,c)):(i.tag=0,i=_p(null,i,r,f,c));else{if(r!=null){var v=r.$$typeof;if(v===M){i.tag=11,i=k0(null,i,r,f,c);break e}else if(v===_){i.tag=14,i=E0(null,i,r,f,c);break e}}throw i=Z(r)||r,Error(s(306,i,""))}}return i;case 0:return _p(r,i,i.type,i.pendingProps,c);case 1:return f=i.type,v=Ja(f,i.pendingProps),_0(r,i,f,v,c);case 3:e:{if(me(i,i.stateNode.containerInfo),r===null)throw Error(s(387));f=i.pendingProps;var x=i.memoizedState;v=x.element,ap(r,i),Cl(i,f,null,c);var C=i.memoizedState;if(f=C.cache,qr(i,sn,f),f!==x.cache&&Qh(i,[sn],c,!0),El(),f=C.element,x.isDehydrated)if(x={element:f,isDehydrated:!1,cache:C.cache},i.updateQueue.baseState=x,i.memoizedState=x,i.flags&256){i=O0(r,i,f,c);break e}else if(f!==v){v=vs(Error(s(424)),i),bl(v),i=O0(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,Rt=js(r.firstChild),jn=i,ct=!0,Fr=null,bs=!0,c=Tb(i,null,f,c),i.child=c;c;)c.flags=c.flags&-3|4096,c=c.sibling;else{if(Ha(),f===v){i=jr(r,i,c);break e}Nn(r,i,f,c)}i=i.child}return i;case 26:return Pu(r,i),r===null?(c=Yw(i.type,null,i.pendingProps,null))?i.memoizedState=c:ct||(c=i.type,r=i.pendingProps,f=Qu(se.current).createElement(c),f[wn]=i,f[Hn]=r,kn(f,c,r),gn(f),i.stateNode=f):i.memoizedState=Yw(i.type,r.memoizedProps,i.pendingProps,r.memoizedState),null;case 27:return Ae(i),r===null&&ct&&(f=i.stateNode=qw(i.type,i.pendingProps,se.current),jn=i,bs=!0,v=Rt,ra(i.type)?(ym=v,Rt=js(f.firstChild)):Rt=v),Nn(r,i,i.pendingProps.children,c),Pu(r,i),r===null&&(i.flags|=4194304),i.child;case 5:return r===null&&ct&&((v=f=Rt)&&(f=A_(f,i.type,i.pendingProps,bs),f!==null?(i.stateNode=f,jn=i,Rt=js(f.firstChild),bs=!1,v=!0):v=!1),v||Hr(i)),Ae(i),v=i.type,x=i.pendingProps,C=r!==null?r.memoizedProps:null,f=x.children,hm(v,x)?f=null:C!==null&&hm(v,C)&&(i.flags|=32),i.memoizedState!==null&&(v=fp(r,i,H2,null,null,c),Wl._currentValue=v),Pu(r,i),Nn(r,i,f,c),i.child;case 6:return r===null&&ct&&((r=c=Rt)&&(c=M_(c,i.pendingProps,bs),c!==null?(i.stateNode=c,jn=i,Rt=null,r=!0):r=!1),r||Hr(i)),null;case 13:return I0(r,i,c);case 4:return me(i,i.stateNode.containerInfo),f=i.pendingProps,r===null?i.child=Ka(i,null,f,c):Nn(r,i,f,c),i.child;case 11:return k0(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,Za(i),v=Sn(v),f=f(v),i.flags|=1,Nn(r,i,f,c),i.child;case 14:return E0(r,i,i.type,i.pendingProps,c);case 15:return C0(r,i,i.type,i.pendingProps,c);case 19:return P0(r,i,c);case 31:return J2(r,i,c);case 22:return T0(r,i,c,i.pendingProps);case 24:return Za(i),f=Sn(sn),r===null?(v=np(),v===null&&(v=Ct,x=ep(),v.pooledCache=x,x.refCount++,x!==null&&(v.pooledCacheLanes|=c),v=x),i.memoizedState={parent:f,cache:v},rp(i),qr(i,sn,v)):((r.lanes&c)!==0&&(ap(r,i),Cl(i,null,null,c),El()),v=r.memoizedState,x=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=x.cache,qr(i,sn,f),f!==v.cache&&Qh(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 Up(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(uw())r.flags|=8192;else throw Ga=wu,sp}else r.flags&=-16777217}function L0(r,i){if(i.type!=="stylesheet"||(i.state.loading&4)!==0)r.flags&=-16777217;else if(r.flags|=16777216,!Qw(i))if(uw())r.flags|=8192;else throw Ga=wu,sp}function Lu(r,i){i!==null&&(r.flags|=4),r.flags&16384&&(i=r.tag!==22?ee():536870912,r.lanes|=i,io|=i)}function Ol(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 e_(r,i,c){var f=i.pendingProps;switch(Yh(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),xr(sn),je(),c.pendingContext&&(c.context=c.pendingContext,c.pendingContext=null),(r===null||r.child===null)&&(Wi(i)?Sr(i):r===null||r.memoizedState.isDehydrated&&(i.flags&256)===0||(i.flags|=1024,Kh())),_t(i),null;case 26:var v=i.type,x=i.memoizedState;return r===null?(Sr(i),x!==null?(_t(i),L0(i,x)):(_t(i),Up(i,v,null,f,c))):x?x!==r.memoizedState?(Sr(i),_t(i),L0(i,x)):(_t(i),i.flags&=-16777217):(r=r.memoizedProps,r!==f&&Sr(i),_t(i),Up(i,v,r,f,c)),null;case 27:if(he(i),c=se.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=J.current,Wi(i)?vb(i):(r=qw(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(x=J.current,Wi(i))vb(i);else{var C=Qu(se.current);switch(x){case 1:x=C.createElementNS("http://www.w3.org/2000/svg",v);break;case 2:x=C.createElementNS("http://www.w3.org/1998/Math/MathML",v);break;default:switch(v){case"svg":x=C.createElementNS("http://www.w3.org/2000/svg",v);break;case"math":x=C.createElementNS("http://www.w3.org/1998/Math/MathML",v);break;case"script":x=C.createElement("div"),x.innerHTML="<script><\/script>",x=x.removeChild(x.firstChild);break;case"select":x=typeof f.is=="string"?C.createElement("select",{is:f.is}):C.createElement("select"),f.multiple?x.multiple=!0:f.size&&(x.size=f.size);break;default:x=typeof f.is=="string"?C.createElement(v,{is:f.is}):C.createElement(v)}}x[wn]=i,x[Hn]=f;e:for(C=i.child;C!==null;){if(C.tag===5||C.tag===6)x.appendChild(C.stateNode);else if(C.tag!==4&&C.tag!==27&&C.child!==null){C.child.return=C,C=C.child;continue}if(C===i)break e;for(;C.sibling===null;){if(C.return===null||C.return===i)break e;C=C.return}C.sibling.return=C.return,C=C.sibling}i.stateNode=x;e:switch(kn(x,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),Up(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=se.current,Wi(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||Iw(r.nodeValue,c)),r||Hr(i,!0)}else r=Qu(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=Wi(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 Ha(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;_t(i),r=!1}else c=Kh(),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=Wi(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 Ha(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;_t(i),v=!1}else v=Kh(),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),x=null,f.memoizedState!==null&&f.memoizedState.cachePool!==null&&(x=f.memoizedState.cachePool.pool),x!==v&&(f.flags|=2048)),c!==r&&c&&(i.child.flags|=8192),Lu(i,i.updateQueue),_t(i),null);case 4:return je(),r===null&&lm(i.stateNode.containerInfo),_t(i),null;case 10:return xr(i.type),_t(i),null;case 19:if(F(Qt),f=i.memoizedState,f===null)return _t(i),null;if(v=(i.flags&128)!==0,x=f.rendering,x===null)if(v)Ol(f,!1);else{if(Gt!==0||r!==null&&(r.flags&128)!==0)for(r=i.child;r!==null;){if(x=ku(r),x!==null){for(i.flags|=128,Ol(f,!1),r=x.updateQueue,i.updateQueue=r,Lu(i,r),i.subtreeFlags=0,r=c,c=i.child;c!==null;)fb(c,r),c=c.sibling;return G(Qt,Qt.current&1|2),ct&&vr(i,f.treeForkCount),i.child}r=r.sibling}f.tail!==null&&ke()>Fu&&(i.flags|=128,v=!0,Ol(f,!1),i.lanes=4194304)}else{if(!v)if(r=ku(x),r!==null){if(i.flags|=128,v=!0,r=r.updateQueue,i.updateQueue=r,Lu(i,r),Ol(f,!0),f.tail===null&&f.tailMode==="hidden"&&!x.alternate&&!ct)return _t(i),null}else 2*ke()-f.renderingStartTime>Fu&&c!==536870912&&(i.flags|=128,v=!0,Ol(f,!1),i.lanes=4194304);f.isBackwards?(x.sibling=i.child,i.child=x):(r=f.last,r!==null?r.sibling=x:i.child=x,f.last=x)}return f.tail!==null?(r=f.tail,f.rendering=r,f.tail=r.sibling,f.renderingStartTime=ke(),r.sibling=null,c=Qt.current,G(Qt,v?c&1|2:c&1),ct&&vr(i,f.treeForkCount),r):(_t(i),null);case 22:case 23:return as(i),cp(),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&&Lu(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&&F(Wa),null;case 24:return c=null,r!==null&&(c=r.memoizedState.cache),i.memoizedState.cache!==c&&(i.flags|=2048),xr(sn),_t(i),null;case 25:return null;case 30:return null}throw Error(s(156,i.tag))}function t_(r,i){switch(Yh(i),i.tag){case 1:return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 3:return xr(sn),je(),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));Ha()}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));Ha()}return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 19:return F(Qt),null;case 4:return je(),null;case 10:return xr(i.type),null;case 22:case 23:return as(i),cp(),r!==null&&F(Wa),r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 24:return xr(sn),null;case 25:return null;default:return null}}function $0(r,i){switch(Yh(i),i.tag){case 3:xr(sn),je();break;case 26:case 27:case 5:he(i);break;case 4:je();break;case 31:i.memoizedState!==null&&as(i);break;case 13:as(i);break;case 19:F(Qt);break;case 10:xr(i.type);break;case 22:case 23:as(i),cp(),r!==null&&F(Wa);break;case 24:xr(sn)}}function Il(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 x=c.create,C=c.inst;f=x(),C.destroy=f}c=c.next}while(c!==v)}}catch(D){yt(i,i.return,D)}}function Xr(r,i,c){try{var f=i.updateQueue,v=f!==null?f.lastEffect:null;if(v!==null){var x=v.next;f=x;do{if((f.tag&r)===r){var C=f.inst,D=C.destroy;if(D!==void 0){C.destroy=void 0,v=i;var Y=c,ne=D;try{ne()}catch(oe){yt(v,Y,oe)}}}f=f.next}while(f!==x)}}catch(oe){yt(i,i.return,oe)}}function U0(r){var i=r.updateQueue;if(i!==null){var c=r.stateNode;try{Mb(i,c)}catch(f){yt(r,r.return,f)}}}function B0(r,i,c){c.props=Ja(r.type,r.memoizedProps),c.state=r.memoizedState;try{c.componentWillUnmount()}catch(f){yt(r,i,f)}}function Dl(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 V0(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 Bp(r,i,c){try{var f=r.stateNode;S_(f,r.type,c,i),f[Hn]=i}catch(v){yt(r,r.return,v)}}function F0(r){return r.tag===5||r.tag===3||r.tag===26||r.tag===27&&ra(r.type)||r.tag===4}function Vp(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||F0(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 Fp(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(Fp(r,i,c),r=r.sibling;r!==null;)Fp(r,i,c),r=r.sibling}function $u(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($u(r,i,c),r=r.sibling;r!==null;)$u(r,i,c),r=r.sibling}function H0(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(x){yt(r,r.return,x)}}var Nr=!1,on=!1,Hp=!1,q0=typeof WeakSet=="function"?WeakSet:Set,vn=null;function n_(r,i){if(r=r.containerInfo,dm=id,r=sb(r),zh(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,x=f.focusNode;f=f.focusOffset;try{c.nodeType,x.nodeType}catch{c=null;break e}var C=0,D=-1,Y=-1,ne=0,oe=0,pe=r,re=null;t:for(;;){for(var ae;pe!==c||v!==0&&pe.nodeType!==3||(D=C+v),pe!==x||f!==0&&pe.nodeType!==3||(Y=C+f),pe.nodeType===3&&(C+=pe.nodeValue.length),(ae=pe.firstChild)!==null;)re=pe,pe=ae;for(;;){if(pe===r)break t;if(re===c&&++ne===v&&(D=C),re===x&&++oe===f&&(Y=C),(ae=pe.nextSibling)!==null)break;pe=re,re=pe.parentNode}pe=ae}c=D===-1||Y===-1?null:{start:D,end:Y}}else c=null}c=c||{start:0,end:0}}else c=null;for(fm={focusedElem:r,selectionRange:c},id=!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,x=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&&x!==null){r=void 0,c=i,v=x.memoizedProps,x=x.memoizedState,f=c.stateNode;try{var Re=Ja(c.type,v);r=f.getSnapshotBeforeUpdate(Re,x),f.__reactInternalSnapshotBeforeUpdate=r}catch(He){yt(c,c.return,He)}}break;case 3:if((r&1024)!==0){if(r=i.stateNode.containerInfo,c=r.nodeType,c===9)mm(r);else if(c===1)switch(r.nodeName){case"HEAD":case"HTML":case"BODY":mm(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 Z0(r,i,c){var f=c.flags;switch(c.tag){case 0:case 11:case 15:Er(r,c),f&4&&Il(5,c);break;case 1:if(Er(r,c),f&4)if(r=c.stateNode,i===null)try{r.componentDidMount()}catch(C){yt(c,c.return,C)}else{var v=Ja(c.type,i.memoizedProps);i=i.memoizedState;try{r.componentDidUpdate(v,i,r.__reactInternalSnapshotBeforeUpdate)}catch(C){yt(c,c.return,C)}}f&64&&U0(c),f&512&&Dl(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{Mb(r,i)}catch(C){yt(c,c.return,C)}}break;case 27:i===null&&f&4&&H0(c);case 26:case 5:Er(r,c),i===null&&f&4&&V0(c),f&512&&Dl(c,c.return);break;case 12:Er(r,c);break;case 31:Er(r,c),f&4&&G0(r,c);break;case 13:Er(r,c),f&4&&K0(r,c),f&64&&(r=c.memoizedState,r!==null&&(r=r.dehydrated,r!==null&&(c=d_.bind(null,c),R_(r,c))));break;case 22:if(f=c.memoizedState!==null||Nr,!f){i=i!==null&&i.memoizedState!==null||on,v=Nr;var x=on;Nr=f,(on=i)&&!x?Cr(r,c,(c.subtreeFlags&8772)!==0):Er(r,c),Nr=v,on=x}break;case 30:break;default:Er(r,c)}}function W0(r){var i=r.alternate;i!==null&&(r.alternate=null,W0(i)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(i=r.stateNode,i!==null&&bh(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;)Y0(r,i,c),c=c.sibling}function Y0(r,i,c){if($e&&typeof $e.onCommitFiberUnmount=="function")try{$e.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),Hl(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(x){yt(c,i,x)}else try{$t.removeChild(c.stateNode)}catch(x){yt(c,i,x)}break;case 18:$t!==null&&(Zn?(r=$t,Uw(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,c.stateNode),mo(r)):Uw($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"&&B0(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 G0(r,i){if(i.memoizedState===null&&(r=i.alternate,r!==null&&(r=r.memoizedState,r!==null))){r=r.dehydrated;try{mo(r)}catch(c){yt(i,i.return,c)}}}function K0(r,i){if(i.memoizedState===null&&(r=i.alternate,r!==null&&(r=r.memoizedState,r!==null&&(r=r.dehydrated,r!==null))))try{mo(r)}catch(c){yt(i,i.return,c)}}function s_(r){switch(r.tag){case 31:case 13:case 19:var i=r.stateNode;return i===null&&(i=r.stateNode=new q0),i;case 22:return r=r.stateNode,i=r._retryCache,i===null&&(i=r._retryCache=new q0),i;default:throw Error(s(435,r.tag))}}function Uu(r,i){var c=s_(r);i.forEach(function(f){if(!c.has(f)){c.add(f);var v=f_.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],x=r,C=i,D=C;e:for(;D!==null;){switch(D.tag){case 27:if(ra(D.type)){$t=D.stateNode,Zn=!1;break e}break;case 5:$t=D.stateNode,Zn=!1;break e;case 3:case 4:$t=D.stateNode.containerInfo,Zn=!0;break e}D=D.return}if($t===null)throw Error(s(160));Y0(x,C,v),$t=null,Zn=!1,x=v.alternate,x!==null&&(x.return=null),v.return=null}if(i.subtreeFlags&13886)for(i=i.child;i!==null;)X0(i,r),i=i.sibling}var Os=null;function X0(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),Il(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 x=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":x=v.getElementsByTagName("title")[0],(!x||x[ll]||x[wn]||x.namespaceURI==="http://www.w3.org/2000/svg"||x.hasAttribute("itemprop"))&&(x=v.createElement(f),v.head.insertBefore(x,v.querySelector("head > title"))),kn(x,f,c),x[wn]=r,gn(x),f=x;break e;case"link":var C=Xw("link","href",v).get(f+(c.href||""));if(C){for(var D=0;D<C.length;D++)if(x=C[D],x.getAttribute("href")===(c.href==null||c.href===""?null:c.href)&&x.getAttribute("rel")===(c.rel==null?null:c.rel)&&x.getAttribute("title")===(c.title==null?null:c.title)&&x.getAttribute("crossorigin")===(c.crossOrigin==null?null:c.crossOrigin)){C.splice(D,1);break t}}x=v.createElement(f),kn(x,f,c),v.head.appendChild(x);break;case"meta":if(C=Xw("meta","content",v).get(f+(c.content||""))){for(D=0;D<C.length;D++)if(x=C[D],x.getAttribute("content")===(c.content==null?null:""+c.content)&&x.getAttribute("name")===(c.name==null?null:c.name)&&x.getAttribute("property")===(c.property==null?null:c.property)&&x.getAttribute("http-equiv")===(c.httpEquiv==null?null:c.httpEquiv)&&x.getAttribute("charset")===(c.charSet==null?null:c.charSet)){C.splice(D,1);break t}}x=v.createElement(f),kn(x,f,c),v.head.appendChild(x);break;default:throw Error(s(468,f))}x[wn]=r,gn(x),f=x}r.stateNode=f}else Jw(v,r.type,r.stateNode);else r.stateNode=Kw(v,f,r.memoizedProps);else x!==f?(x===null?c.stateNode!==null&&(c=c.stateNode,c.parentNode.removeChild(c)):x.count--,f===null?Jw(v,r.type,r.stateNode):Kw(v,f,r.memoizedProps)):f===null&&r.stateNode!==null&&Bp(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&&Bp(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{zi(v,"")}catch(Re){yt(r,r.return,Re)}}f&4&&r.stateNode!=null&&(v=r.memoizedProps,Bp(r,v,c!==null?c.memoizedProps:v)),f&1024&&(Hp=!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(Re){yt(r,r.return,Re)}}break;case 3:if(nd=null,v=Os,Os=ed(i.containerInfo),Wn(i,r),Os=v,Yn(r),f&4&&c!==null&&c.memoizedState.isDehydrated)try{mo(i.containerInfo)}catch(Re){yt(r,r.return,Re)}Hp&&(Hp=!1,J0(r));break;case 4:f=Os,Os=ed(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,Uu(r,f)));break;case 13:Wn(i,r),Yn(r),r.child.flags&8192&&r.memoizedState!==null!=(c!==null&&c.memoizedState!==null)&&(Vu=ke()),f&4&&(f=r.updateQueue,f!==null&&(r.updateQueue=null,Uu(r,f)));break;case 22:v=r.memoizedState!==null;var Y=c!==null&&c.memoizedState!==null,ne=Nr,oe=on;if(Nr=ne||v,on=oe||Y,Wn(i,r),on=oe,Nr=ne,Yn(r),f&8192)e:for(i=r.stateNode,i._visibility=v?i._visibility&-2:i._visibility|1,v&&(c===null||Y||Nr||on||Qa(r)),c=null,i=r;;){if(i.tag===5||i.tag===26){if(c===null){Y=c=i;try{if(x=Y.stateNode,v)C=x.style,typeof C.setProperty=="function"?C.setProperty("display","none","important"):C.display="none";else{D=Y.stateNode;var pe=Y.memoizedProps.style,re=pe!=null&&pe.hasOwnProperty("display")?pe.display:null;D.style.display=re==null||typeof re=="boolean"?"":(""+re).trim()}}catch(Re){yt(Y,Y.return,Re)}}}else if(i.tag===6){if(c===null){Y=i;try{Y.stateNode.nodeValue=v?"":Y.memoizedProps}catch(Re){yt(Y,Y.return,Re)}}}else if(i.tag===18){if(c===null){Y=i;try{var ae=Y.stateNode;v?Bw(ae,!0):Bw(Y.stateNode,!1)}catch(Re){yt(Y,Y.return,Re)}}}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,Uu(r,c))));break;case 19:Wn(i,r),Yn(r),f&4&&(f=r.updateQueue,f!==null&&(r.updateQueue=null,Uu(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(F0(f)){c=f;break}f=f.return}if(c==null)throw Error(s(160));switch(c.tag){case 27:var v=c.stateNode,x=Vp(r);$u(r,x,v);break;case 5:var C=c.stateNode;c.flags&32&&(zi(C,""),c.flags&=-33);var D=Vp(r);$u(r,D,C);break;case 3:case 4:var Y=c.stateNode.containerInfo,ne=Vp(r);Fp(r,ne,Y);break;default:throw Error(s(161))}}catch(oe){yt(r,r.return,oe)}r.flags&=-3}i&4096&&(r.flags&=-4097)}function J0(r){if(r.subtreeFlags&1024)for(r=r.child;r!==null;){var i=r;J0(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;)Z0(r,i.alternate,i),i=i.sibling}function Qa(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),Qa(i);break;case 1:Ks(i,i.return);var c=i.stateNode;typeof c.componentWillUnmount=="function"&&B0(i,i.return,c),Qa(i);break;case 27:Hl(i.stateNode);case 26:case 5:Ks(i,i.return),Qa(i);break;case 22:i.memoizedState===null&&Qa(i);break;case 30:Qa(i);break;default:Qa(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,x=i,C=x.flags;switch(x.tag){case 0:case 11:case 15:Cr(v,x,c),Il(4,x);break;case 1:if(Cr(v,x,c),f=x,v=f.stateNode,typeof v.componentDidMount=="function")try{v.componentDidMount()}catch(ne){yt(f,f.return,ne)}if(f=x,v=f.updateQueue,v!==null){var D=f.stateNode;try{var Y=v.shared.hiddenCallbacks;if(Y!==null)for(v.shared.hiddenCallbacks=null,v=0;v<Y.length;v++)Ab(Y[v],D)}catch(ne){yt(f,f.return,ne)}}c&&C&64&&U0(x),Dl(x,x.return);break;case 27:H0(x);case 26:case 5:Cr(v,x,c),c&&f===null&&C&4&&V0(x),Dl(x,x.return);break;case 12:Cr(v,x,c);break;case 31:Cr(v,x,c),c&&C&4&&G0(v,x);break;case 13:Cr(v,x,c),c&&C&4&&K0(v,x);break;case 22:x.memoizedState===null&&Cr(v,x,c),Dl(x,x.return);break;case 30:break;default:Cr(v,x,c)}i=i.sibling}}function qp(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&&wl(c))}function Zp(r,i){r=null,i.alternate!==null&&(r=i.alternate.memoizedState.cache),i=i.memoizedState.cache,i!==r&&(i.refCount++,r!=null&&wl(r))}function Is(r,i,c,f){if(i.subtreeFlags&10256)for(i=i.child;i!==null;)Q0(r,i,c,f),i=i.sibling}function Q0(r,i,c,f){var v=i.flags;switch(i.tag){case 0:case 11:case 15:Is(r,i,c,f),v&2048&&Il(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&&wl(r)));break;case 12:if(v&2048){Is(r,i,c,f),r=i.stateNode;try{var x=i.memoizedProps,C=x.id,D=x.onPostCommit;typeof D=="function"&&D(C,i.alternate===null?"mount":"update",r.passiveEffectDuration,-0)}catch(Y){yt(i,i.return,Y)}}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:x=i.stateNode,C=i.alternate,i.memoizedState!==null?x._visibility&2?Is(r,i,c,f):Pl(r,i):x._visibility&2?Is(r,i,c,f):(x._visibility|=2,so(r,i,c,f,(i.subtreeFlags&10256)!==0||!1)),v&2048&&qp(C,i);break;case 24:Is(r,i,c,f),v&2048&&Zp(i.alternate,i);break;default:Is(r,i,c,f)}}function so(r,i,c,f,v){for(v=v&&((i.subtreeFlags&10256)!==0||!1),i=i.child;i!==null;){var x=r,C=i,D=c,Y=f,ne=C.flags;switch(C.tag){case 0:case 11:case 15:so(x,C,D,Y,v),Il(8,C);break;case 23:break;case 22:var oe=C.stateNode;C.memoizedState!==null?oe._visibility&2?so(x,C,D,Y,v):Pl(x,C):(oe._visibility|=2,so(x,C,D,Y,v)),v&&ne&2048&&qp(C.alternate,C);break;case 24:so(x,C,D,Y,v),v&&ne&2048&&Zp(C.alternate,C);break;default:so(x,C,D,Y,v)}i=i.sibling}}function Pl(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:Pl(c,f),v&2048&&qp(f.alternate,f);break;case 24:Pl(c,f),v&2048&&Zp(f.alternate,f);break;default:Pl(c,f)}i=i.sibling}}var zl=8192;function ro(r,i,c){if(r.subtreeFlags&zl)for(r=r.child;r!==null;)ew(r,i,c),r=r.sibling}function ew(r,i,c){switch(r.tag){case 26:ro(r,i,c),r.flags&zl&&r.memoizedState!==null&&F_(c,Os,r.memoizedState,r.memoizedProps);break;case 5:ro(r,i,c);break;case 3:case 4:var f=Os;Os=ed(r.stateNode.containerInfo),ro(r,i,c),Os=f;break;case 22:r.memoizedState===null&&(f=r.alternate,f!==null&&f.memoizedState!==null?(f=zl,zl=16777216,ro(r,i,c),zl=f):ro(r,i,c));break;default:ro(r,i,c)}}function tw(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 Ll(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,sw(f,r)}tw(r)}if(r.subtreeFlags&10256)for(r=r.child;r!==null;)nw(r),r=r.sibling}function nw(r){switch(r.tag){case 0:case 11:case 15:Ll(r),r.flags&2048&&Xr(9,r,r.return);break;case 3:Ll(r);break;case 12:Ll(r);break;case 22:var i=r.stateNode;r.memoizedState!==null&&i._visibility&2&&(r.return===null||r.return.tag!==13)?(i._visibility&=-3,Bu(r)):Ll(r);break;default:Ll(r)}}function Bu(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,sw(f,r)}tw(r)}for(r=r.child;r!==null;){switch(i=r,i.tag){case 0:case 11:case 15:Xr(8,i,i.return),Bu(i);break;case 22:c=i.stateNode,c._visibility&2&&(c._visibility&=-3,Bu(i));break;default:Bu(i)}r=r.sibling}}function sw(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:wl(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,x=f.return;if(W0(f),f===c){vn=null;break e}if(v!==null){v.return=x,vn=v;break e}vn=x}}}var r_={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}},a_=typeof WeakMap=="function"?WeakMap:Map,pt=0,Ct=null,nt=null,it=0,vt=0,is=null,Jr=!1,ao=!1,Wp=!1,Tr=0,Gt=0,Qr=0,ei=0,Yp=0,os=0,io=0,$l=null,Gn=null,Gp=!1,Vu=0,rw=0,Fu=1/0,Hu=null,ea=null,hn=0,ta=null,oo=null,Ar=0,Kp=0,Xp=null,aw=null,Ul=0,Jp=null;function ls(){return(pt&2)!==0&&it!==0?it&-it:L.T!==null?rm():bn()}function iw(){if(os===0)if((it&536870912)===0||ct){var r=Rn;Rn<<=1,(Rn&3932160)===0&&(Rn=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)&&(lo(r,0),na(r,it,os,!1)),xe(r,c),((pt&2)===0||r!==Ct)&&(r===Ct&&((pt&2)===0&&(ei|=c),Gt===4&&na(r,it,os,!1)),Xs(r))}function ow(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?l_(r,i):em(r,i,!0),x=f;do{if(v===0){ao&&!f&&na(r,i,0,!1);break}else{if(c=r.current.alternate,x&&!i_(c)){v=em(r,i,!1),x=!1;continue}if(v===2){if(x=i,r.errorRecoveryDisabledLanes&x)var C=0;else C=r.pendingLanes&-536870913,C=C!==0?C:C&536870912?536870912:0;if(C!==0){i=C;e:{var D=r;v=$l;var Y=D.current.memoizedState.isDehydrated;if(Y&&(lo(D,C).flags|=256),C=em(D,C,!1),C!==2){if(Wp&&!Y){D.errorRecoveryDisabledLanes|=x,ei|=x,v=4;break e}x=Gn,Gn=v,x!==null&&(Gn===null?Gn=x:Gn.push.apply(Gn,x))}v=C}if(x=!1,v!==2)continue}}if(v===1){lo(r,0),na(r,i,0,!0);break}e:{switch(f=r,x=v,x){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=Vu+300-ke(),10<v)){if(na(f,i,os,!Jr),qs(f,0,!0)!==0)break e;Ar=i,f.timeoutHandle=Lw(lw.bind(null,f,c,Gn,Hu,Gp,i,os,ei,io,Jr,x,"Throttled",-0,0),v);break e}lw(f,c,Gn,Hu,Gp,i,os,ei,io,Jr,x,null,-0,0)}}break}while(!0);Xs(r)}function lw(r,i,c,f,v,x,C,D,Y,ne,oe,pe,re,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},ew(i,x,pe);var Re=(x&62914560)===x?Vu-ke():(x&4194048)===x?rw-ke():0;if(Re=H_(pe,Re),Re!==null){Ar=x,r.cancelPendingCommit=Re(gw.bind(null,r,i,x,c,f,v,C,D,Y,oe,pe,null,re,ae)),na(r,x,C,!ne);return}}gw(r,i,x,c,f,v,C,D,Y)}function i_(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],x=v.getSnapshot;v=v.value;try{if(!ns(x(),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&=~Yp,i&=~ei,r.suspendedLanes|=i,r.pingedLanes&=~i,f&&(r.warmLanes|=i),f=r.expirationTimes;for(var v=i;0<v;){var x=31-lt(v),C=1<<x;f[x]=-1,v&=~C}c!==0&&We(r,c,i)}function qu(){return(pt&6)===0?(Bl(0),!1):!0}function Qp(){if(nt!==null){if(vt===0)var r=nt.return;else r=nt,yr=qa=null,mp(r),Ji=null,Sl=0,r=nt;for(;r!==null;)$0(r.alternate,r),r=r.return;nt=null}}function lo(r,i){var c=r.timeoutHandle;c!==-1&&(r.timeoutHandle=-1,E_(c)),c=r.cancelPendingCommit,c!==null&&(r.cancelPendingCommit=null,c()),Ar=0,Qp(),Ct=r,nt=c=gr(r.current,null),it=i,vt=0,is=null,Jr=!1,ao=Zs(r,i),Wp=!1,io=os=Yp=ei=Qr=Gt=0,Gn=$l=null,Gp=!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),x=1<<v;i|=r[v],f&=~x}return Tr=i,fu(),c}function cw(r,i){Je=null,L.H=Rl,i===Xi||i===bu?(i=kb(),vt=3):i===sp?(i=kb(),vt=4):vt=i===Rp?8:i!==null&&typeof i=="object"&&typeof i.then=="function"?6:1,is=i,nt===null&&(Gt=1,Iu(r,vs(i,r.current)))}function uw(){var r=rs.current;return r===null?!0:(it&4194048)===it?ws===null:(it&62914560)===it||(it&536870912)!==0?r===ws:!1}function dw(){var r=L.H;return L.H=Rl,r===null?Rl:r}function fw(){var r=L.A;return L.A=r_,r}function Zu(){Gt=4,Jr||(it&4194048)!==it&&rs.current!==null||(ao=!0),(Qr&134217727)===0&&(ei&134217727)===0||Ct===null||na(Ct,it,os,!1)}function em(r,i,c){var f=pt;pt|=2;var v=dw(),x=fw();(Ct!==r||it!==i)&&(Hu=null,lo(r,i)),i=!1;var C=Gt;e:do try{if(vt!==0&&nt!==null){var D=nt,Y=is;switch(vt){case 8:Qp(),C=6;break e;case 3:case 2:case 9:case 6:rs.current===null&&(i=!0);var ne=vt;if(vt=0,is=null,co(r,D,Y,ne),c&&ao){C=0;break e}break;default:ne=vt,vt=0,is=null,co(r,D,Y,ne)}}o_(),C=Gt;break}catch(oe){cw(r,oe)}while(!0);return i&&r.shellSuspendCounter++,yr=qa=null,pt=f,L.H=v,L.A=x,nt===null&&(Ct=null,it=0,fu()),C}function o_(){for(;nt!==null;)hw(nt)}function l_(r,i){var c=pt;pt|=2;var f=dw(),v=fw();Ct!==r||it!==i?(Hu=null,Fu=ke()+500,lo(r,i)):ao=Zs(r,i);e:do try{if(vt!==0&&nt!==null){i=nt;var x=is;t:switch(vt){case 1:vt=0,is=null,co(r,i,x,1);break;case 2:case 9:if(Sb(x)){vt=0,is=null,pw(i);break}i=function(){vt!==2&&vt!==9||Ct!==r||(vt=7),Xs(r)},x.then(i,i);break e;case 3:vt=7;break e;case 4:vt=5;break e;case 7:Sb(x)?(vt=0,is=null,pw(i)):(vt=0,is=null,co(r,i,x,7));break;case 5:var C=null;switch(nt.tag){case 26:C=nt.memoizedState;case 5:case 27:var D=nt;if(C?Qw(C):D.stateNode.complete){vt=0,is=null;var Y=D.sibling;if(Y!==null)nt=Y;else{var ne=D.return;ne!==null?(nt=ne,Wu(ne)):nt=null}break t}}vt=0,is=null,co(r,i,x,5);break;case 6:vt=0,is=null,co(r,i,x,6);break;case 8:Qp(),Gt=6;break e;default:throw Error(s(462))}}c_();break}catch(oe){cw(r,oe)}while(!0);return yr=qa=null,L.H=f,L.A=v,pt=c,nt!==null?0:(Ct=null,it=0,fu(),Gt)}function c_(){for(;nt!==null&&!ye();)hw(nt)}function hw(r){var i=z0(r.alternate,r,Tr);r.memoizedProps=r.pendingProps,i===null?Wu(r):nt=i}function pw(r){var i=r,c=i.alternate;switch(i.tag){case 15:case 0:i=R0(c,i,i.pendingProps,i.type,void 0,it);break;case 11:i=R0(c,i,i.pendingProps,i.type.render,i.ref,it);break;case 5:mp(i);default:$0(c,i),i=nt=fb(i,Tr),i=z0(c,i,Tr)}r.memoizedProps=r.pendingProps,i===null?Wu(r):nt=i}function co(r,i,c,f){yr=qa=null,mp(i),Ji=null,Sl=0;var v=i.return;try{if(X2(r,v,i,c,it)){Gt=1,Iu(r,vs(c,r.current)),nt=null;return}}catch(x){if(v!==null)throw nt=v,x;Gt=1,Iu(r,vs(c,r.current)),nt=null;return}i.flags&32768?(ct||f===1?r=!0:ao||(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))),mw(i,r)):Wu(i)}function Wu(r){var i=r;do{if((i.flags&32768)!==0){mw(i,Jr);return}r=i.return;var c=e_(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 mw(r,i){do{var c=t_(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 gw(r,i,c,f,v,x,C,D,Y){r.cancelPendingCommit=null;do Yu();while(hn!==0);if((pt&6)!==0)throw Error(s(327));if(i!==null){if(i===r.current)throw Error(s(177));if(x=i.lanes|i.childLanes,x|=Vh,Ze(r,c,x,C,D,Y),r===Ct&&(nt=Ct=null,it=0),oo=i,ta=r,Ar=c,Kp=x,Xp=v,aw=f,(i.subtreeFlags&10256)!==0||(i.flags&10256)!==0?(r.callbackNode=null,r.callbackPriority=0,h_(ze,function(){return ww(),null})):(r.callbackNode=null,r.callbackPriority=0),f=(i.flags&13878)!==0,(i.subtreeFlags&13878)!==0||f){f=L.T,L.T=null,v=z.p,z.p=2,C=pt,pt|=4;try{n_(r,i,c)}finally{pt=C,z.p=v,L.T=f}}hn=1,vw(),yw(),xw()}}function vw(){if(hn===1){hn=0;var r=ta,i=oo,c=(i.flags&13878)!==0;if((i.subtreeFlags&13878)!==0||c){c=L.T,L.T=null;var f=z.p;z.p=2;var v=pt;pt|=4;try{X0(i,r);var x=fm,C=sb(r.containerInfo),D=x.focusedElem,Y=x.selectionRange;if(C!==D&&D&&D.ownerDocument&&nb(D.ownerDocument.documentElement,D)){if(Y!==null&&zh(D)){var ne=Y.start,oe=Y.end;if(oe===void 0&&(oe=ne),"selectionStart"in D)D.selectionStart=ne,D.selectionEnd=Math.min(oe,D.value.length);else{var pe=D.ownerDocument||document,re=pe&&pe.defaultView||window;if(re.getSelection){var ae=re.getSelection(),Re=D.textContent.length,He=Math.min(Y.start,Re),St=Y.end===void 0?He:Math.min(Y.end,Re);!ae.extend&&He>St&&(C=St,St=He,He=C);var Q=tb(D,He),K=tb(D,St);if(Q&&K&&(ae.rangeCount!==1||ae.anchorNode!==Q.node||ae.anchorOffset!==Q.offset||ae.focusNode!==K.node||ae.focusOffset!==K.offset)){var te=pe.createRange();te.setStart(Q.node,Q.offset),ae.removeAllRanges(),He>St?(ae.addRange(te),ae.extend(K.node,K.offset)):(te.setEnd(K.node,K.offset),ae.addRange(te))}}}}for(pe=[],ae=D;ae=ae.parentNode;)ae.nodeType===1&&pe.push({element:ae,left:ae.scrollLeft,top:ae.scrollTop});for(typeof D.focus=="function"&&D.focus(),D=0;D<pe.length;D++){var fe=pe[D];fe.element.scrollLeft=fe.left,fe.element.scrollTop=fe.top}}id=!!dm,fm=dm=null}finally{pt=v,z.p=f,L.T=c}}r.current=i,hn=2}}function yw(){if(hn===2){hn=0;var r=ta,i=oo,c=(i.flags&8772)!==0;if((i.subtreeFlags&8772)!==0||c){c=L.T,L.T=null;var f=z.p;z.p=2;var v=pt;pt|=4;try{Z0(r,i.alternate,i)}finally{pt=v,z.p=f,L.T=c}}hn=3}}function xw(){if(hn===4||hn===3){hn=0,be();var r=ta,i=oo,c=Ar,f=aw;(i.subtreeFlags&10256)!==0||(i.flags&10256)!==0?hn=5:(hn=0,oo=ta=null,bw(r,r.pendingLanes));var v=r.pendingLanes;if(v===0&&(ea=null),mn(c),i=i.stateNode,$e&&typeof $e.onCommitFiberRoot=="function")try{$e.onCommitFiberRoot(Jt,i,void 0,(i.current.flags&128)===128)}catch{}if(f!==null){i=L.T,v=z.p,z.p=2,L.T=null;try{for(var x=r.onRecoverableError,C=0;C<f.length;C++){var D=f[C];x(D.value,{componentStack:D.stack})}}finally{L.T=i,z.p=v}}(Ar&3)!==0&&Yu(),Xs(r),v=r.pendingLanes,(c&261930)!==0&&(v&42)!==0?r===Jp?Ul++:(Ul=0,Jp=r):Ul=0,Bl(0)}}function bw(r,i){(r.pooledCacheLanes&=i)===0&&(i=r.pooledCache,i!=null&&(r.pooledCache=null,wl(i)))}function Yu(){return vw(),yw(),xw(),ww()}function ww(){if(hn!==5)return!1;var r=ta,i=Kp;Kp=0;var c=mn(Ar),f=L.T,v=z.p;try{z.p=32>c?32:c,L.T=null,c=Xp,Xp=null;var x=ta,C=Ar;if(hn=0,oo=ta=null,Ar=0,(pt&6)!==0)throw Error(s(331));var D=pt;if(pt|=4,nw(x.current),Q0(x,x.current,C,c),pt=D,Bl(0,!1),$e&&typeof $e.onPostCommitFiberRoot=="function")try{$e.onPostCommitFiberRoot(Jt,x)}catch{}return!0}finally{z.p=v,L.T=f,bw(r,i)}}function jw(r,i,c){i=vs(c,i),i=Mp(r.stateNode,i,2),r=Yr(r,i,2),r!==null&&(xe(r,2),Xs(r))}function yt(r,i,c){if(r.tag===3)jw(r,r,c);else for(;i!==null;){if(i.tag===3){jw(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=S0(2),f=Yr(i,c,2),f!==null&&(N0(c,f,i,r),xe(f,2),Xs(f));break}}i=i.return}}function tm(r,i,c){var f=r.pingCache;if(f===null){f=r.pingCache=new a_;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)||(Wp=!0,v.add(c),r=u_.bind(null,r,i,c),i.then(r,r))}function u_(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>ke()-Vu?(pt&2)===0&&lo(r,0):Yp|=c,io===it&&(io=0)),Xs(r)}function Sw(r,i){i===0&&(i=ee()),r=Va(r,i),r!==null&&(xe(r,i),Xs(r))}function d_(r){var i=r.memoizedState,c=0;i!==null&&(c=i.retryLane),Sw(r,c)}function f_(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),Sw(r,c)}function h_(r,i){return Ve(r,i)}var Gu=null,uo=null,nm=!1,Ku=!1,sm=!1,sa=0;function Xs(r){r!==uo&&r.next===null&&(uo===null?Gu=uo=r:uo=uo.next=r),Ku=!0,nm||(nm=!0,m_())}function Bl(r,i){if(!sm&&Ku){sm=!0;do for(var c=!1,f=Gu;f!==null;){if(r!==0){var v=f.pendingLanes;if(v===0)var x=0;else{var C=f.suspendedLanes,D=f.pingedLanes;x=(1<<31-lt(42|r)+1)-1,x&=v&~(C&~D),x=x&201326741?x&201326741|1:x?x|2:0}x!==0&&(c=!0,Cw(f,x))}else x=it,x=qs(f,f===Ct?x:0,f.cancelPendingCommit!==null||f.timeoutHandle!==-1),(x&3)===0||Zs(f,x)||(c=!0,Cw(f,x));f=f.next}while(c);sm=!1}}function p_(){Nw()}function Nw(){Ku=nm=!1;var r=0;sa!==0&&k_()&&(r=sa);for(var i=ke(),c=null,f=Gu;f!==null;){var v=f.next,x=kw(f,i);x===0?(f.next=null,c===null?Gu=v:c.next=v,v===null&&(uo=c)):(c=f,(r!==0||(x&3)!==0)&&(Ku=!0)),f=v}hn!==0&&hn!==5||Bl(r),sa!==0&&(sa=0)}function kw(r,i){for(var c=r.suspendedLanes,f=r.pingedLanes,v=r.expirationTimes,x=r.pendingLanes&-62914561;0<x;){var C=31-lt(x),D=1<<C,Y=v[C];Y===-1?((D&c)===0||(D&f)!==0)&&(v[C]=Mi(D,i)):Y<=i&&(r.expiredLanes|=D),x&=~D}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&&ie(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&&ie(f),mn(c)){case 2:case 8:c=Be;break;case 32:c=ze;break;case 268435456:c=kt;break;default:c=ze}return f=Ew.bind(null,r),c=Ve(c,f),r.callbackPriority=i,r.callbackNode=c,i}return f!==null&&f!==null&&ie(f),r.callbackPriority=2,r.callbackNode=null,2}function Ew(r,i){if(hn!==0&&hn!==5)return r.callbackNode=null,r.callbackPriority=0,null;var c=r.callbackNode;if(Yu()&&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:(ow(r,f,i),kw(r,ke()),r.callbackNode!=null&&r.callbackNode===c?Ew.bind(null,r):null)}function Cw(r,i){if(Yu())return null;ow(r,i,!0)}function m_(){C_(function(){(pt&6)!==0?Ve(Se,p_):Nw()})}function rm(){if(sa===0){var r=Gi;r===0&&(r=Wt,Wt<<=1,(Wt&261888)===0&&(Wt=256)),sa=r}return sa}function Tw(r){return r==null||typeof r=="symbol"||typeof r=="boolean"?null:typeof r=="function"?r:ru(""+r)}function Aw(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 g_(r,i,c,f,v){if(i==="submit"&&c&&c.stateNode===v){var x=Tw((v[Hn]||null).action),C=f.submitter;C&&(i=(i=C[Hn]||null)?Tw(i.formAction):C.getAttribute("formAction"),i!==null&&(x=i,C=null));var D=new lu("action","action",null,f,v);r.push({event:D,listeners:[{instance:null,listener:function(){if(f.defaultPrevented){if(sa!==0){var Y=C?Aw(v,C):new FormData(v);Np(c,{pending:!0,data:Y,method:v.method,action:x},null,Y)}}else typeof x=="function"&&(D.preventDefault(),Y=C?Aw(v,C):new FormData(v),Np(c,{pending:!0,data:Y,method:v.method,action:x},x,Y))},currentTarget:v}]})}}for(var am=0;am<Bh.length;am++){var im=Bh[am],v_=im.toLowerCase(),y_=im[0].toUpperCase()+im.slice(1);_s(v_,"on"+y_)}_s(ib,"onAnimationEnd"),_s(ob,"onAnimationIteration"),_s(lb,"onAnimationStart"),_s("dblclick","onDoubleClick"),_s("focusin","onFocus"),_s("focusout","onBlur"),_s(I2,"onTransitionRun"),_s(D2,"onTransitionStart"),_s(P2,"onTransitionCancel"),_s(cb,"onTransitionEnd"),Di("onMouseEnter",["mouseout","mouseover"]),Di("onMouseLeave",["mouseout","mouseover"]),Di("onPointerEnter",["pointerout","pointerover"]),Di("onPointerLeave",["pointerout","pointerover"]),La("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),La("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),La("onBeforeInput",["compositionend","keypress","textInput","paste"]),La("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),La("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),La("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Vl="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(" "),x_=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Vl));function Mw(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 x=void 0;if(i)for(var C=f.length-1;0<=C;C--){var D=f[C],Y=D.instance,ne=D.currentTarget;if(D=D.listener,Y!==x&&v.isPropagationStopped())break e;x=D,v.currentTarget=ne;try{x(v)}catch(oe){du(oe)}v.currentTarget=null,x=Y}else for(C=0;C<f.length;C++){if(D=f[C],Y=D.instance,ne=D.currentTarget,D=D.listener,Y!==x&&v.isPropagationStopped())break e;x=D,v.currentTarget=ne;try{x(v)}catch(oe){du(oe)}v.currentTarget=null,x=Y}}}}function st(r,i){var c=i[xh];c===void 0&&(c=i[xh]=new Set);var f=r+"__bubble";c.has(f)||(Rw(i,r,2,!1),c.add(f))}function om(r,i,c){var f=0;i&&(f|=4),Rw(c,r,f,i)}var Xu="_reactListening"+Math.random().toString(36).slice(2);function lm(r){if(!r[Xu]){r[Xu]=!0,Nx.forEach(function(c){c!=="selectionchange"&&(x_.has(c)||om(c,!1,r),om(c,!0,r))});var i=r.nodeType===9?r:r.ownerDocument;i===null||i[Xu]||(i[Xu]=!0,om("selectionchange",!1,i))}}function Rw(r,i,c,f){switch(i1(i)){case 2:var v=W_;break;case 8:v=Y_;break;default:v=Sm}c=v.bind(null,i,c,r),v=void 0,!Th||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 cm(r,i,c,f,v){var x=f;if((i&1)===0&&(i&2)===0&&f!==null)e:for(;;){if(f===null)return;var C=f.tag;if(C===3||C===4){var D=f.stateNode.containerInfo;if(D===v)break;if(C===4)for(C=f.return;C!==null;){var Y=C.tag;if((Y===3||Y===4)&&C.stateNode.containerInfo===v)return;C=C.return}for(;D!==null;){if(C=_i(D),C===null)return;if(Y=C.tag,Y===5||Y===6||Y===26||Y===27){f=x=C;continue e}D=D.parentNode}}f=f.return}Px(function(){var ne=x,oe=Eh(c),pe=[];e:{var re=ub.get(r);if(re!==void 0){var ae=lu,Re=r;switch(r){case"keypress":if(iu(c)===0)break e;case"keydown":case"keyup":ae=f2;break;case"focusin":Re="focus",ae=_h;break;case"focusout":Re="blur",ae=_h;break;case"beforeblur":case"afterblur":ae=_h;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=$x;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ae=e2;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ae=m2;break;case ib:case ob:case lb:ae=s2;break;case cb:ae=v2;break;case"scroll":case"scrollend":ae=JR;break;case"wheel":ae=x2;break;case"copy":case"cut":case"paste":ae=a2;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ae=Bx;break;case"toggle":case"beforetoggle":ae=w2}var He=(i&4)!==0,St=!He&&(r==="scroll"||r==="scrollend"),Q=He?re!==null?re+"Capture":null:re;He=[];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||Q===null||(fe=ul(K,Q),fe!=null&&He.push(Fl(K,fe,te))),St)break;K=K.return}0<He.length&&(re=new ae(re,Re,null,c,oe),pe.push({event:re,listeners:He}))}}if((i&7)===0){e:{if(re=r==="mouseover"||r==="pointerover",ae=r==="mouseout"||r==="pointerout",re&&c!==kh&&(Re=c.relatedTarget||c.fromElement)&&(_i(Re)||Re[Ri]))break e;if((ae||re)&&(re=oe.window===oe?oe:(re=oe.ownerDocument)?re.defaultView||re.parentWindow:window,ae?(Re=c.relatedTarget||c.toElement,ae=ne,Re=Re?_i(Re):null,Re!==null&&(St=l(Re),He=Re.tag,Re!==St||He!==5&&He!==27&&He!==6)&&(Re=null)):(ae=null,Re=ne),ae!==Re)){if(He=$x,fe="onMouseLeave",Q="onMouseEnter",K="mouse",(r==="pointerout"||r==="pointerover")&&(He=Bx,fe="onPointerLeave",Q="onPointerEnter",K="pointer"),St=ae==null?re:cl(ae),te=Re==null?re:cl(Re),re=new He(fe,K+"leave",ae,c,oe),re.target=St,re.relatedTarget=te,fe=null,_i(oe)===ne&&(He=new He(Q,K+"enter",Re,c,oe),He.target=te,He.relatedTarget=St,fe=He),St=fe,ae&&Re)t:{for(He=b_,Q=ae,K=Re,te=0,fe=Q;fe;fe=He(fe))te++;fe=0;for(var Ue=K;Ue;Ue=He(Ue))fe++;for(;0<te-fe;)Q=He(Q),te--;for(;0<fe-te;)K=He(K),fe--;for(;te--;){if(Q===K||K!==null&&Q===K.alternate){He=Q;break t}Q=He(Q),K=He(K)}He=null}else He=null;ae!==null&&_w(pe,re,ae,He,!1),Re!==null&&St!==null&&_w(pe,St,Re,He,!0)}}e:{if(re=ne?cl(ne):window,ae=re.nodeName&&re.nodeName.toLowerCase(),ae==="select"||ae==="input"&&re.type==="file")var ft=Gx;else if(Wx(re))if(Kx)ft=R2;else{ft=A2;var Ie=T2}else ae=re.nodeName,!ae||ae.toLowerCase()!=="input"||re.type!=="checkbox"&&re.type!=="radio"?ne&&Nh(ne.elementType)&&(ft=Gx):ft=M2;if(ft&&(ft=ft(r,ne))){Yx(pe,ft,c,oe);break e}Ie&&Ie(r,re,ne),r==="focusout"&&ne&&re.type==="number"&&ne.memoizedProps.value!=null&&Sh(re,"number",re.value)}switch(Ie=ne?cl(ne):window,r){case"focusin":(Wx(Ie)||Ie.contentEditable==="true")&&(Bi=Ie,Lh=ne,yl=null);break;case"focusout":yl=Lh=Bi=null;break;case"mousedown":$h=!0;break;case"contextmenu":case"mouseup":case"dragend":$h=!1,rb(pe,c,oe);break;case"selectionchange":if(O2)break;case"keydown":case"keyup":rb(pe,c,oe)}var Qe;if(Ih)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 Ui?qx(r,c)&&(ot="onCompositionEnd"):r==="keydown"&&c.keyCode===229&&(ot="onCompositionStart");ot&&(Vx&&c.locale!=="ko"&&(Ui||ot!=="onCompositionStart"?ot==="onCompositionEnd"&&Ui&&(Qe=zx()):(Br=oe,Ah="value"in Br?Br.value:Br.textContent,Ui=!0)),Ie=Ju(ne,ot),0<Ie.length&&(ot=new Ux(ot,r,null,c,oe),pe.push({event:ot,listeners:Ie}),Qe?ot.data=Qe:(Qe=Zx(c),Qe!==null&&(ot.data=Qe)))),(Qe=S2?N2(r,c):k2(r,c))&&(ot=Ju(ne,"onBeforeInput"),0<ot.length&&(Ie=new Ux("onBeforeInput","beforeinput",null,c,oe),pe.push({event:Ie,listeners:ot}),Ie.data=Qe)),g_(pe,r,ne,c,oe)}Mw(pe,i)})}function Fl(r,i,c){return{instance:r,listener:i,currentTarget:c}}function Ju(r,i){for(var c=i+"Capture",f=[];r!==null;){var v=r,x=v.stateNode;if(v=v.tag,v!==5&&v!==26&&v!==27||x===null||(v=ul(r,c),v!=null&&f.unshift(Fl(r,v,x)),v=ul(r,i),v!=null&&f.push(Fl(r,v,x))),r.tag===3)return f;r=r.return}return[]}function b_(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 x=i._reactName,C=[];c!==null&&c!==f;){var D=c,Y=D.alternate,ne=D.stateNode;if(D=D.tag,Y!==null&&Y===f)break;D!==5&&D!==26&&D!==27||ne===null||(Y=ne,v?(ne=ul(c,x),ne!=null&&C.unshift(Fl(c,ne,Y))):v||(ne=ul(c,x),ne!=null&&C.push(Fl(c,ne,Y)))),c=c.return}C.length!==0&&r.push({event:i,listeners:C})}var w_=/\r\n?/g,j_=/\u0000|\uFFFD/g;function Ow(r){return(typeof r=="string"?r:""+r).replace(w_,`
|
|
9
|
-
`).replace(j_,"")}function Iw(r,i){return i=Ow(i),Ow(r)===i}function jt(r,i,c,f,v,x){switch(c){case"children":typeof f=="string"?i==="body"||i==="textarea"&&f===""||zi(r,f):(typeof f=="number"||typeof f=="bigint")&&i!=="body"&&zi(r,""+f);break;case"className":nu(r,"class",f);break;case"tabIndex":nu(r,"tabindex",f);break;case"dir":case"role":case"viewBox":case"width":case"height":nu(r,c,f);break;case"style":Ix(r,f,x);break;case"data":if(i!=="object"){nu(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=ru(""+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 x=="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=ru(""+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=ru(""+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),tu(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":tu(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=KR.get(c)||c,tu(r,c,f))}}function um(r,i,c,f,v,x){switch(c){case"style":Ix(r,f,x);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"?zi(r,f):(typeof f=="number"||typeof f=="bigint")&&zi(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(!kx.hasOwnProperty(c))e:{if(c[0]==="o"&&c[1]==="n"&&(v=c.endsWith("Capture"),i=c.slice(2,v?c.length-7:void 0),x=r[Hn]||null,x=x!=null?x[c]:null,typeof x=="function"&&r.removeEventListener(i,x,v),typeof f=="function")){typeof x!="function"&&x!==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,""):tu(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,x;for(x in c)if(c.hasOwnProperty(x)){var C=c[x];if(C!=null)switch(x){case"src":f=!0;break;case"srcSet":v=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,i));default:jt(r,i,x,C,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 D=x=C=v=null,Y=null,ne=null;for(f in c)if(c.hasOwnProperty(f)){var oe=c[f];if(oe!=null)switch(f){case"name":v=oe;break;case"type":C=oe;break;case"checked":Y=oe;break;case"defaultChecked":ne=oe;break;case"value":x=oe;break;case"defaultValue":D=oe;break;case"children":case"dangerouslySetInnerHTML":if(oe!=null)throw Error(s(137,i));break;default:jt(r,i,f,oe,c,null)}}Mx(r,x,D,Y,ne,C,v,!1);return;case"select":st("invalid",r),f=C=x=null;for(v in c)if(c.hasOwnProperty(v)&&(D=c[v],D!=null))switch(v){case"value":x=D;break;case"defaultValue":C=D;break;case"multiple":f=D;default:jt(r,i,v,D,c,null)}i=x,c=C,r.multiple=!!f,i!=null?Pi(r,!!f,i,!1):c!=null&&Pi(r,!!f,c,!0);return;case"textarea":st("invalid",r),x=v=f=null;for(C in c)if(c.hasOwnProperty(C)&&(D=c[C],D!=null))switch(C){case"value":f=D;break;case"defaultValue":v=D;break;case"children":x=D;break;case"dangerouslySetInnerHTML":if(D!=null)throw Error(s(91));break;default:jt(r,i,C,D,c,null)}_x(r,f,v,x);return;case"option":for(Y in c)c.hasOwnProperty(Y)&&(f=c[Y],f!=null)&&(Y==="selected"?r.selected=f&&typeof f!="function"&&typeof f!="symbol":jt(r,i,Y,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<Vl.length;f++)st(Vl[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(Nh(i)){for(oe in c)c.hasOwnProperty(oe)&&(f=c[oe],f!==void 0&&um(r,i,oe,f,c,void 0));return}}for(D in c)c.hasOwnProperty(D)&&(f=c[D],f!=null&&jt(r,i,D,f,c,null))}function S_(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,x=null,C=null,D=null,Y=null,ne=null,oe=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":Y=pe;default:f.hasOwnProperty(ae)||jt(r,i,ae,null,f,pe)}}for(var re in f){var ae=f[re];if(pe=c[re],f.hasOwnProperty(re)&&(ae!=null||pe!=null))switch(re){case"type":x=ae;break;case"name":v=ae;break;case"checked":ne=ae;break;case"defaultChecked":oe=ae;break;case"value":C=ae;break;case"defaultValue":D=ae;break;case"children":case"dangerouslySetInnerHTML":if(ae!=null)throw Error(s(137,i));break;default:ae!==pe&&jt(r,i,re,ae,f,pe)}}jh(r,C,D,Y,ne,oe,x,v);return;case"select":ae=C=D=re=null;for(x in c)if(Y=c[x],c.hasOwnProperty(x)&&Y!=null)switch(x){case"value":break;case"multiple":ae=Y;default:f.hasOwnProperty(x)||jt(r,i,x,null,f,Y)}for(v in f)if(x=f[v],Y=c[v],f.hasOwnProperty(v)&&(x!=null||Y!=null))switch(v){case"value":re=x;break;case"defaultValue":D=x;break;case"multiple":C=x;default:x!==Y&&jt(r,i,v,x,f,Y)}i=D,c=C,f=ae,re!=null?Pi(r,!!c,re,!1):!!f!=!!c&&(i!=null?Pi(r,!!c,i,!0):Pi(r,!!c,c?[]:"",!1));return;case"textarea":ae=re=null;for(D in c)if(v=c[D],c.hasOwnProperty(D)&&v!=null&&!f.hasOwnProperty(D))switch(D){case"value":break;case"children":break;default:jt(r,i,D,null,f,v)}for(C in f)if(v=f[C],x=c[C],f.hasOwnProperty(C)&&(v!=null||x!=null))switch(C){case"value":re=v;break;case"defaultValue":ae=v;break;case"children":break;case"dangerouslySetInnerHTML":if(v!=null)throw Error(s(91));break;default:v!==x&&jt(r,i,C,v,f,x)}Rx(r,re,ae);return;case"option":for(var Re in c)re=c[Re],c.hasOwnProperty(Re)&&re!=null&&!f.hasOwnProperty(Re)&&(Re==="selected"?r.selected=!1:jt(r,i,Re,null,f,re));for(Y in f)re=f[Y],ae=c[Y],f.hasOwnProperty(Y)&&re!==ae&&(re!=null||ae!=null)&&(Y==="selected"?r.selected=re&&typeof re!="function"&&typeof re!="symbol":jt(r,i,Y,re,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 He in c)re=c[He],c.hasOwnProperty(He)&&re!=null&&!f.hasOwnProperty(He)&&jt(r,i,He,null,f,re);for(ne in f)if(re=f[ne],ae=c[ne],f.hasOwnProperty(ne)&&re!==ae&&(re!=null||ae!=null))switch(ne){case"children":case"dangerouslySetInnerHTML":if(re!=null)throw Error(s(137,i));break;default:jt(r,i,ne,re,f,ae)}return;default:if(Nh(i)){for(var St in c)re=c[St],c.hasOwnProperty(St)&&re!==void 0&&!f.hasOwnProperty(St)&&um(r,i,St,void 0,f,re);for(oe in f)re=f[oe],ae=c[oe],!f.hasOwnProperty(oe)||re===ae||re===void 0&&ae===void 0||um(r,i,oe,re,f,ae);return}}for(var Q in c)re=c[Q],c.hasOwnProperty(Q)&&re!=null&&!f.hasOwnProperty(Q)&&jt(r,i,Q,null,f,re);for(pe in f)re=f[pe],ae=c[pe],!f.hasOwnProperty(pe)||re===ae||re==null&&ae==null||jt(r,i,pe,re,f,ae)}function Dw(r){switch(r){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function N_(){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],x=v.transferSize,C=v.initiatorType,D=v.duration;if(x&&D&&Dw(C)){for(C=0,D=v.responseEnd,f+=1;f<c.length;f++){var Y=c[f],ne=Y.startTime;if(ne>D)break;var oe=Y.transferSize,pe=Y.initiatorType;oe&&Dw(pe)&&(Y=Y.responseEnd,C+=oe*(Y<D?1:(D-ne)/(Y-ne)))}if(--f,i+=8*(x+C)/(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 dm=null,fm=null;function Qu(r){return r.nodeType===9?r:r.ownerDocument}function Pw(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 zw(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 hm(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 pm=null;function k_(){var r=window.event;return r&&r.type==="popstate"?r===pm?!1:(pm=r,!0):(pm=null,!1)}var Lw=typeof setTimeout=="function"?setTimeout:void 0,E_=typeof clearTimeout=="function"?clearTimeout:void 0,$w=typeof Promise=="function"?Promise:void 0,C_=typeof queueMicrotask=="function"?queueMicrotask:typeof $w<"u"?function(r){return $w.resolve(null).then(r).catch(T_)}:Lw;function T_(r){setTimeout(function(){throw r})}function ra(r){return r==="head"}function Uw(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),mo(i);return}f--}else if(c==="$"||c==="$?"||c==="$~"||c==="$!"||c==="&")f++;else if(c==="html")Hl(r.ownerDocument.documentElement);else if(c==="head"){c=r.ownerDocument.head,Hl(c);for(var x=c.firstChild;x;){var C=x.nextSibling,D=x.nodeName;x[ll]||D==="SCRIPT"||D==="STYLE"||D==="LINK"&&x.rel.toLowerCase()==="stylesheet"||c.removeChild(x),x=C}}else c==="body"&&Hl(r.ownerDocument.body);c=v}while(c);mo(i)}function Bw(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 mm(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":mm(c),bh(c);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(c.rel.toLowerCase()==="stylesheet")continue}r.removeChild(c)}}function A_(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[ll])switch(i){case"meta":if(!r.hasAttribute("itemprop"))break;return r;case"link":if(x=r.getAttribute("rel"),x==="stylesheet"&&r.hasAttribute("data-precedence"))break;if(x!==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(x=r.getAttribute("src"),(x!==(v.src==null?null:v.src)||r.getAttribute("type")!==(v.type==null?null:v.type)||r.getAttribute("crossorigin")!==(v.crossOrigin==null?null:v.crossOrigin))&&x&&r.hasAttribute("async")&&!r.hasAttribute("itemprop"))break;return r;default:return r}}else if(i==="input"&&r.type==="hidden"){var x=v.name==null?null:""+v.name;if(v.type==="hidden"&&r.getAttribute("name")===x)return r}else return r;if(r=js(r.nextSibling),r===null)break}return null}function M_(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 Vw(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 gm(r){return r.data==="$?"||r.data==="$~"}function vm(r){return r.data==="$!"||r.data==="$?"&&r.ownerDocument.readyState!=="loading"}function R_(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 ym=null;function Fw(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 Hw(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 qw(r,i,c){switch(i=Qu(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 Hl(r){for(var i=r.attributes;i.length;)r.removeAttributeNode(i[0]);bh(r)}var Ss=new Map,Zw=new Set;function ed(r){return typeof r.getRootNode=="function"?r.getRootNode():r.nodeType===9?r:r.ownerDocument}var Mr=z.d;z.d={f:__,r:O_,D:I_,C:D_,L:P_,m:z_,X:$_,S:L_,M:U_};function __(){var r=Mr.f(),i=qu();return r||i}function O_(r){var i=Oi(r);i!==null&&i.tag===5&&i.type==="form"?c0(i):Mr.r(r)}var fo=typeof document>"u"?null:document;function Ww(r,i,c){var f=fo;if(f&&typeof i=="string"&&i){var v=ms(i);v='link[rel="'+r+'"][href="'+v+'"]',typeof c=="string"&&(v+='[crossorigin="'+c+'"]'),Zw.has(v)||(Zw.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 I_(r){Mr.D(r),Ww("dns-prefetch",r,null)}function D_(r,i){Mr.C(r,i),Ww("preconnect",r,i)}function P_(r,i,c){Mr.L(r,i,c);var f=fo;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 x=v;switch(i){case"style":x=ho(r);break;case"script":x=po(r)}Ss.has(x)||(r=y({rel:"preload",href:i==="image"&&c&&c.imageSrcSet?void 0:r,as:i},c),Ss.set(x,r),f.querySelector(v)!==null||i==="style"&&f.querySelector(ql(x))||i==="script"&&f.querySelector(Zl(x))||(i=f.createElement("link"),kn(i,"link",r),gn(i),f.head.appendChild(i)))}}function z_(r,i){Mr.m(r,i);var c=fo;if(c&&r){var f=i&&typeof i.as=="string"?i.as:"script",v='link[rel="modulepreload"][as="'+ms(f)+'"][href="'+ms(r)+'"]',x=v;switch(f){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":x=po(r)}if(!Ss.has(x)&&(r=y({rel:"modulepreload",href:r},i),Ss.set(x,r),c.querySelector(v)===null)){switch(f){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(c.querySelector(Zl(x)))return}f=c.createElement("link"),kn(f,"link",r),gn(f),c.head.appendChild(f)}}}function L_(r,i,c){Mr.S(r,i,c);var f=fo;if(f&&r){var v=Ii(f).hoistableStyles,x=ho(r);i=i||"default";var C=v.get(x);if(!C){var D={loading:0,preload:null};if(C=f.querySelector(ql(x)))D.loading=5;else{r=y({rel:"stylesheet",href:r,"data-precedence":i},c),(c=Ss.get(x))&&xm(r,c);var Y=C=f.createElement("link");gn(Y),kn(Y,"link",r),Y._p=new Promise(function(ne,oe){Y.onload=ne,Y.onerror=oe}),Y.addEventListener("load",function(){D.loading|=1}),Y.addEventListener("error",function(){D.loading|=2}),D.loading|=4,td(C,i,f)}C={type:"stylesheet",instance:C,count:1,state:D},v.set(x,C)}}}function $_(r,i){Mr.X(r,i);var c=fo;if(c&&r){var f=Ii(c).hoistableScripts,v=po(r),x=f.get(v);x||(x=c.querySelector(Zl(v)),x||(r=y({src:r,async:!0},i),(i=Ss.get(v))&&bm(r,i),x=c.createElement("script"),gn(x),kn(x,"link",r),c.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},f.set(v,x))}}function U_(r,i){Mr.M(r,i);var c=fo;if(c&&r){var f=Ii(c).hoistableScripts,v=po(r),x=f.get(v);x||(x=c.querySelector(Zl(v)),x||(r=y({src:r,async:!0,type:"module"},i),(i=Ss.get(v))&&bm(r,i),x=c.createElement("script"),gn(x),kn(x,"link",r),c.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},f.set(v,x))}}function Yw(r,i,c,f){var v=(v=se.current)?ed(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=ho(c.href),c=Ii(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=ho(c.href);var x=Ii(v).hoistableStyles,C=x.get(r);if(C||(v=v.ownerDocument||v,C={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},x.set(r,C),(x=v.querySelector(ql(r)))&&!x._p&&(C.instance=x,C.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),x||B_(v,r,c,C.state))),i&&f===null)throw Error(s(528,""));return C}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=po(c),c=Ii(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 ho(r){return'href="'+ms(r)+'"'}function ql(r){return'link[rel="stylesheet"]['+r+"]"}function Gw(r){return y({},r,{"data-precedence":r.precedence,precedence:null})}function B_(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 po(r){return'[src="'+ms(r)+'"]'}function Zl(r){return"script[async]"+r}function Kw(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),td(f,c.precedence,r),i.instance=f;case"stylesheet":v=ho(c.href);var x=r.querySelector(ql(v));if(x)return i.state.loading|=4,i.instance=x,gn(x),x;f=Gw(c),(v=Ss.get(v))&&xm(f,v),x=(r.ownerDocument||r).createElement("link"),gn(x);var C=x;return C._p=new Promise(function(D,Y){C.onload=D,C.onerror=Y}),kn(x,"link",f),i.state.loading|=4,td(x,c.precedence,r),i.instance=x;case"script":return x=po(c.src),(v=r.querySelector(Zl(x)))?(i.instance=v,gn(v),v):(f=c,(v=Ss.get(x))&&(f=y({},c),bm(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,td(f,c.precedence,r));return i.instance}function td(r,i,c){for(var f=c.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),v=f.length?f[f.length-1]:null,x=v,C=0;C<f.length;C++){var D=f[C];if(D.dataset.precedence===i)x=D;else if(x!==v)break}x?x.parentNode.insertBefore(r,x.nextSibling):(i=c.nodeType===9?c.head:c,i.insertBefore(r,i.firstChild))}function xm(r,i){r.crossOrigin==null&&(r.crossOrigin=i.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=i.referrerPolicy),r.title==null&&(r.title=i.title)}function bm(r,i){r.crossOrigin==null&&(r.crossOrigin=i.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=i.referrerPolicy),r.integrity==null&&(r.integrity=i.integrity)}var nd=null;function Xw(r,i,c){if(nd===null){var f=new Map,v=nd=new Map;v.set(c,f)}else v=nd,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 x=c[v];if(!(x[ll]||x[wn]||r==="link"&&x.getAttribute("rel")==="stylesheet")&&x.namespaceURI!=="http://www.w3.org/2000/svg"){var C=x.getAttribute(i)||"";C=r+C;var D=f.get(C);D?D.push(x):f.set(C,[x])}}return f}function Jw(r,i,c){r=r.ownerDocument||r,r.head.insertBefore(c,i==="title"?r.querySelector("head > title"):null)}function V_(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 Qw(r){return!(r.type==="stylesheet"&&(r.state.loading&3)===0)}function F_(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=ho(f.href),x=i.querySelector(ql(v));if(x){i=x._p,i!==null&&typeof i=="object"&&typeof i.then=="function"&&(r.count++,r=sd.bind(r),i.then(r,r)),c.state.loading|=4,c.instance=x,gn(x);return}x=i.ownerDocument||i,f=Gw(f),(v=Ss.get(v))&&xm(f,v),x=x.createElement("link"),gn(x);var C=x;C._p=new Promise(function(D,Y){C.onload=D,C.onerror=Y}),kn(x,"link",f),c.instance=x}r.stylesheets===null&&(r.stylesheets=new Map),r.stylesheets.set(c,i),(i=c.state.preload)&&(c.state.loading&3)===0&&(r.count++,c=sd.bind(r),i.addEventListener("load",c),i.addEventListener("error",c))}}var wm=0;function H_(r,i){return r.stylesheets&&r.count===0&&ad(r,r.stylesheets),0<r.count||0<r.imgCount?function(c){var f=setTimeout(function(){if(r.stylesheets&&ad(r,r.stylesheets),r.unsuspend){var x=r.unsuspend;r.unsuspend=null,x()}},6e4+i);0<r.imgBytes&&wm===0&&(wm=62500*N_());var v=setTimeout(function(){if(r.waitingForImages=!1,r.count===0&&(r.stylesheets&&ad(r,r.stylesheets),r.unsuspend)){var x=r.unsuspend;r.unsuspend=null,x()}},(r.imgBytes>wm?50:800)+i);return r.unsuspend=c,function(){r.unsuspend=null,clearTimeout(f),clearTimeout(v)}}:null}function sd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ad(this,this.stylesheets);else if(this.unsuspend){var r=this.unsuspend;this.unsuspend=null,r()}}}var rd=null;function ad(r,i){r.stylesheets=null,r.unsuspend!==null&&(r.count++,rd=new Map,i.forEach(q_,r),rd=null,sd.call(r))}function q_(r,i){if(!(i.state.loading&4)){var c=rd.get(r);if(c)var f=c.get(null);else{c=new Map,rd.set(r,c);for(var v=r.querySelectorAll("link[data-precedence],style[data-precedence]"),x=0;x<v.length;x++){var C=v[x];(C.nodeName==="LINK"||C.getAttribute("media")!=="not all")&&(c.set(C.dataset.precedence,C),f=C)}f&&c.set(null,f)}v=i.instance,C=v.getAttribute("data-precedence"),x=c.get(C)||f,x===f&&c.set(null,v),c.set(C,v),this.count++,f=sd.bind(this),v.addEventListener("load",f),v.addEventListener("error",f),x?x.parentNode.insertBefore(v,x.nextSibling):(r=r.nodeType===9?r.head:r,r.insertBefore(v,r.firstChild)),i.state.loading|=4}}var Wl={$$typeof:S,Provider:null,Consumer:null,_currentValue:B,_currentValue2:B,_threadCount:0};function Z_(r,i,c,f,v,x,C,D,Y){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=x,this.onRecoverableError=C,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Y,this.incompleteTransitions=new Map}function e1(r,i,c,f,v,x,C,D,Y,ne,oe,pe){return r=new Z_(r,i,c,C,Y,ne,oe,pe,D),i=1,x===!0&&(i|=24),x=ss(3,null,null,i),r.current=x,x.stateNode=r,i=ep(),i.refCount++,r.pooledCache=i,i.refCount++,x.memoizedState={element:f,isDehydrated:c,cache:i},rp(x),r}function t1(r){return r?(r=Hi,r):Hi}function n1(r,i,c,f,v,x){v=t1(v),f.context===null?f.context=v:f.pendingContext=v,f=Wr(i),f.payload={element:c},x=x===void 0?null:x,x!==null&&(f.callback=x),c=Yr(r,f,i),c!==null&&(Kn(c,r,i),kl(c,r,i))}function s1(r,i){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var c=r.retryLane;r.retryLane=c!==0&&c<i?c:i}}function jm(r,i){s1(r,i),(r=r.alternate)&&s1(r,i)}function r1(r){if(r.tag===13||r.tag===31){var i=Va(r,67108864);i!==null&&Kn(i,r,67108864),jm(r,67108864)}}function a1(r){if(r.tag===13||r.tag===31){var i=ls();i=Et(i);var c=Va(r,i);c!==null&&Kn(c,r,i),jm(r,i)}}var id=!0;function W_(r,i,c,f){var v=L.T;L.T=null;var x=z.p;try{z.p=2,Sm(r,i,c,f)}finally{z.p=x,L.T=v}}function Y_(r,i,c,f){var v=L.T;L.T=null;var x=z.p;try{z.p=8,Sm(r,i,c,f)}finally{z.p=x,L.T=v}}function Sm(r,i,c,f){if(id){var v=Nm(f);if(v===null)cm(r,i,f,od,c),o1(r,f);else if(K_(v,r,i,c,f))f.stopPropagation();else if(o1(r,f),i&4&&-1<G_.indexOf(r)){for(;v!==null;){var x=Oi(v);if(x!==null)switch(x.tag){case 3:if(x=x.stateNode,x.current.memoizedState.isDehydrated){var C=fn(x.pendingLanes);if(C!==0){var D=x;for(D.pendingLanes|=2,D.entangledLanes|=2;C;){var Y=1<<31-lt(C);D.entanglements[1]|=Y,C&=~Y}Xs(x),(pt&6)===0&&(Fu=ke()+500,Bl(0))}}break;case 31:case 13:D=Va(x,2),D!==null&&Kn(D,x,2),qu(),jm(x,2)}if(x=Nm(f),x===null&&cm(r,i,f,od,c),x===v)break;v=x}v!==null&&f.stopPropagation()}else cm(r,i,f,null,c)}}function Nm(r){return r=Eh(r),km(r)}var od=null;function km(r){if(od=null,r=_i(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 od=r,null}function i1(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(Ee()){case Se:return 2;case Be:return 8;case ze:case bt:return 32;case kt:return 268435456;default:return 32}default:return 32}}var Em=!1,aa=null,ia=null,oa=null,Yl=new Map,Gl=new Map,la=[],G_="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 o1(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":Yl.delete(i.pointerId);break;case"gotpointercapture":case"lostpointercapture":Gl.delete(i.pointerId)}}function Kl(r,i,c,f,v,x){return r===null||r.nativeEvent!==x?(r={blockedOn:i,domEventName:c,eventSystemFlags:f,nativeEvent:x,targetContainers:[v]},i!==null&&(i=Oi(i),i!==null&&r1(i)),r):(r.eventSystemFlags|=f,i=r.targetContainers,v!==null&&i.indexOf(v)===-1&&i.push(v),r)}function K_(r,i,c,f,v){switch(i){case"focusin":return aa=Kl(aa,r,i,c,f,v),!0;case"dragenter":return ia=Kl(ia,r,i,c,f,v),!0;case"mouseover":return oa=Kl(oa,r,i,c,f,v),!0;case"pointerover":var x=v.pointerId;return Yl.set(x,Kl(Yl.get(x)||null,r,i,c,f,v)),!0;case"gotpointercapture":return x=v.pointerId,Gl.set(x,Kl(Gl.get(x)||null,r,i,c,f,v)),!0}return!1}function l1(r){var i=_i(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(){a1(c)});return}}else if(i===31){if(i=d(c),i!==null){r.blockedOn=i,Ws(r.priority,function(){a1(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 ld(r){if(r.blockedOn!==null)return!1;for(var i=r.targetContainers;0<i.length;){var c=Nm(r.nativeEvent);if(c===null){c=r.nativeEvent;var f=new c.constructor(c.type,c);kh=f,c.target.dispatchEvent(f),kh=null}else return i=Oi(c),i!==null&&r1(i),r.blockedOn=c,!1;i.shift()}return!0}function c1(r,i,c){ld(r)&&c.delete(i)}function X_(){Em=!1,aa!==null&&ld(aa)&&(aa=null),ia!==null&&ld(ia)&&(ia=null),oa!==null&&ld(oa)&&(oa=null),Yl.forEach(c1),Gl.forEach(c1)}function cd(r,i){r.blockedOn===i&&(r.blockedOn=null,Em||(Em=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,X_)))}var ud=null;function u1(r){ud!==r&&(ud=r,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){ud===r&&(ud=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(km(f||c)===null)continue;break}var x=Oi(c);x!==null&&(r.splice(i,3),i-=3,Np(x,{pending:!0,data:v,method:c.method,action:f},f,v))}}))}function mo(r){function i(Y){return cd(Y,r)}aa!==null&&cd(aa,r),ia!==null&&cd(ia,r),oa!==null&&cd(oa,r),Yl.forEach(i),Gl.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);)l1(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],x=c[f+1],C=v[Hn]||null;if(typeof x=="function")C||u1(c);else if(C){var D=null;if(x&&x.hasAttribute("formAction")){if(v=x,C=x[Hn]||null)D=C.formAction;else if(km(v)!==null)continue}else D=C.action;typeof D=="function"?c[f+1]=D:(c.splice(f,3),f-=3),u1(c)}}}function d1(){function r(x){x.canIntercept&&x.info==="react-transition"&&x.intercept({handler:function(){return new Promise(function(C){return v=C})},focusReset:"manual",scroll:"manual"})}function i(){v!==null&&(v(),v=null),f||setTimeout(c,20)}function c(){if(!f&&!navigation.transition){var x=navigation.currentEntry;x&&x.url!=null&&navigation.navigate(x.url,{state:x.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 Cm(r){this._internalRoot=r}dd.prototype.render=Cm.prototype.render=function(r){var i=this._internalRoot;if(i===null)throw Error(s(409));var c=i.current,f=ls();n1(c,f,r,i,null,null)},dd.prototype.unmount=Cm.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var i=r.containerInfo;n1(r.current,2,null,r,null,null),qu(),i[Ri]=null}};function dd(r){this._internalRoot=r}dd.prototype.unstable_scheduleHydration=function(r){if(r){var i=bn();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&&l1(r)}};var f1=t.version;if(f1!=="19.2.3")throw Error(s(527,f1,"19.2.3"));z.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 J_={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:L,reconcilerVersion:"19.2.3"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var fd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!fd.isDisabled&&fd.supportsFiber)try{Jt=fd.inject(J_),$e=fd}catch{}}return Jl.createRoot=function(r,i){if(!a(r))throw Error(s(299));var c=!1,f="",v=x0,x=b0,C=w0;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&&(x=i.onCaughtError),i.onRecoverableError!==void 0&&(C=i.onRecoverableError)),i=e1(r,1,!1,null,null,c,f,null,v,x,C,d1),r[Ri]=i.current,lm(r),new Cm(i)},Jl.hydrateRoot=function(r,i,c){if(!a(r))throw Error(s(299));var f=!1,v="",x=x0,C=b0,D=w0,Y=null;return c!=null&&(c.unstable_strictMode===!0&&(f=!0),c.identifierPrefix!==void 0&&(v=c.identifierPrefix),c.onUncaughtError!==void 0&&(x=c.onUncaughtError),c.onCaughtError!==void 0&&(C=c.onCaughtError),c.onRecoverableError!==void 0&&(D=c.onRecoverableError),c.formState!==void 0&&(Y=c.formState)),i=e1(r,1,!0,i,c??null,f,v,Y,x,C,D,d1),i.context=t1(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,xe(i,c),Xs(i),r[Ri]=i.current,lm(r),new dd(i)},Jl.version="19.2.3",Jl}var j1;function lO(){if(j1)return Mm.exports;j1=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(),Mm.exports=oO(),Mm.exports}var cO=lO();const Ck=(...e)=>e.filter((t,n,s)=>!!t&&t.trim()!==""&&s.indexOf(t)===n).join(" ").trim();const uO=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const dO=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,s)=>s?s.toUpperCase():n.toLowerCase());const S1=e=>{const t=dO(e);return t.charAt(0).toUpperCase()+t.slice(1)};var fO={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 hO=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const pO=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,...fO,width:t,height:t,stroke:e,strokeWidth:s?Number(n)*24/Number(t):n,className:Ck("lucide",a),...!l&&!hO(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(pO,{ref:l,iconNode:t,className:Ck(`lucide-${uO(S1(e))}`,`lucide-${e}`,s),...a}));return n.displayName=S1(e),n};const mO=[["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"}]],gO=yn("bot",mO);const vO=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],yO=yn("chevron-down",vO);const xO=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],bO=yn("chevron-right",xO);const wO=[["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"}]],Tk=yn("compass",wO);const jO=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],pc=yn("loader-circle",jO);const SO=[["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"}]],NO=yn("map",SO);const kO=[["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"}]],EO=yn("mic",kO);const CO=[["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"}]],TO=yn("radio",CO);const AO=[["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"}]],Ak=yn("refresh-cw",AO);const MO=[["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"}]],N1=yn("rocket",MO);const RO=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],_O=yn("search",RO);const OO=[["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"}]],Mk=yn("settings",OO);const IO=[["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"}]],DO=yn("sliders-horizontal",IO);const PO=[["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"}]],zO=yn("sparkles",PO);const LO=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],$O=yn("square",LO);const UO=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],BO=yn("terminal",UO);const VO=[["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"}]],FO=yn("volume-2",VO);const HO=[["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"}]],qO=yn("volume-x",HO);function ZO(e){try{const t=localStorage.getItem(e);if(t)return JSON.parse(t)}catch{}}function WO(e,t){try{localStorage.setItem(e,JSON.stringify(t)),window.dispatchEvent(new CustomEvent("hudson:saved",{detail:{key:e}}))}catch{}}const YO=()=>()=>{},GO=()=>!0,KO=()=>!1;function XO(){return g.useSyncExternalStore(YO,GO,KO)}function Ir(e,t){const n=XO(),[s,a]=g.useState(t),l=g.useRef(!1);if(n&&!l.current){l.current=!0;const u=ZO(e);u!==void 0&&a(u)}return g.useEffect(()=>{n&&WO(e,s)},[e,s,n]),[s,a]}var Rk="vercel.ai.error",JO=Symbol.for(Rk),k1,E1,lr=class _k extends(E1=Error,k1=JO,E1){constructor({name:t,message:n,cause:s}){super(n),this[k1]=!0,this.name=t,this.cause=s}static isInstance(t){return _k.hasMarker(t,Rk)}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 Ok(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var Ik="AI_InvalidArgumentError",Dk=`vercel.ai.error.${Ik}`,QO=Symbol.for(Dk),C1,T1,eI=class extends(T1=lr,C1=QO,T1){constructor({message:e,cause:t,argument:n}){super({name:Ik,message:e,cause:t}),this[C1]=!0,this.argument=n}static isInstance(e){return lr.hasMarker(e,Dk)}},Pk="AI_JSONParseError",zk=`vercel.ai.error.${Pk}`,tI=Symbol.for(zk),A1,M1,R1=class extends(M1=lr,A1=tI,M1){constructor({text:e,cause:t}){super({name:Pk,message:`JSON parsing failed: Text: ${e}.
|
|
10
|
-
Error message: ${Ok(t)}`,cause:t}),this[A1]=!0,this.text=e}static isInstance(e){return lr.hasMarker(e,zk)}},Lk="AI_TypeValidationError",$k=`vercel.ai.error.${Lk}`,nI=Symbol.for($k),_1,O1,Wo=class Vg extends(O1=lr,_1=nI,O1){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:Lk,message:`${a}: Value: ${JSON.stringify(t)}.
|
|
11
|
-
Error message: ${Ok(n)}`,cause:n}),this[_1]=!0,this.value=t,this.context=s}static isInstance(t){return lr.hasMarker(t,$k)}static wrap({value:t,cause:n,context:s}){var a,l,u;return Vg.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 Vg({value:t,cause:n,context:s})}};function le(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 b=m[y];b in d||(d[b]=h[b].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 Vo extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Uk extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Bk={};function Ea(e){return Bk}function Vk(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 Fg(e,t){return typeof t=="bigint"?t.toString():t}function Yf(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Xv(e){return e==null}function Jv(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function sI(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 I1=Symbol("evaluating");function ut(e,t,n){let s;Object.defineProperty(e,t,{get(){if(s!==I1)return s===void 0&&(s=I1,s=n()),s},set(a){Object.defineProperty(e,t,{value:a})},configurable:!0})}function ki(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 D1(e){return JSON.stringify(e)}function rI(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Fk="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function kc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const aI=Yf(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Yo(e){if(kc(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(kc(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Hk(e){return Yo(e)?{...e}:Array.isArray(e)?[...e]:e}const iI=new Set(["string","number","symbol"]);function Go(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ra(e,t,n){const s=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(s._zod.parent=e),s}function De(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 oI(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const lI={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 cI(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 ki(this,"shape",u),u},checks:[]});return Ra(e,l)}function uI(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 ki(this,"shape",u),u},checks:[]});return Ra(e,l)}function dI(e,t){if(!Yo(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 ki(this,"shape",l),l}});return Ra(e,a)}function fI(e,t){if(!Yo(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 ki(this,"shape",s),s}});return Ra(e,n)}function hI(e,t){const n=Ma(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t._zod.def.shape};return ki(this,"shape",s),s},get catchall(){return t._zod.def.catchall},checks:[]});return Ra(e,n)}function pI(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 ki(this,"shape",p),p},checks:[]});return Ra(t,u)}function mI(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 ki(this,"shape",l),l}});return Ra(t,s)}function Io(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 Do(e,t){return t.map(n=>{var s;return(s=n).path??(s.path=[]),n.path.unshift(e),n})}function hd(e){return typeof e=="string"?e:e?.message}function Ca(e,t,n){const s={...e,path:e.path??[]};if(!e.message){const a=hd(e.inst?._zod.def?.error?.(e))??hd(t?.error?.(e))??hd(n.customError?.(e))??hd(n.localeError?.(e))??"Invalid input";s.message=a}return delete s.inst,delete s.continue,t?.reportInput||delete s.input,s}function Qv(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ec(...e){const[t,n,s]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:s}:{...t}}const qk=(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,Fg,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Zk=le("$ZodError",qk),Wk=le("$ZodError",qk,{Parent:Error});function gI(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 vI(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 ey=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 Vo;if(u.issues.length){const d=new(a?.Err??e)(u.issues.map(p=>Ca(p,l,Ea())));throw Fk(d,a?.callee),d}return u.value},ty=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=>Ca(p,l,Ea())));throw Fk(d,a?.callee),d}return u.value},Gf=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 Vo;return l.issues.length?{success:!1,error:new(e??Zk)(l.issues.map(u=>Ca(u,a,Ea())))}:{success:!0,data:l.value}},yI=Gf(Wk),Kf=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=>Ca(u,a,Ea())))}:{success:!0,data:l.value}},xI=Kf(Wk),bI=e=>(t,n,s)=>{const a=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return ey(e)(t,n,a)},wI=e=>(t,n,s)=>ey(e)(t,n,s),jI=e=>async(t,n,s)=>{const a=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return ty(e)(t,n,a)},SI=e=>async(t,n,s)=>ty(e)(t,n,s),NI=e=>(t,n,s)=>{const a=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return Gf(e)(t,n,a)},kI=e=>(t,n,s)=>Gf(e)(t,n,s),EI=e=>async(t,n,s)=>{const a=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return Kf(e)(t,n,a)},CI=e=>async(t,n,s)=>Kf(e)(t,n,s),TI=/^[cC][^\s-]{8,}$/,AI=/^[0-9a-z]+$/,MI=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,RI=/^[0-9a-vA-V]{20}$/,_I=/^[A-Za-z0-9]{27}$/,OI=/^[a-zA-Z0-9_-]{21}$/,II=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,DI=/^([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})$/,P1=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)$/,PI=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,zI="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function LI(){return new RegExp(zI,"u")}const $I=/^(?:(?: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])$/,UI=/^(([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}|:))$/,BI=/^((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])$/,VI=/^(([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])$/,FI=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Yk=/^[A-Za-z0-9_-]*$/,HI=/^\+[1-9]\d{6,14}$/,Gk="(?:(?:\\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])))",qI=new RegExp(`^${Gk}$`);function Kk(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 ZI(e){return new RegExp(`^${Kk(e)}$`)}function WI(e){const t=Kk({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(`^${Gk}T(?:${s})$`)}const YI=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},GI=/^-?\d+$/,Xk=/^-?\d+(?:\.\d+)?$/,KI=/^(?:true|false)$/i,XI=/^null$/i,JI=/^[^A-Z]*$/,QI=/^[^a-z]*$/,ts=le("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Jk={number:"number",bigint:"bigint",object:"date"},Qk=le("$ZodCheckLessThan",(e,t)=>{ts.init(e,t);const n=Jk[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})}}),eE=le("$ZodCheckGreaterThan",(e,t)=>{ts.init(e,t);const n=Jk[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})}}),e5=le("$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):sI(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})}}),t5=le("$ZodCheckNumberFormat",(e,t)=>{ts.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),s=n?"int":"number",[a,l]=lI[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=GI)}),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})}}),n5=le("$ZodCheckMaxLength",(e,t)=>{var n;ts.init(e,t),(n=e._zod.def).when??(n.when=s=>{const a=s.value;return!Xv(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=Qv(a);s.issues.push({origin:u,code:"too_big",maximum:t.maximum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),s5=le("$ZodCheckMinLength",(e,t)=>{var n;ts.init(e,t),(n=e._zod.def).when??(n.when=s=>{const a=s.value;return!Xv(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=Qv(a);s.issues.push({origin:u,code:"too_small",minimum:t.minimum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),r5=le("$ZodCheckLengthEquals",(e,t)=>{var n;ts.init(e,t),(n=e._zod.def).when??(n.when=s=>{const a=s.value;return!Xv(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=Qv(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})}}),Xf=le("$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=()=>{})}),a5=le("$ZodCheckRegex",(e,t)=>{Xf.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})}}),i5=le("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=JI),Xf.init(e,t)}),o5=le("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=QI),Xf.init(e,t)}),l5=le("$ZodCheckIncludes",(e,t)=>{ts.init(e,t);const n=Go(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})}}),c5=le("$ZodCheckStartsWith",(e,t)=>{ts.init(e,t);const n=new RegExp(`^${Go(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})}}),u5=le("$ZodCheckEndsWith",(e,t)=>{ts.init(e,t);const n=new RegExp(`.*${Go(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})}}),d5=le("$ZodCheckOverwrite",(e,t)=>{ts.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class f5{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 h5={major:4,minor:3,patch:6},zt=le("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=h5;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=Io(u),m;for(const y of d){if(y._zod.def.when){if(!y._zod.def.when(u))continue}else if(h)continue;const b=u.issues.length,w=y._zod.check(u);if(w instanceof Promise&&p?.async===!1)throw new Vo;if(m||w instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await w,u.issues.length!==b&&(h||(h=Io(u,b)))});else{if(u.issues.length===b)continue;h||(h=Io(u,b))}}return m?m.then(()=>u):u},l=(u,d,p)=>{if(Io(u))return u.aborted=!0,u;const h=a(d,s,p);if(h instanceof Promise){if(p.async===!1)throw new Vo;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 Vo;return p.then(h=>a(h,s,d))}return a(p,s,d)}}ut(e,"~standard",()=>({validate:a=>{try{const l=yI(e,a);return l.success?{value:l.data}:{issues:l.error?.issues}}catch{return xI(e,a).then(u=>u.success?{value:u.data}:{issues:u.error?.issues})}},vendor:"zod",version:1}))}),ny=le("$ZodString",(e,t)=>{zt.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??YI(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=le("$ZodStringFormat",(e,t)=>{Xf.init(e,t),ny.init(e,t)}),p5=le("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=DI),Ut.init(e,t)}),m5=le("$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=P1(s))}else t.pattern??(t.pattern=P1());Ut.init(e,t)}),g5=le("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=PI),Ut.init(e,t)}),v5=le("$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})}}}),y5=le("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=LI()),Ut.init(e,t)}),x5=le("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=OI),Ut.init(e,t)}),b5=le("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=TI),Ut.init(e,t)}),w5=le("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=AI),Ut.init(e,t)}),j5=le("$ZodULID",(e,t)=>{t.pattern??(t.pattern=MI),Ut.init(e,t)}),S5=le("$ZodXID",(e,t)=>{t.pattern??(t.pattern=RI),Ut.init(e,t)}),N5=le("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=_I),Ut.init(e,t)}),k5=le("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=WI(t)),Ut.init(e,t)}),E5=le("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=qI),Ut.init(e,t)}),C5=le("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=ZI(t)),Ut.init(e,t)}),T5=le("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=II),Ut.init(e,t)}),A5=le("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=$I),Ut.init(e,t),e._zod.bag.format="ipv4"}),M5=le("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=UI),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})}}}),R5=le("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=BI),Ut.init(e,t)}),_5=le("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=VI),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 tE(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const O5=le("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=FI),Ut.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{tE(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function I5(e){if(!Yk.test(e))return!1;const t=e.replace(/[-_]/g,s=>s==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return tE(n)}const D5=le("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Yk),Ut.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{I5(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),P5=le("$ZodE164",(e,t)=>{t.pattern??(t.pattern=HI),Ut.init(e,t)});function z5(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 L5=le("$ZodJWT",(e,t)=>{Ut.init(e,t),e._zod.check=n=>{z5(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),nE=le("$ZodNumber",(e,t)=>{zt.init(e,t),e._zod.pattern=e._zod.bag.pattern??Xk,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}}),$5=le("$ZodNumberFormat",(e,t)=>{t5.init(e,t),nE.init(e,t)}),U5=le("$ZodBoolean",(e,t)=>{zt.init(e,t),e._zod.pattern=KI,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}}),B5=le("$ZodNull",(e,t)=>{zt.init(e,t),e._zod.pattern=XI,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}}),V5=le("$ZodUnknown",(e,t)=>{zt.init(e,t),e._zod.parse=n=>n}),F5=le("$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 z1(e,t,n){e.issues.length&&t.issues.push(...Do(n,e.issues)),t.value[n]=e.value}const H5=le("$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=>z1(h,n,u))):z1(p,n,u)}return l.length?Promise.all(l).then(()=>n):n}});function uf(e,t,n,s,a){if(e.issues.length){if(a&&!(n in s))return;t.issues.push(...Do(n,e.issues))}e.value===void 0?n in s&&(t.value[n]=void 0):t.value[n]=e.value}function sE(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=oI(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function rE(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 b=p.run({value:t[y],issues:[]},s);b instanceof Promise?e.push(b.then(w=>uf(w,n,y,t,m))):uf(b,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 q5=le("$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=Yf(()=>sE(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=kc,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 b of u.keys){const w=y[b],j=w._zod.optout==="optional",N=w._zod.run({value:h[b],issues:[]},p);N instanceof Promise?m.push(N.then(k=>uf(k,d,b,h,j))):uf(N,d,b,h,j)}return l?rE(m,h,d,p,s.value,e):m.length?Promise.all(m).then(()=>d):d}}),Z5=le("$ZodObjectJIT",(e,t)=>{q5.init(e,t);const n=e._zod.parse,s=Yf(()=>sE(t)),a=b=>{const w=new f5(["shape","payload","ctx"]),j=s.value,N=S=>{const M=D1(S);return`shape[${M}]._zod.run({ value: input[${M}], issues: [] }, ctx)`};w.write("const input = payload.value;");const k=Object.create(null);let T=0;for(const S of j.keys)k[S]=`key_${T++}`;w.write("const newResult = {};");for(const S of j.keys){const M=k[S],R=D1(S),_=b[S]?._zod?.optout==="optional";w.write(`const ${M} = ${N(S)};`),_?w.write(`
|
|
14
|
-
if (${M}.issues.length) {
|
|
15
|
-
if (${R} in input) {
|
|
16
|
-
payload.issues = payload.issues.concat(${M}.issues.map(iss => ({
|
|
17
|
-
...iss,
|
|
18
|
-
path: iss.path ? [${R}, ...iss.path] : [${R}]
|
|
19
|
-
})));
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (${M}.value === undefined) {
|
|
24
|
-
if (${R} in input) {
|
|
25
|
-
newResult[${R}] = undefined;
|
|
26
|
-
}
|
|
27
|
-
} else {
|
|
28
|
-
newResult[${R}] = ${M}.value;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
`):w.write(`
|
|
32
|
-
if (${M}.issues.length) {
|
|
33
|
-
payload.issues = payload.issues.concat(${M}.issues.map(iss => ({
|
|
34
|
-
...iss,
|
|
35
|
-
path: iss.path ? [${R}, ...iss.path] : [${R}]
|
|
36
|
-
})));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (${M}.value === undefined) {
|
|
40
|
-
if (${R} in input) {
|
|
41
|
-
newResult[${R}] = undefined;
|
|
42
|
-
}
|
|
43
|
-
} else {
|
|
44
|
-
newResult[${R}] = ${M}.value;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
`)}w.write("payload.value = newResult;"),w.write("return payload;");const E=w.compile();return(S,M)=>E(b,S,M)};let l;const u=kc,d=!Bk.jitless,h=d&&aI.value,m=t.catchall;let y;e._zod.parse=(b,w)=>{y??(y=s.value);const j=b.value;return u(j)?d&&h&&w?.async===!1&&w.jitless!==!0?(l||(l=a(t.shape)),b=l(b,w),m?rE([],j,b,w,y,e):b):n(b,w):(b.issues.push({expected:"object",code:"invalid_type",input:j,inst:e}),b)}});function L1(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=>!Io(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=>Ca(u,s,Ea())))}),t)}const aE=le("$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=>Jv(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=>L1(p,a,e,l)):L1(d,a,e,l)}}),W5=le("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,aE.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=Yf(()=>{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(!kc(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)}}),Y5=le("$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])=>$1(n,p,h)):$1(n,l,u)}});function Hg(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(Yo(e)&&Yo(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=Hg(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=Hg(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 $1(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}),Io(e))return e;const u=Hg(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 G5=le("$ZodRecord",(e,t)=>{zt.init(e,t),e._zod.parse=(n,s)=>{const a=n.value;if(!Yo(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(...Do(h,y.issues)),n.value[h]=y.value})):(m.issues.length&&n.issues.push(...Do(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"&&Xk.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=>Ca(y,s,Ea())),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(...Do(d,y.issues)),n.value[p.value]=y.value})):(m.issues.length&&n.issues.push(...Do(d,m.issues)),n.value[p.value]=m.value)}}return l.length?Promise.all(l).then(()=>n):n}}),K5=le("$ZodEnum",(e,t)=>{zt.init(e,t);const n=Vk(t.entries),s=new Set(n);e._zod.values=s,e._zod.pattern=new RegExp(`^(${n.filter(a=>iI.has(typeof a)).map(a=>typeof a=="string"?Go(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}}),X5=le("$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"?Go(s):s?Go(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}}),J5=le("$ZodTransform",(e,t)=>{zt.init(e,t),e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new Uk(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 Vo;return n.value=a,n}});function U1(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const iE=le("$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(`^(${Jv(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=>U1(l,n.value)):U1(a,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,s)}}),Q5=le("$ZodExactOptional",(e,t)=>{iE.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)}),eD=le("$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(`^(${Jv(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)}),tD=le("$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=>B1(l,t)):B1(a,t)}});function B1(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const nD=le("$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))}),sD=le("$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=>V1(l,e)):V1(a,e)}});function V1(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 rD=le("$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=>Ca(u,s,Ea()))},input:n.value}),n.issues=[]),n)):(n.value=a.value,a.issues.length&&(n.value=t.catchValue({...n,error:{issues:a.issues.map(l=>Ca(l,s,Ea()))},input:n.value}),n.issues=[]),n)}}),aD=le("$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=>pd(u,t.in,s)):pd(l,t.in,s)}const a=t.in._zod.run(n,s);return a instanceof Promise?a.then(l=>pd(l,t.out,s)):pd(a,t.out,s)}});function pd(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const iD=le("$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(F1):F1(a)}});function F1(e){return e.value=Object.freeze(e.value),e}const oD=le("$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)}),lD=le("$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=>H1(l,n,s,e));H1(a,n,s,e)}});function H1(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(Ec(a))}}var q1;class cD{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 uD(){return new cD}(q1=globalThis).__zod_globalRegistry??(q1.__zod_globalRegistry=uD());const ac=globalThis.__zod_globalRegistry;function dD(e,t){return new e({type:"string",...De(t)})}function fD(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...De(t)})}function Z1(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...De(t)})}function hD(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...De(t)})}function pD(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...De(t)})}function mD(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...De(t)})}function gD(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...De(t)})}function vD(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...De(t)})}function yD(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...De(t)})}function xD(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...De(t)})}function bD(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...De(t)})}function wD(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...De(t)})}function jD(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...De(t)})}function SD(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...De(t)})}function ND(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...De(t)})}function kD(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...De(t)})}function ED(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...De(t)})}function CD(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...De(t)})}function TD(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...De(t)})}function AD(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...De(t)})}function MD(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...De(t)})}function RD(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...De(t)})}function _D(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...De(t)})}function OD(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...De(t)})}function ID(e,t){return new e({type:"string",format:"date",check:"string_format",...De(t)})}function DD(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...De(t)})}function PD(e,t){return new e({type:"string",format:"duration",check:"string_format",...De(t)})}function zD(e,t){return new e({type:"number",checks:[],...De(t)})}function LD(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...De(t)})}function $D(e,t){return new e({type:"boolean",...De(t)})}function UD(e,t){return new e({type:"null",...De(t)})}function BD(e){return new e({type:"unknown"})}function VD(e,t){return new e({type:"never",...De(t)})}function W1(e,t){return new Qk({check:"less_than",...De(t),value:e,inclusive:!1})}function Im(e,t){return new Qk({check:"less_than",...De(t),value:e,inclusive:!0})}function Y1(e,t){return new eE({check:"greater_than",...De(t),value:e,inclusive:!1})}function Dm(e,t){return new eE({check:"greater_than",...De(t),value:e,inclusive:!0})}function G1(e,t){return new e5({check:"multiple_of",...De(t),value:e})}function oE(e,t){return new n5({check:"max_length",...De(t),maximum:e})}function df(e,t){return new s5({check:"min_length",...De(t),minimum:e})}function lE(e,t){return new r5({check:"length_equals",...De(t),length:e})}function FD(e,t){return new a5({check:"string_format",format:"regex",...De(t),pattern:e})}function HD(e){return new i5({check:"string_format",format:"lowercase",...De(e)})}function qD(e){return new o5({check:"string_format",format:"uppercase",...De(e)})}function ZD(e,t){return new l5({check:"string_format",format:"includes",...De(t),includes:e})}function WD(e,t){return new c5({check:"string_format",format:"starts_with",...De(t),prefix:e})}function YD(e,t){return new u5({check:"string_format",format:"ends_with",...De(t),suffix:e})}function el(e){return new d5({check:"overwrite",tx:e})}function GD(e){return el(t=>t.normalize(e))}function KD(){return el(e=>e.trim())}function XD(){return el(e=>e.toLowerCase())}function JD(){return el(e=>e.toUpperCase())}function QD(){return el(e=>rI(e))}function eP(e,t,n){return new e({type:"array",element:t,...De(n)})}function tP(e,t,n){const s=De(n);return s.abort??(s.abort=!0),new e({type:"custom",check:"custom",fn:t,...s})}function nP(e,t,n){return new e({type:"custom",check:"custom",fn:t,...De(n)})}function sP(e){const t=rP(n=>(n.addIssue=s=>{if(typeof s=="string")n.issues.push(Ec(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(Ec(a))}},e(n.value,n)));return t}function rP(e,t){const n=new ts({check:"custom",...De(t)});return n._zod.check=e,n}function ff(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??ac,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 Mt(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 b=u.schema,w=t.processors[a.type];if(!w)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${a.type}`);w(e,t,b,m)}const y=e._zod.parent;y&&(u.ref||(u.ref=y),Mt(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 hf(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,b=e.external.uri??(j=>j);if(y)return{ref:b(y)};const w=u[1].defId??u[1].schema.id??`schema${e.counter++}`;return u[1].defId=w,{defId:w,ref:`${b("__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 pf(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 b=e.seen.get(m),w=b.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&&b.def)for(const N in p)N==="$ref"||N==="allOf"||N in b.def&&JSON.stringify(p[N])===JSON.stringify(b.def[N])&&delete p[N]}const y=u._zod.parent;if(y&&y!==m){s(y);const b=e.seen.get(y);if(b?.schema.$ref&&(p.$ref=b.schema.$ref,b.def))for(const w in p)w==="$ref"||w==="allOf"||w in b.def&&JSON.stringify(p[w])===JSON.stringify(b.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:mf(t,"input",e.processors),output:mf(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 aP=(e,t={})=>n=>{const s=ff({...n,processors:t});return Mt(e,s),hf(s,e),pf(s,e)},mf=(e,t,n={})=>s=>{const{libraryOptions:a,target:l}=s??{},u=ff({...a??{},target:l,io:t,processors:n});return Mt(e,u),hf(u,e),pf(u,e)},iP={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},cE=(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=iP[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}))])}},uE=(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)},dE=(e,t,n,s)=>{n.type="boolean"},oP=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},lP=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},fE=(e,t,n,s)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},cP=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},uP=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},hE=(e,t,n,s)=>{n.not={}},dP=(e,t,n,s)=>{},pE=(e,t,n,s)=>{},fP=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},mE=(e,t,n,s)=>{const a=e._zod.def,l=Vk(a.entries);l.every(u=>typeof u=="number")&&(n.type="number"),l.every(u=>typeof u=="string")&&(n.type="string"),n.enum=l},gE=(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},hP=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},pP=(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},mP=(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)},gP=(e,t,n,s)=>{n.type="boolean"},vE=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},vP=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},yE=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},yP=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},xP=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},xE=(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=Mt(l.element,t,{...s,path:[...s.path,"items"]})},bE=(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]=Mt(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=Mt(l.catchall,t,{...s,path:[...s.path,"additionalProperties"]})):t.io==="output"&&(a.additionalProperties=!1)},wE=(e,t,n,s)=>{const a=e._zod.def,l=a.inclusive===!1,u=a.options.map((d,p)=>Mt(d,t,{...s,path:[...s.path,l?"oneOf":"anyOf",p]}));l?n.oneOf=u:n.anyOf=u},jE=(e,t,n,s)=>{const a=e._zod.def,l=Mt(a.left,t,{...s,path:[...s.path,"allOf",0]}),u=Mt(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},bP=(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((b,w)=>Mt(b,t,{...s,path:[...s.path,u,w]})),h=l.rest?Mt(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)},SE=(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=Mt(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=Mt(l.keyType,t,{...s,path:[...s.path,"propertyNames"]})),a.additionalProperties=Mt(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)}},NE=(e,t,n,s)=>{const a=e._zod.def,l=Mt(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"}]},kE=(e,t,n,s)=>{const a=e._zod.def;Mt(a.innerType,t,s);const l=t.seen.get(e);l.ref=a.innerType},EE=(e,t,n,s)=>{const a=e._zod.def;Mt(a.innerType,t,s);const l=t.seen.get(e);l.ref=a.innerType,n.default=JSON.parse(JSON.stringify(a.defaultValue))},CE=(e,t,n,s)=>{const a=e._zod.def;Mt(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)))},TE=(e,t,n,s)=>{const a=e._zod.def;Mt(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},AE=(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;Mt(l,t,s);const u=t.seen.get(e);u.ref=l},ME=(e,t,n,s)=>{const a=e._zod.def;Mt(a.innerType,t,s);const l=t.seen.get(e);l.ref=a.innerType,n.readOnly=!0},wP=(e,t,n,s)=>{const a=e._zod.def;Mt(a.innerType,t,s);const l=t.seen.get(e);l.ref=a.innerType},sy=(e,t,n,s)=>{const a=e._zod.def;Mt(a.innerType,t,s);const l=t.seen.get(e);l.ref=a.innerType},RE=(e,t,n,s)=>{const a=e._zod.innerType;Mt(a,t,s);const l=t.seen.get(e);l.ref=a},K1={string:cE,number:uE,boolean:dE,bigint:oP,symbol:lP,null:fE,undefined:cP,void:uP,never:hE,any:dP,unknown:pE,date:fP,enum:mE,literal:gE,nan:hP,template_literal:pP,file:mP,success:gP,custom:vE,function:vP,transform:yE,map:yP,set:xP,array:xE,object:bE,union:wE,intersection:jE,tuple:bP,record:SE,nullable:NE,nonoptional:kE,default:EE,prefault:CE,catch:TE,pipe:AE,readonly:ME,promise:wP,optional:sy,lazy:RE};function jP(e,t){if("_idmap"in e){const s=e,a=ff({...t,processors:K1}),l={};for(const p of s._idmap.entries()){const[h,m]=p;Mt(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;hf(a,m),u[h]=pf(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=ff({...t,processors:K1});return Mt(e,n),hf(n,e),pf(n,e)}const SP=le("ZodISODateTime",(e,t)=>{k5.init(e,t),qt.init(e,t)});function NP(e){return OD(SP,e)}const kP=le("ZodISODate",(e,t)=>{E5.init(e,t),qt.init(e,t)});function EP(e){return ID(kP,e)}const CP=le("ZodISOTime",(e,t)=>{C5.init(e,t),qt.init(e,t)});function TP(e){return DD(CP,e)}const AP=le("ZodISODuration",(e,t)=>{T5.init(e,t),qt.init(e,t)});function MP(e){return PD(AP,e)}const RP=(e,t)=>{Zk.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>vI(e,n)},flatten:{value:n=>gI(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Fg,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Fg,2)}},isEmpty:{get(){return e.issues.length===0}}})},Rs=le("ZodError",RP,{Parent:Error}),_P=ey(Rs),OP=ty(Rs),IP=Gf(Rs),_E=Kf(Rs),DP=bI(Rs),PP=wI(Rs),zP=jI(Rs),LP=SI(Rs),$P=NI(Rs),UP=kI(Rs),BP=EI(Rs),VP=CI(Rs),Lt=le("ZodType",(e,t)=>(zt.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:mf(e,"input"),output:mf(e,"output")}}),e.toJSONSchema=aP(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)=>Ra(e,n,s),e.brand=()=>e,e.register=((n,s)=>(n.add(e,s),e)),e.parse=(n,s)=>_P(e,n,s,{callee:e.parse}),e.safeParse=(n,s)=>IP(e,n,s),e.parseAsync=async(n,s)=>OP(e,n,s,{callee:e.parseAsync}),e.safeParseAsync=async(n,s)=>_E(e,n,s),e.spa=e.safeParseAsync,e.encode=(n,s)=>DP(e,n,s),e.decode=(n,s)=>PP(e,n,s),e.encodeAsync=async(n,s)=>zP(e,n,s),e.decodeAsync=async(n,s)=>LP(e,n,s),e.safeEncode=(n,s)=>$P(e,n,s),e.safeDecode=(n,s)=>UP(e,n,s),e.safeEncodeAsync=async(n,s)=>BP(e,n,s),e.safeDecodeAsync=async(n,s)=>VP(e,n,s),e.refine=(n,s)=>e.check(L4(n,s)),e.superRefine=n=>e.check($4(n)),e.overwrite=n=>e.check(el(n)),e.optional=()=>Q1(e),e.exactOptional=()=>N4(e),e.nullable=()=>ej(e),e.nullish=()=>Q1(ej(e)),e.nonoptional=n=>M4(e,n),e.array=()=>tl(e),e.or=n=>Fn([e,n]),e.and=n=>y4(e,n),e.transform=n=>tj(e,j4(n)),e.default=n=>C4(e,n),e.prefault=n=>A4(e,n),e.catch=n=>_4(e,n),e.pipe=n=>tj(e,n),e.readonly=()=>D4(e),e.describe=n=>{const s=e.clone();return ac.add(s,{description:n}),s},Object.defineProperty(e,"description",{get(){return ac.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return ac.get(e);const s=e.clone();return ac.add(s,n[0]),s},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),OE=le("_ZodString",(e,t)=>{ny.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(s,a,l)=>cE(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(FD(...s)),e.includes=(...s)=>e.check(ZD(...s)),e.startsWith=(...s)=>e.check(WD(...s)),e.endsWith=(...s)=>e.check(YD(...s)),e.min=(...s)=>e.check(df(...s)),e.max=(...s)=>e.check(oE(...s)),e.length=(...s)=>e.check(lE(...s)),e.nonempty=(...s)=>e.check(df(1,...s)),e.lowercase=s=>e.check(HD(s)),e.uppercase=s=>e.check(qD(s)),e.trim=()=>e.check(KD()),e.normalize=(...s)=>e.check(GD(...s)),e.toLowerCase=()=>e.check(XD()),e.toUpperCase=()=>e.check(JD()),e.slugify=()=>e.check(QD())}),FP=le("ZodString",(e,t)=>{ny.init(e,t),OE.init(e,t),e.email=n=>e.check(fD(HP,n)),e.url=n=>e.check(vD(qP,n)),e.jwt=n=>e.check(_D(i4,n)),e.emoji=n=>e.check(yD(ZP,n)),e.guid=n=>e.check(Z1(X1,n)),e.uuid=n=>e.check(hD(md,n)),e.uuidv4=n=>e.check(pD(md,n)),e.uuidv6=n=>e.check(mD(md,n)),e.uuidv7=n=>e.check(gD(md,n)),e.nanoid=n=>e.check(xD(WP,n)),e.guid=n=>e.check(Z1(X1,n)),e.cuid=n=>e.check(bD(YP,n)),e.cuid2=n=>e.check(wD(GP,n)),e.ulid=n=>e.check(jD(KP,n)),e.base64=n=>e.check(AD(s4,n)),e.base64url=n=>e.check(MD(r4,n)),e.xid=n=>e.check(SD(XP,n)),e.ksuid=n=>e.check(ND(JP,n)),e.ipv4=n=>e.check(kD(QP,n)),e.ipv6=n=>e.check(ED(e4,n)),e.cidrv4=n=>e.check(CD(t4,n)),e.cidrv6=n=>e.check(TD(n4,n)),e.e164=n=>e.check(RD(a4,n)),e.datetime=n=>e.check(NP(n)),e.date=n=>e.check(EP(n)),e.time=n=>e.check(TP(n)),e.duration=n=>e.check(MP(n))});function Ce(e){return dD(FP,e)}const qt=le("ZodStringFormat",(e,t)=>{Ut.init(e,t),OE.init(e,t)}),HP=le("ZodEmail",(e,t)=>{g5.init(e,t),qt.init(e,t)}),X1=le("ZodGUID",(e,t)=>{p5.init(e,t),qt.init(e,t)}),md=le("ZodUUID",(e,t)=>{m5.init(e,t),qt.init(e,t)}),qP=le("ZodURL",(e,t)=>{v5.init(e,t),qt.init(e,t)}),ZP=le("ZodEmoji",(e,t)=>{y5.init(e,t),qt.init(e,t)}),WP=le("ZodNanoID",(e,t)=>{x5.init(e,t),qt.init(e,t)}),YP=le("ZodCUID",(e,t)=>{b5.init(e,t),qt.init(e,t)}),GP=le("ZodCUID2",(e,t)=>{w5.init(e,t),qt.init(e,t)}),KP=le("ZodULID",(e,t)=>{j5.init(e,t),qt.init(e,t)}),XP=le("ZodXID",(e,t)=>{S5.init(e,t),qt.init(e,t)}),JP=le("ZodKSUID",(e,t)=>{N5.init(e,t),qt.init(e,t)}),QP=le("ZodIPv4",(e,t)=>{A5.init(e,t),qt.init(e,t)}),e4=le("ZodIPv6",(e,t)=>{M5.init(e,t),qt.init(e,t)}),t4=le("ZodCIDRv4",(e,t)=>{R5.init(e,t),qt.init(e,t)}),n4=le("ZodCIDRv6",(e,t)=>{_5.init(e,t),qt.init(e,t)}),s4=le("ZodBase64",(e,t)=>{O5.init(e,t),qt.init(e,t)}),r4=le("ZodBase64URL",(e,t)=>{D5.init(e,t),qt.init(e,t)}),a4=le("ZodE164",(e,t)=>{P5.init(e,t),qt.init(e,t)}),i4=le("ZodJWT",(e,t)=>{L5.init(e,t),qt.init(e,t)}),IE=le("ZodNumber",(e,t)=>{nE.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(s,a,l)=>uE(e,s,a),e.gt=(s,a)=>e.check(Y1(s,a)),e.gte=(s,a)=>e.check(Dm(s,a)),e.min=(s,a)=>e.check(Dm(s,a)),e.lt=(s,a)=>e.check(W1(s,a)),e.lte=(s,a)=>e.check(Im(s,a)),e.max=(s,a)=>e.check(Im(s,a)),e.int=s=>e.check(J1(s)),e.safe=s=>e.check(J1(s)),e.positive=s=>e.check(Y1(0,s)),e.nonnegative=s=>e.check(Dm(0,s)),e.negative=s=>e.check(W1(0,s)),e.nonpositive=s=>e.check(Im(0,s)),e.multipleOf=(s,a)=>e.check(G1(s,a)),e.step=(s,a)=>e.check(G1(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 o4(e){return zD(IE,e)}const l4=le("ZodNumberFormat",(e,t)=>{$5.init(e,t),IE.init(e,t)});function J1(e){return LD(l4,e)}const c4=le("ZodBoolean",(e,t)=>{U5.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>dE(e,n,s)});function Un(e){return $D(c4,e)}const u4=le("ZodNull",(e,t)=>{B5.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>fE(e,n,s)});function d4(e){return UD(u4,e)}const f4=le("ZodUnknown",(e,t)=>{V5.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>pE()});function nr(){return BD(f4)}const h4=le("ZodNever",(e,t)=>{F5.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>hE(e,n,s)});function DE(e){return VD(h4,e)}const p4=le("ZodArray",(e,t)=>{H5.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>xE(e,n,s,a),e.element=t.element,e.min=(n,s)=>e.check(df(n,s)),e.nonempty=n=>e.check(df(1,n)),e.max=(n,s)=>e.check(oE(n,s)),e.length=(n,s)=>e.check(lE(n,s)),e.unwrap=()=>e.element});function tl(e,t){return eP(p4,e,t)}const PE=le("ZodObject",(e,t)=>{Z5.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>bE(e,n,s,a),ut(e,"shape",()=>t.shape),e.keyof=()=>LE(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:DE()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>dI(e,n),e.safeExtend=n=>fI(e,n),e.merge=n=>hI(e,n),e.pick=n=>cI(e,n),e.omit=n=>uI(e,n),e.partial=(...n)=>pI($E,e,n[0]),e.required=(...n)=>mI(UE,e,n[0])});function Tt(e,t){const n={type:"object",shape:e??{},...De(t)};return new PE(n)}function Ot(e,t){return new PE({type:"object",shape:e,catchall:DE(),...De(t)})}const zE=le("ZodUnion",(e,t)=>{aE.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>wE(e,n,s,a),e.options=t.options});function Fn(e,t){return new zE({type:"union",options:e,...De(t)})}const m4=le("ZodDiscriminatedUnion",(e,t)=>{zE.init(e,t),W5.init(e,t)});function g4(e,t,n){return new m4({type:"union",options:t,discriminator:e,...De(n)})}const v4=le("ZodIntersection",(e,t)=>{Y5.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>jE(e,n,s,a)});function y4(e,t){return new v4({type:"intersection",left:e,right:t})}const x4=le("ZodRecord",(e,t)=>{G5.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>SE(e,n,s,a),e.keyType=t.keyType,e.valueType=t.valueType});function Cc(e,t,n){return new x4({type:"record",keyType:e,valueType:t,...De(n)})}const qg=le("ZodEnum",(e,t)=>{K5.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(s,a,l)=>mE(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 qg({...t,checks:[],...De(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 qg({...t,checks:[],...De(a),entries:l})}});function LE(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(s=>[s,s])):e;return new qg({type:"enum",entries:n,...De(t)})}const b4=le("ZodLiteral",(e,t)=>{X5.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>gE(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 qe(e,t){return new b4({type:"literal",values:Array.isArray(e)?e:[e],...De(t)})}const w4=le("ZodTransform",(e,t)=>{J5.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>yE(e,n),e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new Uk(e.constructor.name);n.addIssue=l=>{if(typeof l=="string")n.issues.push(Ec(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(Ec(u))}};const a=t.transform(n.value,n);return a instanceof Promise?a.then(l=>(n.value=l,n)):(n.value=a,n)}});function j4(e){return new w4({type:"transform",transform:e})}const $E=le("ZodOptional",(e,t)=>{iE.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>sy(e,n,s,a),e.unwrap=()=>e._zod.def.innerType});function Q1(e){return new $E({type:"optional",innerType:e})}const S4=le("ZodExactOptional",(e,t)=>{Q5.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>sy(e,n,s,a),e.unwrap=()=>e._zod.def.innerType});function N4(e){return new S4({type:"optional",innerType:e})}const k4=le("ZodNullable",(e,t)=>{eD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>NE(e,n,s,a),e.unwrap=()=>e._zod.def.innerType});function ej(e){return new k4({type:"nullable",innerType:e})}const E4=le("ZodDefault",(e,t)=>{tD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>EE(e,n,s,a),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function C4(e,t){return new E4({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Hk(t)}})}const T4=le("ZodPrefault",(e,t)=>{nD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>CE(e,n,s,a),e.unwrap=()=>e._zod.def.innerType});function A4(e,t){return new T4({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Hk(t)}})}const UE=le("ZodNonOptional",(e,t)=>{sD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>kE(e,n,s,a),e.unwrap=()=>e._zod.def.innerType});function M4(e,t){return new UE({type:"nonoptional",innerType:e,...De(t)})}const R4=le("ZodCatch",(e,t)=>{rD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>TE(e,n,s,a),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function _4(e,t){return new R4({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const O4=le("ZodPipe",(e,t)=>{aD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>AE(e,n,s,a),e.in=t.in,e.out=t.out});function tj(e,t){return new O4({type:"pipe",in:e,out:t})}const I4=le("ZodReadonly",(e,t)=>{iD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>ME(e,n,s,a),e.unwrap=()=>e._zod.def.innerType});function D4(e){return new I4({type:"readonly",innerType:e})}const P4=le("ZodLazy",(e,t)=>{oD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>RE(e,n,s,a),e.unwrap=()=>e._zod.def.getter()});function z4(e){return new P4({type:"lazy",getter:e})}const ry=le("ZodCustom",(e,t)=>{lD.init(e,t),Lt.init(e,t),e._zod.processJSONSchema=(n,s,a)=>vE(e,n)});function BE(e,t){return tP(ry,e??(()=>!0),t)}function L4(e,t={}){return nP(ry,e,t)}function $4(e){return sP(e)}function gf(e,t={}){const n=new ry({type:"custom",check:"custom",fn:s=>s instanceof e,abort:!0,...De(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 Tc;(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})(Tc||(Tc={}));var nj;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(nj||(nj={}));Tc.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);Tc.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 vf 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 vf))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Tc.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()}}vf.create=e=>new vf(e);var sj;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(sj||(sj={}));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 rj 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 aj=10,U4=13,ti=32;function Pm(e){}function B4(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=Pm,onError:n=Pm,onRetry:s=Pm,onComment:a}=e;let l="",u=!0,d,p="",h=0,m;function y(E){if(u){u=!1,b(E);return}const S=l===""?E:l+E;l=w(S)}function b(E){E.charCodeAt(0)===239&&E.charCodeAt(1)===187&&E.charCodeAt(2)===191&&(E=E.slice(3));const S=l===""?E:l+E;l=w(S)}function w(E){let S=0;if(E.indexOf("\r")===-1){let M=E.indexOf(`
|
|
50
|
-
`,S);for(;M!==-1;){if(S===M){h>0&&t({id:d,event:m,data:p}),d=void 0,p="",h=0,m=void 0,S=M+1,M=E.indexOf(`
|
|
51
|
-
`,S);continue}const R=E.charCodeAt(S);if(ij(E,S,R)){const A=E.charCodeAt(S+5)===ti?S+6:S+5,_=E.slice(A,M);if(h===0&&E.charCodeAt(M+1)===aj){t({id:d,event:m,data:_}),d=void 0,p="",m=void 0,S=M+2,M=E.indexOf(`
|
|
52
|
-
`,S);continue}p=h===0?_:`${p}
|
|
53
|
-
${_}`,h++}else oj(E,S,R)?m=E.slice(E.charCodeAt(S+6)===ti?S+7:S+6,M)||void 0:j(E,S,M);S=M+1,M=E.indexOf(`
|
|
54
|
-
`,S)}return E.slice(S)}for(;S<E.length;){const M=E.indexOf("\r",S),R=E.indexOf(`
|
|
55
|
-
`,S);let A=-1;if(M!==-1&&R!==-1?A=M<R?M:R:M!==-1?M===E.length-1?A=-1:A=M:R!==-1&&(A=R),A===-1)break;j(E,S,A),S=A+1,E.charCodeAt(S-1)===U4&&E.charCodeAt(S)===aj&&S++}return E.slice(S)}function j(E,S,M){if(S===M){k();return}const R=E.charCodeAt(S);if(ij(E,S,R)){const O=E.charCodeAt(S+5)===ti?S+6:S+5,P=E.slice(O,M);p=h===0?P:`${p}
|
|
56
|
-
${P}`,h++;return}if(oj(E,S,R)){m=E.slice(E.charCodeAt(S+6)===ti?S+7:S+6,M)||void 0;return}if(R===105&&E.charCodeAt(S+1)===100&&E.charCodeAt(S+2)===58){const O=E.slice(E.charCodeAt(S+3)===ti?S+4:S+3,M);d=O.includes("\0")?void 0:O;return}if(R===58){if(a){const O=E.slice(S,M);a(O.slice(E.charCodeAt(S+1)===ti?2:1))}return}const A=E.slice(S,M),_=A.indexOf(":");if(_===-1){N(A,"",A);return}const $=A.slice(0,_),V=A.charCodeAt(_+1)===ti?2:1,U=A.slice(_+V);N($,U,A)}function N(E,S,M){switch(E){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 rj(`Invalid \`retry\` value: "${S}"`,{type:"invalid-retry",value:S,line:M}));break;default:n(new rj(`Unknown field "${E.length>20?`${E.slice(0,20)}…`:E}"`,{type:"unknown-field",field:E,value:S,line:M}));break}}function k(){h>0&&t({id:d,event:m,data:p}),d=void 0,p="",h=0,m=void 0}function T(E={}){l&&E.consume&&j(l,0,l.length),u=!0,d=void 0,p="",h=0,m=void 0,l=""}return{feed:y,reset:T}}function ij(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 oj(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 V4 extends TransformStream{constructor({onError:t,onRetry:n,onComment:s}={}){let a;super({start(l){a=B4({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 Fc=({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 eI({argument:"separator",message:`The separator "${s}" must not be part of the alphabet "${n}".`});return()=>`${e}${s}${a()}`},F4=Fc();function go(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 H4=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,q4=/"(?: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 lj(e){const t=JSON.parse(e);return t===null||typeof t!="object"||H4.test(e)===!1&&q4.test(e)===!1?t:Z4(t)}function Z4(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 W4(e){const{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return lj(e)}try{return lj(e)}finally{Error.stackTraceLimit=t}}function ay(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]=ni(n[s])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(ni):ni(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(ni)),e.allOf!=null&&(e.allOf=e.allOf.map(ni)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(ni));const{definitions:t}=e;if(t!=null)for(const n of Object.keys(t))t[n]=ni(t[n]);return e}function ni(e){return typeof e=="boolean"?e:ay(e)}var Y4=Symbol("Let zodToJsonSchema decide on which parser to use"),cj={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"},G4=e=>typeof e=="string"?{...cj,name:e}:{...cj,...e};function fs(){return{}}function K4(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=xt(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 X4(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 J4(){return{type:"boolean"}}function VE(e,t){return xt(e.type._def,t)}var Q4=(e,t)=>xt(e.innerType._def,t);function FE(e,t,n){const s=n??t.dateStrategy;if(Array.isArray(s))return{anyOf:s.map((a,l)=>FE(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 ez(e)}}var ez=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 tz(e,t){return{...xt(e.innerType._def,t),default:e.defaultValue()}}function nz(e,t){return t.effectStrategy==="input"?xt(e.schema._def,t):fs()}function sz(e){return{type:"string",enum:Array.from(e.values)}}var rz=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function az(e,t){const n=[xt(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),xt(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(a=>!!a),s=[];return n.forEach(a=>{if(rz(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 iz(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 zm=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:()=>(zm===void 0&&(zm=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),zm),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 HE(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(`^${Lm(s.value,t)}`),s.message,t);break;case"endsWith":Ln(n,RegExp(`${Lm(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(Lm(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 Lm(e,t){return t.patternStrategy==="escape"?lz(e):e}var oz=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function lz(e){let t="";for(let n=0;n<e.length;n++)oz.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:uj(t,s),...n&&s.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=uj(t,s)}function uj(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 qE(e,t){var n,s,a,l,u,d;const p={type:"object",additionalProperties:(n=xt(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}=HE(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}=VE(e.keyType._def,t);return{...p,propertyNames:m}}}return p}function cz(e,t){if(t.mapStrategy==="record")return qE(e,t);const n=xt(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||fs(),s=xt(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 uz(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 dz(){return{not:fs()}}function fz(){return{type:"null"}}var Zg={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function hz(e,t){const n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(s=>s._def.typeName in Zg&&(!s._def.checks||!s._def.checks.length))){const s=n.reduce((a,l)=>{const u=Zg[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 pz(e,t)}var pz=(e,t)=>{const n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((s,a)=>xt(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 mz(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[Zg[e.innerType._def.typeName],"null"]};const n=xt(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function gz(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 vz(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=xz(d),h=xt(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=yz(e,t);return l!==void 0&&(n.additionalProperties=l),n}function yz(e,t){if(e.catchall._def.typeName!=="ZodNever")return xt(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 xz(e){try{return e.isOptional()}catch{return!0}}var bz=(e,t)=>{var n;if(t.currentPath.toString()===((n=t.propertyPath)==null?void 0:n.toString()))return xt(e.innerType._def,t);const s=xt(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return s?{anyOf:[{not:fs()},s]}:fs()},wz=(e,t)=>{if(t.pipeStrategy==="input")return xt(e.in._def,t);if(t.pipeStrategy==="output")return xt(e.out._def,t);const n=xt(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),s=xt(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,s].filter(a=>a!==void 0)}};function jz(e,t){return xt(e.type._def,t)}function Sz(e,t){const s={type:"array",uniqueItems:!0,items:xt(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 Nz(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,s)=>xt(n._def,{...t,currentPath:[...t.currentPath,"items",`${s}`]})).reduce((n,s)=>s===void 0?n:[...n,s],[]),additionalItems:xt(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,s)=>xt(n._def,{...t,currentPath:[...t.currentPath,"items",`${s}`]})).reduce((n,s)=>s===void 0?n:[...n,s],[])}}function kz(){return{not:fs()}}function Ez(){return fs()}var Cz=(e,t)=>xt(e.innerType._def,t),Tz=(e,t,n)=>{switch(t){case Xe.ZodString:return HE(e,n);case Xe.ZodNumber:return gz(e);case Xe.ZodObject:return vz(e,n);case Xe.ZodBigInt:return X4(e);case Xe.ZodBoolean:return J4();case Xe.ZodDate:return FE(e,n);case Xe.ZodUndefined:return kz();case Xe.ZodNull:return fz();case Xe.ZodArray:return K4(e,n);case Xe.ZodUnion:case Xe.ZodDiscriminatedUnion:return hz(e,n);case Xe.ZodIntersection:return az(e,n);case Xe.ZodTuple:return Nz(e,n);case Xe.ZodRecord:return qE(e,n);case Xe.ZodLiteral:return iz(e);case Xe.ZodEnum:return sz(e);case Xe.ZodNativeEnum:return uz(e);case Xe.ZodNullable:return mz(e,n);case Xe.ZodOptional:return bz(e,n);case Xe.ZodMap:return cz(e,n);case Xe.ZodSet:return Sz(e,n);case Xe.ZodLazy:return()=>e.getter()._def;case Xe.ZodPromise:return jz(e,n);case Xe.ZodNaN:case Xe.ZodNever:return dz();case Xe.ZodEffects:return nz(e,n);case Xe.ZodAny:return fs();case Xe.ZodUnknown:return Ez();case Xe.ZodDefault:return tz(e,n);case Xe.ZodBranded:return VE(e,n);case Xe.ZodReadonly:return Cz(e,n);case Xe.ZodCatch:return Q4(e,n);case Xe.ZodPipeline:return wz(e,n);case Xe.ZodFunction:case Xe.ZodVoid:case Xe.ZodSymbol:return;default:return(s=>{})()}},Az=(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 xt(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!==Y4)return p}if(a&&!n){const p=Mz(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=Tz(e,e.typeName,t),d=typeof u=="function"?xt(u(),t):u;if(d&&Rz(e,t,d),t.postProcess){const p=t.postProcess(d,e,t);return l.jsonSchema=d,p}return l.jsonSchema=d,d}var Mz=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:Az(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}},Rz=(e,t,n)=>(e.description&&(n.description=e.description),n),_z=e=>{const t=G4(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}]))}},Oz=(e,t)=>{var n;const s=_z(t);let a=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((h,[m,y])=>{var b;return{...h,[m]:(b=xt(y._def,{...s,currentPath:[...s.basePath,s.definitionPath,m]},!0))!=null?b:fs()}},{}):void 0;const l=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,u=(n=xt(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},Wg=Symbol.for("vercel.ai.schema");function Iz(e){let t;return()=>(t==null&&(t=e()),t)}function Jf(e,{validate:t}={}){return{[Wg]:!0,_type:void 0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function Dz(e){return typeof e=="object"&&e!==null&&Wg in e&&e[Wg]===!0&&"jsonSchema"in e&&"validate"in e}function iy(e){return e==null?Jf({properties:{},additionalProperties:!1}):Dz(e)?e:"~standard"in e?e["~standard"].vendor==="zod"?ZE(e):Pz(e):e()}function Pz(e){return Jf(()=>ay(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 Wo({value:t,cause:n.issues})}}})}function zz(e,t){var n;const s=(n=void 0)!=null?n:!1;return Jf(()=>Oz(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 Lz(e,t){var n;const s=(n=void 0)!=null?n:!1;return Jf(()=>ay(jP(e,{target:"draft-7",io:"input",reused:s?"ref":"inline"})),{validate:async a=>{const l=await _E(e,a);return l.success?{success:!0,value:l.data}:{success:!1,error:l.error}}})}function $z(e){return"_zod"in e}function ZE(e,t){return $z(e)?Lz(e):zz(e)}async function dj({value:e,schema:t,context:n}){const s=await Ac({value:e,schema:t,context:n});if(!s.success)throw Wo.wrap({value:e,cause:s.error,context:n});return s.value}async function Ac({value:e,schema:t,context:n}){const s=iy(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:Wo.wrap({value:e,cause:a.error,context:n}),rawValue:e}}catch(a){return{success:!1,error:Wo.wrap({value:e,cause:a,context:n}),rawValue:e}}}async function xi({text:e,schema:t}){try{const n=W4(e);return t==null?{success:!0,value:n,rawValue:n}:await Ac({value:n,schema:t})}catch(n){return{success:!1,error:R1.isInstance(n)?n:new R1({text:e,cause:n}),rawValue:void 0}}}function Uz({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new V4).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 Bz=Object.defineProperty,Vz=(e,t)=>{for(var n in t)Bz(e,n,{get:t[n],enumerable:!0})},WE="AI_NoObjectGeneratedError",YE=`vercel.ai.error.${WE}`,Fz=Symbol.for(YE),GE,ja=class extends lr{constructor({message:e="No object generated.",cause:t,text:n,response:s,usage:a,finishReason:l}){super({name:WE,message:e,cause:t}),this[GE]=!0,this.text=n,this.response=s,this.usage=a,this.finishReason=l}static isInstance(e){return lr.hasMarker(e,YE)}};GE=Fz;var KE="AI_UIMessageStreamError",XE=`vercel.ai.error.${KE}`,Hz=Symbol.for(XE),JE,vo=class extends lr{constructor({chunkType:e,chunkId:t,message:n}){super({name:KE,message:n}),this[JE]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return lr.hasMarker(e,XE)}};JE=Hz;var QE=Fn([Ce(),gf(Uint8Array),gf(ArrayBuffer),BE(e=>{var t,n;return(n=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?n:!1},{message:"Must be a Buffer"})]),Mc=z4(()=>Fn([d4(),Ce(),o4(),Un(),Cc(Ce(),Mc.optional()),tl(Mc)])),rt=Cc(Ce(),Cc(Ce(),Mc.optional())),eC=Tt({type:qe("text"),text:Ce(),providerOptions:rt.optional()}),qz=Tt({type:qe("image"),image:Fn([QE,gf(URL)]),mediaType:Ce().optional(),providerOptions:rt.optional()}),tC=Tt({type:qe("file"),data:Fn([QE,gf(URL)]),filename:Ce().optional(),mediaType:Ce(),providerOptions:rt.optional()}),Zz=Tt({type:qe("reasoning"),text:Ce(),providerOptions:rt.optional()}),Wz=Tt({type:qe("tool-call"),toolCallId:Ce(),toolName:Ce(),input:nr(),providerOptions:rt.optional(),providerExecuted:Un().optional()}),Yz=g4("type",[Tt({type:qe("text"),value:Ce(),providerOptions:rt.optional()}),Tt({type:qe("json"),value:Mc,providerOptions:rt.optional()}),Tt({type:qe("execution-denied"),reason:Ce().optional(),providerOptions:rt.optional()}),Tt({type:qe("error-text"),value:Ce(),providerOptions:rt.optional()}),Tt({type:qe("error-json"),value:Mc,providerOptions:rt.optional()}),Tt({type:qe("content"),value:tl(Fn([Tt({type:qe("text"),text:Ce(),providerOptions:rt.optional()}),Tt({type:qe("media"),data:Ce(),mediaType:Ce()}),Tt({type:qe("file-data"),data:Ce(),mediaType:Ce(),filename:Ce().optional(),providerOptions:rt.optional()}),Tt({type:qe("file-url"),url:Ce(),providerOptions:rt.optional()}),Tt({type:qe("file-id"),fileId:Fn([Ce(),Cc(Ce(),Ce())]),providerOptions:rt.optional()}),Tt({type:qe("image-data"),data:Ce(),mediaType:Ce(),providerOptions:rt.optional()}),Tt({type:qe("image-url"),url:Ce(),providerOptions:rt.optional()}),Tt({type:qe("image-file-id"),fileId:Fn([Ce(),Cc(Ce(),Ce())]),providerOptions:rt.optional()}),Tt({type:qe("custom"),providerOptions:rt.optional()})]))})]),nC=Tt({type:qe("tool-result"),toolCallId:Ce(),toolName:Ce(),output:Yz,providerOptions:rt.optional()}),Gz=Tt({type:qe("tool-approval-request"),approvalId:Ce(),toolCallId:Ce()}),Kz=Tt({type:qe("tool-approval-response"),approvalId:Ce(),approved:Un(),reason:Ce().optional()}),Xz=Tt({role:qe("system"),content:Ce(),providerOptions:rt.optional()}),Jz=Tt({role:qe("user"),content:Fn([Ce(),tl(Fn([eC,qz,tC]))]),providerOptions:rt.optional()}),Qz=Tt({role:qe("assistant"),content:Fn([Ce(),tl(Fn([eC,tC,Zz,Wz,nC,Gz]))]),providerOptions:rt.optional()}),e3=Tt({role:qe("tool"),content:tl(Fn([nC,Kz])),providerOptions:rt.optional()});Fn([Xz,Jz,Qz,e3]);function sC(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]=sC(l,a):n[s]=a}return n}var t3={};Vz(t3,{array:()=>a3,choice:()=>i3,json:()=>o3,object:()=>r3,text:()=>s3});function n3(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 Hc(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:n3(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var s3=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),r3=({schema:e,name:t,description:n})=>{const s=iy(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 Ac({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 Hc(a);switch(l.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:l.value}}},createElementStreamTransform(){}}},a3=({element:e,name:t,description:n})=>{const s=iy(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 Wo({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 Ac({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 Hc(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 Ac({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])}})}}},i3=({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 Wo({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 Hc(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(){}}),o3=({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 Hc(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(){}});Fc({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 l3=Iz(()=>ZE(Fn([Ot({type:qe("text-start"),id:Ce(),providerMetadata:rt.optional()}),Ot({type:qe("text-delta"),id:Ce(),delta:Ce(),providerMetadata:rt.optional()}),Ot({type:qe("text-end"),id:Ce(),providerMetadata:rt.optional()}),Ot({type:qe("error"),errorText:Ce()}),Ot({type:qe("tool-input-start"),toolCallId:Ce(),toolName:Ce(),providerExecuted:Un().optional(),providerMetadata:rt.optional(),dynamic:Un().optional(),title:Ce().optional()}),Ot({type:qe("tool-input-delta"),toolCallId:Ce(),inputTextDelta:Ce()}),Ot({type:qe("tool-input-available"),toolCallId:Ce(),toolName:Ce(),input:nr(),providerExecuted:Un().optional(),providerMetadata:rt.optional(),dynamic:Un().optional(),title:Ce().optional()}),Ot({type:qe("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:qe("tool-approval-request"),approvalId:Ce(),toolCallId:Ce()}),Ot({type:qe("tool-output-available"),toolCallId:Ce(),output:nr(),providerExecuted:Un().optional(),providerMetadata:rt.optional(),dynamic:Un().optional(),preliminary:Un().optional()}),Ot({type:qe("tool-output-error"),toolCallId:Ce(),errorText:Ce(),providerExecuted:Un().optional(),providerMetadata:rt.optional(),dynamic:Un().optional()}),Ot({type:qe("tool-output-denied"),toolCallId:Ce()}),Ot({type:qe("reasoning-start"),id:Ce(),providerMetadata:rt.optional()}),Ot({type:qe("reasoning-delta"),id:Ce(),delta:Ce(),providerMetadata:rt.optional()}),Ot({type:qe("reasoning-end"),id:Ce(),providerMetadata:rt.optional()}),Ot({type:qe("source-url"),sourceId:Ce(),url:Ce(),title:Ce().optional(),providerMetadata:rt.optional()}),Ot({type:qe("source-document"),sourceId:Ce(),mediaType:Ce(),title:Ce(),filename:Ce().optional(),providerMetadata:rt.optional()}),Ot({type:qe("file"),url:Ce(),mediaType:Ce(),providerMetadata:rt.optional()}),Ot({type:BE(e=>typeof e=="string"&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:Ce().optional(),data:nr(),transient:Un().optional()}),Ot({type:qe("start-step")}),Ot({type:qe("finish-step")}),Ot({type:qe("start"),messageId:Ce().optional(),messageMetadata:nr().optional()}),Ot({type:qe("finish"),finishReason:LE(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:nr().optional()}),Ot({type:qe("abort"),reason:Ce().optional()}),Ot({type:qe("message-metadata"),messageMetadata:nr()})])));function c3(e){return e.type.startsWith("data-")}function Yg(e){return e.type.startsWith("tool-")}function rC(e){return e.type==="dynamic-tool"}function bi(e){return Yg(e)||rC(e)}function Gg(e){return e.type.split("-").slice(1).join("-")}function aC(e){return rC(e)?e.toolName:Gg(e)}function u3({lastMessage:e,messageId:t}){return{message:e?.role==="assistant"?e:{id:t,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function d3({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,b,w,j;function N(S){const R=h.message.parts.filter(bi).find(A=>A.toolCallId===S);if(R==null)throw new vo({chunkType:"tool-invocation",chunkId:S,message:`No tool invocation found for tool call ID "${S}".`});return R}function k(S){var M;const R=h.message.parts.find($=>Yg($)&&$.toolCallId===S.toolCallId),A=S,_=R;if(R!=null){R.state=S.state,_.input=A.input,_.output=A.output,_.errorText=A.errorText,_.rawInput=A.rawInput,_.preliminary=A.preliminary,S.title!==void 0&&(_.title=S.title),_.providerExecuted=(M=A.providerExecuted)!=null?M:R.providerExecuted;const $=A.providerMetadata;if($!=null)if(S.state==="output-available"||S.state==="output-error"){const V=R;V.resultProviderMetadata=$}else R.callProviderMetadata=$}else h.message.parts.push({type:`tool-${S.toolName}`,toolCallId:S.toolCallId,state:S.state,title:S.title,input:A.input,output:A.output,rawInput:A.rawInput,errorText:A.errorText,providerExecuted:A.providerExecuted,preliminary:A.preliminary,...A.providerMetadata!=null&&(S.state==="output-available"||S.state==="output-error")?{resultProviderMetadata:A.providerMetadata}:{},...A.providerMetadata!=null&&!(S.state==="output-available"||S.state==="output-error")?{callProviderMetadata:A.providerMetadata}:{}})}function T(S){var M,R;const A=h.message.parts.find(V=>V.type==="dynamic-tool"&&V.toolCallId===S.toolCallId),_=S,$=A;if(A!=null){A.state=S.state,$.toolName=S.toolName,$.input=_.input,$.output=_.output,$.errorText=_.errorText,$.rawInput=(M=_.rawInput)!=null?M:$.rawInput,$.preliminary=_.preliminary,S.title!==void 0&&($.title=S.title),$.providerExecuted=(R=_.providerExecuted)!=null?R:A.providerExecuted;const V=_.providerMetadata;if(V!=null)if(S.state==="output-available"||S.state==="output-error"){const U=A;U.resultProviderMetadata=V}else A.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 E(S){if(S!=null){const M=h.message.metadata!=null?sC(h.message.metadata,S):S;t!=null&&await dj({value:M,schema:t,context:{field:"message.metadata",entityId:h.message.id}}),h.message.metadata=M}}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 vo({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 vo({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=(b=d.providerMetadata)!=null?b: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 vo({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 vo({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(Yg);h.partialToolCalls[d.toolCallId]={text:"",toolName:d.toolName,index:S.length,dynamic:d.dynamic,title:d.title},d.dynamic?T({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 vo({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:M}=await Hc(S.text);S.dynamic?T({toolCallId:d.toolCallId,toolName:S.toolName,state:"input-streaming",input:M,title:S.title}):k({toolCallId:d.toolCallId,toolName:S.toolName,state:"input-streaming",input:M,title:S.title}),m();break}case"tool-input-available":{d.dynamic?T({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(bi).find(R=>R.toolCallId===d.toolCallId);(S!=null?S.type==="dynamic-tool":!!d.dynamic)?T({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"?T({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:Gg(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"?T({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:Gg(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 E(d.messageMetadata),(d.messageId!=null||d.messageMetadata!=null)&&m();break}case"finish":{d.finishReason!=null&&(h.finishReason=d.finishReason),await E(d.messageMetadata),d.messageMetadata!=null&&m();break}case"message-metadata":{await E(d.messageMetadata),d.messageMetadata!=null&&m();break}case"error":{a?.(new Error(d.errorText));break}default:if(c3(d)){if(n?.[d.type]!=null){const R=h.message.parts.findIndex(_=>"id"in _&&"data"in _&&_.id===d.id&&_.type===d.type),A=R>=0?R:h.message.parts.length;await dj({value:d.data,schema:n[d.type],context:{field:`message.parts[${A}].data`,entityName:d.type,entityId:d.id}})}const S=d;if(S.transient){u?.(S);break}const M=S.id!=null?h.message.parts.find(R=>S.type===R.type&&S.id===R.id):void 0;M!=null?M.data=S.data:h.message.parts.push(S),u?.(S),m()}}p.enqueue(d)})}}))}async function f3({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()}}Fc({prefix:"aitxt",size:24});Fc({prefix:"aiobj",size:24});var h3=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()})}};Fc({prefix:"aiobj",size:24});async function p3(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 m3=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={...go(p),...go(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})),b=(s=y?.api)!=null?s:this.api,w=y?.headers!==void 0?go(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,T=await((l=this.fetch)!=null?l:globalThis.fetch)(b,{method:"POST",headers:{"Content-Type":"application/json",...w},body:JSON.stringify(j),credentials:N,signal:e});if(!T.ok)throw new Error((u=await T.text())!=null?u:"Failed to fetch the chat response.");if(!T.body)throw new Error("The response body is empty.");return this.processResponseStream(T.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={...go(d),...go(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`,b=m?.headers!==void 0?go(m.headers):h,w=(s=m?.credentials)!=null?s:p,N=await((a=this.fetch)!=null?a:globalThis.fetch)(y,{method:"GET",headers:b,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)}},iC=class extends m3{constructor(e={}){super(e)}processResponseStream(e){return Uz({stream:e,schema:l3}).pipeThrough(new TransformStream({async transform(t,n){if(!t.success)throw t.error;n.enqueue(t.value)}}))}},g3=class{constructor({generateId:e=F4,id:t=e(),transport:n=new iC,messageMetadataSchema:s,dataPartSchemas:a,state:l,onError:u,onToolCall:d,onFinish:p,onData:h,sendAutomaticallyWhen:m}){this.activeResponse=void 0,this.jobExecutor=new h3,this.sendMessage=async(y,b)=>{var w,j,N,k;if(y==null){await this.makeRequest({trigger:"submit-message",messageId:(w=this.lastMessage)==null?void 0:w.id,...b});return}let T;if("text"in y||"files"in y?T={parts:[...Array.isArray(y.files)?y.files:await p3(y.files),..."text"in y&&y.text!=null?[{type:"text",text:y.text}]:[]]}:T=y,y.messageId!=null){const E=this.state.messages.findIndex(S=>S.id===y.messageId);if(E===-1)throw new Error(`message with id ${y.messageId} not found`);if(this.state.messages[E].role!=="user")throw new Error(`message with id ${y.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,E+1),this.state.replaceMessage(E,{...T,id:y.messageId,role:(j=T.role)!=null?j:"user",metadata:y.metadata})}else this.state.pushMessage({...T,id:(N=T.id)!=null?N:this.generateId(),role:(k=T.role)!=null?k:"user",metadata:y.metadata});await this.makeRequest({trigger:"submit-message",messageId:y.messageId,...b})},this.regenerate=async({messageId:y,...b}={})=>{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,...b})},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:b,reason:w,options:j})=>this.jobExecutor.run(async()=>{const N=this.state.messages,k=N[N.length-1],T=E=>bi(E)&&E.state==="approval-requested"&&E.approval.id===y?{...E,state:"approval-responded",approval:{id:y,approved:b,reason:w}}:E;this.state.replaceMessage(N.length-1,{...k,parts:k.parts.map(T)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(T)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(E=>{var S;E&&this.makeRequest({trigger:"submit-message",messageId:(S=this.lastMessage)==null?void 0:S.id,...j})})}),this.addToolOutput=async({state:y="output-available",toolCallId:b,output:w,errorText:j,options:N})=>this.jobExecutor.run(async()=>{const k=this.state.messages,T=k[k.length-1],E=S=>bi(S)&&S.toolCallId===b?{...S,state:y,output:w,errorText:j}:S;this.state.replaceMessage(k.length-1,{...T,parts:T.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(S=>{var M;S&&this.makeRequest({trigger:"submit-message",messageId:(M=this.lastMessage)==null?void 0:M.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,b=!1;try{const w={state:u3({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 T;this.setStatus({status:"streaming"}),w.state.message.id===((T=this.lastMessage)==null?void 0:T.id)?this.state.replaceMessage(this.state.messages.length-1,w.state.message):this.state.pushMessage(w.state.message)}}));await f3({stream:d3({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;b=!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:b,finishReason:(l=this.activeResponse)==null?void 0:l.state.finishReason})}catch(w){console.error(w)}this.activeResponse=void 0}!b&&await this.shouldSendAutomatically()&&await this.makeRequest({trigger:"submit-message",messageId:(d=this.lastMessage)==null?void 0:d.id,metadata:t,headers:n,body:s})}},$m,fj;function v3(){if(fj)return $m;fj=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 $m=e,$m}var y3=v3();const x3=Nk(y3);var oC=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},It=(e,t,n)=>(oC(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)=>(oC(e,t,"write to private field"),t.set(e,n),n);function b3(e,t){return t!=null?x3(e,t):e}var Ns,Hd,qd,ic,oc,lc,To,Kg,Xg,w3=class{constructor(e=[]){er(this,Ns,void 0),er(this,Hd,"ready"),er(this,qd,void 0),er(this,ic,new Set),er(this,oc,new Set),er(this,lc,new Set),this.pushMessage=t=>{ha(this,Ns,It(this,Ns).concat(t)),It(this,To).call(this)},this.popMessage=()=>{ha(this,Ns,It(this,Ns).slice(0,-1)),It(this,To).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,To).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,n)=>{const s=n?b3(t,n):t;return It(this,ic).add(s),()=>{It(this,ic).delete(s)}},this["~registerStatusCallback"]=t=>(It(this,oc).add(t),()=>{It(this,oc).delete(t)}),this["~registerErrorCallback"]=t=>(It(this,lc).add(t),()=>{It(this,lc).delete(t)}),er(this,To,()=>{It(this,ic).forEach(t=>t())}),er(this,Kg,()=>{It(this,oc).forEach(t=>t())}),er(this,Xg,()=>{It(this,lc).forEach(t=>t())}),ha(this,Ns,e)}get status(){return It(this,Hd)}set status(e){ha(this,Hd,e),It(this,Kg).call(this)}get error(){return It(this,qd)}set error(e){ha(this,qd,e),It(this,Xg).call(this)}get messages(){return It(this,Ns)}set messages(e){ha(this,Ns,[...e]),It(this,To).call(this)}};Ns=new WeakMap;Hd=new WeakMap;qd=new WeakMap;ic=new WeakMap;oc=new WeakMap;lc=new WeakMap;To=new WeakMap;Kg=new WeakMap;Xg=new WeakMap;var Ao,hj=class extends g3{constructor({messages:e,...t}){const n=new w3(e);super({...t,state:n}),er(this,Ao,void 0),this["~registerMessagesCallback"]=(s,a)=>It(this,Ao)["~registerMessagesCallback"](s,a),this["~registerStatusCallback"]=s=>It(this,Ao)["~registerStatusCallback"](s),this["~registerErrorCallback"]=s=>It(this,Ao)["~registerErrorCallback"](s),ha(this,Ao,n)}};Ao=new WeakMap;function j3({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:b=>{var w,j;return(j=(w=s.current).onToolCall)==null?void 0:j.call(w,b)},onData:b=>{var w,j;return(j=(w=s.current).onData)==null?void 0:j.call(w,b)},onFinish:b=>{var w,j;return(j=(w=s.current).onFinish)==null?void 0:j.call(w,b)},onError:b=>{var w,j;return(j=(w=s.current).onError)==null?void 0:j.call(w,b)},sendAutomaticallyWhen:b=>{var w,j,N;return(N=(j=(w=s.current).sendAutomaticallyWhen)==null?void 0:j.call(w,b))!=null?N:!1}},l=g.useRef("chat"in n?n.chat:new hj(a));("chat"in n&&n.chat!==l.current||"id"in n&&l.current.id!==n.id)&&(l.current="chat"in n?n.chat:new hj(a));const d=g.useCallback(b=>l.current["~registerMessagesCallback"](b,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(b=>{typeof b=="function"&&(b=b(l.current.messages)),l.current.messages=b},[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 S3(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 N3(e,t){e.current?.(t)}function k3(e,t){e.current?.(t)}function E3(e){const t=new Set;for(const n of e??[])if(n.role==="assistant")for(const s of n.parts??[])s&&bi(s)&&t.add(s.toolCallId);return t}function C3({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:b}){const w=g.useRef(a),j=g.useRef(y),N=g.useRef(b),k=g.useRef(h??crypto.randomUUID()),[T,E]=g.useState(new Set),S=g.useCallback(B=>{E(X=>{const W=new Set(X);return W.has(B)?W.delete(B):W.add(B),W})},[]),[M]=Ir("hudson.settings",{}),R=l??M.aiMode??"api",A=g.useRef(T),_=g.useRef(u),$=g.useRef(s),V=g.useRef(e),U=g.useRef(R),O=g.useRef(d),P=g.useRef(p);g.useEffect(()=>{w.current=a},[a]),g.useEffect(()=>{j.current=y},[y]),g.useEffect(()=>{N.current=b},[b]),g.useEffect(()=>{h&&h!==k.current&&(k.current=h)},[h]),g.useEffect(()=>{m?.(k.current)},[m]),g.useEffect(()=>{A.current=T},[T]),g.useEffect(()=>{_.current=u},[u]),g.useEffect(()=>{$.current=s},[s]),g.useEffect(()=>{V.current=e},[e]),g.useEffect(()=>{U.current=R},[R]),g.useEffect(()=>{O.current=d},[d]),g.useEffect(()=>{P.current=p},[p]);const q=g.useMemo(()=>new iC({api:"/api/ai/chat",body:()=>S3({activeAttachmentsRef:A,attachmentsRef:_,contextRef:$,toolsetRef:V,modeRef:U,sessionIdRef:k,providerRef:O,modelRef:P})}),[]),Z=j3({id:t,messages:n,transport:q,onFinish:B=>N3(j,B),onError:B=>k3(N,B)}),H=g.useRef(E3(n)),L=g.useCallback(()=>{const B=crypto.randomUUID();k.current=B,m?.(B),H.current.clear(),Z.setMessages([])},[Z,m]),{messages:z}=Z;return g.useEffect(()=>{if(w.current){for(const B of z)if(B.role==="assistant"){for(const X of B.parts??[])if(X&&bi(X)){if("state"in X&&X.state==="input-streaming")continue;const W=X.toolCallId;if(!H.current.has(W)){H.current.add(W);const I=aC(X);w.current?.(I,X.input??{})}}}}},[z]),{messages:z,sendMessage:Z.sendMessage,stop:Z.stop,status:Z.status,setMessages:Z.setMessages,clearChat:L,error:Z.error,mode:R,attachments:u??[],activeAttachments:T,toggleAttachment:S}}function T3({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 C3({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)}})}function oy(e={}){const{url:t="ws://localhost:3600",healthUrl:n,systemPrompt:s,cwd:a,workspaceFiles:l,autoConnect:u=!1,sessionKey:d,orphanTTL:p,backend:h,tmuxSession:m,agent:y,provider:b,model:w}=e,j=d?`hudson.relay.${d}`:null,N=()=>{if(!j)return null;try{return localStorage.getItem(j)}catch{return null}},k=de=>{if(j)try{de?localStorage.setItem(j,de):localStorage.removeItem(j)}catch{}},[T,E]=g.useState("disconnected"),[S,M]=g.useState(null),[R,A]=g.useState(null),[_,$]=g.useState(null),[V,U]=g.useState(a||"~"),O=g.useRef(null),P=g.useRef(null),q=g.useRef({cols:80,rows:24}),Z=g.useRef(!1),H=g.useRef(""),L=g.useRef(0),z=g.useRef(V);z.current=V;const B=g.useRef(N()),X=g.useRef(null),W=512*1024,I=g.useCallback(de=>{if(de){if(X.current){X.current(de);return}H.current+=de,H.current.length>W&&(H.current=H.current.slice(-W))}},[]),F=g.useCallback(de=>{const Le=O.current;Le&&Le.readyState===WebSocket.OPEN&&Le.send(JSON.stringify(de))},[]),G=g.useCallback(()=>{const de=O.current;de&&(de.close(),O.current=null)},[]),J=g.useCallback(()=>{L.current+=1,P.current&&(clearTimeout(P.current),P.current=null),G(),Z.current=!1,E("disconnected")},[G]),ce=g.useCallback(()=>{const de=z.current;return{type:"session:init",cols:q.current.cols,rows:q.current.rows,...s?{systemPrompt:s}:{},...de?{cwd:de}:{},...l?{workspaceFiles:l}:{},...p?{orphanTTL:p}:{},...h?{backend:h}:{},...m?{tmuxSession:m}:{},...y?{agent:y}:{},...b?{provider:b}:{},...w?{model:w}:{}}},[s,l,p,h,m,y,b,w]),se=g.useCallback(()=>{Z.current||(Z.current=!0,B.current?F({type:"session:reconnect",sessionId:B.current,cols:q.current.cols,rows:q.current.rows}):F(ce()))},[F,ce]),ve=g.useCallback(async()=>{const de=L.current+1;L.current=de,G(),Z.current=!1,E("connecting"),A(null),$(null);const Le=n||`${t.replace(/^ws(s?):\/\//,"http$1://")}/health`;try{await fetch(Le,{signal:AbortSignal.timeout(2e3)})}catch{if(L.current!==de)return;E("error"),A("Relay service is not running");return}if(L.current!==de)return;G();const Te=new WebSocket(t);O.current=Te;const we=()=>L.current===de&&O.current===Te;Te.onopen=()=>{if(!we()){Te.close();return}se()},Te.onmessage=Ne=>{if(we())try{const _e=JSON.parse(Ne.data);switch(_e.type){case"session:ready":B.current=_e.sessionId,k(_e.sessionId),M(_e.sessionId),E("connected"),A(null),$(null);break;case"session:expired":{B.current=null,k(null),Z.current=!1,I("\x1B[2J\x1B[H"),F(ce()),Z.current=!0;break}case"session:error":E("error"),A(_e.error||"Session failed to start");break;case"terminal:data":_e.data&&I(_e.data);break;case"session:exit":B.current=null,k(null),M(null),$(_e.exitCode??null),_e.exitCode!==0?(E("error"),A(_e.reason||`Process exited with code ${_e.exitCode}`)):E("disconnected");break;case"session:detached":B.current=null,k(null),M(null);break}}catch{}},Te.onclose=()=>{we()&&(O.current=null,Z.current=!1,E(Ne=>Ne==="error"?Ne:"disconnected"))},Te.onerror=()=>{we()&&(E("error"),A("Could not connect to relay"))}},[t,n,se,G,F,s,l]),me=g.useCallback(de=>{F({type:"terminal:input",data:de})},[F]),je=g.useCallback(de=>{F({type:"terminal:input",data:de+"\r"})},[F]),Ae=g.useCallback((de,Le)=>{q.current={cols:de,rows:Le},Z.current&&F({type:"terminal:resize",cols:de,rows:Le})},[F]),he=g.useCallback(de=>{X.current=de,!(!de||H.current.length===0)&&(de(H.current),H.current="")},[]);g.useEffect(()=>(u&&ve(),()=>{J()}),[]);const ue=g.useCallback(()=>{J(),B.current=null,M(null),k(null),A(null),$(null),setTimeout(()=>ve(),200)},[J,ve]);return{status:T,sessionId:S,error:R,exitCode:_,cwd:V,setCwd:U,onData:he,sendInput:me,sendLine:je,resize:Ae,connect:ve,disconnect:J,restart:ue}}const lC=(...e)=>e.filter((t,n,s)=>!!t&&t.trim()!==""&&s.indexOf(t)===n).join(" ").trim();const A3=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const M3=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,s)=>s?s.toUpperCase():n.toLowerCase());const pj=e=>{const t=M3(e);return t.charAt(0).toUpperCase()+t.slice(1)};var R3={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 _3=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const O3=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,...R3,width:t,height:t,stroke:e,strokeWidth:s?Number(n)*24/Number(t):n,className:lC("lucide",a),...!l&&!_3(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(O3,{ref:l,iconNode:t,className:lC(`lucide-${A3(pj(e))}`,`lucide-${e}`,s),...a}));return n.displayName=pj(e),n};const I3=[["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"}]],D3=Zt("circle-alert",I3);const P3=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],z3=Zt("clock",P3);const L3=[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]],$3=Zt("corner-down-left",L3);const U3=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],mj=Zt("loader-circle",U3);const B3=[["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"}]],V3=Zt("map",B3);const F3=[["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"}]],cC=Zt("maximize-2",F3);const H3=[["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"}]],q3=Zt("mic",H3);const Z3=[["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"}]],W3=Zt("minimize-2",Z3);const Y3=[["path",{d:"M5 12h14",key:"1ays0h"}]],G3=Zt("minus",Y3);const K3=[["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"}]],X3=Zt("panel-left-close",K3);const J3=[["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"}]],Q3=Zt("panel-left-open",J3);const eL=[["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"}]],tL=Zt("panel-right-close",eL);const nL=[["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"}]],sL=Zt("panel-right-open",nL);const rL=[["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"}]],aL=Zt("paperclip",rL);const iL=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],oL=Zt("plus",iL);const lL=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],ly=Zt("search",lL);const cL=[["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"}]],uL=Zt("sparkles",cL);const dL=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],uC=Zt("square",dL);const fL=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],hL=Zt("terminal",fL);const pL=[["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"}]],mL=Zt("trash-2",pL);const gL=[["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"}]],vL=Zt("volume-2",gL);const yL=[["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"}]],xL=Zt("volume-x",yL);const bL=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],dC=Zt("x",bL);function wL({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:b,activeAttachments:w,toggleAttachment:j}=e,[N,k]=g.useState(""),T=a!==void 0,E=T?a:N,S=U=>{T?l?.(U):k(U)},M=g.useRef(null),R=g.useRef(null),A=h==="streaming"||h==="submitted",_=b.length>0;g.useEffect(()=>{const U=M.current;U&&(U.scrollTop=U.scrollHeight)},[u]),g.useEffect(()=>{R.current?.focus()},[]);const $=U=>{U.preventDefault();const O=E.trim();!O||A||(S(""),d({text:O}))},V=U=>{U.stopPropagation(),U.key==="Enter"&&!U.shiftKey&&(U.preventDefault(),$(U))};return o.jsxs("div",{className:"flex flex-col h-full font-mono text-[12px]",children:[o.jsxs("div",{ref:M,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,P)=>{if(!O)return null;if(O.type==="text")return o.jsx("span",{children:O.text},P);if(bi(O)){const q=aC(O),Z=Object.entries(O.input??{}).map(([H,L])=>`${H}: ${JSON.stringify(L)}`).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:"↳ "}),q,"(",Z,")"]},P)}return null})})},U.id)),A&&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(D3,{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(aL,{size:11,className:"text-neutral-500 shrink-0"}),b.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:$,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(mL,{size:12})}),o.jsx("input",{ref:R,type:"text",value:E,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:A}),A?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(uC,{size:12})}):o.jsx("button",{type:"submit",disabled:!E.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 jL="modulepreload",SL=function(e){return"/"+e},gj={},Zd=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=SL(h),h in gj)return;gj[h]=!0;const m=h.endsWith(".css"),y=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${y}`))return;const b=document.createElement("link");if(b.rel=m?"stylesheet":jL,m||(b.as="script"),b.crossOrigin="",b.href=h,d&&b.setAttribute("nonce",d),document.head.appendChild(b),m)return new Promise((w,j)=>{b.addEventListener("load",w),b.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)})},NL={titleBarInset:0,dragRegionProps:{},onInteractiveMouseDown:void 0,isSSR:!0,apiBaseUrl:"",serviceApiUrl:""},kL=g.createContext(NL);function Qf(){return g.useContext(kL)}const EL={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"},CL=`
|
|
66
|
-
.xterm { cursor: text; position: relative; user-select: none; -ms-user-select: none; -webkit-user-select: none; }
|
|
67
|
-
.xterm.focus, .xterm:focus { outline: none; }
|
|
68
|
-
.xterm .xterm-helpers { position: absolute; top: 0; z-index: 5; }
|
|
69
|
-
.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; }
|
|
70
|
-
.xterm .composition-view { background: #000; color: #FFF; display: none; position: absolute; white-space: nowrap; z-index: 1; }
|
|
71
|
-
.xterm .composition-view.active { display: block; }
|
|
72
|
-
.xterm .xterm-viewport { background-color: #000; overflow-y: scroll; cursor: default; position: absolute; right: 0; left: 0; top: 0; bottom: 0; }
|
|
73
|
-
.xterm .xterm-screen { position: relative; }
|
|
74
|
-
.xterm .xterm-screen canvas { position: absolute; left: 0; top: 0; }
|
|
75
|
-
.xterm-char-measure-element { display: inline-block; visibility: hidden; position: absolute; top: 0; left: -9999em; line-height: normal; }
|
|
76
|
-
.xterm.enable-mouse-events { cursor: default; }
|
|
77
|
-
.xterm.xterm-cursor-pointer, .xterm .xterm-cursor-pointer { cursor: pointer; }
|
|
78
|
-
.xterm.column-select.focus { cursor: crosshair; }
|
|
79
|
-
.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; }
|
|
80
|
-
.xterm .xterm-accessibility-tree:not(.debug) *::selection { color: transparent; }
|
|
81
|
-
.xterm .xterm-accessibility-tree { font-family: monospace; user-select: text; white-space: pre; }
|
|
82
|
-
.xterm .xterm-accessibility-tree > div { transform-origin: left; width: fit-content; }
|
|
83
|
-
.xterm .live-region { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
|
|
84
|
-
.xterm-dim { opacity: 1 !important; }
|
|
85
|
-
.xterm-underline-1 { text-decoration: underline; }
|
|
86
|
-
.xterm-underline-2 { text-decoration: double underline; }
|
|
87
|
-
.xterm-underline-3 { text-decoration: wavy underline; }
|
|
88
|
-
.xterm-underline-4 { text-decoration: dotted underline; }
|
|
89
|
-
.xterm-underline-5 { text-decoration: dashed underline; }
|
|
90
|
-
.xterm-overline { text-decoration: overline; }
|
|
91
|
-
.xterm-overline.xterm-underline-1 { text-decoration: overline underline; }
|
|
92
|
-
.xterm-overline.xterm-underline-2 { text-decoration: overline double underline; }
|
|
93
|
-
.xterm-overline.xterm-underline-3 { text-decoration: overline wavy underline; }
|
|
94
|
-
.xterm-overline.xterm-underline-4 { text-decoration: overline dotted underline; }
|
|
95
|
-
.xterm-overline.xterm-underline-5 { text-decoration: overline dashed underline; }
|
|
96
|
-
.xterm-strikethrough { text-decoration: line-through; }
|
|
97
|
-
.xterm-screen .xterm-decoration-container .xterm-decoration { z-index: 6; position: absolute; }
|
|
98
|
-
.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer { z-index: 7; }
|
|
99
|
-
.xterm-decoration-overview-ruler { z-index: 8; position: absolute; top: 0; right: 0; pointer-events: none; }
|
|
100
|
-
.xterm-decoration-top { z-index: 2; position: relative; }
|
|
101
|
-
.xterm .xterm-scrollable-element > .scrollbar { cursor: default; }
|
|
102
|
-
.xterm .xterm-scrollable-element > .scrollbar > .scra { cursor: pointer; font-size: 11px !important; }
|
|
103
|
-
.xterm .xterm-scrollable-element > .visible { opacity: 1; background: rgba(0,0,0,0); transition: opacity 100ms linear; z-index: 11; }
|
|
104
|
-
.xterm .xterm-scrollable-element > .invisible { opacity: 0; pointer-events: none; }
|
|
105
|
-
.xterm .xterm-scrollable-element > .invisible.fade { transition: opacity 800ms linear; }
|
|
106
|
-
.xterm .xterm-scrollable-element > .shadow { position: absolute; display: none; }
|
|
107
|
-
.xterm .xterm-scrollable-element > .shadow.top { display: block; top: 0; left: 3px; height: 3px; width: 100%; }
|
|
108
|
-
.xterm .xterm-scrollable-element > .shadow.left { display: block; top: 3px; left: 0; height: 100%; width: 3px; }
|
|
109
|
-
`;function TL(){if(typeof document>"u"||document.querySelector("[data-xterm-css]"))return;const e=document.createElement("style");e.setAttribute("data-xterm-css",""),e.textContent=CL,document.head.appendChild(e)}function AL(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 cy({relay:e,fontSize:t=12,fontFamily:n="'JetBrains Mono', 'Hack Nerd Font', monospace",configItems:s,onOpenSettings:a,onStartService:l,quiet:u=!1}){const{status:d,error:p,exitCode:h,cwd:m,setCwd:y,sendInput:b,resize:w,onData:j,connect:N,disconnect:k}=e,[T,E]=g.useState(!1),{apiBaseUrl:S}=Qf(),M=g.useRef(null),R=g.useRef(null),A=g.useRef(null),_=g.useRef(null),[$,V]=g.useState(!1),[U,O]=g.useState(!1),P=g.useRef(0);g.useEffect(()=>{const G=M.current;if(!G)return;const J=ce=>{ce.key===" "&&!ce.metaKey&&!ce.ctrlKey&&!ce.altKey&&ce.stopPropagation()};return G.addEventListener("keydown",J),()=>G.removeEventListener("keydown",J)},[]);const q=`${S}/api/relay/upload`,Z=g.useCallback(async G=>{try{const J=await AL(G),ce=await fetch(q,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:G.name,data:J})}),{path:se}=await ce.json();return se||null}catch(J){return console.error("File upload failed:",J),null}},[q]);g.useEffect(()=>{const G=M.current;if(!G)return;const J=async ce=>{if(!ce.clipboardData)return;const se=Array.from(ce.clipboardData.items).filter(ve=>ve.type.startsWith("image/"));if(se.length!==0){ce.preventDefault(),ce.stopPropagation();for(const ve of se){const me=ve.getAsFile();if(!me)continue;const je=await Z(me);je&&b(je)}}};return G.addEventListener("paste",J),()=>G.removeEventListener("paste",J)},[b,Z]);const H=g.useCallback(G=>{G.preventDefault(),G.dataTransfer.dropEffect="copy"},[]),L=g.useCallback(G=>{G.preventDefault(),P.current++,G.dataTransfer.types.includes("Files")&&O(!0)},[]),z=g.useCallback(G=>{G.preventDefault(),P.current--,P.current===0&&O(!1)},[]),B=g.useCallback(async G=>{G.preventDefault(),P.current=0,O(!1);const J=Array.from(G.dataTransfer.files).filter(ce=>ce.type.startsWith("image/"));if(J.length!==0)for(const ce of J){const se=await Z(ce);se&&b(se)}},[b,Z]);g.useEffect(()=>{let G=!1,J=null;async function ce(){const[{Terminal:se},{FitAddon:ve},me]=await Promise.all([Zd(()=>import("./xterm-B-qIQCd3.js"),[]),Zd(()=>import("./addon-fit-DX4qG4td.js"),[]),Zd(()=>import("./addon-webgl-DCtw1yLn.js"),[]).catch(()=>null)]);if(TL(),G||!R.current)return;J=new se({fontSize:t,fontFamily:n,theme:EL,cursorBlink:!0,cursorStyle:"bar",allowTransparency:!0,scrollback:5e3,convertEol:!1,allowProposedApi:!0});const je=new ve;if(J.loadAddon(je),J.open(R.current),me)try{const Ae=new me.WebglAddon;Ae.onContextLoss(()=>{Ae.dispose()}),J.loadAddon(Ae)}catch{}try{je.fit()}catch{}A.current=J,_.current=je,w(J.cols,J.rows),J.onData(Ae=>{b(Ae)}),V(!0)}return ce(),()=>{G=!0,J&&(J.dispose(),A.current=null,_.current=null)}},[]),g.useEffect(()=>{const G=A.current;if(G){G.options.fontSize=t,G.options.fontFamily=n;try{_.current?.fit()}catch{}}},[t,n]),g.useEffect(()=>{if($)return j(G=>{A.current?.write(G)}),()=>{j(null)}},[$,j]),g.useEffect(()=>{const G=R.current;if(!G||!$)return;const J=new ResizeObserver(()=>{const ce=_.current,se=A.current;if(!(!ce||!se))try{ce.fit(),w(se.cols,se.rows)}catch{}});return J.observe(G),()=>J.disconnect()},[$,w]),g.useEffect(()=>{d==="connected"&&A.current&&A.current.focus()},[d]);const X=g.useCallback(()=>{d==="connected"&&A.current&&A.current.focus()},[d]),W=d==="error"&&p==="Relay service is not running",I=g.useCallback(async()=>{if(l){E(!0);try{await l()&&setTimeout(()=>N(),500)}finally{E(!1)}}},[l,N]);let F=null;return W?F=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:I,disabled:T,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:T?"Starting...":"Start Service"}),o.jsx("button",{type:"button",onClick:()=>N(),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"})]})]}):d==="error"&&p?F=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:p}),h!==null&&h!==0&&o.jsxs("span",{className:"text-[10px] text-neutral-600",children:["Exit code ",h]}),o.jsx("button",{type:"button",onClick:()=>N(),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"})]}):d==="disconnected"&&!u?F=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:G=>{G.preventDefault(),N()},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:m,onChange:G=>y(G.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(G=>o.jsxs("div",{className:"contents",children:[o.jsx("span",{className:"text-neutral-500",children:G.label}),o.jsx("span",{className:"text-neutral-400 truncate text-left",children:G.value})]},G.label))}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{type:"button",onClick:()=>N(),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"})]})]}):d==="connecting"&&!u&&(F=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:()=>{k()},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:M,className:"relative flex flex-col h-full overflow-hidden",onClick:X,onDragOver:H,onDragEnter:L,onDragLeave:z,onDrop:B,children:[F&&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:F}),U&&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:F?"hidden":"visible",padding:"4px 8px"}})]})}function ML({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:b,voiceKit:w}){const[j,N]=Ir(`assistant.${e.id}.mode`,"relay"),[k,T]=g.useState(""),[E,S]=Ir(`assistant.${e.id}.voice.speakReplies`,w?.settings.speakReplies??!1),{serviceApiUrl:M}=Qf(),R=g.useMemo(()=>_L(e),[e]),A=oy({url:s,systemPrompt:R,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}),_=g.useCallback(async()=>{if(b)return b();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}},[b,M]),$=g.useMemo(()=>{const B=[{label:"Relay",value:s},{label:"Agent",value:l}];return a&&B.push({label:"CWD",value:a}),l==="pi"&&d&&B.push({label:"Model",value:d}),B},[s,l,a,d]),[V,U]=g.useState("text"),O=T3({app:e,commands:t,state:n,provider:u,model:d,onFinish:({message:B,isAbort:X,isDisconnect:W,isError:I})=>{!w||!E||X||W||I||B.role==="assistant"&&w.speakReply(B,{surface:"hudson-assistant",appId:e.id,source:V})}}),P=g.useCallback(B=>{if(!w)return;const X=[k.trim(),B].filter(Boolean).join(" ");w.settings.autoSend&&O.status!=="streaming"&&O.status!=="submitted"?(T(""),U("voice"),O.sendMessage({text:X})):T(X)},[w,k,O]),q=g.useCallback(()=>{w&&(w.input.status==="recording"?w.input.stop():w.input.start(P))},[w,P]),Z=e.intents?.length??0,H=!!w,L=w?.input.status==="transcribing",z=w?.input.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(uL,{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"}),H&&j==="chat"&&o.jsx("button",{type:"button",onClick:()=>{E&&w?.output.stop(),S(!E)},className:`p-1 rounded transition-colors ${E?"text-cyan-300 hover:text-cyan-200":"text-neutral-500 hover:text-neutral-300"}`,title:E?"Speaker on (click to mute)":"Speaker off (click to enable)",children:w?.output.isPlaying?o.jsx(mj,{size:12,className:"animate-spin"}):E?o.jsx(vL,{size:12}):o.jsx(xL,{size:12})}),o.jsxs("div",{className:"flex items-center gap-1 rounded-full border border-neutral-700 p-0.5",children:[o.jsx(yj,{active:j==="relay",onClick:()=>N("relay"),children:"Relay"}),o.jsx(yj,{active:j==="chat",onClick:()=>N("chat"),children:"Chat"})]}),j==="relay"&&A.status==="connected"&&o.jsx("button",{type:"button",onClick:()=>A.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"}),j==="relay"&&A.status==="connected"&&o.jsx("button",{type:"button",onClick:()=>A.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"}),j==="relay"&&A.status!=="connected"&&A.status!=="connecting"&&o.jsx("button",{type:"button",onClick:()=>A.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:j==="relay"?o.jsx(cy,{relay:A,configItems:$,onOpenSettings:y,onStartService:_}):o.jsx(wL,{chat:O,placeholder:Z===0?`Ask about ${e.name} — no intents declared, conversation only.`:`Ask ${e.name} to do something… (${Z} intent${Z===1?"":"s"})`,inputValue:k,onInputChange:B=>{V==="voice"&&B.length===0&&U("text"),T(B)},inputExtras:H&&w?.input.isSupported?o.jsx("button",{type:"button",onClick:q,disabled:L,className:`p-1 rounded transition-colors disabled:opacity-30 ${z?"bg-red-500/15 text-red-300 hover:bg-red-500/20":"text-neutral-500 hover:text-cyan-400"}`,title:z?"Stop recording":"Record voice prompt",children:L?o.jsx(mj,{size:12,className:"animate-spin"}):z?o.jsx(uC,{size:11}):o.jsx(q3,{size:12})}):void 0,inputStatus:H&&w?o.jsx(RL,{inputStatus:w.input.status,inputError:w.input.error,outputStatus:w.output.status,outputError:w.output.error}):void 0})})]})}function RL({inputStatus:e,inputError:t,outputStatus:n,outputError:s}){const a=vj(e)??vj(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 vj(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 yj({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 _L(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(`
|
|
110
|
-
`)}typeof window<"u"&&localStorage.getItem("frame_sounds");const eh={panels:{statusBar:"bg-neutral-950/95 backdrop-blur-xl border-t border-neutral-700 shadow-[0_-5px_30px_rgba(0,0,0,0.6),inset_0_1px_0_rgba(255,255,255,0.06)] fixed bottom-0 left-0 right-0 z-[60]"},zIndex:{drawer:70},layout:{navHeight:48,statusBarHeight:28}},OL=eh.panels;function uy(){const{titleBarInset:e}=Qf();return g.useMemo(()=>{const t=eh.layout.navHeight+e;return{navTotalHeight:t,panelTopOffset:t}},[e])}const IL=({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),[b,w]=g.useState(!1),j=g.useRef(!1),N=g.useRef({x:0,y:0}),k=g.useRef({active:!1,startX:0,startY:0}),T=g.useRef(null),E=g.useRef(null),S=g.useRef(null),M=4,R=g.useRef({x:0,y:0}),A=g.useRef(0),_=g.useRef(!1);g.useEffect(()=>{y(d)},[d]);const $=g.useCallback(W=>{const I=W;return I?I.tagName==="INPUT"||I.tagName==="TEXTAREA"||I.isContentEditable:!1},[]),V=g.useCallback(W=>{const I=W;return I?!!I.closest('button, [role="button"], a, input, textarea, select, [data-interactive="true"]'):!1},[]),U=g.useCallback(W=>{j.current=W,w(W)},[]);g.useEffect(()=>{const W=J=>{if(A.current=J.buttons,k.current.active&&(J.buttons&1)!==1&&(k.current.active=!1),j.current&&(J.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 ce=T.current?.getBoundingClientRect(),se=ce?J.clientX-ce.left:J.clientX,ve=ce?J.clientY-ce.top:J.clientY;if(R.current={x:se,y:ve},E.current&&(E.current.style.left=`${se}px`),S.current&&(S.current.style.top=`${ve}px`),k.current.active&&!j.current){const me=J.clientX-k.current.startX,je=J.clientY-k.current.startY;Math.hypot(me,je)>=M&&(k.current.active=!1,U(!0),_.current=!0,s?.(),N.current={x:J.clientX,y:J.clientY},document.body.style.cursor="grabbing")}j.current&&(n({x:(J.clientX-N.current.x)/t,y:(J.clientY-N.current.y)/t}),N.current={x:J.clientX,y:J.clientY})},I=J=>{A.current=J.buttons,k.current.active=!1,j.current&&(U(!1),a?.(),document.body.style.cursor="")},F=J=>{(J.metaKey||J.ctrlKey)&&J.key==="\\"&&(J.preventDefault(),y(ce=>{const se=!ce;return p?.(se),se}))},G=()=>{k.current.active=!1,I(new MouseEvent("mouseup"))};return window.addEventListener("mousemove",W),window.addEventListener("mouseup",I),window.addEventListener("keydown",F),window.addEventListener("blur",G),document.addEventListener("visibilitychange",G),()=>{window.removeEventListener("mousemove",W),window.removeEventListener("mouseup",I),window.removeEventListener("keydown",F),window.removeEventListener("blur",G),document.removeEventListener("visibilitychange",G)}},[n,a,s,t,$,V,l,U,p]),g.useEffect(()=>{!l||!j.current||(U(!1),a?.(),document.body.style.cursor="")},[l,a,U]);const O=W=>{_.current=!1,!(l||W.button!==0)&&($(W.target)||V(W.target)||(A.current=W.buttons,k.current={active:!0,startX:W.clientX,startY:W.clientY},W.preventDefault()))},P=W=>{!_.current&&u&&u(W),_.current=!1},[q,Z]=g.useState({w:0,h:0});g.useEffect(()=>{const W=()=>Z({w:window.innerWidth,h:window.innerHeight});return W(),window.addEventListener("resize",W),()=>window.removeEventListener("resize",W)},[]);const H=Math.max(.4,Math.min(2,t)),L=100*H,z=20*H,B=(q.w/2+e.x*t)%L,X=(q.h/2+e.y*t)%L;return o.jsxs("div",{ref:T,className:`absolute inset-0 z-0 overflow-hidden bg-black ${b?"cursor-grabbing":"cursor-grab"}`,onMouseDown:O,onClick:P,children:[o.jsx("div",{className:"absolute pointer-events-none",style:{inset:"-100px",opacity:.5*h,transition:"opacity 1s ease",backgroundImage:"radial-gradient(circle, #444 1px, transparent 1px)",backgroundSize:`${z}px ${z}px`,backgroundPosition:`${B+100}px ${X+100}px`}}),o.jsx("div",{className:"absolute pointer-events-none",style:{inset:"-100px",opacity:.25*h,transition:"opacity 1s ease",backgroundImage:"radial-gradient(circle, #555 1px, transparent 1px)",backgroundSize:`${L}px ${L}px`,backgroundPosition:`${B+100}px ${X+100}px`}}),m&&o.jsxs(o.Fragment,{children:[o.jsx("div",{ref:E,className:"absolute top-0 bottom-0 w-px pointer-events-none bg-emerald-500/10",style:{left:0}}),o.jsx("div",{ref:S,className:"absolute left-0 right-0 h-px pointer-events-none bg-emerald-500/10",style:{top:0}})]})]})},DL=({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]),b=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-neutral-950/95 backdrop-blur-xl border border-neutral-700/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-white/10 text-neutral-300 hover:text-white transition-colors",title:"Zoom in",children:o.jsx(oL,{size:14})}),o.jsx("div",{className:"w-full border-t border-b border-neutral-700/50",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-white bg-black/60 outline-none tabular-nums"}):o.jsxs("button",{onClick:w,className:"w-9 py-1.5 text-center text-[11px] font-mono text-neutral-200 hover:text-white hover:bg-white/10 transition-colors cursor-text tabular-nums",title:"Click to set zoom",children:[Math.round(e*100),"%"]})}),o.jsx("button",{onClick:b,className:"w-9 h-8 flex items-center justify-center hover:bg-white/10 text-neutral-300 hover:text-white transition-colors",title:"Zoom out",children:o.jsx(G3,{size:14})})]})},PL={...kk};let xj=0;function zL(e,t="mui"){const[n,s]=g.useState(e),a=e||n;return g.useEffect(()=>{n==null&&(xj+=1,s(`${t}-${xj}`))},[n,t]),a}const bj=PL.useId;function _a(e,t){if(bj!==void 0){const n=bj();return e??(t?`${t}-${n}`:n)}return zL(e,t)}function Ei(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 fC=g.createContext(void 0);function th(e=!0){const t=g.useContext(fC);if(t===void 0&&!e)throw new Error(Ei(25));return t}const hC=g.createContext(void 0);function pC(e){const t=g.useContext(hC);if(t===void 0&&!e)throw new Error(Ei(33));return t}const dy=g.createContext(void 0);function nl(e){const t=g.useContext(dy);if(t===void 0&&!e)throw new Error(Ei(36));return t}const wj={};function Ms(e,t){const n=g.useRef(wj);return n.current===wj&&(n.current=e(t)),n}function Rc(e,t,n,s){const a=Ms(mC).current;return $L(a,e,t,n,s)&&gC(a,[e,t,n,s]),a.callback}function LL(e){const t=Ms(mC).current;return UL(t,e)&&gC(t,e),t.callback}function mC(){return{callback:null,cleanup:null,refs:[]}}function $L(e,t,n,s,a){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==s||e.refs[3]!==a}function UL(e,t){return e.refs.length!==t.length||e.refs.some((n,s)=>n!==t[s])}function gC(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 BL=parseInt(g.version,10);function fy(e){return BL>=e}function jj(e){if(!g.isValidElement(e))return null;const t=e,n=t.props;return(fy(19)?n?.ref:t.ref)??null}function Jg(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function VL(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 FL(e,t){return typeof e=="function"?e(t):e}function HL(e,t){return typeof e=="function"?e(t):e}const mc={};function nh(e,t,n,s,a){let l={...Qg(e,mc)};return t&&(l=Wd(l,t)),n&&(l=Wd(l,n)),s&&(l=Wd(l,s)),l}function qL(e){if(e.length===0)return mc;if(e.length===1)return Qg(e[0],mc);let t={...Qg(e[0],mc)};for(let n=1;n<e.length;n+=1)t=Wd(t,e[n]);return t}function Wd(e,t){return vC(t)?t(e):ZL(e,t)}function ZL(e,t){if(!t)return e;for(const n in t){const s=t[n];switch(n){case"style":{e[n]=Jg(e.style,s);break}case"className":{e[n]=yC(e.className,s);break}default:WL(n,s)?e[n]=YL(e[n],s):e[n]=s}}return e}function WL(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 vC(e){return typeof e=="function"}function Qg(e,t){return vC(e)?e(t):e??mc}function YL(e,t){return t?e?n=>{if(GL(n)){const a=n;ev(a);const l=t(a);return a.baseUIHandlerPrevented||e?.(a),l}const s=t(n);return e?.(n),s}:t:e}function ev(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function yC(e,t){return t?e?t+" "+e:t:e}function GL(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}function xC(){}const bC=Object.freeze([]),Qn=Object.freeze({}),KL=500,XL={style:{transition:"none"}},JL="data-base-ui-click-trigger",QL={fallbackAxisSide:"none"},e$={clipPath:"inset(50%)",position:"fixed",top:0,left:0};function Oa(e,t,n={}){const s=t.render,a=t$(t,n);if(n.enabled===!1)return null;const l=n.state??Qn;return n$(e,s,a,l)}function t$(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?FL(n,l):void 0,y=h?HL(s,l):void 0,b=h?VL(l,p):Qn,w=h?Jg(b,Array.isArray(d)?qL(d):d)??Qn:Qn;return typeof document<"u"&&(h?Array.isArray(u)?w.ref=LL([w.ref,jj(a),...u]):w.ref=Rc(w.ref,jj(a),u):Rc(null,null)),h?(m!==void 0&&(w.className=yC(w.className,m)),y!==void 0&&(w.style=Jg(w.style,y)),w):Qn}function n$(e,t,n,s){if(t){if(typeof t=="function")return t(n,s);const a=nh(n,t.props);return a.ref=n.ref,g.cloneElement(t,a)}return s$(e,n)}function s$(e,t){return g.createElement(e,t)}let yf=(function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e})({});const r$={[yf.startingStyle]:""},a$={[yf.endingStyle]:""},i$={transitionStatus(e){return e==="starting"?r$:e==="ending"?a$:null}};let hy=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=yf.startingStyle]="startingStyle",e[e.endingStyle=yf.endingStyle]="endingStyle",e.anchorHidden="data-anchor-hidden",e})({}),Sj=(function(e){return e.popupOpen="data-popup-open",e.pressed="data-pressed",e})({});const o$={[Sj.popupOpen]:"",[Sj.pressed]:""},l$={[hy.open]:""},c$={[hy.closed]:""},u$={[hy.anchorHidden]:""},d$={open(e){return e?o$:null}},wC={open(e){return e?l$:c$},anchorHidden(e){return e?u$:null}},f$="none",xf="trigger-press",pi="trigger-hover",Nj="trigger-focus",py="outside-press",jC="item-press",sh="focus-out",SC="escape-key",Yd="list-navigation",h$="cancel-open",cc="sibling-open",p$="imperative-action",Um=kk[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],m$=Um&&Um!==g.useLayoutEffect?Um:e=>e();function Ke(e){const t=Ms(g$).current;return t.next=e,m$(t.effect),t.trampoline}function g$(){const e={next:void 0,callback:v$,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function v$(){}function rh(){return typeof window<"u"}function Ia(e){return my(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=(my(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function my(e){return rh()?e instanceof Node||e instanceof An(e).Node:!1}function Pt(e){return rh()?e instanceof Element||e instanceof An(e).Element:!1}function tn(e){return rh()?e instanceof HTMLElement||e instanceof An(e).HTMLElement:!1}function tv(e){return!rh()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof An(e).ShadowRoot}const y$=new Set(["inline","contents"]);function Ci(e){const{overflow:t,overflowX:n,overflowY:s,display:a}=hs(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&!y$.has(a)}const x$=new Set(["table","td","th"]);function b$(e){return x$.has(Ia(e))}const w$=[":popover-open",":modal"];function ah(e){return w$.some(t=>{try{return e.matches(t)}catch{return!1}})}const j$=["transform","translate","scale","rotate","perspective"],S$=["transform","translate","scale","rotate","perspective","filter"],N$=["paint","layout","strict","content"];function gy(e){const t=ih(),n=Pt(e)?hs(e):e;return j$.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)||S$.some(s=>(n.willChange||"").includes(s))||N$.some(s=>(n.contain||"").includes(s))}function k$(e){let t=cr(e);for(;tn(t)&&!ar(t);){if(gy(t))return t;if(ah(t))return null;t=cr(t)}return null}function ih(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const E$=new Set(["html","body","#document"]);function ar(e){return E$.has(Ia(e))}function hs(e){return An(e).getComputedStyle(e)}function oh(e){return Pt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function cr(e){if(Ia(e)==="html")return e;const t=e.assignedSlot||e.parentNode||tv(e)&&e.host||dr(e);return tv(t)?t.host:t}function NC(e){const t=cr(e);return ar(t)?e.ownerDocument?e.ownerDocument.body:e.body:tn(t)&&Ci(t)?t:NC(t)}function Sa(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const a=NC(e),l=a===((s=e.ownerDocument)==null?void 0:s.body),u=An(a);if(l){const d=nv(u);return t.concat(u,u.visualViewport||[],Ci(a)?a:[],d&&n?Sa(d):[])}return t.concat(a,Sa(a,[],n))}function nv(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const C$=()=>{},Ye=typeof document<"u"?g.useLayoutEffect:C$,T$=g.createContext(void 0);function A$(e=!1){const t=g.useContext(T$);if(t===void 0&&!e)throw new Error(Ei(16));return t}function M$(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 R$(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:s=0,native:a=!0}=e,l=g.useRef(null),u=A$(!0)!==void 0,d=Ke(()=>{const b=l.current;return!!(b?.tagName==="A"&&b?.href)}),{props:p}=M$({focusableWhenDisabled:n,disabled:t,composite:u,tabIndex:s,isNativeButton:a}),h=g.useCallback(()=>{const b=l.current;_$(b)&&u&&t&&p.disabled===void 0&&b.disabled&&(b.disabled=!1)},[t,p.disabled,u]);Ye(h,[h]);const m=g.useCallback((b={})=>{const{onClick:w,onMouseDown:j,onKeyUp:N,onKeyDown:k,onPointerDown:T,...E}=b;return nh({type:a?"button":void 0,onClick(M){if(t){M.preventDefault();return}w?.(M)},onMouseDown(M){t||j?.(M)},onKeyDown(M){if(t||(ev(M),k?.(M)),M.baseUIHandlerPrevented)return;const R=M.target===M.currentTarget&&!a&&!d()&&!t,A=M.key==="Enter",_=M.key===" ";R&&((_||A)&&M.preventDefault(),A&&w?.(M))},onKeyUp(M){t||(ev(M),N?.(M)),!M.baseUIHandlerPrevented&&M.target===M.currentTarget&&!a&&!t&&M.key===" "&&w?.(M)},onPointerDown(M){if(t){M.preventDefault();return}T?.(M)}},a?void 0:{role:"button"},p,E)},[t,p,a,d]),y=Ke(b=>{l.current=b,h()});return{getButtonProps:m,buttonRef:y}}function _$(e){return tn(e)&&e.tagName==="BUTTON"}const O$={type:"regular-item"};function I$(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=th(!0),y=m!==void 0,{events:b}=l.useState("floatingTreeRoot"),{getButtonProps:w,buttonRef:j}=R$({disabled:n,focusableWhenDisabled:!0,native:u}),N=g.useCallback(T=>nh({id:a,role:"menuitem",tabIndex:s?0:-1,onMouseMove(E){p&&b.emit("itemhover",{nodeId:p,target:E.currentTarget})},onMouseEnter(){d.type==="submenu-trigger"&&d.setActive()},onKeyUp(E){E.key===" "&&l.context.typingRef.current&&E.preventBaseUIHandler()},onClick(E){t&&b.emit("close",{domEvent:E,reason:jC})},onMouseUp(E){if(m){const S=m.initialCursorPointRef.current;if(m.initialCursorPointRef.current=null,y&&S&&Math.abs(E.clientX-S.x)<=1&&Math.abs(E.clientY-S.y)<=1)return}h.current&&l.context.allowMouseUpTriggerRef.current&&(!y||E.button===2)&&d.type==="regular-item"&&h.current.click()}},T,w),[a,s,w,t,b,l,y,m,d,p]),k=Rc(h,j);return g.useMemo(()=>({getItemProps:N,itemRef:k}),[N,k])}const kC=g.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function D$(){return g.useContext(kC)}let P$=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function z$(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}=D$(),b=g.useRef(-1),[w,j]=g.useState(l??(a===P$.GuessFromOrder?()=>{if(b.current===-1){const T=y.current;y.current+=1,b.current=T}return b.current}:-1)),N=g.useRef(null),k=g.useCallback(T=>{if(N.current=T,w!==-1&&T!==null&&(h.current[w]=T,m)){const E=t!==void 0;m.current[w]=E?t:s?.current?.textContent??T.textContent}},[w,h,m,t,s]);return Ye(()=>{if(l!=null)return;const T=N.current;if(T)return u(T,n),()=>{d(T)}},[l,u,d,n]),Ye(()=>{if(l==null)return p(T=>{const E=N.current?T.get(N.current)?.index:null;E!=null&&j(E)})},[l,p,j]),g.useMemo(()=>({ref:k,index:w}),[w,k])}function EC(e){return _a(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 wi=Ek();const L$=[];function CC(e){g.useEffect(e,L$)}const gd=null;class $${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 vd=new $$;class rr{static create(){return new rr}static request(t){return vd.request(t)}static cancel(t){return vd.cancel(t)}currentId=gd;request(t){this.cancel(),this.currentId=vd.request(()=>{this.currentId=gd,t()})}cancel=()=>{this.currentId!==gd&&(vd.cancel(this.currentId),this.currentId=gd)};disposeEffect=()=>this.cancel}function vy(){const e=Ms(rr.create).current;return CC(e.disposeEffect),e}function U$(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(()=>{wi.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=Ms(B$,e).current;return t.next=e,Ye(t.effect),t}function B$(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}function ai(e){return e==null?e:"current"in e?e.current:e}function V$(e,t=!1,n=!0){const s=vy();return Ke((a,l=null)=>{s.cancel();const u=ai(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||wi.flushSync(a)}).catch(()=>{if(n){if(l!=null&&l.aborted)return;wi.flushSync(a)}else u.getAnimations().length>0&&u.getAnimations().some(p=>p.pending||p.playState!=="finished")&&d()})}t?s.request(d):d()}))})}function TC(e){const{enabled:t=!0,open:n,ref:s,onComplete:a}=e,l=Xn(n),u=Ke(a),d=V$(s,n);g.useEffect(()=>{t&&d(()=>{n===l.current&&u()})},[t,n,u,d,l])}const AC=g.createContext(void 0);function F$(){const e=g.useContext(AC);if(e===void 0)throw new Error(Ei(31));return e}const H$=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=Oa("div",t,{ref:n,props:{role:"group","aria-labelledby":u,...l}});return o.jsx(AC.Provider,{value:p,children:h})}),q$=g.forwardRef(function(t,n){const{className:s,render:a,id:l,...u}=t,d=EC(l),{setLabelId:p}=F$();return Ye(()=>(p(d),()=>{p(void 0)}),[p,d]),Oa("div",t,{ref:n,props:{id:d,role:"presentation",...u}})}),Z$=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=z$({label:u}),b=pC(!0),w=EC(l),{store:j}=nl(),N=j.useState("isActive",y.index),k=j.useState("itemProps"),{getItemProps:T,itemRef:E}=I$({closeOnClick:h,disabled:p,highlighted:N,id:w,store:j,nativeButton:d,nodeId:b?.nodeId,itemMetadata:O$}),S=g.useMemo(()=>({disabled:p,highlighted:N}),[p,N]);return Oa("div",t,{state:S,props:[k,m,T],ref:[E,n,y.ref]})}),Ql=0;class Ko{static create(){return new Ko}currentId=Ql;start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Ql,n()},t)}isStarted(){return this.currentId!==Ql}clear=()=>{this.currentId!==Ql&&(clearTimeout(this.currentId),this.currentId=Ql)};disposeEffect=()=>this.clear}function Fs(){const e=Ms(Ko.create).current;return CC(e.disposeEffect),e}const sl=typeof navigator<"u",Bm=X$(),MC=Q$(),RC=J$(),W$=typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter:none"),Y$=Bm.platform==="MacIntel"&&Bm.maxTouchPoints>1?!0:/iP(hone|ad|od)|iOS/.test(Bm.platform),G$=sl&&/apple/i.test(navigator.vendor),sv=sl&&/android/i.test(MC)||/android/i.test(RC);sl&&MC.toLowerCase().startsWith("mac")&&navigator.maxTouchPoints;const K$=RC.includes("jsdom/");function X$(){if(!sl)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 J$(){if(!sl)return"";const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:t,version:n})=>`${t}/${n}`).join(" "):navigator.userAgent}function Q$(){if(!sl)return"";const e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??""}const rv="data-base-ui-focusable",_C="active",OC="selected",IC="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",Na="ArrowLeft",ka="ArrowRight",yy="ArrowUp",qc="ArrowDown";function xa(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&&tv(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 e6(e){return e.matches("html,body")}function Cn(e){return e?.ownerDocument||document}function t6(e){return tn(e)&&e.matches(IC)}function av(e){return e?e.getAttribute("role")==="combobox"&&t6(e):!1}function bf(e){return e?e.hasAttribute(rv)?e:e.querySelector(`[${rv}]`)||e:null}function Fo(e,t,n=!0){return e.filter(a=>a.parentId===t&&(!n||a.context?.open)).flatMap(a=>[a,...Fo(e,a.id,n)])}function kj(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 n6(e){return"nativeEvent"in e}function DC(e){return e.mozInputSource===0&&e.isTrusted?!0:sv&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function PC(e){return K$?!1:!sv&&e.width===0&&e.height===0||sv&&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 s6(e,t){const n=["mouse","pen"];return n.push("",void 0),n.includes(e)}function r6(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}const a6=["top","right","bottom","left"],Xo=Math.min,cs=Math.max,wf=Math.round,Po=Math.floor,ir=e=>({x:e,y:e}),i6={left:"right",right:"left",bottom:"top",top:"bottom"},o6={start:"end",end:"start"};function iv(e,t,n){return cs(e,Xo(t,n))}function Lr(e,t){return typeof e=="function"?e(t):e}function ds(e){return e.split("-")[0]}function Da(e){return e.split("-")[1]}function xy(e){return e==="x"?"y":"x"}function by(e){return e==="y"?"height":"width"}const l6=new Set(["top","bottom"]);function Cs(e){return l6.has(ds(e))?"y":"x"}function wy(e){return xy(Cs(e))}function c6(e,t,n){n===void 0&&(n=!1);const s=Da(e),a=wy(e),l=by(a);let u=a==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[l]>t.floating[l]&&(u=jf(u)),[u,jf(u)]}function u6(e){const t=jf(e);return[ov(e),t,ov(t)]}function ov(e){return e.replace(/start|end/g,t=>o6[t])}const Ej=["left","right"],Cj=["right","left"],d6=["top","bottom"],f6=["bottom","top"];function h6(e,t,n){switch(e){case"top":case"bottom":return n?t?Cj:Ej:t?Ej:Cj;case"left":case"right":return t?d6:f6;default:return[]}}function p6(e,t,n,s){const a=Da(e);let l=h6(ds(e),n==="start",s);return a&&(l=l.map(u=>u+"-"+a),t&&(l=l.concat(l.map(ov)))),l}function jf(e){return e.replace(/left|right|bottom|top/g,t=>i6[t])}function m6(e){return{top:0,right:0,bottom:0,left:0,...e}}function zC(e){return typeof e!="number"?m6(e):{top:e,right:e,bottom:e,left:e}}function Sf(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 yd(e,t,n){return Math.floor(e/t)!==n}function gc(e,t){return t<0||t>=e.current.length}function Vm(e,t){return On(e,{disabledIndices:t})}function Tj(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&&vc(e,l,s));return l}function g6(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 b=[],w={};let j=!1;{let T=null,E=-1;e.current.forEach((S,M)=>{if(S==null)return;const R=S.closest('[role="row"]');R&&(j=!0),(R!==T||E===-1)&&(T=R,E+=1,b[E]=[]),b[E].push(M),w[M]=E})}const N=j&&b.length>0&&b.some(T=>T.length!==l);function k(T){if(!N||h===-1)return;const E=w[h];if(E==null)return;const S=b[E].indexOf(h);let M=T==="up"?E-1:E+1;s&&(M<0?M=b.length-1:M>=b.length&&(M=0));const R=new Set;for(;M>=0&&M<b.length&&!R.has(M);){R.add(M);const A=b[M];if(A.length===0){M=T==="up"?M-1:M+1;continue}const _=Math.min(S,A.length-1);for(let $=_;$>=0;$-=1){const V=A[$];if(!vc(e,V,u))return V}M=T==="up"?M-1:M+1,s&&(M<0?M=b.length-1:M>=b.length&&(M=0))}}if(t.key===yy){const T=k("up");if(T!==void 0)m&&Tn(t),y=T;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 E=h%l,S=p%l,M=p-(S-E);S===E?y=p:y=S>E?M:M-l}gc(e,y)&&(y=h)}}if(t.key===qc){const T=k("down");T!==void 0?(m&&Tn(t),y=T):(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}))),gc(e,y)&&(y=h))}if(n==="both"){const T=Po(h/l);t.key===(a?Na:ka)&&(m&&Tn(t),h%l!==l-1?(y=On(e,{startingIndex:h,disabledIndices:u}),s&&yd(y,l,T)&&(y=On(e,{startingIndex:h-h%l-1,disabledIndices:u}))):s&&(y=On(e,{startingIndex:h-h%l-1,disabledIndices:u})),yd(y,l,T)&&(y=h)),t.key===(a?ka:Na)&&(m&&Tn(t),h%l!==0?(y=On(e,{startingIndex:h,decrement:!0,disabledIndices:u}),s&&yd(y,l,T)&&(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})),yd(y,l,T)&&(y=h));const E=Po(p/l)===T;gc(e,y)&&(s&&E?y=t.key===(a?ka:Na)?p:On(e,{startingIndex:h-h%l-1,disabledIndices:u}):y=h)}return y}function v6(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 y6(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 x6(e,t){return t.flatMap((n,s)=>e.includes(n)?[s]:[])}function vc(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 b6=["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] *)"],Nf=b6.join(","),LC=typeof Element>"u",Jo=LC?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,kf=!LC&&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},Ef=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]"):Ef(t.parentNode));return u},w6=function(t){var n,s=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"contenteditable");return s===""||s==="true"},$C=function(t,n,s){if(Ef(t))return[];var a=Array.prototype.slice.apply(t.querySelectorAll(Nf));return n&&Jo.call(t,Nf)&&a.unshift(t),a=a.filter(s),a},Cf=function(t,n,s){for(var a=[],l=Array.from(t);l.length;){var u=l.shift();if(!Ef(u,!1))if(u.tagName==="SLOT"){var d=u.assignedElements(),p=d.length?d:u.children,h=Cf(p,!0,s);s.flatten?a.push.apply(a,h):a.push({scopeParent:u,candidates:h})}else{var m=Jo.call(u,Nf);m&&s.filter(u)&&(n||!t.includes(u))&&a.push(u);var y=u.shadowRoot||typeof s.getShadowRoot=="function"&&s.getShadowRoot(u),b=!Ef(y,!1)&&(!s.shadowRootFilter||s.shadowRootFilter(u));if(y&&b){var w=Cf(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},UC=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},BC=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||w6(t))&&!UC(t)?0:t.tabIndex},j6=function(t,n){var s=BC(t);return s<0&&n&&!UC(t)?0:s},S6=function(t,n){return t.tabIndex===n.tabIndex?t.documentOrder-n.documentOrder:t.tabIndex-n.tabIndex},VC=function(t){return t.tagName==="INPUT"},N6=function(t){return VC(t)&&t.type==="hidden"},k6=function(t){var n=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(s){return s.tagName==="SUMMARY"});return n},E6=function(t,n){for(var s=0;s<t.length;s++)if(t[s].checked&&t[s].form===n)return t[s]},C6=function(t){if(!t.name)return!0;var n=t.form||kf(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=E6(a,t.form);return!l||l===t},T6=function(t){return VC(t)&&t.type==="radio"},A6=function(t){return T6(t)&&!C6(t)},M6=function(t){var n,s=t&&kf(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=kf(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},Aj=function(t){var n=t.getBoundingClientRect(),s=n.width,a=n.height;return s===0&&a===0},R6=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=Jo.call(t,"details>summary:first-of-type"),d=u?t.parentElement:t;if(Jo.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=kf(t);if(h&&!h.shadowRoot&&a(h)===!0)return Aj(t);t.assignedSlot?t=t.assignedSlot:!h&&m!==t.ownerDocument?t=m.host:t=h}t=p}if(M6(t))return!t.getClientRects().length;if(s!=="legacy-full")return!0}else if(s==="non-zero-area")return Aj(t);return!1},_6=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 Jo.call(n,"fieldset[disabled] *")?!0:!a.contains(t)}return!0}n=n.parentElement}return!1},lv=function(t,n){return!(n.disabled||N6(n)||R6(n,t)||k6(n)||_6(n))},cv=function(t,n){return!(A6(n)||BC(n)<0||!lv(t,n))},O6=function(t){var n=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},FC=function(t){var n=[],s=[];return t.forEach(function(a,l){var u=!!a.scopeParent,d=u?a.scopeParent:a,p=j6(d,u),h=u?FC(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(S6).reduce(function(a,l){return l.isScope?a.push.apply(a,l.content):a.push(l.content),a},[]).concat(n)},lh=function(t,n){n=n||{};var s;return n.getShadowRoot?s=Cf([t],n.includeContainer,{filter:cv.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:O6}):s=$C(t,n.includeContainer,cv.bind(null,n)),FC(s)},I6=function(t,n){n=n||{};var s;return n.getShadowRoot?s=Cf([t],n.includeContainer,{filter:lv.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):s=$C(t,n.includeContainer,lv.bind(null,n)),s},HC=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return Jo.call(t,Nf)===!1?!1:cv(n,t)};const Zc=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function qC(e,t){const n=lh(e,Zc()),s=n.length;if(s===0)return;const a=xa(Cn(e)),l=n.indexOf(a),u=l===-1?t===1?0:s-1:l+t;return n[u]}function ZC(e){return qC(Cn(e).body,1)||e}function WC(e){return qC(Cn(e).body,-1)||e}function yc(e,t){const n=t||e.currentTarget,s=e.relatedTarget;return!s||!Dt(n,s)}function D6(e){lh(e,Zc()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function Mj(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 YC(){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 GC{nodesRef={current:[]};events=YC();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 KC=g.createContext(null),XC=g.createContext(null),Pa=()=>g.useContext(KC)?.id||null,rl=e=>{const t=g.useContext(XC);return e??t};function P6(e){const t=_a(),n=rl(e),s=Pa();return Ye(()=>{if(!t)return;const a={id:t,parentId:s};return n?.addNode(a),()=>{n?.removeNode(a)}},[n,t,s]),t}function z6(e){const{children:t,id:n}=e,s=Pa();return o.jsx(KC.Provider,{value:g.useMemo(()=>({id:n,parentId:s}),[n,s]),children:t})}function L6(e){const{children:t,externalTree:n}=e,s=Ms(()=>n??new GC).current;return o.jsx(XC.Provider,{value:s,children:t})}function _c(e){return`data-base-ui-${e}`}const JC={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 ji(e){return e?.ownerDocument||document}const Tf=g.forwardRef(function(t,n){const[s,a]=g.useState();Ye(()=>{G$&&a("button")},[]);const l={tabIndex:0,role:s};return o.jsx("span",{...t,ref:n,style:JC,"aria-hidden":s?void 0:!0,...l,"data-base-ui-focus-guard":""})});let Rj=0;function Gd(e,t={}){const{preventScroll:n=!1,cancelPrevious:s=!0,sync:a=!1}=t;s&&cancelAnimationFrame(Rj);const l=()=>e?.focus({preventScroll:n});a?l():Rj=requestAnimationFrame(l)}const Ho={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function _j(e){return e==="inert"?Ho.inert:e==="aria-hidden"?Ho["aria-hidden"]:Ho.none}let xd=new WeakSet,bd={},Fm=0;const QC=e=>e&&(e.host||QC(e.parentNode)),$6=(e,t)=>t.map(n=>{if(e.contains(n))return n;const s=QC(n);return e.contains(s)?s:null}).filter(n=>n!=null);function U6(e,t,n,s){const a="data-base-ui-inert",l=s?"inert":n?"aria-hidden":null,u=$6(t,e),d=new Set,p=new Set(u),h=[];bd[a]||(bd[a]=new WeakMap);const m=bd[a];u.forEach(y),b(t),d.clear();function y(w){!w||d.has(w)||(d.add(w),w.parentNode&&y(w.parentNode))}function b(w){!w||p.has(w)||[].forEach.call(w.children,j=>{if(Ia(j)!=="script")if(d.has(j))b(j);else{const N=l?j.getAttribute(l):null,k=N!==null&&N!=="false",T=_j(l),E=(T.get(j)||0)+1,S=(m.get(j)||0)+1;T.set(j,E),m.set(j,S),h.push(j),E===1&&k&&xd.add(j),S===1&&j.setAttribute(a,""),!k&&l&&j.setAttribute(l,l==="inert"?"":"true")}})}return Fm+=1,()=>{h.forEach(w=>{const j=_j(l),k=(j.get(w)||0)-1,T=(m.get(w)||0)-1;j.set(w,k),m.set(w,T),k||(!xd.has(w)&&l&&w.removeAttribute(l),xd.delete(w)),T||w.removeAttribute(a)}),Fm-=1,Fm||(Ho.inert=new WeakMap,Ho["aria-hidden"]=new WeakMap,Ho.none=new WeakMap,xd=new WeakSet,bd={})}}function B6(e,t=!1,n=!1){const s=Cn(e[0]).body;return U6(e.concat(Array.from(s.querySelectorAll("[aria-live]"))),s,t,n)}const eT=g.createContext(null),tT=()=>g.useContext(eT),V6=_c("portal");function F6(e={}){const{ref:t,container:n,componentProps:s=Qn,elementProps:a,elementState:l}=e,u=_a(),p=tT()?.portalNode,[h,m]=g.useState(null),[y,b]=g.useState(null),w=g.useRef(null);Ye(()=>{if(n===null){w.current&&(w.current=null,b(null),m(null));return}if(u==null)return;const k=(n&&(my(n)?n:n.current))??p??document.body;if(k==null){w.current&&(w.current=null,b(null),m(null));return}w.current!==k&&(w.current=k,b(null),m(k))},[n,p,u]);const j=Oa("div",s,{ref:[t,b],state:l,props:[{id:u,[V6]:""},a]});return{portalNode:y,portalSubtree:h&&j?wi.createPortal(j,h):null}}const H6=g.forwardRef(function(t,n){const{children:s,container:a,className:l,render:u,renderGuards:d,...p}=t,{portalNode:h,portalSubtree:m}=F6({container:a,ref:n,componentProps:t,elementProps:p}),y=g.useRef(null),b=g.useRef(null),w=g.useRef(null),j=g.useRef(null),[N,k]=g.useState(null),T=N?.modal,E=N?.open,S=typeof d=="boolean"?d:!!N&&!N.modal&&N.open&&!!h;g.useEffect(()=>{if(!h||T)return;function R(A){h&&yc(A)&&(A.type==="focusin"?Mj:D6)(h)}return h.addEventListener("focusin",R,!0),h.addEventListener("focusout",R,!0),()=>{h.removeEventListener("focusin",R,!0),h.removeEventListener("focusout",R,!0)}},[h,T]),g.useEffect(()=>{!h||E||Mj(h)},[E,h]);const M=g.useMemo(()=>({beforeOutsideRef:y,afterOutsideRef:b,beforeInsideRef:w,afterInsideRef:j,portalNode:h,setFocusManagerState:k}),[h]);return o.jsxs(g.Fragment,{children:[m,o.jsxs(eT.Provider,{value:M,children:[S&&h&&o.jsx(Tf,{"data-type":"outside",ref:y,onFocus:R=>{if(yc(R,h))w.current?.focus();else{const A=N?N.domReference:null;WC(A)?.focus()}}}),S&&h&&o.jsx("span",{"aria-owns":h.id,style:e$}),h&&wi.createPortal(s,h),S&&h&&o.jsx(Tf,{"data-type":"outside",ref:b,onFocus:R=>{if(yc(R,h))j.current?.focus();else{const A=N?N.domReference:null;ZC(A)?.focus(),N?.closeOnFocusOut&&N?.onOpenChange(!1,cn(sh,R.nativeEvent))}}})]})]})});function q6(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 Oj=20;let ba=[];function jy(){ba=ba.filter(e=>e.isConnected)}function Z6(e){jy(),e&&Ia(e)!=="body"&&(ba.push(e),ba.length>Oj&&(ba=ba.slice(-Oj)))}function Hm(){return jy(),ba[ba.length-1]}function W6(e){if(!e)return null;const t=Zc();return HC(e,t)?e:lh(e,t)[0]||e}function Y6(e){return!e||!e.isConnected?!1:typeof e.checkVisibility=="function"?e.checkVisibility():hs(e).display!=="none"}function Ij(e,t){if(!t.current.includes("floating")&&!e.getAttribute("role")?.includes("dialog"))return;const n=Zc(),a=I6(e,n).filter(u=>{const d=u.getAttribute("data-tabindex")||"";return HC(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 G6(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:b,previousFocusableElement:w,beforeContentFocusGuardRef:j,externalTree:N}=e,k="rootStore"in t?t.rootStore:t,T=k.useState("open"),E=k.useState("domReferenceElement"),S=k.useState("floatingElement"),{events:M,dataRef:R}=k.context,A=Ke(()=>R.current.floatingContext?.nodeId),_=Ke(y),$=l===!1,V=av(E)&&$,U=Xn(a),O=Xn(l),P=Xn(u),q=Xn(m),Z=rl(N),H=tT(),L=g.useRef(null),z=g.useRef(null),B=g.useRef(!1),X=g.useRef(!1),W=g.useRef(!1),I=g.useRef(-1),F=g.useRef(""),G=g.useRef(""),J=Fs(),ce=Fs(),se=vy(),ve=H!=null,me=bf(S),je=Ke((we=me)=>we?lh(we,Zc()):[]),Ae=Ke(we=>{const Ne=je(we);return U.current.map(()=>Ne).filter(Boolean).flat()});g.useEffect(()=>{if(s||!p)return;function we(_e){_e.key==="Tab"&&Dt(me,xa(Cn(me)))&&je().length===0&&!V&&Tn(_e)}const Ne=Cn(me);return Ne.addEventListener("keydown",we),()=>{Ne.removeEventListener("keydown",we)}},[s,E,me,p,U,V,je,Ae]),g.useEffect(()=>{if(s||!S)return;function we(Ne){const _e=Jn(Ne),Ve=je().indexOf(_e);Ve!==-1&&(I.current=Ve)}return S.addEventListener("focusin",we),()=>{S.removeEventListener("focusin",we)}},[s,S,je]),g.useEffect(()=>{if(s||!T)return;const we=Cn(me);function Ne(){W.current=!1}function _e(Ve){const ie=Jn(Ve),ye=Dt(S,ie)||Dt(E,ie)||Dt(H?.portalNode,ie);W.current=!ye,G.current=Ve.pointerType||"keyboard"}function Fe(){G.current="keyboard"}return we.addEventListener("pointerdown",_e,!0),we.addEventListener("pointerup",Ne,!0),we.addEventListener("pointercancel",Ne,!0),we.addEventListener("keydown",Fe,!0),()=>{we.removeEventListener("pointerdown",_e,!0),we.removeEventListener("pointerup",Ne,!0),we.removeEventListener("pointercancel",Ne,!0),we.removeEventListener("keydown",Fe,!0)}},[s,S,E,me,T,H]),g.useEffect(()=>{if(s||!h)return;function we(){X.current=!0,ce.start(0,()=>{X.current=!1})}function Ne(ie){const ye=ie.relatedTarget,be=ie.currentTarget,ke=Jn(ie);queueMicrotask(()=>{const Ee=A(),Se=k.context.triggerElements,Be=!(Dt(E,ye)||Dt(S,ye)||Dt(ye,S)||Dt(H?.portalNode,ye)||ye!=null&&Se.hasElement(ye)||Se.hasMatchingElement(ze=>Dt(ze,ye))||ye?.hasAttribute(_c("focus-guard"))||Z&&(Fo(Z.nodesRef.current,Ee).find(ze=>Dt(ze.context?.elements.floating,ye)||Dt(ze.context?.elements.domReference,ye))||kj(Z.nodesRef.current,Ee).find(ze=>[ze.context?.elements.floating,bf(ze.context?.elements.floating)].includes(ye)||ze.context?.elements.domReference===ye)));if(be===E&&me&&Ij(me,U),d&&be!==E&&!Y6(ke)&&xa(Cn(me))===Cn(me).body){if(tn(me)&&(me.focus(),d==="popup")){se.request(()=>{me.focus()});return}const ze=I.current,bt=je(),kt=bt[ze]||bt[bt.length-1]||me;tn(kt)&&kt.focus()}if(R.current.insideReactTree){R.current.insideReactTree=!1;return}(V||!p)&&ye&&Be&&!X.current&&(V||ye!==Hm())&&(B.current=!0,k.setOpen(!1,cn(sh,ie)))})}function _e(){W.current||(R.current.insideReactTree=!0,J.start(0,()=>{R.current.insideReactTree=!1}))}const Fe=tn(E)?E:null,Ve=[];if(!(!S&&!Fe))return Fe&&(Fe.addEventListener("focusout",Ne),Fe.addEventListener("pointerdown",we),Ve.push(()=>{Fe.removeEventListener("focusout",Ne),Fe.removeEventListener("pointerdown",we)})),S&&(S.addEventListener("focusout",Ne),H&&(S.addEventListener("focusout",_e,!0),Ve.push(()=>{S.removeEventListener("focusout",_e,!0)})),Ve.push(()=>{S.removeEventListener("focusout",Ne)})),()=>{Ve.forEach(ie=>{ie()})}},[s,E,S,me,p,Z,H,k,h,d,je,V,A,U,R,J,ce,se]);const he=g.useRef(null),ue=g.useRef(null),de=Rc(he,j,H?.beforeInsideRef),Le=Rc(ue,H?.afterInsideRef);g.useEffect(()=>{if(s||!S||!T)return;const we=Array.from(H?.portalNode?.querySelectorAll(`[${_c("portal")}]`)||[]),_e=(Z?kj(Z.nodesRef.current,A()):[]).find(ie=>av(ie.context?.elements.domReference||null))?.context?.elements.domReference,Fe=[S,_e,...we,..._(),L.current,z.current,he.current,ue.current,H?.beforeOutsideRef.current,H?.afterOutsideRef.current,ai(w),ai(b),V?E:null].filter(ie=>ie!=null),Ve=B6(Fe,p||V);return()=>{Ve()}},[T,s,E,S,p,U,H,V,Z,A,_,b,w]),Ye(()=>{if(!T||s||!tn(me))return;const we=Cn(me),Ne=xa(we);queueMicrotask(()=>{const _e=Ae(me),Fe=O.current,Ve=typeof Fe=="function"?Fe(q.current||""):Fe;if(Ve===void 0||Ve===!1)return;let ie;Ve===!0||Ve===null?ie=_e[0]||me:ie=ai(Ve),ie=ie||_e[0]||me,!Dt(me,Ne)&&Gd(ie,{preventScroll:ie===me})})},[s,T,me,$,Ae,O,q]),Ye(()=>{if(s||!me)return;const we=Cn(me),Ne=xa(we);Z6(Ne);function _e(ie){if(ie.open||(F.current=q6(ie.nativeEvent,G.current)),ie.reason===pi&&ie.nativeEvent.type==="mouseleave"&&(B.current=!0),ie.reason===py)if(ie.nested)B.current=!1;else if(DC(ie.nativeEvent)||PC(ie.nativeEvent))B.current=!1;else{let ye=!1;document.createElement("div").focus({get preventScroll(){return ye=!0,!1}}),ye?B.current=!1:B.current=!0}}M.on("openchange",_e);const Fe=we.createElement("span");Fe.setAttribute("tabindex","-1"),Fe.setAttribute("aria-hidden","true"),Object.assign(Fe.style,JC),ve&&E&&E.insertAdjacentElement("afterend",Fe);function Ve(){const ie=P.current;let ye=typeof ie=="function"?ie(F.current):ie;if(ye===void 0||ye===!1)return null;if(ye===null&&(ye=!0),typeof ye=="boolean"){const ke=E||Hm();return ke&&ke.isConnected?ke:Fe}const be=E||Hm()||Fe;return ai(ye)||be}return()=>{M.off("openchange",_e);const ie=xa(we),ye=Dt(S,ie)||Z&&Fo(Z.nodesRef.current,A(),!1).some(ke=>Dt(ke.context?.elements.floating,ie)),be=Ve();queueMicrotask(()=>{const ke=W6(be),Ee=typeof P.current!="boolean";P.current&&!B.current&&tn(ke)&&(!(!Ee&&ke!==ie&&ie!==we.body)||ye)&&ke.focus({preventScroll:!0}),Fe.remove()})}},[s,S,me,P,R,M,Z,ve,E,A]),g.useEffect(()=>{queueMicrotask(()=>{B.current=!1})},[s]),g.useEffect(()=>{if(s||!T)return;function we(_e){Jn(_e)?.closest(`[${JL}]`)&&(X.current=!0)}const Ne=Cn(me);return Ne.addEventListener("pointerdown",we,!0),()=>{Ne.removeEventListener("pointerdown",we,!0)}},[s,T,me]),Ye(()=>{if(!s&&H)return H.setFocusManagerState({modal:p,closeOnFocusOut:h,open:T,onOpenChange:k.setOpen,domReference:E}),()=>{H.setFocusManagerState(null)}},[s,H,p,T,k,h,E]),Ye(()=>{if(!(s||!me))return Ij(me,U),()=>{queueMicrotask(jy)}},[s,me,U]);const Te=!s&&(p?!V:!0)&&(ve||p);return o.jsxs(g.Fragment,{children:[Te&&o.jsx(Tf,{"data-type":"inside",ref:de,onFocus:we=>{if(p){const Ne=Ae();Gd(Ne[Ne.length-1])}else H?.portalNode&&(B.current=!1,yc(we,H.portalNode)?ZC(E)?.focus():ai(w??H.beforeOutsideRef)?.focus())}}),n,Te&&o.jsx(Tf,{"data-type":"inside",ref:Le,onFocus:we=>{p?Gd(Ae()[0]):H?.portalNode&&(h&&(B.current=!0),yc(we,H.portalNode)?WC(E)?.focus():ai(b??H.afterOutsideRef)?.focus())}})]})}function Dj(e,t,n){let{reference:s,floating:a}=e;const l=Cs(t),u=wy(t),d=by(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,b=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(Da(t)){case"start":w[u]-=b*(n&&h?-1:1);break;case"end":w[u]+=b*(n&&h?-1:1);break}return w}async function K6(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:b=!1,padding:w=0}=Lr(t,e),j=zC(w),k=d[b?y==="floating"?"reference":"floating":y],T=Sf(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})),E=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)),M=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},R=Sf(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:d,rect:E,offsetParent:S,strategy:p}):E);return{top:(T.top-R.top+j.top)/M.y,bottom:(R.bottom-T.bottom+j.bottom)/M.y,left:(T.left-R.left+j.left)/M.x,right:(R.right-T.right+j.right)/M.x}}const X6=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}=Dj(h,s,p),b=s,w={},j=0;for(let k=0;k<d.length;k++){var N;const{name:T,fn:E}=d[k],{x:S,y:M,data:R,reset:A}=await E({x:m,y,initialPlacement:s,placement:b,strategy:a,middlewareData:w,rects:h,platform:{...u,detectOverflow:(N=u.detectOverflow)!=null?N:K6},elements:{reference:e,floating:t}});m=S??m,y=M??y,w={...w,[T]:{...w[T],...R}},A&&j<=50&&(j++,typeof A=="object"&&(A.placement&&(b=A.placement),A.rects&&(h=A.rects===!0?await u.getElementRects({reference:e,floating:t,strategy:a}):A.rects),{x:m,y}=Dj(h,b,p)),k=-1)}return{x:m,y,placement:b,strategy:a,middlewareData:w}},J6=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:b,fallbackStrategy:w="bestFit",fallbackAxisSideDirection:j="none",flipAlignment:N=!0,...k}=Lr(e,t);if((n=l.arrow)!=null&&n.alignmentOffset)return{};const T=ds(a),E=Cs(d),S=ds(d)===d,M=await(p.isRTL==null?void 0:p.isRTL(h.floating)),R=b||(S||!N?[jf(d)]:u6(d)),A=j!=="none";!b&&A&&R.push(...p6(d,N,j,M));const _=[d,...R],$=await p.detectOverflow(t,k),V=[];let U=((s=l.flip)==null?void 0:s.overflows)||[];if(m&&V.push($[T]),y){const Z=c6(a,u,M);V.push($[Z[0]],$[Z[1]])}if(U=[...U,{placement:a,overflows:V}],!V.every(Z=>Z<=0)){var O,P;const Z=(((O=l.flip)==null?void 0:O.index)||0)+1,H=_[Z];if(H&&(!(y==="alignment"?E!==Cs(H):!1)||U.every(B=>Cs(B.placement)===E?B.overflows[0]>0:!0)))return{data:{index:Z,overflows:U},reset:{placement:H}};let L=(P=U.filter(z=>z.overflows[0]<=0).sort((z,B)=>z.overflows[1]-B.overflows[1])[0])==null?void 0:P.placement;if(!L)switch(w){case"bestFit":{var q;const z=(q=U.filter(B=>{if(A){const X=Cs(B.placement);return X===E||X==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(X=>X>0).reduce((X,W)=>X+W,0)]).sort((B,X)=>B[1]-X[1])[0])==null?void 0:q[0];z&&(L=z);break}case"initialPlacement":L=d;break}if(a!==L)return{reset:{placement:L}}}return{}}}};function Pj(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function zj(e){return a6.some(t=>e[t]>=0)}const Q6=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=Pj(u,n.reference);return{data:{referenceHiddenOffsets:d,referenceHidden:zj(d)}}}case"escaped":{const u=await s.detectOverflow(t,{...l,altBoundary:!0}),d=Pj(u,n.floating);return{data:{escapedOffsets:d,escaped:zj(d)}}}default:return{}}}}},nT=new Set(["left","top"]);async function e8(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=Da(n),p=Cs(n)==="y",h=nT.has(u)?-1:1,m=l&&p?-1:1,y=Lr(t,e);let{mainAxis:b,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:b*h}:{x:b*h,y:w*m}}const t8=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 e8(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}}}}},n8=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:T=>{let{x:E,y:S}=T;return{x:E,y:S}}},...h}=Lr(e,t),m={x:n,y:s},y=await l.detectOverflow(t,h),b=Cs(ds(a)),w=xy(b);let j=m[w],N=m[b];if(u){const T=w==="y"?"top":"left",E=w==="y"?"bottom":"right",S=j+y[T],M=j-y[E];j=iv(S,j,M)}if(d){const T=b==="y"?"top":"left",E=b==="y"?"bottom":"right",S=N+y[T],M=N-y[E];N=iv(S,N,M)}const k=p.fn({...t,[w]:j,[b]:N});return{...k,data:{x:k.x-n,y:k.y-s,enabled:{[w]:u,[b]:d}}}}}},s8=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),b=xy(y);let w=m[b],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=b==="y"?"height":"width",M=l.reference[b]-l.floating[S]+k.mainAxis,R=l.reference[b]+l.reference[S]-k.mainAxis;w<M?w=M:w>R&&(w=R)}if(h){var T,E;const S=b==="y"?"width":"height",M=nT.has(ds(a)),R=l.reference[y]-l.floating[S]+(M&&((T=u.offset)==null?void 0:T[y])||0)+(M?0:k.crossAxis),A=l.reference[y]+l.reference[S]+(M?0:((E=u.offset)==null?void 0:E[y])||0)-(M?k.crossAxis:0);j<R?j=R:j>A&&(j=A)}return{[b]:w,[y]:j}}}},r8=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),b=Da(a),w=Cs(a)==="y",{width:j,height:N}=l.floating;let k,T;y==="top"||y==="bottom"?(k=y,T=b===(await(u.isRTL==null?void 0:u.isRTL(d.floating))?"start":"end")?"left":"right"):(T=y,k=b==="end"?"top":"bottom");const E=N-m.top-m.bottom,S=j-m.left-m.right,M=Xo(N-m[k],E),R=Xo(j-m[T],S),A=!t.middlewareData.shift;let _=M,$=R;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&($=S),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(_=E),A&&!b){const U=cs(m.left,0),O=cs(m.right,0),P=cs(m.top,0),q=cs(m.bottom,0);w?$=j-2*(U!==0||O!==0?U+O:cs(m.left,m.right)):_=N-2*(P!==0||q!==0?P+q:cs(m.top,m.bottom))}await p({...t,availableWidth:$,availableHeight:_});const V=await u.getDimensions(d.floating);return j!==V.width||N!==V.height?{reset:{rects:!0}}:{}}}};function sT(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=wf(n)!==l||wf(s)!==u;return d&&(n=l,s=u),{width:n,height:s,$:d}}function Sy(e){return Pt(e)?e:e.contextElement}function qo(e){const t=Sy(e);if(!tn(t))return ir(1);const n=t.getBoundingClientRect(),{width:s,height:a,$:l}=sT(t);let u=(l?wf(n.width):n.width)/s,d=(l?wf(n.height):n.height)/a;return(!u||!Number.isFinite(u))&&(u=1),(!d||!Number.isFinite(d))&&(d=1),{x:u,y:d}}const a8=ir(0);function rT(e){const t=An(e);return!ih()||!t.visualViewport?a8:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function i8(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==An(e)?!1:t}function Si(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const a=e.getBoundingClientRect(),l=Sy(e);let u=ir(1);t&&(s?Pt(s)&&(u=qo(s)):u=qo(e));const d=i8(l,n,s)?rT(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 b=An(l),w=s&&Pt(s)?An(s):s;let j=b,N=nv(j);for(;N&&s&&w!==j;){const k=qo(N),T=N.getBoundingClientRect(),E=hs(N),S=T.left+(N.clientLeft+parseFloat(E.paddingLeft))*k.x,M=T.top+(N.clientTop+parseFloat(E.paddingTop))*k.y;p*=k.x,h*=k.y,m*=k.x,y*=k.y,p+=S,h+=M,j=An(N),N=nv(j)}}return Sf({width:m,height:y,x:p,y:h})}function ch(e,t){const n=oh(e).scrollLeft;return t?t.left+n:Si(dr(e)).left+n}function aT(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-ch(e,n),a=n.top+t.scrollTop;return{x:s,y:a}}function o8(e){let{elements:t,rect:n,offsetParent:s,strategy:a}=e;const l=a==="fixed",u=dr(s),d=t?ah(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)&&((Ia(s)!=="body"||Ci(u))&&(p=oh(s)),tn(s))){const w=Si(s);h=qo(s),m.x=w.x+s.clientLeft,m.y=w.y+s.clientTop}const b=u&&!y&&!l?aT(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+b.x,y:n.y*h.y-p.scrollTop*h.y+m.y+b.y}}function l8(e){return Array.from(e.getClientRects())}function c8(e){const t=dr(e),n=oh(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+ch(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 Lj=25;function u8(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=ih();(!m||m&&t==="fixed")&&(d=a.offsetLeft,p=a.offsetTop)}const h=ch(s);if(h<=0){const m=s.ownerDocument,y=m.body,b=getComputedStyle(y),w=m.compatMode==="CSS1Compat"&&parseFloat(b.marginLeft)+parseFloat(b.marginRight)||0,j=Math.abs(s.clientWidth-y.clientWidth-w);j<=Lj&&(l-=j)}else h<=Lj&&(l+=h);return{width:l,height:u,x:d,y:p}}const d8=new Set(["absolute","fixed"]);function f8(e,t){const n=Si(e,!0,t==="fixed"),s=n.top+e.clientTop,a=n.left+e.clientLeft,l=tn(e)?qo(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 $j(e,t,n){let s;if(t==="viewport")s=u8(e,n);else if(t==="document")s=c8(dr(e));else if(Pt(t))s=f8(t,n);else{const a=rT(e);s={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return Sf(s)}function iT(e,t){const n=cr(e);return n===t||!Pt(n)||ar(n)?!1:hs(n).position==="fixed"||iT(n,t)}function h8(e,t){const n=t.get(e);if(n)return n;let s=Sa(e,[],!1).filter(d=>Pt(d)&&Ia(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=gy(u);!p&&d.position==="fixed"&&(a=null),(l?!p&&!a:!p&&d.position==="static"&&!!a&&d8.has(a.position)||Ci(u)&&!p&&iT(e,u))?s=s.filter(m=>m!==u):a=d,u=cr(u)}return t.set(e,s),s}function p8(e){let{element:t,boundary:n,rootBoundary:s,strategy:a}=e;const u=[...n==="clippingAncestors"?ah(t)?[]:h8(t,this._c):[].concat(n),s],d=u[0],p=u.reduce((h,m)=>{const y=$j(t,m,a);return h.top=cs(y.top,h.top),h.right=Xo(y.right,h.right),h.bottom=Xo(y.bottom,h.bottom),h.left=cs(y.left,h.left),h},$j(t,d,a));return{width:p.right-p.left,height:p.bottom-p.top,x:p.left,y:p.top}}function m8(e){const{width:t,height:n}=sT(e);return{width:t,height:n}}function g8(e,t,n){const s=tn(t),a=dr(t),l=n==="fixed",u=Si(e,!0,l,t);let d={scrollLeft:0,scrollTop:0};const p=ir(0);function h(){p.x=ch(a)}if(s||!s&&!l)if((Ia(t)!=="body"||Ci(a))&&(d=oh(t)),s){const w=Si(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?aT(a,d):ir(0),y=u.left+d.scrollLeft-p.x-m.x,b=u.top+d.scrollTop-p.y-m.y;return{x:y,y:b,width:u.width,height:u.height}}function qm(e){return hs(e).position==="static"}function Uj(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 oT(e,t){const n=An(e);if(ah(e))return n;if(!tn(e)){let a=cr(e);for(;a&&!ar(a);){if(Pt(a)&&!qm(a))return a;a=cr(a)}return n}let s=Uj(e,t);for(;s&&b$(s)&&qm(s);)s=Uj(s,t);return s&&ar(s)&&qm(s)&&!gy(s)?n:s||k$(e)||n}const v8=async function(e){const t=this.getOffsetParent||oT,n=this.getDimensions,s=await n(e.floating);return{reference:g8(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function y8(e){return hs(e).direction==="rtl"}const x8={convertOffsetParentRelativeRectToViewportRelativeRect:o8,getDocumentElement:dr,getClippingRect:p8,getOffsetParent:oT,getElementRects:v8,getClientRects:l8,getDimensions:m8,getScale:qo,isElement:Pt,isRTL:y8};function lT(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function b8(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:b,height:w}=h;if(d||t(),!b||!w)return;const j=Po(y),N=Po(a.clientWidth-(m+b)),k=Po(a.clientHeight-(y+w)),T=Po(m),S={rootMargin:-j+"px "+-N+"px "+-k+"px "+-T+"px",threshold:cs(0,Xo(1,p))||1};let M=!0;function R(A){const _=A[0].intersectionRatio;if(_!==p){if(!M)return u();_?u(!1,_):s=setTimeout(()=>{u(!1,1e-7)},1e3)}_===1&&!lT(h,e.getBoundingClientRect())&&u(),M=!1}try{n=new IntersectionObserver(R,{...S,root:a.ownerDocument})}catch{n=new IntersectionObserver(R,S)}n.observe(e)}return u(!0),l}function Bj(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=Sy(e),m=a||l?[...h?Sa(h):[],...Sa(t)]:[];m.forEach(T=>{a&&T.addEventListener("scroll",n,{passive:!0}),l&&T.addEventListener("resize",n)});const y=h&&d?b8(h,n):null;let b=-1,w=null;u&&(w=new ResizeObserver(T=>{let[E]=T;E&&E.target===h&&w&&(w.unobserve(t),cancelAnimationFrame(b),b=requestAnimationFrame(()=>{var S;(S=w)==null||S.observe(t)})),n()}),h&&!p&&w.observe(h),w.observe(t));let j,N=p?Si(e):null;p&&k();function k(){const T=Si(e);N&&!lT(N,T)&&n(),N=T,j=requestAnimationFrame(k)}return n(),()=>{var T;m.forEach(E=>{a&&E.removeEventListener("scroll",n),l&&E.removeEventListener("resize",n)}),y?.(),(T=w)==null||T.disconnect(),w=null,p&&cancelAnimationFrame(j)}}const w8=t8,j8=n8,S8=J6,N8=r8,k8=Q6,E8=s8,C8=(e,t,n)=>{const s=new Map,a={platform:x8,...n},l={...a.platform,_c:s};return X6(e,t,{...a,platform:l})};var T8=typeof document<"u",A8=function(){},Kd=T8?g.useLayoutEffect:A8;function Af(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(!Af(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)&&!Af(e[l],t[l]))return!1}return!0}return e!==e&&t!==t}function cT(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Vj(e,t){const n=cT(e);return Math.round(t*n)/n}function Zm(e){const t=g.useRef(e);return Kd(()=>{t.current=e}),t}function M8(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}),[b,w]=g.useState(s);Af(b,s)||w(s);const[j,N]=g.useState(null),[k,T]=g.useState(null),E=g.useCallback(B=>{B!==A.current&&(A.current=B,N(B))},[]),S=g.useCallback(B=>{B!==_.current&&(_.current=B,T(B))},[]),M=l||j,R=u||k,A=g.useRef(null),_=g.useRef(null),$=g.useRef(m),V=p!=null,U=Zm(p),O=Zm(a),P=Zm(h),q=g.useCallback(()=>{if(!A.current||!_.current)return;const B={placement:t,strategy:n,middleware:b};O.current&&(B.platform=O.current),C8(A.current,_.current,B).then(X=>{const W={...X,isPositioned:P.current!==!1};Z.current&&!Af($.current,W)&&($.current=W,wi.flushSync(()=>{y(W)}))})},[b,t,n,O,P]);Kd(()=>{h===!1&&$.current.isPositioned&&($.current.isPositioned=!1,y(B=>({...B,isPositioned:!1})))},[h]);const Z=g.useRef(!1);Kd(()=>(Z.current=!0,()=>{Z.current=!1}),[]),Kd(()=>{if(M&&(A.current=M),R&&(_.current=R),M&&R){if(U.current)return U.current(M,R,q);q()}},[M,R,q,U,V]);const H=g.useMemo(()=>({reference:A,floating:_,setReference:E,setFloating:S}),[E,S]),L=g.useMemo(()=>({reference:M,floating:R}),[M,R]),z=g.useMemo(()=>{const B={position:n,left:0,top:0};if(!L.floating)return B;const X=Vj(L.floating,m.x),W=Vj(L.floating,m.y);return d?{...B,transform:"translate("+X+"px, "+W+"px)",...cT(L.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:X,top:W}},[n,d,L.floating,m.x,m.y]);return g.useMemo(()=>({...m,update:q,refs:H,elements:L,floatingStyles:z}),[m,q,H,L,z])}const R8=(e,t)=>({...w8(e),options:[e,t]}),_8=(e,t)=>({...j8(e),options:[e,t]}),O8=(e,t)=>({...E8(e),options:[e,t]}),I8=(e,t)=>({...S8(e),options:[e,t]}),D8=(e,t)=>({...N8(e),options:[e,t]}),P8=(e,t)=>({...k8(e),options:[e,t]}),z8={intentional:"onClick",sloppy:"onPointerDown"};function L8(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function $8(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:b="sloppy",referencePress:w=!1,referencePressEvent:j="sloppy",ancestorScroll:N=!1,bubbles:k,externalTree:T}=t,E=rl(T),S=Ke(typeof y=="function"?y:()=>!1),M=typeof y=="function"?S:y,R=g.useRef(!1),{escapeKey:A,outsidePress:_}=L8(k),$=g.useRef(null),V=Fs(),U=Fs(),O=Ke(()=>{U.clear(),p.current.insideReactTree=!1}),P=g.useRef(!1),q=g.useRef(""),Z=Ke(he=>{q.current=he.pointerType}),H=Ke(()=>{const he=q.current,ue=he==="pen"||!he?"mouse":he,de=typeof b=="function"?b():b;return typeof de=="string"?de:de[ue]}),L=Ke(he=>{if(!s||!h||!m||he.key!=="Escape"||P.current)return;const ue=p.current.floatingContext?.nodeId,de=E?Fo(E.nodesRef.current,ue):[];if(!A&&de.length>0){let we=!0;if(de.forEach(Ne=>{Ne.context?.open&&!Ne.context.dataRef.current.__escapeKeyBubbles&&(we=!1)}),!we)return}const Le=n6(he)?he.nativeEvent:he,Te=cn(SC,Le);n.setOpen(!1,Te),!A&&!Te.isPropagationAllowed&&he.stopPropagation()}),z=Ke(he=>{const ue=H();return ue==="intentional"&&he.type!=="click"||ue==="sloppy"&&he.type==="click"}),B=Ke(()=>{p.current.insideReactTree=!0,U.start(0,O)}),X=Ke((he,ue=!1)=>{if(z(he)){O();return}if(p.current.insideReactTree){O();return}if(H()==="intentional"&&ue||typeof M=="function"&&!M(he))return;const de=Jn(he),Le=`[${_c("inert")}]`,Te=Cn(n.select("floatingElement")).querySelectorAll(Le),we=n.context.triggerElements;if(de&&(we.hasElement(de)||we.hasMatchingElement(ie=>Dt(ie,de))))return;let Ne=Pt(de)?de:null;for(;Ne&&!ar(Ne);){const ie=cr(Ne);if(ar(ie)||!Pt(ie))break;Ne=ie}if(Te.length&&Pt(de)&&!e6(de)&&!Dt(de,n.select("floatingElement"))&&Array.from(Te).every(ie=>!Dt(Ne,ie)))return;if(tn(de)&&!("touches"in he)){const ie=ar(de),ye=hs(de),be=/auto|scroll/,ke=ie||be.test(ye.overflowX),Ee=ie||be.test(ye.overflowY),Se=ke&&de.clientWidth>0&&de.scrollWidth>de.clientWidth,Be=Ee&&de.clientHeight>0&&de.scrollHeight>de.clientHeight,ze=ye.direction==="rtl",bt=Be&&(ze?he.offsetX<=de.offsetWidth-de.clientWidth:he.offsetX>de.clientWidth),kt=Se&&he.offsetY>de.clientHeight;if(bt||kt)return}const _e=p.current.floatingContext?.nodeId,Fe=E&&Fo(E.nodesRef.current,_e).some(ie=>zs(he,ie.context?.elements.floating));if(zs(he,n.select("floatingElement"))||zs(he,n.select("domReferenceElement"))||Fe)return;const Ve=E?Fo(E.nodesRef.current,_e):[];if(Ve.length>0){let ie=!0;if(Ve.forEach(ye=>{ye.context?.open&&!ye.context.dataRef.current.__outsidePressBubbles&&(ie=!1)}),!ie)return}n.setOpen(!1,cn(py,he)),O()}),W=Ke(he=>{H()!=="sloppy"||he.pointerType==="touch"||!n.select("open")||!h||zs(he,n.select("floatingElement"))||zs(he,n.select("domReferenceElement"))||X(he)}),I=Ke(he=>{if(H()!=="sloppy"||!n.select("open")||!h||zs(he,n.select("floatingElement"))||zs(he,n.select("domReferenceElement")))return;const ue=he.touches[0];ue&&($.current={startTime:Date.now(),startX:ue.clientX,startY:ue.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},V.start(1e3,()=>{$.current&&($.current.dismissOnTouchEnd=!1,$.current.dismissOnMouseDown=!1)}))}),F=Ke(he=>{const ue=Jn(he);function de(){I(he),ue?.removeEventListener(he.type,de)}ue?.addEventListener(he.type,de)}),G=Ke(he=>{const ue=R.current;if(R.current=!1,V.clear(),he.type==="mousedown"&&$.current&&!$.current.dismissOnMouseDown)return;const de=Jn(he);function Le(){he.type==="pointerdown"?W(he):X(he,ue),de?.removeEventListener(he.type,Le)}de?.addEventListener(he.type,Le)}),J=Ke(he=>{if(H()!=="sloppy"||!$.current||zs(he,n.select("floatingElement"))||zs(he,n.select("domReferenceElement")))return;const ue=he.touches[0];if(!ue)return;const de=Math.abs(ue.clientX-$.current.startX),Le=Math.abs(ue.clientY-$.current.startY),Te=Math.sqrt(de*de+Le*Le);Te>5&&($.current.dismissOnTouchEnd=!0),Te>10&&(X(he),V.clear(),$.current=null)}),ce=Ke(he=>{const ue=Jn(he);function de(){J(he),ue?.removeEventListener(he.type,de)}ue?.addEventListener(he.type,de)}),se=Ke(he=>{H()!=="sloppy"||!$.current||zs(he,n.select("floatingElement"))||zs(he,n.select("domReferenceElement"))||($.current.dismissOnTouchEnd&&X(he),V.clear(),$.current=null)}),ve=Ke(he=>{const ue=Jn(he);function de(){se(he),ue?.removeEventListener(he.type,de)}ue?.addEventListener(he.type,de)});g.useEffect(()=>{if(!s||!h)return;p.current.__escapeKeyBubbles=A,p.current.__outsidePressBubbles=_;const he=new Ko;function ue(Ne){n.setOpen(!1,cn(f$,Ne))}function de(){he.clear(),P.current=!0}function Le(){he.start(ih()?5:0,()=>{P.current=!1})}const Te=Cn(a);Te.addEventListener("pointerdown",Z,!0),m&&(Te.addEventListener("keydown",L),Te.addEventListener("compositionstart",de),Te.addEventListener("compositionend",Le)),M&&(Te.addEventListener("click",G,!0),Te.addEventListener("pointerdown",G,!0),Te.addEventListener("touchstart",F,!0),Te.addEventListener("touchmove",ce,!0),Te.addEventListener("touchend",ve,!0),Te.addEventListener("mousedown",G,!0));let we=[];return N&&(Pt(u)&&(we=Sa(u)),Pt(a)&&(we=we.concat(Sa(a))),!Pt(l)&&l&&l.contextElement&&(we=we.concat(Sa(l.contextElement)))),we=we.filter(Ne=>Ne!==Te.defaultView?.visualViewport),we.forEach(Ne=>{Ne.addEventListener("scroll",ue,{passive:!0})}),()=>{Te.removeEventListener("pointerdown",Z,!0),m&&(Te.removeEventListener("keydown",L),Te.removeEventListener("compositionstart",de),Te.removeEventListener("compositionend",Le)),M&&(Te.removeEventListener("click",G,!0),Te.removeEventListener("pointerdown",G,!0),Te.removeEventListener("touchstart",F,!0),Te.removeEventListener("touchmove",ce,!0),Te.removeEventListener("touchend",ve,!0),Te.removeEventListener("mousedown",G,!0)),we.forEach(Ne=>{Ne.removeEventListener("scroll",ue)}),he.clear()}},[p,a,l,u,m,M,s,d,N,h,A,_,L,X,G,W,F,ce,ve,Z,n]),g.useEffect(O,[M,O]);const me=g.useMemo(()=>({onKeyDown:L,...w&&{[z8[j]]:he=>{n.setOpen(!1,cn(xf,he.nativeEvent))},...j!=="intentional"&&{onClick(he){n.setOpen(!1,cn(xf,he.nativeEvent))}}}}),[L,n,w,j]),je=Ke(he=>{const ue=Jn(he.nativeEvent);!Dt(n.select("floatingElement"),ue)||he.button!==0||(R.current=!0)}),Ae=g.useMemo(()=>({onKeyDown:L,onPointerDown:je,onMouseDown:je,onMouseUp:je,onClickCapture:B,onMouseDownCapture:B,onPointerDownCapture:B,onMouseUpCapture:B,onTouchEndCapture:B,onTouchMoveCapture:B}),[L,je,B]);return g.useMemo(()=>h?{reference:me,floating:Ae,trigger:me}:{},[h,me,Ae])}var Mf=Symbol("NOT_FOUND");function U8(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function B8(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function V8(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 Fj=e=>Array.isArray(e)?e:[e];function F8(e){const t=Array.isArray(e[0])?e[0]:e;return V8(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function H8(e,t){const n=[],{length:s}=e;for(let a=0;a<s;a++)n.push(e[a].apply(null,t));return n}function q8(e){let t;return{get(n){return t&&e(t.key,n)?t.value:Mf},put(n,s){t={key:n,value:s}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function Z8(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 Mf}function a(d,p){s(d)===Mf&&(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 W8=(e,t)=>e===t;function Y8(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 G8(e,t){const n=typeof t=="object"?t:{equalityCheck:t},{equalityCheck:s=W8,maxSize:a=1,resultEqualityCheck:l}=n,u=Y8(s);let d=0;const p=a<=1?q8(u):Z8(a,u);function h(){let m=p.get(arguments);if(m===Mf){if(m=e.apply(null,arguments),d++,l){const b=p.getEntries().find(w=>l(w.value,m));b&&(m=b.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 K8=class{constructor(e){this.value=e}deref(){return this.value}},X8=typeof WeakRef<"u"?WeakRef:K8,J8=0,Hj=1;function wd(){return{s:J8,v:void 0,o:null,p:null}}function uT(e,t={}){let n=wd();const{resultEqualityCheck:s}=t;let a,l=0;function u(){let d=n;const{length:p}=arguments;for(let y=0,b=p;y<b;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=wd(),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=wd(),j.set(w,d)):d=N}}const h=d;let m;if(d.s===Hj)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 X8(m):m}return h.s=Hj,h.v=m,m}return u.clearCache=()=>{n=wd(),u.resetResultsCount()},u.resultsCount=()=>l,u.resetResultsCount=()=>{l=0},u}function dT(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()),U8(h,`createSelector expects an output function after the inputs, but received: [${typeof h}]`);const m={...n,...p},{memoize:y,memoizeOptions:b=[],argsMemoize:w=uT,argsMemoizeOptions:j=[]}=m,N=Fj(b),k=Fj(j),T=F8(a),E=y(function(){return l++,h.apply(null,arguments)},...N),S=w(function(){u++;const R=H8(T,arguments);return d=E.apply(null,R),d},...k);return Object.assign(S,{resultFunc:h,memoizedResultFunc:E,dependencies:T,dependencyRecomputations:()=>u,resetDependencyRecomputations:()=>{u=0},lastResult:()=>d,recomputations:()=>l,resetRecomputations:()=>{l=0},memoize:y,argsMemoize:w})};return Object.assign(s,{withTypes:()=>s}),s}var Q8=dT(uT),eU=Object.assign((e,t=Q8)=>{B8(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:()=>eU});dT({memoize:G8,memoizeOptions:{maxSize:1,equalityCheck:Object.is}});const tt=(e,t,n,s,a,l,...u)=>{if(u.length>0)throw new Error(Ei(1));let d;if(e)d=e;else throw new Error("Missing arguments");return d};var Wm={exports:{}},Ym={};var qj;function tU(){if(qj)return Ym;qj=1;var e=Vc();function t(y,b){return y===b&&(y!==0||1/y===1/b)||y!==y&&b!==b}var n=typeof Object.is=="function"?Object.is:t,s=e.useState,a=e.useEffect,l=e.useLayoutEffect,u=e.useDebugValue;function d(y,b){var w=b(),j=s({inst:{value:w,getSnapshot:b}}),N=j[0].inst,k=j[1];return l(function(){N.value=w,N.getSnapshot=b,p(N)&&k({inst:N})},[y,w,b]),a(function(){return p(N)&&k({inst:N}),y(function(){p(N)&&k({inst:N})})},[y]),u(w),w}function p(y){var b=y.getSnapshot;y=y.value;try{var w=b();return!n(y,w)}catch{return!0}}function h(y,b){return b()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:d;return Ym.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:m,Ym}var Zj;function fT(){return Zj||(Zj=1,Wm.exports=tU()),Wm.exports}var nU=fT(),Gm={exports:{}},Km={};var Wj;function sU(){if(Wj)return Km;Wj=1;var e=Vc(),t=fT();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 Km.useSyncExternalStoreWithSelector=function(h,m,y,b,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 T(A){if(!E){if(E=!0,S=A,A=b(A),w!==void 0&&N.hasValue){var _=N.value;if(w(_,A))return M=_}return M=A}if(_=M,s(S,A))return _;var $=b(A);return w!==void 0&&w(_,$)?(S=A,_):(S=A,M=$)}var E=!1,S,M,R=y===void 0?null:y;return[function(){return T(m())},R===null?void 0:function(){return T(R())}]},[m,y,b,w]);var k=a(h,j[0],j[1]);return u(function(){N.hasValue=!0,N.value=k},[k]),p(k),k},Km}var Yj;function rU(){return Yj||(Yj=1,Gm.exports=sU()),Gm.exports}var aU=rU();const iU=fy(19),oU=iU?cU:uU;function lU(e,t,n,s,a){return oU(e,t,n,s,a)}function cU(e,t,n,s,a){const l=g.useCallback(()=>t(e.getSnapshot(),n,s,a),[e,t,n,s,a]);return nU.useSyncExternalStore(e.subscribe,l,l)}function uU(e,t,n,s,a){return aU.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,l=>t(l,n,s,a))}class xc{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])){xc.prototype.setState.call(this,{...this.state,...t});return}}set(t,n){Object.is(this.state[t],n)||xc.prototype.setState.call(this,{...this.state,[t]:n})}notifyAll(){const t={...this.state};xc.prototype.setState.call(this,t)}}class hT extends xc{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 lU(this,l,n,s,a)};useContextCallback(t,n){g.useDebugValue(t);const s=Ke(n??xC);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 dU={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 Ny extends hT{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:YC(),nested:n,noEmit:s,triggerElements:l},dU)}setOpen=(t,n)=>{if((!t||!this.state.open||r6(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 fU(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 hU(e,t,n){const{mounted:s,setMounted:a,transitionStatus:l}=U$(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 TC({enabled:!d,open:e,ref:t.context.popupRef,onComplete(){e||u()}}),{forceUnmount:u,transitionStatus:l}}class ky{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 pU(){return new Ny({open:!1,floatingElement:null,referenceElement:null,triggerElements:new ky,floatingId:"",nested:!1,noEmit:!1,onOpenChange:void 0})}function mU(){return{open:!1,mounted:!1,transitionStatus:"idle",floatingRootContext:pU(),preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,popupElement:null,positionerElement:null,activeTriggerProps:Qn,inactiveTriggerProps:Qn,popupProps:Qn}}const gU={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 vU(e){const{open:t=!1,onOpenChange:n,elements:s={}}=e,a=_a(),l=Pa()!=null,u=Ms(()=>new Ny({open:t,onOpenChange:n,referenceElement:s.reference??null,floatingElement:s.floating??null,triggerElements:s.triggers??new ky,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 yU(e={}){const{nodeId:t,externalTree:n}=e,s=vU(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=rl(n);Ye(()=>{l.domReference&&(p.current=l.domReference)},[l.domReference]);const m=M8({...e,elements:{...l,...u&&{reference:u}}}),y=g.useCallback(_=>{const $=Pt(_)?{getBoundingClientRect:()=>_.getBoundingClientRect(),getClientRects:()=>_.getClientRects(),contextElement:_}:_;d($),m.refs.setReference($)},[m.refs]),[b,w]=g.useState(null),[j,N]=g.useState(null);a.useSyncedValue("referenceElement",b),a.useSyncedValue("domReferenceElement",Pt(b)?b: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]),T=g.useCallback(_=>{N(_),m.refs.setFloating(_)},[m.refs]),E=g.useMemo(()=>({...m.refs,setReference:k,setFloating:T,setPositionReference:y,domReference:p}),[m.refs,k,T,y]),S=g.useMemo(()=>({...m.elements,domReference:l.domReference}),[m.elements,l.domReference]),M=a.useState("open"),R=a.useState("floatingId"),A=g.useMemo(()=>({...m,dataRef:a.context.dataRef,open:M,onOpenChange:a.setOpen,events:a.context.events,floatingId:R,refs:E,elements:S,nodeId:t,rootStore:a}),[m,E,S,t,a,M,R]);return Ye(()=>{a.context.dataRef.current.floatingContext=A;const _=h?.nodesRef.current.find($=>$.id===t);_&&(_.context=A)}),g.useMemo(()=>({...m,context:A,refs:E,elements:S,rootStore:a}),[m,E,S,A,a])}function xU(e){const{popupStore:t,noEmit:n=!1,treatPopupAsFloatingElement:s=!1,onOpenChange:a}=e,l=_a(),u=Pa()!=null,d=t.useState("open"),p=t.useState("activeTriggerElement"),h=t.useState(s?"popupElement":"positionerElement"),m=t.context.triggerElements,y=Ms(()=>new Ny({open:d,referenceElement:p,floatingElement:h,triggerElements:m,onOpenChange:a,floatingId:l,nested:u,noEmit:n})).current;return Ye(()=>{const b={open:d,floatingId:l,referenceElement:p,floatingElement:h};Pt(p)&&(b.domReferenceElement=p),y.update(b)},[d,l,p,h,y]),y.context.onOpenChange=a,y.context.nested=u,y.context.noEmit=n,y}const Gj=_c("safe-polygon"),bU=`button,a,[role="button"],select,[tabindex]:not([tabindex="-1"]),${IC}`;function wU(e){return e?!!e.closest(bU):!1}function jU(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 SU=new Set(["click","mousedown"]);function NU(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:b,performedPointerEventsMutationRef:w,unbindMouseMoveRef:j,restTimeoutPendingRef:N,openChangeTimeout:k,handleCloseOptionsRef:T}=jU(n),E=rl(h),S=Pa(),M=Ke(()=>y.current?!0:u.current.openEvent?SU.has(u.current.openEvent.type):!1),R=Ke(()=>{const U=u.current.openEvent?.type;return U?.includes("mouse")&&U!=="mousedown"}),A=g.useCallback((U,O=!0)=>{const P=kU(p,m.current);P&&!b.current?k.start(P,()=>n.setOpen(!1,cn(pi,U))):O&&(k.clear(),n.setOpen(!1,cn(pi,U)))},[p,b,n,m,k]),_=Ke(()=>{j.current(),b.current=void 0}),$=Ke(()=>{if(w.current){const U=Cn(a).body;U.style.pointerEvents="",U.removeAttribute(Gj),w.current=!1}}),V=Ke(U=>{const O=Jn(U);if(!wU(O)){y.current=!1;return}y.current=!0});Ye(()=>{s||(m.current=void 0,N.current=!1,y.current=!1,_(),$())},[s,m,N,y,_,$]),g.useEffect(()=>()=>{_()},[_]),g.useEffect(()=>$,[$]),Ye(()=>{if(d&&s&&T.current?.blockPointerEvents&&R()&&Pt(l)&&a){w.current=!0;const U=Cn(a).body;U.setAttribute(Gj,"");const O=l,P=a,q=E?.nodesRef.current.find(Z=>Z.id===S)?.context?.elements.floating;return q&&(q.style.pointerEvents=""),U.style.pointerEvents="none",O.style.pointerEvents="auto",P.style.pointerEvents="auto",()=>{U.style.pointerEvents="",O.style.pointerEvents="",P.style.pointerEvents=""}}},[d,s,l,a,T,R,E,S,w]),g.useEffect(()=>{if(!d)return;function U(Z){if(M()||!u.current.floatingContext)return;const H=n.context.triggerElements;Z.relatedTarget&&H.hasElement(Z.relatedTarget)||($(),_(),M()||A(Z))}function O(Z){k.clear(),$(),b.current?.(Z),_()}function P(Z){M()||A(Z,!1)}const q=a;return q&&(q.addEventListener("mouseleave",U),q.addEventListener("mouseenter",O),q.addEventListener("mouseleave",P),q.addEventListener("pointerdown",V,!0)),()=>{q&&(q.removeEventListener("mouseleave",U),q.removeEventListener("mouseenter",O),q.removeEventListener("mouseleave",P),q.removeEventListener("pointerdown",V,!0))}})}function kU(e,t){return t&&!s6(t)?0:typeof e=="function"?e():e}function EU(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=>jd(h,e,"reference"),t),u=g.useCallback(h=>jd(h,e,"floating"),n),d=g.useCallback(h=>jd(h,e,"item"),s),p=g.useCallback(h=>jd(h,e,"trigger"),a);return g.useMemo(()=>({getReferenceProps:l,getFloatingProps:u,getItemProps:d,getTriggerProps:p}),[l,u,d,p])}function jd(e,t,n){const s=new Map,a=n==="item",l={};n==="floating"&&(l.tabIndex=-1,l[rv]="");for(const u in e)a&&e&&(u===_C||u===OC)||(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&&Kj(l,d,a,s)}return Kj(l,e,a,s),l}function Kj(e,t,n,s){for(const a in t){const l=t[a];n&&(a===_C||a===OC)||(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 CU="Escape";function uh(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function Sd(e,t){return uh(t,e===yy||e===qc,e===Na||e===ka)}function Xm(e,t,n){return uh(t,e===qc,n?e===Na:e===ka)||e==="Enter"||e===" "||e===""}function TU(e,t,n){return uh(t,n?e===Na:e===ka,e===qc)}function AU(e,t,n,s){const a=n?e===ka:e===Na,l=e===yy;return t==="both"||t==="horizontal"&&s&&s>1?e===CU:uh(t,a,l)}function MU(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:b=!1,loopFocus:w=!1,nested:j=!1,rtl:N=!1,virtual:k=!1,focusItemOnOpen:T="auto",focusItemOnHover:E=!0,openOnArrowKeyDown:S=!0,disabledIndices:M=void 0,orientation:R="vertical",parentOrientation:A,cols:_=1,scrollItemIntoView:$=!0,itemSizes:V,dense:U=!1,id:O,resetOnPointerLeave:P=!0,externalTree:q}=t,Z=bf(a),H=Xn(Z),L=Pa(),z=rl(q);Ye(()=>{u.current.orientation=R},[u,R]);const B=av(l),X=g.useRef(T),W=g.useRef(y??-1),I=g.useRef(null),F=g.useRef(!0),G=Ke(be=>{h(W.current===-1?null:W.current,be)}),J=g.useRef(G),ce=g.useRef(!!a),se=g.useRef(s),ve=g.useRef(!1),me=g.useRef(!1),je=Xn(M),Ae=Xn(s),he=Xn($),ue=Xn(y),de=Xn(P),Le=Ke(()=>{function be(Be){k?z?.events.emit("virtualfocus",Be):Gd(Be,{sync:ve.current,preventScroll:!0})}const ke=d.current[W.current],Ee=me.current;ke&&be(ke),(ve.current?Be=>Be():requestAnimationFrame)(()=>{const Be=d.current[W.current]||ke;if(!Be)return;ke||be(Be);const ze=he.current;ze&&we&&(Ee||!F.current)&&Be.scrollIntoView?.(typeof ze=="boolean"?{block:"nearest",inline:"nearest"}:ze)})});Ye(()=>{m&&(s&&a?(W.current=y??-1,X.current&&y!=null&&(me.current=!0,G())):ce.current&&(W.current=-1,J.current()))},[m,s,a,y,G]),Ye(()=>{if(m){if(!s){ve.current=!1;return}if(a)if(p==null){if(ve.current=!1,ue.current!=null)return;if(ce.current&&(W.current=-1,Le()),(!se.current||!ce.current)&&X.current&&(I.current!=null||X.current===!0&&I.current==null)){let be=0;const ke=()=>{d.current[0]==null?(be<2&&(be?requestAnimationFrame:queueMicrotask)(ke),be+=1):(W.current=I.current==null||Xm(I.current,R,N)||j?Vm(d):Tj(d),I.current=null,G())};ke()}}else gc(d,p)||(W.current=p,Le(),me.current=!1)}},[m,s,a,p,ue,j,d,R,N,G,Le,je]),Ye(()=>{if(!m||a||!z||k||!ce.current)return;const be=z.nodesRef.current,ke=be.find(Be=>Be.id===L)?.context?.elements.floating,Ee=xa(Cn(a)),Se=be.some(Be=>Be.context&&Dt(Be.context.elements.floating,Ee));ke&&!Se&&F.current&&ke.focus({preventScroll:!0})},[m,a,z,L,k]),Ye(()=>{J.current=G,se.current=s,ce.current=!!a}),Ye(()=>{s||(I.current=null,X.current=T)},[s,T]);const Te=p!=null,we=g.useMemo(()=>{function be(Ee){if(!Ae.current)return;const Se=d.current.indexOf(Ee.currentTarget);Se!==-1&&W.current!==Se&&(W.current=Se,G(Ee))}return{onFocus(Ee){ve.current=!0,be(Ee)},onClick:({currentTarget:Ee})=>Ee.focus({preventScroll:!0}),onMouseMove(Ee){ve.current=!0,me.current=!1,E&&be(Ee)},onPointerLeave(Ee){if(!Ae.current||!F.current||Ee.pointerType==="touch")return;ve.current=!0;const Se=Ee.relatedTarget;!E||d.current.includes(Se)||de.current&&(W.current=-1,G(Ee),k||H.current?.focus({preventScroll:!0}))}}},[Ae,H,E,d,G,de,k]),Ne=g.useCallback(()=>A??z?.nodesRef.current.find(be=>be.id===L)?.context?.dataRef?.current.orientation,[L,z,A]),_e=Ke(be=>{if(F.current=!1,ve.current=!0,be.which===229||!Ae.current&&be.currentTarget===H.current)return;if(j&&AU(be.key,R,N,_)){Sd(be.key,Ne())||Tn(be),n.setOpen(!1,cn(Yd,be.nativeEvent)),tn(l)&&(k?z?.events.emit("virtualfocus",l):l.focus());return}const ke=W.current,Ee=Vm(d,M),Se=Tj(d,M);if(B||(be.key==="Home"&&(Tn(be),W.current=Ee,G(be)),be.key==="End"&&(Tn(be),W.current=Se,G(be))),_>1){const Be=V||Array.from({length:d.current.length},()=>({width:1,height:1})),ze=v6(Be,_,U),bt=ze.findIndex(Xt=>Xt!=null&&!vc(d,Xt,M)),kt=ze.reduce((Xt,Jt,$e)=>Jt!=null&&!vc(d,Jt,M)?$e:Xt,-1),un=ze[g6({current:ze.map(Xt=>Xt!=null?d.current[Xt]:null)},{event:be,orientation:R,loopFocus:w,rtl:N,cols:_,disabledIndices:x6([...(typeof M!="function"?M:null)||d.current.map((Xt,Jt)=>vc(d,Jt,M)?Jt:void 0),void 0],ze),minIndex:bt,maxIndex:kt,prevIndex:y6(W.current>Se?Ee:W.current,Be,ze,_,be.key===qc?"bl":be.key===(N?Na:ka)?"tr":"tl"),stopEvent:!0})];if(un!=null&&(W.current=un,G(be)),R==="both")return}if(Sd(be.key,R)){if(Tn(be),s&&!k&&xa(be.currentTarget.ownerDocument)===be.currentTarget){W.current=Xm(be.key,R,N)?Ee:Se,G(be);return}Xm(be.key,R,N)?w?ke>=Se?b&&ke!==d.current.length?W.current=-1:(ve.current=!1,W.current=Ee):W.current=On(d,{startingIndex:ke,disabledIndices:M}):W.current=Math.min(Se,On(d,{startingIndex:ke,disabledIndices:M})):w?ke<=Ee?b&&ke!==-1?W.current=d.current.length:(ve.current=!1,W.current=Se):W.current=On(d,{startingIndex:ke,decrement:!0,disabledIndices:M}):W.current=Math.max(Ee,On(d,{startingIndex:ke,decrement:!0,disabledIndices:M})),gc(d,W.current)&&(W.current=-1),G(be)}}),Fe=g.useMemo(()=>k&&s&&Te&&{"aria-activedescendant":`${O}-${p}`},[k,s,Te,O,p]),Ve=g.useMemo(()=>({"aria-orientation":R==="both"?void 0:R,...B?{}:Fe,onKeyDown(be){if(be.key==="Tab"&&be.shiftKey&&s&&!k){const ke=Jn(be.nativeEvent);if(ke&&!Dt(H.current,ke))return;Tn(be),n.setOpen(!1,cn(sh,be.nativeEvent)),tn(l)&&l.focus();return}_e(be)},onPointerMove(){F.current=!0}}),[Fe,_e,H,R,B,n,s,k,l]),ie=g.useMemo(()=>{function be(Ee){T==="auto"&&DC(Ee.nativeEvent)&&(X.current=!k)}function ke(Ee){X.current=T,T==="auto"&&PC(Ee.nativeEvent)&&(X.current=!0)}return{onKeyDown(Ee){const Se=n.select("open");F.current=!1;const Be=Ee.key.startsWith("Arrow"),ze=TU(Ee.key,Ne(),N),bt=Sd(Ee.key,R),kt=(j?ze:bt)||Ee.key==="Enter"||Ee.key.trim()==="";if(k&&Se)return _e(Ee);if(!(!Se&&!S&&Be)){if(kt){const un=Sd(Ee.key,Ne());I.current=j&&un?null:Ee.key}if(j){ze&&(Tn(Ee),Se?(W.current=Vm(d,je.current),G(Ee)):n.setOpen(!0,cn(Yd,Ee.nativeEvent,Ee.currentTarget)));return}bt&&(ue.current!=null&&(W.current=ue.current),Tn(Ee),!Se&&S?n.setOpen(!0,cn(Yd,Ee.nativeEvent,Ee.currentTarget)):_e(Ee),Se&&G(Ee))}},onFocus(Ee){n.select("open")&&!k&&(W.current=-1,G(Ee))},onPointerDown:ke,onPointerEnter:ke,onMouseDown:be,onClick:be}},[_e,je,T,d,j,G,n,S,R,Ne,N,ue,k]),ye=g.useMemo(()=>({...Fe,...ie}),[Fe,ie]);return g.useMemo(()=>m?{reference:ye,floating:Ve,item:we,trigger:ie}:{},[m,ye,Ve,ie,we])}const RU=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function _U(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=_a(),m=l?.id||h,y=g.useMemo(()=>bf(u)?.id||a,[u,a]),b=RU.get(p)??p,j=Pa()!=null,N=g.useMemo(()=>b==="tooltip"||p==="label"?Qn:{"aria-haspopup":b==="alertdialog"?"dialog":b,"aria-expanded":"false",...b==="listbox"&&{role:"combobox"},...b==="menu"&&j&&{role:"menuitem"},...p==="select"&&{"aria-autocomplete":"none"},...p==="combobox"&&{"aria-autocomplete":"list"}},[b,j,p]),k=g.useMemo(()=>b==="tooltip"||p==="label"?{[`aria-${p==="label"?"labelledby":"describedby"}`]:s?y:void 0}:{...N,"aria-expanded":s?"true":"false","aria-controls":s?y:void 0,...b==="menu"&&{id:m}},[b,y,s,m,p,N]),T=g.useMemo(()=>{const S={id:y,...b&&{role:b}};return b==="tooltip"||p==="label"?S:{...S,...b==="menu"&&{"aria-labelledby":m}}},[b,y,m,p]),E=g.useCallback(({active:S,selected:M})=>{const R={role:"option",...S&&{id:`${y}-fui-option`}};switch(p){case"select":case"combobox":return{...R,"aria-selected":M}}return{}},[y,p]);return g.useMemo(()=>d?{reference:k,floating:T,item:E,trigger:N}:{},[d,k,T,N,E])}function OU(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:b=bC,selectedIndex:w=null}=t,j=Fs(),N=g.useRef(""),k=g.useRef(w??u??-1),T=g.useRef(null);Ye(()=>{s&&(j.clear(),T.current=null,N.current="")},[s,j]),Ye(()=>{s&&N.current===""&&(k.current=w??u??-1)},[s,w,u]);const E=Ke(A=>{A?a.current.typing||(a.current.typing=A,p?.(A)):a.current.typing&&(a.current.typing=A,p?.(A))}),S=Ke(A=>{function _(P,q,Z){const H=m?m(q,Z):q.find(L=>L?.toLocaleLowerCase().indexOf(Z.toLocaleLowerCase())===0);return H?P.indexOf(H):-1}const $=l.current;if(N.current.length>0&&N.current[0]!==" "&&(_($,$,N.current)===-1?E(!1):A.key===" "&&Tn(A)),$==null||b.includes(A.key)||A.key.length!==1||A.ctrlKey||A.metaKey||A.altKey)return;s&&A.key!==" "&&(Tn(A),E(!0)),$.every(P=>P?P[0]?.toLocaleLowerCase()!==P[1]?.toLocaleLowerCase():!0)&&N.current===A.key&&(N.current="",k.current=T.current),N.current+=A.key,j.start(y,()=>{N.current="",k.current=T.current,E(!1)});const U=k.current,O=_($,[...$.slice((U||0)+1),...$.slice(0,(U||0)+1)],N.current);O!==-1?(d?.(O),T.current=O):A.key!==" "&&(N.current="",E(!1))}),M=g.useMemo(()=>({onKeyDown:S}),[S]),R=g.useMemo(()=>({onKeyDown:S,onKeyUp(A){A.key===" "&&E(!1)}}),[S,E]);return g.useMemo(()=>h?{reference:M,floating:R}:{},[h,M,R])}const IU=g.createContext(void 0);function DU(e){return g.useContext(IU)}const pT="ArrowUp",mT="ArrowDown",gT="ArrowLeft",vT="ArrowRight",yT="Home",xT="End",PU=new Set([gT,vT]),zU=new Set([pT,mT]),LU=new Set([...PU,...zU]);[...LU];const $U=new Set([pT,mT,gT,vT,yT,xT]);function UU(e){return e==="starting"?XL:Qn}const BU={...wC,...i$},VU=g.forwardRef(function(t,n){const{render:s,className:a,finalFocus:l,...u}=t,{store:d}=nl(),{side:p,align:h}=pC(),m=DU()!=null,y=d.useState("open"),b=d.useState("transitionStatus"),w=d.useState("popupProps"),j=d.useState("mounted"),N=d.useState("instantType"),k=d.useState("activeTriggerElement"),T=d.useState("parent"),E=d.useState("lastOpenChangeReason"),S=d.useState("rootId"),M=d.useState("floatingRootContext"),R=d.useState("floatingTreeRoot"),A=d.useState("closeDelay"),_=d.useState("activeTriggerElement");TC({open:y,ref:d.context.popupRef,onComplete(){y&&d.context.onOpenChangeComplete?.(!0)}}),g.useEffect(()=>{function q(Z){d.setOpen(!1,cn(Z.reason,Z.domEvent))}return R.events.on("close",q),()=>{R.events.off("close",q)}},[R.events,d]);const $=d.useState("hoverEnabled"),V=d.useState("disabled");NU(M,{enabled:$&&!V&&T.type!=="context-menu"&&T.type!=="menubar",closeDelay:A});const U=g.useMemo(()=>({transitionStatus:b,side:p,align:h,open:y,nested:T.type==="menu",instant:N}),[b,p,h,y,T.type,N]),O=Oa("div",t,{state:U,ref:[n,d.context.popupRef],stateAttributesMapping:BU,props:[w,{onKeyDown(q){m&&$U.has(q.key)&&q.stopPropagation()}},UU(b),u,{"data-rootownerid":S}]});let P=T.type===void 0||T.type==="context-menu";return(k||T.type==="menubar"&&E!==py)&&(P=!0),o.jsx(G6,{context:M,modal:!1,disabled:!j,returnFocus:l===void 0?P:l,initialFocus:T.type!=="menu",restoreFocus:!0,externalTree:T.type!=="menubar"?R:void 0,previousFocusableElement:_,nextFocusableElement:T.type===void 0?d.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:T.type===void 0?d.context.beforeContentFocusGuardRef:void 0,children:O})}),bT=g.createContext(void 0);function FU(){const e=g.useContext(bT);if(e===void 0)throw new Error(Ei(32));return e}const HU=g.forwardRef(function(t,n){const{keepMounted:s=!1,...a}=t,{store:l}=nl();return l.useState("mounted")||s?o.jsx(bT.Provider,{value:s,children:o.jsx(H6,{ref:n,...a})}):null});function qU(e){return fy(19)?e:e?"true":void 0}const ZU=g.createContext(void 0);function wT(){return g.useContext(ZU)?.direction??"ltr"}const WU=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 b=zC(m),w={x:n,y:s},j=wy(a),N=by(j),k=await u.getDimensions(h),T=j==="y",E=T?"top":"left",S=T?"bottom":"right",M=T?"clientHeight":"clientWidth",R=l.reference[N]+l.reference[j]-w[j]-l.floating[N],A=w[j]-l.reference[j],_=y==="real"?await u.getOffsetParent?.(h):d.floating;let $=d.floating[M]||l.floating[N];(!$||!await u.isElement?.(_))&&($=d.floating[M]||l.floating[N]);const V=R/2-A/2,U=$/2-k[N]/2-1,O=Math.min(b[E],U),P=Math.min(b[S],U),q=O,Z=$-k[N]-P,H=$/2-k[N]/2+V,L=iv(q,H,Z),z=!p.arrow&&Da(a)!=null&&H!==L&&l.reference[N]/2-(H<q?O:P)-k[N]/2<0,B=z?H<q?H-q:H-Z:0;return{[j]:w[j]+B,data:{[j]:L,centerOffset:H-L-B,...z&&{alignmentOffset:B}},reset:z}}}),YU=(e,t)=>({...WU(e),options:[e,t]}),GU={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 P8().fn(e)).data?.referenceHidden||l}}}},KU={sideX:"left",sideY:"top"};function jT(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 Xj(e,t,n){const{rects:s,placement:a}=e;return{side:jT(t,ds(a),n),align:Da(a)||"center",anchor:{width:s.reference.width,height:s.reference.height},positioner:{width:s.floating.width,height:s.floating.height}}}function XU(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:b=!1,floatingRootContext:w,mounted:j,collisionAvoidance:N,shiftCrossAxis:k=!1,nodeId:T,adaptiveOrigin:E,lazyFlip:S=!1,externalTree:M}=e,[R,A]=g.useState(null);!j&&R!==null&&A(null);const _=N.side||"flip",$=N.align||"flip",V=N.fallbackAxisSide||"end",U=typeof t=="function"?t:void 0,O=Ke(U),P=U?O:t,q=Xn(t),H=wT()==="rtl",L=R||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":H?"left":"right","inline-start":H?"right":"left"}[s],z=l==="center"?L:`${L}-${l}`;let B=p;const X=1,W=s==="bottom"?X:0,I=s==="top"?X:0,F=s==="right"?X:0,G=s==="left"?X:0;typeof B=="number"?B={top:B+W,right:B+G,bottom:B+I,left:B+F}:B&&(B={top:(B.top||0)+W,right:(B.right||0)+G,bottom:(B.bottom||0)+I,left:(B.left||0)+F});const J={boundary:d==="clipping-ancestors"?"clippingAncestors":d,padding:B},ce=g.useRef(null),se=Xn(a),ve=Xn(u),Ae=[R8(gt=>{const Bt=Xj(gt,s,H),xn=typeof se.current=="function"?se.current(Bt):se.current,Wt=typeof ve.current=="function"?ve.current(Bt):ve.current;return{mainAxis:xn,crossAxis:Wt,alignmentAxis:Wt}},[typeof a!="function"?a:0,typeof u!="function"?u:0,H,s])],he=$==="none"&&_!=="shift",ue=!he&&(h||k||_==="shift"),de=_==="none"?null:I8({...J,padding:{top:B.top+X,right:B.right+X,bottom:B.bottom+X,left:B.left+X},mainAxis:!k&&_==="flip",crossAxis:$==="flip"?"alignment":!1,fallbackAxisSideDirection:V}),Le=he?null:_8(gt=>{const Bt=ji(gt.elements.floating).documentElement;return{...J,rootBoundary:k?{x:0,y:0,width:Bt.clientWidth,height:Bt.clientHeight}:void 0,mainAxis:$!=="none",crossAxis:ue,limiter:h||k?void 0:O8(xn=>{if(!ce.current)return{};const{width:Wt,height:Rn}=ce.current.getBoundingClientRect(),dn=Cs(ds(xn.placement)),fn=dn==="y"?Wt:Rn,qs=dn==="y"?B.left+B.right:B.top+B.bottom;return{offset:fn/2+qs/2}})}},[J,h,k,B,$]);_==="shift"||$==="shift"||l==="center"?Ae.push(Le,de):Ae.push(de,Le),Ae.push(D8({...J,apply({elements:{floating:gt},rects:{reference:Bt},availableWidth:xn,availableHeight:Wt}){Object.entries({"--available-width":`${xn}px`,"--available-height":`${Wt}px`,"--anchor-width":`${Bt.width}px`,"--anchor-height":`${Bt.height}px`}).forEach(([Rn,dn])=>{gt.style.setProperty(Rn,dn)})}}),YU(()=>({element:ce.current||document.createElement("div"),padding:m,offsetParent:"floating"}),[m]),{name:"transformOrigin",fn(gt){const{elements:Bt,middlewareData:xn,placement:Wt,rects:Rn,y:dn}=gt,fn=ds(Wt),qs=Cs(fn),Zs=ce.current,Mi=xn.arrow?.x||0,ee=xn.arrow?.y||0,ge=Zs?.clientWidth||0,xe=Zs?.clientHeight||0,Ze=Mi+ge/2,We=ee+xe/2,dt=Math.abs(xn.shift?.y||0),Vt=Rn.reference.height/2,Et=typeof a=="function"?a(Xj(gt,s,H)):a,mn=dt>Et,bn={top:`${Ze}px calc(100% + ${Et}px)`,bottom:`${Ze}px ${-Et}px`,left:`calc(100% + ${Et}px) ${We}px`,right:`${-Et}px ${We}px`}[fn],Ws=`${Ze}px ${Rn.reference.y+Vt-dn}px`;return Bt.floating.style.setProperty("--transform-origin",ue&&qs==="y"&&mn?Ws:bn),{}}},GU,E),Ye(()=>{!j&&w&&w.update({referenceElement:null,floatingElement:null,domReferenceElement:null})},[j,w]);const Te=g.useMemo(()=>({elementResize:!y&&typeof ResizeObserver<"u",layoutShift:!y&&typeof IntersectionObserver<"u"}),[y]),{refs:we,elements:Ne,x:_e,y:Fe,middlewareData:Ve,update:ie,placement:ye,context:be,isPositioned:ke,floatingStyles:Ee}=yU({rootContext:w,placement:z,middleware:Ae,strategy:n,whileElementsMounted:b?void 0:(...gt)=>Bj(...gt,Te),nodeId:T,externalTree:M}),{sideX:Se,sideY:Be}=Ve.adaptiveOrigin||KU,ze=ke?n:"fixed",bt=g.useMemo(()=>E?{position:ze,[Se]:_e,[Be]:Fe}:{position:ze,...Ee},[E,ze,Se,_e,Be,Fe,Ee]),kt=g.useRef(null);Ye(()=>{if(!j)return;const gt=q.current,Bt=typeof gt=="function"?gt():gt,Wt=(Jj(Bt)?Bt.current:Bt)||null||null;Wt!==kt.current&&(we.setPositionReference(Wt),kt.current=Wt)},[j,we,P,q]),g.useEffect(()=>{if(!j)return;const gt=q.current;typeof gt!="function"&&Jj(gt)&>.current!==kt.current&&(we.setPositionReference(gt.current),kt.current=gt.current)},[j,we,P,q]),g.useEffect(()=>{if(b&&j&&Ne.domReference&&Ne.floating)return Bj(Ne.domReference,Ne.floating,ie,Te)},[b,j,Ne,ie,Te]);const un=ds(ye),Xt=jT(s,un,H),Jt=Da(ye)||"center",$e=!!Ve.hide?.referenceHidden;Ye(()=>{S&&j&&ke&&A(un)},[S,j,ke,un]);const at=g.useMemo(()=>({position:"absolute",top:Ve.arrow?.y,left:Ve.arrow?.x}),[Ve.arrow]),lt=Ve.arrow?.centerOffset!==0;return g.useMemo(()=>({positionerStyles:bt,arrowStyles:at,arrowRef:ce,arrowUncentered:lt,side:Xt,align:Jt,physicalSide:un,anchorHidden:$e,refs:we,context:be,isPositioned:ke,update:ie}),[bt,at,ce,lt,Xt,Jt,un,$e,we,be,ke,ie])}function Jj(e){return e!=null&&"current"in e}function JU(e){const{children:t,elementsRef:n,labelsRef:s,onMapChange:a}=e,l=Ke(a),u=g.useRef(0),d=Ms(e9).current,p=Ms(QU).current,[h,m]=g.useState(0),y=g.useRef(h),b=Ke((T,E)=>{p.set(T,E??null),y.current+=1,m(y.current)}),w=Ke(T=>{p.delete(T),y.current+=1,m(y.current)}),j=g.useMemo(()=>{const T=new Map;return Array.from(p.keys()).filter(S=>S.isConnected).sort(t9).forEach((S,M)=>{const R=p.get(S)??{};T.set(S,{...R,index:M})}),T},[p,h]);Ye(()=>{if(typeof MutationObserver!="function"||j.size===0)return;const T=new MutationObserver(E=>{const S=new Set,M=R=>S.has(R)?S.delete(R):S.add(R);E.forEach(R=>{R.removedNodes.forEach(M),R.addedNodes.forEach(M)}),S.size===0&&(y.current+=1,m(y.current))});return j.forEach((E,S)=>{S.parentElement&&T.observe(S.parentElement,{childList:!0})}),()=>{T.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(T=>(d.add(T),()=>{d.delete(T)}));Ye(()=>{d.forEach(T=>T(j))},[d,j]);const k=g.useMemo(()=>({register:b,unregister:w,subscribeMapChange:N,elementsRef:n,labelsRef:s,nextIndexRef:u}),[b,w,N,n,s,u]);return o.jsx(kC.Provider,{value:k,children:t})}function QU(){return new Map}function e9(){return new Set}function t9(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 n9=g.forwardRef(function(t,n){const{cutout:s,...a}=t;let l;if(s){const u=s?.getBoundingClientRect();l=`polygon(
|
|
111
|
-
0% 0%,
|
|
112
|
-
100% 0%,
|
|
113
|
-
100% 100%,
|
|
114
|
-
0% 100%,
|
|
115
|
-
0% 0%,
|
|
116
|
-
${u.left}px ${u.top}px,
|
|
117
|
-
${u.left}px ${u.bottom}px,
|
|
118
|
-
${u.right}px ${u.bottom}px,
|
|
119
|
-
${u.right}px ${u.top}px,
|
|
120
|
-
${u.left}px ${u.top}px
|
|
121
|
-
)`}return o.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...a,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:l}})}),s9=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:b=5,arrowPadding:w=5,sticky:j=!1,disableAnchorTracking:N=!1,collisionAvoidance:k=QL,...T}=t,{store:E}=nl(),S=FU(),M=th(!0),R=E.useState("parent"),A=E.useState("floatingRootContext"),_=E.useState("floatingTreeRoot"),$=E.useState("mounted"),V=E.useState("open"),U=E.useState("modal"),O=E.useState("activeTriggerElement"),P=E.useState("lastOpenChangeReason"),q=E.useState("floatingNodeId"),Z=E.useState("floatingParentNodeId");let H=s,L=h,z=m,B=p;R.type==="context-menu"&&(H=s??R.context?.anchor,B=B??"start",!d&&B!=="center"&&(z=t.alignOffset??2,L=t.sideOffset??-5));let X=d,W=B;R.type==="menu"?(X=X??"inline-end",W=W??"start"):R.type==="menubar"&&(X=X??"bottom",W=W??"start");const I=R.type==="context-menu",F=XU({anchor:H,floatingRootContext:A,positionMethod:M?"fixed":a,mounted:$,side:X,sideOffset:L,align:W,alignOffset:z,arrowPadding:I?0:w,collisionBoundary:y,collisionPadding:b,sticky:j,nodeId:q,keepMounted:S,disableAnchorTracking:N,collisionAvoidance:k,shiftCrossAxis:I,externalTree:_}),G=g.useMemo(()=>{const je={};return V||(je.pointerEvents="none"),{role:"presentation",hidden:!$,style:{...F.positionerStyles,...je}}},[V,$,F.positionerStyles]);g.useEffect(()=>{function je(Ae){Ae.open?(Ae.parentNodeId===q&&E.set("hoverEnabled",!1),Ae.nodeId!==q&&Ae.parentNodeId===E.select("floatingParentNodeId")&&E.setOpen(!1,cn(cc))):Ae.parentNodeId===q&&Ae.reason!==cc&&E.set("hoverEnabled",!0)}return _.events.on("menuopenchange",je),()=>{_.events.off("menuopenchange",je)}},[E,_.events,q]),g.useEffect(()=>{if(E.select("floatingParentNodeId")==null)return;function je(Ae){if(Ae.open||Ae.nodeId!==E.select("floatingParentNodeId"))return;const he=Ae.reason??cc;E.setOpen(!1,cn(he))}return _.events.on("menuopenchange",je),()=>{_.events.off("menuopenchange",je)}},[_.events,E]),g.useEffect(()=>{function je(Ae){!V||Ae.nodeId!==E.select("floatingParentNodeId")||Ae.target&&O&&O!==Ae.target&&E.setOpen(!1,cn(cc))}return _.events.on("itemhover",je),()=>{_.events.off("itemhover",je)}},[_.events,V,O,E]),g.useEffect(()=>{const je={open:V,nodeId:q,parentNodeId:Z,reason:E.select("lastOpenChangeReason")};_.events.emit("menuopenchange",je)},[_.events,V,E,q,Z]);const J=g.useMemo(()=>({open:V,side:F.side,align:F.align,anchorHidden:F.anchorHidden,nested:R.type==="menu"}),[V,F.side,F.align,F.anchorHidden,R.type]),ce=g.useMemo(()=>({side:F.side,align:F.align,arrowRef:F.arrowRef,arrowUncentered:F.arrowUncentered,arrowStyles:F.arrowStyles,nodeId:F.context.nodeId}),[F.side,F.align,F.arrowRef,F.arrowUncentered,F.arrowStyles,F.context.nodeId]),se=Oa("div",t,{state:J,stateAttributesMapping:wC,ref:[n,E.useStateSetter("positionerElement")],props:[G,T]}),ve=$&&R.type!=="menu"&&(R.type!=="menubar"&&U&&P!==pi||R.type==="menubar"&&R.context.modal);let me=null;return R.type==="menubar"?me=R.context.contentElement:R.type===void 0&&(me=O),o.jsxs(hC.Provider,{value:ce,children:[ve&&o.jsx(n9,{ref:R.type==="context-menu"||R.type==="nested-context-menu"?R.context.internalBackdropRef:null,inert:qU(!V),cutout:me}),o.jsx(z6,{id:q,children:o.jsx(JU,{elementsRef:E.context.itemDomElements,labelsRef:E.context.itemLabels,children:se})})]})});let Qj={},eS={},tS="";function r9(e){if(typeof document>"u")return!1;const t=ji(e);return An(t).innerWidth-t.documentElement.clientWidth>0}function a9(e){const t=ji(e),n=t.documentElement,s=t.body,a=Ci(n)?n:s,l=a.style.overflow;return a.style.overflow="hidden",()=>{a.style.overflow=l}}function i9(e){const t=ji(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(W$&&(a.visualViewport?.scale??1)!==1)return()=>{};function h(){const b=a.getComputedStyle(n),w=a.getComputedStyle(s),k=(b.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";l=n.scrollTop,u=n.scrollLeft,Qj={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},tS=n.style.scrollBehavior,eS={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 T=n.scrollHeight>n.clientHeight,E=n.scrollWidth>n.clientWidth,S=b.overflowY==="scroll"||w.overflowY==="scroll",M=b.overflowX==="scroll"||w.overflowX==="scroll",R=Math.max(0,a.innerWidth-n.clientWidth),A=Math.max(0,a.innerHeight-n.clientHeight),_=parseFloat(w.marginTop)+parseFloat(w.marginBottom),$=parseFloat(w.marginLeft)+parseFloat(w.marginRight),V=Ci(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"}),(T||S)&&(n.style.overflowY="scroll"),(E||M)&&(n.style.overflowX="scroll"),Object.assign(s.style,{position:"relative",height:_||A?`calc(100dvh - ${_+A}px)`:"100dvh",width:$||R?`calc(100vw - ${$+R}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,Qj),Object.assign(s.style,eS),p||(n.scrollTop=l,n.scrollLeft=u,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=tS)}function y(){m(),d.request(h)}return h(),a.addEventListener("resize",y),()=>{d.cancel(),m(),typeof a.removeEventListener=="function"&&a.removeEventListener("resize",y)}}class o9{lockCount=0;restore=null;timeoutLock=Ko.create();timeoutUnlock=Ko.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=ji(t).documentElement,a=An(s).getComputedStyle(s).overflowY;if(a==="hidden"||a==="clip"){this.restore=xC;return}const l=Y$||!r9(t);this.restore=l?a9(t):i9(t)}}const l9=new o9;function c9(e=!0,t=null){Ye(()=>{if(e)return l9.acquire(t)},[e,t])}const u9=g.createContext(null);function d9(e){return g.useContext(u9)}function f9(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 h9(e){const[t,n]=g.useState(null),s=Ke((d,p)=>{e||n(p)}),a=g.useCallback(()=>{n(null)},[]),{onClick:l,onPointerDown:u}=f9(s);return g.useMemo(()=>({openMethod:t,reset:a,triggerProps:{onClick:l,onPointerDown:u}}),[t,a,l,u])}const p9={...gU,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 Ey extends hT{constructor(t){super({...m9(),...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 ky},p9),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 Ms(()=>t??new Ey(n)).current}unsubscribeParentListener=null}function m9(){return{...mU(),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 GC,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:Qn,keyboardEventRelay:void 0,closeDelay:0}}const g9=g.createContext(void 0);function v9(){return g.useContext(g9)}function y9(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:b,triggerId:w,defaultTriggerId:j=null,highlightItemOnHover:N=!0}=e,k=th(!0),T=nl(!0),E=d9(),S=v9(),M=g.useMemo(()=>S&&T?{type:"menu",store:T.store}:E?{type:"menubar",context:E}:k&&!T?{type:"context-menu",context:k}:{type:void 0},[k,T,E,S]),R=Ey.useStore(b?.store,{parent:M}),A=R.useState("floatingTreeRoot"),_=P6(A),$=Pa();Ye(()=>{k&&!T?R.update({parent:{type:"context-menu",context:k},floatingNodeId:_,floatingParentNodeId:$}):T&&R.update({floatingNodeId:_,floatingParentNodeId:$})},[k,T,_,$,R]),R.useControlledProp("open",n,l),R.useControlledProp("activeTriggerId",w,j),R.useContextCallback("onOpenChangeComplete",a);const V=R.useState("open"),U=R.useState("activeTriggerElement"),O=R.useState("positionerElement"),P=R.useState("hoverEnabled"),q=R.useState("modal"),Z=R.useState("disabled"),H=R.useState("lastOpenChangeReason"),L=R.useState("parent"),z=R.useState("activeIndex"),B=R.useState("payload"),X=R.useState("floatingParentNodeId"),W=g.useRef(null),I=X!=null;let F;R.useSyncedValues({disabled:u,modal:L.type===void 0?d:void 0,rootId:_a()});const{openMethod:G,triggerProps:J,reset:ce}=h9(V);fU(R);const{forceUnmount:se}=hU(V,R,()=>{R.update({allowMouseEnter:!1,stickIfOpen:!0}),ce()}),ve=g.useRef(L.type!=="context-menu"),me=Fs();g.useEffect(()=>{if(V||(W.current=null),L.type==="context-menu"){if(!V){me.clear(),ve.current=!1;return}me.start(500,()=>{ve.current=!0})}},[me,V,L.type]),c9(V&&q&&H!==pi&&G!=="touch",O),Ye(()=>{!V&&!P&&R.set("hoverEnabled",!0)},[V,P,R]);const je=g.useRef(!0),Ae=Fs(),he=Ke(($e,at)=>{const lt=at.reason;if(V===$e&&at.trigger===U||(at.preventUnmountOnClose=()=>{R.set("preventUnmountingOnClose",!0)},!$e&&at.trigger==null&&(at.trigger=U??void 0),s?.($e,at),at.isCanceled))return;const gt={open:$e,nativeEvent:at.event,reason:at.reason,nested:I};F?.emit("openchange",gt);const Bt=at.event;if($e===!1&&Bt?.type==="click"&&Bt.pointerType==="touch"&&!je.current)return;if(!$e&&z!==null){const dn=R.context.itemDomElements.current[z];queueMicrotask(()=>{dn?.setAttribute("tabindex","-1")})}$e&<===Nj?(je.current=!1,Ae.start(300,()=>{je.current=!0})):(je.current=!0,Ae.clear());const xn=(lt===xf||lt===jC)&&Bt.detail===0&&Bt?.isTrusted,Wt=!$e&&(lt===SC||lt==null);function Rn(){const dn={open:$e,openChangeReason:lt};W.current=at.event??null;const fn=at.trigger?.id??null;(fn||$e)&&(dn.activeTriggerId=fn,dn.activeTriggerElement=at.trigger??null),R.update(dn)}lt===pi?wi.flushSync(Rn):Rn(),L.type==="menubar"&&(lt===Nj||lt===sh||lt===pi||lt===Yd||lt===cc)?R.set("instantType","group"):xn||Wt?R.set("instantType",xn?"click":"dismiss"):R.set("instantType",void 0)}),ue=g.useCallback($e=>{const at=cn($e);return at.preventUnmountOnClose=()=>{R.set("preventUnmountingOnClose",!0)},at},[R]),de=g.useCallback(()=>{R.setOpen(!1,ue(p$))},[R,ue]);g.useImperativeHandle(m,()=>({unmount:se,close:de}),[se,de]);let Le;L.type==="context-menu"&&(Le=L.context),g.useImperativeHandle(Le?.positionerRef,()=>O,[O]),g.useImperativeHandle(Le?.actionsRef,()=>({setOpen:he}),[he]);const Te=xU({popupStore:R,onOpenChange:he});F=Te.context.events,g.useEffect(()=>{const $e=({open:at,eventDetails:lt})=>he(at,lt);return F.on("setOpen",$e),()=>{F?.off("setOpen",$e)}},[F,he]);const we=$8(Te,{enabled:!Z,bubbles:y&&L.type==="menu",outsidePress(){return L.type!=="context-menu"||W.current?.type==="contextmenu"?!0:ve.current},externalTree:I?A:void 0}),Ne=_U(Te,{role:"menu"}),_e=wT(),Fe=g.useCallback($e=>{R.select("activeIndex")!==$e&&R.set("activeIndex",$e)},[R]),Ve=MU(Te,{enabled:!Z,listRef:R.context.itemDomElements,activeIndex:z,nested:L.type!==void 0,loopFocus:p,orientation:h,parentOrientation:L.type==="menubar"?L.context.orientation:void 0,rtl:_e==="rtl",disabledIndices:bC,onNavigate:Fe,openOnArrowKeyDown:L.type!=="context-menu",externalTree:I?A:void 0,focusItemOnHover:N}),ie=g.useCallback($e=>{R.context.typingRef.current=$e},[R]),ye=OU(Te,{listRef:R.context.itemLabels,activeIndex:z,resetMs:KL,onMatch:$e=>{V&&$e!==z&&R.set("activeIndex",$e)},onTypingChange:ie}),{getReferenceProps:be,getFloatingProps:ke,getItemProps:Ee,getTriggerProps:Se}=EU([we,Ne,Ve,ye]),Be=g.useMemo(()=>{const $e=nh(be(),{onMouseEnter(){R.set("hoverEnabled",!0)},onMouseMove(){R.set("allowMouseEnter",!0)}},J);return delete $e.role,$e},[be,R,J]),ze=g.useMemo(()=>{const $e=Se();if(!$e)return $e;const{role:at,["aria-controls"]:lt,...gt}=$e;return gt},[Se]),bt=vy(),kt=g.useMemo(()=>ke({onMouseEnter(){L.type==="menu"&&bt.request(()=>R.set("hoverEnabled",!1))},onMouseMove(){R.set("allowMouseEnter",!0)},onClick(){R.select("hoverEnabled")&&R.set("hoverEnabled",!1)},onKeyDown($e){const at=R.select("keyboardEventRelay");at&&!$e.isPropagationStopped()&&at($e)}}),[ke,L.type,bt,R]),un=g.useMemo(()=>Ee(),[Ee]);R.useSyncedValues({floatingRootContext:Te,activeTriggerProps:Be,inactiveTriggerProps:ze,popupProps:kt,itemProps:un});const Xt=g.useMemo(()=>({store:R,parent:M}),[R,M]),Jt=o.jsx(dy.Provider,{value:Xt,children:typeof t=="function"?t({payload:B}):t});return L.type===void 0||L.type==="context-menu"?o.jsx(L6,{externalTree:A,children:Jt}):Jt}function ST(e){if(tn(e)&&e.hasAttribute("data-rootownerid"))return e.getAttribute("data-rootownerid")??void 0;if(!ar(e))return ST(cr(e))}const x9=g.forwardRef(function(t,n){const{className:s,render:a,orientation:l="horizontal",...u}=t,d=g.useMemo(()=>({orientation:l}),[l]);return Oa("div",t,{state:d,ref:n,props:[{role:"separator","aria-orientation":l},u]})});function b9(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=_a(),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(fC.Provider,{value:m,children:o.jsx(dy.Provider,{value:void 0,children:o.jsx(y9,{...e})})})}const nS=500,w9=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:b,rootId:w}=th(!1),{store:j}=nl(!1),N=j.useState("open"),k=g.useRef(null),T=g.useRef(null),E=Fs(),S=Fs(),M=g.useRef(!1);function R(P,q,Z){const H=Z.type.startsWith("touch");b.current={x:P,y:q},u({getBoundingClientRect(){return DOMRect.fromRect({width:H?10:0,height:H?10:0,x:P,y:q})}}),M.current=!1,d.current?.setOpen(!0,cn(xf,Z)),S.start(nS,()=>{M.current=!0})}function A(P){y.current=!0,Tn(P),R(P.clientX,P.clientY,P.nativeEvent),ji(k.current).addEventListener("mouseup",Z=>{if(y.current=!1,!M.current)return;S.clear(),M.current=!1;const H=Jn(Z);Dt(m.current,H)||w&&H&&ST(H)===w||d.current?.setOpen(!1,cn(h$,Z))},{once:!0})}function _(P){if(y.current=!1,P.touches.length===1){P.stopPropagation();const q=P.touches[0];T.current={x:q.clientX,y:q.clientY},E.start(nS,()=>{T.current&&R(T.current.x,T.current.y,P.nativeEvent)})}}function $(P){if(E.isStarted()&&T.current&&P.touches.length===1){const q=P.touches[0],Z=10,H=Math.abs(q.clientX-T.current.x),L=Math.abs(q.clientY-T.current.y);(H>Z||L>Z)&&E.clear()}}function V(){E.clear(),T.current=null}g.useEffect(()=>{function P(Z){const L=Jn(Z);(Dt(k.current,L)||Dt(p.current,L)||Dt(h.current,L))&&Z.preventDefault()}const q=ji(k.current);return q.addEventListener("contextmenu",P),()=>{q.removeEventListener("contextmenu",P)}},[h,p]);const U=g.useMemo(()=>({open:N}),[N]);return Oa("div",t,{state:U,ref:[k,n],props:[{onContextMenu:A,onTouchStart:_,onTouchMove:$,onTouchEnd:V,onTouchCancel:V,style:{WebkitTouchCallout:"none"}},l],stateAttributesMapping:d$})}),Cy=g.createContext({});function Ty(e){const t=g.useRef(null);return t.current===null&&(t.current=e()),t.current}const NT=typeof window<"u",kT=NT?g.useLayoutEffect:g.useEffect,dh=g.createContext(null);function Ay(e,t){e.indexOf(t)===-1&&e.push(t)}function Rf(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 My=()=>{};const $r={},ET=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function CT(e){return typeof e=="object"&&e!==null}const TT=e=>/^0[^.\s]+$/u.test(e);function AT(e){let t;return()=>(t===void 0&&(t=e()),t)}const As=e=>e,j9=(e,t)=>n=>t(e(n)),Wc=(...e)=>e.reduce(j9),Oc=(e,t,n)=>{const s=t-e;return s===0?1:(n-e)/s};class Ry{constructor(){this.subscriptions=[]}add(t){return Ay(this.subscriptions,t),()=>Rf(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 MT(e,t){return t?e*(1e3/t):0}const RT=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,S9=1e-7,N9=12;function k9(e,t,n,s,a){let l,u,d=0;do u=t+(n-t)/2,l=RT(u,s,a)-e,l>0?n=u:t=u;while(Math.abs(l)>S9&&++d<N9);return u}function Yc(e,t,n,s){if(e===t&&n===s)return As;const a=l=>k9(l,0,1,e,n);return l=>l===0||l===1?l:RT(a(l),t,s)}const _T=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,OT=e=>t=>1-e(1-t),IT=Yc(.33,1.53,.69,.99),_y=OT(IT),DT=_T(_y),PT=e=>(e*=2)<1?.5*_y(e):.5*(2-Math.pow(2,-10*(e-1))),Oy=e=>1-Math.sin(Math.acos(e)),zT=OT(Oy),LT=_T(Oy),E9=Yc(.42,0,1,1),C9=Yc(0,0,.58,1),$T=Yc(.42,0,.58,1),T9=e=>Array.isArray(e)&&typeof e[0]!="number",UT=e=>Array.isArray(e)&&typeof e[0]=="number",A9={linear:As,easeIn:E9,easeInOut:$T,easeOut:C9,circIn:Oy,circInOut:LT,circOut:zT,backIn:_y,backInOut:DT,backOut:IT,anticipate:PT},M9=e=>typeof e=="string",sS=e=>{if(UT(e)){My(e.length===4);const[t,n,s,a]=e;return Yc(t,n,s,a)}else if(M9(e))return A9[e];return e},Nd=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function R9(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,b=!1)=>{const j=b&&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 _9=40;function BT(e,t){let n=!1,s=!0;const a={delta:0,timestamp:0,isProcessing:!1},l=()=>n=!0,u=Nd.reduce((S,M)=>(S[M]=R9(l),S),{}),{setup:d,read:p,resolveKeyframes:h,preUpdate:m,update:y,preRender:b,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,_9),1)),a.timestamp=S,a.isProcessing=!0,d.process(a),p.process(a),h.process(a),m.process(a),y.process(a),b.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:Nd.reduce((S,M)=>{const R=u[M];return S[M]=(A,_=!1,$=!1)=>(n||k(),R.schedule(A,_,$)),S},{}),cancel:S=>{for(let M=0;M<Nd.length;M++)u[Nd[M]].cancel(S)},state:a,steps:u}}const{schedule:At,cancel:Ta,state:En,steps:Jm}=BT(typeof requestAnimationFrame<"u"?requestAnimationFrame:As,!0);let Xd;function O9(){Xd=void 0}const Bn={now:()=>(Xd===void 0&&Bn.set(En.isProcessing||$r.useManualTiming?En.timestamp:performance.now()),Xd),set:e=>{Xd=e,queueMicrotask(O9)}},VT=e=>t=>typeof t=="string"&&t.startsWith(e),FT=VT("--"),I9=VT("var(--"),Iy=e=>I9(e)?D9.test(e.split("/*")[0].trim()):!1,D9=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function rS(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}const al={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Ic={...al,transform:e=>ur(0,1,e)},kd={...al,default:1},bc=e=>Math.round(e*1e5)/1e5,Dy=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function P9(e){return e==null}const z9=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Py=(e,t)=>n=>!!(typeof n=="string"&&z9.test(n)&&n.startsWith(e)||t&&!P9(n)&&Object.prototype.hasOwnProperty.call(n,t)),HT=(e,t,n)=>s=>{if(typeof s!="string")return s;const[a,l,u,d]=s.match(Dy);return{[e]:parseFloat(a),[t]:parseFloat(l),[n]:parseFloat(u),alpha:d!==void 0?parseFloat(d):1}},L9=e=>ur(0,255,e),Qm={...al,transform:e=>Math.round(L9(e))},ui={test:Py("rgb","red"),parse:HT("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:s=1})=>"rgba("+Qm.transform(e)+", "+Qm.transform(t)+", "+Qm.transform(n)+", "+bc(Ic.transform(s))+")"};function $9(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 uv={test:Py("#"),parse:$9,transform:ui.transform},Gc=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),pa=Gc("deg"),or=Gc("%"),Oe=Gc("px"),U9=Gc("vh"),B9=Gc("vw"),aS={...or,parse:e=>or.parse(e)/100,transform:e=>or.transform(e*100)},zo={test:Py("hsl","hue"),parse:HT("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:s=1})=>"hsla("+Math.round(e)+", "+or.transform(bc(t))+", "+or.transform(bc(n))+", "+bc(Ic.transform(s))+")"},ln={test:e=>ui.test(e)||uv.test(e)||zo.test(e),parse:e=>ui.test(e)?ui.parse(e):zo.test(e)?zo.parse(e):uv.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?ui.transform(e):zo.transform(e),getAnimatableNone:e=>{const t=ln.parse(e);return t.alpha=0,ln.transform(t)}},V9=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function F9(e){return isNaN(e)&&typeof e=="string"&&(e.match(Dy)?.length||0)+(e.match(V9)?.length||0)>0}const qT="number",ZT="color",H9="var",q9="var(",iS="${}",Z9=/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 Dc(e){const t=e.toString(),n=[],s={color:[],number:[],var:[]},a=[];let l=0;const d=t.replace(Z9,p=>(ln.test(p)?(s.color.push(l),a.push(ZT),n.push(ln.parse(p))):p.startsWith(q9)?(s.var.push(l),a.push(H9),n.push(p)):(s.number.push(l),a.push(qT),n.push(parseFloat(p))),++l,iS)).split(iS);return{values:n,split:d,indexes:s,types:a}}function WT(e){return Dc(e).values}function YT(e){const{split:t,types:n}=Dc(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===qT?l+=bc(a[u]):d===ZT?l+=ln.transform(a[u]):l+=a[u]}return l}}const W9=e=>typeof e=="number"?0:ln.test(e)?ln.getAnimatableNone(e):e;function Y9(e){const t=WT(e);return YT(e)(t.map(W9))}const Vs={test:F9,parse:WT,createTransformer:YT,getAnimatableNone:Y9};function eg(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 G9({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=eg(p,d,e+1/3),l=eg(p,d,e),u=eg(p,d,e-1/3)}return{red:Math.round(a*255),green:Math.round(l*255),blue:Math.round(u*255),alpha:s}}function _f(e,t){return n=>n>0?t:e}const Ht=(e,t,n)=>e+(t-e)*n,tg=(e,t,n)=>{const s=e*e,a=n*(t*t-s)+s;return a<0?0:Math.sqrt(a)},K9=[uv,ui,zo],X9=e=>K9.find(t=>t.test(e));function oS(e){const t=X9(e);if(!t)return!1;let n=t.parse(e);return t===zo&&(n=G9(n)),n}const lS=(e,t)=>{const n=oS(e),s=oS(t);if(!n||!s)return _f(e,t);const a={...n};return l=>(a.red=tg(n.red,s.red,l),a.green=tg(n.green,s.green,l),a.blue=tg(n.blue,s.blue,l),a.alpha=Ht(n.alpha,s.alpha,l),ui.transform(a))},dv=new Set(["none","hidden"]);function J9(e,t){return dv.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Q9(e,t){return n=>Ht(e,t,n)}function zy(e){return typeof e=="number"?Q9:typeof e=="string"?Iy(e)?_f:ln.test(e)?lS:nB:Array.isArray(e)?GT:typeof e=="object"?ln.test(e)?lS:eB:_f}function GT(e,t){const n=[...e],s=n.length,a=e.map((l,u)=>zy(l)(l,t[u]));return l=>{for(let u=0;u<s;u++)n[u]=a[u](l);return n}}function eB(e,t){const n={...e,...t},s={};for(const a in n)e[a]!==void 0&&t[a]!==void 0&&(s[a]=zy(e[a])(e[a],t[a]));return a=>{for(const l in s)n[l]=s[l](a);return n}}function tB(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 nB=(e,t)=>{const n=Vs.createTransformer(t),s=Dc(e),a=Dc(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?dv.has(e)&&!a.values.length||dv.has(t)&&!s.values.length?J9(e,t):Wc(GT(tB(s,a),a.values),n):_f(e,t)};function KT(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?Ht(e,t,n):zy(e)(e,t)}const sB=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>At.update(t,n),stop:()=>Ta(t),now:()=>En.isProcessing?En.timestamp:Bn.now()}},XT=(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)})`},Of=2e4;function Ly(e){let t=0;const n=50;let s=e.next(t);for(;!s.done&&t<Of;)t+=n,s=e.next(t);return t>=Of?1/0:t}function rB(e,t=100,n){const s=n({...e,keyframes:[0,t]}),a=Math.min(Ly(s),Of);return{type:"keyframes",ease:l=>s.next(a*l).value/t,duration:Ts(a)}}const aB=5;function JT(e,t,n){const s=Math.max(t-aB,0);return MT(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},ng=.001;function iB({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,b=m-n,w=fv(h,u),j=Math.exp(-y);return ng-b/w*j},l=h=>{const y=h*u*e,b=y*n+n,w=Math.pow(u,2)*Math.pow(h,2)*e,j=Math.exp(-y),N=fv(Math.pow(h,2),u);return(-a(h)+ng>0?-1:1)*((b-w)*j)/N}):(a=h=>{const m=Math.exp(-h*e),y=(h-n)*e+1;return-ng+m*y},l=h=>{const m=Math.exp(-h*e),y=(n-h)*(e*e);return m*y});const d=5/e,p=lB(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 oB=12;function lB(e,t,n){let s=n;for(let a=1;a<oB;a++)s=s-e(s)/t(s);return s}function fv(e,t){return e*Math.sqrt(1-t*t)}const cB=["duration","bounce"],uB=["stiffness","damping","mass"];function cS(e,t){return t.some(n=>e[n]!==void 0)}function dB(e){let t={velocity:Kt.velocity,stiffness:Kt.stiffness,damping:Kt.damping,mass:Kt.mass,isResolvedFromDuration:!1,...e};if(!cS(e,uB)&&cS(e,cB))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=iB({...e,velocity:0});t={...t,...n,mass:Kt.mass},t.isResolvedFromDuration=!0}return t}function If(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:b,isResolvedFromDuration:w}=dB({...n,velocity:-Ts(n.velocity||0)}),j=b||0,N=h/(2*Math.sqrt(p*m)),k=u-l,T=Ts(Math.sqrt(p/m)),E=Math.abs(k)<5;s||(s=E?Kt.restSpeed.granular:Kt.restSpeed.default),a||(a=E?Kt.restDelta.granular:Kt.restDelta.default);let S;if(N<1){const R=fv(T,N);S=A=>{const _=Math.exp(-N*T*A);return u-_*((j+N*T*k)/R*Math.sin(R*A)+k*Math.cos(R*A))}}else if(N===1)S=R=>u-Math.exp(-T*R)*(k+(j+T*k)*R);else{const R=T*Math.sqrt(N*N-1);S=A=>{const _=Math.exp(-N*T*A),$=Math.min(R*A,300);return u-_*((j+N*T*k)*Math.sinh($)+R*k*Math.cosh($))/R}}const M={calculatedDuration:w&&y||null,next:R=>{const A=S(R);if(w)d.done=R>=y;else{let _=R===0?j:0;N<1&&(_=R===0?Bs(j):JT(S,R,A));const $=Math.abs(_)<=s,V=Math.abs(u-A)<=a;d.done=$&&V}return d.value=d.done?u:A,d},toString:()=>{const R=Math.min(Ly(M),Of),A=XT(_=>M.next(R*_).value,R,30);return R+"ms "+A},toTransition:()=>{}};return M}If.applyToOptions=e=>{const t=rB(e,100,If);return e.ease=t.ease,e.duration=Bs(t.duration),e.type="keyframes",e};function hv({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],b={done:!1,value:y},w=$=>d!==void 0&&$<d||p!==void 0&&$>p,j=$=>d===void 0?p:p===void 0||Math.abs(d-$)<Math.abs(p-$)?d:p;let N=n*t;const k=y+N,T=u===void 0?k:u(k);T!==k&&(N=T-y);const E=$=>-N*Math.exp(-$/s),S=$=>T+E($),M=$=>{const V=E($),U=S($);b.done=Math.abs(V)<=h,b.value=b.done?T:U};let R,A;const _=$=>{w(b.value)&&(R=$,A=If({keyframes:[b.value,j(b.value)],velocity:JT(S,$,b.value),damping:a,stiffness:l,restDelta:h,restSpeed:m}))};return _(0),{calculatedDuration:null,next:$=>{let V=!1;return!A&&R===void 0&&(V=!0,M($),_($)),R!==void 0&&$>=R?A.next($-R):(!V&&M($),b)}}}function fB(e,t,n){const s=[],a=n||$r.mix||KT,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=Wc(p,d)}s.push(d)}return s}function hB(e,t,{clamp:n=!0,ease:s,mixer:a}={}){const l=e.length;if(My(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=fB(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 b=Oc(e[y],e[y+1],m);return d[y](b)};return n?m=>h(ur(e[0],e[l-1],m)):h}function pB(e,t){const n=e[e.length-1];for(let s=1;s<=t;s++){const a=Oc(0,t,s);e.push(Ht(n,1,a))}}function mB(e){const t=[0];return pB(t,e.length-1),t}function gB(e,t){return e.map(n=>n*t)}function vB(e,t){return e.map(()=>t||$T).splice(0,e.length-1)}function wc({duration:e=300,keyframes:t,times:n,ease:s="easeInOut"}){const a=T9(s)?s.map(sS):sS(s),l={done:!1,value:t[0]},u=gB(n&&n.length===t.length?n:mB(t),e),d=hB(u,t,{ease:Array.isArray(a)?a:vB(t,a)});return{calculatedDuration:e,next:p=>(l.value=d(p),l.done=p>=e,l)}}const yB=e=>e!==null;function $y(e,{repeat:t,repeatType:n="loop"},s,a=1){const l=e.filter(yB),d=a<0||t&&n!=="loop"&&t%2===1?0:l.length-1;return!d||s===void 0?l[d]:s}const xB={decay:hv,inertia:hv,tween:wc,keyframes:wc,spring:If};function QT(e){typeof e.type=="string"&&(e.type=xB[e.type])}class Uy{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 bB=e=>e/100;class By extends Uy{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;QT(t);const{type:n=wc,repeat:s=0,repeatDelay:a=0,repeatType:l,velocity:u=0}=t;let{keyframes:d}=t;const p=n||wc;p!==wc&&typeof d[0]!="number"&&(this.mixKeyframes=Wc(bB,KT(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=Ly(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:b,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 T=this.currentTime-h*(this.playbackSpeed>=0?1:-1),E=this.playbackSpeed>=0?T<0:T>a;this.currentTime=Math.max(T,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=a);let S=this.currentTime,M=s;if(y){const $=Math.min(this.currentTime,a)/d;let V=Math.floor($),U=$%1;!U&&$>=1&&(U=1),U===1&&V--,V=Math.min(V,y+1),V%2&&(b==="reverse"?(U=1-U,w&&(U-=w/d)):b==="mirror"&&(M=u)),S=ur(0,1,U)*d}const R=E?{done:!1,value:m[0]}:M.next(S);l&&(R.value=l(R.value));let{done:A}=R;!E&&p!==null&&(A=this.playbackSpeed>=0?this.currentTime>=a:this.currentTime<=0);const _=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&A);return _&&j!==hv&&(R.value=$y(m,this.options,k,this.speed)),N&&N(R.value),_&&this.finish(),R}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=sB,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 wB(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const di=e=>e*180/Math.PI,pv=e=>{const t=di(Math.atan2(e[1],e[0]));return mv(t)},jB={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:pv,rotateZ:pv,skewX:e=>di(Math.atan(e[1])),skewY:e=>di(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},mv=e=>(e=e%360,e<0&&(e+=360),e),uS=pv,dS=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),fS=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),SB={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:dS,scaleY:fS,scale:e=>(dS(e)+fS(e))/2,rotateX:e=>mv(di(Math.atan2(e[6],e[5]))),rotateY:e=>mv(di(Math.atan2(-e[2],e[0]))),rotateZ:uS,rotate:uS,skewX:e=>di(Math.atan(e[4])),skewY:e=>di(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function gv(e){return e.includes("scale")?1:0}function vv(e,t){if(!e||e==="none")return gv(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,a;if(n)s=SB,a=n;else{const d=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=jB,a=d}if(!a)return gv(t);const l=s[t],u=a[1].split(",").map(kB);return typeof l=="function"?l(u):u[l]}const NB=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return vv(n,t)};function kB(e){return parseFloat(e.trim())}const il=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],ol=new Set(il),hS=e=>e===al||e===Oe,EB=new Set(["x","y","z"]),CB=il.filter(e=>!EB.has(e));function TB(e){const t=[];return CB.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})=>vv(t,"x"),y:(e,{transform:t})=>vv(t,"y")};wa.translateX=wa.x;wa.translateY=wa.y;const mi=new Set;let yv=!1,xv=!1,bv=!1;function eA(){if(xv){const e=Array.from(mi).filter(s=>s.needsMeasurement),t=new Set(e.map(s=>s.element)),n=new Map;t.forEach(s=>{const a=TB(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)})}xv=!1,yv=!1,mi.forEach(e=>e.complete(bv)),mi.clear()}function tA(){mi.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(xv=!0)})}function AB(){bv=!0,tA(),eA(),bv=!1}class Vy{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?(mi.add(this),yv||(yv=!0,At.read(tA),At.resolveKeyframes(eA))):(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])}wB(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),mi.delete(this)}cancel(){this.state==="scheduled"&&(mi.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const MB=e=>e.startsWith("--");function RB(e,t,n){MB(t)?e.style.setProperty(t,n):e.style[t]=n}const _B={};function nA(e,t){const n=AT(e);return()=>_B[t]??n()}const OB=nA(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),sA=nA(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),uc=([e,t,n,s])=>`cubic-bezier(${e}, ${t}, ${n}, ${s})`,pS={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:uc([0,.65,.55,1]),circOut:uc([.55,0,1,.45]),backIn:uc([.31,.01,.66,-.59]),backOut:uc([.33,1.53,.69,.99])};function rA(e,t){if(e)return typeof e=="function"?sA()?XT(e,t):"ease-out":UT(e)?uc(e):Array.isArray(e)?e.map(n=>rA(n,t)||pS.easeOut):pS[e]}function IB(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=rA(d,a);Array.isArray(y)&&(m.easing=y);const b={delay:s,duration:a,easing:Array.isArray(y)?"linear":y,fill:"both",iterations:l+1,direction:u==="reverse"?"alternate":"normal"};return h&&(b.pseudoElement=h),e.animate(m,b)}function aA(e){return typeof e=="function"&&"applyToOptions"in e}function DB({type:e,...t}){return aA(e)&&sA()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class iA extends Uy{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,My(typeof t.type!="string");const h=DB(t);this.animation=IB(n,s,a,h,l),h.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!l){const m=$y(a,this.options,d,this.speed);this.updateMotionValue?this.updateMotionValue(m):RB(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&&OB()?(this.animation.timeline=t,As):n(this)}}const oA={anticipate:PT,backInOut:DT,circInOut:LT};function PB(e){return e in oA}function zB(e){typeof e.ease=="string"&&PB(e.ease)&&(e.ease=oA[e.ease])}const sg=10;class LB extends iA{constructor(t){zB(t),QT(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 By({...u,autoplay:!1}),p=Math.max(sg,Bn.now()-this.startTime),h=ur(0,sg,p-sg);n.setWithVelocity(d.sample(Math.max(0,p-h)).value,d.sample(p).value,h),d.stop()}}const mS=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(Vs.test(e)||e==="0")&&!e.startsWith("url("));function $B(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 UB(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=mS(a,t),d=mS(l,t);return!u||!d?!1:$B(e)||(n==="spring"||aA(n))&&s}function wv(e){e.duration=0,e.type="keyframes"}const BB=new Set(["opacity","clipPath","filter","transform"]),VB=AT(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function FB(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 VB()&&n&&BB.has(n)&&(n!=="transform"||!h)&&!p&&!s&&a!=="mirror"&&l!==0&&u!=="inertia"}const HB=40;class qB extends Uy{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 b={autoplay:t,delay:n,type:s,repeat:a,repeatDelay:l,repeatType:u,name:p,motionValue:h,element:m,...y},w=m?.KeyframeResolver||Vy;this.keyframeResolver=new w(d,(j,N,k)=>this.onKeyframesResolved(j,N,b,!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(),UB(t,l,u,d)||(($r.instantAnimations||!p)&&m?.($y(t,s,n)),t[0]=t[t.length-1],wv(s),s.repeat=0);const b={startTime:a?this.resolvedAt?this.resolvedAt-this.createdAt>HB?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:t},w=!h&&FB(b),j=b.motionValue?.owner?.current,N=w?new LB({...b,element:j}):new By(b);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(),AB()),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 lA(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 ZB=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function WB(e){const t=ZB.exec(e);if(!t)return[,];const[,n,s,a]=t;return[`--${n??s}`,a]}function cA(e,t,n=1){const[s,a]=WB(e);if(!s)return;const l=window.getComputedStyle(t).getPropertyValue(s);if(l){const u=l.trim();return ET(u)?parseFloat(u):u}return Iy(a)?cA(a,t,n+1):a}const YB={type:"spring",stiffness:500,damping:25,restSpeed:10},GB=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),KB={type:"keyframes",duration:.8},XB={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},JB=(e,{keyframes:t})=>t.length>2?KB:ol.has(e)?e.startsWith("scale")?GB(t[1]):YB:XB,QB=e=>e!==null;function eV(e,{repeat:t,repeatType:n="loop"},s){const a=e.filter(QB),l=t&&n!=="loop"&&t%2===1?0:a.length-1;return a[l]}function uA(e,t){if(e?.inherit&&t){const{inherit:n,...s}=e;return{...t,...s}}return e}function Fy(e,t){const n=e?.[t]??e?.default??e;return n!==e?uA(n,e):n}function tV({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 Hy=(e,t,n,s={},a,l)=>u=>{const d=Fy(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:b=>{t.set(b),d.onUpdate&&d.onUpdate(b)},onComplete:()=>{u(),d.onComplete&&d.onComplete()},name:e,motionValue:t,element:l?void 0:a};tV(d)||Object.assign(m,JB(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)&&(wv(m),m.delay===0&&(y=!0)),($r.instantAnimations||$r.skipAnimations||a?.shouldSkipAnimations)&&(y=!0,wv(m),m.delay=0),m.allowFlatten=!d.type&&!d.ease,y&&!l&&t.get()!==void 0){const b=eV(m.keyframes,d);if(b!==void 0){At.update(()=>{m.onUpdate(b),m.onComplete()});return}}return d.isSync?new By(m):new qB(m)};function gS(e){const t=[{},{}];return e?.values.forEach((n,s)=>{t[0][s]=n.get(),t[1][s]=n.getVelocity()}),t}function qy(e,t,n,s){if(typeof t=="function"){const[a,l]=gS(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]=gS(s);t=t(n!==void 0?n:e.custom,a,l)}return t}function Zo(e,t,n){const s=e.getProps();return qy(s,t,n!==void 0?n:s.custom,e)}const dA=new Set(["width","height","top","left","right","bottom",...il]),vS=30,nV=e=>!isNaN(parseFloat(e));class sV{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=nV(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 Ry);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>vS)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,vS);return MT(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 Qo(e,t){return new sV(e,t)}const jv=e=>Array.isArray(e);function rV(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Qo(n))}function aV(e){return jv(e)?e[e.length-1]||0:e}function iV(e,t){const n=Zo(e,t);let{transitionEnd:s={},transition:a={},...l}=n||{};l={...l,...s};for(const u in l){const d=aV(l[u]);rV(e,u,d)}}const In=e=>!!(e&&e.getVelocity);function oV(e){return!!(In(e)&&e.add)}function Sv(e,t){const n=e.getValue("willChange");if(oV(n))return n.add(t);if(!n&&$r.WillChange){const s=new $r.WillChange("auto");e.addValue("willChange",s),s.add(t)}}function Zy(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}const lV="framerAppearId",fA="data-"+Zy(lV);function hA(e){return e.props[fA]}function cV({protectedKeys:e,needsAnimating:t},n){const s=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,s}function pA(e,t,{delay:n=0,transitionOverride:s,type:a}={}){let{transition:l,transitionEnd:u,...d}=t;const p=e.getDefaultTransition();l=l?uA(l,p):p;const h=l?.reduceMotion;s&&(l=s);const m=[],y=a&&e.animationState&&e.animationState.getState()[a];for(const b in d){const w=e.getValue(b,e.latestValues[b]??null),j=d[b];if(j===void 0||y&&cV(y,b))continue;const N={delay:n,...Fy(l||{},b)},k=w.get();if(k!==void 0&&!w.isAnimating&&!Array.isArray(j)&&j===k&&!N.velocity)continue;let T=!1;if(window.MotionHandoffAnimation){const M=hA(e);if(M){const R=window.MotionHandoffAnimation(M,b,At);R!==null&&(N.startTime=R,T=!0)}}Sv(e,b);const E=h??e.shouldReduceMotion;w.start(Hy(b,w,j,E&&dA.has(b)?{type:!1}:N,e,T));const S=w.animation;S&&m.push(S)}if(u){const b=()=>At.update(()=>{u&&iV(e,u)});m.length?Promise.all(m).then(b):b()}return m}function Nv(e,t,n={}){const s=Zo(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(pA(e,s,n)):()=>Promise.resolve(),u=e.variantChildren&&e.variantChildren.size?(p=0)=>{const{delayChildren:h=0,staggerChildren:m,staggerDirection:y}=a;return uV(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 uV(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(Nv(p,t,{...u,delay:n+(typeof s=="function"?0:s)+lA(e.variantChildren,p,s,a,l)}).then(()=>p.notify("AnimationComplete",t)));return Promise.all(d)}function dV(e,t,n={}){e.notify("AnimationStart",t);let s;if(Array.isArray(t)){const a=t.map(l=>Nv(e,l,n));s=Promise.all(a)}else if(typeof t=="string")s=Nv(e,t,n);else{const a=typeof t=="function"?Zo(e,t,n.custom):t;s=Promise.all(pA(e,a,n))}return s.then(()=>{e.notify("AnimationComplete",t)})}const fV={test:e=>e==="auto",parse:e=>e},mA=e=>t=>t.test(e),gA=[al,Oe,or,pa,B9,U9,fV],yS=e=>gA.find(mA(e));function hV(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||TT(e):!0}const pV=new Set(["brightness","contrast","saturate","opacity"]);function mV(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[s]=n.match(Dy)||[];if(!s)return e;const a=n.replace(s,"");let l=pV.has(t)?1:0;return s!==n&&(l*=100),t+"("+l+a+")"}const gV=/\b([a-z-]*)\(.*?\)/gu,kv={...Vs,getAnimatableNone:e=>{const t=e.match(gV);return t?t.map(mV).join(" "):e}},Ev={...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))}},xS={...al,transform:Math.round},vV={rotate:pa,rotateX:pa,rotateY:pa,rotateZ:pa,scale:kd,scaleX:kd,scaleY:kd,scaleZ:kd,skew:pa,skewX:pa,skewY:pa,distance:Oe,translateX:Oe,translateY:Oe,translateZ:Oe,x:Oe,y:Oe,z:Oe,perspective:Oe,transformPerspective:Oe,opacity:Ic,originX:aS,originY:aS,originZ:Oe},Wy={borderWidth:Oe,borderTopWidth:Oe,borderRightWidth:Oe,borderBottomWidth:Oe,borderLeftWidth:Oe,borderRadius:Oe,borderTopLeftRadius:Oe,borderTopRightRadius:Oe,borderBottomRightRadius:Oe,borderBottomLeftRadius:Oe,width:Oe,maxWidth:Oe,height:Oe,maxHeight:Oe,top:Oe,right:Oe,bottom:Oe,left:Oe,inset:Oe,insetBlock:Oe,insetBlockStart:Oe,insetBlockEnd:Oe,insetInline:Oe,insetInlineStart:Oe,insetInlineEnd:Oe,padding:Oe,paddingTop:Oe,paddingRight:Oe,paddingBottom:Oe,paddingLeft:Oe,paddingBlock:Oe,paddingBlockStart:Oe,paddingBlockEnd:Oe,paddingInline:Oe,paddingInlineStart:Oe,paddingInlineEnd:Oe,margin:Oe,marginTop:Oe,marginRight:Oe,marginBottom:Oe,marginLeft:Oe,marginBlock:Oe,marginBlockStart:Oe,marginBlockEnd:Oe,marginInline:Oe,marginInlineStart:Oe,marginInlineEnd:Oe,fontSize:Oe,backgroundPositionX:Oe,backgroundPositionY:Oe,...vV,zIndex:xS,fillOpacity:Ic,strokeOpacity:Ic,numOctaves:xS},yV={...Wy,color:ln,backgroundColor:ln,outlineColor:ln,fill:ln,stroke:ln,borderColor:ln,borderTopColor:ln,borderRightColor:ln,borderBottomColor:ln,borderLeftColor:ln,filter:kv,WebkitFilter:kv,mask:Ev,WebkitMask:Ev},vA=e=>yV[e],xV=new Set([kv,Ev]);function yA(e,t){let n=vA(e);return xV.has(n)||(n=Vs),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const bV=new Set(["auto","none","0"]);function wV(e,t,n){let s=0,a;for(;s<e.length&&!a;){const l=e[s];typeof l=="string"&&!bV.has(l)&&Dc(l).values.length&&(a=e[s]),s++}if(a&&n)for(const l of t)e[l]=yA(n,a)}class jV extends Vy{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(),Iy(y))){const b=cA(y,n.current);b!==void 0&&(t[m]=b),m===t.length-1&&(this.finalKeyframe=y)}}if(this.resolveNoneKeyframes(),!dA.has(s)||t.length!==2)return;const[a,l]=t,u=yS(a),d=yS(l),p=rS(a),h=rS(l);if(p!==h&&wa[s]){this.needsMeasurement=!0;return}if(u!==d)if(hS(u)&&hS(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||hV(t[a]))&&s.push(a);s.length&&wV(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 SV=new Set(["opacity","clipPath","filter","transform"]);function xA(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 bA=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function Cv(e){return CT(e)&&"offsetHeight"in e}const{schedule:Yy}=BT(queueMicrotask,!1),$s={x:!1,y:!1};function wA(){return $s.x||$s.y}function NV(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 jA(e,t){const n=xA(e),s=new AbortController,a={passive:!0,...t,signal:s.signal};return[n,a,()=>s.abort()]}function kV(e){return!(e.pointerType==="touch"||wA())}function EV(e,t,n={}){const[s,a,l]=jA(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()},b=k=>{d=!1,window.removeEventListener("pointerup",b),window.removeEventListener("pointercancel",b),p&&(p=!1,y(k))},w=()=>{d=!0,window.addEventListener("pointerup",b,a),window.addEventListener("pointercancel",b,a)},j=k=>{if(k.pointerType!=="touch"){if(d){p=!0;return}y(k)}},N=k=>{if(!kV(k))return;p=!1;const T=t(u,k);typeof T=="function"&&(h=T,u.addEventListener("pointerleave",j,a))};u.addEventListener("pointerenter",N,a),u.addEventListener("pointerdown",w,a)}),l}const SA=(e,t)=>t?e===t?!0:SA(e,t.parentElement):!1,Gy=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,CV=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function TV(e){return CV.has(e.tagName)||e.isContentEditable===!0}const AV=new Set(["INPUT","SELECT","TEXTAREA"]);function MV(e){return AV.has(e.tagName)||e.isContentEditable===!0}const Jd=new WeakSet;function bS(e){return t=>{t.key==="Enter"&&e(t)}}function rg(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const RV=(e,t)=>{const n=e.currentTarget;if(!n)return;const s=bS(()=>{if(Jd.has(n))return;rg(n,"down");const a=bS(()=>{rg(n,"up")}),l=()=>rg(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 wS(e){return Gy(e)&&!wA()}const jS=new WeakSet;function _V(e,t,n={}){const[s,a,l]=jA(e,n),u=d=>{const p=d.currentTarget;if(!wS(d)||jS.has(d))return;Jd.add(p),n.stopPropagation&&jS.add(d);const h=t(p,d),m=(w,j)=>{window.removeEventListener("pointerup",y),window.removeEventListener("pointercancel",b),Jd.has(p)&&Jd.delete(p),wS(w)&&typeof h=="function"&&h(w,{success:j})},y=w=>{m(w,p===window||p===document||n.useGlobalTarget||SA(p,w.target))},b=w=>{m(w,!1)};window.addEventListener("pointerup",y,a),window.addEventListener("pointercancel",b,a)};return s.forEach(d=>{(n.useGlobalTarget?window:d).addEventListener("pointerdown",u,a),Cv(d)&&(d.addEventListener("focus",h=>RV(h,a)),!TV(d)&&!d.hasAttribute("tabindex")&&(d.tabIndex=0))}),l}function Ky(e){return CT(e)&&"ownerSVGElement"in e}const Qd=new WeakMap;let ef;const NA=(e,t,n)=>(s,a)=>a&&a[0]?a[0][e+"Size"]:Ky(s)&&"getBBox"in s?s.getBBox()[t]:s[n],OV=NA("inline","width","offsetWidth"),IV=NA("block","height","offsetHeight");function DV({target:e,borderBoxSize:t}){Qd.get(e)?.forEach(n=>{n(e,{get width(){return OV(e,t)},get height(){return IV(e,t)}})})}function PV(e){e.forEach(DV)}function zV(){typeof ResizeObserver>"u"||(ef=new ResizeObserver(PV))}function LV(e,t){ef||zV();const n=xA(e);return n.forEach(s=>{let a=Qd.get(s);a||(a=new Set,Qd.set(s,a)),a.add(t),ef?.observe(s)}),()=>{n.forEach(s=>{const a=Qd.get(s);a?.delete(t),a?.size||ef?.unobserve(s)})}}const tf=new Set;let Lo;function $V(){Lo=()=>{const e={get width(){return window.innerWidth},get height(){return window.innerHeight}};tf.forEach(t=>t(e))},window.addEventListener("resize",Lo)}function UV(e){return tf.add(e),Lo||$V(),()=>{tf.delete(e),!tf.size&&typeof Lo=="function"&&(window.removeEventListener("resize",Lo),Lo=void 0)}}function SS(e,t){return typeof e=="function"?UV(e):LV(e,t)}function BV(e){return Ky(e)&&e.tagName==="svg"}const VV=[...gA,ln,Vs],FV=e=>VV.find(mA(e)),NS=()=>({translate:0,scale:1,origin:0,originPoint:0}),$o=()=>({x:NS(),y:NS()}),kS=()=>({min:0,max:0}),pn=()=>({x:kS(),y:kS()}),HV=new WeakMap;function fh(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function Pc(e){return typeof e=="string"||Array.isArray(e)}const Xy=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Jy=["initial",...Xy];function hh(e){return fh(e.animate)||Jy.some(t=>Pc(e[t]))}function kA(e){return!!(hh(e)||e.variants)}function qV(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,Qo(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,Qo(u!==void 0?u:a,{owner:e}))}}for(const s in n)t[s]===void 0&&e.removeValue(s);return t}const Tv={current:null},EA={current:!1},ZV=typeof window<"u";function WV(){if(EA.current=!0,!!ZV)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>Tv.current=e.matches;e.addEventListener("change",t),t()}else Tv.current=!1}const ES=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Df={};function CA(e){Df=e}function YV(){return Df}class GV{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=Vy,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=hh(n),this.isVariantNode=kA(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:y,...b}=this.scrapeMotionValuesFromProps(n,{},this);for(const w in b){const j=b[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,HV.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:(EA.current||WV(),this.shouldReduceMotion=Tv.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(),Ta(this.notifyUpdate),Ta(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&&SV.has(t)&&this.current instanceof HTMLElement){const{factory:u,keyframes:d,times:p,ease:h,duration:m}=n.accelerate,y=new iA({element:this.current,name:t,keyframes:d,times:p,ease:h,duration:Bs(m)}),b=u(y);this.valueSubscriptions.set(t,()=>{b(),y.cancel()});return}const s=ol.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 Df){const n=Df[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<ES.length;s++){const a=ES[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=qV(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=Qo(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"&&(ET(s)||TT(s))?s=parseFloat(s):!FV(s)&&Vs.test(n)&&(s=yA(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=qy(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 Ry),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){Yy.render(this.render)}}class TA extends GV{constructor(){super(...arguments),this.KeyframeResolver=jV}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 za{constructor(t){this.isMounted=!1,this.node=t}update(){}}function AA({top:e,left:t,right:n,bottom:s}){return{x:{min:t,max:n},y:{min:e,max:s}}}function KV({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function XV(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 ag(e){return e===void 0||e===1}function Av({scale:e,scaleX:t,scaleY:n}){return!ag(e)||!ag(t)||!ag(n)}function ii(e){return Av(e)||MA(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function MA(e){return CS(e.x)||CS(e.y)}function CS(e){return e&&e!=="0%"}function Pf(e,t,n){const s=e-n,a=t*s;return n+a}function TS(e,t,n,s,a){return a!==void 0&&(e=Pf(e,a,s)),Pf(e,n,s)+t}function Mv(e,t=0,n=1,s,a){e.min=TS(e.min,t,n,s,a),e.max=TS(e.max,t,n,s,a)}function RA(e,{x:t,y:n}){Mv(e.x,t.translate,t.scale,t.originPoint),Mv(e.y,n.translate,n.scale,n.originPoint)}const AS=.999999999999,MS=1.0000000000001;function JV(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&&Bo(e,{x:-l.scroll.offset.x,y:-l.scroll.offset.y}),u&&(t.x*=u.x.scale,t.y*=u.y.scale,RA(e,u)),s&&ii(l.latestValues)&&Bo(e,l.latestValues))}t.x<MS&&t.x>AS&&(t.x=1),t.y<MS&&t.y>AS&&(t.y=1)}function Uo(e,t){e.min=e.min+t,e.max=e.max+t}function RS(e,t,n,s,a=.5){const l=Ht(e.min,e.max,a);Mv(e,t,n,l,s)}function Bo(e,t){RS(e.x,t.x,t.scaleX,t.scale,t.originX),RS(e.y,t.y,t.scaleY,t.scale,t.originY)}function _A(e,t){return AA(XV(e.getBoundingClientRect(),t))}function QV(e,t,n){const s=_A(e,n),{scroll:a}=t;return a&&(Uo(s.x,a.offset.x),Uo(s.y,a.offset.y)),s}const e7={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},t7=il.length;function n7(e,t,n){let s="",a=!0;for(let l=0;l<t7;l++){const u=il[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=bA(d,Wy[u]);if(!p){a=!1;const m=e7[u]||u;s+=`${m}(${h}) `}n&&(t[u]=h)}}return s=s.trim(),n?s=n(t,a?"":s):a&&(s="none"),s}function Qy(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(ol.has(p)){u=!0;continue}else if(FT(p)){a[p]=h;continue}else{const m=bA(h,Wy[p]);p.startsWith("origin")?(d=!0,l[p]=m):s[p]=m}}if(t.transform||(u||n?s.transform=n7(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 OA(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 _S(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const ec={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(Oe.test(e))e=parseFloat(e);else return e;const n=_S(e,t.target.x),s=_S(e,t.target.y);return`${n}% ${s}%`}},s7={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)}},Rv={borderRadius:{...ec,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:ec,borderTopRightRadius:ec,borderBottomLeftRadius:ec,borderBottomRightRadius:ec,boxShadow:s7};function IA(e,{layout:t,layoutId:n}){return ol.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!Rv[e]||e==="opacity")}function ex(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])||IA(u,e)||n?.getValue(u)?.liveStyle!==void 0)&&(l[u]=s[u]);return l}function r7(e){return window.getComputedStyle(e)}class a7 extends TA{constructor(){super(...arguments),this.type="html",this.renderInstance=OA}readValueFromInstance(t,n){if(ol.has(n))return this.projection?.isProjecting?gv(n):NB(t,n);{const s=r7(t),a=(FT(n)?s.getPropertyValue(n):s[n])||0;return typeof a=="string"?a.trim():a}}measureInstanceViewportBox(t,{transformPagePoint:n}){return _A(t,n)}build(t,n,s){Qy(t,n,s.transformTemplate)}scrapeMotionValuesFromProps(t,n,s){return ex(t,n,s)}}const i7={offset:"stroke-dashoffset",array:"stroke-dasharray"},o7={offset:"strokeDashoffset",array:"strokeDasharray"};function l7(e,t,n=1,s=0,a=!0){e.pathLength=1;const l=a?i7:o7;e[l.offset]=`${-s}`,e[l.array]=`${t} ${n}`}const c7=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function DA(e,{attrX:t,attrY:n,attrScale:s,pathLength:a,pathSpacing:l=1,pathOffset:u=0,...d},p,h,m){if(Qy(e,d,h),p){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:y,style:b}=e;y.transform&&(b.transform=y.transform,delete y.transform),(b.transform||y.transformOrigin)&&(b.transformOrigin=y.transformOrigin??"50% 50%",delete y.transformOrigin),b.transform&&(b.transformBox=m?.transformBox??"fill-box",delete y.transformBox);for(const w of c7)y[w]!==void 0&&(b[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&&l7(y,a,l,u,!1)}const PA=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"]),zA=e=>typeof e=="string"&&e.toLowerCase()==="svg";function u7(e,t,n,s){OA(e,t,void 0,s);for(const a in t.attrs)e.setAttribute(PA.has(a)?a:Zy(a),t.attrs[a])}function LA(e,t,n){const s=ex(e,t,n);for(const a in e)if(In(e[a])||In(t[a])){const l=il.indexOf(a)!==-1?"attr"+a.charAt(0).toUpperCase()+a.substring(1):a;s[l]=e[a]}return s}class d7 extends TA{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=pn}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(ol.has(n)){const s=vA(n);return s&&s.default||0}return n=PA.has(n)?n:Zy(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,s){return LA(t,n,s)}build(t,n,s){DA(t,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(t,n,s,a){u7(t,n,s,a)}mount(t){this.isSVGTag=zA(t.tagName),super.mount(t)}}const f7=Jy.length;function $A(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?$A(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<f7;n++){const s=Jy[n],a=e.props[s];(Pc(a)||a===!1)&&(t[s]=a)}return t}function UA(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 h7=[...Xy].reverse(),p7=Xy.length;function m7(e){return t=>Promise.all(t.map(({animation:n,options:s})=>dV(e,n,s)))}function g7(e){let t=m7(e),n=OS(),s=!0;const a=p=>(h,m)=>{const y=Zo(e,m,p==="exit"?e.presenceContext?.custom:void 0);if(y){const{transition:b,transitionEnd:w,...j}=y;h={...h,...j,...w}}return h};function l(p){t=p(e)}function u(p){const{props:h}=e,m=$A(e.parent)||{},y=[],b=new Set;let w={},j=1/0;for(let k=0;k<p7;k++){const T=h7[k],E=n[T],S=h[T]!==void 0?h[T]:m[T],M=Pc(S),R=T===p?E.isActive:null;R===!1&&(j=k);let A=S===m[T]&&S!==h[T]&&M;if(A&&s&&e.manuallyAnimateOnMount&&(A=!1),E.protectedKeys={...w},!E.isActive&&R===null||!S&&!E.prevProp||fh(S)||typeof S=="boolean")continue;if(T==="exit"&&E.isActive&&R!==!0){E.prevResolvedValues&&(w={...w,...E.prevResolvedValues});continue}const _=v7(E.prevProp,S);let $=_||T===p&&E.isActive&&!A&&M||k>j&&M,V=!1;const U=Array.isArray(S)?S:[S];let O=U.reduce(a(T),{});R===!1&&(O={});const{prevResolvedValues:P={}}=E,q={...P,...O},Z=z=>{$=!0,b.has(z)&&(V=!0,b.delete(z)),E.needsAnimating[z]=!0;const B=e.getValue(z);B&&(B.liveStyle=!1)};for(const z in q){const B=O[z],X=P[z];if(w.hasOwnProperty(z))continue;let W=!1;jv(B)&&jv(X)?W=!UA(B,X):W=B!==X,W?B!=null?Z(z):b.add(z):B!==void 0&&b.has(z)?Z(z):E.protectedKeys[z]=!0}E.prevProp=S,E.prevResolvedValues=O,E.isActive&&(w={...w,...O}),s&&e.blockInitialAnimation&&($=!1);const H=A&&_;$&&(!H||V)&&y.push(...U.map(z=>{const B={type:T};if(typeof z=="string"&&s&&!H&&e.manuallyAnimateOnMount&&e.parent){const{parent:X}=e,W=Zo(X,z);if(X.enteringChildren&&W){const{delayChildren:I}=W.transition||{};B.delay=lA(X.enteringChildren,e,I)}}return{animation:z,options:B}}))}if(b.size){const k={};if(typeof h.initial!="boolean"){const T=Zo(e,Array.isArray(h.initial)?h.initial[0]:h.initial);T&&T.transition&&(k.transition=T.transition)}b.forEach(T=>{const E=e.getBaseTarget(T),S=e.getValue(T);S&&(S.liveStyle=!0),k[T]=E??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=OS()}}}function v7(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!UA(t,e):!1}function si(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function OS(){return{animate:si(!0),whileInView:si(),whileHover:si(),whileTap:si(),whileDrag:si(),whileFocus:si(),exit:si()}}function IS(e,t){e.min=t.min,e.max=t.max}function Ls(e,t){IS(e.x,t.x),IS(e.y,t.y)}function DS(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}const BA=1e-4,y7=1-BA,x7=1+BA,VA=.01,b7=0-VA,w7=0+VA;function Vn(e){return e.max-e.min}function j7(e,t,n){return Math.abs(e-t)<=n}function PS(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>=y7&&e.scale<=x7||isNaN(e.scale))&&(e.scale=1),(e.translate>=b7&&e.translate<=w7||isNaN(e.translate))&&(e.translate=0)}function jc(e,t,n,s){PS(e.x,t.x,n.x,s?s.originX:void 0),PS(e.y,t.y,n.y,s?s.originY:void 0)}function zS(e,t,n){e.min=n.min+t.min,e.max=e.min+Vn(t)}function S7(e,t,n){zS(e.x,t.x,n.x),zS(e.y,t.y,n.y)}function LS(e,t,n){e.min=t.min-n.min,e.max=e.min+Vn(t)}function zf(e,t,n){LS(e.x,t.x,n.x),LS(e.y,t.y,n.y)}function $S(e,t,n,s,a){return e-=t,e=Pf(e,1/n,s),a!==void 0&&(e=Pf(e,1/a,s)),e}function N7(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=$S(e.min,t,n,d,a),e.max=$S(e.max,t,n,d,a)}function US(e,t,[n,s,a],l,u){N7(e,t[n],t[s],t[a],t.scale,l,u)}const k7=["x","scaleX","originX"],E7=["y","scaleY","originY"];function BS(e,t,n,s){US(e.x,t,k7,n?n.x:void 0,s?s.x:void 0),US(e.y,t,E7,n?n.y:void 0,s?s.y:void 0)}function VS(e){return e.translate===0&&e.scale===1}function FA(e){return VS(e.x)&&VS(e.y)}function FS(e,t){return e.min===t.min&&e.max===t.max}function C7(e,t){return FS(e.x,t.x)&&FS(e.y,t.y)}function HS(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function HA(e,t){return HS(e.x,t.x)&&HS(e.y,t.y)}function qS(e){return Vn(e.x)/Vn(e.y)}function ZS(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function tr(e){return[e("x"),e("y")]}function T7(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:b,skewX:w,skewY:j}=n;h&&(s=`perspective(${h}px) ${s}`),m&&(s+=`rotate(${m}deg) `),y&&(s+=`rotateX(${y}deg) `),b&&(s+=`rotateY(${b}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 qA=["TopLeft","TopRight","BottomLeft","BottomRight"],A7=qA.length,WS=e=>typeof e=="string"?parseFloat(e):e,YS=e=>typeof e=="number"||Oe.test(e);function M7(e,t,n,s,a,l){a?(e.opacity=Ht(0,n.opacity??1,R7(s)),e.opacityExit=Ht(t.opacity??1,0,_7(s))):l&&(e.opacity=Ht(t.opacity??1,n.opacity??1,s));for(let u=0;u<A7;u++){const d=`border${qA[u]}Radius`;let p=GS(t,d),h=GS(n,d);if(p===void 0&&h===void 0)continue;p||(p=0),h||(h=0),p===0||h===0||YS(p)===YS(h)?(e[d]=Math.max(Ht(WS(p),WS(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 GS(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const R7=ZA(0,.5,zT),_7=ZA(.5,.95,As);function ZA(e,t,n){return s=>s<e?0:s>t?1:n(Oc(e,t,s))}function O7(e,t,n){const s=In(e)?e:Qo(e);return s.start(Hy("",s,t,n)),s.animation}function zc(e,t,n,s={passive:!0}){return e.addEventListener(t,n,s),()=>e.removeEventListener(t,n)}const I7=(e,t)=>e.depth-t.depth;class D7{constructor(){this.children=[],this.isDirty=!1}add(t){Ay(this.children,t),this.isDirty=!0}remove(t){Rf(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(I7),this.isDirty=!1,this.children.forEach(t)}}function P7(e,t){const n=Bn.now(),s=({timestamp:a})=>{const l=a-n;l>=t&&(Ta(s),e(l-t))};return At.setup(s,!0),()=>Ta(s)}function nf(e){return In(e)?e.get():e}class z7{constructor(){this.members=[]}add(t){Ay(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&&Rf(this.members,s)}t.scheduleRender()}remove(t){if(Rf(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 sf={hasAnimatedSinceResize:!0,hasEverUpdated:!1},ig=["","X","Y","Z"],L7=1e3;let $7=0;function og(e,t,n,s){const{latestValues:a}=t;a[e]&&(n[e]=a[e],t.setStaticValue(e,0),s&&(s[e]=0))}function WA(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=hA(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&&WA(s)}function YA({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:s,resetTransform:a}){return class{constructor(u={},d=t?.()){this.id=$7++,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(V7),this.nodes.forEach(Z7),this.nodes.forEach(W7),this.nodes.forEach(F7)},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 D7)}addEventListener(u,d){return this.eventHandlers.has(u)||this.eventHandlers.set(u,new Ry),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=Ky(u)&&!BV(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 b=()=>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=P7(b,250),sf.hasAnimatedSinceResize&&(sf.hasAnimatedSinceResize=!1,this.nodes.forEach(JS)))})}d&&this.root.registerSharedNode(d,this),this.options.animate!==!1&&h&&(d||p)&&this.addEventListener("didUpdate",({delta:m,hasLayoutChanged:y,hasRelativeLayoutChanged:b,layout:w})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const j=this.options.transition||h.getDefaultTransition()||J7,{onLayoutAnimationStart:N,onLayoutAnimationComplete:k}=h.getProps(),T=!this.targetLayout||!HA(this.targetLayout,w),E=!y&&b;if(this.options.layoutRoot||this.resumeFrom||E||y&&(T||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const S={...Fy(j,"layout"),onPlay:N,onComplete:k};(h.shouldReduceMotion||this.options.layoutRoot)&&(S.delay=0,S.type=!1),this.startAnimation(S),this.setAnimationOrigin(m,E)}else y||JS(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(),Ta(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(Y7),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&&WA(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(KS);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(XS);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(q7),this.nodes.forEach(U7),this.nodes.forEach(B7)):this.nodes.forEach(XS),this.clearAllSnapshots();const d=Bn.now();En.delta=ur(0,1e3/60,d-En.timestamp),En.timestamp=d,En.isProcessing=!0,Jm.update.process(En),Jm.preRender.process(En),Jm.render.process(En),En.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Yy.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(H7),this.sharedNodes.forEach(G7)}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&&!FA(this.projectionDelta),p=this.getTransformTemplate(),h=p?p(this.latestValues,""):void 0,m=h!==this.prevTransformTemplateValue;u&&this.instance&&(d||ii(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)),Q7(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(eF))){const{scroll:h}=this.root;h&&(Uo(d.x,h.offset.x),Uo(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),Uo(d.x,m.offset.x),Uo(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&&Bo(p,{x:-m.scroll.offset.x,y:-m.scroll.offset.y}),ii(m.latestValues)&&Bo(p,m.latestValues)}return ii(this.latestValues)&&Bo(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||!ii(h.latestValues))continue;Av(h.latestValues)&&h.updateSnapshot();const m=pn(),y=h.measurePageBox();Ls(m,y),BS(d,h.latestValues,h.snapshot?h.snapshot.layoutBox:void 0,m)}return ii(this.latestValues)&&BS(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 b=this.getClosestProjectingParent();b&&this.linkedParentVersion!==b.layoutVersion&&!b.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(b&&b.layout?this.createRelativeTarget(b,this.layout.layoutBox,b.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(),S7(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Ls(this.target,this.layout.layoutBox),RA(this.target,this.targetDelta)):Ls(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,b&&!!b.resumingFrom==!!this.resumingFrom&&!b.options.layoutScroll&&b.target&&this.animationProgress!==1?this.createRelativeTarget(b,this.target,b.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||Av(this.parent.latestValues)||MA(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(),zf(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,b=this.treeScale.y;JV(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():(DS(this.prevProjectionDelta.x,this.projectionDelta.x),DS(this.prevProjectionDelta.y,this.projectionDelta.y)),jc(this.projectionDelta,this.layoutCorrected,w,this.latestValues),(this.treeScale.x!==y||this.treeScale.y!==b||!ZS(this.projectionDelta.x,this.prevProjectionDelta.x)||!ZS(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=$o(),this.projectionDelta=$o(),this.projectionDeltaWithTransform=$o()}setAnimationOrigin(u,d=!1){const p=this.snapshot,h=p?p.latestValues:{},m={...this.latestValues},y=$o();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!d;const b=pn(),w=p?p.source:void 0,j=this.layout?this.layout.source:void 0,N=w!==j,k=this.getStack(),T=!k||k.members.length<=1,E=!!(N&&!T&&this.options.crossfade===!0&&!this.path.some(X7));this.animationProgress=0;let S;this.mixTargetDelta=M=>{const R=M/1e3;QS(y.x,u.x,R),QS(y.y,u.y,R),this.setTargetDelta(y),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(zf(b,this.layout.layoutBox,this.relativeParent.layout.layoutBox),K7(this.relativeTarget,this.relativeTargetOrigin,b,R),S&&C7(this.relativeTarget,S)&&(this.isProjectionDirty=!1),S||(S=pn()),Ls(S,this.relativeTarget)),N&&(this.animationValues=m,M7(m,h,this.latestValues,R,E,T)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=R},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(u){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Ta(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=At.update(()=>{sf.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Qo(0)),this.motionValue.jump(0,!1),this.currentAnimation=O7(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(L7),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&&GA(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 b=Vn(this.layout.layoutBox.y);p.y.min=u.target.y.min,p.y.max=p.y.min+b}Ls(d,p),Bo(d,m),jc(this.projectionDeltaWithTransform,this.layoutCorrected,d,m)}}registerSharedNode(u,d){this.sharedNodes.has(u)||this.sharedNodes.set(u,new z7),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&&og("z",u,h,this.animationValues);for(let m=0;m<ig.length;m++)og(`rotate${ig[m]}`,u,h,this.animationValues),og(`skew${ig[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=nf(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=nf(d?.pointerEvents)||""),this.hasProjected&&!ii(this.latestValues)&&(u.transform=p?p({},""):"none",this.hasProjected=!1);return}u.visibility="";const m=h.animationValues||h.latestValues;this.applyTransformsToTarget();let y=T7(this.projectionDeltaWithTransform,this.treeScale,m);p&&(y=p(m,y)),u.transform=y;const{x:b,y:w}=this.projectionDelta;u.transformOrigin=`${b.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 Rv){if(m[j]===void 0)continue;const{correct:N,applyTo:k,isCSSVariable:T}=Rv[j],E=y==="none"?m[j]:N(m[j],h);if(k){const S=k.length;for(let M=0;M<S;M++)u[k[M]]=E}else T?this.options.visualElement.renderState.vars[j]=E:u[j]=E}this.options.layoutId&&(u.pointerEvents=h===this?nf(d?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(u=>u.currentAnimation?.stop()),this.root.nodes.forEach(KS),this.root.sharedNodes.clear()}}}function U7(e){e.updateLayout()}function B7(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],b=Vn(y);y.min=n[m].min,y.max=y.min+b}):GA(a,t.layoutBox,n)&&tr(m=>{const y=l?t.measuredBox[m]:t.layoutBox[m],b=Vn(n[m]);y.max=y.min+b,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[m].max=e.relativeTarget[m].min+b)});const u=$o();jc(u,n,t.layoutBox);const d=$o();l?jc(d,e.applyTransform(s,!0),t.measuredBox):jc(d,n,t.layoutBox);const p=!FA(u);let h=!1;if(!e.resumeFrom){const m=e.getClosestProjectingParent();if(m&&!m.resumeFrom){const{snapshot:y,layout:b}=m;if(y&&b){const w=pn();zf(w,t.layoutBox,y.layoutBox);const j=pn();zf(j,n,b.layoutBox),HA(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 V7(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 F7(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function H7(e){e.clearSnapshot()}function KS(e){e.clearMeasurements()}function XS(e){e.isLayoutDirty=!1}function q7(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function JS(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function Z7(e){e.resolveTargetDelta()}function W7(e){e.calcProjection()}function Y7(e){e.resetSkewAndRotation()}function G7(e){e.removeLeadSnapshot()}function QS(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 eN(e,t,n,s){e.min=Ht(t.min,n.min,s),e.max=Ht(t.max,n.max,s)}function K7(e,t,n,s){eN(e.x,t.x,n.x,s),eN(e.y,t.y,n.y,s)}function X7(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const J7={duration:.45,ease:[.4,0,.1,1]},tN=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),nN=tN("applewebkit/")&&!tN("chrome/")?Math.round:As;function sN(e){e.min=nN(e.min),e.max=nN(e.max)}function Q7(e){sN(e.x),sN(e.y)}function GA(e,t,n){return e==="position"||e==="preserve-aspect"&&!j7(qS(t),qS(n),.2)}function eF(e){return e!==e.root&&e.scroll?.wasRoot}const tF=YA({attachResizeListener:(e,t)=>zc(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),lg={current:void 0},KA=YA({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!lg.current){const e=new tF({});e.mount(window),e.setOptions({layoutScroll:!0}),lg.current=e}return lg.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),tx=g.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function rN(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function nF(...e){return t=>{let n=!1;const s=e.map(a=>{const l=rN(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():rN(e[a],null)}}}}function sF(...e){return g.useCallback(nF(...e),e)}class rF 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=Cv(s)&&s.offsetWidth||0,l=Cv(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 aF({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(tx),m=e.props?.ref??e?.ref,y=sF(d,m);return g.useInsertionEffect(()=>{const{width:b,height:w,top:j,left:N,right:k,bottom:T}=p.current;if(t||l===!1||!d.current||!b||!w)return;const E=n==="left"?`left: ${N}`:`right: ${k}`,S=s==="bottom"?`bottom: ${T}`:`top: ${j}`;d.current.dataset.motionPopId=u;const M=document.createElement("style");h&&(M.nonce=h);const R=a??document.head;return R.appendChild(M),M.sheet&&M.sheet.insertRule(`
|
|
122
|
-
[data-motion-pop-id="${u}"] {
|
|
123
|
-
position: absolute !important;
|
|
124
|
-
width: ${b}px !important;
|
|
125
|
-
height: ${w}px !important;
|
|
126
|
-
${E}px !important;
|
|
127
|
-
${S}px !important;
|
|
128
|
-
}
|
|
129
|
-
`),()=>{R.contains(M)&&R.removeChild(M)}},[t]),o.jsx(rF,{isPresent:t,childRef:d,sizeRef:p,pop:l,children:l===!1?e:g.cloneElement(e,{ref:y})})}const iF=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:a,presenceAffectsLayout:l,mode:u,anchorX:d,anchorY:p,root:h})=>{const m=Ty(oF),y=g.useId();let b=!0,w=g.useMemo(()=>(b=!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&&b&&(w={...w}),g.useMemo(()=>{m.forEach((j,N)=>m.set(N,!1))},[n]),g.useEffect(()=>{!n&&!m.size&&s&&s()},[n]),e=o.jsx(aF,{pop:u==="popLayout",isPresent:n,anchorX:d,anchorY:p,root:h,children:e}),o.jsx(dh.Provider,{value:w,children:e})};function oF(){return new Map}function XA(e=!0){const t=g.useContext(dh);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 Ed=e=>e.key||"";function aN(e){const t=[];return g.Children.forEach(e,n=>{g.isValidElement(n)&&t.push(n)}),t}const lF=({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]=XA(u),b=g.useMemo(()=>aN(e),[e]),w=u&&!m?[]:b.map(Ed),j=g.useRef(!0),N=g.useRef(b),k=Ty(()=>new Map),T=g.useRef(new Set),[E,S]=g.useState(b),[M,R]=g.useState(b);kT(()=>{j.current=!1,N.current=b;for(let $=0;$<M.length;$++){const V=Ed(M[$]);w.includes(V)?(k.delete(V),T.current.delete(V)):k.get(V)!==!0&&k.set(V,!1)}},[M,w.length,w.join("-")]);const A=[];if(b!==E){let $=[...b];for(let V=0;V<M.length;V++){const U=M[V],O=Ed(U);w.includes(O)||($.splice(V,0,U),A.push(U))}return l==="wait"&&A.length&&($=A),R(aN($)),S(b),null}const{forceRender:_}=g.useContext(Cy);return o.jsx(o.Fragment,{children:M.map($=>{const V=Ed($),U=u&&!m?!1:b===M||w.includes(V),O=()=>{if(T.current.has(V))return;if(T.current.add(V),k.has(V))k.set(V,!0);else return;let P=!0;k.forEach(q=>{q||(P=!1)}),P&&(_?.(),R(N.current),u&&y?.(),s&&s())};return o.jsx(iF,{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:$},V)})})},JA=g.createContext({strict:!1}),iN={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 oN=!1;function cF(){if(oN)return;const e={};for(const t in iN)e[t]={isEnabled:n=>iN[t].some(s=>!!n[s])};CA(e),oN=!0}function QA(){return cF(),YV()}function uF(e){const t=QA();for(const n in e)t[n]={...t[n],...e[n]};CA(t)}const dF=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 Lf(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||dF.has(e)}let eM=e=>!Lf(e);function fF(e){typeof e=="function"&&(eM=t=>t.startsWith("on")?!Lf(t):e(t))}try{fF(require("@emotion/is-prop-valid").default)}catch{}function hF(e,t,n){const s={};for(const a in e)a==="values"&&typeof e.values=="object"||(eM(a)||n===!0&&Lf(a)||!t&&!Lf(a)||e.draggable&&a.startsWith("onDrag"))&&(s[a]=e[a]);return s}const ph=g.createContext({});function pF(e,t){if(hh(e)){const{initial:n,animate:s}=e;return{initial:n===!1||Pc(n)?n:void 0,animate:Pc(s)?s:void 0}}return e.inherit!==!1?t:{}}function mF(e){const{initial:t,animate:n}=pF(e,g.useContext(ph));return g.useMemo(()=>({initial:t,animate:n}),[lN(t),lN(n)])}function lN(e){return Array.isArray(e)?e.join(" "):e}const nx=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function tM(e,t,n){for(const s in t)!In(t[s])&&!IA(s,n)&&(e[s]=t[s])}function gF({transformTemplate:e},t){return g.useMemo(()=>{const n=nx();return Qy(n,t,e),Object.assign({},n.vars,n.style)},[t])}function vF(e,t){const n=e.style||{},s={};return tM(s,n,e),Object.assign(s,gF(e,t)),s}function yF(e,t){const n={},s=vF(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 nM=()=>({...nx(),attrs:{}});function xF(e,t,n,s){const a=g.useMemo(()=>{const l=nM();return DA(l,t,zA(s),e.transformTemplate,e.style),{...l.attrs,style:{...l.style}}},[t]);if(e.style){const l={};tM(l,e.style,e),a.style={...l,...a.style}}return a}const bF=["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 sx(e){return typeof e!="string"||e.includes("-")?!1:!!(bF.indexOf(e)>-1||/[A-Z]/u.test(e))}function wF(e,t,n,{latestValues:s},a,l=!1,u){const p=(u??sx(e)?xF:yF)(t,s,a,e),h=hF(t,typeof e=="string",l),m=e!==g.Fragment?{...h,...p,ref:n}:{},{children:y}=t,b=g.useMemo(()=>In(y)?y.get():y,[y]);return g.createElement(e,{...m,children:b})}function jF({scrapeMotionValuesFromProps:e,createRenderState:t},n,s,a){return{latestValues:SF(n,s,a,e),renderState:t()}}function SF(e,t,n,s){const a={},l=s(e,{});for(const b in l)a[b]=nf(l[b]);let{initial:u,animate:d}=e;const p=hh(e),h=kA(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"&&!fh(y)){const b=Array.isArray(y)?y:[y];for(let w=0;w<b.length;w++){const j=qy(e,b[w]);if(j){const{transitionEnd:N,transition:k,...T}=j;for(const E in T){let S=T[E];if(Array.isArray(S)){const M=m?S.length-1:0;S=S[M]}S!==null&&(a[E]=S)}for(const E in N)a[E]=N[E]}}}return a}const sM=e=>(t,n)=>{const s=g.useContext(ph),a=g.useContext(dh),l=()=>jF(e,t,s,a);return n?l():Ty(l)},NF=sM({scrapeMotionValuesFromProps:ex,createRenderState:nx}),kF=sM({scrapeMotionValuesFromProps:LA,createRenderState:nM}),EF=Symbol.for("motionComponentSymbol");function CF(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 rM=g.createContext({});function Mo(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function TF(e,t,n,s,a,l){const{visualElement:u}=g.useContext(ph),d=g.useContext(JA),p=g.useContext(dh),h=g.useContext(tx),m=h.reducedMotion,y=h.skipAnimations,b=g.useRef(null),w=g.useRef(!1);s=s||d.renderer,!b.current&&s&&(b.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&&b.current&&(b.current.manuallyAnimateOnMount=!0));const j=b.current,N=g.useContext(rM);j&&!j.projection&&a&&(j.type==="html"||j.type==="svg")&&AF(b.current,n,a,N);const k=g.useRef(!1);g.useInsertionEffect(()=>{j&&k.current&&j.update(n,p)});const T=n[fA],E=g.useRef(!!T&&!window.MotionHandoffIsComplete?.(T)&&window.MotionHasOptimisedAnimation?.(T));return kT(()=>{w.current=!0,j&&(k.current=!0,window.MotionIsMounted=!0,j.updateFeatures(),j.scheduleRenderMicrotask(),E.current&&j.animationState&&j.animationState.animateChanges())}),g.useEffect(()=>{j&&(!E.current&&j.animationState&&j.animationState.animateChanges(),E.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(T)}),E.current=!1),j.enteringChildren=void 0)}),j}function AF(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:aM(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 aM(e){if(e)return e.options.allowProjection!==!1?e.projection:aM(e.parent)}function cg(e,{forwardMotionProps:t=!1,type:n}={},s,a){s&&uF(s);const l=n?n==="svg":sx(e),u=l?kF:NF;function d(h,m){let y;const b={...g.useContext(tx),...h,layoutId:MF(h)},{isStatic:w}=b,j=mF(h),N=u(h,w);if(!w&&NT){RF();const k=_F(b);y=k.MeasureLayout,j.visualElement=TF(e,N,b,a,k.ProjectionNode,l)}return o.jsxs(ph.Provider,{value:j,children:[y&&j.visualElement?o.jsx(y,{visualElement:j.visualElement,...b}):null,wF(e,h,CF(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[EF]=e,p}function MF({layoutId:e}){const t=g.useContext(Cy).id;return t&&e!==void 0?t+"-"+e:e}function RF(e,t){g.useContext(JA).strict}function _F(e){const t=QA(),{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 OF(e,t){if(typeof Proxy>"u")return cg;const n=new Map,s=(l,u)=>cg(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,cg(u,void 0,e,t)),n.get(u))})}const IF=(e,t)=>t.isSVG??sx(e)?new d7(t):new a7(t,{allowProjection:e!==g.Fragment});class DF extends za{constructor(t){super(t),t.animationState||(t.animationState=g7(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();fh(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 PF=0;class zF extends za{constructor(){super(...arguments),this.id=PF++}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 LF={animation:{Feature:DF},exit:{Feature:zF}};function Kc(e){return{point:{x:e.pageX,y:e.pageY}}}const $F=e=>t=>Gy(t)&&e(t,Kc(t));function Sc(e,t,n,s){return zc(e,t,$F(n),s)}const iM=({current:e})=>e?e.ownerDocument.defaultView:null,cN=(e,t)=>Math.abs(e-t);function UF(e,t){const n=cN(e.x,t.x),s=cN(e.y,t.y);return Math.sqrt(n**2+s**2)}const uN=new Set(["auto","scroll"]);class oM{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=dg(this.lastMoveEventInfo,this.history),j=this.startEvent!==null,N=UF(w.offset,{x:0,y:0})>=this.distanceThreshold;if(!j&&!N)return;const{point:k}=w,{timestamp:T}=En;this.history.push({...k,timestamp:T});const{onStart:E,onMove:S}=this.handlers;j||(E&&E(this.lastMoveEvent,w),this.startEvent=this.lastMoveEvent),S&&S(this.lastMoveEvent,w)},this.handlePointerMove=(w,j)=>{this.lastMoveEvent=w,this.lastMoveEventInfo=ug(j,this.transformPagePoint),At.update(this.updatePoint,!0)},this.handlePointerUp=(w,j)=>{this.end();const{onEnd:N,onSessionEnd:k,resumeAnimation:T}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&T&&T(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const E=dg(w.type==="pointercancel"?this.lastMoveEventInfo:ug(j,this.transformPagePoint),this.history);this.startEvent&&N&&N(w,E),k&&k(w,E)},!Gy(t))return;this.dragSnapToOrigin=l,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=u,this.contextWindow=a||window;const p=Kc(t),h=ug(p,this.transformPagePoint),{point:m}=h,{timestamp:y}=En;this.history=[{...m,timestamp:y}];const{onSessionStart:b}=n;b&&b(t,dg(h,this.history)),this.removeListeners=Wc(Sc(this.contextWindow,"pointermove",this.handlePointerMove),Sc(this.contextWindow,"pointerup",this.handlePointerUp),Sc(this.contextWindow,"pointercancel",this.handlePointerUp)),d&&this.startScrollTracking(d)}startScrollTracking(t){let n=t.parentElement;for(;n;){const s=getComputedStyle(n);(uN.has(s.overflowX)||uN.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(),Ta(this.updatePoint)}}function ug(e,t){return t?{point:t(e.point)}:e}function dN(e,t){return{x:e.x-t.x,y:e.y-t.y}}function dg({point:e},t){return{point:e,delta:dN(e,lM(t)),offset:dN(e,BF(t)),velocity:VF(t,.1)}}function BF(e){return e[0]}function lM(e){return e[e.length-1]}function VF(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const a=lM(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 FF(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 fN(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 HF(e,{top:t,left:n,bottom:s,right:a}){return{x:fN(e.x,n,a),y:fN(e.y,t,s)}}function hN(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 qF(e,t){return{x:hN(e.x,t.x),y:hN(e.y,t.y)}}function ZF(e,t){let n=.5;const s=Vn(e),a=Vn(t);return a>s?n=Oc(t.min,t.max-s,e.min):s>a&&(n=Oc(e.min,e.max-a,t.min)),ur(0,1,n)}function WF(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 _v=.35;function YF(e=_v){return e===!1?e=0:e===!0&&(e=_v),{x:pN(e,"left","right"),y:pN(e,"top","bottom")}}function pN(e,t,n){return{min:mN(e,t),max:mN(e,n)}}function mN(e,t){return typeof e=="number"?e:e[t]||0}const GF=new WeakMap;class KF{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(Kc(y).point),this.stopAnimation()},u=(y,b)=>{const{drag:w,dragPropagation:j,onDragStart:N}=this.getProps();if(w&&!j&&(this.openDragLock&&this.openDragLock(),this.openDragLock=NV(w),!this.openDragLock))return;this.latestPointerEvent=y,this.latestPanInfo=b,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),tr(T=>{let E=this.getAxisMotionValue(T).get()||0;if(or.test(E)){const{projection:S}=this.visualElement;if(S&&S.layout){const M=S.layout.layoutBox[T];M&&(E=Vn(M)*(parseFloat(E)/100))}}this.originPoint[T]=E}),N&&At.update(()=>N(y,b),!1,!0),Sv(this.visualElement,"transform");const{animationState:k}=this.visualElement;k&&k.setActive("whileDrag",!0)},d=(y,b)=>{this.latestPointerEvent=y,this.latestPanInfo=b;const{dragPropagation:w,dragDirectionLock:j,onDirectionLock:N,onDrag:k}=this.getProps();if(!w&&!this.openDragLock)return;const{offset:T}=b;if(j&&this.currentDirection===null){this.currentDirection=JF(T),this.currentDirection!==null&&N&&N(this.currentDirection);return}this.updateAxis("x",b.point,T),this.updateAxis("y",b.point,T),this.visualElement.render(),k&&At.update(()=>k(y,b),!1,!0)},p=(y,b)=>{this.latestPointerEvent=y,this.latestPanInfo=b,this.stop(y,b),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 oM(t,{onSessionStart:l,onStart:u,onMove:d,onSessionEnd:p,resumeAnimation:h},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:m,distanceThreshold:s,contextWindow:iM(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||!Cd(t,a,this.currentDirection))return;const l=this.getAxisMotionValue(t);let u=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(u=FF(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=HF(s.layoutBox,t):this.constraints=!1,this.elastic=YF(n),a!==this.constraints&&!Mo(t)&&s&&this.constraints&&!this.hasMutatedConstraints&&tr(l=>{this.constraints!==!1&&this.getAxisMotionValue(l)&&(this.constraints[l]=WF(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=QV(s,a.root,this.visualElement.getTransformPagePoint());let u=qF(a.layout.layoutBox,l);if(n){const d=n(KV(u));this.hasMutatedConstraints=!!d,d&&(u=AA(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(!Cd(m,n,this.currentDirection))return;let y=p&&p[m]||{};u&&(y={min:0,max:0});const b=a?200:1e6,w=a?40:1e7,j={type:"inertia",velocity:s?t[m]:0,bounceStiffness:b,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 Sv(this.visualElement,t),s.start(Hy(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(!Cd(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]=ZF({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(!Cd(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;GF.set(this.visualElement,this);const t=this.visualElement.current,n=Sc(t,"pointerdown",h=>{const{drag:m,dragListener:y=!0}=this.getProps(),b=h.target,w=b!==t&&MV(b);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=XF(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=zc(window,"resize",()=>this.scalePositionWithinConstraints()),p=l.addEventListener("didUpdate",(({delta:h,hasLayoutChanged:m})=>{this.isDragging&&m&&(tr(y=>{const b=this.getAxisMotionValue(y);b&&(this.originPoint[y]+=h[y].translate,b.set(b.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=_v,dragMomentum:d=!0}=t;return{...t,drag:n,dragDirectionLock:s,dragPropagation:a,dragConstraints:l,dragElastic:u,dragMomentum:d}}}function gN(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function XF(e,t,n){const s=SS(e,gN(n)),a=SS(t,gN(n));return()=>{s(),a()}}function Cd(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function JF(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class QF extends za{constructor(t){super(t),this.removeGroupControls=As,this.removeListeners=As,this.controls=new KF(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 fg=e=>(t,n)=>{e&&At.update(()=>e(t,n),!1,!0)};class eH extends za{constructor(){super(...arguments),this.removePointerDownListener=As}onPointerDown(t){this.session=new oM(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:iM(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:a}=this.node.getProps();return{onSessionStart:fg(t),onStart:fg(n),onMove:fg(s),onEnd:(l,u)=>{delete this.session,a&&At.postRender(()=>a(l,u))}}}mount(){this.removePointerDownListener=Sc(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 hg=!1;class tH 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),hg&&l.root.didUpdate(),l.addEventListener("animationComplete",()=>{this.safeToRemove()}),l.setOptions({...l.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),sf.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}),hg=!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(),Yy.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:a}=t;hg=!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 cM(e){const[t,n]=XA(),s=g.useContext(Cy);return o.jsx(tH,{...e,layoutGroup:s,switchLayoutGroup:g.useContext(rM),isPresent:t,safeToRemove:n})}const nH={pan:{Feature:eH},drag:{Feature:QF,ProjectionNode:KA,MeasureLayout:cM}};function vN(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,Kc(t)))}class sH extends za{mount(){const{current:t}=this.node;t&&(this.unmount=EV(t,(n,s)=>(vN(this.node,s,"Start"),a=>vN(this.node,a,"End"))))}unmount(){}}class rH extends za{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=Wc(zc(this.node.current,"focus",()=>this.onFocus()),zc(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function yN(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,Kc(t)))}class aH extends za{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:s}=this.node.props;this.unmount=_V(t,(a,l)=>(yN(this.node,l,"Start"),(u,{success:d})=>yN(this.node,u,d?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:s?.tap===!1})}unmount(){}}const Ov=new WeakMap,pg=new WeakMap,iH=e=>{const t=Ov.get(e.target);t&&t(e)},oH=e=>{e.forEach(iH)};function lH({root:e,...t}){const n=e||document;pg.has(n)||pg.set(n,{});const s=pg.get(n),a=JSON.stringify(t);return s[a]||(s[a]=new IntersectionObserver(oH,{root:e,...t})),s[a]}function cH(e,t,n){const s=lH(t);return Ov.set(e,n),s.observe(e),()=>{Ov.delete(e),s.unobserve(e)}}const uH={some:0,all:1};class dH extends za{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:uH[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(),b=h?m:y;b&&b(p)};return cH(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(fH(t,n))&&this.startObserver()}unmount(){}}function fH({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const hH={inView:{Feature:dH},tap:{Feature:aH},focus:{Feature:rH},hover:{Feature:sH}},pH={layout:{ProjectionNode:KA,MeasureLayout:cM}},mH={...LF,...hH,...nH,...pH},gH=OF(mH,IF);function vH(e){return"type"in e&&e.type==="separator"}function yH(e){return"type"in e&&e.type==="group"}function xN({item:e}){return o.jsxs(Z$,{disabled:e.disabled,onClick:e.action,className:"flex items-center gap-3 px-3 py-1.5 text-[12px] font-mono text-neutral-300 outline-none select-none data-[highlighted]:bg-neutral-700/50 data-[highlighted]:text-white 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-neutral-400",children:e.icon}),o.jsx("span",{className:"flex-1",children:e.label}),e.shortcut&&o.jsx("span",{className:"text-neutral-400 text-[10px] ml-4 tracking-wider",children:e.shortcut})]})}const uM=Oo.forwardRef(({items:e},t)=>o.jsx(gH.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(VU,{className:"bg-neutral-900/95 backdrop-blur-xl border border-neutral-700/60 rounded-lg shadow-2xl py-1 min-w-[180px] z-[200] outline-none",children:e.map((n,s)=>vH(n)?o.jsx(x9,{className:"h-px bg-neutral-700/50 my-1"},`sep-${s}`):yH(n)?o.jsxs(H$,{children:[o.jsx(q$,{className:"px-3 py-1 text-[10px] font-mono uppercase tracking-widest text-neutral-400",children:n.label}),n.items.map(a=>o.jsx(xN,{item:a},a.id))]},`grp-${s}`):o.jsx(xN,{item:n},n.id))})}));uM.displayName="PopupContent";function xH({items:e,children:t}){return e.length===0?o.jsx(o.Fragment,{children:t}):o.jsxs(b9,{children:[o.jsx(w9,{render:o.jsx("div",{style:{display:"contents"}}),children:t}),o.jsx(HU,{children:o.jsx(s9,{className:"z-[200]",sideOffset:4,children:o.jsx(lF,{children:o.jsx(uM,{items:e})})})})]})}const bN=()=>{},bH={x:0,y:0},wH=({children:e,hud:t,mode:n="canvas",panOffset:s=bH,scale:a=1,onPan:l=bN,onZoom:u=bN,onPanStart:d,onPanEnd:p,isTransitioning:h=!1,onViewportChange:m,onCanvasClick:y,canvasProps:b,zoomSensitivity:w,zoomControlsRightOffset:j,canvasContextMenuItems:N})=>{const k=g.useRef(null),T=g.useRef(a);T.current=a;const E=g.useRef(u);E.current=u;const S=g.useRef(l);S.current=l;const M=g.useRef(d);M.current=d;const R=g.useRef(p);R.current=p;const A=g.useRef(w);A.current=w;const[_,$]=g.useState(!1),V=g.useRef(!1),[U,O]=g.useState(!1),P=g.useRef(!1),q=g.useRef({x:0,y:0}),Z=g.useRef(L=>{const z=L.target||document.activeElement;if(!z)return!1;const B=z.tagName;return!!(B==="INPUT"||B==="TEXTAREA"||z.isContentEditable||z.closest?.(".xterm"))});g.useEffect(()=>{if(n!=="canvas")return;const L=X=>{X.key!==" "||X.repeat||Z.current(X)||h||(X.preventDefault(),V.current=!0,$(!0))},z=X=>{X.key===" "&&V.current&&(V.current=!1,$(!1),P.current&&(P.current=!1,O(!1),R.current?.()))},B=()=>{V.current&&(V.current=!1,$(!1),P.current&&(P.current=!1,O(!1),R.current?.()))};return window.addEventListener("keydown",L),window.addEventListener("keyup",z),window.addEventListener("blur",B),()=>{window.removeEventListener("keydown",L),window.removeEventListener("keyup",z),window.removeEventListener("blur",B)}},[n,h]);const H=g.useCallback(L=>{L.button===0&&(L.preventDefault(),P.current=!0,O(!0),q.current={x:L.clientX,y:L.clientY},M.current?.())},[]);return g.useEffect(()=>{if(!_)return;const L=B=>{if(!P.current)return;const X=(B.clientX-q.current.x)/T.current,W=(B.clientY-q.current.y)/T.current;q.current={x:B.clientX,y:B.clientY},S.current({x:X,y:W})},z=()=>{P.current&&(P.current=!1,O(!1),R.current?.())};return window.addEventListener("mousemove",L),window.addEventListener("mouseup",z),()=>{window.removeEventListener("mousemove",L),window.removeEventListener("mouseup",z)}},[_]),g.useEffect(()=>{if(n!=="canvas")return;const L=z=>{if(z.ctrlKey||z.metaKey){z.preventDefault();const B=T.current,X=-z.deltaY*.001*(A.current??1),W=Math.min(Math.max(.2,B+X),3);T.current=W,E.current(W)}};return window.addEventListener("wheel",L,{passive:!1}),()=>window.removeEventListener("wheel",L)},[n]),g.useEffect(()=>{if(!m)return;let L=null;const z=()=>{L&&cancelAnimationFrame(L),L=requestAnimationFrame(()=>{m({width:window.innerWidth,height:window.innerHeight})})};return z(),window.addEventListener("resize",z),()=>{window.removeEventListener("resize",z),L&&cancelAnimationFrame(L)}},[m]),n==="panel"?o.jsxs("div",{ref:k,className:"fixed inset-0 bg-black text-neutral-200 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-black text-neutral-200 overflow-hidden font-sans select-none z-0",children:[o.jsx(xH,{items:N??[],children:o.jsx(IL,{panOffset:s,scale:a,onPan:l,onPanStart:d,onPanEnd:p,isPanLocked:h,onClick:y,showGuides:b?.showGuides,onGuidesChange:b?.onGuidesChange,gridOpacity:b?.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:H}),o.jsx("div",{className:"fixed bottom-[36px] z-30",style:{right:(j??280)+16},children:o.jsx(DL,{scale:a,onZoom:L=>u(L)})}),o.jsx("div",{className:"fixed inset-0 z-50 pointer-events-none overflow-hidden",children:t})]})},yo=4e3,jH=Oo.forwardRef(({pan:e,zoom:t,viewportSize:n,height:s,onClick:a,children:l},u)=>{const[d,p]=Oo.useState(0),h=g.useRef(null),m=Oo.useCallback(E=>{h.current=E,typeof u=="function"?u(E):u&&(u.current=E)},[u]);Oo.useEffect(()=>{const E=h.current;if(!E)return;const S=new ResizeObserver(([M])=>p(M.contentRect.width));return S.observe(E),()=>S.disconnect()},[]);const y=d||260,b=n.width/t/yo*y,w=n.height/t/yo*s,j=(-e.x+yo/2)/yo*y,N=(-e.y+yo/2)/yo*s,k=j-b/2,T=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, #555 1px, transparent 1px)",backgroundSize:"14px 14px"}}),o.jsx("div",{className:"absolute top-1/2 left-0 right-0 h-px bg-neutral-600/40"}),o.jsx("div",{className:"absolute left-1/2 top-0 bottom-0 w-px bg-neutral-600/40"}),o.jsxs("div",{className:"absolute border border-emerald-500/50 bg-emerald-500/5 transition-all duration-75 ease-out",style:{left:`${k}px`,top:`${T}px`,width:`${Math.max(b,4)}px`,height:`${Math.max(w,4)}px`},children:[o.jsx("div",{className:"absolute -top-[1px] -left-[1px] w-[3px] h-[3px] bg-emerald-400 rounded-full"}),o.jsx("div",{className:"absolute -top-[1px] -right-[1px] w-[3px] h-[3px] bg-emerald-400 rounded-full"}),o.jsx("div",{className:"absolute -bottom-[1px] -left-[1px] w-[3px] h-[3px] bg-emerald-400 rounded-full"}),o.jsx("div",{className:"absolute -bottom-[1px] -right-[1px] w-[3px] h-[3px] bg-emerald-400 rounded-full"})]}),l]})});jH.displayName="MinimapCanvas";const SH=({title:e,subtitle:t,center:n,actions:s,onTitleClick:a,search:l})=>{const{dragRegionProps:u,onInteractiveMouseDown:d}=Qf(),{navTotalHeight:p}=uy(),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-neutral-950/95 backdrop-blur-xl border-b border-neutral-700/80 shadow-[0_4px_30px_rgba(0,0,0,0.5)] 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-white/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:[t&&o.jsx("span",{className:"text-neutral-400 flex items-center",children:t}),o.jsx("button",{onClick:a,className:"text-[22px] font-bold text-white tracking-[0.25em] font-mono leading-none bg-transparent border-none cursor-pointer",children:e})]}),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-white/[0.06] border border-neutral-600/50 rounded px-2.5 hover:border-neutral-500/60 focus-within:border-neutral-400/50 focus-within:bg-white/[0.08] transition-all duration-200",children:[o.jsx(ly,{size:11,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-neutral-400"}),o.jsx("input",{type:"text",value:l.value,onChange:m=>l.onChange(m.target.value),placeholder:l.placeholder??"Search...",className:`
|
|
130
|
-
w-full h-7 pl-5 pr-6 bg-transparent text-[12px] font-mono tracking-wider
|
|
131
|
-
placeholder:text-neutral-400 text-neutral-200
|
|
132
|
-
focus:outline-none transition-all duration-200
|
|
133
|
-
${h?"text-emerald-400":""}
|
|
134
|
-
`}),h&&o.jsx("button",{onClick:()=>l.onChange(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-neutral-400 hover:text-white transition-colors",children:o.jsx(dC,{size:12})})]})]})]})})},wN=({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 T=e==="left"?Q3:sL;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-neutral-950/95 border border-neutral-700/80 hover:border-emerald-500/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`,title:`Expand ${t||"panel"}`,children:o.jsx(T,{size:14,className:"text-neutral-400 group-hover:text-emerald-400 transition-colors",strokeWidth:1.5})})}const y=e==="left"?X3:tL,{panelTopOffset:b}=uy(),N=`bg-neutral-950/95 backdrop-blur-xl border border-neutral-700/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:b,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-neutral-700/80 group-hover:bg-emerald-500/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-neutral-500 group-hover:bg-emerald-400/70"}),o.jsx("div",{className:"w-[3px] h-[3px] rounded-full bg-neutral-500 group-hover:bg-emerald-400/70"}),o.jsx("div",{className:"w-[3px] h-[3px] rounded-full bg-neutral-500 group-hover:bg-emerald-400/70"})]})]}),!h&&o.jsx("div",{className:`absolute top-0 ${e==="left"?"right-0":"left-0"} bottom-0 w-px bg-neutral-700/80`}),o.jsx("div",{className:"absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-white/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-neutral-700/50",children:o.jsxs("div",{className:"flex items-center justify-between text-neutral-200 text-[12px]",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[n&&o.jsx("span",{className:"text-neutral-400",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-white/10 rounded transition-colors text-neutral-400 hover:text-white",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})]})]})},NH={emerald:{dot:"bg-emerald-500",ping:"bg-emerald-400",text:"text-emerald-500"},amber:{dot:"bg-amber-500",ping:"bg-amber-400",text:"text-amber-500"},red:{dot:"bg-red-500",ping:"bg-red-400",text:"text-red-500"},neutral:{dot:"bg-neutral-500",ping:"bg-neutral-400",text:"text-neutral-400"}},kH=({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),[b,w]=g.useState(!1);g.useEffect(()=>{w(!0);const k=setInterval(()=>h(new Date),1e3);return()=>clearInterval(k)},[]);const j=NH[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:`${OL.statusBar} h-7 flex items-center justify-between px-3 select-none font-mono text-[12px] text-neutral-200 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-white/5 border border-neutral-800 hover:bg-white/10 transition-colors text-neutral-400 hover:text-white",title:"Expand minimap",children:[o.jsx(V3,{size:10}),o.jsx("span",{className:"text-[11px] font-bold",children:"MAP"}),o.jsx(cC,{size:8,className:"opacity-60"})]}),o.jsx("div",{className:"h-3 w-px bg-neutral-700"})]}),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-neutral-700"}),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-neutral-200 transition-colors cursor-pointer",title:"Copy viewport data",children:[o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("span",{className:"text-neutral-400",children:"PAN:"}),o.jsxs("span",{className:`tabular-nums ${m?"text-emerald-500":""}`,children:[t.pan.x.toFixed(0),",",t.pan.y.toFixed(0)]})]}),o.jsx("div",{className:"h-3 w-px bg-neutral-700"}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("span",{className:"text-neutral-400",children:"SIZE:"}),o.jsxs("span",{className:`tabular-nums ${m?"text-emerald-500":""}`,children:[t.canvasSize?.w??1024,"x",t.canvasSize?.h??1024]})]}),o.jsx("div",{className:"h-3 w-px bg-neutral-700"}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("span",{className:"text-neutral-400",children:"ZOOM:"}),o.jsxs("span",{className:`tabular-nums ${m?"text-emerald-500":""}`,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-neutral-700"}),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 ${d?"bg-emerald-500/10 text-emerald-400 border border-emerald-500/30":"text-neutral-400 hover:text-neutral-100 hover:bg-white/5 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-neutral-700"})]}),o.jsxs("div",{className:"flex items-center gap-1.5 text-neutral-200 min-w-[60px] justify-end",children:[o.jsx(z3,{size:11,className:"text-neutral-400"}),o.jsx("span",{children:b?p.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"--:--"})]})]})]})},EH=({onOpenCommandPalette:e,extraControls:t})=>o.jsx("div",{className:"select-none font-mono text-[12px] border-t border-neutral-700/50",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-neutral-400 hover:text-white transition-colors",children:[o.jsx(ly,{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-neutral-400 font-mono",children:"⌘K"})]})]})}),{statusBarHeight:Td}=eh.layout,jN=120,CH=({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=E=>{const S=j-E.clientY,M=window.innerHeight-Td,R=Math.max(jN,Math.min(M,N+S));m.current&&(m.current.style.height=`${R}px`)},T=E=>{h.current=!1,document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",T),m.current&&(m.current.style.transition="");const S=j-E.clientY,M=window.innerHeight-Td;l(Math.max(jN,Math.min(M,N+S)))};document.addEventListener("mousemove",k),document.addEventListener("mouseup",T)},[a,l]),b=s?`calc(100vh - ${Td}px)`:`${a}px`;return o.jsxs("div",{ref:m,className:`
|
|
135
|
-
fixed left-0 right-0 shadow-[0_-10px_40px_rgba(0,0,0,0.8)] flex flex-col border-t border-neutral-700
|
|
136
|
-
bg-neutral-950/95 backdrop-blur-xl
|
|
137
|
-
${e?"translate-y-0 opacity-100 pointer-events-auto":"translate-y-full opacity-0 pointer-events-none"}
|
|
138
|
-
transition-all duration-300 ease-in-out
|
|
139
|
-
`,style:{bottom:Td,height:b,zIndex:eh.zIndex.drawer},children:[o.jsxs("div",{className:"h-9 bg-neutral-900/70 border-b border-neutral-700 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-emerald-400",children:[o.jsx(hL,{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-neutral-500 hover:text-neutral-300 transition-colors group",title:"Drag to Resize",onMouseDown:y,children:o.jsx("div",{className:"w-16 h-1 rounded-full bg-neutral-700 group-hover:bg-neutral-500 transition-colors"})}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{onClick:n,className:"p-1.5 rounded hover:bg-neutral-700 text-neutral-400 hover:text-white transition-colors",title:s?"Restore":"Maximize",children:s?o.jsx(W3,{size:14}):o.jsx(cC,{size:14})}),o.jsx("button",{onClick:t,className:"p-1.5 rounded hover:bg-red-900/20 text-neutral-400 hover:text-red-400 transition-colors",title:"Close",children:o.jsx(dC,{size:14})})]})]}),o.jsx("div",{className:"flex-1 relative overflow-hidden flex flex-col bg-transparent",children:p})]})},TH=({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=>{y.key==="ArrowDown"?(y.preventDefault(),u(b=>(b+1)%h.length)):y.key==="ArrowUp"?(y.preventDefault(),u(b=>(b-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-black/60 backdrop-blur-[2px] pointer-events-auto",onClick:t,children:o.jsxs("div",{className:"w-[640px] max-w-[90vw] bg-[#161616] border border-neutral-700 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-neutral-700 gap-3",children:[o.jsx(ly,{className:"text-neutral-400",size:18}),o.jsx("input",{ref:d,className:"flex-1 bg-transparent border-none outline-none text-neutral-100 placeholder-neutral-500 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-neutral-700 border border-neutral-700 text-[12px] text-neutral-200 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-neutral-400 text-xs font-mono",children:"No matching commands"}):h.map((y,b)=>o.jsxs("div",{ref:b===l?p:null,className:`px-4 py-2.5 flex items-center gap-3 cursor-pointer transition-colors ${b===l?"bg-emerald-900/20 border-l-2 border-emerald-500":"border-l-2 border-transparent hover:bg-white/5"}`,onClick:()=>{y.action(),t()},onMouseEnter:()=>u(b),children:[y.icon&&o.jsx("div",{className:`text-neutral-300 ${b===l?"text-emerald-400":""}`,children:y.icon}),o.jsx("div",{className:"flex-1",children:o.jsx("div",{className:`text-sm ${b===l?"text-emerald-100":"text-neutral-200"}`,children:y.label})}),y.shortcut&&o.jsx("div",{className:"text-[12px] font-mono text-neutral-300 bg-neutral-800 px-1.5 py-0.5 rounded border border-neutral-700",children:y.shortcut}),b===l&&o.jsx($3,{size:14,className:"text-emerald-500 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-[#111] to-transparent pointer-events-none"})]}),o.jsxs("div",{className:"px-4 py-1.5 bg-neutral-800/90 backdrop-blur-sm border-t border-neutral-700 flex justify-between items-center text-[12px] text-neutral-300 font-mono relative z-10",children:[o.jsx("span",{children:"Command Palette"}),o.jsxs("span",{children:[h.length," matches"]})]})]})}):null},mg=new Map;function gg(e){if(e)return JSON.parse(e)}function AH(e){return e?JSON.stringify([...new Headers(e).entries()].sort(([t],[n])=>t.localeCompare(n))):""}function MH(e,t){return`${(t?.method??"GET").toUpperCase()}:${e}:${AH(t?.headers)}`}async function SN(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 Me(e,t){if(!((t?.method??"GET").toUpperCase()==="GET"&&!t?.body))return gg(await SN(e,t));const a=MH(e,t),l=mg.get(a);if(l)return gg(await l);const u=SN(e,t);mg.set(a,u);try{return gg(await u)}finally{mg.delete(a)}}function Xc(){return!(typeof window>"u"||new URLSearchParams(window.location.search).has("no-ops"))}function RH(e){switch(e){case"profile":case"observe":case"message":return e;default:return}}function _H(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 OH(e){switch(e){case"warroom":return"command";case"mission":return"control";case"conductor":return"conduct";default:return e}}function IH(e){const t=new URL(e.toString()),n=t.pathname.replace(/^\/+/,"").split("/").filter(Boolean),s=t.searchParams.get("compose")==="ask"?"ask":void 0,a=RH(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(!Xc())return{view:"inbox"};const l=_H(n[1]);return l?{view:"ops",mode:l}:{view:"ops"}}return{view:"inbox"}}function vg(){return IH(window.location.href)}function DH(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/${OH(e.mode)}`:"/ops";case"terminal":return e.agentId?`/terminal/${encodeURIComponent(e.agentId)}`:"/terminal"}}function yg(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 PH(){const[e,t]=g.useState(vg),n=g.useRef({});g.useEffect(()=>{const a=()=>{const l=vg();t(l),requestAnimationFrame(()=>{window.scrollTo(0,n.current[yg(l)]??0)})};return window.addEventListener("popstate",a),()=>window.removeEventListener("popstate",a)},[]);const s=g.useCallback(a=>{const l=a.view==="ops"&&!Xc()?{view:"inbox"}:a;n.current[yg(vg())]=window.scrollY,window.history.pushState(null,"",DH(l)),t(l),requestAnimationFrame(()=>{window.scrollTo(0,n.current[yg(l)]??0)})},[]);return{route:e,navigate:s}}function dM(e){const t=e.match(/^dm\.operator\.(.+)$/);return t?t[1]:null}function Dn(e){return`dm.operator.${e}`}const zH=["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"],gi=new Set;let Nc=null,Dr=null,$f=0;function LH(e){try{return JSON.parse(e)}catch{return{kind:"unknown"}}}function fM(){Nc?.close(),Nc=null}function $H(){if(Dr||gi.size===0)return;$f++;const e=Math.min(3e3*2**($f-1),6e4);Dr=setTimeout(()=>{Dr=null,gi.size>0&&hM()},e)}function UH(e){for(const t of[...gi])t(e)}function hM(){if(Nc||gi.size===0)return;const e=new EventSource("/api/events");Nc=e;const t=n=>{UH(LH(n.data))};e.onopen=()=>{$f=0},e.onmessage=t;for(const n of zH)e.addEventListener(n,t);e.onerror=()=>{Nc===e?fM():e.close(),$H()}}function BH(e){return gi.add(e),Dr&&(clearTimeout(Dr),Dr=null),hM(),()=>{gi.delete(e),!(gi.size>0)&&(Dr&&(clearTimeout(Dr),Dr=null),$f=0,fM())}}function Mn(e){const t=g.useRef(e);t.current=e,g.useEffect(()=>BH(n=>{t.current(n)}),[])}function et(e){return e==="working"?"working":!e||e==="offline"?"offline":"available"}function Ni(e){return et(e)!=="offline"}function Pn(e){switch(et(e)){case"working":return"Working";case"available":return"Available";default:return"Offline"}}const mh="ranger.main.mini",VH=new Set([mh,"ranger","@ranger"]),FH=new Set(["plan","conductor","conduct","warroom","command","mission","control","agents","tail","atop"]),HH=new Set(["available","working","active","idle","waiting","registered"]);function rx(e){return[e.id,e.name,e.handle??"",e.selector??"",e.role??""].map(n=>n.trim().toLowerCase()).some(n=>VH.has(n)||n==="ranger"||n.startsWith("ranger.")||n.includes(".ranger.")||n.includes(" ranger"))}function qH(e){return HH.has(e.state?.trim().toLowerCase()??"")}function NN(e){if(!rx(e))return Number.NEGATIVE_INFINITY;let t=0;return qH(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===mh&&(t+=1),t}function ZH(e){return e.filter(rx).sort((t,n)=>{const s=NN(n)-NN(t);return s!==0?s:(n.updatedAt??0)-(t.updatedAt??0)})[0]??null}function WH(e){return ZH(e)?.id??mh}function YH(e){return Dn(e)}function pM(e,t=mh){const n=e.trim().toLowerCase(),s=t.trim().toLowerCase();return n===s||n==="ranger"||n.startsWith("ranger.")||n.includes(".ranger.")}function GH(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=KH(s[1]??"");t.push(...a)}return t}function KH(e){const t=e.trim();if(!t)return[];try{const n=JSON.parse(t);return(Array.isArray(n)?n:[n]).map(a=>mM(a)).filter(a=>!!a)}catch{return[]}}function mM(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 mM(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=XH(t.route??t);return l?{type:"navigate",route:l,...a?{reason:a}:{}}:null}function XH(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"&&FH.has(t.mode)?JH(t.mode):void 0;return{view:"ops",...s?{mode:s}:{}}}default:return null}}function JH(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 gM={current:null,setMenu:null};function gh(){return g.useCallback((e,t)=>{e.preventDefault(),e.stopPropagation(),gM.setMenu?.({position:{x:e.clientX,y:e.clientY},items:t})},[])}function QH({children:e}){const[t,n]=g.useState(null),s=g.useRef(null);gM.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 eq=[195,125,300,45,355,210];function kN(e){return`oklch(0.80 0.14 ${e})`}function tq(e){return`oklch(0.18 0.08 ${e})`}function vi({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 Ro({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 nq({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 sq({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 Ad({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 rq({profile:e,update:t}){return o.jsxs("div",{className:"s-settings-col-gap",children:[o.jsx(vi,{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:kN(e.hue),color:tq(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:eq.map(n=>o.jsx("button",{onClick:()=>t({hue:n}),className:`s-settings-hue-dot${e.hue===n?" s-settings-hue-dot--active":""}`,style:{background:kN(n)}},n))})]})]}),o.jsx(ks,{label:"Display name",hint:"Shown when agents address you.",children:o.jsx(Ro,{value:e.name,onChange:n=>t({name:n})})}),o.jsx(ks,{label:"Handle",hint:"Used in @mentions across threads.",children:o.jsx(Ro,{value:e.handle,onChange:n=>t({handle:n}),mono:!0})}),o.jsx(ks,{label:"Pronouns",children:o.jsx(Ro,{value:e.pronouns,onChange:n=>t({pronouns:n})})}),o.jsx(vi,{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(nq,{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(Ro,{value:e.timezone,onChange:n=>t({timezone:n}),mono:!0})}),o.jsx(ks,{label:"Working hours",children:o.jsx(Ro,{value:e.workingHours,onChange:n=>t({workingHours:n}),mono:!0})})]})]})}function aq({profile:e,update:t}){return o.jsxs("div",{className:"s-settings-col-gap",children:[o.jsx(vi,{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(Ad,{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(sq,{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(Ro,{value:e.quietHours,onChange:n=>t({quietHours:n}),mono:!0})})]}),o.jsx(vi,{label:"Where to reach you"}),o.jsx(ks,{label:"Preferred channel",children:o.jsx(Ad,{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(vi,{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(Ad,{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(Ad,{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 iq={desktop:"◻",mobile:"▯",tablet:"▭"};function oq({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:iq[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 lq({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(vi,{label:`Paired devices · ${t.length}`}),o.jsx("div",{className:"s-settings-col-gap",style:{gap:10},children:t.map(n=>o.jsx(oq,{device:n},n.id))}),o.jsx(vi,{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 cq=[{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"}],uq={operator:"Operator identity",comms:"Communication",devices:"Paired devices"},dq={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 fq({open:e,onClose:t}){const{refreshOnboarding:n}=Nt(),[s,a]=g.useState("operator"),[l,u]=g.useState(dq),[d,p]=g.useState(null),[h,m]=g.useState(!1),y=g.useRef(null),b=g.useCallback(async()=>{try{const N=Me("/api/user"),k=Promise.race([Me("/api/pairing-state"),new Promise((S,M)=>setTimeout(()=>M(new Error("timeout")),3e3))]),[T,E]=await Promise.allSettled([N,k]);T.status==="fulfilled"&&u(T.value),E.status==="fulfilled"&&p(E.value)}finally{m(!0)}},[]);g.useEffect(()=>{e&&b()},[e,b]),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(()=>{Me("/api/user",{method:"POST",body:JSON.stringify(N)}).then(()=>n()).catch(()=>{})},400)},[n]),j=g.useCallback(N=>{u(k=>{const T={...k,...N};return w(T),T})},[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:uq[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:cq.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(rq,{profile:l,update:j}),s==="comms"&&o.jsx(aq,{profile:l,update:j}),s==="devices"&&o.jsx(lq,{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 hq({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 vM=g.createContext(null),pq=["hello","node.upserted","actor.registered","agent.registered","agent.endpoint.upserted","invocation.requested","flight.updated","delivery.state.changed","scout.dispatched"],mq=new Set(pq),gq={"--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.23 0.010 80 / 0.8)","--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-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-border) 55%, 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"},vq={"--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(vM);if(!e)throw new Error("useScout must be used inside ScoutProvider");return e}function yq({children:e,initialTheme:t="dark"}){const{route:n,navigate:s}=PH(),[a,l]=g.useState([]),[u,d]=g.useState(null),[p,h]=g.useState(!1),m=g.useCallback(()=>h(!0),[]),[y,b]=g.useState(!1),w=g.useCallback(()=>b(!0),[]),j=g.useCallback(()=>b(!1),[]),N=t==="light"?vq:gq,k=g.useMemo(()=>WH(a),[a]),T=g.useMemo(()=>YH(k),[k]),E=g.useCallback(async()=>{const $=await Me("/api/agents").catch(()=>null);$&&l($)},[]),S=g.useCallback(async()=>{try{const $=await Me("/api/onboarding/state");d($)}catch{d({hasLocalConfig:!0,hasProjectConfig:!0,hasOperatorName:!0,localConfigPath:null,projectRoot:null,currentDirectory:null,operatorName:null,operatorNameSuggestion:null})}},[]);g.useEffect(()=>{E(),S()},[E,S]);const M=g.useMemo(()=>a.filter($=>Ni($.state)).length,[a]),R=g.useCallback($=>{switch($.type){case"navigate":s($.route);break;case"open-ranger":s({view:"conversation",conversationId:T,...$.mode==="ask"?{composeMode:"ask"}:{}});break;case"refresh":E();break}},[s,T,E]),A=g.useRef({rangerAgentId:k,applyRangerUiAction:R});A.current={rangerAgentId:k,applyRangerUiAction:R},Mn($=>{mq.has($.kind)&&E();const V=$.kind==="message.posted"&&$.payload&&typeof $.payload=="object"?$.payload.message:null;if(!V||typeof V!="object")return;const U=V,O=typeof U.actorId=="string"?U.actorId:"",P=typeof U.body=="string"?U.body:"";if(!(!O||!P||!pM(O,A.current.rangerAgentId)))for(const q of GH(P))A.current.applyRangerUiAction(q)}),g.useEffect(()=>{const $=V=>{const U=V.detail,O=U&&typeof U=="object"&&"type"in U?U:null;O&&A.current.applyRangerUiAction(O)};return window.addEventListener("scout:ranger-ui-action",$),window.scoutRanger={applyUiAction:V=>A.current.applyRangerUiAction(V),navigate:V=>A.current.applyRangerUiAction({type:"navigate",route:V})},()=>{window.removeEventListener("scout:ranger-ui-action",$),window.scoutRanger?.applyUiAction&&delete window.scoutRanger}},[]);const _=g.useMemo(()=>({route:n,navigate:s,agents:a,onlineCount:M,reload:E,onboarding:u,refreshOnboarding:S,onboardingSkipped:p,skipOnboarding:m,settingsOpen:y,openSettings:w,closeSettings:j,rangerAgentId:k,rangerConversationId:T,applyRangerUiAction:R}),[n,s,a,M,E,u,S,p,m,y,w,j,k,T,R]);return o.jsx(vM.Provider,{value:_,children:o.jsx("div",{"data-scout-theme":t,"data-scout-theme-mode":t,style:{...N},children:o.jsxs(QH,{children:[e,o.jsx(fq,{open:y,onClose:j})]})})})}function xq(){const{navigate:e,agents:t,reload:n,openSettings:s,rangerConversationId:a,applyRangerUiAction:l}=Nt(),u=Xc(),d=g.useCallback(async()=>{try{const h=await Me("/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 Me(`/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 yM(){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 Me("/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 bq(){return yM().status}const wq={inbox:"Fleet",conversation:"Conversation","agent-info":"Agent",agents:"Agents",fleet:"Fleet",sessions:"Sessions",activity:"Activity",mesh:"Mesh",settings:"Settings",work:"Work",ops:"Ops"};function jq(){const{route:e,navigate:t}=Nt(),n=Xc(),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"?wq[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 Sq(){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 Nq(){return"panel"}function kq(){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 Eq({app:e,assistant:t=!0}){return o.jsx(e.Provider,{children:o.jsx(Tq,{app:e,assistantEnabled:t})})}function Cq({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 Tq({app:e,assistantEnabled:t}){const{navTotalHeight:n}=uy(),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,b=h?.onDismiss,w=e.slots.Takeover,j=yM(),[N,k]=Ir(`appshell.${e.id}.left`,!1),[T,E]=Ir(`appshell.${e.id}.right`,!1),[S,M]=Ir(`appshell.${e.id}.leftW`,260),[R,A]=Ir(`appshell.${e.id}.rightW`,280),[_,$]=g.useState({x:0,y:0}),[V,U]=g.useState(1),O=g.useCallback(ie=>{$(ye=>({x:ye.x+ie.x,y:ye.y+ie.y}))},[]),P=g.useCallback(ie=>{U(ie)},[]),[q,Z]=g.useState(!1),[H,L]=g.useState(!1),[z,B]=Ir(`appshell.${e.id}.termH`,320),X=!!e.slots.Terminal,W=g.useMemo(()=>{const ie=[];return X&&ie.push("terminal"),t&&ie.push("assistant"),ie},[X,t]),I=W[0]??"terminal",[F,G]=Ir(`appshell.${e.id}.drawerTab`,I),J=W.includes(F)?F:I,[ce,se]=g.useState(!1),[ve,me]=g.useState(new Set),je=g.useCallback(ie=>{me(ye=>{const be=new Set(ye);return be.has(ie)?be.delete(ie):be.add(ie),be})},[]),Ae=g.useCallback(ie=>ye=>{ye.preventDefault();const be=ye.clientX,ke=ie==="left"?S:R,Ee=ie==="left"?M:A,Se=ie==="left"?1:-1,Be=bt=>{const kt=(bt.clientX-be)*Se;Ee(Math.max(200,Math.min(500,ke+kt)))},ze=()=>{document.removeEventListener("mousemove",Be),document.removeEventListener("mouseup",ze)};document.addEventListener("mousemove",Be),document.addEventListener("mouseup",ze)},[S,R,M,A]),he=g.useMemo(()=>{const ie=[{id:"shell:toggle-left",label:"Toggle Left Panel",shortcut:"Cmd+[",action:()=>k(ye=>!ye)},{id:"shell:toggle-right",label:"Toggle Right Panel",shortcut:"Cmd+]",action:()=>E(ye=>!ye)},{id:"shell:toggle-terminal",label:"Toggle Terminal",shortcut:"Ctrl+`",action:()=>Z(ye=>!ye)}];return t&&ie.push({id:"shell:toggle-assistant",label:"Toggle Assistant",shortcut:"Cmd+J",action:()=>{G("assistant"),Z(ye=>!ye||F!=="assistant")}}),ie},[t,F,G,k,E]),ue=g.useMemo(()=>[...s,...he],[s,he]);g.useEffect(()=>{const ie=ye=>{m||((ye.metaKey||ye.ctrlKey)&&ye.key==="k"&&(ye.preventDefault(),se(!0)),(ye.metaKey||ye.ctrlKey)&&ye.key==="["&&(ye.preventDefault(),k(be=>!be)),(ye.metaKey||ye.ctrlKey)&&ye.key==="]"&&(ye.preventDefault(),E(be=>!be)),ye.ctrlKey&&ye.key==="`"&&(ye.preventDefault(),Z(be=>!be)),t&&(ye.metaKey||ye.ctrlKey)&&ye.key==="j"&&(ye.preventDefault(),G("assistant"),Z(be=>!(be&&J==="assistant"))))};return window.addEventListener("keydown",ie),()=>window.removeEventListener("keydown",ie)},[t,J,G,k,E,m]),g.useEffect(()=>{const ie=()=>{G("terminal"),Z(!0),B(ye=>ye>window.innerHeight*.8?420:ye)};return window.addEventListener("scout:open-terminal",ie),()=>window.removeEventListener("scout:open-terminal",ie)},[G,B]);const de=e.slots.Inspector,Le=e.slots.RightPanel,Te=e.tools&&e.tools.length>0,we=o.jsxs(o.Fragment,{children:[de&&o.jsx(de,{}),!de&&Le&&o.jsx(Le,{}),Te&&o.jsx("div",{className:"border-t border-neutral-700/50",children:e.tools.map(ie=>{const ye=ve.has(ie.id);return o.jsxs("div",{children:[o.jsxs("button",{onClick:()=>je(ie.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===ie.id?"text-emerald-400":"text-neutral-300"}`,children:[ye?o.jsx(yO,{size:10}):o.jsx(bO,{size:10}),o.jsx("span",{className:"text-neutral-400",children:ie.icon}),o.jsx("span",{className:"font-bold",children:ie.name})]}),ye&&o.jsx("div",{className:"px-4 pb-3",children:o.jsx(ie.Component,{})})]},ie.id)})})]}),Ne=o.jsxs(o.Fragment,{children:[e.slots.LeftFooter&&o.jsx(e.slots.LeftFooter,{}),o.jsx(EH,{onOpenCommandPalette:()=>se(!0)})]}),_e=g.useRef(null),Fe=g.useRef(null);g.useEffect(()=>{const ie=_e.current;ie&&(m?ie.setAttribute("inert",""):ie.removeAttribute("inert"))},[m]),g.useEffect(()=>{if(!m)return;const ie=Fe.current;if(ie&&(ie.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])")??ie).focus(),!y)return;const ye=be=>{be.key==="Escape"&&(be.preventDefault(),b?.())};return window.addEventListener("keydown",ye),()=>window.removeEventListener("keydown",ye)},[m,y,b]);const Ve=d==="panel"?{position:"absolute",top:n,bottom:28,left:N?0:S,right:T?0:R,overflow:"auto",transition:"left 200ms ease, right 200ms ease"}:{};return o.jsxs(o.Fragment,{children:[o.jsx("div",{ref:_e,"aria-hidden":m?!0:void 0,style:{display:"contents"},children:o.jsx(wH,{mode:d,panOffset:_,scale:V,onPan:O,onZoom:P,hud:o.jsxs(o.Fragment,{children:[o.jsx(SH,{title:e.name.toUpperCase(),search:a??void 0,center:l,actions:u}),o.jsx(wN,{side:"left",title:e.leftPanel?.title??"Navigation",icon:e.leftPanel?.icon,isCollapsed:N,onToggleCollapse:()=>k(!N),width:S,onResizeStart:Ae("left"),footer:Ne,headerActions:e.leftPanel?.headerActions&&o.jsx(e.leftPanel.headerActions,{}),children:e.slots.LeftPanel&&o.jsx(e.slots.LeftPanel,{})}),o.jsx(wN,{side:"right",title:e.rightPanel?.title??"Inspector",icon:e.rightPanel?.icon,isCollapsed:T,onToggleCollapse:()=>E(!T),width:R,onResizeStart:Ae("right"),headerActions:e.rightPanel?.headerActions&&o.jsx(e.rightPanel.headerActions,{}),children:we}),o.jsx(kH,{status:j.status,left:o.jsx(Cq,{statusBar:j}),onToggleTerminal:()=>Z(ie=>!ie),isTerminalOpen:q}),o.jsx("div",{className:"pointer-events-none",style:{position:"fixed",left:N?0:S,right:T?0:R,bottom:0,top:0,zIndex:45,transition:"left 200ms ease, right 200ms ease",transform:"translateZ(0)"},children:o.jsxs(CH,{isOpen:q,onClose:()=>Z(!1),onToggleMaximize:()=>L(ie=>!ie),isMaximized:H,height:Math.min(z,window.innerHeight*.8),onHeightChange:ie=>B(Math.min(ie,window.innerHeight*.8)),title:o.jsx(Aq,{tabs:W,active:J,onSelect:G}),children:[J==="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"})),J==="assistant"&&o.jsx(ML,{app:e,commands:s})]})}),o.jsx(TH,{isOpen:ce,onClose:()=>se(!1),commands:ue})]}),children:o.jsx("div",{style:Ve,className:"frame-scrollbar",children:o.jsx(e.slots.Content,{})})})}),m&&w?o.jsx("div",{ref:Fe,tabIndex:-1,role:"dialog","aria-modal":"true",style:{position:"fixed",inset:0,zIndex:80,outline:"none"},children:o.jsx(w,{})}):null]})}function Aq({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"?BO:zO,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 EN=["#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 EN[Math.abs(t)%EN.length]}function Ur(e){switch(et(e)){case"working":return"var(--green)";case"available":return"var(--accent)";default:return"var(--dim)"}}const Mq={workspace:"workspace",worktree:"workspace",branch:"workspace",profile:"profile",persona:"profile",harness:"harness",runtime:"harness",model:"model",node:"node",host:"node"};function Rq(e){return e.trim().replace(/^@+/,"").replace(/[.,!?;)\]]+$/,"")}function Us(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}const _q="scout";function Oq(e){return Mq[Us(e)]??null}function xM(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 bM(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=Oq(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 wM(s,{raw:e})}function Iq(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=bM(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:wM({definitionId:l.definitionId,nodeQualifier:l.nodeQualifier,workspaceQualifier:l.workspaceQualifier,profile:l.profile,harness:u||l.harness,model:d||l.model},{raw:e})}function Dq(e){const t=Rq(e);return!t||t.includes("@")?null:t.includes("#")||t.includes("?")?Iq(t):bM(t)}function CN(e,t={}){const n=xM(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 wM(e,t={}){const n=xM(e);return n?{raw:t.raw??CN(n,{includeSigil:!1}),label:CN(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 Pq(e){return zq(e).parsed}function zq(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=Dq(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 Lq(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 $q(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&&Uq(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 Uq(e){return/^(?:https?:\/\/|mailto:|\/|#)/iu.test(e)}function us(e){if(!e)return e??"";const t=Pq(e);return Lq(e,t).flatMap((s,a)=>{if(s.kind==="text")return $q(s.value,a*100);const{identity:l}=s,d=l.definitionId===_q?"var(--accent)":mt(l.definitionId);return o.jsx("span",{className:"s-mention",style:{"--mention-color":d},children:l.label},a)})}function Pe(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 fi(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 Bq={"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"},Vq={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 jM(e){return Bq[e]??e.replace(/[._]/g," ")}function Fq(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 Hq(e){return(e??"system").charAt(0).toUpperCase()}function SM(e){return e.length<=14?e:`${e.slice(0,8)}...${e.slice(-4)}`}function qq(e){if(!e)return null;const t=e.split("/").filter(Boolean);return t[t.length-1]??e}function Zq(e){return`${e.actorName??"system"} ${jM(e.kind)}`}function Wq(e){return e.workspaceRoot?`Recorded from ${e.workspaceRoot}.`:e.conversationId?`Linked to thread ${SM(e.conversationId)}.`:"No additional detail was captured for this event."}function Yq({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,b]=g.useState(null),w=g.useRef([]),j=g.useRef(0),N=g.useRef(null),k=gh();g.useEffect(()=>{w.current=t},[t]);const T=g.useCallback(async(A="initial")=>{const _=++j.current;!(w.current.length>0)&&A!=="background"?(u(!0),m(null)):p(!0);try{const V=await Me("/api/activity");if(_!==j.current)return;n(V),m(null),b(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))}},[]),E=g.useCallback(()=>{N.current||(N.current=setTimeout(()=>{N.current=null,T("background")},250))},[T]);g.useEffect(()=>(T("initial"),()=>{N.current&&clearTimeout(N.current)}),[T]),Mn(E);const S=g.useMemo(()=>{const A=new Set(t.map($=>$.actorName??"system")),_=new Set(t.map($=>$.conversationId).filter($=>!!$));return[{label:"Events",value:`${t.length}`,detail:t.length>0?`Latest ${Pe(t[0].ts)}`:"Waiting for records"},{label:"Actors",value:`${A.size}`,detail:A.size>0?"Distinct event owners":"No actors yet"},{label:"Threads",value:`${_.size}`,detail:_.size>0?"Conversation-linked records":"No linked threads"}]},[t]),M=!l&&t.length===0&&!!h,R=!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?Pe(y):"earlier"}`:y?`Updated ${Pe(y)}`:"Waiting for first snapshot"}),o.jsx("button",{type:"button",className:"s-btn",disabled:l||d,onClick:()=>{T("manual")},children:d?"Refreshing...":"Refresh"})]})]}),o.jsx("div",{className:"sys-stat-grid",children:S.map(A=>o.jsxs("div",{className:"sys-stat-card",children:[o.jsx("span",{className:"sys-stat-label",children:A.label}),o.jsx("strong",{className:"sys-stat-value",children:A.value}),o.jsx("span",{className:"sys-stat-detail",children:A.detail})]},A.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."})]}),M&&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:()=>{T("manual")},children:"Try again"})})]}),R&&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(A=>{const _=s===A.id,$=Fq(A.kind),V=Vq[$],U=qq(A.workspaceRoot),O=A.summary&&A.summary!==A.title?A.summary:Wq(A);return o.jsxs("article",{className:`sys-audit-entry${_?" sys-audit-entry-expanded":""}`,onContextMenu:P=>{const q=window.getSelection()?.toString().trim(),Z=[];q&&(Z.push({kind:"action",label:"Copy Selection",shortcut:"⌘C",onSelect:()=>navigator.clipboard.writeText(q)}),Z.push({kind:"separator"}));const H=A.title??A.summary??"";H&&Z.push({kind:"action",label:"Copy Details",onSelect:()=>navigator.clipboard.writeText(H)}),A.actorName&&Z.push({kind:"action",label:"Copy Actor",onSelect:()=>navigator.clipboard.writeText(A.actorName)}),Z.push({kind:"action",label:"Copy Event ID",onSelect:()=>navigator.clipboard.writeText(A.id)}),A.conversationId&&(Z.push({kind:"separator"}),Z.push({kind:"action",label:"Open Thread",onSelect:()=>e({view:"conversation",conversationId:A.conversationId})})),k(P,Z)},children:[o.jsxs("button",{type:"button",className:"sys-audit-toggle","aria-expanded":_,onClick:()=>a(_?null:A.id),children:[o.jsxs("div",{className:"sys-audit-stamp",children:[o.jsx("span",{className:"sys-audit-time",children:Pe(A.ts)}),o.jsx("span",{className:"sys-audit-date",children:fi(A.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:jM(A.kind)})]}),o.jsx("h3",{className:"sys-audit-title",children:us(A.title??Zq(A))}),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(A.actorName??"system")},children:Hq(A.actorName)}),A.actorName??"system"]}),U&&o.jsxs("span",{className:"sys-audit-meta-item",children:["Workspace ",U]}),A.conversationId&&o.jsxs("span",{className:"sys-audit-meta-item",children:["Thread ",SM(A.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:A.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:fi(A.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:A.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:A.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:A.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:A.id})]})]}),A.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:A.conversationId}),children:"Open thread"})})]})]},A.id)})})]})}function Aa(e){const t=e?.trim();if(!t)return null;const[n]=t.split(".");return n?.trim()||t}function Gq(e){const t=e.handle?.trim().replace(/^@+/,"");if(t)return`@${t}`;const n=e.selector?.trim();if(n)return n;const s=Aa(e.id);return s?`@${s}`:null}function Kq(e){return e.name?.trim()||e.agentName?.trim()||Aa(e.id)||e.title?.trim()||"Conversation"}function xg(e){return e?e.replace(/_/g," "):null}function Xq({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 Md({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 Jq({conversationId:e,navigate:t}){const{agents:n}=Nt(),[s,a]=g.useState(null),[l,u]=g.useState(null),d=dM(e),p=g.useCallback(async()=>{u(null);try{const k=await Me(`/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]),Mn(()=>{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=Gq(m),b=[{label:"System ID",value:m.id},{label:"Class",value:xg(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:xg(m.transport)??m.transport}]:[],...m.wakePolicy?[{label:"Wake policy",value:xg(m.wakePolicy)??m.wakePolicy}]:[],...m.capabilities.length>0?[{label:"Capabilities",value:o.jsx(Xq,{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:fi(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??Aa(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 ${Pe(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(Md,{title:"Identity",items:b}),o.jsx(Md,{title:"Workspace",items:w}),o.jsx(Md,{title:"Runtime",items:j}),o.jsx(Md,{title:"Conversation context",items:N})]})]})}function Qq(e){return e.attention==="interrupt"?"failed":e.state==="done"?"completed":e.attention==="badge"||e.state==="waiting"||e.state==="review"?"updated":"working"}function eZ(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 tZ(e){switch(e){case"badge":return"Needs attention";case"interrupt":return"Blocked";default:return null}}function TN({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=tZ(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-${Qq(a)}`,children:a.currentPhase})]}),o.jsxs("div",{className:"s-work-row-meta",children:[o.jsx("span",{children:d}),o.jsx("span",{children:eZ(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:Pe(a.lastMeaningfulAt)})]}),a.lastMeaningfulSummary&&o.jsx("p",{className:"s-work-row-summary",children:us(a.lastMeaningfulSummary)})]},a.id)})})}const NM="/api",nZ=`${NM}/health`,sZ=`${NM}/terminal/run`,kM="/ws/terminal",rZ=`${kM}/health`,aZ="/ws/hmr";function iZ(e,t){if(typeof e!="string")return t;const n=e.trim();return n&&`${n.startsWith("/")?"":"/"}${n}`.replace(/\/{2,}/g,"/").replace(/\/+$/g,"")||t}const oZ={healthPath:nZ,terminalRunPath:sZ,terminalRelayPath:kM,terminalRelayHealthPath:rZ,viteHmrPath:aZ};function EM(){return typeof window>"u"?null:window.__OPENSCOUT_WEB_BOOTSTRAP__??null}function lZ(){const e=EM()?.theme;return typeof e=="string"?e:null}function Jc(e){return iZ(EM()?.routes?.[e],oZ[e])}function CM(){const e=Jc("terminalRelayPath");return typeof window>"u"?`ws://localhost:3200${e}`:`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${e}`}function TM(){const e=Jc("terminalRelayHealthPath");return typeof window>"u"?`http://localhost:3200${e}`:`${window.location.protocol}//${window.location.host}${e}`}const Iv=/^```([a-z0-9_-]+)?\s*$/iu,AM=/^(#{1,6})\s+(.+)$/u,cZ=/^(?:-{3,}|\*{3,}|_{3,})$/u,uZ=/^\s*[-*]\s+(.+)$/u,dZ=/^\s*\d+[.)]\s+(.+)$/u,fZ=/^\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?$/u;function hZ(e){const t=e.replace(/\r\n?/gu,`
|
|
140
|
-
`).trim();return t?t.replace(/([^\n])\s+---\s+(?=(?:#{1,6}\s|\*\*|[A-Z0-9]))/gu,`$1
|
|
141
|
-
|
|
142
|
-
---
|
|
143
|
-
|
|
144
|
-
`).replace(/([^\n])\s+(#{1,6}\s+)/gu,`$1
|
|
145
|
-
|
|
146
|
-
$2`).replace(/\n{3,}/gu,`
|
|
147
|
-
|
|
148
|
-
`):""}function MM(e){return e.trim().length===0}function pZ(e){return AM.test(e.trim())}function RM(e){return cZ.test(e.trim())}function Dv(e){return e.match(uZ)?.[1]?.trim()??null}function Pv(e){return e.match(dZ)?.[1]?.trim()??null}function mZ(e){return Dv(e)!==null||Pv(e)!==null}function AN(e){return e.trim().replace(/^\|/u,"").replace(/\|$/u,"").split("|").map(n=>n.trim())}function _M(e,t){const n=e[t]?.trim(),s=e[t+1]?.trim();return!!(n&&s&&n.includes("|")&&fZ.test(s))}function gZ(e,t){const n=e[t]??"",s=n.trim();return!!(MM(n)||Iv.test(s)||pZ(n)||RM(n)||mZ(n)||s.startsWith(">")||_M(e,t))}function vZ(e){const t=hZ(e);if(!t)return[];const n=t.split(`
|
|
149
|
-
`),s=[];let a=0;for(;a<n.length;){const l=n[a]??"",u=l.trim();if(!u){a+=1;continue}const d=u.match(Iv);if(d){const b=[];for(a+=1;a<n.length&&!Iv.test(n[a].trim());)b.push(n[a]),a+=1;a<n.length&&(a+=1),s.push({type:"code",language:d[1]??null,text:b.join(`
|
|
150
|
-
`)});continue}if(RM(l)){s.push({type:"hr"}),a+=1;continue}const p=u.match(AM);if(p){s.push({type:"heading",depth:p[1].length,text:p[2].trim()}),a+=1;continue}if(_M(n,a)){const b=AN(n[a]);a+=2;const w=[];for(;a<n.length&&n[a].includes("|")&&!MM(n[a]);)w.push(AN(n[a])),a+=1;s.push({type:"table",headers:b,rows:w});continue}const h=Dv(l),m=Pv(l);if(h!==null||m!==null){const b=m!==null,w=[];for(;a<n.length;){const j=b?Pv(n[a]):Dv(n[a]);if(j===null)break;w.push(j),a+=1}s.push({type:"list",ordered:b,items:w});continue}if(u.startsWith(">")){const b=[];for(;a<n.length&&n[a].trim().startsWith(">");)b.push(n[a].trim().replace(/^>\s?/u,"")),a+=1;s.push({type:"blockquote",text:b.join(`
|
|
151
|
-
`).trim()});continue}const y=[];for(;a<n.length&&!gZ(n,a);)y.push(n[a].trimEnd()),a+=1;s.push({type:"paragraph",text:y.join(`
|
|
152
|
-
`).trim()})}return s}function yZ(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 xZ(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 bZ(e,t){switch(e.type){case"paragraph":return o.jsx("p",{className:"s-message-markup-paragraph",children:us(e.text)},t);case"heading":return yZ(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 xZ(e,t)}}function OM({text:e,className:t}){const n=vZ(e??"");return n.length===0?e??"":o.jsx("div",{className:["s-message-markup",t].filter(Boolean).join(" "),children:n.map(bZ)})}const IM="scout:sessions:lastViewed";function ax(){if(typeof localStorage>"u")return{};try{const e=localStorage.getItem(IM);if(!e)return{};const t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function wZ(e,t=Date.now()){const n=ax();n[e]=t;try{localStorage.setItem(IM,JSON.stringify(n))}catch{}return n}function bg(e,t,n){return e?e>(n[t]??0):!1}async function jZ(e){await fetch(Jc("terminalRunPath"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:e})})}const zv=new Set(["completed","failed","cancelled"]),SZ={direct:"Direct message",channel:"Channel",group_direct:"Group",thread:"Thread"},MN=[{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 DM(e,t){if(t<=0)return!0;const n=e[t-1];return!n||/\s/.test(n)}function NZ(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]!=="/"||!DM(e,n))return null;const s=e.slice(n+1,t);return/[^a-zA-Z0-9_-]/.test(s)?null:{start:n,query:s}}function kZ(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]!=="@"||!DM(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 EZ(e){if(!e)return null;const t=e.replace(/[\\/]+$/,"");return t?t.split(/[\\/]/).filter(Boolean).at(-1)??t:null}function CZ(e){return e.kind==="direct"&&e.agentName?e.agentName:e.kind==="direct"&&e.agentId?Aa(e.agentId)??e.agentId:e.title.replace(/\s*<>\s*/g," · ")}function wg(e){const t=es(e);return t===null?"":new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(t)}function TZ(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 RN(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 AZ(e){switch(e){case"status":return"Status";case"system":return"System";case"scout.dispatch":return"Dispatch";default:return null}}function Rd(e){return[...e].sort((t,n)=>(es(t.createdAt)??0)-(es(n.createdAt)??0))}function MZ(e){return e.filter(t=>!zv.has(t.state)).sort((t,n)=>(es(n.startedAt)??0)-(es(t.startedAt)??0))[0]??null}function _N(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 RZ(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 Lv(e,t){if(e.class==="operator")return!0;const n=e.actorName?.toLowerCase()??"";return n===t.toLowerCase()||n==="operator"||n==="you"}function _Z(e,t){return e.reduce((n,s)=>{if(Lv(s,t))return n;const a=es(s.createdAt);return a===null?n:n===null||a>n?a:n},null)}function OZ(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 IZ(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()||OZ(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 Ni(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 DZ(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 PZ(){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 zZ(){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 LZ(e){if(!e)return null;if(e.kind==="direct")return e.agentName??Aa(e.agentId)??null;const t=e.participantIds.filter(n=>n!=="operator");return t.length===0?null:t.map(n=>Aa(n)??n).join(", ")}function $v({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),[b,w]=g.useState([]),[j,N]=g.useState(null),k=g.useRef(null),T=g.useRef(null),E=g.useRef(new Set),S=g.useRef(null),M=g.useRef(0),R=g.useRef(null),A=dM(e),_=u?.agentId??A,$=u?.kind==="direct"||A!==null,V=g.useMemo(()=>_?l.find(ee=>ee.id===_)??null:null,[l,_]),[U,O]=g.useState([]),[P,q]=g.useState(new Set),[Z]=g.useState(()=>ax());g.useEffect(()=>{Me("/api/sessions").then(ee=>O(ee.sort((ge,xe)=>(xe.lastMessageAt??0)-(ge.lastMessageAt??0)))).catch(()=>{}),Me("/api/fleet").then(ee=>{const ge=new Set;for(const xe of ee.needsAttention)xe.conversationId&&ge.add(xe.conversationId),xe.agentId&&ge.add(xe.agentId);for(const xe of ee.activeAsks)xe.status==="needs_attention"&&xe.conversationId&&ge.add(xe.conversationId);q(ge)}).catch(()=>{})},[]);const H=g.useCallback(async()=>{N(null);try{const ee=await Me(`/api/session/${encodeURIComponent(e)}`).catch(()=>null);d(ee);const ge=ee?.agentId??A,xe=ee?.kind==="direct"&&ge&&ge.startsWith("local-session-agent-")?Dn(ge):e;if(xe!==e){s({view:"conversation",conversationId:xe,...t?{composeMode:t}:{}});return}const[Ze,We]=await Promise.all([Me(`/api/messages?conversationId=${encodeURIComponent(xe)}&limit=300`),Me(`/api/flights?conversationId=${encodeURIComponent(xe)}`)]);h(Rd(Ze)),w(We),E.current=new Set(We.map(dt=>dt.invocationId)),y(MZ(We))}catch(ee){N(ee instanceof Error?ee.message:String(ee))}},[e,t,A,s]);g.useEffect(()=>{H()},[H]);const[L,z]=g.useState(null),[B,X]=g.useState(!1);g.useEffect(()=>{if(!_)return;let ee=!1;return Me(`/api/agents/${encodeURIComponent(_)}/session-catalog`).then(ge=>{ee||z(ge)}).catch(()=>{}),()=>{ee=!0}},[_]),g.useEffect(()=>{S.current=m},[m]);const[W,I]=g.useState(()=>n??""),[F,G]=g.useState(!1),[J,ce]=g.useState("operator"),[se,ve]=g.useState({open:!1,query:"",triggerStart:-1,index:0}),[me,je]=g.useState({open:!1,query:"",triggerStart:-1,index:0}),[Ae,he]=g.useState(null),[ue,de]=g.useState(t==="ask"?"ask":"tell");g.useEffect(()=>{de($&&t==="ask"?"ask":"tell")},[e,t,$]),g.useEffect(()=>{if(!n)return;const ee=`${e}:${n}`;R.current!==ee&&(R.current=ee,I(n),requestAnimationFrame(()=>T.current?.focus()))},[e,n]);const Le=g.useMemo(()=>{const ee=new Set,ge=[];for(const xe of l){const Ze=xe.handle?.trim().replace(/^@+/,"")??Aa(xe.id)??xe.id;if(!Ze)continue;const We=Ze.toLowerCase();ee.has(We)||(ee.add(We),ge.push({id:xe.id,label:Ze,name:xe.name??Ze,handle:Ze}))}return ge.sort((xe,Ze)=>xe.handle.localeCompare(Ze.handle))},[l]),Te=g.useMemo(()=>{if(!se.open)return[];const ee=se.query.toLowerCase();return ee?MN.filter(ge=>ge.command.toLowerCase().startsWith("/"+ee)||ge.command.toLowerCase().includes(ee)):MN},[se.open,se.query]),we=g.useMemo(()=>{if(!me.open)return[];const ee=me.query.toLowerCase();return ee?Le.filter(ge=>ge.handle.toLowerCase().includes(ee)||ge.name.toLowerCase().includes(ee)).slice(0,8):Le.slice(0,8)},[me.open,me.query,Le]),Ne=g.useCallback(()=>{ve(ee=>ee.open?{...ee,open:!1}:ee),je(ee=>ee.open?{...ee,open:!1}:ee)},[]),_e=g.useCallback((ee,ge)=>{const xe=NZ(ee,ge);ve(xe?We=>({open:!0,query:xe.query,triggerStart:xe.start,index:We.open&&We.triggerStart===xe.start?We.index:0}):We=>We.open?{...We,open:!1}:We);const Ze=kZ(ee,ge);je(Ze?We=>({open:!0,query:Ze.query,triggerStart:Ze.start,index:We.open&&We.triggerStart===Ze.start?We.index:0}):We=>We.open?{...We,open:!1}:We)},[]),Fe=g.useCallback(ee=>{const ge=T.current,xe=se.triggerStart;if(xe<0)return;const Ze=ge?.selectionStart??W.length,We=W.slice(0,xe),dt=W.slice(Ze),Vt=ee.insert,Et=`${We}${Vt}${dt}`;I(Et),ve(mn=>({...mn,open:!1})),requestAnimationFrame(()=>{const mn=T.current;if(!mn)return;const bn=We.length+Vt.length;mn.focus(),mn.setSelectionRange(bn,bn)})},[W,se.triggerStart]),Ve=g.useCallback(ee=>{const ge=T.current,xe=me.triggerStart;if(xe<0)return;const Ze=ge?.selectionStart??W.length,We=W.slice(0,xe),dt=W.slice(Ze),Vt=dt.length===0||!dt.startsWith(" "),Et=`@${ee.handle}${Vt?" ":""}`,mn=`${We}${Et}${dt}`;I(mn),je(bn=>({...bn,open:!1})),requestAnimationFrame(()=>{const bn=T.current;if(!bn)return;const Ws=We.length+Et.length;bn.focus(),bn.setSelectionRange(Ws,Ws)})},[W,me.triggerStart]);g.useEffect(()=>{const ee=T.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"},[W]),g.useEffect(()=>{Me("/api/user").then(ee=>ce(ee.name)).catch(()=>{})},[]);const ie=g.useMemo(()=>_Z(p,J),[p,J]);g.useEffect(()=>{Ae===null||ie===null||ie>=Ae&&he(null)},[Ae,ie]);const ye=g.useMemo(()=>!m||zv.has(m.state)?!1:(es(m.startedAt)??Ae??Date.now())>=(ie??0),[Ae,m,ie]),be=F||Ae!==null||ye,ke=Kq({name:V?.name,agentName:u?.agentName,id:_,title:u?.title}),Ee=g.useMemo(()=>IZ({agentName:ke,agentState:V?.state??null,sending:F,currentFlight:m,showWorkingTurn:ye}),[V?.state,ke,m,F,ye]),Se=u?CZ(u):ke,Be=u?.kind?SZ[u.kind]??u.kind:"Conversation";LZ(u);const ze=EZ(u?.workspaceRoot),bt=u?.lastMessageAt??p[p.length-1]?.createdAt??null,kt=[ze?{label:ze,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:$?2:1,Xt=g.useMemo(()=>(!P.has(e)&&!(_&&P.has(_)),null),[e,_,P]);Mn(g.useCallback(ee=>{if(ee.kind==="message.posted"){const ge=ee.payload?.message;if(!ge||ge.conversationId!==e)return;const xe=ge.actorId===_,Ze={id:ge.id,conversationId:ge.conversationId,actorName:xe?ke:J,body:ge.body,createdAt:ge.createdAt,class:xe?ge.class:"operator"};if(h(We=>{if(We.some(dt=>dt.id===ge.id))return We;if(!xe){const dt=We.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=[...We];return Vt[dt]=Ze,Rd(Vt)}}return Rd([...We,Ze])}),xe){const We=es(ge.createdAt)??Date.now();he(dt=>dt===null||We<dt?dt:null),y(dt=>{if(!dt)return dt;const Vt=es(dt.startedAt)??0;return We>=Vt?null:dt})}return}if(ee.kind==="invocation.requested"){const ge=ee.payload?.invocation;if(!ge||ge.targetAgentId!==_||ge.conversationId!==e)return;E.current.add(ge.id),he(xe=>xe??Date.now());return}if(ee.kind==="flight.updated"){const ge=ee.payload?.flight;if(!ge||ge.targetAgentId!==_||!(E.current.has(ge.invocationId)||S.current?.id===ge.id))return;if(zv.has(ge.state)){y(Ze=>Ze?.id===ge.id?null:Ze),H();return}E.current.add(ge.invocationId),y(_N(ge,e,_??""));return}ee.kind!=="agent.endpoint.upserted"&&ee.kind==="unknown"&&H()},[_,ke,e,H,J])),g.useEffect(()=>{if(!be)return;const ee=setInterval(()=>{H()},5e3);return()=>clearInterval(ee)},[be,H]),g.useEffect(()=>{const ee=()=>{if(document.visibilityState!=="visible")return;const ge=Date.now();ge-M.current<1e3||(M.current=ge,H())};return window.addEventListener("focus",ee),document.addEventListener("visibilitychange",ee),()=>{window.removeEventListener("focus",ee),document.removeEventListener("visibilitychange",ee)}},[H]);const Jt=p.length+(Ee.showTyping?1:0),$e=g.useRef(0);g.useEffect(()=>{Jt>$e.current&&k.current?.scrollIntoView({behavior:"smooth"}),$e.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 xe=ee.trim();if(!xe||F)return;const Ze=ge?.forceMode??ue,We=$?be?"steer":Ze:"tell",dt=Date.now(),Vt={id:`optimistic-${dt}`,conversationId:e,actorName:J,body:xe,createdAt:dt,class:"operator"};G(!0),he(dt),N(null),h(Et=>Rd([...Et,Vt]));try{const Et=await Me(We==="ask"?"/api/ask":"/api/send",{method:"POST",body:JSON.stringify({body:xe,conversationId:e})});Et.flight&&(E.current.add(Et.flight.invocationId),y(_N(Et.flight,e,_??"")))}catch(Et){h(mn=>mn.filter(bn=>bn.id!==Vt.id)),he(null),N(Et instanceof Error?Et.message:String(Et))}finally{G(!1)}},gt=async()=>{const ee=W.trim();ee&&(I(""),await lt(ee))},Bt=async()=>{if(_)try{await Me("/api/agents/"+encodeURIComponent(_)+"/interrupt",{method:"POST",body:JSON.stringify({})})}catch{}},xn=Ee.tone==="working"||Ee.tone==="pending",Wt=$?be?"steer":ue:"tell",Rn=$?"Reply — or type / to route, @ to mention an agent, ? to ask a question":`Message ${ke}...`,dn=!W.trim()&&xn,fn=gh(),qs=g.useCallback((ee,ge)=>{const xe=window.getSelection()?.toString().trim(),Ze=[];xe&&(Ze.push({kind:"action",label:"Copy Selection",shortcut:"⌘C",onSelect:()=>navigator.clipboard.writeText(xe)}),Ze.push({kind:"separator"})),Ze.push({kind:"action",label:"Copy Message",onSelect:()=>navigator.clipboard.writeText(ge.body)}),ge.actorName&&!Lv(ge,J)&&Ze.push({kind:"action",label:"Copy Agent ID",onSelect:()=>navigator.clipboard.writeText(ge.actorName??"")}),Ze.push({kind:"separator"}),Ze.push({kind:"action",label:"Copy Message ID",onSelect:()=>navigator.clipboard.writeText(ge.id)}),fn(ee,Ze)},[J,fn]),Zs=async(ee,ge)=>{const xe=`@${ge.agentId} `,Ze=W.trim();if(Ze){I(""),await lt(`${xe}${Ze}`,{forceMode:"tell"});return}I(xe),T.current?.focus()},Mi=g.useMemo(()=>u?u.participantIds.filter(ee=>ee!=="operator").slice(0,4).map(ee=>{const ge=l.find(xe=>xe.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:()=>$?s({view:"agent-info",conversationId:e}):void 0,style:$?{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:Be}),bt&&o.jsx("span",{className:"s-thread-center-header-time",title:wg(bt),children:Pe(bt)})]})]}),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??Aa(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:()=>{T.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"})]}),Ee.showStrip&&o.jsxs("div",{className:`s-thread-status s-thread-status--${Ee.tone}`,"aria-live":"polite",children:[o.jsx("span",{className:"s-thread-status-dot",style:{background:DZ(Ee,V?.state??null)}}),o.jsxs("div",{className:"s-thread-status-copy",children:[o.jsx("span",{className:"s-thread-status-label",children:Ee.label}),o.jsx("span",{className:"s-thread-status-detail",children:Ee.detail})]})]}),!a&&$&&V&&(V.harnessSessionId||V.harnessLogPath||L?.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:[L?.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:L.activeSessionId,children:L.activeSessionId.slice(0,8)})]}),L?.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:L.resumeCommand,onClick:()=>{jZ(L.resumeCommand).then(()=>s({view:"terminal",agentId:_??void 0})),X(!0)},children:B?"Going…":`Takeover — ${L.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:$?"Use Tell for quick coordination or Ask for owned work with a reply.":"Start the thread below."})]}):p.map((ee,ge)=>{const xe=Lv(ee,J),Ze=RZ(ee),We=Ze?"scout.dispatch":ee.class,dt=AZ(We),Vt=We==="status",Et=ge===0||!TZ(p[ge-1]?.createdAt,ee.createdAt),mn=wg(ee.createdAt),bn=!xe&&ee.actorName?l.find(Ft=>Ft.name===ee.actorName)??null:null,Ws=xe?J.toLowerCase():bn?.handle??null;return o.jsxs("div",{className:["s-thread-feed-block",xe&&"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":RN(ee.createdAt),children:[o.jsx("span",{className:"s-thread-day-line","aria-hidden":"true"}),o.jsx("span",{className:"s-thread-day-label",children:RN(ee.createdAt)}),o.jsx("span",{className:"s-thread-day-line","aria-hidden":"true"})]}),o.jsx("article",{id:`msg-${ee.id}`,className:["s-thread-msg",xe&&"s-thread-msg--you",Vt&&"s-thread-msg--tool"].filter(Boolean).join(" "),"data-class":We,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(xe?J:ee.actorName??"?")},children:(xe?J[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:xe?J: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:Pe(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(OM,{text:ee.body})}),Ze&&Ze.candidates.length>0&&o.jsx("div",{className:"s-thread-dispatch",children:Ze.candidates.map(Ft=>o.jsxs("button",{type:"button",className:"s-thread-dispatch-tile",onClick:()=>{Zs(Ze,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)}),Ee.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(ke)},children:ke[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:ke}),o.jsx("span",{className:"s-thread-msg-kind",children:"Live"})]}),o.jsx("span",{className:"s-thread-msg-time",title:m?.startedAt?wg(m.startedAt):"now",children:m?.startedAt?Pe(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:Ee.detail})]})]})]})})}),o.jsx("div",{ref:k})]}),Ee.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(ke)},children:ke[0]?.toUpperCase()??"?"})}),o.jsxs("span",{className:"s-thread-presence-line-label",children:[ke," is ",Ee.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:[se.open&&Te.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"}),Te.map((ee,ge)=>o.jsxs("button",{type:"button",role:"option","aria-selected":ge===se.index,className:["s-thread-compose-suggest-item",ge===se.index&&"s-thread-compose-suggest-item--active"].filter(Boolean).join(" "),onMouseDown:xe=>{xe.preventDefault(),Fe(ee)},onMouseEnter:()=>ve(xe=>({...xe,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))]}),me.open&&we.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"}),we.map((ee,ge)=>o.jsxs("button",{type:"button",role:"option","aria-selected":ge===me.index,className:["s-thread-compose-suggest-item",ge===me.index&&"s-thread-compose-suggest-item--active"].filter(Boolean).join(" "),onMouseDown:xe=>{xe.preventDefault(),Ve(ee)},onMouseEnter:()=>je(xe=>({...xe,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:T,className:"s-thread-compose-input",placeholder:Rn,value:W,onChange:ee=>{const ge=ee.target.value;I(ge),_e(ge,ee.target.selectionStart)},onSelect:ee=>{const ge=ee.currentTarget;_e(ge.value,ge.selectionStart)},onBlur:()=>{setTimeout(Ne,120)},onKeyDown:ee=>{if(se.open&&Te.length>0||me.open&&we.length>0){if(ee.key==="ArrowDown"){ee.preventDefault(),se.open?ve(xe=>({...xe,index:(xe.index+1)%Te.length})):me.open&&je(xe=>({...xe,index:(xe.index+1)%we.length}));return}if(ee.key==="ArrowUp"){ee.preventDefault(),se.open?ve(xe=>({...xe,index:(xe.index-1+Te.length)%Te.length})):me.open&&je(xe=>({...xe,index:(xe.index-1+we.length)%we.length}));return}if(ee.key==="Escape"){ee.preventDefault(),Ne();return}if(ee.key==="Enter"||ee.key==="Tab"){if(ee.shiftKey)return;if(ee.preventDefault(),se.open){const xe=Te[se.index]??Te[0];xe&&Fe(xe)}else if(me.open){const xe=we[me.index]??we[0];xe&&Ve(xe)}return}}ee.key!=="Enter"||ee.shiftKey||ee.nativeEvent.isComposing||(ee.preventDefault(),!F&&W.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(zZ,{})}):o.jsx("button",{type:"submit",className:"s-thread-compose-send",disabled:F||!W.trim(),"aria-label":Wt==="ask"?"Ask agent":Wt==="steer"?"Steer agent":$?"Tell agent":"Send message",children:o.jsx(PZ,{})})]})]})})]})})}async function $Z(e){await fetch(Jc("terminalRunPath"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:e})})}const PM={think:"var(--dim)",tool:"var(--accent)",ask:"var(--amber)",message:"var(--muted)",note:"var(--green)",system:"var(--dim)",boot:"var(--dim)"},UZ={read:"◎",edit:"✎",bash:"$",grep:"⌕",write:"✎",think:"∿"},BZ=20,zM=new Intl.NumberFormat("en-US"),VZ=new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1});function FZ(e){const t=Math.floor(e/60),n=Math.floor(e%60);return`${String(t).padStart(2,"0")}:${String(n).padStart(2,"0")}`}function ON(e,t){return e>=Math.max(0,t-BZ)}function tc(e){return typeof e!="number"||!Number.isFinite(e)?null:zM.format(e)}function ua(e){return typeof e!="number"||!Number.isFinite(e)?"—":Math.abs(e)<1e3?zM.format(e):VZ.format(e).toLowerCase()}function HZ(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 IN(e){return!!e&&Object.keys(e).length>0}function jg(e){return e.filter(t=>!!t)}function qZ({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 ZZ({event:e}){const t=UZ[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(`
|
|
153
|
-
`)})]})}function WZ({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 YZ({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(OM,{text:e.text})})]})}function GZ({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 KZ({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 XZ(){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 JZ({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 QZ({event:e,prevT:t}){const n=e.t-t,s=PM[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:FZ(e.t)}),o.jsx("span",{className:"s-observe-row-bead",style:{background:s}}),e.kind==="think"&&o.jsx(qZ,{event:e}),e.kind==="tool"&&o.jsx(ZZ,{event:e}),e.kind==="ask"&&o.jsx(WZ,{event:e}),e.kind==="message"&&o.jsx(YZ,{event:e}),e.kind==="note"&&o.jsx(GZ,{event:e}),(e.kind==="system"||e.kind==="boot")&&o.jsx(KZ,{event:e})]})}function eW({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(QZ,{event:s,prevT:a>0?e[a-1].t:0},s.id)),o.jsx("div",{ref:n})]})}function tW({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 nW({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 Rr({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 Sg({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 sW({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:PM[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 DN(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 rW(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 aW({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,b)=>(b.endedAt??0)-(y.endedAt??0)).slice(0,5),p=e.activeSessionId??t,h=p?p.slice(0,8):null,m=g.useCallback(()=>{e.resumeCommand&&($Z(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 ",DN(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:[DN(y.startedAt),y.endedAt?` · ${rW(y.startedAt,y.endedAt)}`:""]})]},y.id))]})]})}const iW={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 LM({data:e,agentId:t,sessionId:n}){const s=e??iW,{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 Me(`/api/agents/${encodeURIComponent(t)}/session-catalog`).then(F=>{I||h(F)}).catch(()=>{}),()=>{I=!0}},[t]);const m=a.length>0?a[a.length-1].t+30:60,[y,b]=g.useState(m),[w,j]=g.useState(!1),[N,k]=g.useState(1),T=g.useRef(m);g.useEffect(()=>{b(I=>{const F=T.current;T.current=m;const G=ON(I,F);return I>m||G?m:I})},[m]),g.useEffect(()=>{if(!w)return;const I=setInterval(()=>{b(F=>{const G=F+N;return G>=m?(j(!1),m):G})},100);return()=>clearInterval(I)},[w,m,N]);const E=a.filter(I=>I.t<=y),S=d&&ON(y,m),M=d?S?"Following live":"Jump to live ↦":"Jump to end ↦",R=s.metadata,A=R?.session,_=R?.usage,$=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,P=a.filter(I=>I.kind==="tool"&&(I.tool==="edit"||I.tool==="write")).length,q=a.length>0?a[a.length-1].t:0,Z=u&&u.length>0?Math.round((u[u.length-1]??0)*100):null,H=[{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"),L=jg([typeof _?.assistantMessages=="number"?{label:"Assistant msgs",value:tc(_.assistantMessages)??"0",tone:"accent"}:null,typeof _?.webSearchRequests=="number"?{label:"Web search",value:tc(_.webSearchRequests)??"0"}:null,typeof _?.webFetchRequests=="number"?{label:"Web fetch",value:tc(_.webFetchRequests)??"0"}:null,_?.serviceTier?{label:"Service tier",value:_.serviceTier,tone:"good"}:null,_?.speed?{label:"Speed",value:_.speed}:null,_?.planType?{label:"Plan",value:_.planType}:null]),z=jg([typeof _?.contextWindowTokens=="number"?{label:"Model window",value:`${tc(_.contextWindowTokens)} tokens`,title:tc(_.contextWindowTokens)??void 0,tone:"accent"}:null,Z!==null?{label:"Derived load",value:`${Z}%`,tone:Z>=80?"warn":"default"}:null]),B=jg([A?.model?{label:"Model",value:A.model,tone:"accent"}:null,A?.adapterType?{label:"Adapter",value:A.adapterType}:null,A?.gitBranch?{label:"Branch",value:A.gitBranch}:null,A?.cwd?{label:"Workspace",value:A.cwd,title:A.cwd,wrap:!0}:null,A?.entrypoint?{label:"Entrypoint",value:A.entrypoint}:null,A?.cliVersion?{label:"CLI",value:A.cliVersion}:null,A?.permissionMode?{label:"Permissions",value:A.permissionMode}:null,A?.approvalPolicy?{label:"Approval",value:A.approvalPolicy}:null,A?.sandbox?{label:"Sandbox",value:A.sandbox}:null,A?.userType?{label:"User type",value:A.userType}:null,A?.originator?{label:"Originator",value:A.originator}:null,A?.modelProvider?{label:"Provider",value:A.modelProvider}:null,A?.effort?{label:"Effort",value:A.effort}:null,A?.timezone?{label:"Timezone",value:A.timezone}:null,A?.externalSessionId?{label:"External session",value:A.externalSessionId,title:A.externalSessionId,wrap:!0}:null,A?.threadId?{label:"Thread",value:A.threadId,title:A.threadId,wrap:!0}:null,A?.threadPath?{label:"Thread path",value:A.threadPath,title:A.threadPath,wrap:!0}:null,A?.source?{label:"Runtime source",value:A.source}:null]),X=IN(_),W=IN(A);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(XZ,{})}),o.jsx(eW,{events:E,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(aW,{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(Rr,{label:"Turns",value:ua(A?.turnCount??0)}),o.jsx(Rr,{label:"Tools",value:ua($)}),o.jsx(Rr,{label:"Thinks",value:ua(V)}),o.jsx(Rr,{label:"Asks",value:ua(U)}),o.jsx(Rr,{label:"Reads",value:ua(O)}),o.jsx(Rr,{label:"Edits",value:ua(P)}),o.jsx(Rr,{label:"Files",value:ua(l.length)}),o.jsx(Rr,{label:"Window",value:HZ(q)})]})]}),o.jsxs("div",{children:[o.jsx("div",{className:"s-observe-rail-label",children:"Context window"}),o.jsx(Sg,{rows:z}),u&&u.length>=2?o.jsxs(o.Fragment,{children:[o.jsx(tW,{data:u,cursor:y/m}),o.jsx("div",{className:"s-observe-ctx-detail",children:"Sparkline shows derived session load across the observed trace."})]}):z.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(nW,{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"}),H.length>0&&o.jsx("div",{className:"s-observe-stats s-observe-stats--usage",children:H.map(I=>o.jsx(Rr,{label:I.label,value:ua(I.value)},I.label))}),L.length>0?o.jsx(Sg,{rows:L}):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"}),B.length>0?o.jsx(Sg,{rows:B}):W?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:()=>{b(0),j(!1)},children:"⏮"}),o.jsx(sW,{events:a,duration:m,cursor:y,onCursor:b}),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(JZ,{liveSession:d,isLive:S}),o.jsx("button",{className:`s-observe-jump-btn${S?" s-observe-jump-btn--active":""}`,onClick:()=>b(m),children:M})]})]})}async function oW(e){await fetch(Jc("terminalRunPath"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:e})})}function lW(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 Lc(e){if(!e)return null;const t=e.replace(/_/g," ");return t.toLowerCase()==="relay agent"?"agent":t}function cW(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 uW({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&&(oW(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 ",Pe(u.startedAt)]})]})}function dW({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&&` · ${Pe(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}`,` · ${Pe(l.ts)}`]})]})]},l.id))]})}function dc({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 fW({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(dc,{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:Pe(l.createdAt)})]}),o.jsx("div",{className:"s-profile-signal-text",children:l.body})]})]},l.id)})})]})}function hW({agent:e,allAgents:t,session:n,conversationId:s,navigate:a,activeTab:l}){const{name:u,qualifier:d}=lW(e,t),[p,h]=g.useState([]),[m,y]=g.useState([]),[b,w]=g.useState(null),[j,N]=g.useState(null),[k,T]=g.useState(!1),[E,S]=g.useState(null),M=et(e.state),R=gh(),A=g.useCallback(async()=>{const[X,W]=await Promise.allSettled([Me(`/api/work?agentId=${encodeURIComponent(e.id)}`),Me("/api/fleet")]);X.status==="fulfilled"&&h(X.value),W.status==="fulfilled"&&w(W.value)},[e.id]),_=g.useCallback(async()=>{if(!s){y([]);return}try{const X=await Me(`/api/messages?conversationId=${encodeURIComponent(s)}&limit=20`);y(X)}catch{y([])}},[s]),$=g.useCallback(async()=>{T(!0);try{const X=await Me(`/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{T(!1)}},[e.id]);g.useEffect(()=>{A(),_(),Me(`/api/agents/${encodeURIComponent(e.id)}/session-catalog`).then(S).catch(()=>{})},[A,_,e.id]),g.useEffect(()=>{N(null),T(!1)},[e.id]),g.useEffect(()=>{l==="observe"&&$()},[l,$]),Mn(()=>{A(),_(),l==="observe"&&$()}),g.useEffect(()=>{if(l!=="observe"||!j?.data.live)return;const X=setInterval(()=>{$()},2500);return()=>clearInterval(X)},[l,j?.data.live,$]);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),P=Lc(e.role)??Lc(e.agentClass),q=e.harness,Z=[P,q].filter(Boolean).filter((X,W,I)=>I.indexOf(X)===W),H=g.useMemo(()=>t.filter(X=>X.project===e.project).length,[t,e.project]),L=V?.currentPhase==="review"?85:V?.currentPhase==="working"?50:20,z=[{key:"profile",label:"Profile"},{key:"observe",label:"Observe"},{key:"message",label:"Message",disabled:!s}],B=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 W=window.getSelection()?.toString().trim(),I=[];W&&(I.push({kind:"action",label:"Copy Selection",shortcut:"⌘C",onSelect:()=>navigator.clipboard.writeText(W)}),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}`)}),R(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--${M}`,style:{background:Ur(e.state)}})]}),o.jsxs("div",{className:"s-profile-identity-copy",children:[Z.length>0&&o.jsx("div",{className:"s-profile-identity-eyebrow",children:Z.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${M==="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:["— ",Pe(e.updatedAt)]})]})})]}),o.jsx("nav",{className:"s-profile-tabs",children:z.map(X=>o.jsx("button",{type:"button",className:`s-profile-tab${l===X.key?" s-profile-tab--active":""}`,disabled:X.disabled,onClick:()=>B(X.key),children:X.label},X.key))})]})}),l==="profile"&&o.jsxs("div",{className:"s-profile-tab-content",children:[(e.project||e.branch||e.cwd||E?.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}),H>1&&o.jsxs("div",{className:"s-profile-facet-detail",children:[H," 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 ",Pe(e.updatedAt)]})]}),E?.activeSessionId&&o.jsx(uW,{catalog:E,agentId:e.id})]}),V&&M==="working"&&o.jsxs(o.Fragment,{children:[o.jsx(dc,{label:"Current task",right:`${L}% · 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:`${L}%`}})}),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:Pe(V.lastMeaningfulAt)})]})]})]}),U.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(dc,{label:"Active work",right:`${U.length} in flight`}),o.jsx("div",{className:"s-profile-work",children:o.jsx(TN,{items:U,navigate:a,emptyTitle:"Nothing in flight"})})]}),O.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(dc,{label:U.length>0?"Recently completed":"Recent work",right:`${O.length}`}),o.jsx("div",{className:"s-profile-work",children:o.jsx(TN,{items:O,navigate:a,emptyTitle:""})})]}),o.jsx(dc,{label:"Activity"}),o.jsx("div",{className:"s-profile-work",children:o.jsx(dW,{agent:e,fleet:b,navigate:a})}),o.jsx(fW,{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(LM,{data:j?.data,agentId:e.id,sessionId:j?.sessionId})}),l==="message"&&s&&o.jsx("div",{className:"s-profile-tab-conversation",children:o.jsx($v,{conversationId:s,navigate:a,embedded:!0})})]})}function pW({navigate:e,selectedAgentId:t,conversationId:n,tab:s}){const{agents:a}=Nt(),[l,u]=g.useState([]),d=g.useCallback(async()=>{const y=await Me("/api/sessions").catch(()=>null);y&&u(y)},[]);g.useEffect(()=>{d()},[d]),Mn(()=>{d()});const p=t?a.find(y=>y.id===t)??null:null,{conversationByAgentId:h,sessionByAgentId:m}=cW(l);if(p){const y=n??h.get(p.id)??p.conversationId??null,b=s??(n?"message":"profile");return o.jsx(hW,{agent:p,allAgents:a,session:m.get(p.id)??null,conversationId:y,navigate:e,activeTab:b})}return o.jsx(gW,{agents:a,sessionByAgentId:m,conversationByAgentId:h,navigate:e})}const $M="—";function mW(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??$M,b=u.get(y)??[];b.push(m),u.set(y,b)}const d=Array.from(u.entries()).map(([m,y])=>{const b=y.filter(Uv).length;return{name:m,agents:y,online:b,kind:b>0?"active":"idle"}}),p=new Set(["main","master","trunk"]);d.sort((m,y)=>{const b=p.has(m.name),w=p.has(y.name);return b!==w?b?-1:1:m.name.localeCompare(y.name)});for(const m of d)m.agents.sort((y,b)=>y.name.localeCompare(b.name));const h=a.reduce((m,y)=>{const b=y.updatedAt;return b&&(m===null||b>m)?b:m},null);n.push({key:s,name:s,path:l,branches:d,totalAgents:a.length,totalOnline:a.filter(Uv).length,lastActivityAt:h})}return n.sort((s,a)=>s.name.localeCompare(a.name)),n}function gW({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(()=>mW(e),[e]),l=e.filter(Uv).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(vW,{repo:p,sessionByAgentId:t,conversationByAgentId:n,navigate:s,viewMode:u},p.key))})]})}function vW({repo:e,sessionByAgentId:t,conversationByAgentId:n,navigate:s,viewMode:a}){const[l,u]=g.useState(()=>e.branches[0]?.name??$M),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:Pe(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(yW,{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 Uv(e){return et(e.state)!=="offline"}function yW({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(xW,{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(bW,{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(wW,{agent:u,session:t.get(u.id)??null,onClick:l(u)},u.id))})}function xW({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=Lc(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:Pe(l)})]})}function bW({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(Lc).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:Pe(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 wW({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=Lc(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(`
|
|
154
|
-
`),children:[o.jsx("span",{className:"s-agent-log-time",children:l?Pe(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 jW(e){return e<5?"Still up":e<12?"Good morning":e<18?"Good afternoon":"Good evening"}function nc(e){return e.status==="fulfilled"?null:e.reason instanceof Error?e.reason.message:String(e.reason)}function SW(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 NW(e){const t=(e.title??e.summary??"").trim().toLowerCase();return`${e.conversationId??"global"}:${t}`}function kW(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 EW(e,t=12){const n=e.map(l=>({item:l,rank:SW(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=NW(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 PN({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([]),[b,w]=g.useState("trailing 7d"),[j,N]=g.useState("3h buckets"),[k,T]=g.useState(!0),[E,S]=g.useState(!1),[M,R]=g.useState(null),[A,_]=g.useState(null),$=g.useRef(null),V=g.useRef(0),U=g.useRef(0),O=g.useRef(null);g.useEffect(()=>{O.current=p},[p]);const P=g.useCallback(async(ue="initial")=>{const de=++V.current;!(O.current!==null)&&ue!=="background"?(T(!0),R(null)):S(!0);const[Te,we,Ne,_e,Fe]=await Promise.allSettled([Me("/api/activity"),Me("/api/sessions"),Me("/api/fleet"),Me("/api/heartrate"),s()]);if(de!==V.current)return;Te.status==="fulfilled"&&l(Te.value),we.status==="fulfilled"&&d([...we.value].sort((ie,ye)=>(ye.lastMessageAt??0)-(ie.lastMessageAt??0))),Ne.status==="fulfilled"&&(O.current=Ne.value,h(Ne.value)),_e.status==="fulfilled"&&(y(_e.value.buckets),w(_e.value.windowLabel),N(_e.value.bucketLabel??""));const Ve=[nc(Te),nc(we),nc(Ne),nc(_e),nc(Fe)].filter(ie=>!!ie);R(Ve[0]??null),Ve.length<5&&_(Date.now()),T(!1),S(!1)},[s]),q=g.useCallback(()=>{$.current||($.current=setTimeout(()=>{$.current=null,P("background")},250))},[P]);g.useEffect(()=>(P(),()=>{$.current&&clearTimeout($.current)}),[P]),Mn(q),g.useEffect(()=>{const ue=setInterval(()=>{document.visibilityState==="visible"&&P("background")},15e3);return()=>clearInterval(ue)},[P]),g.useEffect(()=>{const ue=()=>{if(document.visibilityState!=="visible")return;const de=Date.now();de-U.current<1e3||(U.current=de,P("background"))};return window.addEventListener("focus",ue),document.addEventListener("visibilitychange",ue),()=>{window.removeEventListener("focus",ue),document.removeEventListener("visibilitychange",ue)}},[P]);const Z=g.useMemo(()=>t.filter(ue=>et(ue.state)==="working"),[t]),H=g.useMemo(()=>t.filter(ue=>et(ue.state)==="available"),[t]),L=g.useMemo(()=>t.filter(ue=>et(ue.state)==="offline"),[t]),z=g.useMemo(()=>(p?.activeAsks??[]).filter(ue=>ue.status==="needs_attention"||ue.status==="failed"),[p]),B=g.useMemo(()=>(p?.activeAsks??[]).filter(ue=>ue.status==="queued"||ue.status==="working"),[p]),X=g.useMemo(()=>p?.needsAttention??[],[p]),W=g.useMemo(()=>{const ue=new Map;for(const de of B){const Le=ue.get(de.agentId);(!Le||de.updatedAt>Le.updatedAt)&&ue.set(de.agentId,de)}return ue},[B]),I=g.useMemo(()=>B.filter(ue=>!Z.some(de=>de.id===ue.agentId)),[Z,B]),F=z.length+X.length,G=g.useMemo(()=>{const ue=[...z.map(de=>de.updatedAt),...X.map(de=>de.updatedAt)];return ue.length>0?Math.min(...ue):null},[z,X]),J=g.useMemo(()=>EW(a),[a]),ce=J.length===0?"quiet":`latest ${J.length} signal${J.length===1?"":"s"}`,se=new Date,ve=jW(se.getHours()),me=Xc(),je=n?.operatorName?.trim()||n?.operatorNameSuggestion?.trim()||"operator",Ae=g.useMemo(()=>{const ue=[];return Z.length>0&&ue.push(`${Z.length} agent${Z.length===1?" is":"s are"} working now`),H.length>0&&ue.push(`${H.length} agent${H.length===1?" is":"s are"} available`),F>0&&ue.push(`${F} thing${F===1?"":"s"} need${F===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},[Z,H,F,t]),he=k?"syncing":M?`sync issue · ${A?Pe(A):"waiting"}`:A?`updated ${Pe(A)}`:"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 ·"," ",se.toLocaleDateString([],{weekday:"long",month:"short",day:"numeric"}),o.jsx("span",{className:`s-fleet-sync-note${M?" s-fleet-sync-note--error":""}`,children:he})]}),o.jsxs("h1",{className:"s-hero-greeting",children:[ve,", ",o.jsxs("em",{children:[je,"."]})]}),o.jsxs("p",{className:"s-hero-narrative",children:[Ae.map((ue,de)=>o.jsxs("span",{children:[de>0&&", ",ue.includes("need")?o.jsx("span",{className:"s-hero-warn",children:ue}):o.jsx("strong",{children:ue})]},de)),"."]}),o.jsxs("div",{className:"s-hero-actions",children:[F>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 · ",F]}),me&&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||E,onClick:()=>{P("manual")},children:[o.jsx(Ak,{"aria-hidden":"true",size:12,strokeWidth:2,className:E?"s-refresh-spin":void 0}),o.jsx("span",{children:E?"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:["● ",b,j?` · ${j}`:""]})]}),o.jsx(TW,{buckets:m}),o.jsxs("div",{className:"s-heartrate-stats",children:[o.jsx(Ng,{label:"Active",value:Z.length,color:"var(--green)"}),o.jsx(Ng,{label:"Waiting",value:H.length,color:"var(--amber)"}),o.jsx(Ng,{label:"Offline",value:L.length,color:"var(--dim)"})]})]})]}),o.jsxs("div",{className:"s-fleet-section",id:"home-needs-you",children:[o.jsx(kg,{label:`Needs you · ${F}`,right:F>0&&G!==null?o.jsxs("span",{style:{color:"var(--amber)"},children:["oldest ",Pe(G)]}):"clear"}),z.length>0&&o.jsx("div",{className:"s-ask-grid",children:z.slice(0,4).map(ue=>o.jsx(MW,{ask:ue,agents:t,navigate:e,operatorName:je,pending:!0},ue.invocationId))}),X.length>0&&o.jsx("div",{className:"s-attention-list",children:X.map(ue=>o.jsx(RW,{item:ue,navigate:e},ue.recordId))}),F===0&&o.jsx(AW,{agents:t,activeCount:Z.length,waitingCount:H.length,offlineCount:L.length,navigate:e})]}),(Z.length>0||I.length>0)&&o.jsxs("div",{className:"s-fleet-section",children:[o.jsx(kg,{label:`What's moving · ${Z.length+I.length}`,right:o.jsx("button",{className:"s-link-btn",onClick:()=>e({view:"mesh"}),children:"open mesh ↗"})}),Z.length>0&&o.jsx("div",{className:"s-now-grid",style:{gridTemplateColumns:`repeat(${Math.min(Z.length,3)}, 1fr)`},children:Z.map(ue=>o.jsx(_W,{agent:ue,ask:W.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(OW,{ask:ue,navigate:e},ue.invocationId))})]}),J.length>0&&o.jsxs("div",{className:"s-fleet-section",children:[o.jsx(kg,{label:"Since you were away",right:ce}),o.jsx(IW,{items:J,agents:t,navigate:e})]})]})})}function CW(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 TW({buckets:e}){const u=e.length;if(u<2||e.every(b=>b.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((b,w)=>({x:w*p,y:60-Math.max(0,Math.min(1,b.value))*54})),m=CW(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 Ng({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 kg({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 AW({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(Eg,{label:"Working",value:t,color:"var(--green)"}),o.jsx(Eg,{label:"Available",value:n,color:"var(--accent)"}),o.jsx(Eg,{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?Pe(u.updatedAt):"no heartbeat"})]},u.id)})}):o.jsx("div",{className:"s-fleet-clear-empty",children:"No roster entries."})]})}function Eg({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 MW({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:Pe(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 RW({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:Pe(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 _W({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 ${Pe(e.updatedAt)}`:"active"}),o.jsx("span",{children:l})]})]})}function OW({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:Pe(e.updatedAt)})]})}function IW({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=kW(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:Pe(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 DW=g.lazy(()=>Zd(()=>import("./arc.es-B2XMIUBi.js"),[]).then(e=>({default:e.ArcDiagram})));function yi(e){if(!e)return"";const t=e.replace(/^https?:\/\//,"").split("/")[0],[n]=t.split(":");return n.split(".")[0]}function PW(e){const t=e.hostName?.trim();if(t&&t.toLowerCase()!=="localhost")return yi(t)||t;const n=e.dnsName?.trim().replace(/\.$/,"");return n?yi(n)||n:yi(e.name)||e.name}function Bv(e){if(!e)return"";const t=e.replace(/^https?:\/\//,"").split("/")[0],[n]=t.split(":");return n.replace(/\.$/,"").toLowerCase()}function va(e){const t=Bv(e);return t?t.split(".")[0]??t:""}function zW(e){return e.brokerUrl?yi(e.brokerUrl):e.hostName?yi(e.hostName):e.id.slice(0,10)}function LW(e,t){return Math.abs(e)>=Math.abs(t)?e>=0?["right","left"]:["left","right"]:t>=0?["bottom","top"]:["top","bottom"]}function $W(e,t){const n=va(t.hostName||t.name),s=va(e.localNode?.hostName||e.localNode?.name);return!!s&&n===s}function UW(e,t){const n=new Set([va(e.hostName),va(e.name),...e.addresses.map(a=>Bv(a)),...e.addresses.map(a=>va(a))].filter(Boolean)),s=new Set([va(t.hostName),va(t.name),Bv(t.brokerUrl),va(t.brokerUrl)].filter(Boolean));for(const a of n)if(s.has(a))return!0;return!1}function BW(e){if(!e.localNode)return null;const t=e.localNode.id,n=Object.values(e.nodes).filter(b=>b.id!==t),s=e.tailscale.peers.filter(b=>!$W(e,b)).filter(b=>!n.some(w=>UW(b,w))),a=[...n.map(b=>({kind:"mesh",peer:b})),...s.map(b=>({kind:"tailnet",peer:b}))],l=800,u=300,d=l/2,p=u/2,h={[t]:{x:d,y:p,size:"m"}},m={[t]:{icon:"Database",name:yi(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 b=a.length,w=Math.min(170,100+b*10);a.forEach(({kind:j,peer:N},k)=>{const T=k/b*Math.PI*2-Math.PI/2,E=Math.round(d+w*Math.cos(T)),S=Math.round(p+w*Math.sin(T)),M=j==="mesh"?N.id:`tailnet:${N.id}`,R=j==="mesh"?yi(N.hostName)||N.name||"peer":PW(N)||"tailnet",A=j==="mesh"?zW(N):N.online?N.addresses[0]??"tailnet only":"tailnet offline";h[M]={x:E,y:S,size:j==="mesh"?"m":"s"},m[M]={icon:j==="mesh"?"Database":"CircleDashed",name:R,subtitle:A,color:j==="mesh"?N.advertiseScope==="mesh"?"emerald":"zinc":N.online?"sky":"zinc"};const[_,$]=LW(E-d,S-p);y.push({from:t,to:M,fromAnchor:_,toAnchor:$,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 VW({mesh:e}){const t=g.useMemo(()=>BW(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(DW,{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 FW(e){return e.code==="local_only"?"notice":e.severity==="error"?"error":"warning"}function HW(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 qW(e){return e?e.replace(/^https?:\/\//,"").split("/")[0]??e:"Unavailable"}function ZW(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 WW(e){return e==="mesh"?"Announced to mesh":e==="local"?"Local only":e||"Not advertised"}function YW(e){return e.identity.discoverable?"success":e.health.reachable?"warning":"danger"}function GW(e){return e.identity.discoverable?"Discoverable":e.health.reachable?"Not discoverable":"Broker offline"}function KW(e){return!e.health.reachable||e.issues.some(t=>t.severity==="error")?"danger":e.issues.length>0?"warning":"success"}function XW(e){return e.health.reachable?e.issues.some(t=>t.severity==="error")?"Degraded":e.issues.length>0?"Needs attention":"Healthy":"Broker unreachable"}function JW({issue:e}){const t=FW(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:HW(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 QW({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,b]=g.useState(null),[w,j]=g.useState(null),[N,k]=g.useState(null),[T,E]=g.useState(null),S=g.useRef(null),M=g.useRef(0);g.useEffect(()=>{S.current=t},[t]);const R=g.useCallback(async(z="initial")=>{const B=++M.current;!(S.current!==null)&&z!=="background"?(a(!0),k(null)):u(!0);try{const W=await Me("/api/mesh");if(B!==M.current)return;n(W),k(null),E(Date.now())}catch(W){if(B!==M.current)return;k(W instanceof Error?W.message:String(W))}finally{B===M.current&&(a(!1),u(!1))}},[]);g.useEffect(()=>{R("initial")},[R]),g.useEffect(()=>{const z=setInterval(()=>{R("background")},1e4);return()=>clearInterval(z)},[R]);const A=g.useCallback(async()=>{p(!0),b(null);try{const z=await Me("/api/mesh/announce",{method:"POST",body:"{}"});n(z),S.current=z,k(null),E(Date.now()),b({tone:z.identity.discoverable?"success":"warning",title:z.identity.discoverable?"Mesh updated.":"Mesh updated, but still needs attention.",message:z.identity.discoverable?"This broker is now announced to the mesh.":"Mesh visibility was updated, but this broker still is not peer-reachable."})}catch(z){b({tone:"warning",title:"Could not announce broker.",message:z instanceof Error?z.message:String(z)})}finally{p(!1)}},[]),_=g.useCallback(async()=>{m(!0),j(null);try{const z=await Me("/api/mesh/tailscale",{method:"POST",body:JSON.stringify({action:"open_app"})});n(z),S.current=z,k(null),E(Date.now()),j({tone:z.tailscale.running?"success":"warning",title:z.tailscale.running?"Tailscale is running.":"Tailscale launch requested.",message:z.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(z){j({tone:"warning",title:"Could not open Tailscale.",message:z instanceof Error?z.message:String(z)})}finally{m(!1)}},[]),$=t?KW(t):"warning",V=t?XW(t):"Loading",U=t?Object.values(t.nodes):[],O=t?.localNode?.id,P=t?.localNode?.hostName?.toLowerCase(),q=U.filter(z=>z.id!==O),Z=(t?.tailscale.peers??[]).filter(z=>{const B=z.hostName?.toLowerCase();return!B||B==="localhost"?!0:!(P&&(B===P||B.startsWith(`${P.split(".")[0]}.`)))}),H=t?t.issues.length>0?t.issues:t.warnings.map((z,B)=>({code:`fallback-${B}`,severity:"warning",title:"Mesh notice",summary:z,action:null,actionCommand:null})):[],L=g.useMemo(()=>t?[{label:"Broker",value:t.health.reachable?"Reachable":"Unavailable",detail:t.health.error??qW(t.brokerUrl)},{label:"Discoverable",value:t.identity.discoverable?"Yes":"No",detail:t.identity.modeLabel},{label:"Mesh peers",value:`${q.length}`,detail:q.length>0?"Remote brokers in this mesh":"No remote brokers discovered"},{label:"Tailnet",value:t.tailscale.available?t.tailscale.running?`${Z.filter(z=>z.online).length}/${Z.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"}]:[],[Z,t,q.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-${$}`,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 ${T?Pe(T):"earlier"}`:T?`Confirmed ${Pe(T)}`:"Waiting for first snapshot"}),o.jsx("button",{type:"button",className:"s-btn",disabled:s||l,onClick:()=>{R("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:()=>{R("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-${YW(t)}`,children:GW(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:()=>{R("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:()=>{A()},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:L.map(z=>o.jsxs("div",{className:"sys-stat-card",children:[o.jsx("span",{className:"sys-stat-label",children:z.label}),o.jsx("strong",{className:"sys-stat-value",children:z.value}),o.jsx("span",{className:"sys-stat-detail",children:z.detail})]},z.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."})]})}),H.length>0?o.jsx("div",{className:"sys-issue-grid",children:H.map((z,B)=>o.jsx(JW,{issue:z},`${z.code}-${B}`))}):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(VW,{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","."]})]})}),q.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:q.map(z=>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:z.name}),o.jsx("span",{className:`sys-chip sys-chip-${z.advertiseScope==="mesh"?"success":"neutral"}`,children:WW(z.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:z.id})]}),z.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:z.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:z.lastSeenAt?Pe(z.lastSeenAt):"Recently registered"})]})]},z.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."})]})}),Z.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:Z.map(z=>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:ZW(z)}),o.jsx("span",{className:`sys-chip sys-chip-${z.online?"success":"failed"}`,children:z.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:z.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:z.os??"Unknown"})]})]},z.id))})]})]})]})}const eY=[[/```[\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 tY(e,t=140){if(!e)return"";let n=e;for(const[s,a]of eY)n=n.replace(s,a);return n=n.replace(/\s+/g," ").trim(),n.length>t&&(n=`${n.slice(0,t-1)}…`),n}function nY(){const e=window.getSelection();return e!==null&&e.toString().trim().length>0}function sY(e){nY()||e()}const zN={direct:"DM",channel:"Channel",group_direct:"Group",thread:"Thread"},rY=new Set(["all","direct","channel","group_direct","thread"]);function Vv(e){return typeof window>"u"?"":new URLSearchParams(window.location.search).get(e)??""}function aY(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 iY(){const e=Vv("view");return rY.has(e)?e:"all"}function oY(e){return e.kind==="direct"&&e.agentName?e.agentName:e.title.replace(/\s*<>\s*/g," · ")}function lY(e){return e.trim().toLowerCase()}function cY(e){return[e.id,e.title,e.preview??"",e.agentName??"",e.harness??"",e.harnessSessionId??"",e.harnessLogPath??"",...e.participantIds]}function LN(e,t){if(!t)return null;const n=e.harnessSessionId?.trim();return n&&n.toLowerCase().includes(t)?n:null}function uY(e){if(!e)return null;const t=e.replace(/[\\/]+$/,"");return t?t.split(/[\\/]/).filter(Boolean).at(-1)??t:null}function dY(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 fY({navigate:e}){const[t,n]=g.useState([]),[s,a]=g.useState(()=>iY()),[l,u]=g.useState(()=>Vv("q")),[d,p]=g.useState(()=>Vv("unread")==="1"),[h,m]=g.useState(()=>ax()),[y,b]=g.useState(0),[w,j]=g.useState(null),N=g.useRef(null),k=g.useRef(null),T=gh(),E=g.useCallback(async()=>{j(null);try{const P=await Me("/api/sessions");n(P.sort((q,Z)=>(Z.lastMessageAt??0)-(q.lastMessageAt??0)))}catch(P){j(P instanceof Error?P.message:String(P))}},[]);g.useEffect(()=>{E()},[E]),Mn(()=>{E()});const[,S]=g.useState(0);g.useEffect(()=>{const P=setInterval(()=>S(q=>q+1),15e3);return()=>clearInterval(P)},[]),g.useEffect(()=>{aY({view:s==="all"?null:s,q:l.trim()||null,unread:d?"1":null})},[s,l,d]);const M=g.useMemo(()=>Array.from(new Set(t.map(P=>P.kind))),[t]),R=g.useMemo(()=>{const P={all:t.length};for(const q of t)P[q.kind]=(P[q.kind]??0)+1;return P},[t]),A=g.useMemo(()=>lY(l),[l]),_=g.useMemo(()=>t.filter(P=>bg(P.lastMessageAt,P.id,h)).length,[t,h]),$=g.useMemo(()=>t.filter(P=>!(s!=="all"&&P.kind!==s||d&&!bg(P.lastMessageAt,P.id,h)||A&&!cY(P).some(Z=>Z.toLowerCase().includes(A)))),[t,s,d,h,A]);g.useEffect(()=>{y>=$.length&&b(Math.max(0,$.length-1))},[$.length,y]);const V=g.useCallback((P,q={})=>{if(m(wZ(P.id)),q.observe&&P.agentId){e({view:"agents",agentId:P.agentId,conversationId:P.id,tab:"observe"});return}e({view:"conversation",conversationId:P.id})},[e]);g.useEffect(()=>{function P(q){const Z=q.target,H=Z instanceof HTMLInputElement||Z instanceof HTMLTextAreaElement||Z instanceof HTMLElement&&Z.isContentEditable;if((q.metaKey||q.ctrlKey)&&q.key.toLowerCase()==="k"){q.preventDefault(),N.current?.focus(),N.current?.select();return}if(H){q.key==="Escape"&&Z===N.current&&N.current?.blur();return}if(q.key==="/"){q.preventDefault(),N.current?.focus();return}if(q.key==="j"||q.key==="ArrowDown"){q.preventDefault(),b(L=>Math.min($.length-1,L+1));return}if(q.key==="k"||q.key==="ArrowUp"){q.preventDefault(),b(L=>Math.max(0,L-1));return}if(q.key==="Enter"||q.key==="o"){const L=$[y];L&&(q.preventDefault(),V(L,{observe:!!LN(L,A)}))}}return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[$,y,V,A]),g.useEffect(()=>{k.current?.querySelector(`[data-idx="${y}"]`)?.scrollIntoView({block:"nearest"})},[y]);const U=M.length>1,O=d?_>0?`${_} unread threads need attention.`:"No unread threads right now.":$.length===t.length?"Recent activity across every conversation.":`${$.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:[$.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($N,{label:"All",count:R.all,pressed:s==="all",onClick:()=>a("all")}),M.map(P=>o.jsx($N,{label:zN[P]??P,count:R[P]??0,pressed:s===P,onClick:()=>a(P)},P))]}),o.jsxs("button",{type:"button",className:`s-seg-standalone${d?" is-on":""}`,onClick:()=>p(P=>!P),"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:P=>u(P.target.value),onKeyDown:P=>{P.key==="Escape"&&(l?u(""):P.target.blur())}}),o.jsx("kbd",{className:"s-search-kbd",children:"⌘K"})]})]}),w&&o.jsx("p",{className:"s-error",children:w}),$.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:$.map((P,q)=>{const Z=oY(P),H=(P.agentName??Z)[0]?.toUpperCase()??"?",L=bg(P.lastMessageAt,P.id,h),z=q===y,B=tY(P.preview,160),X=zN[P.kind]??P.kind,W=uY(P.workspaceRoot),I=LN(P,A);return o.jsxs("div",{"data-idx":q,"data-unread":L?"true":"false","data-selected":z?"true":"false",className:"s-inbox-row",role:"option","aria-selected":z,tabIndex:z?0:-1,onClick:()=>{sY(()=>{b(q),V(P,{observe:!!I})})},onMouseEnter:()=>b(q),onContextMenu:F=>{const G=window.getSelection()?.toString().trim(),J=[];G&&(J.push({kind:"action",label:"Copy Selection",shortcut:"⌘C",onSelect:()=>navigator.clipboard.writeText(G)}),J.push({kind:"separator"})),J.push({kind:"action",label:"Open Conversation",onSelect:()=>V(P)}),P.agentId&&J.push({kind:"action",label:"Open Observe",onSelect:()=>V(P,{observe:!0})}),J.push({kind:"action",label:"Copy Title",onSelect:()=>navigator.clipboard.writeText(Z)}),P.id&&J.push({kind:"action",label:"Copy Conversation ID",onSelect:()=>navigator.clipboard.writeText(P.id)});const ce=P.harnessSessionId;ce&&J.push({kind:"action",label:"Copy Harness Session ID",onSelect:()=>navigator.clipboard.writeText(ce)}),T(F,J)},children:[o.jsxs("div",{className:"s-session-avatar-wrap",children:[o.jsx("div",{className:"s-avatar",style:{background:mt(P.agentName??Z)},"aria-hidden":"true",children:H}),L&&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:Z,children:Z})}),o.jsx("div",{className:"s-session-trailing",children:P.lastMessageAt&&o.jsx("span",{className:"s-inbox-time s-tabular",title:dY(P.lastMessageAt),children:Pe(P.lastMessageAt)})})]}),B?o.jsx("p",{className:"s-inbox-preview",children:B}):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]}),W&&o.jsx("span",{className:"s-session-pill",title:P.workspaceRoot??void 0,children:W}),P.currentBranch&&o.jsx("span",{className:"s-session-pill",title:P.currentBranch,children:P.currentBranch})]})]})]},P.id)})})]})]})}function $N({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 li=(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))(li||{});const hY=[0,1],UM=[1,0],BM=[2,3],VM=[3,2],pY={L:hY,M:UM,Q:BM,H:VM},mY=/^\d*$/,gY=/^[A-Z0-9 $%*+./:-]*$/,Cg="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",ix=1,ox=40,UN=3,vY=3,_d=40,yY=10,FM=[[-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]],HM=[[-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 xY{constructor(t,n,s,a){if(this.version=t,this.ecc=n,t<ix||t>ox)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,li.Timing),this.setFunctionModule(s,6,s%2===0,li.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,li.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,li.Alignment)}setFunctionModule(t,n,s,a=li.Function){this.modules[n][t]=s,this.types[n][t]=a}addEccAndInterleave(t){const n=this.version,s=this.ecc;if(t.length!==rf(n,s))throw new RangeError("Invalid argument");const a=HM[s[0]][n],l=FM[s[0]][n],u=Math.floor(Fv(n)/8),d=a-u%a,p=Math.floor(u/a),h=[],m=TY(l);for(let b=0,w=0;b<a;b++){const j=t.slice(w,w+p-l+(b<d?0:1));w+=j.length;const N=AY(j,m);b<d&&j.push(0),h.push(j.concat(N))}const y=[];for(let b=0;b<h[0].length;b++)h.forEach((w,j)=>{(b!==p-l||j>=d)&&y.push(w[b])});return y}drawCodewords(t){if(t.length!==Math.floor(Fv(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+=UN:d>5&&t++):(this.finderPenaltyAddHistory(d,p),u||(t+=this.finderPenaltyCountPatterns(p)*_d),u=this.modules[l][h],d=1);t+=this.finderPenaltyTerminateAndCount(u,d,p)*_d}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+=UN:d>5&&t++):(this.finderPenaltyAddHistory(d,p),u||(t+=this.finderPenaltyCountPatterns(p)*_d),u=this.modules[h][l],d=1);t+=this.finderPenaltyTerminateAndCount(u,d,p)*_d}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+=vY)}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*yY,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 lx{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 bY=[1,10,12,14],wY=[2,9,11,13],jY=[4,8,16,16];function qM(e,t){return e[Math.floor((t+7)/17)+1]}function ZM(e){const t=[];for(const n of e)zr(n,8,t);return new lx(jY,e.length,t)}function SY(e){if(!WM(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 lx(bY,e.length,t)}function NY(e){if(!YM(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=Cg.indexOf(e.charAt(n))*45;s+=Cg.indexOf(e.charAt(n+1)),zr(s,11,t)}return n<e.length&&zr(Cg.indexOf(e.charAt(n)),6,t),new lx(wY,e.length,t)}function kY(e){return e===""?[]:WM(e)?[SY(e)]:YM(e)?[NY(e)]:[ZM(CY(e))]}function WM(e){return mY.test(e)}function YM(e){return gY.test(e)}function EY(e,t){let n=0;for(const s of e){const a=qM(s.mode,t);if(s.numChars>=1<<a)return Number.POSITIVE_INFINITY;n+=4+a+s.bitData.length}return n}function CY(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 Fv(e){if(e<ix||e>ox)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 rf(e,t){return Math.floor(Fv(e)/8)-FM[t[0]][e]*HM[t[0]][e]}function TY(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]=Hv(t[a],n),a+1<t.length&&(t[a]^=t[a+1]);n=Hv(n,2)}return t}function AY(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]^=Hv(l,a))}return n}function Hv(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 MY(e,t,n=1,s=40,a=-1,l=!0){if(!(ix<=n&&n<=s&&s<=ox)||a<-1||a>7)throw new RangeError("Invalid value");let u,d;for(u=n;;u++){const y=rf(u,t)*8,b=EY(e,u);if(b<=y){d=b;break}if(u>=s)throw new RangeError("Data too long")}for(const y of[UM,BM,VM])l&&d<=rf(u,y)*8&&(t=y);const p=[];for(const y of e){zr(y.mode[0],4,p),zr(y.numChars,qM(y.mode,u),p);for(const b of y.getData())p.push(b)}const h=rf(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,b)=>m[b>>>3]|=y<<7-(b&7)),new xY(u,t,m,a)}function RY(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"?kY(e):Array.isArray(e)?[ZM(e)]:void 0;if(!p)throw new Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);const h=MY(p,pY[n],a,l,u,s),m=_Y({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(b=>!b))),t?.onEncoded?.(m),m}function _Y(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=li.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 BN(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function OY(e,t={}){const n=RY(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 b=y*s,w=m*s;n.data[m][y]&&h.push(`M${b},${w}h${s}v${s}h-${s}z`)}return p+=`<rect fill="${BN(a)}" width="${d}" height="${u}"/>`,p+=`<path fill="${BN(l)}" d="${h.join("")}"/>`,p+="</svg>",p}function IY(e){return e?e.replace(/^wss?:\/\//,"").replace(/:\d+$/,""):null}function VN(e){return e?e.length<=18?e:`${e.slice(0,10)}...${e.slice(-6)}`:null}function DY(e){return e?e.status==="paired"||e.status==="connected"?"success":e.status==="error"||e.status==="closed"?"danger":"warning":"warning"}function PY(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 FN({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 zY({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,b]=g.useState(!1),[w,j]=g.useState(null),[N,k]=g.useState(null),[T,E]=g.useState(null),[S,M]=g.useState(null),[R,A]=g.useState(()=>Date.now()),[_,$]=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 P=g.useCallback(async(se="initial")=>{if(se==="background"&&O.current)return;const ve=++U.current;!(V.current!==null)&&se!=="background"?(p(!0),k(null)):m(!0);try{const je=await Me(se==="manual"?"/api/pairing-state/refresh":"/api/pairing-state");if(ve!==U.current)return;n(je),k(null),M(Date.now())}catch(je){if(ve!==U.current)return;k(je instanceof Error?je.message:String(je))}finally{ve===U.current&&(p(!1),m(!1))}},[]),q=g.useCallback(async()=>{try{const se=await Me("/api/user");u(se.name),a(se.name),E(null)}catch(se){E(se instanceof Error?se.message:String(se))}},[]),Z=g.useRef(!1);g.useEffect(()=>{P("initial"),q()},[P,q]),g.useEffect(()=>{const se=setInterval(()=>{P("background")},1e4);return()=>clearInterval(se)},[P]),g.useEffect(()=>{if(!t?.pairing?.expiresAt)return;A(Date.now());const se=setInterval(()=>{A(Date.now())},1e3);return()=>clearInterval(se)},[t?.pairing?.expiresAt]);const H=g.useCallback(async()=>{b(!0),E(null);try{const se=await Me("/api/user",{method:"POST",body:JSON.stringify({name:s})});u(se.name),a(se.name)}catch(se){E(se instanceof Error?se.message:String(se))}finally{b(!1)}},[s]),L=g.useCallback(async se=>{const ve=++U.current;j(se),k(null);try{const me=await Me("/api/pairing/control",{method:"POST",body:JSON.stringify({action:se})});if(ve!==U.current)return;n(me),M(Date.now())}catch(me){if(ve!==U.current)return;k(me instanceof Error?me.message:String(me))}finally{ve===U.current&&j(null)}},[]);g.useEffect(()=>{!t||t.isRunning||Z.current||(Z.current=!0,L("start"))},[t,L]);const z=g.useCallback(async se=>{$(se);try{await Me(`/api/pairing/peers/${encodeURIComponent(se)}`,{method:"DELETE"}),P("manual")}catch{}finally{$(null)}},[P]),B=g.useMemo(()=>{const se=t?.pairing?.qrValue?.trim();return se?OY(se,{border:2,ecc:"M",pixelSize:8}):null},[t?.pairing?.qrValue]),X=IY(t?.pairing?.relay??t?.relay??null),W=PY(t?.pairing?.expiresAt,R),F=(t?.trustedPeers.find(se=>se.fingerprint===t.connectedPeerFingerprint)??null)?.name??VN(t?.connectedPeerFingerprint??null),G=DY(t),J=s.trim()!==l,ce=!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-${G}`,children:t.statusLabel}),o.jsx("div",{className:"sys-sync-note",children:d?"Loading...":N&&t?`Snapshot from ${S?Pe(S):"earlier"}`:S?`Updated ${Pe(S)}`:""}),o.jsx("button",{type:"button",className:"s-btn",disabled:d||h||!!w,onClick:()=>{P("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})]}),T&&o.jsxs("div",{className:"sys-banner sys-banner-warning",children:[o.jsx("strong",{children:"Identity error."}),o.jsx("span",{children:T})]}),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."})]}),ce&&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:()=>{P("manual")},children:"Try again"})})]}),o.jsxs("div",{className:"sys-settings-hero",children:[o.jsx("div",{className:"sys-settings-qr-col",children:B?o.jsxs("div",{className:"sys-settings-qr-frame",children:[o.jsx("div",{className:"s-qr",dangerouslySetInnerHTML:{__html:B}}),W&&o.jsxs("span",{className:"sys-settings-qr-expires",children:["Expires in ",W]})]}):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:se=>a(se.target.value),onKeyDown:se=>{se.key==="Enter"&&J&&!y&&H()}}),o.jsx("button",{type:"button",className:"s-btn s-btn-primary",disabled:!J||y,onClick:()=>{H()},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(FN,{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(FN,{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})]}),F&&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:F})]}),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:()=>{L("restart")},children:w==="restart"?"Restarting...":"Restart"}),o.jsx("button",{type:"button",className:"s-btn",disabled:!!w,onClick:()=>{L("stop")},children:w==="stop"?"Stopping...":"Stop"})]}):o.jsx("button",{type:"button",className:"s-btn s-btn-primary",disabled:!!w,onClick:()=>{L("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(se=>{const ve=se.fingerprint===t.connectedPeerFingerprint;return o.jsxs("tr",{className:ve?"sys-peers-row-connected":"",children:[o.jsx("td",{children:o.jsxs("span",{className:"sys-peers-name",children:[se.name??VN(se.fingerprint)??"Peer",ve&&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:se.fingerprint})}),o.jsx("td",{children:se.pairedAtLabel??"—"}),o.jsx("td",{children:se.lastSeenLabel??"—"}),o.jsx("td",{children:o.jsx("button",{type:"button",className:"sys-peers-remove",disabled:_===se.fingerprint,onClick:()=>{z(se.fingerprint)},title:"Remove peer",children:_===se.fingerprint?"...":"Remove"})})]},se.fingerprint)})})]})]})]})}const LY=2500,$Y=1e4;function GM(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")?LY:$Y,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 Me(`/api/observe/agents${h}`);if(!s.current)return;n(y=>{const b={};for(const w of e)b[w.id]=y[w.id];for(const w of m){const{agentId:j,...N}=w;b[j]=N}return b})}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 fc=340,Uf=220,xo=16,UY=48,BY=36,HN=28,Od=40,KM=180,XM=140;function VY(e){const t=FY(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(Od),l=Array.from({length:n},(p,h)=>Od+h*(fc*2+xo+UY));for(const p of t){const h=a.indexOf(Math.min(...a)),m=l[h],y=a[h],b=Math.min(2,p.agents.length),w=Math.ceil(p.agents.length/b),j=b*fc+(b-1)*xo,N=HN+w*Uf+(w-1)*xo,k=p.agents.map((T,E)=>{const S=E%b,M=Math.floor(E/b);return{agentId:T.id,x:m+S*(fc+xo),y:y+HN+M*(Uf+xo)}});s.push({label:p.label,x:m,y,w:j,h:N,tiles:k}),a[h]=y+N+BY}const u=Math.max(...l.map((p,h)=>p+fc*2+xo))+Od,d=Math.max(...a)+Od;return{groups:s,canvasW:u,canvasH:d}}function FY(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 HY(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 JM(e,t,n){const s=n?.events.slice(-8).map(HY).filter(Boolean)??[];return s.length>0?s:et(e.state)==="offline"?["No session trace available"]:["Waiting for session trace…",...t?[`task: ${t}`]:[]]}function qY(e){switch(et(e)){case"working":return"var(--green)";case"available":return"var(--accent)";default:return"var(--dim)"}}function ZY({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 WY({navigate:e,agents:t}){const[n,s]=g.useState(null),[a,l]=g.useState(null),u=GM(t),d=g.useCallback(async U=>{await Me(`/api/agents/${encodeURIComponent(U)}/interrupt`,{method:"POST",body:JSON.stringify({})})},[]),p=g.useRef(null),[h,m]=g.useState({w:0,h:0}),[y,b]=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(([P])=>{const{width:q,height:Z}=P.contentRect;m({w:q,h:Z})});return O.observe(U),()=>O.disconnect()},[]);const T=g.useCallback(async()=>{try{l(await Me("/api/fleet"))}catch{}},[]);g.useEffect(()=>{T()},[T]),Mn(()=>{T()});const E=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(()=>VY(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));b({x:(h.w-S.canvasW*O)/2,y:Math.max(8,(h.h-S.canvasH*O)/2)}),j(O)},[S,h]);const M=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]),R=g.useCallback(U=>{N.current&&b({x:k.current.panX+(U.clientX-k.current.x),y:k.current.panY+(U.clientY-k.current.y)})},[]),A=g.useCallback(()=>{N.current=!1},[]);g.useEffect(()=>{const U=p.current;if(!U)return;const O=P=>{P.preventDefault();const q=U.getBoundingClientRect(),Z=P.clientX-q.left,H=P.clientY-q.top,L=P.deltaY>0?.92:1.08,z=Math.max(.2,Math.min(2,w*L)),B=z/w;b(X=>({x:Z-(Z-X.x)*B,y:H-(H-X.y)*B})),j(z)};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 $=g.useCallback(U=>{const O=p.current;if(!O)return;const P=U.currentTarget.getBoundingClientRect(),q=U.clientX-P.left,Z=U.clientY-P.top,H=Math.min(KM/S.canvasW,XM/S.canvasH),L=q/H,z=Z/H,B=O.clientWidth,X=O.clientHeight;b({x:B/2-L*w,y:X/2-z*w})},[S,w]),V=g.useMemo(()=>{const U={};for(const O of S.groups)for(const P of O.tiles)U[P.agentId]={x:P.x,y:P.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:M,onMouseMove:R,onMouseUp:A,onMouseLeave:A,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(KY,{agent:U,task:E[U.id]??null,observe:u[U.id]?.data??null,x:O.x,y:O.y,onClick:()=>s(U.id)},U.id):null})]}),o.jsx(YY,{layout:S,agents:t,pan:y,zoom:w,viewportRef:p,onClick:$})]}),_&&o.jsx(GY,{agent:_,task:E[_.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 YY({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(KM/e.canvasW,XM/e.canvasH),d=e.canvasW*u,p=e.canvasH*u,h=a.current,m=h?.clientWidth??0,y=h?.clientHeight??0,b=-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(T=>{const E=t.find(S=>S.id===T.agentId);return o.jsx("div",{className:"s-conductor-minimap-tile",style:{left:T.x*u,top:T.y*u,width:fc*u,height:Uf*u,background:E?mt(E.name):"var(--dim)",opacity:E&&et(E.state)==="working"?.8:.35}},T.agentId)})),o.jsx("div",{className:"s-conductor-minimap-viewport",style:{left:Math.max(0,b),top:Math.max(0,w),width:Math.min(j,d),height:Math.min(N,p)}})]})}function GY({agent:e,task:t,observe:n,onClose:s,onTell:a,onAsk:l,onFreeze:u,onOpenProfile:d}){const p=JM(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 KY({agent:e,task:t,observe:n,x:s,y:a,onClick:l}){const u=mt(e.name),d=qY(e.state),p=Pn(e.state).toUpperCase(),h=JM(e,t?.summary??null,n),m=et(e.state)==="working",y=n?.events[n.events.length-1],b=y?ya(y):t?.summary??Pn(e.state);return o.jsxs("div",{className:"s-conductor-tile",style:{left:s,top:a,height:Uf},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(ZY,{color:u,data:n?.contextUsage}),o.jsx("span",{className:"s-conductor-tile-detail",children:b}),m&&o.jsx("span",{className:"s-conductor-terminal-cursor"})]})]})}const hc=420,Bf=320,bo=20,XY=48,JY=36,qN=28,Id=40,QM=180,eR=140,tR="scout_mc_vp";function QY(e){try{localStorage.setItem(tR,JSON.stringify(e))}catch{}}function eG(){try{const e=localStorage.getItem(tR);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 tG(e){const t=nG(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(Id),l=Array.from({length:n},(p,h)=>Id+h*(hc*2+bo+XY));for(const p of t){const h=a.indexOf(Math.min(...a)),m=l[h],y=a[h],b=Math.min(2,p.agents.length),w=Math.ceil(p.agents.length/b),j=b*hc+(b-1)*bo,N=qN+w*Bf+(w-1)*bo,k=p.agents.map((T,E)=>({agentId:T.id,x:m+E%b*(hc+bo),y:y+qN+Math.floor(E/b)*(Bf+bo)}));s.push({label:p.label,x:m,y,w:j,h:N,tiles:k}),a[h]=y+N+JY}const u=Math.max(...l.map(p=>p+hc*2+bo))+Id,d=Math.max(...a)+Id;return{groups:s,canvasW:u,canvasH:d}}function nG(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 sG={think:"var(--dim)",tool:"var(--accent)",ask:"var(--amber)",message:"var(--muted)",note:"var(--green)",system:"var(--dim)",boot:"var(--dim)"},rG={think:"think",tool:"tool",ask:"ask",message:"msg",note:"note",system:"sys",boot:"boot"};function aG({navigate:e,agents:t}){const[n,s]=g.useState(null),a=GM(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),[b,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 P=new ResizeObserver(([q])=>{d({w:q.contentRect.width,h:q.contentRect.height})});return P.observe(O),()=>P.disconnect()},[]);const T=g.useMemo(()=>tG(t),[t]),E=g.useRef([]),S=g.useCallback((O=!0)=>{if(T.canvasW===0||u.w===0)return;E.current.forEach(clearTimeout);const P=Math.min(1,u.w/T.canvasW,u.h/T.canvasH),q=Math.max(.15,Math.min(1,P*.92));w(!1),y(q),h({x:(u.w-T.canvasW*q)/2,y:Math.max(8,(u.h-T.canvasH*q)/2)});const Z=setTimeout(()=>{w(!0);const L=O?eG():null;L?(h(L.pan),y(L.zoom)):(h({x:24,y:24}),y(.55))},700),H=setTimeout(()=>w(!1),1700);E.current=[Z,H]},[T,u]);g.useEffect(()=>{T.canvasW===0||u.w===0||k.current||(k.current=!0,S(!0))},[T,u,S]),g.useEffect(()=>{const O=setInterval(()=>{QY({pan:p,zoom:m})},3e4);return()=>clearInterval(O)},[p,m]);const M=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]),R=g.useCallback(O=>{j.current&&h({x:N.current.panX+(O.clientX-N.current.x),y:N.current.panY+(O.clientY-N.current.y)})},[]),A=g.useCallback(()=>{j.current=!1},[]);g.useEffect(()=>{const O=l.current;if(!O)return;const P=q=>{q.preventDefault();const Z=O.getBoundingClientRect(),H=q.clientX-Z.left,L=q.clientY-Z.top,z=q.deltaY>0?.92:1.08,B=Math.max(.2,Math.min(2,m*z)),X=B/m;h(W=>({x:H-(H-W.x)*X,y:L-(L-W.y)*X})),y(B)};return O.addEventListener("wheel",P,{passive:!1}),()=>O.removeEventListener("wheel",P)},[m]);const _=n?t.find(O=>O.id===n):null;g.useEffect(()=>{const O=P=>{P.target.tagName==="INPUT"||P.target.tagName==="TEXTAREA"||(P.key==="Escape"&&s(null),(P.key==="h"||P.key==="H")&&S(!1))};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[_,S]);const $=g.useCallback(O=>{const P=O.currentTarget.getBoundingClientRect(),q=O.clientX-P.left,Z=O.clientY-P.top,H=Math.min(QM/T.canvasW,eR/T.canvasH),L=q/H,z=Z/H,B=l.current;B&&h({x:B.clientWidth/2-L*m,y:B.clientHeight/2-z*m})},[T,m]),V=g.useMemo(()=>{const O={};for(const P of T.groups)for(const q of P.tiles)O[q.agentId]={x:q.x,y:q.y};return O},[T]),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":""," ·"," ",T.groups.length," workspace",T.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:M,onMouseMove:R,onMouseUp:A,onMouseLeave:A,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:b?"transform 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94)":"none"},children:[T.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 P=V[O.id];if(!P)return null;const q=a[O.id];return o.jsx(iG,{agent:O,observe:q?.data??null,x:P.x,y:P.y,onClick:()=>s(O.id)},O.id)})]}),t.length>0&&o.jsx(lG,{layout:T,agents:t,pan:p,zoom:m,viewportRef:l,onClick:$})]}),_&&o.jsx(oG,{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 iG({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),b=t?.contextUsage,w=b&&b.length>0?Math.round(b[b.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:Bf},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:cG(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:sG[k.kind]??"var(--dim)"}}),o.jsx("span",{className:"s-mission-evt-kind",children:rG[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 oG({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(LM,{data:t??void 0,agentId:e.id})})]})})}function lG({layout:e,agents:t,pan:n,zoom:s,viewportRef:a,onClick:l}){if(e.canvasW===0)return null;const u=Math.min(QM/e.canvasW,eR/e.canvasH),d=e.canvasW*u,p=e.canvasH*u,h=a.current,m=h?.clientWidth??0,y=h?.clientHeight??0,b=-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(T=>{const E=t.find(S=>S.id===T.agentId);return o.jsx("div",{className:"s-mission-minimap-tile",style:{left:T.x*u,top:T.y*u,width:hc*u,height:Bf*u,background:E?mt(E.name):"var(--dim)",opacity:E&&et(E.state)==="working"?.8:.35}},T.agentId)})),o.jsx("div",{className:"s-mission-minimap-viewport",style:{left:Math.max(0,b),top:Math.max(0,w),width:Math.min(j,d),height:Math.min(N,p)}})]})}function cG(e){switch(e){case"working":return"var(--green)";case"available":return"var(--accent)";default:return"var(--dim)"}}const uG=["openai","codex","codex_app_server"],dG=["anthropic","claude","claude-code","claude_stream_json"],ri={"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}},fG={"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 hG(e){const t=e.provider?.trim().toLowerCase()??"",n=e.adapterType?.trim().toLowerCase()??"",s=nR(e.model)??"",a=[t,n].filter(Boolean);return a.some(l=>uG.some(u=>l.includes(u)))?"openai":a.some(l=>dG.some(u=>l.includes(u)))?"anthropic":s.startsWith("gpt-")||s.startsWith("o")||s.includes("codex")?"openai":s.startsWith("claude-")?"anthropic":"unknown"}function nR(e){return e?e.trim().toLowerCase().replace(/^(openai|anthropic)\//,"").replace(/_/g,"-").replace(/-\d{8}$/,""):null}function pG(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 mG(e){const t=hG(e),n=nR(e.model),s=pG(e.usage),a=gG(t,n),l=vG(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,b=[Dd("input","Input",d,u.inputPerM,l),Dd("cached_input","Cached input",p,u.cachedInputPerM??u.inputPerM,l),Dd("cache_write","Cache write",h,u.cacheWritePerM??u.inputPerM,l),Dd("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:b,totalUsd:b.reduce((w,j)=>w+j.costUsd,0),billedTotalUsd:b.reduce((w,j)=>w+j.billedCostUsd,0),billingMode:l,subscriptionWindows:e.subscriptionWindows??[]}}function gG(e,t){if(e==="unknown")return{rateCard:null,source:"unknown"};const n=t?`${e}:${t}`:null;if(n&&ri[n])return{rateCard:ri[n],source:"exact"};const s=t?fG[t]:null;if(s&&ri[s])return{rateCard:ri[s],source:"alias"};if(e==="anthropic"){if(t?.includes("opus"))return{rateCard:ri["anthropic:claude-opus-4.5"],source:"provider-default"};if(t?.includes("haiku"))return{rateCard:ri["anthropic:claude-haiku-4.5"],source:"provider-default"};if(t?.includes("sonnet")||!t)return{rateCard:ri["anthropic:claude-sonnet-4.5"],source:"provider-default"}}return{rateCard:null,source:"unknown"}}function Dd(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 vG(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 qv=1440*6e4,yG=90*6e4;function ZN(e){if(!e)return null;const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function sc(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 WN(e){return e==null?"—":e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(2)}s`}function Pd(e){return e==null?"$—":e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function xG(e,t){if(!e)return null;const n=e.data.events.filter(a=>a.kind==="message"||a.kind==="tool").filter(a=>t-a.t<=yG).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 bG(e,t){const n=new Array(24).fill(0),s=t-qv;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)/qv*n.length)));n[l]+=1}return n}function wG({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 jG(e){return e.transport??ZN(e.cwd)??ZN(e.projectRoot)??"local"}function SG(e){return e.project??e.role??e.agentClass??"Unassigned"}function NG(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<=qv}),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,b=mG({adapterType:h?.data.metadata?.session?.adapterType,capturedAt:h?.updatedAt??l,model:m,provider:y,usage:h?.data.metadata?.usage});return{agent:e,team:SG(e),machine:jG(e),model:m,provider:y,state:et(e.state),activeFlights:s.filter(w=>w.agentId===e.id).length,sessions24h:d.length,throughput:bG(p,l),avgLatencyMs:xG(h,l),usage:b.usage,cost:b,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 kG({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(""),[b,w]=g.useState(()=>Date.now()),j=g.useCallback(async()=>{const O=t.map(L=>L.id).join(","),[P,q,Z,H]=await Promise.allSettled([Me("/api/fleet"),Me("/api/sessions"),Me("/api/activity"),O?Me(`/api/observe/agents?ids=${encodeURIComponent(O)}`):Promise.resolve([])]);P.status==="fulfilled"&&s(P.value),q.status==="fulfilled"&&l(q.value),Z.status==="fulfilled"&&d(Z.value),H.status==="fulfilled"&&h(H.value),w(Date.now())},[t]);g.useEffect(()=>{j()},[j]),Mn(()=>{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(P=>NG(P,a,u,O,N,b)).sort((P,q)=>{const Z={working:0,available:1,offline:2},H=Z[P.state]-Z[q.state];return H!==0?H:(q.lastActiveAt??0)-(P.lastActiveAt??0)})},[u,t,n?.activeAsks,b,N,a]),T=g.useMemo(()=>{const O=m.trim().toLowerCase();return O?k.filter(P=>`${P.agent.name} ${P.team} ${P.machine} ${P.agent.handle??""} ${P.agent.harness??""}`.toLowerCase().includes(O)):k},[m,k]),E=k.filter(O=>O.state==="working").length,S=k.filter(O=>O.state!=="offline").length,M=k.reduce((O,P)=>O+(P.usage.total??0),0),R=k.some(O=>O.cost.totalUsd!=null)?k.reduce((O,P)=>O+(P.cost.totalUsd??0),0):null,A=k.some(O=>O.cost.billedTotalUsd!=null)?k.reduce((O,P)=>O+(P.cost.billedTotalUsd??0),0):null,_=(()=>{const O=k.map(P=>P.avgLatencyMs).filter(P=>P!=null);return O.length===0?null:Math.round(O.reduce((P,q)=>P+q,0)/O.length)})(),$=k.reduce((O,P)=>O+P.errors,0),V=g.useMemo(()=>{const O=new Map;for(const P of k)O.set(P.team,(O.get(P.team)??0)+1);return[...O.entries()].sort((P,q)=>q[1]-P[1]).slice(0,6)},[k]),U=g.useMemo(()=>{const O=new Map;for(const P of k)O.set(P.machine,(O.get(P.machine)??0)+1);return[...O.entries()].sort((P,q)=>q[1]-P[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:$})]})]}),o.jsxs("div",{className:"s-ops-agents-rail-group",children:[o.jsx("div",{className:"s-ops-agents-rail-heading",children:"Teams"}),V.map(([O,P])=>o.jsxs("button",{className:"s-ops-agents-rail-row",type:"button",children:[O,o.jsx("span",{children:P})]},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,P])=>o.jsxs("button",{className:"s-ops-agents-rail-row",type:"button",children:[O,o.jsx("span",{children:P})]},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(_O,{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(DO,{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(zd,{label:"Running",value:String(E),sub:`of ${t.length} total`}),o.jsx(zd,{label:"Tokens",value:sc(M||null),sub:R==null?"usage metadata pending":`${Pd(R)} API equiv`}),o.jsx(zd,{label:"Avg latency",value:WN(_),sub:"recent observe events"}),o.jsx(zd,{label:"Billed",value:Pd(A),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:T.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:[T.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(wG,{values:O.throughput,warn:O.errors>0})}),o.jsx("td",{className:"s-ops-agents-num",children:WN(O.avgLatencyMs)}),o.jsx("td",{className:"s-ops-agents-num",children:sc(O.usage.uncachedInput??O.usage.input)}),o.jsx("td",{className:"s-ops-agents-num",children:sc(O.usage.cachedInput)}),o.jsx("td",{className:"s-ops-agents-num",children:sc(O.usage.cacheWrite)}),o.jsx("td",{className:"s-ops-agents-num",children:sc(O.usage.output)}),o.jsx("td",{className:`s-ops-agents-num${O.cost.rateCardSource==="unknown"?" s-ops-agents-num--dim":""}`,children:Pd(O.cost.totalUsd)}),o.jsx("td",{className:`s-ops-agents-num${O.cost.billingMode==="subscription"?" s-ops-agents-num--covered":""}`,children:Pd(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?Pe(O.lastActiveAt):"—"})]},O.agent.id)),T.length===0&&o.jsx("tr",{children:o.jsx("td",{colSpan:15,className:"s-ops-agents-empty",children:"No agents match the current search."})})]})]})})]})]})]})}function zd({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 cx={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 ux(e){const t=[e];return e.children&&e.children.forEach(n=>t.push(...ux(n))),t}function sR(e,t){if(e.id===t)return e;if(!e.children)return null;for(const n of e.children){const s=sR(n,t);if(s)return s}return null}function YN(e,t){return ux(e).filter(n=>n.kind==="task"&&n.assigneeId===t).length}function rR(e){switch(e){case"done":return 1;case"inflight":return .7;case"committed":return .32;case"stuck":return .18;default:return .1}}function EG(e){return(e.currentPhase||e.state).replace(/\s+/g," ")}function CG(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 TG(e){switch(e.status){case"working":return"inflight";case"completed":return"done";case"needs_attention":case"failed":return"stuck";default:return"committed"}}function aR(e,t){return typeof e!="number"||!Number.isFinite(e)?null:Math.max(0,Math.round((t-e)/6e4))}function AG(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 dx(e){return e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.collaborationRecordId?{view:"work",workId:e.collaborationRecordId}:{view:"agents",agentId:e.agentId}}function MG(e,t){const n=CG(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: ${EG(e)}`,progress:rR(n),stuckMins:n==="stuck"?aR(e.lastMeaningfulAt,t):null,updatedAt:e.lastMeaningfulAt,route:{view:"work",workId:e.id}}}function RG(e,t){const n=TG(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:rR(n),stuckMins:n==="stuck"?aR(e.updatedAt,t):null,updatedAt:e.updatedAt,route:dx(e)}}function _G(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 iR=10080*6e4,oR=720*6e4,Vf={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 OG(e){return e==="done"||e==="cancelled"}function IG(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=>OG(s.state))?e.acceptanceState==="pending"?"needs_review":"complete":"queued"}function DG(e){return e.status==="failed"||e.status==="needs_attention"?"blocked":e.status==="working"?"active":e.status==="queued"?"queued":"needs_review"}function PG(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>oR?{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 zG(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>oR?{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 lR(e,t){return(t.get(e.id)??[]).flatMap(s=>[s,...lR(s,t)])}function cR(e,t,n){const s=(t.get(e.id)??[]).sort((l,u)=>u.lastMeaningfulAt-l.lastMeaningfulAt).map(l=>cR(l,t,n));return{...MG(e,n),children:s.length>0?s:void 0}}function LG(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 $G(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 UG(e,t,n,s){const a=lR(e,t),l=cR(e,t,s),u=ux(l).filter(b=>b.kind==="task"),d=IG(e,a),p=PG(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?LG(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(b=>b.lastMeaningfulAt||b.updatedAt||b.createdAt)),ownerId:e.ownerId??e.nextMoveOwnerId,ownerName:e.ownerName??e.nextMoveOwnerName,harnesses:$G(y,n),root:m,leafNodes:u,route:{view:"work",workId:e.id},completion:p}}function BG(e,t){const n=RG(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:DG(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:dx(e),completion:zG(e,t)}}function VG(e){return new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function FG(e){const t=e.leafNodes.slice(0,6).map(a=>`- ${cx[a.state].label}: ${a.title}`).join(`
|
|
155
|
-
`),n=e.leafNodes.length>6?`
|
|
156
|
-
- ${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: ${Vf[e.status].label}`,`Completion signal: ${e.completion.label}`,`Last visible update: ${VG(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(`
|
|
157
|
-
`)}function HG(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 qG(e,t,n){return t==="all"?!0:t==="ongoing"?e.status!=="complete":n-Math.max(e.createdAt,e.updatedAt)<=iR}function ZG(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 WG({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"),[b,w]=g.useState("ongoing"),[j,N]=g.useState(()=>Date.now()),[k,T]=g.useState("loading"),[E,S]=g.useState(null),M=g.useRef(0),R=g.useCallback(async()=>{const O=++M.current,[P,q,Z]=await Promise.allSettled([Me("/api/fleet"),Me("/api/work?limit=250"),Me("/api/work?active=false&limit=250")]);if(O!==M.current)return;P.status==="fulfilled"&&s(P.value),(q.status==="fulfilled"||Z.status==="fulfilled")&&l(HG([q,Z]));const H=[P.status==="rejected"?`fleet: ${P.reason instanceof Error?P.reason.message:String(P.reason)}`:null,q.status==="rejected"?`active work: ${q.reason instanceof Error?q.reason.message:String(q.reason)}`:null,Z.status==="rejected"?`recent work: ${Z.reason instanceof Error?Z.reason.message:String(Z.reason)}`:null].filter(L=>!!L);S(H.length>0?H.join(" · "):null),T("ready"),N(Date.now())},[]);g.useEffect(()=>{R()},[R]),Mn(()=>{R()}),g.useEffect(()=>{const O=setInterval(()=>N(Date.now()),15e3);return()=>clearInterval(O)},[]);const A=g.useMemo(()=>Object.fromEntries(t.map(O=>[O.id,O])),[t]),_=g.useMemo(()=>{const O=new Map(a.map(W=>[W.id,W])),P=new Map;for(const W of a)if(W.parentId&&O.has(W.parentId)){const I=P.get(W.parentId)??[];I.push(W),P.set(W.parentId,I)}const Z=a.filter(W=>!W.parentId||!O.has(W.parentId)).map(W=>UG(W,P,A,j)),H=new Set(a.map(W=>W.id)),L=[...n?.activeAsks??[],...n?.recentCompleted??[]].filter(W=>!W.collaborationRecordId||!H.has(W.collaborationRecordId)).map(W=>BG(W,j)),z=[...Z,...L].sort(ZG),B=z.filter(W=>qG(W,b,j)),X=new Set;for(const W of z)W.harnesses.forEach(I=>X.add(I));return{records:z,visibleRecords:B,risks:_G(n?.needsAttention??[],n?.activeAsks??[],a),recentCompleted:(n?.recentCompleted??[]).slice(0,4),pendingAttention:n?.needsAttention??[],harnesses:[...X].sort(),counts:{ongoing:z.filter(W=>W.status!=="complete").length,recent:z.filter(W=>j-Math.max(W.createdAt,W.updatedAt)<=iR).length,review:z.filter(W=>W.completion.state==="needs_review").length,blocked:z.filter(W=>W.status==="blocked").length}}},[A,b,n,j,a]),$=g.useMemo(()=>_.records.find(O=>O.id===u)??_.visibleRecords[0]??_.records[0]??null,[_.records,_.visibleRecords,u]),V=p&&$?sR($.root,p):null,U=k==="loading"&&_.records.length===0;return g.useEffect(()=>{const O=_.visibleRecords[0]?.id??_.records[0]?.id??null;(!u||!_.records.some(P=>P.id===u))&&d(O)},[_.records,_.visibleRecords,u]),g.useEffect(()=>{if(!$){p!==null&&h(null);return}V||h($.root.id)},[p,V,$]),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"}`}),E&&o.jsxs("span",{className:"s-plan-banner-meta s-plan-banner-meta--error",children:["partial data · ",E]}),o.jsx("span",{style:{flex:1}}),n&&o.jsxs("span",{className:"s-plan-banner-meta",children:["updated ",Pe(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${b===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":E&&_.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.":E&&_.records.length===0?E:_.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(YG,{record:O,selected:O.id===$?.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(eK,{risk:O},O.id))]}),o.jsxs("div",{className:"s-plan-col",style:{padding:"20px 16px 40px"},children:[$&&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:$.title}),o.jsx("p",{className:"s-plan-goal",children:$.summary??$.completion.summary})]}),o.jsx("span",{className:"s-ops-state-chip",style:{color:Vf[$.status].color},children:Vf[$.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:[$?.leafNodes.length??0," item",($?.leafNodes.length??0)===1?"":"s"," · created ",$?Pe($.createdAt):"never"," · updated ",$?Pe($.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))})]}),$?o.jsx(uR,{node:$.root,depth:0,mode:m,selected:p??$.root.id,setSelected:h,agentsById:A,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:[$&&o.jsx(GG,{record:$,navigate:e}),V&&o.jsxs("div",{children:[o.jsx("div",{className:"s-ops-eyebrow",children:"Selected node"}),o.jsx(tK,{node:V,agentsById:A,navigate:e})]}),$&&o.jsxs("div",{children:[o.jsx("div",{className:"s-ops-eyebrow",children:"Agents on plan"}),t.filter(O=>YN($.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 P=YN($.root,O.id);return P===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:[P," item",P===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(JG,{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(QG,{ask:O,navigate:e},O.invocationId))]})]})]})})}function YG({record:e,selected:t,onSelect:n}){const s=Vf[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:Pe(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 GG({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 ",Pe(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:FG(e)}),children:"Evaluate with owner"})]})]})}function uR({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(KG,{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(uR,{node:p,depth:t+1,mode:n,selected:s,setSelected:a,agentsById:l,nowMs:u},p.id))})]})}function KG({node:e,depth:t,mode:n,selected:s,onClick:a,agentsById:l,nowMs:u}){const d=cx[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(XG,{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 XG({node:e,nowMs:t}){return e.state==="done"?o.jsxs("span",{style:{opacity:.55},children:["✓ completed ",e.updatedAt?Pe(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?` · ${Pe(e.updatedAt)}`:""]}):e.state==="committed"?o.jsxs("span",{children:["◐ ",e.detail??"queued",e.updatedAt?` · ${Pe(e.updatedAt)}`:""]}):o.jsxs("span",{style:{opacity:.55},children:["◌ waiting for first live signal ",e.updatedAt?Pe(e.updatedAt):""]})}function JG({item:e,navigate:t}){const n=AG(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:Pe(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 QG({ask:e,navigate:t}){const n=dx(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:Pe(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 eK({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 tK({node:e,agentsById:t,navigate:n}){const s=cx[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 GN=48,KN=720;function nK(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 Tg(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}function sK({storageKey:e,columns:t}){const n=g.useMemo(()=>{const b=nK(e)??{},w={};for(const j of t)w[j.key]=b[j.key]??j.defaultWidth;return w},[e,t]),[s,a]=g.useState(n);g.useEffect(()=>{a(b=>{let w=!1;const j={...b};for(const N of t)j[N.key]==null&&(j[N.key]=N.defaultWidth,w=!0);return w?j:b})},[t]);const l=g.useMemo(()=>{const b=new Map;for(const w of t)b.set(w.key,w);return b},[t]),u=g.useRef(null),d=g.useCallback(b=>{const w=u.current;if(!w)return;const j=b.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(b=>(Tg(e,b),b)))},[d,e]);g.useEffect(()=>()=>{window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p)},[d,p]);const h=g.useCallback(b=>{const w=s[b],j=l.get(b),N=j?.minWidth??GN,k=j?.maxWidth??KN;return{style:{width:w,minWidth:N,maxWidth:k},"data-resize-key":b}},[s,l]),m=g.useCallback(b=>({onPointerDown:k=>{if(k.button!==0)return;k.preventDefault(),k.stopPropagation();const T=l.get(b),E=T?.minWidth??GN,S=T?.maxWidth??KN,M=s[b]??T?.defaultWidth??E;u.current={key:b,startX:k.clientX,startWidth:M,min:E,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 T=l.get(b);T&&a(E=>{const S={...E,[b]:T.defaultWidth};return Tg(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 b={};for(const w of t)b[w.key]=w.defaultWidth;return Tg(e,b),b})},[t,e]);return{widths:s,getColumnProps:h,getResizeHandleProps:m,resetAll:y}}var rK=Object.create,dR=Object.defineProperty,aK=Object.getOwnPropertyDescriptor,fR=Object.getOwnPropertyNames,iK=Object.getPrototypeOf,oK=Object.prototype.hasOwnProperty,fr=(e,t)=>function(){return t||(0,e[fR(e)[0]])((t={exports:{}}).exports,t),t.exports},lK=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=fR(t),l=0,u=a.length,d;l<u;l++)d=a[l],!oK.call(e,d)&&d!==n&&dR(e,d,{get:(p=>t[p]).bind(null,d),enumerable:!(s=aK(t,d))||s.enumerable});return e},nn=(e,t,n)=>(n=e!=null?rK(iK(e)):{},lK(dR(n,"default",{value:e,enumerable:!0}),e)),hR=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}}),cK=fr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(e,t){var n=hR().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}}),uK=fr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(e,t){var n=hR().default,s=cK();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}}),Ti=fr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(e,t){var n=uK();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=Ti();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 Qc(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(dK,t)}};return t}function dK(e,t){return t(e)}function fK(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 hK(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 Qc(d=>(n++,a.push(d),l(),{unsubscribe(){n--,u();const p=a.findIndex(h=>h===d);p>-1&&a.splice(p,1)}}))}}function pR(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=Qc(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 pK(e){return Qc(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 $c(e){return!!e&&!Array.isArray(e)&&typeof e=="object"}function mK(){return Object.create(null)}const XN=e=>e();function JN(e=0){return new Promise(t=>setTimeout(t,e))}var gK=Object.create,mR=Object.defineProperty,vK=Object.getOwnPropertyDescriptor,gR=Object.getOwnPropertyNames,yK=Object.getPrototypeOf,xK=Object.prototype.hasOwnProperty,eu=(e,t)=>function(){return t||(0,e[gR(e)[0]])((t={exports:{}}).exports,t),t.exports},bK=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=gR(t),l=0,u=a.length,d;l<u;l++)d=a[l],!xK.call(e,d)&&d!==n&&mR(e,d,{get:(p=>t[p]).bind(null,d),enumerable:!(s=vK(t,d))||s.enumerable});return e},vh=(e,t,n)=>(n=e!=null?gK(yK(e)):{},bK(mR(n,"default",{value:e,enumerable:!0}),e));const vR=()=>{},QN=e=>{Object.freeze&&Object.freeze(e)};function yR(e,t,n){var s;const a=t.join(".");return(s=n[a])!==null&&s!==void 0||(n[a]=new Proxy(vR,{get(l,u){if(!(typeof u!="string"||u==="then"))return yR(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)}),QN(h.args),QN(h.path),e(h)}})),n[a]}const wK=e=>yR(e,[],mK()),jK=e=>new Proxy(vR,{get(t,n){if(n!=="then")return e(n)}});var xR=eu({"../../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}}),SK=eu({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(e,t){var n=xR().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}}),NK=eu({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(e,t){var n=xR().default,s=SK();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}}),bR=eu({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(e,t){var n=NK();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}}),fx=eu({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(e,t){var n=bR();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}});vh(fx());vh(bR());var Ld=vh(fx());function kK(e,t){if("error"in e){const s=t.deserialize(e.error);return{ok:!1,error:(0,Ld.default)((0,Ld.default)({},e),{},{error:s})}}return{ok:!0,result:(0,Ld.default)((0,Ld.default)({},e.result),(!e.result.type||e.result.type==="data")&&{type:"data",data:t.deserialize(e.result.data)})}}var Ag=class extends Error{constructor(){super("Unable to transform response from server")}};function EK(e,t){let n;try{n=kK(e,t)}catch{throw new Ag}if(!n.ok&&(!$c(n.error.error)||typeof n.error.error.code!="number"))throw new Ag;if(n.ok&&!$c(n.result))throw new Ag;return n}vh(fx());var $d=nn(Ti()),wo=nn(Hs());function CK(e){return e instanceof ci}function TK(e){return $c(e)&&$c(e.error)&&typeof e.error.code=="number"&&typeof e.error.message=="string"}function AK(e,t){return typeof e=="string"?e:$c(e)&&typeof e.message=="string"?e.message:t}var ci=class af extends Error{constructor(t,n){var s,a;const l=n?.cause;super(t,{cause:l}),(0,$d.default)(this,"cause",void 0),(0,$d.default)(this,"shape",void 0),(0,$d.default)(this,"data",void 0),(0,$d.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,af.prototype)}static from(t,n={}){const s=t;return CK(s)?(n.meta&&(s.meta=(0,wo.default)((0,wo.default)({},s.meta),n.meta)),s):TK(s)?new af(s.error.message,(0,wo.default)((0,wo.default)({},n),{},{result:s,cause:n.cause})):new af(AK(s,"Unknown error"),(0,wo.default)((0,wo.default)({},n),{},{cause:s}))}};function MK(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 RK={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)}},_K={enabled:!1,closeMs:0},OK={enabled:!1,pongTimeoutMs:1e3,intervalMs:5e3},IK=e=>e===0?0:Math.min(1e3*2**e,3e4),wR=(e,...t)=>typeof e=="function"?e(...t):e;var DK=nn(Ti()),jo=class jR extends Error{constructor(t){super(t.message,{cause:t.cause}),this.name="TRPCWebSocketClosedError",Object.setPrototypeOf(this,jR.prototype)}},PK=class{constructor(e,t){this.onTimeout=e,this.timeoutMs=t,(0,DK.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 SR(){let e,t;return{promise:new Promise((s,a)=>{e=s,t=a}),resolve:e,reject:t}}async function zK(e){const t=await wR(e.url);if(!e.connectionParams)return t;const s=`${t.includes("?")?"&":"?"}connectionParams=1`;return t+s}async function LK(e,t){const n={method:"connectionParams",data:await wR(e)};return t.encode(n)}var ek=nn(Ti()),$K=class{constructor(){(0,ek.default)(this,"outgoingRequests",new Array),(0,ek.default)(this,"pendingRequests",{})}register(e,t){const{promise:n,resolve:s}=SR();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(Ti());function UK(e){const{promise:t,resolve:n,reject:s}=SR();return e.addEventListener("open",()=>{e.removeEventListener("error",s),n()}),e.addEventListener("error",s),t}function BK(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 NR=class Zv{constructor(t){var n;if((0,ma.default)(this,"id",++Zv.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",pR(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=++Zv.connectCount;const n=zK(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&&BK(s,t.keepAliveOpts),s.addEventListener("close",()=>{t.ws===s&&(t.ws=null)}),await UK(s),t.urlOptions.connectionParams&&s.send(await LK(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)(NR,"connectCount",0);function VK(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(Ti()),So=nn(Hs()),FK=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 $K),(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:RK,this.callbacks={onOpen:e.onOpen,onClose:e.onClose,onError:e.onError};const s=(0,So.default)((0,So.default)({},_K),e.lazy);this.inactivityTimeout=new PK(()=>{if(this.requestManager.hasOutgoingRequests()||this.requestManager.hasPendingRequests()){this.inactivityTimeout.reset();return}this.close().catch(()=>null)},s.closeMs),this.activeConnection=new NR({WebSocketPonyfill:e.WebSocket,urlOptions:e,keepAlive:(0,So.default)((0,So.default)({},OK),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:IK,this.lazyMode=s.enabled,this.connectionState=pR({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 jo({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(ci.from(new jo({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 Qc(d=>{const p=this.batchSend({id:e,method:t,params:{input:l.input.serialize(s),path:n,lastEventId:u}},(0,So.default)((0,So.default)({},d),{},{next(h){const m=EK(h,l.output);if(!m.ok){d.error(ci.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 VK(this.activeConnection)}reconnect(e){var t=this;if(this.connectionState.next({type:"state",state:"connecting",error:ci.from(e)}),this.reconnecting)return;const n=async s=>{try{await JN(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(ci.from(s??new jo({message:"WebSocket closed",cause:s}))),this.requestManager.delete(l.id))};e.addEventListener("open",()=>{XN(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 jo({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 jo({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 jo({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(),XN(async()=>{n.activeConnection.isOpen()||await n.open(),await JN(0),n.requestManager.hasOutgoingRequests()&&n.send(n.requestManager.flush().map(({message:s})=>s))}).catch(s=>{this.requestManager.delete(e.id),t.error(ci.from(s))}),this.requestManager.register(e,t)}};function HK(e){return new FK(e)}function qK(e){const{client:t}=e,n=MK(e.transformer);return()=>({op:s})=>Qc(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 Mg=nn(Ti()),tk=nn(Hs()),ZK=class{constructor(e){(0,Mg.default)(this,"links",void 0),(0,Mg.default)(this,"runtime",void 0),(0,Mg.default)(this,"requestId",void 0),this.requestId=0,this.runtime={},this.links=e.links.map(t=>t(this.runtime))}$request(e){var t;return pK({links:this.links,op:(0,tk.default)((0,tk.default)({},e),{},{context:(t=e.context)!==null&&t!==void 0?t:{},id:++this.requestId})}).pipe(hK())}async requestAsPromise(e){var t=this;try{const n=t.$request(e);return(await fK(n)).result.data}catch(n){throw ci.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 WK=Symbol.for("trpc_untypedClient"),YK={query:"query",mutate:"mutation",subscribe:"subscription"},GK=e=>YK[e];function KK(e){const t=wK(({path:n,args:s})=>{const a=[...n],l=GK(a.pop()),u=a.join(".");return e[l](u,...s)});return jK(n=>n===WK?e:t[n])}function XK(e){const t=new ZK(e);return KK(t)}nn(Hs());nn(Hs());var JK=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(JK());nn(Hs());var QK=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(b){return Promise.reject(b)}}),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,b)}else m|=1}catch(j){return b(j)}if(m===1)return h!==a?Promise.reject(h):Promise.resolve();if(h!==a)throw h}function b(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}}),kR=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}}),eX=fr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(e,t){var n=kR();function s(a){return new n(a,0)}t.exports=s,t.exports.__esModule=!0,t.exports.default=t.exports}}),tX=fr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(e,t){var n=kR();function s(l){return function(){return new a(l.apply(this,arguments))}}function a(l){var u,d;function p(m,y){try{var b=l[m](y),w=b.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(b.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(b,w){var j={key:m,arg:y,resolve:b,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(QK());nn(eX());nn(tX());nn(Hs());const of=new Set;let Rg=null,nk=null,Ff=null;function nX(){return`ws://${typeof window<"u"?window.location.hostname:"127.0.0.1"}:65535/trpc`}function sX(e){for(const t of[...of])t(e)}function rX(){Ff||(Rg||(Rg=HK({url:nX()}),nk=XK({links:[qK({client:Rg})]})),Ff=nk.tail.events.subscribe(void 0,{onData:e=>{const t=e.data;t&&sX(t)}}))}function aX(){Ff?.unsubscribe(),Ff=null}function ER(e){const t=g.useRef(e);t.current=e,g.useEffect(()=>{const n=s=>t.current(s);return of.add(n),rX(),()=>{of.delete(n),of.size===0&&aX()}},[])}const sk=4e3,iX=500,oX=5e3,lX=5e3,cX=6e4,Hf={"scout-managed":"scout","hudson-managed":"hudson",unattributed:"native"},hx={tool:"working",run:"active",idle:"idle"};function Wv(e){const t=e.split(/\s+/)[0]??"",n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function uX(e,t=60){const n=e.split(/\s+/);if(n.length===0)return e;n[0]=Wv(n[0]);const s=n.join(" ");return s.length<=t?s:s.slice(0,t-1)+"…"}function dX(e){for(const t of e){const n=Wv(t.command);if(n&&!(n==="sh"||n==="zsh"||n==="bash"||n==="login"))return n}return e[0]?.command?Wv(e[0].command):"—"}function fX(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 CR(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 TR(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 hX(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 Yv(e){return e?e.slice(0,8):"—"}function AR(e){return e?.trim().toLowerCase()||"unknown"}function pX(e){return AR(e).replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function px(e){return`s-atop-chip s-atop-chip--harness s-atop-chip--harness-${pX(e)}`}const mX=/permission-mode/i;function gX(e){return e.kind!=="system"?!1:mX.test(e.summary)}function MR(e){return e.kind==="assistant"}function vX(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++,MR(a)&&l.reqCount++,gX(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<lX&&(u=l.lastKind==="tool"?"tool":"run");const d=fX(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:AR(a.source),attribution:a.harness,project:a.cwd?yX(a.cwd):"(unknown)",cwd:a.cwd??"",command:a.command,parentLabel:dX(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 Uc(e){if(e.cacheReadIn==null||e.tokIn==null)return null;const t=e.cacheReadIn+e.tokIn;return t===0?null:e.cacheReadIn/t}function oi(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 RR(e){return e==null?"—":`${Math.round(e*100)}%`}function yX(e){if(!e)return"";const t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function xX(e,t,n){const s=n-cX;let a=0;for(const d of t)MR(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 qf={tool:0,run:1,idle:2};function No(e){return e??-1}function bX(e,t,n,s){switch(n){case"status":return(qf[e.status]-qf[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(No(e.tokIn)-No(t.tokIn))*s;case"tokOut":return(No(e.tokOut)-No(t.tokOut))*s;case"cache":return(No(Uc(e))-No(Uc(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 rk({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 wX(){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),[b,w]=g.useState("status"),[j,N]=g.useState(1),[k,T]=g.useState(null),E=g.useRef([]),S=g.useRef([]),[M,R]=g.useState([]),[A,_]=g.useState([]),$=g.useCallback(I=>{t(F=>F.length>=sk?[...F.slice(F.length-sk+1),I]:[...F,I])},[]);ER($),g.useEffect(()=>{let I=!1;return(async()=>{try{const F=await Me(`/api/tail/recent?limit=${iX}`);I||t(F.events??[])}catch{}})(),()=>{I=!0}},[]);const V=g.useCallback(async()=>{try{const I=await Me("/api/tail/discover");s(I)}catch{}},[]);g.useEffect(()=>{V();const I=setInterval(()=>{V()},oX);return()=>clearInterval(I)},[V]),g.useEffect(()=>{const I=setInterval(()=>l(Date.now()),1e3);return()=>clearInterval(I)},[]);const U=g.useMemo(()=>vX(n,e,a),[n,e,a]),O=g.useMemo(()=>xX(U,e,a),[U,e,a]);g.useEffect(()=>{E.current=[...E.current,O.running].slice(-24),S.current=[...S.current,O.tooling].slice(-24),R(E.current),_(S.current)},[O.running,O.tooling]);const P=g.useMemo(()=>{const I=new Set;return U.forEach(F=>I.add(F.harness)),[...I]},[U]),q=g.useMemo(()=>{const I=new Set;return U.forEach(F=>I.add(F.status)),[...I]},[U]),Z=g.useMemo(()=>{const I=u.trim().toLowerCase();return U.filter(G=>{if(p.size>0&&!p.has(G.harness)||m.size>0&&!m.has(G.status))return!1;if(!I)return!0;const J=Hf[G.attribution];return`${G.pid} ${G.project} ${G.command} ${G.harness} ${G.attribution} ${J} ${G.sessionId??""} ${G.lastSummary??""}`.toLowerCase().includes(I)}).slice().sort((G,J)=>{const ce=qf[G.status]-qf[J.status];return ce!==0&&b!=="status"?ce:bX(G,J,b,j)})},[U,u,p,m,b,j]);g.useEffect(()=>{k!=null&&(U.some(I=>I.pid===k)||T(null))},[U,k]),g.useEffect(()=>{const I=F=>{const G=F.target,J=G instanceof HTMLInputElement||G instanceof HTMLTextAreaElement||(G?.isContentEditable??!1);if(F.key==="Escape"&&k!=null){F.preventDefault(),T(null);return}if(!J&&(F.key==="j"||F.key==="k")){if(Z.length===0)return;F.preventDefault();const ce=Z.findIndex(ve=>ve.pid===k),se=F.key==="j"?Z[Math.min(Z.length-1,ce<0?0:ce+1)]:Z[Math.max(0,ce<0?0:ce-1)];se&&T(se.pid)}};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[Z,k]);const H=I=>{b===I?N(F=>F===1?-1:1):(w(I),N(I==="project"||I==="agent"?1:-1))},L=I=>{h(F=>{const G=new Set(F);return G.has(I)?G.delete(I):G.add(I),G})},z=I=>{y(F=>{const G=new Set(F);return G.has(I)?G.delete(I):G.add(I),G})},B=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]),W=g.useMemo(()=>k==null?[]:e.filter(I=>I.pid===k).slice(-40),[e,k]);return o.jsxs("div",{className:"s-atop",children:[o.jsx(jX,{summary:O,runHistory:M,toolHistory:A}),o.jsx(SX,{search:u,onSearch:d,harnessOptions:P,harnessFilter:p,onToggleHarness:L,statusOptions:q,statusFilter:m,onToggleStatus:z,summary:O}),o.jsx(kX,{rows:Z,sortKey:b,sortDir:j,onSort:H,selectedPid:k,onSelect:T,now:a}),o.jsx(EX,{shown:Z.length,total:U.length,hasSelection:k!=null}),B&&o.jsx(CX,{row:B,process:X,events:W,now:a,onClose:()=>T(null)})]})}function jX({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(rk,{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(rk,{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:px(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 SX({search:e,onSearch:t,harnessOptions:n,harnessFilter:s,onToggleHarness:a,statusOptions:l,statusFilter:u,onToggleStatus:d,summary:p}){const h=b=>p.harnesses.find(w=>w.harness===b)?.count??0,m=b=>b==="tool"?p.tooling:b==="run"?p.running-p.tooling:p.idle,y=g.useRef(null);return g.useEffect(()=>{const b=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",b),()=>window.removeEventListener("keydown",b)},[]),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:b=>t(b.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(b=>{const w=s.has(b);return o.jsxs("button",{className:`s-atop-pill s-atop-pill--harness${w?" s-atop-pill--on":""}`,onClick:()=>a(b),children:[b,o.jsx("span",{className:"s-atop-pill-ct",children:h(b)})]},b)})]}),l.length>1&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"s-atop-fbar-label",children:"status"}),["tool","run","idle"].filter(b=>l.includes(b)).map(b=>{const w=u.has(b);return o.jsxs("button",{className:`s-atop-pill s-atop-pill--status-${b}${w?" s-atop-pill--on":""}`,onClick:()=>d(b),children:[hx[b],o.jsx("span",{className:"s-atop-pill-ct",children:m(b)})]},b)})]}),o.jsx("div",{className:"s-atop-fbar-spacer"})]})}const _g=[{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 rc({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:oi(e)})}function NX({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:RR(e)})}function kX({rows:e,sortKey:t,sortDir:n,onSort:s,selectedPid:a,onSelect:l,now:u}){const{getColumnProps:d,getResizeHandleProps:p}=sK({storageKey:"openscout.atop.cols",columns:_g});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:_g.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:_g.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"}),hx[h.status]]})}),o.jsxs("td",{className:"s-atop-col-agent",children:[o.jsx("span",{className:px(h.harness),title:`origin: ${Hf[h.attribution]}`,children:h.harness}),o.jsx("span",{className:"s-atop-agent-id",title:h.sessionId??`pid ${h.pid}`,children:Yv(h.sessionId)})]}),o.jsx("td",{className:"s-atop-col-project",title:h.cwd,children:h.project}),o.jsx(rc,{value:h.reqCount||null}),o.jsx(rc,{value:h.tokIn}),o.jsx(rc,{value:h.tokOut}),o.jsx(NX,{value:Uc(h)}),o.jsx(rc,{value:h.toolCount||null}),o.jsx(rc,{value:h.permCount||null,accent:h.permCount>0?"amber":void 0}),o.jsx("td",{className:"s-atop-col-last",children:TR(h.lastEventAt,u)}),o.jsx("td",{className:"s-atop-col-runtime",children:CR(h.sessionRuntimeSec)})]},h.pid))})]})})}function EX({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 CX({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),b=y?y[1]:"(tool)";d[b]=(d[b]??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"}),hx[e.status]]}),o.jsxs("span",{className:"s-atop-drawer-pid",children:["pid ",e.pid]}),o.jsx("span",{className:px(e.harness),title:`origin: ${Hf[e.attribution]}`,children:e.harness}),o.jsxs("span",{className:"s-atop-drawer-session",children:["session ",Yv(e.sessionId)]})]}),o.jsx("h2",{className:"s-atop-drawer-title",children:e.project}),o.jsxs("p",{className:"s-atop-drawer-sub",children:["session ",Yv(e.sessionId)," · runtime ",CR(e.sessionRuntimeSec)," · last activity ",TR(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:oi(e.reqCount||null)}),o.jsx(fa,{label:"Tools",value:oi(e.toolCount||null)}),o.jsx(fa,{label:"Permissions",value:oi(e.permCount||null),accent:e.permCount>0?"amber":void 0}),o.jsx(fa,{label:"Tok in",value:oi(e.tokIn),dim:e.tokIn==null}),o.jsx(fa,{label:"Tok out",value:oi(e.tokOut),dim:e.tokOut==null}),o.jsx(fa,{label:"Cache hit",value:RR(Uc(e)),dim:Uc(e)==null}),o.jsx(fa,{label:"Model",value:e.model??"—",dim:e.model==null}),o.jsx(fa,{label:"Events",value:oi(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:hX(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:Hf[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:uX(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 TX=e=>e==="right"?"railOccupantRight":"railOccupantBottom";function AX(e,t,n,s){g.useEffect(()=>{if(!n||typeof window>"u"||typeof document>"u")return;const a=TX(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 MX=620,RX=360,_X=280,OX=900,IX=720,ak=["a[href]","button:not([disabled])","textarea:not([disabled])","input:not([disabled])","select:not([disabled])","[tabindex]:not([tabindex='-1'])"].join(", ");function DX({open:e,onClose:t,side:n="right",owner:s,defaultSize:a,minSize:l=_X,maxSize:u,resizable:d=!1,backdrop:p=!0,scrollLock:h=!1,focusTrap:m=!1,ariaLabel:y,className:b,children:w}){const j=a??(n==="right"?MX:RX),N=u??(n==="right"?OX:IX),[k,T]=g.useState(j),[E,S]=g.useState(!1),M=g.useRef(null),R=g.useRef(null),A=g.useCallback(()=>t(),[t]);AX(n,s,e,A),g.useEffect(()=>{if(!e)return;const V=U=>{U.key==="Escape"&&(U.preventDefault(),A())};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[e,A]),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;R.current=document.activeElement;const V=M.current;return V?((V.querySelector(ak)??V).focus(),()=>{R.current?.focus?.()}):void 0},[e]),g.useEffect(()=>{if(!E)return;const V=O=>{if(n==="right"){const P=window.innerWidth-O.clientX;T(Math.min(N,Math.max(l,P)))}else{const P=window.innerHeight-O.clientY;T(Math.min(N,Math.max(l,P)))}},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)}},[E,n,l,N]);const _=V=>{if(!m||V.key!=="Tab")return;const U=M.current;if(!U)return;const O=Array.from(U.querySelectorAll(ak));if(O.length===0){V.preventDefault(),U.focus();return}const P=O[0],q=O[O.length-1],Z=document.activeElement;V.shiftKey?(Z===P||!U.contains(Z))&&(V.preventDefault(),q.focus()):Z===q&&(V.preventDefault(),P.focus())};if(!e)return null;const $=n==="right"?{width:k}:{height:k};return o.jsxs(o.Fragment,{children:[p&&o.jsx("div",{className:"s-slide-backdrop","data-side":n,onClick:A,"aria-hidden":"true"}),o.jsxs("aside",{ref:M,className:`s-slide s-slide--${n}${E?" s-slide--resizing":""}${b?` ${b}`:""}`,role:"dialog","aria-modal":"true","aria-label":y,tabIndex:-1,onKeyDown:_,style:$,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 ik=5e3,PX=500,ok=5e3,zX=3e4,_R={user:">",assistant:"<",tool:"*","tool-result":"=",system:"~",other:"·"},mx={"scout-managed":"scout","hudson-managed":"hudson",unattributed:"native"},OR={"scout-managed":"s-tail-chip--origin-scout","hudson-managed":"s-tail-chip--origin-hudson",unattributed:"s-tail-chip--origin-native"};function gx(e){return e?.trim().toLowerCase()||"unknown"}function LX(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=gx(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 $X(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 UX(e){return e?(e.split(":")[0]??e).slice(0,8):"—"}function BX(e,t){if(!t)return!0;const n=mx[e.harness];return`${e.summary} ${e.project} ${e.sessionId} ${e.source} ${e.harness} ${n}`.toLowerCase().includes(t.toLowerCase())}function VX({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,b]=g.useState(0),[w,j]=g.useState(0),[N,k]=g.useState(null),T=g.useRef(null),E=g.useRef(null),S=g.useRef(!0),M=g.useRef([]),R=g.useCallback(H=>{M.current.push(Date.now()),n(L=>L.length>=ik?[...L.slice(L.length-ik+1),H]:[...L,H])},[]);ER(R),g.useEffect(()=>{let H=!1;return(async()=>{try{const L=await Me(`/api/tail/recent?limit=${PX}`);H||n(L.events??[])}catch{}})(),()=>{H=!0}},[]);const A=g.useCallback(async()=>{try{const H=await Me("/api/tail/discover");a(H)}catch{}},[]);g.useEffect(()=>{A();const H=setInterval(()=>{A()},zX);return()=>clearInterval(H)},[A]),g.useEffect(()=>{const H=setInterval(()=>{const z=Date.now()-ok,B=M.current.filter(X=>X>=z);M.current=B,j(B.length/(ok/1e3))},1e3);return()=>clearInterval(H)},[]);const _=g.useMemo(()=>l?t.filter(H=>BX(H,l)):t,[t,l]);g.useLayoutEffect(()=>{const H=T.current;if(H){if(h){b(L=>L+1);return}H.scrollTop=H.scrollHeight}},[_,h]);const $=g.useCallback(()=>{const H=T.current;if(!H)return;const z=H.scrollHeight-H.scrollTop-H.clientHeight<24;S.current=z,z?(m(!1),b(0)):h||m(!0)},[h]),V=g.useCallback(H=>{u(H),p(!0),requestAnimationFrame(()=>E.current?.focus())},[]),U=g.useCallback(H=>{!H||!e||e({view:"sessions",sessionId:H})},[e]),O=g.useCallback(()=>{const H=T.current;H&&(H.scrollTop=H.scrollHeight,m(!1),b(0))},[]);g.useEffect(()=>{const H=L=>{const z=L.target,B=z instanceof HTMLInputElement||z instanceof HTMLTextAreaElement||(z?.isContentEditable??!1);if(L.key==="/"&&!B){L.preventDefault(),p(!0),requestAnimationFrame(()=>E.current?.focus());return}if(L.key==="Escape"&&d&&document.activeElement===E.current){L.preventDefault(),p(!1),E.current?.blur(),u("");return}(L.key==="g"||L.key==="G")&&!B&&(L.preventDefault(),O())};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[d,O]);const P=s?.totals,q=P?.transcripts??s?.transcripts?.length??0,Z=g.useMemo(()=>LX(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:q})," log",q===1?"":"s"]}),o.jsxs("span",{className:"s-tail-status-cell",children:[o.jsx("strong",{children:P?.total??0})," proc",(P?.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:Z.length>0?Z.slice(0,4).map(H=>o.jsxs("span",{children:[o.jsx("strong",{children:H.count})," ",H.source]},H.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:E,className:"s-tail-filter-input",value:l,placeholder:"substring across summary · project · session",onChange:H=>u(H.target.value),onKeyDown:H=>{H.key==="Enter"&&(H.preventDefault(),E.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:T,onScroll:$,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:q?o.jsxs(o.Fragment,{children:["watching ",q," transcript",q===1?"":"s"]}):o.jsx(o.Fragment,{children:"no moving transcript logs detected · start a session to see traffic"})})]}):_.map(H=>o.jsx(FX,{event:H,selected:N?.id===H.id,onSelect:k,onProjectClick:V,onSessionClick:U},H.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(ZX,{event:N,onClose:()=>k(null),onProjectClick:V,onSessionClick:U})]})}function FX({event:e,selected:t,onSelect:n,onProjectClick:s,onSessionClick:a}){const l=OR[e.harness],u=mx[e.harness],d=gx(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:$X(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(Zf,{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(Zf,{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:UX(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:_R[e.kind]}),o.jsx("span",{className:"s-tail-summary",children:e.summary})]})}function Zf({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 HX(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 lf(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 qX(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 ZX({event:e,onClose:t,onProjectClick:n,onSessionClick:s}){const[a,l]=g.useState(!0),u=OR[e.harness],d=mx[e.harness],p=gx(e.source),h=qX(e.raw);return o.jsxs(DX,{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:_R[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:HX(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(Zf,{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(Zf,{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(WX,{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:lf(e.raw??e)}})]})]})]})}function WX({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:lf(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:lf(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:lf(e)}})]})}const YX=15*6e4,GX=1440*6e4,vx=30*6e4,IR=1440*6e4,KX=vx,XX=[{label:"30m",value:vx},{label:"4h",value:240*6e4},{label:"24h",value:IR}],hi="operator",Pr="broker";function yx(e,t){return typeof e.updatedAt=="number"&&Number.isFinite(e.updatedAt)&&e.updatedAt>0&&e.updatedAt<=t&&t-e.updatedAt<=GX}function DR(e,t){return et(e.state)!=="offline"&&yx(e,t)&&t-(e.updatedAt??t)>YX}function yh(e){return e.replace(/[._]/g," ")}function xx(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 JX(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Ai(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 QX(e){const t=Math.max(1,Math.round(e/6e4));return Math.min(IR,Math.max(vx,t*6e4))}function eJ(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 QX(n*a)}function Wf(e){switch(e){case"critical":return 0;case"warning":return 1;default:return 2}}function Og(e,t){const n=Wf(e.severity)-Wf(t.severity);return n!==0?n:e.updatedAt-t.updatedAt}function lk(e,t){const n=Wf(e.severity)-Wf(t.severity);return n!==0?n:t.updatedAt-e.updatedAt}function tJ(e){return e.conversationId?{view:"conversation",conversationId:e.conversationId}:null}function PR(e){return"actorId"in e?e.actorId:null}function zR(e){return"agentId"in e?e.agentId:null}function Bc(e,t){if(e===hi)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 ck(e){return e.replace(/^@/,"").toLowerCase().replace(/[^a-z0-9]+/g,"")}function nJ(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=ck(n);return t.find(l=>[l.id,l.name,l.handle??"",l.selector??""].some(u=>ck(u)===s))?.id??null}function sJ(e,t){const n=e.conversationId;return!n||!n.startsWith("dm.")?null:n.startsWith("dm.operator.")?hi:t&&n.startsWith(`dm.${t}.`)?n.slice(`dm.${t}.`.length)||null:t&&n.endsWith(`.${t}`)&&n.slice(3,-`.${t}`.length)||null}function rJ(e,t){const n=PR(e),s=e.kind,a=nJ(e.title??e.summary,t),l=sJ(e,n);if(s==="ask_replied"||s==="flight_updated")return hi;if(a&&a!==n)return a;if(l&&l!==n)return l;const u=zR(e);return u&&u!==n?u:Pr}function aJ(e){return PR(e)??zR(e)??Pr}function iJ(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=aJ(w),k=rJ(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:xx(w.title??w.summary,92),ts:w.ts,route:tJ(w)}}),l=[...s.entries()].filter(([w])=>w!==hi&&w!==Pr).sort((w,j)=>j[1]-w[1]).slice(0,18).map(([w])=>w),u=new Set([hi,Pr,...l]),d=1e3,p=620,h=[{id:hi,label:"Operator",detail:"command",kind:"operator",x:118,y:p/2,state:"online",weight:s.get(hi)??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),T=-Math.PI*.62+j/Math.max(1,k-1)*Math.PI*1.24,E=j%2===0?250:315,S=630+Math.cos(T)*E,M=p/2+Math.sin(T)*235;h.push({id:w,label:Bc(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,M)),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}}),b=[...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:b,messageRate:e.length}}function oJ(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 lJ(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 cJ(e){return[{label:"Open agent",route:{view:"agents",agentId:e.id}}]}function uJ(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:xx(e.summary,140),agentId:e.agentId,agentName:e.agentName,updatedAt:e.updatedAt,startedAt:null,completedAt:null,actions:oJ(e),meta:[e.agentName??"Unassigned",yh(e.kind),e.state,e.acceptanceState]}}function dJ(e){return e.status==="failed"?"failed":e.status==="completed"?"done":"running"}function fJ(e){return e.status==="failed"||e.attention==="interrupt"?"critical":e.attention==="badge"||e.status==="needs_attention"?"warning":"info"}function uk(e){return{source:"ask",item:e,key:`ask:${e.invocationId}`,lane:dJ(e),severity:fJ(e),pill:e.statusLabel,title:e.task||"Delegated ask",summary:xx(e.summary,140),agentId:e.agentId,agentName:e.agentName??e.agentId,updatedAt:e.updatedAt,startedAt:e.startedAt,completedAt:e.completedAt,actions:lJ(e),meta:[e.agentName??e.agentId,e.harness??"unknown harness",e.transport??"unknown transport"]}}function hJ(e,t){const n=et(e.state),s=DR(e,t);if(!(n==="offline"&&yx(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 ${Ai(e.updatedAt,t)}.`,agentId:e.id,agentName:e.name,updatedAt:e.updatedAt??t,startedAt:null,completedAt:null,actions:cJ(e),meta:[Pn(e.state),e.project??e.role??e.agentClass,e.harness??"unknown harness"]}}function pJ(e,t,n){const s=(e?.needsAttention??[]).map(uJ),a=(e?.activeAsks??[]).map(uk),l=(e?.recentCompleted??[]).map(uk),u=t.map(d=>hJ(d,n)).filter(d=>!!d);return[...s,...a,...l,...u]}function mJ(e,t){return e.map(n=>{const s=et(n.state),a=DR(n,t),l=yx(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 ${Ai(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 gJ(e,t){const n=["s-warroom-decision",`s-warroom-decision--${e.severity}`];return t&&n.push("s-warroom-decision--selected"),n.join(" ")}function vJ(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 yJ({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"),[b,w]=g.useState(KX),[j,N]=g.useState(()=>Date.now()),k=g.useCallback(async()=>{try{const z=await Me("/api/fleet");s(z),z.activity.length>0?l([]):l(await Me("/api/activity"))}catch{const z=await Promise.allSettled([Me("/api/activity")]);z[0].status==="fulfilled"&&l(z[0].value)}N(Date.now())},[]);g.useEffect(()=>{k()},[k]),Mn(()=>{k()}),g.useEffect(()=>{const z=setInterval(()=>N(Date.now()),1e3);return()=>clearInterval(z)},[]);const T=g.useMemo(()=>n?.activity.length?n.activity:a,[a,n?.activity]),E=g.useMemo(()=>{const z=j-b;return T.filter(B=>B.ts>=z&&B.ts<=j)},[T,b,j]),S=g.useMemo(()=>iJ(E,t),[E,t]),M=S.messageRate,R=g.useMemo(()=>pJ(n,t,j),[t,n,j]),A=g.useMemo(()=>R.filter(z=>z.lane==="attention"||z.lane==="failed").sort(Og),[R]),_=g.useMemo(()=>({attention:R.filter(z=>z.lane==="attention").sort(Og),running:R.filter(z=>z.lane==="running").sort(lk),failed:R.filter(z=>z.lane==="failed").sort(Og),done:R.filter(z=>z.lane==="done").sort(lk).slice(0,8)}),[R]);g.useEffect(()=>{const z=A[0]?.key??_.running[0]?.key??_.done[0]?.key??null;if(!z){u!==null&&d(null);return}(!u||!R.some(B=>B.key===u))&&d(z)},[R,_.done,_.running,A,u]);const $=g.useMemo(()=>R.find(z=>z.key===u)??A[0]??_.running[0]??_.done[0]??null,[R,_.done,_.running,A,u]),V=_.failed.length,U=t.filter(z=>et(z.state)!=="offline").length,O=A.filter(z=>z.severity!=="info").length,P=g.useMemo(()=>mJ(t,j),[t,j]),q=g.useMemo(()=>new Map(S.nodes.map(z=>[z.id,z.label])),[S.nodes]),Z=g.useMemo(()=>S.edges.find(z=>z.id===p)??null,[S.edges,p]),H=n?`${Ai(n.generatedAt,j)} ago`:"loading",L=m==="flow"?Z?yh(Z.kind):"No selection":$?$.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 ",H," / Local time ",JX(j)]})]}),o.jsxs("div",{className:"s-warroom-kpis",children:[o.jsx(Ig,{label:"Action needed",value:String(O),detail:`${A.length} queued`,warn:O>0,hot:V>0}),o.jsx(Ig,{label:"Online",value:`${U}/${t.length}`,detail:"agents",warn:U<t.length}),o.jsx(Ig,{label:"Messages",value:String(M),detail:`last ${Or(b)}`})]})]}),o.jsxs("div",{className:"s-warroom-layout",children:[o.jsxs("aside",{className:"s-warroom-queue",children:[o.jsx(Dg,{title:"State",meta:A.length===0?"clear":`${A.length} priority`}),o.jsx(xJ,{queueItems:A,selectedKey:$?.key??null,nowMs:j,onSelect:z=>{d(z),y("item")}})]}),o.jsxs("main",{className:"s-warroom-board",children:[o.jsx(Dg,{title:"Message Topology",meta:`${S.visibleEdges.length} visible flows / ${Or(b)}`}),o.jsx(wJ,{network:S,nowMs:j,flowWindowMs:b,selectedFlowId:m==="flow"?Z?.id??null:null,onFlowWindowChange:w,onSelectFlow:z=>{h(z),y("flow")}})]}),o.jsxs("aside",{className:"s-warroom-inspector",children:[o.jsx(Dg,{title:"Inspector",meta:L}),m==="flow"?Z?o.jsx(SJ,{edge:Z,nodeLabels:q,nowMs:j,navigate:e}):o.jsx("div",{className:"s-warroom-empty",children:"Select a message flow to inspect."}):$?o.jsx(NJ,{item:$,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:P.slice(0,8).map(z=>o.jsxs("button",{type:"button",className:"s-warroom-health-row",onClick:()=>e(z.route),children:[o.jsx("span",{className:"s-warroom-dot"}),o.jsx("span",{children:z.name}),o.jsx("span",{children:z.state}),o.jsx("span",{children:z.detail})]},z.key))})]})]})]})]})}function Ig({label:e,value:t,detail:n,warn:s=!1,hot:a=!1}){return o.jsxs("div",{className:vJ(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 Dg({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 xJ({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(bJ,{item:a,nowMs:n,selected:a.key===t,onSelect:()=>s(a.key)},a.key))})]})]})}function bJ({item:e,nowMs:t,selected:n,onSelect:s}){return o.jsxs("button",{type:"button",className:gJ(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:[Ai(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 wJ({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 b=(w=m)=>{const j=eJ(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:XX.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(),b()},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=>b(w.currentTarget.value),onKeyDown:w=>{w.key==="Enter"&&(w.preventDefault(),b(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?Ai(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(jJ,{edge:w,active:u.has(w.id),selected:w.id===s,nodeLabels:d,onSelect:()=>l(w.id)},w.id))})]})]})}function jJ({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)??Bc(e.fromId,new Map)," ",o.jsx("span",{children:"→"})," ",s.get(e.toId)??Bc(e.toId,new Map)]}),o.jsx("span",{className:"s-warroom-flow-kind",children:yh(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 SJ({edge:e,nodeLabels:t,nowMs:n,navigate:s}){const a=t.get(e.fromId)??Bc(e.fromId,new Map),l=t.get(e.toId)??Bc(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:yh(e.kind)}),o.jsxs("span",{children:[Ai(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 NJ({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 ",Ai(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 kJ=[{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 EJ({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:kJ.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(aG,{navigate:e,agents:n}),t==="agents"&&o.jsx(kG,{navigate:e,agents:n}),t==="plan"&&o.jsx(WG,{navigate:e,agents:n}),t==="conductor"&&o.jsx(WY,{navigate:e,agents:n}),t==="warroom"&&o.jsx(yJ,{navigate:e,agents:n}),t==="tail"&&o.jsx(VX,{navigate:e}),t==="atop"&&o.jsx(wX,{})]})]})}function CJ({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=oy({url:CM(),healthUrl:TM(),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(cy,{relay:l,fontSize:13,quiet:!0})})]})}function TJ(e){return e.attention==="interrupt"?"failed":e.state==="done"?"completed":e.attention==="badge"||e.state==="waiting"||e.state==="review"?"updated":"working"}function Pg(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 AJ(e){switch(e){case"badge":return"Needs attention";case"interrupt":return"Blocked";default:return null}}function MJ(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 dk(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 zg({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 fk({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 RJ(e){const t=e.split(".");return t[t.length-1]||e}function _J({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 Me(`/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]),Mn(()=>{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=AJ(n.attention),m=n.ownerName??n.ownerId??"Unassigned",y=n.nextMoveOwnerName??n.nextMoveOwnerId??"—",b=[{label:"State",value:Pg(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:fi(n.createdAt)},{label:"Updated",value:fi(n.updatedAt)},{label:"Last activity",value:fi(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 ",RJ(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-${TJ(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 ",Pe(n.updatedAt)]}),o.jsx("span",{children:m}),o.jsx("span",{children:Pg(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(zg,{title:"Status",items:b}),o.jsx(zg,{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 ${Pe(N.startedAt)}`:"Start time unavailable"}),N.completedAt&&o.jsxs("span",{children:["Completed ",Pe(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:Pg(N.state)}),o.jsx("span",{children:Pe(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-${dk(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:Pe(N.at)}),o.jsx("span",{className:`s-work-timeline-kind s-work-timeline-kind-${dk(N)}`,children:MJ(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:fi(N.at)})]})]},N.id))})]})]}),o.jsxs("aside",{className:"s-work-casefile-side",children:[o.jsx(zg,{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(fk,{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(fk,{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 OJ(){const{route:e,navigate:t}=Nt();return o.jsx(IJ,{children:DJ(e,t)})}function IJ({children:e}){return o.jsx("div",{style:{background:"var(--bg)",color:"var(--ink)",minHeight:"100%",height:"100%",display:"flex",flexDirection:"column"},children:e})}function DJ(e,t){switch(e.view){case"conversation":return o.jsx($v,{conversationId:e.conversationId,initialComposeMode:e.composeMode,initialDraft:e.composeDraft,navigate:t});case"agent-info":return o.jsx(Jq,{conversationId:e.conversationId,navigate:t});case"settings":return o.jsx(zY,{navigate:t});case"agents":return o.jsx(pW,{navigate:t,selectedAgentId:e.agentId,conversationId:e.conversationId,tab:e.tab});case"fleet":return o.jsx(PN,{navigate:t});case"sessions":return e.sessionId?o.jsx($v,{conversationId:e.sessionId,navigate:t}):o.jsx(fY,{navigate:t});case"mesh":return o.jsx(QW,{navigate:t});case"activity":return o.jsx(Yq,{navigate:t});case"ops":return o.jsx(EJ,{navigate:t,mode:e.mode});case"terminal":return o.jsx(CJ,{agentId:e.agentId,navigate:t});case"work":return o.jsx(_J,{workId:e.workId,navigate:t});default:return o.jsx(PN,{navigate:t})}}function PJ(){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=>Ni(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(zJ,{agent:s,agents:t,navigate:n})}function zJ({agent:e,agents:t,navigate:n}){const s=Ni(e.state),[a,l]=g.useState(null),u=g.useCallback(async()=>{const d=await Me("/api/fleet").catch(()=>null);d&&l(d)},[]);return g.useEffect(()=>{u()},[u]),Mn(()=>{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(_o,{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 ",Pe(e.updatedAt)]})]}),o.jsx(_o,{label:"Presence",children:o.jsx(LJ,{focusAgent:e,agents:t,navigate:n})}),a&&o.jsx($J,{asks:a.activeAsks,agentId:e.id,navigate:n}),o.jsxs(_o,{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(_o,{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(_o,{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 LJ({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,b)=>{const w=2*Math.PI*b/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),b=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:[b&&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 $J({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(_o,{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 _o({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 UJ(){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=>Ni(a.state)),s=e.filter(a=>!Ni(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(hk,{label:"Online",count:n.length,children:n.map(a=>o.jsx(pk,{agent:a,navigate:t},a.id))}),s.length>0&&o.jsx(hk,{label:"Standby",count:s.length,children:s.map(a=>o.jsx(pk,{agent:a,navigate:t,dim:!0},a.id))})]})}function hk({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 pk({agent:e,navigate:t,dim:n}){const s=Ni(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:Pe(e.updatedAt)})]})}function BJ(){const{route:e}=Nt(),[t,n]=g.useState([]),s=g.useCallback(async()=>{try{n(await Me("/api/sessions"))}catch{}},[]);if(g.useEffect(()=>{s()},[s]),Mn(()=>{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(Ud,{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(Ud,{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(Ud,{label:"Activity",children:[o.jsx(Qs,{label:"Messages",value:`${a.messageCount}`}),a.lastMessageAt&&o.jsx(Qs,{label:"Last",value:Pe(a.lastMessageAt)}),a.participantIds.length>0&&o.jsx(Qs,{label:"Participants",value:`${a.participantIds.length}`})]}),a.preview&&o.jsx(Ud,{label:"Preview",children:o.jsxs("div",{className:"text-[11px] italic leading-relaxed text-[var(--scout-chrome-ink-soft)]",children:['"',a.preview,'"']})})]})}function Ud({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 VJ(){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 Me(`/api/work/${encodeURIComponent(t)}`))}catch{s(null)}},[t]);if(g.useEffect(()=>{a()},[a]),Mn(()=>{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=HJ(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 ",FJ(n.id)]}),o.jsx("div",{className:"text-[13px] leading-snug text-[var(--scout-chrome-ink-strong)]",children:n.title})]}),o.jsxs(Bd,{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(Bd,{label:"Ownership",children:[n.ownerName&&o.jsx(ko,{label:"Owner",value:n.ownerName}),n.nextMoveOwnerName&&o.jsx(ko,{label:"Next move",value:n.nextMoveOwnerName}),n.priority&&o.jsx(ko,{label:"Priority",value:n.priority})]}),o.jsxs(Bd,{label:"Activity",children:[o.jsx(ko,{label:"Children",value:`${n.activeChildWorkCount}`}),o.jsx(ko,{label:"Flights",value:`${n.activeFlightCount}`}),n.lastMeaningfulAt&&o.jsx(ko,{label:"Last update",value:Pe(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(Bd,{label:"Latest",children:o.jsx("div",{className:"text-[11px] italic leading-relaxed text-[var(--scout-chrome-ink-soft)]",children:n.lastMeaningfulSummary})})]})}function FJ(e){return e.length>10?`${e.slice(0,8)}…`:e}function HJ(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 Bd({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 ko({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 qJ=43115,ZJ=2e3,WJ=500;function YJ(e){return new GJ(e)}class GJ{base;clientId;probeTimeout;pollInterval;_state="unknown";constructor(t){if(t?.baseUrl)this.base=t.baseUrl.replace(/\/$/,"");else{const n=t?.port??qJ;this.base=`http://127.0.0.1:${n}`}this.clientId=t?.clientId??"vox-web",this.probeTimeout=t?.probeTimeout??ZJ,this.pollInterval=t?.pollInterval??WJ}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??JJ(n.type)??"wav";d.append("audio",n,`audio.${h}`)}else{const h=s??"wav",m=new Blob([n],{type:QJ(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 KJ(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 XJ(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 KJ{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 eQ(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,mk(l.data));return}l.result&&typeof l.result=="object"&&(s=mk(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:nQ(t.metrics)?t.metrics:void 0}}emitError(t){for(const n of this.errorListeners)n(t)}}function XJ(e){return new Promise(t=>setTimeout(t,e))}function JJ(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 QJ(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 eQ(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=tQ(a,t)}a+=s.decode();const l=a.trim();l&&t(LR(l))}finally{n.releaseLock()}}function tQ(e,t){let n=e;for(;;){const s=n.indexOf(`
|
|
158
|
-
`);if(s===-1)return n;const a=n.slice(0,s).trim();n=n.slice(s+1),a&&t(LR(a))}}function LR(e){try{return JSON.parse(e)}catch{throw new Es("Live session stream returned invalid JSON.","protocol_error")}}function mk(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function nQ(e){return!!(e&&typeof e=="object")}const sQ="http://127.0.0.1:43115",rQ="openscout-web";class Vd{constructor(t=sQ){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=xk(n),!1}}launch(t={}){window.location.href=gk("launch",{source:t.source,returnTo:t.returnTo??yk(),context:vk(t.context)})}openSettings(t={}){window.location.href=gk("settings",{source:t.source,returnTo:t.returnTo??yk(),context:vk(t.context)})}async startLive(t={}){const n=this.client.createLiveSession();let s=null;iQ(n,t,l=>{s=l});const a=n.start({modelId:"parakeet:v3"}).then(l=>(s??=$R(l),s)).catch(l=>{throw new Error(xk(l))});return{get sessionId(){return n.id},result:a,stop:async()=>{await n.stop()},cancel:async()=>{await n.cancel().catch(()=>{})}}}createClient(t=1200){return YJ({baseUrl:this.baseUrl,clientId:rQ,probeTimeout:t})}}async function aQ(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 iQ(e,t,n){e.onState(s=>t.onState?.(s.state)),e.onPartial(s=>t.onPartial?.(s.text)),e.onFinal(s=>{const a=$R(s);n(a),t.onFinal?.(a)})}function $R(e){return{sessionId:e.sessionId,text:e.text.trim(),durationMs:e.durationMs}}function gk(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 vk(e){if(e)return JSON.stringify(e)}function yk(){try{return window.location.origin}catch{return}}function xk(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 oQ="What's the state of things? Give me a terse ops summary, the biggest risk, and the next action you recommend.";function lQ(){const{agents:e,rangerAgentId:t,rangerConversationId:n,applyRangerUiAction:s,reload:a}=Nt(),l=g.useMemo(()=>e.find(Se=>Se.id===t)??e.find(rx)??null,[e,t]),[u,d]=g.useState(""),[p,h]=g.useState(!1),[m,y]=g.useState(null),[b,w]=g.useState(null),[j,N]=g.useState(null),[k,T]=g.useState("probing"),[E,S]=dQ("openscout.ranger.voiceReplies",!1),[M,R]=g.useState(!1),[A,_]=g.useState(null),[$,V]=g.useState(""),[U,O]=g.useState(!1),[P,q]=g.useState(null),[Z,H]=g.useState(null),[L,z]=g.useState(null),[B,X]=g.useState(!1),[W,I]=g.useState(!1),[F,G]=g.useState(!1),[J,ce]=g.useState(null),[se,ve]=g.useState(null),[me,je]=g.useState(""),[Ae,he]=g.useState(""),ue=g.useRef(null),de=g.useRef(null),Le=g.useRef(E);Le.current=E;const Te=g.useCallback(async()=>{I(!0),ce(null);try{const Se=await Me(`/api/agents/${encodeURIComponent(t)}/config`);je(Se.model??""),he(Se.systemPrompt),ve(null)}catch(Se){ce(Se instanceof Error?Se.message:"Could not load Ranger settings.")}finally{I(!1)}},[t]);g.useEffect(()=>{B&&Te()},[Te,B]);const we=g.useCallback(async()=>{G(!0),ce(null),ve(null);try{const Se=await Me(`/api/agents/${encodeURIComponent(t)}/config`,{method:"POST",body:JSON.stringify({model:me,systemPrompt:Ae,restart:!0})});je(Se.config.model??""),he(Se.config.systemPrompt),ve(Se.restarted?"Saved and restarted":"Saved"),await a()}catch(Se){ce(Se instanceof Error?Se.message:"Could not save Ranger settings.")}finally{G(!1)}},[me,Ae,t,a]),Ne=g.useCallback(async()=>{const Se=ue.current??new Vd;ue.current=Se,T("probing");const Be=await Se.probe();return w(Be),N(Be?null:Se.lastUnavailableReason??"Vox Companion is not reachable."),T("idle"),Be},[]);g.useEffect(()=>{Ne()},[Ne]);const _e=g.useCallback(()=>{const Se=ue.current??new Vd;ue.current=Se,y(null),T("launching"),Se.launch({source:"openscout",context:bk()}),window.setTimeout(()=>{Ne()},2400)},[Ne]),Fe=g.useCallback(()=>{const Se=ue.current??new Vd;ue.current=Se,Se.openSettings({source:"openscout",context:bk()})},[]),Ve=g.useCallback(async Se=>{const Be=Se.trim();if(!(!Be||p)){h(!0),y(null),q(Be),H(null),z("Sending to Ranger");try{await Me("/api/ask",{method:"POST",body:JSON.stringify({body:Be,conversationId:n})}),d(""),z("Waiting for Ranger")}catch(ze){z(null),y(ze instanceof Error?ze.message:"Could not ask Ranger.")}finally{h(!1)}}},[n,p]),ie=g.useCallback(async()=>{if(M)return;const Se=ue.current??new Vd;if(ue.current=Se,y(null),V(""),_("starting"),b!==!0&&!await Ne()){_(null);return}try{const Be=await Se.startLive({onState:_,onPartial:V});de.current=Be,R(!0);const ze=await Be.result;R(!1),de.current=null,V(""),_("done"),ze.text&&await Ve(ze.text)}catch(Be){R(!1),de.current=null,_("error"),y(Be instanceof Error?Be.message:"Vox recording failed.")}},[Ve,Ne,M,b]),ye=g.useCallback(async()=>{_("processing"),await de.current?.stop()},[]),be=g.useCallback(async()=>{await de.current?.cancel(),de.current=null,R(!1),V(""),_(null)},[]);Mn(Se=>{if(Se.kind!=="message.posted")return;const Be=Se.payload&&typeof Se.payload=="object"?Se.payload.message:null;if(!Be||typeof Be!="object")return;const ze=Be,bt=typeof ze.conversationId=="string"?ze.conversationId:"";if(bt&&bt!==n||typeof ze.actorId!="string"||!pM(ze.actorId,t)||typeof ze.body!="string"||!ze.body.trim())return;const kt=cQ(ze.body);kt&&(H(kt),z("Ranger replied"),Le.current&&(O(!0),aQ(kt).catch(un=>y(un instanceof Error?un.message:"Vox speech failed.")).finally(()=>O(!1))))});const ke=M?A==="processing"?"Sending":"Stop":k==="probing"?"Checking Vox":k==="launching"?"Opening Vox":b===!1?"Launch Vox":"Start Talking",Ee=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(gO,{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," · ",Ee,l?.model?` · ${l.model}`:""]})]}),o.jsx("button",{type:"button",title:"Ranger settings",onClick:()=>X(Se=>!Se),className:`rounded border p-1.5 transition-colors ${B?"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(Mk,{size:13})})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsx(Fd,{icon:o.jsx(TO,{size:13}),label:"State",onClick:()=>{Ve(oQ)},disabled:p}),o.jsx(Fd,{icon:o.jsx(NO,{size:13}),label:"Ops Tail",onClick:()=>s({type:"navigate",route:{view:"ops",mode:"tail"}})}),o.jsx(Fd,{icon:o.jsx(Tk,{size:13}),label:"Fleet",onClick:()=>s({type:"navigate",route:{view:"fleet"}})}),o.jsx(Fd,{icon:E?o.jsx(FO,{size:13}):o.jsx(qO,{size:13}),label:E?"Replies On":"Replies Off",onClick:()=>S(!E)})]}),B&&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:me,onChange:Se=>je(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:W||F})]}),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:Ae,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:W||F})]}),J&&o.jsx("div",{className:"font-mono text-[10px] leading-relaxed text-red-300",children:J}),se&&o.jsx("div",{className:"font-mono text-[10px] leading-relaxed text-lime-200",children:se}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("button",{type:"button",onClick:()=>{we()},disabled:W||F||!Ae.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:[(W||F)&&o.jsx(pc,{size:13,className:"animate-spin"}),F?"Saving":"Save"]}),o.jsx("button",{type:"button",onClick:()=>{Te()},disabled:W||F,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"})]})]})}),b===!1&&o.jsx(uQ,{issue:j,probeState:k,onLaunch:_e,onRetry:()=>{Ne()},onSettings:Fe}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs("button",{type:"button",onClick:()=>{if(b===!1){_e();return}M?ye():ie()},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 ${M?"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||A==="processing"||k==="probing",children:[A==="processing"||k==="probing"?o.jsx(pc,{size:13,className:"animate-spin"}):M?o.jsx($O,{size:12,className:"fill-current"}):o.jsx(EO,{size:13}),ke]}),M&&o.jsx("button",{type:"button",onClick:()=>{be()},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"})]}),($||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…":$}),(P||Z||L)&&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:[L&&o.jsx("div",{className:"mb-1 uppercase tracking-[0.12em] text-[var(--scout-chrome-ink-ghost)]",children:L}),P&&o.jsxs("p",{className:"line-clamp-3",children:[o.jsx("span",{className:"text-[var(--scout-chrome-ink-soft)]",children:"You: "}),P]}),Z?o.jsxs("p",{className:"mt-1 line-clamp-4",children:[o.jsx("span",{className:"text-lime-200",children:"Ranger: "}),Z]}):L==="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(),Ve(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(pc,{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 cQ(e){return e.replace(/```(?:scout-ui|scout-ui-action|ranger-ui)\s*[\s\S]*?```/gi,"").trim()}function bk(){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 Fd({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 uQ({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(N1,{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(Lg,{icon:t==="launching"?o.jsx(pc,{size:12,className:"animate-spin"}):o.jsx(N1,{size:12}),label:t==="launching"?"Opening":"Launch",onClick:n,disabled:t==="probing",title:"Open Vox"}),o.jsx(Lg,{icon:t==="probing"?o.jsx(pc,{size:12,className:"animate-spin"}):o.jsx(Ak,{size:12}),label:"Retry",onClick:s,disabled:l,title:"Check Vox again"}),o.jsx(Lg,{icon:o.jsx(Mk,{size:12}),label:"Settings",onClick:a,disabled:t==="probing",title:"Open Vox settings"})]})]})}function Lg({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 dQ(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 fQ(){const{route:e}=Nt();let t=null;switch(e.view){case"inbox":case"fleet":t=o.jsx(UJ,{});break;case"agents":case"agent-info":t=o.jsx(PJ,{});break;case"sessions":case"conversation":t=o.jsx(BJ,{});break;case"work":t=o.jsx(VJ,{});break;case"ops":t=null;break;default:t=null}return o.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[o.jsx(lQ,{}),o.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t})]})}function hQ(){const{openSettings:e}=Nt();return o.jsx(hq,{onOpen:e})}const Eo={working:0,available:1,offline:2};function pQ(e){return e.project?e.project.toLowerCase():"other"}function mQ(e){const t=new Map;for(const s of e){const a=pQ(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=(Eo[et(d.state)]??9)-(Eo[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(Eo[h]??9)<(Eo[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=(Eo[s.bestState]??9)-(Eo[a.bestState]??9);return l!==0?l:a.latestUpdate-s.latestUpdate}),n}function gQ(e){return e.trim().toLowerCase()}function vQ(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 yQ(e,t){return t?vQ(e).some(n=>n.toLowerCase().includes(t)):!0}function Co(e,t){return t?[e.harnessSessionId,e.conversationId].find(s=>s?.toLowerCase().includes(t))??null:null}function $g(e,t,n={}){e({view:"agents",agentId:t.id,...n.observe?{conversationId:t.conversationId,tab:"observe"}:{}})}function xQ(){const{agents:e,route:t,navigate:n}=Nt(),[s,a]=g.useState(()=>new Set),[l,u]=g.useState(""),d=gQ(l),p=d.length>0,h=g.useMemo(()=>e.filter(j=>yQ(j,d)),[e,d]),m=g.useMemo(()=>mQ(h),[h]),y=h[0]??null,b=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&&$g(n,y,{observe:!!Co(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),T=N?j.agents[0]:null,E=j.agents.some(M=>M.id===b),S=T?Co(T,d):null;return o.jsxs("div",{className:"s-left-roster-parent",children:[o.jsxs("button",{className:`s-left-roster-row${E&&(N||!k)?" s-left-roster-row--active":""}`,onClick:()=>{N?$g(n,T,{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&&(T.project||T.branch)&&o.jsxs("span",{className:"s-left-roster-sub",children:[T.name,T.branch?` · ${T.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&&T.updatedAt&&o.jsx("span",{className:"s-left-roster-time",children:Pe(T.updatedAt)})]}),!N&&k&&o.jsx("div",{className:"s-left-roster-instances",children:j.agents.map(M=>o.jsxs("button",{className:`s-left-roster-instance${M.id===b?" s-left-roster-instance--active":""}`,onClick:()=>$g(n,M,{observe:!!Co(M,d)}),title:Co(M,d)??void 0,children:[o.jsx("span",{className:`s-left-roster-instance-dot s-left-roster-dot--${et(M.state)}`,style:{background:Ur(M.state)}}),o.jsxs("span",{className:"s-left-roster-instance-label",children:[M.name,M.branch?` · ${M.branch}`:"",Co(M,d)?` · ${Co(M,d)}`:""]}),M.updatedAt&&o.jsx("span",{className:"s-left-roster-time",children:Pe(M.updatedAt)})]},M.id))})]},j.key)})})]})}function bQ(){const e=oy({url:CM(),healthUrl:TM(),autoConnect:!0,sessionKey:"scout-terminal"});return o.jsx("div",{style:{height:"100%",background:"#0d0d0d",overflow:"hidden"},children:o.jsx(cy,{relay:e,fontSize:13})})}function wQ(){const{onboarding:e}=Nt();return e?e.hasLocalConfig?e.hasOperatorName?e.hasProjectConfig?null:o.jsx(Ug,{children:o.jsx(NQ,{})}):o.jsx(Ug,{children:o.jsx(SQ,{})}):o.jsx(Ug,{children:o.jsx(jQ,{})}):null}function Ug({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 bx({eyebrow:e,title:t,description:n}){return o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[o.jsx("div",{style:kQ,children:e}),o.jsx("div",{style:EQ,children:t}),o.jsx("div",{style:CQ,children:n})]})}function wx({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:{...AQ,opacity:n||s?.5:1,cursor:n||s?"default":"pointer"},children:s?"Working…":e}),o.jsx("button",{type:"button",onClick:a,style:MQ,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 jx({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 jQ(){const{onboarding:e,refreshOnboarding:t}=Nt(),[n,s]=g.useState(!1),[a,l]=g.useState(null),u=async()=>{s(!0),l(null);try{await Me("/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(bx,{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:Kv,children:"~/.openscout/config.json"})," with sensible defaults — you can edit it any time."]})}),o.jsxs("ul",{style:RQ,children:[o.jsx(wk,{label:"Local config (~/.openscout/config.json)",done:!1,hint:"missing"}),o.jsx(wk,{label:".openscout/project.json in a repo",done:!!e?.hasProjectConfig,hint:e?.hasProjectConfig?e.projectRoot??void 0:"checked after setup"})]}),o.jsx(jx,{message:a}),o.jsx(wx,{primary:"Initialize Scout",onPrimary:()=>{u()},busy:n})]})}function SQ(){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 Me("/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(bx,{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:cf,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:Gv}),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(jx,{message:d}),o.jsx(wx,{primary:"Continue",onPrimary:()=>{h()},busy:l,primaryDisabled:!s.trim()})]})}function NQ(){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,b]=g.useState(null),w=(T,E)=>{a(S=>S.map((M,R)=>R===T?E:M))},j=()=>a(T=>[...T,""]),N=T=>a(E=>E.filter((S,M)=>M!==T)),k=async()=>{const T=s.map(S=>S.trim()).filter(Boolean),E=l.trim();if(!E){b("Pick where Scout should anchor this context.");return}m(!0),b(null);try{await Me("/api/onboarding/project",{method:"POST",body:JSON.stringify({contextRoot:E,sourceRoots:T,defaultHarness:d})}),await t()}catch(S){b(S instanceof Error?S.message:String(S))}finally{m(!1)}};return o.jsxs(o.Fragment,{children:[o.jsx(bx,{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:Kv,children:"<context>/.openscout/project.json"}),"."]})}),o.jsxs("div",{style:Bg,children:[o.jsx("label",{style:cf,children:"Scan folders"}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[s.map((T,E)=>o.jsxs("div",{style:{display:"flex",gap:8},children:[o.jsx("input",{value:T,onChange:S=>w(E,S.target.value),placeholder:E===0?"~/dev":"Add another folder",style:{...Gv,flex:1}}),o.jsx("button",{type:"button",onClick:()=>N(E),disabled:s.length<=1,style:{...jk,opacity:s.length<=1?.4:1,cursor:s.length<=1?"default":"pointer"},"aria-label":`Remove folder ${E+1}`,children:"−"})]},E)),o.jsx("button",{type:"button",onClick:j,style:{...jk,alignSelf:"flex-start"},children:"+ Add folder"})]})]}),o.jsxs("div",{style:Bg,children:[o.jsx("label",{style:cf,children:"Context root"}),o.jsx("input",{value:l,onChange:T=>u(T.target.value),placeholder:"~/dev",style:Gv}),o.jsxs("div",{style:TQ,children:["Scout writes ",o.jsx("code",{style:Kv,children:".openscout/project.json"})," ","inside this folder."]})]}),o.jsxs("div",{style:Bg,children:[o.jsx("label",{style:cf,children:"Default harness"}),o.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:["claude","codex"].map(T=>{const E=d===T;return o.jsxs("button",{type:"button",onClick:()=>p(T),style:{..._Q,borderColor:E?"var(--accent, #2dd4bf)":"rgba(255,255,255,0.12)",backgroundColor:E?"rgba(45,212,191,0.08)":"rgba(255,255,255,0.02)"},children:[o.jsx("div",{style:{fontSize:15,fontWeight:600,textTransform:"capitalize"},children:T}),o.jsx("div",{style:{fontSize:12,color:"rgba(255,255,255,0.55)",marginTop:6,lineHeight:1.5},children:T==="claude"?"Anthropic Claude Code — local CLI agent.":"OpenAI Codex — cloud agentic sandbox."})]},T)})})]}),o.jsx(jx,{message:y}),o.jsx(wx,{primary:"Create project",onPrimary:()=>{k()},busy:h,primaryDisabled:!l.trim()})]})}function wk({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 kQ={fontSize:11,fontFamily:"var(--hud-font-mono)",textTransform:"uppercase",letterSpacing:"0.18em",color:"rgba(255,255,255,0.4)"},EQ={fontSize:36,fontWeight:600,letterSpacing:"-0.01em",lineHeight:1.15},CQ={fontSize:15,lineHeight:1.75,color:"rgba(255,255,255,0.6)",maxWidth:580},Bg={display:"flex",flexDirection:"column",gap:10},cf={fontSize:11,fontFamily:"var(--hud-font-mono)",textTransform:"uppercase",letterSpacing:"0.15em",color:"rgba(255,255,255,0.5)"},Gv={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"},TQ={fontSize:12,color:"rgba(255,255,255,0.45)",lineHeight:1.6},Kv={fontFamily:"var(--hud-font-mono)",fontSize:12,padding:"2px 6px",borderRadius:4,backgroundColor:"rgba(255,255,255,0.06)"},AQ={fontSize:13,fontWeight:600,padding:"12px 24px",borderRadius:10,backgroundColor:"var(--accent, #2dd4bf)",color:"#0b0d12",border:"none",transition:"opacity 0.15s ease"},jk={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"},MQ={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"},RQ={display:"flex",flexDirection:"column",gap:20,margin:0,padding:0,listStyle:"none"},_Q={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"},OQ=[{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 UR(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(Tk,{size:14,strokeWidth:1.2}),Provider:({children:n})=>g.createElement(yq,{initialTheme:t},n),leftPanel:{title:"Agents"},rightPanel:{title:"Context"},slots:{Content:OJ,LeftPanel:xQ,LeftFooter:hQ,Inspector:fQ,Takeover:wQ,Terminal:bQ},intents:OQ,hooks:{useCommands:xq,useStatus:bq,useNavCenter:jq,useNavActions:Sq,useLayoutMode:Nq,useTakeover:kq}}}UR();function Sk(e){return e==="dark"||e==="light"?e:null}function IQ(){if(typeof window>"u")return"dark";const e=Sk(lZ());if(e)return e;const t=Sk(new URLSearchParams(window.location.search).get("theme"));return t||"dark"}function DQ(e){typeof document>"u"||(document.documentElement.dataset.scoutThemeMode=e,document.documentElement.style.colorScheme=e)}const BR=document.getElementById("root");if(!BR)throw new Error("missing #root");const VR=IQ();DQ(VR);cO.createRoot(BR).render(o.jsx(g.StrictMode,{children:o.jsx(Eq,{app:UR({initialTheme:VR})})}));export{kk as F,Oo as f,o as j,g as r};
|