@openscout/scout 0.2.58 → 0.2.61
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/dist/client/assets/{arc.es-Bkj9Bkvx.js → arc.es-DgeMPL-I.js} +1 -1
- package/dist/client/assets/index-25TJx0iN.js +140 -0
- package/dist/client/assets/index-B1kglsyi.css +1 -0
- package/dist/client/index.html +2 -2
- package/dist/main.mjs +2576 -4579
- package/dist/pair-supervisor.mjs +1127 -2405
- package/dist/scout-control-plane-web.mjs +798 -2939
- package/package.json +2 -2
- package/dist/client/assets/index-BDyu05Hi.js +0 -140
- package/dist/client/assets/index-pbcZpgCR.css +0 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
function pM(e,t){for(var n=0;n<t.length;n++){const a=t[n];if(typeof a!="string"&&!Array.isArray(a)){for(const i in a)if(i!=="default"&&!(i in e)){const c=Object.getOwnPropertyDescriptor(a,i);c&&Object.defineProperty(e,i,c.get?c:{enumerable:!0,get:()=>a[i]})}}}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 i of document.querySelectorAll('link[rel="modulepreload"]'))a(i);new MutationObserver(i=>{for(const c of i)if(c.type==="childList")for(const u of c.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&a(u)}).observe(document,{childList:!0,subtree:!0});function n(i){const c={};return i.integrity&&(c.integrity=i.integrity),i.referrerPolicy&&(c.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?c.credentials="include":i.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function a(i){if(i.ep)return;i.ep=!0;const c=n(i);fetch(i.href,c)}})();function Dj(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Dm={exports:{}},Cl={};var Yb;function gM(){if(Yb)return Cl;Yb=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(a,i,c){var u=null;if(c!==void 0&&(u=""+c),i.key!==void 0&&(u=""+i.key),"key"in i){c={};for(var f in i)f!=="key"&&(c[f]=i[f])}else c=i;return i=c.ref,{$$typeof:e,type:a,key:u,ref:i!==void 0?i:null,props:c}}return Cl.Fragment=t,Cl.jsx=n,Cl.jsxs=n,Cl}var Gb;function vM(){return Gb||(Gb=1,Dm.exports=gM()),Dm.exports}var o=vM(),zm={exports:{}},Fe={};var Wb;function yM(){if(Wb)return Fe;Wb=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),u=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),x=Symbol.for("react.activity"),b=Symbol.iterator;function w(z){return z===null||typeof z!="object"?null:(z=b&&z[b]||z["@@iterator"],typeof z=="function"?z:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,T={};function k(z,Y,W){this.props=z,this.context=Y,this.refs=T,this.updater=W||j}k.prototype.isReactComponent={},k.prototype.setState=function(z,Y){if(typeof z!="object"&&typeof z!="function"&&z!=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,z,Y,"setState")},k.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function C(){}C.prototype=k.prototype;function S(z,Y,W){this.props=z,this.context=Y,this.refs=T,this.updater=W||j}var R=S.prototype=new C;R.constructor=S,N(R,k.prototype),R.isPureReactComponent=!0;var A=Array.isArray;function _(){}var O={H:null,A:null,T:null,S:null},V=Object.prototype.hasOwnProperty;function Z(z,Y,W){var J=W.ref;return{$$typeof:e,type:z,key:Y,ref:J!==void 0?J:null,props:W}}function I(z,Y){return Z(z.type,Y,z.props)}function $(z){return typeof z=="object"&&z!==null&&z.$$typeof===e}function L(z){var Y={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(W){return Y[W]})}var P=/\/+/g;function q(z,Y){return typeof z=="object"&&z!==null&&z.key!=null?L(""+z.key):Y.toString(36)}function ee(z){switch(z.status){case"fulfilled":return z.value;case"rejected":throw z.reason;default:switch(typeof z.status=="string"?z.then(_,_):(z.status="pending",z.then(function(Y){z.status==="pending"&&(z.status="fulfilled",z.value=Y)},function(Y){z.status==="pending"&&(z.status="rejected",z.reason=Y)})),z.status){case"fulfilled":return z.value;case"rejected":throw z.reason}}throw z}function D(z,Y,W,J,de){var ae=typeof z;(ae==="undefined"||ae==="boolean")&&(z=null);var ye=!1;if(z===null)ye=!0;else switch(ae){case"bigint":case"string":case"number":ye=!0;break;case"object":switch(z.$$typeof){case e:case t:ye=!0;break;case g:return ye=z._init,D(ye(z._payload),Y,W,J,de)}}if(ye)return de=de(z),ye=J===""?"."+q(z,0):J,A(de)?(W="",ye!=null&&(W=ye.replace(P,"$&/")+"/"),D(de,Y,W,"",function(_e){return _e})):de!=null&&($(de)&&(de=I(de,W+(de.key==null||z&&z.key===de.key?"":(""+de.key).replace(P,"$&/")+"/")+ye)),Y.push(de)),1;ye=0;var ve=J===""?".":J+":";if(A(z))for(var be=0;be<z.length;be++)J=z[be],ae=ve+q(J,be),ye+=D(J,Y,W,ae,de);else if(be=w(z),typeof be=="function")for(z=be.call(z),be=0;!(J=z.next()).done;)J=J.value,ae=ve+q(J,be++),ye+=D(J,Y,W,ae,de);else if(ae==="object"){if(typeof z.then=="function")return D(ee(z),Y,W,J,de);throw Y=String(z),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys(z).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.")}return ye}function U(z,Y,W){if(z==null)return z;var J=[],de=0;return D(z,J,"","",function(ae){return Y.call(W,ae,de++)}),J}function B(z){if(z._status===-1){var Y=z._result;Y=Y(),Y.then(function(W){(z._status===0||z._status===-1)&&(z._status=1,z._result=W)},function(W){(z._status===0||z._status===-1)&&(z._status=2,z._result=W)}),z._status===-1&&(z._status=0,z._result=Y)}if(z._status===1)return z._result.default;throw z._result}var G=typeof reportError=="function"?reportError:function(z){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Y=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof z=="object"&&z!==null&&typeof z.message=="string"?String(z.message):String(z),error:z});if(!window.dispatchEvent(Y))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",z);return}console.error(z)},K={map:U,forEach:function(z,Y,W){U(z,function(){Y.apply(this,arguments)},W)},count:function(z){var Y=0;return U(z,function(){Y++}),Y},toArray:function(z){return U(z,function(Y){return Y})||[]},only:function(z){if(!$(z))throw Error("React.Children.only expected to receive a single React element child.");return z}};return Fe.Activity=x,Fe.Children=K,Fe.Component=k,Fe.Fragment=n,Fe.Profiler=i,Fe.PureComponent=S,Fe.StrictMode=a,Fe.Suspense=m,Fe.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=O,Fe.__COMPILER_RUNTIME={__proto__:null,c:function(z){return O.H.useMemoCache(z)}},Fe.cache=function(z){return function(){return z.apply(null,arguments)}},Fe.cacheSignal=function(){return null},Fe.cloneElement=function(z,Y,W){if(z==null)throw Error("The argument must be a React element, but you passed "+z+".");var J=N({},z.props),de=z.key;if(Y!=null)for(ae in Y.key!==void 0&&(de=""+Y.key),Y)!V.call(Y,ae)||ae==="key"||ae==="__self"||ae==="__source"||ae==="ref"&&Y.ref===void 0||(J[ae]=Y[ae]);var ae=arguments.length-2;if(ae===1)J.children=W;else if(1<ae){for(var ye=Array(ae),ve=0;ve<ae;ve++)ye[ve]=arguments[ve+2];J.children=ye}return Z(z.type,de,J)},Fe.createContext=function(z){return z={$$typeof:u,_currentValue:z,_currentValue2:z,_threadCount:0,Provider:null,Consumer:null},z.Provider=z,z.Consumer={$$typeof:c,_context:z},z},Fe.createElement=function(z,Y,W){var J,de={},ae=null;if(Y!=null)for(J in Y.key!==void 0&&(ae=""+Y.key),Y)V.call(Y,J)&&J!=="key"&&J!=="__self"&&J!=="__source"&&(de[J]=Y[J]);var ye=arguments.length-2;if(ye===1)de.children=W;else if(1<ye){for(var ve=Array(ye),be=0;be<ye;be++)ve[be]=arguments[be+2];de.children=ve}if(z&&z.defaultProps)for(J in ye=z.defaultProps,ye)de[J]===void 0&&(de[J]=ye[J]);return Z(z,ae,de)},Fe.createRef=function(){return{current:null}},Fe.forwardRef=function(z){return{$$typeof:f,render:z}},Fe.isValidElement=$,Fe.lazy=function(z){return{$$typeof:g,_payload:{_status:-1,_result:z},_init:B}},Fe.memo=function(z,Y){return{$$typeof:h,type:z,compare:Y===void 0?null:Y}},Fe.startTransition=function(z){var Y=O.T,W={};O.T=W;try{var J=z(),de=O.S;de!==null&&de(W,J),typeof J=="object"&&J!==null&&typeof J.then=="function"&&J.then(_,G)}catch(ae){G(ae)}finally{Y!==null&&W.types!==null&&(Y.types=W.types),O.T=Y}},Fe.unstable_useCacheRefresh=function(){return O.H.useCacheRefresh()},Fe.use=function(z){return O.H.use(z)},Fe.useActionState=function(z,Y,W){return O.H.useActionState(z,Y,W)},Fe.useCallback=function(z,Y){return O.H.useCallback(z,Y)},Fe.useContext=function(z){return O.H.useContext(z)},Fe.useDebugValue=function(){},Fe.useDeferredValue=function(z,Y){return O.H.useDeferredValue(z,Y)},Fe.useEffect=function(z,Y){return O.H.useEffect(z,Y)},Fe.useEffectEvent=function(z){return O.H.useEffectEvent(z)},Fe.useId=function(){return O.H.useId()},Fe.useImperativeHandle=function(z,Y,W){return O.H.useImperativeHandle(z,Y,W)},Fe.useInsertionEffect=function(z,Y){return O.H.useInsertionEffect(z,Y)},Fe.useLayoutEffect=function(z,Y){return O.H.useLayoutEffect(z,Y)},Fe.useMemo=function(z,Y){return O.H.useMemo(z,Y)},Fe.useOptimistic=function(z,Y){return O.H.useOptimistic(z,Y)},Fe.useReducer=function(z,Y,W){return O.H.useReducer(z,Y,W)},Fe.useRef=function(z){return O.H.useRef(z)},Fe.useState=function(z){return O.H.useState(z)},Fe.useSyncExternalStore=function(z,Y,W){return O.H.useSyncExternalStore(z,Y,W)},Fe.useTransition=function(){return O.H.useTransition()},Fe.version="19.2.3",Fe}var Xb;function uc(){return Xb||(Xb=1,zm.exports=yM()),zm.exports}var v=uc();const lo=Dj(v),zj=pM({__proto__:null,default:lo},[v]);var Lm={exports:{}},Tl={},$m={exports:{}},Pm={};var Kb;function xM(){return Kb||(Kb=1,(function(e){function t(D,U){var B=D.length;D.push(U);e:for(;0<B;){var G=B-1>>>1,K=D[G];if(0<i(K,U))D[G]=U,D[B]=K,B=G;else break e}}function n(D){return D.length===0?null:D[0]}function a(D){if(D.length===0)return null;var U=D[0],B=D.pop();if(B!==U){D[0]=B;e:for(var G=0,K=D.length,z=K>>>1;G<z;){var Y=2*(G+1)-1,W=D[Y],J=Y+1,de=D[J];if(0>i(W,B))J<K&&0>i(de,W)?(D[G]=de,D[J]=B,G=J):(D[G]=W,D[Y]=B,G=Y);else if(J<K&&0>i(de,B))D[G]=de,D[J]=B,G=J;else break e}}return U}function i(D,U){var B=D.sortIndex-U.sortIndex;return B!==0?B:D.id-U.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var u=Date,f=u.now();e.unstable_now=function(){return u.now()-f}}var m=[],h=[],g=1,x=null,b=3,w=!1,j=!1,N=!1,T=!1,k=typeof setTimeout=="function"?setTimeout:null,C=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;function R(D){for(var U=n(h);U!==null;){if(U.callback===null)a(h);else if(U.startTime<=D)a(h),U.sortIndex=U.expirationTime,t(m,U);else break;U=n(h)}}function A(D){if(N=!1,R(D),!j)if(n(m)!==null)j=!0,_||(_=!0,L());else{var U=n(h);U!==null&&ee(A,U.startTime-D)}}var _=!1,O=-1,V=5,Z=-1;function I(){return T?!0:!(e.unstable_now()-Z<V)}function $(){if(T=!1,_){var D=e.unstable_now();Z=D;var U=!0;try{e:{j=!1,N&&(N=!1,C(O),O=-1),w=!0;var B=b;try{t:{for(R(D),x=n(m);x!==null&&!(x.expirationTime>D&&I());){var G=x.callback;if(typeof G=="function"){x.callback=null,b=x.priorityLevel;var K=G(x.expirationTime<=D);if(D=e.unstable_now(),typeof K=="function"){x.callback=K,R(D),U=!0;break t}x===n(m)&&a(m),R(D)}else a(m);x=n(m)}if(x!==null)U=!0;else{var z=n(h);z!==null&&ee(A,z.startTime-D),U=!1}}break e}finally{x=null,b=B,w=!1}U=void 0}}finally{U?L():_=!1}}}var L;if(typeof S=="function")L=function(){S($)};else if(typeof MessageChannel<"u"){var P=new MessageChannel,q=P.port2;P.port1.onmessage=$,L=function(){q.postMessage(null)}}else L=function(){k($,0)};function ee(D,U){O=k(function(){D(e.unstable_now())},U)}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(D){D.callback=null},e.unstable_forceFrameRate=function(D){0>D||125<D?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):V=0<D?Math.floor(1e3/D):5},e.unstable_getCurrentPriorityLevel=function(){return b},e.unstable_next=function(D){switch(b){case 1:case 2:case 3:var U=3;break;default:U=b}var B=b;b=U;try{return D()}finally{b=B}},e.unstable_requestPaint=function(){T=!0},e.unstable_runWithPriority=function(D,U){switch(D){case 1:case 2:case 3:case 4:case 5:break;default:D=3}var B=b;b=D;try{return U()}finally{b=B}},e.unstable_scheduleCallback=function(D,U,B){var G=e.unstable_now();switch(typeof B=="object"&&B!==null?(B=B.delay,B=typeof B=="number"&&0<B?G+B:G):B=G,D){case 1:var K=-1;break;case 2:K=250;break;case 5:K=1073741823;break;case 4:K=1e4;break;default:K=5e3}return K=B+K,D={id:g++,callback:U,priorityLevel:D,startTime:B,expirationTime:K,sortIndex:-1},B>G?(D.sortIndex=B,t(h,D),n(m)===null&&D===n(h)&&(N?(C(O),O=-1):N=!0,ee(A,B-G))):(D.sortIndex=K,t(m,D),j||w||(j=!0,_||(_=!0,L()))),D},e.unstable_shouldYield=I,e.unstable_wrapCallback=function(D){var U=b;return function(){var B=b;b=U;try{return D.apply(this,arguments)}finally{b=B}}}})(Pm)),Pm}var Jb;function bM(){return Jb||(Jb=1,$m.exports=xM()),$m.exports}var Um={exports:{}},Rn={};var Qb;function wM(){if(Qb)return Rn;Qb=1;var e=uc();function t(m){var h="https://react.dev/errors/"+m;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var g=2;g<arguments.length;g++)h+="&args[]="+encodeURIComponent(arguments[g])}return"Minified React error #"+m+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var a={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},i=Symbol.for("react.portal");function c(m,h,g){var x=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:x==null?null:""+x,children:m,containerInfo:h,implementation:g}}var u=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function f(m,h){if(m==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return Rn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,Rn.createPortal=function(m,h){var g=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 c(m,h,null,g)},Rn.flushSync=function(m){var h=u.T,g=a.p;try{if(u.T=null,a.p=2,m)return m()}finally{u.T=h,a.p=g,a.d.f()}},Rn.preconnect=function(m,h){typeof m=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,a.d.C(m,h))},Rn.prefetchDNS=function(m){typeof m=="string"&&a.d.D(m)},Rn.preinit=function(m,h){if(typeof m=="string"&&h&&typeof h.as=="string"){var g=h.as,x=f(g,h.crossOrigin),b=typeof h.integrity=="string"?h.integrity:void 0,w=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;g==="style"?a.d.S(m,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:x,integrity:b,fetchPriority:w}):g==="script"&&a.d.X(m,{crossOrigin:x,integrity:b,fetchPriority:w,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},Rn.preinitModule=function(m,h){if(typeof m=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var g=f(h.as,h.crossOrigin);a.d.M(m,{crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&a.d.M(m)},Rn.preload=function(m,h){if(typeof m=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var g=h.as,x=f(g,h.crossOrigin);a.d.L(m,g,{crossOrigin:x,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})}},Rn.preloadModule=function(m,h){if(typeof m=="string")if(h){var g=f(h.as,h.crossOrigin);a.d.m(m,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else a.d.m(m)},Rn.requestFormReset=function(m){a.d.r(m)},Rn.unstable_batchedUpdates=function(m,h){return m(h)},Rn.useFormState=function(m,h,g){return u.H.useFormState(m,h,g)},Rn.useFormStatus=function(){return u.H.useHostTransitionStatus()},Rn.version="19.2.3",Rn}var ew;function Lj(){if(ew)return Um.exports;ew=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(),Um.exports=wM(),Um.exports}var tw;function SM(){if(tw)return Tl;tw=1;var e=bM(),t=uc(),n=Lj();function a(s){var r="https://react.dev/errors/"+s;if(1<arguments.length){r+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)r+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+s+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function c(s){var r=s,l=s;if(s.alternate)for(;r.return;)r=r.return;else{s=r;do r=s,(r.flags&4098)!==0&&(l=r.return),s=r.return;while(s)}return r.tag===3?l:null}function u(s){if(s.tag===13){var r=s.memoizedState;if(r===null&&(s=s.alternate,s!==null&&(r=s.memoizedState)),r!==null)return r.dehydrated}return null}function f(s){if(s.tag===31){var r=s.memoizedState;if(r===null&&(s=s.alternate,s!==null&&(r=s.memoizedState)),r!==null)return r.dehydrated}return null}function m(s){if(c(s)!==s)throw Error(a(188))}function h(s){var r=s.alternate;if(!r){if(r=c(s),r===null)throw Error(a(188));return r!==s?null:s}for(var l=s,d=r;;){var p=l.return;if(p===null)break;var y=p.alternate;if(y===null){if(d=p.return,d!==null){l=d;continue}break}if(p.child===y.child){for(y=p.child;y;){if(y===l)return m(p),s;if(y===d)return m(p),r;y=y.sibling}throw Error(a(188))}if(l.return!==d.return)l=p,d=y;else{for(var E=!1,M=p.child;M;){if(M===l){E=!0,l=p,d=y;break}if(M===d){E=!0,d=p,l=y;break}M=M.sibling}if(!E){for(M=y.child;M;){if(M===l){E=!0,l=y,d=p;break}if(M===d){E=!0,d=y,l=p;break}M=M.sibling}if(!E)throw Error(a(189))}}if(l.alternate!==d)throw Error(a(190))}if(l.tag!==3)throw Error(a(188));return l.stateNode.current===l?s:r}function g(s){var r=s.tag;if(r===5||r===26||r===27||r===6)return s;for(s=s.child;s!==null;){if(r=g(s),r!==null)return r;s=s.sibling}return null}var x=Object.assign,b=Symbol.for("react.element"),w=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),C=Symbol.for("react.consumer"),S=Symbol.for("react.context"),R=Symbol.for("react.forward_ref"),A=Symbol.for("react.suspense"),_=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),V=Symbol.for("react.lazy"),Z=Symbol.for("react.activity"),I=Symbol.for("react.memo_cache_sentinel"),$=Symbol.iterator;function L(s){return s===null||typeof s!="object"?null:(s=$&&s[$]||s["@@iterator"],typeof s=="function"?s:null)}var P=Symbol.for("react.client.reference");function q(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===P?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case N:return"Fragment";case k:return"Profiler";case T:return"StrictMode";case A:return"Suspense";case _:return"SuspenseList";case Z:return"Activity"}if(typeof s=="object")switch(s.$$typeof){case j:return"Portal";case S:return s.displayName||"Context";case C:return(s._context.displayName||"Context")+".Consumer";case R:var r=s.render;return s=s.displayName,s||(s=r.displayName||r.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case O:return r=s.displayName||null,r!==null?r:q(s.type)||"Memo";case V:r=s._payload,s=s._init;try{return q(s(r))}catch{}}return null}var ee=Array.isArray,D=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,U=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B={pending:!1,data:null,method:null,action:null},G=[],K=-1;function z(s){return{current:s}}function Y(s){0>K||(s.current=G[K],G[K]=null,K--)}function W(s,r){K++,G[K]=s.current,s.current=r}var J=z(null),de=z(null),ae=z(null),ye=z(null);function ve(s,r){switch(W(ae,r),W(de,s),W(J,null),r.nodeType){case 9:case 11:s=(s=r.documentElement)&&(s=s.namespaceURI)?gb(s):0;break;default:if(s=r.tagName,r=r.namespaceURI)r=gb(r),s=vb(r,s);else switch(s){case"svg":s=1;break;case"math":s=2;break;default:s=0}}Y(J),W(J,s)}function be(){Y(J),Y(de),Y(ae)}function _e(s){s.memoizedState!==null&&W(ye,s);var r=J.current,l=vb(r,s.type);r!==l&&(W(de,s),W(J,l))}function ie(s){de.current===s&&(Y(J),Y(de)),ye.current===s&&(Y(ye),jl._currentValue=B)}var ke,we;function Ue(s){if(ke===void 0)try{throw Error()}catch(l){var r=l.stack.trim().match(/\n( *(at )?)/);ke=r&&r[1]||"",we=-1<l.stack.indexOf(`
|
|
2
|
+
at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
3
|
+
`+ke+s+we}var Ae=!1;function xe(s,r){if(!s||Ae)return"";Ae=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var d={DetermineComponentFrameRoot:function(){try{if(r){var fe=function(){throw Error()};if(Object.defineProperty(fe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(fe,[])}catch(re){var se=re}Reflect.construct(s,[],fe)}else{try{fe.call()}catch(re){se=re}s.call(fe.prototype)}}else{try{throw Error()}catch(re){se=re}(fe=s())&&typeof fe.catch=="function"&&fe.catch(function(){})}}catch(re){if(re&&se&&typeof re.stack=="string")return[re.stack,se.stack]}return[null,null]}};d.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var p=Object.getOwnPropertyDescriptor(d.DetermineComponentFrameRoot,"name");p&&p.configurable&&Object.defineProperty(d.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var y=d.DetermineComponentFrameRoot(),E=y[0],M=y[1];if(E&&M){var H=E.split(`
|
|
4
|
+
`),ne=M.split(`
|
|
5
|
+
`);for(p=d=0;d<H.length&&!H[d].includes("DetermineComponentFrameRoot");)d++;for(;p<ne.length&&!ne[p].includes("DetermineComponentFrameRoot");)p++;if(d===H.length||p===ne.length)for(d=H.length-1,p=ne.length-1;1<=d&&0<=p&&H[d]!==ne[p];)p--;for(;1<=d&&0<=p;d--,p--)if(H[d]!==ne[p]){if(d!==1||p!==1)do if(d--,p--,0>p||H[d]!==ne[p]){var oe=`
|
|
6
|
+
`+H[d].replace(" at new "," at ");return s.displayName&&oe.includes("<anonymous>")&&(oe=oe.replace("<anonymous>",s.displayName)),oe}while(1<=d&&0<=p);break}}}finally{Ae=!1,Error.prepareStackTrace=l}return(l=s?s.displayName||s.name:"")?Ue(l):""}function Ee(s,r){switch(s.tag){case 26:case 27:case 5:return Ue(s.type);case 16:return Ue("Lazy");case 13:return s.child!==r&&r!==null?Ue("Suspense Fallback"):Ue("Suspense");case 19:return Ue("SuspenseList");case 0:case 15:return xe(s.type,!1);case 11:return xe(s.type.render,!1);case 1:return xe(s.type,!0);case 31:return Ue("Activity");default:return""}}function Ye(s){try{var r="",l=null;do r+=Ee(s,l),l=s,s=s.return;while(s);return r}catch(d){return`
|
|
7
|
+
Error generating stack: `+d.message+`
|
|
8
|
+
`+d.stack}}var Be=Object.prototype.hasOwnProperty,He=e.unstable_scheduleCallback,ce=e.unstable_cancelCallback,he=e.unstable_shouldYield,pe=e.unstable_requestPaint,je=e.unstable_now,Ne=e.unstable_getCurrentPriorityLevel,Je=e.unstable_ImmediatePriority,et=e.unstable_UserBlockingPriority,Ge=e.unstable_NormalPriority,Bt=e.unstable_LowPriority,Et=e.unstable_IdlePriority,fn=e.log,hn=e.unstable_setDisableYieldValue,on=null,Ie=null;function tt(s){if(typeof fn=="function"&&hn(s),Ie&&typeof Ie.setStrictMode=="function")try{Ie.setStrictMode(on,s)}catch{}}var ut=Math.clz32?Math.clz32:vn,xt=Math.log,Lt=Math.LN2;function vn(s){return s>>>=0,s===0?32:31-(xt(s)/Lt|0)|0}var Xt=256,mn=262144,ln=4194304;function yn(s){var r=s&42;if(r!==0)return r;switch(s&-s){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 s&261888;case 262144:case 524288:case 1048576:case 2097152:return s&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return s&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return s}}function Ts(s,r,l){var d=s.pendingLanes;if(d===0)return 0;var p=0,y=s.suspendedLanes,E=s.pingedLanes;s=s.warmLanes;var M=d&134217727;return M!==0?(d=M&~y,d!==0?p=yn(d):(E&=M,E!==0?p=yn(E):l||(l=M&~s,l!==0&&(p=yn(l))))):(M=d&~y,M!==0?p=yn(M):E!==0?p=yn(E):l||(l=d&~s,l!==0&&(p=yn(l)))),p===0?0:r!==0&&r!==p&&(r&y)===0&&(y=p&-p,l=r&-r,y>=l||y===32&&(l&4194048)!==0)?r:p}function Q(s,r){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&r)===0}function me(s,r){switch(s){case 1:case 2:case 4:case 8:case 64:return r+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 r+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 ge(){var s=ln;return ln<<=1,(ln&62914560)===0&&(ln=4194304),s}function Ve(s){for(var r=[],l=0;31>l;l++)r.push(s);return r}function ze(s,r){s.pendingLanes|=r,r!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function dt(s,r,l,d,p,y){var E=s.pendingLanes;s.pendingLanes=l,s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0,s.expiredLanes&=l,s.entangledLanes&=l,s.errorRecoveryDisabledLanes&=l,s.shellSuspendCounter=0;var M=s.entanglements,H=s.expirationTimes,ne=s.hiddenUpdates;for(l=E&~l;0<l;){var oe=31-ut(l),fe=1<<oe;M[oe]=0,H[oe]=-1;var se=ne[oe];if(se!==null)for(ne[oe]=null,oe=0;oe<se.length;oe++){var re=se[oe];re!==null&&(re.lane&=-536870913)}l&=~fe}d!==0&&$t(s,d,0),y!==0&&p===0&&s.tag!==0&&(s.suspendedLanes|=y&~(E&~r))}function $t(s,r,l){s.pendingLanes|=r,s.suspendedLanes&=~r;var d=31-ut(r);s.entangledLanes|=r,s.entanglements[d]=s.entanglements[d]|1073741824|l&261930}function Ft(s,r){var l=s.entangledLanes|=r;for(s=s.entanglements;l;){var d=31-ut(l),p=1<<d;p&r|s[d]&r&&(s[d]|=r),l&=~p}}function xn(s,r){var l=r&-r;return l=(l&42)!==0?1:qt(l),(l&(s.suspendedLanes|r))!==0?0:l}function qt(s){switch(s){case 2:s=1;break;case 8:s=4;break;case 32:s=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:s=128;break;case 268435456:s=134217728;break;default:s=0}return s}function As(s){return s&=-s,2<s?8<s?(s&134217727)!==0?32:268435456:8:2}function cn(){var s=U.p;return s!==0?s:(s=window.event,s===void 0?32:Ub(s.type))}function wc(s,r){var l=U.p;try{return U.p=s,r()}finally{U.p=l}}var Ma=Math.random().toString(36).slice(2),bn="__reactFiber$"+Ma,Un="__reactProps$"+Ma,di="__reactContainer$"+Ma,Ef="__reactEvents$"+Ma,aA="__reactListeners$"+Ma,rA="__reactHandles$"+Ma,sy="__reactResources$"+Ma,$o="__reactMarker$"+Ma;function Cf(s){delete s[bn],delete s[Un],delete s[Ef],delete s[aA],delete s[rA]}function fi(s){var r=s[bn];if(r)return r;for(var l=s.parentNode;l;){if(r=l[di]||l[bn]){if(l=r.alternate,r.child!==null||l!==null&&l.child!==null)for(s=Nb(s);s!==null;){if(l=s[bn])return l;s=Nb(s)}return r}s=l,l=s.parentNode}return null}function hi(s){if(s=s[bn]||s[di]){var r=s.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return s}return null}function Po(s){var r=s.tag;if(r===5||r===26||r===27||r===6)return s.stateNode;throw Error(a(33))}function mi(s){var r=s[sy];return r||(r=s[sy]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function pn(s){s[$o]=!0}var ay=new Set,ry={};function kr(s,r){pi(s,r),pi(s+"Capture",r)}function pi(s,r){for(ry[s]=r,s=0;s<r.length;s++)ay.add(r[s])}var iA=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]*$"),iy={},oy={};function oA(s){return Be.call(oy,s)?!0:Be.call(iy,s)?!1:iA.test(s)?oy[s]=!0:(iy[s]=!0,!1)}function Sc(s,r,l){if(oA(r))if(l===null)s.removeAttribute(r);else{switch(typeof l){case"undefined":case"function":case"symbol":s.removeAttribute(r);return;case"boolean":var d=r.toLowerCase().slice(0,5);if(d!=="data-"&&d!=="aria-"){s.removeAttribute(r);return}}s.setAttribute(r,""+l)}}function jc(s,r,l){if(l===null)s.removeAttribute(r);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(r);return}s.setAttribute(r,""+l)}}function ia(s,r,l,d){if(d===null)s.removeAttribute(l);else{switch(typeof d){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(l);return}s.setAttributeNS(r,l,""+d)}}function us(s){switch(typeof s){case"bigint":case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function ly(s){var r=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function lA(s,r,l){var d=Object.getOwnPropertyDescriptor(s.constructor.prototype,r);if(!s.hasOwnProperty(r)&&typeof d<"u"&&typeof d.get=="function"&&typeof d.set=="function"){var p=d.get,y=d.set;return Object.defineProperty(s,r,{configurable:!0,get:function(){return p.call(this)},set:function(E){l=""+E,y.call(this,E)}}),Object.defineProperty(s,r,{enumerable:d.enumerable}),{getValue:function(){return l},setValue:function(E){l=""+E},stopTracking:function(){s._valueTracker=null,delete s[r]}}}}function Tf(s){if(!s._valueTracker){var r=ly(s)?"checked":"value";s._valueTracker=lA(s,r,""+s[r])}}function cy(s){if(!s)return!1;var r=s._valueTracker;if(!r)return!0;var l=r.getValue(),d="";return s&&(d=ly(s)?s.checked?"true":"false":s.value),s=d,s!==l?(r.setValue(s),!0):!1}function Nc(s){if(s=s||(typeof document<"u"?document:void 0),typeof s>"u")return null;try{return s.activeElement||s.body}catch{return s.body}}var cA=/[\n"\\]/g;function ds(s){return s.replace(cA,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Af(s,r,l,d,p,y,E,M){s.name="",E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"?s.type=E:s.removeAttribute("type"),r!=null?E==="number"?(r===0&&s.value===""||s.value!=r)&&(s.value=""+us(r)):s.value!==""+us(r)&&(s.value=""+us(r)):E!=="submit"&&E!=="reset"||s.removeAttribute("value"),r!=null?Rf(s,E,us(r)):l!=null?Rf(s,E,us(l)):d!=null&&s.removeAttribute("value"),p==null&&y!=null&&(s.defaultChecked=!!y),p!=null&&(s.checked=p&&typeof p!="function"&&typeof p!="symbol"),M!=null&&typeof M!="function"&&typeof M!="symbol"&&typeof M!="boolean"?s.name=""+us(M):s.removeAttribute("name")}function uy(s,r,l,d,p,y,E,M){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(s.type=y),r!=null||l!=null){if(!(y!=="submit"&&y!=="reset"||r!=null)){Tf(s);return}l=l!=null?""+us(l):"",r=r!=null?""+us(r):l,M||r===s.value||(s.value=r),s.defaultValue=r}d=d??p,d=typeof d!="function"&&typeof d!="symbol"&&!!d,s.checked=M?s.checked:!!d,s.defaultChecked=!!d,E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"&&(s.name=E),Tf(s)}function Rf(s,r,l){r==="number"&&Nc(s.ownerDocument)===s||s.defaultValue===""+l||(s.defaultValue=""+l)}function gi(s,r,l,d){if(s=s.options,r){r={};for(var p=0;p<l.length;p++)r["$"+l[p]]=!0;for(l=0;l<s.length;l++)p=r.hasOwnProperty("$"+s[l].value),s[l].selected!==p&&(s[l].selected=p),p&&d&&(s[l].defaultSelected=!0)}else{for(l=""+us(l),r=null,p=0;p<s.length;p++){if(s[p].value===l){s[p].selected=!0,d&&(s[p].defaultSelected=!0);return}r!==null||s[p].disabled||(r=s[p])}r!==null&&(r.selected=!0)}}function dy(s,r,l){if(r!=null&&(r=""+us(r),r!==s.value&&(s.value=r),l==null)){s.defaultValue!==r&&(s.defaultValue=r);return}s.defaultValue=l!=null?""+us(l):""}function fy(s,r,l,d){if(r==null){if(d!=null){if(l!=null)throw Error(a(92));if(ee(d)){if(1<d.length)throw Error(a(93));d=d[0]}l=d}l==null&&(l=""),r=l}l=us(r),s.defaultValue=l,d=s.textContent,d===l&&d!==""&&d!==null&&(s.value=d),Tf(s)}function vi(s,r){if(r){var l=s.firstChild;if(l&&l===s.lastChild&&l.nodeType===3){l.nodeValue=r;return}}s.textContent=r}var uA=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 hy(s,r,l){var d=r.indexOf("--")===0;l==null||typeof l=="boolean"||l===""?d?s.setProperty(r,""):r==="float"?s.cssFloat="":s[r]="":d?s.setProperty(r,l):typeof l!="number"||l===0||uA.has(r)?r==="float"?s.cssFloat=l:s[r]=(""+l).trim():s[r]=l+"px"}function my(s,r,l){if(r!=null&&typeof r!="object")throw Error(a(62));if(s=s.style,l!=null){for(var d in l)!l.hasOwnProperty(d)||r!=null&&r.hasOwnProperty(d)||(d.indexOf("--")===0?s.setProperty(d,""):d==="float"?s.cssFloat="":s[d]="");for(var p in r)d=r[p],r.hasOwnProperty(p)&&l[p]!==d&&hy(s,p,d)}else for(var y in r)r.hasOwnProperty(y)&&hy(s,y,r[y])}function Mf(s){if(s.indexOf("-")===-1)return!1;switch(s){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 dA=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"]]),fA=/^[\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 kc(s){return fA.test(""+s)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":s}function oa(){}var _f=null;function Of(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var yi=null,xi=null;function py(s){var r=hi(s);if(r&&(s=r.stateNode)){var l=s[Un]||null;e:switch(s=r.stateNode,r.type){case"input":if(Af(s,l.value,l.defaultValue,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name),r=l.name,l.type==="radio"&&r!=null){for(l=s;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll('input[name="'+ds(""+r)+'"][type="radio"]'),r=0;r<l.length;r++){var d=l[r];if(d!==s&&d.form===s.form){var p=d[Un]||null;if(!p)throw Error(a(90));Af(d,p.value,p.defaultValue,p.defaultValue,p.checked,p.defaultChecked,p.type,p.name)}}for(r=0;r<l.length;r++)d=l[r],d.form===s.form&&cy(d)}break e;case"textarea":dy(s,l.value,l.defaultValue);break e;case"select":r=l.value,r!=null&&gi(s,!!l.multiple,r,!1)}}}var If=!1;function gy(s,r,l){if(If)return s(r,l);If=!0;try{var d=s(r);return d}finally{if(If=!1,(yi!==null||xi!==null)&&(fu(),yi&&(r=yi,s=xi,xi=yi=null,py(r),s)))for(r=0;r<s.length;r++)py(s[r])}}function Uo(s,r){var l=s.stateNode;if(l===null)return null;var d=l[Un]||null;if(d===null)return null;l=d[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(d=!d.disabled)||(s=s.type,d=!(s==="button"||s==="input"||s==="select"||s==="textarea")),s=!d;break e;default:s=!1}if(s)return null;if(l&&typeof l!="function")throw Error(a(231,r,typeof l));return l}var la=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Df=!1;if(la)try{var Bo={};Object.defineProperty(Bo,"passive",{get:function(){Df=!0}}),window.addEventListener("test",Bo,Bo),window.removeEventListener("test",Bo,Bo)}catch{Df=!1}var _a=null,zf=null,Ec=null;function vy(){if(Ec)return Ec;var s,r=zf,l=r.length,d,p="value"in _a?_a.value:_a.textContent,y=p.length;for(s=0;s<l&&r[s]===p[s];s++);var E=l-s;for(d=1;d<=E&&r[l-d]===p[y-d];d++);return Ec=p.slice(s,1<d?1-d:void 0)}function Cc(s){var r=s.keyCode;return"charCode"in s?(s=s.charCode,s===0&&r===13&&(s=13)):s=r,s===10&&(s=13),32<=s||s===13?s:0}function Tc(){return!0}function yy(){return!1}function Bn(s){function r(l,d,p,y,E){this._reactName=l,this._targetInst=p,this.type=d,this.nativeEvent=y,this.target=E,this.currentTarget=null;for(var M in s)s.hasOwnProperty(M)&&(l=s[M],this[M]=l?l(y):y[M]);return this.isDefaultPrevented=(y.defaultPrevented!=null?y.defaultPrevented:y.returnValue===!1)?Tc:yy,this.isPropagationStopped=yy,this}return x(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=Tc)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=Tc)},persist:function(){},isPersistent:Tc}),r}var Er={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ac=Bn(Er),Vo=x({},Er,{view:0,detail:0}),hA=Bn(Vo),Lf,$f,Ho,Rc=x({},Vo,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Uf,button:0,buttons:0,relatedTarget:function(s){return s.relatedTarget===void 0?s.fromElement===s.srcElement?s.toElement:s.fromElement:s.relatedTarget},movementX:function(s){return"movementX"in s?s.movementX:(s!==Ho&&(Ho&&s.type==="mousemove"?(Lf=s.screenX-Ho.screenX,$f=s.screenY-Ho.screenY):$f=Lf=0,Ho=s),Lf)},movementY:function(s){return"movementY"in s?s.movementY:$f}}),xy=Bn(Rc),mA=x({},Rc,{dataTransfer:0}),pA=Bn(mA),gA=x({},Vo,{relatedTarget:0}),Pf=Bn(gA),vA=x({},Er,{animationName:0,elapsedTime:0,pseudoElement:0}),yA=Bn(vA),xA=x({},Er,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),bA=Bn(xA),wA=x({},Er,{data:0}),by=Bn(wA),SA={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},jA={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"},NA={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function kA(s){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(s):(s=NA[s])?!!r[s]:!1}function Uf(){return kA}var EA=x({},Vo,{key:function(s){if(s.key){var r=SA[s.key]||s.key;if(r!=="Unidentified")return r}return s.type==="keypress"?(s=Cc(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?jA[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Uf,charCode:function(s){return s.type==="keypress"?Cc(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?Cc(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),CA=Bn(EA),TA=x({},Rc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),wy=Bn(TA),AA=x({},Vo,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Uf}),RA=Bn(AA),MA=x({},Er,{propertyName:0,elapsedTime:0,pseudoElement:0}),_A=Bn(MA),OA=x({},Rc,{deltaX:function(s){return"deltaX"in s?s.deltaX:"wheelDeltaX"in s?-s.wheelDeltaX:0},deltaY:function(s){return"deltaY"in s?s.deltaY:"wheelDeltaY"in s?-s.wheelDeltaY:"wheelDelta"in s?-s.wheelDelta:0},deltaZ:0,deltaMode:0}),IA=Bn(OA),DA=x({},Er,{newState:0,oldState:0}),zA=Bn(DA),LA=[9,13,27,32],Bf=la&&"CompositionEvent"in window,Zo=null;la&&"documentMode"in document&&(Zo=document.documentMode);var $A=la&&"TextEvent"in window&&!Zo,Sy=la&&(!Bf||Zo&&8<Zo&&11>=Zo),jy=" ",Ny=!1;function ky(s,r){switch(s){case"keyup":return LA.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ey(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var bi=!1;function PA(s,r){switch(s){case"compositionend":return Ey(r);case"keypress":return r.which!==32?null:(Ny=!0,jy);case"textInput":return s=r.data,s===jy&&Ny?null:s;default:return null}}function UA(s,r){if(bi)return s==="compositionend"||!Bf&&ky(s,r)?(s=vy(),Ec=zf=_a=null,bi=!1,s):null;switch(s){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return Sy&&r.locale!=="ko"?null:r.data;default:return null}}var BA={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 Cy(s){var r=s&&s.nodeName&&s.nodeName.toLowerCase();return r==="input"?!!BA[s.type]:r==="textarea"}function Ty(s,r,l,d){yi?xi?xi.push(d):xi=[d]:yi=d,r=xu(r,"onChange"),0<r.length&&(l=new Ac("onChange","change",null,l,d),s.push({event:l,listeners:r}))}var Fo=null,qo=null;function VA(s){ub(s,0)}function Mc(s){var r=Po(s);if(cy(r))return s}function Ay(s,r){if(s==="change")return r}var Ry=!1;if(la){var Vf;if(la){var Hf="oninput"in document;if(!Hf){var My=document.createElement("div");My.setAttribute("oninput","return;"),Hf=typeof My.oninput=="function"}Vf=Hf}else Vf=!1;Ry=Vf&&(!document.documentMode||9<document.documentMode)}function _y(){Fo&&(Fo.detachEvent("onpropertychange",Oy),qo=Fo=null)}function Oy(s){if(s.propertyName==="value"&&Mc(qo)){var r=[];Ty(r,qo,s,Of(s)),gy(VA,r)}}function HA(s,r,l){s==="focusin"?(_y(),Fo=r,qo=l,Fo.attachEvent("onpropertychange",Oy)):s==="focusout"&&_y()}function ZA(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return Mc(qo)}function FA(s,r){if(s==="click")return Mc(r)}function qA(s,r){if(s==="input"||s==="change")return Mc(r)}function YA(s,r){return s===r&&(s!==0||1/s===1/r)||s!==s&&r!==r}var Jn=typeof Object.is=="function"?Object.is:YA;function Yo(s,r){if(Jn(s,r))return!0;if(typeof s!="object"||s===null||typeof r!="object"||r===null)return!1;var l=Object.keys(s),d=Object.keys(r);if(l.length!==d.length)return!1;for(d=0;d<l.length;d++){var p=l[d];if(!Be.call(r,p)||!Jn(s[p],r[p]))return!1}return!0}function Iy(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function Dy(s,r){var l=Iy(s);s=0;for(var d;l;){if(l.nodeType===3){if(d=s+l.textContent.length,s<=r&&d>=r)return{node:l,offset:r-s};s=d}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=Iy(l)}}function zy(s,r){return s&&r?s===r?!0:s&&s.nodeType===3?!1:r&&r.nodeType===3?zy(s,r.parentNode):"contains"in s?s.contains(r):s.compareDocumentPosition?!!(s.compareDocumentPosition(r)&16):!1:!1}function Ly(s){s=s!=null&&s.ownerDocument!=null&&s.ownerDocument.defaultView!=null?s.ownerDocument.defaultView:window;for(var r=Nc(s.document);r instanceof s.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)s=r.contentWindow;else break;r=Nc(s.document)}return r}function Zf(s){var r=s&&s.nodeName&&s.nodeName.toLowerCase();return r&&(r==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||r==="textarea"||s.contentEditable==="true")}var GA=la&&"documentMode"in document&&11>=document.documentMode,wi=null,Ff=null,Go=null,qf=!1;function $y(s,r,l){var d=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;qf||wi==null||wi!==Nc(d)||(d=wi,"selectionStart"in d&&Zf(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),Go&&Yo(Go,d)||(Go=d,d=xu(Ff,"onSelect"),0<d.length&&(r=new Ac("onSelect","select",null,r,l),s.push({event:r,listeners:d}),r.target=wi)))}function Cr(s,r){var l={};return l[s.toLowerCase()]=r.toLowerCase(),l["Webkit"+s]="webkit"+r,l["Moz"+s]="moz"+r,l}var Si={animationend:Cr("Animation","AnimationEnd"),animationiteration:Cr("Animation","AnimationIteration"),animationstart:Cr("Animation","AnimationStart"),transitionrun:Cr("Transition","TransitionRun"),transitionstart:Cr("Transition","TransitionStart"),transitioncancel:Cr("Transition","TransitionCancel"),transitionend:Cr("Transition","TransitionEnd")},Yf={},Py={};la&&(Py=document.createElement("div").style,"AnimationEvent"in window||(delete Si.animationend.animation,delete Si.animationiteration.animation,delete Si.animationstart.animation),"TransitionEvent"in window||delete Si.transitionend.transition);function Tr(s){if(Yf[s])return Yf[s];if(!Si[s])return s;var r=Si[s],l;for(l in r)if(r.hasOwnProperty(l)&&l in Py)return Yf[s]=r[l];return s}var Uy=Tr("animationend"),By=Tr("animationiteration"),Vy=Tr("animationstart"),WA=Tr("transitionrun"),XA=Tr("transitionstart"),KA=Tr("transitioncancel"),Hy=Tr("transitionend"),Zy=new Map,Gf="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(" ");Gf.push("scrollEnd");function Rs(s,r){Zy.set(s,r),kr(r,[s])}var _c=typeof reportError=="function"?reportError:function(s){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var r=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof s=="object"&&s!==null&&typeof s.message=="string"?String(s.message):String(s),error:s});if(!window.dispatchEvent(r))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",s);return}console.error(s)},fs=[],ji=0,Wf=0;function Oc(){for(var s=ji,r=Wf=ji=0;r<s;){var l=fs[r];fs[r++]=null;var d=fs[r];fs[r++]=null;var p=fs[r];fs[r++]=null;var y=fs[r];if(fs[r++]=null,d!==null&&p!==null){var E=d.pending;E===null?p.next=p:(p.next=E.next,E.next=p),d.pending=p}y!==0&&Fy(l,p,y)}}function Ic(s,r,l,d){fs[ji++]=s,fs[ji++]=r,fs[ji++]=l,fs[ji++]=d,Wf|=d,s.lanes|=d,s=s.alternate,s!==null&&(s.lanes|=d)}function Xf(s,r,l,d){return Ic(s,r,l,d),Dc(s)}function Ar(s,r){return Ic(s,null,null,r),Dc(s)}function Fy(s,r,l){s.lanes|=l;var d=s.alternate;d!==null&&(d.lanes|=l);for(var p=!1,y=s.return;y!==null;)y.childLanes|=l,d=y.alternate,d!==null&&(d.childLanes|=l),y.tag===22&&(s=y.stateNode,s===null||s._visibility&1||(p=!0)),s=y,y=y.return;return s.tag===3?(y=s.stateNode,p&&r!==null&&(p=31-ut(l),s=y.hiddenUpdates,d=s[p],d===null?s[p]=[r]:d.push(r),r.lane=l|536870912),y):null}function Dc(s){if(50<gl)throw gl=0,rm=null,Error(a(185));for(var r=s.return;r!==null;)s=r,r=s.return;return s.tag===3?s.stateNode:null}var Ni={};function JA(s,r,l,d){this.tag=s,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=d,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Qn(s,r,l,d){return new JA(s,r,l,d)}function Kf(s){return s=s.prototype,!(!s||!s.isReactComponent)}function ca(s,r){var l=s.alternate;return l===null?(l=Qn(s.tag,r,s.key,s.mode),l.elementType=s.elementType,l.type=s.type,l.stateNode=s.stateNode,l.alternate=s,s.alternate=l):(l.pendingProps=r,l.type=s.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=s.flags&65011712,l.childLanes=s.childLanes,l.lanes=s.lanes,l.child=s.child,l.memoizedProps=s.memoizedProps,l.memoizedState=s.memoizedState,l.updateQueue=s.updateQueue,r=s.dependencies,l.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},l.sibling=s.sibling,l.index=s.index,l.ref=s.ref,l.refCleanup=s.refCleanup,l}function qy(s,r){s.flags&=65011714;var l=s.alternate;return l===null?(s.childLanes=0,s.lanes=r,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=l.childLanes,s.lanes=l.lanes,s.child=l.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=l.memoizedProps,s.memoizedState=l.memoizedState,s.updateQueue=l.updateQueue,s.type=l.type,r=l.dependencies,s.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),s}function zc(s,r,l,d,p,y){var E=0;if(d=s,typeof s=="function")Kf(s)&&(E=1);else if(typeof s=="string")E=sM(s,l,J.current)?26:s==="html"||s==="head"||s==="body"?27:5;else e:switch(s){case Z:return s=Qn(31,l,r,p),s.elementType=Z,s.lanes=y,s;case N:return Rr(l.children,p,y,r);case T:E=8,p|=24;break;case k:return s=Qn(12,l,r,p|2),s.elementType=k,s.lanes=y,s;case A:return s=Qn(13,l,r,p),s.elementType=A,s.lanes=y,s;case _:return s=Qn(19,l,r,p),s.elementType=_,s.lanes=y,s;default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case S:E=10;break e;case C:E=9;break e;case R:E=11;break e;case O:E=14;break e;case V:E=16,d=null;break e}E=29,l=Error(a(130,s===null?"null":typeof s,"")),d=null}return r=Qn(E,l,r,p),r.elementType=s,r.type=d,r.lanes=y,r}function Rr(s,r,l,d){return s=Qn(7,s,d,r),s.lanes=l,s}function Jf(s,r,l){return s=Qn(6,s,null,r),s.lanes=l,s}function Yy(s){var r=Qn(18,null,null,0);return r.stateNode=s,r}function Qf(s,r,l){return r=Qn(4,s.children!==null?s.children:[],s.key,r),r.lanes=l,r.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},r}var Gy=new WeakMap;function hs(s,r){if(typeof s=="object"&&s!==null){var l=Gy.get(s);return l!==void 0?l:(r={value:s,source:r,stack:Ye(r)},Gy.set(s,r),r)}return{value:s,source:r,stack:Ye(r)}}var ki=[],Ei=0,Lc=null,Wo=0,ms=[],ps=0,Oa=null,Bs=1,Vs="";function ua(s,r){ki[Ei++]=Wo,ki[Ei++]=Lc,Lc=s,Wo=r}function Wy(s,r,l){ms[ps++]=Bs,ms[ps++]=Vs,ms[ps++]=Oa,Oa=s;var d=Bs;s=Vs;var p=32-ut(d)-1;d&=~(1<<p),l+=1;var y=32-ut(r)+p;if(30<y){var E=p-p%5;y=(d&(1<<E)-1).toString(32),d>>=E,p-=E,Bs=1<<32-ut(r)+p|l<<p|d,Vs=y+s}else Bs=1<<y|l<<p|d,Vs=s}function eh(s){s.return!==null&&(ua(s,1),Wy(s,1,0))}function th(s){for(;s===Lc;)Lc=ki[--Ei],ki[Ei]=null,Wo=ki[--Ei],ki[Ei]=null;for(;s===Oa;)Oa=ms[--ps],ms[ps]=null,Vs=ms[--ps],ms[ps]=null,Bs=ms[--ps],ms[ps]=null}function Xy(s,r){ms[ps++]=Bs,ms[ps++]=Vs,ms[ps++]=Oa,Bs=r.id,Vs=r.overflow,Oa=s}var wn=null,At=null,ot=!1,Ia=null,gs=!1,nh=Error(a(519));function Da(s){var r=Error(a(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Xo(hs(r,s)),nh}function Ky(s){var r=s.stateNode,l=s.type,d=s.memoizedProps;switch(r[bn]=s,r[Un]=d,l){case"dialog":st("cancel",r),st("close",r);break;case"iframe":case"object":case"embed":st("load",r);break;case"video":case"audio":for(l=0;l<yl.length;l++)st(yl[l],r);break;case"source":st("error",r);break;case"img":case"image":case"link":st("error",r),st("load",r);break;case"details":st("toggle",r);break;case"input":st("invalid",r),uy(r,d.value,d.defaultValue,d.checked,d.defaultChecked,d.type,d.name,!0);break;case"select":st("invalid",r);break;case"textarea":st("invalid",r),fy(r,d.value,d.defaultValue,d.children)}l=d.children,typeof l!="string"&&typeof l!="number"&&typeof l!="bigint"||r.textContent===""+l||d.suppressHydrationWarning===!0||mb(r.textContent,l)?(d.popover!=null&&(st("beforetoggle",r),st("toggle",r)),d.onScroll!=null&&st("scroll",r),d.onScrollEnd!=null&&st("scrollend",r),d.onClick!=null&&(r.onclick=oa),r=!0):r=!1,r||Da(s,!0)}function Jy(s){for(wn=s.return;wn;)switch(wn.tag){case 5:case 31:case 13:gs=!1;return;case 27:case 3:gs=!0;return;default:wn=wn.return}}function Ci(s){if(s!==wn)return!1;if(!ot)return Jy(s),ot=!0,!1;var r=s.tag,l;if((l=r!==3&&r!==27)&&((l=r===5)&&(l=s.type,l=!(l!=="form"&&l!=="button")||bm(s.type,s.memoizedProps)),l=!l),l&&At&&Da(s),Jy(s),r===13){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(a(317));At=jb(s)}else if(r===31){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(a(317));At=jb(s)}else r===27?(r=At,Wa(s.type)?(s=km,km=null,At=s):At=r):At=wn?ys(s.stateNode.nextSibling):null;return!0}function Mr(){At=wn=null,ot=!1}function sh(){var s=Ia;return s!==null&&(Fn===null?Fn=s:Fn.push.apply(Fn,s),Ia=null),s}function Xo(s){Ia===null?Ia=[s]:Ia.push(s)}var ah=z(null),_r=null,da=null;function za(s,r,l){W(ah,r._currentValue),r._currentValue=l}function fa(s){s._currentValue=ah.current,Y(ah)}function rh(s,r,l){for(;s!==null;){var d=s.alternate;if((s.childLanes&r)!==r?(s.childLanes|=r,d!==null&&(d.childLanes|=r)):d!==null&&(d.childLanes&r)!==r&&(d.childLanes|=r),s===l)break;s=s.return}}function ih(s,r,l,d){var p=s.child;for(p!==null&&(p.return=s);p!==null;){var y=p.dependencies;if(y!==null){var E=p.child;y=y.firstContext;e:for(;y!==null;){var M=y;y=p;for(var H=0;H<r.length;H++)if(M.context===r[H]){y.lanes|=l,M=y.alternate,M!==null&&(M.lanes|=l),rh(y.return,l,s),d||(E=null);break e}y=M.next}}else if(p.tag===18){if(E=p.return,E===null)throw Error(a(341));E.lanes|=l,y=E.alternate,y!==null&&(y.lanes|=l),rh(E,l,s),E=null}else E=p.child;if(E!==null)E.return=p;else for(E=p;E!==null;){if(E===s){E=null;break}if(p=E.sibling,p!==null){p.return=E.return,E=p;break}E=E.return}p=E}}function Ti(s,r,l,d){s=null;for(var p=r,y=!1;p!==null;){if(!y){if((p.flags&524288)!==0)y=!0;else if((p.flags&262144)!==0)break}if(p.tag===10){var E=p.alternate;if(E===null)throw Error(a(387));if(E=E.memoizedProps,E!==null){var M=p.type;Jn(p.pendingProps.value,E.value)||(s!==null?s.push(M):s=[M])}}else if(p===ye.current){if(E=p.alternate,E===null)throw Error(a(387));E.memoizedState.memoizedState!==p.memoizedState.memoizedState&&(s!==null?s.push(jl):s=[jl])}p=p.return}s!==null&&ih(r,s,l,d),r.flags|=262144}function $c(s){for(s=s.firstContext;s!==null;){if(!Jn(s.context._currentValue,s.memoizedValue))return!0;s=s.next}return!1}function Or(s){_r=s,da=null,s=s.dependencies,s!==null&&(s.firstContext=null)}function Sn(s){return Qy(_r,s)}function Pc(s,r){return _r===null&&Or(s),Qy(s,r)}function Qy(s,r){var l=r._currentValue;if(r={context:r,memoizedValue:l,next:null},da===null){if(s===null)throw Error(a(308));da=r,s.dependencies={lanes:0,firstContext:r},s.flags|=524288}else da=da.next=r;return l}var QA=typeof AbortController<"u"?AbortController:function(){var s=[],r=this.signal={aborted:!1,addEventListener:function(l,d){s.push(d)}};this.abort=function(){r.aborted=!0,s.forEach(function(l){return l()})}},eR=e.unstable_scheduleCallback,tR=e.unstable_NormalPriority,en={$$typeof:S,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function oh(){return{controller:new QA,data:new Map,refCount:0}}function Ko(s){s.refCount--,s.refCount===0&&eR(tR,function(){s.controller.abort()})}var Jo=null,lh=0,Ai=0,Ri=null;function nR(s,r){if(Jo===null){var l=Jo=[];lh=0,Ai=dm(),Ri={status:"pending",value:void 0,then:function(d){l.push(d)}}}return lh++,r.then(e0,e0),r}function e0(){if(--lh===0&&Jo!==null){Ri!==null&&(Ri.status="fulfilled");var s=Jo;Jo=null,Ai=0,Ri=null;for(var r=0;r<s.length;r++)(0,s[r])()}}function sR(s,r){var l=[],d={status:"pending",value:null,reason:null,then:function(p){l.push(p)}};return s.then(function(){d.status="fulfilled",d.value=r;for(var p=0;p<l.length;p++)(0,l[p])(r)},function(p){for(d.status="rejected",d.reason=p,p=0;p<l.length;p++)(0,l[p])(void 0)}),d}var t0=D.S;D.S=function(s,r){$x=je(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&nR(s,r),t0!==null&&t0(s,r)};var Ir=z(null);function ch(){var s=Ir.current;return s!==null?s:jt.pooledCache}function Uc(s,r){r===null?W(Ir,Ir.current):W(Ir,r.pool)}function n0(){var s=ch();return s===null?null:{parent:en._currentValue,pool:s}}var Mi=Error(a(460)),uh=Error(a(474)),Bc=Error(a(542)),Vc={then:function(){}};function s0(s){return s=s.status,s==="fulfilled"||s==="rejected"}function a0(s,r,l){switch(l=s[l],l===void 0?s.push(r):l!==r&&(r.then(oa,oa),r=l),r.status){case"fulfilled":return r.value;case"rejected":throw s=r.reason,i0(s),s;default:if(typeof r.status=="string")r.then(oa,oa);else{if(s=jt,s!==null&&100<s.shellSuspendCounter)throw Error(a(482));s=r,s.status="pending",s.then(function(d){if(r.status==="pending"){var p=r;p.status="fulfilled",p.value=d}},function(d){if(r.status==="pending"){var p=r;p.status="rejected",p.reason=d}})}switch(r.status){case"fulfilled":return r.value;case"rejected":throw s=r.reason,i0(s),s}throw zr=r,Mi}}function Dr(s){try{var r=s._init;return r(s._payload)}catch(l){throw l!==null&&typeof l=="object"&&typeof l.then=="function"?(zr=l,Mi):l}}var zr=null;function r0(){if(zr===null)throw Error(a(459));var s=zr;return zr=null,s}function i0(s){if(s===Mi||s===Bc)throw Error(a(483))}var _i=null,Qo=0;function Hc(s){var r=Qo;return Qo+=1,_i===null&&(_i=[]),a0(_i,s,r)}function el(s,r){r=r.props.ref,s.ref=r!==void 0?r:null}function Zc(s,r){throw r.$$typeof===b?Error(a(525)):(s=Object.prototype.toString.call(r),Error(a(31,s==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":s)))}function o0(s){function r(X,F){if(s){var te=X.deletions;te===null?(X.deletions=[F],X.flags|=16):te.push(F)}}function l(X,F){if(!s)return null;for(;F!==null;)r(X,F),F=F.sibling;return null}function d(X){for(var F=new Map;X!==null;)X.key!==null?F.set(X.key,X):F.set(X.index,X),X=X.sibling;return F}function p(X,F){return X=ca(X,F),X.index=0,X.sibling=null,X}function y(X,F,te){return X.index=te,s?(te=X.alternate,te!==null?(te=te.index,te<F?(X.flags|=67108866,F):te):(X.flags|=67108866,F)):(X.flags|=1048576,F)}function E(X){return s&&X.alternate===null&&(X.flags|=67108866),X}function M(X,F,te,ue){return F===null||F.tag!==6?(F=Jf(te,X.mode,ue),F.return=X,F):(F=p(F,te),F.return=X,F)}function H(X,F,te,ue){var De=te.type;return De===N?oe(X,F,te.props.children,ue,te.key):F!==null&&(F.elementType===De||typeof De=="object"&&De!==null&&De.$$typeof===V&&Dr(De)===F.type)?(F=p(F,te.props),el(F,te),F.return=X,F):(F=zc(te.type,te.key,te.props,null,X.mode,ue),el(F,te),F.return=X,F)}function ne(X,F,te,ue){return F===null||F.tag!==4||F.stateNode.containerInfo!==te.containerInfo||F.stateNode.implementation!==te.implementation?(F=Qf(te,X.mode,ue),F.return=X,F):(F=p(F,te.children||[]),F.return=X,F)}function oe(X,F,te,ue,De){return F===null||F.tag!==7?(F=Rr(te,X.mode,ue,De),F.return=X,F):(F=p(F,te),F.return=X,F)}function fe(X,F,te){if(typeof F=="string"&&F!==""||typeof F=="number"||typeof F=="bigint")return F=Jf(""+F,X.mode,te),F.return=X,F;if(typeof F=="object"&&F!==null){switch(F.$$typeof){case w:return te=zc(F.type,F.key,F.props,null,X.mode,te),el(te,F),te.return=X,te;case j:return F=Qf(F,X.mode,te),F.return=X,F;case V:return F=Dr(F),fe(X,F,te)}if(ee(F)||L(F))return F=Rr(F,X.mode,te,null),F.return=X,F;if(typeof F.then=="function")return fe(X,Hc(F),te);if(F.$$typeof===S)return fe(X,Pc(X,F),te);Zc(X,F)}return null}function se(X,F,te,ue){var De=F!==null?F.key:null;if(typeof te=="string"&&te!==""||typeof te=="number"||typeof te=="bigint")return De!==null?null:M(X,F,""+te,ue);if(typeof te=="object"&&te!==null){switch(te.$$typeof){case w:return te.key===De?H(X,F,te,ue):null;case j:return te.key===De?ne(X,F,te,ue):null;case V:return te=Dr(te),se(X,F,te,ue)}if(ee(te)||L(te))return De!==null?null:oe(X,F,te,ue,null);if(typeof te.then=="function")return se(X,F,Hc(te),ue);if(te.$$typeof===S)return se(X,F,Pc(X,te),ue);Zc(X,te)}return null}function re(X,F,te,ue,De){if(typeof ue=="string"&&ue!==""||typeof ue=="number"||typeof ue=="bigint")return X=X.get(te)||null,M(F,X,""+ue,De);if(typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case w:return X=X.get(ue.key===null?te:ue.key)||null,H(F,X,ue,De);case j:return X=X.get(ue.key===null?te:ue.key)||null,ne(F,X,ue,De);case V:return ue=Dr(ue),re(X,F,te,ue,De)}if(ee(ue)||L(ue))return X=X.get(te)||null,oe(F,X,ue,De,null);if(typeof ue.then=="function")return re(X,F,te,Hc(ue),De);if(ue.$$typeof===S)return re(X,F,te,Pc(F,ue),De);Zc(F,ue)}return null}function Ce(X,F,te,ue){for(var De=null,ft=null,Re=F,Ke=F=0,it=null;Re!==null&&Ke<te.length;Ke++){Re.index>Ke?(it=Re,Re=null):it=Re.sibling;var ht=se(X,Re,te[Ke],ue);if(ht===null){Re===null&&(Re=it);break}s&&Re&&ht.alternate===null&&r(X,Re),F=y(ht,F,Ke),ft===null?De=ht:ft.sibling=ht,ft=ht,Re=it}if(Ke===te.length)return l(X,Re),ot&&ua(X,Ke),De;if(Re===null){for(;Ke<te.length;Ke++)Re=fe(X,te[Ke],ue),Re!==null&&(F=y(Re,F,Ke),ft===null?De=Re:ft.sibling=Re,ft=Re);return ot&&ua(X,Ke),De}for(Re=d(Re);Ke<te.length;Ke++)it=re(Re,X,Ke,te[Ke],ue),it!==null&&(s&&it.alternate!==null&&Re.delete(it.key===null?Ke:it.key),F=y(it,F,Ke),ft===null?De=it:ft.sibling=it,ft=it);return s&&Re.forEach(function(er){return r(X,er)}),ot&&ua(X,Ke),De}function Le(X,F,te,ue){if(te==null)throw Error(a(151));for(var De=null,ft=null,Re=F,Ke=F=0,it=null,ht=te.next();Re!==null&&!ht.done;Ke++,ht=te.next()){Re.index>Ke?(it=Re,Re=null):it=Re.sibling;var er=se(X,Re,ht.value,ue);if(er===null){Re===null&&(Re=it);break}s&&Re&&er.alternate===null&&r(X,Re),F=y(er,F,Ke),ft===null?De=er:ft.sibling=er,ft=er,Re=it}if(ht.done)return l(X,Re),ot&&ua(X,Ke),De;if(Re===null){for(;!ht.done;Ke++,ht=te.next())ht=fe(X,ht.value,ue),ht!==null&&(F=y(ht,F,Ke),ft===null?De=ht:ft.sibling=ht,ft=ht);return ot&&ua(X,Ke),De}for(Re=d(Re);!ht.done;Ke++,ht=te.next())ht=re(Re,X,Ke,ht.value,ue),ht!==null&&(s&&ht.alternate!==null&&Re.delete(ht.key===null?Ke:ht.key),F=y(ht,F,Ke),ft===null?De=ht:ft.sibling=ht,ft=ht);return s&&Re.forEach(function(mM){return r(X,mM)}),ot&&ua(X,Ke),De}function St(X,F,te,ue){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 De=te.key;F!==null;){if(F.key===De){if(De=te.type,De===N){if(F.tag===7){l(X,F.sibling),ue=p(F,te.props.children),ue.return=X,X=ue;break e}}else if(F.elementType===De||typeof De=="object"&&De!==null&&De.$$typeof===V&&Dr(De)===F.type){l(X,F.sibling),ue=p(F,te.props),el(ue,te),ue.return=X,X=ue;break e}l(X,F);break}else r(X,F);F=F.sibling}te.type===N?(ue=Rr(te.props.children,X.mode,ue,te.key),ue.return=X,X=ue):(ue=zc(te.type,te.key,te.props,null,X.mode,ue),el(ue,te),ue.return=X,X=ue)}return E(X);case j:e:{for(De=te.key;F!==null;){if(F.key===De)if(F.tag===4&&F.stateNode.containerInfo===te.containerInfo&&F.stateNode.implementation===te.implementation){l(X,F.sibling),ue=p(F,te.children||[]),ue.return=X,X=ue;break e}else{l(X,F);break}else r(X,F);F=F.sibling}ue=Qf(te,X.mode,ue),ue.return=X,X=ue}return E(X);case V:return te=Dr(te),St(X,F,te,ue)}if(ee(te))return Ce(X,F,te,ue);if(L(te)){if(De=L(te),typeof De!="function")throw Error(a(150));return te=De.call(te),Le(X,F,te,ue)}if(typeof te.then=="function")return St(X,F,Hc(te),ue);if(te.$$typeof===S)return St(X,F,Pc(X,te),ue);Zc(X,te)}return typeof te=="string"&&te!==""||typeof te=="number"||typeof te=="bigint"?(te=""+te,F!==null&&F.tag===6?(l(X,F.sibling),ue=p(F,te),ue.return=X,X=ue):(l(X,F),ue=Jf(te,X.mode,ue),ue.return=X,X=ue),E(X)):l(X,F)}return function(X,F,te,ue){try{Qo=0;var De=St(X,F,te,ue);return _i=null,De}catch(Re){if(Re===Mi||Re===Bc)throw Re;var ft=Qn(29,Re,null,X.mode);return ft.lanes=ue,ft.return=X,ft}}}var Lr=o0(!0),l0=o0(!1),La=!1;function dh(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function fh(s,r){s=s.updateQueue,r.updateQueue===s&&(r.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,callbacks:null})}function $a(s){return{lane:s,tag:0,payload:null,callback:null,next:null}}function Pa(s,r,l){var d=s.updateQueue;if(d===null)return null;if(d=d.shared,(pt&2)!==0){var p=d.pending;return p===null?r.next=r:(r.next=p.next,p.next=r),d.pending=r,r=Dc(s),Fy(s,null,l),r}return Ic(s,d,r,l),Dc(s)}function tl(s,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194048)!==0)){var d=r.lanes;d&=s.pendingLanes,l|=d,r.lanes=l,Ft(s,l)}}function hh(s,r){var l=s.updateQueue,d=s.alternate;if(d!==null&&(d=d.updateQueue,l===d)){var p=null,y=null;if(l=l.firstBaseUpdate,l!==null){do{var E={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};y===null?p=y=E:y=y.next=E,l=l.next}while(l!==null);y===null?p=y=r:y=y.next=r}else p=y=r;l={baseState:d.baseState,firstBaseUpdate:p,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},s.updateQueue=l;return}s=l.lastBaseUpdate,s===null?l.firstBaseUpdate=r:s.next=r,l.lastBaseUpdate=r}var mh=!1;function nl(){if(mh){var s=Ri;if(s!==null)throw s}}function sl(s,r,l,d){mh=!1;var p=s.updateQueue;La=!1;var y=p.firstBaseUpdate,E=p.lastBaseUpdate,M=p.shared.pending;if(M!==null){p.shared.pending=null;var H=M,ne=H.next;H.next=null,E===null?y=ne:E.next=ne,E=H;var oe=s.alternate;oe!==null&&(oe=oe.updateQueue,M=oe.lastBaseUpdate,M!==E&&(M===null?oe.firstBaseUpdate=ne:M.next=ne,oe.lastBaseUpdate=H))}if(y!==null){var fe=p.baseState;E=0,oe=ne=H=null,M=y;do{var se=M.lane&-536870913,re=se!==M.lane;if(re?(rt&se)===se:(d&se)===se){se!==0&&se===Ai&&(mh=!0),oe!==null&&(oe=oe.next={lane:0,tag:M.tag,payload:M.payload,callback:null,next:null});e:{var Ce=s,Le=M;se=r;var St=l;switch(Le.tag){case 1:if(Ce=Le.payload,typeof Ce=="function"){fe=Ce.call(St,fe,se);break e}fe=Ce;break e;case 3:Ce.flags=Ce.flags&-65537|128;case 0:if(Ce=Le.payload,se=typeof Ce=="function"?Ce.call(St,fe,se):Ce,se==null)break e;fe=x({},fe,se);break e;case 2:La=!0}}se=M.callback,se!==null&&(s.flags|=64,re&&(s.flags|=8192),re=p.callbacks,re===null?p.callbacks=[se]:re.push(se))}else re={lane:se,tag:M.tag,payload:M.payload,callback:M.callback,next:null},oe===null?(ne=oe=re,H=fe):oe=oe.next=re,E|=se;if(M=M.next,M===null){if(M=p.shared.pending,M===null)break;re=M,M=re.next,re.next=null,p.lastBaseUpdate=re,p.shared.pending=null}}while(!0);oe===null&&(H=fe),p.baseState=H,p.firstBaseUpdate=ne,p.lastBaseUpdate=oe,y===null&&(p.shared.lanes=0),Za|=E,s.lanes=E,s.memoizedState=fe}}function c0(s,r){if(typeof s!="function")throw Error(a(191,s));s.call(r)}function u0(s,r){var l=s.callbacks;if(l!==null)for(s.callbacks=null,s=0;s<l.length;s++)c0(l[s],r)}var Oi=z(null),Fc=z(0);function d0(s,r){s=wa,W(Fc,s),W(Oi,r),wa=s|r.baseLanes}function ph(){W(Fc,wa),W(Oi,Oi.current)}function gh(){wa=Fc.current,Y(Oi),Y(Fc)}var es=z(null),vs=null;function Ua(s){var r=s.alternate;W(Kt,Kt.current&1),W(es,s),vs===null&&(r===null||Oi.current!==null||r.memoizedState!==null)&&(vs=s)}function vh(s){W(Kt,Kt.current),W(es,s),vs===null&&(vs=s)}function f0(s){s.tag===22?(W(Kt,Kt.current),W(es,s),vs===null&&(vs=s)):Ba()}function Ba(){W(Kt,Kt.current),W(es,es.current)}function ts(s){Y(es),vs===s&&(vs=null),Y(Kt)}var Kt=z(0);function qc(s){for(var r=s;r!==null;){if(r.tag===13){var l=r.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||jm(l)||Nm(l)))return r}else if(r.tag===19&&(r.memoizedProps.revealOrder==="forwards"||r.memoizedProps.revealOrder==="backwards"||r.memoizedProps.revealOrder==="unstable_legacy-backwards"||r.memoizedProps.revealOrder==="together")){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===s)break;for(;r.sibling===null;){if(r.return===null||r.return===s)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var ha=0,Xe=null,bt=null,tn=null,Yc=!1,Ii=!1,$r=!1,Gc=0,al=0,Di=null,aR=0;function Yt(){throw Error(a(321))}function yh(s,r){if(r===null)return!1;for(var l=0;l<r.length&&l<s.length;l++)if(!Jn(s[l],r[l]))return!1;return!0}function xh(s,r,l,d,p,y){return ha=y,Xe=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,D.H=s===null||s.memoizedState===null?W0:Ih,$r=!1,y=l(d,p),$r=!1,Ii&&(y=m0(r,l,d,p)),h0(s),y}function h0(s){D.H=ol;var r=bt!==null&&bt.next!==null;if(ha=0,tn=bt=Xe=null,Yc=!1,al=0,Di=null,r)throw Error(a(300));s===null||nn||(s=s.dependencies,s!==null&&$c(s)&&(nn=!0))}function m0(s,r,l,d){Xe=s;var p=0;do{if(Ii&&(Di=null),al=0,Ii=!1,25<=p)throw Error(a(301));if(p+=1,tn=bt=null,s.updateQueue!=null){var y=s.updateQueue;y.lastEffect=null,y.events=null,y.stores=null,y.memoCache!=null&&(y.memoCache.index=0)}D.H=X0,y=r(l,d)}while(Ii);return y}function rR(){var s=D.H,r=s.useState()[0];return r=typeof r.then=="function"?rl(r):r,s=s.useState()[0],(bt!==null?bt.memoizedState:null)!==s&&(Xe.flags|=1024),r}function bh(){var s=Gc!==0;return Gc=0,s}function wh(s,r,l){r.updateQueue=s.updateQueue,r.flags&=-2053,s.lanes&=~l}function Sh(s){if(Yc){for(s=s.memoizedState;s!==null;){var r=s.queue;r!==null&&(r.pending=null),s=s.next}Yc=!1}ha=0,tn=bt=Xe=null,Ii=!1,al=Gc=0,Di=null}function On(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return tn===null?Xe.memoizedState=tn=s:tn=tn.next=s,tn}function Jt(){if(bt===null){var s=Xe.alternate;s=s!==null?s.memoizedState:null}else s=bt.next;var r=tn===null?Xe.memoizedState:tn.next;if(r!==null)tn=r,bt=s;else{if(s===null)throw Xe.alternate===null?Error(a(467)):Error(a(310));bt=s,s={memoizedState:bt.memoizedState,baseState:bt.baseState,baseQueue:bt.baseQueue,queue:bt.queue,next:null},tn===null?Xe.memoizedState=tn=s:tn=tn.next=s}return tn}function Wc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function rl(s){var r=al;return al+=1,Di===null&&(Di=[]),s=a0(Di,s,r),r=Xe,(tn===null?r.memoizedState:tn.next)===null&&(r=r.alternate,D.H=r===null||r.memoizedState===null?W0:Ih),s}function Xc(s){if(s!==null&&typeof s=="object"){if(typeof s.then=="function")return rl(s);if(s.$$typeof===S)return Sn(s)}throw Error(a(438,String(s)))}function jh(s){var r=null,l=Xe.updateQueue;if(l!==null&&(r=l.memoCache),r==null){var d=Xe.alternate;d!==null&&(d=d.updateQueue,d!==null&&(d=d.memoCache,d!=null&&(r={data:d.data.map(function(p){return p.slice()}),index:0})))}if(r==null&&(r={data:[],index:0}),l===null&&(l=Wc(),Xe.updateQueue=l),l.memoCache=r,l=r.data[r.index],l===void 0)for(l=r.data[r.index]=Array(s),d=0;d<s;d++)l[d]=I;return r.index++,l}function ma(s,r){return typeof r=="function"?r(s):r}function Kc(s){var r=Jt();return Nh(r,bt,s)}function Nh(s,r,l){var d=s.queue;if(d===null)throw Error(a(311));d.lastRenderedReducer=l;var p=s.baseQueue,y=d.pending;if(y!==null){if(p!==null){var E=p.next;p.next=y.next,y.next=E}r.baseQueue=p=y,d.pending=null}if(y=s.baseState,p===null)s.memoizedState=y;else{r=p.next;var M=E=null,H=null,ne=r,oe=!1;do{var fe=ne.lane&-536870913;if(fe!==ne.lane?(rt&fe)===fe:(ha&fe)===fe){var se=ne.revertLane;if(se===0)H!==null&&(H=H.next={lane:0,revertLane:0,gesture:null,action:ne.action,hasEagerState:ne.hasEagerState,eagerState:ne.eagerState,next:null}),fe===Ai&&(oe=!0);else if((ha&se)===se){ne=ne.next,se===Ai&&(oe=!0);continue}else fe={lane:0,revertLane:ne.revertLane,gesture:null,action:ne.action,hasEagerState:ne.hasEagerState,eagerState:ne.eagerState,next:null},H===null?(M=H=fe,E=y):H=H.next=fe,Xe.lanes|=se,Za|=se;fe=ne.action,$r&&l(y,fe),y=ne.hasEagerState?ne.eagerState:l(y,fe)}else se={lane:fe,revertLane:ne.revertLane,gesture:ne.gesture,action:ne.action,hasEagerState:ne.hasEagerState,eagerState:ne.eagerState,next:null},H===null?(M=H=se,E=y):H=H.next=se,Xe.lanes|=fe,Za|=fe;ne=ne.next}while(ne!==null&&ne!==r);if(H===null?E=y:H.next=M,!Jn(y,s.memoizedState)&&(nn=!0,oe&&(l=Ri,l!==null)))throw l;s.memoizedState=y,s.baseState=E,s.baseQueue=H,d.lastRenderedState=y}return p===null&&(d.lanes=0),[s.memoizedState,d.dispatch]}function kh(s){var r=Jt(),l=r.queue;if(l===null)throw Error(a(311));l.lastRenderedReducer=s;var d=l.dispatch,p=l.pending,y=r.memoizedState;if(p!==null){l.pending=null;var E=p=p.next;do y=s(y,E.action),E=E.next;while(E!==p);Jn(y,r.memoizedState)||(nn=!0),r.memoizedState=y,r.baseQueue===null&&(r.baseState=y),l.lastRenderedState=y}return[y,d]}function p0(s,r,l){var d=Xe,p=Jt(),y=ot;if(y){if(l===void 0)throw Error(a(407));l=l()}else l=r();var E=!Jn((bt||p).memoizedState,l);if(E&&(p.memoizedState=l,nn=!0),p=p.queue,Th(y0.bind(null,d,p,s),[s]),p.getSnapshot!==r||E||tn!==null&&tn.memoizedState.tag&1){if(d.flags|=2048,zi(9,{destroy:void 0},v0.bind(null,d,p,l,r),null),jt===null)throw Error(a(349));y||(ha&127)!==0||g0(d,r,l)}return l}function g0(s,r,l){s.flags|=16384,s={getSnapshot:r,value:l},r=Xe.updateQueue,r===null?(r=Wc(),Xe.updateQueue=r,r.stores=[s]):(l=r.stores,l===null?r.stores=[s]:l.push(s))}function v0(s,r,l,d){r.value=l,r.getSnapshot=d,x0(r)&&b0(s)}function y0(s,r,l){return l(function(){x0(r)&&b0(s)})}function x0(s){var r=s.getSnapshot;s=s.value;try{var l=r();return!Jn(s,l)}catch{return!0}}function b0(s){var r=Ar(s,2);r!==null&&qn(r,s,2)}function Eh(s){var r=On();if(typeof s=="function"){var l=s;if(s=l(),$r){tt(!0);try{l()}finally{tt(!1)}}}return r.memoizedState=r.baseState=s,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ma,lastRenderedState:s},r}function w0(s,r,l,d){return s.baseState=l,Nh(s,bt,typeof d=="function"?d:ma)}function iR(s,r,l,d,p){if(eu(s))throw Error(a(485));if(s=r.action,s!==null){var y={payload:p,action:s,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(E){y.listeners.push(E)}};D.T!==null?l(!0):y.isTransition=!1,d(y),l=r.pending,l===null?(y.next=r.pending=y,S0(r,y)):(y.next=l.next,r.pending=l.next=y)}}function S0(s,r){var l=r.action,d=r.payload,p=s.state;if(r.isTransition){var y=D.T,E={};D.T=E;try{var M=l(p,d),H=D.S;H!==null&&H(E,M),j0(s,r,M)}catch(ne){Ch(s,r,ne)}finally{y!==null&&E.types!==null&&(y.types=E.types),D.T=y}}else try{y=l(p,d),j0(s,r,y)}catch(ne){Ch(s,r,ne)}}function j0(s,r,l){l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(function(d){N0(s,r,d)},function(d){return Ch(s,r,d)}):N0(s,r,l)}function N0(s,r,l){r.status="fulfilled",r.value=l,k0(r),s.state=l,r=s.pending,r!==null&&(l=r.next,l===r?s.pending=null:(l=l.next,r.next=l,S0(s,l)))}function Ch(s,r,l){var d=s.pending;if(s.pending=null,d!==null){d=d.next;do r.status="rejected",r.reason=l,k0(r),r=r.next;while(r!==d)}s.action=null}function k0(s){s=s.listeners;for(var r=0;r<s.length;r++)(0,s[r])()}function E0(s,r){return r}function C0(s,r){if(ot){var l=jt.formState;if(l!==null){e:{var d=Xe;if(ot){if(At){t:{for(var p=At,y=gs;p.nodeType!==8;){if(!y){p=null;break t}if(p=ys(p.nextSibling),p===null){p=null;break t}}y=p.data,p=y==="F!"||y==="F"?p:null}if(p){At=ys(p.nextSibling),d=p.data==="F!";break e}}Da(d)}d=!1}d&&(r=l[0])}}return l=On(),l.memoizedState=l.baseState=r,d={pending:null,lanes:0,dispatch:null,lastRenderedReducer:E0,lastRenderedState:r},l.queue=d,l=q0.bind(null,Xe,d),d.dispatch=l,d=Eh(!1),y=Oh.bind(null,Xe,!1,d.queue),d=On(),p={state:r,dispatch:null,action:s,pending:null},d.queue=p,l=iR.bind(null,Xe,p,y,l),p.dispatch=l,d.memoizedState=s,[r,l,!1]}function T0(s){var r=Jt();return A0(r,bt,s)}function A0(s,r,l){if(r=Nh(s,r,E0)[0],s=Kc(ma)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var d=rl(r)}catch(E){throw E===Mi?Bc:E}else d=r;r=Jt();var p=r.queue,y=p.dispatch;return l!==r.memoizedState&&(Xe.flags|=2048,zi(9,{destroy:void 0},oR.bind(null,p,l),null)),[d,y,s]}function oR(s,r){s.action=r}function R0(s){var r=Jt(),l=bt;if(l!==null)return A0(r,l,s);Jt(),r=r.memoizedState,l=Jt();var d=l.queue.dispatch;return l.memoizedState=s,[r,d,!1]}function zi(s,r,l,d){return s={tag:s,create:l,deps:d,inst:r,next:null},r=Xe.updateQueue,r===null&&(r=Wc(),Xe.updateQueue=r),l=r.lastEffect,l===null?r.lastEffect=s.next=s:(d=l.next,l.next=s,s.next=d,r.lastEffect=s),s}function M0(){return Jt().memoizedState}function Jc(s,r,l,d){var p=On();Xe.flags|=s,p.memoizedState=zi(1|r,{destroy:void 0},l,d===void 0?null:d)}function Qc(s,r,l,d){var p=Jt();d=d===void 0?null:d;var y=p.memoizedState.inst;bt!==null&&d!==null&&yh(d,bt.memoizedState.deps)?p.memoizedState=zi(r,y,l,d):(Xe.flags|=s,p.memoizedState=zi(1|r,y,l,d))}function _0(s,r){Jc(8390656,8,s,r)}function Th(s,r){Qc(2048,8,s,r)}function lR(s){Xe.flags|=4;var r=Xe.updateQueue;if(r===null)r=Wc(),Xe.updateQueue=r,r.events=[s];else{var l=r.events;l===null?r.events=[s]:l.push(s)}}function O0(s){var r=Jt().memoizedState;return lR({ref:r,nextImpl:s}),function(){if((pt&2)!==0)throw Error(a(440));return r.impl.apply(void 0,arguments)}}function I0(s,r){return Qc(4,2,s,r)}function D0(s,r){return Qc(4,4,s,r)}function z0(s,r){if(typeof r=="function"){s=s();var l=r(s);return function(){typeof l=="function"?l():r(null)}}if(r!=null)return s=s(),r.current=s,function(){r.current=null}}function L0(s,r,l){l=l!=null?l.concat([s]):null,Qc(4,4,z0.bind(null,r,s),l)}function Ah(){}function $0(s,r){var l=Jt();r=r===void 0?null:r;var d=l.memoizedState;return r!==null&&yh(r,d[1])?d[0]:(l.memoizedState=[s,r],s)}function P0(s,r){var l=Jt();r=r===void 0?null:r;var d=l.memoizedState;if(r!==null&&yh(r,d[1]))return d[0];if(d=s(),$r){tt(!0);try{s()}finally{tt(!1)}}return l.memoizedState=[d,r],d}function Rh(s,r,l){return l===void 0||(ha&1073741824)!==0&&(rt&261930)===0?s.memoizedState=r:(s.memoizedState=l,s=Ux(),Xe.lanes|=s,Za|=s,l)}function U0(s,r,l,d){return Jn(l,r)?l:Oi.current!==null?(s=Rh(s,l,d),Jn(s,r)||(nn=!0),s):(ha&42)===0||(ha&1073741824)!==0&&(rt&261930)===0?(nn=!0,s.memoizedState=l):(s=Ux(),Xe.lanes|=s,Za|=s,r)}function B0(s,r,l,d,p){var y=U.p;U.p=y!==0&&8>y?y:8;var E=D.T,M={};D.T=M,Oh(s,!1,r,l);try{var H=p(),ne=D.S;if(ne!==null&&ne(M,H),H!==null&&typeof H=="object"&&typeof H.then=="function"){var oe=sR(H,d);il(s,r,oe,as(s))}else il(s,r,d,as(s))}catch(fe){il(s,r,{then:function(){},status:"rejected",reason:fe},as())}finally{U.p=y,E!==null&&M.types!==null&&(E.types=M.types),D.T=E}}function cR(){}function Mh(s,r,l,d){if(s.tag!==5)throw Error(a(476));var p=V0(s).queue;B0(s,p,r,B,l===null?cR:function(){return H0(s),l(d)})}function V0(s){var r=s.memoizedState;if(r!==null)return r;r={memoizedState:B,baseState:B,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ma,lastRenderedState:B},next:null};var l={};return r.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ma,lastRenderedState:l},next:null},s.memoizedState=r,s=s.alternate,s!==null&&(s.memoizedState=r),r}function H0(s){var r=V0(s);r.next===null&&(r=s.alternate.memoizedState),il(s,r.next.queue,{},as())}function _h(){return Sn(jl)}function Z0(){return Jt().memoizedState}function F0(){return Jt().memoizedState}function uR(s){for(var r=s.return;r!==null;){switch(r.tag){case 24:case 3:var l=as();s=$a(l);var d=Pa(r,s,l);d!==null&&(qn(d,r,l),tl(d,r,l)),r={cache:oh()},s.payload=r;return}r=r.return}}function dR(s,r,l){var d=as();l={lane:d,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},eu(s)?Y0(r,l):(l=Xf(s,r,l,d),l!==null&&(qn(l,s,d),G0(l,r,d)))}function q0(s,r,l){var d=as();il(s,r,l,d)}function il(s,r,l,d){var p={lane:d,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(eu(s))Y0(r,p);else{var y=s.alternate;if(s.lanes===0&&(y===null||y.lanes===0)&&(y=r.lastRenderedReducer,y!==null))try{var E=r.lastRenderedState,M=y(E,l);if(p.hasEagerState=!0,p.eagerState=M,Jn(M,E))return Ic(s,r,p,0),jt===null&&Oc(),!1}catch{}if(l=Xf(s,r,p,d),l!==null)return qn(l,s,d),G0(l,r,d),!0}return!1}function Oh(s,r,l,d){if(d={lane:2,revertLane:dm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},eu(s)){if(r)throw Error(a(479))}else r=Xf(s,l,d,2),r!==null&&qn(r,s,2)}function eu(s){var r=s.alternate;return s===Xe||r!==null&&r===Xe}function Y0(s,r){Ii=Yc=!0;var l=s.pending;l===null?r.next=r:(r.next=l.next,l.next=r),s.pending=r}function G0(s,r,l){if((l&4194048)!==0){var d=r.lanes;d&=s.pendingLanes,l|=d,r.lanes=l,Ft(s,l)}}var ol={readContext:Sn,use:Xc,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};ol.useEffectEvent=Yt;var W0={readContext:Sn,use:Xc,useCallback:function(s,r){return On().memoizedState=[s,r===void 0?null:r],s},useContext:Sn,useEffect:_0,useImperativeHandle:function(s,r,l){l=l!=null?l.concat([s]):null,Jc(4194308,4,z0.bind(null,r,s),l)},useLayoutEffect:function(s,r){return Jc(4194308,4,s,r)},useInsertionEffect:function(s,r){Jc(4,2,s,r)},useMemo:function(s,r){var l=On();r=r===void 0?null:r;var d=s();if($r){tt(!0);try{s()}finally{tt(!1)}}return l.memoizedState=[d,r],d},useReducer:function(s,r,l){var d=On();if(l!==void 0){var p=l(r);if($r){tt(!0);try{l(r)}finally{tt(!1)}}}else p=r;return d.memoizedState=d.baseState=p,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:p},d.queue=s,s=s.dispatch=dR.bind(null,Xe,s),[d.memoizedState,s]},useRef:function(s){var r=On();return s={current:s},r.memoizedState=s},useState:function(s){s=Eh(s);var r=s.queue,l=q0.bind(null,Xe,r);return r.dispatch=l,[s.memoizedState,l]},useDebugValue:Ah,useDeferredValue:function(s,r){var l=On();return Rh(l,s,r)},useTransition:function(){var s=Eh(!1);return s=B0.bind(null,Xe,s.queue,!0,!1),On().memoizedState=s,[!1,s]},useSyncExternalStore:function(s,r,l){var d=Xe,p=On();if(ot){if(l===void 0)throw Error(a(407));l=l()}else{if(l=r(),jt===null)throw Error(a(349));(rt&127)!==0||g0(d,r,l)}p.memoizedState=l;var y={value:l,getSnapshot:r};return p.queue=y,_0(y0.bind(null,d,y,s),[s]),d.flags|=2048,zi(9,{destroy:void 0},v0.bind(null,d,y,l,r),null),l},useId:function(){var s=On(),r=jt.identifierPrefix;if(ot){var l=Vs,d=Bs;l=(d&~(1<<32-ut(d)-1)).toString(32)+l,r="_"+r+"R_"+l,l=Gc++,0<l&&(r+="H"+l.toString(32)),r+="_"}else l=aR++,r="_"+r+"r_"+l.toString(32)+"_";return s.memoizedState=r},useHostTransitionStatus:_h,useFormState:C0,useActionState:C0,useOptimistic:function(s){var r=On();r.memoizedState=r.baseState=s;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=l,r=Oh.bind(null,Xe,!0,l),l.dispatch=r,[s,r]},useMemoCache:jh,useCacheRefresh:function(){return On().memoizedState=uR.bind(null,Xe)},useEffectEvent:function(s){var r=On(),l={impl:s};return r.memoizedState=l,function(){if((pt&2)!==0)throw Error(a(440));return l.impl.apply(void 0,arguments)}}},Ih={readContext:Sn,use:Xc,useCallback:$0,useContext:Sn,useEffect:Th,useImperativeHandle:L0,useInsertionEffect:I0,useLayoutEffect:D0,useMemo:P0,useReducer:Kc,useRef:M0,useState:function(){return Kc(ma)},useDebugValue:Ah,useDeferredValue:function(s,r){var l=Jt();return U0(l,bt.memoizedState,s,r)},useTransition:function(){var s=Kc(ma)[0],r=Jt().memoizedState;return[typeof s=="boolean"?s:rl(s),r]},useSyncExternalStore:p0,useId:Z0,useHostTransitionStatus:_h,useFormState:T0,useActionState:T0,useOptimistic:function(s,r){var l=Jt();return w0(l,bt,s,r)},useMemoCache:jh,useCacheRefresh:F0};Ih.useEffectEvent=O0;var X0={readContext:Sn,use:Xc,useCallback:$0,useContext:Sn,useEffect:Th,useImperativeHandle:L0,useInsertionEffect:I0,useLayoutEffect:D0,useMemo:P0,useReducer:kh,useRef:M0,useState:function(){return kh(ma)},useDebugValue:Ah,useDeferredValue:function(s,r){var l=Jt();return bt===null?Rh(l,s,r):U0(l,bt.memoizedState,s,r)},useTransition:function(){var s=kh(ma)[0],r=Jt().memoizedState;return[typeof s=="boolean"?s:rl(s),r]},useSyncExternalStore:p0,useId:Z0,useHostTransitionStatus:_h,useFormState:R0,useActionState:R0,useOptimistic:function(s,r){var l=Jt();return bt!==null?w0(l,bt,s,r):(l.baseState=s,[s,l.queue.dispatch])},useMemoCache:jh,useCacheRefresh:F0};X0.useEffectEvent=O0;function Dh(s,r,l,d){r=s.memoizedState,l=l(d,r),l=l==null?r:x({},r,l),s.memoizedState=l,s.lanes===0&&(s.updateQueue.baseState=l)}var zh={enqueueSetState:function(s,r,l){s=s._reactInternals;var d=as(),p=$a(d);p.payload=r,l!=null&&(p.callback=l),r=Pa(s,p,d),r!==null&&(qn(r,s,d),tl(r,s,d))},enqueueReplaceState:function(s,r,l){s=s._reactInternals;var d=as(),p=$a(d);p.tag=1,p.payload=r,l!=null&&(p.callback=l),r=Pa(s,p,d),r!==null&&(qn(r,s,d),tl(r,s,d))},enqueueForceUpdate:function(s,r){s=s._reactInternals;var l=as(),d=$a(l);d.tag=2,r!=null&&(d.callback=r),r=Pa(s,d,l),r!==null&&(qn(r,s,l),tl(r,s,l))}};function K0(s,r,l,d,p,y,E){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(d,y,E):r.prototype&&r.prototype.isPureReactComponent?!Yo(l,d)||!Yo(p,y):!0}function J0(s,r,l,d){s=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(l,d),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(l,d),r.state!==s&&zh.enqueueReplaceState(r,r.state,null)}function Pr(s,r){var l=r;if("ref"in r){l={};for(var d in r)d!=="ref"&&(l[d]=r[d])}if(s=s.defaultProps){l===r&&(l=x({},l));for(var p in s)l[p]===void 0&&(l[p]=s[p])}return l}function Q0(s){_c(s)}function ex(s){console.error(s)}function tx(s){_c(s)}function tu(s,r){try{var l=s.onUncaughtError;l(r.value,{componentStack:r.stack})}catch(d){setTimeout(function(){throw d})}}function nx(s,r,l){try{var d=s.onCaughtError;d(l.value,{componentStack:l.stack,errorBoundary:r.tag===1?r.stateNode:null})}catch(p){setTimeout(function(){throw p})}}function Lh(s,r,l){return l=$a(l),l.tag=3,l.payload={element:null},l.callback=function(){tu(s,r)},l}function sx(s){return s=$a(s),s.tag=3,s}function ax(s,r,l,d){var p=l.type.getDerivedStateFromError;if(typeof p=="function"){var y=d.value;s.payload=function(){return p(y)},s.callback=function(){nx(r,l,d)}}var E=l.stateNode;E!==null&&typeof E.componentDidCatch=="function"&&(s.callback=function(){nx(r,l,d),typeof p!="function"&&(Fa===null?Fa=new Set([this]):Fa.add(this));var M=d.stack;this.componentDidCatch(d.value,{componentStack:M!==null?M:""})})}function fR(s,r,l,d,p){if(l.flags|=32768,d!==null&&typeof d=="object"&&typeof d.then=="function"){if(r=l.alternate,r!==null&&Ti(r,l,p,!0),l=es.current,l!==null){switch(l.tag){case 31:case 13:return vs===null?hu():l.alternate===null&&Gt===0&&(Gt=3),l.flags&=-257,l.flags|=65536,l.lanes=p,d===Vc?l.flags|=16384:(r=l.updateQueue,r===null?l.updateQueue=new Set([d]):r.add(d),lm(s,d,p)),!1;case 22:return l.flags|=65536,d===Vc?l.flags|=16384:(r=l.updateQueue,r===null?(r={transitions:null,markerInstances:null,retryQueue:new Set([d])},l.updateQueue=r):(l=r.retryQueue,l===null?r.retryQueue=new Set([d]):l.add(d)),lm(s,d,p)),!1}throw Error(a(435,l.tag))}return lm(s,d,p),hu(),!1}if(ot)return r=es.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=p,d!==nh&&(s=Error(a(422),{cause:d}),Xo(hs(s,l)))):(d!==nh&&(r=Error(a(423),{cause:d}),Xo(hs(r,l))),s=s.current.alternate,s.flags|=65536,p&=-p,s.lanes|=p,d=hs(d,l),p=Lh(s.stateNode,d,p),hh(s,p),Gt!==4&&(Gt=2)),!1;var y=Error(a(520),{cause:d});if(y=hs(y,l),pl===null?pl=[y]:pl.push(y),Gt!==4&&(Gt=2),r===null)return!0;d=hs(d,l),l=r;do{switch(l.tag){case 3:return l.flags|=65536,s=p&-p,l.lanes|=s,s=Lh(l.stateNode,d,s),hh(l,s),!1;case 1:if(r=l.type,y=l.stateNode,(l.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&(Fa===null||!Fa.has(y))))return l.flags|=65536,p&=-p,l.lanes|=p,p=sx(p),ax(p,s,l,d),hh(l,p),!1}l=l.return}while(l!==null);return!1}var $h=Error(a(461)),nn=!1;function jn(s,r,l,d){r.child=s===null?l0(r,null,l,d):Lr(r,s.child,l,d)}function rx(s,r,l,d,p){l=l.render;var y=r.ref;if("ref"in d){var E={};for(var M in d)M!=="ref"&&(E[M]=d[M])}else E=d;return Or(r),d=xh(s,r,l,E,y,p),M=bh(),s!==null&&!nn?(wh(s,r,p),pa(s,r,p)):(ot&&M&&eh(r),r.flags|=1,jn(s,r,d,p),r.child)}function ix(s,r,l,d,p){if(s===null){var y=l.type;return typeof y=="function"&&!Kf(y)&&y.defaultProps===void 0&&l.compare===null?(r.tag=15,r.type=y,ox(s,r,y,d,p)):(s=zc(l.type,null,d,r,r.mode,p),s.ref=r.ref,s.return=r,r.child=s)}if(y=s.child,!qh(s,p)){var E=y.memoizedProps;if(l=l.compare,l=l!==null?l:Yo,l(E,d)&&s.ref===r.ref)return pa(s,r,p)}return r.flags|=1,s=ca(y,d),s.ref=r.ref,s.return=r,r.child=s}function ox(s,r,l,d,p){if(s!==null){var y=s.memoizedProps;if(Yo(y,d)&&s.ref===r.ref)if(nn=!1,r.pendingProps=d=y,qh(s,p))(s.flags&131072)!==0&&(nn=!0);else return r.lanes=s.lanes,pa(s,r,p)}return Ph(s,r,l,d,p)}function lx(s,r,l,d){var p=d.children,y=s!==null?s.memoizedState:null;if(s===null&&r.stateNode===null&&(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),d.mode==="hidden"){if((r.flags&128)!==0){if(y=y!==null?y.baseLanes|l:l,s!==null){for(d=r.child=s.child,p=0;d!==null;)p=p|d.lanes|d.childLanes,d=d.sibling;d=p&~y}else d=0,r.child=null;return cx(s,r,y,l,d)}if((l&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},s!==null&&Uc(r,y!==null?y.cachePool:null),y!==null?d0(r,y):ph(),f0(r);else return d=r.lanes=536870912,cx(s,r,y!==null?y.baseLanes|l:l,l,d)}else y!==null?(Uc(r,y.cachePool),d0(r,y),Ba(),r.memoizedState=null):(s!==null&&Uc(r,null),ph(),Ba());return jn(s,r,p,l),r.child}function ll(s,r){return s!==null&&s.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function cx(s,r,l,d,p){var y=ch();return y=y===null?null:{parent:en._currentValue,pool:y},r.memoizedState={baseLanes:l,cachePool:y},s!==null&&Uc(r,null),ph(),f0(r),s!==null&&Ti(s,r,d,!0),r.childLanes=p,null}function nu(s,r){return r=au({mode:r.mode,children:r.children},s.mode),r.ref=s.ref,s.child=r,r.return=s,r}function ux(s,r,l){return Lr(r,s.child,null,l),s=nu(r,r.pendingProps),s.flags|=2,ts(r),r.memoizedState=null,s}function hR(s,r,l){var d=r.pendingProps,p=(r.flags&128)!==0;if(r.flags&=-129,s===null){if(ot){if(d.mode==="hidden")return s=nu(r,d),r.lanes=536870912,ll(null,s);if(vh(r),(s=At)?(s=Sb(s,gs),s=s!==null&&s.data==="&"?s:null,s!==null&&(r.memoizedState={dehydrated:s,treeContext:Oa!==null?{id:Bs,overflow:Vs}:null,retryLane:536870912,hydrationErrors:null},l=Yy(s),l.return=r,r.child=l,wn=r,At=null)):s=null,s===null)throw Da(r);return r.lanes=536870912,null}return nu(r,d)}var y=s.memoizedState;if(y!==null){var E=y.dehydrated;if(vh(r),p)if(r.flags&256)r.flags&=-257,r=ux(s,r,l);else if(r.memoizedState!==null)r.child=s.child,r.flags|=128,r=null;else throw Error(a(558));else if(nn||Ti(s,r,l,!1),p=(l&s.childLanes)!==0,nn||p){if(d=jt,d!==null&&(E=xn(d,l),E!==0&&E!==y.retryLane))throw y.retryLane=E,Ar(s,E),qn(d,s,E),$h;hu(),r=ux(s,r,l)}else s=y.treeContext,At=ys(E.nextSibling),wn=r,ot=!0,Ia=null,gs=!1,s!==null&&Xy(r,s),r=nu(r,d),r.flags|=4096;return r}return s=ca(s.child,{mode:d.mode,children:d.children}),s.ref=r.ref,r.child=s,s.return=r,s}function su(s,r){var l=r.ref;if(l===null)s!==null&&s.ref!==null&&(r.flags|=4194816);else{if(typeof l!="function"&&typeof l!="object")throw Error(a(284));(s===null||s.ref!==l)&&(r.flags|=4194816)}}function Ph(s,r,l,d,p){return Or(r),l=xh(s,r,l,d,void 0,p),d=bh(),s!==null&&!nn?(wh(s,r,p),pa(s,r,p)):(ot&&d&&eh(r),r.flags|=1,jn(s,r,l,p),r.child)}function dx(s,r,l,d,p,y){return Or(r),r.updateQueue=null,l=m0(r,d,l,p),h0(s),d=bh(),s!==null&&!nn?(wh(s,r,y),pa(s,r,y)):(ot&&d&&eh(r),r.flags|=1,jn(s,r,l,y),r.child)}function fx(s,r,l,d,p){if(Or(r),r.stateNode===null){var y=Ni,E=l.contextType;typeof E=="object"&&E!==null&&(y=Sn(E)),y=new l(d,y),r.memoizedState=y.state!==null&&y.state!==void 0?y.state:null,y.updater=zh,r.stateNode=y,y._reactInternals=r,y=r.stateNode,y.props=d,y.state=r.memoizedState,y.refs={},dh(r),E=l.contextType,y.context=typeof E=="object"&&E!==null?Sn(E):Ni,y.state=r.memoizedState,E=l.getDerivedStateFromProps,typeof E=="function"&&(Dh(r,l,E,d),y.state=r.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof y.getSnapshotBeforeUpdate=="function"||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(E=y.state,typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount(),E!==y.state&&zh.enqueueReplaceState(y,y.state,null),sl(r,d,y,p),nl(),y.state=r.memoizedState),typeof y.componentDidMount=="function"&&(r.flags|=4194308),d=!0}else if(s===null){y=r.stateNode;var M=r.memoizedProps,H=Pr(l,M);y.props=H;var ne=y.context,oe=l.contextType;E=Ni,typeof oe=="object"&&oe!==null&&(E=Sn(oe));var fe=l.getDerivedStateFromProps;oe=typeof fe=="function"||typeof y.getSnapshotBeforeUpdate=="function",M=r.pendingProps!==M,oe||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(M||ne!==E)&&J0(r,y,d,E),La=!1;var se=r.memoizedState;y.state=se,sl(r,d,y,p),nl(),ne=r.memoizedState,M||se!==ne||La?(typeof fe=="function"&&(Dh(r,l,fe,d),ne=r.memoizedState),(H=La||K0(r,l,H,d,se,ne,E))?(oe||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount()),typeof y.componentDidMount=="function"&&(r.flags|=4194308)):(typeof y.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=d,r.memoizedState=ne),y.props=d,y.state=ne,y.context=E,d=H):(typeof y.componentDidMount=="function"&&(r.flags|=4194308),d=!1)}else{y=r.stateNode,fh(s,r),E=r.memoizedProps,oe=Pr(l,E),y.props=oe,fe=r.pendingProps,se=y.context,ne=l.contextType,H=Ni,typeof ne=="object"&&ne!==null&&(H=Sn(ne)),M=l.getDerivedStateFromProps,(ne=typeof M=="function"||typeof y.getSnapshotBeforeUpdate=="function")||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(E!==fe||se!==H)&&J0(r,y,d,H),La=!1,se=r.memoizedState,y.state=se,sl(r,d,y,p),nl();var re=r.memoizedState;E!==fe||se!==re||La||s!==null&&s.dependencies!==null&&$c(s.dependencies)?(typeof M=="function"&&(Dh(r,l,M,d),re=r.memoizedState),(oe=La||K0(r,l,oe,d,se,re,H)||s!==null&&s.dependencies!==null&&$c(s.dependencies))?(ne||typeof y.UNSAFE_componentWillUpdate!="function"&&typeof y.componentWillUpdate!="function"||(typeof y.componentWillUpdate=="function"&&y.componentWillUpdate(d,re,H),typeof y.UNSAFE_componentWillUpdate=="function"&&y.UNSAFE_componentWillUpdate(d,re,H)),typeof y.componentDidUpdate=="function"&&(r.flags|=4),typeof y.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof y.componentDidUpdate!="function"||E===s.memoizedProps&&se===s.memoizedState||(r.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||E===s.memoizedProps&&se===s.memoizedState||(r.flags|=1024),r.memoizedProps=d,r.memoizedState=re),y.props=d,y.state=re,y.context=H,d=oe):(typeof y.componentDidUpdate!="function"||E===s.memoizedProps&&se===s.memoizedState||(r.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||E===s.memoizedProps&&se===s.memoizedState||(r.flags|=1024),d=!1)}return y=d,su(s,r),d=(r.flags&128)!==0,y||d?(y=r.stateNode,l=d&&typeof l.getDerivedStateFromError!="function"?null:y.render(),r.flags|=1,s!==null&&d?(r.child=Lr(r,s.child,null,p),r.child=Lr(r,null,l,p)):jn(s,r,l,p),r.memoizedState=y.state,s=r.child):s=pa(s,r,p),s}function hx(s,r,l,d){return Mr(),r.flags|=256,jn(s,r,l,d),r.child}var Uh={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Bh(s){return{baseLanes:s,cachePool:n0()}}function Vh(s,r,l){return s=s!==null?s.childLanes&~l:0,r&&(s|=ss),s}function mx(s,r,l){var d=r.pendingProps,p=!1,y=(r.flags&128)!==0,E;if((E=y)||(E=s!==null&&s.memoizedState===null?!1:(Kt.current&2)!==0),E&&(p=!0,r.flags&=-129),E=(r.flags&32)!==0,r.flags&=-33,s===null){if(ot){if(p?Ua(r):Ba(),(s=At)?(s=Sb(s,gs),s=s!==null&&s.data!=="&"?s:null,s!==null&&(r.memoizedState={dehydrated:s,treeContext:Oa!==null?{id:Bs,overflow:Vs}:null,retryLane:536870912,hydrationErrors:null},l=Yy(s),l.return=r,r.child=l,wn=r,At=null)):s=null,s===null)throw Da(r);return Nm(s)?r.lanes=32:r.lanes=536870912,null}var M=d.children;return d=d.fallback,p?(Ba(),p=r.mode,M=au({mode:"hidden",children:M},p),d=Rr(d,p,l,null),M.return=r,d.return=r,M.sibling=d,r.child=M,d=r.child,d.memoizedState=Bh(l),d.childLanes=Vh(s,E,l),r.memoizedState=Uh,ll(null,d)):(Ua(r),Hh(r,M))}var H=s.memoizedState;if(H!==null&&(M=H.dehydrated,M!==null)){if(y)r.flags&256?(Ua(r),r.flags&=-257,r=Zh(s,r,l)):r.memoizedState!==null?(Ba(),r.child=s.child,r.flags|=128,r=null):(Ba(),M=d.fallback,p=r.mode,d=au({mode:"visible",children:d.children},p),M=Rr(M,p,l,null),M.flags|=2,d.return=r,M.return=r,d.sibling=M,r.child=d,Lr(r,s.child,null,l),d=r.child,d.memoizedState=Bh(l),d.childLanes=Vh(s,E,l),r.memoizedState=Uh,r=ll(null,d));else if(Ua(r),Nm(M)){if(E=M.nextSibling&&M.nextSibling.dataset,E)var ne=E.dgst;E=ne,d=Error(a(419)),d.stack="",d.digest=E,Xo({value:d,source:null,stack:null}),r=Zh(s,r,l)}else if(nn||Ti(s,r,l,!1),E=(l&s.childLanes)!==0,nn||E){if(E=jt,E!==null&&(d=xn(E,l),d!==0&&d!==H.retryLane))throw H.retryLane=d,Ar(s,d),qn(E,s,d),$h;jm(M)||hu(),r=Zh(s,r,l)}else jm(M)?(r.flags|=192,r.child=s.child,r=null):(s=H.treeContext,At=ys(M.nextSibling),wn=r,ot=!0,Ia=null,gs=!1,s!==null&&Xy(r,s),r=Hh(r,d.children),r.flags|=4096);return r}return p?(Ba(),M=d.fallback,p=r.mode,H=s.child,ne=H.sibling,d=ca(H,{mode:"hidden",children:d.children}),d.subtreeFlags=H.subtreeFlags&65011712,ne!==null?M=ca(ne,M):(M=Rr(M,p,l,null),M.flags|=2),M.return=r,d.return=r,d.sibling=M,r.child=d,ll(null,d),d=r.child,M=s.child.memoizedState,M===null?M=Bh(l):(p=M.cachePool,p!==null?(H=en._currentValue,p=p.parent!==H?{parent:H,pool:H}:p):p=n0(),M={baseLanes:M.baseLanes|l,cachePool:p}),d.memoizedState=M,d.childLanes=Vh(s,E,l),r.memoizedState=Uh,ll(s.child,d)):(Ua(r),l=s.child,s=l.sibling,l=ca(l,{mode:"visible",children:d.children}),l.return=r,l.sibling=null,s!==null&&(E=r.deletions,E===null?(r.deletions=[s],r.flags|=16):E.push(s)),r.child=l,r.memoizedState=null,l)}function Hh(s,r){return r=au({mode:"visible",children:r},s.mode),r.return=s,s.child=r}function au(s,r){return s=Qn(22,s,null,r),s.lanes=0,s}function Zh(s,r,l){return Lr(r,s.child,null,l),s=Hh(r,r.pendingProps.children),s.flags|=2,r.memoizedState=null,s}function px(s,r,l){s.lanes|=r;var d=s.alternate;d!==null&&(d.lanes|=r),rh(s.return,r,l)}function Fh(s,r,l,d,p,y){var E=s.memoizedState;E===null?s.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:d,tail:l,tailMode:p,treeForkCount:y}:(E.isBackwards=r,E.rendering=null,E.renderingStartTime=0,E.last=d,E.tail=l,E.tailMode=p,E.treeForkCount=y)}function gx(s,r,l){var d=r.pendingProps,p=d.revealOrder,y=d.tail;d=d.children;var E=Kt.current,M=(E&2)!==0;if(M?(E=E&1|2,r.flags|=128):E&=1,W(Kt,E),jn(s,r,d,l),d=ot?Wo:0,!M&&s!==null&&(s.flags&128)!==0)e:for(s=r.child;s!==null;){if(s.tag===13)s.memoizedState!==null&&px(s,l,r);else if(s.tag===19)px(s,l,r);else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===r)break e;for(;s.sibling===null;){if(s.return===null||s.return===r)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}switch(p){case"forwards":for(l=r.child,p=null;l!==null;)s=l.alternate,s!==null&&qc(s)===null&&(p=l),l=l.sibling;l=p,l===null?(p=r.child,r.child=null):(p=l.sibling,l.sibling=null),Fh(r,!1,p,l,y,d);break;case"backwards":case"unstable_legacy-backwards":for(l=null,p=r.child,r.child=null;p!==null;){if(s=p.alternate,s!==null&&qc(s)===null){r.child=p;break}s=p.sibling,p.sibling=l,l=p,p=s}Fh(r,!0,l,null,y,d);break;case"together":Fh(r,!1,null,null,void 0,d);break;default:r.memoizedState=null}return r.child}function pa(s,r,l){if(s!==null&&(r.dependencies=s.dependencies),Za|=r.lanes,(l&r.childLanes)===0)if(s!==null){if(Ti(s,r,l,!1),(l&r.childLanes)===0)return null}else return null;if(s!==null&&r.child!==s.child)throw Error(a(153));if(r.child!==null){for(s=r.child,l=ca(s,s.pendingProps),r.child=l,l.return=r;s.sibling!==null;)s=s.sibling,l=l.sibling=ca(s,s.pendingProps),l.return=r;l.sibling=null}return r.child}function qh(s,r){return(s.lanes&r)!==0?!0:(s=s.dependencies,!!(s!==null&&$c(s)))}function mR(s,r,l){switch(r.tag){case 3:ve(r,r.stateNode.containerInfo),za(r,en,s.memoizedState.cache),Mr();break;case 27:case 5:_e(r);break;case 4:ve(r,r.stateNode.containerInfo);break;case 10:za(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,vh(r),null;break;case 13:var d=r.memoizedState;if(d!==null)return d.dehydrated!==null?(Ua(r),r.flags|=128,null):(l&r.child.childLanes)!==0?mx(s,r,l):(Ua(r),s=pa(s,r,l),s!==null?s.sibling:null);Ua(r);break;case 19:var p=(s.flags&128)!==0;if(d=(l&r.childLanes)!==0,d||(Ti(s,r,l,!1),d=(l&r.childLanes)!==0),p){if(d)return gx(s,r,l);r.flags|=128}if(p=r.memoizedState,p!==null&&(p.rendering=null,p.tail=null,p.lastEffect=null),W(Kt,Kt.current),d)break;return null;case 22:return r.lanes=0,lx(s,r,l,r.pendingProps);case 24:za(r,en,s.memoizedState.cache)}return pa(s,r,l)}function vx(s,r,l){if(s!==null)if(s.memoizedProps!==r.pendingProps)nn=!0;else{if(!qh(s,l)&&(r.flags&128)===0)return nn=!1,mR(s,r,l);nn=(s.flags&131072)!==0}else nn=!1,ot&&(r.flags&1048576)!==0&&Wy(r,Wo,r.index);switch(r.lanes=0,r.tag){case 16:e:{var d=r.pendingProps;if(s=Dr(r.elementType),r.type=s,typeof s=="function")Kf(s)?(d=Pr(s,d),r.tag=1,r=fx(null,r,s,d,l)):(r.tag=0,r=Ph(null,r,s,d,l));else{if(s!=null){var p=s.$$typeof;if(p===R){r.tag=11,r=rx(null,r,s,d,l);break e}else if(p===O){r.tag=14,r=ix(null,r,s,d,l);break e}}throw r=q(s)||s,Error(a(306,r,""))}}return r;case 0:return Ph(s,r,r.type,r.pendingProps,l);case 1:return d=r.type,p=Pr(d,r.pendingProps),fx(s,r,d,p,l);case 3:e:{if(ve(r,r.stateNode.containerInfo),s===null)throw Error(a(387));d=r.pendingProps;var y=r.memoizedState;p=y.element,fh(s,r),sl(r,d,null,l);var E=r.memoizedState;if(d=E.cache,za(r,en,d),d!==y.cache&&ih(r,[en],l,!0),nl(),d=E.element,y.isDehydrated)if(y={element:d,isDehydrated:!1,cache:E.cache},r.updateQueue.baseState=y,r.memoizedState=y,r.flags&256){r=hx(s,r,d,l);break e}else if(d!==p){p=hs(Error(a(424)),r),Xo(p),r=hx(s,r,d,l);break e}else for(s=r.stateNode.containerInfo,s.nodeType===9?s=s.body:s=s.nodeName==="HTML"?s.ownerDocument.body:s,At=ys(s.firstChild),wn=r,ot=!0,Ia=null,gs=!0,l=l0(r,null,d,l),r.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(Mr(),d===p){r=pa(s,r,l);break e}jn(s,r,d,l)}r=r.child}return r;case 26:return su(s,r),s===null?(l=Tb(r.type,null,r.pendingProps,null))?r.memoizedState=l:ot||(l=r.type,s=r.pendingProps,d=bu(ae.current).createElement(l),d[bn]=r,d[Un]=s,Nn(d,l,s),pn(d),r.stateNode=d):r.memoizedState=Tb(r.type,s.memoizedProps,r.pendingProps,s.memoizedState),null;case 27:return _e(r),s===null&&ot&&(d=r.stateNode=kb(r.type,r.pendingProps,ae.current),wn=r,gs=!0,p=At,Wa(r.type)?(km=p,At=ys(d.firstChild)):At=p),jn(s,r,r.pendingProps.children,l),su(s,r),s===null&&(r.flags|=4194304),r.child;case 5:return s===null&&ot&&((p=d=At)&&(d=ZR(d,r.type,r.pendingProps,gs),d!==null?(r.stateNode=d,wn=r,At=ys(d.firstChild),gs=!1,p=!0):p=!1),p||Da(r)),_e(r),p=r.type,y=r.pendingProps,E=s!==null?s.memoizedProps:null,d=y.children,bm(p,y)?d=null:E!==null&&bm(p,E)&&(r.flags|=32),r.memoizedState!==null&&(p=xh(s,r,rR,null,null,l),jl._currentValue=p),su(s,r),jn(s,r,d,l),r.child;case 6:return s===null&&ot&&((s=l=At)&&(l=FR(l,r.pendingProps,gs),l!==null?(r.stateNode=l,wn=r,At=null,s=!0):s=!1),s||Da(r)),null;case 13:return mx(s,r,l);case 4:return ve(r,r.stateNode.containerInfo),d=r.pendingProps,s===null?r.child=Lr(r,null,d,l):jn(s,r,d,l),r.child;case 11:return rx(s,r,r.type,r.pendingProps,l);case 7:return jn(s,r,r.pendingProps,l),r.child;case 8:return jn(s,r,r.pendingProps.children,l),r.child;case 12:return jn(s,r,r.pendingProps.children,l),r.child;case 10:return d=r.pendingProps,za(r,r.type,d.value),jn(s,r,d.children,l),r.child;case 9:return p=r.type._context,d=r.pendingProps.children,Or(r),p=Sn(p),d=d(p),r.flags|=1,jn(s,r,d,l),r.child;case 14:return ix(s,r,r.type,r.pendingProps,l);case 15:return ox(s,r,r.type,r.pendingProps,l);case 19:return gx(s,r,l);case 31:return hR(s,r,l);case 22:return lx(s,r,l,r.pendingProps);case 24:return Or(r),d=Sn(en),s===null?(p=ch(),p===null&&(p=jt,y=oh(),p.pooledCache=y,y.refCount++,y!==null&&(p.pooledCacheLanes|=l),p=y),r.memoizedState={parent:d,cache:p},dh(r),za(r,en,p)):((s.lanes&l)!==0&&(fh(s,r),sl(r,null,null,l),nl()),p=s.memoizedState,y=r.memoizedState,p.parent!==d?(p={parent:d,cache:d},r.memoizedState=p,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=p),za(r,en,d)):(d=y.cache,za(r,en,d),d!==p.cache&&ih(r,[en],l,!0))),jn(s,r,r.pendingProps.children,l),r.child;case 29:throw r.pendingProps}throw Error(a(156,r.tag))}function ga(s){s.flags|=4}function Yh(s,r,l,d,p){if((r=(s.mode&32)!==0)&&(r=!1),r){if(s.flags|=16777216,(p&335544128)===p)if(s.stateNode.complete)s.flags|=8192;else if(Zx())s.flags|=8192;else throw zr=Vc,uh}else s.flags&=-16777217}function yx(s,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)s.flags&=-16777217;else if(s.flags|=16777216,!Ob(r))if(Zx())s.flags|=8192;else throw zr=Vc,uh}function ru(s,r){r!==null&&(s.flags|=4),s.flags&16384&&(r=s.tag!==22?ge():536870912,s.lanes|=r,Ui|=r)}function cl(s,r){if(!ot)switch(s.tailMode){case"hidden":r=s.tail;for(var l=null;r!==null;)r.alternate!==null&&(l=r),r=r.sibling;l===null?s.tail=null:l.sibling=null;break;case"collapsed":l=s.tail;for(var d=null;l!==null;)l.alternate!==null&&(d=l),l=l.sibling;d===null?r||s.tail===null?s.tail=null:s.tail.sibling=null:d.sibling=null}}function Rt(s){var r=s.alternate!==null&&s.alternate.child===s.child,l=0,d=0;if(r)for(var p=s.child;p!==null;)l|=p.lanes|p.childLanes,d|=p.subtreeFlags&65011712,d|=p.flags&65011712,p.return=s,p=p.sibling;else for(p=s.child;p!==null;)l|=p.lanes|p.childLanes,d|=p.subtreeFlags,d|=p.flags,p.return=s,p=p.sibling;return s.subtreeFlags|=d,s.childLanes=l,r}function pR(s,r,l){var d=r.pendingProps;switch(th(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Rt(r),null;case 1:return Rt(r),null;case 3:return l=r.stateNode,d=null,s!==null&&(d=s.memoizedState.cache),r.memoizedState.cache!==d&&(r.flags|=2048),fa(en),be(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(s===null||s.child===null)&&(Ci(r)?ga(r):s===null||s.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,sh())),Rt(r),null;case 26:var p=r.type,y=r.memoizedState;return s===null?(ga(r),y!==null?(Rt(r),yx(r,y)):(Rt(r),Yh(r,p,null,d,l))):y?y!==s.memoizedState?(ga(r),Rt(r),yx(r,y)):(Rt(r),r.flags&=-16777217):(s=s.memoizedProps,s!==d&&ga(r),Rt(r),Yh(r,p,s,d,l)),null;case 27:if(ie(r),l=ae.current,p=r.type,s!==null&&r.stateNode!=null)s.memoizedProps!==d&&ga(r);else{if(!d){if(r.stateNode===null)throw Error(a(166));return Rt(r),null}s=J.current,Ci(r)?Ky(r):(s=kb(p,d,l),r.stateNode=s,ga(r))}return Rt(r),null;case 5:if(ie(r),p=r.type,s!==null&&r.stateNode!=null)s.memoizedProps!==d&&ga(r);else{if(!d){if(r.stateNode===null)throw Error(a(166));return Rt(r),null}if(y=J.current,Ci(r))Ky(r);else{var E=bu(ae.current);switch(y){case 1:y=E.createElementNS("http://www.w3.org/2000/svg",p);break;case 2:y=E.createElementNS("http://www.w3.org/1998/Math/MathML",p);break;default:switch(p){case"svg":y=E.createElementNS("http://www.w3.org/2000/svg",p);break;case"math":y=E.createElementNS("http://www.w3.org/1998/Math/MathML",p);break;case"script":y=E.createElement("div"),y.innerHTML="<script><\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?E.createElement("select",{is:d.is}):E.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?E.createElement(p,{is:d.is}):E.createElement(p)}}y[bn]=r,y[Un]=d;e:for(E=r.child;E!==null;){if(E.tag===5||E.tag===6)y.appendChild(E.stateNode);else if(E.tag!==4&&E.tag!==27&&E.child!==null){E.child.return=E,E=E.child;continue}if(E===r)break e;for(;E.sibling===null;){if(E.return===null||E.return===r)break e;E=E.return}E.sibling.return=E.return,E=E.sibling}r.stateNode=y;e:switch(Nn(y,p,d),p){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&ga(r)}}return Rt(r),Yh(r,r.type,s===null?null:s.memoizedProps,r.pendingProps,l),null;case 6:if(s&&r.stateNode!=null)s.memoizedProps!==d&&ga(r);else{if(typeof d!="string"&&r.stateNode===null)throw Error(a(166));if(s=ae.current,Ci(r)){if(s=r.stateNode,l=r.memoizedProps,d=null,p=wn,p!==null)switch(p.tag){case 27:case 5:d=p.memoizedProps}s[bn]=r,s=!!(s.nodeValue===l||d!==null&&d.suppressHydrationWarning===!0||mb(s.nodeValue,l)),s||Da(r,!0)}else s=bu(s).createTextNode(d),s[bn]=r,r.stateNode=s}return Rt(r),null;case 31:if(l=r.memoizedState,s===null||s.memoizedState!==null){if(d=Ci(r),l!==null){if(s===null){if(!d)throw Error(a(318));if(s=r.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(a(557));s[bn]=r}else Mr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Rt(r),s=!1}else l=sh(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=l),s=!0;if(!s)return r.flags&256?(ts(r),r):(ts(r),null);if((r.flags&128)!==0)throw Error(a(558))}return Rt(r),null;case 13:if(d=r.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(p=Ci(r),d!==null&&d.dehydrated!==null){if(s===null){if(!p)throw Error(a(318));if(p=r.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(a(317));p[bn]=r}else Mr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Rt(r),p=!1}else p=sh(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=p),p=!0;if(!p)return r.flags&256?(ts(r),r):(ts(r),null)}return ts(r),(r.flags&128)!==0?(r.lanes=l,r):(l=d!==null,s=s!==null&&s.memoizedState!==null,l&&(d=r.child,p=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(p=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==p&&(d.flags|=2048)),l!==s&&l&&(r.child.flags|=8192),ru(r,r.updateQueue),Rt(r),null);case 4:return be(),s===null&&pm(r.stateNode.containerInfo),Rt(r),null;case 10:return fa(r.type),Rt(r),null;case 19:if(Y(Kt),d=r.memoizedState,d===null)return Rt(r),null;if(p=(r.flags&128)!==0,y=d.rendering,y===null)if(p)cl(d,!1);else{if(Gt!==0||s!==null&&(s.flags&128)!==0)for(s=r.child;s!==null;){if(y=qc(s),y!==null){for(r.flags|=128,cl(d,!1),s=y.updateQueue,r.updateQueue=s,ru(r,s),r.subtreeFlags=0,s=l,l=r.child;l!==null;)qy(l,s),l=l.sibling;return W(Kt,Kt.current&1|2),ot&&ua(r,d.treeForkCount),r.child}s=s.sibling}d.tail!==null&&je()>uu&&(r.flags|=128,p=!0,cl(d,!1),r.lanes=4194304)}else{if(!p)if(s=qc(y),s!==null){if(r.flags|=128,p=!0,s=s.updateQueue,r.updateQueue=s,ru(r,s),cl(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!ot)return Rt(r),null}else 2*je()-d.renderingStartTime>uu&&l!==536870912&&(r.flags|=128,p=!0,cl(d,!1),r.lanes=4194304);d.isBackwards?(y.sibling=r.child,r.child=y):(s=d.last,s!==null?s.sibling=y:r.child=y,d.last=y)}return d.tail!==null?(s=d.tail,d.rendering=s,d.tail=s.sibling,d.renderingStartTime=je(),s.sibling=null,l=Kt.current,W(Kt,p?l&1|2:l&1),ot&&ua(r,d.treeForkCount),s):(Rt(r),null);case 22:case 23:return ts(r),gh(),d=r.memoizedState!==null,s!==null?s.memoizedState!==null!==d&&(r.flags|=8192):d&&(r.flags|=8192),d?(l&536870912)!==0&&(r.flags&128)===0&&(Rt(r),r.subtreeFlags&6&&(r.flags|=8192)):Rt(r),l=r.updateQueue,l!==null&&ru(r,l.retryQueue),l=null,s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(l=s.memoizedState.cachePool.pool),d=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(d=r.memoizedState.cachePool.pool),d!==l&&(r.flags|=2048),s!==null&&Y(Ir),null;case 24:return l=null,s!==null&&(l=s.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),fa(en),Rt(r),null;case 25:return null;case 30:return null}throw Error(a(156,r.tag))}function gR(s,r){switch(th(r),r.tag){case 1:return s=r.flags,s&65536?(r.flags=s&-65537|128,r):null;case 3:return fa(en),be(),s=r.flags,(s&65536)!==0&&(s&128)===0?(r.flags=s&-65537|128,r):null;case 26:case 27:case 5:return ie(r),null;case 31:if(r.memoizedState!==null){if(ts(r),r.alternate===null)throw Error(a(340));Mr()}return s=r.flags,s&65536?(r.flags=s&-65537|128,r):null;case 13:if(ts(r),s=r.memoizedState,s!==null&&s.dehydrated!==null){if(r.alternate===null)throw Error(a(340));Mr()}return s=r.flags,s&65536?(r.flags=s&-65537|128,r):null;case 19:return Y(Kt),null;case 4:return be(),null;case 10:return fa(r.type),null;case 22:case 23:return ts(r),gh(),s!==null&&Y(Ir),s=r.flags,s&65536?(r.flags=s&-65537|128,r):null;case 24:return fa(en),null;case 25:return null;default:return null}}function xx(s,r){switch(th(r),r.tag){case 3:fa(en),be();break;case 26:case 27:case 5:ie(r);break;case 4:be();break;case 31:r.memoizedState!==null&&ts(r);break;case 13:ts(r);break;case 19:Y(Kt);break;case 10:fa(r.type);break;case 22:case 23:ts(r),gh(),s!==null&&Y(Ir);break;case 24:fa(en)}}function ul(s,r){try{var l=r.updateQueue,d=l!==null?l.lastEffect:null;if(d!==null){var p=d.next;l=p;do{if((l.tag&s)===s){d=void 0;var y=l.create,E=l.inst;d=y(),E.destroy=d}l=l.next}while(l!==p)}}catch(M){vt(r,r.return,M)}}function Va(s,r,l){try{var d=r.updateQueue,p=d!==null?d.lastEffect:null;if(p!==null){var y=p.next;d=y;do{if((d.tag&s)===s){var E=d.inst,M=E.destroy;if(M!==void 0){E.destroy=void 0,p=r;var H=l,ne=M;try{ne()}catch(oe){vt(p,H,oe)}}}d=d.next}while(d!==y)}}catch(oe){vt(r,r.return,oe)}}function bx(s){var r=s.updateQueue;if(r!==null){var l=s.stateNode;try{u0(r,l)}catch(d){vt(s,s.return,d)}}}function wx(s,r,l){l.props=Pr(s.type,s.memoizedProps),l.state=s.memoizedState;try{l.componentWillUnmount()}catch(d){vt(s,r,d)}}function dl(s,r){try{var l=s.ref;if(l!==null){switch(s.tag){case 26:case 27:case 5:var d=s.stateNode;break;case 30:d=s.stateNode;break;default:d=s.stateNode}typeof l=="function"?s.refCleanup=l(d):l.current=d}}catch(p){vt(s,r,p)}}function Hs(s,r){var l=s.ref,d=s.refCleanup;if(l!==null)if(typeof d=="function")try{d()}catch(p){vt(s,r,p)}finally{s.refCleanup=null,s=s.alternate,s!=null&&(s.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(p){vt(s,r,p)}else l.current=null}function Sx(s){var r=s.type,l=s.memoizedProps,d=s.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":l.autoFocus&&d.focus();break e;case"img":l.src?d.src=l.src:l.srcSet&&(d.srcset=l.srcSet)}}catch(p){vt(s,s.return,p)}}function Gh(s,r,l){try{var d=s.stateNode;$R(d,s.type,l,r),d[Un]=r}catch(p){vt(s,s.return,p)}}function jx(s){return s.tag===5||s.tag===3||s.tag===26||s.tag===27&&Wa(s.type)||s.tag===4}function Wh(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||jx(s.return))return null;s=s.return}for(s.sibling.return=s.return,s=s.sibling;s.tag!==5&&s.tag!==6&&s.tag!==18;){if(s.tag===27&&Wa(s.type)||s.flags&2||s.child===null||s.tag===4)continue e;s.child.return=s,s=s.child}if(!(s.flags&2))return s.stateNode}}function Xh(s,r,l){var d=s.tag;if(d===5||d===6)s=s.stateNode,r?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(s,r):(r=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,r.appendChild(s),l=l._reactRootContainer,l!=null||r.onclick!==null||(r.onclick=oa));else if(d!==4&&(d===27&&Wa(s.type)&&(l=s.stateNode,r=null),s=s.child,s!==null))for(Xh(s,r,l),s=s.sibling;s!==null;)Xh(s,r,l),s=s.sibling}function iu(s,r,l){var d=s.tag;if(d===5||d===6)s=s.stateNode,r?l.insertBefore(s,r):l.appendChild(s);else if(d!==4&&(d===27&&Wa(s.type)&&(l=s.stateNode),s=s.child,s!==null))for(iu(s,r,l),s=s.sibling;s!==null;)iu(s,r,l),s=s.sibling}function Nx(s){var r=s.stateNode,l=s.memoizedProps;try{for(var d=s.type,p=r.attributes;p.length;)r.removeAttributeNode(p[0]);Nn(r,d,l),r[bn]=s,r[Un]=l}catch(y){vt(s,s.return,y)}}var va=!1,sn=!1,Kh=!1,kx=typeof WeakSet=="function"?WeakSet:Set,gn=null;function vR(s,r){if(s=s.containerInfo,ym=Cu,s=Ly(s),Zf(s)){if("selectionStart"in s)var l={start:s.selectionStart,end:s.selectionEnd};else e:{l=(l=s.ownerDocument)&&l.defaultView||window;var d=l.getSelection&&l.getSelection();if(d&&d.rangeCount!==0){l=d.anchorNode;var p=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{l.nodeType,y.nodeType}catch{l=null;break e}var E=0,M=-1,H=-1,ne=0,oe=0,fe=s,se=null;t:for(;;){for(var re;fe!==l||p!==0&&fe.nodeType!==3||(M=E+p),fe!==y||d!==0&&fe.nodeType!==3||(H=E+d),fe.nodeType===3&&(E+=fe.nodeValue.length),(re=fe.firstChild)!==null;)se=fe,fe=re;for(;;){if(fe===s)break t;if(se===l&&++ne===p&&(M=E),se===y&&++oe===d&&(H=E),(re=fe.nextSibling)!==null)break;fe=se,se=fe.parentNode}fe=re}l=M===-1||H===-1?null:{start:M,end:H}}else l=null}l=l||{start:0,end:0}}else l=null;for(xm={focusedElem:s,selectionRange:l},Cu=!1,gn=r;gn!==null;)if(r=gn,s=r.child,(r.subtreeFlags&1028)!==0&&s!==null)s.return=r,gn=s;else for(;gn!==null;){switch(r=gn,y=r.alternate,s=r.flags,r.tag){case 0:if((s&4)!==0&&(s=r.updateQueue,s=s!==null?s.events:null,s!==null))for(l=0;l<s.length;l++)p=s[l],p.ref.impl=p.nextImpl;break;case 11:case 15:break;case 1:if((s&1024)!==0&&y!==null){s=void 0,l=r,p=y.memoizedProps,y=y.memoizedState,d=l.stateNode;try{var Ce=Pr(l.type,p);s=d.getSnapshotBeforeUpdate(Ce,y),d.__reactInternalSnapshotBeforeUpdate=s}catch(Le){vt(l,l.return,Le)}}break;case 3:if((s&1024)!==0){if(s=r.stateNode.containerInfo,l=s.nodeType,l===9)Sm(s);else if(l===1)switch(s.nodeName){case"HEAD":case"HTML":case"BODY":Sm(s);break;default:s.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((s&1024)!==0)throw Error(a(163))}if(s=r.sibling,s!==null){s.return=r.return,gn=s;break}gn=r.return}}function Ex(s,r,l){var d=l.flags;switch(l.tag){case 0:case 11:case 15:xa(s,l),d&4&&ul(5,l);break;case 1:if(xa(s,l),d&4)if(s=l.stateNode,r===null)try{s.componentDidMount()}catch(E){vt(l,l.return,E)}else{var p=Pr(l.type,r.memoizedProps);r=r.memoizedState;try{s.componentDidUpdate(p,r,s.__reactInternalSnapshotBeforeUpdate)}catch(E){vt(l,l.return,E)}}d&64&&bx(l),d&512&&dl(l,l.return);break;case 3:if(xa(s,l),d&64&&(s=l.updateQueue,s!==null)){if(r=null,l.child!==null)switch(l.child.tag){case 27:case 5:r=l.child.stateNode;break;case 1:r=l.child.stateNode}try{u0(s,r)}catch(E){vt(l,l.return,E)}}break;case 27:r===null&&d&4&&Nx(l);case 26:case 5:xa(s,l),r===null&&d&4&&Sx(l),d&512&&dl(l,l.return);break;case 12:xa(s,l);break;case 31:xa(s,l),d&4&&Ax(s,l);break;case 13:xa(s,l),d&4&&Rx(s,l),d&64&&(s=l.memoizedState,s!==null&&(s=s.dehydrated,s!==null&&(l=ER.bind(null,l),qR(s,l))));break;case 22:if(d=l.memoizedState!==null||va,!d){r=r!==null&&r.memoizedState!==null||sn,p=va;var y=sn;va=d,(sn=r)&&!y?ba(s,l,(l.subtreeFlags&8772)!==0):xa(s,l),va=p,sn=y}break;case 30:break;default:xa(s,l)}}function Cx(s){var r=s.alternate;r!==null&&(s.alternate=null,Cx(r)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(r=s.stateNode,r!==null&&Cf(r)),s.stateNode=null,s.return=null,s.dependencies=null,s.memoizedProps=null,s.memoizedState=null,s.pendingProps=null,s.stateNode=null,s.updateQueue=null}var Pt=null,Vn=!1;function ya(s,r,l){for(l=l.child;l!==null;)Tx(s,r,l),l=l.sibling}function Tx(s,r,l){if(Ie&&typeof Ie.onCommitFiberUnmount=="function")try{Ie.onCommitFiberUnmount(on,l)}catch{}switch(l.tag){case 26:sn||Hs(l,r),ya(s,r,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&(l=l.stateNode,l.parentNode.removeChild(l));break;case 27:sn||Hs(l,r);var d=Pt,p=Vn;Wa(l.type)&&(Pt=l.stateNode,Vn=!1),ya(s,r,l),bl(l.stateNode),Pt=d,Vn=p;break;case 5:sn||Hs(l,r);case 6:if(d=Pt,p=Vn,Pt=null,ya(s,r,l),Pt=d,Vn=p,Pt!==null)if(Vn)try{(Pt.nodeType===9?Pt.body:Pt.nodeName==="HTML"?Pt.ownerDocument.body:Pt).removeChild(l.stateNode)}catch(y){vt(l,r,y)}else try{Pt.removeChild(l.stateNode)}catch(y){vt(l,r,y)}break;case 18:Pt!==null&&(Vn?(s=Pt,bb(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,l.stateNode),Gi(s)):bb(Pt,l.stateNode));break;case 4:d=Pt,p=Vn,Pt=l.stateNode.containerInfo,Vn=!0,ya(s,r,l),Pt=d,Vn=p;break;case 0:case 11:case 14:case 15:Va(2,l,r),sn||Va(4,l,r),ya(s,r,l);break;case 1:sn||(Hs(l,r),d=l.stateNode,typeof d.componentWillUnmount=="function"&&wx(l,r,d)),ya(s,r,l);break;case 21:ya(s,r,l);break;case 22:sn=(d=sn)||l.memoizedState!==null,ya(s,r,l),sn=d;break;default:ya(s,r,l)}}function Ax(s,r){if(r.memoizedState===null&&(s=r.alternate,s!==null&&(s=s.memoizedState,s!==null))){s=s.dehydrated;try{Gi(s)}catch(l){vt(r,r.return,l)}}}function Rx(s,r){if(r.memoizedState===null&&(s=r.alternate,s!==null&&(s=s.memoizedState,s!==null&&(s=s.dehydrated,s!==null))))try{Gi(s)}catch(l){vt(r,r.return,l)}}function yR(s){switch(s.tag){case 31:case 13:case 19:var r=s.stateNode;return r===null&&(r=s.stateNode=new kx),r;case 22:return s=s.stateNode,r=s._retryCache,r===null&&(r=s._retryCache=new kx),r;default:throw Error(a(435,s.tag))}}function ou(s,r){var l=yR(s);r.forEach(function(d){if(!l.has(d)){l.add(d);var p=CR.bind(null,s,d);d.then(p,p)}})}function Hn(s,r){var l=r.deletions;if(l!==null)for(var d=0;d<l.length;d++){var p=l[d],y=s,E=r,M=E;e:for(;M!==null;){switch(M.tag){case 27:if(Wa(M.type)){Pt=M.stateNode,Vn=!1;break e}break;case 5:Pt=M.stateNode,Vn=!1;break e;case 3:case 4:Pt=M.stateNode.containerInfo,Vn=!0;break e}M=M.return}if(Pt===null)throw Error(a(160));Tx(y,E,p),Pt=null,Vn=!1,y=p.alternate,y!==null&&(y.return=null),p.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)Mx(r,s),r=r.sibling}var Ms=null;function Mx(s,r){var l=s.alternate,d=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:Hn(r,s),Zn(s),d&4&&(Va(3,s,s.return),ul(3,s),Va(5,s,s.return));break;case 1:Hn(r,s),Zn(s),d&512&&(sn||l===null||Hs(l,l.return)),d&64&&va&&(s=s.updateQueue,s!==null&&(d=s.callbacks,d!==null&&(l=s.shared.hiddenCallbacks,s.shared.hiddenCallbacks=l===null?d:l.concat(d))));break;case 26:var p=Ms;if(Hn(r,s),Zn(s),d&512&&(sn||l===null||Hs(l,l.return)),d&4){var y=l!==null?l.memoizedState:null;if(d=s.memoizedState,l===null)if(d===null)if(s.stateNode===null){e:{d=s.type,l=s.memoizedProps,p=p.ownerDocument||p;t:switch(d){case"title":y=p.getElementsByTagName("title")[0],(!y||y[$o]||y[bn]||y.namespaceURI==="http://www.w3.org/2000/svg"||y.hasAttribute("itemprop"))&&(y=p.createElement(d),p.head.insertBefore(y,p.querySelector("head > title"))),Nn(y,d,l),y[bn]=s,pn(y),d=y;break e;case"link":var E=Mb("link","href",p).get(d+(l.href||""));if(E){for(var M=0;M<E.length;M++)if(y=E[M],y.getAttribute("href")===(l.href==null||l.href===""?null:l.href)&&y.getAttribute("rel")===(l.rel==null?null:l.rel)&&y.getAttribute("title")===(l.title==null?null:l.title)&&y.getAttribute("crossorigin")===(l.crossOrigin==null?null:l.crossOrigin)){E.splice(M,1);break t}}y=p.createElement(d),Nn(y,d,l),p.head.appendChild(y);break;case"meta":if(E=Mb("meta","content",p).get(d+(l.content||""))){for(M=0;M<E.length;M++)if(y=E[M],y.getAttribute("content")===(l.content==null?null:""+l.content)&&y.getAttribute("name")===(l.name==null?null:l.name)&&y.getAttribute("property")===(l.property==null?null:l.property)&&y.getAttribute("http-equiv")===(l.httpEquiv==null?null:l.httpEquiv)&&y.getAttribute("charset")===(l.charSet==null?null:l.charSet)){E.splice(M,1);break t}}y=p.createElement(d),Nn(y,d,l),p.head.appendChild(y);break;default:throw Error(a(468,d))}y[bn]=s,pn(y),d=y}s.stateNode=d}else _b(p,s.type,s.stateNode);else s.stateNode=Rb(p,d,s.memoizedProps);else y!==d?(y===null?l.stateNode!==null&&(l=l.stateNode,l.parentNode.removeChild(l)):y.count--,d===null?_b(p,s.type,s.stateNode):Rb(p,d,s.memoizedProps)):d===null&&s.stateNode!==null&&Gh(s,s.memoizedProps,l.memoizedProps)}break;case 27:Hn(r,s),Zn(s),d&512&&(sn||l===null||Hs(l,l.return)),l!==null&&d&4&&Gh(s,s.memoizedProps,l.memoizedProps);break;case 5:if(Hn(r,s),Zn(s),d&512&&(sn||l===null||Hs(l,l.return)),s.flags&32){p=s.stateNode;try{vi(p,"")}catch(Ce){vt(s,s.return,Ce)}}d&4&&s.stateNode!=null&&(p=s.memoizedProps,Gh(s,p,l!==null?l.memoizedProps:p)),d&1024&&(Kh=!0);break;case 6:if(Hn(r,s),Zn(s),d&4){if(s.stateNode===null)throw Error(a(162));d=s.memoizedProps,l=s.stateNode;try{l.nodeValue=d}catch(Ce){vt(s,s.return,Ce)}}break;case 3:if(ju=null,p=Ms,Ms=wu(r.containerInfo),Hn(r,s),Ms=p,Zn(s),d&4&&l!==null&&l.memoizedState.isDehydrated)try{Gi(r.containerInfo)}catch(Ce){vt(s,s.return,Ce)}Kh&&(Kh=!1,_x(s));break;case 4:d=Ms,Ms=wu(s.stateNode.containerInfo),Hn(r,s),Zn(s),Ms=d;break;case 12:Hn(r,s),Zn(s);break;case 31:Hn(r,s),Zn(s),d&4&&(d=s.updateQueue,d!==null&&(s.updateQueue=null,ou(s,d)));break;case 13:Hn(r,s),Zn(s),s.child.flags&8192&&s.memoizedState!==null!=(l!==null&&l.memoizedState!==null)&&(cu=je()),d&4&&(d=s.updateQueue,d!==null&&(s.updateQueue=null,ou(s,d)));break;case 22:p=s.memoizedState!==null;var H=l!==null&&l.memoizedState!==null,ne=va,oe=sn;if(va=ne||p,sn=oe||H,Hn(r,s),sn=oe,va=ne,Zn(s),d&8192)e:for(r=s.stateNode,r._visibility=p?r._visibility&-2:r._visibility|1,p&&(l===null||H||va||sn||Ur(s)),l=null,r=s;;){if(r.tag===5||r.tag===26){if(l===null){H=l=r;try{if(y=H.stateNode,p)E=y.style,typeof E.setProperty=="function"?E.setProperty("display","none","important"):E.display="none";else{M=H.stateNode;var fe=H.memoizedProps.style,se=fe!=null&&fe.hasOwnProperty("display")?fe.display:null;M.style.display=se==null||typeof se=="boolean"?"":(""+se).trim()}}catch(Ce){vt(H,H.return,Ce)}}}else if(r.tag===6){if(l===null){H=r;try{H.stateNode.nodeValue=p?"":H.memoizedProps}catch(Ce){vt(H,H.return,Ce)}}}else if(r.tag===18){if(l===null){H=r;try{var re=H.stateNode;p?wb(re,!0):wb(H.stateNode,!1)}catch(Ce){vt(H,H.return,Ce)}}}else if((r.tag!==22&&r.tag!==23||r.memoizedState===null||r===s)&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===s)break e;for(;r.sibling===null;){if(r.return===null||r.return===s)break e;l===r&&(l=null),r=r.return}l===r&&(l=null),r.sibling.return=r.return,r=r.sibling}d&4&&(d=s.updateQueue,d!==null&&(l=d.retryQueue,l!==null&&(d.retryQueue=null,ou(s,l))));break;case 19:Hn(r,s),Zn(s),d&4&&(d=s.updateQueue,d!==null&&(s.updateQueue=null,ou(s,d)));break;case 30:break;case 21:break;default:Hn(r,s),Zn(s)}}function Zn(s){var r=s.flags;if(r&2){try{for(var l,d=s.return;d!==null;){if(jx(d)){l=d;break}d=d.return}if(l==null)throw Error(a(160));switch(l.tag){case 27:var p=l.stateNode,y=Wh(s);iu(s,y,p);break;case 5:var E=l.stateNode;l.flags&32&&(vi(E,""),l.flags&=-33);var M=Wh(s);iu(s,M,E);break;case 3:case 4:var H=l.stateNode.containerInfo,ne=Wh(s);Xh(s,ne,H);break;default:throw Error(a(161))}}catch(oe){vt(s,s.return,oe)}s.flags&=-3}r&4096&&(s.flags&=-4097)}function _x(s){if(s.subtreeFlags&1024)for(s=s.child;s!==null;){var r=s;_x(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),s=s.sibling}}function xa(s,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)Ex(s,r.alternate,r),r=r.sibling}function Ur(s){for(s=s.child;s!==null;){var r=s;switch(r.tag){case 0:case 11:case 14:case 15:Va(4,r,r.return),Ur(r);break;case 1:Hs(r,r.return);var l=r.stateNode;typeof l.componentWillUnmount=="function"&&wx(r,r.return,l),Ur(r);break;case 27:bl(r.stateNode);case 26:case 5:Hs(r,r.return),Ur(r);break;case 22:r.memoizedState===null&&Ur(r);break;case 30:Ur(r);break;default:Ur(r)}s=s.sibling}}function ba(s,r,l){for(l=l&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var d=r.alternate,p=s,y=r,E=y.flags;switch(y.tag){case 0:case 11:case 15:ba(p,y,l),ul(4,y);break;case 1:if(ba(p,y,l),d=y,p=d.stateNode,typeof p.componentDidMount=="function")try{p.componentDidMount()}catch(ne){vt(d,d.return,ne)}if(d=y,p=d.updateQueue,p!==null){var M=d.stateNode;try{var H=p.shared.hiddenCallbacks;if(H!==null)for(p.shared.hiddenCallbacks=null,p=0;p<H.length;p++)c0(H[p],M)}catch(ne){vt(d,d.return,ne)}}l&&E&64&&bx(y),dl(y,y.return);break;case 27:Nx(y);case 26:case 5:ba(p,y,l),l&&d===null&&E&4&&Sx(y),dl(y,y.return);break;case 12:ba(p,y,l);break;case 31:ba(p,y,l),l&&E&4&&Ax(p,y);break;case 13:ba(p,y,l),l&&E&4&&Rx(p,y);break;case 22:y.memoizedState===null&&ba(p,y,l),dl(y,y.return);break;case 30:break;default:ba(p,y,l)}r=r.sibling}}function Jh(s,r){var l=null;s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(l=s.memoizedState.cachePool.pool),s=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(s=r.memoizedState.cachePool.pool),s!==l&&(s!=null&&s.refCount++,l!=null&&Ko(l))}function Qh(s,r){s=null,r.alternate!==null&&(s=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==s&&(r.refCount++,s!=null&&Ko(s))}function _s(s,r,l,d){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)Ox(s,r,l,d),r=r.sibling}function Ox(s,r,l,d){var p=r.flags;switch(r.tag){case 0:case 11:case 15:_s(s,r,l,d),p&2048&&ul(9,r);break;case 1:_s(s,r,l,d);break;case 3:_s(s,r,l,d),p&2048&&(s=null,r.alternate!==null&&(s=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==s&&(r.refCount++,s!=null&&Ko(s)));break;case 12:if(p&2048){_s(s,r,l,d),s=r.stateNode;try{var y=r.memoizedProps,E=y.id,M=y.onPostCommit;typeof M=="function"&&M(E,r.alternate===null?"mount":"update",s.passiveEffectDuration,-0)}catch(H){vt(r,r.return,H)}}else _s(s,r,l,d);break;case 31:_s(s,r,l,d);break;case 13:_s(s,r,l,d);break;case 23:break;case 22:y=r.stateNode,E=r.alternate,r.memoizedState!==null?y._visibility&2?_s(s,r,l,d):fl(s,r):y._visibility&2?_s(s,r,l,d):(y._visibility|=2,Li(s,r,l,d,(r.subtreeFlags&10256)!==0||!1)),p&2048&&Jh(E,r);break;case 24:_s(s,r,l,d),p&2048&&Qh(r.alternate,r);break;default:_s(s,r,l,d)}}function Li(s,r,l,d,p){for(p=p&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var y=s,E=r,M=l,H=d,ne=E.flags;switch(E.tag){case 0:case 11:case 15:Li(y,E,M,H,p),ul(8,E);break;case 23:break;case 22:var oe=E.stateNode;E.memoizedState!==null?oe._visibility&2?Li(y,E,M,H,p):fl(y,E):(oe._visibility|=2,Li(y,E,M,H,p)),p&&ne&2048&&Jh(E.alternate,E);break;case 24:Li(y,E,M,H,p),p&&ne&2048&&Qh(E.alternate,E);break;default:Li(y,E,M,H,p)}r=r.sibling}}function fl(s,r){if(r.subtreeFlags&10256)for(r=r.child;r!==null;){var l=s,d=r,p=d.flags;switch(d.tag){case 22:fl(l,d),p&2048&&Jh(d.alternate,d);break;case 24:fl(l,d),p&2048&&Qh(d.alternate,d);break;default:fl(l,d)}r=r.sibling}}var hl=8192;function $i(s,r,l){if(s.subtreeFlags&hl)for(s=s.child;s!==null;)Ix(s,r,l),s=s.sibling}function Ix(s,r,l){switch(s.tag){case 26:$i(s,r,l),s.flags&hl&&s.memoizedState!==null&&aM(l,Ms,s.memoizedState,s.memoizedProps);break;case 5:$i(s,r,l);break;case 3:case 4:var d=Ms;Ms=wu(s.stateNode.containerInfo),$i(s,r,l),Ms=d;break;case 22:s.memoizedState===null&&(d=s.alternate,d!==null&&d.memoizedState!==null?(d=hl,hl=16777216,$i(s,r,l),hl=d):$i(s,r,l));break;default:$i(s,r,l)}}function Dx(s){var r=s.alternate;if(r!==null&&(s=r.child,s!==null)){r.child=null;do r=s.sibling,s.sibling=null,s=r;while(s!==null)}}function ml(s){var r=s.deletions;if((s.flags&16)!==0){if(r!==null)for(var l=0;l<r.length;l++){var d=r[l];gn=d,Lx(d,s)}Dx(s)}if(s.subtreeFlags&10256)for(s=s.child;s!==null;)zx(s),s=s.sibling}function zx(s){switch(s.tag){case 0:case 11:case 15:ml(s),s.flags&2048&&Va(9,s,s.return);break;case 3:ml(s);break;case 12:ml(s);break;case 22:var r=s.stateNode;s.memoizedState!==null&&r._visibility&2&&(s.return===null||s.return.tag!==13)?(r._visibility&=-3,lu(s)):ml(s);break;default:ml(s)}}function lu(s){var r=s.deletions;if((s.flags&16)!==0){if(r!==null)for(var l=0;l<r.length;l++){var d=r[l];gn=d,Lx(d,s)}Dx(s)}for(s=s.child;s!==null;){switch(r=s,r.tag){case 0:case 11:case 15:Va(8,r,r.return),lu(r);break;case 22:l=r.stateNode,l._visibility&2&&(l._visibility&=-3,lu(r));break;default:lu(r)}s=s.sibling}}function Lx(s,r){for(;gn!==null;){var l=gn;switch(l.tag){case 0:case 11:case 15:Va(8,l,r);break;case 23:case 22:if(l.memoizedState!==null&&l.memoizedState.cachePool!==null){var d=l.memoizedState.cachePool.pool;d!=null&&d.refCount++}break;case 24:Ko(l.memoizedState.cache)}if(d=l.child,d!==null)d.return=l,gn=d;else e:for(l=s;gn!==null;){d=gn;var p=d.sibling,y=d.return;if(Cx(d),d===l){gn=null;break e}if(p!==null){p.return=y,gn=p;break e}gn=y}}}var xR={getCacheForType:function(s){var r=Sn(en),l=r.data.get(s);return l===void 0&&(l=s(),r.data.set(s,l)),l},cacheSignal:function(){return Sn(en).controller.signal}},bR=typeof WeakMap=="function"?WeakMap:Map,pt=0,jt=null,nt=null,rt=0,gt=0,ns=null,Ha=!1,Pi=!1,em=!1,wa=0,Gt=0,Za=0,Br=0,tm=0,ss=0,Ui=0,pl=null,Fn=null,nm=!1,cu=0,$x=0,uu=1/0,du=null,Fa=null,un=0,qa=null,Bi=null,Sa=0,sm=0,am=null,Px=null,gl=0,rm=null;function as(){return(pt&2)!==0&&rt!==0?rt&-rt:D.T!==null?dm():cn()}function Ux(){if(ss===0)if((rt&536870912)===0||ot){var s=mn;mn<<=1,(mn&3932160)===0&&(mn=262144),ss=s}else ss=536870912;return s=es.current,s!==null&&(s.flags|=32),ss}function qn(s,r,l){(s===jt&&(gt===2||gt===9)||s.cancelPendingCommit!==null)&&(Vi(s,0),Ya(s,rt,ss,!1)),ze(s,l),((pt&2)===0||s!==jt)&&(s===jt&&((pt&2)===0&&(Br|=l),Gt===4&&Ya(s,rt,ss,!1)),Zs(s))}function Bx(s,r,l){if((pt&6)!==0)throw Error(a(327));var d=!l&&(r&127)===0&&(r&s.expiredLanes)===0||Q(s,r),p=d?jR(s,r):om(s,r,!0),y=d;do{if(p===0){Pi&&!d&&Ya(s,r,0,!1);break}else{if(l=s.current.alternate,y&&!wR(l)){p=om(s,r,!1),y=!1;continue}if(p===2){if(y=r,s.errorRecoveryDisabledLanes&y)var E=0;else E=s.pendingLanes&-536870913,E=E!==0?E:E&536870912?536870912:0;if(E!==0){r=E;e:{var M=s;p=pl;var H=M.current.memoizedState.isDehydrated;if(H&&(Vi(M,E).flags|=256),E=om(M,E,!1),E!==2){if(em&&!H){M.errorRecoveryDisabledLanes|=y,Br|=y,p=4;break e}y=Fn,Fn=p,y!==null&&(Fn===null?Fn=y:Fn.push.apply(Fn,y))}p=E}if(y=!1,p!==2)continue}}if(p===1){Vi(s,0),Ya(s,r,0,!0);break}e:{switch(d=s,y=p,y){case 0:case 1:throw Error(a(345));case 4:if((r&4194048)!==r)break;case 6:Ya(d,r,ss,!Ha);break e;case 2:Fn=null;break;case 3:case 5:break;default:throw Error(a(329))}if((r&62914560)===r&&(p=cu+300-je(),10<p)){if(Ya(d,r,ss,!Ha),Ts(d,0,!0)!==0)break e;Sa=r,d.timeoutHandle=yb(Vx.bind(null,d,l,Fn,du,nm,r,ss,Br,Ui,Ha,y,"Throttled",-0,0),p);break e}Vx(d,l,Fn,du,nm,r,ss,Br,Ui,Ha,y,null,-0,0)}}break}while(!0);Zs(s)}function Vx(s,r,l,d,p,y,E,M,H,ne,oe,fe,se,re){if(s.timeoutHandle=-1,fe=r.subtreeFlags,fe&8192||(fe&16785408)===16785408){fe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:oa},Ix(r,y,fe);var Ce=(y&62914560)===y?cu-je():(y&4194048)===y?$x-je():0;if(Ce=rM(fe,Ce),Ce!==null){Sa=y,s.cancelPendingCommit=Ce(Xx.bind(null,s,r,y,l,d,p,E,M,H,oe,fe,null,se,re)),Ya(s,y,E,!ne);return}}Xx(s,r,y,l,d,p,E,M,H)}function wR(s){for(var r=s;;){var l=r.tag;if((l===0||l===11||l===15)&&r.flags&16384&&(l=r.updateQueue,l!==null&&(l=l.stores,l!==null)))for(var d=0;d<l.length;d++){var p=l[d],y=p.getSnapshot;p=p.value;try{if(!Jn(y(),p))return!1}catch{return!1}}if(l=r.child,r.subtreeFlags&16384&&l!==null)l.return=r,r=l;else{if(r===s)break;for(;r.sibling===null;){if(r.return===null||r.return===s)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function Ya(s,r,l,d){r&=~tm,r&=~Br,s.suspendedLanes|=r,s.pingedLanes&=~r,d&&(s.warmLanes|=r),d=s.expirationTimes;for(var p=r;0<p;){var y=31-ut(p),E=1<<y;d[y]=-1,p&=~E}l!==0&&$t(s,l,r)}function fu(){return(pt&6)===0?(vl(0),!1):!0}function im(){if(nt!==null){if(gt===0)var s=nt.return;else s=nt,da=_r=null,Sh(s),_i=null,Qo=0,s=nt;for(;s!==null;)xx(s.alternate,s),s=s.return;nt=null}}function Vi(s,r){var l=s.timeoutHandle;l!==-1&&(s.timeoutHandle=-1,BR(l)),l=s.cancelPendingCommit,l!==null&&(s.cancelPendingCommit=null,l()),Sa=0,im(),jt=s,nt=l=ca(s.current,null),rt=r,gt=0,ns=null,Ha=!1,Pi=Q(s,r),em=!1,Ui=ss=tm=Br=Za=Gt=0,Fn=pl=null,nm=!1,(r&8)!==0&&(r|=r&32);var d=s.entangledLanes;if(d!==0)for(s=s.entanglements,d&=r;0<d;){var p=31-ut(d),y=1<<p;r|=s[p],d&=~y}return wa=r,Oc(),l}function Hx(s,r){Xe=null,D.H=ol,r===Mi||r===Bc?(r=r0(),gt=3):r===uh?(r=r0(),gt=4):gt=r===$h?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,ns=r,nt===null&&(Gt=1,tu(s,hs(r,s.current)))}function Zx(){var s=es.current;return s===null?!0:(rt&4194048)===rt?vs===null:(rt&62914560)===rt||(rt&536870912)!==0?s===vs:!1}function Fx(){var s=D.H;return D.H=ol,s===null?ol:s}function qx(){var s=D.A;return D.A=xR,s}function hu(){Gt=4,Ha||(rt&4194048)!==rt&&es.current!==null||(Pi=!0),(Za&134217727)===0&&(Br&134217727)===0||jt===null||Ya(jt,rt,ss,!1)}function om(s,r,l){var d=pt;pt|=2;var p=Fx(),y=qx();(jt!==s||rt!==r)&&(du=null,Vi(s,r)),r=!1;var E=Gt;e:do try{if(gt!==0&&nt!==null){var M=nt,H=ns;switch(gt){case 8:im(),E=6;break e;case 3:case 2:case 9:case 6:es.current===null&&(r=!0);var ne=gt;if(gt=0,ns=null,Hi(s,M,H,ne),l&&Pi){E=0;break e}break;default:ne=gt,gt=0,ns=null,Hi(s,M,H,ne)}}SR(),E=Gt;break}catch(oe){Hx(s,oe)}while(!0);return r&&s.shellSuspendCounter++,da=_r=null,pt=d,D.H=p,D.A=y,nt===null&&(jt=null,rt=0,Oc()),E}function SR(){for(;nt!==null;)Yx(nt)}function jR(s,r){var l=pt;pt|=2;var d=Fx(),p=qx();jt!==s||rt!==r?(du=null,uu=je()+500,Vi(s,r)):Pi=Q(s,r);e:do try{if(gt!==0&&nt!==null){r=nt;var y=ns;t:switch(gt){case 1:gt=0,ns=null,Hi(s,r,y,1);break;case 2:case 9:if(s0(y)){gt=0,ns=null,Gx(r);break}r=function(){gt!==2&>!==9||jt!==s||(gt=7),Zs(s)},y.then(r,r);break e;case 3:gt=7;break e;case 4:gt=5;break e;case 7:s0(y)?(gt=0,ns=null,Gx(r)):(gt=0,ns=null,Hi(s,r,y,7));break;case 5:var E=null;switch(nt.tag){case 26:E=nt.memoizedState;case 5:case 27:var M=nt;if(E?Ob(E):M.stateNode.complete){gt=0,ns=null;var H=M.sibling;if(H!==null)nt=H;else{var ne=M.return;ne!==null?(nt=ne,mu(ne)):nt=null}break t}}gt=0,ns=null,Hi(s,r,y,5);break;case 6:gt=0,ns=null,Hi(s,r,y,6);break;case 8:im(),Gt=6;break e;default:throw Error(a(462))}}NR();break}catch(oe){Hx(s,oe)}while(!0);return da=_r=null,D.H=d,D.A=p,pt=l,nt!==null?0:(jt=null,rt=0,Oc(),Gt)}function NR(){for(;nt!==null&&!he();)Yx(nt)}function Yx(s){var r=vx(s.alternate,s,wa);s.memoizedProps=s.pendingProps,r===null?mu(s):nt=r}function Gx(s){var r=s,l=r.alternate;switch(r.tag){case 15:case 0:r=dx(l,r,r.pendingProps,r.type,void 0,rt);break;case 11:r=dx(l,r,r.pendingProps,r.type.render,r.ref,rt);break;case 5:Sh(r);default:xx(l,r),r=nt=qy(r,wa),r=vx(l,r,wa)}s.memoizedProps=s.pendingProps,r===null?mu(s):nt=r}function Hi(s,r,l,d){da=_r=null,Sh(r),_i=null,Qo=0;var p=r.return;try{if(fR(s,p,r,l,rt)){Gt=1,tu(s,hs(l,s.current)),nt=null;return}}catch(y){if(p!==null)throw nt=p,y;Gt=1,tu(s,hs(l,s.current)),nt=null;return}r.flags&32768?(ot||d===1?s=!0:Pi||(rt&536870912)!==0?s=!1:(Ha=s=!0,(d===2||d===9||d===3||d===6)&&(d=es.current,d!==null&&d.tag===13&&(d.flags|=16384))),Wx(r,s)):mu(r)}function mu(s){var r=s;do{if((r.flags&32768)!==0){Wx(r,Ha);return}s=r.return;var l=pR(r.alternate,r,wa);if(l!==null){nt=l;return}if(r=r.sibling,r!==null){nt=r;return}nt=r=s}while(r!==null);Gt===0&&(Gt=5)}function Wx(s,r){do{var l=gR(s.alternate,s);if(l!==null){l.flags&=32767,nt=l;return}if(l=s.return,l!==null&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!r&&(s=s.sibling,s!==null)){nt=s;return}nt=s=l}while(s!==null);Gt=6,nt=null}function Xx(s,r,l,d,p,y,E,M,H){s.cancelPendingCommit=null;do pu();while(un!==0);if((pt&6)!==0)throw Error(a(327));if(r!==null){if(r===s.current)throw Error(a(177));if(y=r.lanes|r.childLanes,y|=Wf,dt(s,l,y,E,M,H),s===jt&&(nt=jt=null,rt=0),Bi=r,qa=s,Sa=l,sm=y,am=p,Px=d,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(s.callbackNode=null,s.callbackPriority=0,TR(Ge,function(){return tb(),null})):(s.callbackNode=null,s.callbackPriority=0),d=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||d){d=D.T,D.T=null,p=U.p,U.p=2,E=pt,pt|=4;try{vR(s,r,l)}finally{pt=E,U.p=p,D.T=d}}un=1,Kx(),Jx(),Qx()}}function Kx(){if(un===1){un=0;var s=qa,r=Bi,l=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||l){l=D.T,D.T=null;var d=U.p;U.p=2;var p=pt;pt|=4;try{Mx(r,s);var y=xm,E=Ly(s.containerInfo),M=y.focusedElem,H=y.selectionRange;if(E!==M&&M&&M.ownerDocument&&zy(M.ownerDocument.documentElement,M)){if(H!==null&&Zf(M)){var ne=H.start,oe=H.end;if(oe===void 0&&(oe=ne),"selectionStart"in M)M.selectionStart=ne,M.selectionEnd=Math.min(oe,M.value.length);else{var fe=M.ownerDocument||document,se=fe&&fe.defaultView||window;if(se.getSelection){var re=se.getSelection(),Ce=M.textContent.length,Le=Math.min(H.start,Ce),St=H.end===void 0?Le:Math.min(H.end,Ce);!re.extend&&Le>St&&(E=St,St=Le,Le=E);var X=Dy(M,Le),F=Dy(M,St);if(X&&F&&(re.rangeCount!==1||re.anchorNode!==X.node||re.anchorOffset!==X.offset||re.focusNode!==F.node||re.focusOffset!==F.offset)){var te=fe.createRange();te.setStart(X.node,X.offset),re.removeAllRanges(),Le>St?(re.addRange(te),re.extend(F.node,F.offset)):(te.setEnd(F.node,F.offset),re.addRange(te))}}}}for(fe=[],re=M;re=re.parentNode;)re.nodeType===1&&fe.push({element:re,left:re.scrollLeft,top:re.scrollTop});for(typeof M.focus=="function"&&M.focus(),M=0;M<fe.length;M++){var ue=fe[M];ue.element.scrollLeft=ue.left,ue.element.scrollTop=ue.top}}Cu=!!ym,xm=ym=null}finally{pt=p,U.p=d,D.T=l}}s.current=r,un=2}}function Jx(){if(un===2){un=0;var s=qa,r=Bi,l=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||l){l=D.T,D.T=null;var d=U.p;U.p=2;var p=pt;pt|=4;try{Ex(s,r.alternate,r)}finally{pt=p,U.p=d,D.T=l}}un=3}}function Qx(){if(un===4||un===3){un=0,pe();var s=qa,r=Bi,l=Sa,d=Px;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?un=5:(un=0,Bi=qa=null,eb(s,s.pendingLanes));var p=s.pendingLanes;if(p===0&&(Fa=null),As(l),r=r.stateNode,Ie&&typeof Ie.onCommitFiberRoot=="function")try{Ie.onCommitFiberRoot(on,r,void 0,(r.current.flags&128)===128)}catch{}if(d!==null){r=D.T,p=U.p,U.p=2,D.T=null;try{for(var y=s.onRecoverableError,E=0;E<d.length;E++){var M=d[E];y(M.value,{componentStack:M.stack})}}finally{D.T=r,U.p=p}}(Sa&3)!==0&&pu(),Zs(s),p=s.pendingLanes,(l&261930)!==0&&(p&42)!==0?s===rm?gl++:(gl=0,rm=s):gl=0,vl(0)}}function eb(s,r){(s.pooledCacheLanes&=r)===0&&(r=s.pooledCache,r!=null&&(s.pooledCache=null,Ko(r)))}function pu(){return Kx(),Jx(),Qx(),tb()}function tb(){if(un!==5)return!1;var s=qa,r=sm;sm=0;var l=As(Sa),d=D.T,p=U.p;try{U.p=32>l?32:l,D.T=null,l=am,am=null;var y=qa,E=Sa;if(un=0,Bi=qa=null,Sa=0,(pt&6)!==0)throw Error(a(331));var M=pt;if(pt|=4,zx(y.current),Ox(y,y.current,E,l),pt=M,vl(0,!1),Ie&&typeof Ie.onPostCommitFiberRoot=="function")try{Ie.onPostCommitFiberRoot(on,y)}catch{}return!0}finally{U.p=p,D.T=d,eb(s,r)}}function nb(s,r,l){r=hs(l,r),r=Lh(s.stateNode,r,2),s=Pa(s,r,2),s!==null&&(ze(s,2),Zs(s))}function vt(s,r,l){if(s.tag===3)nb(s,s,l);else for(;r!==null;){if(r.tag===3){nb(r,s,l);break}else if(r.tag===1){var d=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(Fa===null||!Fa.has(d))){s=hs(l,s),l=sx(2),d=Pa(r,l,2),d!==null&&(ax(l,d,r,s),ze(d,2),Zs(d));break}}r=r.return}}function lm(s,r,l){var d=s.pingCache;if(d===null){d=s.pingCache=new bR;var p=new Set;d.set(r,p)}else p=d.get(r),p===void 0&&(p=new Set,d.set(r,p));p.has(l)||(em=!0,p.add(l),s=kR.bind(null,s,r,l),r.then(s,s))}function kR(s,r,l){var d=s.pingCache;d!==null&&d.delete(r),s.pingedLanes|=s.suspendedLanes&l,s.warmLanes&=~l,jt===s&&(rt&l)===l&&(Gt===4||Gt===3&&(rt&62914560)===rt&&300>je()-cu?(pt&2)===0&&Vi(s,0):tm|=l,Ui===rt&&(Ui=0)),Zs(s)}function sb(s,r){r===0&&(r=ge()),s=Ar(s,r),s!==null&&(ze(s,r),Zs(s))}function ER(s){var r=s.memoizedState,l=0;r!==null&&(l=r.retryLane),sb(s,l)}function CR(s,r){var l=0;switch(s.tag){case 31:case 13:var d=s.stateNode,p=s.memoizedState;p!==null&&(l=p.retryLane);break;case 19:d=s.stateNode;break;case 22:d=s.stateNode._retryCache;break;default:throw Error(a(314))}d!==null&&d.delete(r),sb(s,l)}function TR(s,r){return He(s,r)}var gu=null,Zi=null,cm=!1,vu=!1,um=!1,Ga=0;function Zs(s){s!==Zi&&s.next===null&&(Zi===null?gu=Zi=s:Zi=Zi.next=s),vu=!0,cm||(cm=!0,RR())}function vl(s,r){if(!um&&vu){um=!0;do for(var l=!1,d=gu;d!==null;){if(s!==0){var p=d.pendingLanes;if(p===0)var y=0;else{var E=d.suspendedLanes,M=d.pingedLanes;y=(1<<31-ut(42|s)+1)-1,y&=p&~(E&~M),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(l=!0,ob(d,y))}else y=rt,y=Ts(d,d===jt?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||Q(d,y)||(l=!0,ob(d,y));d=d.next}while(l);um=!1}}function AR(){ab()}function ab(){vu=cm=!1;var s=0;Ga!==0&&UR()&&(s=Ga);for(var r=je(),l=null,d=gu;d!==null;){var p=d.next,y=rb(d,r);y===0?(d.next=null,l===null?gu=p:l.next=p,p===null&&(Zi=l)):(l=d,(s!==0||(y&3)!==0)&&(vu=!0)),d=p}un!==0&&un!==5||vl(s),Ga!==0&&(Ga=0)}function rb(s,r){for(var l=s.suspendedLanes,d=s.pingedLanes,p=s.expirationTimes,y=s.pendingLanes&-62914561;0<y;){var E=31-ut(y),M=1<<E,H=p[E];H===-1?((M&l)===0||(M&d)!==0)&&(p[E]=me(M,r)):H<=r&&(s.expiredLanes|=M),y&=~M}if(r=jt,l=rt,l=Ts(s,s===r?l:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),d=s.callbackNode,l===0||s===r&&(gt===2||gt===9)||s.cancelPendingCommit!==null)return d!==null&&d!==null&&ce(d),s.callbackNode=null,s.callbackPriority=0;if((l&3)===0||Q(s,l)){if(r=l&-l,r===s.callbackPriority)return r;switch(d!==null&&ce(d),As(l)){case 2:case 8:l=et;break;case 32:l=Ge;break;case 268435456:l=Et;break;default:l=Ge}return d=ib.bind(null,s),l=He(l,d),s.callbackPriority=r,s.callbackNode=l,r}return d!==null&&d!==null&&ce(d),s.callbackPriority=2,s.callbackNode=null,2}function ib(s,r){if(un!==0&&un!==5)return s.callbackNode=null,s.callbackPriority=0,null;var l=s.callbackNode;if(pu()&&s.callbackNode!==l)return null;var d=rt;return d=Ts(s,s===jt?d:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),d===0?null:(Bx(s,d,r),rb(s,je()),s.callbackNode!=null&&s.callbackNode===l?ib.bind(null,s):null)}function ob(s,r){if(pu())return null;Bx(s,r,!0)}function RR(){VR(function(){(pt&6)!==0?He(Je,AR):ab()})}function dm(){if(Ga===0){var s=Ai;s===0&&(s=Xt,Xt<<=1,(Xt&261888)===0&&(Xt=256)),Ga=s}return Ga}function lb(s){return s==null||typeof s=="symbol"||typeof s=="boolean"?null:typeof s=="function"?s:kc(""+s)}function cb(s,r){var l=r.ownerDocument.createElement("input");return l.name=r.name,l.value=r.value,s.id&&l.setAttribute("form",s.id),r.parentNode.insertBefore(l,r),s=new FormData(s),l.parentNode.removeChild(l),s}function MR(s,r,l,d,p){if(r==="submit"&&l&&l.stateNode===p){var y=lb((p[Un]||null).action),E=d.submitter;E&&(r=(r=E[Un]||null)?lb(r.formAction):E.getAttribute("formAction"),r!==null&&(y=r,E=null));var M=new Ac("action","action",null,d,p);s.push({event:M,listeners:[{instance:null,listener:function(){if(d.defaultPrevented){if(Ga!==0){var H=E?cb(p,E):new FormData(p);Mh(l,{pending:!0,data:H,method:p.method,action:y},null,H)}}else typeof y=="function"&&(M.preventDefault(),H=E?cb(p,E):new FormData(p),Mh(l,{pending:!0,data:H,method:p.method,action:y},y,H))},currentTarget:p}]})}}for(var fm=0;fm<Gf.length;fm++){var hm=Gf[fm],_R=hm.toLowerCase(),OR=hm[0].toUpperCase()+hm.slice(1);Rs(_R,"on"+OR)}Rs(Uy,"onAnimationEnd"),Rs(By,"onAnimationIteration"),Rs(Vy,"onAnimationStart"),Rs("dblclick","onDoubleClick"),Rs("focusin","onFocus"),Rs("focusout","onBlur"),Rs(WA,"onTransitionRun"),Rs(XA,"onTransitionStart"),Rs(KA,"onTransitionCancel"),Rs(Hy,"onTransitionEnd"),pi("onMouseEnter",["mouseout","mouseover"]),pi("onMouseLeave",["mouseout","mouseover"]),pi("onPointerEnter",["pointerout","pointerover"]),pi("onPointerLeave",["pointerout","pointerover"]),kr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),kr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),kr("onBeforeInput",["compositionend","keypress","textInput","paste"]),kr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),kr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),kr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var yl="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(" "),IR=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(yl));function ub(s,r){r=(r&4)!==0;for(var l=0;l<s.length;l++){var d=s[l],p=d.event;d=d.listeners;e:{var y=void 0;if(r)for(var E=d.length-1;0<=E;E--){var M=d[E],H=M.instance,ne=M.currentTarget;if(M=M.listener,H!==y&&p.isPropagationStopped())break e;y=M,p.currentTarget=ne;try{y(p)}catch(oe){_c(oe)}p.currentTarget=null,y=H}else for(E=0;E<d.length;E++){if(M=d[E],H=M.instance,ne=M.currentTarget,M=M.listener,H!==y&&p.isPropagationStopped())break e;y=M,p.currentTarget=ne;try{y(p)}catch(oe){_c(oe)}p.currentTarget=null,y=H}}}}function st(s,r){var l=r[Ef];l===void 0&&(l=r[Ef]=new Set);var d=s+"__bubble";l.has(d)||(db(r,s,2,!1),l.add(d))}function mm(s,r,l){var d=0;r&&(d|=4),db(l,s,d,r)}var yu="_reactListening"+Math.random().toString(36).slice(2);function pm(s){if(!s[yu]){s[yu]=!0,ay.forEach(function(l){l!=="selectionchange"&&(IR.has(l)||mm(l,!1,s),mm(l,!0,s))});var r=s.nodeType===9?s:s.ownerDocument;r===null||r[yu]||(r[yu]=!0,mm("selectionchange",!1,r))}}function db(s,r,l,d){switch(Ub(r)){case 2:var p=lM;break;case 8:p=cM;break;default:p=Rm}l=p.bind(null,r,l,s),p=void 0,!Df||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(p=!0),d?p!==void 0?s.addEventListener(r,l,{capture:!0,passive:p}):s.addEventListener(r,l,!0):p!==void 0?s.addEventListener(r,l,{passive:p}):s.addEventListener(r,l,!1)}function gm(s,r,l,d,p){var y=d;if((r&1)===0&&(r&2)===0&&d!==null)e:for(;;){if(d===null)return;var E=d.tag;if(E===3||E===4){var M=d.stateNode.containerInfo;if(M===p)break;if(E===4)for(E=d.return;E!==null;){var H=E.tag;if((H===3||H===4)&&E.stateNode.containerInfo===p)return;E=E.return}for(;M!==null;){if(E=fi(M),E===null)return;if(H=E.tag,H===5||H===6||H===26||H===27){d=y=E;continue e}M=M.parentNode}}d=d.return}gy(function(){var ne=y,oe=Of(l),fe=[];e:{var se=Zy.get(s);if(se!==void 0){var re=Ac,Ce=s;switch(s){case"keypress":if(Cc(l)===0)break e;case"keydown":case"keyup":re=CA;break;case"focusin":Ce="focus",re=Pf;break;case"focusout":Ce="blur",re=Pf;break;case"beforeblur":case"afterblur":re=Pf;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":re=xy;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":re=pA;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":re=RA;break;case Uy:case By:case Vy:re=yA;break;case Hy:re=_A;break;case"scroll":case"scrollend":re=hA;break;case"wheel":re=IA;break;case"copy":case"cut":case"paste":re=bA;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":re=wy;break;case"toggle":case"beforetoggle":re=zA}var Le=(r&4)!==0,St=!Le&&(s==="scroll"||s==="scrollend"),X=Le?se!==null?se+"Capture":null:se;Le=[];for(var F=ne,te;F!==null;){var ue=F;if(te=ue.stateNode,ue=ue.tag,ue!==5&&ue!==26&&ue!==27||te===null||X===null||(ue=Uo(F,X),ue!=null&&Le.push(xl(F,ue,te))),St)break;F=F.return}0<Le.length&&(se=new re(se,Ce,null,l,oe),fe.push({event:se,listeners:Le}))}}if((r&7)===0){e:{if(se=s==="mouseover"||s==="pointerover",re=s==="mouseout"||s==="pointerout",se&&l!==_f&&(Ce=l.relatedTarget||l.fromElement)&&(fi(Ce)||Ce[di]))break e;if((re||se)&&(se=oe.window===oe?oe:(se=oe.ownerDocument)?se.defaultView||se.parentWindow:window,re?(Ce=l.relatedTarget||l.toElement,re=ne,Ce=Ce?fi(Ce):null,Ce!==null&&(St=c(Ce),Le=Ce.tag,Ce!==St||Le!==5&&Le!==27&&Le!==6)&&(Ce=null)):(re=null,Ce=ne),re!==Ce)){if(Le=xy,ue="onMouseLeave",X="onMouseEnter",F="mouse",(s==="pointerout"||s==="pointerover")&&(Le=wy,ue="onPointerLeave",X="onPointerEnter",F="pointer"),St=re==null?se:Po(re),te=Ce==null?se:Po(Ce),se=new Le(ue,F+"leave",re,l,oe),se.target=St,se.relatedTarget=te,ue=null,fi(oe)===ne&&(Le=new Le(X,F+"enter",Ce,l,oe),Le.target=te,Le.relatedTarget=St,ue=Le),St=ue,re&&Ce)t:{for(Le=DR,X=re,F=Ce,te=0,ue=X;ue;ue=Le(ue))te++;ue=0;for(var De=F;De;De=Le(De))ue++;for(;0<te-ue;)X=Le(X),te--;for(;0<ue-te;)F=Le(F),ue--;for(;te--;){if(X===F||F!==null&&X===F.alternate){Le=X;break t}X=Le(X),F=Le(F)}Le=null}else Le=null;re!==null&&fb(fe,se,re,Le,!1),Ce!==null&&St!==null&&fb(fe,St,Ce,Le,!0)}}e:{if(se=ne?Po(ne):window,re=se.nodeName&&se.nodeName.toLowerCase(),re==="select"||re==="input"&&se.type==="file")var ft=Ay;else if(Cy(se))if(Ry)ft=qA;else{ft=ZA;var Re=HA}else re=se.nodeName,!re||re.toLowerCase()!=="input"||se.type!=="checkbox"&&se.type!=="radio"?ne&&Mf(ne.elementType)&&(ft=Ay):ft=FA;if(ft&&(ft=ft(s,ne))){Ty(fe,ft,l,oe);break e}Re&&Re(s,se,ne),s==="focusout"&&ne&&se.type==="number"&&ne.memoizedProps.value!=null&&Rf(se,"number",se.value)}switch(Re=ne?Po(ne):window,s){case"focusin":(Cy(Re)||Re.contentEditable==="true")&&(wi=Re,Ff=ne,Go=null);break;case"focusout":Go=Ff=wi=null;break;case"mousedown":qf=!0;break;case"contextmenu":case"mouseup":case"dragend":qf=!1,$y(fe,l,oe);break;case"selectionchange":if(GA)break;case"keydown":case"keyup":$y(fe,l,oe)}var Ke;if(Bf)e:{switch(s){case"compositionstart":var it="onCompositionStart";break e;case"compositionend":it="onCompositionEnd";break e;case"compositionupdate":it="onCompositionUpdate";break e}it=void 0}else bi?ky(s,l)&&(it="onCompositionEnd"):s==="keydown"&&l.keyCode===229&&(it="onCompositionStart");it&&(Sy&&l.locale!=="ko"&&(bi||it!=="onCompositionStart"?it==="onCompositionEnd"&&bi&&(Ke=vy()):(_a=oe,zf="value"in _a?_a.value:_a.textContent,bi=!0)),Re=xu(ne,it),0<Re.length&&(it=new by(it,s,null,l,oe),fe.push({event:it,listeners:Re}),Ke?it.data=Ke:(Ke=Ey(l),Ke!==null&&(it.data=Ke)))),(Ke=$A?PA(s,l):UA(s,l))&&(it=xu(ne,"onBeforeInput"),0<it.length&&(Re=new by("onBeforeInput","beforeinput",null,l,oe),fe.push({event:Re,listeners:it}),Re.data=Ke)),MR(fe,s,ne,l,oe)}ub(fe,r)})}function xl(s,r,l){return{instance:s,listener:r,currentTarget:l}}function xu(s,r){for(var l=r+"Capture",d=[];s!==null;){var p=s,y=p.stateNode;if(p=p.tag,p!==5&&p!==26&&p!==27||y===null||(p=Uo(s,l),p!=null&&d.unshift(xl(s,p,y)),p=Uo(s,r),p!=null&&d.push(xl(s,p,y))),s.tag===3)return d;s=s.return}return[]}function DR(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5&&s.tag!==27);return s||null}function fb(s,r,l,d,p){for(var y=r._reactName,E=[];l!==null&&l!==d;){var M=l,H=M.alternate,ne=M.stateNode;if(M=M.tag,H!==null&&H===d)break;M!==5&&M!==26&&M!==27||ne===null||(H=ne,p?(ne=Uo(l,y),ne!=null&&E.unshift(xl(l,ne,H))):p||(ne=Uo(l,y),ne!=null&&E.push(xl(l,ne,H)))),l=l.return}E.length!==0&&s.push({event:r,listeners:E})}var zR=/\r\n?/g,LR=/\u0000|\uFFFD/g;function hb(s){return(typeof s=="string"?s:""+s).replace(zR,`
|
|
9
|
+
`).replace(LR,"")}function mb(s,r){return r=hb(r),hb(s)===r}function wt(s,r,l,d,p,y){switch(l){case"children":typeof d=="string"?r==="body"||r==="textarea"&&d===""||vi(s,d):(typeof d=="number"||typeof d=="bigint")&&r!=="body"&&vi(s,""+d);break;case"className":jc(s,"class",d);break;case"tabIndex":jc(s,"tabindex",d);break;case"dir":case"role":case"viewBox":case"width":case"height":jc(s,l,d);break;case"style":my(s,d,y);break;case"data":if(r!=="object"){jc(s,"data",d);break}case"src":case"href":if(d===""&&(r!=="a"||l!=="href")){s.removeAttribute(l);break}if(d==null||typeof d=="function"||typeof d=="symbol"||typeof d=="boolean"){s.removeAttribute(l);break}d=kc(""+d),s.setAttribute(l,d);break;case"action":case"formAction":if(typeof d=="function"){s.setAttribute(l,"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 y=="function"&&(l==="formAction"?(r!=="input"&&wt(s,r,"name",p.name,p,null),wt(s,r,"formEncType",p.formEncType,p,null),wt(s,r,"formMethod",p.formMethod,p,null),wt(s,r,"formTarget",p.formTarget,p,null)):(wt(s,r,"encType",p.encType,p,null),wt(s,r,"method",p.method,p,null),wt(s,r,"target",p.target,p,null)));if(d==null||typeof d=="symbol"||typeof d=="boolean"){s.removeAttribute(l);break}d=kc(""+d),s.setAttribute(l,d);break;case"onClick":d!=null&&(s.onclick=oa);break;case"onScroll":d!=null&&st("scroll",s);break;case"onScrollEnd":d!=null&&st("scrollend",s);break;case"dangerouslySetInnerHTML":if(d!=null){if(typeof d!="object"||!("__html"in d))throw Error(a(61));if(l=d.__html,l!=null){if(p.children!=null)throw Error(a(60));s.innerHTML=l}}break;case"multiple":s.multiple=d&&typeof d!="function"&&typeof d!="symbol";break;case"muted":s.muted=d&&typeof d!="function"&&typeof d!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(d==null||typeof d=="function"||typeof d=="boolean"||typeof d=="symbol"){s.removeAttribute("xlink:href");break}l=kc(""+d),s.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",l);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":d!=null&&typeof d!="function"&&typeof d!="symbol"?s.setAttribute(l,""+d):s.removeAttribute(l);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":d&&typeof d!="function"&&typeof d!="symbol"?s.setAttribute(l,""):s.removeAttribute(l);break;case"capture":case"download":d===!0?s.setAttribute(l,""):d!==!1&&d!=null&&typeof d!="function"&&typeof d!="symbol"?s.setAttribute(l,d):s.removeAttribute(l);break;case"cols":case"rows":case"size":case"span":d!=null&&typeof d!="function"&&typeof d!="symbol"&&!isNaN(d)&&1<=d?s.setAttribute(l,d):s.removeAttribute(l);break;case"rowSpan":case"start":d==null||typeof d=="function"||typeof d=="symbol"||isNaN(d)?s.removeAttribute(l):s.setAttribute(l,d);break;case"popover":st("beforetoggle",s),st("toggle",s),Sc(s,"popover",d);break;case"xlinkActuate":ia(s,"http://www.w3.org/1999/xlink","xlink:actuate",d);break;case"xlinkArcrole":ia(s,"http://www.w3.org/1999/xlink","xlink:arcrole",d);break;case"xlinkRole":ia(s,"http://www.w3.org/1999/xlink","xlink:role",d);break;case"xlinkShow":ia(s,"http://www.w3.org/1999/xlink","xlink:show",d);break;case"xlinkTitle":ia(s,"http://www.w3.org/1999/xlink","xlink:title",d);break;case"xlinkType":ia(s,"http://www.w3.org/1999/xlink","xlink:type",d);break;case"xmlBase":ia(s,"http://www.w3.org/XML/1998/namespace","xml:base",d);break;case"xmlLang":ia(s,"http://www.w3.org/XML/1998/namespace","xml:lang",d);break;case"xmlSpace":ia(s,"http://www.w3.org/XML/1998/namespace","xml:space",d);break;case"is":Sc(s,"is",d);break;case"innerText":case"textContent":break;default:(!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(l=dA.get(l)||l,Sc(s,l,d))}}function vm(s,r,l,d,p,y){switch(l){case"style":my(s,d,y);break;case"dangerouslySetInnerHTML":if(d!=null){if(typeof d!="object"||!("__html"in d))throw Error(a(61));if(l=d.__html,l!=null){if(p.children!=null)throw Error(a(60));s.innerHTML=l}}break;case"children":typeof d=="string"?vi(s,d):(typeof d=="number"||typeof d=="bigint")&&vi(s,""+d);break;case"onScroll":d!=null&&st("scroll",s);break;case"onScrollEnd":d!=null&&st("scrollend",s);break;case"onClick":d!=null&&(s.onclick=oa);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ry.hasOwnProperty(l))e:{if(l[0]==="o"&&l[1]==="n"&&(p=l.endsWith("Capture"),r=l.slice(2,p?l.length-7:void 0),y=s[Un]||null,y=y!=null?y[l]:null,typeof y=="function"&&s.removeEventListener(r,y,p),typeof d=="function")){typeof y!="function"&&y!==null&&(l in s?s[l]=null:s.hasAttribute(l)&&s.removeAttribute(l)),s.addEventListener(r,d,p);break e}l in s?s[l]=d:d===!0?s.setAttribute(l,""):Sc(s,l,d)}}}function Nn(s,r,l){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":st("error",s),st("load",s);var d=!1,p=!1,y;for(y in l)if(l.hasOwnProperty(y)){var E=l[y];if(E!=null)switch(y){case"src":d=!0;break;case"srcSet":p=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(a(137,r));default:wt(s,r,y,E,l,null)}}p&&wt(s,r,"srcSet",l.srcSet,l,null),d&&wt(s,r,"src",l.src,l,null);return;case"input":st("invalid",s);var M=y=E=p=null,H=null,ne=null;for(d in l)if(l.hasOwnProperty(d)){var oe=l[d];if(oe!=null)switch(d){case"name":p=oe;break;case"type":E=oe;break;case"checked":H=oe;break;case"defaultChecked":ne=oe;break;case"value":y=oe;break;case"defaultValue":M=oe;break;case"children":case"dangerouslySetInnerHTML":if(oe!=null)throw Error(a(137,r));break;default:wt(s,r,d,oe,l,null)}}uy(s,y,M,H,ne,E,p,!1);return;case"select":st("invalid",s),d=E=y=null;for(p in l)if(l.hasOwnProperty(p)&&(M=l[p],M!=null))switch(p){case"value":y=M;break;case"defaultValue":E=M;break;case"multiple":d=M;default:wt(s,r,p,M,l,null)}r=y,l=E,s.multiple=!!d,r!=null?gi(s,!!d,r,!1):l!=null&&gi(s,!!d,l,!0);return;case"textarea":st("invalid",s),y=p=d=null;for(E in l)if(l.hasOwnProperty(E)&&(M=l[E],M!=null))switch(E){case"value":d=M;break;case"defaultValue":p=M;break;case"children":y=M;break;case"dangerouslySetInnerHTML":if(M!=null)throw Error(a(91));break;default:wt(s,r,E,M,l,null)}fy(s,d,p,y);return;case"option":for(H in l)l.hasOwnProperty(H)&&(d=l[H],d!=null)&&(H==="selected"?s.selected=d&&typeof d!="function"&&typeof d!="symbol":wt(s,r,H,d,l,null));return;case"dialog":st("beforetoggle",s),st("toggle",s),st("cancel",s),st("close",s);break;case"iframe":case"object":st("load",s);break;case"video":case"audio":for(d=0;d<yl.length;d++)st(yl[d],s);break;case"image":st("error",s),st("load",s);break;case"details":st("toggle",s);break;case"embed":case"source":case"link":st("error",s),st("load",s);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 l)if(l.hasOwnProperty(ne)&&(d=l[ne],d!=null))switch(ne){case"children":case"dangerouslySetInnerHTML":throw Error(a(137,r));default:wt(s,r,ne,d,l,null)}return;default:if(Mf(r)){for(oe in l)l.hasOwnProperty(oe)&&(d=l[oe],d!==void 0&&vm(s,r,oe,d,l,void 0));return}}for(M in l)l.hasOwnProperty(M)&&(d=l[M],d!=null&&wt(s,r,M,d,l,null))}function $R(s,r,l,d){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var p=null,y=null,E=null,M=null,H=null,ne=null,oe=null;for(re in l){var fe=l[re];if(l.hasOwnProperty(re)&&fe!=null)switch(re){case"checked":break;case"value":break;case"defaultValue":H=fe;default:d.hasOwnProperty(re)||wt(s,r,re,null,d,fe)}}for(var se in d){var re=d[se];if(fe=l[se],d.hasOwnProperty(se)&&(re!=null||fe!=null))switch(se){case"type":y=re;break;case"name":p=re;break;case"checked":ne=re;break;case"defaultChecked":oe=re;break;case"value":E=re;break;case"defaultValue":M=re;break;case"children":case"dangerouslySetInnerHTML":if(re!=null)throw Error(a(137,r));break;default:re!==fe&&wt(s,r,se,re,d,fe)}}Af(s,E,M,H,ne,oe,y,p);return;case"select":re=E=M=se=null;for(y in l)if(H=l[y],l.hasOwnProperty(y)&&H!=null)switch(y){case"value":break;case"multiple":re=H;default:d.hasOwnProperty(y)||wt(s,r,y,null,d,H)}for(p in d)if(y=d[p],H=l[p],d.hasOwnProperty(p)&&(y!=null||H!=null))switch(p){case"value":se=y;break;case"defaultValue":M=y;break;case"multiple":E=y;default:y!==H&&wt(s,r,p,y,d,H)}r=M,l=E,d=re,se!=null?gi(s,!!l,se,!1):!!d!=!!l&&(r!=null?gi(s,!!l,r,!0):gi(s,!!l,l?[]:"",!1));return;case"textarea":re=se=null;for(M in l)if(p=l[M],l.hasOwnProperty(M)&&p!=null&&!d.hasOwnProperty(M))switch(M){case"value":break;case"children":break;default:wt(s,r,M,null,d,p)}for(E in d)if(p=d[E],y=l[E],d.hasOwnProperty(E)&&(p!=null||y!=null))switch(E){case"value":se=p;break;case"defaultValue":re=p;break;case"children":break;case"dangerouslySetInnerHTML":if(p!=null)throw Error(a(91));break;default:p!==y&&wt(s,r,E,p,d,y)}dy(s,se,re);return;case"option":for(var Ce in l)se=l[Ce],l.hasOwnProperty(Ce)&&se!=null&&!d.hasOwnProperty(Ce)&&(Ce==="selected"?s.selected=!1:wt(s,r,Ce,null,d,se));for(H in d)se=d[H],re=l[H],d.hasOwnProperty(H)&&se!==re&&(se!=null||re!=null)&&(H==="selected"?s.selected=se&&typeof se!="function"&&typeof se!="symbol":wt(s,r,H,se,d,re));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 Le in l)se=l[Le],l.hasOwnProperty(Le)&&se!=null&&!d.hasOwnProperty(Le)&&wt(s,r,Le,null,d,se);for(ne in d)if(se=d[ne],re=l[ne],d.hasOwnProperty(ne)&&se!==re&&(se!=null||re!=null))switch(ne){case"children":case"dangerouslySetInnerHTML":if(se!=null)throw Error(a(137,r));break;default:wt(s,r,ne,se,d,re)}return;default:if(Mf(r)){for(var St in l)se=l[St],l.hasOwnProperty(St)&&se!==void 0&&!d.hasOwnProperty(St)&&vm(s,r,St,void 0,d,se);for(oe in d)se=d[oe],re=l[oe],!d.hasOwnProperty(oe)||se===re||se===void 0&&re===void 0||vm(s,r,oe,se,d,re);return}}for(var X in l)se=l[X],l.hasOwnProperty(X)&&se!=null&&!d.hasOwnProperty(X)&&wt(s,r,X,null,d,se);for(fe in d)se=d[fe],re=l[fe],!d.hasOwnProperty(fe)||se===re||se==null&&re==null||wt(s,r,fe,se,d,re)}function pb(s){switch(s){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function PR(){if(typeof performance.getEntriesByType=="function"){for(var s=0,r=0,l=performance.getEntriesByType("resource"),d=0;d<l.length;d++){var p=l[d],y=p.transferSize,E=p.initiatorType,M=p.duration;if(y&&M&&pb(E)){for(E=0,M=p.responseEnd,d+=1;d<l.length;d++){var H=l[d],ne=H.startTime;if(ne>M)break;var oe=H.transferSize,fe=H.initiatorType;oe&&pb(fe)&&(H=H.responseEnd,E+=oe*(H<M?1:(M-ne)/(H-ne)))}if(--d,r+=8*(y+E)/(p.duration/1e3),s++,10<s)break}}if(0<s)return r/s/1e6}return navigator.connection&&(s=navigator.connection.downlink,typeof s=="number")?s:5}var ym=null,xm=null;function bu(s){return s.nodeType===9?s:s.ownerDocument}function gb(s){switch(s){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function vb(s,r){if(s===0)switch(r){case"svg":return 1;case"math":return 2;default:return 0}return s===1&&r==="foreignObject"?0:s}function bm(s,r){return s==="textarea"||s==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.children=="bigint"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var wm=null;function UR(){var s=window.event;return s&&s.type==="popstate"?s===wm?!1:(wm=s,!0):(wm=null,!1)}var yb=typeof setTimeout=="function"?setTimeout:void 0,BR=typeof clearTimeout=="function"?clearTimeout:void 0,xb=typeof Promise=="function"?Promise:void 0,VR=typeof queueMicrotask=="function"?queueMicrotask:typeof xb<"u"?function(s){return xb.resolve(null).then(s).catch(HR)}:yb;function HR(s){setTimeout(function(){throw s})}function Wa(s){return s==="head"}function bb(s,r){var l=r,d=0;do{var p=l.nextSibling;if(s.removeChild(l),p&&p.nodeType===8)if(l=p.data,l==="/$"||l==="/&"){if(d===0){s.removeChild(p),Gi(r);return}d--}else if(l==="$"||l==="$?"||l==="$~"||l==="$!"||l==="&")d++;else if(l==="html")bl(s.ownerDocument.documentElement);else if(l==="head"){l=s.ownerDocument.head,bl(l);for(var y=l.firstChild;y;){var E=y.nextSibling,M=y.nodeName;y[$o]||M==="SCRIPT"||M==="STYLE"||M==="LINK"&&y.rel.toLowerCase()==="stylesheet"||l.removeChild(y),y=E}}else l==="body"&&bl(s.ownerDocument.body);l=p}while(l);Gi(r)}function wb(s,r){var l=s;s=0;do{var d=l.nextSibling;if(l.nodeType===1?r?(l._stashedDisplay=l.style.display,l.style.display="none"):(l.style.display=l._stashedDisplay||"",l.getAttribute("style")===""&&l.removeAttribute("style")):l.nodeType===3&&(r?(l._stashedText=l.nodeValue,l.nodeValue=""):l.nodeValue=l._stashedText||""),d&&d.nodeType===8)if(l=d.data,l==="/$"){if(s===0)break;s--}else l!=="$"&&l!=="$?"&&l!=="$~"&&l!=="$!"||s++;l=d}while(l)}function Sm(s){var r=s.firstChild;for(r&&r.nodeType===10&&(r=r.nextSibling);r;){var l=r;switch(r=r.nextSibling,l.nodeName){case"HTML":case"HEAD":case"BODY":Sm(l),Cf(l);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(l.rel.toLowerCase()==="stylesheet")continue}s.removeChild(l)}}function ZR(s,r,l,d){for(;s.nodeType===1;){var p=l;if(s.nodeName.toLowerCase()!==r.toLowerCase()){if(!d&&(s.nodeName!=="INPUT"||s.type!=="hidden"))break}else if(d){if(!s[$o])switch(r){case"meta":if(!s.hasAttribute("itemprop"))break;return s;case"link":if(y=s.getAttribute("rel"),y==="stylesheet"&&s.hasAttribute("data-precedence"))break;if(y!==p.rel||s.getAttribute("href")!==(p.href==null||p.href===""?null:p.href)||s.getAttribute("crossorigin")!==(p.crossOrigin==null?null:p.crossOrigin)||s.getAttribute("title")!==(p.title==null?null:p.title))break;return s;case"style":if(s.hasAttribute("data-precedence"))break;return s;case"script":if(y=s.getAttribute("src"),(y!==(p.src==null?null:p.src)||s.getAttribute("type")!==(p.type==null?null:p.type)||s.getAttribute("crossorigin")!==(p.crossOrigin==null?null:p.crossOrigin))&&y&&s.hasAttribute("async")&&!s.hasAttribute("itemprop"))break;return s;default:return s}}else if(r==="input"&&s.type==="hidden"){var y=p.name==null?null:""+p.name;if(p.type==="hidden"&&s.getAttribute("name")===y)return s}else return s;if(s=ys(s.nextSibling),s===null)break}return null}function FR(s,r,l){if(r==="")return null;for(;s.nodeType!==3;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!l||(s=ys(s.nextSibling),s===null))return null;return s}function Sb(s,r){for(;s.nodeType!==8;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!r||(s=ys(s.nextSibling),s===null))return null;return s}function jm(s){return s.data==="$?"||s.data==="$~"}function Nm(s){return s.data==="$!"||s.data==="$?"&&s.ownerDocument.readyState!=="loading"}function qR(s,r){var l=s.ownerDocument;if(s.data==="$~")s._reactRetry=r;else if(s.data!=="$?"||l.readyState!=="loading")r();else{var d=function(){r(),l.removeEventListener("DOMContentLoaded",d)};l.addEventListener("DOMContentLoaded",d),s._reactRetry=d}}function ys(s){for(;s!=null;s=s.nextSibling){var r=s.nodeType;if(r===1||r===3)break;if(r===8){if(r=s.data,r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"||r==="F!"||r==="F")break;if(r==="/$"||r==="/&")return null}}return s}var km=null;function jb(s){s=s.nextSibling;for(var r=0;s;){if(s.nodeType===8){var l=s.data;if(l==="/$"||l==="/&"){if(r===0)return ys(s.nextSibling);r--}else l!=="$"&&l!=="$!"&&l!=="$?"&&l!=="$~"&&l!=="&"||r++}s=s.nextSibling}return null}function Nb(s){s=s.previousSibling;for(var r=0;s;){if(s.nodeType===8){var l=s.data;if(l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"){if(r===0)return s;r--}else l!=="/$"&&l!=="/&"||r++}s=s.previousSibling}return null}function kb(s,r,l){switch(r=bu(l),s){case"html":if(s=r.documentElement,!s)throw Error(a(452));return s;case"head":if(s=r.head,!s)throw Error(a(453));return s;case"body":if(s=r.body,!s)throw Error(a(454));return s;default:throw Error(a(451))}}function bl(s){for(var r=s.attributes;r.length;)s.removeAttributeNode(r[0]);Cf(s)}var xs=new Map,Eb=new Set;function wu(s){return typeof s.getRootNode=="function"?s.getRootNode():s.nodeType===9?s:s.ownerDocument}var ja=U.d;U.d={f:YR,r:GR,D:WR,C:XR,L:KR,m:JR,X:eM,S:QR,M:tM};function YR(){var s=ja.f(),r=fu();return s||r}function GR(s){var r=hi(s);r!==null&&r.tag===5&&r.type==="form"?H0(r):ja.r(s)}var Fi=typeof document>"u"?null:document;function Cb(s,r,l){var d=Fi;if(d&&typeof r=="string"&&r){var p=ds(r);p='link[rel="'+s+'"][href="'+p+'"]',typeof l=="string"&&(p+='[crossorigin="'+l+'"]'),Eb.has(p)||(Eb.add(p),s={rel:s,crossOrigin:l,href:r},d.querySelector(p)===null&&(r=d.createElement("link"),Nn(r,"link",s),pn(r),d.head.appendChild(r)))}}function WR(s){ja.D(s),Cb("dns-prefetch",s,null)}function XR(s,r){ja.C(s,r),Cb("preconnect",s,r)}function KR(s,r,l){ja.L(s,r,l);var d=Fi;if(d&&s&&r){var p='link[rel="preload"][as="'+ds(r)+'"]';r==="image"&&l&&l.imageSrcSet?(p+='[imagesrcset="'+ds(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(p+='[imagesizes="'+ds(l.imageSizes)+'"]')):p+='[href="'+ds(s)+'"]';var y=p;switch(r){case"style":y=qi(s);break;case"script":y=Yi(s)}xs.has(y)||(s=x({rel:"preload",href:r==="image"&&l&&l.imageSrcSet?void 0:s,as:r},l),xs.set(y,s),d.querySelector(p)!==null||r==="style"&&d.querySelector(wl(y))||r==="script"&&d.querySelector(Sl(y))||(r=d.createElement("link"),Nn(r,"link",s),pn(r),d.head.appendChild(r)))}}function JR(s,r){ja.m(s,r);var l=Fi;if(l&&s){var d=r&&typeof r.as=="string"?r.as:"script",p='link[rel="modulepreload"][as="'+ds(d)+'"][href="'+ds(s)+'"]',y=p;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=Yi(s)}if(!xs.has(y)&&(s=x({rel:"modulepreload",href:s},r),xs.set(y,s),l.querySelector(p)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Sl(y)))return}d=l.createElement("link"),Nn(d,"link",s),pn(d),l.head.appendChild(d)}}}function QR(s,r,l){ja.S(s,r,l);var d=Fi;if(d&&s){var p=mi(d).hoistableStyles,y=qi(s);r=r||"default";var E=p.get(y);if(!E){var M={loading:0,preload:null};if(E=d.querySelector(wl(y)))M.loading=5;else{s=x({rel:"stylesheet",href:s,"data-precedence":r},l),(l=xs.get(y))&&Em(s,l);var H=E=d.createElement("link");pn(H),Nn(H,"link",s),H._p=new Promise(function(ne,oe){H.onload=ne,H.onerror=oe}),H.addEventListener("load",function(){M.loading|=1}),H.addEventListener("error",function(){M.loading|=2}),M.loading|=4,Su(E,r,d)}E={type:"stylesheet",instance:E,count:1,state:M},p.set(y,E)}}}function eM(s,r){ja.X(s,r);var l=Fi;if(l&&s){var d=mi(l).hoistableScripts,p=Yi(s),y=d.get(p);y||(y=l.querySelector(Sl(p)),y||(s=x({src:s,async:!0},r),(r=xs.get(p))&&Cm(s,r),y=l.createElement("script"),pn(y),Nn(y,"link",s),l.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(p,y))}}function tM(s,r){ja.M(s,r);var l=Fi;if(l&&s){var d=mi(l).hoistableScripts,p=Yi(s),y=d.get(p);y||(y=l.querySelector(Sl(p)),y||(s=x({src:s,async:!0,type:"module"},r),(r=xs.get(p))&&Cm(s,r),y=l.createElement("script"),pn(y),Nn(y,"link",s),l.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(p,y))}}function Tb(s,r,l,d){var p=(p=ae.current)?wu(p):null;if(!p)throw Error(a(446));switch(s){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(r=qi(l.href),l=mi(p).hoistableStyles,d=l.get(r),d||(d={type:"style",instance:null,count:0,state:null},l.set(r,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){s=qi(l.href);var y=mi(p).hoistableStyles,E=y.get(s);if(E||(p=p.ownerDocument||p,E={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(s,E),(y=p.querySelector(wl(s)))&&!y._p&&(E.instance=y,E.state.loading=5),xs.has(s)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},xs.set(s,l),y||nM(p,s,l,E.state))),r&&d===null)throw Error(a(528,""));return E}if(r&&d!==null)throw Error(a(529,""));return null;case"script":return r=l.async,l=l.src,typeof l=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=Yi(l),l=mi(p).hoistableScripts,d=l.get(r),d||(d={type:"script",instance:null,count:0,state:null},l.set(r,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(a(444,s))}}function qi(s){return'href="'+ds(s)+'"'}function wl(s){return'link[rel="stylesheet"]['+s+"]"}function Ab(s){return x({},s,{"data-precedence":s.precedence,precedence:null})}function nM(s,r,l,d){s.querySelector('link[rel="preload"][as="style"]['+r+"]")?d.loading=1:(r=s.createElement("link"),d.preload=r,r.addEventListener("load",function(){return d.loading|=1}),r.addEventListener("error",function(){return d.loading|=2}),Nn(r,"link",l),pn(r),s.head.appendChild(r))}function Yi(s){return'[src="'+ds(s)+'"]'}function Sl(s){return"script[async]"+s}function Rb(s,r,l){if(r.count++,r.instance===null)switch(r.type){case"style":var d=s.querySelector('style[data-href~="'+ds(l.href)+'"]');if(d)return r.instance=d,pn(d),d;var p=x({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return d=(s.ownerDocument||s).createElement("style"),pn(d),Nn(d,"style",p),Su(d,l.precedence,s),r.instance=d;case"stylesheet":p=qi(l.href);var y=s.querySelector(wl(p));if(y)return r.state.loading|=4,r.instance=y,pn(y),y;d=Ab(l),(p=xs.get(p))&&Em(d,p),y=(s.ownerDocument||s).createElement("link"),pn(y);var E=y;return E._p=new Promise(function(M,H){E.onload=M,E.onerror=H}),Nn(y,"link",d),r.state.loading|=4,Su(y,l.precedence,s),r.instance=y;case"script":return y=Yi(l.src),(p=s.querySelector(Sl(y)))?(r.instance=p,pn(p),p):(d=l,(p=xs.get(y))&&(d=x({},l),Cm(d,p)),s=s.ownerDocument||s,p=s.createElement("script"),pn(p),Nn(p,"link",d),s.head.appendChild(p),r.instance=p);case"void":return null;default:throw Error(a(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(d=r.instance,r.state.loading|=4,Su(d,l.precedence,s));return r.instance}function Su(s,r,l){for(var d=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),p=d.length?d[d.length-1]:null,y=p,E=0;E<d.length;E++){var M=d[E];if(M.dataset.precedence===r)y=M;else if(y!==p)break}y?y.parentNode.insertBefore(s,y.nextSibling):(r=l.nodeType===9?l.head:l,r.insertBefore(s,r.firstChild))}function Em(s,r){s.crossOrigin==null&&(s.crossOrigin=r.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=r.referrerPolicy),s.title==null&&(s.title=r.title)}function Cm(s,r){s.crossOrigin==null&&(s.crossOrigin=r.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=r.referrerPolicy),s.integrity==null&&(s.integrity=r.integrity)}var ju=null;function Mb(s,r,l){if(ju===null){var d=new Map,p=ju=new Map;p.set(l,d)}else p=ju,d=p.get(l),d||(d=new Map,p.set(l,d));if(d.has(s))return d;for(d.set(s,null),l=l.getElementsByTagName(s),p=0;p<l.length;p++){var y=l[p];if(!(y[$o]||y[bn]||s==="link"&&y.getAttribute("rel")==="stylesheet")&&y.namespaceURI!=="http://www.w3.org/2000/svg"){var E=y.getAttribute(r)||"";E=s+E;var M=d.get(E);M?M.push(y):d.set(E,[y])}}return d}function _b(s,r,l){s=s.ownerDocument||s,s.head.insertBefore(l,r==="title"?s.querySelector("head > title"):null)}function sM(s,r,l){if(l===1||r.itemProp!=null)return!1;switch(s){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;return r.rel==="stylesheet"?(s=r.disabled,typeof r.precedence=="string"&&s==null):!0;case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function Ob(s){return!(s.type==="stylesheet"&&(s.state.loading&3)===0)}function aM(s,r,l,d){if(l.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var p=qi(d.href),y=r.querySelector(wl(p));if(y){r=y._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(s.count++,s=Nu.bind(s),r.then(s,s)),l.state.loading|=4,l.instance=y,pn(y);return}y=r.ownerDocument||r,d=Ab(d),(p=xs.get(p))&&Em(d,p),y=y.createElement("link"),pn(y);var E=y;E._p=new Promise(function(M,H){E.onload=M,E.onerror=H}),Nn(y,"link",d),l.instance=y}s.stylesheets===null&&(s.stylesheets=new Map),s.stylesheets.set(l,r),(r=l.state.preload)&&(l.state.loading&3)===0&&(s.count++,l=Nu.bind(s),r.addEventListener("load",l),r.addEventListener("error",l))}}var Tm=0;function rM(s,r){return s.stylesheets&&s.count===0&&Eu(s,s.stylesheets),0<s.count||0<s.imgCount?function(l){var d=setTimeout(function(){if(s.stylesheets&&Eu(s,s.stylesheets),s.unsuspend){var y=s.unsuspend;s.unsuspend=null,y()}},6e4+r);0<s.imgBytes&&Tm===0&&(Tm=62500*PR());var p=setTimeout(function(){if(s.waitingForImages=!1,s.count===0&&(s.stylesheets&&Eu(s,s.stylesheets),s.unsuspend)){var y=s.unsuspend;s.unsuspend=null,y()}},(s.imgBytes>Tm?50:800)+r);return s.unsuspend=l,function(){s.unsuspend=null,clearTimeout(d),clearTimeout(p)}}:null}function Nu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Eu(this,this.stylesheets);else if(this.unsuspend){var s=this.unsuspend;this.unsuspend=null,s()}}}var ku=null;function Eu(s,r){s.stylesheets=null,s.unsuspend!==null&&(s.count++,ku=new Map,r.forEach(iM,s),ku=null,Nu.call(s))}function iM(s,r){if(!(r.state.loading&4)){var l=ku.get(s);if(l)var d=l.get(null);else{l=new Map,ku.set(s,l);for(var p=s.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y<p.length;y++){var E=p[y];(E.nodeName==="LINK"||E.getAttribute("media")!=="not all")&&(l.set(E.dataset.precedence,E),d=E)}d&&l.set(null,d)}p=r.instance,E=p.getAttribute("data-precedence"),y=l.get(E)||d,y===d&&l.set(null,p),l.set(E,p),this.count++,d=Nu.bind(this),p.addEventListener("load",d),p.addEventListener("error",d),y?y.parentNode.insertBefore(p,y.nextSibling):(s=s.nodeType===9?s.head:s,s.insertBefore(p,s.firstChild)),r.state.loading|=4}}var jl={$$typeof:S,Provider:null,Consumer:null,_currentValue:B,_currentValue2:B,_threadCount:0};function oM(s,r,l,d,p,y,E,M,H){this.tag=1,this.containerInfo=s,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=Ve(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ve(0),this.hiddenUpdates=Ve(null),this.identifierPrefix=d,this.onUncaughtError=p,this.onCaughtError=y,this.onRecoverableError=E,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=H,this.incompleteTransitions=new Map}function Ib(s,r,l,d,p,y,E,M,H,ne,oe,fe){return s=new oM(s,r,l,E,H,ne,oe,fe,M),r=1,y===!0&&(r|=24),y=Qn(3,null,null,r),s.current=y,y.stateNode=s,r=oh(),r.refCount++,s.pooledCache=r,r.refCount++,y.memoizedState={element:d,isDehydrated:l,cache:r},dh(y),s}function Db(s){return s?(s=Ni,s):Ni}function zb(s,r,l,d,p,y){p=Db(p),d.context===null?d.context=p:d.pendingContext=p,d=$a(r),d.payload={element:l},y=y===void 0?null:y,y!==null&&(d.callback=y),l=Pa(s,d,r),l!==null&&(qn(l,s,r),tl(l,s,r))}function Lb(s,r){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var l=s.retryLane;s.retryLane=l!==0&&l<r?l:r}}function Am(s,r){Lb(s,r),(s=s.alternate)&&Lb(s,r)}function $b(s){if(s.tag===13||s.tag===31){var r=Ar(s,67108864);r!==null&&qn(r,s,67108864),Am(s,67108864)}}function Pb(s){if(s.tag===13||s.tag===31){var r=as();r=qt(r);var l=Ar(s,r);l!==null&&qn(l,s,r),Am(s,r)}}var Cu=!0;function lM(s,r,l,d){var p=D.T;D.T=null;var y=U.p;try{U.p=2,Rm(s,r,l,d)}finally{U.p=y,D.T=p}}function cM(s,r,l,d){var p=D.T;D.T=null;var y=U.p;try{U.p=8,Rm(s,r,l,d)}finally{U.p=y,D.T=p}}function Rm(s,r,l,d){if(Cu){var p=Mm(d);if(p===null)gm(s,r,d,Tu,l),Bb(s,d);else if(dM(p,s,r,l,d))d.stopPropagation();else if(Bb(s,d),r&4&&-1<uM.indexOf(s)){for(;p!==null;){var y=hi(p);if(y!==null)switch(y.tag){case 3:if(y=y.stateNode,y.current.memoizedState.isDehydrated){var E=yn(y.pendingLanes);if(E!==0){var M=y;for(M.pendingLanes|=2,M.entangledLanes|=2;E;){var H=1<<31-ut(E);M.entanglements[1]|=H,E&=~H}Zs(y),(pt&6)===0&&(uu=je()+500,vl(0))}}break;case 31:case 13:M=Ar(y,2),M!==null&&qn(M,y,2),fu(),Am(y,2)}if(y=Mm(d),y===null&&gm(s,r,d,Tu,l),y===p)break;p=y}p!==null&&d.stopPropagation()}else gm(s,r,d,null,l)}}function Mm(s){return s=Of(s),_m(s)}var Tu=null;function _m(s){if(Tu=null,s=fi(s),s!==null){var r=c(s);if(r===null)s=null;else{var l=r.tag;if(l===13){if(s=u(r),s!==null)return s;s=null}else if(l===31){if(s=f(r),s!==null)return s;s=null}else if(l===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;s=null}else r!==s&&(s=null)}}return Tu=s,null}function Ub(s){switch(s){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(Ne()){case Je:return 2;case et:return 8;case Ge:case Bt:return 32;case Et:return 268435456;default:return 32}default:return 32}}var Om=!1,Xa=null,Ka=null,Ja=null,Nl=new Map,kl=new Map,Qa=[],uM="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 Bb(s,r){switch(s){case"focusin":case"focusout":Xa=null;break;case"dragenter":case"dragleave":Ka=null;break;case"mouseover":case"mouseout":Ja=null;break;case"pointerover":case"pointerout":Nl.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":kl.delete(r.pointerId)}}function El(s,r,l,d,p,y){return s===null||s.nativeEvent!==y?(s={blockedOn:r,domEventName:l,eventSystemFlags:d,nativeEvent:y,targetContainers:[p]},r!==null&&(r=hi(r),r!==null&&$b(r)),s):(s.eventSystemFlags|=d,r=s.targetContainers,p!==null&&r.indexOf(p)===-1&&r.push(p),s)}function dM(s,r,l,d,p){switch(r){case"focusin":return Xa=El(Xa,s,r,l,d,p),!0;case"dragenter":return Ka=El(Ka,s,r,l,d,p),!0;case"mouseover":return Ja=El(Ja,s,r,l,d,p),!0;case"pointerover":var y=p.pointerId;return Nl.set(y,El(Nl.get(y)||null,s,r,l,d,p)),!0;case"gotpointercapture":return y=p.pointerId,kl.set(y,El(kl.get(y)||null,s,r,l,d,p)),!0}return!1}function Vb(s){var r=fi(s.target);if(r!==null){var l=c(r);if(l!==null){if(r=l.tag,r===13){if(r=u(l),r!==null){s.blockedOn=r,wc(s.priority,function(){Pb(l)});return}}else if(r===31){if(r=f(l),r!==null){s.blockedOn=r,wc(s.priority,function(){Pb(l)});return}}else if(r===3&&l.stateNode.current.memoizedState.isDehydrated){s.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}s.blockedOn=null}function Au(s){if(s.blockedOn!==null)return!1;for(var r=s.targetContainers;0<r.length;){var l=Mm(s.nativeEvent);if(l===null){l=s.nativeEvent;var d=new l.constructor(l.type,l);_f=d,l.target.dispatchEvent(d),_f=null}else return r=hi(l),r!==null&&$b(r),s.blockedOn=l,!1;r.shift()}return!0}function Hb(s,r,l){Au(s)&&l.delete(r)}function fM(){Om=!1,Xa!==null&&Au(Xa)&&(Xa=null),Ka!==null&&Au(Ka)&&(Ka=null),Ja!==null&&Au(Ja)&&(Ja=null),Nl.forEach(Hb),kl.forEach(Hb)}function Ru(s,r){s.blockedOn===r&&(s.blockedOn=null,Om||(Om=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,fM)))}var Mu=null;function Zb(s){Mu!==s&&(Mu=s,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Mu===s&&(Mu=null);for(var r=0;r<s.length;r+=3){var l=s[r],d=s[r+1],p=s[r+2];if(typeof d!="function"){if(_m(d||l)===null)continue;break}var y=hi(l);y!==null&&(s.splice(r,3),r-=3,Mh(y,{pending:!0,data:p,method:l.method,action:d},d,p))}}))}function Gi(s){function r(H){return Ru(H,s)}Xa!==null&&Ru(Xa,s),Ka!==null&&Ru(Ka,s),Ja!==null&&Ru(Ja,s),Nl.forEach(r),kl.forEach(r);for(var l=0;l<Qa.length;l++){var d=Qa[l];d.blockedOn===s&&(d.blockedOn=null)}for(;0<Qa.length&&(l=Qa[0],l.blockedOn===null);)Vb(l),l.blockedOn===null&&Qa.shift();if(l=(s.ownerDocument||s).$$reactFormReplay,l!=null)for(d=0;d<l.length;d+=3){var p=l[d],y=l[d+1],E=p[Un]||null;if(typeof y=="function")E||Zb(l);else if(E){var M=null;if(y&&y.hasAttribute("formAction")){if(p=y,E=y[Un]||null)M=E.formAction;else if(_m(p)!==null)continue}else M=E.action;typeof M=="function"?l[d+1]=M:(l.splice(d,3),d-=3),Zb(l)}}}function Fb(){function s(y){y.canIntercept&&y.info==="react-transition"&&y.intercept({handler:function(){return new Promise(function(E){return p=E})},focusReset:"manual",scroll:"manual"})}function r(){p!==null&&(p(),p=null),d||setTimeout(l,20)}function l(){if(!d&&!navigation.transition){var y=navigation.currentEntry;y&&y.url!=null&&navigation.navigate(y.url,{state:y.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var d=!1,p=null;return navigation.addEventListener("navigate",s),navigation.addEventListener("navigatesuccess",r),navigation.addEventListener("navigateerror",r),setTimeout(l,100),function(){d=!0,navigation.removeEventListener("navigate",s),navigation.removeEventListener("navigatesuccess",r),navigation.removeEventListener("navigateerror",r),p!==null&&(p(),p=null)}}}function Im(s){this._internalRoot=s}_u.prototype.render=Im.prototype.render=function(s){var r=this._internalRoot;if(r===null)throw Error(a(409));var l=r.current,d=as();zb(l,d,s,r,null,null)},_u.prototype.unmount=Im.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var r=s.containerInfo;zb(s.current,2,null,s,null,null),fu(),r[di]=null}};function _u(s){this._internalRoot=s}_u.prototype.unstable_scheduleHydration=function(s){if(s){var r=cn();s={blockedOn:null,target:s,priority:r};for(var l=0;l<Qa.length&&r!==0&&r<Qa[l].priority;l++);Qa.splice(l,0,s),l===0&&Vb(s)}};var qb=t.version;if(qb!=="19.2.3")throw Error(a(527,qb,"19.2.3"));U.findDOMNode=function(s){var r=s._reactInternals;if(r===void 0)throw typeof s.render=="function"?Error(a(188)):(s=Object.keys(s).join(","),Error(a(268,s)));return s=h(r),s=s!==null?g(s):null,s=s===null?null:s.stateNode,s};var hM={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:D,reconcilerVersion:"19.2.3"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Ou=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ou.isDisabled&&Ou.supportsFiber)try{on=Ou.inject(hM),Ie=Ou}catch{}}return Tl.createRoot=function(s,r){if(!i(s))throw Error(a(299));var l=!1,d="",p=Q0,y=ex,E=tx;return r!=null&&(r.unstable_strictMode===!0&&(l=!0),r.identifierPrefix!==void 0&&(d=r.identifierPrefix),r.onUncaughtError!==void 0&&(p=r.onUncaughtError),r.onCaughtError!==void 0&&(y=r.onCaughtError),r.onRecoverableError!==void 0&&(E=r.onRecoverableError)),r=Ib(s,1,!1,null,null,l,d,null,p,y,E,Fb),s[di]=r.current,pm(s),new Im(r)},Tl.hydrateRoot=function(s,r,l){if(!i(s))throw Error(a(299));var d=!1,p="",y=Q0,E=ex,M=tx,H=null;return l!=null&&(l.unstable_strictMode===!0&&(d=!0),l.identifierPrefix!==void 0&&(p=l.identifierPrefix),l.onUncaughtError!==void 0&&(y=l.onUncaughtError),l.onCaughtError!==void 0&&(E=l.onCaughtError),l.onRecoverableError!==void 0&&(M=l.onRecoverableError),l.formState!==void 0&&(H=l.formState)),r=Ib(s,1,!0,r,l??null,d,p,H,y,E,M,Fb),r.context=Db(null),l=r.current,d=as(),d=qt(d),p=$a(d),p.callback=null,Pa(l,p,d),l=d,r.current.lanes=l,ze(r,l),Zs(r),s[di]=r.current,pm(s),new _u(r)},Tl.version="19.2.3",Tl}var nw;function jM(){if(nw)return Lm.exports;nw=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(),Lm.exports=SM(),Lm.exports}var NM=jM();const $j=(...e)=>e.filter((t,n,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===n).join(" ").trim();const kM=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const EM=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,a)=>a?a.toUpperCase():n.toLowerCase());const sw=e=>{const t=EM(e);return t.charAt(0).toUpperCase()+t.slice(1)};var CM={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 TM=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const AM=v.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:a,className:i="",children:c,iconNode:u,...f},m)=>v.createElement("svg",{ref:m,...CM,width:t,height:t,stroke:e,strokeWidth:a?Number(n)*24/Number(t):n,className:$j("lucide",i),...!c&&!TM(f)&&{"aria-hidden":"true"},...f},[...u.map(([h,g])=>v.createElement(h,g)),...Array.isArray(c)?c:[c]]));const dc=(e,t)=>{const n=v.forwardRef(({className:a,...i},c)=>v.createElement(AM,{ref:c,iconNode:t,className:$j(`lucide-${kM(sw(e))}`,`lucide-${e}`,a),...i}));return n.displayName=sw(e),n};const RM=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],MM=dc("chevron-down",RM);const _M=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],OM=dc("chevron-right",_M);const IM=[["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"}]],DM=dc("compass",IM);const zM=[["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"}]],LM=dc("sparkles",zM);const $M=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],PM=dc("terminal",$M);function UM(e){try{const t=localStorage.getItem(e);if(t)return JSON.parse(t)}catch{}}function BM(e,t){try{localStorage.setItem(e,JSON.stringify(t)),window.dispatchEvent(new CustomEvent("hudson:saved",{detail:{key:e}}))}catch{}}const VM=()=>()=>{},HM=()=>!0,ZM=()=>!1;function FM(){return v.useSyncExternalStore(VM,HM,ZM)}function ka(e,t){const n=FM(),[a,i]=v.useState(t),c=v.useRef(!1);if(n&&!c.current){c.current=!0;const u=UM(e);u!==void 0&&i(u)}return v.useEffect(()=>{n&&BM(e,a)},[e,a,n]),[a,i]}var Pj="vercel.ai.error",qM=Symbol.for(Pj),aw,rw,ta=class Uj extends(rw=Error,aw=qM,rw){constructor({name:t,message:n,cause:a}){super(n),this[aw]=!0,this.name=t,this.cause=a}static isInstance(t){return Uj.hasMarker(t,Pj)}static hasMarker(t,n){const a=Symbol.for(n);return t!=null&&typeof t=="object"&&a in t&&typeof t[a]=="boolean"&&t[a]===!0}};function Bj(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var Vj="AI_InvalidArgumentError",Hj=`vercel.ai.error.${Vj}`,YM=Symbol.for(Hj),iw,ow,GM=class extends(ow=ta,iw=YM,ow){constructor({message:e,cause:t,argument:n}){super({name:Vj,message:e,cause:t}),this[iw]=!0,this.argument=n}static isInstance(e){return ta.hasMarker(e,Hj)}},Zj="AI_JSONParseError",Fj=`vercel.ai.error.${Zj}`,WM=Symbol.for(Fj),lw,cw,uw=class extends(cw=ta,lw=WM,cw){constructor({text:e,cause:t}){super({name:Zj,message:`JSON parsing failed: Text: ${e}.
|
|
10
|
+
Error message: ${Bj(t)}`,cause:t}),this[lw]=!0,this.text=e}static isInstance(e){return ta.hasMarker(e,Fj)}},qj="AI_TypeValidationError",Yj=`vercel.ai.error.${qj}`,XM=Symbol.for(Yj),dw,fw,jo=class Bp extends(fw=ta,dw=XM,fw){constructor({value:t,cause:n,context:a}){let i="Type validation failed";if(a?.field&&(i+=` for ${a.field}`),a?.entityName||a?.entityId){i+=" (";const c=[];a.entityName&&c.push(a.entityName),a.entityId&&c.push(`id: "${a.entityId}"`),i+=c.join(", "),i+=")"}super({name:qj,message:`${i}: Value: ${JSON.stringify(t)}.
|
|
11
|
+
Error message: ${Bj(n)}`,cause:n}),this[dw]=!0,this.value=t,this.context=a}static isInstance(t){return ta.hasMarker(t,Yj)}static wrap({value:t,cause:n,context:a}){var i,c,u;return Bp.isInstance(n)&&n.value===t&&((i=n.context)==null?void 0:i.field)===a?.field&&((c=n.context)==null?void 0:c.entityName)===a?.entityName&&((u=n.context)==null?void 0:u.entityId)===a?.entityId?n:new Bp({value:t,cause:n,context:a})}};function le(e,t,n){function a(f,m){if(f._zod||Object.defineProperty(f,"_zod",{value:{def:m,constr:u,traits:new Set},enumerable:!1}),f._zod.traits.has(e))return;f._zod.traits.add(e),t(f,m);const h=u.prototype,g=Object.keys(h);for(let x=0;x<g.length;x++){const b=g[x];b in f||(f[b]=h[b].bind(f))}}const i=n?.Parent??Object;class c extends i{}Object.defineProperty(c,"name",{value:e});function u(f){var m;const h=n?.Parent?new c:this;a(h,f),(m=h._zod).deferred??(m.deferred=[]);for(const g of h._zod.deferred)g();return h}return Object.defineProperty(u,"init",{value:a}),Object.defineProperty(u,Symbol.hasInstance,{value:f=>n?.Parent&&f instanceof n.Parent?!0:f?._zod?.traits?.has(e)}),Object.defineProperty(u,"name",{value:e}),u}class yo extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Gj extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Wj={};function hr(e){return Wj}function Xj(e){const t=Object.values(e).filter(a=>typeof a=="number");return Object.entries(e).filter(([a,i])=>t.indexOf(+a)===-1).map(([a,i])=>i)}function Vp(e,t){return typeof t=="bigint"?t.toString():t}function tf(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Vg(e){return e==null}function Hg(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function KM(e,t){const n=(e.toString().split(".")[1]||"").length,a=t.toString();let i=(a.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(a)){const m=a.match(/\d?e-(\d?)/);m?.[1]&&(i=Number.parseInt(m[1]))}const c=n>i?n:i,u=Number.parseInt(e.toFixed(c).replace(".","")),f=Number.parseInt(t.toFixed(c).replace(".",""));return u%f/10**c}const hw=Symbol("evaluating");function lt(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==hw)return a===void 0&&(a=hw,a=n()),a},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function li(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function vr(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function mw(e){return JSON.stringify(e)}function JM(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Kj="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Kl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const QM=tf(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function No(e){if(Kl(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Kl(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Jj(e){return No(e)?{...e}:Array.isArray(e)?[...e]:e}const e2=new Set(["string","number","symbol"]);function ko(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function yr(e,t,n){const a=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(a._zod.parent=e),a}function Me(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 t2(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const n2={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 s2(e,t){const n=e._zod.def,a=n.checks;if(a&&a.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const c=vr(e._zod.def,{get shape(){const u={};for(const f in t){if(!(f in n.shape))throw new Error(`Unrecognized key: "${f}"`);t[f]&&(u[f]=n.shape[f])}return li(this,"shape",u),u},checks:[]});return yr(e,c)}function a2(e,t){const n=e._zod.def,a=n.checks;if(a&&a.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const c=vr(e._zod.def,{get shape(){const u={...e._zod.def.shape};for(const f in t){if(!(f in n.shape))throw new Error(`Unrecognized key: "${f}"`);t[f]&&delete u[f]}return li(this,"shape",u),u},checks:[]});return yr(e,c)}function r2(e,t){if(!No(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const c=e._zod.def.shape;for(const u in t)if(Object.getOwnPropertyDescriptor(c,u)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=vr(e._zod.def,{get shape(){const c={...e._zod.def.shape,...t};return li(this,"shape",c),c}});return yr(e,i)}function i2(e,t){if(!No(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=vr(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return li(this,"shape",a),a}});return yr(e,n)}function o2(e,t){const n=vr(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return li(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:[]});return yr(e,n)}function l2(e,t,n){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const u=vr(t._zod.def,{get shape(){const f=t._zod.def.shape,m={...f};if(n)for(const h in n){if(!(h in f))throw new Error(`Unrecognized key: "${h}"`);n[h]&&(m[h]=e?new e({type:"optional",innerType:f[h]}):f[h])}else for(const h in f)m[h]=e?new e({type:"optional",innerType:f[h]}):f[h];return li(this,"shape",m),m},checks:[]});return yr(t,u)}function c2(e,t,n){const a=vr(t._zod.def,{get shape(){const i=t._zod.def.shape,c={...i};if(n)for(const u in n){if(!(u in c))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(c[u]=new e({type:"nonoptional",innerType:i[u]}))}else for(const u in i)c[u]=new e({type:"nonoptional",innerType:i[u]});return li(this,"shape",c),c}});return yr(t,a)}function co(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 uo(e,t){return t.map(n=>{var a;return(a=n).path??(a.path=[]),n.path.unshift(e),n})}function Iu(e){return typeof e=="string"?e:e?.message}function mr(e,t,n){const a={...e,path:e.path??[]};if(!e.message){const i=Iu(e.inst?._zod.def?.error?.(e))??Iu(t?.error?.(e))??Iu(n.customError?.(e))??Iu(n.localeError?.(e))??"Invalid input";a.message=i}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function Zg(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Jl(...e){const[t,n,a]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:a}:{...t}}const Qj=(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,Vp,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},eN=le("$ZodError",Qj),tN=le("$ZodError",Qj,{Parent:Error});function u2(e,t=n=>n.message){const n={},a=[];for(const i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):a.push(t(i));return{formErrors:a,fieldErrors:n}}function d2(e,t=n=>n.message){const n={_errors:[]},a=i=>{for(const c of i.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(u=>a({issues:u}));else if(c.code==="invalid_key")a({issues:c.issues});else if(c.code==="invalid_element")a({issues:c.issues});else if(c.path.length===0)n._errors.push(t(c));else{let u=n,f=0;for(;f<c.path.length;){const m=c.path[f];f===c.path.length-1?(u[m]=u[m]||{_errors:[]},u[m]._errors.push(t(c))):u[m]=u[m]||{_errors:[]},u=u[m],f++}}};return a(e),n}const Fg=e=>(t,n,a,i)=>{const c=a?Object.assign(a,{async:!1}):{async:!1},u=t._zod.run({value:n,issues:[]},c);if(u instanceof Promise)throw new yo;if(u.issues.length){const f=new(i?.Err??e)(u.issues.map(m=>mr(m,c,hr())));throw Kj(f,i?.callee),f}return u.value},qg=e=>async(t,n,a,i)=>{const c=a?Object.assign(a,{async:!0}):{async:!0};let u=t._zod.run({value:n,issues:[]},c);if(u instanceof Promise&&(u=await u),u.issues.length){const f=new(i?.Err??e)(u.issues.map(m=>mr(m,c,hr())));throw Kj(f,i?.callee),f}return u.value},nf=e=>(t,n,a)=>{const i=a?{...a,async:!1}:{async:!1},c=t._zod.run({value:n,issues:[]},i);if(c instanceof Promise)throw new yo;return c.issues.length?{success:!1,error:new(e??eN)(c.issues.map(u=>mr(u,i,hr())))}:{success:!0,data:c.value}},f2=nf(tN),sf=e=>async(t,n,a)=>{const i=a?Object.assign(a,{async:!0}):{async:!0};let c=t._zod.run({value:n,issues:[]},i);return c instanceof Promise&&(c=await c),c.issues.length?{success:!1,error:new e(c.issues.map(u=>mr(u,i,hr())))}:{success:!0,data:c.value}},h2=sf(tN),m2=e=>(t,n,a)=>{const i=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Fg(e)(t,n,i)},p2=e=>(t,n,a)=>Fg(e)(t,n,a),g2=e=>async(t,n,a)=>{const i=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return qg(e)(t,n,i)},v2=e=>async(t,n,a)=>qg(e)(t,n,a),y2=e=>(t,n,a)=>{const i=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return nf(e)(t,n,i)},x2=e=>(t,n,a)=>nf(e)(t,n,a),b2=e=>async(t,n,a)=>{const i=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return sf(e)(t,n,i)},w2=e=>async(t,n,a)=>sf(e)(t,n,a),S2=/^[cC][^\s-]{8,}$/,j2=/^[0-9a-z]+$/,N2=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,k2=/^[0-9a-vA-V]{20}$/,E2=/^[A-Za-z0-9]{27}$/,C2=/^[a-zA-Z0-9_-]{21}$/,T2=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,A2=/^([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})$/,pw=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)$/,R2=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,M2="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function _2(){return new RegExp(M2,"u")}const O2=/^(?:(?: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])$/,I2=/^(([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}|:))$/,D2=/^((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])$/,z2=/^(([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])$/,L2=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,nN=/^[A-Za-z0-9_-]*$/,$2=/^\+[1-9]\d{6,14}$/,sN="(?:(?:\\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])))",P2=new RegExp(`^${sN}$`);function aN(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 U2(e){return new RegExp(`^${aN(e)}$`)}function B2(e){const t=aN({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const a=`${t}(?:${n.join("|")})`;return new RegExp(`^${sN}T(?:${a})$`)}const V2=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},H2=/^-?\d+$/,rN=/^-?\d+(?:\.\d+)?$/,Z2=/^(?:true|false)$/i,F2=/^null$/i,q2=/^[^A-Z]*$/,Y2=/^[^a-z]*$/,Kn=le("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),iN={number:"number",bigint:"bigint",object:"date"},oN=le("$ZodCheckLessThan",(e,t)=>{Kn.init(e,t);const n=iN[typeof t.value];e._zod.onattach.push(a=>{const i=a._zod.bag,c=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<c&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value<=t.value:a.value<t.value)||a.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),lN=le("$ZodCheckGreaterThan",(e,t)=>{Kn.init(e,t);const n=iN[typeof t.value];e._zod.onattach.push(a=>{const i=a._zod.bag,c=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>c&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value>=t.value:a.value>t.value)||a.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),G2=le("$ZodCheckMultipleOf",(e,t)=>{Kn.init(e,t),e._zod.onattach.push(n=>{var a;(a=n._zod.bag).multipleOf??(a.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):KM(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})}}),W2=le("$ZodCheckNumberFormat",(e,t)=>{Kn.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),a=n?"int":"number",[i,c]=n2[t.format];e._zod.onattach.push(u=>{const f=u._zod.bag;f.format=t.format,f.minimum=i,f.maximum=c,n&&(f.pattern=H2)}),e._zod.check=u=>{const f=u.value;if(n){if(!Number.isInteger(f)){u.issues.push({expected:a,format:t.format,code:"invalid_type",continue:!1,input:f,inst:e});return}if(!Number.isSafeInteger(f)){f>0?u.issues.push({input:f,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort}):u.issues.push({input:f,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort});return}}f<i&&u.issues.push({origin:"number",input:f,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),f>c&&u.issues.push({origin:"number",input:f,code:"too_big",maximum:c,inclusive:!0,inst:e,continue:!t.abort})}}),X2=le("$ZodCheckMaxLength",(e,t)=>{var n;Kn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const i=a.value;return!Vg(i)&&i.length!==void 0}),e._zod.onattach.push(a=>{const i=a._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(a._zod.bag.maximum=t.maximum)}),e._zod.check=a=>{const i=a.value;if(i.length<=t.maximum)return;const u=Zg(i);a.issues.push({origin:u,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),K2=le("$ZodCheckMinLength",(e,t)=>{var n;Kn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const i=a.value;return!Vg(i)&&i.length!==void 0}),e._zod.onattach.push(a=>{const i=a._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(a._zod.bag.minimum=t.minimum)}),e._zod.check=a=>{const i=a.value;if(i.length>=t.minimum)return;const u=Zg(i);a.issues.push({origin:u,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),J2=le("$ZodCheckLengthEquals",(e,t)=>{var n;Kn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const i=a.value;return!Vg(i)&&i.length!==void 0}),e._zod.onattach.push(a=>{const i=a._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=a=>{const i=a.value,c=i.length;if(c===t.length)return;const u=Zg(i),f=c>t.length;a.issues.push({origin:u,...f?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:a.value,inst:e,continue:!t.abort})}}),af=le("$ZodCheckStringFormat",(e,t)=>{var n,a;Kn.init(e,t),e._zod.onattach.push(i=>{const c=i._zod.bag;c.format=t.format,t.pattern&&(c.patterns??(c.patterns=new Set),c.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(a=e._zod).check??(a.check=()=>{})}),Q2=le("$ZodCheckRegex",(e,t)=>{af.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})}}),e_=le("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=q2),af.init(e,t)}),t_=le("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Y2),af.init(e,t)}),n_=le("$ZodCheckIncludes",(e,t)=>{Kn.init(e,t);const n=ko(t.includes),a=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=a,e._zod.onattach.push(i=>{const c=i._zod.bag;c.patterns??(c.patterns=new Set),c.patterns.add(a)}),e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),s_=le("$ZodCheckStartsWith",(e,t)=>{Kn.init(e,t);const n=new RegExp(`^${ko(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=a=>{a.value.startsWith(t.prefix)||a.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:a.value,inst:e,continue:!t.abort})}}),a_=le("$ZodCheckEndsWith",(e,t)=>{Kn.init(e,t);const n=new RegExp(`.*${ko(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=a=>{a.value.endsWith(t.suffix)||a.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:a.value,inst:e,continue:!t.abort})}}),r_=le("$ZodCheckOverwrite",(e,t)=>{Kn.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class i_{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 a=t.split(`
|
|
12
|
+
`).filter(u=>u),i=Math.min(...a.map(u=>u.length-u.trimStart().length)),c=a.map(u=>u.slice(i)).map(u=>" ".repeat(this.indent*2)+u);for(const u of c)this.content.push(u)}compile(){const t=Function,n=this?.args,i=[...(this?.content??[""]).map(c=>` ${c}`)];return new t(...n,i.join(`
|
|
13
|
+
`))}}const o_={major:4,minor:3,patch:6},Dt=le("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=o_;const a=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&a.unshift(e);for(const i of a)for(const c of i._zod.onattach)c(e);if(a.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const i=(u,f,m)=>{let h=co(u),g;for(const x of f){if(x._zod.def.when){if(!x._zod.def.when(u))continue}else if(h)continue;const b=u.issues.length,w=x._zod.check(u);if(w instanceof Promise&&m?.async===!1)throw new yo;if(g||w instanceof Promise)g=(g??Promise.resolve()).then(async()=>{await w,u.issues.length!==b&&(h||(h=co(u,b)))});else{if(u.issues.length===b)continue;h||(h=co(u,b))}}return g?g.then(()=>u):u},c=(u,f,m)=>{if(co(u))return u.aborted=!0,u;const h=i(f,a,m);if(h instanceof Promise){if(m.async===!1)throw new yo;return h.then(g=>e._zod.parse(g,m))}return e._zod.parse(h,m)};e._zod.run=(u,f)=>{if(f.skipChecks)return e._zod.parse(u,f);if(f.direction==="backward"){const h=e._zod.parse({value:u.value,issues:[]},{...f,skipChecks:!0});return h instanceof Promise?h.then(g=>c(g,u,f)):c(h,u,f)}const m=e._zod.parse(u,f);if(m instanceof Promise){if(f.async===!1)throw new yo;return m.then(h=>i(h,a,f))}return i(m,a,f)}}lt(e,"~standard",()=>({validate:i=>{try{const c=f2(e,i);return c.success?{value:c.data}:{issues:c.error?.issues}}catch{return h2(e,i).then(u=>u.success?{value:u.data}:{issues:u.error?.issues})}},vendor:"zod",version:1}))}),Yg=le("$ZodString",(e,t)=>{Dt.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??V2(e._zod.bag),e._zod.parse=(n,a)=>{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)=>{af.init(e,t),Yg.init(e,t)}),l_=le("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=A2),Ut.init(e,t)}),c_=le("$ZodUUID",(e,t)=>{if(t.version){const a={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(a===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=pw(a))}else t.pattern??(t.pattern=pw());Ut.init(e,t)}),u_=le("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=R2),Ut.init(e,t)}),d_=le("$ZodURL",(e,t)=>{Ut.init(e,t),e._zod.check=n=>{try{const a=n.value.trim(),i=new URL(a);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.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(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.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=i.href:n.value=a;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),f_=le("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=_2()),Ut.init(e,t)}),h_=le("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=C2),Ut.init(e,t)}),m_=le("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=S2),Ut.init(e,t)}),p_=le("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=j2),Ut.init(e,t)}),g_=le("$ZodULID",(e,t)=>{t.pattern??(t.pattern=N2),Ut.init(e,t)}),v_=le("$ZodXID",(e,t)=>{t.pattern??(t.pattern=k2),Ut.init(e,t)}),y_=le("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=E2),Ut.init(e,t)}),x_=le("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=B2(t)),Ut.init(e,t)}),b_=le("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=P2),Ut.init(e,t)}),w_=le("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=U2(t)),Ut.init(e,t)}),S_=le("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=T2),Ut.init(e,t)}),j_=le("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=O2),Ut.init(e,t),e._zod.bag.format="ipv4"}),N_=le("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=I2),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})}}}),k_=le("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=D2),Ut.init(e,t)}),E_=le("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=z2),Ut.init(e,t),e._zod.check=n=>{const a=n.value.split("/");try{if(a.length!==2)throw new Error;const[i,c]=a;if(!c)throw new Error;const u=Number(c);if(`${u}`!==c)throw new Error;if(u<0||u>128)throw new Error;new URL(`http://[${i}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function cN(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const C_=le("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=L2),Ut.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{cN(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function T_(e){if(!nN.test(e))return!1;const t=e.replace(/[-_]/g,a=>a==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return cN(n)}const A_=le("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=nN),Ut.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{T_(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),R_=le("$ZodE164",(e,t)=>{t.pattern??(t.pattern=$2),Ut.init(e,t)});function M_(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[a]=n;if(!a)return!1;const i=JSON.parse(atob(a));return!("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}const __=le("$ZodJWT",(e,t)=>{Ut.init(e,t),e._zod.check=n=>{M_(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),uN=le("$ZodNumber",(e,t)=>{Dt.init(e,t),e._zod.pattern=e._zod.bag.pattern??rN,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;const c=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...c?{received:c}:{}}),n}}),O_=le("$ZodNumberFormat",(e,t)=>{W2.init(e,t),uN.init(e,t)}),I_=le("$ZodBoolean",(e,t)=>{Dt.init(e,t),e._zod.pattern=Z2,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=!!n.value}catch{}const i=n.value;return typeof i=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),D_=le("$ZodNull",(e,t)=>{Dt.init(e,t),e._zod.pattern=F2,e._zod.values=new Set([null]),e._zod.parse=(n,a)=>{const i=n.value;return i===null||n.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),n}}),z_=le("$ZodUnknown",(e,t)=>{Dt.init(e,t),e._zod.parse=n=>n}),L_=le("$ZodNever",(e,t)=>{Dt.init(e,t),e._zod.parse=(n,a)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function gw(e,t,n){e.issues.length&&t.issues.push(...uo(n,e.issues)),t.value[n]=e.value}const $_=le("$ZodArray",(e,t)=>{Dt.init(e,t),e._zod.parse=(n,a)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);const c=[];for(let u=0;u<i.length;u++){const f=i[u],m=t.element._zod.run({value:f,issues:[]},a);m instanceof Promise?c.push(m.then(h=>gw(h,n,u))):gw(m,n,u)}return c.length?Promise.all(c).then(()=>n):n}});function jd(e,t,n,a,i){if(e.issues.length){if(i&&!(n in a))return;t.issues.push(...uo(n,e.issues))}e.value===void 0?n in a&&(t.value[n]=void 0):t.value[n]=e.value}function dN(e){const t=Object.keys(e.shape);for(const a of t)if(!e.shape?.[a]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=t2(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function fN(e,t,n,a,i,c){const u=[],f=i.keySet,m=i.catchall._zod,h=m.def.type,g=m.optout==="optional";for(const x in t){if(f.has(x))continue;if(h==="never"){u.push(x);continue}const b=m.run({value:t[x],issues:[]},a);b instanceof Promise?e.push(b.then(w=>jd(w,n,x,t,g))):jd(b,n,x,t,g)}return u.length&&n.issues.push({code:"unrecognized_keys",keys:u,input:t,inst:c}),e.length?Promise.all(e).then(()=>n):n}const P_=le("$ZodObject",(e,t)=>{if(Dt.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const f=t.shape;Object.defineProperty(t,"shape",{get:()=>{const m={...f};return Object.defineProperty(t,"shape",{value:m}),m}})}const a=tf(()=>dN(t));lt(e._zod,"propValues",()=>{const f=t.shape,m={};for(const h in f){const g=f[h]._zod;if(g.values){m[h]??(m[h]=new Set);for(const x of g.values)m[h].add(x)}}return m});const i=Kl,c=t.catchall;let u;e._zod.parse=(f,m)=>{u??(u=a.value);const h=f.value;if(!i(h))return f.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),f;f.value={};const g=[],x=u.shape;for(const b of u.keys){const w=x[b],j=w._zod.optout==="optional",N=w._zod.run({value:h[b],issues:[]},m);N instanceof Promise?g.push(N.then(T=>jd(T,f,b,h,j))):jd(N,f,b,h,j)}return c?fN(g,h,f,m,a.value,e):g.length?Promise.all(g).then(()=>f):f}}),U_=le("$ZodObjectJIT",(e,t)=>{P_.init(e,t);const n=e._zod.parse,a=tf(()=>dN(t)),i=b=>{const w=new i_(["shape","payload","ctx"]),j=a.value,N=S=>{const R=mw(S);return`shape[${R}]._zod.run({ value: input[${R}], issues: [] }, ctx)`};w.write("const input = payload.value;");const T=Object.create(null);let k=0;for(const S of j.keys)T[S]=`key_${k++}`;w.write("const newResult = {};");for(const S of j.keys){const R=T[S],A=mw(S),O=b[S]?._zod?.optout==="optional";w.write(`const ${R} = ${N(S)};`),O?w.write(`
|
|
14
|
+
if (${R}.issues.length) {
|
|
15
|
+
if (${A} in input) {
|
|
16
|
+
payload.issues = payload.issues.concat(${R}.issues.map(iss => ({
|
|
17
|
+
...iss,
|
|
18
|
+
path: iss.path ? [${A}, ...iss.path] : [${A}]
|
|
19
|
+
})));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (${R}.value === undefined) {
|
|
24
|
+
if (${A} in input) {
|
|
25
|
+
newResult[${A}] = undefined;
|
|
26
|
+
}
|
|
27
|
+
} else {
|
|
28
|
+
newResult[${A}] = ${R}.value;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
`):w.write(`
|
|
32
|
+
if (${R}.issues.length) {
|
|
33
|
+
payload.issues = payload.issues.concat(${R}.issues.map(iss => ({
|
|
34
|
+
...iss,
|
|
35
|
+
path: iss.path ? [${A}, ...iss.path] : [${A}]
|
|
36
|
+
})));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (${R}.value === undefined) {
|
|
40
|
+
if (${A} in input) {
|
|
41
|
+
newResult[${A}] = undefined;
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
newResult[${A}] = ${R}.value;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
`)}w.write("payload.value = newResult;"),w.write("return payload;");const C=w.compile();return(S,R)=>C(b,S,R)};let c;const u=Kl,f=!Wj.jitless,h=f&&QM.value,g=t.catchall;let x;e._zod.parse=(b,w)=>{x??(x=a.value);const j=b.value;return u(j)?f&&h&&w?.async===!1&&w.jitless!==!0?(c||(c=i(t.shape)),b=c(b,w),g?fN([],j,b,w,x,e):b):n(b,w):(b.issues.push({expected:"object",code:"invalid_type",input:j,inst:e}),b)}});function vw(e,t,n,a){for(const c of e)if(c.issues.length===0)return t.value=c.value,t;const i=e.filter(c=>!co(c));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(c=>c.issues.map(u=>mr(u,a,hr())))}),t)}const hN=le("$ZodUnion",(e,t)=>{Dt.init(e,t),lt(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),lt(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),lt(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),lt(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){const i=t.options.map(c=>c._zod.pattern);return new RegExp(`^(${i.map(c=>Hg(c.source)).join("|")})$`)}});const n=t.options.length===1,a=t.options[0]._zod.run;e._zod.parse=(i,c)=>{if(n)return a(i,c);let u=!1;const f=[];for(const m of t.options){const h=m._zod.run({value:i.value,issues:[]},c);if(h instanceof Promise)f.push(h),u=!0;else{if(h.issues.length===0)return h;f.push(h)}}return u?Promise.all(f).then(m=>vw(m,i,e,c)):vw(f,i,e,c)}}),B_=le("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,hN.init(e,t);const n=e._zod.parse;lt(e._zod,"propValues",()=>{const i={};for(const c of t.options){const u=c._zod.propValues;if(!u||Object.keys(u).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(c)}"`);for(const[f,m]of Object.entries(u)){i[f]||(i[f]=new Set);for(const h of m)i[f].add(h)}}return i});const a=tf(()=>{const i=t.options,c=new Map;for(const u of i){const f=u._zod.propValues?.[t.discriminator];if(!f||f.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(u)}"`);for(const m of f){if(c.has(m))throw new Error(`Duplicate discriminator value "${String(m)}"`);c.set(m,u)}}return c});e._zod.parse=(i,c)=>{const u=i.value;if(!Kl(u))return i.issues.push({code:"invalid_type",expected:"object",input:u,inst:e}),i;const f=a.value.get(u?.[t.discriminator]);return f?f._zod.run(i,c):t.unionFallback?n(i,c):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:u,path:[t.discriminator],inst:e}),i)}}),V_=le("$ZodIntersection",(e,t)=>{Dt.init(e,t),e._zod.parse=(n,a)=>{const i=n.value,c=t.left._zod.run({value:i,issues:[]},a),u=t.right._zod.run({value:i,issues:[]},a);return c instanceof Promise||u instanceof Promise?Promise.all([c,u]).then(([m,h])=>yw(n,m,h)):yw(n,c,u)}});function Hp(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(No(e)&&No(t)){const n=Object.keys(t),a=Object.keys(e).filter(c=>n.indexOf(c)!==-1),i={...e,...t};for(const c of a){const u=Hp(e[c],t[c]);if(!u.valid)return{valid:!1,mergeErrorPath:[c,...u.mergeErrorPath]};i[c]=u.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let a=0;a<e.length;a++){const i=e[a],c=t[a],u=Hp(i,c);if(!u.valid)return{valid:!1,mergeErrorPath:[a,...u.mergeErrorPath]};n.push(u.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function yw(e,t,n){const a=new Map;let i;for(const f of t.issues)if(f.code==="unrecognized_keys"){i??(i=f);for(const m of f.keys)a.has(m)||a.set(m,{}),a.get(m).l=!0}else e.issues.push(f);for(const f of n.issues)if(f.code==="unrecognized_keys")for(const m of f.keys)a.has(m)||a.set(m,{}),a.get(m).r=!0;else e.issues.push(f);const c=[...a].filter(([,f])=>f.l&&f.r).map(([f])=>f);if(c.length&&i&&e.issues.push({...i,keys:c}),co(e))return e;const u=Hp(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 H_=le("$ZodRecord",(e,t)=>{Dt.init(e,t),e._zod.parse=(n,a)=>{const i=n.value;if(!No(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;const c=[],u=t.keyType._zod.values;if(u){n.value={};const f=new Set;for(const h of u)if(typeof h=="string"||typeof h=="number"||typeof h=="symbol"){f.add(typeof h=="number"?h.toString():h);const g=t.valueType._zod.run({value:i[h],issues:[]},a);g instanceof Promise?c.push(g.then(x=>{x.issues.length&&n.issues.push(...uo(h,x.issues)),n.value[h]=x.value})):(g.issues.length&&n.issues.push(...uo(h,g.issues)),n.value[h]=g.value)}let m;for(const h in i)f.has(h)||(m=m??[],m.push(h));m&&m.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:m})}else{n.value={};for(const f of Reflect.ownKeys(i)){if(f==="__proto__")continue;let m=t.keyType._zod.run({value:f,issues:[]},a);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof f=="string"&&rN.test(f)&&m.issues.length){const x=t.keyType._zod.run({value:Number(f),issues:[]},a);if(x instanceof Promise)throw new Error("Async schemas not supported in object keys currently");x.issues.length===0&&(m=x)}if(m.issues.length){t.mode==="loose"?n.value[f]=i[f]:n.issues.push({code:"invalid_key",origin:"record",issues:m.issues.map(x=>mr(x,a,hr())),input:f,path:[f],inst:e});continue}const g=t.valueType._zod.run({value:i[f],issues:[]},a);g instanceof Promise?c.push(g.then(x=>{x.issues.length&&n.issues.push(...uo(f,x.issues)),n.value[m.value]=x.value})):(g.issues.length&&n.issues.push(...uo(f,g.issues)),n.value[m.value]=g.value)}}return c.length?Promise.all(c).then(()=>n):n}}),Z_=le("$ZodEnum",(e,t)=>{Dt.init(e,t);const n=Xj(t.entries),a=new Set(n);e._zod.values=a,e._zod.pattern=new RegExp(`^(${n.filter(i=>e2.has(typeof i)).map(i=>typeof i=="string"?ko(i):i.toString()).join("|")})$`),e._zod.parse=(i,c)=>{const u=i.value;return a.has(u)||i.issues.push({code:"invalid_value",values:n,input:u,inst:e}),i}}),F_=le("$ZodLiteral",(e,t)=>{if(Dt.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(a=>typeof a=="string"?ko(a):a?ko(a.toString()):String(a)).join("|")})$`),e._zod.parse=(a,i)=>{const c=a.value;return n.has(c)||a.issues.push({code:"invalid_value",values:t.values,input:c,inst:e}),a}}),q_=le("$ZodTransform",(e,t)=>{Dt.init(e,t),e._zod.parse=(n,a)=>{if(a.direction==="backward")throw new Gj(e.constructor.name);const i=t.transform(n.value,n);if(a.async)return(i instanceof Promise?i:Promise.resolve(i)).then(u=>(n.value=u,n));if(i instanceof Promise)throw new yo;return n.value=i,n}});function xw(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const mN=le("$ZodOptional",(e,t)=>{Dt.init(e,t),e._zod.optin="optional",e._zod.optout="optional",lt(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),lt(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Hg(n.source)})?$`):void 0}),e._zod.parse=(n,a)=>{if(t.innerType._zod.optin==="optional"){const i=t.innerType._zod.run(n,a);return i instanceof Promise?i.then(c=>xw(c,n.value)):xw(i,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,a)}}),Y_=le("$ZodExactOptional",(e,t)=>{mN.init(e,t),lt(e._zod,"values",()=>t.innerType._zod.values),lt(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,a)=>t.innerType._zod.run(n,a)}),G_=le("$ZodNullable",(e,t)=>{Dt.init(e,t),lt(e._zod,"optin",()=>t.innerType._zod.optin),lt(e._zod,"optout",()=>t.innerType._zod.optout),lt(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Hg(n.source)}|null)$`):void 0}),lt(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,a)=>n.value===null?n:t.innerType._zod.run(n,a)}),W_=le("$ZodDefault",(e,t)=>{Dt.init(e,t),e._zod.optin="optional",lt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,a)=>{if(a.direction==="backward")return t.innerType._zod.run(n,a);if(n.value===void 0)return n.value=t.defaultValue,n;const i=t.innerType._zod.run(n,a);return i instanceof Promise?i.then(c=>bw(c,t)):bw(i,t)}});function bw(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const X_=le("$ZodPrefault",(e,t)=>{Dt.init(e,t),e._zod.optin="optional",lt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,a)=>(a.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,a))}),K_=le("$ZodNonOptional",(e,t)=>{Dt.init(e,t),lt(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(a=>a!==void 0)):void 0}),e._zod.parse=(n,a)=>{const i=t.innerType._zod.run(n,a);return i instanceof Promise?i.then(c=>ww(c,e)):ww(i,e)}});function ww(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 J_=le("$ZodCatch",(e,t)=>{Dt.init(e,t),lt(e._zod,"optin",()=>t.innerType._zod.optin),lt(e._zod,"optout",()=>t.innerType._zod.optout),lt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,a)=>{if(a.direction==="backward")return t.innerType._zod.run(n,a);const i=t.innerType._zod.run(n,a);return i instanceof Promise?i.then(c=>(n.value=c.value,c.issues.length&&(n.value=t.catchValue({...n,error:{issues:c.issues.map(u=>mr(u,a,hr()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(c=>mr(c,a,hr()))},input:n.value}),n.issues=[]),n)}}),Q_=le("$ZodPipe",(e,t)=>{Dt.init(e,t),lt(e._zod,"values",()=>t.in._zod.values),lt(e._zod,"optin",()=>t.in._zod.optin),lt(e._zod,"optout",()=>t.out._zod.optout),lt(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,a)=>{if(a.direction==="backward"){const c=t.out._zod.run(n,a);return c instanceof Promise?c.then(u=>Du(u,t.in,a)):Du(c,t.in,a)}const i=t.in._zod.run(n,a);return i instanceof Promise?i.then(c=>Du(c,t.out,a)):Du(i,t.out,a)}});function Du(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const eO=le("$ZodReadonly",(e,t)=>{Dt.init(e,t),lt(e._zod,"propValues",()=>t.innerType._zod.propValues),lt(e._zod,"values",()=>t.innerType._zod.values),lt(e._zod,"optin",()=>t.innerType?._zod?.optin),lt(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,a)=>{if(a.direction==="backward")return t.innerType._zod.run(n,a);const i=t.innerType._zod.run(n,a);return i instanceof Promise?i.then(Sw):Sw(i)}});function Sw(e){return e.value=Object.freeze(e.value),e}const tO=le("$ZodLazy",(e,t)=>{Dt.init(e,t),lt(e._zod,"innerType",()=>t.getter()),lt(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),lt(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),lt(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),lt(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(n,a)=>e._zod.innerType._zod.run(n,a)}),nO=le("$ZodCustom",(e,t)=>{Kn.init(e,t),Dt.init(e,t),e._zod.parse=(n,a)=>n,e._zod.check=n=>{const a=n.value,i=t.fn(a);if(i instanceof Promise)return i.then(c=>jw(c,n,a,e));jw(i,n,a,e)}});function jw(e,t,n,a){if(!e){const i={code:"custom",input:n,inst:a,path:[...a._zod.def.path??[]],continue:!a._zod.def.abort};a._zod.def.params&&(i.params=a._zod.def.params),t.issues.push(Jl(i))}}var Nw;class sO{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const a=n[0];return this._map.set(t,a),a&&typeof a=="object"&&"id"in a&&this._idmap.set(a.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 a={...this.get(n)??{}};delete a.id;const i={...a,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function aO(){return new sO}(Nw=globalThis).__zod_globalRegistry??(Nw.__zod_globalRegistry=aO());const _l=globalThis.__zod_globalRegistry;function rO(e,t){return new e({type:"string",...Me(t)})}function iO(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Me(t)})}function kw(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Me(t)})}function oO(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Me(t)})}function lO(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Me(t)})}function cO(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Me(t)})}function uO(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Me(t)})}function dO(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Me(t)})}function fO(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Me(t)})}function hO(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Me(t)})}function mO(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Me(t)})}function pO(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Me(t)})}function gO(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Me(t)})}function vO(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Me(t)})}function yO(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Me(t)})}function xO(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Me(t)})}function bO(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Me(t)})}function wO(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Me(t)})}function SO(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Me(t)})}function jO(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Me(t)})}function NO(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Me(t)})}function kO(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Me(t)})}function EO(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Me(t)})}function CO(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Me(t)})}function TO(e,t){return new e({type:"string",format:"date",check:"string_format",...Me(t)})}function AO(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Me(t)})}function RO(e,t){return new e({type:"string",format:"duration",check:"string_format",...Me(t)})}function MO(e,t){return new e({type:"number",checks:[],...Me(t)})}function _O(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Me(t)})}function OO(e,t){return new e({type:"boolean",...Me(t)})}function IO(e,t){return new e({type:"null",...Me(t)})}function DO(e){return new e({type:"unknown"})}function zO(e,t){return new e({type:"never",...Me(t)})}function Ew(e,t){return new oN({check:"less_than",...Me(t),value:e,inclusive:!1})}function Bm(e,t){return new oN({check:"less_than",...Me(t),value:e,inclusive:!0})}function Cw(e,t){return new lN({check:"greater_than",...Me(t),value:e,inclusive:!1})}function Vm(e,t){return new lN({check:"greater_than",...Me(t),value:e,inclusive:!0})}function Tw(e,t){return new G2({check:"multiple_of",...Me(t),value:e})}function pN(e,t){return new X2({check:"max_length",...Me(t),maximum:e})}function Nd(e,t){return new K2({check:"min_length",...Me(t),minimum:e})}function gN(e,t){return new J2({check:"length_equals",...Me(t),length:e})}function LO(e,t){return new Q2({check:"string_format",format:"regex",...Me(t),pattern:e})}function $O(e){return new e_({check:"string_format",format:"lowercase",...Me(e)})}function PO(e){return new t_({check:"string_format",format:"uppercase",...Me(e)})}function UO(e,t){return new n_({check:"string_format",format:"includes",...Me(t),includes:e})}function BO(e,t){return new s_({check:"string_format",format:"starts_with",...Me(t),prefix:e})}function VO(e,t){return new a_({check:"string_format",format:"ends_with",...Me(t),suffix:e})}function Ro(e){return new r_({check:"overwrite",tx:e})}function HO(e){return Ro(t=>t.normalize(e))}function ZO(){return Ro(e=>e.trim())}function FO(){return Ro(e=>e.toLowerCase())}function qO(){return Ro(e=>e.toUpperCase())}function YO(){return Ro(e=>JM(e))}function GO(e,t,n){return new e({type:"array",element:t,...Me(n)})}function WO(e,t,n){const a=Me(n);return a.abort??(a.abort=!0),new e({type:"custom",check:"custom",fn:t,...a})}function XO(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Me(n)})}function KO(e){const t=JO(n=>(n.addIssue=a=>{if(typeof a=="string")n.issues.push(Jl(a,n.value,t._zod.def));else{const i=a;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),n.issues.push(Jl(i))}},e(n.value,n)));return t}function JO(e,t){const n=new Kn({check:"custom",...Me(t)});return n._zod.check=e,n}function kd(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??_l,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 Tt(e,t,n={path:[],schemaPath:[]}){var a;const i=e._zod.def,c=t.seen.get(e);if(c)return c.count++,n.schemaPath.includes(e)&&(c.cycle=n.path),c.schema;const u={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,u);const f=e._zod.toJSONSchema?.();if(f)u.schema=f;else{const g={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,u.schema,g);else{const b=u.schema,w=t.processors[i.type];if(!w)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);w(e,t,b,g)}const x=e._zod.parent;x&&(u.ref||(u.ref=x),Tt(x,t,g),t.seen.get(x).isParent=!0)}const m=t.metadataRegistry.get(e);return m&&Object.assign(u.schema,m),t.io==="input"&&Dn(e)&&(delete u.schema.examples,delete u.schema.default),t.io==="input"&&u.schema._prefault&&((a=u.schema).default??(a.default=u.schema._prefault)),delete u.schema._prefault,t.seen.get(e).schema}function Ed(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const a=new Map;for(const u of e.seen.entries()){const f=e.metadataRegistry.get(u[0])?.id;if(f){const m=a.get(f);if(m&&m!==u[0])throw new Error(`Duplicate schema id "${f}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);a.set(f,u[0])}}const i=u=>{const f=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const x=e.external.registry.get(u[0])?.id,b=e.external.uri??(j=>j);if(x)return{ref:b(x)};const w=u[1].defId??u[1].schema.id??`schema${e.counter++}`;return u[1].defId=w,{defId:w,ref:`${b("__shared")}#/${f}/${w}`}}if(u[1]===n)return{ref:"#"};const h=`#/${f}/`,g=u[1].schema.id??`__schema${e.counter++}`;return{defId:g,ref:h+g}},c=u=>{if(u[1].schema.$ref)return;const f=u[1],{ref:m,defId:h}=i(u);f.def={...f.schema},h&&(f.defId=h);const g=f.schema;for(const x in g)delete g[x];g.$ref=m};if(e.cycles==="throw")for(const u of e.seen.entries()){const f=u[1];if(f.cycle)throw new Error(`Cycle detected: #/${f.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 f=u[1];if(t===u[0]){c(u);continue}if(e.external){const h=e.external.registry.get(u[0])?.id;if(t!==u[0]&&h){c(u);continue}}if(e.metadataRegistry.get(u[0])?.id){c(u);continue}if(f.cycle){c(u);continue}if(f.count>1&&e.reused==="ref"){c(u);continue}}}function Cd(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const a=u=>{const f=e.seen.get(u);if(f.ref===null)return;const m=f.def??f.schema,h={...m},g=f.ref;if(f.ref=null,g){a(g);const b=e.seen.get(g),w=b.schema;if(w.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(m.allOf=m.allOf??[],m.allOf.push(w)):Object.assign(m,w),Object.assign(m,h),u._zod.parent===g)for(const N in m)N==="$ref"||N==="allOf"||N in h||delete m[N];if(w.$ref&&b.def)for(const N in m)N==="$ref"||N==="allOf"||N in b.def&&JSON.stringify(m[N])===JSON.stringify(b.def[N])&&delete m[N]}const x=u._zod.parent;if(x&&x!==g){a(x);const b=e.seen.get(x);if(b?.schema.$ref&&(m.$ref=b.schema.$ref,b.def))for(const w in m)w==="$ref"||w==="allOf"||w in b.def&&JSON.stringify(m[w])===JSON.stringify(b.def[w])&&delete m[w]}e.override({zodSchema:u,jsonSchema:m,path:f.path??[]})};for(const u of[...e.seen.entries()].reverse())a(u[0]);const i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$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");i.$id=e.external.uri(u)}Object.assign(i,n.def??n.schema);const c=e.external?.defs??{};for(const u of e.seen.entries()){const f=u[1];f.def&&f.defId&&(c[f.defId]=f.def)}e.external||Object.keys(c).length>0&&(e.target==="draft-2020-12"?i.$defs=c:i.definitions=c);try{const u=JSON.parse(JSON.stringify(i));return Object.defineProperty(u,"~standard",{value:{...t["~standard"],jsonSchema:{input:Td(t,"input",e.processors),output:Td(t,"output",e.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function Dn(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const a=e._zod.def;if(a.type==="transform")return!0;if(a.type==="array")return Dn(a.element,n);if(a.type==="set")return Dn(a.valueType,n);if(a.type==="lazy")return Dn(a.getter(),n);if(a.type==="promise"||a.type==="optional"||a.type==="nonoptional"||a.type==="nullable"||a.type==="readonly"||a.type==="default"||a.type==="prefault")return Dn(a.innerType,n);if(a.type==="intersection")return Dn(a.left,n)||Dn(a.right,n);if(a.type==="record"||a.type==="map")return Dn(a.keyType,n)||Dn(a.valueType,n);if(a.type==="pipe")return Dn(a.in,n)||Dn(a.out,n);if(a.type==="object"){for(const i in a.shape)if(Dn(a.shape[i],n))return!0;return!1}if(a.type==="union"){for(const i of a.options)if(Dn(i,n))return!0;return!1}if(a.type==="tuple"){for(const i of a.items)if(Dn(i,n))return!0;return!!(a.rest&&Dn(a.rest,n))}return!1}const QO=(e,t={})=>n=>{const a=kd({...n,processors:t});return Tt(e,a),Ed(a,e),Cd(a,e)},Td=(e,t,n={})=>a=>{const{libraryOptions:i,target:c}=a??{},u=kd({...i??{},target:c,io:t,processors:n});return Tt(e,u),Ed(u,e),Cd(u,e)},eI={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},vN=(e,t,n,a)=>{const i=n;i.type="string";const{minimum:c,maximum:u,format:f,patterns:m,contentEncoding:h}=e._zod.bag;if(typeof c=="number"&&(i.minLength=c),typeof u=="number"&&(i.maxLength=u),f&&(i.format=eI[f]??f,i.format===""&&delete i.format,f==="time"&&delete i.format),h&&(i.contentEncoding=h),m&&m.size>0){const g=[...m];g.length===1?i.pattern=g[0].source:g.length>1&&(i.allOf=[...g.map(x=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:x.source}))])}},yN=(e,t,n,a)=>{const i=n,{minimum:c,maximum:u,format:f,multipleOf:m,exclusiveMaximum:h,exclusiveMinimum:g}=e._zod.bag;typeof f=="string"&&f.includes("int")?i.type="integer":i.type="number",typeof g=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=g,i.exclusiveMinimum=!0):i.exclusiveMinimum=g),typeof c=="number"&&(i.minimum=c,typeof g=="number"&&t.target!=="draft-04"&&(g>=c?delete i.minimum:delete i.exclusiveMinimum)),typeof h=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=h,i.exclusiveMaximum=!0):i.exclusiveMaximum=h),typeof u=="number"&&(i.maximum=u,typeof h=="number"&&t.target!=="draft-04"&&(h<=u?delete i.maximum:delete i.exclusiveMaximum)),typeof m=="number"&&(i.multipleOf=m)},xN=(e,t,n,a)=>{n.type="boolean"},tI=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},nI=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},bN=(e,t,n,a)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},sI=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},aI=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},wN=(e,t,n,a)=>{n.not={}},rI=(e,t,n,a)=>{},SN=(e,t,n,a)=>{},iI=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},jN=(e,t,n,a)=>{const i=e._zod.def,c=Xj(i.entries);c.every(u=>typeof u=="number")&&(n.type="number"),c.every(u=>typeof u=="string")&&(n.type="string"),n.enum=c},NN=(e,t,n,a)=>{const i=e._zod.def,c=[];for(const u of i.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");c.push(Number(u))}else c.push(u);if(c.length!==0)if(c.length===1){const u=c[0];n.type=u===null?"null":typeof u,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[u]:n.const=u}else c.every(u=>typeof u=="number")&&(n.type="number"),c.every(u=>typeof u=="string")&&(n.type="string"),c.every(u=>typeof u=="boolean")&&(n.type="boolean"),c.every(u=>u===null)&&(n.type="null"),n.enum=c},oI=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},lI=(e,t,n,a)=>{const i=n,c=e._zod.pattern;if(!c)throw new Error("Pattern not found in template literal");i.type="string",i.pattern=c.source},cI=(e,t,n,a)=>{const i=n,c={type:"string",format:"binary",contentEncoding:"binary"},{minimum:u,maximum:f,mime:m}=e._zod.bag;u!==void 0&&(c.minLength=u),f!==void 0&&(c.maxLength=f),m?m.length===1?(c.contentMediaType=m[0],Object.assign(i,c)):(Object.assign(i,c),i.anyOf=m.map(h=>({contentMediaType:h}))):Object.assign(i,c)},uI=(e,t,n,a)=>{n.type="boolean"},kN=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},dI=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},EN=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},fI=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},hI=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},CN=(e,t,n,a)=>{const i=n,c=e._zod.def,{minimum:u,maximum:f}=e._zod.bag;typeof u=="number"&&(i.minItems=u),typeof f=="number"&&(i.maxItems=f),i.type="array",i.items=Tt(c.element,t,{...a,path:[...a.path,"items"]})},TN=(e,t,n,a)=>{const i=n,c=e._zod.def;i.type="object",i.properties={};const u=c.shape;for(const h in u)i.properties[h]=Tt(u[h],t,{...a,path:[...a.path,"properties",h]});const f=new Set(Object.keys(u)),m=new Set([...f].filter(h=>{const g=c.shape[h]._zod;return t.io==="input"?g.optin===void 0:g.optout===void 0}));m.size>0&&(i.required=Array.from(m)),c.catchall?._zod.def.type==="never"?i.additionalProperties=!1:c.catchall?c.catchall&&(i.additionalProperties=Tt(c.catchall,t,{...a,path:[...a.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},AN=(e,t,n,a)=>{const i=e._zod.def,c=i.inclusive===!1,u=i.options.map((f,m)=>Tt(f,t,{...a,path:[...a.path,c?"oneOf":"anyOf",m]}));c?n.oneOf=u:n.anyOf=u},RN=(e,t,n,a)=>{const i=e._zod.def,c=Tt(i.left,t,{...a,path:[...a.path,"allOf",0]}),u=Tt(i.right,t,{...a,path:[...a.path,"allOf",1]}),f=h=>"allOf"in h&&Object.keys(h).length===1,m=[...f(c)?c.allOf:[c],...f(u)?u.allOf:[u]];n.allOf=m},mI=(e,t,n,a)=>{const i=n,c=e._zod.def;i.type="array";const u=t.target==="draft-2020-12"?"prefixItems":"items",f=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",m=c.items.map((b,w)=>Tt(b,t,{...a,path:[...a.path,u,w]})),h=c.rest?Tt(c.rest,t,{...a,path:[...a.path,f,...t.target==="openapi-3.0"?[c.items.length]:[]]}):null;t.target==="draft-2020-12"?(i.prefixItems=m,h&&(i.items=h)):t.target==="openapi-3.0"?(i.items={anyOf:m},h&&i.items.anyOf.push(h),i.minItems=m.length,h||(i.maxItems=m.length)):(i.items=m,h&&(i.additionalItems=h));const{minimum:g,maximum:x}=e._zod.bag;typeof g=="number"&&(i.minItems=g),typeof x=="number"&&(i.maxItems=x)},MN=(e,t,n,a)=>{const i=n,c=e._zod.def;i.type="object";const u=c.keyType,m=u._zod.bag?.patterns;if(c.mode==="loose"&&m&&m.size>0){const g=Tt(c.valueType,t,{...a,path:[...a.path,"patternProperties","*"]});i.patternProperties={};for(const x of m)i.patternProperties[x.source]=g}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=Tt(c.keyType,t,{...a,path:[...a.path,"propertyNames"]})),i.additionalProperties=Tt(c.valueType,t,{...a,path:[...a.path,"additionalProperties"]});const h=u._zod.values;if(h){const g=[...h].filter(x=>typeof x=="string"||typeof x=="number");g.length>0&&(i.required=g)}},_N=(e,t,n,a)=>{const i=e._zod.def,c=Tt(i.innerType,t,a),u=t.seen.get(e);t.target==="openapi-3.0"?(u.ref=i.innerType,n.nullable=!0):n.anyOf=[c,{type:"null"}]},ON=(e,t,n,a)=>{const i=e._zod.def;Tt(i.innerType,t,a);const c=t.seen.get(e);c.ref=i.innerType},IN=(e,t,n,a)=>{const i=e._zod.def;Tt(i.innerType,t,a);const c=t.seen.get(e);c.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},DN=(e,t,n,a)=>{const i=e._zod.def;Tt(i.innerType,t,a);const c=t.seen.get(e);c.ref=i.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},zN=(e,t,n,a)=>{const i=e._zod.def;Tt(i.innerType,t,a);const c=t.seen.get(e);c.ref=i.innerType;let u;try{u=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=u},LN=(e,t,n,a)=>{const i=e._zod.def,c=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;Tt(c,t,a);const u=t.seen.get(e);u.ref=c},$N=(e,t,n,a)=>{const i=e._zod.def;Tt(i.innerType,t,a);const c=t.seen.get(e);c.ref=i.innerType,n.readOnly=!0},pI=(e,t,n,a)=>{const i=e._zod.def;Tt(i.innerType,t,a);const c=t.seen.get(e);c.ref=i.innerType},Gg=(e,t,n,a)=>{const i=e._zod.def;Tt(i.innerType,t,a);const c=t.seen.get(e);c.ref=i.innerType},PN=(e,t,n,a)=>{const i=e._zod.innerType;Tt(i,t,a);const c=t.seen.get(e);c.ref=i},Aw={string:vN,number:yN,boolean:xN,bigint:tI,symbol:nI,null:bN,undefined:sI,void:aI,never:wN,any:rI,unknown:SN,date:iI,enum:jN,literal:NN,nan:oI,template_literal:lI,file:cI,success:uI,custom:kN,function:dI,transform:EN,map:fI,set:hI,array:CN,object:TN,union:AN,intersection:RN,tuple:mI,record:MN,nullable:_N,nonoptional:ON,default:IN,prefault:DN,catch:zN,pipe:LN,readonly:$N,promise:pI,optional:Gg,lazy:PN};function gI(e,t){if("_idmap"in e){const a=e,i=kd({...t,processors:Aw}),c={};for(const m of a._idmap.entries()){const[h,g]=m;Tt(g,i)}const u={},f={registry:a,uri:t?.uri,defs:c};i.external=f;for(const m of a._idmap.entries()){const[h,g]=m;Ed(i,g),u[h]=Cd(i,g)}if(Object.keys(c).length>0){const m=i.target==="draft-2020-12"?"$defs":"definitions";u.__shared={[m]:c}}return{schemas:u}}const n=kd({...t,processors:Aw});return Tt(e,n),Ed(n,e),Cd(n,e)}const vI=le("ZodISODateTime",(e,t)=>{x_.init(e,t),Ht.init(e,t)});function yI(e){return CO(vI,e)}const xI=le("ZodISODate",(e,t)=>{b_.init(e,t),Ht.init(e,t)});function bI(e){return TO(xI,e)}const wI=le("ZodISOTime",(e,t)=>{w_.init(e,t),Ht.init(e,t)});function SI(e){return AO(wI,e)}const jI=le("ZodISODuration",(e,t)=>{S_.init(e,t),Ht.init(e,t)});function NI(e){return RO(jI,e)}const kI=(e,t)=>{eN.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>d2(e,n)},flatten:{value:n=>u2(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Vp,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Vp,2)}},isEmpty:{get(){return e.issues.length===0}}})},Cs=le("ZodError",kI,{Parent:Error}),EI=Fg(Cs),CI=qg(Cs),TI=nf(Cs),UN=sf(Cs),AI=m2(Cs),RI=p2(Cs),MI=g2(Cs),_I=v2(Cs),OI=y2(Cs),II=x2(Cs),DI=b2(Cs),zI=w2(Cs),zt=le("ZodType",(e,t)=>(Dt.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Td(e,"input"),output:Td(e,"output")}}),e.toJSONSchema=QO(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(vr(t,{checks:[...t.checks??[],...n.map(a=>typeof a=="function"?{_zod:{check:a,def:{check:"custom"},onattach:[]}}:a)]}),{parent:!0}),e.with=e.check,e.clone=(n,a)=>yr(e,n,a),e.brand=()=>e,e.register=((n,a)=>(n.add(e,a),e)),e.parse=(n,a)=>EI(e,n,a,{callee:e.parse}),e.safeParse=(n,a)=>TI(e,n,a),e.parseAsync=async(n,a)=>CI(e,n,a,{callee:e.parseAsync}),e.safeParseAsync=async(n,a)=>UN(e,n,a),e.spa=e.safeParseAsync,e.encode=(n,a)=>AI(e,n,a),e.decode=(n,a)=>RI(e,n,a),e.encodeAsync=async(n,a)=>MI(e,n,a),e.decodeAsync=async(n,a)=>_I(e,n,a),e.safeEncode=(n,a)=>OI(e,n,a),e.safeDecode=(n,a)=>II(e,n,a),e.safeEncodeAsync=async(n,a)=>DI(e,n,a),e.safeDecodeAsync=async(n,a)=>zI(e,n,a),e.refine=(n,a)=>e.check(_D(n,a)),e.superRefine=n=>e.check(OD(n)),e.overwrite=n=>e.check(Ro(n)),e.optional=()=>_w(e),e.exactOptional=()=>yD(e),e.nullable=()=>Ow(e),e.nullish=()=>_w(Ow(e)),e.nonoptional=n=>ND(e,n),e.array=()=>Mo(e),e.or=n=>Pn([e,n]),e.and=n=>fD(e,n),e.transform=n=>Iw(e,gD(n)),e.default=n=>wD(e,n),e.prefault=n=>jD(e,n),e.catch=n=>ED(e,n),e.pipe=n=>Iw(e,n),e.readonly=()=>AD(e),e.describe=n=>{const a=e.clone();return _l.add(a,{description:n}),a},Object.defineProperty(e,"description",{get(){return _l.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return _l.get(e);const a=e.clone();return _l.add(a,n[0]),a},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),BN=le("_ZodString",(e,t)=>{Yg.init(e,t),zt.init(e,t),e._zod.processJSONSchema=(a,i,c)=>vN(e,a,i);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...a)=>e.check(LO(...a)),e.includes=(...a)=>e.check(UO(...a)),e.startsWith=(...a)=>e.check(BO(...a)),e.endsWith=(...a)=>e.check(VO(...a)),e.min=(...a)=>e.check(Nd(...a)),e.max=(...a)=>e.check(pN(...a)),e.length=(...a)=>e.check(gN(...a)),e.nonempty=(...a)=>e.check(Nd(1,...a)),e.lowercase=a=>e.check($O(a)),e.uppercase=a=>e.check(PO(a)),e.trim=()=>e.check(ZO()),e.normalize=(...a)=>e.check(HO(...a)),e.toLowerCase=()=>e.check(FO()),e.toUpperCase=()=>e.check(qO()),e.slugify=()=>e.check(YO())}),LI=le("ZodString",(e,t)=>{Yg.init(e,t),BN.init(e,t),e.email=n=>e.check(iO($I,n)),e.url=n=>e.check(dO(PI,n)),e.jwt=n=>e.check(EO(eD,n)),e.emoji=n=>e.check(fO(UI,n)),e.guid=n=>e.check(kw(Rw,n)),e.uuid=n=>e.check(oO(zu,n)),e.uuidv4=n=>e.check(lO(zu,n)),e.uuidv6=n=>e.check(cO(zu,n)),e.uuidv7=n=>e.check(uO(zu,n)),e.nanoid=n=>e.check(hO(BI,n)),e.guid=n=>e.check(kw(Rw,n)),e.cuid=n=>e.check(mO(VI,n)),e.cuid2=n=>e.check(pO(HI,n)),e.ulid=n=>e.check(gO(ZI,n)),e.base64=n=>e.check(jO(KI,n)),e.base64url=n=>e.check(NO(JI,n)),e.xid=n=>e.check(vO(FI,n)),e.ksuid=n=>e.check(yO(qI,n)),e.ipv4=n=>e.check(xO(YI,n)),e.ipv6=n=>e.check(bO(GI,n)),e.cidrv4=n=>e.check(wO(WI,n)),e.cidrv6=n=>e.check(SO(XI,n)),e.e164=n=>e.check(kO(QI,n)),e.datetime=n=>e.check(yI(n)),e.date=n=>e.check(bI(n)),e.time=n=>e.check(SI(n)),e.duration=n=>e.check(NI(n))});function Se(e){return rO(LI,e)}const Ht=le("ZodStringFormat",(e,t)=>{Ut.init(e,t),BN.init(e,t)}),$I=le("ZodEmail",(e,t)=>{u_.init(e,t),Ht.init(e,t)}),Rw=le("ZodGUID",(e,t)=>{l_.init(e,t),Ht.init(e,t)}),zu=le("ZodUUID",(e,t)=>{c_.init(e,t),Ht.init(e,t)}),PI=le("ZodURL",(e,t)=>{d_.init(e,t),Ht.init(e,t)}),UI=le("ZodEmoji",(e,t)=>{f_.init(e,t),Ht.init(e,t)}),BI=le("ZodNanoID",(e,t)=>{h_.init(e,t),Ht.init(e,t)}),VI=le("ZodCUID",(e,t)=>{m_.init(e,t),Ht.init(e,t)}),HI=le("ZodCUID2",(e,t)=>{p_.init(e,t),Ht.init(e,t)}),ZI=le("ZodULID",(e,t)=>{g_.init(e,t),Ht.init(e,t)}),FI=le("ZodXID",(e,t)=>{v_.init(e,t),Ht.init(e,t)}),qI=le("ZodKSUID",(e,t)=>{y_.init(e,t),Ht.init(e,t)}),YI=le("ZodIPv4",(e,t)=>{j_.init(e,t),Ht.init(e,t)}),GI=le("ZodIPv6",(e,t)=>{N_.init(e,t),Ht.init(e,t)}),WI=le("ZodCIDRv4",(e,t)=>{k_.init(e,t),Ht.init(e,t)}),XI=le("ZodCIDRv6",(e,t)=>{E_.init(e,t),Ht.init(e,t)}),KI=le("ZodBase64",(e,t)=>{C_.init(e,t),Ht.init(e,t)}),JI=le("ZodBase64URL",(e,t)=>{A_.init(e,t),Ht.init(e,t)}),QI=le("ZodE164",(e,t)=>{R_.init(e,t),Ht.init(e,t)}),eD=le("ZodJWT",(e,t)=>{__.init(e,t),Ht.init(e,t)}),VN=le("ZodNumber",(e,t)=>{uN.init(e,t),zt.init(e,t),e._zod.processJSONSchema=(a,i,c)=>yN(e,a,i),e.gt=(a,i)=>e.check(Cw(a,i)),e.gte=(a,i)=>e.check(Vm(a,i)),e.min=(a,i)=>e.check(Vm(a,i)),e.lt=(a,i)=>e.check(Ew(a,i)),e.lte=(a,i)=>e.check(Bm(a,i)),e.max=(a,i)=>e.check(Bm(a,i)),e.int=a=>e.check(Mw(a)),e.safe=a=>e.check(Mw(a)),e.positive=a=>e.check(Cw(0,a)),e.nonnegative=a=>e.check(Vm(0,a)),e.negative=a=>e.check(Ew(0,a)),e.nonpositive=a=>e.check(Bm(0,a)),e.multipleOf=(a,i)=>e.check(Tw(a,i)),e.step=(a,i)=>e.check(Tw(a,i)),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 tD(e){return MO(VN,e)}const nD=le("ZodNumberFormat",(e,t)=>{O_.init(e,t),VN.init(e,t)});function Mw(e){return _O(nD,e)}const sD=le("ZodBoolean",(e,t)=>{I_.init(e,t),zt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>xN(e,n,a)});function zn(e){return OO(sD,e)}const aD=le("ZodNull",(e,t)=>{D_.init(e,t),zt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>bN(e,n,a)});function rD(e){return IO(aD,e)}const iD=le("ZodUnknown",(e,t)=>{z_.init(e,t),zt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>SN()});function Gs(){return DO(iD)}const oD=le("ZodNever",(e,t)=>{L_.init(e,t),zt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>wN(e,n,a)});function HN(e){return zO(oD,e)}const lD=le("ZodArray",(e,t)=>{$_.init(e,t),zt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>CN(e,n,a,i),e.element=t.element,e.min=(n,a)=>e.check(Nd(n,a)),e.nonempty=n=>e.check(Nd(1,n)),e.max=(n,a)=>e.check(pN(n,a)),e.length=(n,a)=>e.check(gN(n,a)),e.unwrap=()=>e.element});function Mo(e,t){return GO(lD,e,t)}const ZN=le("ZodObject",(e,t)=>{U_.init(e,t),zt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>TN(e,n,a,i),lt(e,"shape",()=>t.shape),e.keyof=()=>qN(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Gs()}),e.loose=()=>e.clone({...e._zod.def,catchall:Gs()}),e.strict=()=>e.clone({...e._zod.def,catchall:HN()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>r2(e,n),e.safeExtend=n=>i2(e,n),e.merge=n=>o2(e,n),e.pick=n=>s2(e,n),e.omit=n=>a2(e,n),e.partial=(...n)=>l2(YN,e,n[0]),e.required=(...n)=>c2(GN,e,n[0])});function Nt(e,t){const n={type:"object",shape:e??{},...Me(t)};return new ZN(n)}function Mt(e,t){return new ZN({type:"object",shape:e,catchall:HN(),...Me(t)})}const FN=le("ZodUnion",(e,t)=>{hN.init(e,t),zt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>AN(e,n,a,i),e.options=t.options});function Pn(e,t){return new FN({type:"union",options:e,...Me(t)})}const cD=le("ZodDiscriminatedUnion",(e,t)=>{FN.init(e,t),B_.init(e,t)});function uD(e,t,n){return new cD({type:"union",options:t,discriminator:e,...Me(n)})}const dD=le("ZodIntersection",(e,t)=>{V_.init(e,t),zt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>RN(e,n,a,i)});function fD(e,t){return new dD({type:"intersection",left:e,right:t})}const hD=le("ZodRecord",(e,t)=>{H_.init(e,t),zt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>MN(e,n,a,i),e.keyType=t.keyType,e.valueType=t.valueType});function Ql(e,t,n){return new hD({type:"record",keyType:e,valueType:t,...Me(n)})}const Zp=le("ZodEnum",(e,t)=>{Z_.init(e,t),zt.init(e,t),e._zod.processJSONSchema=(a,i,c)=>jN(e,a,i),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(a,i)=>{const c={};for(const u of a)if(n.has(u))c[u]=t.entries[u];else throw new Error(`Key ${u} not found in enum`);return new Zp({...t,checks:[],...Me(i),entries:c})},e.exclude=(a,i)=>{const c={...t.entries};for(const u of a)if(n.has(u))delete c[u];else throw new Error(`Key ${u} not found in enum`);return new Zp({...t,checks:[],...Me(i),entries:c})}});function qN(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(a=>[a,a])):e;return new Zp({type:"enum",entries:n,...Me(t)})}const mD=le("ZodLiteral",(e,t)=>{F_.init(e,t),zt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>NN(e,n,a),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 $e(e,t){return new mD({type:"literal",values:Array.isArray(e)?e:[e],...Me(t)})}const pD=le("ZodTransform",(e,t)=>{q_.init(e,t),zt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>EN(e,n),e._zod.parse=(n,a)=>{if(a.direction==="backward")throw new Gj(e.constructor.name);n.addIssue=c=>{if(typeof c=="string")n.issues.push(Jl(c,n.value,t));else{const u=c;u.fatal&&(u.continue=!1),u.code??(u.code="custom"),u.input??(u.input=n.value),u.inst??(u.inst=e),n.issues.push(Jl(u))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(c=>(n.value=c,n)):(n.value=i,n)}});function gD(e){return new pD({type:"transform",transform:e})}const YN=le("ZodOptional",(e,t)=>{mN.init(e,t),zt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Gg(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function _w(e){return new YN({type:"optional",innerType:e})}const vD=le("ZodExactOptional",(e,t)=>{Y_.init(e,t),zt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Gg(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function yD(e){return new vD({type:"optional",innerType:e})}const xD=le("ZodNullable",(e,t)=>{G_.init(e,t),zt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>_N(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function Ow(e){return new xD({type:"nullable",innerType:e})}const bD=le("ZodDefault",(e,t)=>{W_.init(e,t),zt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>IN(e,n,a,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function wD(e,t){return new bD({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Jj(t)}})}const SD=le("ZodPrefault",(e,t)=>{X_.init(e,t),zt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>DN(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function jD(e,t){return new SD({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Jj(t)}})}const GN=le("ZodNonOptional",(e,t)=>{K_.init(e,t),zt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>ON(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function ND(e,t){return new GN({type:"nonoptional",innerType:e,...Me(t)})}const kD=le("ZodCatch",(e,t)=>{J_.init(e,t),zt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>zN(e,n,a,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ED(e,t){return new kD({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const CD=le("ZodPipe",(e,t)=>{Q_.init(e,t),zt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>LN(e,n,a,i),e.in=t.in,e.out=t.out});function Iw(e,t){return new CD({type:"pipe",in:e,out:t})}const TD=le("ZodReadonly",(e,t)=>{eO.init(e,t),zt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>$N(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function AD(e){return new TD({type:"readonly",innerType:e})}const RD=le("ZodLazy",(e,t)=>{tO.init(e,t),zt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>PN(e,n,a,i),e.unwrap=()=>e._zod.def.getter()});function MD(e){return new RD({type:"lazy",getter:e})}const Wg=le("ZodCustom",(e,t)=>{nO.init(e,t),zt.init(e,t),e._zod.processJSONSchema=(n,a,i)=>kN(e,n)});function WN(e,t){return WO(Wg,e??(()=>!0),t)}function _D(e,t={}){return XO(Wg,e,t)}function OD(e){return KO(e)}function Ad(e,t={}){const n=new Wg({type:"custom",check:"custom",fn:a=>a instanceof e,abort:!0,...Me(t)});return n._zod.bag.Class=e,n._zod.check=a=>{a.value instanceof e||a.issues.push({code:"invalid_type",expected:e.name,input:a.value,inst:n,path:[...n._zod.def.path??[]]})},n}var ec;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function n(i){throw new Error}e.assertNever=n,e.arrayToEnum=i=>{const c={};for(const u of i)c[u]=u;return c},e.getValidEnumValues=i=>{const c=e.objectKeys(i).filter(f=>typeof i[i[f]]!="number"),u={};for(const f of c)u[f]=i[f];return e.objectValues(u)},e.objectValues=i=>e.objectKeys(i).map(function(c){return i[c]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const c=[];for(const u in i)Object.prototype.hasOwnProperty.call(i,u)&&c.push(u);return c},e.find=(i,c)=>{for(const u of i)if(c(u))return u},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function a(i,c=" | "){return i.map(u=>typeof u=="string"?`'${u}'`:u).join(c)}e.joinValues=a,e.jsonStringifyReplacer=(i,c)=>typeof c=="bigint"?c.toString():c})(ec||(ec={}));var Dw;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(Dw||(Dw={}));ec.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);ec.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 Rd extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};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(c){return c.message},a={_errors:[]},i=c=>{for(const u of c.issues)if(u.code==="invalid_union")u.unionErrors.map(i);else if(u.code==="invalid_return_type")i(u.returnTypeError);else if(u.code==="invalid_arguments")i(u.argumentsError);else if(u.path.length===0)a._errors.push(n(u));else{let f=a,m=0;for(;m<u.path.length;){const h=u.path[m];m===u.path.length-1?(f[h]=f[h]||{_errors:[]},f[h]._errors.push(n(u))):f[h]=f[h]||{_errors:[]},f=f[h],m++}}};return i(this),a}static assert(t){if(!(t instanceof Rd))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ec.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n=Object.create(null),a=[];for(const i of this.issues)if(i.path.length>0){const c=i.path[0];n[c]=n[c]||[],n[c].push(t(i))}else a.push(t(i));return{formErrors:a,fieldErrors:n}}get formErrors(){return this.flatten()}}Rd.create=e=>new Rd(e);var zw;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(zw||(zw={}));var We;(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"})(We||(We={}));class Lw 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 $w=10,ID=13,Vr=32;function Hm(e){}function DD(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=Hm,onError:n=Hm,onRetry:a=Hm,onComment:i}=e;let c="",u=!0,f,m="",h=0,g;function x(C){if(u){u=!1,b(C);return}const S=c===""?C:c+C;c=w(S)}function b(C){C.charCodeAt(0)===239&&C.charCodeAt(1)===187&&C.charCodeAt(2)===191&&(C=C.slice(3));const S=c===""?C:c+C;c=w(S)}function w(C){let S=0;if(C.indexOf("\r")===-1){let R=C.indexOf(`
|
|
50
|
+
`,S);for(;R!==-1;){if(S===R){h>0&&t({id:f,event:g,data:m}),f=void 0,m="",h=0,g=void 0,S=R+1,R=C.indexOf(`
|
|
51
|
+
`,S);continue}const A=C.charCodeAt(S);if(Pw(C,S,A)){const _=C.charCodeAt(S+5)===Vr?S+6:S+5,O=C.slice(_,R);if(h===0&&C.charCodeAt(R+1)===$w){t({id:f,event:g,data:O}),f=void 0,m="",g=void 0,S=R+2,R=C.indexOf(`
|
|
52
|
+
`,S);continue}m=h===0?O:`${m}
|
|
53
|
+
${O}`,h++}else Uw(C,S,A)?g=C.slice(C.charCodeAt(S+6)===Vr?S+7:S+6,R)||void 0:j(C,S,R);S=R+1,R=C.indexOf(`
|
|
54
|
+
`,S)}return C.slice(S)}for(;S<C.length;){const R=C.indexOf("\r",S),A=C.indexOf(`
|
|
55
|
+
`,S);let _=-1;if(R!==-1&&A!==-1?_=R<A?R:A:R!==-1?R===C.length-1?_=-1:_=R:A!==-1&&(_=A),_===-1)break;j(C,S,_),S=_+1,C.charCodeAt(S-1)===ID&&C.charCodeAt(S)===$w&&S++}return C.slice(S)}function j(C,S,R){if(S===R){T();return}const A=C.charCodeAt(S);if(Pw(C,S,A)){const $=C.charCodeAt(S+5)===Vr?S+6:S+5,L=C.slice($,R);m=h===0?L:`${m}
|
|
56
|
+
${L}`,h++;return}if(Uw(C,S,A)){g=C.slice(C.charCodeAt(S+6)===Vr?S+7:S+6,R)||void 0;return}if(A===105&&C.charCodeAt(S+1)===100&&C.charCodeAt(S+2)===58){const $=C.slice(C.charCodeAt(S+3)===Vr?S+4:S+3,R);f=$.includes("\0")?void 0:$;return}if(A===58){if(i){const $=C.slice(S,R);i($.slice(C.charCodeAt(S+1)===Vr?2:1))}return}const _=C.slice(S,R),O=_.indexOf(":");if(O===-1){N(_,"",_);return}const V=_.slice(0,O),Z=_.charCodeAt(O+1)===Vr?2:1,I=_.slice(O+Z);N(V,I,_)}function N(C,S,R){switch(C){case"event":g=S||void 0;break;case"data":m=h===0?S:`${m}
|
|
57
|
+
${S}`,h++;break;case"id":f=S.includes("\0")?void 0:S;break;case"retry":/^\d+$/.test(S)?a(parseInt(S,10)):n(new Lw(`Invalid \`retry\` value: "${S}"`,{type:"invalid-retry",value:S,line:R}));break;default:n(new Lw(`Unknown field "${C.length>20?`${C.slice(0,20)}…`:C}"`,{type:"unknown-field",field:C,value:S,line:R}));break}}function T(){h>0&&t({id:f,event:g,data:m}),f=void 0,m="",h=0,g=void 0}function k(C={}){c&&C.consume&&j(c,0,c.length),u=!0,f=void 0,m="",h=0,g=void 0,c=""}return{feed:x,reset:k}}function Pw(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 Uw(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 zD extends TransformStream{constructor({onError:t,onRetry:n,onComment:a}={}){let i;super({start(c){i=DD({onEvent:u=>{c.enqueue(u)},onError(u){t==="terminate"?c.error(u):typeof t=="function"&&t(u)},onRetry:n,onComment:a})},transform(c){i.feed(c)}})}}var fc=({prefix:e,size:t=16,alphabet:n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:a="-"}={})=>{const i=()=>{const c=n.length,u=new Array(t);for(let f=0;f<t;f++)u[f]=n[Math.random()*c|0];return u.join("")};if(e==null)return i;if(n.includes(a))throw new GM({argument:"separator",message:`The separator "${a}" must not be part of the alphabet "${n}".`});return()=>`${e}${a}${i()}`},LD=fc();function Wi(e){if(e==null)return{};const t={};if(e instanceof Headers)e.forEach((n,a)=>{t[a.toLowerCase()]=n});else{Array.isArray(e)||(e=Object.entries(e));for(const[n,a]of e)a!=null&&(t[n.toLowerCase()]=a)}return t}var $D=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,PD=/"(?: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 Bw(e){const t=JSON.parse(e);return t===null||typeof t!="object"||$D.test(e)===!1&&PD.test(e)===!1?t:UD(t)}function UD(e){let t=[e];for(;t.length;){const n=t;t=[];for(const a of n){if(Object.prototype.hasOwnProperty.call(a,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(a,"constructor")&&a.constructor!==null&&typeof a.constructor=="object"&&Object.prototype.hasOwnProperty.call(a.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const i in a){const c=a[i];c&&typeof c=="object"&&t.push(c)}}}return e}function BD(e){const{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return Bw(e)}try{return Bw(e)}finally{Error.stackTraceLimit=t}}function Xg(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 a of Object.keys(n))n[a]=Hr(n[a])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(Hr):Hr(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(Hr)),e.allOf!=null&&(e.allOf=e.allOf.map(Hr)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(Hr));const{definitions:t}=e;if(t!=null)for(const n of Object.keys(t))t[n]=Hr(t[n]);return e}function Hr(e){return typeof e=="boolean"?e:Xg(e)}var VD=Symbol("Let zodToJsonSchema decide on which parser to use"),Vw={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"},HD=e=>typeof e=="string"?{...Vw,name:e}:{...Vw,...e};function ls(){return{}}function ZD(e,t){var n,a,i;const c={type:"array"};return(n=e.type)!=null&&n._def&&((i=(a=e.type)==null?void 0:a._def)==null?void 0:i.typeName)!==We.ZodAny&&(c.items=yt(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&(c.minItems=e.minLength.value),e.maxLength&&(c.maxItems=e.maxLength.value),e.exactLength&&(c.minItems=e.exactLength.value,c.maxItems=e.exactLength.value),c}function FD(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 qD(){return{type:"boolean"}}function XN(e,t){return yt(e.type._def,t)}var YD=(e,t)=>yt(e.innerType._def,t);function KN(e,t,n){const a=n??t.dateStrategy;if(Array.isArray(a))return{anyOf:a.map((i,c)=>KN(e,t,i))};switch(a){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return GD(e)}}var GD=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 WD(e,t){return{...yt(e.innerType._def,t),default:e.defaultValue()}}function XD(e,t){return t.effectStrategy==="input"?yt(e.schema._def,t):ls()}function KD(e){return{type:"string",enum:Array.from(e.values)}}var JD=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function QD(e,t){const n=[yt(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),yt(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(i=>!!i),a=[];return n.forEach(i=>{if(JD(i))a.push(...i.allOf);else{let c=i;if("additionalProperties"in i&&i.additionalProperties===!1){const{additionalProperties:u,...f}=i;c=f}a.push(c)}}),a.length?{allOf:a}:void 0}function e5(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,Os={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 JN(e,t){const n={type:"string"};if(e.checks)for(const a of e.checks)switch(a.kind){case"min":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,a.value):a.value;break;case"max":n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,a.value):a.value;break;case"email":switch(t.emailStrategy){case"format:email":Is(n,"email",a.message,t);break;case"format:idn-email":Is(n,"idn-email",a.message,t);break;case"pattern:zod":In(n,Os.email,a.message,t);break}break;case"url":Is(n,"uri",a.message,t);break;case"uuid":Is(n,"uuid",a.message,t);break;case"regex":In(n,a.regex,a.message,t);break;case"cuid":In(n,Os.cuid,a.message,t);break;case"cuid2":In(n,Os.cuid2,a.message,t);break;case"startsWith":In(n,RegExp(`^${Fm(a.value,t)}`),a.message,t);break;case"endsWith":In(n,RegExp(`${Fm(a.value,t)}$`),a.message,t);break;case"datetime":Is(n,"date-time",a.message,t);break;case"date":Is(n,"date",a.message,t);break;case"time":Is(n,"time",a.message,t);break;case"duration":Is(n,"duration",a.message,t);break;case"length":n.minLength=typeof n.minLength=="number"?Math.max(n.minLength,a.value):a.value,n.maxLength=typeof n.maxLength=="number"?Math.min(n.maxLength,a.value):a.value;break;case"includes":{In(n,RegExp(Fm(a.value,t)),a.message,t);break}case"ip":{a.version!=="v6"&&Is(n,"ipv4",a.message,t),a.version!=="v4"&&Is(n,"ipv6",a.message,t);break}case"base64url":In(n,Os.base64url,a.message,t);break;case"jwt":In(n,Os.jwt,a.message,t);break;case"cidr":{a.version!=="v6"&&In(n,Os.ipv4Cidr,a.message,t),a.version!=="v4"&&In(n,Os.ipv6Cidr,a.message,t);break}case"emoji":In(n,Os.emoji(),a.message,t);break;case"ulid":{In(n,Os.ulid,a.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{Is(n,"binary",a.message,t);break}case"contentEncoding:base64":{n.contentEncoding="base64";break}case"pattern:zod":{In(n,Os.base64,a.message,t);break}}break}case"nanoid":In(n,Os.nanoid,a.message,t)}return n}function Fm(e,t){return t.patternStrategy==="escape"?n5(e):e}var t5=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function n5(e){let t="";for(let n=0;n<e.length;n++)t5.has(e[n])||(t+="\\"),t+=e[n];return t}function Is(e,t,n,a){var i;e.format||(i=e.anyOf)!=null&&i.some(c=>c.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...n&&a.errorMessages&&{errorMessage:{format:n}}})):e.format=t}function In(e,t,n,a){var i;e.pattern||(i=e.allOf)!=null&&i.some(c=>c.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:Hw(t,a),...n&&a.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=Hw(t,a)}function Hw(e,t){var n;if(!t.applyRegexFlags||!e.flags)return e.source;const a={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},i=a.i?e.source.toLowerCase():e.source;let c="",u=!1,f=!1,m=!1;for(let h=0;h<i.length;h++){if(u){c+=i[h],u=!1;continue}if(a.i){if(f){if(i[h].match(/[a-z]/)){m?(c+=i[h],c+=`${i[h-2]}-${i[h]}`.toUpperCase(),m=!1):i[h+1]==="-"&&((n=i[h+2])!=null&&n.match(/[a-z]/))?(c+=i[h],m=!0):c+=`${i[h]}${i[h].toUpperCase()}`;continue}}else if(i[h].match(/[a-z]/)){c+=`[${i[h]}${i[h].toUpperCase()}]`;continue}}if(a.m){if(i[h]==="^"){c+=`(^|(?<=[\r
|
|
58
|
+
]))`;continue}else if(i[h]==="$"){c+=`($|(?=[\r
|
|
59
|
+
]))`;continue}}if(a.s&&i[h]==="."){c+=f?`${i[h]}\r
|
|
60
|
+
`:`[${i[h]}\r
|
|
61
|
+
]`;continue}c+=i[h],i[h]==="\\"?u=!0:f&&i[h]==="]"?f=!1:!f&&i[h]==="["&&(f=!0)}try{new RegExp(c)}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 c}function QN(e,t){var n,a,i,c,u,f;const m={type:"object",additionalProperties:(n=yt(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?n:t.allowedAdditionalProperties};if(((a=e.keyType)==null?void 0:a._def.typeName)===We.ZodString&&((i=e.keyType._def.checks)!=null&&i.length)){const{type:h,...g}=JN(e.keyType._def,t);return{...m,propertyNames:g}}else{if(((c=e.keyType)==null?void 0:c._def.typeName)===We.ZodEnum)return{...m,propertyNames:{enum:e.keyType._def.values}};if(((u=e.keyType)==null?void 0:u._def.typeName)===We.ZodBranded&&e.keyType._def.type._def.typeName===We.ZodString&&((f=e.keyType._def.type._def.checks)!=null&&f.length)){const{type:h,...g}=XN(e.keyType._def,t);return{...m,propertyNames:g}}}return m}function s5(e,t){if(t.mapStrategy==="record")return QN(e,t);const n=yt(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||ls(),a=yt(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||ls();return{type:"array",maxItems:125,items:{type:"array",items:[n,a],minItems:2,maxItems:2}}}function a5(e){const t=e.values,a=Object.keys(e.values).filter(c=>typeof t[t[c]]!="number").map(c=>t[c]),i=Array.from(new Set(a.map(c=>typeof c)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:a}}function r5(){return{not:ls()}}function i5(){return{type:"null"}}var Fp={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function o5(e,t){const n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(a=>a._def.typeName in Fp&&(!a._def.checks||!a._def.checks.length))){const a=n.reduce((i,c)=>{const u=Fp[c._def.typeName];return u&&!i.includes(u)?[...i,u]:i},[]);return{type:a.length>1?a:a[0]}}else if(n.every(a=>a._def.typeName==="ZodLiteral"&&!a.description)){const a=n.reduce((i,c)=>{const u=typeof c._def.value;switch(u){case"string":case"number":case"boolean":return[...i,u];case"bigint":return[...i,"integer"];case"object":if(c._def.value===null)return[...i,"null"];default:return i}},[]);if(a.length===n.length){const i=a.filter((c,u,f)=>f.indexOf(c)===u);return{type:i.length>1?i:i[0],enum:n.reduce((c,u)=>c.includes(u._def.value)?c:[...c,u._def.value],[])}}}else if(n.every(a=>a._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((a,i)=>[...a,...i._def.values.filter(c=>!a.includes(c))],[])};return l5(e,t)}var l5=(e,t)=>{const n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((a,i)=>yt(a._def,{...t,currentPath:[...t.currentPath,"anyOf",`${i}`]})).filter(a=>!!a&&(!t.strictUnions||typeof a=="object"&&Object.keys(a).length>0));return n.length?{anyOf:n}:void 0};function c5(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[Fp[e.innerType._def.typeName],"null"]};const n=yt(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function u5(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 d5(e,t){const n={type:"object",properties:{}},a=[],i=e.shape();for(const u in i){let f=i[u];if(f===void 0||f._def===void 0)continue;const m=h5(f),h=yt(f._def,{...t,currentPath:[...t.currentPath,"properties",u],propertyPath:[...t.currentPath,"properties",u]});h!==void 0&&(n.properties[u]=h,m||a.push(u))}a.length&&(n.required=a);const c=f5(e,t);return c!==void 0&&(n.additionalProperties=c),n}function f5(e,t){if(e.catchall._def.typeName!=="ZodNever")return yt(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 h5(e){try{return e.isOptional()}catch{return!0}}var m5=(e,t)=>{var n;if(t.currentPath.toString()===((n=t.propertyPath)==null?void 0:n.toString()))return yt(e.innerType._def,t);const a=yt(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return a?{anyOf:[{not:ls()},a]}:ls()},p5=(e,t)=>{if(t.pipeStrategy==="input")return yt(e.in._def,t);if(t.pipeStrategy==="output")return yt(e.out._def,t);const n=yt(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),a=yt(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,a].filter(i=>i!==void 0)}};function g5(e,t){return yt(e.type._def,t)}function v5(e,t){const a={type:"array",uniqueItems:!0,items:yt(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&(a.minItems=e.minSize.value),e.maxSize&&(a.maxItems=e.maxSize.value),a}function y5(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((n,a)=>yt(n._def,{...t,currentPath:[...t.currentPath,"items",`${a}`]})).reduce((n,a)=>a===void 0?n:[...n,a],[]),additionalItems:yt(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((n,a)=>yt(n._def,{...t,currentPath:[...t.currentPath,"items",`${a}`]})).reduce((n,a)=>a===void 0?n:[...n,a],[])}}function x5(){return{not:ls()}}function b5(){return ls()}var w5=(e,t)=>yt(e.innerType._def,t),S5=(e,t,n)=>{switch(t){case We.ZodString:return JN(e,n);case We.ZodNumber:return u5(e);case We.ZodObject:return d5(e,n);case We.ZodBigInt:return FD(e);case We.ZodBoolean:return qD();case We.ZodDate:return KN(e,n);case We.ZodUndefined:return x5();case We.ZodNull:return i5();case We.ZodArray:return ZD(e,n);case We.ZodUnion:case We.ZodDiscriminatedUnion:return o5(e,n);case We.ZodIntersection:return QD(e,n);case We.ZodTuple:return y5(e,n);case We.ZodRecord:return QN(e,n);case We.ZodLiteral:return e5(e);case We.ZodEnum:return KD(e);case We.ZodNativeEnum:return a5(e);case We.ZodNullable:return c5(e,n);case We.ZodOptional:return m5(e,n);case We.ZodMap:return s5(e,n);case We.ZodSet:return v5(e,n);case We.ZodLazy:return()=>e.getter()._def;case We.ZodPromise:return g5(e,n);case We.ZodNaN:case We.ZodNever:return r5();case We.ZodEffects:return XD(e,n);case We.ZodAny:return ls();case We.ZodUnknown:return b5();case We.ZodDefault:return WD(e,n);case We.ZodBranded:return XN(e,n);case We.ZodReadonly:return w5(e,n);case We.ZodCatch:return YD(e,n);case We.ZodPipeline:return p5(e,n);case We.ZodFunction:case We.ZodVoid:case We.ZodSymbol:return;default:return(a=>{})()}},j5=(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 yt(e,t,n=!1){var a;const i=t.seen.get(e);if(t.override){const m=(a=t.override)==null?void 0:a.call(t,e,t,i,n);if(m!==VD)return m}if(i&&!n){const m=N5(i,t);if(m!==void 0)return m}const c={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,c);const u=S5(e,e.typeName,t),f=typeof u=="function"?yt(u(),t):u;if(f&&k5(e,t,f),t.postProcess){const m=t.postProcess(f,e,t);return c.jsonSchema=f,m}return c.jsonSchema=f,f}var N5=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:j5(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((n,a)=>t.currentPath[a]===n)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),ls()):t.$refStrategy==="seen"?ls():void 0}},k5=(e,t,n)=>(e.description&&(n.description=e.description),n),E5=e=>{const t=HD(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(([a,i])=>[i._def,{def:i._def,path:[...t.basePath,t.definitionPath,a],jsonSchema:void 0}]))}},C5=(e,t)=>{var n;const a=E5(t);let i=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((h,[g,x])=>{var b;return{...h,[g]:(b=yt(x._def,{...a,currentPath:[...a.basePath,a.definitionPath,g]},!0))!=null?b:ls()}},{}):void 0;const c=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,u=(n=yt(e._def,c===void 0?a:{...a,currentPath:[...a.basePath,a.definitionPath,c]},!1))!=null?n:ls(),f=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;f!==void 0&&(u.title=f);const m=c===void 0?i?{...u,[a.definitionPath]:i}:u:{$ref:[...a.$refStrategy==="relative"?[]:a.basePath,a.definitionPath,c].join("/"),[a.definitionPath]:{...i,[c]:u}};return m.$schema="http://json-schema.org/draft-07/schema#",m},qp=Symbol.for("vercel.ai.schema");function T5(e){let t;return()=>(t==null&&(t=e()),t)}function rf(e,{validate:t}={}){return{[qp]:!0,_type:void 0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function A5(e){return typeof e=="object"&&e!==null&&qp in e&&e[qp]===!0&&"jsonSchema"in e&&"validate"in e}function Kg(e){return e==null?rf({properties:{},additionalProperties:!1}):A5(e)?e:"~standard"in e?e["~standard"].vendor==="zod"?ek(e):R5(e):e()}function R5(e){return rf(()=>Xg(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 jo({value:t,cause:n.issues})}}})}function M5(e,t){var n;const a=(n=void 0)!=null?n:!1;return rf(()=>C5(e,{$refStrategy:a?"root":"none"}),{validate:async i=>{const c=await e.safeParseAsync(i);return c.success?{success:!0,value:c.data}:{success:!1,error:c.error}}})}function _5(e,t){var n;const a=(n=void 0)!=null?n:!1;return rf(()=>Xg(gI(e,{target:"draft-7",io:"input",reused:a?"ref":"inline"})),{validate:async i=>{const c=await UN(e,i);return c.success?{success:!0,value:c.data}:{success:!1,error:c.error}}})}function O5(e){return"_zod"in e}function ek(e,t){return O5(e)?_5(e):M5(e)}async function Zw({value:e,schema:t,context:n}){const a=await tc({value:e,schema:t,context:n});if(!a.success)throw jo.wrap({value:e,cause:a.error,context:n});return a.value}async function tc({value:e,schema:t,context:n}){const a=Kg(t);try{if(a.validate==null)return{success:!0,value:e,rawValue:e};const i=await a.validate(e);return i.success?{success:!0,value:i.value,rawValue:e}:{success:!1,error:jo.wrap({value:e,cause:i.error,context:n}),rawValue:e}}catch(i){return{success:!1,error:jo.wrap({value:e,cause:i,context:n}),rawValue:e}}}async function ni({text:e,schema:t}){try{const n=BD(e);return t==null?{success:!0,value:n,rawValue:n}:await tc({value:n,schema:t})}catch(n){return{success:!1,error:uw.isInstance(n)?n:new uw({text:e,cause:n}),rawValue:void 0}}}function I5({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new zD).pipeThrough(new TransformStream({async transform({data:n},a){n!=="[DONE]"&&a.enqueue(await ni({text:n,schema:t}))}}))}async function sr(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}var D5=Object.defineProperty,z5=(e,t)=>{for(var n in t)D5(e,n,{get:t[n],enumerable:!0})},tk="AI_NoObjectGeneratedError",nk=`vercel.ai.error.${tk}`,L5=Symbol.for(nk),sk,cr=class extends ta{constructor({message:e="No object generated.",cause:t,text:n,response:a,usage:i,finishReason:c}){super({name:tk,message:e,cause:t}),this[sk]=!0,this.text=n,this.response=a,this.usage=i,this.finishReason=c}static isInstance(e){return ta.hasMarker(e,nk)}};sk=L5;var ak="AI_UIMessageStreamError",rk=`vercel.ai.error.${ak}`,$5=Symbol.for(rk),ik,Xi=class extends ta{constructor({chunkType:e,chunkId:t,message:n}){super({name:ak,message:n}),this[ik]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return ta.hasMarker(e,rk)}};ik=$5;var ok=Pn([Se(),Ad(Uint8Array),Ad(ArrayBuffer),WN(e=>{var t,n;return(n=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?n:!1},{message:"Must be a Buffer"})]),nc=MD(()=>Pn([rD(),Se(),tD(),zn(),Ql(Se(),nc.optional()),Mo(nc)])),at=Ql(Se(),Ql(Se(),nc.optional())),lk=Nt({type:$e("text"),text:Se(),providerOptions:at.optional()}),P5=Nt({type:$e("image"),image:Pn([ok,Ad(URL)]),mediaType:Se().optional(),providerOptions:at.optional()}),ck=Nt({type:$e("file"),data:Pn([ok,Ad(URL)]),filename:Se().optional(),mediaType:Se(),providerOptions:at.optional()}),U5=Nt({type:$e("reasoning"),text:Se(),providerOptions:at.optional()}),B5=Nt({type:$e("tool-call"),toolCallId:Se(),toolName:Se(),input:Gs(),providerOptions:at.optional(),providerExecuted:zn().optional()}),V5=uD("type",[Nt({type:$e("text"),value:Se(),providerOptions:at.optional()}),Nt({type:$e("json"),value:nc,providerOptions:at.optional()}),Nt({type:$e("execution-denied"),reason:Se().optional(),providerOptions:at.optional()}),Nt({type:$e("error-text"),value:Se(),providerOptions:at.optional()}),Nt({type:$e("error-json"),value:nc,providerOptions:at.optional()}),Nt({type:$e("content"),value:Mo(Pn([Nt({type:$e("text"),text:Se(),providerOptions:at.optional()}),Nt({type:$e("media"),data:Se(),mediaType:Se()}),Nt({type:$e("file-data"),data:Se(),mediaType:Se(),filename:Se().optional(),providerOptions:at.optional()}),Nt({type:$e("file-url"),url:Se(),providerOptions:at.optional()}),Nt({type:$e("file-id"),fileId:Pn([Se(),Ql(Se(),Se())]),providerOptions:at.optional()}),Nt({type:$e("image-data"),data:Se(),mediaType:Se(),providerOptions:at.optional()}),Nt({type:$e("image-url"),url:Se(),providerOptions:at.optional()}),Nt({type:$e("image-file-id"),fileId:Pn([Se(),Ql(Se(),Se())]),providerOptions:at.optional()}),Nt({type:$e("custom"),providerOptions:at.optional()})]))})]),uk=Nt({type:$e("tool-result"),toolCallId:Se(),toolName:Se(),output:V5,providerOptions:at.optional()}),H5=Nt({type:$e("tool-approval-request"),approvalId:Se(),toolCallId:Se()}),Z5=Nt({type:$e("tool-approval-response"),approvalId:Se(),approved:zn(),reason:Se().optional()}),F5=Nt({role:$e("system"),content:Se(),providerOptions:at.optional()}),q5=Nt({role:$e("user"),content:Pn([Se(),Mo(Pn([lk,P5,ck]))]),providerOptions:at.optional()}),Y5=Nt({role:$e("assistant"),content:Pn([Se(),Mo(Pn([lk,ck,U5,B5,uk,H5]))]),providerOptions:at.optional()}),G5=Nt({role:$e("tool"),content:Mo(Pn([uk,Z5])),providerOptions:at.optional()});Pn([F5,q5,Y5,G5]);function dk(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 a in t)if(Object.prototype.hasOwnProperty.call(t,a)){const i=t[a];if(i===void 0)continue;const c=a in e?e[a]:void 0,u=i!==null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),f=c!=null&&typeof c=="object"&&!Array.isArray(c)&&!(c instanceof Date)&&!(c instanceof RegExp);u&&f?n[a]=dk(c,i):n[a]=i}return n}var W5={};z5(W5,{array:()=>Q5,choice:()=>ez,json:()=>tz,object:()=>J5,text:()=>K5});function X5(e){const t=["ROOT"];let n=-1,a=null;function i(m,h,g){switch(m){case'"':{n=h,t.pop(),t.push(g),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{n=h,a=h,t.pop(),t.push(g),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(g),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(g),t.push("INSIDE_NUMBER");break}case"{":{n=h,t.pop(),t.push(g),t.push("INSIDE_OBJECT_START");break}case"[":{n=h,t.pop(),t.push(g),t.push("INSIDE_ARRAY_START");break}}}function c(m,h){switch(m){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{n=h,t.pop();break}}}function u(m,h){switch(m){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=h,t.pop();break}}}for(let m=0;m<e.length;m++){const h=e[m];switch(t[t.length-1]){case"ROOT":i(h,m,"FINISH");break;case"INSIDE_OBJECT_START":{switch(h){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{n=m,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":{i(h,m,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{c(h,m);break}case"INSIDE_STRING":{switch(h){case'"':{t.pop(),n=m;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:n=m}break}case"INSIDE_ARRAY_START":{h==="]"?(n=m,t.pop()):(n=m,i(h,m,"INSIDE_ARRAY_AFTER_VALUE"));break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(h){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{n=m,t.pop();break}default:{n=m;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{i(h,m,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),n=m;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=m;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&u(h,m),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&c(h,m);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&c(h,m);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&u(h,m);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const x=e.substring(a,m+1);!"false".startsWith(x)&&!"true".startsWith(x)&&!"null".startsWith(x)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?c(h,m):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&u(h,m)):n=m;break}}}let f=e.slice(0,n+1);for(let m=t.length-1;m>=0;m--)switch(t[m]){case"INSIDE_STRING":{f+='"';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":{f+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{f+="]";break}case"INSIDE_LITERAL":{const g=e.substring(a,e.length);"true".startsWith(g)?f+="true".slice(g.length):"false".startsWith(g)?f+="false".slice(g.length):"null".startsWith(g)&&(f+="null".slice(g.length))}}return f}async function hc(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await ni({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await ni({text:X5(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var K5=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),J5=({schema:e,name:t,description:n})=>{const a=Kg(e);return{name:"object",responseFormat:sr(a.jsonSchema).then(i=>({type:"json",schema:i,...t!=null&&{name:t},...n!=null&&{description:n}})),async parseCompleteOutput({text:i},c){const u=await ni({text:i});if(!u.success)throw new cr({message:"No object generated: could not parse the response.",cause:u.error,text:i,response:c.response,usage:c.usage,finishReason:c.finishReason});const f=await tc({value:u.value,schema:a});if(!f.success)throw new cr({message:"No object generated: response did not match schema.",cause:f.error,text:i,response:c.response,usage:c.usage,finishReason:c.finishReason});return f.value},async parsePartialOutput({text:i}){const c=await hc(i);switch(c.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:c.value}}},createElementStreamTransform(){}}},Q5=({element:e,name:t,description:n})=>{const a=Kg(e);return{name:"array",responseFormat:sr(a.jsonSchema).then(i=>{const{$schema:c,...u}=i;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:i},c){const u=await ni({text:i});if(!u.success)throw new cr({message:"No object generated: could not parse the response.",cause:u.error,text:i,response:c.response,usage:c.usage,finishReason:c.finishReason});const f=u.value;if(f==null||typeof f!="object"||!("elements"in f)||!Array.isArray(f.elements))throw new cr({message:"No object generated: response did not match schema.",cause:new jo({value:f,cause:"response must be an object with an elements array"}),text:i,response:c.response,usage:c.usage,finishReason:c.finishReason});for(const m of f.elements){const h=await tc({value:m,schema:a});if(!h.success)throw new cr({message:"No object generated: response did not match schema.",cause:h.error,text:i,response:c.response,usage:c.usage,finishReason:c.finishReason})}return f.elements},async parsePartialOutput({text:i}){const c=await hc(i);switch(c.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const u=c.value;if(u==null||typeof u!="object"||!("elements"in u)||!Array.isArray(u.elements))return;const f=c.state==="repaired-parse"&&u.elements.length>0?u.elements.slice(0,-1):u.elements,m=[];for(const h of f){const g=await tc({value:h,schema:a});g.success&&m.push(g.value)}return{partial:m}}}},createElementStreamTransform(){let i=0;return new TransformStream({transform({partialOutput:c},u){if(c!=null)for(;i<c.length;i++)u.enqueue(c[i])}})}}},ez=({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:a},i){const c=await ni({text:a});if(!c.success)throw new cr({message:"No object generated: could not parse the response.",cause:c.error,text:a,response:i.response,usage:i.usage,finishReason:i.finishReason});const u=c.value;if(u==null||typeof u!="object"||!("result"in u)||typeof u.result!="string"||!e.includes(u.result))throw new cr({message:"No object generated: response did not match schema.",cause:new jo({value:u,cause:"response must be an object that contains a choice value."}),text:a,response:i.response,usage:i.usage,finishReason:i.finishReason});return u.result},async parsePartialOutput({text:a}){const i=await hc(a);switch(i.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const c=i.value;if(c==null||typeof c!="object"||!("result"in c)||typeof c.result!="string")return;const u=e.filter(f=>f.startsWith(c.result));return i.state==="successful-parse"?u.includes(c.result)?{partial:c.result}:void 0:u.length===1?{partial:u[0]}:void 0}}},createElementStreamTransform(){}}),tz=({name:e,description:t}={})=>({name:"json",responseFormat:Promise.resolve({type:"json",...e!=null&&{name:e},...t!=null&&{description:t}}),async parseCompleteOutput({text:n},a){const i=await ni({text:n});if(!i.success)throw new cr({message:"No object generated: could not parse the response.",cause:i.error,text:n,response:a.response,usage:a.usage,finishReason:a.finishReason});return i.value},async parsePartialOutput({text:n}){const a=await hc(n);switch(a.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return a.value===void 0?void 0:{partial:a.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 nz=T5(()=>ek(Pn([Mt({type:$e("text-start"),id:Se(),providerMetadata:at.optional()}),Mt({type:$e("text-delta"),id:Se(),delta:Se(),providerMetadata:at.optional()}),Mt({type:$e("text-end"),id:Se(),providerMetadata:at.optional()}),Mt({type:$e("error"),errorText:Se()}),Mt({type:$e("tool-input-start"),toolCallId:Se(),toolName:Se(),providerExecuted:zn().optional(),providerMetadata:at.optional(),dynamic:zn().optional(),title:Se().optional()}),Mt({type:$e("tool-input-delta"),toolCallId:Se(),inputTextDelta:Se()}),Mt({type:$e("tool-input-available"),toolCallId:Se(),toolName:Se(),input:Gs(),providerExecuted:zn().optional(),providerMetadata:at.optional(),dynamic:zn().optional(),title:Se().optional()}),Mt({type:$e("tool-input-error"),toolCallId:Se(),toolName:Se(),input:Gs(),providerExecuted:zn().optional(),providerMetadata:at.optional(),dynamic:zn().optional(),errorText:Se(),title:Se().optional()}),Mt({type:$e("tool-approval-request"),approvalId:Se(),toolCallId:Se()}),Mt({type:$e("tool-output-available"),toolCallId:Se(),output:Gs(),providerExecuted:zn().optional(),providerMetadata:at.optional(),dynamic:zn().optional(),preliminary:zn().optional()}),Mt({type:$e("tool-output-error"),toolCallId:Se(),errorText:Se(),providerExecuted:zn().optional(),providerMetadata:at.optional(),dynamic:zn().optional()}),Mt({type:$e("tool-output-denied"),toolCallId:Se()}),Mt({type:$e("reasoning-start"),id:Se(),providerMetadata:at.optional()}),Mt({type:$e("reasoning-delta"),id:Se(),delta:Se(),providerMetadata:at.optional()}),Mt({type:$e("reasoning-end"),id:Se(),providerMetadata:at.optional()}),Mt({type:$e("source-url"),sourceId:Se(),url:Se(),title:Se().optional(),providerMetadata:at.optional()}),Mt({type:$e("source-document"),sourceId:Se(),mediaType:Se(),title:Se(),filename:Se().optional(),providerMetadata:at.optional()}),Mt({type:$e("file"),url:Se(),mediaType:Se(),providerMetadata:at.optional()}),Mt({type:WN(e=>typeof e=="string"&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:Se().optional(),data:Gs(),transient:zn().optional()}),Mt({type:$e("start-step")}),Mt({type:$e("finish-step")}),Mt({type:$e("start"),messageId:Se().optional(),messageMetadata:Gs().optional()}),Mt({type:$e("finish"),finishReason:qN(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:Gs().optional()}),Mt({type:$e("abort"),reason:Se().optional()}),Mt({type:$e("message-metadata"),messageMetadata:Gs()})])));function sz(e){return e.type.startsWith("data-")}function Yp(e){return e.type.startsWith("tool-")}function fk(e){return e.type==="dynamic-tool"}function si(e){return Yp(e)||fk(e)}function Gp(e){return e.type.split("-").slice(1).join("-")}function hk(e){return fk(e)?e.toolName:Gp(e)}function az({lastMessage:e,messageId:t}){return{message:e?.role==="assistant"?e:{id:t,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function rz({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:a,onError:i,onToolCall:c,onData:u}){return e.pipeThrough(new TransformStream({async transform(f,m){await a(async({state:h,write:g})=>{var x,b,w,j;function N(S){const A=h.message.parts.filter(si).find(_=>_.toolCallId===S);if(A==null)throw new Xi({chunkType:"tool-invocation",chunkId:S,message:`No tool invocation found for tool call ID "${S}".`});return A}function T(S){var R;const A=h.message.parts.find(V=>Yp(V)&&V.toolCallId===S.toolCallId),_=S,O=A;if(A!=null){A.state=S.state,O.input=_.input,O.output=_.output,O.errorText=_.errorText,O.rawInput=_.rawInput,O.preliminary=_.preliminary,S.title!==void 0&&(O.title=S.title),O.providerExecuted=(R=_.providerExecuted)!=null?R:A.providerExecuted;const V=_.providerMetadata;if(V!=null)if(S.state==="output-available"||S.state==="output-error"){const Z=A;Z.resultProviderMetadata=V}else A.callProviderMetadata=V}else h.message.parts.push({type:`tool-${S.toolName}`,toolCallId:S.toolCallId,state:S.state,title:S.title,input:_.input,output:_.output,rawInput:_.rawInput,errorText:_.errorText,providerExecuted:_.providerExecuted,preliminary:_.preliminary,..._.providerMetadata!=null&&(S.state==="output-available"||S.state==="output-error")?{resultProviderMetadata:_.providerMetadata}:{},..._.providerMetadata!=null&&!(S.state==="output-available"||S.state==="output-error")?{callProviderMetadata:_.providerMetadata}:{}})}function k(S){var R,A;const _=h.message.parts.find(Z=>Z.type==="dynamic-tool"&&Z.toolCallId===S.toolCallId),O=S,V=_;if(_!=null){_.state=S.state,V.toolName=S.toolName,V.input=O.input,V.output=O.output,V.errorText=O.errorText,V.rawInput=(R=O.rawInput)!=null?R:V.rawInput,V.preliminary=O.preliminary,S.title!==void 0&&(V.title=S.title),V.providerExecuted=(A=O.providerExecuted)!=null?A:_.providerExecuted;const Z=O.providerMetadata;if(Z!=null)if(S.state==="output-available"||S.state==="output-error"){const I=_;I.resultProviderMetadata=Z}else _.callProviderMetadata=Z}else h.message.parts.push({type:"dynamic-tool",toolName:S.toolName,toolCallId:S.toolCallId,state:S.state,input:O.input,output:O.output,errorText:O.errorText,preliminary:O.preliminary,providerExecuted:O.providerExecuted,title:S.title,...O.providerMetadata!=null&&(S.state==="output-available"||S.state==="output-error")?{resultProviderMetadata:O.providerMetadata}:{},...O.providerMetadata!=null&&!(S.state==="output-available"||S.state==="output-error")?{callProviderMetadata:O.providerMetadata}:{}})}async function C(S){if(S!=null){const R=h.message.metadata!=null?dk(h.message.metadata,S):S;t!=null&&await Zw({value:R,schema:t,context:{field:"message.metadata",entityId:h.message.id}}),h.message.metadata=R}}switch(f.type){case"text-start":{const S={type:"text",text:"",providerMetadata:f.providerMetadata,state:"streaming"};h.activeTextParts[f.id]=S,h.message.parts.push(S),g();break}case"text-delta":{const S=h.activeTextParts[f.id];if(S==null)throw new Xi({chunkType:"text-delta",chunkId:f.id,message:`Received text-delta for missing text part with ID "${f.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});S.text+=f.delta,S.providerMetadata=(x=f.providerMetadata)!=null?x:S.providerMetadata,g();break}case"text-end":{const S=h.activeTextParts[f.id];if(S==null)throw new Xi({chunkType:"text-end",chunkId:f.id,message:`Received text-end for missing text part with ID "${f.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});S.state="done",S.providerMetadata=(b=f.providerMetadata)!=null?b:S.providerMetadata,delete h.activeTextParts[f.id],g();break}case"reasoning-start":{const S={type:"reasoning",text:"",providerMetadata:f.providerMetadata,state:"streaming"};h.activeReasoningParts[f.id]=S,h.message.parts.push(S),g();break}case"reasoning-delta":{const S=h.activeReasoningParts[f.id];if(S==null)throw new Xi({chunkType:"reasoning-delta",chunkId:f.id,message:`Received reasoning-delta for missing reasoning part with ID "${f.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});S.text+=f.delta,S.providerMetadata=(w=f.providerMetadata)!=null?w:S.providerMetadata,g();break}case"reasoning-end":{const S=h.activeReasoningParts[f.id];if(S==null)throw new Xi({chunkType:"reasoning-end",chunkId:f.id,message:`Received reasoning-end for missing reasoning part with ID "${f.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});S.providerMetadata=(j=f.providerMetadata)!=null?j:S.providerMetadata,S.state="done",delete h.activeReasoningParts[f.id],g();break}case"file":{h.message.parts.push({type:"file",mediaType:f.mediaType,url:f.url,...f.providerMetadata!=null?{providerMetadata:f.providerMetadata}:{}}),g();break}case"source-url":{h.message.parts.push({type:"source-url",sourceId:f.sourceId,url:f.url,title:f.title,providerMetadata:f.providerMetadata}),g();break}case"source-document":{h.message.parts.push({type:"source-document",sourceId:f.sourceId,mediaType:f.mediaType,title:f.title,filename:f.filename,providerMetadata:f.providerMetadata}),g();break}case"tool-input-start":{const S=h.message.parts.filter(Yp);h.partialToolCalls[f.toolCallId]={text:"",toolName:f.toolName,index:S.length,dynamic:f.dynamic,title:f.title},f.dynamic?k({toolCallId:f.toolCallId,toolName:f.toolName,state:"input-streaming",input:void 0,providerExecuted:f.providerExecuted,title:f.title,providerMetadata:f.providerMetadata}):T({toolCallId:f.toolCallId,toolName:f.toolName,state:"input-streaming",input:void 0,providerExecuted:f.providerExecuted,title:f.title,providerMetadata:f.providerMetadata}),g();break}case"tool-input-delta":{const S=h.partialToolCalls[f.toolCallId];if(S==null)throw new Xi({chunkType:"tool-input-delta",chunkId:f.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${f.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});S.text+=f.inputTextDelta;const{value:R}=await hc(S.text);S.dynamic?k({toolCallId:f.toolCallId,toolName:S.toolName,state:"input-streaming",input:R,title:S.title}):T({toolCallId:f.toolCallId,toolName:S.toolName,state:"input-streaming",input:R,title:S.title}),g();break}case"tool-input-available":{f.dynamic?k({toolCallId:f.toolCallId,toolName:f.toolName,state:"input-available",input:f.input,providerExecuted:f.providerExecuted,providerMetadata:f.providerMetadata,title:f.title}):T({toolCallId:f.toolCallId,toolName:f.toolName,state:"input-available",input:f.input,providerExecuted:f.providerExecuted,providerMetadata:f.providerMetadata,title:f.title}),g(),c&&!f.providerExecuted&&await c({toolCall:f});break}case"tool-input-error":{const S=h.message.parts.filter(si).find(A=>A.toolCallId===f.toolCallId);(S!=null?S.type==="dynamic-tool":!!f.dynamic)?k({toolCallId:f.toolCallId,toolName:f.toolName,state:"output-error",input:f.input,errorText:f.errorText,providerExecuted:f.providerExecuted,providerMetadata:f.providerMetadata}):T({toolCallId:f.toolCallId,toolName:f.toolName,state:"output-error",input:void 0,rawInput:f.input,errorText:f.errorText,providerExecuted:f.providerExecuted,providerMetadata:f.providerMetadata}),g();break}case"tool-approval-request":{const S=N(f.toolCallId);S.state="approval-requested",S.approval={id:f.approvalId},g();break}case"tool-output-denied":{const S=N(f.toolCallId);S.state="output-denied",g();break}case"tool-output-available":{const S=N(f.toolCallId);S.type==="dynamic-tool"?k({toolCallId:f.toolCallId,toolName:S.toolName,state:"output-available",input:S.input,output:f.output,preliminary:f.preliminary,providerExecuted:f.providerExecuted,providerMetadata:f.providerMetadata,title:S.title}):T({toolCallId:f.toolCallId,toolName:Gp(S),state:"output-available",input:S.input,output:f.output,providerExecuted:f.providerExecuted,preliminary:f.preliminary,providerMetadata:f.providerMetadata,title:S.title}),g();break}case"tool-output-error":{const S=N(f.toolCallId);S.type==="dynamic-tool"?k({toolCallId:f.toolCallId,toolName:S.toolName,state:"output-error",input:S.input,errorText:f.errorText,providerExecuted:f.providerExecuted,providerMetadata:f.providerMetadata,title:S.title}):T({toolCallId:f.toolCallId,toolName:Gp(S),state:"output-error",input:S.input,rawInput:S.rawInput,errorText:f.errorText,providerExecuted:f.providerExecuted,providerMetadata:f.providerMetadata,title:S.title}),g();break}case"start-step":{h.message.parts.push({type:"step-start"});break}case"finish-step":{h.activeTextParts={},h.activeReasoningParts={};break}case"start":{f.messageId!=null&&(h.message.id=f.messageId),await C(f.messageMetadata),(f.messageId!=null||f.messageMetadata!=null)&&g();break}case"finish":{f.finishReason!=null&&(h.finishReason=f.finishReason),await C(f.messageMetadata),f.messageMetadata!=null&&g();break}case"message-metadata":{await C(f.messageMetadata),f.messageMetadata!=null&&g();break}case"error":{i?.(new Error(f.errorText));break}default:if(sz(f)){if(n?.[f.type]!=null){const A=h.message.parts.findIndex(O=>"id"in O&&"data"in O&&O.id===f.id&&O.type===f.type),_=A>=0?A:h.message.parts.length;await Zw({value:f.data,schema:n[f.type],context:{field:`message.parts[${_}].data`,entityName:f.type,entityId:f.id}})}const S=f;if(S.transient){u?.(S);break}const R=S.id!=null?h.message.parts.find(A=>S.type===A.type&&S.id===A.id):void 0;R!=null?R.data=S.data:h.message.parts.push(S),u?.(S),g()}}m.enqueue(f)})}}))}async function iz({stream:e,onError:t}){const n=e.getReader();try{for(;;){const{done:a}=await n.read();if(a)break}}catch(a){t?.(a)}finally{n.releaseLock()}}fc({prefix:"aitxt",size:24});fc({prefix:"aiobj",size:24});var oz=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(a){n(a)}}),this.processQueue()})}};fc({prefix:"aiobj",size:24});async function lz(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:a}=t,i=await new Promise((c,u)=>{const f=new FileReader;f.onload=m=>{var h;c((h=m.target)==null?void 0:h.result)},f.onerror=m=>u(m),f.readAsDataURL(t)});return{type:"file",mediaType:a,filename:n,url:i}}))}var cz=class{constructor({api:e="/api/chat",credentials:t,headers:n,body:a,fetch:i,prepareSendMessagesRequest:c,prepareReconnectToStreamRequest:u}){this.api=e,this.credentials=t,this.headers=n,this.body=a,this.fetch=i,this.prepareSendMessagesRequest=c,this.prepareReconnectToStreamRequest=u}async sendMessages({abortSignal:e,...t}){var n,a,i,c,u;const f=await sr(this.body),m=await sr(this.headers),h=await sr(this.credentials),g={...Wi(m),...Wi(t.headers)},x=await((n=this.prepareSendMessagesRequest)==null?void 0:n.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...f,...t.body},headers:g,credentials:h,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId})),b=(a=x?.api)!=null?a:this.api,w=x?.headers!==void 0?Wi(x.headers):g,j=x?.body!==void 0?x.body:{...f,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId},N=(i=x?.credentials)!=null?i:h,k=await((c=this.fetch)!=null?c:globalThis.fetch)(b,{method:"POST",headers:{"Content-Type":"application/json",...w},body:JSON.stringify(j),credentials:N,signal:e});if(!k.ok)throw new Error((u=await k.text())!=null?u:"Failed to fetch the chat response.");if(!k.body)throw new Error("The response body is empty.");return this.processResponseStream(k.body)}async reconnectToStream(e){var t,n,a,i,c;const u=await sr(this.body),f=await sr(this.headers),m=await sr(this.credentials),h={...Wi(f),...Wi(e.headers)},g=await((t=this.prepareReconnectToStreamRequest)==null?void 0:t.call(this,{api:this.api,id:e.chatId,body:{...u,...e.body},headers:h,credentials:m,requestMetadata:e.metadata})),x=(n=g?.api)!=null?n:`${this.api}/${e.chatId}/stream`,b=g?.headers!==void 0?Wi(g.headers):h,w=(a=g?.credentials)!=null?a:m,N=await((i=this.fetch)!=null?i:globalThis.fetch)(x,{method:"GET",headers:b,credentials:w});if(N.status===204)return null;if(!N.ok)throw new Error((c=await N.text())!=null?c:"Failed to fetch the chat response.");if(!N.body)throw new Error("The response body is empty.");return this.processResponseStream(N.body)}},mk=class extends cz{constructor(e={}){super(e)}processResponseStream(e){return I5({stream:e,schema:nz}).pipeThrough(new TransformStream({async transform(t,n){if(!t.success)throw t.error;n.enqueue(t.value)}}))}},uz=class{constructor({generateId:e=LD,id:t=e(),transport:n=new mk,messageMetadataSchema:a,dataPartSchemas:i,state:c,onError:u,onToolCall:f,onFinish:m,onData:h,sendAutomaticallyWhen:g}){this.activeResponse=void 0,this.jobExecutor=new oz,this.sendMessage=async(x,b)=>{var w,j,N,T;if(x==null){await this.makeRequest({trigger:"submit-message",messageId:(w=this.lastMessage)==null?void 0:w.id,...b});return}let k;if("text"in x||"files"in x?k={parts:[...Array.isArray(x.files)?x.files:await lz(x.files),..."text"in x&&x.text!=null?[{type:"text",text:x.text}]:[]]}:k=x,x.messageId!=null){const C=this.state.messages.findIndex(S=>S.id===x.messageId);if(C===-1)throw new Error(`message with id ${x.messageId} not found`);if(this.state.messages[C].role!=="user")throw new Error(`message with id ${x.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,C+1),this.state.replaceMessage(C,{...k,id:x.messageId,role:(j=k.role)!=null?j:"user",metadata:x.metadata})}else this.state.pushMessage({...k,id:(N=k.id)!=null?N:this.generateId(),role:(T=k.role)!=null?T:"user",metadata:x.metadata});await this.makeRequest({trigger:"submit-message",messageId:x.messageId,...b})},this.regenerate=async({messageId:x,...b}={})=>{const w=x==null?this.state.messages.length-1:this.state.messages.findIndex(j=>j.id===x);if(w===-1)throw new Error(`message ${x} 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:x,...b})},this.resumeStream=async(x={})=>{await this.makeRequest({trigger:"resume-stream",...x})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:x,approved:b,reason:w,options:j})=>this.jobExecutor.run(async()=>{const N=this.state.messages,T=N[N.length-1],k=C=>si(C)&&C.state==="approval-requested"&&C.approval.id===x?{...C,state:"approval-responded",approval:{id:x,approved:b,reason:w}}:C;this.state.replaceMessage(N.length-1,{...T,parts:T.parts.map(k)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(k)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(C=>{var S;C&&this.makeRequest({trigger:"submit-message",messageId:(S=this.lastMessage)==null?void 0:S.id,...j})})}),this.addToolOutput=async({state:x="output-available",toolCallId:b,output:w,errorText:j,options:N})=>this.jobExecutor.run(async()=>{const T=this.state.messages,k=T[T.length-1],C=S=>si(S)&&S.toolCallId===b?{...S,state:x,output:w,errorText:j}:S;this.state.replaceMessage(T.length-1,{...k,parts:k.parts.map(C)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(C)),this.status!=="streaming"&&this.status!=="submitted"&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(S=>{var R;S&&this.makeRequest({trigger:"submit-message",messageId:(R=this.lastMessage)==null?void 0:R.id,...N})})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var x;this.status!=="streaming"&&this.status!=="submitted"||(x=this.activeResponse)!=null&&x.abortController&&this.activeResponse.abortController.abort()},this.id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=a,this.dataPartSchemas=i,this.state=c,this.onError=u,this.onToolCall=f,this.onFinish=m,this.onData=h,this.sendAutomaticallyWhen=g}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:a,messageId:i}){var c,u,f;let m;if(e==="resume-stream")try{const w=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:n,body:a});if(w==null)return;m=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 g=!1,x=!1,b=!1;try{const w={state:az({lastMessage:this.state.snapshot(h),messageId:this.generateId()}),abortController:new AbortController};w.abortController.signal.addEventListener("abort",()=>{g=!0}),this.activeResponse=w;let j;e==="resume-stream"?j=m:j=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:w.abortController.signal,metadata:t,headers:n,body:a,trigger:e,messageId:i});const N=T=>this.jobExecutor.run(()=>T({state:w.state,write:()=>{var k;this.setStatus({status:"streaming"}),w.state.message.id===((k=this.lastMessage)==null?void 0:k.id)?this.state.replaceMessage(this.state.messages.length-1,w.state.message):this.state.pushMessage(w.state.message)}}));await iz({stream:rz({stream:j,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:N,onError:T=>{throw T}}),onError:T=>{throw T}}),this.setStatus({status:"ready"})}catch(w){if(g||w.name==="AbortError")return g=!0,this.setStatus({status:"ready"}),null;b=!0,w instanceof TypeError&&(w.message.toLowerCase().includes("fetch")||w.message.toLowerCase().includes("network"))&&(x=!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:g,isDisconnect:x,isError:b,finishReason:(c=this.activeResponse)==null?void 0:c.state.finishReason})}catch(w){console.error(w)}this.activeResponse=void 0}!b&&await this.shouldSendAutomatically()&&await this.makeRequest({trigger:"submit-message",messageId:(f=this.lastMessage)==null?void 0:f.id,metadata:t,headers:n,body:a})}},qm,Fw;function dz(){if(Fw)return qm;Fw=1;function e(t,n){if(typeof t!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof t}\`.`);let a,i=0;return function(...u){clearTimeout(a);const f=Date.now(),m=f-i,h=n-m;h<=0?(i=f,t.apply(this,u)):a=setTimeout(()=>{i=Date.now(),t.apply(this,u)},h)}}return qm=e,qm}var fz=dz();const hz=Dj(fz);var pk=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},_t=(e,t,n)=>(pk(e,t,"read from private field"),n?n.call(e):t.get(e)),qs=(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)},tr=(e,t,n,a)=>(pk(e,t,"write to private field"),t.set(e,n),n);function mz(e,t){return t!=null?hz(e,t):e}var bs,od,ld,Ol,Il,Dl,so,Wp,Xp,pz=class{constructor(e=[]){qs(this,bs,void 0),qs(this,od,"ready"),qs(this,ld,void 0),qs(this,Ol,new Set),qs(this,Il,new Set),qs(this,Dl,new Set),this.pushMessage=t=>{tr(this,bs,_t(this,bs).concat(t)),_t(this,so).call(this)},this.popMessage=()=>{tr(this,bs,_t(this,bs).slice(0,-1)),_t(this,so).call(this)},this.replaceMessage=(t,n)=>{tr(this,bs,[..._t(this,bs).slice(0,t),this.snapshot(n),..._t(this,bs).slice(t+1)]),_t(this,so).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,n)=>{const a=n?mz(t,n):t;return _t(this,Ol).add(a),()=>{_t(this,Ol).delete(a)}},this["~registerStatusCallback"]=t=>(_t(this,Il).add(t),()=>{_t(this,Il).delete(t)}),this["~registerErrorCallback"]=t=>(_t(this,Dl).add(t),()=>{_t(this,Dl).delete(t)}),qs(this,so,()=>{_t(this,Ol).forEach(t=>t())}),qs(this,Wp,()=>{_t(this,Il).forEach(t=>t())}),qs(this,Xp,()=>{_t(this,Dl).forEach(t=>t())}),tr(this,bs,e)}get status(){return _t(this,od)}set status(e){tr(this,od,e),_t(this,Wp).call(this)}get error(){return _t(this,ld)}set error(e){tr(this,ld,e),_t(this,Xp).call(this)}get messages(){return _t(this,bs)}set messages(e){tr(this,bs,[...e]),_t(this,so).call(this)}};bs=new WeakMap;od=new WeakMap;ld=new WeakMap;Ol=new WeakMap;Il=new WeakMap;Dl=new WeakMap;so=new WeakMap;Wp=new WeakMap;Xp=new WeakMap;var ao,qw=class extends uz{constructor({messages:e,...t}){const n=new pz(e);super({...t,state:n}),qs(this,ao,void 0),this["~registerMessagesCallback"]=(a,i)=>_t(this,ao)["~registerMessagesCallback"](a,i),this["~registerStatusCallback"]=a=>_t(this,ao)["~registerStatusCallback"](a),this["~registerErrorCallback"]=a=>_t(this,ao)["~registerErrorCallback"](a),tr(this,ao,n)}};ao=new WeakMap;function gz({experimental_throttle:e,resume:t=!1,...n}={}){const a=v.useRef("chat"in n?{}:{onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});"chat"in n||(a.current={onToolCall:n.onToolCall,onData:n.onData,onFinish:n.onFinish,onError:n.onError,sendAutomaticallyWhen:n.sendAutomaticallyWhen});const i={...n,onToolCall:b=>{var w,j;return(j=(w=a.current).onToolCall)==null?void 0:j.call(w,b)},onData:b=>{var w,j;return(j=(w=a.current).onData)==null?void 0:j.call(w,b)},onFinish:b=>{var w,j;return(j=(w=a.current).onFinish)==null?void 0:j.call(w,b)},onError:b=>{var w,j;return(j=(w=a.current).onError)==null?void 0:j.call(w,b)},sendAutomaticallyWhen:b=>{var w,j,N;return(N=(j=(w=a.current).sendAutomaticallyWhen)==null?void 0:j.call(w,b))!=null?N:!1}},c=v.useRef("chat"in n?n.chat:new qw(i));("chat"in n&&n.chat!==c.current||"id"in n&&c.current.id!==n.id)&&(c.current="chat"in n?n.chat:new qw(i));const f=v.useCallback(b=>c.current["~registerMessagesCallback"](b,e),[e,c.current.id]),m=v.useSyncExternalStore(f,()=>c.current.messages,()=>c.current.messages),h=v.useSyncExternalStore(c.current["~registerStatusCallback"],()=>c.current.status,()=>c.current.status),g=v.useSyncExternalStore(c.current["~registerErrorCallback"],()=>c.current.error,()=>c.current.error),x=v.useCallback(b=>{typeof b=="function"&&(b=b(c.current.messages)),c.current.messages=b},[c]);return v.useEffect(()=>{t&&c.current.resumeStream()},[t,c]),{id:c.current.id,messages:m,setMessages:x,sendMessage:c.current.sendMessage,regenerate:c.current.regenerate,clearError:c.current.clearError,stop:c.current.stop,error:g,resumeStream:c.current.resumeStream,status:h,addToolResult:c.current.addToolOutput,addToolOutput:c.current.addToolOutput,addToolApprovalResponse:c.current.addToolApprovalResponse}}function vz(e){const t={};for(const n of e.attachmentsRef.current??[])if(e.activeAttachmentsRef.current.has(n.label)){const a=n.content();a!==null&&(t[n.label.toLowerCase()]=a)}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 yz(e,t){e.current?.(t)}function xz(e,t){e.current?.(t)}function bz(e){const t=new Set;for(const n of e??[])if(n.role==="assistant")for(const a of n.parts??[])a&&si(a)&&t.add(a.toolCallId);return t}function wz({toolset:e,chatId:t,initialMessages:n,context:a,onToolCall:i,mode:c,attachments:u,provider:f,model:m,sessionId:h,onSessionIdChange:g,onFinish:x,onError:b}){const w=v.useRef(i),j=v.useRef(x),N=v.useRef(b),T=v.useRef(h??crypto.randomUUID()),[k,C]=v.useState(new Set),S=v.useCallback(B=>{C(G=>{const K=new Set(G);return K.has(B)?K.delete(B):K.add(B),K})},[]),[R]=ka("hudson.settings",{}),A=c??R.aiMode??"api",_=v.useRef(k),O=v.useRef(u),V=v.useRef(a),Z=v.useRef(e),I=v.useRef(A),$=v.useRef(f),L=v.useRef(m);v.useEffect(()=>{w.current=i},[i]),v.useEffect(()=>{j.current=x},[x]),v.useEffect(()=>{N.current=b},[b]),v.useEffect(()=>{h&&h!==T.current&&(T.current=h)},[h]),v.useEffect(()=>{g?.(T.current)},[g]),v.useEffect(()=>{_.current=k},[k]),v.useEffect(()=>{O.current=u},[u]),v.useEffect(()=>{V.current=a},[a]),v.useEffect(()=>{Z.current=e},[e]),v.useEffect(()=>{I.current=A},[A]),v.useEffect(()=>{$.current=f},[f]),v.useEffect(()=>{L.current=m},[m]);const P=v.useMemo(()=>new mk({api:"/api/ai/chat",body:()=>vz({activeAttachmentsRef:_,attachmentsRef:O,contextRef:V,toolsetRef:Z,modeRef:I,sessionIdRef:T,providerRef:$,modelRef:L})}),[]),q=gz({id:t,messages:n,transport:P,onFinish:B=>yz(j,B),onError:B=>xz(N,B)}),ee=v.useRef(bz(n)),D=v.useCallback(()=>{const B=crypto.randomUUID();T.current=B,g?.(B),ee.current.clear(),q.setMessages([])},[q,g]),{messages:U}=q;return v.useEffect(()=>{if(w.current){for(const B of U)if(B.role==="assistant"){for(const G of B.parts??[])if(G&&si(G)){if("state"in G&&G.state==="input-streaming")continue;const K=G.toolCallId;if(!ee.current.has(K)){ee.current.add(K);const z=hk(G);w.current?.(z,G.input??{})}}}}},[U]),{messages:U,sendMessage:q.sendMessage,stop:q.stop,status:q.status,setMessages:q.setMessages,clearChat:D,error:q.error,mode:A,attachments:u??[],activeAttachments:k,toggleAttachment:S}}function Sz({app:e,commands:t,state:n,provider:a,model:i,onFinish:c}){const u=v.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(g=>({name:g.name,description:g.description,type:g.type,optional:g.optional,enum:g.enum}))})),[e.intents]),f=v.useMemo(()=>({appId:e.id,appName:e.name,appDescription:e.description,intents:u,state:n}),[e.id,e.name,e.description,u,n]),m=v.useCallback(h=>{const g=t.find(x=>x.id===h);if(!g){console.warn(`[useAssistant] no command for id "${h}"`);return}g.action()},[t]);return wz({toolset:"intents",context:f,provider:a,model:i,onFinish:c,onToolCall:(h,g)=>{if(h!=="dispatch")return;const x=g.commandId;typeof x=="string"&&m(x)}})}function Jg(e={}){const{url:t="ws://localhost:3600",systemPrompt:n,cwd:a,workspaceFiles:i,autoConnect:c=!1,sessionKey:u,orphanTTL:f,backend:m,tmuxSession:h,agent:g,provider:x,model:b}=e,w=u?`hudson.relay.${u}`:null,j=()=>{if(!w)return null;try{return localStorage.getItem(w)}catch{return null}},N=ie=>{if(w)try{ie?localStorage.setItem(w,ie):localStorage.removeItem(w)}catch{}},[T,k]=v.useState("disconnected"),[C,S]=v.useState(null),[R,A]=v.useState(null),[_,O]=v.useState(null),[V,Z]=v.useState(a||"~"),I=v.useRef(null),$=v.useRef(null),L=v.useRef({cols:80,rows:24}),P=v.useRef(!1),q=v.useRef(""),ee=v.useRef(0),D=v.useRef(V);D.current=V;const U=v.useRef(j()),B=v.useRef(null),G=512*1024,K=v.useCallback(ie=>{if(ie){if(B.current){B.current(ie);return}q.current+=ie,q.current.length>G&&(q.current=q.current.slice(-G))}},[]),z=v.useCallback(ie=>{const ke=I.current;ke&&ke.readyState===WebSocket.OPEN&&ke.send(JSON.stringify(ie))},[]),Y=v.useCallback(()=>{ee.current+=1,$.current&&(clearTimeout($.current),$.current=null);const ie=I.current;ie&&(ie.close(),I.current=null),P.current=!1,k("disconnected")},[]),W=v.useCallback(()=>{const ie=D.current;return{type:"session:init",cols:L.current.cols,rows:L.current.rows,...n?{systemPrompt:n}:{},...ie?{cwd:ie}:{},...i?{workspaceFiles:i}:{},...f?{orphanTTL:f}:{},...m?{backend:m}:{},...h?{tmuxSession:h}:{},...g?{agent:g}:{},...x?{provider:x}:{},...b?{model:b}:{}}},[n,i,f,m,h,g,x,b]),J=v.useCallback(()=>{P.current||(P.current=!0,U.current?z({type:"session:reconnect",sessionId:U.current,cols:L.current.cols,rows:L.current.rows}):z(W()))},[z,W]),de=v.useCallback(async()=>{const ie=ee.current+1;ee.current=ie,I.current&&(I.current.close(),I.current=null),P.current=!1,k("connecting"),A(null),O(null);const ke=t.replace(/^ws(s?):\/\//,"http$1://");try{await fetch(`${ke}/health`,{signal:AbortSignal.timeout(2e3)})}catch{if(ee.current!==ie)return;k("error"),A("Relay service is not running");return}if(ee.current!==ie)return;I.current&&(I.current.close(),I.current=null);const we=new WebSocket(t);I.current=we;const Ue=()=>ee.current===ie&&I.current===we;we.onopen=()=>{if(!Ue()){we.close();return}J()},we.onmessage=Ae=>{if(Ue())try{const xe=JSON.parse(Ae.data);switch(xe.type){case"session:ready":U.current=xe.sessionId,N(xe.sessionId),S(xe.sessionId),k("connected"),A(null),O(null);break;case"session:expired":{U.current=null,N(null),P.current=!1,K("\x1B[2J\x1B[H"),z(W()),P.current=!0;break}case"session:error":k("error"),A(xe.error||"Session failed to start");break;case"terminal:data":xe.data&&K(xe.data);break;case"session:exit":U.current=null,N(null),S(null),O(xe.exitCode??null),xe.exitCode!==0?(k("error"),A(xe.reason||`Process exited with code ${xe.exitCode}`)):k("disconnected");break;case"session:detached":U.current=null,N(null),S(null);break}}catch{}},we.onclose=()=>{Ue()&&(I.current=null,P.current=!1,k(Ae=>Ae==="error"?Ae:"disconnected"))},we.onerror=()=>{Ue()&&(k("error"),A("Could not connect to relay"))}},[t,J,z,n,i]),ae=v.useCallback(ie=>{z({type:"terminal:input",data:ie})},[z]),ye=v.useCallback(ie=>{z({type:"terminal:input",data:ie+"\r"})},[z]),ve=v.useCallback((ie,ke)=>{L.current={cols:ie,rows:ke},P.current&&z({type:"terminal:resize",cols:ie,rows:ke})},[z]),be=v.useCallback(ie=>{B.current=ie,!(!ie||q.current.length===0)&&(ie(q.current),q.current="")},[]);v.useEffect(()=>(c&&de(),()=>{Y()}),[]);const _e=v.useCallback(()=>{Y(),U.current=null,S(null),N(null),A(null),O(null),setTimeout(()=>de(),200)},[Y,de]);return{status:T,sessionId:C,error:R,exitCode:_,cwd:V,setCwd:Z,onData:be,sendInput:ae,sendLine:ye,resize:ve,connect:de,disconnect:Y,restart:_e}}const gk=(...e)=>e.filter((t,n,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===n).join(" ").trim();const jz=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const Nz=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,a)=>a?a.toUpperCase():n.toLowerCase());const Yw=e=>{const t=Nz(e);return t.charAt(0).toUpperCase()+t.slice(1)};var kz={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 Ez=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const Cz=v.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:a,className:i="",children:c,iconNode:u,...f},m)=>v.createElement("svg",{ref:m,...kz,width:t,height:t,stroke:e,strokeWidth:a?Number(n)*24/Number(t):n,className:gk("lucide",i),...!c&&!Ez(f)&&{"aria-hidden":"true"},...f},[...u.map(([h,g])=>v.createElement(h,g)),...Array.isArray(c)?c:[c]]));const Zt=(e,t)=>{const n=v.forwardRef(({className:a,...i},c)=>v.createElement(Cz,{ref:c,iconNode:t,className:gk(`lucide-${jz(Yw(e))}`,`lucide-${e}`,a),...i}));return n.displayName=Yw(e),n};const Tz=[["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"}]],Az=Zt("circle-alert",Tz);const Rz=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],Mz=Zt("clock",Rz);const _z=[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]],Oz=Zt("corner-down-left",_z);const Iz=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Gw=Zt("loader-circle",Iz);const Dz=[["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"}]],zz=Zt("map",Dz);const Lz=[["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"}]],vk=Zt("maximize-2",Lz);const $z=[["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"}]],Pz=Zt("mic",$z);const Uz=[["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"}]],Bz=Zt("minimize-2",Uz);const Vz=[["path",{d:"M5 12h14",key:"1ays0h"}]],Hz=Zt("minus",Vz);const Zz=[["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"}]],Fz=Zt("panel-left-close",Zz);const qz=[["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"}]],Yz=Zt("panel-left-open",qz);const Gz=[["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"}]],Wz=Zt("panel-right-close",Gz);const Xz=[["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"}]],Kz=Zt("panel-right-open",Xz);const Jz=[["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"}]],Qz=Zt("paperclip",Jz);const e4=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],t4=Zt("plus",e4);const n4=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Qg=Zt("search",n4);const s4=[["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"}]],a4=Zt("sparkles",s4);const r4=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],yk=Zt("square",r4);const i4=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],o4=Zt("terminal",i4);const l4=[["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"}]],c4=Zt("trash-2",l4);const u4=[["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"}]],d4=Zt("volume-2",u4);const f4=[["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"}]],h4=Zt("volume-x",f4);const m4=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],xk=Zt("x",m4);function p4({chat:e,placeholder:t="Ask AI...",inputExtras:n,inputStatus:a,inputValue:i,onInputChange:c}){const{messages:u,sendMessage:f,stop:m,status:h,clearChat:g,error:x,attachments:b,activeAttachments:w,toggleAttachment:j}=e,[N,T]=v.useState(""),k=i!==void 0,C=k?i:N,S=I=>{k?c?.(I):T(I)},R=v.useRef(null),A=v.useRef(null),_=h==="streaming"||h==="submitted",O=b.length>0;v.useEffect(()=>{const I=R.current;I&&(I.scrollTop=I.scrollHeight)},[u]),v.useEffect(()=>{A.current?.focus()},[]);const V=I=>{I.preventDefault();const $=C.trim();!$||_||(S(""),f({text:$}))},Z=I=>{I.stopPropagation(),I.key==="Enter"&&!I.shiftKey&&(I.preventDefault(),V(I))};return o.jsxs("div",{className:"flex flex-col h-full font-mono text-[12px]",children:[o.jsxs("div",{ref:R,className:"flex-1 overflow-y-auto frame-scrollbar p-3 space-y-3",children:[u.length===0&&o.jsx("div",{className:"text-neutral-500 text-center py-8 select-none",children:t}),u.map(I=>o.jsx("div",{className:`flex ${I.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 ${I.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:(I.parts??[]).map(($,L)=>{if(!$)return null;if($.type==="text")return o.jsx("span",{children:$.text},L);if(si($)){const P=hk($),q=Object.entries($.input??{}).map(([ee,D])=>`${ee}: ${JSON.stringify(D)}`).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:"↳ "}),P,"(",q,")"]},L)}return null})})},I.id)),_&&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:"..."})})})]}),x&&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(Az,{size:12}),o.jsx("span",{className:"truncate",children:x.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&&o.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[o.jsx(Qz,{size:11,className:"text-neutral-500 shrink-0"}),b.map(I=>{const $=w.has(I.label);return o.jsx("button",{type:"button",onClick:()=>j(I.label),className:`text-[10px] px-2 py-0.5 rounded-full border transition-colors ${$?"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:I.label},I.label)}),w.size>0&&o.jsx("span",{className:"text-[10px] text-neutral-600 ml-1",children:"attached"})]}),o.jsxs("form",{onSubmit:V,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:()=>g(),className:"p-1 rounded text-neutral-500 hover:text-neutral-300 hover:bg-neutral-700 transition-colors",title:"Clear",children:o.jsx(c4,{size:12})}),o.jsx("input",{ref:A,type:"text",value:C,onChange:I=>S(I.target.value),onKeyDown:Z,placeholder:t,className:"flex-1 bg-transparent outline-none text-neutral-100 placeholder:text-neutral-500 caret-emerald-400",disabled:_}),_?o.jsx("button",{type:"button",onClick:()=>m(),className:"p-1.5 rounded text-amber-400 hover:bg-amber-900/20 transition-colors",title:"Stop",children:o.jsx(yk,{size:12})}):o.jsx("button",{type:"submit",disabled:!C.trim(),className:"text-[11px] px-2 py-1 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/30 hover:bg-emerald-500/20 disabled:opacity-30 disabled:cursor-default transition-colors",children:"Send"})]})]})]})}const g4="modulepreload",v4=function(e){return"/"+e},Ww={},cd=function(t,n,a){let i=Promise.resolve();if(n&&n.length>0){let m=function(h){return Promise.all(h.map(g=>Promise.resolve(g).then(x=>({status:"fulfilled",value:x}),x=>({status:"rejected",reason:x}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),f=u?.nonce||u?.getAttribute("nonce");i=m(n.map(h=>{if(h=v4(h),h in Ww)return;Ww[h]=!0;const g=h.endsWith(".css"),x=g?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${x}`))return;const b=document.createElement("link");if(b.rel=g?"stylesheet":g4,g||(b.as="script"),b.crossOrigin="",b.href=h,f&&b.setAttribute("nonce",f),document.head.appendChild(b),g)return new Promise((w,j)=>{b.addEventListener("load",w),b.addEventListener("error",()=>j(new Error(`Unable to preload CSS for ${h}`)))})}))}function c(u){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=u,window.dispatchEvent(f),!f.defaultPrevented)throw u}return i.then(u=>{for(const f of u||[])f.status==="rejected"&&c(f.reason);return t().catch(c)})},y4={titleBarInset:0,dragRegionProps:{},onInteractiveMouseDown:void 0,isSSR:!0,apiBaseUrl:"",serviceApiUrl:""},x4=v.createContext(y4);function of(){return v.useContext(x4)}const b4={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"},w4=`
|
|
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 S4(){if(typeof document>"u"||document.querySelector("[data-xterm-css]"))return;const e=document.createElement("style");e.setAttribute("data-xterm-css",""),e.textContent=w4,document.head.appendChild(e)}function j4(e){return new Promise((t,n)=>{const a=new FileReader;a.onload=()=>{const i=a.result;t(i.split(",")[1])},a.onerror=n,a.readAsDataURL(e)})}function ev({relay:e,fontSize:t=12,fontFamily:n="'JetBrains Mono', 'Hack Nerd Font', monospace",configItems:a,onOpenSettings:i,onStartService:c,quiet:u=!1}){const{status:f,error:m,exitCode:h,cwd:g,setCwd:x,sendInput:b,resize:w,onData:j,connect:N,disconnect:T}=e,[k,C]=v.useState(!1),{apiBaseUrl:S}=of(),R=v.useRef(null),A=v.useRef(null),_=v.useRef(null),O=v.useRef(null),[V,Z]=v.useState(!1),[I,$]=v.useState(!1),L=v.useRef(0);v.useEffect(()=>{const W=R.current;if(!W)return;const J=de=>{de.key===" "&&!de.metaKey&&!de.ctrlKey&&!de.altKey&&de.stopPropagation()};return W.addEventListener("keydown",J),()=>W.removeEventListener("keydown",J)},[]);const P=`${S}/api/relay/upload`,q=v.useCallback(async W=>{try{const J=await j4(W),de=await fetch(P,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:W.name,data:J})}),{path:ae}=await de.json();return ae||null}catch(J){return console.error("File upload failed:",J),null}},[P]);v.useEffect(()=>{const W=R.current;if(!W)return;const J=async de=>{if(!de.clipboardData)return;const ae=Array.from(de.clipboardData.items).filter(ye=>ye.type.startsWith("image/"));if(ae.length!==0){de.preventDefault(),de.stopPropagation();for(const ye of ae){const ve=ye.getAsFile();if(!ve)continue;const be=await q(ve);be&&b(be)}}};return W.addEventListener("paste",J),()=>W.removeEventListener("paste",J)},[b,q]);const ee=v.useCallback(W=>{W.preventDefault(),W.dataTransfer.dropEffect="copy"},[]),D=v.useCallback(W=>{W.preventDefault(),L.current++,W.dataTransfer.types.includes("Files")&&$(!0)},[]),U=v.useCallback(W=>{W.preventDefault(),L.current--,L.current===0&&$(!1)},[]),B=v.useCallback(async W=>{W.preventDefault(),L.current=0,$(!1);const J=Array.from(W.dataTransfer.files).filter(de=>de.type.startsWith("image/"));if(J.length!==0)for(const de of J){const ae=await q(de);ae&&b(ae)}},[b,q]);v.useEffect(()=>{let W=!1,J=null;async function de(){const[{Terminal:ae},{FitAddon:ye},ve]=await Promise.all([cd(()=>import("./xterm-B-qIQCd3.js"),[]),cd(()=>import("./addon-fit-DX4qG4td.js"),[]),cd(()=>import("./addon-webgl-DCtw1yLn.js"),[]).catch(()=>null)]);if(S4(),W||!A.current)return;J=new ae({fontSize:t,fontFamily:n,theme:b4,cursorBlink:!0,cursorStyle:"bar",allowTransparency:!0,scrollback:5e3,convertEol:!1,allowProposedApi:!0});const be=new ye;if(J.loadAddon(be),J.open(A.current),ve)try{const _e=new ve.WebglAddon;_e.onContextLoss(()=>{_e.dispose()}),J.loadAddon(_e)}catch{}try{be.fit()}catch{}_.current=J,O.current=be,w(J.cols,J.rows),J.onData(_e=>{b(_e)}),Z(!0)}return de(),()=>{W=!0,J&&(J.dispose(),_.current=null,O.current=null)}},[]),v.useEffect(()=>{const W=_.current;if(W){W.options.fontSize=t,W.options.fontFamily=n;try{O.current?.fit()}catch{}}},[t,n]),v.useEffect(()=>{if(V)return j(W=>{_.current?.write(W)}),()=>{j(null)}},[V,j]),v.useEffect(()=>{const W=A.current;if(!W||!V)return;const J=new ResizeObserver(()=>{const de=O.current,ae=_.current;if(!(!de||!ae))try{de.fit(),w(ae.cols,ae.rows)}catch{}});return J.observe(W),()=>J.disconnect()},[V,w]),v.useEffect(()=>{f==="connected"&&_.current&&_.current.focus()},[f]);const G=v.useCallback(()=>{f==="connected"&&_.current&&_.current.focus()},[f]),K=f==="error"&&m==="Relay service is not running",z=v.useCallback(async()=>{if(c){C(!0);try{await c()&&setTimeout(()=>N(),500)}finally{C(!1)}}},[c,N]);let Y=null;return K?Y=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:c?"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:[c&&o.jsx("button",{type:"button",onClick:z,disabled:k,className:"text-[11px] px-4 py-1.5 rounded-full border border-emerald-500/30 text-emerald-400 hover:bg-emerald-500/10 transition-colors font-medium disabled:opacity-50",children:k?"Starting...":"Start Service"}),o.jsx("button",{type:"button",onClick:()=>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"}),i&&o.jsx("button",{type:"button",onClick:i,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"})]})]}):f==="error"&&m?Y=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:m}),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"})]}):f==="disconnected"&&!u?Y=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:W=>{W.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:g,onChange:W=>x(W.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"})]}),a&&a.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:a.map(W=>o.jsxs("div",{className:"contents",children:[o.jsx("span",{className:"text-neutral-500",children:W.label}),o.jsx("span",{className:"text-neutral-400 truncate text-left",children:W.value})]},W.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"}),i&&o.jsx("button",{type:"button",onClick:i,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"})]})]}):f==="connecting"&&!u&&(Y=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:()=>{T()},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:R,className:"relative flex flex-col h-full overflow-hidden",onClick:G,onDragOver:ee,onDragEnter:D,onDragLeave:U,onDrop:B,children:[Y&&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:Y}),I&&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:A,className:"flex-1 min-h-0 min-w-0 overflow-hidden",style:{visibility:Y?"hidden":"visible",padding:"4px 8px"}})]})}function N4({app:e,commands:t,state:n,relayUrl:a="ws://localhost:3600",cwd:i,agent:c="pi",provider:u,model:f,backend:m="pty",tmuxSession:h,workspaceFiles:g,onOpenSettings:x,onStartService:b,voiceKit:w}){const[j,N]=ka(`assistant.${e.id}.mode`,"relay"),[T,k]=v.useState(""),[C,S]=ka(`assistant.${e.id}.voice.speakReplies`,w?.settings.speakReplies??!1),{serviceApiUrl:R}=of(),A=v.useMemo(()=>E4(e),[e]),_=Jg({url:a,systemPrompt:A,cwd:i,workspaceFiles:g,sessionKey:`assistant-${e.id}`,backend:m,tmuxSession:h,agent:c,provider:c==="pi"?u:void 0,model:c==="pi"?f:void 0}),O=v.useCallback(async()=>{if(b)return b();try{return(await(await fetch(`${R}/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,R]),V=v.useMemo(()=>{const B=[{label:"Relay",value:a},{label:"Agent",value:c}];return i&&B.push({label:"CWD",value:i}),c==="pi"&&f&&B.push({label:"Model",value:f}),B},[a,c,i,f]),[Z,I]=v.useState("text"),$=Sz({app:e,commands:t,state:n,provider:u,model:f,onFinish:({message:B,isAbort:G,isDisconnect:K,isError:z})=>{!w||!C||G||K||z||B.role==="assistant"&&w.speakReply(B,{surface:"hudson-assistant",appId:e.id,source:Z})}}),L=v.useCallback(B=>{if(!w)return;const G=[T.trim(),B].filter(Boolean).join(" ");w.settings.autoSend&&$.status!=="streaming"&&$.status!=="submitted"?(k(""),I("voice"),$.sendMessage({text:G})):k(G)},[w,T,$]),P=v.useCallback(()=>{w&&(w.input.status==="recording"?w.input.stop():w.input.start(L))},[w,L]),q=e.intents?.length??0,ee=!!w,D=w?.input.status==="transcribing",U=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(a4,{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"}),ee&&j==="chat"&&o.jsx("button",{type:"button",onClick:()=>{C&&w?.output.stop(),S(!C)},className:`p-1 rounded transition-colors ${C?"text-cyan-300 hover:text-cyan-200":"text-neutral-500 hover:text-neutral-300"}`,title:C?"Speaker on (click to mute)":"Speaker off (click to enable)",children:w?.output.isPlaying?o.jsx(Gw,{size:12,className:"animate-spin"}):C?o.jsx(d4,{size:12}):o.jsx(h4,{size:12})}),o.jsxs("div",{className:"flex items-center gap-1 rounded-full border border-neutral-700 p-0.5",children:[o.jsx(Kw,{active:j==="relay",onClick:()=>N("relay"),children:"Relay"}),o.jsx(Kw,{active:j==="chat",onClick:()=>N("chat"),children:"Chat"})]}),j==="relay"&&_.status==="connected"&&o.jsx("button",{type:"button",onClick:()=>_.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"&&_.status==="connected"&&o.jsx("button",{type:"button",onClick:()=>_.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"&&_.status!=="connected"&&_.status!=="connecting"&&o.jsx("button",{type:"button",onClick:()=>_.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(ev,{relay:_,configItems:V,onOpenSettings:x,onStartService:O}):o.jsx(p4,{chat:$,placeholder:q===0?`Ask about ${e.name} — no intents declared, conversation only.`:`Ask ${e.name} to do something… (${q} intent${q===1?"":"s"})`,inputValue:T,onInputChange:B=>{Z==="voice"&&B.length===0&&I("text"),k(B)},inputExtras:ee&&w?.input.isSupported?o.jsx("button",{type:"button",onClick:P,disabled:D,className:`p-1 rounded transition-colors disabled:opacity-30 ${U?"bg-red-500/15 text-red-300 hover:bg-red-500/20":"text-neutral-500 hover:text-cyan-400"}`,title:U?"Stop recording":"Record voice prompt",children:D?o.jsx(Gw,{size:12,className:"animate-spin"}):U?o.jsx(yk,{size:11}):o.jsx(Pz,{size:12})}):void 0,inputStatus:ee&&w?o.jsx(k4,{inputStatus:w.input.status,inputError:w.input.error,outputStatus:w.output.status,outputError:w.output.error}):void 0})})]})}function k4({inputStatus:e,inputError:t,outputStatus:n,outputError:a}){const i=Xw(e)??Xw(n),c=t??a;return!i&&!c?null:o.jsxs("div",{className:"flex items-center gap-2",children:[i&&o.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full border font-mono ${i.className}`,children:i.label}),c&&o.jsx("span",{className:"text-[10px] text-neutral-500 truncate flex-1",title:c,children:c})]})}function Xw(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 Kw({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 E4(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 a of n)t.push(`- ${a.title} — ${a.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 lf={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}},C4=lf.panels;function tv(){const{titleBarInset:e}=of();return v.useMemo(()=>{const t=lf.layout.navHeight+e;return{navTotalHeight:t,panelTopOffset:t}},[e])}const T4=({panOffset:e,scale:t,onPan:n,onPanStart:a,onPanEnd:i,isPanLocked:c=!1,onClick:u,showGuides:f=!1,onGuidesChange:m,gridOpacity:h=1})=>{const[g,x]=v.useState(f),[b,w]=v.useState(!1),j=v.useRef(!1),N=v.useRef({x:0,y:0}),T=v.useRef({active:!1,startX:0,startY:0}),k=v.useRef(null),C=v.useRef(null),S=v.useRef(null),R=4,A=v.useRef({x:0,y:0}),_=v.useRef(0),O=v.useRef(!1);v.useEffect(()=>{x(f)},[f]);const V=v.useCallback(K=>{const z=K;return z?z.tagName==="INPUT"||z.tagName==="TEXTAREA"||z.isContentEditable:!1},[]),Z=v.useCallback(K=>{const z=K;return z?!!z.closest('button, [role="button"], a, input, textarea, select, [data-interactive="true"]'):!1},[]),I=v.useCallback(K=>{j.current=K,w(K)},[]);v.useEffect(()=>{const K=J=>{if(_.current=J.buttons,T.current.active&&(J.buttons&1)!==1&&(T.current.active=!1),j.current&&(J.buttons&1)!==1){I(!1),T.current.active=!1,i?.(),document.body.style.cursor="";return}if(c&&j.current){I(!1),T.current.active=!1,i?.(),document.body.style.cursor="";return}const de=k.current?.getBoundingClientRect(),ae=de?J.clientX-de.left:J.clientX,ye=de?J.clientY-de.top:J.clientY;if(A.current={x:ae,y:ye},C.current&&(C.current.style.left=`${ae}px`),S.current&&(S.current.style.top=`${ye}px`),T.current.active&&!j.current){const ve=J.clientX-T.current.startX,be=J.clientY-T.current.startY;Math.hypot(ve,be)>=R&&(T.current.active=!1,I(!0),O.current=!0,a?.(),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})},z=J=>{_.current=J.buttons,T.current.active=!1,j.current&&(I(!1),i?.(),document.body.style.cursor="")},Y=J=>{(J.metaKey||J.ctrlKey)&&J.key==="\\"&&(J.preventDefault(),x(de=>{const ae=!de;return m?.(ae),ae}))},W=()=>{T.current.active=!1,z(new MouseEvent("mouseup"))};return window.addEventListener("mousemove",K),window.addEventListener("mouseup",z),window.addEventListener("keydown",Y),window.addEventListener("blur",W),document.addEventListener("visibilitychange",W),()=>{window.removeEventListener("mousemove",K),window.removeEventListener("mouseup",z),window.removeEventListener("keydown",Y),window.removeEventListener("blur",W),document.removeEventListener("visibilitychange",W)}},[n,i,a,t,V,Z,c,I,m]),v.useEffect(()=>{!c||!j.current||(I(!1),i?.(),document.body.style.cursor="")},[c,i,I]);const $=K=>{O.current=!1,!(c||K.button!==0)&&(V(K.target)||Z(K.target)||(_.current=K.buttons,T.current={active:!0,startX:K.clientX,startY:K.clientY},K.preventDefault()))},L=K=>{!O.current&&u&&u(K),O.current=!1},[P,q]=v.useState({w:0,h:0});v.useEffect(()=>{const K=()=>q({w:window.innerWidth,h:window.innerHeight});return K(),window.addEventListener("resize",K),()=>window.removeEventListener("resize",K)},[]);const ee=Math.max(.4,Math.min(2,t)),D=100*ee,U=20*ee,B=(P.w/2+e.x*t)%D,G=(P.h/2+e.y*t)%D;return o.jsxs("div",{ref:k,className:`absolute inset-0 z-0 overflow-hidden bg-black ${b?"cursor-grabbing":"cursor-grab"}`,onMouseDown:$,onClick:L,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:`${U}px ${U}px`,backgroundPosition:`${B+100}px ${G+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 1.5px, transparent 1.5px)",backgroundSize:`${D}px ${D}px`,backgroundPosition:`${B+100}px ${G+100}px`}}),g&&o.jsxs(o.Fragment,{children:[o.jsx("div",{ref:C,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}})]})]})},A4=({scale:e,onZoom:t,min:n=.2,max:a=3,step:i=.1})=>{const[c,u]=v.useState(!1),[f,m]=v.useState(""),h=v.useRef(null),g=v.useCallback(T=>Math.min(a,Math.max(n,T)),[n,a]),x=v.useCallback(()=>{t(g(e+i))},[e,i,t,g]),b=v.useCallback(()=>{t(g(e-i))},[e,i,t,g]),w=v.useCallback(()=>{m(Math.round(e*100).toString()),u(!0)},[e]),j=v.useCallback(()=>{u(!1);const T=parseInt(f,10);!isNaN(T)&&T>0&&t(g(T/100))},[f,t,g]),N=v.useCallback(T=>{T.key==="Enter"?j():T.key==="Escape"&&u(!1)},[j]);return v.useEffect(()=>{c&&h.current&&(h.current.focus(),h.current.select())},[c]),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:x,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(t4,{size:14})}),o.jsx("div",{className:"w-full border-t border-b border-neutral-700/50",children:c?o.jsx("input",{ref:h,type:"text",value:f,onChange:T=>m(T.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(Hz,{size:14})})]})},R4={...zj};let Jw=0;function M4(e,t="mui"){const[n,a]=v.useState(e),i=e||n;return v.useEffect(()=>{n==null&&(Jw+=1,a(`${t}-${Jw}`))},[n,t]),i}const Qw=R4.useId;function xr(e,t){if(Qw!==void 0){const n=Qw();return e??(t?`${t}-${n}`:n)}return M4(e,t)}function ci(e,...t){const n=new URL(`https://base-ui.com/production-error/${e}`);return t.forEach(a=>n.searchParams.append("args[]",a)),`Base UI error #${e}; visit ${n} for the full message.`}const bk=v.createContext(void 0);function cf(e=!0){const t=v.useContext(bk);if(t===void 0&&!e)throw new Error(ci(25));return t}const wk=v.createContext(void 0);function Sk(e){const t=v.useContext(wk);if(t===void 0&&!e)throw new Error(ci(33));return t}const nv=v.createContext(void 0);function _o(e){const t=v.useContext(nv);if(t===void 0&&!e)throw new Error(ci(36));return t}const e1={};function Es(e,t){const n=v.useRef(e1);return n.current===e1&&(n.current=e(t)),n}function sc(e,t,n,a){const i=Es(jk).current;return O4(i,e,t,n,a)&&Nk(i,[e,t,n,a]),i.callback}function _4(e){const t=Es(jk).current;return I4(t,e)&&Nk(t,e),t.callback}function jk(){return{callback:null,cleanup:null,refs:[]}}function O4(e,t,n,a,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==a||e.refs[3]!==i}function I4(e,t){return e.refs.length!==t.length||e.refs.some((n,a)=>n!==t[a])}function Nk(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 a=Array(t.length).fill(null);for(let i=0;i<t.length;i+=1){const c=t[i];if(c!=null)switch(typeof c){case"function":{const u=c(n);typeof u=="function"&&(a[i]=u);break}case"object":{c.current=n;break}}}e.cleanup=()=>{for(let i=0;i<t.length;i+=1){const c=t[i];if(c!=null)switch(typeof c){case"function":{const u=a[i];typeof u=="function"?u():c(null);break}case"object":{c.current=null;break}}}}}}}const D4=parseInt(v.version,10);function sv(e){return D4>=e}function t1(e){if(!v.isValidElement(e))return null;const t=e,n=t.props;return(sv(19)?n?.ref:t.ref)??null}function Kp(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function z4(e,t){const n={};for(const a in e){const i=e[a];if(t?.hasOwnProperty(a)){const c=t[a](i);c!=null&&Object.assign(n,c);continue}i===!0?n[`data-${a.toLowerCase()}`]="":i&&(n[`data-${a.toLowerCase()}`]=i.toString())}return n}function L4(e,t){return typeof e=="function"?e(t):e}function $4(e,t){return typeof e=="function"?e(t):e}const Bl={};function uf(e,t,n,a,i){let c={...Jp(e,Bl)};return t&&(c=ud(c,t)),n&&(c=ud(c,n)),a&&(c=ud(c,a)),c}function P4(e){if(e.length===0)return Bl;if(e.length===1)return Jp(e[0],Bl);let t={...Jp(e[0],Bl)};for(let n=1;n<e.length;n+=1)t=ud(t,e[n]);return t}function ud(e,t){return kk(t)?t(e):U4(e,t)}function U4(e,t){if(!t)return e;for(const n in t){const a=t[n];switch(n){case"style":{e[n]=Kp(e.style,a);break}case"className":{e[n]=Ek(e.className,a);break}default:B4(n,a)?e[n]=V4(e[n],a):e[n]=a}}return e}function B4(e,t){const n=e.charCodeAt(0),a=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&a===110&&i>=65&&i<=90&&(typeof t=="function"||typeof t>"u")}function kk(e){return typeof e=="function"}function Jp(e,t){return kk(e)?e(t):e??Bl}function V4(e,t){return t?e?n=>{if(H4(n)){const i=n;Qp(i);const c=t(i);return i.baseUIHandlerPrevented||e?.(i),c}const a=t(n);return e?.(n),a}:t:e}function Qp(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function Ek(e,t){return t?e?t+" "+e:t:e}function H4(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}function Ck(){}const Tk=Object.freeze([]),Wn=Object.freeze({}),Z4=500,F4={style:{transition:"none"}},q4="data-base-ui-click-trigger",Y4={fallbackAxisSide:"none"},G4={clipPath:"inset(50%)",position:"fixed",top:0,left:0};function br(e,t,n={}){const a=t.render,i=W4(t,n);if(n.enabled===!1)return null;const c=n.state??Wn;return X4(e,a,i,c)}function W4(e,t={}){const{className:n,style:a,render:i}=e,{state:c=Wn,ref:u,props:f,stateAttributesMapping:m,enabled:h=!0}=t,g=h?L4(n,c):void 0,x=h?$4(a,c):void 0,b=h?z4(c,m):Wn,w=h?Kp(b,Array.isArray(f)?P4(f):f)??Wn:Wn;return typeof document<"u"&&(h?Array.isArray(u)?w.ref=_4([w.ref,t1(i),...u]):w.ref=sc(w.ref,t1(i),u):sc(null,null)),h?(g!==void 0&&(w.className=Ek(w.className,g)),x!==void 0&&(w.style=Kp(w.style,x)),w):Wn}function X4(e,t,n,a){if(t){if(typeof t=="function")return t(n,a);const i=uf(n,t.props);return i.ref=n.ref,v.cloneElement(t,i)}return K4(e,n)}function K4(e,t){return v.createElement(e,t)}let Md=(function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e})({});const J4={[Md.startingStyle]:""},Q4={[Md.endingStyle]:""},e3={transitionStatus(e){return e==="starting"?J4:e==="ending"?Q4:null}};let av=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=Md.startingStyle]="startingStyle",e[e.endingStyle=Md.endingStyle]="endingStyle",e.anchorHidden="data-anchor-hidden",e})({}),n1=(function(e){return e.popupOpen="data-popup-open",e.pressed="data-pressed",e})({});const t3={[n1.popupOpen]:"",[n1.pressed]:""},n3={[av.open]:""},s3={[av.closed]:""},a3={[av.anchorHidden]:""},r3={open(e){return e?t3:null}},Ak={open(e){return e?n3:s3},anchorHidden(e){return e?a3:null}},i3="none",_d="trigger-press",Kr="trigger-hover",s1="trigger-focus",rv="outside-press",Rk="item-press",df="focus-out",Mk="escape-key",dd="list-navigation",o3="cancel-open",zl="sibling-open",l3="imperative-action",Ym=zj[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],c3=Ym&&Ym!==v.useLayoutEffect?Ym:e=>e();function qe(e){const t=Es(u3).current;return t.next=e,c3(t.effect),t.trampoline}function u3(){const e={next:void 0,callback:d3,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function d3(){}function ff(){return typeof window<"u"}function wr(e){return iv(e)?(e.nodeName||"").toLowerCase():"#document"}function Tn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ra(e){var t;return(t=(iv(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function iv(e){return ff()?e instanceof Node||e instanceof Tn(e).Node:!1}function It(e){return ff()?e instanceof Element||e instanceof Tn(e).Element:!1}function Qt(e){return ff()?e instanceof HTMLElement||e instanceof Tn(e).HTMLElement:!1}function eg(e){return!ff()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Tn(e).ShadowRoot}const f3=new Set(["inline","contents"]);function ui(e){const{overflow:t,overflowX:n,overflowY:a,display:i}=cs(e);return/auto|scroll|overlay|hidden|clip/.test(t+a+n)&&!f3.has(i)}const h3=new Set(["table","td","th"]);function m3(e){return h3.has(wr(e))}const p3=[":popover-open",":modal"];function hf(e){return p3.some(t=>{try{return e.matches(t)}catch{return!1}})}const g3=["transform","translate","scale","rotate","perspective"],v3=["transform","translate","scale","rotate","perspective","filter"],y3=["paint","layout","strict","content"];function ov(e){const t=mf(),n=It(e)?cs(e):e;return g3.some(a=>n[a]?n[a]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||v3.some(a=>(n.willChange||"").includes(a))||y3.some(a=>(n.contain||"").includes(a))}function x3(e){let t=na(e);for(;Qt(t)&&!Js(t);){if(ov(t))return t;if(hf(t))return null;t=na(t)}return null}function mf(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const b3=new Set(["html","body","#document"]);function Js(e){return b3.has(wr(e))}function cs(e){return Tn(e).getComputedStyle(e)}function pf(e){return It(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function na(e){if(wr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||eg(e)&&e.host||ra(e);return eg(t)?t.host:t}function _k(e){const t=na(e);return Js(t)?e.ownerDocument?e.ownerDocument.body:e.body:Qt(t)&&ui(t)?t:_k(t)}function ur(e,t,n){var a;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=_k(e),c=i===((a=e.ownerDocument)==null?void 0:a.body),u=Tn(i);if(c){const f=tg(u);return t.concat(u,u.visualViewport||[],ui(i)?i:[],f&&n?ur(f):[])}return t.concat(i,ur(i,[],n))}function tg(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const w3=()=>{},Ze=typeof document<"u"?v.useLayoutEffect:w3,S3=v.createContext(void 0);function j3(e=!1){const t=v.useContext(S3);if(t===void 0&&!e)throw new Error(ci(16));return t}function N3(e){const{focusableWhenDisabled:t,disabled:n,composite:a=!1,tabIndex:i=0,isNativeButton:c}=e,u=a&&t!==!1,f=a&&t===!1;return{props:v.useMemo(()=>{const h={onKeyDown(g){n&&t&&g.key!=="Tab"&&g.preventDefault()}};return a||(h.tabIndex=i,!c&&n&&(h.tabIndex=t?i:-1)),(c&&(t||u)||!c&&n)&&(h["aria-disabled"]=n),c&&(!t||f)&&(h.disabled=n),h},[a,n,t,u,f,c,i])}}function k3(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:a=0,native:i=!0}=e,c=v.useRef(null),u=j3(!0)!==void 0,f=qe(()=>{const b=c.current;return!!(b?.tagName==="A"&&b?.href)}),{props:m}=N3({focusableWhenDisabled:n,disabled:t,composite:u,tabIndex:a,isNativeButton:i}),h=v.useCallback(()=>{const b=c.current;E3(b)&&u&&t&&m.disabled===void 0&&b.disabled&&(b.disabled=!1)},[t,m.disabled,u]);Ze(h,[h]);const g=v.useCallback((b={})=>{const{onClick:w,onMouseDown:j,onKeyUp:N,onKeyDown:T,onPointerDown:k,...C}=b;return uf({type:i?"button":void 0,onClick(R){if(t){R.preventDefault();return}w?.(R)},onMouseDown(R){t||j?.(R)},onKeyDown(R){if(t||(Qp(R),T?.(R)),R.baseUIHandlerPrevented)return;const A=R.target===R.currentTarget&&!i&&!f()&&!t,_=R.key==="Enter",O=R.key===" ";A&&((O||_)&&R.preventDefault(),_&&w?.(R))},onKeyUp(R){t||(Qp(R),N?.(R)),!R.baseUIHandlerPrevented&&R.target===R.currentTarget&&!i&&!t&&R.key===" "&&w?.(R)},onPointerDown(R){if(t){R.preventDefault();return}k?.(R)}},i?void 0:{role:"button"},m,C)},[t,m,i,f]),x=qe(b=>{c.current=b,h()});return{getButtonProps:g,buttonRef:x}}function E3(e){return Qt(e)&&e.tagName==="BUTTON"}const C3={type:"regular-item"};function T3(e){const{closeOnClick:t,disabled:n=!1,highlighted:a,id:i,store:c,nativeButton:u,itemMetadata:f,nodeId:m}=e,h=v.useRef(null),g=cf(!0),x=g!==void 0,{events:b}=c.useState("floatingTreeRoot"),{getButtonProps:w,buttonRef:j}=k3({disabled:n,focusableWhenDisabled:!0,native:u}),N=v.useCallback(k=>uf({id:i,role:"menuitem",tabIndex:a?0:-1,onMouseMove(C){m&&b.emit("itemhover",{nodeId:m,target:C.currentTarget})},onMouseEnter(){f.type==="submenu-trigger"&&f.setActive()},onKeyUp(C){C.key===" "&&c.context.typingRef.current&&C.preventBaseUIHandler()},onClick(C){t&&b.emit("close",{domEvent:C,reason:Rk})},onMouseUp(C){if(g){const S=g.initialCursorPointRef.current;if(g.initialCursorPointRef.current=null,x&&S&&Math.abs(C.clientX-S.x)<=1&&Math.abs(C.clientY-S.y)<=1)return}h.current&&c.context.allowMouseUpTriggerRef.current&&(!x||C.button===2)&&f.type==="regular-item"&&h.current.click()}},k,w),[i,a,w,t,b,c,x,g,f,m]),T=sc(h,j);return v.useMemo(()=>({getItemProps:N,itemRef:T}),[N,T])}const Ok=v.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function A3(){return v.useContext(Ok)}let R3=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function M3(e={}){const{label:t,metadata:n,textRef:a,indexGuessBehavior:i,index:c}=e,{register:u,unregister:f,subscribeMapChange:m,elementsRef:h,labelsRef:g,nextIndexRef:x}=A3(),b=v.useRef(-1),[w,j]=v.useState(c??(i===R3.GuessFromOrder?()=>{if(b.current===-1){const k=x.current;x.current+=1,b.current=k}return b.current}:-1)),N=v.useRef(null),T=v.useCallback(k=>{if(N.current=k,w!==-1&&k!==null&&(h.current[w]=k,g)){const C=t!==void 0;g.current[w]=C?t:a?.current?.textContent??k.textContent}},[w,h,g,t,a]);return Ze(()=>{if(c!=null)return;const k=N.current;if(k)return u(k,n),()=>{f(k)}},[c,u,f,n]),Ze(()=>{if(c==null)return m(k=>{const C=N.current?k.get(N.current)?.index:null;C!=null&&j(C)})},[c,m,j]),v.useMemo(()=>({ref:T,index:w}),[w,T])}function Ik(e){return xr(e,"base-ui")}function rn(e,t,n,a){let i=!1,c=!1;const u=Wn;return{reason:e,event:t??new Event("base-ui"),cancel(){i=!0},allowPropagation(){c=!0},get isCanceled(){return i},get isPropagationAllowed(){return c},trigger:n,...u}}var ai=Lj();const _3=[];function Dk(e){v.useEffect(e,_3)}const Lu=null;class O3{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=t=>{this.isScheduled=!1;const n=this.callbacks,a=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,a>0)for(let i=0;i<n.length;i+=1)n[i]?.(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 $u=new O3;class Xs{static create(){return new Xs}static request(t){return $u.request(t)}static cancel(t){return $u.cancel(t)}currentId=Lu;request(t){this.cancel(),this.currentId=$u.request(()=>{this.currentId=Lu,t()})}cancel=()=>{this.currentId!==Lu&&($u.cancel(this.currentId),this.currentId=Lu)};disposeEffect=()=>this.cancel}function lv(){const e=Es(Xs.create).current;return Dk(e.disposeEffect),e}function I3(e,t=!1,n=!1){const[a,i]=v.useState(e&&t?"idle":void 0),[c,u]=v.useState(e);return e&&!c&&(u(!0),i("starting")),!e&&c&&a!=="ending"&&!n&&i("ending"),!e&&!c&&a==="ending"&&i(void 0),Ze(()=>{if(!e&&c&&a!=="ending"&&n){const f=Xs.request(()=>{i("ending")});return()=>{Xs.cancel(f)}}},[e,c,a,n]),Ze(()=>{if(!e||t)return;const f=Xs.request(()=>{ai.flushSync(()=>{i(void 0)})});return()=>{Xs.cancel(f)}},[t,e]),Ze(()=>{if(!e||!t)return;e&&c&&a!=="idle"&&i("starting");const f=Xs.request(()=>{i("idle")});return()=>{Xs.cancel(f)}},[t,e,c,i,a]),v.useMemo(()=>({mounted:c,setMounted:u,transitionStatus:a}),[c,a])}function Yn(e){const t=Es(D3,e).current;return t.next=e,Ze(t.effect),t}function D3(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}function Fr(e){return e==null?e:"current"in e?e.current:e}function z3(e,t=!1,n=!0){const a=lv();return qe((i,c=null)=>{a.cancel();const u=Fr(e);u!=null&&(typeof u.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED?i():a.request(()=>{function f(){u&&Promise.all(u.getAnimations().map(m=>m.finished)).then(()=>{c!=null&&c.aborted||ai.flushSync(i)}).catch(()=>{if(n){if(c!=null&&c.aborted)return;ai.flushSync(i)}else u.getAnimations().length>0&&u.getAnimations().some(m=>m.pending||m.playState!=="finished")&&f()})}t?a.request(f):f()}))})}function zk(e){const{enabled:t=!0,open:n,ref:a,onComplete:i}=e,c=Yn(n),u=qe(i),f=z3(a,n);v.useEffect(()=>{t&&f(()=>{n===c.current&&u()})},[t,n,u,f,c])}const Lk=v.createContext(void 0);function L3(){const e=v.useContext(Lk);if(e===void 0)throw new Error(ci(31));return e}const $3=v.forwardRef(function(t,n){const{render:a,className:i,...c}=t,[u,f]=v.useState(void 0),m=v.useMemo(()=>({setLabelId:f}),[f]),h=br("div",t,{ref:n,props:{role:"group","aria-labelledby":u,...c}});return o.jsx(Lk.Provider,{value:m,children:h})}),P3=v.forwardRef(function(t,n){const{className:a,render:i,id:c,...u}=t,f=Ik(c),{setLabelId:m}=L3();return Ze(()=>(m(f),()=>{m(void 0)}),[m,f]),br("div",t,{ref:n,props:{id:f,role:"presentation",...u}})}),U3=v.forwardRef(function(t,n){const{render:a,className:i,id:c,label:u,nativeButton:f=!1,disabled:m=!1,closeOnClick:h=!0,...g}=t,x=M3({label:u}),b=Sk(!0),w=Ik(c),{store:j}=_o(),N=j.useState("isActive",x.index),T=j.useState("itemProps"),{getItemProps:k,itemRef:C}=T3({closeOnClick:h,disabled:m,highlighted:N,id:w,store:j,nativeButton:f,nodeId:b?.nodeId,itemMetadata:C3}),S=v.useMemo(()=>({disabled:m,highlighted:N}),[m,N]);return br("div",t,{state:S,props:[T,g,k],ref:[C,n,x.ref]})}),Al=0;class Eo{static create(){return new Eo}currentId=Al;start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Al,n()},t)}isStarted(){return this.currentId!==Al}clear=()=>{this.currentId!==Al&&(clearTimeout(this.currentId),this.currentId=Al)};disposeEffect=()=>this.clear}function Us(){const e=Es(Eo.create).current;return Dk(e.disposeEffect),e}const Oo=typeof navigator<"u",Gm=F3(),$k=Y3(),Pk=q3(),B3=typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter:none"),V3=Gm.platform==="MacIntel"&&Gm.maxTouchPoints>1?!0:/iP(hone|ad|od)|iOS/.test(Gm.platform),H3=Oo&&/apple/i.test(navigator.vendor),ng=Oo&&/android/i.test($k)||/android/i.test(Pk);Oo&&$k.toLowerCase().startsWith("mac")&&navigator.maxTouchPoints;const Z3=Pk.includes("jsdom/");function F3(){if(!Oo)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 q3(){if(!Oo)return"";const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:t,version:n})=>`${t}/${n}`).join(" "):navigator.userAgent}function Y3(){if(!Oo)return"";const e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??""}const sg="data-base-ui-focusable",Uk="active",Bk="selected",Vk="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",dr="ArrowLeft",fr="ArrowRight",cv="ArrowUp",mc="ArrowDown";function ir(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function Ot(e,t){if(!e||!t)return!1;const n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&eg(n)){let a=t;for(;a;){if(e===a)return!0;a=a.parentNode||a.host}}return!1}function Gn(e){return"composedPath"in e?e.composedPath()[0]:e.target}function Ds(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 G3(e){return e.matches("html,body")}function En(e){return e?.ownerDocument||document}function W3(e){return Qt(e)&&e.matches(Vk)}function ag(e){return e?e.getAttribute("role")==="combobox"&&W3(e):!1}function Od(e){return e?e.hasAttribute(sg)?e:e.querySelector(`[${sg}]`)||e:null}function xo(e,t,n=!0){return e.filter(i=>i.parentId===t&&(!n||i.context?.open)).flatMap(i=>[i,...xo(e,i.id,n)])}function a1(e,t){let n=[],a=e.find(i=>i.id===t)?.parentId;for(;a;){const i=e.find(c=>c.id===a);a=i?.parentId,i&&(n=n.concat(i))}return n}function Cn(e){e.preventDefault(),e.stopPropagation()}function X3(e){return"nativeEvent"in e}function Hk(e){return e.mozInputSource===0&&e.isTrusted?!0:ng&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Zk(e){return Z3?!1:!ng&&e.width===0&&e.height===0||ng&&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 K3(e,t){const n=["mouse","pen"];return n.push("",void 0),n.includes(e)}function J3(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}const Q3=["top","right","bottom","left"],Co=Math.min,rs=Math.max,Id=Math.round,fo=Math.floor,Qs=e=>({x:e,y:e}),eL={left:"right",right:"left",bottom:"top",top:"bottom"},tL={start:"end",end:"start"};function rg(e,t,n){return rs(e,Co(t,n))}function Ta(e,t){return typeof e=="function"?e(t):e}function is(e){return e.split("-")[0]}function Sr(e){return e.split("-")[1]}function uv(e){return e==="x"?"y":"x"}function dv(e){return e==="y"?"height":"width"}const nL=new Set(["top","bottom"]);function Ss(e){return nL.has(is(e))?"y":"x"}function fv(e){return uv(Ss(e))}function sL(e,t,n){n===void 0&&(n=!1);const a=Sr(e),i=fv(e),c=dv(i);let u=i==="x"?a===(n?"end":"start")?"right":"left":a==="start"?"bottom":"top";return t.reference[c]>t.floating[c]&&(u=Dd(u)),[u,Dd(u)]}function aL(e){const t=Dd(e);return[ig(e),t,ig(t)]}function ig(e){return e.replace(/start|end/g,t=>tL[t])}const r1=["left","right"],i1=["right","left"],rL=["top","bottom"],iL=["bottom","top"];function oL(e,t,n){switch(e){case"top":case"bottom":return n?t?i1:r1:t?r1:i1;case"left":case"right":return t?rL:iL;default:return[]}}function lL(e,t,n,a){const i=Sr(e);let c=oL(is(e),n==="start",a);return i&&(c=c.map(u=>u+"-"+i),t&&(c=c.concat(c.map(ig)))),c}function Dd(e){return e.replace(/left|right|bottom|top/g,t=>eL[t])}function cL(e){return{top:0,right:0,bottom:0,left:0,...e}}function Fk(e){return typeof e!="number"?cL(e):{top:e,right:e,bottom:e,left:e}}function zd(e){const{x:t,y:n,width:a,height:i}=e;return{width:a,height:i,top:n,left:t,right:t+a,bottom:n+i,x:t,y:n}}function Pu(e,t,n){return Math.floor(e/t)!==n}function Vl(e,t){return t<0||t>=e.current.length}function Wm(e,t){return Mn(e,{disabledIndices:t})}function o1(e,t){return Mn(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function Mn(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:a,amount:i=1}={}){let c=t;do c+=n?-i:i;while(c>=0&&c<=e.current.length-1&&Hl(e,c,a));return c}function uL(e,{event:t,orientation:n,loopFocus:a,rtl:i,cols:c,disabledIndices:u,minIndex:f,maxIndex:m,prevIndex:h,stopEvent:g=!1}){let x=h;const b=[],w={};let j=!1;{let k=null,C=-1;e.current.forEach((S,R)=>{if(S==null)return;const A=S.closest('[role="row"]');A&&(j=!0),(A!==k||C===-1)&&(k=A,C+=1,b[C]=[]),b[C].push(R),w[R]=C})}const N=j&&b.length>0&&b.some(k=>k.length!==c);function T(k){if(!N||h===-1)return;const C=w[h];if(C==null)return;const S=b[C].indexOf(h);let R=k==="up"?C-1:C+1;a&&(R<0?R=b.length-1:R>=b.length&&(R=0));const A=new Set;for(;R>=0&&R<b.length&&!A.has(R);){A.add(R);const _=b[R];if(_.length===0){R=k==="up"?R-1:R+1;continue}const O=Math.min(S,_.length-1);for(let V=O;V>=0;V-=1){const Z=_[V];if(!Hl(e,Z,u))return Z}R=k==="up"?R-1:R+1,a&&(R<0?R=b.length-1:R>=b.length&&(R=0))}}if(t.key===cv){const k=T("up");if(k!==void 0)g&&Cn(t),x=k;else{if(g&&Cn(t),h===-1)x=m;else if(x=Mn(e,{startingIndex:x,amount:c,decrement:!0,disabledIndices:u}),a&&(h-c<f||x<0)){const C=h%c,S=m%c,R=m-(S-C);S===C?x=m:x=S>C?R:R-c}Vl(e,x)&&(x=h)}}if(t.key===mc){const k=T("down");k!==void 0?(g&&Cn(t),x=k):(g&&Cn(t),h===-1?x=f:(x=Mn(e,{startingIndex:h,amount:c,disabledIndices:u}),a&&h+c>m&&(x=Mn(e,{startingIndex:h%c-c,amount:c,disabledIndices:u}))),Vl(e,x)&&(x=h))}if(n==="both"){const k=fo(h/c);t.key===(i?dr:fr)&&(g&&Cn(t),h%c!==c-1?(x=Mn(e,{startingIndex:h,disabledIndices:u}),a&&Pu(x,c,k)&&(x=Mn(e,{startingIndex:h-h%c-1,disabledIndices:u}))):a&&(x=Mn(e,{startingIndex:h-h%c-1,disabledIndices:u})),Pu(x,c,k)&&(x=h)),t.key===(i?fr:dr)&&(g&&Cn(t),h%c!==0?(x=Mn(e,{startingIndex:h,decrement:!0,disabledIndices:u}),a&&Pu(x,c,k)&&(x=Mn(e,{startingIndex:h+(c-h%c),decrement:!0,disabledIndices:u}))):a&&(x=Mn(e,{startingIndex:h+(c-h%c),decrement:!0,disabledIndices:u})),Pu(x,c,k)&&(x=h));const C=fo(m/c)===k;Vl(e,x)&&(a&&C?x=t.key===(i?fr:dr)?m:Mn(e,{startingIndex:h-h%c-1,disabledIndices:u}):x=h)}return x}function dL(e,t,n){const a=[];let i=0;return e.forEach(({width:c,height:u},f)=>{let m=!1;for(n&&(i=0);!m;){const h=[];for(let g=0;g<c;g+=1)for(let x=0;x<u;x+=1)h.push(i+g+x*t);i%t+c<=t&&h.every(g=>a[g]==null)?(h.forEach(g=>{a[g]=f}),m=!0):i+=1}}),[...a]}function fL(e,t,n,a,i){if(e===-1)return-1;const c=n.indexOf(e),u=t[e];switch(i){case"tl":return c;case"tr":return u?c+u.width-1:c;case"bl":return u?c+(u.height-1)*a:c;case"br":return n.lastIndexOf(e);default:return-1}}function hL(e,t){return t.flatMap((n,a)=>e.includes(n)?[a]:[])}function Hl(e,t,n){if(typeof n=="function")return n(t);if(n)return n.includes(t);const a=e.current[t];return a?a.hasAttribute("disabled")||a.getAttribute("aria-disabled")==="true":!1}var mL=["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] *)"],Ld=mL.join(","),qk=typeof Element>"u",To=qk?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,$d=!qk&&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},Pd=function(t,n){var a;n===void 0&&(n=!0);var i=t==null||(a=t.getAttribute)===null||a===void 0?void 0:a.call(t,"inert"),c=i===""||i==="true",u=c||n&&t&&(typeof t.closest=="function"?t.closest("[inert]"):Pd(t.parentNode));return u},pL=function(t){var n,a=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"contenteditable");return a===""||a==="true"},Yk=function(t,n,a){if(Pd(t))return[];var i=Array.prototype.slice.apply(t.querySelectorAll(Ld));return n&&To.call(t,Ld)&&i.unshift(t),i=i.filter(a),i},Ud=function(t,n,a){for(var i=[],c=Array.from(t);c.length;){var u=c.shift();if(!Pd(u,!1))if(u.tagName==="SLOT"){var f=u.assignedElements(),m=f.length?f:u.children,h=Ud(m,!0,a);a.flatten?i.push.apply(i,h):i.push({scopeParent:u,candidates:h})}else{var g=To.call(u,Ld);g&&a.filter(u)&&(n||!t.includes(u))&&i.push(u);var x=u.shadowRoot||typeof a.getShadowRoot=="function"&&a.getShadowRoot(u),b=!Pd(x,!1)&&(!a.shadowRootFilter||a.shadowRootFilter(u));if(x&&b){var w=Ud(x===!0?u.children:x.children,!0,a);a.flatten?i.push.apply(i,w):i.push({scopeParent:u,candidates:w})}else c.unshift.apply(c,u.children)}}return i},Gk=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},Wk=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||pL(t))&&!Gk(t)?0:t.tabIndex},gL=function(t,n){var a=Wk(t);return a<0&&n&&!Gk(t)?0:a},vL=function(t,n){return t.tabIndex===n.tabIndex?t.documentOrder-n.documentOrder:t.tabIndex-n.tabIndex},Xk=function(t){return t.tagName==="INPUT"},yL=function(t){return Xk(t)&&t.type==="hidden"},xL=function(t){var n=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(a){return a.tagName==="SUMMARY"});return n},bL=function(t,n){for(var a=0;a<t.length;a++)if(t[a].checked&&t[a].form===n)return t[a]},wL=function(t){if(!t.name)return!0;var n=t.form||$d(t),a=function(f){return n.querySelectorAll('input[type="radio"][name="'+f+'"]')},i;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")i=a(window.CSS.escape(t.name));else try{i=a(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 c=bL(i,t.form);return!c||c===t},SL=function(t){return Xk(t)&&t.type==="radio"},jL=function(t){return SL(t)&&!wL(t)},NL=function(t){var n,a=t&&$d(t),i=(n=a)===null||n===void 0?void 0:n.host,c=!1;if(a&&a!==t){var u,f,m;for(c=!!((u=i)!==null&&u!==void 0&&(f=u.ownerDocument)!==null&&f!==void 0&&f.contains(i)||t!=null&&(m=t.ownerDocument)!==null&&m!==void 0&&m.contains(t));!c&&i;){var h,g,x;a=$d(i),i=(h=a)===null||h===void 0?void 0:h.host,c=!!((g=i)!==null&&g!==void 0&&(x=g.ownerDocument)!==null&&x!==void 0&&x.contains(i))}}return c},l1=function(t){var n=t.getBoundingClientRect(),a=n.width,i=n.height;return a===0&&i===0},kL=function(t,n){var a=n.displayCheck,i=n.getShadowRoot;if(a==="full-native"&&"checkVisibility"in t){var c=t.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!c}if(getComputedStyle(t).visibility==="hidden")return!0;var u=To.call(t,"details>summary:first-of-type"),f=u?t.parentElement:t;if(To.call(f,"details:not([open]) *"))return!0;if(!a||a==="full"||a==="full-native"||a==="legacy-full"){if(typeof i=="function"){for(var m=t;t;){var h=t.parentElement,g=$d(t);if(h&&!h.shadowRoot&&i(h)===!0)return l1(t);t.assignedSlot?t=t.assignedSlot:!h&&g!==t.ownerDocument?t=g.host:t=h}t=m}if(NL(t))return!t.getClientRects().length;if(a!=="legacy-full")return!0}else if(a==="non-zero-area")return l1(t);return!1},EL=function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var n=t.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var a=0;a<n.children.length;a++){var i=n.children.item(a);if(i.tagName==="LEGEND")return To.call(n,"fieldset[disabled] *")?!0:!i.contains(t)}return!0}n=n.parentElement}return!1},og=function(t,n){return!(n.disabled||yL(n)||kL(n,t)||xL(n)||EL(n))},lg=function(t,n){return!(jL(n)||Wk(n)<0||!og(t,n))},CL=function(t){var n=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},Kk=function(t){var n=[],a=[];return t.forEach(function(i,c){var u=!!i.scopeParent,f=u?i.scopeParent:i,m=gL(f,u),h=u?Kk(i.candidates):f;m===0?u?n.push.apply(n,h):n.push(f):a.push({documentOrder:c,tabIndex:m,item:i,isScope:u,content:h})}),a.sort(vL).reduce(function(i,c){return c.isScope?i.push.apply(i,c.content):i.push(c.content),i},[]).concat(n)},gf=function(t,n){n=n||{};var a;return n.getShadowRoot?a=Ud([t],n.includeContainer,{filter:lg.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:CL}):a=Yk(t,n.includeContainer,lg.bind(null,n)),Kk(a)},TL=function(t,n){n=n||{};var a;return n.getShadowRoot?a=Ud([t],n.includeContainer,{filter:og.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):a=Yk(t,n.includeContainer,og.bind(null,n)),a},Jk=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return To.call(t,Ld)===!1?!1:lg(n,t)};const pc=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Qk(e,t){const n=gf(e,pc()),a=n.length;if(a===0)return;const i=ir(En(e)),c=n.indexOf(i),u=c===-1?t===1?0:a-1:c+t;return n[u]}function eE(e){return Qk(En(e).body,1)||e}function tE(e){return Qk(En(e).body,-1)||e}function Zl(e,t){const n=t||e.currentTarget,a=e.relatedTarget;return!a||!Ot(n,a)}function AL(e){gf(e,pc()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function c1(e){e.querySelectorAll("[data-tabindex]").forEach(n=>{const a=n.dataset.tabindex;delete n.dataset.tabindex,a?n.setAttribute("tabindex",a):n.removeAttribute("tabindex")})}function nE(){const e=new Map;return{emit(t,n){e.get(t)?.forEach(a=>a(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 sE{nodesRef={current:[]};events=nE();addNode(t){this.nodesRef.current.push(t)}removeNode(t){const n=this.nodesRef.current.findIndex(a=>a===t);n!==-1&&this.nodesRef.current.splice(n,1)}}const aE=v.createContext(null),rE=v.createContext(null),jr=()=>v.useContext(aE)?.id||null,Io=e=>{const t=v.useContext(rE);return e??t};function RL(e){const t=xr(),n=Io(e),a=jr();return Ze(()=>{if(!t)return;const i={id:t,parentId:a};return n?.addNode(i),()=>{n?.removeNode(i)}},[n,t,a]),t}function ML(e){const{children:t,id:n}=e,a=jr();return o.jsx(aE.Provider,{value:v.useMemo(()=>({id:n,parentId:a}),[n,a]),children:t})}function _L(e){const{children:t,externalTree:n}=e,a=Es(()=>n??new sE).current;return o.jsx(rE.Provider,{value:a,children:t})}function ac(e){return`data-base-ui-${e}`}const iE={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 ri(e){return e?.ownerDocument||document}const Bd=v.forwardRef(function(t,n){const[a,i]=v.useState();Ze(()=>{H3&&i("button")},[]);const c={tabIndex:0,role:a};return o.jsx("span",{...t,ref:n,style:iE,"aria-hidden":a?void 0:!0,...c,"data-base-ui-focus-guard":""})});let u1=0;function fd(e,t={}){const{preventScroll:n=!1,cancelPrevious:a=!0,sync:i=!1}=t;a&&cancelAnimationFrame(u1);const c=()=>e?.focus({preventScroll:n});i?c():u1=requestAnimationFrame(c)}const bo={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function d1(e){return e==="inert"?bo.inert:e==="aria-hidden"?bo["aria-hidden"]:bo.none}let Uu=new WeakSet,Bu={},Xm=0;const oE=e=>e&&(e.host||oE(e.parentNode)),OL=(e,t)=>t.map(n=>{if(e.contains(n))return n;const a=oE(n);return e.contains(a)?a:null}).filter(n=>n!=null);function IL(e,t,n,a){const i="data-base-ui-inert",c=a?"inert":n?"aria-hidden":null,u=OL(t,e),f=new Set,m=new Set(u),h=[];Bu[i]||(Bu[i]=new WeakMap);const g=Bu[i];u.forEach(x),b(t),f.clear();function x(w){!w||f.has(w)||(f.add(w),w.parentNode&&x(w.parentNode))}function b(w){!w||m.has(w)||[].forEach.call(w.children,j=>{if(wr(j)!=="script")if(f.has(j))b(j);else{const N=c?j.getAttribute(c):null,T=N!==null&&N!=="false",k=d1(c),C=(k.get(j)||0)+1,S=(g.get(j)||0)+1;k.set(j,C),g.set(j,S),h.push(j),C===1&&T&&Uu.add(j),S===1&&j.setAttribute(i,""),!T&&c&&j.setAttribute(c,c==="inert"?"":"true")}})}return Xm+=1,()=>{h.forEach(w=>{const j=d1(c),T=(j.get(w)||0)-1,k=(g.get(w)||0)-1;j.set(w,T),g.set(w,k),T||(!Uu.has(w)&&c&&w.removeAttribute(c),Uu.delete(w)),k||w.removeAttribute(i)}),Xm-=1,Xm||(bo.inert=new WeakMap,bo["aria-hidden"]=new WeakMap,bo.none=new WeakMap,Uu=new WeakSet,Bu={})}}function DL(e,t=!1,n=!1){const a=En(e[0]).body;return IL(e.concat(Array.from(a.querySelectorAll("[aria-live]"))),a,t,n)}const lE=v.createContext(null),cE=()=>v.useContext(lE),zL=ac("portal");function LL(e={}){const{ref:t,container:n,componentProps:a=Wn,elementProps:i,elementState:c}=e,u=xr(),m=cE()?.portalNode,[h,g]=v.useState(null),[x,b]=v.useState(null),w=v.useRef(null);Ze(()=>{if(n===null){w.current&&(w.current=null,b(null),g(null));return}if(u==null)return;const T=(n&&(iv(n)?n:n.current))??m??document.body;if(T==null){w.current&&(w.current=null,b(null),g(null));return}w.current!==T&&(w.current=T,b(null),g(T))},[n,m,u]);const j=br("div",a,{ref:[t,b],state:c,props:[{id:u,[zL]:""},i]});return{portalNode:x,portalSubtree:h&&j?ai.createPortal(j,h):null}}const $L=v.forwardRef(function(t,n){const{children:a,container:i,className:c,render:u,renderGuards:f,...m}=t,{portalNode:h,portalSubtree:g}=LL({container:i,ref:n,componentProps:t,elementProps:m}),x=v.useRef(null),b=v.useRef(null),w=v.useRef(null),j=v.useRef(null),[N,T]=v.useState(null),k=N?.modal,C=N?.open,S=typeof f=="boolean"?f:!!N&&!N.modal&&N.open&&!!h;v.useEffect(()=>{if(!h||k)return;function A(_){h&&Zl(_)&&(_.type==="focusin"?c1:AL)(h)}return h.addEventListener("focusin",A,!0),h.addEventListener("focusout",A,!0),()=>{h.removeEventListener("focusin",A,!0),h.removeEventListener("focusout",A,!0)}},[h,k]),v.useEffect(()=>{!h||C||c1(h)},[C,h]);const R=v.useMemo(()=>({beforeOutsideRef:x,afterOutsideRef:b,beforeInsideRef:w,afterInsideRef:j,portalNode:h,setFocusManagerState:T}),[h]);return o.jsxs(v.Fragment,{children:[g,o.jsxs(lE.Provider,{value:R,children:[S&&h&&o.jsx(Bd,{"data-type":"outside",ref:x,onFocus:A=>{if(Zl(A,h))w.current?.focus();else{const _=N?N.domReference:null;tE(_)?.focus()}}}),S&&h&&o.jsx("span",{"aria-owns":h.id,style:G4}),h&&ai.createPortal(a,h),S&&h&&o.jsx(Bd,{"data-type":"outside",ref:b,onFocus:A=>{if(Zl(A,h))j.current?.focus();else{const _=N?N.domReference:null;eE(_)?.focus(),N?.closeOnFocusOut&&N?.onOpenChange(!1,rn(df,A.nativeEvent))}}})]})]})});function PL(e,t){const n=Tn(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 f1=20;let or=[];function hv(){or=or.filter(e=>e.isConnected)}function UL(e){hv(),e&&wr(e)!=="body"&&(or.push(e),or.length>f1&&(or=or.slice(-f1)))}function Km(){return hv(),or[or.length-1]}function BL(e){if(!e)return null;const t=pc();return Jk(e,t)?e:gf(e,t)[0]||e}function VL(e){return!e||!e.isConnected?!1:typeof e.checkVisibility=="function"?e.checkVisibility():cs(e).display!=="none"}function h1(e,t){if(!t.current.includes("floating")&&!e.getAttribute("role")?.includes("dialog"))return;const n=pc(),i=TL(e,n).filter(u=>{const f=u.getAttribute("data-tabindex")||"";return Jk(u,n)||u.hasAttribute("data-tabindex")&&!f.startsWith("-")}),c=e.getAttribute("tabindex");t.current.includes("floating")||i.length===0?c!=="0"&&e.setAttribute("tabindex","0"):(c!=="-1"||e.hasAttribute("data-tabindex")&&e.getAttribute("data-tabindex")!=="-1")&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}function HL(e){const{context:t,children:n,disabled:a=!1,order:i=["content"],initialFocus:c=!0,returnFocus:u=!0,restoreFocus:f=!1,modal:m=!0,closeOnFocusOut:h=!0,openInteractionType:g="",getInsideElements:x=()=>[],nextFocusableElement:b,previousFocusableElement:w,beforeContentFocusGuardRef:j,externalTree:N}=e,T="rootStore"in t?t.rootStore:t,k=T.useState("open"),C=T.useState("domReferenceElement"),S=T.useState("floatingElement"),{events:R,dataRef:A}=T.context,_=qe(()=>A.current.floatingContext?.nodeId),O=qe(x),V=c===!1,Z=ag(C)&&V,I=Yn(i),$=Yn(c),L=Yn(u),P=Yn(g),q=Io(N),ee=cE(),D=v.useRef(null),U=v.useRef(null),B=v.useRef(!1),G=v.useRef(!1),K=v.useRef(!1),z=v.useRef(-1),Y=v.useRef(""),W=v.useRef(""),J=Us(),de=Us(),ae=lv(),ye=ee!=null,ve=Od(S),be=qe((xe=ve)=>xe?gf(xe,pc()):[]),_e=qe(xe=>{const Ee=be(xe);return I.current.map(()=>Ee).filter(Boolean).flat()});v.useEffect(()=>{if(a||!m)return;function xe(Ye){Ye.key==="Tab"&&Ot(ve,ir(En(ve)))&&be().length===0&&!Z&&Cn(Ye)}const Ee=En(ve);return Ee.addEventListener("keydown",xe),()=>{Ee.removeEventListener("keydown",xe)}},[a,C,ve,m,I,Z,be,_e]),v.useEffect(()=>{if(a||!S)return;function xe(Ee){const Ye=Gn(Ee),He=be().indexOf(Ye);He!==-1&&(z.current=He)}return S.addEventListener("focusin",xe),()=>{S.removeEventListener("focusin",xe)}},[a,S,be]),v.useEffect(()=>{if(a||!k)return;const xe=En(ve);function Ee(){K.current=!1}function Ye(He){const ce=Gn(He),he=Ot(S,ce)||Ot(C,ce)||Ot(ee?.portalNode,ce);K.current=!he,W.current=He.pointerType||"keyboard"}function Be(){W.current="keyboard"}return xe.addEventListener("pointerdown",Ye,!0),xe.addEventListener("pointerup",Ee,!0),xe.addEventListener("pointercancel",Ee,!0),xe.addEventListener("keydown",Be,!0),()=>{xe.removeEventListener("pointerdown",Ye,!0),xe.removeEventListener("pointerup",Ee,!0),xe.removeEventListener("pointercancel",Ee,!0),xe.removeEventListener("keydown",Be,!0)}},[a,S,C,ve,k,ee]),v.useEffect(()=>{if(a||!h)return;function xe(){G.current=!0,de.start(0,()=>{G.current=!1})}function Ee(ce){const he=ce.relatedTarget,pe=ce.currentTarget,je=Gn(ce);queueMicrotask(()=>{const Ne=_(),Je=T.context.triggerElements,et=!(Ot(C,he)||Ot(S,he)||Ot(he,S)||Ot(ee?.portalNode,he)||he!=null&&Je.hasElement(he)||Je.hasMatchingElement(Ge=>Ot(Ge,he))||he?.hasAttribute(ac("focus-guard"))||q&&(xo(q.nodesRef.current,Ne).find(Ge=>Ot(Ge.context?.elements.floating,he)||Ot(Ge.context?.elements.domReference,he))||a1(q.nodesRef.current,Ne).find(Ge=>[Ge.context?.elements.floating,Od(Ge.context?.elements.floating)].includes(he)||Ge.context?.elements.domReference===he)));if(pe===C&&ve&&h1(ve,I),f&&pe!==C&&!VL(je)&&ir(En(ve))===En(ve).body){if(Qt(ve)&&(ve.focus(),f==="popup")){ae.request(()=>{ve.focus()});return}const Ge=z.current,Bt=be(),Et=Bt[Ge]||Bt[Bt.length-1]||ve;Qt(Et)&&Et.focus()}if(A.current.insideReactTree){A.current.insideReactTree=!1;return}(Z||!m)&&he&&et&&!G.current&&(Z||he!==Km())&&(B.current=!0,T.setOpen(!1,rn(df,ce)))})}function Ye(){K.current||(A.current.insideReactTree=!0,J.start(0,()=>{A.current.insideReactTree=!1}))}const Be=Qt(C)?C:null,He=[];if(!(!S&&!Be))return Be&&(Be.addEventListener("focusout",Ee),Be.addEventListener("pointerdown",xe),He.push(()=>{Be.removeEventListener("focusout",Ee),Be.removeEventListener("pointerdown",xe)})),S&&(S.addEventListener("focusout",Ee),ee&&(S.addEventListener("focusout",Ye,!0),He.push(()=>{S.removeEventListener("focusout",Ye,!0)})),He.push(()=>{S.removeEventListener("focusout",Ee)})),()=>{He.forEach(ce=>{ce()})}},[a,C,S,ve,m,q,ee,T,h,f,be,Z,_,I,A,J,de,ae]);const ie=v.useRef(null),ke=v.useRef(null),we=sc(ie,j,ee?.beforeInsideRef),Ue=sc(ke,ee?.afterInsideRef);v.useEffect(()=>{if(a||!S||!k)return;const xe=Array.from(ee?.portalNode?.querySelectorAll(`[${ac("portal")}]`)||[]),Ye=(q?a1(q.nodesRef.current,_()):[]).find(ce=>ag(ce.context?.elements.domReference||null))?.context?.elements.domReference,Be=[S,Ye,...xe,...O(),D.current,U.current,ie.current,ke.current,ee?.beforeOutsideRef.current,ee?.afterOutsideRef.current,Fr(w),Fr(b),Z?C:null].filter(ce=>ce!=null),He=DL(Be,m||Z);return()=>{He()}},[k,a,C,S,m,I,ee,Z,q,_,O,b,w]),Ze(()=>{if(!k||a||!Qt(ve))return;const xe=En(ve),Ee=ir(xe);queueMicrotask(()=>{const Ye=_e(ve),Be=$.current,He=typeof Be=="function"?Be(P.current||""):Be;if(He===void 0||He===!1)return;let ce;He===!0||He===null?ce=Ye[0]||ve:ce=Fr(He),ce=ce||Ye[0]||ve,!Ot(ve,Ee)&&fd(ce,{preventScroll:ce===ve})})},[a,k,ve,V,_e,$,P]),Ze(()=>{if(a||!ve)return;const xe=En(ve),Ee=ir(xe);UL(Ee);function Ye(ce){if(ce.open||(Y.current=PL(ce.nativeEvent,W.current)),ce.reason===Kr&&ce.nativeEvent.type==="mouseleave"&&(B.current=!0),ce.reason===rv)if(ce.nested)B.current=!1;else if(Hk(ce.nativeEvent)||Zk(ce.nativeEvent))B.current=!1;else{let he=!1;document.createElement("div").focus({get preventScroll(){return he=!0,!1}}),he?B.current=!1:B.current=!0}}R.on("openchange",Ye);const Be=xe.createElement("span");Be.setAttribute("tabindex","-1"),Be.setAttribute("aria-hidden","true"),Object.assign(Be.style,iE),ye&&C&&C.insertAdjacentElement("afterend",Be);function He(){const ce=L.current;let he=typeof ce=="function"?ce(Y.current):ce;if(he===void 0||he===!1)return null;if(he===null&&(he=!0),typeof he=="boolean"){const je=C||Km();return je&&je.isConnected?je:Be}const pe=C||Km()||Be;return Fr(he)||pe}return()=>{R.off("openchange",Ye);const ce=ir(xe),he=Ot(S,ce)||q&&xo(q.nodesRef.current,_(),!1).some(je=>Ot(je.context?.elements.floating,ce)),pe=He();queueMicrotask(()=>{const je=BL(pe),Ne=typeof L.current!="boolean";L.current&&!B.current&&Qt(je)&&(!(!Ne&&je!==ce&&ce!==xe.body)||he)&&je.focus({preventScroll:!0}),Be.remove()})}},[a,S,ve,L,A,R,q,ye,C,_]),v.useEffect(()=>{queueMicrotask(()=>{B.current=!1})},[a]),v.useEffect(()=>{if(a||!k)return;function xe(Ye){Gn(Ye)?.closest(`[${q4}]`)&&(G.current=!0)}const Ee=En(ve);return Ee.addEventListener("pointerdown",xe,!0),()=>{Ee.removeEventListener("pointerdown",xe,!0)}},[a,k,ve]),Ze(()=>{if(!a&&ee)return ee.setFocusManagerState({modal:m,closeOnFocusOut:h,open:k,onOpenChange:T.setOpen,domReference:C}),()=>{ee.setFocusManagerState(null)}},[a,ee,m,k,T,h,C]),Ze(()=>{if(!(a||!ve))return h1(ve,I),()=>{queueMicrotask(hv)}},[a,ve,I]);const Ae=!a&&(m?!Z:!0)&&(ye||m);return o.jsxs(v.Fragment,{children:[Ae&&o.jsx(Bd,{"data-type":"inside",ref:we,onFocus:xe=>{if(m){const Ee=_e();fd(Ee[Ee.length-1])}else ee?.portalNode&&(B.current=!1,Zl(xe,ee.portalNode)?eE(C)?.focus():Fr(w??ee.beforeOutsideRef)?.focus())}}),n,Ae&&o.jsx(Bd,{"data-type":"inside",ref:Ue,onFocus:xe=>{m?fd(_e()[0]):ee?.portalNode&&(h&&(B.current=!0),Zl(xe,ee.portalNode)?tE(C)?.focus():Fr(b??ee.afterOutsideRef)?.focus())}})]})}function m1(e,t,n){let{reference:a,floating:i}=e;const c=Ss(t),u=fv(t),f=dv(u),m=is(t),h=c==="y",g=a.x+a.width/2-i.width/2,x=a.y+a.height/2-i.height/2,b=a[f]/2-i[f]/2;let w;switch(m){case"top":w={x:g,y:a.y-i.height};break;case"bottom":w={x:g,y:a.y+a.height};break;case"right":w={x:a.x+a.width,y:x};break;case"left":w={x:a.x-i.width,y:x};break;default:w={x:a.x,y:a.y}}switch(Sr(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 ZL(e,t){var n;t===void 0&&(t={});const{x:a,y:i,platform:c,rects:u,elements:f,strategy:m}=e,{boundary:h="clippingAncestors",rootBoundary:g="viewport",elementContext:x="floating",altBoundary:b=!1,padding:w=0}=Ta(t,e),j=Fk(w),T=f[b?x==="floating"?"reference":"floating":x],k=zd(await c.getClippingRect({element:(n=await(c.isElement==null?void 0:c.isElement(T)))==null||n?T:T.contextElement||await(c.getDocumentElement==null?void 0:c.getDocumentElement(f.floating)),boundary:h,rootBoundary:g,strategy:m})),C=x==="floating"?{x:a,y:i,width:u.floating.width,height:u.floating.height}:u.reference,S=await(c.getOffsetParent==null?void 0:c.getOffsetParent(f.floating)),R=await(c.isElement==null?void 0:c.isElement(S))?await(c.getScale==null?void 0:c.getScale(S))||{x:1,y:1}:{x:1,y:1},A=zd(c.convertOffsetParentRelativeRectToViewportRelativeRect?await c.convertOffsetParentRelativeRectToViewportRelativeRect({elements:f,rect:C,offsetParent:S,strategy:m}):C);return{top:(k.top-A.top+j.top)/R.y,bottom:(A.bottom-k.bottom+j.bottom)/R.y,left:(k.left-A.left+j.left)/R.x,right:(A.right-k.right+j.right)/R.x}}const FL=async(e,t,n)=>{const{placement:a="bottom",strategy:i="absolute",middleware:c=[],platform:u}=n,f=c.filter(Boolean),m=await(u.isRTL==null?void 0:u.isRTL(t));let h=await u.getElementRects({reference:e,floating:t,strategy:i}),{x:g,y:x}=m1(h,a,m),b=a,w={},j=0;for(let T=0;T<f.length;T++){var N;const{name:k,fn:C}=f[T],{x:S,y:R,data:A,reset:_}=await C({x:g,y:x,initialPlacement:a,placement:b,strategy:i,middlewareData:w,rects:h,platform:{...u,detectOverflow:(N=u.detectOverflow)!=null?N:ZL},elements:{reference:e,floating:t}});g=S??g,x=R??x,w={...w,[k]:{...w[k],...A}},_&&j<=50&&(j++,typeof _=="object"&&(_.placement&&(b=_.placement),_.rects&&(h=_.rects===!0?await u.getElementRects({reference:e,floating:t,strategy:i}):_.rects),{x:g,y:x}=m1(h,b,m)),T=-1)}return{x:g,y:x,placement:b,strategy:i,middlewareData:w}},qL=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,a;const{placement:i,middlewareData:c,rects:u,initialPlacement:f,platform:m,elements:h}=t,{mainAxis:g=!0,crossAxis:x=!0,fallbackPlacements:b,fallbackStrategy:w="bestFit",fallbackAxisSideDirection:j="none",flipAlignment:N=!0,...T}=Ta(e,t);if((n=c.arrow)!=null&&n.alignmentOffset)return{};const k=is(i),C=Ss(f),S=is(f)===f,R=await(m.isRTL==null?void 0:m.isRTL(h.floating)),A=b||(S||!N?[Dd(f)]:aL(f)),_=j!=="none";!b&&_&&A.push(...lL(f,N,j,R));const O=[f,...A],V=await m.detectOverflow(t,T),Z=[];let I=((a=c.flip)==null?void 0:a.overflows)||[];if(g&&Z.push(V[k]),x){const q=sL(i,u,R);Z.push(V[q[0]],V[q[1]])}if(I=[...I,{placement:i,overflows:Z}],!Z.every(q=>q<=0)){var $,L;const q=((($=c.flip)==null?void 0:$.index)||0)+1,ee=O[q];if(ee&&(!(x==="alignment"?C!==Ss(ee):!1)||I.every(B=>Ss(B.placement)===C?B.overflows[0]>0:!0)))return{data:{index:q,overflows:I},reset:{placement:ee}};let D=(L=I.filter(U=>U.overflows[0]<=0).sort((U,B)=>U.overflows[1]-B.overflows[1])[0])==null?void 0:L.placement;if(!D)switch(w){case"bestFit":{var P;const U=(P=I.filter(B=>{if(_){const G=Ss(B.placement);return G===C||G==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(G=>G>0).reduce((G,K)=>G+K,0)]).sort((B,G)=>B[1]-G[1])[0])==null?void 0:P[0];U&&(D=U);break}case"initialPlacement":D=f;break}if(i!==D)return{reset:{placement:D}}}return{}}}};function p1(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function g1(e){return Q3.some(t=>e[t]>=0)}const YL=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:a}=t,{strategy:i="referenceHidden",...c}=Ta(e,t);switch(i){case"referenceHidden":{const u=await a.detectOverflow(t,{...c,elementContext:"reference"}),f=p1(u,n.reference);return{data:{referenceHiddenOffsets:f,referenceHidden:g1(f)}}}case"escaped":{const u=await a.detectOverflow(t,{...c,altBoundary:!0}),f=p1(u,n.floating);return{data:{escapedOffsets:f,escaped:g1(f)}}}default:return{}}}}},uE=new Set(["left","top"]);async function GL(e,t){const{placement:n,platform:a,elements:i}=e,c=await(a.isRTL==null?void 0:a.isRTL(i.floating)),u=is(n),f=Sr(n),m=Ss(n)==="y",h=uE.has(u)?-1:1,g=c&&m?-1:1,x=Ta(t,e);let{mainAxis:b,crossAxis:w,alignmentAxis:j}=typeof x=="number"?{mainAxis:x,crossAxis:0,alignmentAxis:null}:{mainAxis:x.mainAxis||0,crossAxis:x.crossAxis||0,alignmentAxis:x.alignmentAxis};return f&&typeof j=="number"&&(w=f==="end"?j*-1:j),m?{x:w*g,y:b*h}:{x:b*h,y:w*g}}const WL=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,a;const{x:i,y:c,placement:u,middlewareData:f}=t,m=await GL(t,e);return u===((n=f.offset)==null?void 0:n.placement)&&(a=f.arrow)!=null&&a.alignmentOffset?{}:{x:i+m.x,y:c+m.y,data:{...m,placement:u}}}}},XL=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:a,placement:i,platform:c}=t,{mainAxis:u=!0,crossAxis:f=!1,limiter:m={fn:k=>{let{x:C,y:S}=k;return{x:C,y:S}}},...h}=Ta(e,t),g={x:n,y:a},x=await c.detectOverflow(t,h),b=Ss(is(i)),w=uv(b);let j=g[w],N=g[b];if(u){const k=w==="y"?"top":"left",C=w==="y"?"bottom":"right",S=j+x[k],R=j-x[C];j=rg(S,j,R)}if(f){const k=b==="y"?"top":"left",C=b==="y"?"bottom":"right",S=N+x[k],R=N-x[C];N=rg(S,N,R)}const T=m.fn({...t,[w]:j,[b]:N});return{...T,data:{x:T.x-n,y:T.y-a,enabled:{[w]:u,[b]:f}}}}}},KL=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:a,placement:i,rects:c,middlewareData:u}=t,{offset:f=0,mainAxis:m=!0,crossAxis:h=!0}=Ta(e,t),g={x:n,y:a},x=Ss(i),b=uv(x);let w=g[b],j=g[x];const N=Ta(f,t),T=typeof N=="number"?{mainAxis:N,crossAxis:0}:{mainAxis:0,crossAxis:0,...N};if(m){const S=b==="y"?"height":"width",R=c.reference[b]-c.floating[S]+T.mainAxis,A=c.reference[b]+c.reference[S]-T.mainAxis;w<R?w=R:w>A&&(w=A)}if(h){var k,C;const S=b==="y"?"width":"height",R=uE.has(is(i)),A=c.reference[x]-c.floating[S]+(R&&((k=u.offset)==null?void 0:k[x])||0)+(R?0:T.crossAxis),_=c.reference[x]+c.reference[S]+(R?0:((C=u.offset)==null?void 0:C[x])||0)-(R?T.crossAxis:0);j<A?j=A:j>_&&(j=_)}return{[b]:w,[x]:j}}}},JL=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,a;const{placement:i,rects:c,platform:u,elements:f}=t,{apply:m=()=>{},...h}=Ta(e,t),g=await u.detectOverflow(t,h),x=is(i),b=Sr(i),w=Ss(i)==="y",{width:j,height:N}=c.floating;let T,k;x==="top"||x==="bottom"?(T=x,k=b===(await(u.isRTL==null?void 0:u.isRTL(f.floating))?"start":"end")?"left":"right"):(k=x,T=b==="end"?"top":"bottom");const C=N-g.top-g.bottom,S=j-g.left-g.right,R=Co(N-g[T],C),A=Co(j-g[k],S),_=!t.middlewareData.shift;let O=R,V=A;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(V=S),(a=t.middlewareData.shift)!=null&&a.enabled.y&&(O=C),_&&!b){const I=rs(g.left,0),$=rs(g.right,0),L=rs(g.top,0),P=rs(g.bottom,0);w?V=j-2*(I!==0||$!==0?I+$:rs(g.left,g.right)):O=N-2*(L!==0||P!==0?L+P:rs(g.top,g.bottom))}await m({...t,availableWidth:V,availableHeight:O});const Z=await u.getDimensions(f.floating);return j!==Z.width||N!==Z.height?{reset:{rects:!0}}:{}}}};function dE(e){const t=cs(e);let n=parseFloat(t.width)||0,a=parseFloat(t.height)||0;const i=Qt(e),c=i?e.offsetWidth:n,u=i?e.offsetHeight:a,f=Id(n)!==c||Id(a)!==u;return f&&(n=c,a=u),{width:n,height:a,$:f}}function mv(e){return It(e)?e:e.contextElement}function wo(e){const t=mv(e);if(!Qt(t))return Qs(1);const n=t.getBoundingClientRect(),{width:a,height:i,$:c}=dE(t);let u=(c?Id(n.width):n.width)/a,f=(c?Id(n.height):n.height)/i;return(!u||!Number.isFinite(u))&&(u=1),(!f||!Number.isFinite(f))&&(f=1),{x:u,y:f}}const QL=Qs(0);function fE(e){const t=Tn(e);return!mf()||!t.visualViewport?QL:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function e$(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Tn(e)?!1:t}function ii(e,t,n,a){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),c=mv(e);let u=Qs(1);t&&(a?It(a)&&(u=wo(a)):u=wo(e));const f=e$(c,n,a)?fE(c):Qs(0);let m=(i.left+f.x)/u.x,h=(i.top+f.y)/u.y,g=i.width/u.x,x=i.height/u.y;if(c){const b=Tn(c),w=a&&It(a)?Tn(a):a;let j=b,N=tg(j);for(;N&&a&&w!==j;){const T=wo(N),k=N.getBoundingClientRect(),C=cs(N),S=k.left+(N.clientLeft+parseFloat(C.paddingLeft))*T.x,R=k.top+(N.clientTop+parseFloat(C.paddingTop))*T.y;m*=T.x,h*=T.y,g*=T.x,x*=T.y,m+=S,h+=R,j=Tn(N),N=tg(j)}}return zd({width:g,height:x,x:m,y:h})}function vf(e,t){const n=pf(e).scrollLeft;return t?t.left+n:ii(ra(e)).left+n}function hE(e,t){const n=e.getBoundingClientRect(),a=n.left+t.scrollLeft-vf(e,n),i=n.top+t.scrollTop;return{x:a,y:i}}function t$(e){let{elements:t,rect:n,offsetParent:a,strategy:i}=e;const c=i==="fixed",u=ra(a),f=t?hf(t.floating):!1;if(a===u||f&&c)return n;let m={scrollLeft:0,scrollTop:0},h=Qs(1);const g=Qs(0),x=Qt(a);if((x||!x&&!c)&&((wr(a)!=="body"||ui(u))&&(m=pf(a)),Qt(a))){const w=ii(a);h=wo(a),g.x=w.x+a.clientLeft,g.y=w.y+a.clientTop}const b=u&&!x&&!c?hE(u,m):Qs(0);return{width:n.width*h.x,height:n.height*h.y,x:n.x*h.x-m.scrollLeft*h.x+g.x+b.x,y:n.y*h.y-m.scrollTop*h.y+g.y+b.y}}function n$(e){return Array.from(e.getClientRects())}function s$(e){const t=ra(e),n=pf(e),a=e.ownerDocument.body,i=rs(t.scrollWidth,t.clientWidth,a.scrollWidth,a.clientWidth),c=rs(t.scrollHeight,t.clientHeight,a.scrollHeight,a.clientHeight);let u=-n.scrollLeft+vf(e);const f=-n.scrollTop;return cs(a).direction==="rtl"&&(u+=rs(t.clientWidth,a.clientWidth)-i),{width:i,height:c,x:u,y:f}}const v1=25;function a$(e,t){const n=Tn(e),a=ra(e),i=n.visualViewport;let c=a.clientWidth,u=a.clientHeight,f=0,m=0;if(i){c=i.width,u=i.height;const g=mf();(!g||g&&t==="fixed")&&(f=i.offsetLeft,m=i.offsetTop)}const h=vf(a);if(h<=0){const g=a.ownerDocument,x=g.body,b=getComputedStyle(x),w=g.compatMode==="CSS1Compat"&&parseFloat(b.marginLeft)+parseFloat(b.marginRight)||0,j=Math.abs(a.clientWidth-x.clientWidth-w);j<=v1&&(c-=j)}else h<=v1&&(c+=h);return{width:c,height:u,x:f,y:m}}const r$=new Set(["absolute","fixed"]);function i$(e,t){const n=ii(e,!0,t==="fixed"),a=n.top+e.clientTop,i=n.left+e.clientLeft,c=Qt(e)?wo(e):Qs(1),u=e.clientWidth*c.x,f=e.clientHeight*c.y,m=i*c.x,h=a*c.y;return{width:u,height:f,x:m,y:h}}function y1(e,t,n){let a;if(t==="viewport")a=a$(e,n);else if(t==="document")a=s$(ra(e));else if(It(t))a=i$(t,n);else{const i=fE(e);a={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return zd(a)}function mE(e,t){const n=na(e);return n===t||!It(n)||Js(n)?!1:cs(n).position==="fixed"||mE(n,t)}function o$(e,t){const n=t.get(e);if(n)return n;let a=ur(e,[],!1).filter(f=>It(f)&&wr(f)!=="body"),i=null;const c=cs(e).position==="fixed";let u=c?na(e):e;for(;It(u)&&!Js(u);){const f=cs(u),m=ov(u);!m&&f.position==="fixed"&&(i=null),(c?!m&&!i:!m&&f.position==="static"&&!!i&&r$.has(i.position)||ui(u)&&!m&&mE(e,u))?a=a.filter(g=>g!==u):i=f,u=na(u)}return t.set(e,a),a}function l$(e){let{element:t,boundary:n,rootBoundary:a,strategy:i}=e;const u=[...n==="clippingAncestors"?hf(t)?[]:o$(t,this._c):[].concat(n),a],f=u[0],m=u.reduce((h,g)=>{const x=y1(t,g,i);return h.top=rs(x.top,h.top),h.right=Co(x.right,h.right),h.bottom=Co(x.bottom,h.bottom),h.left=rs(x.left,h.left),h},y1(t,f,i));return{width:m.right-m.left,height:m.bottom-m.top,x:m.left,y:m.top}}function c$(e){const{width:t,height:n}=dE(e);return{width:t,height:n}}function u$(e,t,n){const a=Qt(t),i=ra(t),c=n==="fixed",u=ii(e,!0,c,t);let f={scrollLeft:0,scrollTop:0};const m=Qs(0);function h(){m.x=vf(i)}if(a||!a&&!c)if((wr(t)!=="body"||ui(i))&&(f=pf(t)),a){const w=ii(t,!0,c,t);m.x=w.x+t.clientLeft,m.y=w.y+t.clientTop}else i&&h();c&&!a&&i&&h();const g=i&&!a&&!c?hE(i,f):Qs(0),x=u.left+f.scrollLeft-m.x-g.x,b=u.top+f.scrollTop-m.y-g.y;return{x,y:b,width:u.width,height:u.height}}function Jm(e){return cs(e).position==="static"}function x1(e,t){if(!Qt(e)||cs(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return ra(e)===n&&(n=n.ownerDocument.body),n}function pE(e,t){const n=Tn(e);if(hf(e))return n;if(!Qt(e)){let i=na(e);for(;i&&!Js(i);){if(It(i)&&!Jm(i))return i;i=na(i)}return n}let a=x1(e,t);for(;a&&m3(a)&&Jm(a);)a=x1(a,t);return a&&Js(a)&&Jm(a)&&!ov(a)?n:a||x3(e)||n}const d$=async function(e){const t=this.getOffsetParent||pE,n=this.getDimensions,a=await n(e.floating);return{reference:u$(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:a.width,height:a.height}}};function f$(e){return cs(e).direction==="rtl"}const h$={convertOffsetParentRelativeRectToViewportRelativeRect:t$,getDocumentElement:ra,getClippingRect:l$,getOffsetParent:pE,getElementRects:d$,getClientRects:n$,getDimensions:c$,getScale:wo,isElement:It,isRTL:f$};function gE(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function m$(e,t){let n=null,a;const i=ra(e);function c(){var f;clearTimeout(a),(f=n)==null||f.disconnect(),n=null}function u(f,m){f===void 0&&(f=!1),m===void 0&&(m=1),c();const h=e.getBoundingClientRect(),{left:g,top:x,width:b,height:w}=h;if(f||t(),!b||!w)return;const j=fo(x),N=fo(i.clientWidth-(g+b)),T=fo(i.clientHeight-(x+w)),k=fo(g),S={rootMargin:-j+"px "+-N+"px "+-T+"px "+-k+"px",threshold:rs(0,Co(1,m))||1};let R=!0;function A(_){const O=_[0].intersectionRatio;if(O!==m){if(!R)return u();O?u(!1,O):a=setTimeout(()=>{u(!1,1e-7)},1e3)}O===1&&!gE(h,e.getBoundingClientRect())&&u(),R=!1}try{n=new IntersectionObserver(A,{...S,root:i.ownerDocument})}catch{n=new IntersectionObserver(A,S)}n.observe(e)}return u(!0),c}function b1(e,t,n,a){a===void 0&&(a={});const{ancestorScroll:i=!0,ancestorResize:c=!0,elementResize:u=typeof ResizeObserver=="function",layoutShift:f=typeof IntersectionObserver=="function",animationFrame:m=!1}=a,h=mv(e),g=i||c?[...h?ur(h):[],...ur(t)]:[];g.forEach(k=>{i&&k.addEventListener("scroll",n,{passive:!0}),c&&k.addEventListener("resize",n)});const x=h&&f?m$(h,n):null;let b=-1,w=null;u&&(w=new ResizeObserver(k=>{let[C]=k;C&&C.target===h&&w&&(w.unobserve(t),cancelAnimationFrame(b),b=requestAnimationFrame(()=>{var S;(S=w)==null||S.observe(t)})),n()}),h&&!m&&w.observe(h),w.observe(t));let j,N=m?ii(e):null;m&&T();function T(){const k=ii(e);N&&!gE(N,k)&&n(),N=k,j=requestAnimationFrame(T)}return n(),()=>{var k;g.forEach(C=>{i&&C.removeEventListener("scroll",n),c&&C.removeEventListener("resize",n)}),x?.(),(k=w)==null||k.disconnect(),w=null,m&&cancelAnimationFrame(j)}}const p$=WL,g$=XL,v$=qL,y$=JL,x$=YL,b$=KL,w$=(e,t,n)=>{const a=new Map,i={platform:h$,...n},c={...i.platform,_c:a};return FL(e,t,{...i,platform:c})};var S$=typeof document<"u",j$=function(){},hd=S$?v.useLayoutEffect:j$;function Vd(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,a,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(a=n;a--!==0;)if(!Vd(e[a],t[a]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(a=n;a--!==0;)if(!{}.hasOwnProperty.call(t,i[a]))return!1;for(a=n;a--!==0;){const c=i[a];if(!(c==="_owner"&&e.$$typeof)&&!Vd(e[c],t[c]))return!1}return!0}return e!==e&&t!==t}function vE(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function w1(e,t){const n=vE(e);return Math.round(t*n)/n}function Qm(e){const t=v.useRef(e);return hd(()=>{t.current=e}),t}function N$(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:a=[],platform:i,elements:{reference:c,floating:u}={},transform:f=!0,whileElementsMounted:m,open:h}=e,[g,x]=v.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[b,w]=v.useState(a);Vd(b,a)||w(a);const[j,N]=v.useState(null),[T,k]=v.useState(null),C=v.useCallback(B=>{B!==_.current&&(_.current=B,N(B))},[]),S=v.useCallback(B=>{B!==O.current&&(O.current=B,k(B))},[]),R=c||j,A=u||T,_=v.useRef(null),O=v.useRef(null),V=v.useRef(g),Z=m!=null,I=Qm(m),$=Qm(i),L=Qm(h),P=v.useCallback(()=>{if(!_.current||!O.current)return;const B={placement:t,strategy:n,middleware:b};$.current&&(B.platform=$.current),w$(_.current,O.current,B).then(G=>{const K={...G,isPositioned:L.current!==!1};q.current&&!Vd(V.current,K)&&(V.current=K,ai.flushSync(()=>{x(K)}))})},[b,t,n,$,L]);hd(()=>{h===!1&&V.current.isPositioned&&(V.current.isPositioned=!1,x(B=>({...B,isPositioned:!1})))},[h]);const q=v.useRef(!1);hd(()=>(q.current=!0,()=>{q.current=!1}),[]),hd(()=>{if(R&&(_.current=R),A&&(O.current=A),R&&A){if(I.current)return I.current(R,A,P);P()}},[R,A,P,I,Z]);const ee=v.useMemo(()=>({reference:_,floating:O,setReference:C,setFloating:S}),[C,S]),D=v.useMemo(()=>({reference:R,floating:A}),[R,A]),U=v.useMemo(()=>{const B={position:n,left:0,top:0};if(!D.floating)return B;const G=w1(D.floating,g.x),K=w1(D.floating,g.y);return f?{...B,transform:"translate("+G+"px, "+K+"px)",...vE(D.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:G,top:K}},[n,f,D.floating,g.x,g.y]);return v.useMemo(()=>({...g,update:P,refs:ee,elements:D,floatingStyles:U}),[g,P,ee,D,U])}const k$=(e,t)=>({...p$(e),options:[e,t]}),E$=(e,t)=>({...g$(e),options:[e,t]}),C$=(e,t)=>({...b$(e),options:[e,t]}),T$=(e,t)=>({...v$(e),options:[e,t]}),A$=(e,t)=>({...y$(e),options:[e,t]}),R$=(e,t)=>({...x$(e),options:[e,t]}),M$={intentional:"onClick",sloppy:"onPointerDown"};function _$(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}function O$(e,t={}){const n="rootStore"in e?e.rootStore:e,a=n.useState("open"),i=n.useState("floatingElement"),c=n.useState("referenceElement"),u=n.useState("domReferenceElement"),{onOpenChange:f,dataRef:m}=n.context,{enabled:h=!0,escapeKey:g=!0,outsidePress:x=!0,outsidePressEvent:b="sloppy",referencePress:w=!1,referencePressEvent:j="sloppy",ancestorScroll:N=!1,bubbles:T,externalTree:k}=t,C=Io(k),S=qe(typeof x=="function"?x:()=>!1),R=typeof x=="function"?S:x,A=v.useRef(!1),{escapeKey:_,outsidePress:O}=_$(T),V=v.useRef(null),Z=Us(),I=Us(),$=qe(()=>{I.clear(),m.current.insideReactTree=!1}),L=v.useRef(!1),P=v.useRef(""),q=qe(ie=>{P.current=ie.pointerType}),ee=qe(()=>{const ie=P.current,ke=ie==="pen"||!ie?"mouse":ie,we=typeof b=="function"?b():b;return typeof we=="string"?we:we[ke]}),D=qe(ie=>{if(!a||!h||!g||ie.key!=="Escape"||L.current)return;const ke=m.current.floatingContext?.nodeId,we=C?xo(C.nodesRef.current,ke):[];if(!_&&we.length>0){let xe=!0;if(we.forEach(Ee=>{Ee.context?.open&&!Ee.context.dataRef.current.__escapeKeyBubbles&&(xe=!1)}),!xe)return}const Ue=X3(ie)?ie.nativeEvent:ie,Ae=rn(Mk,Ue);n.setOpen(!1,Ae),!_&&!Ae.isPropagationAllowed&&ie.stopPropagation()}),U=qe(ie=>{const ke=ee();return ke==="intentional"&&ie.type!=="click"||ke==="sloppy"&&ie.type==="click"}),B=qe(()=>{m.current.insideReactTree=!0,I.start(0,$)}),G=qe((ie,ke=!1)=>{if(U(ie)){$();return}if(m.current.insideReactTree){$();return}if(ee()==="intentional"&&ke||typeof R=="function"&&!R(ie))return;const we=Gn(ie),Ue=`[${ac("inert")}]`,Ae=En(n.select("floatingElement")).querySelectorAll(Ue),xe=n.context.triggerElements;if(we&&(xe.hasElement(we)||xe.hasMatchingElement(ce=>Ot(ce,we))))return;let Ee=It(we)?we:null;for(;Ee&&!Js(Ee);){const ce=na(Ee);if(Js(ce)||!It(ce))break;Ee=ce}if(Ae.length&&It(we)&&!G3(we)&&!Ot(we,n.select("floatingElement"))&&Array.from(Ae).every(ce=>!Ot(Ee,ce)))return;if(Qt(we)&&!("touches"in ie)){const ce=Js(we),he=cs(we),pe=/auto|scroll/,je=ce||pe.test(he.overflowX),Ne=ce||pe.test(he.overflowY),Je=je&&we.clientWidth>0&&we.scrollWidth>we.clientWidth,et=Ne&&we.clientHeight>0&&we.scrollHeight>we.clientHeight,Ge=he.direction==="rtl",Bt=et&&(Ge?ie.offsetX<=we.offsetWidth-we.clientWidth:ie.offsetX>we.clientWidth),Et=Je&&ie.offsetY>we.clientHeight;if(Bt||Et)return}const Ye=m.current.floatingContext?.nodeId,Be=C&&xo(C.nodesRef.current,Ye).some(ce=>Ds(ie,ce.context?.elements.floating));if(Ds(ie,n.select("floatingElement"))||Ds(ie,n.select("domReferenceElement"))||Be)return;const He=C?xo(C.nodesRef.current,Ye):[];if(He.length>0){let ce=!0;if(He.forEach(he=>{he.context?.open&&!he.context.dataRef.current.__outsidePressBubbles&&(ce=!1)}),!ce)return}n.setOpen(!1,rn(rv,ie)),$()}),K=qe(ie=>{ee()!=="sloppy"||ie.pointerType==="touch"||!n.select("open")||!h||Ds(ie,n.select("floatingElement"))||Ds(ie,n.select("domReferenceElement"))||G(ie)}),z=qe(ie=>{if(ee()!=="sloppy"||!n.select("open")||!h||Ds(ie,n.select("floatingElement"))||Ds(ie,n.select("domReferenceElement")))return;const ke=ie.touches[0];ke&&(V.current={startTime:Date.now(),startX:ke.clientX,startY:ke.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},Z.start(1e3,()=>{V.current&&(V.current.dismissOnTouchEnd=!1,V.current.dismissOnMouseDown=!1)}))}),Y=qe(ie=>{const ke=Gn(ie);function we(){z(ie),ke?.removeEventListener(ie.type,we)}ke?.addEventListener(ie.type,we)}),W=qe(ie=>{const ke=A.current;if(A.current=!1,Z.clear(),ie.type==="mousedown"&&V.current&&!V.current.dismissOnMouseDown)return;const we=Gn(ie);function Ue(){ie.type==="pointerdown"?K(ie):G(ie,ke),we?.removeEventListener(ie.type,Ue)}we?.addEventListener(ie.type,Ue)}),J=qe(ie=>{if(ee()!=="sloppy"||!V.current||Ds(ie,n.select("floatingElement"))||Ds(ie,n.select("domReferenceElement")))return;const ke=ie.touches[0];if(!ke)return;const we=Math.abs(ke.clientX-V.current.startX),Ue=Math.abs(ke.clientY-V.current.startY),Ae=Math.sqrt(we*we+Ue*Ue);Ae>5&&(V.current.dismissOnTouchEnd=!0),Ae>10&&(G(ie),Z.clear(),V.current=null)}),de=qe(ie=>{const ke=Gn(ie);function we(){J(ie),ke?.removeEventListener(ie.type,we)}ke?.addEventListener(ie.type,we)}),ae=qe(ie=>{ee()!=="sloppy"||!V.current||Ds(ie,n.select("floatingElement"))||Ds(ie,n.select("domReferenceElement"))||(V.current.dismissOnTouchEnd&&G(ie),Z.clear(),V.current=null)}),ye=qe(ie=>{const ke=Gn(ie);function we(){ae(ie),ke?.removeEventListener(ie.type,we)}ke?.addEventListener(ie.type,we)});v.useEffect(()=>{if(!a||!h)return;m.current.__escapeKeyBubbles=_,m.current.__outsidePressBubbles=O;const ie=new Eo;function ke(Ee){n.setOpen(!1,rn(i3,Ee))}function we(){ie.clear(),L.current=!0}function Ue(){ie.start(mf()?5:0,()=>{L.current=!1})}const Ae=En(i);Ae.addEventListener("pointerdown",q,!0),g&&(Ae.addEventListener("keydown",D),Ae.addEventListener("compositionstart",we),Ae.addEventListener("compositionend",Ue)),R&&(Ae.addEventListener("click",W,!0),Ae.addEventListener("pointerdown",W,!0),Ae.addEventListener("touchstart",Y,!0),Ae.addEventListener("touchmove",de,!0),Ae.addEventListener("touchend",ye,!0),Ae.addEventListener("mousedown",W,!0));let xe=[];return N&&(It(u)&&(xe=ur(u)),It(i)&&(xe=xe.concat(ur(i))),!It(c)&&c&&c.contextElement&&(xe=xe.concat(ur(c.contextElement)))),xe=xe.filter(Ee=>Ee!==Ae.defaultView?.visualViewport),xe.forEach(Ee=>{Ee.addEventListener("scroll",ke,{passive:!0})}),()=>{Ae.removeEventListener("pointerdown",q,!0),g&&(Ae.removeEventListener("keydown",D),Ae.removeEventListener("compositionstart",we),Ae.removeEventListener("compositionend",Ue)),R&&(Ae.removeEventListener("click",W,!0),Ae.removeEventListener("pointerdown",W,!0),Ae.removeEventListener("touchstart",Y,!0),Ae.removeEventListener("touchmove",de,!0),Ae.removeEventListener("touchend",ye,!0),Ae.removeEventListener("mousedown",W,!0)),xe.forEach(Ee=>{Ee.removeEventListener("scroll",ke)}),ie.clear()}},[m,i,c,u,g,R,a,f,N,h,_,O,D,G,W,K,Y,de,ye,q,n]),v.useEffect($,[R,$]);const ve=v.useMemo(()=>({onKeyDown:D,...w&&{[M$[j]]:ie=>{n.setOpen(!1,rn(_d,ie.nativeEvent))},...j!=="intentional"&&{onClick(ie){n.setOpen(!1,rn(_d,ie.nativeEvent))}}}}),[D,n,w,j]),be=qe(ie=>{const ke=Gn(ie.nativeEvent);!Ot(n.select("floatingElement"),ke)||ie.button!==0||(A.current=!0)}),_e=v.useMemo(()=>({onKeyDown:D,onPointerDown:be,onMouseDown:be,onMouseUp:be,onClickCapture:B,onMouseDownCapture:B,onPointerDownCapture:B,onMouseUpCapture:B,onTouchEndCapture:B,onTouchMoveCapture:B}),[D,be,B]);return v.useMemo(()=>h?{reference:ve,floating:_e,trigger:ve}:{},[h,ve,_e])}var Hd=Symbol("NOT_FOUND");function I$(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function D$(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function z$(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(n=>typeof n=="function")){const n=e.map(a=>typeof a=="function"?`function ${a.name||"unnamed"}()`:typeof a).join(", ");throw new TypeError(`${t}[${n}]`)}}var S1=e=>Array.isArray(e)?e:[e];function L$(e){const t=Array.isArray(e[0])?e[0]:e;return z$(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function $$(e,t){const n=[],{length:a}=e;for(let i=0;i<a;i++)n.push(e[i].apply(null,t));return n}function P$(e){let t;return{get(n){return t&&e(t.key,n)?t.value:Hd},put(n,a){t={key:n,value:a}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function U$(e,t){let n=[];function a(f){const m=n.findIndex(h=>t(f,h.key));if(m>-1){const h=n[m];return m>0&&(n.splice(m,1),n.unshift(h)),h.value}return Hd}function i(f,m){a(f)===Hd&&(n.unshift({key:f,value:m}),n.length>e&&n.pop())}function c(){return n}function u(){n=[]}return{get:a,put:i,getEntries:c,clear:u}}var B$=(e,t)=>e===t;function V$(e){return function(n,a){if(n===null||a===null||n.length!==a.length)return!1;const{length:i}=n;for(let c=0;c<i;c++)if(!e(n[c],a[c]))return!1;return!0}}function H$(e,t){const n=typeof t=="object"?t:{equalityCheck:t},{equalityCheck:a=B$,maxSize:i=1,resultEqualityCheck:c}=n,u=V$(a);let f=0;const m=i<=1?P$(u):U$(i,u);function h(){let g=m.get(arguments);if(g===Hd){if(g=e.apply(null,arguments),f++,c){const b=m.getEntries().find(w=>c(w.value,g));b&&(g=b.value,f!==0&&f--)}m.put(arguments,g)}return g}return h.clearCache=()=>{m.clear(),h.resetResultsCount()},h.resultsCount=()=>f,h.resetResultsCount=()=>{f=0},h}var Z$=class{constructor(e){this.value=e}deref(){return this.value}},F$=typeof WeakRef<"u"?WeakRef:Z$,q$=0,j1=1;function Vu(){return{s:q$,v:void 0,o:null,p:null}}function yE(e,t={}){let n=Vu();const{resultEqualityCheck:a}=t;let i,c=0;function u(){let f=n;const{length:m}=arguments;for(let x=0,b=m;x<b;x++){const w=arguments[x];if(typeof w=="function"||typeof w=="object"&&w!==null){let j=f.o;j===null&&(f.o=j=new WeakMap);const N=j.get(w);N===void 0?(f=Vu(),j.set(w,f)):f=N}else{let j=f.p;j===null&&(f.p=j=new Map);const N=j.get(w);N===void 0?(f=Vu(),j.set(w,f)):f=N}}const h=f;let g;if(f.s===j1)g=f.v;else if(g=e.apply(null,arguments),c++,a){const x=i?.deref?.()??i;x!=null&&a(x,g)&&(g=x,c!==0&&c--),i=typeof g=="object"&&g!==null||typeof g=="function"?new F$(g):g}return h.s=j1,h.v=g,g}return u.clearCache=()=>{n=Vu(),u.resetResultsCount()},u.resultsCount=()=>c,u.resetResultsCount=()=>{c=0},u}function xE(e,...t){const n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,a=(...i)=>{let c=0,u=0,f,m={},h=i.pop();typeof h=="object"&&(m=h,h=i.pop()),I$(h,`createSelector expects an output function after the inputs, but received: [${typeof h}]`);const g={...n,...m},{memoize:x,memoizeOptions:b=[],argsMemoize:w=yE,argsMemoizeOptions:j=[]}=g,N=S1(b),T=S1(j),k=L$(i),C=x(function(){return c++,h.apply(null,arguments)},...N),S=w(function(){u++;const A=$$(k,arguments);return f=C.apply(null,A),f},...T);return Object.assign(S,{resultFunc:h,memoizedResultFunc:C,dependencies:k,dependencyRecomputations:()=>u,resetDependencyRecomputations:()=>{u=0},lastResult:()=>f,recomputations:()=>c,resetRecomputations:()=>{c=0},memoize:x,argsMemoize:w})};return Object.assign(a,{withTypes:()=>a}),a}var Y$=xE(yE),G$=Object.assign((e,t=Y$)=>{D$(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),a=n.map(c=>e[c]);return t(a,(...c)=>c.reduce((u,f,m)=>(u[n[m]]=f,u),{}))},{withTypes:()=>G$});xE({memoize:H$,memoizeOptions:{maxSize:1,equalityCheck:Object.is}});const Qe=(e,t,n,a,i,c,...u)=>{if(u.length>0)throw new Error(ci(1));let f;if(e)f=e;else throw new Error("Missing arguments");return f};var ep={exports:{}},tp={};var N1;function W$(){if(N1)return tp;N1=1;var e=uc();function t(x,b){return x===b&&(x!==0||1/x===1/b)||x!==x&&b!==b}var n=typeof Object.is=="function"?Object.is:t,a=e.useState,i=e.useEffect,c=e.useLayoutEffect,u=e.useDebugValue;function f(x,b){var w=b(),j=a({inst:{value:w,getSnapshot:b}}),N=j[0].inst,T=j[1];return c(function(){N.value=w,N.getSnapshot=b,m(N)&&T({inst:N})},[x,w,b]),i(function(){return m(N)&&T({inst:N}),x(function(){m(N)&&T({inst:N})})},[x]),u(w),w}function m(x){var b=x.getSnapshot;x=x.value;try{var w=b();return!n(x,w)}catch{return!0}}function h(x,b){return b()}var g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:f;return tp.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:g,tp}var k1;function bE(){return k1||(k1=1,ep.exports=W$()),ep.exports}var X$=bE(),np={exports:{}},sp={};var E1;function K$(){if(E1)return sp;E1=1;var e=uc(),t=bE();function n(h,g){return h===g&&(h!==0||1/h===1/g)||h!==h&&g!==g}var a=typeof Object.is=="function"?Object.is:n,i=t.useSyncExternalStore,c=e.useRef,u=e.useEffect,f=e.useMemo,m=e.useDebugValue;return sp.useSyncExternalStoreWithSelector=function(h,g,x,b,w){var j=c(null);if(j.current===null){var N={hasValue:!1,value:null};j.current=N}else N=j.current;j=f(function(){function k(_){if(!C){if(C=!0,S=_,_=b(_),w!==void 0&&N.hasValue){var O=N.value;if(w(O,_))return R=O}return R=_}if(O=R,a(S,_))return O;var V=b(_);return w!==void 0&&w(O,V)?(S=_,O):(S=_,R=V)}var C=!1,S,R,A=x===void 0?null:x;return[function(){return k(g())},A===null?void 0:function(){return k(A())}]},[g,x,b,w]);var T=i(h,j[0],j[1]);return u(function(){N.hasValue=!0,N.value=T},[T]),m(T),T},sp}var C1;function J$(){return C1||(C1=1,np.exports=K$()),np.exports}var Q$=J$();const eP=sv(19),tP=eP?sP:aP;function nP(e,t,n,a,i){return tP(e,t,n,a,i)}function sP(e,t,n,a,i){const c=v.useCallback(()=>t(e.getSnapshot(),n,a,i),[e,t,n,a,i]);return X$.useSyncExternalStore(e.subscribe,c,c)}function aP(e,t,n,a,i){return Q$.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,c=>t(c,n,a,i))}class Fl{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 a of this.listeners){if(n!==this.updateTick)return;a(t)}}update(t){for(const n in t)if(!Object.is(this.state[n],t[n])){Fl.prototype.setState.call(this,{...this.state,...t});return}}set(t,n){Object.is(this.state[t],n)||Fl.prototype.setState.call(this,{...this.state,[t]:n})}notifyAll(){const t={...this.state};Fl.prototype.setState.call(this,t)}}class wE extends Fl{constructor(t,n={},a){super(t),this.context=n,this.selectors=a}controlledValues=new Map;useSyncedValue(t,n){v.useDebugValue(t),Ze(()=>{this.state[t]!==n&&this.set(t,n)},[t,n])}useSyncedValueWithCleanup(t,n){Ze(()=>(this.state[t]!==n&&this.set(t,n),()=>{this.set(t,void 0)}),[t,n])}useSyncedValues(t){const n=Object.values(t);Ze(()=>{this.update(t)},n)}useControlledProp(t,n,a){v.useDebugValue(t);const i=n!==void 0;this.controlledValues.has(t)||(this.controlledValues.set(t,i),!i&&!Object.is(this.state[t],a)&&super.setState({...this.state,[t]:a})),Ze(()=>{i&&!Object.is(this.state[t],n)&&super.setState({...this.state,[t]:n})},[t,n,a,i])}set(t,n){this.controlledValues.get(t)!==!0&&super.set(t,n)}update(t){const n={...t};for(const a in n)if(Object.hasOwn(n,a)&&this.controlledValues.get(a)===!0){delete n[a];continue}super.update(n)}setState(t){const n={...t};for(const a in n)if(Object.hasOwn(n,a)&&this.controlledValues.get(a)===!0){delete n[a];continue}super.setState({...this.state,...n})}select=(t,n,a,i)=>{const c=this.selectors[t];return c(this.state,n,a,i)};useState=(t,n,a,i)=>{v.useDebugValue(t);const c=this.selectors[t];return nP(this,c,n,a,i)};useContextCallback(t,n){v.useDebugValue(t);const a=qe(n??Ck);this.context[t]=a}useStateSetter(t){const n=v.useRef(void 0);return n.current===void 0&&(n.current=a=>{this.set(t,a)}),n.current}observe(t,n){let a;typeof t=="function"?a=t:a=this.selectors[t];let i=a(this.state);return n(i,i,this),this.subscribe(c=>{const u=a(c);if(!Object.is(i,u)){const f=i;i=u,n(u,f,this)}})}}const rP={open:Qe(e=>e.open),domReferenceElement:Qe(e=>e.domReferenceElement),referenceElement:Qe(e=>e.positionReference??e.referenceElement),floatingElement:Qe(e=>e.floatingElement),floatingId:Qe(e=>e.floatingId)};class pv extends wE{constructor(t){const{nested:n,noEmit:a,onOpenChange:i,triggerElements:c,...u}=t;super({...u,positionReference:u.referenceElement,domReferenceElement:u.referenceElement},{onOpenChange:i,dataRef:{current:{}},events:nE(),nested:n,noEmit:a,triggerElements:c},rP)}setOpen=(t,n)=>{if((!t||!this.state.open||J3(n.event))&&(this.context.dataRef.current.openEvent=t?n.event:void 0),!this.context.noEmit){const a={open:t,reason:n.reason,nativeEvent:n.event,nested:this.context.nested,triggerElement:n.trigger};this.context.events.emit("openchange",a)}this.context.onOpenChange?.(t,n)}}function iP(e){const t=e.useState("open");Ze(()=>{if(t&&!e.select("activeTriggerId")&&e.context.triggerElements.size===1){const n=e.context.triggerElements.entries().next();if(!n.done){const[a,i]=n.value;e.update({activeTriggerId:a,activeTriggerElement:i})}}},[t,e])}function oP(e,t,n){const{mounted:a,setMounted:i,transitionStatus:c}=I3(e);t.useSyncedValues({mounted:a,transitionStatus:c});const u=qe(()=>{i(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)}),f=t.useState("preventUnmountingOnClose");return zk({enabled:!f,open:e,ref:t.context.popupRef,onComplete(){e||u()}}),{forceUnmount:u,transitionStatus:c}}class gv{constructor(){this.elements=new Set,this.idMap=new Map}add(t,n){const a=this.idMap.get(t);a!==n&&(a!==void 0&&this.elements.delete(a),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 lP(){return new pv({open:!1,floatingElement:null,referenceElement:null,triggerElements:new gv,floatingId:"",nested:!1,noEmit:!1,onOpenChange:void 0})}function cP(){return{open:!1,mounted:!1,transitionStatus:"idle",floatingRootContext:lP(),preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,popupElement:null,positionerElement:null,activeTriggerProps:Wn,inactiveTriggerProps:Wn,popupProps:Wn}}const uP={open:Qe(e=>e.open),mounted:Qe(e=>e.mounted),transitionStatus:Qe(e=>e.transitionStatus),floatingRootContext:Qe(e=>e.floatingRootContext),preventUnmountingOnClose:Qe(e=>e.preventUnmountingOnClose),payload:Qe(e=>e.payload),activeTriggerId:Qe(e=>e.activeTriggerId),activeTriggerElement:Qe(e=>e.mounted?e.activeTriggerElement:null),isTriggerActive:Qe((e,t)=>t!==void 0&&e.activeTriggerId===t),isOpenedByTrigger:Qe((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.open),isMountedByTrigger:Qe((e,t)=>t!==void 0&&e.activeTriggerId===t&&e.mounted),triggerProps:Qe((e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps),popupProps:Qe(e=>e.popupProps),popupElement:Qe(e=>e.popupElement),positionerElement:Qe(e=>e.positionerElement)};function dP(e){const{open:t=!1,onOpenChange:n,elements:a={}}=e,i=xr(),c=jr()!=null,u=Es(()=>new pv({open:t,onOpenChange:n,referenceElement:a.reference??null,floatingElement:a.floating??null,triggerElements:a.triggers??new gv,floatingId:i,nested:c,noEmit:e.noEmit||!1})).current;return Ze(()=>{const f={open:t,floatingId:i};a.reference!==void 0&&(f.referenceElement=a.reference,f.domReferenceElement=It(a.reference)?a.reference:null),a.floating!==void 0&&(f.floatingElement=a.floating),u.update(f)},[t,i,a.reference,a.floating,u]),u.context.onOpenChange=n,u.context.nested=c,u.context.noEmit=e.noEmit||!1,u}function fP(e={}){const{nodeId:t,externalTree:n}=e,a=dP(e),i=e.rootContext||a,c={reference:i.useState("referenceElement"),floating:i.useState("floatingElement"),domReference:i.useState("domReferenceElement")},[u,f]=v.useState(null),m=v.useRef(null),h=Io(n);Ze(()=>{c.domReference&&(m.current=c.domReference)},[c.domReference]);const g=N$({...e,elements:{...c,...u&&{reference:u}}}),x=v.useCallback(O=>{const V=It(O)?{getBoundingClientRect:()=>O.getBoundingClientRect(),getClientRects:()=>O.getClientRects(),contextElement:O}:O;f(V),g.refs.setReference(V)},[g.refs]),[b,w]=v.useState(null),[j,N]=v.useState(null);i.useSyncedValue("referenceElement",b),i.useSyncedValue("domReferenceElement",It(b)?b:null),i.useSyncedValue("floatingElement",j);const T=v.useCallback(O=>{(It(O)||O===null)&&(m.current=O,w(O)),(It(g.refs.reference.current)||g.refs.reference.current===null||O!==null&&!It(O))&&g.refs.setReference(O)},[g.refs,w]),k=v.useCallback(O=>{N(O),g.refs.setFloating(O)},[g.refs]),C=v.useMemo(()=>({...g.refs,setReference:T,setFloating:k,setPositionReference:x,domReference:m}),[g.refs,T,k,x]),S=v.useMemo(()=>({...g.elements,domReference:c.domReference}),[g.elements,c.domReference]),R=i.useState("open"),A=i.useState("floatingId"),_=v.useMemo(()=>({...g,dataRef:i.context.dataRef,open:R,onOpenChange:i.setOpen,events:i.context.events,floatingId:A,refs:C,elements:S,nodeId:t,rootStore:i}),[g,C,S,t,i,R,A]);return Ze(()=>{i.context.dataRef.current.floatingContext=_;const O=h?.nodesRef.current.find(V=>V.id===t);O&&(O.context=_)}),v.useMemo(()=>({...g,context:_,refs:C,elements:S,rootStore:i}),[g,C,S,_,i])}function hP(e){const{popupStore:t,noEmit:n=!1,treatPopupAsFloatingElement:a=!1,onOpenChange:i}=e,c=xr(),u=jr()!=null,f=t.useState("open"),m=t.useState("activeTriggerElement"),h=t.useState(a?"popupElement":"positionerElement"),g=t.context.triggerElements,x=Es(()=>new pv({open:f,referenceElement:m,floatingElement:h,triggerElements:g,onOpenChange:i,floatingId:c,nested:u,noEmit:n})).current;return Ze(()=>{const b={open:f,floatingId:c,referenceElement:m,floatingElement:h};It(m)&&(b.domReferenceElement=m),x.update(b)},[f,c,m,h,x]),x.context.onOpenChange=i,x.context.nested=u,x.context.noEmit=n,x}const T1=ac("safe-polygon"),mP=`button,a,[role="button"],select,[tabindex]:not([tabindex="-1"]),${Vk}`;function pP(e){return e?!!e.closest(mP):!1}function gP(e){const t=v.useRef(void 0),n=v.useRef(!1),a=v.useRef(void 0),i=v.useRef(!0),c=v.useRef(!1),u=v.useRef(()=>{}),f=v.useRef(!1),m=Us(),h=Us(),g=v.useRef(void 0);return v.useMemo(()=>{const x=e.context.dataRef.current;return x.hoverInteractionState||(x.hoverInteractionState={pointerTypeRef:t,interactedInsideRef:n,handlerRef:a,blockMouseMoveRef:i,performedPointerEventsMutationRef:c,unbindMouseMoveRef:u,restTimeoutPendingRef:f,openChangeTimeout:m,restTimeout:h,handleCloseOptionsRef:g}),x.hoverInteractionState},[e,t,n,a,i,c,u,f,m,h,g])}const vP=new Set(["click","mousedown"]);function yP(e,t={}){const n="rootStore"in e?e.rootStore:e,a=n.useState("open"),i=n.useState("floatingElement"),c=n.useState("domReferenceElement"),{dataRef:u}=n.context,{enabled:f=!0,closeDelay:m=0,externalTree:h}=t,{pointerTypeRef:g,interactedInsideRef:x,handlerRef:b,performedPointerEventsMutationRef:w,unbindMouseMoveRef:j,restTimeoutPendingRef:N,openChangeTimeout:T,handleCloseOptionsRef:k}=gP(n),C=Io(h),S=jr(),R=qe(()=>x.current?!0:u.current.openEvent?vP.has(u.current.openEvent.type):!1),A=qe(()=>{const I=u.current.openEvent?.type;return I?.includes("mouse")&&I!=="mousedown"}),_=v.useCallback((I,$=!0)=>{const L=xP(m,g.current);L&&!b.current?T.start(L,()=>n.setOpen(!1,rn(Kr,I))):$&&(T.clear(),n.setOpen(!1,rn(Kr,I)))},[m,b,n,g,T]),O=qe(()=>{j.current(),b.current=void 0}),V=qe(()=>{if(w.current){const I=En(i).body;I.style.pointerEvents="",I.removeAttribute(T1),w.current=!1}}),Z=qe(I=>{const $=Gn(I);if(!pP($)){x.current=!1;return}x.current=!0});Ze(()=>{a||(g.current=void 0,N.current=!1,x.current=!1,O(),V())},[a,g,N,x,O,V]),v.useEffect(()=>()=>{O()},[O]),v.useEffect(()=>V,[V]),Ze(()=>{if(f&&a&&k.current?.blockPointerEvents&&A()&&It(c)&&i){w.current=!0;const I=En(i).body;I.setAttribute(T1,"");const $=c,L=i,P=C?.nodesRef.current.find(q=>q.id===S)?.context?.elements.floating;return P&&(P.style.pointerEvents=""),I.style.pointerEvents="none",$.style.pointerEvents="auto",L.style.pointerEvents="auto",()=>{I.style.pointerEvents="",$.style.pointerEvents="",L.style.pointerEvents=""}}},[f,a,c,i,k,A,C,S,w]),v.useEffect(()=>{if(!f)return;function I(q){if(R()||!u.current.floatingContext)return;const ee=n.context.triggerElements;q.relatedTarget&&ee.hasElement(q.relatedTarget)||(V(),O(),R()||_(q))}function $(q){T.clear(),V(),b.current?.(q),O()}function L(q){R()||_(q,!1)}const P=i;return P&&(P.addEventListener("mouseleave",I),P.addEventListener("mouseenter",$),P.addEventListener("mouseleave",L),P.addEventListener("pointerdown",Z,!0)),()=>{P&&(P.removeEventListener("mouseleave",I),P.removeEventListener("mouseenter",$),P.removeEventListener("mouseleave",L),P.removeEventListener("pointerdown",Z,!0))}})}function xP(e,t){return t&&!K3(t)?0:typeof e=="function"?e():e}function bP(e=[]){const t=e.map(h=>h?.reference),n=e.map(h=>h?.floating),a=e.map(h=>h?.item),i=e.map(h=>h?.trigger),c=v.useCallback(h=>Hu(h,e,"reference"),t),u=v.useCallback(h=>Hu(h,e,"floating"),n),f=v.useCallback(h=>Hu(h,e,"item"),a),m=v.useCallback(h=>Hu(h,e,"trigger"),i);return v.useMemo(()=>({getReferenceProps:c,getFloatingProps:u,getItemProps:f,getTriggerProps:m}),[c,u,f,m])}function Hu(e,t,n){const a=new Map,i=n==="item",c={};n==="floating"&&(c.tabIndex=-1,c[sg]="");for(const u in e)i&&e&&(u===Uk||u===Bk)||(c[u]=e[u]);for(let u=0;u<t.length;u+=1){let f;const m=t[u]?.[n];typeof m=="function"?f=e?m(e):null:f=m,f&&A1(c,f,i,a)}return A1(c,e,i,a),c}function A1(e,t,n,a){for(const i in t){const c=t[i];n&&(i===Uk||i===Bk)||(i.startsWith("on")?(a.has(i)||a.set(i,[]),typeof c=="function"&&(a.get(i)?.push(c),e[i]=(...u)=>a.get(i)?.map(f=>f(...u)).find(f=>f!==void 0))):e[i]=c)}}const wP="Escape";function yf(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function Zu(e,t){return yf(t,e===cv||e===mc,e===dr||e===fr)}function ap(e,t,n){return yf(t,e===mc,n?e===dr:e===fr)||e==="Enter"||e===" "||e===""}function SP(e,t,n){return yf(t,n?e===dr:e===fr,e===mc)}function jP(e,t,n,a){const i=n?e===fr:e===dr,c=e===cv;return t==="both"||t==="horizontal"&&a&&a>1?e===wP:yf(t,i,c)}function NP(e,t){const n="rootStore"in e?e.rootStore:e,a=n.useState("open"),i=n.useState("floatingElement"),c=n.useState("domReferenceElement"),u=n.context.dataRef,{listRef:f,activeIndex:m,onNavigate:h=()=>{},enabled:g=!0,selectedIndex:x=null,allowEscape:b=!1,loopFocus:w=!1,nested:j=!1,rtl:N=!1,virtual:T=!1,focusItemOnOpen:k="auto",focusItemOnHover:C=!0,openOnArrowKeyDown:S=!0,disabledIndices:R=void 0,orientation:A="vertical",parentOrientation:_,cols:O=1,scrollItemIntoView:V=!0,itemSizes:Z,dense:I=!1,id:$,resetOnPointerLeave:L=!0,externalTree:P}=t,q=Od(i),ee=Yn(q),D=jr(),U=Io(P);Ze(()=>{u.current.orientation=A},[u,A]);const B=ag(c),G=v.useRef(k),K=v.useRef(x??-1),z=v.useRef(null),Y=v.useRef(!0),W=qe(pe=>{h(K.current===-1?null:K.current,pe)}),J=v.useRef(W),de=v.useRef(!!i),ae=v.useRef(a),ye=v.useRef(!1),ve=v.useRef(!1),be=Yn(R),_e=Yn(a),ie=Yn(V),ke=Yn(x),we=Yn(L),Ue=qe(()=>{function pe(et){T?U?.events.emit("virtualfocus",et):fd(et,{sync:ye.current,preventScroll:!0})}const je=f.current[K.current],Ne=ve.current;je&&pe(je),(ye.current?et=>et():requestAnimationFrame)(()=>{const et=f.current[K.current]||je;if(!et)return;je||pe(et);const Ge=ie.current;Ge&&xe&&(Ne||!Y.current)&&et.scrollIntoView?.(typeof Ge=="boolean"?{block:"nearest",inline:"nearest"}:Ge)})});Ze(()=>{g&&(a&&i?(K.current=x??-1,G.current&&x!=null&&(ve.current=!0,W())):de.current&&(K.current=-1,J.current()))},[g,a,i,x,W]),Ze(()=>{if(g){if(!a){ye.current=!1;return}if(i)if(m==null){if(ye.current=!1,ke.current!=null)return;if(de.current&&(K.current=-1,Ue()),(!ae.current||!de.current)&&G.current&&(z.current!=null||G.current===!0&&z.current==null)){let pe=0;const je=()=>{f.current[0]==null?(pe<2&&(pe?requestAnimationFrame:queueMicrotask)(je),pe+=1):(K.current=z.current==null||ap(z.current,A,N)||j?Wm(f):o1(f),z.current=null,W())};je()}}else Vl(f,m)||(K.current=m,Ue(),ve.current=!1)}},[g,a,i,m,ke,j,f,A,N,W,Ue,be]),Ze(()=>{if(!g||i||!U||T||!de.current)return;const pe=U.nodesRef.current,je=pe.find(et=>et.id===D)?.context?.elements.floating,Ne=ir(En(i)),Je=pe.some(et=>et.context&&Ot(et.context.elements.floating,Ne));je&&!Je&&Y.current&&je.focus({preventScroll:!0})},[g,i,U,D,T]),Ze(()=>{J.current=W,ae.current=a,de.current=!!i}),Ze(()=>{a||(z.current=null,G.current=k)},[a,k]);const Ae=m!=null,xe=v.useMemo(()=>{function pe(Ne){if(!_e.current)return;const Je=f.current.indexOf(Ne.currentTarget);Je!==-1&&K.current!==Je&&(K.current=Je,W(Ne))}return{onFocus(Ne){ye.current=!0,pe(Ne)},onClick:({currentTarget:Ne})=>Ne.focus({preventScroll:!0}),onMouseMove(Ne){ye.current=!0,ve.current=!1,C&&pe(Ne)},onPointerLeave(Ne){if(!_e.current||!Y.current||Ne.pointerType==="touch")return;ye.current=!0;const Je=Ne.relatedTarget;!C||f.current.includes(Je)||we.current&&(K.current=-1,W(Ne),T||ee.current?.focus({preventScroll:!0}))}}},[_e,ee,C,f,W,we,T]),Ee=v.useCallback(()=>_??U?.nodesRef.current.find(pe=>pe.id===D)?.context?.dataRef?.current.orientation,[D,U,_]),Ye=qe(pe=>{if(Y.current=!1,ye.current=!0,pe.which===229||!_e.current&&pe.currentTarget===ee.current)return;if(j&&jP(pe.key,A,N,O)){Zu(pe.key,Ee())||Cn(pe),n.setOpen(!1,rn(dd,pe.nativeEvent)),Qt(c)&&(T?U?.events.emit("virtualfocus",c):c.focus());return}const je=K.current,Ne=Wm(f,R),Je=o1(f,R);if(B||(pe.key==="Home"&&(Cn(pe),K.current=Ne,W(pe)),pe.key==="End"&&(Cn(pe),K.current=Je,W(pe))),O>1){const et=Z||Array.from({length:f.current.length},()=>({width:1,height:1})),Ge=dL(et,O,I),Bt=Ge.findIndex(hn=>hn!=null&&!Hl(f,hn,R)),Et=Ge.reduce((hn,on,Ie)=>on!=null&&!Hl(f,on,R)?Ie:hn,-1),fn=Ge[uL({current:Ge.map(hn=>hn!=null?f.current[hn]:null)},{event:pe,orientation:A,loopFocus:w,rtl:N,cols:O,disabledIndices:hL([...(typeof R!="function"?R:null)||f.current.map((hn,on)=>Hl(f,on,R)?on:void 0),void 0],Ge),minIndex:Bt,maxIndex:Et,prevIndex:fL(K.current>Je?Ne:K.current,et,Ge,O,pe.key===mc?"bl":pe.key===(N?dr:fr)?"tr":"tl"),stopEvent:!0})];if(fn!=null&&(K.current=fn,W(pe)),A==="both")return}if(Zu(pe.key,A)){if(Cn(pe),a&&!T&&ir(pe.currentTarget.ownerDocument)===pe.currentTarget){K.current=ap(pe.key,A,N)?Ne:Je,W(pe);return}ap(pe.key,A,N)?w?je>=Je?b&&je!==f.current.length?K.current=-1:(ye.current=!1,K.current=Ne):K.current=Mn(f,{startingIndex:je,disabledIndices:R}):K.current=Math.min(Je,Mn(f,{startingIndex:je,disabledIndices:R})):w?je<=Ne?b&&je!==-1?K.current=f.current.length:(ye.current=!1,K.current=Je):K.current=Mn(f,{startingIndex:je,decrement:!0,disabledIndices:R}):K.current=Math.max(Ne,Mn(f,{startingIndex:je,decrement:!0,disabledIndices:R})),Vl(f,K.current)&&(K.current=-1),W(pe)}}),Be=v.useMemo(()=>T&&a&&Ae&&{"aria-activedescendant":`${$}-${m}`},[T,a,Ae,$,m]),He=v.useMemo(()=>({"aria-orientation":A==="both"?void 0:A,...B?{}:Be,onKeyDown(pe){if(pe.key==="Tab"&&pe.shiftKey&&a&&!T){const je=Gn(pe.nativeEvent);if(je&&!Ot(ee.current,je))return;Cn(pe),n.setOpen(!1,rn(df,pe.nativeEvent)),Qt(c)&&c.focus();return}Ye(pe)},onPointerMove(){Y.current=!0}}),[Be,Ye,ee,A,B,n,a,T,c]),ce=v.useMemo(()=>{function pe(Ne){k==="auto"&&Hk(Ne.nativeEvent)&&(G.current=!T)}function je(Ne){G.current=k,k==="auto"&&Zk(Ne.nativeEvent)&&(G.current=!0)}return{onKeyDown(Ne){const Je=n.select("open");Y.current=!1;const et=Ne.key.startsWith("Arrow"),Ge=SP(Ne.key,Ee(),N),Bt=Zu(Ne.key,A),Et=(j?Ge:Bt)||Ne.key==="Enter"||Ne.key.trim()==="";if(T&&Je)return Ye(Ne);if(!(!Je&&!S&&et)){if(Et){const fn=Zu(Ne.key,Ee());z.current=j&&fn?null:Ne.key}if(j){Ge&&(Cn(Ne),Je?(K.current=Wm(f,be.current),W(Ne)):n.setOpen(!0,rn(dd,Ne.nativeEvent,Ne.currentTarget)));return}Bt&&(ke.current!=null&&(K.current=ke.current),Cn(Ne),!Je&&S?n.setOpen(!0,rn(dd,Ne.nativeEvent,Ne.currentTarget)):Ye(Ne),Je&&W(Ne))}},onFocus(Ne){n.select("open")&&!T&&(K.current=-1,W(Ne))},onPointerDown:je,onPointerEnter:je,onMouseDown:pe,onClick:pe}},[Ye,be,k,f,j,W,n,S,A,Ee,N,ke,T]),he=v.useMemo(()=>({...Be,...ce}),[Be,ce]);return v.useMemo(()=>g?{reference:he,floating:He,item:xe,trigger:ce}:{},[g,he,He,ce,xe])}const kP=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function EP(e,t={}){const n="rootStore"in e?e.rootStore:e,a=n.useState("open"),i=n.useState("floatingId"),c=n.useState("domReferenceElement"),u=n.useState("floatingElement"),{enabled:f=!0,role:m="dialog"}=t,h=xr(),g=c?.id||h,x=v.useMemo(()=>Od(u)?.id||i,[u,i]),b=kP.get(m)??m,j=jr()!=null,N=v.useMemo(()=>b==="tooltip"||m==="label"?Wn:{"aria-haspopup":b==="alertdialog"?"dialog":b,"aria-expanded":"false",...b==="listbox"&&{role:"combobox"},...b==="menu"&&j&&{role:"menuitem"},...m==="select"&&{"aria-autocomplete":"none"},...m==="combobox"&&{"aria-autocomplete":"list"}},[b,j,m]),T=v.useMemo(()=>b==="tooltip"||m==="label"?{[`aria-${m==="label"?"labelledby":"describedby"}`]:a?x:void 0}:{...N,"aria-expanded":a?"true":"false","aria-controls":a?x:void 0,...b==="menu"&&{id:g}},[b,x,a,g,m,N]),k=v.useMemo(()=>{const S={id:x,...b&&{role:b}};return b==="tooltip"||m==="label"?S:{...S,...b==="menu"&&{"aria-labelledby":g}}},[b,x,g,m]),C=v.useCallback(({active:S,selected:R})=>{const A={role:"option",...S&&{id:`${x}-fui-option`}};switch(m){case"select":case"combobox":return{...A,"aria-selected":R}}return{}},[x,m]);return v.useMemo(()=>f?{reference:T,floating:k,item:C,trigger:N}:{},[f,T,k,N,C])}function CP(e,t){const n="rootStore"in e?e.rootStore:e,a=n.useState("open"),i=n.context.dataRef,{listRef:c,activeIndex:u,onMatch:f,onTypingChange:m,enabled:h=!0,findMatch:g=null,resetMs:x=750,ignoreKeys:b=Tk,selectedIndex:w=null}=t,j=Us(),N=v.useRef(""),T=v.useRef(w??u??-1),k=v.useRef(null);Ze(()=>{a&&(j.clear(),k.current=null,N.current="")},[a,j]),Ze(()=>{a&&N.current===""&&(T.current=w??u??-1)},[a,w,u]);const C=qe(_=>{_?i.current.typing||(i.current.typing=_,m?.(_)):i.current.typing&&(i.current.typing=_,m?.(_))}),S=qe(_=>{function O(L,P,q){const ee=g?g(P,q):P.find(D=>D?.toLocaleLowerCase().indexOf(q.toLocaleLowerCase())===0);return ee?L.indexOf(ee):-1}const V=c.current;if(N.current.length>0&&N.current[0]!==" "&&(O(V,V,N.current)===-1?C(!1):_.key===" "&&Cn(_)),V==null||b.includes(_.key)||_.key.length!==1||_.ctrlKey||_.metaKey||_.altKey)return;a&&_.key!==" "&&(Cn(_),C(!0)),V.every(L=>L?L[0]?.toLocaleLowerCase()!==L[1]?.toLocaleLowerCase():!0)&&N.current===_.key&&(N.current="",T.current=k.current),N.current+=_.key,j.start(x,()=>{N.current="",T.current=k.current,C(!1)});const I=T.current,$=O(V,[...V.slice((I||0)+1),...V.slice(0,(I||0)+1)],N.current);$!==-1?(f?.($),k.current=$):_.key!==" "&&(N.current="",C(!1))}),R=v.useMemo(()=>({onKeyDown:S}),[S]),A=v.useMemo(()=>({onKeyDown:S,onKeyUp(_){_.key===" "&&C(!1)}}),[S,C]);return v.useMemo(()=>h?{reference:R,floating:A}:{},[h,R,A])}const TP=v.createContext(void 0);function AP(e){return v.useContext(TP)}const SE="ArrowUp",jE="ArrowDown",NE="ArrowLeft",kE="ArrowRight",EE="Home",CE="End",RP=new Set([NE,kE]),MP=new Set([SE,jE]),_P=new Set([...RP,...MP]);[..._P];const OP=new Set([SE,jE,NE,kE,EE,CE]);function IP(e){return e==="starting"?F4:Wn}const DP={...Ak,...e3},zP=v.forwardRef(function(t,n){const{render:a,className:i,finalFocus:c,...u}=t,{store:f}=_o(),{side:m,align:h}=Sk(),g=AP()!=null,x=f.useState("open"),b=f.useState("transitionStatus"),w=f.useState("popupProps"),j=f.useState("mounted"),N=f.useState("instantType"),T=f.useState("activeTriggerElement"),k=f.useState("parent"),C=f.useState("lastOpenChangeReason"),S=f.useState("rootId"),R=f.useState("floatingRootContext"),A=f.useState("floatingTreeRoot"),_=f.useState("closeDelay"),O=f.useState("activeTriggerElement");zk({open:x,ref:f.context.popupRef,onComplete(){x&&f.context.onOpenChangeComplete?.(!0)}}),v.useEffect(()=>{function P(q){f.setOpen(!1,rn(q.reason,q.domEvent))}return A.events.on("close",P),()=>{A.events.off("close",P)}},[A.events,f]);const V=f.useState("hoverEnabled"),Z=f.useState("disabled");yP(R,{enabled:V&&!Z&&k.type!=="context-menu"&&k.type!=="menubar",closeDelay:_});const I=v.useMemo(()=>({transitionStatus:b,side:m,align:h,open:x,nested:k.type==="menu",instant:N}),[b,m,h,x,k.type,N]),$=br("div",t,{state:I,ref:[n,f.context.popupRef],stateAttributesMapping:DP,props:[w,{onKeyDown(P){g&&OP.has(P.key)&&P.stopPropagation()}},IP(b),u,{"data-rootownerid":S}]});let L=k.type===void 0||k.type==="context-menu";return(T||k.type==="menubar"&&C!==rv)&&(L=!0),o.jsx(HL,{context:R,modal:!1,disabled:!j,returnFocus:c===void 0?L:c,initialFocus:k.type!=="menu",restoreFocus:!0,externalTree:k.type!=="menubar"?A:void 0,previousFocusableElement:O,nextFocusableElement:k.type===void 0?f.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:k.type===void 0?f.context.beforeContentFocusGuardRef:void 0,children:$})}),TE=v.createContext(void 0);function LP(){const e=v.useContext(TE);if(e===void 0)throw new Error(ci(32));return e}const $P=v.forwardRef(function(t,n){const{keepMounted:a=!1,...i}=t,{store:c}=_o();return c.useState("mounted")||a?o.jsx(TE.Provider,{value:a,children:o.jsx($L,{ref:n,...i})}):null});function PP(e){return sv(19)?e:e?"true":void 0}const UP=v.createContext(void 0);function AE(){return v.useContext(UP)?.direction??"ltr"}const BP=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:a,placement:i,rects:c,platform:u,elements:f,middlewareData:m}=t,{element:h,padding:g=0,offsetParent:x="real"}=Ta(e,t)||{};if(h==null)return{};const b=Fk(g),w={x:n,y:a},j=fv(i),N=dv(j),T=await u.getDimensions(h),k=j==="y",C=k?"top":"left",S=k?"bottom":"right",R=k?"clientHeight":"clientWidth",A=c.reference[N]+c.reference[j]-w[j]-c.floating[N],_=w[j]-c.reference[j],O=x==="real"?await u.getOffsetParent?.(h):f.floating;let V=f.floating[R]||c.floating[N];(!V||!await u.isElement?.(O))&&(V=f.floating[R]||c.floating[N]);const Z=A/2-_/2,I=V/2-T[N]/2-1,$=Math.min(b[C],I),L=Math.min(b[S],I),P=$,q=V-T[N]-L,ee=V/2-T[N]/2+Z,D=rg(P,ee,q),U=!m.arrow&&Sr(i)!=null&&ee!==D&&c.reference[N]/2-(ee<P?$:L)-T[N]/2<0,B=U?ee<P?ee-P:ee-q:0;return{[j]:w[j]+B,data:{[j]:D,centerOffset:ee-D-B,...U&&{alignmentOffset:B}},reset:U}}}),VP=(e,t)=>({...BP(e),options:[e,t]}),HP={name:"hide",async fn(e){const{width:t,height:n,x:a,y:i}=e.rects.reference,c=t===0&&n===0&&a===0&&i===0;return{data:{referenceHidden:(await R$().fn(e)).data?.referenceHidden||c}}}},ZP={sideX:"left",sideY:"top"};function RE(e,t,n){const a=e==="inline-start"||e==="inline-end";return{top:"top",right:a?n?"inline-start":"inline-end":"right",bottom:"bottom",left:a?n?"inline-end":"inline-start":"left"}[t]}function R1(e,t,n){const{rects:a,placement:i}=e;return{side:RE(t,is(i),n),align:Sr(i)||"center",anchor:{width:a.reference.width,height:a.reference.height},positioner:{width:a.floating.width,height:a.floating.height}}}function FP(e){const{anchor:t,positionMethod:n="absolute",side:a="bottom",sideOffset:i=0,align:c="center",alignOffset:u=0,collisionBoundary:f,collisionPadding:m=5,sticky:h=!1,arrowPadding:g=5,disableAnchorTracking:x=!1,keepMounted:b=!1,floatingRootContext:w,mounted:j,collisionAvoidance:N,shiftCrossAxis:T=!1,nodeId:k,adaptiveOrigin:C,lazyFlip:S=!1,externalTree:R}=e,[A,_]=v.useState(null);!j&&A!==null&&_(null);const O=N.side||"flip",V=N.align||"flip",Z=N.fallbackAxisSide||"end",I=typeof t=="function"?t:void 0,$=qe(I),L=I?$:t,P=Yn(t),ee=AE()==="rtl",D=A||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":ee?"left":"right","inline-start":ee?"right":"left"}[a],U=c==="center"?D:`${D}-${c}`;let B=m;const G=1,K=a==="bottom"?G:0,z=a==="top"?G:0,Y=a==="right"?G:0,W=a==="left"?G:0;typeof B=="number"?B={top:B+K,right:B+W,bottom:B+z,left:B+Y}:B&&(B={top:(B.top||0)+K,right:(B.right||0)+W,bottom:(B.bottom||0)+z,left:(B.left||0)+Y});const J={boundary:f==="clipping-ancestors"?"clippingAncestors":f,padding:B},de=v.useRef(null),ae=Yn(i),ye=Yn(u),_e=[k$(xt=>{const Lt=R1(xt,a,ee),vn=typeof ae.current=="function"?ae.current(Lt):ae.current,Xt=typeof ye.current=="function"?ye.current(Lt):ye.current;return{mainAxis:vn,crossAxis:Xt,alignmentAxis:Xt}},[typeof i!="function"?i:0,typeof u!="function"?u:0,ee,a])],ie=V==="none"&&O!=="shift",ke=!ie&&(h||T||O==="shift"),we=O==="none"?null:T$({...J,padding:{top:B.top+G,right:B.right+G,bottom:B.bottom+G,left:B.left+G},mainAxis:!T&&O==="flip",crossAxis:V==="flip"?"alignment":!1,fallbackAxisSideDirection:Z}),Ue=ie?null:E$(xt=>{const Lt=ri(xt.elements.floating).documentElement;return{...J,rootBoundary:T?{x:0,y:0,width:Lt.clientWidth,height:Lt.clientHeight}:void 0,mainAxis:V!=="none",crossAxis:ke,limiter:h||T?void 0:C$(vn=>{if(!de.current)return{};const{width:Xt,height:mn}=de.current.getBoundingClientRect(),ln=Ss(is(vn.placement)),yn=ln==="y"?Xt:mn,Ts=ln==="y"?B.left+B.right:B.top+B.bottom;return{offset:yn/2+Ts/2}})}},[J,h,T,B,V]);O==="shift"||V==="shift"||c==="center"?_e.push(Ue,we):_e.push(we,Ue),_e.push(A$({...J,apply({elements:{floating:xt},rects:{reference:Lt},availableWidth:vn,availableHeight:Xt}){Object.entries({"--available-width":`${vn}px`,"--available-height":`${Xt}px`,"--anchor-width":`${Lt.width}px`,"--anchor-height":`${Lt.height}px`}).forEach(([mn,ln])=>{xt.style.setProperty(mn,ln)})}}),VP(()=>({element:de.current||document.createElement("div"),padding:g,offsetParent:"floating"}),[g]),{name:"transformOrigin",fn(xt){const{elements:Lt,middlewareData:vn,placement:Xt,rects:mn,y:ln}=xt,yn=is(Xt),Ts=Ss(yn),Q=de.current,me=vn.arrow?.x||0,ge=vn.arrow?.y||0,Ve=Q?.clientWidth||0,ze=Q?.clientHeight||0,dt=me+Ve/2,$t=ge+ze/2,Ft=Math.abs(vn.shift?.y||0),xn=mn.reference.height/2,qt=typeof i=="function"?i(R1(xt,a,ee)):i,As=Ft>qt,cn={top:`${dt}px calc(100% + ${qt}px)`,bottom:`${dt}px ${-qt}px`,left:`calc(100% + ${qt}px) ${$t}px`,right:`${-qt}px ${$t}px`}[yn],wc=`${dt}px ${mn.reference.y+xn-ln}px`;return Lt.floating.style.setProperty("--transform-origin",ke&&Ts==="y"&&As?wc:cn),{}}},HP,C),Ze(()=>{!j&&w&&w.update({referenceElement:null,floatingElement:null,domReferenceElement:null})},[j,w]);const Ae=v.useMemo(()=>({elementResize:!x&&typeof ResizeObserver<"u",layoutShift:!x&&typeof IntersectionObserver<"u"}),[x]),{refs:xe,elements:Ee,x:Ye,y:Be,middlewareData:He,update:ce,placement:he,context:pe,isPositioned:je,floatingStyles:Ne}=fP({rootContext:w,placement:U,middleware:_e,strategy:n,whileElementsMounted:b?void 0:(...xt)=>b1(...xt,Ae),nodeId:k,externalTree:R}),{sideX:Je,sideY:et}=He.adaptiveOrigin||ZP,Ge=je?n:"fixed",Bt=v.useMemo(()=>C?{position:Ge,[Je]:Ye,[et]:Be}:{position:Ge,...Ne},[C,Ge,Je,Ye,et,Be,Ne]),Et=v.useRef(null);Ze(()=>{if(!j)return;const xt=P.current,Lt=typeof xt=="function"?xt():xt,Xt=(M1(Lt)?Lt.current:Lt)||null||null;Xt!==Et.current&&(xe.setPositionReference(Xt),Et.current=Xt)},[j,xe,L,P]),v.useEffect(()=>{if(!j)return;const xt=P.current;typeof xt!="function"&&M1(xt)&&xt.current!==Et.current&&(xe.setPositionReference(xt.current),Et.current=xt.current)},[j,xe,L,P]),v.useEffect(()=>{if(b&&j&&Ee.domReference&&Ee.floating)return b1(Ee.domReference,Ee.floating,ce,Ae)},[b,j,Ee,ce,Ae]);const fn=is(he),hn=RE(a,fn,ee),on=Sr(he)||"center",Ie=!!He.hide?.referenceHidden;Ze(()=>{S&&j&&je&&_(fn)},[S,j,je,fn]);const tt=v.useMemo(()=>({position:"absolute",top:He.arrow?.y,left:He.arrow?.x}),[He.arrow]),ut=He.arrow?.centerOffset!==0;return v.useMemo(()=>({positionerStyles:Bt,arrowStyles:tt,arrowRef:de,arrowUncentered:ut,side:hn,align:on,physicalSide:fn,anchorHidden:Ie,refs:xe,context:pe,isPositioned:je,update:ce}),[Bt,tt,de,ut,hn,on,fn,Ie,xe,pe,je,ce])}function M1(e){return e!=null&&"current"in e}function qP(e){const{children:t,elementsRef:n,labelsRef:a,onMapChange:i}=e,c=qe(i),u=v.useRef(0),f=Es(GP).current,m=Es(YP).current,[h,g]=v.useState(0),x=v.useRef(h),b=qe((k,C)=>{m.set(k,C??null),x.current+=1,g(x.current)}),w=qe(k=>{m.delete(k),x.current+=1,g(x.current)}),j=v.useMemo(()=>{const k=new Map;return Array.from(m.keys()).filter(S=>S.isConnected).sort(WP).forEach((S,R)=>{const A=m.get(S)??{};k.set(S,{...A,index:R})}),k},[m,h]);Ze(()=>{if(typeof MutationObserver!="function"||j.size===0)return;const k=new MutationObserver(C=>{const S=new Set,R=A=>S.has(A)?S.delete(A):S.add(A);C.forEach(A=>{A.removedNodes.forEach(R),A.addedNodes.forEach(R)}),S.size===0&&(x.current+=1,g(x.current))});return j.forEach((C,S)=>{S.parentElement&&k.observe(S.parentElement,{childList:!0})}),()=>{k.disconnect()}},[j]),Ze(()=>{x.current===h&&(n.current.length!==j.size&&(n.current.length=j.size),a&&a.current.length!==j.size&&(a.current.length=j.size),u.current=j.size),c(j)},[c,j,n,a,h]),Ze(()=>()=>{n.current=[]},[n]),Ze(()=>()=>{a&&(a.current=[])},[a]);const N=qe(k=>(f.add(k),()=>{f.delete(k)}));Ze(()=>{f.forEach(k=>k(j))},[f,j]);const T=v.useMemo(()=>({register:b,unregister:w,subscribeMapChange:N,elementsRef:n,labelsRef:a,nextIndexRef:u}),[b,w,N,n,a,u]);return o.jsx(Ok.Provider,{value:T,children:t})}function YP(){return new Map}function GP(){return new Set}function WP(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 XP=v.forwardRef(function(t,n){const{cutout:a,...i}=t;let c;if(a){const u=a?.getBoundingClientRect();c=`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":"",...i,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:c}})}),KP=v.forwardRef(function(t,n){const{anchor:a,positionMethod:i="absolute",className:c,render:u,side:f,align:m,sideOffset:h=0,alignOffset:g=0,collisionBoundary:x="clipping-ancestors",collisionPadding:b=5,arrowPadding:w=5,sticky:j=!1,disableAnchorTracking:N=!1,collisionAvoidance:T=Y4,...k}=t,{store:C}=_o(),S=LP(),R=cf(!0),A=C.useState("parent"),_=C.useState("floatingRootContext"),O=C.useState("floatingTreeRoot"),V=C.useState("mounted"),Z=C.useState("open"),I=C.useState("modal"),$=C.useState("activeTriggerElement"),L=C.useState("lastOpenChangeReason"),P=C.useState("floatingNodeId"),q=C.useState("floatingParentNodeId");let ee=a,D=h,U=g,B=m;A.type==="context-menu"&&(ee=a??A.context?.anchor,B=B??"start",!f&&B!=="center"&&(U=t.alignOffset??2,D=t.sideOffset??-5));let G=f,K=B;A.type==="menu"?(G=G??"inline-end",K=K??"start"):A.type==="menubar"&&(G=G??"bottom",K=K??"start");const z=A.type==="context-menu",Y=FP({anchor:ee,floatingRootContext:_,positionMethod:R?"fixed":i,mounted:V,side:G,sideOffset:D,align:K,alignOffset:U,arrowPadding:z?0:w,collisionBoundary:x,collisionPadding:b,sticky:j,nodeId:P,keepMounted:S,disableAnchorTracking:N,collisionAvoidance:T,shiftCrossAxis:z,externalTree:O}),W=v.useMemo(()=>{const be={};return Z||(be.pointerEvents="none"),{role:"presentation",hidden:!V,style:{...Y.positionerStyles,...be}}},[Z,V,Y.positionerStyles]);v.useEffect(()=>{function be(_e){_e.open?(_e.parentNodeId===P&&C.set("hoverEnabled",!1),_e.nodeId!==P&&_e.parentNodeId===C.select("floatingParentNodeId")&&C.setOpen(!1,rn(zl))):_e.parentNodeId===P&&_e.reason!==zl&&C.set("hoverEnabled",!0)}return O.events.on("menuopenchange",be),()=>{O.events.off("menuopenchange",be)}},[C,O.events,P]),v.useEffect(()=>{if(C.select("floatingParentNodeId")==null)return;function be(_e){if(_e.open||_e.nodeId!==C.select("floatingParentNodeId"))return;const ie=_e.reason??zl;C.setOpen(!1,rn(ie))}return O.events.on("menuopenchange",be),()=>{O.events.off("menuopenchange",be)}},[O.events,C]),v.useEffect(()=>{function be(_e){!Z||_e.nodeId!==C.select("floatingParentNodeId")||_e.target&&$&&$!==_e.target&&C.setOpen(!1,rn(zl))}return O.events.on("itemhover",be),()=>{O.events.off("itemhover",be)}},[O.events,Z,$,C]),v.useEffect(()=>{const be={open:Z,nodeId:P,parentNodeId:q,reason:C.select("lastOpenChangeReason")};O.events.emit("menuopenchange",be)},[O.events,Z,C,P,q]);const J=v.useMemo(()=>({open:Z,side:Y.side,align:Y.align,anchorHidden:Y.anchorHidden,nested:A.type==="menu"}),[Z,Y.side,Y.align,Y.anchorHidden,A.type]),de=v.useMemo(()=>({side:Y.side,align:Y.align,arrowRef:Y.arrowRef,arrowUncentered:Y.arrowUncentered,arrowStyles:Y.arrowStyles,nodeId:Y.context.nodeId}),[Y.side,Y.align,Y.arrowRef,Y.arrowUncentered,Y.arrowStyles,Y.context.nodeId]),ae=br("div",t,{state:J,stateAttributesMapping:Ak,ref:[n,C.useStateSetter("positionerElement")],props:[W,k]}),ye=V&&A.type!=="menu"&&(A.type!=="menubar"&&I&&L!==Kr||A.type==="menubar"&&A.context.modal);let ve=null;return A.type==="menubar"?ve=A.context.contentElement:A.type===void 0&&(ve=$),o.jsxs(wk.Provider,{value:de,children:[ye&&o.jsx(XP,{ref:A.type==="context-menu"||A.type==="nested-context-menu"?A.context.internalBackdropRef:null,inert:PP(!Z),cutout:ve}),o.jsx(ML,{id:P,children:o.jsx(qP,{elementsRef:C.context.itemDomElements,labelsRef:C.context.itemLabels,children:ae})})]})});let _1={},O1={},I1="";function JP(e){if(typeof document>"u")return!1;const t=ri(e);return Tn(t).innerWidth-t.documentElement.clientWidth>0}function QP(e){const t=ri(e),n=t.documentElement,a=t.body,i=ui(n)?n:a,c=i.style.overflow;return i.style.overflow="hidden",()=>{i.style.overflow=c}}function e6(e){const t=ri(e),n=t.documentElement,a=t.body,i=Tn(n);let c=0,u=0;const f=Xs.create(),m=typeof CSS<"u"&&CSS.supports?.("scrollbar-gutter","stable");if(B3&&(i.visualViewport?.scale??1)!==1)return()=>{};function h(){const b=i.getComputedStyle(n),w=i.getComputedStyle(a),T=(b.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";c=n.scrollTop,u=n.scrollLeft,_1={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},I1=n.style.scrollBehavior,O1={position:a.style.position,height:a.style.height,width:a.style.width,boxSizing:a.style.boxSizing,overflowY:a.style.overflowY,overflowX:a.style.overflowX,scrollBehavior:a.style.scrollBehavior};const k=n.scrollHeight>n.clientHeight,C=n.scrollWidth>n.clientWidth,S=b.overflowY==="scroll"||w.overflowY==="scroll",R=b.overflowX==="scroll"||w.overflowX==="scroll",A=Math.max(0,i.innerWidth-n.clientWidth),_=Math.max(0,i.innerHeight-n.clientHeight),O=parseFloat(w.marginTop)+parseFloat(w.marginBottom),V=parseFloat(w.marginLeft)+parseFloat(w.marginRight),Z=ui(n)?n:a;if(m){n.style.scrollbarGutter=T,Z.style.overflowY="hidden",Z.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:T,overflowY:"hidden",overflowX:"hidden"}),(k||S)&&(n.style.overflowY="scroll"),(C||R)&&(n.style.overflowX="scroll"),Object.assign(a.style,{position:"relative",height:O||_?`calc(100dvh - ${O+_}px)`:"100dvh",width:V||A?`calc(100vw - ${V+A}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),a.scrollTop=c,a.scrollLeft=u,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function g(){Object.assign(n.style,_1),Object.assign(a.style,O1),m||(n.scrollTop=c,n.scrollLeft=u,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=I1)}function x(){g(),f.request(h)}return h(),i.addEventListener("resize",x),()=>{f.cancel(),g(),typeof i.removeEventListener=="function"&&i.removeEventListener("resize",x)}}class t6{lockCount=0;restore=null;timeoutLock=Eo.create();timeoutUnlock=Eo.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 a=ri(t).documentElement,i=Tn(a).getComputedStyle(a).overflowY;if(i==="hidden"||i==="clip"){this.restore=Ck;return}const c=V3||!JP(t);this.restore=c?QP(t):e6(t)}}const n6=new t6;function s6(e=!0,t=null){Ze(()=>{if(e)return n6.acquire(t)},[e,t])}const a6=v.createContext(null);function r6(e){return v.useContext(a6)}function i6(e){const t=v.useRef(""),n=v.useCallback(i=>{i.defaultPrevented||(t.current=i.pointerType,e(i,i.pointerType))},[e]);return{onClick:v.useCallback(i=>{if(i.detail===0){e(i,"keyboard");return}"pointerType"in i&&e(i,i.pointerType),e(i,t.current),t.current=""},[e]),onPointerDown:n}}function o6(e){const[t,n]=v.useState(null),a=qe((f,m)=>{e||n(m)}),i=v.useCallback(()=>{n(null)},[]),{onClick:c,onPointerDown:u}=i6(a);return v.useMemo(()=>({openMethod:t,reset:i,triggerProps:{onClick:c,onPointerDown:u}}),[t,i,c,u])}const l6={...uP,disabled:Qe(e=>e.parent.type==="menubar"&&e.parent.context.disabled||e.disabled),modal:Qe(e=>(e.parent.type===void 0||e.parent.type==="context-menu")&&(e.modal??!0)),allowMouseEnter:Qe(e=>e.parent.type==="menu"?e.parent.store.select("allowMouseEnter"):e.allowMouseEnter),stickIfOpen:Qe(e=>e.stickIfOpen),parent:Qe(e=>e.parent),rootId:Qe(e=>e.parent.type==="menu"?e.parent.store.select("rootId"):e.parent.type!==void 0?e.parent.context.rootId:e.rootId),activeIndex:Qe(e=>e.activeIndex),isActive:Qe((e,t)=>e.activeIndex===t),hoverEnabled:Qe(e=>e.hoverEnabled),instantType:Qe(e=>e.instantType),lastOpenChangeReason:Qe(e=>e.openChangeReason),floatingTreeRoot:Qe(e=>e.parent.type==="menu"?e.parent.store.select("floatingTreeRoot"):e.floatingTreeRoot),floatingNodeId:Qe(e=>e.floatingNodeId),floatingParentNodeId:Qe(e=>e.floatingParentNodeId),itemProps:Qe(e=>e.itemProps),closeDelay:Qe(e=>e.closeDelay),keyboardEventRelay:Qe(e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type==="menu")return e.parent.store.select("keyboardEventRelay")})};class vv extends wE{constructor(t){super({...c6(),...t},{positionerRef:v.createRef(),popupRef:v.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:v.createRef(),beforeContentFocusGuardRef:v.createRef(),onOpenChangeComplete:void 0,triggerElements:new gv},l6),this.observe(Qe(n=>n.allowMouseEnter),(n,a)=>{this.state.parent.type==="menu"&&n!==a&&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 Es(()=>t??new vv(n)).current}unsubscribeParentListener=null}function c6(){return{...cP(),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 sE,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:Wn,keyboardEventRelay:void 0,closeDelay:0}}const u6=v.createContext(void 0);function d6(){return v.useContext(u6)}function f6(e){const{children:t,open:n,onOpenChange:a,onOpenChangeComplete:i,defaultOpen:c=!1,disabled:u=!1,modal:f,loopFocus:m=!0,orientation:h="vertical",actionsRef:g,closeParentOnEsc:x=!0,handle:b,triggerId:w,defaultTriggerId:j=null,highlightItemOnHover:N=!0}=e,T=cf(!0),k=_o(!0),C=r6(),S=d6(),R=v.useMemo(()=>S&&k?{type:"menu",store:k.store}:C?{type:"menubar",context:C}:T&&!k?{type:"context-menu",context:T}:{type:void 0},[T,k,C,S]),A=vv.useStore(b?.store,{parent:R}),_=A.useState("floatingTreeRoot"),O=RL(_),V=jr();Ze(()=>{T&&!k?A.update({parent:{type:"context-menu",context:T},floatingNodeId:O,floatingParentNodeId:V}):k&&A.update({floatingNodeId:O,floatingParentNodeId:V})},[T,k,O,V,A]),A.useControlledProp("open",n,c),A.useControlledProp("activeTriggerId",w,j),A.useContextCallback("onOpenChangeComplete",i);const Z=A.useState("open"),I=A.useState("activeTriggerElement"),$=A.useState("positionerElement"),L=A.useState("hoverEnabled"),P=A.useState("modal"),q=A.useState("disabled"),ee=A.useState("lastOpenChangeReason"),D=A.useState("parent"),U=A.useState("activeIndex"),B=A.useState("payload"),G=A.useState("floatingParentNodeId"),K=v.useRef(null),z=G!=null;let Y;A.useSyncedValues({disabled:u,modal:D.type===void 0?f:void 0,rootId:xr()});const{openMethod:W,triggerProps:J,reset:de}=o6(Z);iP(A);const{forceUnmount:ae}=oP(Z,A,()=>{A.update({allowMouseEnter:!1,stickIfOpen:!0}),de()}),ye=v.useRef(D.type!=="context-menu"),ve=Us();v.useEffect(()=>{if(Z||(K.current=null),D.type==="context-menu"){if(!Z){ve.clear(),ye.current=!1;return}ve.start(500,()=>{ye.current=!0})}},[ve,Z,D.type]),s6(Z&&P&&ee!==Kr&&W!=="touch",$),Ze(()=>{!Z&&!L&&A.set("hoverEnabled",!0)},[Z,L,A]);const be=v.useRef(!0),_e=Us(),ie=qe((Ie,tt)=>{const ut=tt.reason;if(Z===Ie&&tt.trigger===I||(tt.preventUnmountOnClose=()=>{A.set("preventUnmountingOnClose",!0)},!Ie&&tt.trigger==null&&(tt.trigger=I??void 0),a?.(Ie,tt),tt.isCanceled))return;const xt={open:Ie,nativeEvent:tt.event,reason:tt.reason,nested:z};Y?.emit("openchange",xt);const Lt=tt.event;if(Ie===!1&&Lt?.type==="click"&&Lt.pointerType==="touch"&&!be.current)return;if(!Ie&&U!==null){const ln=A.context.itemDomElements.current[U];queueMicrotask(()=>{ln?.setAttribute("tabindex","-1")})}Ie&&ut===s1?(be.current=!1,_e.start(300,()=>{be.current=!0})):(be.current=!0,_e.clear());const vn=(ut===_d||ut===Rk)&&Lt.detail===0&&Lt?.isTrusted,Xt=!Ie&&(ut===Mk||ut==null);function mn(){const ln={open:Ie,openChangeReason:ut};K.current=tt.event??null;const yn=tt.trigger?.id??null;(yn||Ie)&&(ln.activeTriggerId=yn,ln.activeTriggerElement=tt.trigger??null),A.update(ln)}ut===Kr?ai.flushSync(mn):mn(),D.type==="menubar"&&(ut===s1||ut===df||ut===Kr||ut===dd||ut===zl)?A.set("instantType","group"):vn||Xt?A.set("instantType",vn?"click":"dismiss"):A.set("instantType",void 0)}),ke=v.useCallback(Ie=>{const tt=rn(Ie);return tt.preventUnmountOnClose=()=>{A.set("preventUnmountingOnClose",!0)},tt},[A]),we=v.useCallback(()=>{A.setOpen(!1,ke(l3))},[A,ke]);v.useImperativeHandle(g,()=>({unmount:ae,close:we}),[ae,we]);let Ue;D.type==="context-menu"&&(Ue=D.context),v.useImperativeHandle(Ue?.positionerRef,()=>$,[$]),v.useImperativeHandle(Ue?.actionsRef,()=>({setOpen:ie}),[ie]);const Ae=hP({popupStore:A,onOpenChange:ie});Y=Ae.context.events,v.useEffect(()=>{const Ie=({open:tt,eventDetails:ut})=>ie(tt,ut);return Y.on("setOpen",Ie),()=>{Y?.off("setOpen",Ie)}},[Y,ie]);const xe=O$(Ae,{enabled:!q,bubbles:x&&D.type==="menu",outsidePress(){return D.type!=="context-menu"||K.current?.type==="contextmenu"?!0:ye.current},externalTree:z?_:void 0}),Ee=EP(Ae,{role:"menu"}),Ye=AE(),Be=v.useCallback(Ie=>{A.select("activeIndex")!==Ie&&A.set("activeIndex",Ie)},[A]),He=NP(Ae,{enabled:!q,listRef:A.context.itemDomElements,activeIndex:U,nested:D.type!==void 0,loopFocus:m,orientation:h,parentOrientation:D.type==="menubar"?D.context.orientation:void 0,rtl:Ye==="rtl",disabledIndices:Tk,onNavigate:Be,openOnArrowKeyDown:D.type!=="context-menu",externalTree:z?_:void 0,focusItemOnHover:N}),ce=v.useCallback(Ie=>{A.context.typingRef.current=Ie},[A]),he=CP(Ae,{listRef:A.context.itemLabels,activeIndex:U,resetMs:Z4,onMatch:Ie=>{Z&&Ie!==U&&A.set("activeIndex",Ie)},onTypingChange:ce}),{getReferenceProps:pe,getFloatingProps:je,getItemProps:Ne,getTriggerProps:Je}=bP([xe,Ee,He,he]),et=v.useMemo(()=>{const Ie=uf(pe(),{onMouseEnter(){A.set("hoverEnabled",!0)},onMouseMove(){A.set("allowMouseEnter",!0)}},J);return delete Ie.role,Ie},[pe,A,J]),Ge=v.useMemo(()=>{const Ie=Je();if(!Ie)return Ie;const{role:tt,["aria-controls"]:ut,...xt}=Ie;return xt},[Je]),Bt=lv(),Et=v.useMemo(()=>je({onMouseEnter(){D.type==="menu"&&Bt.request(()=>A.set("hoverEnabled",!1))},onMouseMove(){A.set("allowMouseEnter",!0)},onClick(){A.select("hoverEnabled")&&A.set("hoverEnabled",!1)},onKeyDown(Ie){const tt=A.select("keyboardEventRelay");tt&&!Ie.isPropagationStopped()&&tt(Ie)}}),[je,D.type,Bt,A]),fn=v.useMemo(()=>Ne(),[Ne]);A.useSyncedValues({floatingRootContext:Ae,activeTriggerProps:et,inactiveTriggerProps:Ge,popupProps:Et,itemProps:fn});const hn=v.useMemo(()=>({store:A,parent:R}),[A,R]),on=o.jsx(nv.Provider,{value:hn,children:typeof t=="function"?t({payload:B}):t});return D.type===void 0||D.type==="context-menu"?o.jsx(_L,{externalTree:_,children:on}):on}function ME(e){if(Qt(e)&&e.hasAttribute("data-rootownerid"))return e.getAttribute("data-rootownerid")??void 0;if(!Js(e))return ME(na(e))}const h6=v.forwardRef(function(t,n){const{className:a,render:i,orientation:c="horizontal",...u}=t,f=v.useMemo(()=>({orientation:c}),[c]);return br("div",t,{state:f,ref:n,props:[{role:"separator","aria-orientation":c},u]})});function m6(e){const[t,n]=v.useState({getBoundingClientRect(){return DOMRect.fromRect({width:0,height:0,x:0,y:0})}}),a=v.useRef(null),i=v.useRef(null),c=v.useRef(null),u=v.useRef(null),f=v.useRef(!0),m=v.useRef(null),h=xr(),g=v.useMemo(()=>({anchor:t,setAnchor:n,actionsRef:c,backdropRef:a,internalBackdropRef:i,positionerRef:u,allowMouseUpTriggerRef:f,initialCursorPointRef:m,rootId:h}),[t,h]);return o.jsx(bk.Provider,{value:g,children:o.jsx(nv.Provider,{value:void 0,children:o.jsx(f6,{...e})})})}const D1=500,p6=v.forwardRef(function(t,n){const{render:a,className:i,...c}=t,{setAnchor:u,actionsRef:f,internalBackdropRef:m,backdropRef:h,positionerRef:g,allowMouseUpTriggerRef:x,initialCursorPointRef:b,rootId:w}=cf(!1),{store:j}=_o(!1),N=j.useState("open"),T=v.useRef(null),k=v.useRef(null),C=Us(),S=Us(),R=v.useRef(!1);function A(L,P,q){const ee=q.type.startsWith("touch");b.current={x:L,y:P},u({getBoundingClientRect(){return DOMRect.fromRect({width:ee?10:0,height:ee?10:0,x:L,y:P})}}),R.current=!1,f.current?.setOpen(!0,rn(_d,q)),S.start(D1,()=>{R.current=!0})}function _(L){x.current=!0,Cn(L),A(L.clientX,L.clientY,L.nativeEvent),ri(T.current).addEventListener("mouseup",q=>{if(x.current=!1,!R.current)return;S.clear(),R.current=!1;const ee=Gn(q);Ot(g.current,ee)||w&&ee&&ME(ee)===w||f.current?.setOpen(!1,rn(o3,q))},{once:!0})}function O(L){if(x.current=!1,L.touches.length===1){L.stopPropagation();const P=L.touches[0];k.current={x:P.clientX,y:P.clientY},C.start(D1,()=>{k.current&&A(k.current.x,k.current.y,L.nativeEvent)})}}function V(L){if(C.isStarted()&&k.current&&L.touches.length===1){const P=L.touches[0],q=10,ee=Math.abs(P.clientX-k.current.x),D=Math.abs(P.clientY-k.current.y);(ee>q||D>q)&&C.clear()}}function Z(){C.clear(),k.current=null}v.useEffect(()=>{function L(q){const D=Gn(q);(Ot(T.current,D)||Ot(m.current,D)||Ot(h.current,D))&&q.preventDefault()}const P=ri(T.current);return P.addEventListener("contextmenu",L),()=>{P.removeEventListener("contextmenu",L)}},[h,m]);const I=v.useMemo(()=>({open:N}),[N]);return br("div",t,{state:I,ref:[T,n],props:[{onContextMenu:_,onTouchStart:O,onTouchMove:V,onTouchEnd:Z,onTouchCancel:Z,style:{WebkitTouchCallout:"none"}},c],stateAttributesMapping:r3})}),yv=v.createContext({});function xv(e){const t=v.useRef(null);return t.current===null&&(t.current=e()),t.current}const _E=typeof window<"u",OE=_E?v.useLayoutEffect:v.useEffect,xf=v.createContext(null);function bv(e,t){e.indexOf(t)===-1&&e.push(t)}function Zd(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const sa=(e,t,n)=>n>t?t:n<e?e:n;let wv=()=>{};const Aa={},IE=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function DE(e){return typeof e=="object"&&e!==null}const zE=e=>/^0[^.\s]+$/u.test(e);function LE(e){let t;return()=>(t===void 0&&(t=e()),t)}const Ns=e=>e,g6=(e,t)=>n=>t(e(n)),gc=(...e)=>e.reduce(g6),rc=(e,t,n)=>{const a=t-e;return a===0?1:(n-e)/a};class Sv{constructor(){this.subscriptions=[]}add(t){return bv(this.subscriptions,t),()=>Zd(this.subscriptions,t)}notify(t,n,a){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](t,n,a);else for(let c=0;c<i;c++){const u=this.subscriptions[c];u&&u(t,n,a)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const $s=e=>e*1e3,js=e=>e/1e3;function $E(e,t){return t?e*(1e3/t):0}const PE=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,v6=1e-7,y6=12;function x6(e,t,n,a,i){let c,u,f=0;do u=t+(n-t)/2,c=PE(u,a,i)-e,c>0?n=u:t=u;while(Math.abs(c)>v6&&++f<y6);return u}function vc(e,t,n,a){if(e===t&&n===a)return Ns;const i=c=>x6(c,0,1,e,n);return c=>c===0||c===1?c:PE(i(c),t,a)}const UE=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,BE=e=>t=>1-e(1-t),VE=vc(.33,1.53,.69,.99),jv=BE(VE),HE=UE(jv),ZE=e=>(e*=2)<1?.5*jv(e):.5*(2-Math.pow(2,-10*(e-1))),Nv=e=>1-Math.sin(Math.acos(e)),FE=BE(Nv),qE=UE(Nv),b6=vc(.42,0,1,1),w6=vc(0,0,.58,1),YE=vc(.42,0,.58,1),S6=e=>Array.isArray(e)&&typeof e[0]!="number",GE=e=>Array.isArray(e)&&typeof e[0]=="number",j6={linear:Ns,easeIn:b6,easeInOut:YE,easeOut:w6,circIn:Nv,circInOut:qE,circOut:FE,backIn:jv,backInOut:HE,backOut:VE,anticipate:ZE},N6=e=>typeof e=="string",z1=e=>{if(GE(e)){wv(e.length===4);const[t,n,a,i]=e;return vc(t,n,a,i)}else if(N6(e))return j6[e];return e},Fu=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function k6(e,t){let n=new Set,a=new Set,i=!1,c=!1;const u=new WeakSet;let f={delta:0,timestamp:0,isProcessing:!1};function m(g){u.has(g)&&(h.schedule(g),e()),g(f)}const h={schedule:(g,x=!1,b=!1)=>{const j=b&&i?n:a;return x&&u.add(g),j.has(g)||j.add(g),g},cancel:g=>{a.delete(g),u.delete(g)},process:g=>{if(f=g,i){c=!0;return}i=!0,[n,a]=[a,n],n.forEach(m),n.clear(),i=!1,c&&(c=!1,h.process(g))}};return h}const E6=40;function WE(e,t){let n=!1,a=!0;const i={delta:0,timestamp:0,isProcessing:!1},c=()=>n=!0,u=Fu.reduce((S,R)=>(S[R]=k6(c),S),{}),{setup:f,read:m,resolveKeyframes:h,preUpdate:g,update:x,preRender:b,render:w,postRender:j}=u,N=()=>{const S=Aa.useManualTiming?i.timestamp:performance.now();n=!1,Aa.useManualTiming||(i.delta=a?1e3/60:Math.max(Math.min(S-i.timestamp,E6),1)),i.timestamp=S,i.isProcessing=!0,f.process(i),m.process(i),h.process(i),g.process(i),x.process(i),b.process(i),w.process(i),j.process(i),i.isProcessing=!1,n&&t&&(a=!1,e(N))},T=()=>{n=!0,a=!0,i.isProcessing||e(N)};return{schedule:Fu.reduce((S,R)=>{const A=u[R];return S[R]=(_,O=!1,V=!1)=>(n||T(),A.schedule(_,O,V)),S},{}),cancel:S=>{for(let R=0;R<Fu.length;R++)u[Fu[R]].cancel(S)},state:i,steps:u}}const{schedule:Ct,cancel:pr,state:kn,steps:rp}=WE(typeof requestAnimationFrame<"u"?requestAnimationFrame:Ns,!0);let md;function C6(){md=void 0}const Ln={now:()=>(md===void 0&&Ln.set(kn.isProcessing||Aa.useManualTiming?kn.timestamp:performance.now()),md),set:e=>{md=e,queueMicrotask(C6)}},XE=e=>t=>typeof t=="string"&&t.startsWith(e),KE=XE("--"),T6=XE("var(--"),kv=e=>T6(e)?A6.test(e.split("/*")[0].trim()):!1,A6=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function L1(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}const Do={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},ic={...Do,transform:e=>sa(0,1,e)},qu={...Do,default:1},ql=e=>Math.round(e*1e5)/1e5,Ev=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function R6(e){return e==null}const M6=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Cv=(e,t)=>n=>!!(typeof n=="string"&&M6.test(n)&&n.startsWith(e)||t&&!R6(n)&&Object.prototype.hasOwnProperty.call(n,t)),JE=(e,t,n)=>a=>{if(typeof a!="string")return a;const[i,c,u,f]=a.match(Ev);return{[e]:parseFloat(i),[t]:parseFloat(c),[n]:parseFloat(u),alpha:f!==void 0?parseFloat(f):1}},_6=e=>sa(0,255,e),ip={...Do,transform:e=>Math.round(_6(e))},Gr={test:Cv("rgb","red"),parse:JE("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:a=1})=>"rgba("+ip.transform(e)+", "+ip.transform(t)+", "+ip.transform(n)+", "+ql(ic.transform(a))+")"};function O6(e){let t="",n="",a="",i="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),a=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),a=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,a+=a,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(a,16),alpha:i?parseInt(i,16)/255:1}}const cg={test:Cv("#"),parse:O6,transform:Gr.transform},yc=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),nr=yc("deg"),ea=yc("%"),Te=yc("px"),I6=yc("vh"),D6=yc("vw"),$1={...ea,parse:e=>ea.parse(e)/100,transform:e=>ea.transform(e*100)},ho={test:Cv("hsl","hue"),parse:JE("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:a=1})=>"hsla("+Math.round(e)+", "+ea.transform(ql(t))+", "+ea.transform(ql(n))+", "+ql(ic.transform(a))+")"},an={test:e=>Gr.test(e)||cg.test(e)||ho.test(e),parse:e=>Gr.test(e)?Gr.parse(e):ho.test(e)?ho.parse(e):cg.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Gr.transform(e):ho.transform(e),getAnimatableNone:e=>{const t=an.parse(e);return t.alpha=0,an.transform(t)}},z6=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function L6(e){return isNaN(e)&&typeof e=="string"&&(e.match(Ev)?.length||0)+(e.match(z6)?.length||0)>0}const QE="number",eC="color",$6="var",P6="var(",P1="${}",U6=/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 oc(e){const t=e.toString(),n=[],a={color:[],number:[],var:[]},i=[];let c=0;const f=t.replace(U6,m=>(an.test(m)?(a.color.push(c),i.push(eC),n.push(an.parse(m))):m.startsWith(P6)?(a.var.push(c),i.push($6),n.push(m)):(a.number.push(c),i.push(QE),n.push(parseFloat(m))),++c,P1)).split(P1);return{values:n,split:f,indexes:a,types:i}}function tC(e){return oc(e).values}function nC(e){const{split:t,types:n}=oc(e),a=t.length;return i=>{let c="";for(let u=0;u<a;u++)if(c+=t[u],i[u]!==void 0){const f=n[u];f===QE?c+=ql(i[u]):f===eC?c+=an.transform(i[u]):c+=i[u]}return c}}const B6=e=>typeof e=="number"?0:an.test(e)?an.getAnimatableNone(e):e;function V6(e){const t=tC(e);return nC(e)(t.map(B6))}const Ps={test:L6,parse:tC,createTransformer:nC,getAnimatableNone:V6};function op(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 H6({hue:e,saturation:t,lightness:n,alpha:a}){e/=360,t/=100,n/=100;let i=0,c=0,u=0;if(!t)i=c=u=n;else{const f=n<.5?n*(1+t):n+t-n*t,m=2*n-f;i=op(m,f,e+1/3),c=op(m,f,e),u=op(m,f,e-1/3)}return{red:Math.round(i*255),green:Math.round(c*255),blue:Math.round(u*255),alpha:a}}function Fd(e,t){return n=>n>0?t:e}const Vt=(e,t,n)=>e+(t-e)*n,lp=(e,t,n)=>{const a=e*e,i=n*(t*t-a)+a;return i<0?0:Math.sqrt(i)},Z6=[cg,Gr,ho],F6=e=>Z6.find(t=>t.test(e));function U1(e){const t=F6(e);if(!t)return!1;let n=t.parse(e);return t===ho&&(n=H6(n)),n}const B1=(e,t)=>{const n=U1(e),a=U1(t);if(!n||!a)return Fd(e,t);const i={...n};return c=>(i.red=lp(n.red,a.red,c),i.green=lp(n.green,a.green,c),i.blue=lp(n.blue,a.blue,c),i.alpha=Vt(n.alpha,a.alpha,c),Gr.transform(i))},ug=new Set(["none","hidden"]);function q6(e,t){return ug.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Y6(e,t){return n=>Vt(e,t,n)}function Tv(e){return typeof e=="number"?Y6:typeof e=="string"?kv(e)?Fd:an.test(e)?B1:X6:Array.isArray(e)?sC:typeof e=="object"?an.test(e)?B1:G6:Fd}function sC(e,t){const n=[...e],a=n.length,i=e.map((c,u)=>Tv(c)(c,t[u]));return c=>{for(let u=0;u<a;u++)n[u]=i[u](c);return n}}function G6(e,t){const n={...e,...t},a={};for(const i in n)e[i]!==void 0&&t[i]!==void 0&&(a[i]=Tv(e[i])(e[i],t[i]));return i=>{for(const c in a)n[c]=a[c](i);return n}}function W6(e,t){const n=[],a={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){const c=t.types[i],u=e.indexes[c][a[c]],f=e.values[u]??0;n[i]=f,a[c]++}return n}const X6=(e,t)=>{const n=Ps.createTransformer(t),a=oc(e),i=oc(t);return a.indexes.var.length===i.indexes.var.length&&a.indexes.color.length===i.indexes.color.length&&a.indexes.number.length>=i.indexes.number.length?ug.has(e)&&!i.values.length||ug.has(t)&&!a.values.length?q6(e,t):gc(sC(W6(a,i),i.values),n):Fd(e,t)};function aC(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?Vt(e,t,n):Tv(e)(e,t)}const K6=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>Ct.update(t,n),stop:()=>pr(t),now:()=>kn.isProcessing?kn.timestamp:Ln.now()}},rC=(e,t,n=10)=>{let a="";const i=Math.max(Math.round(t/n),2);for(let c=0;c<i;c++)a+=Math.round(e(c/(i-1))*1e4)/1e4+", ";return`linear(${a.substring(0,a.length-2)})`},qd=2e4;function Av(e){let t=0;const n=50;let a=e.next(t);for(;!a.done&&t<qd;)t+=n,a=e.next(t);return t>=qd?1/0:t}function J6(e,t=100,n){const a=n({...e,keyframes:[0,t]}),i=Math.min(Av(a),qd);return{type:"keyframes",ease:c=>a.next(i*c).value/t,duration:js(i)}}const Q6=5;function iC(e,t,n){const a=Math.max(t-Q6,0);return $E(n-e(a),t-a)}const Wt={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},cp=.001;function e8({duration:e=Wt.duration,bounce:t=Wt.bounce,velocity:n=Wt.velocity,mass:a=Wt.mass}){let i,c,u=1-t;u=sa(Wt.minDamping,Wt.maxDamping,u),e=sa(Wt.minDuration,Wt.maxDuration,js(e)),u<1?(i=h=>{const g=h*u,x=g*e,b=g-n,w=dg(h,u),j=Math.exp(-x);return cp-b/w*j},c=h=>{const x=h*u*e,b=x*n+n,w=Math.pow(u,2)*Math.pow(h,2)*e,j=Math.exp(-x),N=dg(Math.pow(h,2),u);return(-i(h)+cp>0?-1:1)*((b-w)*j)/N}):(i=h=>{const g=Math.exp(-h*e),x=(h-n)*e+1;return-cp+g*x},c=h=>{const g=Math.exp(-h*e),x=(n-h)*(e*e);return g*x});const f=5/e,m=n8(i,c,f);if(e=$s(e),isNaN(m))return{stiffness:Wt.stiffness,damping:Wt.damping,duration:e};{const h=Math.pow(m,2)*a;return{stiffness:h,damping:u*2*Math.sqrt(a*h),duration:e}}}const t8=12;function n8(e,t,n){let a=n;for(let i=1;i<t8;i++)a=a-e(a)/t(a);return a}function dg(e,t){return e*Math.sqrt(1-t*t)}const s8=["duration","bounce"],a8=["stiffness","damping","mass"];function V1(e,t){return t.some(n=>e[n]!==void 0)}function r8(e){let t={velocity:Wt.velocity,stiffness:Wt.stiffness,damping:Wt.damping,mass:Wt.mass,isResolvedFromDuration:!1,...e};if(!V1(e,a8)&&V1(e,s8))if(t.velocity=0,e.visualDuration){const n=e.visualDuration,a=2*Math.PI/(n*1.2),i=a*a,c=2*sa(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:Wt.mass,stiffness:i,damping:c}}else{const n=e8({...e,velocity:0});t={...t,...n,mass:Wt.mass},t.isResolvedFromDuration=!0}return t}function Yd(e=Wt.visualDuration,t=Wt.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:a,restDelta:i}=n;const c=n.keyframes[0],u=n.keyframes[n.keyframes.length-1],f={done:!1,value:c},{stiffness:m,damping:h,mass:g,duration:x,velocity:b,isResolvedFromDuration:w}=r8({...n,velocity:-js(n.velocity||0)}),j=b||0,N=h/(2*Math.sqrt(m*g)),T=u-c,k=js(Math.sqrt(m/g)),C=Math.abs(T)<5;a||(a=C?Wt.restSpeed.granular:Wt.restSpeed.default),i||(i=C?Wt.restDelta.granular:Wt.restDelta.default);let S;if(N<1){const A=dg(k,N);S=_=>{const O=Math.exp(-N*k*_);return u-O*((j+N*k*T)/A*Math.sin(A*_)+T*Math.cos(A*_))}}else if(N===1)S=A=>u-Math.exp(-k*A)*(T+(j+k*T)*A);else{const A=k*Math.sqrt(N*N-1);S=_=>{const O=Math.exp(-N*k*_),V=Math.min(A*_,300);return u-O*((j+N*k*T)*Math.sinh(V)+A*T*Math.cosh(V))/A}}const R={calculatedDuration:w&&x||null,next:A=>{const _=S(A);if(w)f.done=A>=x;else{let O=A===0?j:0;N<1&&(O=A===0?$s(j):iC(S,A,_));const V=Math.abs(O)<=a,Z=Math.abs(u-_)<=i;f.done=V&&Z}return f.value=f.done?u:_,f},toString:()=>{const A=Math.min(Av(R),qd),_=rC(O=>R.next(A*O).value,A,30);return A+"ms "+_},toTransition:()=>{}};return R}Yd.applyToOptions=e=>{const t=J6(e,100,Yd);return e.ease=t.ease,e.duration=$s(t.duration),e.type="keyframes",e};function fg({keyframes:e,velocity:t=0,power:n=.8,timeConstant:a=325,bounceDamping:i=10,bounceStiffness:c=500,modifyTarget:u,min:f,max:m,restDelta:h=.5,restSpeed:g}){const x=e[0],b={done:!1,value:x},w=V=>f!==void 0&&V<f||m!==void 0&&V>m,j=V=>f===void 0?m:m===void 0||Math.abs(f-V)<Math.abs(m-V)?f:m;let N=n*t;const T=x+N,k=u===void 0?T:u(T);k!==T&&(N=k-x);const C=V=>-N*Math.exp(-V/a),S=V=>k+C(V),R=V=>{const Z=C(V),I=S(V);b.done=Math.abs(Z)<=h,b.value=b.done?k:I};let A,_;const O=V=>{w(b.value)&&(A=V,_=Yd({keyframes:[b.value,j(b.value)],velocity:iC(S,V,b.value),damping:i,stiffness:c,restDelta:h,restSpeed:g}))};return O(0),{calculatedDuration:null,next:V=>{let Z=!1;return!_&&A===void 0&&(Z=!0,R(V),O(V)),A!==void 0&&V>=A?_.next(V-A):(!Z&&R(V),b)}}}function i8(e,t,n){const a=[],i=n||Aa.mix||aC,c=e.length-1;for(let u=0;u<c;u++){let f=i(e[u],e[u+1]);if(t){const m=Array.isArray(t)?t[u]||Ns:t;f=gc(m,f)}a.push(f)}return a}function o8(e,t,{clamp:n=!0,ease:a,mixer:i}={}){const c=e.length;if(wv(c===t.length),c===1)return()=>t[0];if(c===2&&t[0]===t[1])return()=>t[1];const u=e[0]===e[1];e[0]>e[c-1]&&(e=[...e].reverse(),t=[...t].reverse());const f=i8(t,a,i),m=f.length,h=g=>{if(u&&g<e[0])return t[0];let x=0;if(m>1)for(;x<e.length-2&&!(g<e[x+1]);x++);const b=rc(e[x],e[x+1],g);return f[x](b)};return n?g=>h(sa(e[0],e[c-1],g)):h}function l8(e,t){const n=e[e.length-1];for(let a=1;a<=t;a++){const i=rc(0,t,a);e.push(Vt(n,1,i))}}function c8(e){const t=[0];return l8(t,e.length-1),t}function u8(e,t){return e.map(n=>n*t)}function d8(e,t){return e.map(()=>t||YE).splice(0,e.length-1)}function Yl({duration:e=300,keyframes:t,times:n,ease:a="easeInOut"}){const i=S6(a)?a.map(z1):z1(a),c={done:!1,value:t[0]},u=u8(n&&n.length===t.length?n:c8(t),e),f=o8(u,t,{ease:Array.isArray(i)?i:d8(t,i)});return{calculatedDuration:e,next:m=>(c.value=f(m),c.done=m>=e,c)}}const f8=e=>e!==null;function Rv(e,{repeat:t,repeatType:n="loop"},a,i=1){const c=e.filter(f8),f=i<0||t&&n!=="loop"&&t%2===1?0:c.length-1;return!f||a===void 0?c[f]:a}const h8={decay:fg,inertia:fg,tween:Yl,keyframes:Yl,spring:Yd};function oC(e){typeof e.type=="string"&&(e.type=h8[e.type])}class Mv{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 m8=e=>e/100;class _v extends Mv{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!==Ln.now()&&this.tick(Ln.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;oC(t);const{type:n=Yl,repeat:a=0,repeatDelay:i=0,repeatType:c,velocity:u=0}=t;let{keyframes:f}=t;const m=n||Yl;m!==Yl&&typeof f[0]!="number"&&(this.mixKeyframes=gc(m8,aC(f[0],f[1])),f=[0,100]);const h=m({...t,keyframes:f});c==="mirror"&&(this.mirroredGenerator=m({...t,keyframes:[...f].reverse(),velocity:-u})),h.calculatedDuration===null&&(h.calculatedDuration=Av(h));const{calculatedDuration:g}=h;this.calculatedDuration=g,this.resolvedDuration=g+i,this.totalDuration=this.resolvedDuration*(a+1)-i,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:a,totalDuration:i,mixKeyframes:c,mirroredGenerator:u,resolvedDuration:f,calculatedDuration:m}=this;if(this.startTime===null)return a.next(0);const{delay:h=0,keyframes:g,repeat:x,repeatType:b,repeatDelay:w,type:j,onUpdate:N,finalKeyframe:T}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-i/this.speed,this.startTime)),n?this.currentTime=t:this.updateTime(t);const k=this.currentTime-h*(this.playbackSpeed>=0?1:-1),C=this.playbackSpeed>=0?k<0:k>i;this.currentTime=Math.max(k,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let S=this.currentTime,R=a;if(x){const V=Math.min(this.currentTime,i)/f;let Z=Math.floor(V),I=V%1;!I&&V>=1&&(I=1),I===1&&Z--,Z=Math.min(Z,x+1),Z%2&&(b==="reverse"?(I=1-I,w&&(I-=w/f)):b==="mirror"&&(R=u)),S=sa(0,1,I)*f}const A=C?{done:!1,value:g[0]}:R.next(S);c&&(A.value=c(A.value));let{done:_}=A;!C&&m!==null&&(_=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const O=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&_);return O&&j!==fg&&(A.value=Rv(g,this.options,T,this.speed)),N&&N(A.value),O&&this.finish(),A}then(t,n){return this.finished.then(t,n)}get duration(){return js(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+js(t)}get time(){return js(this.currentTime)}set time(t){t=$s(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(Ln.now());const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=js(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=K6,startTime:n}=this.options;this.driver||(this.driver=t(i=>this.tick(i))),this.options.onPlay?.();const a=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=a):this.holdTime!==null?this.startTime=a-this.holdTime:this.startTime||(this.startTime=n??a),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(Ln.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 p8(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const Wr=e=>e*180/Math.PI,hg=e=>{const t=Wr(Math.atan2(e[1],e[0]));return mg(t)},g8={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:hg,rotateZ:hg,skewX:e=>Wr(Math.atan(e[1])),skewY:e=>Wr(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},mg=e=>(e=e%360,e<0&&(e+=360),e),H1=hg,Z1=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),F1=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),v8={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Z1,scaleY:F1,scale:e=>(Z1(e)+F1(e))/2,rotateX:e=>mg(Wr(Math.atan2(e[6],e[5]))),rotateY:e=>mg(Wr(Math.atan2(-e[2],e[0]))),rotateZ:H1,rotate:H1,skewX:e=>Wr(Math.atan(e[4])),skewY:e=>Wr(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function pg(e){return e.includes("scale")?1:0}function gg(e,t){if(!e||e==="none")return pg(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let a,i;if(n)a=v8,i=n;else{const f=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);a=g8,i=f}if(!i)return pg(t);const c=a[t],u=i[1].split(",").map(x8);return typeof c=="function"?c(u):u[c]}const y8=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return gg(n,t)};function x8(e){return parseFloat(e.trim())}const zo=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Lo=new Set(zo),q1=e=>e===Do||e===Te,b8=new Set(["x","y","z"]),w8=zo.filter(e=>!b8.has(e));function S8(e){const t=[];return w8.forEach(n=>{const a=e.getValue(n);a!==void 0&&(t.push([n,a.get()]),a.set(n.startsWith("scale")?1:0))}),t}const lr={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})=>gg(t,"x"),y:(e,{transform:t})=>gg(t,"y")};lr.translateX=lr.x;lr.translateY=lr.y;const Jr=new Set;let vg=!1,yg=!1,xg=!1;function lC(){if(yg){const e=Array.from(Jr).filter(a=>a.needsMeasurement),t=new Set(e.map(a=>a.element)),n=new Map;t.forEach(a=>{const i=S8(a);i.length&&(n.set(a,i),a.render())}),e.forEach(a=>a.measureInitialState()),t.forEach(a=>{a.render();const i=n.get(a);i&&i.forEach(([c,u])=>{a.getValue(c)?.set(u)})}),e.forEach(a=>a.measureEndState()),e.forEach(a=>{a.suspendedScrollY!==void 0&&window.scrollTo(0,a.suspendedScrollY)})}yg=!1,vg=!1,Jr.forEach(e=>e.complete(xg)),Jr.clear()}function cC(){Jr.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(yg=!0)})}function j8(){xg=!0,cC(),lC(),xg=!1}class Ov{constructor(t,n,a,i,c,u=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=a,this.motionValue=i,this.element=c,this.isAsync=u}scheduleResolve(){this.state="scheduled",this.isAsync?(Jr.add(this),vg||(vg=!0,Ct.read(cC),Ct.resolveKeyframes(lC))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:a,motionValue:i}=this;if(t[0]===null){const c=i?.get(),u=t[t.length-1];if(c!==void 0)t[0]=c;else if(a&&n){const f=a.readValue(n,u);f!=null&&(t[0]=f)}t[0]===void 0&&(t[0]=u),i&&c===void 0&&i.set(t[0])}p8(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),Jr.delete(this)}cancel(){this.state==="scheduled"&&(Jr.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const N8=e=>e.startsWith("--");function k8(e,t,n){N8(t)?e.style.setProperty(t,n):e.style[t]=n}const E8={};function uC(e,t){const n=LE(e);return()=>E8[t]??n()}const C8=uC(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),dC=uC(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Ll=([e,t,n,a])=>`cubic-bezier(${e}, ${t}, ${n}, ${a})`,Y1={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Ll([0,.65,.55,1]),circOut:Ll([.55,0,1,.45]),backIn:Ll([.31,.01,.66,-.59]),backOut:Ll([.33,1.53,.69,.99])};function fC(e,t){if(e)return typeof e=="function"?dC()?rC(e,t):"ease-out":GE(e)?Ll(e):Array.isArray(e)?e.map(n=>fC(n,t)||Y1.easeOut):Y1[e]}function T8(e,t,n,{delay:a=0,duration:i=300,repeat:c=0,repeatType:u="loop",ease:f="easeOut",times:m}={},h=void 0){const g={[t]:n};m&&(g.offset=m);const x=fC(f,i);Array.isArray(x)&&(g.easing=x);const b={delay:a,duration:i,easing:Array.isArray(x)?"linear":x,fill:"both",iterations:c+1,direction:u==="reverse"?"alternate":"normal"};return h&&(b.pseudoElement=h),e.animate(g,b)}function hC(e){return typeof e=="function"&&"applyToOptions"in e}function A8({type:e,...t}){return hC(e)&&dC()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class mC extends Mv{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!t)return;const{element:n,name:a,keyframes:i,pseudoElement:c,allowFlatten:u=!1,finalKeyframe:f,onComplete:m}=t;this.isPseudoElement=!!c,this.allowFlatten=u,this.options=t,wv(typeof t.type!="string");const h=A8(t);this.animation=T8(n,a,i,h,c),h.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!c){const g=Rv(i,this.options,f,this.speed);this.updateMotionValue?this.updateMotionValue(g):k8(n,a,g),this.animation.cancel()}m?.(),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 js(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+js(t)}get time(){return js(Number(this.animation.currentTime)||0)}set time(t){this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=$s(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&&C8()?(this.animation.timeline=t,Ns):n(this)}}const pC={anticipate:ZE,backInOut:HE,circInOut:qE};function R8(e){return e in pC}function M8(e){typeof e.ease=="string"&&R8(e.ease)&&(e.ease=pC[e.ease])}const up=10;class _8 extends mC{constructor(t){M8(t),oC(t),super(t),t.startTime!==void 0&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:n,onUpdate:a,onComplete:i,element:c,...u}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const f=new _v({...u,autoplay:!1}),m=Math.max(up,Ln.now()-this.startTime),h=sa(0,up,m-up);n.setWithVelocity(f.sample(Math.max(0,m-h)).value,f.sample(m).value,h),f.stop()}}const G1=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(Ps.test(e)||e==="0")&&!e.startsWith("url("));function O8(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 I8(e,t,n,a){const i=e[0];if(i===null)return!1;if(t==="display"||t==="visibility")return!0;const c=e[e.length-1],u=G1(i,t),f=G1(c,t);return!u||!f?!1:O8(e)||(n==="spring"||hC(n))&&a}function bg(e){e.duration=0,e.type="keyframes"}const D8=new Set(["opacity","clipPath","filter","transform"]),z8=LE(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function L8(e){const{motionValue:t,name:n,repeatDelay:a,repeatType:i,damping:c,type:u}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:m,transformTemplate:h}=t.owner.getProps();return z8()&&n&&D8.has(n)&&(n!=="transform"||!h)&&!m&&!a&&i!=="mirror"&&c!==0&&u!=="inertia"}const $8=40;class P8 extends Mv{constructor({autoplay:t=!0,delay:n=0,type:a="keyframes",repeat:i=0,repeatDelay:c=0,repeatType:u="loop",keyframes:f,name:m,motionValue:h,element:g,...x}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Ln.now();const b={autoplay:t,delay:n,type:a,repeat:i,repeatDelay:c,repeatType:u,name:m,motionValue:h,element:g,...x},w=g?.KeyframeResolver||Ov;this.keyframeResolver=new w(f,(j,N,T)=>this.onKeyframesResolved(j,N,b,!T),m,h,g),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(t,n,a,i){this.keyframeResolver=void 0;const{name:c,type:u,velocity:f,delay:m,isHandoff:h,onUpdate:g}=a;this.resolvedAt=Ln.now(),I8(t,c,u,f)||((Aa.instantAnimations||!m)&&g?.(Rv(t,a,n)),t[0]=t[t.length-1],bg(a),a.repeat=0);const b={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>$8?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...a,keyframes:t},w=!h&&L8(b),j=b.motionValue?.owner?.current,N=w?new _8({...b,element:j}):new _v(b);N.finished.then(()=>{this.notifyFinished()}).catch(Ns),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(),j8()),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 gC(e,t,n,a=0,i=1){const c=Array.from(e).sort((h,g)=>h.sortNodePosition(g)).indexOf(t),u=e.size,f=(u-1)*a;return typeof n=="function"?n(c,u):i===1?c*a:f-c*a}const U8=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function B8(e){const t=U8.exec(e);if(!t)return[,];const[,n,a,i]=t;return[`--${n??a}`,i]}function vC(e,t,n=1){const[a,i]=B8(e);if(!a)return;const c=window.getComputedStyle(t).getPropertyValue(a);if(c){const u=c.trim();return IE(u)?parseFloat(u):u}return kv(i)?vC(i,t,n+1):i}const V8={type:"spring",stiffness:500,damping:25,restSpeed:10},H8=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Z8={type:"keyframes",duration:.8},F8={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},q8=(e,{keyframes:t})=>t.length>2?Z8:Lo.has(e)?e.startsWith("scale")?H8(t[1]):V8:F8,Y8=e=>e!==null;function G8(e,{repeat:t,repeatType:n="loop"},a){const i=e.filter(Y8),c=t&&n!=="loop"&&t%2===1?0:i.length-1;return i[c]}function yC(e,t){if(e?.inherit&&t){const{inherit:n,...a}=e;return{...t,...a}}return e}function Iv(e,t){const n=e?.[t]??e?.default??e;return n!==e?yC(n,e):n}function W8({when:e,delay:t,delayChildren:n,staggerChildren:a,staggerDirection:i,repeat:c,repeatType:u,repeatDelay:f,from:m,elapsed:h,...g}){return!!Object.keys(g).length}const Dv=(e,t,n,a={},i,c)=>u=>{const f=Iv(a,e)||{},m=f.delay||a.delay||0;let{elapsed:h=0}=a;h=h-$s(m);const g={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...f,delay:-h,onUpdate:b=>{t.set(b),f.onUpdate&&f.onUpdate(b)},onComplete:()=>{u(),f.onComplete&&f.onComplete()},name:e,motionValue:t,element:c?void 0:i};W8(f)||Object.assign(g,q8(e,g)),g.duration&&(g.duration=$s(g.duration)),g.repeatDelay&&(g.repeatDelay=$s(g.repeatDelay)),g.from!==void 0&&(g.keyframes[0]=g.from);let x=!1;if((g.type===!1||g.duration===0&&!g.repeatDelay)&&(bg(g),g.delay===0&&(x=!0)),(Aa.instantAnimations||Aa.skipAnimations||i?.shouldSkipAnimations)&&(x=!0,bg(g),g.delay=0),g.allowFlatten=!f.type&&!f.ease,x&&!c&&t.get()!==void 0){const b=G8(g.keyframes,f);if(b!==void 0){Ct.update(()=>{g.onUpdate(b),g.onComplete()});return}}return f.isSync?new _v(g):new P8(g)};function W1(e){const t=[{},{}];return e?.values.forEach((n,a)=>{t[0][a]=n.get(),t[1][a]=n.getVelocity()}),t}function zv(e,t,n,a){if(typeof t=="function"){const[i,c]=W1(a);t=t(n!==void 0?n:e.custom,i,c)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[i,c]=W1(a);t=t(n!==void 0?n:e.custom,i,c)}return t}function So(e,t,n){const a=e.getProps();return zv(a,t,n!==void 0?n:a.custom,e)}const xC=new Set(["width","height","top","left","right","bottom",...zo]),X1=30,X8=e=>!isNaN(parseFloat(e));class K8{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=a=>{const i=Ln.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(a),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const c of this.dependents)c.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=Ln.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=X8(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 Sv);const a=this.events[t].add(n);return t==="change"?()=>{a(),Ct.read(()=>{this.events.change.getSize()||this.stop()})}:a}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,a){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-a}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=Ln.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>X1)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,X1);return $E(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 Ao(e,t){return new K8(e,t)}const wg=e=>Array.isArray(e);function J8(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Ao(n))}function Q8(e){return wg(e)?e[e.length-1]||0:e}function eU(e,t){const n=So(e,t);let{transitionEnd:a={},transition:i={},...c}=n||{};c={...c,...a};for(const u in c){const f=Q8(c[u]);J8(e,u,f)}}const _n=e=>!!(e&&e.getVelocity);function tU(e){return!!(_n(e)&&e.add)}function Sg(e,t){const n=e.getValue("willChange");if(tU(n))return n.add(t);if(!n&&Aa.WillChange){const a=new Aa.WillChange("auto");e.addValue("willChange",a),a.add(t)}}function Lv(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}const nU="framerAppearId",bC="data-"+Lv(nU);function wC(e){return e.props[bC]}function sU({protectedKeys:e,needsAnimating:t},n){const a=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,a}function SC(e,t,{delay:n=0,transitionOverride:a,type:i}={}){let{transition:c,transitionEnd:u,...f}=t;const m=e.getDefaultTransition();c=c?yC(c,m):m;const h=c?.reduceMotion;a&&(c=a);const g=[],x=i&&e.animationState&&e.animationState.getState()[i];for(const b in f){const w=e.getValue(b,e.latestValues[b]??null),j=f[b];if(j===void 0||x&&sU(x,b))continue;const N={delay:n,...Iv(c||{},b)},T=w.get();if(T!==void 0&&!w.isAnimating&&!Array.isArray(j)&&j===T&&!N.velocity)continue;let k=!1;if(window.MotionHandoffAnimation){const R=wC(e);if(R){const A=window.MotionHandoffAnimation(R,b,Ct);A!==null&&(N.startTime=A,k=!0)}}Sg(e,b);const C=h??e.shouldReduceMotion;w.start(Dv(b,w,j,C&&xC.has(b)?{type:!1}:N,e,k));const S=w.animation;S&&g.push(S)}if(u){const b=()=>Ct.update(()=>{u&&eU(e,u)});g.length?Promise.all(g).then(b):b()}return g}function jg(e,t,n={}){const a=So(e,t,n.type==="exit"?e.presenceContext?.custom:void 0);let{transition:i=e.getDefaultTransition()||{}}=a||{};n.transitionOverride&&(i=n.transitionOverride);const c=a?()=>Promise.all(SC(e,a,n)):()=>Promise.resolve(),u=e.variantChildren&&e.variantChildren.size?(m=0)=>{const{delayChildren:h=0,staggerChildren:g,staggerDirection:x}=i;return aU(e,t,m,h,g,x,n)}:()=>Promise.resolve(),{when:f}=i;if(f){const[m,h]=f==="beforeChildren"?[c,u]:[u,c];return m().then(()=>h())}else return Promise.all([c(),u(n.delay)])}function aU(e,t,n=0,a=0,i=0,c=1,u){const f=[];for(const m of e.variantChildren)m.notify("AnimationStart",t),f.push(jg(m,t,{...u,delay:n+(typeof a=="function"?0:a)+gC(e.variantChildren,m,a,i,c)}).then(()=>m.notify("AnimationComplete",t)));return Promise.all(f)}function rU(e,t,n={}){e.notify("AnimationStart",t);let a;if(Array.isArray(t)){const i=t.map(c=>jg(e,c,n));a=Promise.all(i)}else if(typeof t=="string")a=jg(e,t,n);else{const i=typeof t=="function"?So(e,t,n.custom):t;a=Promise.all(SC(e,i,n))}return a.then(()=>{e.notify("AnimationComplete",t)})}const iU={test:e=>e==="auto",parse:e=>e},jC=e=>t=>t.test(e),NC=[Do,Te,ea,nr,D6,I6,iU],K1=e=>NC.find(jC(e));function oU(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||zE(e):!0}const lU=new Set(["brightness","contrast","saturate","opacity"]);function cU(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[a]=n.match(Ev)||[];if(!a)return e;const i=n.replace(a,"");let c=lU.has(t)?1:0;return a!==n&&(c*=100),t+"("+c+i+")"}const uU=/\b([a-z-]*)\(.*?\)/gu,Ng={...Ps,getAnimatableNone:e=>{const t=e.match(uU);return t?t.map(cU).join(" "):e}},kg={...Ps,getAnimatableNone:e=>{const t=Ps.parse(e);return Ps.createTransformer(e)(t.map(a=>typeof a=="number"?0:typeof a=="object"?{...a,alpha:1}:a))}},J1={...Do,transform:Math.round},dU={rotate:nr,rotateX:nr,rotateY:nr,rotateZ:nr,scale:qu,scaleX:qu,scaleY:qu,scaleZ:qu,skew:nr,skewX:nr,skewY:nr,distance:Te,translateX:Te,translateY:Te,translateZ:Te,x:Te,y:Te,z:Te,perspective:Te,transformPerspective:Te,opacity:ic,originX:$1,originY:$1,originZ:Te},$v={borderWidth:Te,borderTopWidth:Te,borderRightWidth:Te,borderBottomWidth:Te,borderLeftWidth:Te,borderRadius:Te,borderTopLeftRadius:Te,borderTopRightRadius:Te,borderBottomRightRadius:Te,borderBottomLeftRadius:Te,width:Te,maxWidth:Te,height:Te,maxHeight:Te,top:Te,right:Te,bottom:Te,left:Te,inset:Te,insetBlock:Te,insetBlockStart:Te,insetBlockEnd:Te,insetInline:Te,insetInlineStart:Te,insetInlineEnd:Te,padding:Te,paddingTop:Te,paddingRight:Te,paddingBottom:Te,paddingLeft:Te,paddingBlock:Te,paddingBlockStart:Te,paddingBlockEnd:Te,paddingInline:Te,paddingInlineStart:Te,paddingInlineEnd:Te,margin:Te,marginTop:Te,marginRight:Te,marginBottom:Te,marginLeft:Te,marginBlock:Te,marginBlockStart:Te,marginBlockEnd:Te,marginInline:Te,marginInlineStart:Te,marginInlineEnd:Te,fontSize:Te,backgroundPositionX:Te,backgroundPositionY:Te,...dU,zIndex:J1,fillOpacity:ic,strokeOpacity:ic,numOctaves:J1},fU={...$v,color:an,backgroundColor:an,outlineColor:an,fill:an,stroke:an,borderColor:an,borderTopColor:an,borderRightColor:an,borderBottomColor:an,borderLeftColor:an,filter:Ng,WebkitFilter:Ng,mask:kg,WebkitMask:kg},kC=e=>fU[e],hU=new Set([Ng,kg]);function EC(e,t){let n=kC(e);return hU.has(n)||(n=Ps),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const mU=new Set(["auto","none","0"]);function pU(e,t,n){let a=0,i;for(;a<e.length&&!i;){const c=e[a];typeof c=="string"&&!mU.has(c)&&oc(c).values.length&&(i=e[a]),a++}if(i&&n)for(const c of t)e[c]=EC(n,i)}class gU extends Ov{constructor(t,n,a,i,c){super(t,n,a,i,c,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:a}=this;if(!n||!n.current)return;super.readKeyframes();for(let g=0;g<t.length;g++){let x=t[g];if(typeof x=="string"&&(x=x.trim(),kv(x))){const b=vC(x,n.current);b!==void 0&&(t[g]=b),g===t.length-1&&(this.finalKeyframe=x)}}if(this.resolveNoneKeyframes(),!xC.has(a)||t.length!==2)return;const[i,c]=t,u=K1(i),f=K1(c),m=L1(i),h=L1(c);if(m!==h&&lr[a]){this.needsMeasurement=!0;return}if(u!==f)if(q1(u)&&q1(f))for(let g=0;g<t.length;g++){const x=t[g];typeof x=="string"&&(t[g]=parseFloat(x))}else lr[a]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,a=[];for(let i=0;i<t.length;i++)(t[i]===null||oU(t[i]))&&a.push(i);a.length&&pU(t,a,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:a}=this;if(!t||!t.current)return;a==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=lr[a](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&t.getValue(a,i).jump(i,!1)}measureEndState(){const{element:t,name:n,unresolvedKeyframes:a}=this;if(!t||!t.current)return;const i=t.getValue(n);i&&i.jump(this.measuredOrigin,!1);const c=a.length-1,u=a[c];a[c]=lr[n](t.measureViewportBox(),window.getComputedStyle(t.current)),u!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=u),this.removedTransforms?.length&&this.removedTransforms.forEach(([f,m])=>{t.getValue(f).set(m)}),this.resolveNoneKeyframes()}}const vU=new Set(["opacity","clipPath","filter","transform"]);function CC(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e=="string"){let a=document;const i=n?.[e]??a.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(a=>a!=null)}const TC=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function Eg(e){return DE(e)&&"offsetHeight"in e}const{schedule:Pv}=WE(queueMicrotask,!1),Ls={x:!1,y:!1};function AC(){return Ls.x||Ls.y}function yU(e){return e==="x"||e==="y"?Ls[e]?null:(Ls[e]=!0,()=>{Ls[e]=!1}):Ls.x||Ls.y?null:(Ls.x=Ls.y=!0,()=>{Ls.x=Ls.y=!1})}function RC(e,t){const n=CC(e),a=new AbortController,i={passive:!0,...t,signal:a.signal};return[n,i,()=>a.abort()]}function xU(e){return!(e.pointerType==="touch"||AC())}function bU(e,t,n={}){const[a,i,c]=RC(e,n);return a.forEach(u=>{let f=!1,m=!1,h;const g=()=>{u.removeEventListener("pointerleave",j)},x=T=>{h&&(h(T),h=void 0),g()},b=T=>{f=!1,window.removeEventListener("pointerup",b),window.removeEventListener("pointercancel",b),m&&(m=!1,x(T))},w=()=>{f=!0,window.addEventListener("pointerup",b,i),window.addEventListener("pointercancel",b,i)},j=T=>{if(T.pointerType!=="touch"){if(f){m=!0;return}x(T)}},N=T=>{if(!xU(T))return;m=!1;const k=t(u,T);typeof k=="function"&&(h=k,u.addEventListener("pointerleave",j,i))};u.addEventListener("pointerenter",N,i),u.addEventListener("pointerdown",w,i)}),c}const MC=(e,t)=>t?e===t?!0:MC(e,t.parentElement):!1,Uv=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,wU=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function SU(e){return wU.has(e.tagName)||e.isContentEditable===!0}const jU=new Set(["INPUT","SELECT","TEXTAREA"]);function NU(e){return jU.has(e.tagName)||e.isContentEditable===!0}const pd=new WeakSet;function Q1(e){return t=>{t.key==="Enter"&&e(t)}}function dp(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const kU=(e,t)=>{const n=e.currentTarget;if(!n)return;const a=Q1(()=>{if(pd.has(n))return;dp(n,"down");const i=Q1(()=>{dp(n,"up")}),c=()=>dp(n,"cancel");n.addEventListener("keyup",i,t),n.addEventListener("blur",c,t)});n.addEventListener("keydown",a,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",a),t)};function eS(e){return Uv(e)&&!AC()}const tS=new WeakSet;function EU(e,t,n={}){const[a,i,c]=RC(e,n),u=f=>{const m=f.currentTarget;if(!eS(f)||tS.has(f))return;pd.add(m),n.stopPropagation&&tS.add(f);const h=t(m,f),g=(w,j)=>{window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",b),pd.has(m)&&pd.delete(m),eS(w)&&typeof h=="function"&&h(w,{success:j})},x=w=>{g(w,m===window||m===document||n.useGlobalTarget||MC(m,w.target))},b=w=>{g(w,!1)};window.addEventListener("pointerup",x,i),window.addEventListener("pointercancel",b,i)};return a.forEach(f=>{(n.useGlobalTarget?window:f).addEventListener("pointerdown",u,i),Eg(f)&&(f.addEventListener("focus",h=>kU(h,i)),!SU(f)&&!f.hasAttribute("tabindex")&&(f.tabIndex=0))}),c}function Bv(e){return DE(e)&&"ownerSVGElement"in e}const gd=new WeakMap;let vd;const _C=(e,t,n)=>(a,i)=>i&&i[0]?i[0][e+"Size"]:Bv(a)&&"getBBox"in a?a.getBBox()[t]:a[n],CU=_C("inline","width","offsetWidth"),TU=_C("block","height","offsetHeight");function AU({target:e,borderBoxSize:t}){gd.get(e)?.forEach(n=>{n(e,{get width(){return CU(e,t)},get height(){return TU(e,t)}})})}function RU(e){e.forEach(AU)}function MU(){typeof ResizeObserver>"u"||(vd=new ResizeObserver(RU))}function _U(e,t){vd||MU();const n=CC(e);return n.forEach(a=>{let i=gd.get(a);i||(i=new Set,gd.set(a,i)),i.add(t),vd?.observe(a)}),()=>{n.forEach(a=>{const i=gd.get(a);i?.delete(t),i?.size||vd?.unobserve(a)})}}const yd=new Set;let mo;function OU(){mo=()=>{const e={get width(){return window.innerWidth},get height(){return window.innerHeight}};yd.forEach(t=>t(e))},window.addEventListener("resize",mo)}function IU(e){return yd.add(e),mo||OU(),()=>{yd.delete(e),!yd.size&&typeof mo=="function"&&(window.removeEventListener("resize",mo),mo=void 0)}}function nS(e,t){return typeof e=="function"?IU(e):_U(e,t)}function DU(e){return Bv(e)&&e.tagName==="svg"}const zU=[...NC,an,Ps],LU=e=>zU.find(jC(e)),sS=()=>({translate:0,scale:1,origin:0,originPoint:0}),po=()=>({x:sS(),y:sS()}),aS=()=>({min:0,max:0}),dn=()=>({x:aS(),y:aS()}),$U=new WeakMap;function bf(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function lc(e){return typeof e=="string"||Array.isArray(e)}const Vv=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Hv=["initial",...Vv];function wf(e){return bf(e.animate)||Hv.some(t=>lc(e[t]))}function OC(e){return!!(wf(e)||e.variants)}function PU(e,t,n){for(const a in t){const i=t[a],c=n[a];if(_n(i))e.addValue(a,i);else if(_n(c))e.addValue(a,Ao(i,{owner:e}));else if(c!==i)if(e.hasValue(a)){const u=e.getValue(a);u.liveStyle===!0?u.jump(i):u.hasAnimated||u.set(i)}else{const u=e.getStaticValue(a);e.addValue(a,Ao(u!==void 0?u:i,{owner:e}))}}for(const a in n)t[a]===void 0&&e.removeValue(a);return t}const Cg={current:null},IC={current:!1},UU=typeof window<"u";function BU(){if(IC.current=!0,!!UU)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>Cg.current=e.matches;e.addEventListener("change",t),t()}else Cg.current=!1}const rS=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Gd={};function DC(e){Gd=e}function VU(){return Gd}class HU{scrapeMotionValuesFromProps(t,n,a){return{}}constructor({parent:t,props:n,presenceContext:a,reducedMotionConfig:i,skipAnimations:c,blockInitialAnimation:u,visualState:f},m={}){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=Ov,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=Ln.now();this.renderScheduledAt<w&&(this.renderScheduledAt=w,Ct.render(this.render,!1,!0))};const{latestValues:h,renderState:g}=f;this.latestValues=h,this.baseTarget={...h},this.initialValues=n.initial?{...h}:{},this.renderState=g,this.parent=t,this.props=n,this.presenceContext=a,this.depth=t?t.depth+1:0,this.reducedMotionConfig=i,this.skipAnimationsConfig=c,this.options=m,this.blockInitialAnimation=!!u,this.isControllingVariants=wf(n),this.isVariantNode=OC(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:x,...b}=this.scrapeMotionValuesFromProps(n,{},this);for(const w in b){const j=b[w];h[w]!==void 0&&_n(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,$U.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,a)=>this.bindToMotionValue(a,n)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(IC.current||BU(),this.shouldReduceMotion=Cg.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(),pr(this.notifyUpdate),pr(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&&vU.has(t)&&this.current instanceof HTMLElement){const{factory:u,keyframes:f,times:m,ease:h,duration:g}=n.accelerate,x=new mC({element:this.current,name:t,keyframes:f,times:m,ease:h,duration:$s(g)}),b=u(x);this.valueSubscriptions.set(t,()=>{b(),x.cancel()});return}const a=Lo.has(t);a&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",u=>{this.latestValues[t]=u,this.props.onUpdate&&Ct.preRender(this.notifyUpdate),a&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let c;typeof window<"u"&&window.MotionCheckAppearSync&&(c=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{i(),c&&c(),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 Gd){const n=Gd[t];if(!n)continue;const{isEnabled:a,Feature:i}=n;if(!this.features[t]&&i&&a(this.props)&&(this.features[t]=new i(this)),this.features[t]){const c=this.features[t];c.isMounted?c.update():(c.mount(),c.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):dn()}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 a=0;a<rS.length;a++){const i=rS[a];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const c="on"+i,u=t[c];u&&(this.propEventSubscriptions[i]=this.on(i,u))}this.prevMotionValues=PU(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 a=this.values.get(t);n!==a&&(a&&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 a=this.values.get(t);return a===void 0&&n!==void 0&&(a=Ao(n===null?void 0:n,{owner:this}),this.addValue(t,a)),a}readValue(t,n){let a=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return a!=null&&(typeof a=="string"&&(IE(a)||zE(a))?a=parseFloat(a):!LU(a)&&Ps.test(n)&&(a=EC(t,n)),this.setBaseTarget(t,_n(a)?a.get():a)),_n(a)?a.get():a}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){const{initial:n}=this.props;let a;if(typeof n=="string"||typeof n=="object"){const c=zv(this.props,n,this.presenceContext?.custom);c&&(a=c[t])}if(n&&a!==void 0)return a;const i=this.getBaseTargetFromProps(this.props,t);return i!==void 0&&!_n(i)?i:this.initialValues[t]!==void 0&&a===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new Sv),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){Pv.render(this.render)}}class zC extends HU{constructor(){super(...arguments),this.KeyframeResolver=gU}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){const a=t.style;return a?a[n]:void 0}removeValueFromRenderState(t,{vars:n,style:a}){delete n[t],delete a[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;_n(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class Nr{constructor(t){this.isMounted=!1,this.node=t}update(){}}function LC({top:e,left:t,right:n,bottom:a}){return{x:{min:t,max:n},y:{min:e,max:a}}}function ZU({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function FU(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),a=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:a.y,right:a.x}}function fp(e){return e===void 0||e===1}function Tg({scale:e,scaleX:t,scaleY:n}){return!fp(e)||!fp(t)||!fp(n)}function qr(e){return Tg(e)||$C(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function $C(e){return iS(e.x)||iS(e.y)}function iS(e){return e&&e!=="0%"}function Wd(e,t,n){const a=e-n,i=t*a;return n+i}function oS(e,t,n,a,i){return i!==void 0&&(e=Wd(e,i,a)),Wd(e,n,a)+t}function Ag(e,t=0,n=1,a,i){e.min=oS(e.min,t,n,a,i),e.max=oS(e.max,t,n,a,i)}function PC(e,{x:t,y:n}){Ag(e.x,t.translate,t.scale,t.originPoint),Ag(e.y,n.translate,n.scale,n.originPoint)}const lS=.999999999999,cS=1.0000000000001;function qU(e,t,n,a=!1){const i=n.length;if(!i)return;t.x=t.y=1;let c,u;for(let f=0;f<i;f++){c=n[f],u=c.projectionDelta;const{visualElement:m}=c.options;m&&m.props.style&&m.props.style.display==="contents"||(a&&c.options.layoutScroll&&c.scroll&&c!==c.root&&vo(e,{x:-c.scroll.offset.x,y:-c.scroll.offset.y}),u&&(t.x*=u.x.scale,t.y*=u.y.scale,PC(e,u)),a&&qr(c.latestValues)&&vo(e,c.latestValues))}t.x<cS&&t.x>lS&&(t.x=1),t.y<cS&&t.y>lS&&(t.y=1)}function go(e,t){e.min=e.min+t,e.max=e.max+t}function uS(e,t,n,a,i=.5){const c=Vt(e.min,e.max,i);Ag(e,t,n,c,a)}function vo(e,t){uS(e.x,t.x,t.scaleX,t.scale,t.originX),uS(e.y,t.y,t.scaleY,t.scale,t.originY)}function UC(e,t){return LC(FU(e.getBoundingClientRect(),t))}function YU(e,t,n){const a=UC(e,n),{scroll:i}=t;return i&&(go(a.x,i.offset.x),go(a.y,i.offset.y)),a}const GU={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},WU=zo.length;function XU(e,t,n){let a="",i=!0;for(let c=0;c<WU;c++){const u=zo[c],f=e[u];if(f===void 0)continue;let m=!0;if(typeof f=="number")m=f===(u.startsWith("scale")?1:0);else{const h=parseFloat(f);m=u.startsWith("scale")?h===1:h===0}if(!m||n){const h=TC(f,$v[u]);if(!m){i=!1;const g=GU[u]||u;a+=`${g}(${h}) `}n&&(t[u]=h)}}return a=a.trim(),n?a=n(t,i?"":a):i&&(a="none"),a}function Zv(e,t,n){const{style:a,vars:i,transformOrigin:c}=e;let u=!1,f=!1;for(const m in t){const h=t[m];if(Lo.has(m)){u=!0;continue}else if(KE(m)){i[m]=h;continue}else{const g=TC(h,$v[m]);m.startsWith("origin")?(f=!0,c[m]=g):a[m]=g}}if(t.transform||(u||n?a.transform=XU(t,e.transform,n):a.transform&&(a.transform="none")),f){const{originX:m="50%",originY:h="50%",originZ:g=0}=c;a.transformOrigin=`${m} ${h} ${g}`}}function BC(e,{style:t,vars:n},a,i){const c=e.style;let u;for(u in t)c[u]=t[u];i?.applyProjectionStyles(c,a);for(u in n)c.setProperty(u,n[u])}function dS(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const Rl={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(Te.test(e))e=parseFloat(e);else return e;const n=dS(e,t.target.x),a=dS(e,t.target.y);return`${n}% ${a}%`}},KU={correct:(e,{treeScale:t,projectionDelta:n})=>{const a=e,i=Ps.parse(e);if(i.length>5)return a;const c=Ps.createTransformer(e),u=typeof i[0]!="number"?1:0,f=n.x.scale*t.x,m=n.y.scale*t.y;i[0+u]/=f,i[1+u]/=m;const h=Vt(f,m,.5);return typeof i[2+u]=="number"&&(i[2+u]/=h),typeof i[3+u]=="number"&&(i[3+u]/=h),c(i)}},Rg={borderRadius:{...Rl,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Rl,borderTopRightRadius:Rl,borderBottomLeftRadius:Rl,borderBottomRightRadius:Rl,boxShadow:KU};function VC(e,{layout:t,layoutId:n}){return Lo.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!Rg[e]||e==="opacity")}function Fv(e,t,n){const a=e.style,i=t?.style,c={};if(!a)return c;for(const u in a)(_n(a[u])||i&&_n(i[u])||VC(u,e)||n?.getValue(u)?.liveStyle!==void 0)&&(c[u]=a[u]);return c}function JU(e){return window.getComputedStyle(e)}class QU extends zC{constructor(){super(...arguments),this.type="html",this.renderInstance=BC}readValueFromInstance(t,n){if(Lo.has(n))return this.projection?.isProjecting?pg(n):y8(t,n);{const a=JU(t),i=(KE(n)?a.getPropertyValue(n):a[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(t,{transformPagePoint:n}){return UC(t,n)}build(t,n,a){Zv(t,n,a.transformTemplate)}scrapeMotionValuesFromProps(t,n,a){return Fv(t,n,a)}}const eB={offset:"stroke-dashoffset",array:"stroke-dasharray"},tB={offset:"strokeDashoffset",array:"strokeDasharray"};function nB(e,t,n=1,a=0,i=!0){e.pathLength=1;const c=i?eB:tB;e[c.offset]=`${-a}`,e[c.array]=`${t} ${n}`}const sB=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function HC(e,{attrX:t,attrY:n,attrScale:a,pathLength:i,pathSpacing:c=1,pathOffset:u=0,...f},m,h,g){if(Zv(e,f,h),m){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:x,style:b}=e;x.transform&&(b.transform=x.transform,delete x.transform),(b.transform||x.transformOrigin)&&(b.transformOrigin=x.transformOrigin??"50% 50%",delete x.transformOrigin),b.transform&&(b.transformBox=g?.transformBox??"fill-box",delete x.transformBox);for(const w of sB)x[w]!==void 0&&(b[w]=x[w],delete x[w]);t!==void 0&&(x.x=t),n!==void 0&&(x.y=n),a!==void 0&&(x.scale=a),i!==void 0&&nB(x,i,c,u,!1)}const ZC=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"]),FC=e=>typeof e=="string"&&e.toLowerCase()==="svg";function aB(e,t,n,a){BC(e,t,void 0,a);for(const i in t.attrs)e.setAttribute(ZC.has(i)?i:Lv(i),t.attrs[i])}function qC(e,t,n){const a=Fv(e,t,n);for(const i in e)if(_n(e[i])||_n(t[i])){const c=zo.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;a[c]=e[i]}return a}class rB extends zC{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=dn}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(Lo.has(n)){const a=kC(n);return a&&a.default||0}return n=ZC.has(n)?n:Lv(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,a){return qC(t,n,a)}build(t,n,a){HC(t,n,this.isSVGTag,a.transformTemplate,a.style)}renderInstance(t,n,a,i){aB(t,n,a,i)}mount(t){this.isSVGTag=FC(t.tagName),super.mount(t)}}const iB=Hv.length;function YC(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?YC(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<iB;n++){const a=Hv[n],i=e.props[a];(lc(i)||i===!1)&&(t[a]=i)}return t}function GC(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let a=0;a<n;a++)if(t[a]!==e[a])return!1;return!0}const oB=[...Vv].reverse(),lB=Vv.length;function cB(e){return t=>Promise.all(t.map(({animation:n,options:a})=>rU(e,n,a)))}function uB(e){let t=cB(e),n=fS(),a=!0;const i=m=>(h,g)=>{const x=So(e,g,m==="exit"?e.presenceContext?.custom:void 0);if(x){const{transition:b,transitionEnd:w,...j}=x;h={...h,...j,...w}}return h};function c(m){t=m(e)}function u(m){const{props:h}=e,g=YC(e.parent)||{},x=[],b=new Set;let w={},j=1/0;for(let T=0;T<lB;T++){const k=oB[T],C=n[k],S=h[k]!==void 0?h[k]:g[k],R=lc(S),A=k===m?C.isActive:null;A===!1&&(j=T);let _=S===g[k]&&S!==h[k]&&R;if(_&&a&&e.manuallyAnimateOnMount&&(_=!1),C.protectedKeys={...w},!C.isActive&&A===null||!S&&!C.prevProp||bf(S)||typeof S=="boolean")continue;if(k==="exit"&&C.isActive&&A!==!0){C.prevResolvedValues&&(w={...w,...C.prevResolvedValues});continue}const O=dB(C.prevProp,S);let V=O||k===m&&C.isActive&&!_&&R||T>j&&R,Z=!1;const I=Array.isArray(S)?S:[S];let $=I.reduce(i(k),{});A===!1&&($={});const{prevResolvedValues:L={}}=C,P={...L,...$},q=U=>{V=!0,b.has(U)&&(Z=!0,b.delete(U)),C.needsAnimating[U]=!0;const B=e.getValue(U);B&&(B.liveStyle=!1)};for(const U in P){const B=$[U],G=L[U];if(w.hasOwnProperty(U))continue;let K=!1;wg(B)&&wg(G)?K=!GC(B,G):K=B!==G,K?B!=null?q(U):b.add(U):B!==void 0&&b.has(U)?q(U):C.protectedKeys[U]=!0}C.prevProp=S,C.prevResolvedValues=$,C.isActive&&(w={...w,...$}),a&&e.blockInitialAnimation&&(V=!1);const ee=_&&O;V&&(!ee||Z)&&x.push(...I.map(U=>{const B={type:k};if(typeof U=="string"&&a&&!ee&&e.manuallyAnimateOnMount&&e.parent){const{parent:G}=e,K=So(G,U);if(G.enteringChildren&&K){const{delayChildren:z}=K.transition||{};B.delay=gC(G.enteringChildren,e,z)}}return{animation:U,options:B}}))}if(b.size){const T={};if(typeof h.initial!="boolean"){const k=So(e,Array.isArray(h.initial)?h.initial[0]:h.initial);k&&k.transition&&(T.transition=k.transition)}b.forEach(k=>{const C=e.getBaseTarget(k),S=e.getValue(k);S&&(S.liveStyle=!0),T[k]=C??null}),x.push({animation:T})}let N=!!x.length;return a&&(h.initial===!1||h.initial===h.animate)&&!e.manuallyAnimateOnMount&&(N=!1),a=!1,N?t(x):Promise.resolve()}function f(m,h){if(n[m].isActive===h)return Promise.resolve();e.variantChildren?.forEach(x=>x.animationState?.setActive(m,h)),n[m].isActive=h;const g=u(m);for(const x in n)n[x].protectedKeys={};return g}return{animateChanges:u,setActive:f,setAnimateFunction:c,getState:()=>n,reset:()=>{n=fS()}}}function dB(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!GC(t,e):!1}function Zr(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function fS(){return{animate:Zr(!0),whileInView:Zr(),whileHover:Zr(),whileTap:Zr(),whileDrag:Zr(),whileFocus:Zr(),exit:Zr()}}function hS(e,t){e.min=t.min,e.max=t.max}function zs(e,t){hS(e.x,t.x),hS(e.y,t.y)}function mS(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}const WC=1e-4,fB=1-WC,hB=1+WC,XC=.01,mB=0-XC,pB=0+XC;function $n(e){return e.max-e.min}function gB(e,t,n){return Math.abs(e-t)<=n}function pS(e,t,n,a=.5){e.origin=a,e.originPoint=Vt(t.min,t.max,e.origin),e.scale=$n(n)/$n(t),e.translate=Vt(n.min,n.max,e.origin)-e.originPoint,(e.scale>=fB&&e.scale<=hB||isNaN(e.scale))&&(e.scale=1),(e.translate>=mB&&e.translate<=pB||isNaN(e.translate))&&(e.translate=0)}function Gl(e,t,n,a){pS(e.x,t.x,n.x,a?a.originX:void 0),pS(e.y,t.y,n.y,a?a.originY:void 0)}function gS(e,t,n){e.min=n.min+t.min,e.max=e.min+$n(t)}function vB(e,t,n){gS(e.x,t.x,n.x),gS(e.y,t.y,n.y)}function vS(e,t,n){e.min=t.min-n.min,e.max=e.min+$n(t)}function Xd(e,t,n){vS(e.x,t.x,n.x),vS(e.y,t.y,n.y)}function yS(e,t,n,a,i){return e-=t,e=Wd(e,1/n,a),i!==void 0&&(e=Wd(e,1/i,a)),e}function yB(e,t=0,n=1,a=.5,i,c=e,u=e){if(ea.test(t)&&(t=parseFloat(t),t=Vt(u.min,u.max,t/100)-u.min),typeof t!="number")return;let f=Vt(c.min,c.max,a);e===c&&(f-=t),e.min=yS(e.min,t,n,f,i),e.max=yS(e.max,t,n,f,i)}function xS(e,t,[n,a,i],c,u){yB(e,t[n],t[a],t[i],t.scale,c,u)}const xB=["x","scaleX","originX"],bB=["y","scaleY","originY"];function bS(e,t,n,a){xS(e.x,t,xB,n?n.x:void 0,a?a.x:void 0),xS(e.y,t,bB,n?n.y:void 0,a?a.y:void 0)}function wS(e){return e.translate===0&&e.scale===1}function KC(e){return wS(e.x)&&wS(e.y)}function SS(e,t){return e.min===t.min&&e.max===t.max}function wB(e,t){return SS(e.x,t.x)&&SS(e.y,t.y)}function jS(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function JC(e,t){return jS(e.x,t.x)&&jS(e.y,t.y)}function NS(e){return $n(e.x)/$n(e.y)}function kS(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function Ys(e){return[e("x"),e("y")]}function SB(e,t,n){let a="";const i=e.x.translate/t.x,c=e.y.translate/t.y,u=n?.z||0;if((i||c||u)&&(a=`translate3d(${i}px, ${c}px, ${u}px) `),(t.x!==1||t.y!==1)&&(a+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:h,rotate:g,rotateX:x,rotateY:b,skewX:w,skewY:j}=n;h&&(a=`perspective(${h}px) ${a}`),g&&(a+=`rotate(${g}deg) `),x&&(a+=`rotateX(${x}deg) `),b&&(a+=`rotateY(${b}deg) `),w&&(a+=`skewX(${w}deg) `),j&&(a+=`skewY(${j}deg) `)}const f=e.x.scale*t.x,m=e.y.scale*t.y;return(f!==1||m!==1)&&(a+=`scale(${f}, ${m})`),a||"none"}const QC=["TopLeft","TopRight","BottomLeft","BottomRight"],jB=QC.length,ES=e=>typeof e=="string"?parseFloat(e):e,CS=e=>typeof e=="number"||Te.test(e);function NB(e,t,n,a,i,c){i?(e.opacity=Vt(0,n.opacity??1,kB(a)),e.opacityExit=Vt(t.opacity??1,0,EB(a))):c&&(e.opacity=Vt(t.opacity??1,n.opacity??1,a));for(let u=0;u<jB;u++){const f=`border${QC[u]}Radius`;let m=TS(t,f),h=TS(n,f);if(m===void 0&&h===void 0)continue;m||(m=0),h||(h=0),m===0||h===0||CS(m)===CS(h)?(e[f]=Math.max(Vt(ES(m),ES(h),a),0),(ea.test(h)||ea.test(m))&&(e[f]+="%")):e[f]=h}(t.rotate||n.rotate)&&(e.rotate=Vt(t.rotate||0,n.rotate||0,a))}function TS(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const kB=eT(0,.5,FE),EB=eT(.5,.95,Ns);function eT(e,t,n){return a=>a<e?0:a>t?1:n(rc(e,t,a))}function CB(e,t,n){const a=_n(e)?e:Ao(e);return a.start(Dv("",a,t,n)),a.animation}function cc(e,t,n,a={passive:!0}){return e.addEventListener(t,n,a),()=>e.removeEventListener(t,n)}const TB=(e,t)=>e.depth-t.depth;class AB{constructor(){this.children=[],this.isDirty=!1}add(t){bv(this.children,t),this.isDirty=!0}remove(t){Zd(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(TB),this.isDirty=!1,this.children.forEach(t)}}function RB(e,t){const n=Ln.now(),a=({timestamp:i})=>{const c=i-n;c>=t&&(pr(a),e(c-t))};return Ct.setup(a,!0),()=>pr(a)}function xd(e){return _n(e)?e.get():e}class MB{constructor(){this.members=[]}add(t){bv(this.members,t);for(let n=this.members.length-1;n>=0;n--){const a=this.members[n];if(a===t||a===this.lead||a===this.prevLead)continue;const i=a.instance;i&&i.isConnected===!1&&a.isPresent!==!1&&!a.snapshot&&Zd(this.members,a)}t.scheduleRender()}remove(t){if(Zd(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(i=>t===i);if(n===0)return!1;let a;for(let i=n;i>=0;i--){const c=this.members[i],u=c.instance;if(c.isPresent!==!1&&(!u||u.isConnected!==!1)){a=c;break}}return a?(this.promote(a),!0):!1}promote(t,n){const a=this.lead;if(t!==a&&(this.prevLead=a,this.lead=t,t.show(),a)){a.instance&&a.scheduleRender(),t.scheduleRender();const i=a.options.layoutDependency,c=t.options.layoutDependency;if(!(i!==void 0&&c!==void 0&&i===c)){const m=a.instance;m&&m.isConnected===!1&&!a.snapshot||(t.resumeFrom=a,n&&(t.resumeFrom.preserveOpacity=!0),a.snapshot&&(t.snapshot=a.snapshot,t.snapshot.latestValues=a.animationValues||a.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0))}const{crossfade:f}=t.options;f===!1&&a.hide()}}exitAnimationComplete(){this.members.forEach(t=>{const{options:n,resumingFrom:a}=t;n.onExitComplete&&n.onExitComplete(),a&&a.options.onExitComplete&&a.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}const bd={hasAnimatedSinceResize:!0,hasEverUpdated:!1},hp=["","X","Y","Z"],_B=1e3;let OB=0;function mp(e,t,n,a){const{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),a&&(a[e]=0))}function tT(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=wC(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:c}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",Ct,!(i||c))}const{parent:a}=e;a&&!a.hasCheckedOptimisedAppear&&tT(a)}function nT({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:a,resetTransform:i}){return class{constructor(u={},f=t?.()){this.id=OB++,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(zB),this.nodes.forEach(UB),this.nodes.forEach(BB),this.nodes.forEach(LB)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=u,this.root=f?f.root||f:this,this.path=f?[...f.path,f]:[],this.parent=f,this.depth=f?f.depth+1:0;for(let m=0;m<this.path.length;m++)this.path[m].shouldResetTransform=!0;this.root===this&&(this.nodes=new AB)}addEventListener(u,f){return this.eventHandlers.has(u)||this.eventHandlers.set(u,new Sv),this.eventHandlers.get(u).add(f)}notifyListeners(u,...f){const m=this.eventHandlers.get(u);m&&m.notify(...f)}hasListeners(u){return this.eventHandlers.has(u)}mount(u){if(this.instance)return;this.isSVG=Bv(u)&&!DU(u),this.instance=u;const{layoutId:f,layout:m,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&&(m||f)&&(this.isLayoutDirty=!0),e){let g,x=0;const b=()=>this.root.updateBlockedByResize=!1;Ct.read(()=>{x=window.innerWidth}),e(u,()=>{const w=window.innerWidth;w!==x&&(x=w,this.root.updateBlockedByResize=!0,g&&g(),g=RB(b,250),bd.hasAnimatedSinceResize&&(bd.hasAnimatedSinceResize=!1,this.nodes.forEach(MS)))})}f&&this.root.registerSharedNode(f,this),this.options.animate!==!1&&h&&(f||m)&&this.addEventListener("didUpdate",({delta:g,hasLayoutChanged:x,hasRelativeLayoutChanged:b,layout:w})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const j=this.options.transition||h.getDefaultTransition()||qB,{onLayoutAnimationStart:N,onLayoutAnimationComplete:T}=h.getProps(),k=!this.targetLayout||!JC(this.targetLayout,w),C=!x&&b;if(this.options.layoutRoot||this.resumeFrom||C||x&&(k||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const S={...Iv(j,"layout"),onPlay:N,onComplete:T};(h.shouldReduceMotion||this.options.layoutRoot)&&(S.delay=0,S.type=!1),this.startAnimation(S),this.setAnimationOrigin(g,C)}else x||MS(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(),pr(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(VB),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&&tT(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let g=0;g<this.path.length;g++){const x=this.path[g];x.shouldResetTransform=!0,x.updateScroll("snapshot"),x.options.layoutRoot&&x.willUpdate(!1)}const{layoutId:f,layout:m}=this.options;if(f===void 0&&!m)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(AS);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(RS);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(PB),this.nodes.forEach(IB),this.nodes.forEach(DB)):this.nodes.forEach(RS),this.clearAllSnapshots();const f=Ln.now();kn.delta=sa(0,1e3/60,f-kn.timestamp),kn.timestamp=f,kn.isProcessing=!0,rp.update.process(kn),rp.preRender.process(kn),rp.render.process(kn),kn.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Pv.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach($B),this.sharedNodes.forEach(HB)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Ct.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Ct.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!$n(this.snapshot.measuredBox.x)&&!$n(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 m=0;m<this.path.length;m++)this.path[m].updateScroll();const u=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected=dn(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:f}=this.options;f&&f.notify("LayoutMeasure",this.layout.layoutBox,u?u.layoutBox:void 0)}updateScroll(u="measure"){let f=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===u&&(f=!1),f&&this.instance){const m=a(this.instance);this.scroll={animationId:this.root.animationId,phase:u,isRoot:m,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:m}}}resetTransform(){if(!i)return;const u=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,f=this.projectionDelta&&!KC(this.projectionDelta),m=this.getTransformTemplate(),h=m?m(this.latestValues,""):void 0,g=h!==this.prevTransformTemplateValue;u&&this.instance&&(f||qr(this.latestValues)||g)&&(i(this.instance,h),this.shouldResetTransform=!1,this.scheduleRender())}measure(u=!0){const f=this.measurePageBox();let m=this.removeElementScroll(f);return u&&(m=this.removeTransform(m)),YB(m),{animationId:this.root.animationId,measuredBox:f,layoutBox:m,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:u}=this.options;if(!u)return dn();const f=u.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(GB))){const{scroll:h}=this.root;h&&(go(f.x,h.offset.x),go(f.y,h.offset.y))}return f}removeElementScroll(u){const f=dn();if(zs(f,u),this.scroll?.wasRoot)return f;for(let m=0;m<this.path.length;m++){const h=this.path[m],{scroll:g,options:x}=h;h!==this.root&&g&&x.layoutScroll&&(g.wasRoot&&zs(f,u),go(f.x,g.offset.x),go(f.y,g.offset.y))}return f}applyTransform(u,f=!1){const m=dn();zs(m,u);for(let h=0;h<this.path.length;h++){const g=this.path[h];!f&&g.options.layoutScroll&&g.scroll&&g!==g.root&&vo(m,{x:-g.scroll.offset.x,y:-g.scroll.offset.y}),qr(g.latestValues)&&vo(m,g.latestValues)}return qr(this.latestValues)&&vo(m,this.latestValues),m}removeTransform(u){const f=dn();zs(f,u);for(let m=0;m<this.path.length;m++){const h=this.path[m];if(!h.instance||!qr(h.latestValues))continue;Tg(h.latestValues)&&h.updateSnapshot();const g=dn(),x=h.measurePageBox();zs(g,x),bS(f,h.latestValues,h.snapshot?h.snapshot.layoutBox:void 0,g)}return qr(this.latestValues)&&bS(f,this.latestValues),f}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!==kn.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(u=!1){const f=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=f.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=f.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=f.isSharedProjectionDirty);const m=!!this.resumingFrom||this!==f;if(!(u||m&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:g,layoutId:x}=this.options;if(!this.layout||!(g||x))return;this.resolvedRelativeTargetAt=kn.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=dn(),this.targetWithTransforms=dn()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),vB(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):zs(this.target,this.layout.layoutBox),PC(this.target,this.targetDelta)):zs(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||Tg(this.parent.latestValues)||$C(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,f,m){this.relativeParent=u,this.linkedParentVersion=u.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=dn(),this.relativeTargetOrigin=dn(),Xd(this.relativeTargetOrigin,f,m),zs(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){const u=this.getLead(),f=!!this.resumingFrom||this!==u;let m=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(m=!1),f&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(m=!1),this.resolvedRelativeTargetAt===kn.timestamp&&(m=!1),m)return;const{layout:h,layoutId:g}=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||g))return;zs(this.layoutCorrected,this.layout.layoutBox);const x=this.treeScale.x,b=this.treeScale.y;qU(this.layoutCorrected,this.treeScale,this.path,f),u.layout&&!u.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(u.target=u.layout.layoutBox,u.targetWithTransforms=dn());const{target:w}=u;if(!w){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(mS(this.prevProjectionDelta.x,this.projectionDelta.x),mS(this.prevProjectionDelta.y,this.projectionDelta.y)),Gl(this.projectionDelta,this.layoutCorrected,w,this.latestValues),(this.treeScale.x!==x||this.treeScale.y!==b||!kS(this.projectionDelta.x,this.prevProjectionDelta.x)||!kS(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 f=this.getStack();f&&f.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=po(),this.projectionDelta=po(),this.projectionDeltaWithTransform=po()}setAnimationOrigin(u,f=!1){const m=this.snapshot,h=m?m.latestValues:{},g={...this.latestValues},x=po();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!f;const b=dn(),w=m?m.source:void 0,j=this.layout?this.layout.source:void 0,N=w!==j,T=this.getStack(),k=!T||T.members.length<=1,C=!!(N&&!k&&this.options.crossfade===!0&&!this.path.some(FB));this.animationProgress=0;let S;this.mixTargetDelta=R=>{const A=R/1e3;_S(x.x,u.x,A),_S(x.y,u.y,A),this.setTargetDelta(x),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Xd(b,this.layout.layoutBox,this.relativeParent.layout.layoutBox),ZB(this.relativeTarget,this.relativeTargetOrigin,b,A),S&&wB(this.relativeTarget,S)&&(this.isProjectionDirty=!1),S||(S=dn()),zs(S,this.relativeTarget)),N&&(this.animationValues=g,NB(g,h,this.latestValues,A,C,k)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=A},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(u){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(pr(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Ct.update(()=>{bd.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Ao(0)),this.motionValue.jump(0,!1),this.currentAnimation=CB(this.motionValue,[0,1e3],{...u,velocity:0,isSync:!0,onUpdate:f=>{this.mixTargetDelta(f),u.onUpdate&&u.onUpdate(f)},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(_B),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const u=this.getLead();let{targetWithTransforms:f,target:m,layout:h,latestValues:g}=u;if(!(!f||!m||!h)){if(this!==u&&this.layout&&h&&sT(this.options.animationType,this.layout.layoutBox,h.layoutBox)){m=this.target||dn();const x=$n(this.layout.layoutBox.x);m.x.min=u.target.x.min,m.x.max=m.x.min+x;const b=$n(this.layout.layoutBox.y);m.y.min=u.target.y.min,m.y.max=m.y.min+b}zs(f,m),vo(f,g),Gl(this.projectionDeltaWithTransform,this.layoutCorrected,f,g)}}registerSharedNode(u,f){this.sharedNodes.has(u)||this.sharedNodes.set(u,new MB),this.sharedNodes.get(u).add(f);const h=f.options.initialPromotionConfig;f.promote({transition:h?h.transition:void 0,preserveFollowOpacity:h&&h.shouldPreserveFollowOpacity?h.shouldPreserveFollowOpacity(f):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:f,preserveFollowOpacity:m}={}){const h=this.getStack();h&&h.promote(this,m),u&&(this.projectionDelta=void 0,this.needsReset=!0),f&&this.setOptions({transition:f})}relegate(){const u=this.getStack();return u?u.relegate(this):!1}resetSkewAndRotation(){const{visualElement:u}=this.options;if(!u)return;let f=!1;const{latestValues:m}=u;if((m.z||m.rotate||m.rotateX||m.rotateY||m.rotateZ||m.skewX||m.skewY)&&(f=!0),!f)return;const h={};m.z&&mp("z",u,h,this.animationValues);for(let g=0;g<hp.length;g++)mp(`rotate${hp[g]}`,u,h,this.animationValues),mp(`skew${hp[g]}`,u,h,this.animationValues);u.render();for(const g in h)u.setStaticValue(g,h[g]),this.animationValues&&(this.animationValues[g]=h[g]);u.scheduleRender()}applyProjectionStyles(u,f){if(!this.instance||this.isSVG)return;if(!this.isVisible){u.visibility="hidden";return}const m=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,u.visibility="",u.opacity="",u.pointerEvents=xd(f?.pointerEvents)||"",u.transform=m?m(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=xd(f?.pointerEvents)||""),this.hasProjected&&!qr(this.latestValues)&&(u.transform=m?m({},""):"none",this.hasProjected=!1);return}u.visibility="";const g=h.animationValues||h.latestValues;this.applyTransformsToTarget();let x=SB(this.projectionDeltaWithTransform,this.treeScale,g);m&&(x=m(g,x)),u.transform=x;const{x:b,y:w}=this.projectionDelta;u.transformOrigin=`${b.origin*100}% ${w.origin*100}% 0`,h.animationValues?u.opacity=h===this?g.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:g.opacityExit:u.opacity=h===this?g.opacity!==void 0?g.opacity:"":g.opacityExit!==void 0?g.opacityExit:0;for(const j in Rg){if(g[j]===void 0)continue;const{correct:N,applyTo:T,isCSSVariable:k}=Rg[j],C=x==="none"?g[j]:N(g[j],h);if(T){const S=T.length;for(let R=0;R<S;R++)u[T[R]]=C}else k?this.options.visualElement.renderState.vars[j]=C:u[j]=C}this.options.layoutId&&(u.pointerEvents=h===this?xd(f?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(u=>u.currentAnimation?.stop()),this.root.nodes.forEach(AS),this.root.sharedNodes.clear()}}}function IB(e){e.updateLayout()}function DB(e){const t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:a}=e.layout,{animationType:i}=e.options,c=t.source!==e.layout.source;i==="size"?Ys(g=>{const x=c?t.measuredBox[g]:t.layoutBox[g],b=$n(x);x.min=n[g].min,x.max=x.min+b}):sT(i,t.layoutBox,n)&&Ys(g=>{const x=c?t.measuredBox[g]:t.layoutBox[g],b=$n(n[g]);x.max=x.min+b,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[g].max=e.relativeTarget[g].min+b)});const u=po();Gl(u,n,t.layoutBox);const f=po();c?Gl(f,e.applyTransform(a,!0),t.measuredBox):Gl(f,n,t.layoutBox);const m=!KC(u);let h=!1;if(!e.resumeFrom){const g=e.getClosestProjectingParent();if(g&&!g.resumeFrom){const{snapshot:x,layout:b}=g;if(x&&b){const w=dn();Xd(w,t.layoutBox,x.layoutBox);const j=dn();Xd(j,n,b.layoutBox),JC(w,j)||(h=!0),g.options.layoutRoot&&(e.relativeTarget=j,e.relativeTargetOrigin=w,e.relativeParent=g)}}}e.notifyListeners("didUpdate",{layout:n,snapshot:t,delta:f,layoutDelta:u,hasLayoutChanged:m,hasRelativeLayoutChanged:h})}else if(e.isLead()){const{onExitComplete:n}=e.options;n&&n()}e.options.transition=void 0}function zB(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 LB(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function $B(e){e.clearSnapshot()}function AS(e){e.clearMeasurements()}function RS(e){e.isLayoutDirty=!1}function PB(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function MS(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function UB(e){e.resolveTargetDelta()}function BB(e){e.calcProjection()}function VB(e){e.resetSkewAndRotation()}function HB(e){e.removeLeadSnapshot()}function _S(e,t,n){e.translate=Vt(t.translate,0,n),e.scale=Vt(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function OS(e,t,n,a){e.min=Vt(t.min,n.min,a),e.max=Vt(t.max,n.max,a)}function ZB(e,t,n,a){OS(e.x,t.x,n.x,a),OS(e.y,t.y,n.y,a)}function FB(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const qB={duration:.45,ease:[.4,0,.1,1]},IS=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),DS=IS("applewebkit/")&&!IS("chrome/")?Math.round:Ns;function zS(e){e.min=DS(e.min),e.max=DS(e.max)}function YB(e){zS(e.x),zS(e.y)}function sT(e,t,n){return e==="position"||e==="preserve-aspect"&&!gB(NS(t),NS(n),.2)}function GB(e){return e!==e.root&&e.scroll?.wasRoot}const WB=nT({attachResizeListener:(e,t)=>cc(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),pp={current:void 0},aT=nT({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!pp.current){const e=new WB({});e.mount(window),e.setOptions({layoutScroll:!0}),pp.current=e}return pp.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),qv=v.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function LS(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function XB(...e){return t=>{let n=!1;const a=e.map(i=>{const c=LS(i,t);return!n&&typeof c=="function"&&(n=!0),c});if(n)return()=>{for(let i=0;i<a.length;i++){const c=a[i];typeof c=="function"?c():LS(e[i],null)}}}}function KB(...e){return v.useCallback(XB(...e),e)}class JB extends v.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const a=n.offsetParent,i=Eg(a)&&a.offsetWidth||0,c=Eg(a)&&a.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=i-u.width-u.left,u.bottom=c-u.height-u.top}return null}componentDidUpdate(){}render(){return this.props.children}}function QB({children:e,isPresent:t,anchorX:n,anchorY:a,root:i,pop:c}){const u=v.useId(),f=v.useRef(null),m=v.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0}),{nonce:h}=v.useContext(qv),g=e.props?.ref??e?.ref,x=KB(f,g);return v.useInsertionEffect(()=>{const{width:b,height:w,top:j,left:N,right:T,bottom:k}=m.current;if(t||c===!1||!f.current||!b||!w)return;const C=n==="left"?`left: ${N}`:`right: ${T}`,S=a==="bottom"?`bottom: ${k}`:`top: ${j}`;f.current.dataset.motionPopId=u;const R=document.createElement("style");h&&(R.nonce=h);const A=i??document.head;return A.appendChild(R),R.sheet&&R.sheet.insertRule(`
|
|
122
|
+
[data-motion-pop-id="${u}"] {
|
|
123
|
+
position: absolute !important;
|
|
124
|
+
width: ${b}px !important;
|
|
125
|
+
height: ${w}px !important;
|
|
126
|
+
${C}px !important;
|
|
127
|
+
${S}px !important;
|
|
128
|
+
}
|
|
129
|
+
`),()=>{A.contains(R)&&A.removeChild(R)}},[t]),o.jsx(JB,{isPresent:t,childRef:f,sizeRef:m,pop:c,children:c===!1?e:v.cloneElement(e,{ref:x})})}const e9=({children:e,initial:t,isPresent:n,onExitComplete:a,custom:i,presenceAffectsLayout:c,mode:u,anchorX:f,anchorY:m,root:h})=>{const g=xv(t9),x=v.useId();let b=!0,w=v.useMemo(()=>(b=!1,{id:x,initial:t,isPresent:n,custom:i,onExitComplete:j=>{g.set(j,!0);for(const N of g.values())if(!N)return;a&&a()},register:j=>(g.set(j,!1),()=>g.delete(j))}),[n,g,a]);return c&&b&&(w={...w}),v.useMemo(()=>{g.forEach((j,N)=>g.set(N,!1))},[n]),v.useEffect(()=>{!n&&!g.size&&a&&a()},[n]),e=o.jsx(QB,{pop:u==="popLayout",isPresent:n,anchorX:f,anchorY:m,root:h,children:e}),o.jsx(xf.Provider,{value:w,children:e})};function t9(){return new Map}function rT(e=!0){const t=v.useContext(xf);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:a,register:i}=t,c=v.useId();v.useEffect(()=>{if(e)return i(c)},[e]);const u=v.useCallback(()=>e&&a&&a(c),[c,a,e]);return!n&&a?[!1,u]:[!0]}const Yu=e=>e.key||"";function $S(e){const t=[];return v.Children.forEach(e,n=>{v.isValidElement(n)&&t.push(n)}),t}const n9=({children:e,custom:t,initial:n=!0,onExitComplete:a,presenceAffectsLayout:i=!0,mode:c="sync",propagate:u=!1,anchorX:f="left",anchorY:m="top",root:h})=>{const[g,x]=rT(u),b=v.useMemo(()=>$S(e),[e]),w=u&&!g?[]:b.map(Yu),j=v.useRef(!0),N=v.useRef(b),T=xv(()=>new Map),k=v.useRef(new Set),[C,S]=v.useState(b),[R,A]=v.useState(b);OE(()=>{j.current=!1,N.current=b;for(let V=0;V<R.length;V++){const Z=Yu(R[V]);w.includes(Z)?(T.delete(Z),k.current.delete(Z)):T.get(Z)!==!0&&T.set(Z,!1)}},[R,w.length,w.join("-")]);const _=[];if(b!==C){let V=[...b];for(let Z=0;Z<R.length;Z++){const I=R[Z],$=Yu(I);w.includes($)||(V.splice(Z,0,I),_.push(I))}return c==="wait"&&_.length&&(V=_),A($S(V)),S(b),null}const{forceRender:O}=v.useContext(yv);return o.jsx(o.Fragment,{children:R.map(V=>{const Z=Yu(V),I=u&&!g?!1:b===R||w.includes(Z),$=()=>{if(k.current.has(Z))return;if(k.current.add(Z),T.has(Z))T.set(Z,!0);else return;let L=!0;T.forEach(P=>{P||(L=!1)}),L&&(O?.(),A(N.current),u&&x?.(),a&&a())};return o.jsx(e9,{isPresent:I,initial:!j.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:c,root:h,onExitComplete:I?void 0:$,anchorX:f,anchorY:m,children:V},Z)})})},iT=v.createContext({strict:!1}),PS={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 US=!1;function s9(){if(US)return;const e={};for(const t in PS)e[t]={isEnabled:n=>PS[t].some(a=>!!n[a])};DC(e),US=!0}function oT(){return s9(),VU()}function a9(e){const t=oT();for(const n in e)t[n]={...t[n],...e[n]};DC(t)}const r9=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 Kd(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||r9.has(e)}let lT=e=>!Kd(e);function i9(e){typeof e=="function"&&(lT=t=>t.startsWith("on")?!Kd(t):e(t))}try{i9(require("@emotion/is-prop-valid").default)}catch{}function o9(e,t,n){const a={};for(const i in e)i==="values"&&typeof e.values=="object"||(lT(i)||n===!0&&Kd(i)||!t&&!Kd(i)||e.draggable&&i.startsWith("onDrag"))&&(a[i]=e[i]);return a}const Sf=v.createContext({});function l9(e,t){if(wf(e)){const{initial:n,animate:a}=e;return{initial:n===!1||lc(n)?n:void 0,animate:lc(a)?a:void 0}}return e.inherit!==!1?t:{}}function c9(e){const{initial:t,animate:n}=l9(e,v.useContext(Sf));return v.useMemo(()=>({initial:t,animate:n}),[BS(t),BS(n)])}function BS(e){return Array.isArray(e)?e.join(" "):e}const Yv=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function cT(e,t,n){for(const a in t)!_n(t[a])&&!VC(a,n)&&(e[a]=t[a])}function u9({transformTemplate:e},t){return v.useMemo(()=>{const n=Yv();return Zv(n,t,e),Object.assign({},n.vars,n.style)},[t])}function d9(e,t){const n=e.style||{},a={};return cT(a,n,e),Object.assign(a,u9(e,t)),a}function f9(e,t){const n={},a=d9(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,a.userSelect=a.WebkitUserSelect=a.WebkitTouchCallout="none",a.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=a,n}const uT=()=>({...Yv(),attrs:{}});function h9(e,t,n,a){const i=v.useMemo(()=>{const c=uT();return HC(c,t,FC(a),e.transformTemplate,e.style),{...c.attrs,style:{...c.style}}},[t]);if(e.style){const c={};cT(c,e.style,e),i.style={...c,...i.style}}return i}const m9=["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 Gv(e){return typeof e!="string"||e.includes("-")?!1:!!(m9.indexOf(e)>-1||/[A-Z]/u.test(e))}function p9(e,t,n,{latestValues:a},i,c=!1,u){const m=(u??Gv(e)?h9:f9)(t,a,i,e),h=o9(t,typeof e=="string",c),g=e!==v.Fragment?{...h,...m,ref:n}:{},{children:x}=t,b=v.useMemo(()=>_n(x)?x.get():x,[x]);return v.createElement(e,{...g,children:b})}function g9({scrapeMotionValuesFromProps:e,createRenderState:t},n,a,i){return{latestValues:v9(n,a,i,e),renderState:t()}}function v9(e,t,n,a){const i={},c=a(e,{});for(const b in c)i[b]=xd(c[b]);let{initial:u,animate:f}=e;const m=wf(e),h=OC(e);t&&h&&!m&&e.inherit!==!1&&(u===void 0&&(u=t.initial),f===void 0&&(f=t.animate));let g=n?n.initial===!1:!1;g=g||u===!1;const x=g?f:u;if(x&&typeof x!="boolean"&&!bf(x)){const b=Array.isArray(x)?x:[x];for(let w=0;w<b.length;w++){const j=zv(e,b[w]);if(j){const{transitionEnd:N,transition:T,...k}=j;for(const C in k){let S=k[C];if(Array.isArray(S)){const R=g?S.length-1:0;S=S[R]}S!==null&&(i[C]=S)}for(const C in N)i[C]=N[C]}}}return i}const dT=e=>(t,n)=>{const a=v.useContext(Sf),i=v.useContext(xf),c=()=>g9(e,t,a,i);return n?c():xv(c)},y9=dT({scrapeMotionValuesFromProps:Fv,createRenderState:Yv}),x9=dT({scrapeMotionValuesFromProps:qC,createRenderState:uT}),b9=Symbol.for("motionComponentSymbol");function w9(e,t,n){const a=v.useRef(n);v.useInsertionEffect(()=>{a.current=n});const i=v.useRef(null);return v.useCallback(c=>{c&&e.onMount?.(c),t&&(c?t.mount(c):t.unmount());const u=a.current;if(typeof u=="function")if(c){const f=u(c);typeof f=="function"&&(i.current=f)}else i.current?(i.current(),i.current=null):u(c);else u&&(u.current=c)},[t])}const fT=v.createContext({});function ro(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function S9(e,t,n,a,i,c){const{visualElement:u}=v.useContext(Sf),f=v.useContext(iT),m=v.useContext(xf),h=v.useContext(qv),g=h.reducedMotion,x=h.skipAnimations,b=v.useRef(null),w=v.useRef(!1);a=a||f.renderer,!b.current&&a&&(b.current=a(e,{visualState:t,parent:u,props:n,presenceContext:m,blockInitialAnimation:m?m.initial===!1:!1,reducedMotionConfig:g,skipAnimations:x,isSVG:c}),w.current&&b.current&&(b.current.manuallyAnimateOnMount=!0));const j=b.current,N=v.useContext(fT);j&&!j.projection&&i&&(j.type==="html"||j.type==="svg")&&j9(b.current,n,i,N);const T=v.useRef(!1);v.useInsertionEffect(()=>{j&&T.current&&j.update(n,m)});const k=n[bC],C=v.useRef(!!k&&!window.MotionHandoffIsComplete?.(k)&&window.MotionHasOptimisedAnimation?.(k));return OE(()=>{w.current=!0,j&&(T.current=!0,window.MotionIsMounted=!0,j.updateFeatures(),j.scheduleRenderMicrotask(),C.current&&j.animationState&&j.animationState.animateChanges())}),v.useEffect(()=>{j&&(!C.current&&j.animationState&&j.animationState.animateChanges(),C.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(k)}),C.current=!1),j.enteringChildren=void 0)}),j}function j9(e,t,n,a){const{layoutId:i,layout:c,drag:u,dragConstraints:f,layoutScroll:m,layoutRoot:h,layoutCrossfade:g}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:hT(e.parent)),e.projection.setOptions({layoutId:i,layout:c,alwaysMeasureLayout:!!u||f&&ro(f),visualElement:e,animationType:typeof c=="string"?c:"both",initialPromotionConfig:a,crossfade:g,layoutScroll:m,layoutRoot:h})}function hT(e){if(e)return e.options.allowProjection!==!1?e.projection:hT(e.parent)}function gp(e,{forwardMotionProps:t=!1,type:n}={},a,i){a&&a9(a);const c=n?n==="svg":Gv(e),u=c?x9:y9;function f(h,g){let x;const b={...v.useContext(qv),...h,layoutId:N9(h)},{isStatic:w}=b,j=c9(h),N=u(h,w);if(!w&&_E){k9();const T=E9(b);x=T.MeasureLayout,j.visualElement=S9(e,N,b,i,T.ProjectionNode,c)}return o.jsxs(Sf.Provider,{value:j,children:[x&&j.visualElement?o.jsx(x,{visualElement:j.visualElement,...b}):null,p9(e,h,w9(N,j.visualElement,g),N,w,t,c)]})}f.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const m=v.forwardRef(f);return m[b9]=e,m}function N9({layoutId:e}){const t=v.useContext(yv).id;return t&&e!==void 0?t+"-"+e:e}function k9(e,t){v.useContext(iT).strict}function E9(e){const t=oT(),{drag:n,layout:a}=t;if(!n&&!a)return{};const i={...n,...a};return{MeasureLayout:n?.isEnabled(e)||a?.isEnabled(e)?i.MeasureLayout:void 0,ProjectionNode:i.ProjectionNode}}function C9(e,t){if(typeof Proxy>"u")return gp;const n=new Map,a=(c,u)=>gp(c,u,e,t),i=(c,u)=>a(c,u);return new Proxy(i,{get:(c,u)=>u==="create"?a:(n.has(u)||n.set(u,gp(u,void 0,e,t)),n.get(u))})}const T9=(e,t)=>t.isSVG??Gv(e)?new rB(t):new QU(t,{allowProjection:e!==v.Fragment});class A9 extends Nr{constructor(t){super(t),t.animationState||(t.animationState=uB(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();bf(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 R9=0;class M9 extends Nr{constructor(){super(...arguments),this.id=R9++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:a}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===a)return;const i=this.node.animationState.setActive("exit",!t);n&&!t&&i.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 _9={animation:{Feature:A9},exit:{Feature:M9}};function xc(e){return{point:{x:e.pageX,y:e.pageY}}}const O9=e=>t=>Uv(t)&&e(t,xc(t));function Wl(e,t,n,a){return cc(e,t,O9(n),a)}const mT=({current:e})=>e?e.ownerDocument.defaultView:null,VS=(e,t)=>Math.abs(e-t);function I9(e,t){const n=VS(e.x,t.x),a=VS(e.y,t.y);return Math.sqrt(n**2+a**2)}const HS=new Set(["auto","scroll"]);class pT{constructor(t,n,{transformPagePoint:a,contextWindow:i=window,dragSnapToOrigin:c=!1,distanceThreshold:u=3,element:f}={}){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=yp(this.lastMoveEventInfo,this.history),j=this.startEvent!==null,N=I9(w.offset,{x:0,y:0})>=this.distanceThreshold;if(!j&&!N)return;const{point:T}=w,{timestamp:k}=kn;this.history.push({...T,timestamp:k});const{onStart:C,onMove:S}=this.handlers;j||(C&&C(this.lastMoveEvent,w),this.startEvent=this.lastMoveEvent),S&&S(this.lastMoveEvent,w)},this.handlePointerMove=(w,j)=>{this.lastMoveEvent=w,this.lastMoveEventInfo=vp(j,this.transformPagePoint),Ct.update(this.updatePoint,!0)},this.handlePointerUp=(w,j)=>{this.end();const{onEnd:N,onSessionEnd:T,resumeAnimation:k}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&k&&k(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const C=yp(w.type==="pointercancel"?this.lastMoveEventInfo:vp(j,this.transformPagePoint),this.history);this.startEvent&&N&&N(w,C),T&&T(w,C)},!Uv(t))return;this.dragSnapToOrigin=c,this.handlers=n,this.transformPagePoint=a,this.distanceThreshold=u,this.contextWindow=i||window;const m=xc(t),h=vp(m,this.transformPagePoint),{point:g}=h,{timestamp:x}=kn;this.history=[{...g,timestamp:x}];const{onSessionStart:b}=n;b&&b(t,yp(h,this.history)),this.removeListeners=gc(Wl(this.contextWindow,"pointermove",this.handlePointerMove),Wl(this.contextWindow,"pointerup",this.handlePointerUp),Wl(this.contextWindow,"pointercancel",this.handlePointerUp)),f&&this.startScrollTracking(f)}startScrollTracking(t){let n=t.parentElement;for(;n;){const a=getComputedStyle(n);(HS.has(a.overflowX)||HS.has(a.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 a=t===window,i=a?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},c={x:i.x-n.x,y:i.y-n.y};c.x===0&&c.y===0||(a?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=c.x,this.lastMoveEventInfo.point.y+=c.y):this.history.length>0&&(this.history[0].x-=c.x,this.history[0].y-=c.y),this.scrollPositions.set(t,i),Ct.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),pr(this.updatePoint)}}function vp(e,t){return t?{point:t(e.point)}:e}function ZS(e,t){return{x:e.x-t.x,y:e.y-t.y}}function yp({point:e},t){return{point:e,delta:ZS(e,gT(t)),offset:ZS(e,D9(t)),velocity:z9(t,.1)}}function D9(e){return e[0]}function gT(e){return e[e.length-1]}function z9(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,a=null;const i=gT(e);for(;n>=0&&(a=e[n],!(i.timestamp-a.timestamp>$s(t)));)n--;if(!a)return{x:0,y:0};a===e[0]&&e.length>2&&i.timestamp-a.timestamp>$s(t)*2&&(a=e[1]);const c=js(i.timestamp-a.timestamp);if(c===0)return{x:0,y:0};const u={x:(i.x-a.x)/c,y:(i.y-a.y)/c};return u.x===1/0&&(u.x=0),u.y===1/0&&(u.y=0),u}function L9(e,{min:t,max:n},a){return t!==void 0&&e<t?e=a?Vt(t,e,a.min):Math.max(e,t):n!==void 0&&e>n&&(e=a?Vt(n,e,a.max):Math.min(e,n)),e}function FS(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 $9(e,{top:t,left:n,bottom:a,right:i}){return{x:FS(e.x,n,i),y:FS(e.y,t,a)}}function qS(e,t){let n=t.min-e.min,a=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,a]=[a,n]),{min:n,max:a}}function P9(e,t){return{x:qS(e.x,t.x),y:qS(e.y,t.y)}}function U9(e,t){let n=.5;const a=$n(e),i=$n(t);return i>a?n=rc(t.min,t.max-a,e.min):a>i&&(n=rc(e.min,e.max-i,t.min)),sa(0,1,n)}function B9(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 Mg=.35;function V9(e=Mg){return e===!1?e=0:e===!0&&(e=Mg),{x:YS(e,"left","right"),y:YS(e,"top","bottom")}}function YS(e,t,n){return{min:GS(e,t),max:GS(e,n)}}function GS(e,t){return typeof e=="number"?e:e[t]||0}const H9=new WeakMap;class Z9{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=dn(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:a}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const c=x=>{n&&this.snapToCursor(xc(x).point),this.stopAnimation()},u=(x,b)=>{const{drag:w,dragPropagation:j,onDragStart:N}=this.getProps();if(w&&!j&&(this.openDragLock&&this.openDragLock(),this.openDragLock=yU(w),!this.openDragLock))return;this.latestPointerEvent=x,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),Ys(k=>{let C=this.getAxisMotionValue(k).get()||0;if(ea.test(C)){const{projection:S}=this.visualElement;if(S&&S.layout){const R=S.layout.layoutBox[k];R&&(C=$n(R)*(parseFloat(C)/100))}}this.originPoint[k]=C}),N&&Ct.update(()=>N(x,b),!1,!0),Sg(this.visualElement,"transform");const{animationState:T}=this.visualElement;T&&T.setActive("whileDrag",!0)},f=(x,b)=>{this.latestPointerEvent=x,this.latestPanInfo=b;const{dragPropagation:w,dragDirectionLock:j,onDirectionLock:N,onDrag:T}=this.getProps();if(!w&&!this.openDragLock)return;const{offset:k}=b;if(j&&this.currentDirection===null){this.currentDirection=q9(k),this.currentDirection!==null&&N&&N(this.currentDirection);return}this.updateAxis("x",b.point,k),this.updateAxis("y",b.point,k),this.visualElement.render(),T&&Ct.update(()=>T(x,b),!1,!0)},m=(x,b)=>{this.latestPointerEvent=x,this.latestPanInfo=b,this.stop(x,b),this.latestPointerEvent=null,this.latestPanInfo=null},h=()=>{const{dragSnapToOrigin:x}=this.getProps();(x||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:g}=this.getProps();this.panSession=new pT(t,{onSessionStart:c,onStart:u,onMove:f,onSessionEnd:m,resumeAnimation:h},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:g,distanceThreshold:a,contextWindow:mT(this.visualElement),element:this.visualElement.current})}stop(t,n){const a=t||this.latestPointerEvent,i=n||this.latestPanInfo,c=this.isDragging;if(this.cancel(),!c||!i||!a)return;const{velocity:u}=i;this.startAnimation(u);const{onDragEnd:f}=this.getProps();f&&Ct.postRender(()=>f(a,i))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:a}=this.getProps();!a&&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,a){const{drag:i}=this.getProps();if(!a||!Gu(t,i,this.currentDirection))return;const c=this.getAxisMotionValue(t);let u=this.originPoint[t]+a[t];this.constraints&&this.constraints[t]&&(u=L9(u,this.constraints[t],this.elastic[t])),c.set(u)}resolveConstraints(){const{dragConstraints:t,dragElastic:n}=this.getProps(),a=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,i=this.constraints;t&&ro(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&a?this.constraints=$9(a.layoutBox,t):this.constraints=!1,this.elastic=V9(n),i!==this.constraints&&!ro(t)&&a&&this.constraints&&!this.hasMutatedConstraints&&Ys(c=>{this.constraints!==!1&&this.getAxisMotionValue(c)&&(this.constraints[c]=B9(a.layoutBox[c],this.constraints[c]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!ro(t))return!1;const a=t.current,{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const c=YU(a,i.root,this.visualElement.getTransformPagePoint());let u=P9(i.layout.layoutBox,c);if(n){const f=n(ZU(u));this.hasMutatedConstraints=!!f,f&&(u=LC(f))}return u}startAnimation(t){const{drag:n,dragMomentum:a,dragElastic:i,dragTransition:c,dragSnapToOrigin:u,onDragTransitionEnd:f}=this.getProps(),m=this.constraints||{},h=Ys(g=>{if(!Gu(g,n,this.currentDirection))return;let x=m&&m[g]||{};u&&(x={min:0,max:0});const b=i?200:1e6,w=i?40:1e7,j={type:"inertia",velocity:a?t[g]:0,bounceStiffness:b,bounceDamping:w,timeConstant:750,restDelta:1,restSpeed:10,...c,...x};return this.startAxisValueAnimation(g,j)});return Promise.all(h).then(f)}startAxisValueAnimation(t,n){const a=this.getAxisMotionValue(t);return Sg(this.visualElement,t),a.start(Dv(t,a,0,n,this.visualElement,!1))}stopAnimation(){Ys(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,a=this.visualElement.getProps(),i=a[n];return i||this.visualElement.getValue(t,(a.initial?a.initial[t]:void 0)||0)}snapToCursor(t){Ys(n=>{const{drag:a}=this.getProps();if(!Gu(n,a,this.currentDirection))return;const{projection:i}=this.visualElement,c=this.getAxisMotionValue(n);if(i&&i.layout){const{min:u,max:f}=i.layout.layoutBox[n],m=c.get()||0;c.set(t[n]-Vt(u,f,.5)+m)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:a}=this.visualElement;if(!ro(n)||!a||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};Ys(u=>{const f=this.getAxisMotionValue(u);if(f&&this.constraints!==!1){const m=f.get();i[u]=U9({min:m,max:m},this.constraints[u])}});const{transformTemplate:c}=this.visualElement.getProps();this.visualElement.current.style.transform=c?c({},""):"none",a.root&&a.root.updateScroll(),a.updateLayout(),this.constraints=!1,this.resolveConstraints(),Ys(u=>{if(!Gu(u,t,null))return;const f=this.getAxisMotionValue(u),{min:m,max:h}=this.constraints[u];f.set(Vt(m,h,i[u]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;H9.set(this.visualElement,this);const t=this.visualElement.current,n=Wl(t,"pointerdown",h=>{const{drag:g,dragListener:x=!0}=this.getProps(),b=h.target,w=b!==t&&NU(b);g&&x&&!w&&this.start(h)});let a;const i=()=>{const{dragConstraints:h}=this.getProps();ro(h)&&h.current&&(this.constraints=this.resolveRefConstraints(),a||(a=F9(t,h.current,()=>this.scalePositionWithinConstraints())))},{projection:c}=this.visualElement,u=c.addEventListener("measure",i);c&&!c.layout&&(c.root&&c.root.updateScroll(),c.updateLayout()),Ct.read(i);const f=cc(window,"resize",()=>this.scalePositionWithinConstraints()),m=c.addEventListener("didUpdate",(({delta:h,hasLayoutChanged:g})=>{this.isDragging&&g&&(Ys(x=>{const b=this.getAxisMotionValue(x);b&&(this.originPoint[x]+=h[x].translate,b.set(b.get()+h[x].translate))}),this.visualElement.render())}));return()=>{f(),n(),u(),m&&m(),a&&a()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:a=!1,dragPropagation:i=!1,dragConstraints:c=!1,dragElastic:u=Mg,dragMomentum:f=!0}=t;return{...t,drag:n,dragDirectionLock:a,dragPropagation:i,dragConstraints:c,dragElastic:u,dragMomentum:f}}}function WS(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function F9(e,t,n){const a=nS(e,WS(n)),i=nS(t,WS(n));return()=>{a(),i()}}function Gu(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function q9(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class Y9 extends Nr{constructor(t){super(t),this.removeGroupControls=Ns,this.removeListeners=Ns,this.controls=new Z9(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Ns}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 xp=e=>(t,n)=>{e&&Ct.update(()=>e(t,n),!1,!0)};class G9 extends Nr{constructor(){super(...arguments),this.removePointerDownListener=Ns}onPointerDown(t){this.session=new pT(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:mT(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:a,onPanEnd:i}=this.node.getProps();return{onSessionStart:xp(t),onStart:xp(n),onMove:xp(a),onEnd:(c,u)=>{delete this.session,i&&Ct.postRender(()=>i(c,u))}}}mount(){this.removePointerDownListener=Wl(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 bp=!1;class W9 extends v.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:a,layoutId:i}=this.props,{projection:c}=t;c&&(n.group&&n.group.add(c),a&&a.register&&i&&a.register(c),bp&&c.root.didUpdate(),c.addEventListener("animationComplete",()=>{this.safeToRemove()}),c.setOptions({...c.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),bd.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:a,drag:i,isPresent:c}=this.props,{projection:u}=a;return u&&(u.isPresent=c,t.layoutDependency!==n&&u.setOptions({...u.options,layoutDependency:n}),bp=!0,i||t.layoutDependency!==n||n===void 0||t.isPresent!==c?u.willUpdate():this.safeToRemove(),t.isPresent!==c&&(c?u.promote():u.relegate()||Ct.postRender(()=>{const f=u.getStack();(!f||!f.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),Pv.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:a}=this.props,{projection:i}=t;bp=!0,i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),a&&a.deregister&&a.deregister(i))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function vT(e){const[t,n]=rT(),a=v.useContext(yv);return o.jsx(W9,{...e,layoutGroup:a,switchLayoutGroup:v.useContext(fT),isPresent:t,safeToRemove:n})}const X9={pan:{Feature:G9},drag:{Feature:Y9,ProjectionNode:aT,MeasureLayout:vT}};function XS(e,t,n){const{props:a}=e;e.animationState&&a.whileHover&&e.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,c=a[i];c&&Ct.postRender(()=>c(t,xc(t)))}class K9 extends Nr{mount(){const{current:t}=this.node;t&&(this.unmount=bU(t,(n,a)=>(XS(this.node,a,"Start"),i=>XS(this.node,i,"End"))))}unmount(){}}class J9 extends Nr{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=gc(cc(this.node.current,"focus",()=>this.onFocus()),cc(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function KS(e,t,n){const{props:a}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&a.whileTap&&e.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),c=a[i];c&&Ct.postRender(()=>c(t,xc(t)))}class Q9 extends Nr{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:a}=this.node.props;this.unmount=EU(t,(i,c)=>(KS(this.node,c,"Start"),(u,{success:f})=>KS(this.node,u,f?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:a?.tap===!1})}unmount(){}}const _g=new WeakMap,wp=new WeakMap,eV=e=>{const t=_g.get(e.target);t&&t(e)},tV=e=>{e.forEach(eV)};function nV({root:e,...t}){const n=e||document;wp.has(n)||wp.set(n,{});const a=wp.get(n),i=JSON.stringify(t);return a[i]||(a[i]=new IntersectionObserver(tV,{root:e,...t})),a[i]}function sV(e,t,n){const a=nV(t);return _g.set(e,n),a.observe(e),()=>{_g.delete(e),a.unobserve(e)}}const aV={some:0,all:1};class rV extends Nr{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:a,amount:i="some",once:c}=t,u={root:n?n.current:void 0,rootMargin:a,threshold:typeof i=="number"?i:aV[i]},f=m=>{const{isIntersecting:h}=m;if(this.isInView===h||(this.isInView=h,c&&!h&&this.hasEnteredView))return;h&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",h);const{onViewportEnter:g,onViewportLeave:x}=this.node.getProps(),b=h?g:x;b&&b(m)};return sV(this.node.current,u,f)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(iV(t,n))&&this.startObserver()}unmount(){}}function iV({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const oV={inView:{Feature:rV},tap:{Feature:Q9},focus:{Feature:J9},hover:{Feature:K9}},lV={layout:{ProjectionNode:aT,MeasureLayout:vT}},cV={..._9,...oV,...X9,...lV},uV=C9(cV,T9);function dV(e){return"type"in e&&e.type==="separator"}function fV(e){return"type"in e&&e.type==="group"}function JS({item:e}){return o.jsxs(U3,{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 yT=lo.forwardRef(({items:e},t)=>o.jsx(uV.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(zP,{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,a)=>dV(n)?o.jsx(h6,{className:"h-px bg-neutral-700/50 my-1"},`sep-${a}`):fV(n)?o.jsxs($3,{children:[o.jsx(P3,{className:"px-3 py-1 text-[10px] font-mono uppercase tracking-widest text-neutral-400",children:n.label}),n.items.map(i=>o.jsx(JS,{item:i},i.id))]},`grp-${a}`):o.jsx(JS,{item:n},n.id))})}));yT.displayName="PopupContent";function hV({items:e,children:t}){return e.length===0?o.jsx(o.Fragment,{children:t}):o.jsxs(m6,{children:[o.jsx(p6,{render:o.jsx("div",{style:{display:"contents"}}),children:t}),o.jsx($P,{children:o.jsx(KP,{className:"z-[200]",sideOffset:4,children:o.jsx(n9,{children:o.jsx(yT,{items:e})})})})]})}const QS=()=>{},mV={x:0,y:0},pV=({children:e,hud:t,mode:n="canvas",panOffset:a=mV,scale:i=1,onPan:c=QS,onZoom:u=QS,onPanStart:f,onPanEnd:m,isTransitioning:h=!1,onViewportChange:g,onCanvasClick:x,canvasProps:b,zoomSensitivity:w,zoomControlsRightOffset:j,canvasContextMenuItems:N})=>{const T=v.useRef(null),k=v.useRef(i);k.current=i;const C=v.useRef(u);C.current=u;const S=v.useRef(c);S.current=c;const R=v.useRef(f);R.current=f;const A=v.useRef(m);A.current=m;const _=v.useRef(w);_.current=w;const[O,V]=v.useState(!1),Z=v.useRef(!1),[I,$]=v.useState(!1),L=v.useRef(!1),P=v.useRef({x:0,y:0}),q=v.useRef(D=>{const U=D.target||document.activeElement;if(!U)return!1;const B=U.tagName;return!!(B==="INPUT"||B==="TEXTAREA"||U.isContentEditable||U.closest?.(".xterm"))});v.useEffect(()=>{if(n!=="canvas")return;const D=G=>{G.key!==" "||G.repeat||q.current(G)||h||(G.preventDefault(),Z.current=!0,V(!0))},U=G=>{G.key===" "&&Z.current&&(Z.current=!1,V(!1),L.current&&(L.current=!1,$(!1),A.current?.()))},B=()=>{Z.current&&(Z.current=!1,V(!1),L.current&&(L.current=!1,$(!1),A.current?.()))};return window.addEventListener("keydown",D),window.addEventListener("keyup",U),window.addEventListener("blur",B),()=>{window.removeEventListener("keydown",D),window.removeEventListener("keyup",U),window.removeEventListener("blur",B)}},[n,h]);const ee=v.useCallback(D=>{D.button===0&&(D.preventDefault(),L.current=!0,$(!0),P.current={x:D.clientX,y:D.clientY},R.current?.())},[]);return v.useEffect(()=>{if(!O)return;const D=B=>{if(!L.current)return;const G=(B.clientX-P.current.x)/k.current,K=(B.clientY-P.current.y)/k.current;P.current={x:B.clientX,y:B.clientY},S.current({x:G,y:K})},U=()=>{L.current&&(L.current=!1,$(!1),A.current?.())};return window.addEventListener("mousemove",D),window.addEventListener("mouseup",U),()=>{window.removeEventListener("mousemove",D),window.removeEventListener("mouseup",U)}},[O]),v.useEffect(()=>{if(n!=="canvas")return;const D=U=>{if(U.ctrlKey||U.metaKey){U.preventDefault();const B=k.current,G=-U.deltaY*.001*(_.current??1),K=Math.min(Math.max(.2,B+G),3);k.current=K,C.current(K)}};return window.addEventListener("wheel",D,{passive:!1}),()=>window.removeEventListener("wheel",D)},[n]),v.useEffect(()=>{if(!g)return;let D=null;const U=()=>{D&&cancelAnimationFrame(D),D=requestAnimationFrame(()=>{g({width:window.innerWidth,height:window.innerHeight})})};return U(),window.addEventListener("resize",U),()=>{window.removeEventListener("resize",U),D&&cancelAnimationFrame(D)}},[g]),n==="panel"?o.jsxs("div",{ref:T,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:T,className:"fixed inset-0 bg-black text-neutral-200 overflow-hidden font-sans select-none z-0",children:[o.jsx(hV,{items:N??[],children:o.jsx(T4,{panOffset:a,scale:i,onPan:c,onPanStart:f,onPanEnd:m,isPanLocked:h,onClick:x,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:i},children:o.jsx("div",{style:{position:"absolute",left:a.x,top:a.y},children:e})}),O&&o.jsx("div",{className:`fixed inset-0 z-20 ${I?"cursor-grabbing":"cursor-grab"}`,onMouseDown:ee}),o.jsx("div",{className:"fixed bottom-[36px] z-30",style:{right:(j??280)+16},children:o.jsx(A4,{scale:i,onZoom:D=>u(D)})}),o.jsx("div",{className:"fixed inset-0 z-50 pointer-events-none overflow-hidden",children:t})]})},Ki=4e3,gV=lo.forwardRef(({pan:e,zoom:t,viewportSize:n,height:a,onClick:i,children:c},u)=>{const[f,m]=lo.useState(0),h=v.useRef(null),g=lo.useCallback(C=>{h.current=C,typeof u=="function"?u(C):u&&(u.current=C)},[u]);lo.useEffect(()=>{const C=h.current;if(!C)return;const S=new ResizeObserver(([R])=>m(R.contentRect.width));return S.observe(C),()=>S.disconnect()},[]);const x=f||260,b=n.width/t/Ki*x,w=n.height/t/Ki*a,j=(-e.x+Ki/2)/Ki*x,N=(-e.y+Ki/2)/Ki*a,T=j-b/2,k=N-w/2;return o.jsxs("div",{ref:g,className:"relative cursor-crosshair overflow-hidden",style:{height:`${a}px`},onClick:i,children:[o.jsx("div",{className:"absolute inset-0 opacity-30",style:{backgroundImage:"radial-gradient(circle, #555 0.5px, transparent 0.5px)",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 rounded-[1px] transition-all duration-75 ease-out",style:{left:`${T}px`,top:`${k}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"})]}),c]})});gV.displayName="MinimapCanvas";const vV=({title:e,subtitle:t,center:n,actions:a,onTitleClick:i,search:c})=>{const{dragRegionProps:u,onInteractiveMouseDown:f}=of(),{navTotalHeight:m}=tv(),h=c&&c.value&&c.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:m},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:f,children:[t&&o.jsx("span",{className:"text-neutral-400 flex items-center",children:t}),o.jsx("button",{onClick:i,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:f,children:n}),o.jsxs("div",{className:"absolute right-4 bottom-0 h-12 z-10 flex items-center gap-3",onMouseDown:f,children:[a,c&&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(Qg,{size:11,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-neutral-400"}),o.jsx("input",{type:"text",value:c.value,onChange:g=>c.onChange(g.target.value),placeholder:c.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:()=>c.onChange(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-neutral-400 hover:text-white transition-colors",children:o.jsx(xk,{size:12})})]})]})]})})},ej=({side:e,title:t,icon:n,isCollapsed:a=!1,onToggleCollapse:i,headerActions:c,footer:u,style:f,width:m,onResizeStart:h,children:g})=>{if(a){const k=e==="left"?Yz:Kz;return o.jsx("button",{onClick:i,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(k,{size:14,className:"text-neutral-400 group-hover:text-emerald-400 transition-colors",strokeWidth:1.5})})}const x=e==="left"?Fz:Wz,{panelTopOffset:b}=tv(),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"}`,T={...f,position:"fixed",top:b,left:e==="left"?0:void 0,right:e==="right"?0:void 0,width:`${m||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:T,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:[c,i&&o.jsx("button",{onClick:i,className:"p-1 hover:bg-white/10 rounded transition-colors text-neutral-400 hover:text-white",title:"Collapse panel",children:o.jsx(x,{size:12})})]})]})}),o.jsx("div",{className:"flex-1 overflow-y-auto frame-scrollbar",children:g}),u&&o.jsx("div",{className:"shrink-0",children:u})]})]})},yV={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"}},xV=({left:e,viewport:t,right:n,isMinimapCollapsed:a=!1,onExpandMinimap:i,status:c={label:"READY",color:"emerald"},onToggleTerminal:u,isTerminalOpen:f=!1})=>{const[m,h]=v.useState(new Date),[g,x]=v.useState(!1),[b,w]=v.useState(!1);v.useEffect(()=>{w(!0);const T=setInterval(()=>h(new Date),1e3);return()=>clearInterval(T)},[]);const j=yV[c.color],N=async()=>{if(!t)return;const T=`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(T),x(!0),setTimeout(()=>x(!1),1500)}catch{}};return o.jsxs("div",{"data-frame-panel":"status-bar",className:`${C4.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:[a&&i&&o.jsxs(o.Fragment,{children:[o.jsxs("button",{onClick:i,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(zz,{size:10}),o.jsx("span",{className:"text-[11px] font-bold",children:"MAP"}),o.jsx(vk,{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:c.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 ${g?"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 ${g?"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 ${g?"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 ${f?"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(Mz,{size:11,className:"text-neutral-400"}),o.jsx("span",{children:b?m.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"--:--"})]})]})]})},bV=({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(Qg,{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:Wu}=lf.layout,tj=120,wV=({isOpen:e,onClose:t,onToggleMaximize:n,isMaximized:a=!1,height:i=320,onHeightChange:c,title:u,headerActions:f,children:m})=>{const h=v.useRef(!1),g=v.useRef(null),x=v.useCallback(w=>{if(!c)return;w.preventDefault(),h.current=!0;const j=w.clientY,N=i;g.current&&(g.current.style.transition="none");const T=C=>{const S=j-C.clientY,R=window.innerHeight-Wu,A=Math.max(tj,Math.min(R,N+S));g.current&&(g.current.style.height=`${A}px`)},k=C=>{h.current=!1,document.removeEventListener("mousemove",T),document.removeEventListener("mouseup",k),g.current&&(g.current.style.transition="");const S=j-C.clientY,R=window.innerHeight-Wu;c(Math.max(tj,Math.min(R,N+S)))};document.addEventListener("mousemove",T),document.addEventListener("mouseup",k)},[i,c]),b=a?`calc(100vh - ${Wu}px)`:`${i}px`;return o.jsxs("div",{ref:g,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:Wu,height:b,zIndex:lf.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(o4,{size:14}),o.jsx("span",{className:"text-xs font-bold tracking-widest font-mono",children:"TERMINAL"})]}),f]}),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:x,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:a?"Restore":"Maximize",children:a?o.jsx(Bz,{size:14}):o.jsx(vk,{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(xk,{size:14})})]})]}),o.jsx("div",{className:"flex-1 relative overflow-hidden flex flex-col bg-transparent",children:m})]})},SV=({isOpen:e,onClose:t,commands:n})=>{const[a,i]=v.useState(""),[c,u]=v.useState(0),f=v.useRef(null),m=v.useRef(null),h=n.filter(x=>x.label.toLowerCase().includes(a.toLowerCase()));v.useEffect(()=>{e&&(setTimeout(()=>f.current?.focus(),10),i(""),u(0))},[e]),v.useEffect(()=>{u(0)},[a]),v.useEffect(()=>{m.current?.scrollIntoView({behavior:"smooth",block:"nearest"})},[c]);const g=x=>{x.key==="ArrowDown"?(x.preventDefault(),u(b=>(b+1)%h.length)):x.key==="ArrowUp"?(x.preventDefault(),u(b=>(b-1+h.length)%h.length)):x.key==="Enter"?(x.preventDefault(),h[c]&&(h[c].action(),t())):x.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:x=>x.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center px-4 py-3 border-b border-neutral-700 gap-3",children:[o.jsx(Qg,{className:"text-neutral-400",size:18}),o.jsx("input",{ref:f,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:a,onChange:x=>i(x.target.value),onKeyDown:g,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((x,b)=>o.jsxs("div",{ref:b===c?m:null,className:`px-4 py-2.5 flex items-center gap-3 cursor-pointer transition-colors ${b===c?"bg-emerald-900/20 border-l-2 border-emerald-500":"border-l-2 border-transparent hover:bg-white/5"}`,onClick:()=>{x.action(),t()},onMouseEnter:()=>u(b),children:[x.icon&&o.jsx("div",{className:`text-neutral-300 ${b===c?"text-emerald-400":""}`,children:x.icon}),o.jsx("div",{className:"flex-1",children:o.jsx("div",{className:`text-sm ${b===c?"text-emerald-100":"text-neutral-200"}`,children:x.label})}),x.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:x.shortcut}),b===c&&o.jsx(Oz,{size:14,className:"text-emerald-500 ml-2"})]},x.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},Sp=new Map;function jp(e){if(e)return JSON.parse(e)}function jV(e){return e?JSON.stringify([...new Headers(e).entries()].sort(([t],[n])=>t.localeCompare(n))):""}function NV(e,t){return`${(t?.method??"GET").toUpperCase()}:${e}:${jV(t?.headers)}`}async function nj(e,t){const n=await fetch(e,{...t,headers:{...t?.headers??{},...t?.body?{"content-type":"application/json"}:{}}});if(!n.ok){const a=await n.text();let i=a||`HTTP ${n.status}`;try{const c=JSON.parse(a);c?.error&&(i=c.error)}catch{}throw new Error(i)}return await n.text()}async function Oe(e,t){if(!((t?.method??"GET").toUpperCase()==="GET"&&!t?.body))return jp(await nj(e,t));const i=NV(e,t),c=Sp.get(i);if(c)return jp(await c);const u=nj(e,t);Sp.set(i,u);try{return jp(await u)}finally{Sp.delete(i)}}function bc(){return!(typeof window>"u"||new URLSearchParams(window.location.search).has("no-ops"))}function kV(e){switch(e){case"profile":case"observe":case"message":return e;default:return}}function EV(e){const t=new URL(e.toString()),n=t.pathname.replace(/^\/+/,"").split("/").filter(Boolean),a=t.searchParams.get("compose")==="ask"?"ask":void 0,i=kV(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:i??"message"};if(n[0]==="agents"&&n[1]){const c=decodeURIComponent(n[1]);return i==="message"?{view:"agents",agentId:c,conversationId:os(c),tab:"message"}:{view:"agents",agentId:c,...i?{tab:i}:{}}}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]),...a?{composeMode:a}:{}};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(!bc())return{view:"inbox"};const c=n[1];return c==="conductor"||c==="warroom"||c==="plan"||c==="mission"?{view:"ops",mode:c}:{view:"ops"}}return{view:"inbox"}}function Np(){return EV(window.location.href)}function CV(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===os(e.agentId),a=n?"profile":e.conversationId?"message":"profile";n?t.set("tab","message"):e.tab&&e.tab!==a&&t.set("tab",e.tab);const i=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"}${i?`?${i}`:""}`}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&&e.mode!=="plan"?`/ops/${e.mode}`:"/ops";case"terminal":return e.agentId?`/terminal/${encodeURIComponent(e.agentId)}`:"/terminal"}}function kp(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 TV(){const[e,t]=v.useState(Np),n=v.useRef({});v.useEffect(()=>{const i=()=>{const c=Np();t(c),requestAnimationFrame(()=>{window.scrollTo(0,n.current[kp(c)]??0)})};return window.addEventListener("popstate",i),()=>window.removeEventListener("popstate",i)},[]);const a=v.useCallback(i=>{const c=i.view==="ops"&&!bc()?{view:"inbox"}:i;n.current[kp(Np())]=window.scrollY,window.history.pushState(null,"",CV(c)),t(c),requestAnimationFrame(()=>{window.scrollTo(0,n.current[kp(c)]??0)})},[]);return{route:e,navigate:a}}function xT(e){const t=e.match(/^dm\.operator\.(.+)$/);return t?t[1]:null}function os(e){return`dm.operator.${e}`}const AV=["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"],Qr=new Set;let Xl=null,Ea=null,Jd=0;function RV(e){try{return JSON.parse(e)}catch{return{kind:"unknown"}}}function bT(){Xl?.close(),Xl=null}function MV(){if(Ea||Qr.size===0)return;Jd++;const e=Math.min(3e3*2**(Jd-1),6e4);Ea=setTimeout(()=>{Ea=null,Qr.size>0&&wT()},e)}function _V(e){for(const t of[...Qr])t(e)}function wT(){if(Xl||Qr.size===0)return;const e=new EventSource("/api/events");Xl=e;const t=n=>{_V(RV(n.data))};e.onopen=()=>{Jd=0},e.onmessage=t;for(const n of AV)e.addEventListener(n,t);e.onerror=()=>{Xl===e?bT():e.close(),MV()}}function OV(e){return Qr.add(e),Ea&&(clearTimeout(Ea),Ea=null),wT(),()=>{Qr.delete(e),!(Qr.size>0)&&(Ea&&(clearTimeout(Ea),Ea=null),Jd=0,bT())}}function An(e){const t=v.useRef(e);t.current=e,v.useEffect(()=>OV(n=>{t.current(n)}),[])}function mt(e){return e==="working"?"working":!e||e==="offline"?"offline":"available"}function oi(e){return mt(e)!=="offline"}function aa(e){switch(mt(e)){case"working":return"Working";case"available":return"Available";default:return"Offline"}}const ST={current:null,setMenu:null};function jf(){return v.useCallback((e,t)=>{e.preventDefault(),e.stopPropagation(),ST.setMenu?.({position:{x:e.clientX,y:e.clientY},items:t})},[])}function IV({children:e}){const[t,n]=v.useState(null),a=v.useRef(null);ST.setMenu=n;const i=v.useCallback(()=>n(null),[]);return v.useEffect(()=>{if(!t)return;const c=()=>i(),u=m=>{m.key==="Escape"&&i()},f=()=>i();return window.addEventListener("mousedown",c,!0),window.addEventListener("keydown",u),window.addEventListener("scroll",f,!0),window.addEventListener("contextmenu",i,!0),()=>{window.removeEventListener("mousedown",c,!0),window.removeEventListener("keydown",u),window.removeEventListener("scroll",f,!0),window.removeEventListener("contextmenu",i,!0)}},[t,i]),v.useEffect(()=>{if(!t||!a.current)return;const c=a.current,u=c.getBoundingClientRect(),f=window.innerWidth,m=window.innerHeight;let h=t.position.x,g=t.position.y;h+u.width>f-8&&(h=f-u.width-8),g+u.height>m-8&&(g=m-u.height-8),h<8&&(h=8),g<8&&(g=8),c.style.left=`${h}px`,c.style.top=`${g}px`},[t]),t?o.jsxs(o.Fragment,{children:[e,o.jsx("div",{ref:a,className:"s-context-menu",style:{left:t.position.x,top:t.position.y},role:"menu",onMouseDown:c=>c.stopPropagation(),children:t.items.map((c,u)=>c.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:()=>{c.onSelect(),i()},children:[o.jsx("span",{className:"s-context-menu-label",children:c.label}),c.shortcut&&o.jsx("span",{className:"s-context-menu-shortcut",children:c.shortcut})]},u))})]}):o.jsx(o.Fragment,{children:e})}const DV=[195,125,300,45,355,210];function sj(e){return`oklch(0.80 0.14 ${e})`}function zV(e){return`oklch(0.18 0.08 ${e})`}function ei({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 ws({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 io({value:e,onChange:t,mono:n}){return o.jsx("input",{className:`s-settings-input${n?" s-settings-input--mono":""}`,value:e,onChange:a=>t(a.target.value)})}function LV({value:e,onChange:t,rows:n=3}){return o.jsx("textarea",{className:"s-settings-textarea",value:e,onChange:a=>t(a.target.value),rows:n})}function $V({value:e,onChange:t,min:n,max:a,step:i=1,unit:c=""}){return o.jsxs("div",{className:"s-settings-slider-wrap",children:[o.jsx("input",{type:"range",min:n,max:a,step:i,value:e,onChange:u=>t(Number(u.target.value))}),o.jsxs("span",{className:"s-settings-slider-value",children:[e," ",c]})]})}function Xu({value:e,onChange:t,options:n,stacked:a,columns:i}){return o.jsx("div",{className:a?"s-settings-option-stacked":"s-settings-option-grid",style:a?void 0:{gridTemplateColumns:`repeat(${i??n.length}, 1fr)`},children:n.map(c=>o.jsxs("button",{className:`s-settings-option-btn${e===c.id?" s-settings-option-btn--active":""}`,onClick:()=>t(c.id),children:[o.jsx("span",{className:"s-settings-option-label",children:c.label}),o.jsx("span",{className:"s-settings-option-sub",children:c.sub})]},c.id))})}function PV({profile:e,update:t}){return o.jsxs("div",{className:"s-settings-col-gap",children:[o.jsx(ei,{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:sj(e.hue),color:zV(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:DV.map(n=>o.jsx("button",{onClick:()=>t({hue:n}),className:`s-settings-hue-dot${e.hue===n?" s-settings-hue-dot--active":""}`,style:{background:sj(n)}},n))})]})]}),o.jsx(ws,{label:"Display name",hint:"Shown when agents address you.",children:o.jsx(io,{value:e.name,onChange:n=>t({name:n})})}),o.jsx(ws,{label:"Handle",hint:"Used in @mentions across threads.",children:o.jsx(io,{value:e.handle,onChange:n=>t({handle:n}),mono:!0})}),o.jsx(ws,{label:"Pronouns",children:o.jsx(io,{value:e.pronouns,onChange:n=>t({pronouns:n})})}),o.jsx(ei,{label:"How agents understand you",right:"shipped as system prompt context"}),o.jsx(ws,{label:"Operator bio",hint:"How you want to be worked with. Agents read this before asking you things.",children:o.jsx(LV,{value:e.bio,onChange:n=>t({bio:n}),rows:4})}),o.jsxs("div",{className:"s-settings-two-col",children:[o.jsx(ws,{label:"Timezone",children:o.jsx(io,{value:e.timezone,onChange:n=>t({timezone:n}),mono:!0})}),o.jsx(ws,{label:"Working hours",children:o.jsx(io,{value:e.workingHours,onChange:n=>t({workingHours:n}),mono:!0})})]})]})}function UV({profile:e,update:t}){return o.jsxs("div",{className:"s-settings-col-gap",children:[o.jsx(ei,{label:"Interrupt policy"}),o.jsx(ws,{label:"When agents can ping you directly",hint:"Blocking-only means only asks that truly stall work. Others get batched.",children:o.jsx(Xu,{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(ws,{label:"Batch window (min)",children:o.jsx($V,{value:e.batchWindow,min:5,max:60,step:5,onChange:n=>t({batchWindow:n}),unit:"min"})}),o.jsx(ws,{label:"Quiet hours",children:o.jsx(io,{value:e.quietHours,onChange:n=>t({quietHours:n}),mono:!0})})]}),o.jsx(ei,{label:"Where to reach you"}),o.jsx(ws,{label:"Preferred channel",children:o.jsx(Xu,{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(ei,{label:"Tone calibration",right:"how agents write to you"}),o.jsxs("div",{className:"s-settings-two-col",children:[o.jsx(ws,{label:"Verbosity",children:o.jsx(Xu,{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(ws,{label:"Tone",children:o.jsx(Xu,{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 BV={desktop:"◻",mobile:"▯",tablet:"▭"};function VV({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:BV[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 HV({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 a=n.fingerprint===e.connectedPeerFingerprint;t.push({id:n.fingerprint,name:n.name??"Paired device",kind:"mobile",status:a?"online":"offline",relay:"tailscale",lastSeen:n.lastSeenLabel??"—"})}return o.jsxs("div",{className:"s-settings-col-gap",children:[o.jsx(ei,{label:`Paired devices · ${t.length}`}),o.jsx("div",{className:"s-settings-col-gap",style:{gap:10},children:t.map(n=>o.jsx(VV,{device:n},n.id))}),o.jsx(ei,{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 ZV=[{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"}],FV={operator:"Operator identity",comms:"Communication",devices:"Paired devices"},qV={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 YV({open:e,onClose:t}){const{refreshOnboarding:n}=kt(),[a,i]=v.useState("operator"),[c,u]=v.useState(qV),[f,m]=v.useState(null),[h,g]=v.useState(!1),x=v.useRef(null),b=v.useCallback(async()=>{try{const N=Oe("/api/user"),T=Promise.race([Oe("/api/pairing-state"),new Promise((S,R)=>setTimeout(()=>R(new Error("timeout")),3e3))]),[k,C]=await Promise.allSettled([N,T]);k.status==="fulfilled"&&u(k.value),C.status==="fulfilled"&&m(C.value)}finally{g(!0)}},[]);v.useEffect(()=>{e&&b()},[e,b]),v.useEffect(()=>{if(!e)return;const N=T=>{T.key==="Escape"&&t()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[e,t]);const w=v.useCallback(N=>{x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{Oe("/api/user",{method:"POST",body:JSON.stringify(N)}).then(()=>n()).catch(()=>{})},400)},[n]),j=v.useCallback(N=>{u(T=>{const k={...T,...N};return w(k),k})},[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:FV[a]}),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:ZV.map(N=>o.jsxs("button",{onClick:()=>i(N.id),className:`s-settings-rail-btn${a===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:[a==="operator"&&o.jsx(PV,{profile:c,update:j}),a==="comms"&&o.jsx(UV,{profile:c,update:j}),a==="devices"&&o.jsx(HV,{pairing:f})]}):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 GV({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 jT=v.createContext(null),WV=["hello","node.upserted","actor.registered","agent.registered","agent.endpoint.upserted","invocation.requested","flight.updated","delivery.state.changed","scout.dispatched"],XV=new Set(WV),KV={"--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"},JV={"--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 kt(){const e=v.useContext(jT);if(!e)throw new Error("useScout must be used inside ScoutProvider");return e}function QV({children:e,initialTheme:t="dark"}){const{route:n,navigate:a}=TV(),[i,c]=v.useState([]),[u,f]=v.useState(null),[m,h]=v.useState(!1),g=v.useCallback(()=>h(!0),[]),[x,b]=v.useState(!1),w=v.useCallback(()=>b(!0),[]),j=v.useCallback(()=>b(!1),[]),N=t==="light"?JV:KV,T=v.useCallback(async()=>{const R=await Oe("/api/agents").catch(()=>null);R&&c(R)},[]),k=v.useCallback(async()=>{try{const R=await Oe("/api/onboarding/state");f(R)}catch{f({hasLocalConfig:!0,hasProjectConfig:!0,hasOperatorName:!0,localConfigPath:null,projectRoot:null,currentDirectory:null,operatorName:null,operatorNameSuggestion:null})}},[]);v.useEffect(()=>{T(),k()},[T,k]),An(R=>{XV.has(R.kind)&&T()});const C=v.useMemo(()=>i.filter(R=>oi(R.state)).length,[i]),S=v.useMemo(()=>({route:n,navigate:a,agents:i,onlineCount:C,reload:T,onboarding:u,refreshOnboarding:k,onboardingSkipped:m,skipOnboarding:g,settingsOpen:x,openSettings:w,closeSettings:j}),[n,a,i,C,T,u,k,m,g,x,w,j]);return o.jsx(jT.Provider,{value:S,children:o.jsx("div",{"data-scout-theme":t,"data-scout-theme-mode":t,style:{...N},children:o.jsxs(IV,{children:[e,o.jsx(YV,{open:x,onClose:j})]})})})}function eH(){const{navigate:e,agents:t,reload:n,openSettings:a}=kt(),i=bc(),c=v.useCallback(async u=>{await Oe(`/api/agents/${encodeURIComponent(u)}/interrupt`,{method:"POST",body:JSON.stringify({})})},[]);return v.useMemo(()=>{const u=[{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"},...i?[{id:"nav:ops",label:"Go to Ops",action:()=>e({view:"ops"}),shortcut:"Cmd+7"}]:[],{id:"nav:settings",label:"Open Settings",action:()=>a(),shortcut:"Cmd+,"},{id:"nav:pair",label:"Pair Device",action:()=>a()},{id:"scout:reload",label:"Reload Agents",action:()=>{n()}}];for(const f of t)u.push({id:`scout:open:${f.id}`,label:`Open ${f.name}`,action:()=>e({view:"conversation",conversationId:os(f.id)})}),u.push({id:`scout:send:${f.id}`,label:`Tell ${f.name}`,action:()=>e({view:"conversation",conversationId:os(f.id)})}),u.push({id:`scout:ask:${f.id}`,label:`Ask ${f.name}`,action:()=>e({view:"conversation",conversationId:os(f.id),composeMode:"ask"})}),u.push({id:`scout:interrupt:${f.id}`,label:`Interrupt ${f.name}`,action:()=>{c(f.id)}});return u},[t,c,e,i,n])}function NT(){const{onlineCount:e}=kt(),[t,n]=v.useState(null),a=v.useRef(0),i=v.useCallback(async()=>{const c=++a.current;try{const u=await Oe("/api/mesh");if(c!==a.current)return;n(u)}catch{if(c!==a.current)return;n(null)}},[]);return v.useEffect(()=>{i();const c=setInterval(()=>{i()},15e3);return()=>clearInterval(c)},[i]),{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 tH(){return NT().status}const nH={inbox:"Fleet",conversation:"Conversation","agent-info":"Agent",agents:"Agents",fleet:"Fleet",sessions:"Sessions",activity:"Activity",mesh:"Mesh",settings:"Settings",work:"Work",ops:"Ops"};function sH(){const{route:e,navigate:t}=kt(),n=bc(),a=[{label:"Fleet",view:"inbox"},{label:"Agents",view:"agents"},{label:"Sessions",view:"sessions"},{label:"Mesh",view:"mesh"},...n?[{label:"Ops",view:"ops"}]:[]],i=e.view==="fleet"||e.view==="activity"?"inbox":e.view==="conversation"||e.view==="agent-info"?"agents":e.view==="work"?n?"ops":"inbox":e.view,c=e.view==="conversation"||e.view==="agent-info"||e.view==="work"?nH[e.view]??e.view:null;return v.createElement("div",{className:"scout-nav-tabs"},a.map(({label:u,view:f})=>v.createElement("button",{key:f,className:`scout-nav-tab${i===f?" active":""}`,onClick:()=>t({view:f})},u)),c&&v.createElement("span",{className:"scout-nav-slash"},"/"),c&&v.createElement("span",{className:"scout-nav-crumb"},c))}function aH(){const{openSettings:e}=kt();return v.createElement("button",{onClick:()=>e(),className:"scout-nav-action"},"Pair device")}function rH(){return"panel"}function iH(){const{onboarding:e,onboardingSkipped:t,skipOnboarding:n}=kt();if(!e)return null;if(t)return{active:!1,dismissible:!0};const a=!e.hasLocalConfig,i=!e.hasProjectConfig,c=!e.hasOperatorName;return{active:a||c||i,dismissible:!0,onDismiss:n}}function oH({app:e,assistant:t=!0}){return o.jsx(e.Provider,{children:o.jsx(cH,{app:e,assistantEnabled:t})})}function lH({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 cH({app:e,assistantEnabled:t}){const{navTotalHeight:n}=tv(),a=e.hooks.useCommands(),i=e.hooks.useSearch?.()??null,c=e.hooks.useNavCenter?.()??null,u=e.hooks.useNavActions?.()??null,f=e.hooks.useLayoutMode?.()??e.mode,m=e.hooks.useActiveToolHint?.()??null,h=e.hooks.useTakeover?.()??null,g=h?.active===!0,x=g&&h?.dismissible===!0,b=h?.onDismiss,w=e.slots.Takeover,j=NT(),[N,T]=ka(`appshell.${e.id}.left`,!1),[k,C]=ka(`appshell.${e.id}.right`,!1),[S,R]=ka(`appshell.${e.id}.leftW`,260),[A,_]=ka(`appshell.${e.id}.rightW`,280),[O,V]=v.useState({x:0,y:0}),[Z,I]=v.useState(1),$=v.useCallback(ce=>{V(he=>({x:he.x+ce.x,y:he.y+ce.y}))},[]),L=v.useCallback(ce=>{I(ce)},[]),[P,q]=v.useState(!1),[ee,D]=v.useState(!1),[U,B]=ka(`appshell.${e.id}.termH`,320),G=!!e.slots.Terminal,K=v.useMemo(()=>{const ce=[];return G&&ce.push("terminal"),t&&ce.push("assistant"),ce},[G,t]),z=K[0]??"terminal",[Y,W]=ka(`appshell.${e.id}.drawerTab`,z),J=K.includes(Y)?Y:z,[de,ae]=v.useState(!1),[ye,ve]=v.useState(new Set),be=v.useCallback(ce=>{ve(he=>{const pe=new Set(he);return pe.has(ce)?pe.delete(ce):pe.add(ce),pe})},[]),_e=v.useCallback(ce=>he=>{he.preventDefault();const pe=he.clientX,je=ce==="left"?S:A,Ne=ce==="left"?R:_,Je=ce==="left"?1:-1,et=Bt=>{const Et=(Bt.clientX-pe)*Je;Ne(Math.max(200,Math.min(500,je+Et)))},Ge=()=>{document.removeEventListener("mousemove",et),document.removeEventListener("mouseup",Ge)};document.addEventListener("mousemove",et),document.addEventListener("mouseup",Ge)},[S,A,R,_]),ie=v.useMemo(()=>{const ce=[{id:"shell:toggle-left",label:"Toggle Left Panel",shortcut:"Cmd+[",action:()=>T(he=>!he)},{id:"shell:toggle-right",label:"Toggle Right Panel",shortcut:"Cmd+]",action:()=>C(he=>!he)},{id:"shell:toggle-terminal",label:"Toggle Terminal",shortcut:"Ctrl+`",action:()=>q(he=>!he)}];return t&&ce.push({id:"shell:toggle-assistant",label:"Toggle Assistant",shortcut:"Cmd+J",action:()=>{W("assistant"),q(he=>!he||Y!=="assistant")}}),ce},[t,Y,W,T,C]),ke=v.useMemo(()=>[...a,...ie],[a,ie]);v.useEffect(()=>{const ce=he=>{g||((he.metaKey||he.ctrlKey)&&he.key==="k"&&(he.preventDefault(),ae(!0)),(he.metaKey||he.ctrlKey)&&he.key==="["&&(he.preventDefault(),T(pe=>!pe)),(he.metaKey||he.ctrlKey)&&he.key==="]"&&(he.preventDefault(),C(pe=>!pe)),he.ctrlKey&&he.key==="`"&&(he.preventDefault(),q(pe=>!pe)),t&&(he.metaKey||he.ctrlKey)&&he.key==="j"&&(he.preventDefault(),W("assistant"),q(pe=>!(pe&&J==="assistant"))))};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[t,J,W,T,C,g]),v.useEffect(()=>{const ce=()=>{W("terminal"),q(!0),B(he=>he>window.innerHeight*.8?420:he)};return window.addEventListener("scout:open-terminal",ce),()=>window.removeEventListener("scout:open-terminal",ce)},[W,B]);const we=e.slots.Inspector,Ue=e.slots.RightPanel,Ae=e.tools&&e.tools.length>0,xe=o.jsxs(o.Fragment,{children:[we&&o.jsx(we,{}),!we&&Ue&&o.jsx(Ue,{}),Ae&&o.jsx("div",{className:"border-t border-neutral-700/50",children:e.tools.map(ce=>{const he=ye.has(ce.id);return o.jsxs("div",{children:[o.jsxs("button",{onClick:()=>be(ce.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 ${m===ce.id?"text-emerald-400":"text-neutral-300"}`,children:[he?o.jsx(MM,{size:10}):o.jsx(OM,{size:10}),o.jsx("span",{className:"text-neutral-400",children:ce.icon}),o.jsx("span",{className:"font-bold",children:ce.name})]}),he&&o.jsx("div",{className:"px-4 pb-3",children:o.jsx(ce.Component,{})})]},ce.id)})})]}),Ee=o.jsxs(o.Fragment,{children:[e.slots.LeftFooter&&o.jsx(e.slots.LeftFooter,{}),o.jsx(bV,{onOpenCommandPalette:()=>ae(!0)})]}),Ye=v.useRef(null),Be=v.useRef(null);v.useEffect(()=>{const ce=Ye.current;ce&&(g?ce.setAttribute("inert",""):ce.removeAttribute("inert"))},[g]),v.useEffect(()=>{if(!g)return;const ce=Be.current;if(ce&&(ce.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])")??ce).focus(),!x)return;const he=pe=>{pe.key==="Escape"&&(pe.preventDefault(),b?.())};return window.addEventListener("keydown",he),()=>window.removeEventListener("keydown",he)},[g,x,b]);const He=f==="panel"?{position:"absolute",top:n,bottom:28,left:N?0:S,right:k?0:A,overflow:"auto",transition:"left 200ms ease, right 200ms ease"}:{};return o.jsxs(o.Fragment,{children:[o.jsx("div",{ref:Ye,"aria-hidden":g?!0:void 0,style:{display:"contents"},children:o.jsx(pV,{mode:f,panOffset:O,scale:Z,onPan:$,onZoom:L,hud:o.jsxs(o.Fragment,{children:[o.jsx(vV,{title:e.name.toUpperCase(),search:i??void 0,center:c,actions:u}),o.jsx(ej,{side:"left",title:e.leftPanel?.title??"Navigation",icon:e.leftPanel?.icon,isCollapsed:N,onToggleCollapse:()=>T(!N),width:S,onResizeStart:_e("left"),footer:Ee,headerActions:e.leftPanel?.headerActions&&o.jsx(e.leftPanel.headerActions,{}),children:e.slots.LeftPanel&&o.jsx(e.slots.LeftPanel,{})}),o.jsx(ej,{side:"right",title:e.rightPanel?.title??"Inspector",icon:e.rightPanel?.icon,isCollapsed:k,onToggleCollapse:()=>C(!k),width:A,onResizeStart:_e("right"),headerActions:e.rightPanel?.headerActions&&o.jsx(e.rightPanel.headerActions,{}),children:xe}),o.jsx(xV,{status:j.status,left:o.jsx(lH,{statusBar:j}),onToggleTerminal:()=>q(ce=>!ce),isTerminalOpen:P}),o.jsx("div",{className:"pointer-events-none",style:{position:"fixed",left:N?0:S,right:k?0:A,bottom:0,top:0,zIndex:45,transition:"left 200ms ease, right 200ms ease",transform:"translateZ(0)"},children:o.jsxs(wV,{isOpen:P,onClose:()=>q(!1),onToggleMaximize:()=>D(ce=>!ce),isMaximized:ee,height:Math.min(U,window.innerHeight*.8),onHeightChange:ce=>B(Math.min(ce,window.innerHeight*.8)),title:o.jsx(uH,{tabs:K,active:J,onSelect:W}),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(N4,{app:e,commands:a})]})}),o.jsx(SV,{isOpen:de,onClose:()=>ae(!1),commands:ke})]}),children:o.jsx("div",{style:He,className:"frame-scrollbar",children:o.jsx(e.slots.Content,{})})})}),g&&w?o.jsx("div",{ref:Be,tabIndex:-1,role:"dialog","aria-modal":"true",style:{position:"fixed",inset:0,zIndex:80,outline:"none"},children:o.jsx(w,{})}):null]})}function uH({tabs:e,active:t,onSelect:n}){return e.length===0?null:o.jsx("div",{className:"flex items-center gap-0.5",children:e.map(a=>{const i=a===t,c=a==="terminal"?PM:LM,u=a==="terminal"?"TERMINAL":"ASSISTANT",f=a==="terminal"?"text-emerald-400":"text-cyan-400";return o.jsxs("button",{type:"button",onClick:()=>n(a),className:`flex items-center gap-1.5 px-2.5 py-1 rounded text-xs font-bold tracking-widest font-mono transition-colors ${i?`${f} bg-white/[0.04]`:"text-neutral-500 hover:text-neutral-300"}`,children:[o.jsx(c,{size:13}),o.jsx("span",{children:u})]},a)})})}const dH={ask_sent:"asked",ask_replied:"replied",ask_failed:"failed",ask_working:"working",flight_created:"task started",flight_updated:"task updated",message_sent:"sent",message_received:"received",agent_online:"online",agent_offline:"offline"};function fH(e){return dH[e]??e.replace(/_/g," ")}const aj=["#6366f1","#8b5cf6","#0ea5e9","#14b8a6","#f59e0b","#ef4444","#ec4899","#10b981"];function ct(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return aj[Math.abs(t)%aj.length]}function Ra(e){switch(mt(e)){case"working":return"var(--green)";case"available":return"var(--accent)";default:return"var(--dim)"}}const hH={workspace:"workspace",worktree:"workspace",branch:"workspace",profile:"profile",persona:"profile",harness:"harness",runtime:"harness",node:"node",host:"node"};function mH(e){return e.trim().replace(/^@+/,"").replace(/[.,!?;)\]]+$/,"")}function Ks(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}const pH="scout";function gH(e){return hH[Ks(e)]??null}function kT(e){const t=Ks(e.definitionId),n=e.workspaceQualifier?Ks(e.workspaceQualifier):void 0,a=e.profile?Ks(e.profile):void 0,i=e.harness?Ks(e.harness):void 0,c=e.nodeQualifier?Ks(e.nodeQualifier):void 0;return t?{definitionId:t,...n?{workspaceQualifier:n}:{},...a?{profile:a}:{},...i?{harness:i}:{},...c?{nodeQualifier:c}:{}}:null}function vH(e){const t=e.split(".").filter(Boolean),n=t.shift();if(!n)return null;const a={definitionId:n},i=[];for(const c of t){if(c.includes(":")){const[u,f=""]=c.split(":",2),m=gH(u),h=Ks(f);if(!m||!h)return null;m==="workspace"?a.workspaceQualifier=h:m==="profile"?a.profile=h:m==="harness"?a.harness=h:m==="node"&&(a.nodeQualifier=h);continue}i.push(c)}if(i.length===1){const c=Ks(i[0]);if(!c)return null;a.workspaceQualifier=c}else if(i.length===2){const c=Ks(i[0]),u=Ks(i[1]);if(!c||!u)return null;a.workspaceQualifier||(a.workspaceQualifier=c),a.nodeQualifier||(a.nodeQualifier=u)}else if(i.length>2)return null;return xH(a,{raw:e})}function yH(e){const t=mH(e);return!t||t.includes("@")||t.includes("#")?null:vH(t)}function rj(e,t={}){const n=kT(e);if(!n)return t.includeSigil===!1?"":"@";const i=[`${t.includeSigil===!1?"":"@"}${n.definitionId}`];return n.workspaceQualifier&&i.push(n.workspaceQualifier),n.profile&&i.push(`profile:${n.profile}`),n.harness&&i.push(`harness:${n.harness}`),n.nodeQualifier&&i.push(`node:${n.nodeQualifier}`),i.join(".")}function xH(e,t={}){const n=kT(e);return n?{raw:t.raw??rj(n,{includeSigil:!1}),label:rj(n),definitionId:n.definitionId,...n.nodeQualifier?{nodeQualifier:n.nodeQualifier}:{},...n.workspaceQualifier?{workspaceQualifier:n.workspaceQualifier}:{},...n.profile?{profile:n.profile}:{},...n.harness?{harness:n.harness}:{}}:null}function bH(e){return wH(e).parsed}function wH(e){const t=Array.from(e.matchAll(/(^|\s)@([a-z0-9][a-z0-9._/:-]*)/gi)),n=new Map,a=[];for(const i of t){const c=i[2]??"",u=yH(c);if(!u){c&&a.push(`@${c}`);continue}n.set(u.label,u)}return{parsed:Array.from(n.values()),unparsed:Array.from(new Set(a))}}function SH(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 a=[];let i=e;const c=/@([a-z0-9][a-z0-9._/:-]*)/i;for(;i.length>0;){const u=c.exec(i);if(!u||u.index===void 0){a.push({kind:"text",value:i});break}u.index>0&&a.push({kind:"text",value:i.slice(0,u.index)});const f=u[0],m=f.toLowerCase(),h=n.get(m);h?a.push({kind:"mention",identity:h}):a.push({kind:"text",value:f}),i=i.slice(u.index+f.length)}return a}function jH(e,t){const n=[],a=/\*\*(.+?)\*\*/g;let i=0,c,u=0;for(;(c=a.exec(e))!==null;)c.index>i&&n.push(o.jsx("span",{children:e.slice(i,c.index)},`${t}-${u++}`)),n.push(o.jsx("strong",{children:c[1]},`${t}-${u++}`)),i=c.index+c[0].length;return i<e.length&&n.push(o.jsx("span",{children:e.slice(i)},`${t}-${u++}`)),n.length>0?n:[o.jsx("span",{children:e},t)]}function ks(e){if(!e)return e??"";const t=bH(e);return SH(e,t).flatMap((a,i)=>{if(a.kind==="text")return jH(a.value,i*100);const{identity:c}=a,f=c.definitionId===pH?"var(--accent)":ct(c.definitionId);return o.jsx("span",{className:"s-mention",style:{"--mention-color":f},children:c.label},i)})}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 Xr(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 NH={"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"},kH={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 ET(e){return NH[e]??e.replace(/[._]/g," ")}function EH(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 CH(e){return(e??"system").charAt(0).toUpperCase()}function CT(e){return e.length<=14?e:`${e.slice(0,8)}...${e.slice(-4)}`}function TH(e){if(!e)return null;const t=e.split("/").filter(Boolean);return t[t.length-1]??e}function AH(e){return`${e.actorName??"system"} ${ET(e.kind)}`}function RH(e){return e.workspaceRoot?`Recorded from ${e.workspaceRoot}.`:e.conversationId?`Linked to thread ${CT(e.conversationId)}.`:"No additional detail was captured for this event."}function MH({navigate:e}){const[t,n]=v.useState([]),[a,i]=v.useState(null),[c,u]=v.useState(!0),[f,m]=v.useState(!1),[h,g]=v.useState(null),[x,b]=v.useState(null),w=v.useRef([]),j=v.useRef(0),N=v.useRef(null),T=jf();v.useEffect(()=>{w.current=t},[t]);const k=v.useCallback(async(_="initial")=>{const O=++j.current;!(w.current.length>0)&&_!=="background"?(u(!0),g(null)):m(!0);try{const Z=await Oe("/api/activity");if(O!==j.current)return;n(Z),g(null),b(Date.now()),i(I=>Z.some($=>$.id===I)?I:null)}catch(Z){if(O!==j.current)return;g(Z instanceof Error?Z.message:String(Z))}finally{O===j.current&&(u(!1),m(!1))}},[]),C=v.useCallback(()=>{N.current||(N.current=setTimeout(()=>{N.current=null,k("background")},250))},[k]);v.useEffect(()=>(k("initial"),()=>{N.current&&clearTimeout(N.current)}),[k]),An(C);const S=v.useMemo(()=>{const _=new Set(t.map(V=>V.actorName??"system")),O=new Set(t.map(V=>V.conversationId).filter(V=>!!V));return[{label:"Events",value:`${t.length}`,detail:t.length>0?`Latest ${Pe(t[0].ts)}`:"Waiting for records"},{label:"Actors",value:`${_.size}`,detail:_.size>0?"Distinct event owners":"No actors yet"},{label:"Threads",value:`${O.size}`,detail:O.size>0?"Conversation-linked records":"No linked threads"}]},[t]),R=!c&&t.length===0&&!!h,A=!c&&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:c?"Loading audit ledger...":h&&t.length>0?`Showing last confirmed snapshot from ${x?Pe(x):"earlier"}`:x?`Updated ${Pe(x)}`:"Waiting for first snapshot"}),o.jsx("button",{type:"button",className:"s-btn",disabled:c||f,onClick:()=>{k("manual")},children:f?"Refreshing...":"Refresh"})]})]}),o.jsx("div",{className:"sys-stat-grid",children:S.map(_=>o.jsxs("div",{className:"sys-stat-card",children:[o.jsx("span",{className:"sys-stat-label",children:_.label}),o.jsx("strong",{className:"sys-stat-value",children:_.value}),o.jsx("span",{className:"sys-stat-detail",children:_.detail})]},_.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})]}),c&&t.length===0&&o.jsxs("div",{className:"sys-panel sys-state-card",children:[o.jsx("h3",{className:"sys-state-title",children:"Loading activity"}),o.jsx("p",{className:"sys-state-body",children:"Pulling the latest records from the broker database."})]}),R&&o.jsxs("div",{className:"sys-panel sys-state-card sys-state-card-error",children:[o.jsx("h3",{className:"sys-state-title",children:"Activity is unavailable"}),o.jsx("p",{className:"sys-state-body",children:h}),o.jsx("div",{className:"sys-inline-actions",children:o.jsx("button",{type:"button",className:"s-btn",onClick:()=>{k("manual")},children:"Try again"})})]}),A&&o.jsxs("div",{className:"sys-panel sys-state-card",children:[o.jsx("h3",{className:"sys-state-title",children:"No activity yet"}),o.jsx("p",{className:"sys-state-body",children:"Events appear here after agents register, send messages, or advance work."})]}),t.length>0&&o.jsx("div",{className:"sys-audit-list",children:t.map(_=>{const O=a===_.id,V=EH(_.kind),Z=kH[V],I=TH(_.workspaceRoot),$=_.summary&&_.summary!==_.title?_.summary:RH(_);return o.jsxs("article",{className:`sys-audit-entry${O?" sys-audit-entry-expanded":""}`,onContextMenu:L=>{const P=window.getSelection()?.toString().trim(),q=[];P&&(q.push({kind:"action",label:"Copy Selection",shortcut:"⌘C",onSelect:()=>navigator.clipboard.writeText(P)}),q.push({kind:"separator"}));const ee=_.title??_.summary??"";ee&&q.push({kind:"action",label:"Copy Details",onSelect:()=>navigator.clipboard.writeText(ee)}),_.actorName&&q.push({kind:"action",label:"Copy Actor",onSelect:()=>navigator.clipboard.writeText(_.actorName)}),q.push({kind:"action",label:"Copy Event ID",onSelect:()=>navigator.clipboard.writeText(_.id)}),_.conversationId&&(q.push({kind:"separator"}),q.push({kind:"action",label:"Open Thread",onSelect:()=>e({view:"conversation",conversationId:_.conversationId})})),T(L,q)},children:[o.jsxs("button",{type:"button",className:"sys-audit-toggle","aria-expanded":O,onClick:()=>i(O?null:_.id),children:[o.jsxs("div",{className:"sys-audit-stamp",children:[o.jsx("span",{className:"sys-audit-time",children:Pe(_.ts)}),o.jsx("span",{className:"sys-audit-date",children:Xr(_.ts)})]}),o.jsx("div",{className:`sys-audit-marker sys-audit-marker-${Z.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:Z.label}),o.jsx("span",{className:"sys-audit-kind",children:ET(_.kind)})]}),o.jsx("h3",{className:"sys-audit-title",children:ks(_.title??AH(_))}),o.jsx("p",{className:"sys-audit-summary",children:ks($)}),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:ct(_.actorName??"system")},children:CH(_.actorName)}),_.actorName??"system"]}),I&&o.jsxs("span",{className:"sys-audit-meta-item",children:["Workspace ",I]}),_.conversationId&&o.jsxs("span",{className:"sys-audit-meta-item",children:["Thread ",CT(_.conversationId)]})]})]}),o.jsx("div",{className:"sys-audit-expand",children:O?"Close":"Details"})]}),O&&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:_.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:Xr(_.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:_.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:_.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:_.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:_.id})]})]}),_.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:_.conversationId}),children:"Open thread"})})]})]},_.id)})})]})}function gr(e){const t=e?.trim();if(!t)return null;const[n]=t.split(".");return n?.trim()||t}function _H(e){const t=e.handle?.trim().replace(/^@+/,"");if(t)return`@${t}`;const n=e.selector?.trim();if(n)return n;const a=gr(e.id);return a?`@${a}`:null}function OH(e){return e.name?.trim()||e.agentName?.trim()||gr(e.id)||e.title?.trim()||"Conversation"}function Ep(e){return e?e.replace(/_/g," "):null}function IH({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 Ku({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 DH({conversationId:e,navigate:t}){const{agents:n}=kt(),[a,i]=v.useState(null),[c,u]=v.useState(null),f=xT(e),m=v.useCallback(async()=>{u(null);try{const T=await Oe(`/api/session/${encodeURIComponent(e)}`).catch(()=>null);i(T)}catch(T){u(T instanceof Error?T.message:String(T)),i(null)}},[e]);v.useEffect(()=>{m()},[m]),An(()=>{m()});const h=a?.agentId??f,g=v.useMemo(()=>h?n.find(T=>T.id===h)??null:null,[n,h]);if(!g)return o.jsxs("div",{children:[o.jsx("button",{type:"button",className:"s-back",onClick:()=>t({view:"conversation",conversationId:e}),children:"← Back"}),c&&o.jsx("p",{className:"s-error",children:c}),o.jsx("div",{className:"s-empty",children:o.jsx("p",{children:"Agent not found"})})]});const x=_H(g),b=[{label:"System ID",value:g.id},{label:"Class",value:Ep(g.agentClass)??"—"},...g.role?[{label:"Role",value:g.role}]:[],...g.selector&&g.selector!==x?[{label:"Selector",value:g.selector}]:[]],w=[...g.project?[{label:"Project",value:g.project}]:[],...g.branch?[{label:"Branch",value:g.branch}]:[],...g.projectRoot?[{label:"Path",value:g.projectRoot}]:[],...g.cwd?[{label:"Working dir",value:g.cwd}]:[]],j=[...g.harness?[{label:"Harness",value:g.harness}]:[],...g.transport?[{label:"Transport",value:Ep(g.transport)??g.transport}]:[],...g.wakePolicy?[{label:"Wake policy",value:Ep(g.wakePolicy)??g.wakePolicy}]:[],...g.capabilities.length>0?[{label:"Capabilities",value:o.jsx(IH,{values:g.capabilities})}]:[]],N=[{label:"Thread ID",value:e},...a?.workspaceRoot?[{label:"Workspace",value:a.workspaceRoot}]:[],...a?.currentBranch?[{label:"Session branch",value:a.currentBranch}]:[],...a?.messageCount!=null?[{label:"Messages",value:String(a.messageCount)}]:[],...a?.lastMessageAt?[{label:"Last message",value:Xr(a.lastMessageAt)}]:[],...g.harnessSessionId?[{label:"Harness session",value:g.harnessSessionId}]:[],...g.harnessLogPath?[{label:"Harness log",value:g.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:g.id}),children:"Open in Agents"})]}),c&&o.jsx("p",{className:"s-error",children:c}),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:ct(g.name)},children:g.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:x??gr(g.id)??g.id}),o.jsxs("span",{className:`s-agent-state-chip s-agent-state-chip-${mt(g.state)}`,children:[o.jsx("span",{className:"s-dot",style:{background:Ra(g.state)}}),aa(g.state)]})]}),o.jsx("h1",{className:"s-agent-profile-hero-title",children:g.name}),o.jsxs("p",{className:"s-agent-profile-hero-context",children:[a?.title?`Conversation: ${a.title}.`:"Attached to the current conversation.",g.updatedAt?` Updated ${Pe(g.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(Ku,{title:"Identity",items:b}),o.jsx(Ku,{title:"Workspace",items:w}),o.jsx(Ku,{title:"Runtime",items:j}),o.jsx(Ku,{title:"Conversation context",items:N})]})]})}function zH(e){return e.attention==="interrupt"?"failed":e.state==="done"?"completed":e.attention==="badge"||e.state==="waiting"||e.state==="review"?"updated":"working"}function LH(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 $H(e){switch(e){case"badge":return"Needs attention";case"interrupt":return"Blocked";default:return null}}function ij({items:e,navigate:t,emptyTitle:n,emptyDetail:a}){if(e.length===0){const i=[{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}),a&&o.jsx("p",{className:"s-work-empty-detail",children:a})]}),o.jsx("div",{className:"s-work-empty-skeleton","aria-hidden":"true",children:i.map((c,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:c.titleWidth}}),o.jsx("span",{className:"s-work-empty-pill"})]}),o.jsx("div",{className:"s-work-empty-row-meta",children:c.metaWidths.map(f=>o.jsx("span",{className:"s-work-empty-line s-work-empty-line-meta",style:{width:f}},f))}),o.jsx("span",{className:"s-work-empty-line s-work-empty-line-summary",style:{width:c.summaryWidth}})]},u))})]})}return o.jsx("div",{className:"s-work-list",children:e.map(i=>{const c=!!i.id||!!i.conversationId,u=$H(i.attention),f=i.ownerName??i.ownerId??"Unassigned",m=i.id?()=>t({view:"work",workId:i.id}):i.conversationId?()=>t({view:"conversation",conversationId:i.conversationId}):void 0;return o.jsxs("div",{className:`s-work-row${c?" s-work-row-clickable":""}`,onClick:m,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:i.title}),i.priority&&o.jsx("span",{className:"s-badge",children:i.priority})]}),o.jsx("span",{className:`s-pill s-pill-${zH(i)}`,children:i.currentPhase})]}),o.jsxs("div",{className:"s-work-row-meta",children:[o.jsx("span",{children:f}),o.jsx("span",{children:LH(i.state)}),i.activeChildWorkCount>0&&o.jsxs("span",{children:[i.activeChildWorkCount," child",i.activeChildWorkCount===1?"":"ren"]}),i.activeFlightCount>0&&o.jsxs("span",{children:[i.activeFlightCount," flight",i.activeFlightCount===1?"":"s"]}),u&&o.jsx("span",{children:u}),o.jsx("span",{children:Pe(i.lastMeaningfulAt)})]}),i.lastMeaningfulSummary&&o.jsx("p",{className:"s-work-row-summary",children:ks(i.lastMeaningfulSummary)})]},i.id)})})}const TT="scout:sessions:lastViewed";function Wv(){if(typeof localStorage>"u")return{};try{const e=localStorage.getItem(TT);if(!e)return{};const t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function PH(e,t=Date.now()){const n=Wv();n[e]=t;try{localStorage.setItem(TT,JSON.stringify(n))}catch{}return n}function Cp(e,t,n){return e?e>(n[t]??0):!1}async function UH(e){await fetch("/api/terminal/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:e})})}const Og=new Set(["completed","failed","cancelled"]),BH={direct:"Direct message",channel:"Channel",group_direct:"Group",thread:"Thread"},oj=[{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 AT(e,t){if(t<=0)return!0;const n=e[t-1];return!n||/\s/.test(n)}function VH(e,t){if(t===0)return null;let n=t-1;for(;n>=0;){const i=e[n];if(i==="/")break;if(!i||/\s/.test(i))return null;n-=1}if(n<0||e[n]!=="/"||!AT(e,n))return null;const a=e.slice(n+1,t);return/[^a-zA-Z0-9_-]/.test(a)?null:{start:n,query:a}}function HH(e,t){if(t===0)return null;let n=t-1;for(;n>=0;){const i=e[n];if(i==="@")break;if(!i||/\s/.test(i))return null;n-=1}if(n<0||e[n]!=="@"||!AT(e,n))return null;const a=e.slice(n+1,t);return/[^a-zA-Z0-9._/:-]/.test(a)?null:{start:n,query:a}}function Xn(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?null:e<1e12?e*1e3:e}function ZH(e){if(!e)return null;const t=e.replace(/[\\/]+$/,"");return t?t.split(/[\\/]/).filter(Boolean).at(-1)??t:null}function FH(e){return e.kind==="direct"&&e.agentName?e.agentName:e.kind==="direct"&&e.agentId?gr(e.agentId)??e.agentId:e.title.replace(/\s*<>\s*/g," · ")}function Tp(e){const t=Xn(e);return t===null?"":new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(t)}function qH(e,t){const n=Xn(e),a=Xn(t);if(n===null||a===null)return!1;const i=new Date(n),c=new Date(a);return i.getFullYear()===c.getFullYear()&&i.getMonth()===c.getMonth()&&i.getDate()===c.getDate()}function lj(e){const t=Xn(e);if(t===null)return"";const n=new Date(t),a=new Date,i=new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),c=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime(),u=1440*60*1e3;return c===i?"Today":c===i-u?"Yesterday":new Intl.DateTimeFormat(void 0,{weekday:"short",month:"short",day:"numeric"}).format(t)}function YH(e){switch(e){case"status":return"Status";case"system":return"System";case"scout.dispatch":return"Dispatch";default:return null}}function Ju(e){return[...e].sort((t,n)=>(Xn(t.createdAt)??0)-(Xn(n.createdAt)??0))}function GH(e){return e.filter(t=>!Og.has(t.state)).sort((t,n)=>(Xn(n.startedAt)??0)-(Xn(t.startedAt)??0))[0]??null}function cj(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 WH(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 Ig(e,t){if(e.class==="operator")return!0;const n=e.actorName?.toLowerCase()??"";return n===t.toLowerCase()||n==="operator"||n==="you"}function XH(e,t){return e.reduce((n,a)=>{if(Ig(a,t))return n;const i=Xn(a.createdAt);return i===null?n:n===null||i>n?i:n},null)}function KH(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 JH(e){const{agentName:t,agentState:n,sending:a,currentFlight:i,showWorkingTurn:c}=e;if(a&&!i)return{label:"Sending",detail:`Handing your message to ${t}.`,tone:"pending",showStrip:!0,showTyping:!1};if(i&&c){const u=i.summary?.trim()||KH(t,i.state);switch(i.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 oi(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 QH(e,t){switch(e.tone){case"pending":return"var(--accent)";case"working":return"var(--green)";case"offline":return"var(--dim)";default:return Ra(t)}}function e7(){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 t7(){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 n7(e){if(!e)return null;if(e.kind==="direct")return e.agentName??gr(e.agentId)??null;const t=e.participantIds.filter(n=>n!=="operator");return t.length===0?null:t.map(n=>gr(n)??n).join(", ")}function Dg({conversationId:e,initialComposeMode:t,navigate:n,embedded:a}){const{agents:i}=kt(),[c,u]=v.useState(null),[f,m]=v.useState([]),[h,g]=v.useState(null),[x,b]=v.useState([]),[w,j]=v.useState(null),N=v.useRef(null),T=v.useRef(null),k=v.useRef(new Set),C=v.useRef(null),S=v.useRef(0),R=xT(e),A=c?.agentId??R,_=c?.kind==="direct"||R!==null,O=v.useMemo(()=>A?i.find(Q=>Q.id===A)??null:null,[i,A]),[V,Z]=v.useState([]),[I,$]=v.useState(new Set),[L]=v.useState(()=>Wv());v.useEffect(()=>{Oe("/api/sessions").then(Q=>Z(Q.sort((me,ge)=>(ge.lastMessageAt??0)-(me.lastMessageAt??0)))).catch(()=>{}),Oe("/api/fleet").then(Q=>{const me=new Set;for(const ge of Q.needsAttention)ge.conversationId&&me.add(ge.conversationId),ge.agentId&&me.add(ge.agentId);for(const ge of Q.activeAsks)ge.status==="needs_attention"&&ge.conversationId&&me.add(ge.conversationId);$(me)}).catch(()=>{})},[]);const P=v.useCallback(async()=>{j(null);try{const Q=await Oe(`/api/session/${encodeURIComponent(e)}`).catch(()=>null);u(Q);const me=Q?.agentId??R,ge=Q?.kind==="direct"&&me&&me.startsWith("local-session-agent-")?os(me):e;if(ge!==e){n({view:"conversation",conversationId:ge,...t?{composeMode:t}:{}});return}const[Ve,ze]=await Promise.all([Oe(`/api/messages?conversationId=${encodeURIComponent(ge)}&limit=300`),Oe(`/api/flights?conversationId=${encodeURIComponent(ge)}`)]);m(Ju(Ve)),b(ze),k.current=new Set(ze.map(dt=>dt.invocationId)),g(GH(ze))}catch(Q){j(Q instanceof Error?Q.message:String(Q))}},[e,t,R,n]);v.useEffect(()=>{P()},[P]);const[q,ee]=v.useState(null),[D,U]=v.useState(!1);v.useEffect(()=>{if(!A)return;let Q=!1;return Oe(`/api/agents/${encodeURIComponent(A)}/session-catalog`).then(me=>{Q||ee(me)}).catch(()=>{}),()=>{Q=!0}},[A]),v.useEffect(()=>{C.current=h},[h]);const[B,G]=v.useState(""),[K,z]=v.useState(!1),[Y,W]=v.useState("operator"),[J,de]=v.useState({open:!1,query:"",triggerStart:-1,index:0}),[ae,ye]=v.useState({open:!1,query:"",triggerStart:-1,index:0}),[ve,be]=v.useState(null),[_e,ie]=v.useState(t==="ask"?"ask":"tell");v.useEffect(()=>{ie(_&&t==="ask"?"ask":"tell")},[e,t,_]);const ke=v.useMemo(()=>{const Q=new Set,me=[];for(const ge of i){const Ve=ge.handle?.trim().replace(/^@+/,"")??gr(ge.id)??ge.id;if(!Ve)continue;const ze=Ve.toLowerCase();Q.has(ze)||(Q.add(ze),me.push({id:ge.id,label:Ve,name:ge.name??Ve,handle:Ve}))}return me.sort((ge,Ve)=>ge.handle.localeCompare(Ve.handle))},[i]),we=v.useMemo(()=>{if(!J.open)return[];const Q=J.query.toLowerCase();return Q?oj.filter(me=>me.command.toLowerCase().startsWith("/"+Q)||me.command.toLowerCase().includes(Q)):oj},[J.open,J.query]),Ue=v.useMemo(()=>{if(!ae.open)return[];const Q=ae.query.toLowerCase();return Q?ke.filter(me=>me.handle.toLowerCase().includes(Q)||me.name.toLowerCase().includes(Q)).slice(0,8):ke.slice(0,8)},[ae.open,ae.query,ke]),Ae=v.useCallback(()=>{de(Q=>Q.open?{...Q,open:!1}:Q),ye(Q=>Q.open?{...Q,open:!1}:Q)},[]),xe=v.useCallback((Q,me)=>{const ge=VH(Q,me);de(ge?ze=>({open:!0,query:ge.query,triggerStart:ge.start,index:ze.open&&ze.triggerStart===ge.start?ze.index:0}):ze=>ze.open?{...ze,open:!1}:ze);const Ve=HH(Q,me);ye(Ve?ze=>({open:!0,query:Ve.query,triggerStart:Ve.start,index:ze.open&&ze.triggerStart===Ve.start?ze.index:0}):ze=>ze.open?{...ze,open:!1}:ze)},[]),Ee=v.useCallback(Q=>{const me=T.current,ge=J.triggerStart;if(ge<0)return;const Ve=me?.selectionStart??B.length,ze=B.slice(0,ge),dt=B.slice(Ve),$t=Q.insert,Ft=`${ze}${$t}${dt}`;G(Ft),de(xn=>({...xn,open:!1})),requestAnimationFrame(()=>{const xn=T.current;if(!xn)return;const qt=ze.length+$t.length;xn.focus(),xn.setSelectionRange(qt,qt)})},[B,J.triggerStart]),Ye=v.useCallback(Q=>{const me=T.current,ge=ae.triggerStart;if(ge<0)return;const Ve=me?.selectionStart??B.length,ze=B.slice(0,ge),dt=B.slice(Ve),$t=dt.length===0||!dt.startsWith(" "),Ft=`@${Q.handle}${$t?" ":""}`,xn=`${ze}${Ft}${dt}`;G(xn),ye(qt=>({...qt,open:!1})),requestAnimationFrame(()=>{const qt=T.current;if(!qt)return;const As=ze.length+Ft.length;qt.focus(),qt.setSelectionRange(As,As)})},[B,ae.triggerStart]);v.useEffect(()=>{const Q=T.current;if(!Q)return;Q.style.height="0px";const me=Math.min(Math.max(Q.scrollHeight,40),160);Q.style.height=`${me}px`,Q.style.overflowY=Q.scrollHeight>me?"auto":"hidden"},[B]),v.useEffect(()=>{Oe("/api/user").then(Q=>W(Q.name)).catch(()=>{})},[]);const Be=v.useMemo(()=>XH(f,Y),[f,Y]);v.useEffect(()=>{ve===null||Be===null||Be>=ve&&be(null)},[ve,Be]);const He=v.useMemo(()=>!h||Og.has(h.state)?!1:(Xn(h.startedAt)??ve??Date.now())>=(Be??0),[ve,h,Be]),ce=K||ve!==null||He,he=OH({name:O?.name,agentName:c?.agentName,id:A,title:c?.title}),pe=v.useMemo(()=>JH({agentName:he,agentState:O?.state??null,sending:K,currentFlight:h,showWorkingTurn:He}),[O?.state,he,h,K,He]),je=c?FH(c):he,Ne=c?.kind?BH[c.kind]??c.kind:"Conversation";n7(c);const Je=ZH(c?.workspaceRoot),et=c?.lastMessageAt??f[f.length-1]?.createdAt??null,Ge=[Je?{label:Je,title:c?.workspaceRoot??void 0}:null,c?.currentBranch?{label:c.currentBranch,title:c.currentBranch}:null,O?.harness??c?.harness?{label:O?.harness??c?.harness??"",title:void 0}:null].filter(Q=>!!Q),Bt=c?c.participantIds.length:_?2:1,Et=v.useMemo(()=>(!I.has(e)&&!(A&&I.has(A)),null),[e,A,I]);An(v.useCallback(Q=>{if(Q.kind==="message.posted"){const me=Q.payload?.message;if(!me||me.conversationId!==e)return;const ge=me.actorId===A,Ve={id:me.id,conversationId:me.conversationId,actorName:ge?he:Y,body:me.body,createdAt:me.createdAt,class:ge?me.class:"operator"};if(m(ze=>{if(ze.some(dt=>dt.id===me.id))return ze;if(!ge){const dt=ze.findIndex($t=>$t.id.startsWith("optimistic-")&&$t.body===me.body&&Math.abs((Xn($t.createdAt)??0)-(Xn(me.createdAt)??0))<=6e4);if(dt!==-1){const $t=[...ze];return $t[dt]=Ve,Ju($t)}}return Ju([...ze,Ve])}),ge){const ze=Xn(me.createdAt)??Date.now();be(dt=>dt===null||ze<dt?dt:null),g(dt=>{if(!dt)return dt;const $t=Xn(dt.startedAt)??0;return ze>=$t?null:dt})}return}if(Q.kind==="invocation.requested"){const me=Q.payload?.invocation;if(!me||me.targetAgentId!==A||me.conversationId!==e)return;k.current.add(me.id),be(ge=>ge??Date.now());return}if(Q.kind==="flight.updated"){const me=Q.payload?.flight;if(!me||me.targetAgentId!==A||!(k.current.has(me.invocationId)||C.current?.id===me.id))return;if(Og.has(me.state)){g(Ve=>Ve?.id===me.id?null:Ve),P();return}k.current.add(me.invocationId),g(cj(me,e,A??""));return}Q.kind!=="agent.endpoint.upserted"&&Q.kind==="unknown"&&P()},[A,he,e,P,Y])),v.useEffect(()=>{if(!ce)return;const Q=setInterval(()=>{P()},5e3);return()=>clearInterval(Q)},[ce,P]),v.useEffect(()=>{const Q=()=>{if(document.visibilityState!=="visible")return;const me=Date.now();me-S.current<1e3||(S.current=me,P())};return window.addEventListener("focus",Q),document.addEventListener("visibilitychange",Q),()=>{window.removeEventListener("focus",Q),document.removeEventListener("visibilitychange",Q)}},[P]);const fn=f.length+(pe.showTyping?1:0),hn=v.useRef(0);v.useEffect(()=>{fn>hn.current&&N.current?.scrollIntoView({behavior:"smooth"}),hn.current=fn},[fn]);const[,on]=v.useState(0);v.useEffect(()=>{const Q=setInterval(()=>on(me=>me+1),15e3);return()=>clearInterval(Q)},[]);const Ie=async(Q,me)=>{const ge=Q.trim();if(!ge||K)return;const Ve=me?.forceMode??_e,ze=_?ce?"steer":Ve:"tell",dt=Date.now(),$t={id:`optimistic-${dt}`,conversationId:e,actorName:Y,body:ge,createdAt:dt,class:"operator"};z(!0),be(dt),j(null),m(Ft=>Ju([...Ft,$t]));try{const Ft=await Oe(ze==="ask"?"/api/ask":"/api/send",{method:"POST",body:JSON.stringify({body:ge,conversationId:e})});Ft.flight&&(k.current.add(Ft.flight.invocationId),g(cj(Ft.flight,e,A??"")))}catch(Ft){m(xn=>xn.filter(qt=>qt.id!==$t.id)),be(null),j(Ft instanceof Error?Ft.message:String(Ft))}finally{z(!1)}},tt=async()=>{const Q=B.trim();Q&&(G(""),await Ie(Q))},ut=async()=>{if(A)try{await Oe("/api/agents/"+encodeURIComponent(A)+"/interrupt",{method:"POST",body:JSON.stringify({})})}catch{}},xt=pe.tone==="working"||pe.tone==="pending",Lt=_?ce?"steer":_e:"tell",vn=_?"Reply — or type / to route, @ to mention an agent, ? to ask a question":`Message ${he}...`,Xt=!B.trim()&&xt,mn=jf(),ln=v.useCallback((Q,me)=>{const ge=window.getSelection()?.toString().trim(),Ve=[];ge&&(Ve.push({kind:"action",label:"Copy Selection",shortcut:"⌘C",onSelect:()=>navigator.clipboard.writeText(ge)}),Ve.push({kind:"separator"})),Ve.push({kind:"action",label:"Copy Message",onSelect:()=>navigator.clipboard.writeText(me.body)}),me.actorName&&!Ig(me,Y)&&Ve.push({kind:"action",label:"Copy Agent ID",onSelect:()=>navigator.clipboard.writeText(me.actorName??"")}),Ve.push({kind:"separator"}),Ve.push({kind:"action",label:"Copy Message ID",onSelect:()=>navigator.clipboard.writeText(me.id)}),mn(Q,Ve)},[Y,mn]),yn=async(Q,me)=>{const ge=`@${me.agentId} `,Ve=B.trim();if(Ve){G(""),await Ie(`${ge}${Ve}`,{forceMode:"tell"});return}G(ge),T.current?.focus()},Ts=v.useMemo(()=>c?c.participantIds.filter(Q=>Q!=="operator").slice(0,4).map(Q=>{const me=i.find(ge=>ge.id===Q);return{id:Q,name:me?.name??Q}}):[],[c,i]);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:()=>_?n({view:"agent-info",conversationId:e}):void 0,style:_?{cursor:"pointer"}:void 0,onContextMenu:Q=>{const me=[{kind:"action",label:"Copy Title",onSelect:()=>navigator.clipboard.writeText(je)}];A&&me.push({kind:"action",label:"Copy Agent ID",onSelect:()=>navigator.clipboard.writeText(A)}),me.push({kind:"action",label:"Copy Conversation ID",onSelect:()=>navigator.clipboard.writeText(e)}),mn(Q,me)},children:[o.jsxs("div",{className:"s-thread-center-header-info",children:[o.jsx("span",{className:"s-thread-center-header-name",children:je}),o.jsxs("div",{className:"s-thread-center-header-eyebrow",children:[o.jsx("span",{className:"s-thread-center-header-kicker",children:Ne}),et&&o.jsx("span",{className:"s-thread-center-header-time",title:Tp(et),children:Pe(et)})]})]}),o.jsxs("div",{className:"s-thread-center-header-right",children:[Ge.length>0&&o.jsx("div",{className:"s-thread-center-header-chips",children:Ge.map((Q,me)=>o.jsx("span",{className:"s-thread-center-chip",title:Q.title,children:Q.label},`${Q.label}-${me}`))}),Ts.length>0&&o.jsxs("div",{className:"s-thread-center-avatars",children:[Ts.map(Q=>o.jsx("div",{className:"s-ops-avatar",style:{"--size":"22px",background:ct(Q.name)},title:Q.name,children:Q.name[0]?.toUpperCase()??"?"},Q.id)),o.jsx("span",{className:"s-thread-center-participant-count",children:Bt})]})]})]}),Et&&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:Et.task}),o.jsxs("div",{className:"s-thread-pinned-ask-routing",children:[o.jsx("span",{children:Et.agentName??gr(Et.agentId)??Et.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"})]}),pe.showStrip&&o.jsxs("div",{className:`s-thread-status s-thread-status--${pe.tone}`,"aria-live":"polite",children:[o.jsx("span",{className:"s-thread-status-dot",style:{background:QH(pe,O?.state??null)}}),o.jsxs("div",{className:"s-thread-status-copy",children:[o.jsx("span",{className:"s-thread-status-label",children:pe.label}),o.jsx("span",{className:"s-thread-status-detail",children:pe.detail})]})]}),!a&&_&&O&&(O.harnessSessionId||O.harnessLogPath||q?.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:[q?.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:q.activeSessionId,children:q.activeSessionId.slice(0,8)})]}),q?.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:q.resumeCommand,onClick:()=>{UH(q.resumeCommand).then(()=>n({view:"terminal",agentId:A??void 0})),U(!0)},children:D?"Going…":`Takeover — ${q.resumeCommand}`})})]}),O.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:O.harnessSessionId})]}),O.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:O.harnessLogPath})]})]})]}),w&&o.jsx("p",{className:"s-thread-error",children:w}),o.jsxs("div",{className:"s-thread-feed",children:[o.jsx("div",{className:"s-thread-feed-spacer"}),f.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."})]}):f.map((Q,me)=>{const ge=Ig(Q,Y),Ve=WH(Q),ze=Ve?"scout.dispatch":Q.class,dt=YH(ze),$t=ze==="status",Ft=me===0||!qH(f[me-1]?.createdAt,Q.createdAt),xn=Tp(Q.createdAt),qt=!ge&&Q.actorName?i.find(cn=>cn.name===Q.actorName)??null:null,As=ge?Y.toLowerCase():qt?.handle??null;return o.jsxs("div",{className:["s-thread-feed-block",ge&&"s-thread-feed-block--you",Ft&&"s-thread-feed-block--full-width"].filter(Boolean).join(" "),children:[Ft&&o.jsxs("div",{className:"s-thread-day-divider","aria-label":lj(Q.createdAt),children:[o.jsx("span",{className:"s-thread-day-line","aria-hidden":"true"}),o.jsx("span",{className:"s-thread-day-label",children:lj(Q.createdAt)}),o.jsx("span",{className:"s-thread-day-line","aria-hidden":"true"})]}),o.jsx("article",{id:`msg-${Q.id}`,className:["s-thread-msg",ge&&"s-thread-msg--you",$t&&"s-thread-msg--tool"].filter(Boolean).join(" "),"data-class":ze,onContextMenu:cn=>ln(cn,Q),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:ct(ge?Y:Q.actorName??"?")},children:(ge?Y[0]:Q.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:ge?Y:Q.actorName}),As&&o.jsxs("span",{className:"s-thread-msg-handle",children:["@",As]}),dt&&o.jsx("span",{className:"s-thread-msg-kind",children:dt})]}),o.jsx("span",{className:"s-thread-msg-time",title:xn,children:Pe(Q.createdAt)}),o.jsx("button",{type:"button",className:"s-thread-msg-permalink","aria-label":"Copy link to message",title:"Copy link to message",onClick:()=>{const cn=`${window.location.origin}${window.location.pathname}#msg-${Q.id}`;navigator.clipboard.writeText(cn)},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:xn,children:ks(Q.body)}),Ve&&Ve.candidates.length>0&&o.jsx("div",{className:"s-thread-dispatch",children:Ve.candidates.map(cn=>o.jsxs("button",{type:"button",className:"s-thread-dispatch-tile",onClick:()=>{yn(Ve,cn)},children:[o.jsxs("span",{className:"s-thread-dispatch-tile-id",children:["@",cn.agentId]}),o.jsx("span",{className:"s-thread-dispatch-tile-state",children:cn.endpointState}),o.jsx("span",{className:"s-thread-dispatch-tile-meta",children:[cn.workspace,cn.node,cn.projectRoot].filter(Boolean).join(" · ")||cn.displayName})]},cn.agentId))})]})]})})]},Q.id)}),pe.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:ct(he)},children:he[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:he}),o.jsx("span",{className:"s-thread-msg-kind",children:"Live"})]}),o.jsx("span",{className:"s-thread-msg-time",title:h?.startedAt?Tp(h.startedAt):"now",children:h?.startedAt?Pe(h.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:pe.detail})]})]})]})})}),o.jsx("div",{ref:N})]}),pe.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:ct(he)},children:he[0]?.toUpperCase()??"?"})}),o.jsxs("span",{className:"s-thread-presence-line-label",children:[he," is ",pe.label.toLowerCase(),"..."]}),o.jsx("div",{className:"s-thread-presence-strip"})]}),o.jsx("form",{className:"s-thread-compose",onSubmit:Q=>{Q.preventDefault(),tt()},children:o.jsxs("div",{className:"s-thread-compose-shell",children:[J.open&&we.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"}),we.map((Q,me)=>o.jsxs("button",{type:"button",role:"option","aria-selected":me===J.index,className:["s-thread-compose-suggest-item",me===J.index&&"s-thread-compose-suggest-item--active"].filter(Boolean).join(" "),onMouseDown:ge=>{ge.preventDefault(),Ee(Q)},onMouseEnter:()=>de(ge=>({...ge,index:me})),children:[o.jsx("span",{className:"s-thread-compose-suggest-cmd",children:Q.label}),o.jsx("span",{className:"s-thread-compose-suggest-desc",children:Q.description})]},Q.command))]}),ae.open&&Ue.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"}),Ue.map((Q,me)=>o.jsxs("button",{type:"button",role:"option","aria-selected":me===ae.index,className:["s-thread-compose-suggest-item",me===ae.index&&"s-thread-compose-suggest-item--active"].filter(Boolean).join(" "),onMouseDown:ge=>{ge.preventDefault(),Ye(Q)},onMouseEnter:()=>ye(ge=>({...ge,index:me})),children:[o.jsx("span",{className:"s-ops-avatar s-thread-compose-suggest-avatar",style:{"--size":"20px",background:ct(Q.name)},children:Q.name[0]?.toUpperCase()??"?"}),o.jsxs("span",{className:"s-thread-compose-suggest-cmd",children:["@",Q.handle]}),o.jsx("span",{className:"s-thread-compose-suggest-desc",children:Q.name})]},Q.id))]}),o.jsxs("div",{className:"s-thread-compose-row",children:[o.jsx("textarea",{ref:T,className:"s-thread-compose-input",placeholder:vn,value:B,onChange:Q=>{const me=Q.target.value;G(me),xe(me,Q.target.selectionStart)},onSelect:Q=>{const me=Q.currentTarget;xe(me.value,me.selectionStart)},onBlur:()=>{setTimeout(Ae,120)},onKeyDown:Q=>{if(J.open&&we.length>0||ae.open&&Ue.length>0){if(Q.key==="ArrowDown"){Q.preventDefault(),J.open?de(ge=>({...ge,index:(ge.index+1)%we.length})):ae.open&&ye(ge=>({...ge,index:(ge.index+1)%Ue.length}));return}if(Q.key==="ArrowUp"){Q.preventDefault(),J.open?de(ge=>({...ge,index:(ge.index-1+we.length)%we.length})):ae.open&&ye(ge=>({...ge,index:(ge.index-1+Ue.length)%Ue.length}));return}if(Q.key==="Escape"){Q.preventDefault(),Ae();return}if(Q.key==="Enter"||Q.key==="Tab"){if(Q.shiftKey)return;if(Q.preventDefault(),J.open){const ge=we[J.index]??we[0];ge&&Ee(ge)}else if(ae.open){const ge=Ue[ae.index]??Ue[0];ge&&Ye(ge)}return}}Q.key!=="Enter"||Q.shiftKey||Q.nativeEvent.isComposing||(Q.preventDefault(),!K&&B.trim()&&tt())},rows:1}),Xt?o.jsx("button",{type:"button",className:"s-thread-compose-send s-thread-compose-send--stop",onClick:()=>{ut()},"aria-label":"Stop agent",children:o.jsx(t7,{})}):o.jsx("button",{type:"submit",className:"s-thread-compose-send",disabled:K||!B.trim(),"aria-label":Lt==="ask"?"Ask agent":Lt==="steer"?"Steer agent":_?"Tell agent":"Send message",children:o.jsx(e7,{})})]})]})})]})})}async function s7(e){await fetch("/api/terminal/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:e})})}const RT={think:"var(--dim)",tool:"var(--accent)",ask:"var(--amber)",message:"var(--muted)",note:"var(--green)",system:"var(--dim)",boot:"var(--dim)"},a7={read:"◎",edit:"✎",bash:"$",grep:"⌕",write:"✎",think:"∿"},r7=20;function i7(e){const t=Math.floor(e/60),n=Math.floor(e%60);return`${String(t).padStart(2,"0")}:${String(n).padStart(2,"0")}`}function uj(e,t){return e>=Math.max(0,t-r7)}function o7({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 l7({event:e}){const t=a7[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(([a,i])=>`${a}: ${i}`).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(`
|
|
140
|
+
`)})]})}function c7({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 u7({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:e.text})]})}function d7({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 f7({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 h7(){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 m7({liveSession:e,isLive:t}){const n=e?t?"live":"paused":"replay",a=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:a})]})}function p7({event:e,prevT:t}){const n=e.t-t,a=RT[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:i7(e.t)}),o.jsx("span",{className:"s-observe-row-bead",style:{background:a}}),e.kind==="think"&&o.jsx(o7,{event:e}),e.kind==="tool"&&o.jsx(l7,{event:e}),e.kind==="ask"&&o.jsx(c7,{event:e}),e.kind==="message"&&o.jsx(u7,{event:e}),e.kind==="note"&&o.jsx(d7,{event:e}),(e.kind==="system"||e.kind==="boot")&&o.jsx(f7,{event:e})]})}function g7({events:e,isLive:t}){const n=v.useRef(null);return v.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((a,i)=>o.jsx(p7,{event:a,prevT:i>0?e[i-1].t:0},a.id)),o.jsx("div",{ref:n})]})}function v7({data:e,cursor:t}){const i=e.length;if(i<2)return null;const c=276/(i-1),u=e.map((m,h)=>`${h===0?"M":"L"} ${(h*c).toFixed(1)} ${((1-m)*44).toFixed(1)}`).join(" "),f=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:f,y1:0,x2:f,y2:44,stroke:"var(--accent)",strokeWidth:1,opacity:.6,strokeDasharray:"2 3"})]})}function y7({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 x7({events:e,duration:t,cursor:n,onCursor:a}){const i=v.useRef(null),c=v.useCallback(u=>{const f=i.current.getBoundingClientRect(),m=u.clientX-f.left;a(Math.max(0,Math.min(t,m/f.width*t)))},[t,a]);return o.jsx("div",{className:"s-observe-track-wrap",children:o.jsxs("div",{ref:i,className:"s-observe-track",onClick:c,children:[e.map(u=>{const f=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:f===6?-2:-1,height:f,background:RT[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 dj(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 b7(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 w7({catalog:e,sessionId:t,agentId:n}){const{navigate:a}=kt(),[i,c]=v.useState(!1),u=e.sessions.find(x=>x.id===e.activeSessionId),f=e.sessions.filter(x=>x.id!==e.activeSessionId&&x.endedAt).sort((x,b)=>(b.endedAt??0)-(x.endedAt??0)).slice(0,5),m=e.activeSessionId??t,h=m?m.slice(0,8):null,g=v.useCallback(()=>{e.resumeCommand&&(s7(e.resumeCommand).then(()=>{a({view:"terminal",agentId:n})}),c(!0))},[e.resumeCommand,a,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:m??void 0,children:h}),u&&o.jsxs("span",{className:"s-observe-session-time",children:["started ",dj(u.startedAt)]}),e.resumeCommand&&o.jsx("button",{className:"s-observe-takeover-btn",onClick:g,title:e.resumeCommand,children:i?"Sent":"Takeover"})]})}),f.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"]}),f.map(x=>o.jsxs("div",{className:"s-observe-session-past",children:[o.jsx("span",{className:"s-observe-session-id",children:x.id.slice(0,8)}),o.jsxs("span",{className:"s-observe-session-time",children:[dj(x.startedAt),x.endedAt?` · ${b7(x.startedAt,x.endedAt)}`:""]})]},x.id))]})]})}const S7={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 MT({data:e,agentId:t,sessionId:n}){const a=e??S7,{events:i,files:c,contextUsage:u}=a,f=a.live===!0,[m,h]=v.useState(null);v.useEffect(()=>{if(!t)return;let Z=!1;return Oe(`/api/agents/${encodeURIComponent(t)}/session-catalog`).then(I=>{Z||h(I)}).catch(()=>{}),()=>{Z=!0}},[t]);const g=i.length>0?i[i.length-1].t+30:60,[x,b]=v.useState(g),[w,j]=v.useState(!1),[N,T]=v.useState(1),k=v.useRef(g);v.useEffect(()=>{b(Z=>{const I=k.current;k.current=g;const $=uj(Z,I);return Z>g||$?g:Z})},[g]),v.useEffect(()=>{if(!w)return;const Z=setInterval(()=>{b(I=>{const $=I+N;return $>=g?(j(!1),g):$})},100);return()=>clearInterval(Z)},[w,g,N]);const C=i.filter(Z=>Z.t<=x),S=f&&uj(x,g),R=f?S?"Following live":"Jump to live ↦":"Jump to end ↦",A=i.filter(Z=>Z.kind==="tool").length,_=i.filter(Z=>Z.kind==="think").length,O=i.filter(Z=>Z.kind==="ask").length,V=i.filter(Z=>Z.kind==="tool"&&Z.tool==="edit").length;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(h7,{})}),o.jsx(g7,{events:C,isLive:S})]}),o.jsxs("aside",{className:"s-observe-rail",children:[m&&m.sessions.length>0&&o.jsxs("div",{children:[o.jsx("div",{className:"s-observe-rail-label",children:"Session"}),o.jsx(w7,{catalog:m,sessionId:n??null,agentId:t})]}),o.jsxs("div",{children:[o.jsx("div",{className:"s-observe-rail-label",children:"Context window"}),u&&u.length>=2?o.jsxs(o.Fragment,{children:[o.jsx(v7,{data:u,cursor:x/g}),o.jsxs("div",{className:"s-observe-ctx-detail",children:[Math.round((u[u.length-1]??0)*100),"% ·"," ","derived session load"]})]}):o.jsx("div",{className:"s-observe-ctx-detail",children:"Unavailable for this session"})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"s-observe-rail-label",children:["Files touched · ",c.length]}),o.jsx("div",{className:"s-observe-files",children:c.map(Z=>o.jsxs("div",{className:`s-observe-file${Z.lastT<=x?" s-observe-file--visible":" s-observe-file--hidden"}`,children:[o.jsx(y7,{state:Z.state}),o.jsx("span",{className:"s-observe-file-path",children:Z.path}),o.jsxs("span",{className:"s-observe-file-touches",children:["×",Z.touches]})]},Z.path))})]}),o.jsxs("div",{children:[o.jsx("div",{className:"s-observe-rail-label",children:"Session stats"}),o.jsxs("div",{className:"s-observe-stats",children:[o.jsxs("div",{className:"s-observe-stat",children:[o.jsx("div",{className:"s-observe-stat-label",children:"Tools"}),o.jsx("div",{className:"s-observe-stat-value",children:A})]}),o.jsxs("div",{className:"s-observe-stat",children:[o.jsx("div",{className:"s-observe-stat-label",children:"Thinks"}),o.jsx("div",{className:"s-observe-stat-value",children:_})]}),o.jsxs("div",{className:"s-observe-stat",children:[o.jsx("div",{className:"s-observe-stat-label",children:"Asks"}),o.jsx("div",{className:"s-observe-stat-value",children:O})]}),o.jsxs("div",{className:"s-observe-stat",children:[o.jsx("div",{className:"s-observe-stat-label",children:"Edits"}),o.jsx("div",{className:"s-observe-stat-value",children:V})]})]})]})]}),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(x7,{events:i,duration:g,cursor:x,onCursor:b}),o.jsx("div",{className:"s-observe-speed-group",children:[.5,1,2,4].map(Z=>o.jsxs("button",{className:`s-observe-speed-btn${N===Z?" s-observe-speed-btn--active":""}`,onClick:()=>T(Z),children:[Z,"×"]},Z))}),o.jsx(m7,{liveSession:f,isLive:S}),o.jsx("button",{className:`s-observe-jump-btn${S?" s-observe-jump-btn--active":""}`,onClick:()=>b(g),children:R})]})]})}async function j7(e){await fetch("/api/terminal/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:e})})}function N7(e,t){if(t.filter(i=>i.name===e.name).length<=1)return{name:e.name,qualifier:null};const a=e.project??e.branch??e.id.replace(/^.*\./,"");return{name:e.name,qualifier:a}}function fj(e){if(!e)return null;const t=e.replace(/_/g," ");return t.toLowerCase()==="relay agent"?"agent":t}function k7(e){const t=[...e].filter(i=>i.kind==="direct"&&!!i.agentId).sort((i,c)=>(c.lastMessageAt??0)-(i.lastMessageAt??0)),n=new Map,a=new Map;for(const i of t)n.has(i.agentId)||(n.set(i.agentId,i.id),a.set(i.agentId,i));return{conversationByAgentId:n,sessionByAgentId:a}}function E7({catalog:e,agentId:t}){const{navigate:n}=kt(),[a,i]=v.useState(!1),c=e.activeSessionId?.slice(0,8)??null,u=e.sessions.find(m=>m.id===e.activeSessionId),f=()=>{e.resumeCommand&&(j7(e.resumeCommand).then(()=>n({view:"terminal",agentId:t})),i(!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:[c,e.resumeCommand&&o.jsx("button",{type:"button",className:"s-profile-facet-action",onClick:f,title:e.resumeCommand,children:a?"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 C7({agent:e,fleet:t,navigate:n}){const a=v.useMemo(()=>t?t.activity.filter(c=>c.agentId===e.id||c.actorId===e.id).slice(0,6):[],[t,e.id]),i=v.useMemo(()=>t?t.recentCompleted.filter(c=>c.agentId===e.id).slice(0,4):[],[t,e.id]);return a.length===0&&i.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:[i.map(c=>o.jsxs("div",{className:"s-profile-activity-row",onClick:()=>{c.conversationId&&n({view:"agents",agentId:e.id,conversationId:c.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:c.summary??c.task}),o.jsxs("div",{className:"s-profile-activity-meta",children:[c.status==="completed"?"completed":c.status,c.completedAt&&` · ${Pe(c.completedAt)}`]})]})]},c.invocationId)),a.map(c=>o.jsxs("div",{className:"s-profile-activity-row",onClick:()=>{c.conversationId&&n({view:"agents",agentId:e.id,conversationId:c.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:c.title??c.summary??c.kind}),o.jsxs("div",{className:"s-profile-activity-meta",children:[c.kind.replace(/_/g," "),c.actorName&&` · ${c.actorName}`,` · ${Pe(c.ts)}`]})]})]},c.id))]})}function $l({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 T7({messages:e,navigate:t,conversationId:n,agentId:a}){const i=e.slice(-8).reverse();return i.length===0?null:o.jsxs("div",{className:"s-profile-signals",children:[o.jsx($l,{label:"Recent signal",right:"last 1h"}),o.jsx("div",{className:"s-profile-signal-list",children:i.map(c=>{const f=c.class==="ask"||c.body?.toLowerCase().startsWith("@")?"ASK":"MESSAGE";return o.jsxs("div",{className:"s-profile-signal",onClick:()=>{n&&t({view:"agents",agentId:a,conversationId:n})},children:[o.jsx("div",{className:"s-profile-signal-avatar",style:{background:ct(c.actorName??"?")},children:(c.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:f}),o.jsx("span",{className:"s-profile-signal-sep",children:"·"}),o.jsx("span",{className:"s-profile-signal-routing",children:c.actorName}),o.jsx("span",{className:"s-profile-signal-time",children:Pe(c.createdAt)})]}),o.jsx("div",{className:"s-profile-signal-text",children:c.body})]})]},c.id)})})]})}function A7({agent:e,allAgents:t,session:n,conversationId:a,navigate:i,activeTab:c}){const{name:u,qualifier:f}=N7(e,t),[m,h]=v.useState([]),[g,x]=v.useState([]),[b,w]=v.useState(null),[j,N]=v.useState(null),[T,k]=v.useState(!1),[C,S]=v.useState(null),R=mt(e.state),A=jf(),_=v.useCallback(async()=>{const[G,K]=await Promise.allSettled([Oe(`/api/work?agentId=${encodeURIComponent(e.id)}`),Oe("/api/fleet")]);G.status==="fulfilled"&&h(G.value),K.status==="fulfilled"&&w(K.value)},[e.id]),O=v.useCallback(async()=>{if(!a){x([]);return}try{const G=await Oe(`/api/messages?conversationId=${encodeURIComponent(a)}&limit=20`);x(G)}catch{x([])}},[a]),V=v.useCallback(async()=>{k(!0);try{const G=await Oe(`/api/agents/${encodeURIComponent(e.id)}/observe`);N(G)}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{k(!1)}},[e.id]);v.useEffect(()=>{_(),O(),Oe(`/api/agents/${encodeURIComponent(e.id)}/session-catalog`).then(S).catch(()=>{})},[_,O,e.id]),v.useEffect(()=>{N(null),k(!1)},[e.id]),v.useEffect(()=>{c==="observe"&&V()},[c,V]),An(()=>{_(),O(),c==="observe"&&V()}),v.useEffect(()=>{if(c!=="observe"||!j?.data.live)return;const G=setInterval(()=>{V()},2500);return()=>clearInterval(G)},[c,j?.data.live,V]);const Z=m.find(G=>G.state==="working"||G.state==="review"),I=m.filter(G=>G.state==="working"||G.state==="review"||G.state==="waiting"),$=m.filter(G=>G.state==="done").slice(0,5),L=fj(e.role)??fj(e.agentClass),P=e.harness,q=[L,P].filter(Boolean).filter((G,K,z)=>z.indexOf(G)===K),ee=v.useMemo(()=>t.filter(G=>G.project===e.project).length,[t,e.project]),D=Z?.currentPhase==="review"?85:Z?.currentPhase==="working"?50:20,U=[{key:"profile",label:"Profile"},{key:"observe",label:"Observe"},{key:"message",label:"Message",disabled:!a}],B=G=>{i({view:"agents",agentId:e.id,...a?{conversationId:a}:{},tab:G})};return o.jsxs("div",{className:`s-profile-center${c!=="profile"?" s-profile-center--tabbed":""}`,children:[o.jsx("button",{type:"button",className:"s-back s-profile-mobile-back",onClick:()=>i({view:"agents"}),children:"← All agents"}),o.jsx("section",{className:"s-profile-identity",onContextMenu:G=>{const K=window.getSelection()?.toString().trim(),z=[];K&&(z.push({kind:"action",label:"Copy Selection",shortcut:"⌘C",onSelect:()=>navigator.clipboard.writeText(K)}),z.push({kind:"separator"})),z.push({kind:"action",label:"Copy Agent Name",onSelect:()=>navigator.clipboard.writeText(u)}),z.push({kind:"action",label:"Copy Agent ID",onSelect:()=>navigator.clipboard.writeText(e.id)}),e.handle&&z.push({kind:"action",label:`Copy @${e.handle}`,onSelect:()=>navigator.clipboard.writeText(`@${e.handle}`)}),A(G,z)},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:ct(e.name)},children:e.name[0].toUpperCase()}),o.jsx("span",{className:`s-profile-identity-pulse s-profile-identity-pulse--${R}`,style:{background:Ra(e.state)}})]}),o.jsxs("div",{className:"s-profile-identity-copy",children:[q.length>0&&o.jsx("div",{className:"s-profile-identity-eyebrow",children:q.join(" · ")}),o.jsxs("h1",{className:"s-profile-identity-name",children:[u,f&&o.jsx("span",{className:"s-profile-identity-name-qualifier",children:f}),e.handle&&o.jsxs("span",{className:"s-profile-identity-name-handle",children:["@",e.handle]})]}),o.jsx("div",{className:"s-profile-identity-state-row",children:o.jsxs("span",{className:"s-profile-identity-state",children:[o.jsx("span",{className:`s-profile-identity-state-dot${R==="working"?" s-profile-identity-state-dot--pulse":""}`,style:{background:Ra(e.state)}}),o.jsx("span",{className:"s-profile-identity-state-label",children:aa(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:U.map(G=>o.jsx("button",{type:"button",className:`s-profile-tab${c===G.key?" s-profile-tab--active":""}`,disabled:G.disabled,onClick:()=>B(G.key),children:G.label},G.key))})]})}),c==="profile"&&o.jsxs("div",{className:"s-profile-tab-content",children:[(e.project||e.branch||e.cwd||C?.activeSessionId)&&o.jsxs("div",{className:"s-profile-facets",children:[e.project&&o.jsxs("div",{className:"s-profile-facet",children:[o.jsx("div",{className:"s-profile-facet-label",children:"Workspace"}),o.jsx("div",{className:"s-profile-facet-value",children:e.project}),ee>1&&o.jsxs("div",{className:"s-profile-facet-detail",children:[ee," 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)]})]}),C?.activeSessionId&&o.jsx(E7,{catalog:C,agentId:e.id})]}),Z&&R==="working"&&o.jsxs(o.Fragment,{children:[o.jsx($l,{label:"Current task",right:`${D}% · live`}),o.jsxs("div",{className:"s-profile-task",children:[o.jsx("div",{className:"s-profile-task-title",children:Z.title}),Z.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:`${D}%`}})}),o.jsxs("div",{className:"s-profile-task-action",children:[o.jsx("span",{className:"s-profile-task-action-chevron",children:"›"}),o.jsx("span",{children:Z.lastMeaningfulSummary}),o.jsx("span",{className:"s-profile-task-cursor"})]})]}),o.jsxs("div",{className:"s-profile-task-meta",children:[o.jsx("span",{children:Z.currentPhase}),o.jsx("span",{children:Pe(Z.lastMeaningfulAt)})]})]})]}),I.length>0&&o.jsxs(o.Fragment,{children:[o.jsx($l,{label:"Active work",right:`${I.length} in flight`}),o.jsx("div",{className:"s-profile-work",children:o.jsx(ij,{items:I,navigate:i,emptyTitle:"Nothing in flight"})})]}),$.length>0&&o.jsxs(o.Fragment,{children:[o.jsx($l,{label:I.length>0?"Recently completed":"Recent work",right:`${$.length}`}),o.jsx("div",{className:"s-profile-work",children:o.jsx(ij,{items:$,navigate:i,emptyTitle:""})})]}),o.jsx($l,{label:"Activity"}),o.jsx("div",{className:"s-profile-work",children:o.jsx(C7,{agent:e,fleet:b,navigate:i})}),o.jsx(T7,{messages:g,navigate:i,conversationId:a,agentId:e.id})]}),c==="observe"&&o.jsx("div",{className:"s-profile-tab-conversation",children:T&&!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(MT,{data:j?.data,agentId:e.id,sessionId:j?.sessionId})}),c==="message"&&a&&o.jsx("div",{className:"s-profile-tab-conversation",children:o.jsx(Dg,{conversationId:a,navigate:i,embedded:!0})})]})}function R7({navigate:e,selectedAgentId:t,conversationId:n,tab:a}){const{agents:i}=kt(),[c,u]=v.useState([]),f=v.useCallback(async()=>{const x=await Oe("/api/sessions").catch(()=>null);x&&u(x)},[]);v.useEffect(()=>{f()},[f]),An(()=>{f()});const m=t?i.find(x=>x.id===t)??null:null,{conversationByAgentId:h,sessionByAgentId:g}=k7(c);if(m){const x=n??h.get(m.id)??m.conversationId??null,b=a??(n?"message":"profile");return o.jsx(A7,{agent:m,allAgents:i,session:g.get(m.id)??null,conversationId:x,navigate:e,activeTab:b})}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:"Select an agent"}),o.jsx("p",{className:"s-profile-empty-copy",children:"Pick an agent from the sidebar to view its profile, current work, and session context."})]})})}function M7(e){switch(e){case"queued":case"working":return"working";case"needs_attention":return"updated";case"failed":return"failed";default:return"completed"}}function _7(e){switch(e){case"completed":return"completed";case"failed":case"cancelled":return"failed";case"waiting":return"updated";default:return"working"}}function O7(e){return e.replace(/[_-]/g," ")}function I7(e,t){return e.summary?.trim()||t?.summary?.trim()||t?.task?.trim()||"No flight summary yet."}function D7(e,t){if(typeof e!="number")return"duration unknown";const n=e<1e12?e*1e3:e,a=Math.max(0,t-n),i=Math.floor(a/1e3);if(i<5)return"just started";if(i<60)return`${i}s`;const c=Math.floor(i/60);if(c<60)return`${c}m`;const u=Math.floor(c/60);return u<24?`${u}h ${c%60}m`:`${Math.floor(u/24)}d ${u%24}h`}function z7(e){return e.conversationId?{view:"conversation",conversationId:e.conversationId}:{view:"agents",agentId:e.agentId}}function L7(e){return e.collaborationRecordId?{view:"work",workId:e.collaborationRecordId}:e.conversationId?{view:"conversation",conversationId:e.conversationId}:{view:"agents",agentId:e.agentId}}function $7(e){return 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}function P7(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 Ml({title:e,detail:t}){return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"s-dashboard-panel-header",children:o.jsx("div",{children:o.jsx("h3",{children:e})})}),o.jsx("p",{className:"s-dashboard-panel-copy",children:t})]})}function hj({ask:e,navigate:t,section:n}){const a=z7(e),i=e.completedAt?`finished ${Pe(e.completedAt)}`:e.startedAt?`started ${Pe(e.startedAt)}`:`updated ${Pe(e.updatedAt)}`;return o.jsxs("div",{className:`s-work-row s-work-row-clickable s-dashboard-fleet-row s-dashboard-fleet-row-${n}`,"data-status":e.status,onClick:()=>t(a),children:[o.jsxs("div",{className:"s-work-row-header",children:[o.jsxs("div",{className:"s-fleet-row-title-wrap",children:[o.jsx("div",{className:"s-avatar s-avatar-sm",style:{background:ct(e.agentName??e.agentId)},children:(e.agentName??e.agentId)[0]?.toUpperCase()??"?"}),o.jsxs("div",{className:"s-fleet-row-title-copy",children:[o.jsxs("div",{className:"s-work-row-title-wrap",children:[o.jsx("span",{className:"s-work-row-title",children:e.agentName??e.agentId}),e.harness&&o.jsx("span",{className:"s-badge",children:e.harness})]}),o.jsxs("div",{className:"s-work-row-meta",style:{marginTop:2},children:[o.jsx("span",{className:"s-dot",style:{background:Ra(e.agentState)}}),o.jsx("span",{children:aa(e.agentState)}),o.jsx("span",{children:i})]})]})]}),o.jsx("span",{className:`s-pill s-pill-${M7(e.status)}`,children:e.statusLabel})]}),o.jsx("p",{className:"s-work-row-summary",children:ks(e.task)}),e.summary&&o.jsx("p",{className:"s-work-row-summary",style:{marginTop:8},children:ks(e.summary)})]})}function U7({item:e,navigate:t}){const n=$7(e),a=e.kind==="question"?"question":e.state.replace(/_/g," "),i=e.acceptanceState!=="none"?e.acceptanceState.replace(/_/g," "):e.kind==="question"?"awaiting answer":"your move";return o.jsxs("div",{className:`s-work-row s-dashboard-fleet-row s-dashboard-fleet-attention-row${n?" s-work-row-clickable":""}`,onClick:n?()=>t(n):void 0,children:[o.jsx("div",{className:"s-work-row-header",children:o.jsx("div",{className:"s-work-row-title-wrap",children:o.jsx("span",{className:"s-work-row-title",children:e.title})})}),o.jsxs("div",{className:"s-work-row-meta",children:[e.kind==="work_item"&&o.jsx("span",{children:"work item"}),e.agentName&&o.jsx("span",{children:e.agentName}),o.jsx("span",{children:a}),o.jsx("span",{children:i}),o.jsx("span",{children:Pe(e.updatedAt)})]}),e.summary&&o.jsx("p",{className:"s-work-row-summary",children:ks(e.summary)})]})}function B7({flight:e,navigate:t,nowMs:n,description:a}){const i=L7(e),c=e.agentName??e.agentId,u=O7(e.state),f=D7(e.startedAt,n),m=typeof e.startedAt=="number"&&f!=="just started"?`in flight for ${f}`:f;return o.jsxs("div",{className:"s-work-row s-work-row-clickable s-dashboard-fleet-row s-dashboard-flight-row","data-status":e.state,onClick:()=>t(i),children:[o.jsxs("div",{className:"s-work-row-header",children:[o.jsxs("div",{className:"s-fleet-row-title-wrap",children:[o.jsx("div",{className:"s-avatar s-avatar-sm",style:{background:ct(c)},children:c[0]?.toUpperCase()??"?"}),o.jsxs("div",{className:"s-fleet-row-title-copy",children:[o.jsx("div",{className:"s-work-row-title-wrap",children:o.jsx("span",{className:"s-work-row-title",children:c})}),o.jsxs("div",{className:"s-work-row-meta",style:{marginTop:2},children:[o.jsx("span",{children:m}),e.conversationId&&o.jsx("span",{children:"conversation linked"}),e.collaborationRecordId&&o.jsx("span",{children:"work linked"})]})]})]}),o.jsx("span",{className:`s-pill s-pill-${_7(e.state)}`,children:u})]}),o.jsx("p",{className:"s-work-row-summary",children:ks(a)})]})}function V7({item:e,navigate:t}){const n=P7(e),a=e.actorName??"system",i=e.agentId&&e.agentId!==e.actorName?e.agentId:null;return o.jsxs("div",{className:`s-dashboard-activity-row${n?" s-dashboard-activity-row-clickable":""}`,onClick:n?()=>t(n):void 0,children:[o.jsx("div",{className:"s-avatar s-avatar-sm",style:{background:ct(a)},children:a[0]?.toUpperCase()??"S"}),o.jsxs("div",{className:"s-dashboard-activity-actors",children:[o.jsx("span",{className:"s-dashboard-activity-actor",children:a}),i&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"s-dashboard-activity-arrow","aria-hidden":"true",children:"→"}),o.jsx("span",{className:"s-dashboard-activity-recipient",children:i})]})]}),o.jsx("span",{className:"s-dashboard-activity-kind",children:fH(e.kind)}),o.jsx("span",{className:"s-dashboard-activity-time",children:Pe(e.ts)}),(e.title||e.summary)&&o.jsx("p",{className:"s-dashboard-activity-summary",children:ks(e.title??e.summary??"")})]})}function H7({navigate:e}){const[t,n]=v.useState(null),[a,i]=v.useState([]),[c,u]=v.useState(()=>Date.now()),f=v.useCallback(async()=>{const[j,N]=await Promise.allSettled([Oe("/api/fleet"),Oe("/api/flights")]);j.status==="fulfilled"?n(j.value):n(null),N.status==="fulfilled"?i(N.value):i([])},[]);v.useEffect(()=>{f()},[f]),An(()=>{f()}),v.useEffect(()=>{const j=setInterval(()=>u(Date.now()),15e3);return()=>clearInterval(j)},[]);const m=t?.activeAsks??[],h=t?.recentCompleted??[],g=t?.needsAttention??[],x=t?.activity??[],b=new Map(m.map(j=>[j.invocationId,j])),w=g.length>0?`${g.length} item${g.length===1?" is":"s are"} waiting on you. Clear ${g.length===1?"it":"those"} first, then monitor the rest of the queue.`:a.length>0?`${a.length} flight${a.length===1?" is":"s are"} active across the fleet. The queue is clear of interruptions.`:m.length>0?`${m.length} ask${m.length===1?" is":"s are"} currently in flight. The queue is clear of interruptions.`:h.length>0?"Nothing is actively running right now. Recent finishes are ready for review.":"No asks have moved through the fleet yet. Start work and this becomes the operations board.";return o.jsxs("div",{className:"s-home s-dashboard-screen s-dashboard-fleet",children:[o.jsx("div",{className:"s-dashboard-hero s-dashboard-hero-fleet",children:o.jsxs("div",{className:"s-dashboard-hero-copy",children:[o.jsxs("div",{className:"s-dashboard-hero-head",children:[o.jsx("h2",{children:"Fleet"}),t&&o.jsxs("span",{className:"s-time",children:["Updated ",Pe(t.generatedAt)]})]}),o.jsx("p",{children:w}),o.jsxs("div",{className:"s-dashboard-summary-grid",children:[o.jsxs("div",{className:`s-dashboard-summary-card${(t?.totals.needsAttention??0)>0?" s-dashboard-summary-card-attention":""}`,children:[o.jsx("div",{className:"s-dashboard-summary-label",children:"Needs input"}),o.jsx("div",{className:"s-dashboard-summary-value",children:t?.totals.needsAttention??0}),o.jsx("div",{className:"s-dashboard-summary-meta",children:"Questions, reviews, or decisions waiting on you"})]}),o.jsxs("div",{className:"s-dashboard-summary-card",children:[o.jsx("div",{className:"s-dashboard-summary-label",children:"Active flights"}),o.jsx("div",{className:"s-dashboard-summary-value",children:a.length}),o.jsx("div",{className:"s-dashboard-summary-meta",children:"Tasks currently running or queued on agents"})]}),o.jsxs("div",{className:`s-dashboard-summary-card${(t?.totals.recentCompleted??0)>0?" s-dashboard-summary-card-finished":""}`,children:[o.jsx("div",{className:"s-dashboard-summary-label",children:"Finished"}),o.jsx("div",{className:"s-dashboard-summary-value",children:t?.totals.recentCompleted??0}),o.jsx("div",{className:"s-dashboard-summary-meta",children:"Recent completions and failures to review"})]}),o.jsxs("div",{className:"s-dashboard-summary-card",children:[o.jsx("div",{className:"s-dashboard-summary-label",children:"Activity"}),o.jsx("div",{className:"s-dashboard-summary-value",children:t?.totals.activity??0}),o.jsx("div",{className:"s-dashboard-summary-meta",children:"Recent events across the fleet"})]})]})]})}),o.jsxs("div",{className:"s-dashboard-fleet-stack",children:[o.jsxs("section",{className:`s-dashboard-panel${g.length>0?" s-dashboard-panel-attention":""}`,children:[o.jsx(Ml,{title:"Needs your input",detail:"Handle interruptions, pending answers, and review requests first."}),g.length===0?o.jsxs("div",{className:"s-empty",children:[o.jsx("p",{children:"Nothing is waiting on you"}),o.jsx("p",{children:"When agents ask a question or a work item needs review, it will land here first."})]}):o.jsx("div",{className:"s-work-list",children:g.map(j=>o.jsx(U7,{item:j,navigate:e},j.recordId))})]}),o.jsxs("section",{className:"s-dashboard-panel s-dashboard-panel-flights",children:[o.jsx(Ml,{title:"In-flight agents",detail:"Agents with active flights right now, including how long each task has been in flight."}),a.length===0?o.jsxs("div",{className:"s-empty",children:[o.jsx("p",{children:"No agents in flight"}),o.jsx("p",{children:"Active flights will appear here as soon as an agent starts, queues, or waits on a task."})]}):o.jsx("div",{className:"s-work-list",children:a.map(j=>o.jsx(B7,{flight:j,navigate:e,nowMs:c,description:I7(j,b.get(j.invocationId))},j.id))})]}),o.jsxs("div",{className:"s-dashboard-fleet-columns",children:[o.jsxs("section",{className:"s-dashboard-panel s-dashboard-panel-active",children:[o.jsx(Ml,{title:"Active asks",detail:"The asks still in flight across the fleet."}),m.length===0?o.jsxs("div",{className:"s-empty",children:[o.jsx("p",{children:"No active asks"}),o.jsx("p",{children:"New agent work will appear here while it is still in progress."})]}):o.jsx("div",{className:"s-work-list",children:m.map(j=>o.jsx(hj,{ask:j,navigate:e,section:"active"},j.invocationId))})]}),o.jsxs("section",{className:"s-dashboard-panel s-dashboard-panel-finished",children:[o.jsx(Ml,{title:"Recent finishes",detail:"Review completions and failures once the active queue is stable."}),h.length===0?o.jsxs("div",{className:"s-empty",children:[o.jsx("p",{children:"No recent finishes"}),o.jsx("p",{children:"Completed asks and failures will show up here once they settle."})]}):o.jsx("div",{className:"s-work-list",children:h.map(j=>o.jsx(hj,{ask:j,navigate:e,section:"finished"},j.invocationId))})]})]}),o.jsxs("section",{className:"s-dashboard-panel s-dashboard-panel-activity",children:[o.jsx(Ml,{title:"Recent activity",detail:"The broader event stream behind the queue."}),x.length===0?o.jsxs("div",{className:"s-empty",children:[o.jsx("p",{children:"No recent fleet activity"}),o.jsx("p",{children:"Messages, asks, and other agent activity will stream here."})]}):o.jsx("div",{className:"s-dashboard-activity-feed",children:x.slice(0,20).map(j=>o.jsx(V7,{item:j,navigate:e},j.id))})]})]})]})}function Z7(e){return e<5?"Still up":e<12?"Good morning":e<18?"Good afternoon":"Good evening"}function F7({navigate:e}){const{agents:t,onboarding:n}=kt(),[a,i]=v.useState([]),[c,u]=v.useState([]),[f,m]=v.useState(null),[h,g]=v.useState([]),[x,b]=v.useState("trailing 7d"),[w,j]=v.useState("3h buckets"),N=v.useRef(null),T=v.useCallback(async()=>{const[P,q,ee,D]=await Promise.allSettled([Oe("/api/activity"),Oe("/api/sessions"),Oe("/api/fleet"),Oe("/api/heartrate")]);P.status==="fulfilled"&&i(P.value),q.status==="fulfilled"&&u([...q.value].sort((U,B)=>(B.lastMessageAt??0)-(U.lastMessageAt??0))),ee.status==="fulfilled"&&m(ee.value),D.status==="fulfilled"&&(g(D.value.buckets),b(D.value.windowLabel),j(D.value.bucketLabel??""))},[]),k=v.useCallback(()=>{N.current||(N.current=setTimeout(()=>{N.current=null,T()},250))},[T]);v.useEffect(()=>(T(),()=>{N.current&&clearTimeout(N.current)}),[T]),An(k);const C=v.useMemo(()=>t.filter(P=>mt(P.state)==="working"),[t]),S=v.useMemo(()=>t.filter(P=>mt(P.state)==="available"),[t]),R=v.useMemo(()=>t.filter(P=>mt(P.state)==="offline"),[t]),A=v.useMemo(()=>(f?.activeAsks??[]).filter(P=>P.status==="needs_attention"||P.status==="queued"),[f]),_=v.useMemo(()=>(f?.recentCompleted??[]).slice(0,3),[f]),O=v.useMemo(()=>a.slice(0,8),[a]),V=new Date,Z=Z7(V.getHours()),I=bc(),$=n?.operatorName?.trim()||n?.operatorNameSuggestion?.trim()||"operator",L=v.useMemo(()=>{const P=[];return C.length>0&&P.push(`${C.length} agent${C.length===1?" is":"s are"} working now`),A.length>0&&P.push(`${A.length} thing${A.length===1?"":"s"} need${A.length===1?"s":""} you`),_.length>0&&P.push(`${_.length} ask${_.length===1?" was":"s were"} resolved recently`),P.length===0&&t.length>0&&P.push(`${t.length} agent${t.length===1?" is":"s are"} registered`),P.length===0&&P.push("no agents are connected yet"),P},[C,A,_,t]);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 ·"," ",V.toLocaleDateString([],{weekday:"long",month:"short",day:"numeric"})]}),o.jsxs("h1",{className:"s-hero-greeting",children:[Z,", ",o.jsxs("em",{children:[$,"."]})]}),o.jsxs("p",{className:"s-hero-narrative",children:[L.map((P,q)=>o.jsxs("span",{children:[q>0&&", ",P.includes("need")?o.jsx("span",{className:"s-hero-warn",children:P}):o.jsx("strong",{children:P})]},q)),"."]}),o.jsxs("div",{className:"s-hero-actions",children:[A.length>0&&o.jsxs("button",{className:"s-btn-fleet s-btn-fleet--primary",onClick:()=>e({view:"fleet"}),children:["Answer asks · ",A.length]}),I&&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("div",{className:"s-heartrate-card",children:[o.jsxs("div",{className:"s-heartrate-header",children:[o.jsx("span",{className:"s-eyebrow",children:"Fleet heart-rate"}),o.jsx("span",{style:{flex:1}}),o.jsxs("span",{className:"s-heartrate-live",children:["● ",x,w?` · ${w}`:""]})]}),o.jsx(Y7,{buckets:h}),o.jsxs("div",{className:"s-heartrate-stats",children:[o.jsx(Ap,{label:"Active",value:C.length,color:"var(--green)"}),o.jsx(Ap,{label:"Waiting",value:S.length,color:"var(--amber)"}),o.jsx(Ap,{label:"Done",value:R.length,color:"var(--dim)"})]})]})]}),o.jsxs("div",{className:"s-fleet-section",children:[o.jsx(Rp,{label:`Needs you · ${A.length}`,right:A.length>0?o.jsxs("span",{style:{color:"var(--amber)"},children:["oldest"," ",Pe(Math.min(...A.map(P=>P.updatedAt)))]}):"clear"}),o.jsxs("div",{className:"s-ask-grid",children:[A.slice(0,4).map(P=>o.jsx(mj,{ask:P,agents:t,navigate:e,operatorName:$,pending:!0},P.invocationId)),_.slice(0,Math.max(0,2-A.length)).map(P=>o.jsx(mj,{ask:P,agents:t,navigate:e,operatorName:$,pending:!1},P.invocationId)),A.length<2&&_.length===0&&o.jsxs("div",{className:"s-ask-empty",children:[o.jsx("span",{className:"s-eyebrow",children:"No more asks"}),o.jsx("span",{className:"s-ask-empty-detail",children:"Fleet is unblocked on you."})]})]})]}),C.length>0&&o.jsxs("div",{className:"s-fleet-section",children:[o.jsx(Rp,{label:`What's moving · ${C.length} active`,right:o.jsx("button",{className:"s-link-btn",onClick:()=>e({view:"mesh"}),children:"open mesh ↗"})}),o.jsx("div",{className:"s-now-grid",style:{gridTemplateColumns:`repeat(${Math.min(C.length,3)}, 1fr)`},children:C.map(P=>o.jsx(G7,{agent:P,navigate:e},P.id))})]}),O.length>0&&o.jsxs("div",{className:"s-fleet-section",children:[o.jsx(Rp,{label:"Since you were away",right:`last hour · ${O.length} events`}),o.jsx(W7,{items:O,agents:t,navigate:e})]})]})})}function q7(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 a=e[Math.max(0,n-1)],i=e[n],c=e[n+1],u=e[Math.min(e.length-1,n+2)],f={x:i.x+(c.x-a.x)/6,y:i.y+(c.y-a.y)/6},m={x:c.x-(u.x-i.x)/6,y:c.y-(u.y-i.y)/6};t.push(`C ${f.x.toFixed(1)} ${f.y.toFixed(1)}, ${m.x.toFixed(1)} ${m.y.toFixed(1)}, ${c.x.toFixed(1)} ${c.y.toFixed(1)}`)}return t.join(" ")}function Y7({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 m=372/(u-1),h=e.map((b,w)=>({x:w*m,y:60-Math.max(0,Math.min(1,b.value))*54})),g=q7(h),x=`${g} 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:x,fill:"url(#hrFill)"}),o.jsx("path",{d:g,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 Ap({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 Rp({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 mj({ask:e,agents:t,navigate:n,operatorName:a,pending:i}){const u=t.find(m=>m.id===e.agentId)?.name??e.agentName??e.agentId,f=e.conversationId?{view:"conversation",conversationId:e.conversationId}:{view:"agents",agentId:e.agentId};return o.jsxs("div",{className:`s-ask-block${i?" s-ask-block--pending":""}`,style:{cursor:"pointer"},onClick:()=>n(f),children:[o.jsxs("div",{className:"s-ask-header",children:[o.jsx("span",{className:"s-eyebrow s-ask-label",children:i?"◌ ASK — AWAITING":"● ASK — RESOLVED"}),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:ct(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:a})]}),o.jsxs("div",{className:"s-ask-text",children:['"',e.summary??e.task,'"']})]})]}),i&&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 G7({agent:e,navigate:t}){const n=e.handle?`@${e.handle}`:e.id,a=e.role??e.agentClass,i=e.branch??"main",c=os(e.id);return o.jsxs("div",{className:"s-now-card",onClick:()=>t({view:"agents",agentId:e.id,conversationId:c,tab:"observe"}),children:[o.jsxs("div",{className:"s-now-card-head",children:[o.jsx("div",{className:"s-avatar s-avatar-sm",style:{background:ct(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:[n," · ",a]})]}),o.jsx("span",{className:"s-now-card-live",children:"● live"})]}),o.jsx("div",{className:"s-now-card-task",children:e.cwd??`Working in ${e.project??"workspace"}`}),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:"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:i})]})]})}function W7({items:e,agents:t,navigate:n}){const a=[...e].sort((u,f)=>f.ts-u.ts),i={"collaboration.ask":"?","message.sent":"·","message.received":"·","flight.started":"⌘","flight.completed":"⌘","agent.online":"→","agent.offline":"→","agent.registered":"→","collaboration.answer":"↳"},c={"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"}),a.map(u=>{const f=u.actorName??"system",m=c[u.kind]??"var(--dim)",h=i[u.kind]??"·",g=u.kind.split(".").pop()??u.kind,x=u.conversationId?{view:"conversation",conversationId:u.conversationId}:null;return o.jsxs("div",{className:"s-timeline-row",style:{cursor:x?"pointer":void 0},onClick:x?()=>n(x):void 0,children:[o.jsx("div",{className:"s-timeline-bead",style:{background:m}}),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:m},children:h}),o.jsx("div",{className:"s-avatar",style:{width:18,height:18,fontSize:9,background:ct(f)},children:f[0]?.toUpperCase()??"?"}),o.jsx("span",{className:"s-timeline-handle",children:f})]}),o.jsx("span",{className:"s-timeline-text",children:u.title??u.summary??""}),o.jsx("span",{className:"s-timeline-kind",children:g})]},u.id)})]})}const X7=v.lazy(()=>cd(()=>import("./arc.es-DgeMPL-I.js"),[]).then(e=>({default:e.ArcDiagram})));function ti(e){if(!e)return"";const t=e.replace(/^https?:\/\//,"").split("/")[0],[n]=t.split(":");return n.split(".")[0]}function K7(e){const t=e.hostName?.trim();if(t&&t.toLowerCase()!=="localhost")return ti(t)||t;const n=e.dnsName?.trim().replace(/\.$/,"");return n?ti(n)||n:ti(e.name)||e.name}function zg(e){if(!e)return"";const t=e.replace(/^https?:\/\//,"").split("/")[0],[n]=t.split(":");return n.replace(/\.$/,"").toLowerCase()}function ar(e){const t=zg(e);return t?t.split(".")[0]??t:""}function J7(e){return e.brokerUrl?ti(e.brokerUrl):e.hostName?ti(e.hostName):e.id.slice(0,10)}function Q7(e,t){return Math.abs(e)>=Math.abs(t)?e>=0?["right","left"]:["left","right"]:t>=0?["bottom","top"]:["top","bottom"]}function eZ(e,t){const n=ar(t.hostName||t.name),a=ar(e.localNode?.hostName||e.localNode?.name);return!!a&&n===a}function tZ(e,t){const n=new Set([ar(e.hostName),ar(e.name),...e.addresses.map(i=>zg(i)),...e.addresses.map(i=>ar(i))].filter(Boolean)),a=new Set([ar(t.hostName),ar(t.name),zg(t.brokerUrl),ar(t.brokerUrl)].filter(Boolean));for(const i of n)if(a.has(i))return!0;return!1}function nZ(e){if(!e.localNode)return null;const t=e.localNode.id,n=Object.values(e.nodes).filter(b=>b.id!==t),a=e.tailscale.peers.filter(b=>!eZ(e,b)).filter(b=>!n.some(w=>tZ(b,w))),i=[...n.map(b=>({kind:"mesh",peer:b})),...a.map(b=>({kind:"tailnet",peer:b}))],c=800,u=300,f=c/2,m=u/2,h={[t]:{x:f,y:m,size:"m"}},g={[t]:{icon:"Database",name:ti(e.localNode.hostName)||e.localNode.name||"broker",subtitle:"this node",color:"violet"}},x=[];if(i.length===0)h.__placeholder={x:f+220,y:m,size:"m"},g.__placeholder={icon:"CircleDashed",name:"No peers yet",subtitle:"awaiting discovery",color:"zinc"},x.push({from:t,to:"__placeholder",fromAnchor:"right",toAnchor:"left",style:"pending"});else{const b=i.length,w=Math.min(170,100+b*10);i.forEach(({kind:j,peer:N},T)=>{const k=T/b*Math.PI*2-Math.PI/2,C=Math.round(f+w*Math.cos(k)),S=Math.round(m+w*Math.sin(k)),R=j==="mesh"?N.id:`tailnet:${N.id}`,A=j==="mesh"?ti(N.hostName)||N.name||"peer":K7(N)||"tailnet",_=j==="mesh"?J7(N):N.online?N.addresses[0]??"tailnet only":"tailnet offline";h[R]={x:C,y:S,size:j==="mesh"?"m":"s"},g[R]={icon:j==="mesh"?"Database":"CircleDashed",name:A,subtitle:_,color:j==="mesh"?N.advertiseScope==="mesh"?"emerald":"zinc":N.online?"sky":"zinc"};const[O,V]=Q7(C-f,S-m);x.push({from:t,to:R,fromAnchor:O,toAnchor:V,style:j==="mesh"?N.advertiseScope==="mesh"?"mesh":"local":N.online?"tailnet":"tailnet-offline"})})}return{layout:{width:c,height:u},nodes:h,nodeData:g,connectors:x,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 sZ({mesh:e}){const t=v.useMemo(()=>nZ(e),[e]);return t?o.jsx("div",{className:"s-mesh-topology",children:o.jsx(v.Suspense,{fallback:o.jsx("div",{className:"s-mesh-topology-fallback"}),children:o.jsx(X7,{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 aZ(e){return e.code==="local_only"?"notice":e.severity==="error"?"error":"warning"}function rZ(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 iZ(e){return e?e.replace(/^https?:\/\//,"").split("/")[0]??e:"Unavailable"}function oZ(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 lZ(e){return e==="mesh"?"Announced to mesh":e==="local"?"Local only":e||"Not advertised"}function cZ(e){return e.identity.discoverable?"success":e.health.reachable?"warning":"danger"}function uZ(e){return e.identity.discoverable?"Discoverable":e.health.reachable?"Not discoverable":"Broker offline"}function dZ(e){return!e.health.reachable||e.issues.some(t=>t.severity==="error")?"danger":e.issues.length>0?"warning":"success"}function fZ(e){return e.health.reachable?e.issues.some(t=>t.severity==="error")?"Degraded":e.issues.length>0?"Needs attention":"Healthy":"Broker unreachable"}function hZ({issue:e}){const t=aZ(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:rZ(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 mZ({navigate:e}){const[t,n]=v.useState(null),[a,i]=v.useState(!0),[c,u]=v.useState(!1),[f,m]=v.useState(!1),[h,g]=v.useState(!1),[x,b]=v.useState(null),[w,j]=v.useState(null),[N,T]=v.useState(null),[k,C]=v.useState(null),S=v.useRef(null),R=v.useRef(0);v.useEffect(()=>{S.current=t},[t]);const A=v.useCallback(async(U="initial")=>{const B=++R.current;!(S.current!==null)&&U!=="background"?(i(!0),T(null)):u(!0);try{const K=await Oe("/api/mesh");if(B!==R.current)return;n(K),T(null),C(Date.now())}catch(K){if(B!==R.current)return;T(K instanceof Error?K.message:String(K))}finally{B===R.current&&(i(!1),u(!1))}},[]);v.useEffect(()=>{A("initial")},[A]),v.useEffect(()=>{const U=setInterval(()=>{A("background")},1e4);return()=>clearInterval(U)},[A]);const _=v.useCallback(async()=>{m(!0),b(null);try{const U=await Oe("/api/mesh/announce",{method:"POST",body:"{}"});n(U),S.current=U,T(null),C(Date.now()),b({tone:U.identity.discoverable?"success":"warning",title:U.identity.discoverable?"Mesh updated.":"Mesh updated, but still needs attention.",message:U.identity.discoverable?"This broker is now announced to the mesh.":"Mesh visibility was updated, but this broker still is not peer-reachable."})}catch(U){b({tone:"warning",title:"Could not announce broker.",message:U instanceof Error?U.message:String(U)})}finally{m(!1)}},[]),O=v.useCallback(async()=>{g(!0),j(null);try{const U=await Oe("/api/mesh/tailscale",{method:"POST",body:JSON.stringify({action:"open_app"})});n(U),S.current=U,T(null),C(Date.now()),j({tone:U.tailscale.running?"success":"warning",title:U.tailscale.running?"Tailscale is running.":"Tailscale launch requested.",message:U.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(U){j({tone:"warning",title:"Could not open Tailscale.",message:U instanceof Error?U.message:String(U)})}finally{g(!1)}},[]),V=t?dZ(t):"warning",Z=t?fZ(t):"Loading",I=t?Object.values(t.nodes):[],$=t?.localNode?.id,L=t?.localNode?.hostName?.toLowerCase(),P=I.filter(U=>U.id!==$),q=(t?.tailscale.peers??[]).filter(U=>{const B=U.hostName?.toLowerCase();return!B||B==="localhost"?!0:!(L&&(B===L||B.startsWith(`${L.split(".")[0]}.`)))}),ee=t?t.issues.length>0?t.issues:t.warnings.map((U,B)=>({code:`fallback-${B}`,severity:"warning",title:"Mesh notice",summary:U,action:null,actionCommand:null})):[],D=v.useMemo(()=>t?[{label:"Broker",value:t.health.reachable?"Reachable":"Unavailable",detail:t.health.error??iZ(t.brokerUrl)},{label:"Discoverable",value:t.identity.discoverable?"Yes":"No",detail:t.identity.modeLabel},{label:"Mesh peers",value:`${P.length}`,detail:P.length>0?"Remote brokers in this mesh":"No remote brokers discovered"},{label:"Tailnet",value:t.tailscale.available?t.tailscale.running?`${q.filter(U=>U.online).length}/${q.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"}]:[],[q,t,P.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-${V}`,children:Z}),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:a?"Loading system snapshot...":N&&t?`Showing last confirmed snapshot from ${k?Pe(k):"earlier"}`:k?`Confirmed ${Pe(k)}`:"Waiting for first snapshot"}),o.jsx("button",{type:"button",className:"s-btn",disabled:a||c,onClick:()=>{A("manual")},children:c?"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})]}),a&&!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."})]}),!a&&!t&&N&&o.jsxs("div",{className:"sys-panel sys-state-card sys-state-card-error",children:[o.jsx("h3",{className:"sys-state-title",children:"Mesh status is unavailable"}),o.jsx("p",{className:"sys-state-body",children:N}),o.jsx("div",{className:"sys-inline-actions",children:o.jsx("button",{type:"button",className:"s-btn",onClick:()=>{A("manual")},children:"Try again"})})]}),t&&o.jsxs(o.Fragment,{children:[o.jsxs("section",{className:"sys-panel sys-mesh-identity",children:[o.jsxs("div",{className:"sys-section-head",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"sys-section-title",children:"This broker"}),o.jsx("p",{className:"sys-section-subtitle",children:"The identity peers will learn if they discover this machine."})]}),o.jsx("span",{className:`sys-chip sys-chip-${cZ(t)}`,children:uZ(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:()=>{O()},children:h?"Opening Tailscale...":"Open Tailscale"}),o.jsx("button",{type:"button",className:"s-btn",disabled:h||c,onClick:()=>{A("manual")},children:c?"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:f,onClick:()=>{_()},children:f?"Announcing...":"Announce on mesh"})}),x&&o.jsxs("div",{className:`sys-banner ${x.tone==="success"?"sys-banner-success":"sys-banner-warning"}`,children:[o.jsx("strong",{children:x.title}),o.jsx("span",{children:x.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:D.map(U=>o.jsxs("div",{className:"sys-stat-card",children:[o.jsx("span",{className:"sys-stat-label",children:U.label}),o.jsx("strong",{className:"sys-stat-value",children:U.value}),o.jsx("span",{className:"sys-stat-detail",children:U.detail})]},U.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."})]})}),ee.length>0?o.jsx("div",{className:"sys-issue-grid",children:ee.map((U,B)=>o.jsx(hZ,{issue:U},`${U.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(sZ,{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","."]})]})}),P.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:P.map(U=>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:U.name}),o.jsx("span",{className:`sys-chip sys-chip-${U.advertiseScope==="mesh"?"success":"neutral"}`,children:lZ(U.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:U.id})]}),U.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:U.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:U.lastSeenAt?Pe(U.lastSeenAt):"Recently registered"})]})]},U.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."})]})}),q.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:q.map(U=>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:oZ(U)}),o.jsx("span",{className:`sys-chip sys-chip-${U.online?"success":"failed"}`,children:U.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:U.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:U.os??"Unknown"})]})]},U.id))})]})]})]})}const pZ=[[/```[\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 gZ(e,t=140){if(!e)return"";let n=e;for(const[a,i]of pZ)n=n.replace(a,i);return n=n.replace(/\s+/g," ").trim(),n.length>t&&(n=`${n.slice(0,t-1)}…`),n}function vZ(){const e=window.getSelection();return e!==null&&e.toString().trim().length>0}function yZ(e){vZ()||e()}const pj={direct:"DM",channel:"Channel",group_direct:"Group",thread:"Thread"},xZ=new Set(["all","direct","channel","group_direct","thread"]);function Lg(e){return typeof window>"u"?"":new URLSearchParams(window.location.search).get(e)??""}function bZ(e){if(typeof window>"u")return;const t=new URLSearchParams(window.location.search);for(const[a,i]of Object.entries(e))i===null||i===""?t.delete(a):t.set(a,i);const n=t.toString();window.history.replaceState(null,"",window.location.pathname+(n?`?${n}`:""))}function wZ(){const e=Lg("view");return xZ.has(e)?e:"all"}function SZ(e){return e.kind==="direct"&&e.agentName?e.agentName:e.title.replace(/\s*<>\s*/g," · ")}function jZ(e){return e.trim().toLowerCase()}function NZ(e){return[e.id,e.title,e.preview??"",e.agentName??"",e.harness??"",e.harnessSessionId??"",e.harnessLogPath??"",...e.participantIds]}function gj(e,t){if(!t)return null;const n=e.harnessSessionId?.trim();return n&&n.toLowerCase().includes(t)?n:null}function kZ(e){if(!e)return null;const t=e.replace(/[\\/]+$/,"");return t?t.split(/[\\/]/).filter(Boolean).at(-1)??t:null}function EZ(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 CZ({navigate:e}){const[t,n]=v.useState([]),[a,i]=v.useState(()=>wZ()),[c,u]=v.useState(()=>Lg("q")),[f,m]=v.useState(()=>Lg("unread")==="1"),[h,g]=v.useState(()=>Wv()),[x,b]=v.useState(0),[w,j]=v.useState(null),N=v.useRef(null),T=v.useRef(null),k=jf(),C=v.useCallback(async()=>{j(null);try{const L=await Oe("/api/sessions");n(L.sort((P,q)=>(q.lastMessageAt??0)-(P.lastMessageAt??0)))}catch(L){j(L instanceof Error?L.message:String(L))}},[]);v.useEffect(()=>{C()},[C]),An(()=>{C()});const[,S]=v.useState(0);v.useEffect(()=>{const L=setInterval(()=>S(P=>P+1),15e3);return()=>clearInterval(L)},[]),v.useEffect(()=>{bZ({view:a==="all"?null:a,q:c.trim()||null,unread:f?"1":null})},[a,c,f]);const R=v.useMemo(()=>Array.from(new Set(t.map(L=>L.kind))),[t]),A=v.useMemo(()=>{const L={all:t.length};for(const P of t)L[P.kind]=(L[P.kind]??0)+1;return L},[t]),_=v.useMemo(()=>jZ(c),[c]),O=v.useMemo(()=>t.filter(L=>Cp(L.lastMessageAt,L.id,h)).length,[t,h]),V=v.useMemo(()=>t.filter(L=>!(a!=="all"&&L.kind!==a||f&&!Cp(L.lastMessageAt,L.id,h)||_&&!NZ(L).some(q=>q.toLowerCase().includes(_)))),[t,a,f,h,_]);v.useEffect(()=>{x>=V.length&&b(Math.max(0,V.length-1))},[V.length,x]);const Z=v.useCallback((L,P={})=>{if(g(PH(L.id)),P.observe&&L.agentId){e({view:"agents",agentId:L.agentId,conversationId:L.id,tab:"observe"});return}e({view:"conversation",conversationId:L.id})},[e]);v.useEffect(()=>{function L(P){const q=P.target,ee=q instanceof HTMLInputElement||q instanceof HTMLTextAreaElement||q instanceof HTMLElement&&q.isContentEditable;if((P.metaKey||P.ctrlKey)&&P.key.toLowerCase()==="k"){P.preventDefault(),N.current?.focus(),N.current?.select();return}if(ee){P.key==="Escape"&&q===N.current&&N.current?.blur();return}if(P.key==="/"){P.preventDefault(),N.current?.focus();return}if(P.key==="j"||P.key==="ArrowDown"){P.preventDefault(),b(D=>Math.min(V.length-1,D+1));return}if(P.key==="k"||P.key==="ArrowUp"){P.preventDefault(),b(D=>Math.max(0,D-1));return}if(P.key==="Enter"||P.key==="o"){const D=V[x];D&&(P.preventDefault(),Z(D,{observe:!!gj(D,_)}))}}return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[V,x,Z,_]),v.useEffect(()=>{T.current?.querySelector(`[data-idx="${x}"]`)?.scrollIntoView({block:"nearest"})},[x]);const I=R.length>1,$=f?O>0?`${O} unread threads need attention.`:"No unread threads right now.":V.length===t.length?"Recent activity across every conversation.":`${V.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:[V.length," of ",t.length]})]}),o.jsx("p",{className:"s-thread-overview-summary",children:$})]})}),o.jsxs("section",{className:"s-thread-panel s-thread-panel-list",children:[o.jsxs("div",{className:"s-sessions-toolbar",children:[I&&o.jsxs("div",{className:"s-seg",role:"tablist","aria-label":"Session kind",children:[o.jsx(vj,{label:"All",count:A.all,pressed:a==="all",onClick:()=>i("all")}),R.map(L=>o.jsx(vj,{label:pj[L]??L,count:A[L]??0,pressed:a===L,onClick:()=>i(L)},L))]}),o.jsxs("button",{type:"button",className:`s-seg-standalone${f?" is-on":""}`,onClick:()=>m(L=>!L),"aria-pressed":f,title:"Show unread only",children:[o.jsx("span",{className:"s-dot s-dot-sm","aria-hidden":"true"}),o.jsx("span",{children:"Unread"}),O>0&&o.jsx("span",{className:"s-seg-count",children:O})]}),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:c,onChange:L=>u(L.target.value),onKeyDown:L=>{L.key==="Escape"&&(c?u(""):L.target.blur())}}),o.jsx("kbd",{className:"s-search-kbd",children:"⌘K"})]})]}),w&&o.jsx("p",{className:"s-error",children:w}),V.length===0?o.jsxs("div",{className:"s-empty s-thread-empty-state",children:[o.jsx("p",{children:c||f?"No matches":"No conversations"}),o.jsx("p",{children:c?"Try a different search term.":f?"You're all caught up.":"Conversations appear here when agents communicate."})]}):o.jsx("div",{className:"s-inbox",ref:T,role:"listbox","aria-label":"Sessions",children:V.map((L,P)=>{const q=SZ(L),ee=(L.agentName??q)[0]?.toUpperCase()??"?",D=Cp(L.lastMessageAt,L.id,h),U=P===x,B=gZ(L.preview,160),G=pj[L.kind]??L.kind,K=kZ(L.workspaceRoot),z=gj(L,_);return o.jsxs("div",{"data-idx":P,"data-unread":D?"true":"false","data-selected":U?"true":"false",className:"s-inbox-row",role:"option","aria-selected":U,tabIndex:U?0:-1,onClick:()=>{yZ(()=>{b(P),Z(L,{observe:!!z})})},onMouseEnter:()=>b(P),onContextMenu:Y=>{const W=window.getSelection()?.toString().trim(),J=[];W&&(J.push({kind:"action",label:"Copy Selection",shortcut:"⌘C",onSelect:()=>navigator.clipboard.writeText(W)}),J.push({kind:"separator"})),J.push({kind:"action",label:"Open Conversation",onSelect:()=>Z(L)}),L.agentId&&J.push({kind:"action",label:"Open Observe",onSelect:()=>Z(L,{observe:!0})}),J.push({kind:"action",label:"Copy Title",onSelect:()=>navigator.clipboard.writeText(q)}),L.id&&J.push({kind:"action",label:"Copy Conversation ID",onSelect:()=>navigator.clipboard.writeText(L.id)});const de=L.harnessSessionId;de&&J.push({kind:"action",label:"Copy Harness Session ID",onSelect:()=>navigator.clipboard.writeText(de)}),k(Y,J)},children:[o.jsxs("div",{className:"s-session-avatar-wrap",children:[o.jsx("div",{className:"s-avatar",style:{background:ct(L.agentName??q)},"aria-hidden":"true",children:ee}),D&&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:q,children:q})}),o.jsx("div",{className:"s-session-trailing",children:L.lastMessageAt&&o.jsx("span",{className:"s-inbox-time s-tabular",title:EZ(L.lastMessageAt),children:Pe(L.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:G}),z&&o.jsxs("span",{className:"s-session-pill",title:z,children:["session · ",z]}),K&&o.jsx("span",{className:"s-session-pill",title:L.workspaceRoot??void 0,children:K}),L.currentBranch&&o.jsx("span",{className:"s-session-pill",title:L.currentBranch,children:L.currentBranch})]})]})]},L.id)})})]})]})}function vj({label:e,count:t,pressed:n,onClick:a}){return o.jsxs("button",{type:"button",className:"s-seg-btn","aria-pressed":n,onClick:a,children:[o.jsx("span",{children:e}),o.jsx("span",{className:"s-seg-count",children:t})]})}var Yr=(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))(Yr||{});const TZ=[0,1],_T=[1,0],OT=[2,3],IT=[3,2],AZ={L:TZ,M:_T,Q:OT,H:IT},RZ=/^\d*$/,MZ=/^[A-Z0-9 $%*+./:-]*$/,Mp="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",Xv=1,Kv=40,yj=3,_Z=3,Qu=40,OZ=10,DT=[[-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]],zT=[[-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 IZ{constructor(t,n,a,i){if(this.version=t,this.ecc=n,t<Xv||t>Kv)throw new RangeError("Version value out of range");if(i<-1||i>7)throw new RangeError("Mask value out of range");this.size=t*4+17;const c=Array.from({length:this.size}).fill(!1);for(let f=0;f<this.size;f++)this.modules.push(c.slice()),this.types.push(c.map(()=>0));this.drawFunctionPatterns();const u=this.addEccAndInterleave(a);if(this.drawCodewords(u),i===-1){let f=1e9;for(let m=0;m<8;m++){this.applyMask(m),this.drawFormatBits(m);const h=this.getPenaltyScore();h<f&&(i=m,f=h),this.applyMask(m)}}this.mask=i,this.applyMask(i),this.drawFormatBits(i)}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 a=0;a<this.size;a++)this.setFunctionModule(6,a,a%2===0,Yr.Timing),this.setFunctionModule(a,6,a%2===0,Yr.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 a=0;a<n;a++)for(let i=0;i<n;i++)a===0&&i===0||a===0&&i===n-1||a===n-1&&i===0||this.drawAlignmentPattern(t[a],t[i]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(t){const n=this.ecc[1]<<3|t;let a=n;for(let c=0;c<10;c++)a=a<<1^(a>>>9)*1335;const i=(n<<10|a)^21522;for(let c=0;c<=5;c++)this.setFunctionModule(8,c,Na(i,c));this.setFunctionModule(8,7,Na(i,6)),this.setFunctionModule(8,8,Na(i,7)),this.setFunctionModule(7,8,Na(i,8));for(let c=9;c<15;c++)this.setFunctionModule(14-c,8,Na(i,c));for(let c=0;c<8;c++)this.setFunctionModule(this.size-1-c,8,Na(i,c));for(let c=8;c<15;c++)this.setFunctionModule(8,this.size-15+c,Na(i,c));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let t=this.version;for(let a=0;a<12;a++)t=t<<1^(t>>>11)*7973;const n=this.version<<12|t;for(let a=0;a<18;a++){const i=Na(n,a),c=this.size-11+a%3,u=Math.floor(a/3);this.setFunctionModule(c,u,i),this.setFunctionModule(u,c,i)}}drawFinderPattern(t,n){for(let a=-4;a<=4;a++)for(let i=-4;i<=4;i++){const c=Math.max(Math.abs(i),Math.abs(a)),u=t+i,f=n+a;u>=0&&u<this.size&&f>=0&&f<this.size&&this.setFunctionModule(u,f,c!==2&&c!==4,Yr.Position)}}drawAlignmentPattern(t,n){for(let a=-2;a<=2;a++)for(let i=-2;i<=2;i++)this.setFunctionModule(t+i,n+a,Math.max(Math.abs(i),Math.abs(a))!==1,Yr.Alignment)}setFunctionModule(t,n,a,i=Yr.Function){this.modules[n][t]=a,this.types[n][t]=i}addEccAndInterleave(t){const n=this.version,a=this.ecc;if(t.length!==wd(n,a))throw new RangeError("Invalid argument");const i=zT[a[0]][n],c=DT[a[0]][n],u=Math.floor($g(n)/8),f=i-u%i,m=Math.floor(u/i),h=[],g=HZ(c);for(let b=0,w=0;b<i;b++){const j=t.slice(w,w+m-c+(b<f?0:1));w+=j.length;const N=ZZ(j,g);b<f&&j.push(0),h.push(j.concat(N))}const x=[];for(let b=0;b<h[0].length;b++)h.forEach((w,j)=>{(b!==m-c||j>=f)&&x.push(w[b])});return x}drawCodewords(t){if(t.length!==Math.floor($g(this.version)/8))throw new RangeError("Invalid argument");let n=0;for(let a=this.size-1;a>=1;a-=2){a===6&&(a=5);for(let i=0;i<this.size;i++)for(let c=0;c<2;c++){const u=a-c,m=(a+1&2)===0?this.size-1-i:i;!this.types[m][u]&&n<t.length*8&&(this.modules[m][u]=Na(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 a=0;a<this.size;a++){let i;switch(t){case 0:i=(a+n)%2===0;break;case 1:i=n%2===0;break;case 2:i=a%3===0;break;case 3:i=(a+n)%3===0;break;case 4:i=(Math.floor(a/3)+Math.floor(n/2))%2===0;break;case 5:i=a*n%2+a*n%3===0;break;case 6:i=(a*n%2+a*n%3)%2===0;break;case 7:i=((a+n)%2+a*n%3)%2===0;break;default:throw new Error("Unreachable")}!this.types[n][a]&&i&&(this.modules[n][a]=!this.modules[n][a])}}getPenaltyScore(){let t=0;for(let c=0;c<this.size;c++){let u=!1,f=0;const m=[0,0,0,0,0,0,0];for(let h=0;h<this.size;h++)this.modules[c][h]===u?(f++,f===5?t+=yj:f>5&&t++):(this.finderPenaltyAddHistory(f,m),u||(t+=this.finderPenaltyCountPatterns(m)*Qu),u=this.modules[c][h],f=1);t+=this.finderPenaltyTerminateAndCount(u,f,m)*Qu}for(let c=0;c<this.size;c++){let u=!1,f=0;const m=[0,0,0,0,0,0,0];for(let h=0;h<this.size;h++)this.modules[h][c]===u?(f++,f===5?t+=yj:f>5&&t++):(this.finderPenaltyAddHistory(f,m),u||(t+=this.finderPenaltyCountPatterns(m)*Qu),u=this.modules[h][c],f=1);t+=this.finderPenaltyTerminateAndCount(u,f,m)*Qu}for(let c=0;c<this.size-1;c++)for(let u=0;u<this.size-1;u++){const f=this.modules[c][u];f===this.modules[c][u+1]&&f===this.modules[c+1][u]&&f===this.modules[c+1][u+1]&&(t+=_Z)}let n=0;for(const c of this.modules)n=c.reduce((u,f)=>u+(f?1:0),n);const a=this.size*this.size,i=Math.ceil(Math.abs(n*20-a*10)/a)-1;return t+=i*OZ,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,a=[6];for(let i=this.size-7;a.length<t;i-=n)a.splice(1,0,i);return a}}finderPenaltyCountPatterns(t){const n=t[1],a=n>0&&t[2]===n&&t[3]===n*3&&t[4]===n&&t[5]===n;return(a&&t[0]>=n*4&&t[6]>=n?1:0)+(a&&t[6]>=n*4&&t[0]>=n?1:0)}finderPenaltyTerminateAndCount(t,n,a){return t&&(this.finderPenaltyAddHistory(n,a),n=0),n+=this.size,this.finderPenaltyAddHistory(n,a),this.finderPenaltyCountPatterns(a)}finderPenaltyAddHistory(t,n){n[0]===0&&(t+=this.size),n.pop(),n.unshift(t)}}function Ca(e,t,n){if(t<0||t>31||e>>>t)throw new RangeError("Value out of range");for(let a=t-1;a>=0;a--)n.push(e>>>a&1)}function Na(e,t){return(e>>>t&1)!==0}class Jv{constructor(t,n,a){if(this.mode=t,this.numChars=n,this.bitData=a,n<0)throw new RangeError("Invalid argument");this.bitData=a.slice()}getData(){return this.bitData.slice()}}const DZ=[1,10,12,14],zZ=[2,9,11,13],LZ=[4,8,16,16];function LT(e,t){return e[Math.floor((t+7)/17)+1]}function $T(e){const t=[];for(const n of e)Ca(n,8,t);return new Jv(LZ,e.length,t)}function $Z(e){if(!PT(e))throw new RangeError("String contains non-numeric characters");const t=[];for(let n=0;n<e.length;){const a=Math.min(e.length-n,3);Ca(Number.parseInt(e.substring(n,n+a),10),a*3+1,t),n+=a}return new Jv(DZ,e.length,t)}function PZ(e){if(!UT(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 a=Mp.indexOf(e.charAt(n))*45;a+=Mp.indexOf(e.charAt(n+1)),Ca(a,11,t)}return n<e.length&&Ca(Mp.indexOf(e.charAt(n)),6,t),new Jv(zZ,e.length,t)}function UZ(e){return e===""?[]:PT(e)?[$Z(e)]:UT(e)?[PZ(e)]:[$T(VZ(e))]}function PT(e){return RZ.test(e)}function UT(e){return MZ.test(e)}function BZ(e,t){let n=0;for(const a of e){const i=LT(a.mode,t);if(a.numChars>=1<<i)return Number.POSITIVE_INFINITY;n+=4+i+a.bitData.length}return n}function VZ(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 $g(e){if(e<Xv||e>Kv)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 wd(e,t){return Math.floor($g(e)/8)-DT[t[0]][e]*zT[t[0]][e]}function HZ(e){if(e<1||e>255)throw new RangeError("Degree out of range");const t=[];for(let a=0;a<e-1;a++)t.push(0);t.push(1);let n=1;for(let a=0;a<e;a++){for(let i=0;i<t.length;i++)t[i]=Pg(t[i],n),i+1<t.length&&(t[i]^=t[i+1]);n=Pg(n,2)}return t}function ZZ(e,t){const n=t.map(a=>0);for(const a of e){const i=a^n.shift();n.push(0),t.forEach((c,u)=>n[u]^=Pg(c,i))}return n}function Pg(e,t){if(e>>>8||t>>>8)throw new RangeError("Byte out of range");let n=0;for(let a=7;a>=0;a--)n=n<<1^(n>>>7)*285,n^=(t>>>a&1)*e;return n}function FZ(e,t,n=1,a=40,i=-1,c=!0){if(!(Xv<=n&&n<=a&&a<=Kv)||i<-1||i>7)throw new RangeError("Invalid value");let u,f;for(u=n;;u++){const x=wd(u,t)*8,b=BZ(e,u);if(b<=x){f=b;break}if(u>=a)throw new RangeError("Data too long")}for(const x of[_T,OT,IT])c&&f<=wd(u,x)*8&&(t=x);const m=[];for(const x of e){Ca(x.mode[0],4,m),Ca(x.numChars,LT(x.mode,u),m);for(const b of x.getData())m.push(b)}const h=wd(u,t)*8;Ca(0,Math.min(4,h-m.length),m),Ca(0,(8-m.length%8)%8,m);for(let x=236;m.length<h;x^=253)Ca(x,8,m);const g=Array.from({length:Math.ceil(m.length/8)},()=>0);return m.forEach((x,b)=>g[b>>>3]|=x<<7-(b&7)),new IZ(u,t,g,i)}function qZ(e,t){const{ecc:n="L",boostEcc:a=!1,minVersion:i=1,maxVersion:c=40,maskPattern:u=-1,border:f=1}=t||{},m=typeof e=="string"?UZ(e):Array.isArray(e)?[$T(e)]:void 0;if(!m)throw new Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);const h=FZ(m,AZ[n],i,c,u,a),g=YZ({version:h.version,maskPattern:h.mask,size:h.size,data:h.modules,types:h.types},f);return t?.invert&&(g.data=g.data.map(x=>x.map(b=>!b))),t?.onEncoded?.(g),g}function YZ(e,t=1){if(!t)return e;const{size:n}=e,a=n+t*2;e.size=a,e.data.forEach(c=>{for(let u=0;u<t;u++)c.unshift(!1),c.push(!1)});for(let c=0;c<t;c++)e.data.unshift(Array.from({length:a},u=>!1)),e.data.push(Array.from({length:a},u=>!1));const i=Yr.Border;e.types.forEach(c=>{for(let u=0;u<t;u++)c.unshift(i),c.push(i)});for(let c=0;c<t;c++)e.types.unshift(Array.from({length:a},u=>i)),e.types.push(Array.from({length:a},u=>i));return e}function xj(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function GZ(e,t={}){const n=qZ(e,t),{pixelSize:a=10,whiteColor:i="white",blackColor:c="black"}=t,u=n.size*a,f=n.size*a;let m=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${f} ${u}">`;const h=[];for(let g=0;g<n.size;g++)for(let x=0;x<n.size;x++){const b=x*a,w=g*a;n.data[g][x]&&h.push(`M${b},${w}h${a}v${a}h-${a}z`)}return m+=`<rect fill="${xj(i)}" width="${f}" height="${u}"/>`,m+=`<path fill="${xj(c)}" d="${h.join("")}"/>`,m+="</svg>",m}function WZ(e){return e?e.replace(/^wss?:\/\//,"").replace(/:\d+$/,""):null}function bj(e){return e?e.length<=18?e:`${e.slice(0,10)}...${e.slice(-6)}`:null}function XZ(e){return e?e.status==="paired"||e.status==="connected"?"success":e.status==="error"||e.status==="closed"?"danger":"warning":"warning"}function KZ(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 a=Math.floor(n/60),i=n%60;return i>0?`${a}m ${i}s`:`${a}m`}function wj({value:e}){const[t,n]=v.useState(!1),a=v.useCallback(()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),1500)})},[e]);return o.jsx("button",{type:"button",className:"sys-copy-btn",onClick:a,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 JZ({navigate:e}){const[t,n]=v.useState(null),[a,i]=v.useState(""),[c,u]=v.useState(""),[f,m]=v.useState(!0),[h,g]=v.useState(!1),[x,b]=v.useState(!1),[w,j]=v.useState(null),[N,T]=v.useState(null),[k,C]=v.useState(null),[S,R]=v.useState(null),[A,_]=v.useState(()=>Date.now()),[O,V]=v.useState(null),Z=v.useRef(null),I=v.useRef(0),$=v.useRef(null);v.useEffect(()=>{Z.current=t},[t]),v.useEffect(()=>{$.current=w},[w]);const L=v.useCallback(async(ae="initial")=>{if(ae==="background"&&$.current)return;const ye=++I.current;!(Z.current!==null)&&ae!=="background"?(m(!0),T(null)):g(!0);try{const be=await Oe(ae==="manual"?"/api/pairing-state/refresh":"/api/pairing-state");if(ye!==I.current)return;n(be),T(null),R(Date.now())}catch(be){if(ye!==I.current)return;T(be instanceof Error?be.message:String(be))}finally{ye===I.current&&(m(!1),g(!1))}},[]),P=v.useCallback(async()=>{try{const ae=await Oe("/api/user");u(ae.name),i(ae.name),C(null)}catch(ae){C(ae instanceof Error?ae.message:String(ae))}},[]),q=v.useRef(!1);v.useEffect(()=>{L("initial"),P()},[L,P]),v.useEffect(()=>{const ae=setInterval(()=>{L("background")},1e4);return()=>clearInterval(ae)},[L]),v.useEffect(()=>{if(!t?.pairing?.expiresAt)return;_(Date.now());const ae=setInterval(()=>{_(Date.now())},1e3);return()=>clearInterval(ae)},[t?.pairing?.expiresAt]);const ee=v.useCallback(async()=>{b(!0),C(null);try{const ae=await Oe("/api/user",{method:"POST",body:JSON.stringify({name:a})});u(ae.name),i(ae.name)}catch(ae){C(ae instanceof Error?ae.message:String(ae))}finally{b(!1)}},[a]),D=v.useCallback(async ae=>{const ye=++I.current;j(ae),T(null);try{const ve=await Oe("/api/pairing/control",{method:"POST",body:JSON.stringify({action:ae})});if(ye!==I.current)return;n(ve),R(Date.now())}catch(ve){if(ye!==I.current)return;T(ve instanceof Error?ve.message:String(ve))}finally{ye===I.current&&j(null)}},[]);v.useEffect(()=>{!t||t.isRunning||q.current||(q.current=!0,D("start"))},[t,D]);const U=v.useCallback(async ae=>{V(ae);try{await Oe(`/api/pairing/peers/${encodeURIComponent(ae)}`,{method:"DELETE"}),L("manual")}catch{}finally{V(null)}},[L]),B=v.useMemo(()=>{const ae=t?.pairing?.qrValue?.trim();return ae?GZ(ae,{border:2,ecc:"M",pixelSize:8}):null},[t?.pairing?.qrValue]),G=WZ(t?.pairing?.relay??t?.relay??null),K=KZ(t?.pairing?.expiresAt,A),Y=(t?.trustedPeers.find(ae=>ae.fingerprint===t.connectedPeerFingerprint)??null)?.name??bj(t?.connectedPeerFingerprint??null),W=XZ(t),J=a.trim()!==c,de=!f&&!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-${W}`,children:t.statusLabel}),o.jsx("div",{className:"sys-sync-note",children:f?"Loading...":N&&t?`Snapshot from ${S?Pe(S):"earlier"}`:S?`Updated ${Pe(S)}`:""}),o.jsx("button",{type:"button",className:"s-btn",disabled:f||h||!!w,onClick:()=>{L("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})]}),k&&o.jsxs("div",{className:"sys-banner sys-banner-warning",children:[o.jsx("strong",{children:"Identity error."}),o.jsx("span",{children:k})]}),f&&!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."})]}),de&&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:()=>{L("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}}),K&&o.jsxs("span",{className:"sys-settings-qr-expires",children:["Expires in ",K]})]}):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:a,onChange:ae=>i(ae.target.value),onKeyDown:ae=>{ae.key==="Enter"&&J&&!x&&ee()}}),o.jsx("button",{type:"button",className:"s-btn s-btn-primary",disabled:!J||x,onClick:()=>{ee()},children:x?"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(wj,{value:t.identityFingerprint})]})]}),G&&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:G}),o.jsx(wj,{value:G})]})]}),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})]}),Y&&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:Y})]}),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:()=>{D("restart")},children:w==="restart"?"Restarting...":"Restart"}),o.jsx("button",{type:"button",className:"s-btn",disabled:!!w,onClick:()=>{D("stop")},children:w==="stop"?"Stopping...":"Stop"})]}):o.jsx("button",{type:"button",className:"s-btn s-btn-primary",disabled:!!w,onClick:()=>{D("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(ae=>{const ye=ae.fingerprint===t.connectedPeerFingerprint;return o.jsxs("tr",{className:ye?"sys-peers-row-connected":"",children:[o.jsx("td",{children:o.jsxs("span",{className:"sys-peers-name",children:[ae.name??bj(ae.fingerprint)??"Peer",ye&&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:ae.fingerprint})}),o.jsx("td",{children:ae.pairedAtLabel??"—"}),o.jsx("td",{children:ae.lastSeenLabel??"—"}),o.jsx("td",{children:o.jsx("button",{type:"button",className:"sys-peers-remove",disabled:O===ae.fingerprint,onClick:()=>{U(ae.fingerprint)},title:"Remove peer",children:O===ae.fingerprint?"...":"Remove"})})]},ae.fingerprint)})})]})]})]})}const QZ=2500,eF=1e4;function BT(e){const[t,n]=v.useState({}),a=v.useRef(!0),i=v.useRef(!1),c=v.useRef(!1),u=e.map(h=>h.id.trim()).filter(h=>h.length>0).join(","),f=e.some(h=>mt(h.state)==="working")?QZ:eF,m=v.useCallback(async()=>{if(e.length===0){n({});return}if(i.current){c.current=!0;return}i.current=!0;try{const h=u?`?ids=${encodeURIComponent(u)}`:"",g=await Oe(`/api/observe/agents${h}`);if(!a.current)return;n(x=>{const b={};for(const w of e)b[w.id]=x[w.id];for(const w of g){const{agentId:j,...N}=w;b[j]=N}return b})}finally{i.current=!1,c.current&&(c.current=!1,m())}},[u,e]);return v.useEffect(()=>{if(a.current=!0,e.length===0)return n({}),()=>{a.current=!1};m();const h=setInterval(()=>{m()},f);return()=>{a.current=!1,clearInterval(h)}},[e.length,m,f]),t}function rr(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 Pl=340,Qd=220,Ji=16,tF=48,nF=36,Sj=28,ed=40,VT=180,HT=140;function sF(e){const t=aF(e);if(t.length===0)return{groups:[],canvasW:0,canvasH:0};const n=Math.max(1,Math.round(Math.sqrt(t.length*1.4))),a=[],i=new Array(n).fill(ed),c=Array.from({length:n},(m,h)=>ed+h*(Pl*2+Ji+tF));for(const m of t){const h=i.indexOf(Math.min(...i)),g=c[h],x=i[h],b=Math.min(2,m.agents.length),w=Math.ceil(m.agents.length/b),j=b*Pl+(b-1)*Ji,N=Sj+w*Qd+(w-1)*Ji,T=m.agents.map((k,C)=>{const S=C%b,R=Math.floor(C/b);return{agentId:k.id,x:g+S*(Pl+Ji),y:x+Sj+R*(Qd+Ji)}});a.push({label:m.label,x:g,y:x,w:j,h:N,tiles:T}),i[h]=x+N+nF}const u=Math.max(...c.map((m,h)=>m+Pl*2+Ji))+ed,f=Math.max(...i)+ed;return{groups:a,canvasW:u,canvasH:f}}function aF(e){const t={working:0,available:1,offline:2},n=[...e].sort((c,u)=>{const f=t[mt(c.state)]??1,m=t[mt(u.state)]??1;return f!==m?f-m:c.name.localeCompare(u.name)}),a=new Map;for(const c of n){const u=c.project??"unassigned";a.has(u)||a.set(u,[]),a.get(u).push(c)}const i=[];for(const[c,u]of a)i.push({label:c,agents:u});return i.sort((c,u)=>u.agents.length-c.agents.length),i}function rF(e){switch(e.kind){case"tool":return`$ ${rr(e)}`;case"think":return`~ ${rr(e)}`;case"ask":return`↗ ${rr(e)}`;case"message":return`→ ${rr(e)}`;case"note":return`+ ${rr(e)}`;case"system":case"boot":return`▸ ${rr(e)}`}}function ZT(e,t,n){const a=n?.events.slice(-8).map(rF).filter(Boolean)??[];return a.length>0?a:mt(e.state)==="offline"?["No session trace available"]:["Waiting for session trace…",...t?[`task: ${t}`]:[]]}function iF(e){switch(mt(e)){case"working":return"var(--green)";case"available":return"var(--accent)";default:return"var(--dim)"}}function oF({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 a=n.map((i,c)=>`${c/(n.length-1)*100},${20-i*18-1}`).join(" ");return o.jsx("svg",{viewBox:"0 0 100 20",preserveAspectRatio:"none",style:{width:80,height:16},children:o.jsx("polyline",{points:a,fill:"none",stroke:e,strokeWidth:"1"})})}function lF({navigate:e,agents:t}){const[n,a]=v.useState(null),[i,c]=v.useState(null),u=BT(t),f=v.useCallback(async I=>{await Oe(`/api/agents/${encodeURIComponent(I)}/interrupt`,{method:"POST",body:JSON.stringify({})})},[]),m=v.useRef(null),[h,g]=v.useState({w:0,h:0}),[x,b]=v.useState({x:0,y:0}),[w,j]=v.useState(1),N=v.useRef(!1),T=v.useRef({x:0,y:0,panX:0,panY:0});v.useEffect(()=>{const I=m.current;if(!I)return;const $=new ResizeObserver(([L])=>{const{width:P,height:q}=L.contentRect;g({w:P,h:q})});return $.observe(I),()=>$.disconnect()},[]);const k=v.useCallback(async()=>{try{c(await Oe("/api/fleet"))}catch{}},[]);v.useEffect(()=>{k()},[k]),An(()=>{k()});const C=v.useMemo(()=>{const I={};for(const $ of i?.activeAsks??[])I[$.agentId]={agentId:$.agentId,task:$.task,summary:$.summary??null};return I},[i]),S=v.useMemo(()=>sF(t),[t]);v.useEffect(()=>{if(S.canvasW===0||h.w===0)return;const I=Math.min(1,h.w/S.canvasW,h.h/S.canvasH),$=Math.max(.15,Math.min(1,I*.92));b({x:(h.w-S.canvasW*$)/2,y:Math.max(8,(h.h-S.canvasH*$)/2)}),j($)},[S,h]);const R=v.useCallback(I=>{I.target.closest(".s-conductor-tile")||(N.current=!0,T.current={x:I.clientX,y:I.clientY,panX:x.x,panY:x.y})},[x]),A=v.useCallback(I=>{N.current&&b({x:T.current.panX+(I.clientX-T.current.x),y:T.current.panY+(I.clientY-T.current.y)})},[]),_=v.useCallback(()=>{N.current=!1},[]);v.useEffect(()=>{const I=m.current;if(!I)return;const $=L=>{L.preventDefault();const P=I.getBoundingClientRect(),q=L.clientX-P.left,ee=L.clientY-P.top,D=L.deltaY>0?.92:1.08,U=Math.max(.2,Math.min(2,w*D)),B=U/w;b(G=>({x:q-(q-G.x)*B,y:ee-(ee-G.y)*B})),j(U)};return I.addEventListener("wheel",$,{passive:!1}),()=>I.removeEventListener("wheel",$)},[w]);const O=n?t.find(I=>I.id===n):null;v.useEffect(()=>{if(!O)return;const I=$=>{$.key==="Escape"&&a(null)};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[O]);const V=v.useCallback(I=>{const $=m.current;if(!$)return;const L=I.currentTarget.getBoundingClientRect(),P=I.clientX-L.left,q=I.clientY-L.top,ee=Math.min(VT/S.canvasW,HT/S.canvasH),D=P/ee,U=q/ee,B=$.clientWidth,G=$.clientHeight;b({x:B/2-D*w,y:G/2-U*w})},[S,w]),Z=v.useMemo(()=>{const I={};for(const $ of S.groups)for(const L of $.tiles)I[L.agentId]={x:L.x,y:L.y};return I},[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:m,className:"s-conductor-viewport",onMouseDown:R,onMouseMove:A,onMouseUp:_,onMouseLeave:_,children:[o.jsxs("div",{className:"s-conductor-canvas",style:{transform:`translate(${x.x}px, ${x.y}px) scale(${w})`},children:[S.groups.map(I=>o.jsx("div",{className:"s-conductor-group-label",style:{left:I.x,top:I.y},children:I.label},I.label)),t.map(I=>{const $=Z[I.id];return $?o.jsx(dF,{agent:I,task:C[I.id]??null,observe:u[I.id]?.data??null,x:$.x,y:$.y,onClick:()=>a(I.id)},I.id):null})]}),o.jsx(cF,{layout:S,agents:t,pan:x,zoom:w,viewportRef:m,onClick:V})]}),O&&o.jsx(uF,{agent:O,task:C[O.id]??null,observe:u[O.id]?.data??null,onClose:()=>a(null),onTell:()=>{a(null),e({view:"conversation",conversationId:os(O.id),composeMode:"tell"})},onAsk:()=>{a(null),e({view:"conversation",conversationId:os(O.id),composeMode:"ask"})},onFreeze:mt(O.state)==="working"?()=>{a(null),f(O.id)}:void 0,onOpenProfile:()=>{a(null),e({view:"agents",agentId:O.id})}})]})}function cF({layout:e,agents:t,pan:n,zoom:a,viewportRef:i,onClick:c}){if(e.canvasW===0||t.length===0)return null;const u=Math.min(VT/e.canvasW,HT/e.canvasH),f=e.canvasW*u,m=e.canvasH*u,h=i.current,g=h?.clientWidth??0,x=h?.clientHeight??0,b=-n.x/a*u,w=-n.y/a*u,j=g/a*u,N=x/a*u;return o.jsxs("div",{className:"s-conductor-minimap",style:{width:f,height:m,opacity:.85},onClick:c,children:[e.groups.map(T=>o.jsx("div",{className:"s-conductor-minimap-group",style:{left:T.x*u,top:T.y*u},children:T.label},T.label)),e.groups.flatMap(T=>T.tiles.map(k=>{const C=t.find(S=>S.id===k.agentId);return o.jsx("div",{className:"s-conductor-minimap-tile",style:{left:k.x*u,top:k.y*u,width:Pl*u,height:Qd*u,background:C?ct(C.name):"var(--dim)",opacity:C&&mt(C.state)==="working"?.8:.35}},k.agentId)})),o.jsx("div",{className:"s-conductor-minimap-viewport",style:{left:Math.max(0,b),top:Math.max(0,w),width:Math.min(j,f),height:Math.min(N,m)}})]})}function uF({agent:e,task:t,observe:n,onClose:a,onTell:i,onAsk:c,onFreeze:u,onOpenProfile:f}){const m=ZT(e,t?.summary??null,n);return o.jsx("div",{className:"s-conductor-overlay",onClick:a,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:ct(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:a,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??aa(e.state)]}),o.jsxs("div",{className:"s-conductor-terminal",style:{height:"auto",minHeight:160},children:[m.map((h,g)=>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},g)),mt(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:i,children:"Send instruction"}),o.jsx("button",{className:"s-ops-btn",onClick:u,disabled:!u,children:"Freeze"}),o.jsx("button",{className:"s-ops-btn",onClick:c,children:"Route ask"}),o.jsx("span",{style:{flex:1}}),o.jsx("button",{className:"s-ops-btn",onClick:f,children:"Open profile ↗"})]})]})})}function dF({agent:e,task:t,observe:n,x:a,y:i,onClick:c}){const u=ct(e.name),f=iF(e.state),m=aa(e.state).toUpperCase(),h=ZT(e,t?.summary??null,n),g=mt(e.state)==="working",x=n?.events[n.events.length-1],b=x?rr(x):t?.summary??aa(e.state);return o.jsxs("div",{className:"s-conductor-tile",style:{left:a,top:i,height:Qd},onClick:w=>{w.stopPropagation(),c()},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:f},children:m})]}),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)),g&&o.jsx("span",{className:"s-conductor-terminal-cursor"})]}),o.jsxs("div",{className:"s-conductor-tile-footer",children:[o.jsx(oF,{color:u,data:n?.contextUsage}),o.jsx("span",{className:"s-conductor-tile-detail",children:b}),g&&o.jsx("span",{className:"s-conductor-terminal-cursor"})]})]})}const Ul=420,ef=320,Qi=20,fF=48,hF=36,jj=28,td=40,FT=180,qT=140,YT="scout_mc_vp";function mF(e){try{localStorage.setItem(YT,JSON.stringify(e))}catch{}}function pF(){try{const e=localStorage.getItem(YT);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 gF(e){const t=vF(e);if(t.length===0)return{groups:[],canvasW:0,canvasH:0};const n=Math.max(1,Math.round(Math.sqrt(t.length*1.2))),a=[],i=new Array(n).fill(td),c=Array.from({length:n},(m,h)=>td+h*(Ul*2+Qi+fF));for(const m of t){const h=i.indexOf(Math.min(...i)),g=c[h],x=i[h],b=Math.min(2,m.agents.length),w=Math.ceil(m.agents.length/b),j=b*Ul+(b-1)*Qi,N=jj+w*ef+(w-1)*Qi,T=m.agents.map((k,C)=>({agentId:k.id,x:g+C%b*(Ul+Qi),y:x+jj+Math.floor(C/b)*(ef+Qi)}));a.push({label:m.label,x:g,y:x,w:j,h:N,tiles:T}),i[h]=x+N+hF}const u=Math.max(...c.map(m=>m+Ul*2+Qi))+td,f=Math.max(...i)+td;return{groups:a,canvasW:u,canvasH:f}}function vF(e){const t={working:0,available:1,offline:2},n=[...e].sort((c,u)=>{const f=t[mt(c.state)]??1,m=t[mt(u.state)]??1;return f!==m?f-m:c.name.localeCompare(u.name)}),a=new Map;for(const c of n){const u=c.project??"unassigned";a.has(u)||a.set(u,[]),a.get(u).push(c)}const i=[];for(const[c,u]of a)i.push({label:c,agents:u});return i.sort((c,u)=>u.agents.length-c.agents.length),i}const yF={think:"var(--dim)",tool:"var(--accent)",ask:"var(--amber)",message:"var(--muted)",note:"var(--green)",system:"var(--dim)",boot:"var(--dim)"},xF={think:"think",tool:"tool",ask:"ask",message:"msg",note:"note",system:"sys",boot:"boot"};function bF({navigate:e,agents:t}){const[n,a]=v.useState(null),i=BT(t),c=v.useRef(null),[u,f]=v.useState({w:0,h:0}),[m,h]=v.useState({x:0,y:0}),[g,x]=v.useState(1),[b,w]=v.useState(!1),j=v.useRef(!1),N=v.useRef({x:0,y:0,panX:0,panY:0}),T=v.useRef(!1);v.useEffect(()=>{const $=c.current;if(!$)return;const L=new ResizeObserver(([P])=>{f({w:P.contentRect.width,h:P.contentRect.height})});return L.observe($),()=>L.disconnect()},[]);const k=v.useMemo(()=>gF(t),[t]),C=v.useRef([]),S=v.useCallback(($=!0)=>{if(k.canvasW===0||u.w===0)return;C.current.forEach(clearTimeout);const L=Math.min(1,u.w/k.canvasW,u.h/k.canvasH),P=Math.max(.15,Math.min(1,L*.92));w(!1),x(P),h({x:(u.w-k.canvasW*P)/2,y:Math.max(8,(u.h-k.canvasH*P)/2)});const q=setTimeout(()=>{w(!0);const D=$?pF():null;D?(h(D.pan),x(D.zoom)):(h({x:24,y:24}),x(.55))},700),ee=setTimeout(()=>w(!1),1700);C.current=[q,ee]},[k,u]);v.useEffect(()=>{k.canvasW===0||u.w===0||T.current||(T.current=!0,S(!0))},[k,u,S]),v.useEffect(()=>{const $=setInterval(()=>{mF({pan:m,zoom:g})},3e4);return()=>clearInterval($)},[m,g]);const R=v.useCallback($=>{$.target.closest(".s-mission-tile")||(j.current=!0,N.current={x:$.clientX,y:$.clientY,panX:m.x,panY:m.y})},[m]),A=v.useCallback($=>{j.current&&h({x:N.current.panX+($.clientX-N.current.x),y:N.current.panY+($.clientY-N.current.y)})},[]),_=v.useCallback(()=>{j.current=!1},[]);v.useEffect(()=>{const $=c.current;if(!$)return;const L=P=>{P.preventDefault();const q=$.getBoundingClientRect(),ee=P.clientX-q.left,D=P.clientY-q.top,U=P.deltaY>0?.92:1.08,B=Math.max(.2,Math.min(2,g*U)),G=B/g;h(K=>({x:ee-(ee-K.x)*G,y:D-(D-K.y)*G})),x(B)};return $.addEventListener("wheel",L,{passive:!1}),()=>$.removeEventListener("wheel",L)},[g]);const O=n?t.find($=>$.id===n):null;v.useEffect(()=>{const $=L=>{L.target.tagName==="INPUT"||L.target.tagName==="TEXTAREA"||(L.key==="Escape"&&a(null),(L.key==="h"||L.key==="H")&&S(!1))};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[O,S]);const V=v.useCallback($=>{const L=$.currentTarget.getBoundingClientRect(),P=$.clientX-L.left,q=$.clientY-L.top,ee=Math.min(FT/k.canvasW,qT/k.canvasH),D=P/ee,U=q/ee,B=c.current;B&&h({x:B.clientWidth/2-D*g,y:B.clientHeight/2-U*g})},[k,g]),Z=v.useMemo(()=>{const $={};for(const L of k.groups)for(const P of L.tiles)$[P.agentId]={x:P.x,y:P.y};return $},[k]),I=t.filter($=>mt($.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":""," ·"," ",k.groups.length," workspace",k.groups.length!==1?"s":""]}),I>0&&o.jsxs("span",{className:"s-mission-bar-live",children:[o.jsx("span",{className:"s-mission-bar-live-dot"}),I," 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:c,className:"s-mission-viewport",onMouseDown:R,onMouseMove:A,onMouseUp:_,onMouseLeave:_,children:[t.length===0?o.jsxs("div",{className:"s-mission-empty",children:[o.jsx("div",{className:"s-mission-empty-title",children:"Mission 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(${m.x}px, ${m.y}px) scale(${g})`,transition:b?"transform 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94)":"none"},children:[k.groups.map($=>o.jsx("div",{className:"s-mission-group-label",style:{left:$.x,top:$.y},children:$.label},$.label)),t.map($=>{const L=Z[$.id];if(!L)return null;const P=i[$.id];return o.jsx(wF,{agent:$,observe:P?.data??null,x:L.x,y:L.y,onClick:()=>a($.id)},$.id)})]}),t.length>0&&o.jsx(jF,{layout:k,agents:t,pan:m,zoom:g,viewportRef:c,onClick:V})]}),O&&o.jsx(SF,{agent:O,observe:i[O.id]?.data??null,onClose:()=>a(null),onTell:()=>{a(null),e({view:"conversation",conversationId:os(O.id),composeMode:"tell"})},onAsk:()=>{a(null),e({view:"conversation",conversationId:os(O.id),composeMode:"ask"})},onProfile:()=>{a(null),e({view:"agents",agentId:O.id})}})]})}function wF({agent:e,observe:t,x:n,y:a,onClick:i}){const c=v.useRef(null),u=mt(e.state),f=ct(e.name),m=t?.events??[],h=m.slice(-8),g=t?.live===!0,x=m.some(T=>T.kind==="ask"&&!T.answer),b=t?.contextUsage,w=b&&b.length>0?Math.round(b[b.length-1]*100):null,j=m.filter(T=>T.kind==="tool").length,N=m.filter(T=>T.kind==="tool"&&T.tool==="edit").length;return v.useEffect(()=>{c.current&&(c.current.scrollTop=c.current.scrollHeight)},[m.length]),o.jsxs("div",{className:`s-mission-tile${u==="working"?" s-mission-tile--working":""}${x?" s-mission-tile--asking":""}`,style:{left:n,top:a,height:ef},onClick:T=>{T.stopPropagation(),i()},children:[o.jsxs("div",{className:"s-mission-tile-header",children:[o.jsx("div",{className:"s-ops-avatar",style:{"--size":"22px",background:f},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:NF(u)},children:aa(e.state).toUpperCase()})]}),o.jsx("div",{className:"s-mission-tile-stream",ref:c,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(T=>o.jsxs("div",{className:"s-mission-evt",children:[o.jsx("span",{className:"s-mission-evt-bead",style:{background:yF[T.kind]??"var(--dim)"}}),o.jsx("span",{className:"s-mission-evt-kind",children:xF[T.kind]??T.kind}),o.jsxs("span",{className:`s-mission-evt-text s-mission-evt-text--${T.kind}`,children:[rr(T),T.live&&o.jsx("span",{className:"s-observe-cursor"})]})]},T.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"]})]}),g&&o.jsxs("span",{className:"s-mission-tile-live",children:[o.jsx("span",{className:"s-mission-tile-live-dot"}),"LIVE"]})]})]})}function SF({agent:e,observe:t,onClose:n,onTell:a,onAsk:i,onProfile:c}){const u=ct(e.name);return o.jsx("div",{className:"s-mission-overlay",onClick:n,children:o.jsxs("div",{onClick:f=>f.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"," · ",aa(e.state)]})]}),o.jsxs("div",{className:"s-mission-overlay-actions",children:[o.jsx("button",{className:"s-ops-btn s-ops-btn--primary",onClick:a,children:"Tell"}),o.jsx("button",{className:"s-ops-btn",onClick:i,children:"Ask"}),o.jsx("button",{className:"s-ops-btn",onClick:c,children:"Profile ↗"}),o.jsx("button",{className:"s-ops-btn",onClick:n,children:"ESC"})]})]}),o.jsx("div",{className:"s-mission-overlay-body",children:o.jsx(MT,{data:t??void 0,agentId:e.id})})]})})}function jF({layout:e,agents:t,pan:n,zoom:a,viewportRef:i,onClick:c}){if(e.canvasW===0)return null;const u=Math.min(FT/e.canvasW,qT/e.canvasH),f=e.canvasW*u,m=e.canvasH*u,h=i.current,g=h?.clientWidth??0,x=h?.clientHeight??0,b=-n.x/a*u,w=-n.y/a*u,j=g/a*u,N=x/a*u;return o.jsxs("div",{className:"s-mission-minimap",style:{width:f,height:m},onClick:c,children:[e.groups.map(T=>o.jsx("div",{className:"s-mission-minimap-group",style:{left:T.x*u,top:T.y*u},children:T.label},T.label)),e.groups.flatMap(T=>T.tiles.map(k=>{const C=t.find(S=>S.id===k.agentId);return o.jsx("div",{className:"s-mission-minimap-tile",style:{left:k.x*u,top:k.y*u,width:Ul*u,height:ef*u,background:C?ct(C.name):"var(--dim)",opacity:C&&mt(C.state)==="working"?.8:.35}},k.agentId)})),o.jsx("div",{className:"s-mission-minimap-viewport",style:{left:Math.max(0,b),top:Math.max(0,w),width:Math.min(j,f),height:Math.min(N,m)}})]})}function NF(e){switch(e){case"working":return"var(--green)";case"available":return"var(--accent)";default:return"var(--dim)"}}const GT={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 WT(e){const t=[e];return e.children&&e.children.forEach(n=>t.push(...WT(n))),t}function XT(e,t){if(e.id===t)return e;if(!e.children)return null;for(const n of e.children){const a=XT(n,t);if(a)return a}return null}function Nj(e,t){return WT(e).filter(n=>n.kind==="task"&&n.assigneeId===t).length}function Nf(e){switch(e){case"done":return 1;case"inflight":return .7;case"committed":return .32;case"stuck":return .18;default:return .1}}function kF(e){return(e.currentPhase||e.state).replace(/\s+/g," ")}function KT(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 JT(e){switch(e.status){case"working":return"inflight";case"completed":return"done";case"needs_attention":case"failed":return"stuck";default:return"committed"}}function kj(e){const t=KT(e);return t==="stuck"?"attention":t==="inflight"?"active":"committed"}function EF(e){const t=JT(e);return t==="stuck"?"attention":t==="inflight"?"active":"committed"}function kf(e,t){return typeof e!="number"||!Number.isFinite(e)?null:Math.max(0,Math.round((t-e)/6e4))}function Qv(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 QT(e){return e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.collaborationRecordId?{view:"work",workId:e.collaborationRecordId}:{view:"agents",agentId:e.agentId}}function _p(e,t){const n=KT(e),a=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:a,why:e.summary??`Current phase: ${kF(e)}`,progress:Nf(n),stuckMins:n==="stuck"?kf(e.lastMeaningfulAt,t):null,updatedAt:e.lastMeaningfulAt,route:{view:"work",workId:e.id}}}function CF(e,t){const n=JT(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:Nf(n),stuckMins:n==="stuck"?kf(e.updatedAt,t):null,updatedAt:e.updatedAt,route:QT(e)}}function TF(e,t){return{id:`attention:${e.recordId}`,kind:"task",title:e.title,summary:e.summary,state:"stuck",assigneeId:e.agentId,detail:e.summary??e.state.replace(/_/g," "),why:e.kind==="question"?"Operator input is required before this can move again.":"This work item is blocked on a review, decision, or reply.",progress:Nf("stuck"),stuckMins:kf(e.updatedAt,t),updatedAt:e.updatedAt,route:Qv(e)}}function Op(e,t){return(t.updatedAt??0)-(e.updatedAt??0)}function Ip(e,t,n,a,i){return{id:`lane:${e}`,kind:"phase",title:t,summary:n,state:a,assigneeId:null,detail:n,why:n,progress:Nf(a),stuckMins:null,updatedAt:i[0]?.updatedAt??null,route:{view:"fleet"},children:i}}function AF(e,t,n,a){return e>0?"Resolve blockers before the queue widens":t>0?"Keep the live queue moving":n>0?"Commit the next slice of work":a>0?"Stand up the next unit of work":"No live operational plan yet"}function RF(e,t,n,a){return e===0&&t===0?a>0?`${a} agent${a===1?" is":"s are"} connected, but no work items or asks are active yet.`:"Bring agents online or dispatch the first ask to light up the plan surface.":`${e} live work item${e===1?"":"s"}, ${t} active ask${t===1?"":"s"}, and ${n} item${n===1?"":"s"} currently need operator awareness.`}function MF(e,t){return`Derived from live collaboration records, active asks, and recent fleet activity. This surface now reflects the current checkout instead of a canned mission narrative. ${e>0?`You have ${e} active work records in play.`:"No work records are active yet."} ${t>0?`${t} recent fleet events are informing the live view.`:"Recent fleet activity is quiet right now."}`}function _F(e,t,n){const a=[];for(const i of e.slice(0,4))a.push({id:`risk:attention:${i.recordId}`,title:i.title,detail:i.summary??(i.kind==="question"?"Waiting on an answer or decision.":"Waiting on the next operator move."),severity:i.kind==="question"?"high":"med"});for(const i of n){if(a.length>=4)break;i.attention==="interrupt"&&a.push({id:`risk:work:${i.id}`,title:i.title,detail:i.lastMeaningfulSummary??"Latest flight failed or the work item is blocked.",severity:"high"})}for(const i of t){if(a.length>=4)break;i.status==="failed"&&a.push({id:`risk:ask:${i.invocationId}`,title:i.task,detail:i.summary??"The delegated ask reported a failure state.",severity:"high"})}return a}function OF({navigate:e,agents:t}){const[n,a]=v.useState(null),[i,c]=v.useState([]),[u,f]=v.useState(null),[m,h]=v.useState("plan"),[g,x]=v.useState(()=>Date.now()),b=v.useCallback(async()=>{const[k,C]=await Promise.allSettled([Oe("/api/fleet"),Oe("/api/work")]);k.status==="fulfilled"&&a(k.value),C.status==="fulfilled"&&c(C.value),x(Date.now())},[]);v.useEffect(()=>{b()},[b]),An(()=>{b()}),v.useEffect(()=>{const k=setInterval(()=>x(Date.now()),15e3);return()=>clearInterval(k)},[]);const w=v.useMemo(()=>Object.fromEntries(t.map(k=>[k.id,k])),[t]),j=v.useMemo(()=>t.filter(k=>mt(k.state)!=="offline").length,[t]),N=v.useMemo(()=>{const k=[],C=[],S=[],R=new Set,A=new Map(i.map($=>[$.id,$]));for(const $ of n?.needsAttention??[]){const L=A.get($.recordId);if(L){const P=_p(L,g);k.push({...P,state:"stuck",detail:$.summary??P.detail,why:$.summary??P.summary??P.why,stuckMins:kf($.updatedAt,g),updatedAt:$.updatedAt,route:P.route??Qv($)}),R.add(L.id)}else k.push(TF($,g))}for(const $ of n?.activeAsks??[]){const L=$.collaborationRecordId??null,P=L?A.get(L):null;if(!(P&&R.has(P.id)))if(P){const q=_p(P,g),ee=kj(P);ee==="attention"?k.push(q):ee==="active"?C.push(q):S.push(q),R.add(P.id)}else{const q=CF($,g),ee=EF($);ee==="attention"?k.push(q):ee==="active"?C.push(q):S.push(q)}}for(const $ of i){if(R.has($.id))continue;const L=_p($,g),P=kj($);P==="attention"?k.push(L):P==="active"?C.push(L):S.push(L)}k.sort(Op),C.sort(Op),S.sort(Op);const _=[];k.length>0&&_.push(Ip("attention","Needs input",`${k.length} item${k.length===1?"":"s"} are waiting on an answer, decision, or unblock.`,"stuck",k)),C.length>0&&_.push(Ip("active","In flight",`${C.length} item${C.length===1?"":"s"} are currently moving through the fleet.`,"inflight",C)),S.length>0&&_.push(Ip("committed","Committed next",`${S.length} item${S.length===1?"":"s"} are queued or ready to be picked up next.`,"committed",S));const O=[...k,...C,...S],V={id:"plan:root",kind:"mission",title:AF(k.length,C.length,S.length,j),summary:RF(i.length,n?.activeAsks.length??0,k.length,j),state:k.length>0?"stuck":C.length>0?"inflight":S.length>0?"committed":"proposed",assigneeId:null,detail:null,why:MF(i.length,n?.activity.length??0),progress:O.length>0?O.reduce(($,L)=>$+(L.progress??0),0)/O.length:0,stuckMins:null,updatedAt:n?.generatedAt??null,route:{view:"fleet"},badge:`${O.length} live item${O.length===1?"":"s"}`,children:_},Z=_F(n?.needsAttention??[],n?.activeAsks??[],i),I=(n?.recentCompleted??[]).slice(0,4);return{root:V,leafNodes:O,risks:Z,recentCompleted:I,pendingAttention:n?.needsAttention??[],counts:{done:I.length,inflight:C.length,stuck:k.length}}},[n,g,j,i]),T=u?XT(N.root,u):null;return v.useEffect(()=>{T||f(N.leafNodes[0]?.id??N.root.id)},[N.leafNodes,N.root.id,T]),o.jsx("div",{className:"s-plan",children:o.jsxs("div",{className:"s-plan-inner",children:[o.jsxs("div",{className:"s-plan-banner",children:[o.jsx("span",{className:"s-plan-banner-badge",children:"◉ Live plan"}),o.jsxs("span",{className:"s-plan-banner-meta",children:[i.length," work item",i.length===1?"":"s"," · ",n?.activeAsks.length??0," active ask",(n?.activeAsks.length??0)===1?"":"s"," · ",N.pendingAttention.length," waiting on you"]}),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:"◇ Mission"}),o.jsx("h1",{className:"s-plan-title",children:N.root.title}),o.jsx("p",{className:"s-plan-goal",children:N.root.summary}),o.jsx("div",{className:"s-ops-eyebrow",children:"Derived from live state"}),o.jsx("p",{className:"s-plan-rationale",children:N.root.why}),o.jsx("div",{className:"s-ops-eyebrow",children:"Risks · watch"}),N.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."})]}):N.risks.map(k=>o.jsx($F,{risk:k},k.id)),o.jsx("div",{className:"s-ops-eyebrow",style:{marginTop:24},children:"Agents on mission"}),t.filter(k=>Nj(N.root,k.id)>0).length===0?o.jsxs("div",{className:"s-plan-change-card",children:[o.jsx("div",{className:"s-plan-change-summary",children:"No assigned work yet"}),o.jsx("div",{className:"s-plan-change-why",children:"As soon as asks and work items have clear owners, this roster will show who is carrying what."})]}):t.map(k=>{const C=Nj(N.root,k.id);return C===0?null:o.jsxs("div",{className:"s-plan-agent-row",children:[o.jsx("div",{className:"s-ops-avatar",style:{"--size":"22px",background:ct(k.name)},children:k.name[0]?.toUpperCase()}),o.jsxs("div",{className:"s-plan-agent-row-copy",children:[o.jsx("div",{className:"s-plan-agent-row-name",children:k.name}),o.jsxs("div",{className:"s-plan-agent-row-tasks",children:[C," item",C===1?"":"s"," assigned"]})]})]},k.id)})]}),o.jsxs("div",{className:"s-plan-col",style:{padding:"20px 16px 40px"},children:[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:[N.leafNodes.length," items · ",N.counts.done," recent done · ",N.counts.inflight," in flight · ",N.counts.stuck," stuck"]}),o.jsx("div",{className:"s-plan-tree-toggle",children:["plan","live"].map(k=>o.jsx("button",{className:`s-plan-tree-toggle-btn${m===k?" s-plan-tree-toggle-btn--active":""}`,onClick:()=>h(k),children:k},k))})]}),N.root.children&&N.root.children.length>0?o.jsx(eA,{node:N.root,depth:0,mode:m,selected:u??N.root.id,setSelected:f,agentsById:w,nowMs:g}):o.jsxs("div",{className:"s-plan-change-card",children:[o.jsx("div",{className:"s-plan-change-summary",children:"No live plan records yet"}),o.jsx("div",{className:"s-plan-change-why",children:"The execution tree is populated from live work items and active asks. Dispatch work and it will appear here automatically."})]})]}),o.jsxs("div",{className:"s-plan-col",style:{display:"flex",flexDirection:"column",gap:24},children:[o.jsxs("div",{children:[o.jsxs("div",{className:"s-ops-eyebrow",children:["↻ Attention queue · ",N.pendingAttention.length]}),N.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."})]}):N.pendingAttention.map(k=>o.jsx(zF,{item:k,navigate:e},k.recordId))]}),o.jsxs("div",{children:[o.jsxs("div",{className:"s-ops-eyebrow",children:["✓ Recent finishes · ",N.recentCompleted.length]}),N.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."})]}):N.recentCompleted.map(k=>o.jsx(LF,{ask:k,navigate:e},k.invocationId))]}),T&&o.jsxs("div",{children:[o.jsx("div",{className:"s-ops-eyebrow",children:"◎ Selected"}),o.jsx(PF,{node:T,agentsById:w,navigate:e})]})]})]})})}function eA({node:e,depth:t,mode:n,selected:a,setSelected:i,agentsById:c,nowMs:u}){const f=e.children&&e.children.length>0;return o.jsxs("div",{children:[o.jsx(IF,{node:e,depth:t,mode:n,selected:a===e.id,onClick:()=>i(e.id),agentsById:c,nowMs:u}),f&&o.jsx("div",{className:t===0?void 0:"s-plan-node-children",children:e.children.map(m=>o.jsx(eA,{node:m,depth:t+1,mode:n,selected:a,setSelected:i,agentsById:c,nowMs:u},m.id))})]})}function IF({node:e,depth:t,mode:n,selected:a,onClick:i,agentsById:c,nowMs:u}){const f=GT[e.state],m=e.assigneeId?c[e.assigneeId]:null,h=e.kind==="mission",g=e.kind==="phase",x=h?"mission":g?"phase":"task";return o.jsxs("div",{className:`s-plan-node s-plan-node--${x}${a?" s-plan-node--selected":""}`,onClick:i,children:[!h&&o.jsx("span",{className:"s-plan-node-icon",style:{color:f.color},children:f.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--${x}${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(DF,{node:e,nowMs:u})})]}),!h&&o.jsx("div",{className:"s-plan-node-assignee",children:m?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"s-ops-avatar",style:{"--size":"18px",background:ct(m.name)},children:m.name[0]?.toUpperCase()}),o.jsx("span",{className:"s-plan-node-assignee-handle",children:m.handle?`@${m.handle}`:m.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:f.color}})}),o.jsx("span",{className:"s-ops-state-chip",style:{color:f.color},children:f.label})]}),h&&o.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:10.5,color:"var(--dim)",letterSpacing:"0.08em"},children:e.badge??"LIVE"})]})}function DF({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 zF({item:e,navigate:t}){const n=Qv(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 LF({ask:e,navigate:t}){const n=QT(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 $F({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 PF({node:e,agentsById:t,navigate:n}){const a=GT[e.state],i=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:a.color},children:a.icon}),o.jsx("span",{className:"s-ops-state-chip",style:{color:a.color,fontSize:10},children:a.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}),i&&o.jsxs("div",{className:"s-plan-detail-assignee",children:[o.jsx("div",{className:"s-ops-avatar",style:{"--size":"22px",background:ct(i.name)},children:i.name[0]?.toUpperCase()}),o.jsxs("div",{style:{flex:1},children:[o.jsx("div",{style:{fontSize:12.5},children:i.name}),o.jsxs("div",{style:{fontSize:10.5,color:"var(--dim)",fontFamily:"var(--font-mono)"},children:[i.project??"—"," · ",i.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"}),i&&o.jsx("button",{className:"s-ops-btn",onClick:()=>n({view:"conversation",conversationId:os(i.id),composeMode:"tell"}),children:"Tell owner"}),i&&o.jsx("button",{className:"s-ops-btn",onClick:()=>n({view:"conversation",conversationId:os(i.id),composeMode:"ask"}),children:"Ask owner"})]})]})}function UF(e){const t=Math.floor(e/3600).toString().padStart(2,"0"),n=Math.floor(e%3600/60).toString().padStart(2,"0"),a=(e%60).toString().padStart(2,"0");return`${t}:${n}:${a}`}function BF(e){return e.replace(/[._]/g," ")}function Dp(e,t=56){const n=(e??"").replace(/\s+/g," ").trim();return n?n.length>t?`${n.slice(0,t-1)}…`:n:"live event"}function Ej(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 Cj(e){return e.conversationId?{view:"conversation",conversationId:e.conversationId}:e.collaborationRecordId?{view:"work",workId:e.collaborationRecordId}:{view:"agents",agentId:e.agentId}}function VF(e){return e.conversationId?{view:"conversation",conversationId:e.conversationId}:null}function HF(e,t,n=60){const a=new Array(n).fill(0),i=60*6e4,c=t-i;for(const f of e){if(f.ts<c||f.ts>t)continue;const m=f.ts-c,h=Math.min(n-1,Math.max(0,Math.floor(m/i*n)));a[h]+=1}const u=Math.max(1,...a);return{raw:a,normalized:a.map(f=>f/u)}}function ZF({navigate:e,agents:t}){const[n,a]=v.useState(null),[i,c]=v.useState([]),[u,f]=v.useState([]),[m,h]=v.useState(()=>Date.now()),g=v.useCallback(async()=>{const[I,$,L]=await Promise.allSettled([Oe("/api/fleet"),Oe("/api/activity"),Oe("/api/sessions")]);I.status==="fulfilled"&&a(I.value),$.status==="fulfilled"&&c($.value),L.status==="fulfilled"&&f(L.value),h(Date.now())},[]);v.useEffect(()=>{g()},[g]),An(()=>{g()}),v.useEffect(()=>{const I=setInterval(()=>h(Date.now()),1e3);return()=>clearInterval(I)},[]);const x=t.filter(I=>mt(I.state)!=="offline").length,b=n?.needsAttention??[],w=n?.activeAsks??[],j=u.length>0?u.length:new Set(i.map(I=>I.conversationId).filter(I=>!!I)).size,N=[...b.map(I=>I.updatedAt),...w.map(I=>I.updatedAt)].filter(I=>typeof I=="number"&&Number.isFinite(I)),T=N.length>0?Math.min(...N):null,k=T?Math.max(0,Math.floor((m-T)/1e3)):0,C=v.useMemo(()=>HF(i,m),[i,m]),S=C.raw.reduce((I,$)=>I+$,0),R=Math.max(0,...C.raw),A=C.raw[C.raw.length-1]??0,_=v.useMemo(()=>i.slice(0,8).map(I=>({key:I.id,agent:I.actorName??"system",tool:BF(I.kind),result:Dp(I.title??I.summary),route:VF(I)})),[i]),O=v.useMemo(()=>{const I=[];for(const $ of b)I.push({key:$.recordId,label:$.title||"Unresolved item",route:Ej($),tone:$.kind==="question"?"high":"med"});for(const $ of w)($.status==="failed"||$.status==="needs_attention")&&I.push({key:$.invocationId,label:$.summary??$.task,route:Cj($),tone:$.status==="failed"?"high":"med"});return I.slice(0,6)},[w,b]),V=b.length>0?b:[],Z=V.length===0?w.slice(0,3):[];return o.jsxs("div",{className:"s-warroom",children:[o.jsxs("div",{className:"s-warroom-topstrip",children:[o.jsx("div",{className:"s-warroom-topstrip-left",children:o.jsx("span",{className:"s-ops-label",children:"▸ War Room"})}),o.jsxs("div",{className:"s-warroom-topstrip-center",children:["OPERATIONS · ",new Date(m).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})]}),o.jsxs("div",{className:"s-warroom-topstrip-right",children:[o.jsx(nd,{label:"Agents",value:`${x}/${t.length}`}),o.jsx(nd,{label:"Threads",value:String(j)}),o.jsx(nd,{label:"Attention",value:String(b.length),warn:b.length>0}),o.jsx(nd,{label:"Events/h",value:String(S)})]})]}),o.jsxs("div",{className:"s-warroom-grid",children:[o.jsxs("div",{className:"s-warroom-panel",children:[o.jsx("div",{className:"s-ops-label",style:{marginBottom:12},children:"◌ Asks · Awaiting"}),o.jsxs("div",{className:"s-warroom-breach",children:[o.jsx("div",{className:"s-warroom-breach-clock",children:UF(k)}),o.jsxs("div",{className:"s-warroom-breach-sub",children:["Oldest unresolved · ",b[0]?.agentName??w[0]?.agentName??"clear"]})]}),V.length>0?V.slice(0,3).map(I=>{const $=Ej(I);return o.jsxs("button",{type:"button",className:"s-warroom-ask-card",style:{textAlign:"left",cursor:$?"pointer":"default"},onClick:$?()=>e($):void 0,children:[o.jsxs("div",{className:"s-warroom-ask-header",children:[o.jsx("div",{className:"s-ops-avatar",style:{"--size":"18px",background:ct(I.agentName??"?")},children:(I.agentName??"?")[0]?.toUpperCase()}),o.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--muted)"},children:I.agentName??"unknown"})]}),o.jsx("div",{className:"s-warroom-ask-body",children:Dp(I.title??I.summary,110)})]},I.recordId)}):Z.length>0?Z.map(I=>{const $=Cj(I);return o.jsxs("button",{type:"button",className:"s-warroom-ask-card",style:{textAlign:"left",cursor:$?"pointer":"default"},onClick:$?()=>e($):void 0,children:[o.jsxs("div",{className:"s-warroom-ask-header",children:[o.jsx("div",{className:"s-ops-avatar",style:{"--size":"18px",background:ct(I.agentName??I.agentId)},children:(I.agentName??I.agentId)[0]?.toUpperCase()}),o.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--muted)"},children:I.agentName??I.agentId})]}),o.jsx("div",{className:"s-warroom-ask-body",children:Dp(I.summary??I.task,110)})]},I.invocationId)}):o.jsx("div",{className:"s-warroom-ask-card",style:{color:"var(--dim)"},children:"No unresolved asks right now."}),o.jsx("div",{className:"s-ops-label",style:{marginTop:16},children:"○ Blockers"}),o.jsx("div",{className:"s-warroom-blockers",children:O.length===0?o.jsx("div",{style:{color:"var(--dim)"},children:"No blockers"}):O.map(I=>o.jsxs("button",{type:"button",className:I.tone==="high"?"s-warroom-blockers-item--high":"s-warroom-blockers-item--med",style:{textAlign:"left",cursor:I.route?"pointer":"default"},onClick:I.route?()=>e(I.route):void 0,children:[I.tone==="high"?"▲":"•"," ",I.label]},I.key))})]}),o.jsxs("div",{className:"s-warroom-panel s-warroom-mesh",children:[o.jsx("div",{className:"s-warroom-mesh-label",children:o.jsx("span",{className:"s-ops-label",children:"◉ Mesh · Live"})}),o.jsx(qF,{agents:t})]}),o.jsxs("div",{className:"s-warroom-panel",style:{display:"flex",flexDirection:"column",gap:14},children:[o.jsx("div",{className:"s-ops-label",children:"›_ Live stream"}),o.jsx(FF,{items:_,navigate:e}),o.jsx("div",{className:"s-ops-label",children:"Fleet load"}),o.jsxs("div",{className:"s-warroom-burn-grid",children:[o.jsx(sd,{num:String(S),label:"events/h"}),o.jsx(sd,{num:String(w.length),label:"active asks"}),o.jsx(sd,{num:String(b.length),label:"waiting"}),o.jsx(sd,{num:String(x),label:"online"})]})]}),o.jsxs("div",{className:"s-warroom-waveform-panel",children:[o.jsxs("div",{className:"s-warroom-waveform-header",children:[o.jsx("span",{className:"s-ops-label",children:"⌇ Fleet activity · Last 60m"}),o.jsx("span",{className:"s-warroom-waveform-meta",children:"events/min · live"}),o.jsx("span",{style:{flex:1}}),o.jsxs("span",{className:"s-warroom-waveform-meta",children:["peak ",R," · now ",A]})]}),o.jsx(YF,{values:C.normalized})]})]})]})}function nd({label:e,value:t,warn:n}){return o.jsxs("div",{className:"s-warroom-telemetry",children:[o.jsx("div",{className:"s-warroom-telemetry-label",children:e}),o.jsx("div",{className:`s-warroom-telemetry-value${n?" s-warroom-telemetry-value--warn":""}`,children:t})]})}function FF({items:e,navigate:t}){return e.length===0?o.jsx("div",{className:"s-warroom-ticker",children:o.jsxs("div",{className:"s-warroom-ticker-line",style:{opacity:.5},children:[o.jsx("span",{className:"s-warroom-ticker-agent",children:"system"}),o.jsx("span",{className:"s-warroom-ticker-sep",children:"›"}),o.jsx("span",{className:"s-warroom-ticker-tool",children:"waiting"}),o.jsx("span",{className:"s-warroom-ticker-result",children:"no recent fleet activity"})]})}):o.jsx("div",{className:"s-warroom-ticker",children:e.map((n,a)=>o.jsxs("button",{type:"button",className:"s-warroom-ticker-line",style:{opacity:1-a*.06,textAlign:"left",cursor:n.route?"pointer":"default"},onClick:n.route?()=>t(n.route):void 0,children:[o.jsx("span",{className:"s-warroom-ticker-agent",children:n.agent}),o.jsx("span",{className:"s-warroom-ticker-sep",children:"›"}),o.jsx("span",{className:"s-warroom-ticker-tool",children:n.tool}),o.jsx("span",{className:"s-warroom-ticker-result",children:n.result})]},n.key))})}function sd({num:e,label:t}){return o.jsxs("div",{className:"s-warroom-burn-tile",children:[o.jsx("div",{className:"s-warroom-burn-num",children:e}),o.jsx("div",{className:"s-warroom-burn-label",children:t})]})}function qF({agents:e}){const a=v.useMemo(()=>{if(e.length===0)return{};const i=.5,c=.5,u=.3,f={};return e.forEach((m,h)=>{const g=h/e.length*Math.PI*2-Math.PI/2;f[m.id]={x:i+u*Math.cos(g),y:c+u*Math.sin(g)}}),f},[e]);return o.jsxs("svg",{viewBox:"0 0 800 480",preserveAspectRatio:"xMidYMid meet",style:{width:"100%",height:"100%"},children:[o.jsxs("defs",{children:[o.jsx("pattern",{id:"warGrid",width:"40",height:"40",patternUnits:"userSpaceOnUse",children:o.jsx("path",{d:"M 40 0 L 0 0 0 40",fill:"none",stroke:"var(--border)",strokeWidth:"0.5",opacity:"0.4"})}),o.jsxs("radialGradient",{id:"warGlow",cx:"50%",cy:"50%",r:"50%",children:[o.jsx("stop",{offset:"0%",stopColor:"var(--accent)",stopOpacity:"0.1"}),o.jsx("stop",{offset:"100%",stopColor:"var(--accent)",stopOpacity:"0"})]})]}),o.jsx("rect",{width:800,height:480,fill:"url(#warGrid)"}),o.jsx("circle",{cx:800/2,cy:480/2,r:200,fill:"url(#warGlow)"}),e.flatMap((i,c)=>e.slice(c+1).map(u=>{const f=a[i.id],m=a[u.id];return!f||!m?null:o.jsx("line",{x1:f.x*800,y1:f.y*480,x2:m.x*800,y2:m.y*480,stroke:"var(--dim)",strokeWidth:"0.8",opacity:"0.3"},`${i.id}-${u.id}`)})),e.map(i=>{const c=a[i.id];if(!c)return null;const u=c.x*800,f=c.y*480,m=ct(i.name),h=mt(i.state)==="working";return o.jsxs("g",{transform:`translate(${u}, ${f})`,children:[h&&o.jsxs("circle",{r:"18",fill:"none",stroke:m,strokeWidth:"1",opacity:"0.5",children:[o.jsx("animate",{attributeName:"r",values:"18;30;18",dur:"2.5s",repeatCount:"indefinite"}),o.jsx("animate",{attributeName:"opacity",values:"0.5;0;0.5",dur:"2.5s",repeatCount:"indefinite"})]}),o.jsx("circle",{r:"18",fill:m,stroke:"var(--bg)",strokeWidth:"2"}),o.jsx("text",{textAnchor:"middle",dy:"0.35em",fontFamily:"var(--font-mono)",fontSize:"14",fontWeight:"600",fill:"rgba(0,0,0,0.7)",children:i.name[0]?.toUpperCase()}),o.jsx("text",{textAnchor:"middle",y:36,fontFamily:"var(--font-mono)",fontSize:"10",fill:"var(--muted)",letterSpacing:"0.1em",children:i.name.toUpperCase()}),o.jsxs("text",{textAnchor:"middle",y:48,fontFamily:"var(--font-mono)",fontSize:"8.5",fill:"var(--dim)",letterSpacing:"0.08em",children:[mt(i.state).toUpperCase()," · ",i.project??"—"]})]},i.id)})]})}function YF({values:e}){const a=e.length>1?e:[0,0],i=a.map((c,u)=>`${u/(a.length-1)*1e3},${80-c*72-4}`).join(" ");return o.jsxs("svg",{viewBox:"0 0 1000 80",preserveAspectRatio:"none",style:{width:"100%",height:80,display:"block"},children:[o.jsx("defs",{children:o.jsxs("linearGradient",{id:"waveFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[o.jsx("stop",{offset:"0%",stopColor:"var(--accent)",stopOpacity:"0.35"}),o.jsx("stop",{offset:"100%",stopColor:"var(--accent)",stopOpacity:"0"})]})}),o.jsx("polyline",{points:`0,80 ${i} 1000,80`,fill:"url(#waveFill)"}),o.jsx("polyline",{points:i,fill:"none",stroke:"var(--accent)",strokeWidth:"1.2"})]})}const GF=[{id:"mission",label:"Mission Control"},{id:"plan",label:"Plan"},{id:"conductor",label:"Conductor"},{id:"warroom",label:"War Room"}];function WF({navigate:e,mode:t="mission"}){const{agents:n}=kt();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:GF.map(a=>o.jsx("button",{className:`s-ops-tab${t===a.id?" s-ops-tab--active":""}`,onClick:()=>e({view:"ops",mode:a.id}),children:a.label},a.id))})]}),o.jsxs("div",{className:"s-ops-body",children:[t==="mission"&&o.jsx(bF,{navigate:e,agents:n}),t==="plan"&&o.jsx(OF,{navigate:e,agents:n}),t==="conductor"&&o.jsx(lF,{navigate:e,agents:n}),t==="warroom"&&o.jsx(ZF,{navigate:e,agents:n})]})]})}function XF(){return typeof window>"u"?"ws://localhost:3200":`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}`}function KF({agentId:e,navigate:t}){const{agents:n}=kt(),a=e?n.find(f=>f.id===e):null,i=a?ct(a.name):"var(--accent)",c=Jg({url:XF(),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"}),a&&o.jsxs("div",{className:"s-term-agent",children:[o.jsx("div",{className:"s-ops-avatar",style:{"--size":"18px",background:i},children:a.name[0]?.toUpperCase()}),o.jsx("span",{className:"s-term-agent-name",children:a.name}),a.handle&&o.jsxs("span",{className:"s-term-agent-handle",children:["@",a.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${c.status==="connected"?" s-term-dot--live":c.status==="connecting"?" s-term-dot--connecting":""}`}),c.status==="connected"?"LIVE":c.status==="connecting"?"CONNECTING":"OFFLINE"]})]}),o.jsx("div",{className:"s-term-body",children:o.jsx(ev,{relay:c,fontSize:13,quiet:!0})})]})}function JF(e){return e.attention==="interrupt"?"failed":e.state==="done"?"completed":e.attention==="badge"||e.state==="waiting"||e.state==="review"?"updated":"working"}function zp(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 QF(e){switch(e){case"badge":return"Needs attention";case"interrupt":return"Blocked";default:return null}}function eq(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 Tj(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 Lp({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 Aj({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 tq(e){const t=e.split(".");return t[t.length-1]||e}function nq({workId:e,navigate:t}){const[n,a]=v.useState(null),[i,c]=v.useState(null),[u,f]=v.useState(!1),m=v.useCallback(async()=>{c(null);try{const N=await Oe(`/api/work/${encodeURIComponent(e)}`);a(N)}catch(N){c(N instanceof Error?N.message:String(N)),a(null)}finally{f(!0)}},[e]);if(v.useEffect(()=>{f(!1),m()},[m]),An(()=>{m()}),!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"}),i&&o.jsx("p",{className:"s-error",children:i}),o.jsx("div",{className:"s-empty",children:o.jsx("p",{children:"Work item not found"})})]});const h=QF(n.attention),g=n.ownerName??n.ownerId??"Unassigned",x=n.nextMoveOwnerName??n.nextMoveOwnerId??"—",b=[{label:"State",value:zp(n.state)},{label:"Acceptance",value:n.acceptanceState.replace(/_/g," ")},{label:"Phase",value:n.currentPhase},...h?[{label:"Attention",value:h}]:[]],w=[{label:"Owner",value:g},{label:"Next move",value:x},...n.priority?[{label:"Priority",value:n.priority}]:[],{label:"Conversation",value:n.conversationId?"Attached":"None"}],j=[{label:"Case ID",value:n.id},{label:"Created",value:Xr(n.createdAt)},{label:"Updated",value:Xr(n.updatedAt)},{label:"Last activity",value:Xr(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 ",tq(n.id)]})]}),i&&o.jsx("p",{className:"s-error",children:i}),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-${JF(n)}`,children:n.currentPhase})]}),n.lastMeaningfulSummary&&o.jsx("div",{className:"s-work-casefile-summary",children:ks(n.lastMeaningfulSummary)}),o.jsxs("div",{className:"s-work-casefile-meta",children:[o.jsxs("span",{children:["Updated ",Pe(n.updatedAt)]}),o.jsx("span",{children:g}),o.jsx("span",{children:zp(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(Lp,{title:"Status",items:b}),o.jsx(Lp,{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:zp(N.state)}),o.jsx("span",{children:Pe(N.lastMeaningfulAt)})]}),N.lastMeaningfulSummary&&o.jsx("div",{className:"s-work-related-card-copy",children:ks(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-${Tj(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-${Tj(N)}`,children:eq(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:ks(N.summary)}),o.jsx("div",{className:"s-work-timeline-stamp",children:Xr(N.at)})]})]},N.id))})]})]}),o.jsxs("aside",{className:"s-work-casefile-side",children:[o.jsx(Lp,{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(Aj,{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(Aj,{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 sq(){const{route:e,navigate:t}=kt();return o.jsx(aq,{children:rq(e,t)})}function aq({children:e}){return o.jsx("div",{style:{background:"var(--bg)",color:"var(--ink)",minHeight:"100%",height:"100%",display:"flex",flexDirection:"column"},children:e})}function rq(e,t){switch(e.view){case"conversation":return o.jsx(Dg,{conversationId:e.conversationId,initialComposeMode:e.composeMode,navigate:t});case"agent-info":return o.jsx(DH,{conversationId:e.conversationId,navigate:t});case"settings":return o.jsx(JZ,{navigate:t});case"agents":return o.jsx(R7,{navigate:t,selectedAgentId:e.agentId,conversationId:e.conversationId,tab:e.tab});case"fleet":return o.jsx(H7,{navigate:t});case"sessions":return e.sessionId?o.jsx(Dg,{conversationId:e.sessionId,navigate:t}):o.jsx(CZ,{navigate:t});case"mesh":return o.jsx(mZ,{navigate:t});case"activity":return o.jsx(MH,{navigate:t});case"ops":return o.jsx(WF,{navigate:t,mode:e.mode});case"terminal":return o.jsx(KF,{agentId:e.agentId,navigate:t});case"work":return o.jsx(nq,{workId:e.workId,navigate:t});default:return o.jsx(F7,{navigate:t})}}function iq(){const{route:e,agents:t,navigate:n}=kt();if(e.view!=="agents")return null;const a=e.agentId?t.find(i=>i.id===e.agentId)??null:null;if(!a){const i=t.filter(c=>oi(c.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(Ws,{label:"Total",value:`${t.length}`}),o.jsx(Ws,{label:"Working",value:`${i}`}),o.jsx(Ws,{label:"Available",value:`${t.length-i}`}),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(oq,{agent:a,agents:t,navigate:n})}function oq({agent:e,agents:t,navigate:n}){const a=oi(e.state),[i,c]=v.useState(null),u=v.useCallback(async()=>{const f=await Oe("/api/fleet").catch(()=>null);f&&c(f)},[]);return v.useEffect(()=>{u()},[u]),An(()=>{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:ct(e.name)},children:[e.name[0]?.toUpperCase()??"?",a&&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:Ra(e.state),opacity:mt(e.state)==="working"?.85:.6}})]}),o.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[o.jsx("span",{className:"truncate text-[13px] text-[var(--scout-chrome-ink-strong)]",children:e.name}),e.handle&&o.jsxs("span",{className:"text-[10px] font-mono text-cyan-400/70",children:["@",e.handle]})]})]}),o.jsxs(oo,{label:"State",children:[o.jsxs("div",{className:"flex items-baseline gap-2",children:[o.jsx("span",{className:"w-1.5 h-1.5 rounded-full",style:{background:Ra(e.state),opacity:a?1:.4}}),o.jsx("span",{className:"text-[12px] capitalize text-[var(--scout-chrome-ink)]",children:aa(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(oo,{label:"Presence",children:o.jsx(lq,{focusAgent:e,agents:t,navigate:n})}),i&&o.jsx(cq,{asks:i.activeAsks,agentId:e.id,navigate:n}),o.jsxs(oo,{label:"Identity",children:[o.jsx(Ws,{label:"Class",value:e.agentClass}),e.role&&o.jsx(Ws,{label:"Role",value:e.role}),e.harness&&o.jsx(Ws,{label:"Harness",value:e.harness}),e.transport&&o.jsx(Ws,{label:"Transport",value:e.transport})]}),(e.project||e.branch||e.cwd)&&o.jsxs(oo,{label:"Project",children:[e.project&&o.jsx(Ws,{label:"Name",value:e.project}),e.branch&&o.jsx(Ws,{label:"Branch",value:e.branch}),e.cwd&&o.jsx(Ws,{label:"Cwd",value:e.cwd})]}),e.capabilities.length>0&&o.jsx(oo,{label:`Capabilities · ${e.capabilities.length}`,children:o.jsx("div",{className:"flex flex-wrap gap-1",children:e.capabilities.map(f=>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:f},f))})})]})}function lq({focusAgent:e,agents:t,navigate:n}){const m=t.filter(g=>g.id!==e.id).slice(0,8),h=v.useMemo(()=>{const g=[{agent:e,x:120,y:90,focused:!0}];return m.forEach((x,b)=>{const w=2*Math.PI*b/Math.max(m.length,1)-Math.PI/2;g.push({agent:x,x:120+68*Math.cos(w),y:90+68*Math.sin(w),focused:!1})}),g},[e,m,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((g,x)=>o.jsxs("g",{children:[o.jsx("line",{x1:120,y1:90,x2:g.x,y2:g.y,stroke:"var(--accent)",strokeWidth:1,opacity:.6}),o.jsx("circle",{r:2,fill:"var(--accent)",children:o.jsx("animateMotion",{dur:`${2+x*.3}s`,repeatCount:"indefinite",path:`M 120,90 L ${g.x},${g.y}`})})]},`e-${g.agent.id}`)),h.map(g=>{const x=mt(g.agent.state),b=x==="working"||x==="available",w=g.focused?14:9;return o.jsxs("g",{style:{cursor:"pointer"},onClick:()=>n({view:"agents",agentId:g.agent.id}),children:[b&&o.jsxs("circle",{cx:g.x,cy:g.y,r:w+5,fill:"none",stroke:ct(g.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:g.x,cy:g.y,r:w,fill:ct(g.agent.name),stroke:g.focused?"var(--accent)":"var(--surface)",strokeWidth:g.focused?1.5:1}),o.jsx("text",{x:g.x,y:g.y,dy:"0.35em",textAnchor:"middle",fontFamily:"var(--font-mono)",fontSize:g.focused?10:8,fontWeight:600,fill:"var(--scout-chrome-avatar-ink)",children:g.agent.name[0].toUpperCase()}),o.jsx("text",{x:g.x,y:g.y+w+10,textAnchor:"middle",fontFamily:"var(--font-mono)",fontSize:8,fill:"var(--dim)",letterSpacing:"0.04em",children:g.agent.name.length>9?g.agent.name.slice(0,8)+"...":g.agent.name})]},g.agent.id)})]})}function cq({asks:e,agentId:t,navigate:n}){const a=e.filter(i=>i.agentId===t&&(i.status==="needs_attention"||i.status==="queued"));return a.length===0?null:o.jsx(oo,{label:`Incoming asks · ${a.length}`,children:o.jsx("div",{className:"flex flex-col gap-2",children:a.map(i=>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:()=>{i.conversationId&&n({view:"agents",agentId:t,conversationId:i.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:i.summary??i.task}),o.jsxs("div",{className:"mt-1.5 text-[9px] font-mono text-[var(--scout-chrome-ink-ghost)]",children:[i.harness??"operator"," → ",i.agentName??"agent"]})]},i.invocationId))})})}function oo({label:e,children:t}){return o.jsxs("div",{className:"flex flex-col",children:[o.jsx("div",{className:"mb-1.5 text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e}),t]})}function Ws({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 uq(){const[e,t]=v.useState(null),n=v.useCallback(async()=>{try{t(await Oe("/api/fleet"))}catch{}},[]);if(v.useEffect(()=>{n()},[n]),An(()=>{n()}),!e)return o.jsx("div",{className:"flex h-full items-center justify-center text-[11px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-ghost)]",children:"Loading fleet…"});const a=e.totals;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:"text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:["Updated ",Pe(e.generatedAt)]}),o.jsx(ad,{label:"Needs Input",value:a.needsAttention,emphasis:a.needsAttention>0?"warn":"muted"}),o.jsx(ad,{label:"Active Asks",value:a.active}),o.jsx(ad,{label:"Recent Finished",value:a.recentCompleted,emphasis:a.recentCompleted>0?"good":"muted"}),o.jsx(ad,{label:"Activity",value:a.activity})]})}function ad({label:e,value:t,emphasis:n}){const a=n==="good"?"text-emerald-300/90":n==="warn"?"text-amber-300/90":n==="muted"?"text-[var(--scout-chrome-ink-faint)]":"text-[var(--scout-chrome-ink)]";return o.jsxs("div",{className:"flex flex-col border-b border-[var(--scout-chrome-border-soft)] pb-3 last:border-b-0",children:[o.jsx("span",{className:`text-[24px] font-mono tabular-nums leading-none ${a}`,children:t}),o.jsx("span",{className:"mt-1 text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e})]})}function dq(){const{agents:e,navigate:t}=kt();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(i=>oi(i.state)),a=e.filter(i=>!oi(i.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(Rj,{label:"Online",count:n.length,children:n.map(i=>o.jsx(Mj,{agent:i,navigate:t},i.id))}),a.length>0&&o.jsx(Rj,{label:"Standby",count:a.length,children:a.map(i=>o.jsx(Mj,{agent:i,navigate:t,dim:!0},i.id))})]})}function Rj({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 Mj({agent:e,navigate:t,dim:n}){const a=oi(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:ct(e.name)},children:[e.name[0]?.toUpperCase()??"?",a&&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:aa(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 fq(){const{route:e}=kt(),[t,n]=v.useState([]),a=v.useCallback(async()=>{try{n(await Oe("/api/sessions"))}catch{}},[]);if(v.useEffect(()=>{a()},[a]),An(()=>{a()}),e.view!=="sessions")return null;const i=e.sessionId?t.find(c=>c.id===e.sessionId)??null:null;if(!i){const c=new Set(t.map(f=>f.kind)),u=t.filter(f=>f.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(Fs,{label:"Total",value:`${t.length}`}),o.jsx(Fs,{label:"Kinds",value:`${c.size}`}),o.jsx(Fs,{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:i.title}),o.jsx("div",{className:"text-[10px] font-mono uppercase tracking-wider text-cyan-400/70 mt-1",children:i.kind})]}),i.agentName&&o.jsxs(rd,{label:"Agent",children:[o.jsx(Fs,{label:"Name",value:i.agentName}),i.harness&&o.jsx(Fs,{label:"Harness",value:i.harness})]}),(i.currentBranch||i.workspaceRoot)&&o.jsxs(rd,{label:"Workspace",children:[i.currentBranch&&o.jsx(Fs,{label:"Branch",value:i.currentBranch}),i.workspaceRoot&&o.jsx(Fs,{label:"Root",value:i.workspaceRoot})]}),o.jsxs(rd,{label:"Activity",children:[o.jsx(Fs,{label:"Messages",value:`${i.messageCount}`}),i.lastMessageAt&&o.jsx(Fs,{label:"Last",value:Pe(i.lastMessageAt)}),i.participantIds.length>0&&o.jsx(Fs,{label:"Participants",value:`${i.participantIds.length}`})]}),i.preview&&o.jsx(rd,{label:"Preview",children:o.jsxs("div",{className:"text-[11px] italic leading-relaxed text-[var(--scout-chrome-ink-soft)]",children:['"',i.preview,'"']})})]})}function rd({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 Fs({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 hq(){const{route:e}=kt(),t=e.view==="work"?e.workId:null,[n,a]=v.useState(null),i=v.useCallback(async()=>{if(!t){a(null);return}try{a(await Oe(`/api/work/${encodeURIComponent(t)}`))}catch{a(null)}},[t]);if(v.useEffect(()=>{i()},[i]),An(()=>{t&&i()}),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 c=pq(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 ",mq(n.id)]}),o.jsx("div",{className:"text-[13px] leading-snug text-[var(--scout-chrome-ink-strong)]",children:n.title})]}),o.jsxs(id,{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 ${c.dot}`}),o.jsx("span",{className:`text-[12px] capitalize ${c.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(id,{label:"Ownership",children:[n.ownerName&&o.jsx(eo,{label:"Owner",value:n.ownerName}),n.nextMoveOwnerName&&o.jsx(eo,{label:"Next move",value:n.nextMoveOwnerName}),n.priority&&o.jsx(eo,{label:"Priority",value:n.priority})]}),o.jsxs(id,{label:"Activity",children:[o.jsx(eo,{label:"Children",value:`${n.activeChildWorkCount}`}),o.jsx(eo,{label:"Flights",value:`${n.activeFlightCount}`}),n.lastMeaningfulAt&&o.jsx(eo,{label:"Last update",value: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(id,{label:"Latest",children:o.jsx("div",{className:"text-[11px] italic leading-relaxed text-[var(--scout-chrome-ink-soft)]",children:n.lastMeaningfulSummary})})]})}function mq(e){return e.length>10?`${e.slice(0,8)}…`:e}function pq(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 id({label:e,children:t}){return o.jsxs("div",{className:"flex flex-col",children:[o.jsx("div",{className:"mb-1.5 text-[9px] font-mono uppercase tracking-[0.15em] text-[var(--scout-chrome-ink-faint)]",children:e}),t]})}function eo({label:e,value:t}){return o.jsxs("div",{className:"flex items-baseline justify-between py-0.5 gap-2",children:[o.jsx("span",{className:"shrink-0 text-[10px] font-mono uppercase tracking-wider text-[var(--scout-chrome-ink-faint)]",children:e}),o.jsx("span",{className:"truncate text-[11px] font-mono text-[var(--scout-chrome-ink)]",children:t})]})}function gq(){const{route:e}=kt();switch(e.view){case"inbox":return o.jsx(dq,{});case"agents":case"agent-info":return o.jsx(iq,{});case"fleet":return o.jsx(uq,{});case"sessions":case"conversation":return o.jsx(fq,{});case"work":return o.jsx(hq,{});case"ops":return null;default:return null}}function vq(){const{openSettings:e}=kt();return o.jsx(GV,{onOpen:e})}const to={working:0,available:1,offline:2};function yq(e){return e.project?e.project.toLowerCase():"other"}function xq(e){const t=new Map;for(const a of e){const i=yq(a),c=t.get(i);c?c.push(a):t.set(i,[a])}const n=[];for(const[a,i]of t){i.sort((f,m)=>{const h=(to[mt(f.state)]??9)-(to[mt(m.state)]??9);return h!==0?h:(m.updatedAt??0)-(f.updatedAt??0)});const c=i.reduce((f,m)=>{const h=mt(m.state);return(to[h]??9)<(to[f]??9)?h:f},"offline"),u=Math.max(...i.map(f=>f.updatedAt??0));n.push({key:a,label:a,agents:i,bestState:c,latestUpdate:u})}return n.sort((a,i)=>{const c=(to[a.bestState]??9)-(to[i.bestState]??9);return c!==0?c:i.latestUpdate-a.latestUpdate}),n}function bq(e){return e.trim().toLowerCase()}function wq(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 Sq(e,t){return t?wq(e).some(n=>n.toLowerCase().includes(t)):!0}function no(e,t){return t?[e.harnessSessionId,e.conversationId].find(a=>a?.toLowerCase().includes(t))??null:null}function $p(e,t,n={}){e({view:"agents",agentId:t.id,...n.observe?{conversationId:t.conversationId,tab:"observe"}:{}})}function jq(){const{agents:e,route:t,navigate:n}=kt(),[a,i]=v.useState(()=>new Set),[c,u]=v.useState(""),f=bq(c),m=f.length>0,h=v.useMemo(()=>e.filter(j=>Sq(j,f)),[e,f]),g=v.useMemo(()=>xq(h),[h]),x=h[0]??null,b=t.view==="agents"?t.agentId:void 0,w=j=>{i(N=>{const T=new Set(N);return T.has(j)?T.delete(j):T.add(j),T})};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:c,onChange:j=>u(j.target.value),onKeyDown:j=>{j.key==="Escape"&&(c?u(""):j.target.blur()),j.key==="Enter"&&x&&$p(n,x,{observe:!!no(x,f)})}})}),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."}):g.map(j=>{const N=j.agents.length===1,T=m||a.has(j.key),k=N?j.agents[0]:null,C=j.agents.some(R=>R.id===b),S=k?no(k,f):null;return o.jsxs("div",{className:"s-left-roster-parent",children:[o.jsxs("button",{className:`s-left-roster-row${C&&(N||!T)?" s-left-roster-row--active":""}`,onClick:()=>{N?$p(n,k,{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:ct(j.label)},children:j.label[0].toUpperCase()}),o.jsx("span",{className:`s-left-roster-dot s-left-roster-dot--${j.bestState}`,style:{background:Ra(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&&(k.project||k.branch)&&o.jsxs("span",{className:"s-left-roster-sub",children:[k.name,k.branch?` · ${k.branch}`:""]}),!N&&!T&&o.jsxs("span",{className:"s-left-roster-sub",children:[j.agents.length," agents"]})]}),!N&&o.jsx("span",{className:"s-left-roster-ct",children:T?"▾":"▸"}),N&&k.updatedAt&&o.jsx("span",{className:"s-left-roster-time",children:Pe(k.updatedAt)})]}),!N&&T&&o.jsx("div",{className:"s-left-roster-instances",children:j.agents.map(R=>o.jsxs("button",{className:`s-left-roster-instance${R.id===b?" s-left-roster-instance--active":""}`,onClick:()=>$p(n,R,{observe:!!no(R,f)}),title:no(R,f)??void 0,children:[o.jsx("span",{className:`s-left-roster-instance-dot s-left-roster-dot--${mt(R.state)}`,style:{background:Ra(R.state)}}),o.jsxs("span",{className:"s-left-roster-instance-label",children:[R.name,R.branch?` · ${R.branch}`:"",no(R,f)?` · ${no(R,f)}`:""]}),R.updatedAt&&o.jsx("span",{className:"s-left-roster-time",children:Pe(R.updatedAt)})]},R.id))})]},j.key)})})]})}function Nq(){return typeof window>"u"?"ws://localhost:3200":`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}`}function kq(){const e=Jg({url:Nq(),autoConnect:!0,sessionKey:"scout-terminal"});return o.jsx("div",{style:{height:"100%",background:"#0d0d0d",overflow:"hidden"},children:o.jsx(ev,{relay:e,fontSize:13})})}function Eq(){const{onboarding:e}=kt();return e?e.hasLocalConfig?e.hasOperatorName?e.hasProjectConfig?null:o.jsx(Pp,{children:o.jsx(Aq,{})}):o.jsx(Pp,{children:o.jsx(Tq,{})}):o.jsx(Pp,{children:o.jsx(Cq,{})}):null}function Pp({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 ey({eyebrow:e,title:t,description:n}){return o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[o.jsx("div",{style:Rq,children:e}),o.jsx("div",{style:Mq,children:t}),o.jsx("div",{style:_q,children:n})]})}function ty({primary:e,onPrimary:t,primaryDisabled:n,busy:a}){const{skipOnboarding:i}=kt();return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:24,paddingTop:8},children:[o.jsx("button",{type:"button",onClick:t,disabled:n||a,style:{...Iq,opacity:n||a?.5:1,cursor:n||a?"default":"pointer"},children:a?"Working…":e}),o.jsx("button",{type:"button",onClick:i,style:Dq,onMouseEnter:c=>{c.currentTarget.style.color="rgba(255,255,255,0.8)"},onMouseLeave:c=>{c.currentTarget.style.color="rgba(255,255,255,0.45)"},children:"Skip for now"})]})}function ny({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 Cq(){const{onboarding:e,refreshOnboarding:t}=kt(),[n,a]=v.useState(!1),[i,c]=v.useState(null),u=async()=>{a(!0),c(null);try{await Oe("/api/onboarding/init",{method:"POST",body:"{}"}),await t()}catch(f){c(f instanceof Error?f.message:String(f))}finally{a(!1)}};return o.jsxs(o.Fragment,{children:[o.jsx(ey,{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:Bg,children:"~/.openscout/config.json"})," with sensible defaults — you can edit it any time."]})}),o.jsxs("ul",{style:zq,children:[o.jsx(_j,{label:"Local config (~/.openscout/config.json)",done:!1,hint:"missing"}),o.jsx(_j,{label:".openscout/project.json in a repo",done:!!e?.hasProjectConfig,hint:e?.hasProjectConfig?e.projectRoot??void 0:"checked after setup"})]}),o.jsx(ny,{message:i}),o.jsx(ty,{primary:"Initialize Scout",onPrimary:()=>{u()},busy:n})]})}function Tq(){const{onboarding:e,refreshOnboarding:t}=kt(),n=e?.operatorNameSuggestion??"",[a,i]=v.useState(n),[c,u]=v.useState(!1),[f,m]=v.useState(null);v.useEffect(()=>{!a&&n&&i(n)},[n,a]);const h=async()=>{const g=a.trim();if(!g){m("Name is required.");return}u(!0),m(null);try{await Oe("/api/user",{method:"POST",body:JSON.stringify({name:g})}),await t()}catch(x){m(x instanceof Error?x.message:String(x))}finally{u(!1)}};return o.jsxs(o.Fragment,{children:[o.jsx(ey,{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:Sd,children:"Your name"}),o.jsx("input",{autoFocus:!0,value:a,onChange:g=>{i(g.target.value),m(null)},onKeyDown:g=>{g.key==="Enter"&&h()},placeholder:n||"Operator",style:Ug}),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(ny,{message:f}),o.jsx(ty,{primary:"Continue",onPrimary:()=>{h()},busy:c,primaryDisabled:!a.trim()})]})}function Aq(){const{onboarding:e,refreshOnboarding:t}=kt(),n=e?.currentDirectory??"",[a,i]=v.useState([n||"~/dev"]),[c,u]=v.useState(n),[f,m]=v.useState("claude"),[h,g]=v.useState(!1),[x,b]=v.useState(null),w=(k,C)=>{i(S=>S.map((R,A)=>A===k?C:R))},j=()=>i(k=>[...k,""]),N=k=>i(C=>C.filter((S,R)=>R!==k)),T=async()=>{const k=a.map(S=>S.trim()).filter(Boolean),C=c.trim();if(!C){b("Pick where Scout should anchor this context.");return}g(!0),b(null);try{await Oe("/api/onboarding/project",{method:"POST",body:JSON.stringify({contextRoot:C,sourceRoots:k,defaultHarness:f})}),await t()}catch(S){b(S instanceof Error?S.message:String(S))}finally{g(!1)}};return o.jsxs(o.Fragment,{children:[o.jsx(ey,{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:Bg,children:"<context>/.openscout/project.json"}),"."]})}),o.jsxs("div",{style:Up,children:[o.jsx("label",{style:Sd,children:"Scan folders"}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[a.map((k,C)=>o.jsxs("div",{style:{display:"flex",gap:8},children:[o.jsx("input",{value:k,onChange:S=>w(C,S.target.value),placeholder:C===0?"~/dev":"Add another folder",style:{...Ug,flex:1}}),o.jsx("button",{type:"button",onClick:()=>N(C),disabled:a.length<=1,style:{...Oj,opacity:a.length<=1?.4:1,cursor:a.length<=1?"default":"pointer"},"aria-label":`Remove folder ${C+1}`,children:"−"})]},C)),o.jsx("button",{type:"button",onClick:j,style:{...Oj,alignSelf:"flex-start"},children:"+ Add folder"})]})]}),o.jsxs("div",{style:Up,children:[o.jsx("label",{style:Sd,children:"Context root"}),o.jsx("input",{value:c,onChange:k=>u(k.target.value),placeholder:"~/dev",style:Ug}),o.jsxs("div",{style:Oq,children:["Scout writes ",o.jsx("code",{style:Bg,children:".openscout/project.json"})," ","inside this folder."]})]}),o.jsxs("div",{style:Up,children:[o.jsx("label",{style:Sd,children:"Default harness"}),o.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:["claude","codex"].map(k=>{const C=f===k;return o.jsxs("button",{type:"button",onClick:()=>m(k),style:{...Lq,borderColor:C?"var(--accent, #2dd4bf)":"rgba(255,255,255,0.12)",backgroundColor:C?"rgba(45,212,191,0.08)":"rgba(255,255,255,0.02)"},children:[o.jsx("div",{style:{fontSize:15,fontWeight:600,textTransform:"capitalize"},children:k}),o.jsx("div",{style:{fontSize:12,color:"rgba(255,255,255,0.55)",marginTop:6,lineHeight:1.5},children:k==="claude"?"Anthropic Claude Code — local CLI agent.":"OpenAI Codex — cloud agentic sandbox."})]},k)})})]}),o.jsx(ny,{message:x}),o.jsx(ty,{primary:"Create project",onPrimary:()=>{T()},busy:h,primaryDisabled:!c.trim()})]})}function _j({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 Rq={fontSize:11,fontFamily:"var(--hud-font-mono)",textTransform:"uppercase",letterSpacing:"0.18em",color:"rgba(255,255,255,0.4)"},Mq={fontSize:36,fontWeight:600,letterSpacing:"-0.01em",lineHeight:1.15},_q={fontSize:15,lineHeight:1.75,color:"rgba(255,255,255,0.6)",maxWidth:580},Up={display:"flex",flexDirection:"column",gap:10},Sd={fontSize:11,fontFamily:"var(--hud-font-mono)",textTransform:"uppercase",letterSpacing:"0.15em",color:"rgba(255,255,255,0.5)"},Ug={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"},Oq={fontSize:12,color:"rgba(255,255,255,0.45)",lineHeight:1.6},Bg={fontFamily:"var(--hud-font-mono)",fontSize:12,padding:"2px 6px",borderRadius:4,backgroundColor:"rgba(255,255,255,0.06)"},Iq={fontSize:13,fontWeight:600,padding:"12px 24px",borderRadius:10,backgroundColor:"var(--accent, #2dd4bf)",color:"#0b0d12",border:"none",transition:"opacity 0.15s ease"},Oj={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"},Dq={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"},zq={display:"flex",flexDirection:"column",gap:20,margin:0,padding:0,listStyle:"none"},Lq={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"},$q=[{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 tA(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:v.createElement(DM,{size:14,strokeWidth:1.2}),Provider:({children:n})=>v.createElement(QV,{initialTheme:t},n),leftPanel:{title:"Agents"},rightPanel:{title:"Context"},slots:{Content:sq,LeftPanel:jq,LeftFooter:vq,Inspector:gq,Takeover:Eq,Terminal:kq},intents:$q,hooks:{useCommands:eH,useStatus:tH,useNavCenter:sH,useNavActions:aH,useLayoutMode:rH,useTakeover:iH}}}tA();function Ij(e){return e==="dark"||e==="light"?e:null}function Pq(){if(typeof window>"u")return"dark";const e=Ij(window.__OPENSCOUT_WEB_BOOTSTRAP__?.theme);if(e)return e;const t=Ij(new URLSearchParams(window.location.search).get("theme"));return t||"dark"}function Uq(e){typeof document>"u"||(document.documentElement.dataset.scoutThemeMode=e,document.documentElement.style.colorScheme=e)}const nA=document.getElementById("root");if(!nA)throw new Error("missing #root");const sA=Pq();Uq(sA);NM.createRoot(nA).render(o.jsx(v.StrictMode,{children:o.jsx(oH,{app:tA({initialTheme:sA})})}));export{zj as F,lo as f,o as j,v as r};
|